This commit is contained in:
2024-08-30 17:36:21 +08:00
parent a3f0288c92
commit eec9d6045c
19 changed files with 332 additions and 219 deletions

View File

@@ -3,6 +3,10 @@ import { createElement } from "../functions";
import { createIcon } from "./icon";
function fillCheckbox(container, type = 'fa-regular', label, tabindex = -1, charactor = 'check', title) {
const checkIcon = createIcon(type, charactor);
checkIcon.classList.add('ui-check-icon');
const indeterminateIcon = createIcon(type, 'grip-lines');
indeterminateIcon.classList.add('ui-indeterminate-icon')
container.appendChild(
createElement('layer', layer => {
layer.className = 'ui-check-inner';
@@ -18,7 +22,7 @@ function fillCheckbox(container, type = 'fa-regular', label, tabindex = -1, char
if (tabindex >= 0) {
layer.tabIndex = tabindex;
}
}, createIcon(type, charactor))
}, checkIcon, indeterminateIcon)
);
if (label instanceof Element) {
container.appendChild(label);
@@ -68,6 +72,9 @@ export function createCheckbox(opts = {}) {
if (opts.checked === true) {
input.checked = true;
}
if (opts.indeterminate === true) {
input.indeterminate = true;
}
if (opts.enabled === false) {
input.disabled = true;
}