app change
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import { createElement } from "../functions";
|
||||
import { createIcon } from "./icon";
|
||||
|
||||
function fillCheckbox(container, type, label) {
|
||||
function fillCheckbox(container, type, label, charactor = 'check') {
|
||||
container.appendChild(
|
||||
createElement('layer', 'check-box-inner', createIcon(type, 'check'))
|
||||
createElement('layer', 'check-box-inner', createIcon(type, charactor))
|
||||
);
|
||||
if (label instanceof HTMLElement) {
|
||||
container.appendChild(label);
|
||||
@ -14,6 +14,33 @@ function fillCheckbox(container, type, label) {
|
||||
}
|
||||
}
|
||||
|
||||
function createRadiobox(opts = {}) {
|
||||
const container = createElement('label', 'checkbox-wrapper radiobox-wrapper',
|
||||
createElement('input', input => {
|
||||
input.setAttribute('type', 'radio');
|
||||
input.name = opts.name;
|
||||
if (opts.checked === true) {
|
||||
input.checked = true;
|
||||
}
|
||||
if (opts.enabled === false) {
|
||||
input.disabled = true;
|
||||
}
|
||||
if (opts.customerAttributes != null) {
|
||||
for (let entry of Object.entries(opts.customerAttributes)) {
|
||||
input.setAttribute(entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
if (typeof opts.onchange === 'function') {
|
||||
input.addEventListener('change', opts.onchange);
|
||||
}
|
||||
}));
|
||||
if (opts.className) {
|
||||
container.classList.add(opts.className);
|
||||
}
|
||||
fillCheckbox(container, opts.type || 'fa-regular', opts.label, 'circle');
|
||||
return container;
|
||||
}
|
||||
|
||||
function createCheckbox(opts = {}) {
|
||||
const container = createElement('label', 'checkbox-wrapper',
|
||||
createElement('input', input => {
|
||||
@ -131,5 +158,6 @@ function resolveCheckbox(container = document.body, legacy) {
|
||||
|
||||
export {
|
||||
createCheckbox,
|
||||
resolveCheckbox
|
||||
resolveCheckbox,
|
||||
createRadiobox
|
||||
}
|
Reference in New Issue
Block a user