add dropdown component
This commit is contained in:
@ -5,7 +5,9 @@ function fillCheckbox(container, type, label) {
|
||||
layer.className = 'check-box-inner';
|
||||
layer.appendChild(createIcon(type, 'check'));
|
||||
container.appendChild(layer);
|
||||
if (label != null && label.length > 0) {
|
||||
if (label instanceof HTMLElement) {
|
||||
container.appendChild(label);
|
||||
} else if (label != null && label.length > 0) {
|
||||
const span = document.createElement('span');
|
||||
span.innerText = label;
|
||||
container.appendChild(span);
|
||||
@ -21,6 +23,11 @@ function createCheckbox(opts) {
|
||||
if (opts.checked === true) {
|
||||
input.checked = 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);
|
||||
}
|
||||
@ -50,9 +57,7 @@ function createCheckbox(opts) {
|
||||
}
|
||||
|
||||
function resolveCheckbox(container, legacy) {
|
||||
if (container == null) {
|
||||
container = document.body;
|
||||
}
|
||||
container ??= document.body;
|
||||
if (legacy) {
|
||||
const checks = container.querySelectorAll('input[type="checkbox"]');
|
||||
for (let chk of checks) {
|
||||
|
Reference in New Issue
Block a user