@deepfuture/dui-components 0.0.21 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -65
- package/_install.js +11 -0
- package/accordion/accordion-item.d.ts +3 -20
- package/accordion/accordion-item.js +92 -292
- package/accordion/accordion.d.ts +3 -18
- package/accordion/accordion.js +9 -247
- package/accordion/index.d.ts +6 -6
- package/accordion/index.js +5 -5
- package/alert-dialog/alert-dialog-close.d.ts +3 -14
- package/alert-dialog/alert-dialog-close.js +4 -34
- package/alert-dialog/alert-dialog-popup.d.ts +3 -32
- package/alert-dialog/alert-dialog-popup.js +68 -317
- package/alert-dialog/alert-dialog-trigger.d.ts +3 -14
- package/alert-dialog/alert-dialog-trigger.js +4 -51
- package/alert-dialog/alert-dialog.d.ts +3 -30
- package/alert-dialog/alert-dialog.js +8 -158
- package/alert-dialog/index.d.ts +11 -11
- package/alert-dialog/index.js +9 -9
- package/all.d.ts +159 -123
- package/all.js +134 -231
- package/avatar/avatar.d.ts +3 -39
- package/avatar/avatar.js +18 -238
- package/avatar/index.d.ts +4 -4
- package/avatar/index.js +3 -3
- package/badge/badge.d.ts +3 -10
- package/badge/badge.js +87 -22
- package/badge/index.d.ts +2 -3
- package/badge/index.js +2 -3
- package/breadcrumb/breadcrumb-ellipsis.d.ts +3 -12
- package/breadcrumb/breadcrumb-ellipsis.js +8 -34
- package/breadcrumb/breadcrumb-item.d.ts +3 -11
- package/breadcrumb/breadcrumb-item.js +7 -26
- package/breadcrumb/breadcrumb-link.d.ts +3 -12
- package/breadcrumb/breadcrumb-link.js +16 -26
- package/breadcrumb/breadcrumb-page.d.ts +3 -11
- package/breadcrumb/breadcrumb-page.js +8 -31
- package/breadcrumb/breadcrumb-separator.d.ts +3 -12
- package/breadcrumb/breadcrumb-separator.js +8 -31
- package/breadcrumb/breadcrumb.d.ts +3 -12
- package/breadcrumb/breadcrumb.js +10 -33
- package/breadcrumb/index.d.ts +12 -13
- package/breadcrumb/index.js +12 -13
- package/button/button.d.ts +3 -32
- package/button/button.js +220 -165
- package/button/index.d.ts +3 -3
- package/button/index.js +3 -3
- package/calendar/calendar.d.ts +3 -31
- package/calendar/calendar.js +71 -481
- package/calendar/index.d.ts +3 -3
- package/calendar/index.js +3 -3
- package/card/card.d.ts +3 -27
- package/card/card.js +80 -163
- package/card/index.d.ts +2 -3
- package/card/index.js +2 -3
- package/card-grid/card-grid.d.ts +3 -15
- package/card-grid/card-grid.js +8 -106
- package/card-grid/index.d.ts +2 -3
- package/card-grid/index.js +2 -3
- package/checkbox/checkbox-group.d.ts +3 -34
- package/checkbox/checkbox-group.js +11 -188
- package/checkbox/checkbox.d.ts +3 -47
- package/checkbox/checkbox.js +43 -341
- package/checkbox/index.d.ts +6 -6
- package/checkbox/index.js +5 -5
- package/collapsible/collapsible.d.ts +3 -20
- package/collapsible/collapsible.js +82 -277
- package/collapsible/index.d.ts +3 -3
- package/collapsible/index.js +3 -3
- package/combobox/combobox.d.ts +3 -47
- package/combobox/combobox.js +136 -538
- package/combobox/index.d.ts +4 -4
- package/combobox/index.js +3 -3
- package/command/command-empty.d.ts +3 -8
- package/command/command-empty.js +10 -88
- package/command/command-group.d.ts +3 -13
- package/command/command-group.js +14 -114
- package/command/command-input.d.ts +3 -11
- package/command/command-input.js +20 -136
- package/command/command-item.d.ts +3 -18
- package/command/command-item.js +23 -212
- package/command/command-list.d.ts +3 -7
- package/command/command-list.js +11 -79
- package/command/command-separator.d.ts +3 -5
- package/command/command-separator.js +10 -11
- package/command/command-shortcut.d.ts +3 -5
- package/command/command-shortcut.js +9 -12
- package/command/command.d.ts +3 -23
- package/command/command.js +10 -339
- package/command/index.d.ts +17 -19
- package/command/index.js +16 -18
- package/data-table/data-table.d.ts +3 -57
- package/data-table/data-table.js +85 -449
- package/data-table/index.d.ts +3 -4
- package/data-table/index.js +2 -3
- package/dialog/dialog-close.d.ts +3 -14
- package/dialog/dialog-close.js +4 -34
- package/dialog/dialog-popup.d.ts +3 -34
- package/dialog/dialog-popup.js +70 -336
- package/dialog/dialog-trigger.d.ts +3 -14
- package/dialog/dialog-trigger.js +4 -51
- package/dialog/dialog.d.ts +3 -30
- package/dialog/dialog.js +8 -158
- package/dialog/index.d.ts +11 -11
- package/dialog/index.js +9 -9
- package/dropzone/dropzone.d.ts +3 -72
- package/dropzone/dropzone.js +29 -407
- package/dropzone/index.d.ts +4 -4
- package/dropzone/index.js +3 -3
- package/field/field.d.ts +3 -30
- package/field/field.js +34 -353
- package/field/index.d.ts +1 -0
- package/field/index.js +1 -0
- package/fieldset/fieldset.d.ts +3 -18
- package/fieldset/fieldset.js +21 -110
- package/fieldset/index.d.ts +1 -0
- package/fieldset/index.js +1 -0
- package/icon/icon.d.ts +3 -15
- package/icon/icon.js +4 -33
- package/icon/index.d.ts +2 -3
- package/icon/index.js +2 -3
- package/input/index.d.ts +3 -3
- package/input/index.js +3 -3
- package/input/input.d.ts +3 -49
- package/input/input.js +57 -238
- package/menu/index.d.ts +4 -5
- package/menu/index.js +4 -5
- package/menu/menu-item.d.ts +3 -13
- package/menu/menu-item.js +40 -91
- package/menu/menu.d.ts +3 -15
- package/menu/menu.js +27 -277
- package/menubar/index.d.ts +3 -4
- package/menubar/index.js +2 -3
- package/menubar/menubar.d.ts +3 -19
- package/menubar/menubar.js +12 -183
- package/number-field/index.d.ts +3 -3
- package/number-field/index.js +3 -3
- package/number-field/number-field.d.ts +3 -55
- package/number-field/number-field.js +205 -698
- package/package.json +125 -113
- package/popover/index.d.ts +11 -11
- package/popover/index.js +9 -9
- package/popover/popover-close.d.ts +3 -12
- package/popover/popover-close.js +4 -32
- package/popover/popover-popup.d.ts +3 -18
- package/popover/popover-popup.js +28 -205
- package/popover/popover-trigger.d.ts +3 -13
- package/popover/popover-trigger.js +4 -73
- package/popover/popover.d.ts +3 -29
- package/popover/popover.js +8 -207
- package/portal/index.d.ts +3 -4
- package/portal/index.js +2 -3
- package/portal/portal.d.ts +3 -27
- package/portal/portal.js +8 -157
- package/preview-card/index.d.ts +9 -9
- package/preview-card/index.js +7 -7
- package/preview-card/preview-card-popup.d.ts +3 -14
- package/preview-card/preview-card-popup.js +29 -194
- package/preview-card/preview-card-trigger.d.ts +3 -12
- package/preview-card/preview-card-trigger.js +4 -74
- package/preview-card/preview-card.d.ts +3 -33
- package/preview-card/preview-card.js +8 -239
- package/progress/index.d.ts +2 -3
- package/progress/index.js +2 -3
- package/progress/progress.d.ts +3 -17
- package/progress/progress.js +28 -130
- package/radio/index.d.ts +6 -6
- package/radio/index.js +5 -5
- package/radio/radio-group.d.ts +3 -37
- package/radio/radio-group.js +8 -200
- package/radio/radio.d.ts +3 -28
- package/radio/radio.js +38 -213
- package/scroll-area/index.d.ts +2 -3
- package/scroll-area/index.js +2 -3
- package/scroll-area/scroll-area.d.ts +3 -36
- package/scroll-area/scroll-area.js +25 -535
- package/select/index.d.ts +3 -4
- package/select/index.js +2 -3
- package/select/select.d.ts +3 -39
- package/select/select.js +115 -425
- package/separator/index.d.ts +2 -3
- package/separator/index.js +2 -3
- package/separator/separator.d.ts +3 -10
- package/separator/separator.js +23 -85
- package/sidebar/index.d.ts +29 -29
- package/sidebar/index.js +27 -32
- package/sidebar/sidebar-content.d.ts +3 -12
- package/sidebar/sidebar-content.js +7 -29
- package/sidebar/sidebar-footer.d.ts +3 -10
- package/sidebar/sidebar-footer.js +7 -20
- package/sidebar/sidebar-group-label.d.ts +3 -15
- package/sidebar/sidebar-group-label.js +16 -41
- package/sidebar/sidebar-group.d.ts +3 -13
- package/sidebar/sidebar-group.js +7 -24
- package/sidebar/sidebar-header.d.ts +3 -10
- package/sidebar/sidebar-header.js +7 -16
- package/sidebar/sidebar-inset.d.ts +3 -13
- package/sidebar/sidebar-inset.js +7 -28
- package/sidebar/sidebar-menu-button.d.ts +3 -26
- package/sidebar/sidebar-menu-button.js +59 -217
- package/sidebar/sidebar-menu-item.d.ts +3 -10
- package/sidebar/sidebar-menu-item.js +7 -19
- package/sidebar/sidebar-menu.d.ts +3 -12
- package/sidebar/sidebar-menu.js +7 -25
- package/sidebar/sidebar-provider.d.ts +3 -34
- package/sidebar/sidebar-provider.js +22 -232
- package/sidebar/sidebar-separator.d.ts +3 -10
- package/sidebar/sidebar-separator.js +9 -19
- package/sidebar/sidebar-trigger.d.ts +3 -14
- package/sidebar/sidebar-trigger.js +10 -46
- package/sidebar/sidebar.d.ts +3 -19
- package/sidebar/sidebar.js +65 -262
- package/slider/index.d.ts +3 -3
- package/slider/index.js +3 -3
- package/slider/slider.d.ts +3 -45
- package/slider/slider.js +97 -382
- package/spinner/index.d.ts +2 -3
- package/spinner/index.js +2 -3
- package/spinner/spinner.d.ts +3 -11
- package/spinner/spinner.js +20 -163
- package/split-button/index.d.ts +3 -1
- package/split-button/index.js +3 -1
- package/split-button/split-button.d.ts +3 -33
- package/split-button/split-button.js +306 -394
- package/stepper/index.d.ts +3 -3
- package/stepper/index.js +3 -3
- package/stepper/stepper.d.ts +3 -41
- package/stepper/stepper.js +57 -381
- package/switch/index.d.ts +3 -3
- package/switch/index.js +3 -3
- package/switch/switch.d.ts +3 -30
- package/switch/switch.js +63 -228
- package/tabs/index.d.ts +12 -12
- package/tabs/index.js +11 -11
- package/tabs/tab.d.ts +3 -14
- package/tabs/tab.js +32 -131
- package/tabs/tabs-indicator.d.ts +3 -9
- package/tabs/tabs-indicator.js +17 -22
- package/tabs/tabs-list.d.ts +3 -15
- package/tabs/tabs-list.js +14 -113
- package/tabs/tabs-panel.d.ts +3 -16
- package/tabs/tabs-panel.js +32 -114
- package/tabs/tabs.d.ts +3 -22
- package/tabs/tabs.js +8 -170
- package/textarea/index.d.ts +4 -4
- package/textarea/index.js +3 -3
- package/textarea/textarea.d.ts +3 -36
- package/textarea/textarea.js +63 -220
- package/toggle/index.d.ts +6 -6
- package/toggle/index.js +5 -5
- package/toggle/toggle-group.d.ts +3 -27
- package/toggle/toggle-group.js +9 -224
- package/toggle/toggle.d.ts +3 -26
- package/toggle/toggle.js +93 -178
- package/tokens/properties.css +361 -0
- package/tokens/prose.css +250 -0
- package/tokens/prose.d.ts +2 -0
- package/tokens/prose.js +4 -0
- package/tokens/tokens-raw.d.ts +2 -0
- package/tokens/tokens-raw.js +2 -0
- package/tokens/tokens.css +409 -0
- package/tokens/tokens.d.ts +2 -0
- package/tokens/tokens.js +5 -0
- package/toolbar/index.d.ts +2 -3
- package/toolbar/index.js +2 -3
- package/toolbar/toolbar.d.ts +3 -11
- package/toolbar/toolbar.js +25 -116
- package/tooltip/index.d.ts +9 -9
- package/tooltip/index.js +7 -7
- package/tooltip/tooltip-popup.d.ts +3 -14
- package/tooltip/tooltip-popup.js +31 -185
- package/tooltip/tooltip-trigger.d.ts +3 -14
- package/tooltip/tooltip-trigger.js +5 -148
- package/tooltip/tooltip.d.ts +3 -35
- package/tooltip/tooltip.js +8 -253
- package/trunc/index.d.ts +2 -3
- package/trunc/index.js +2 -3
- package/trunc/trunc.d.ts +3 -17
- package/trunc/trunc.js +10 -108
- package/_deprecated/center/center.d.ts +0 -14
- package/_deprecated/center/center.js +0 -37
- package/_deprecated/center/index.d.ts +0 -3
- package/_deprecated/center/index.js +0 -3
- package/_deprecated/center/register.js +0 -4
- package/_deprecated/hstack/hstack.d.ts +0 -25
- package/_deprecated/hstack/hstack.js +0 -187
- package/_deprecated/hstack/index.d.ts +0 -4
- package/_deprecated/hstack/index.js +0 -3
- package/_deprecated/hstack/register.d.ts +0 -1
- package/_deprecated/hstack/register.js +0 -4
- package/_deprecated/page-inset/index.d.ts +0 -3
- package/_deprecated/page-inset/index.js +0 -3
- package/_deprecated/page-inset/page-inset.d.ts +0 -28
- package/_deprecated/page-inset/page-inset.js +0 -151
- package/_deprecated/page-inset/register.d.ts +0 -1
- package/_deprecated/page-inset/register.js +0 -4
- package/_deprecated/vstack/index.d.ts +0 -3
- package/_deprecated/vstack/index.js +0 -3
- package/_deprecated/vstack/register.d.ts +0 -1
- package/_deprecated/vstack/register.js +0 -4
- package/_deprecated/vstack/vstack.d.ts +0 -17
- package/_deprecated/vstack/vstack.js +0 -125
- package/accordion/accordion-context.d.ts +0 -15
- package/accordion/accordion-context.js +0 -3
- package/alert-dialog/alert-dialog-context.d.ts +0 -13
- package/alert-dialog/alert-dialog-context.js +0 -3
- package/checkbox/checkbox-group-context.d.ts +0 -11
- package/checkbox/checkbox-group-context.js +0 -3
- package/command/command-context.d.ts +0 -30
- package/command/command-context.js +0 -3
- package/command/command-score.d.ts +0 -6
- package/command/command-score.js +0 -31
- package/dialog/dialog-context.d.ts +0 -13
- package/dialog/dialog-context.js +0 -3
- package/global.d.ts +0 -179
- package/menubar/menubar-context.d.ts +0 -9
- package/menubar/menubar-context.js +0 -2
- package/popover/popover-context.d.ts +0 -17
- package/popover/popover-context.js +0 -3
- package/preview-card/preview-card-context.d.ts +0 -16
- package/preview-card/preview-card-context.js +0 -3
- package/radio/radio-group-context.d.ts +0 -11
- package/radio/radio-group-context.js +0 -2
- package/sidebar/sidebar-context.d.ts +0 -15
- package/sidebar/sidebar-context.js +0 -3
- package/split-button/register.d.ts +0 -1
- package/split-button/register.js +0 -4
- package/tabs/tabs-context.d.ts +0 -8
- package/tabs/tabs-context.js +0 -2
- package/toggle/toggle-group-context.d.ts +0 -9
- package/toggle/toggle-group-context.js +0 -2
- package/tooltip/tooltip-context.d.ts +0 -17
- package/tooltip/tooltip-context.js +0 -3
- /package/{_deprecated/center/register.d.ts → _install.d.ts} +0 -0
|
@@ -1,193 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
import { css, html, LitElement } from "lit";
|
|
41
|
-
import { property, state } from "lit/decorators.js";
|
|
42
|
-
import { provide } from "@lit/context";
|
|
43
|
-
import { base } from "@deepfuture/dui-core/base";
|
|
44
|
-
import { customEvent } from "@deepfuture/dui-core/event";
|
|
45
|
-
import { checkboxGroupContext, } from "./checkbox-group-context.js";
|
|
46
|
-
export const valueChangeEvent = customEvent("value-change", {
|
|
47
|
-
bubbles: true,
|
|
48
|
-
composed: true,
|
|
49
|
-
});
|
|
50
|
-
/** Structural styles only — layout and behavioral CSS. */
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiCheckboxGroupPrimitive } from "@deepfuture/dui-primitives/checkbox";
|
|
3
|
+
import "../_install.js";
|
|
51
4
|
const styles = css `
|
|
52
|
-
|
|
53
|
-
|
|
5
|
+
[part="root"] {
|
|
6
|
+
gap: var(--space-1);
|
|
54
7
|
}
|
|
55
8
|
|
|
56
|
-
[part="root"] {
|
|
57
|
-
|
|
58
|
-
flex-direction: column;
|
|
59
|
-
align-items: start;
|
|
9
|
+
[part="root"][data-disabled] {
|
|
10
|
+
opacity: 0.4;
|
|
60
11
|
}
|
|
61
12
|
`;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* uncontrolled usage, and an `allValues` prop for parent checkbox
|
|
67
|
-
* (select-all) patterns.
|
|
68
|
-
*
|
|
69
|
-
* @slot - Default slot for `<dui-checkbox>` children.
|
|
70
|
-
* @csspart root - The group container element.
|
|
71
|
-
*
|
|
72
|
-
* @fires value-change - Fired when the set of checked values changes. Detail: string[]
|
|
73
|
-
*/
|
|
74
|
-
let DuiCheckboxGroup = (() => {
|
|
75
|
-
let _classSuper = LitElement;
|
|
76
|
-
let _value_decorators;
|
|
77
|
-
let _value_initializers = [];
|
|
78
|
-
let _value_extraInitializers = [];
|
|
79
|
-
let _defaultValue_decorators;
|
|
80
|
-
let _defaultValue_initializers = [];
|
|
81
|
-
let _defaultValue_extraInitializers = [];
|
|
82
|
-
let _allValues_decorators;
|
|
83
|
-
let _allValues_initializers = [];
|
|
84
|
-
let _allValues_extraInitializers = [];
|
|
85
|
-
let _disabled_decorators;
|
|
86
|
-
let _disabled_initializers = [];
|
|
87
|
-
let _disabled_extraInitializers = [];
|
|
88
|
-
let _private_internalValues_decorators;
|
|
89
|
-
let _private_internalValues_initializers = [];
|
|
90
|
-
let _private_internalValues_extraInitializers = [];
|
|
91
|
-
let _private_internalValues_descriptor;
|
|
92
|
-
let __ctx_decorators;
|
|
93
|
-
let __ctx_initializers = [];
|
|
94
|
-
let __ctx_extraInitializers = [];
|
|
95
|
-
return class DuiCheckboxGroup extends _classSuper {
|
|
96
|
-
static {
|
|
97
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
98
|
-
_value_decorators = [property({ attribute: false })];
|
|
99
|
-
_defaultValue_decorators = [property({ attribute: false })];
|
|
100
|
-
_allValues_decorators = [property({ attribute: false })];
|
|
101
|
-
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
102
|
-
_private_internalValues_decorators = [state()];
|
|
103
|
-
__ctx_decorators = [provide({ context: checkboxGroupContext }), state()];
|
|
104
|
-
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
105
|
-
__esDecorate(this, null, _defaultValue_decorators, { kind: "accessor", name: "defaultValue", static: false, private: false, access: { has: obj => "defaultValue" in obj, get: obj => obj.defaultValue, set: (obj, value) => { obj.defaultValue = value; } }, metadata: _metadata }, _defaultValue_initializers, _defaultValue_extraInitializers);
|
|
106
|
-
__esDecorate(this, null, _allValues_decorators, { kind: "accessor", name: "allValues", static: false, private: false, access: { has: obj => "allValues" in obj, get: obj => obj.allValues, set: (obj, value) => { obj.allValues = value; } }, metadata: _metadata }, _allValues_initializers, _allValues_extraInitializers);
|
|
107
|
-
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
108
|
-
__esDecorate(this, _private_internalValues_descriptor = { get: __setFunctionName(function () { return this.#internalValues_accessor_storage; }, "#internalValues", "get"), set: __setFunctionName(function (value) { this.#internalValues_accessor_storage = value; }, "#internalValues", "set") }, _private_internalValues_decorators, { kind: "accessor", name: "#internalValues", static: false, private: true, access: { has: obj => #internalValues in obj, get: obj => obj.#internalValues, set: (obj, value) => { obj.#internalValues = value; } }, metadata: _metadata }, _private_internalValues_initializers, _private_internalValues_extraInitializers);
|
|
109
|
-
__esDecorate(this, null, __ctx_decorators, { kind: "accessor", name: "_ctx", static: false, private: false, access: { has: obj => "_ctx" in obj, get: obj => obj._ctx, set: (obj, value) => { obj._ctx = value; } }, metadata: _metadata }, __ctx_initializers, __ctx_extraInitializers);
|
|
110
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
111
|
-
}
|
|
112
|
-
static tagName = "dui-checkbox-group";
|
|
113
|
-
static styles = [base, styles];
|
|
114
|
-
#value_accessor_storage = __runInitializers(this, _value_initializers, undefined);
|
|
115
|
-
/** Checked values (controlled). */
|
|
116
|
-
get value() { return this.#value_accessor_storage; }
|
|
117
|
-
set value(value) { this.#value_accessor_storage = value; }
|
|
118
|
-
#defaultValue_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _defaultValue_initializers, []));
|
|
119
|
-
/** Initial checked values for uncontrolled usage. */
|
|
120
|
-
get defaultValue() { return this.#defaultValue_accessor_storage; }
|
|
121
|
-
set defaultValue(value) { this.#defaultValue_accessor_storage = value; }
|
|
122
|
-
#allValues_accessor_storage = (__runInitializers(this, _defaultValue_extraInitializers), __runInitializers(this, _allValues_initializers, []));
|
|
123
|
-
/**
|
|
124
|
-
* All possible checkbox values in the group.
|
|
125
|
-
* Required when using a parent (select-all) checkbox.
|
|
126
|
-
*/
|
|
127
|
-
get allValues() { return this.#allValues_accessor_storage; }
|
|
128
|
-
set allValues(value) { this.#allValues_accessor_storage = value; }
|
|
129
|
-
#disabled_accessor_storage = (__runInitializers(this, _allValues_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
130
|
-
/** Whether all checkboxes in the group are disabled. */
|
|
131
|
-
get disabled() { return this.#disabled_accessor_storage; }
|
|
132
|
-
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
133
|
-
#internalValues_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _private_internalValues_initializers, []));
|
|
134
|
-
get #internalValues() { return _private_internalValues_descriptor.get.call(this); }
|
|
135
|
-
set #internalValues(value) { return _private_internalValues_descriptor.set.call(this, value); }
|
|
136
|
-
#getCheckedValues = (__runInitializers(this, _private_internalValues_extraInitializers), () => this.value ?? this.#internalValues);
|
|
137
|
-
#toggle = (val) => {
|
|
138
|
-
const current = this.#getCheckedValues();
|
|
139
|
-
const next = current.includes(val)
|
|
140
|
-
? current.filter((v) => v !== val)
|
|
141
|
-
: [...current, val];
|
|
142
|
-
if (this.value === undefined) {
|
|
143
|
-
this.#internalValues = next;
|
|
144
|
-
}
|
|
145
|
-
this.dispatchEvent(valueChangeEvent(next));
|
|
146
|
-
};
|
|
147
|
-
#toggleAll = (checked) => {
|
|
148
|
-
const next = checked ? [...this.allValues] : [];
|
|
149
|
-
if (this.value === undefined) {
|
|
150
|
-
this.#internalValues = next;
|
|
151
|
-
}
|
|
152
|
-
this.dispatchEvent(valueChangeEvent(next));
|
|
153
|
-
};
|
|
154
|
-
#_ctx_accessor_storage = __runInitializers(this, __ctx_initializers, this.#buildContext());
|
|
155
|
-
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
156
|
-
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
157
|
-
#buildContext() {
|
|
158
|
-
return {
|
|
159
|
-
checkedValues: this.#getCheckedValues(),
|
|
160
|
-
allValues: this.allValues,
|
|
161
|
-
disabled: this.disabled,
|
|
162
|
-
toggle: this.#toggle,
|
|
163
|
-
toggleAll: this.#toggleAll,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
connectedCallback() {
|
|
167
|
-
super.connectedCallback();
|
|
168
|
-
if (this.value === undefined && this.defaultValue.length > 0) {
|
|
169
|
-
this.#internalValues = [...this.defaultValue];
|
|
170
|
-
}
|
|
171
|
-
this._ctx = this.#buildContext();
|
|
172
|
-
}
|
|
173
|
-
willUpdate() {
|
|
174
|
-
this._ctx = this.#buildContext();
|
|
175
|
-
}
|
|
176
|
-
render() {
|
|
177
|
-
return html `
|
|
178
|
-
<div
|
|
179
|
-
part="root"
|
|
180
|
-
role="group"
|
|
181
|
-
?data-disabled="${this.disabled}"
|
|
182
|
-
>
|
|
183
|
-
<slot></slot>
|
|
184
|
-
</div>
|
|
185
|
-
`;
|
|
186
|
-
}
|
|
187
|
-
constructor() {
|
|
188
|
-
super(...arguments);
|
|
189
|
-
__runInitializers(this, __ctx_extraInitializers);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
})();
|
|
193
|
-
export { DuiCheckboxGroup };
|
|
13
|
+
export class DuiCheckboxGroup extends DuiCheckboxGroupPrimitive {
|
|
14
|
+
static styles = [...DuiCheckboxGroupPrimitive.styles, styles];
|
|
15
|
+
}
|
|
16
|
+
customElements.define(DuiCheckboxGroup.tagName, DuiCheckboxGroup);
|
package/checkbox/checkbox.d.ts
CHANGED
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare
|
|
4
|
-
checked: boolean;
|
|
5
|
-
indeterminate: boolean;
|
|
6
|
-
}) => CustomEvent<{
|
|
7
|
-
checked: boolean;
|
|
8
|
-
indeterminate: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
/**
|
|
11
|
-
* `<dui-checkbox>` — A checkbox input with optional indeterminate state.
|
|
12
|
-
*
|
|
13
|
-
* Supports controlled and uncontrolled usage, group context integration,
|
|
14
|
-
* and field context for form validation states.
|
|
15
|
-
*
|
|
16
|
-
* @csspart root - The checkbox box element.
|
|
17
|
-
* @csspart indicator - The check/indeterminate indicator.
|
|
18
|
-
*
|
|
19
|
-
* @fires checked-change - Fired when checked state changes. Detail: { checked, indeterminate }
|
|
20
|
-
*/
|
|
21
|
-
export declare class DuiCheckbox extends LitElement {
|
|
22
|
-
#private;
|
|
23
|
-
static tagName: "dui-checkbox";
|
|
24
|
-
static formAssociated: boolean;
|
|
1
|
+
import { DuiCheckboxPrimitive } from "@deepfuture/dui-primitives/checkbox";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
export declare class DuiCheckbox extends DuiCheckboxPrimitive {
|
|
25
4
|
static styles: import("lit").CSSResult[];
|
|
26
|
-
constructor();
|
|
27
|
-
/** Whether the checkbox is checked (controlled). */
|
|
28
|
-
accessor checked: boolean | undefined;
|
|
29
|
-
/** Initial checked state for uncontrolled usage. */
|
|
30
|
-
accessor defaultChecked: boolean;
|
|
31
|
-
/** Whether the checkbox is in an indeterminate (mixed) state. */
|
|
32
|
-
accessor indeterminate: boolean;
|
|
33
|
-
/** Whether the checkbox is disabled. */
|
|
34
|
-
accessor disabled: boolean;
|
|
35
|
-
/** Whether the checkbox is read-only. */
|
|
36
|
-
accessor readOnly: boolean;
|
|
37
|
-
/** Whether the checkbox is required for form submission. */
|
|
38
|
-
accessor required: boolean;
|
|
39
|
-
/** The name attribute for form submission. */
|
|
40
|
-
accessor name: string | undefined;
|
|
41
|
-
/** The value attribute for form submission. */
|
|
42
|
-
accessor value: string | undefined;
|
|
43
|
-
/** When true, acts as a parent (select-all) checkbox within a group. */
|
|
44
|
-
accessor parent: boolean;
|
|
45
|
-
connectedCallback(): void;
|
|
46
|
-
willUpdate(): void;
|
|
47
|
-
disconnectedCallback(): void;
|
|
48
|
-
render(): TemplateResult;
|
|
49
5
|
}
|
package/checkbox/checkbox.js
CHANGED
|
@@ -1,359 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
import { css, html, LitElement, nothing } from "lit";
|
|
41
|
-
import { property, state } from "lit/decorators.js";
|
|
42
|
-
import { ContextConsumer } from "@lit/context";
|
|
43
|
-
import { base } from "@deepfuture/dui-core/base";
|
|
44
|
-
import { customEvent } from "@deepfuture/dui-core/event";
|
|
45
|
-
import { checkboxGroupContext } from "./checkbox-group-context.js";
|
|
46
|
-
export const checkedChangeEvent = customEvent("checked-change", { bubbles: true, composed: true });
|
|
47
|
-
/** Structural styles only — layout and behavioral CSS. */
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiCheckboxPrimitive } from "@deepfuture/dui-primitives/checkbox";
|
|
3
|
+
import "../_install.js";
|
|
48
4
|
const styles = css `
|
|
49
5
|
:host {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
text-align: start;
|
|
6
|
+
--checkbox-size: var(--space-4_5);
|
|
7
|
+
gap: var(--space-2);
|
|
8
|
+
font-size: var(--text-sm);
|
|
54
9
|
}
|
|
55
10
|
|
|
56
|
-
|
|
57
|
-
|
|
11
|
+
[part="root"] {
|
|
12
|
+
width: var(--checkbox-size);
|
|
13
|
+
height: var(--checkbox-size);
|
|
14
|
+
margin-block-start: calc(
|
|
15
|
+
(var(--line-height-normal) * 1em - var(--checkbox-size)) / 2
|
|
16
|
+
);
|
|
17
|
+
border-radius: var(--radius-sm);
|
|
18
|
+
transition-property: background, border-color, box-shadow, filter, transform;
|
|
19
|
+
transition-duration: var(--duration-fast);
|
|
58
20
|
}
|
|
59
21
|
|
|
60
|
-
[part="root"] {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
border: none;
|
|
70
|
-
outline: 0;
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
user-select: none;
|
|
22
|
+
[part="root"][data-unchecked] {
|
|
23
|
+
border: var(--border-width-thin) solid var(--border);
|
|
24
|
+
background: transparent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part="root"][data-checked],
|
|
28
|
+
[part="root"][data-indeterminate] {
|
|
29
|
+
background: var(--accent);
|
|
30
|
+
border: var(--border-width-thin) solid var(--accent);
|
|
73
31
|
}
|
|
74
32
|
|
|
75
33
|
[part="root"][data-disabled] {
|
|
76
|
-
|
|
34
|
+
opacity: 0.4;
|
|
77
35
|
}
|
|
78
36
|
|
|
79
|
-
[part="root"]
|
|
80
|
-
|
|
37
|
+
[part="root"]:focus-visible {
|
|
38
|
+
outline: none;
|
|
39
|
+
box-shadow:
|
|
40
|
+
0 0 0 var(--focus-ring-offset) var(--background),
|
|
41
|
+
0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
|
|
81
42
|
}
|
|
82
43
|
|
|
83
|
-
[part="
|
|
84
|
-
|
|
44
|
+
:host([aria-invalid="true"]) [part="root"] {
|
|
45
|
+
background: color-mix(in oklch, var(--destructive) 15%, transparent);
|
|
46
|
+
border-color: color-mix(in oklch, var(--destructive) 70%, transparent);
|
|
85
47
|
}
|
|
86
48
|
|
|
87
|
-
[part="indicator"]
|
|
88
|
-
|
|
49
|
+
[part="indicator"] {
|
|
50
|
+
color: oklch(from var(--accent) 0.98 0.01 h);
|
|
89
51
|
}
|
|
90
52
|
|
|
53
|
+
.Icon {
|
|
54
|
+
width: var(--space-3);
|
|
55
|
+
height: var(--space-3);
|
|
56
|
+
}
|
|
91
57
|
`;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
viewBox="0 0 24 24"
|
|
97
|
-
fill="none"
|
|
98
|
-
stroke="currentColor"
|
|
99
|
-
stroke-width="3"
|
|
100
|
-
stroke-linecap="round"
|
|
101
|
-
stroke-linejoin="round"
|
|
102
|
-
>
|
|
103
|
-
<polyline points="20 6 9 17 4 12"></polyline>
|
|
104
|
-
</svg>
|
|
105
|
-
`;
|
|
106
|
-
const indeterminateIcon = html `
|
|
107
|
-
<svg
|
|
108
|
-
class="Icon"
|
|
109
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
110
|
-
viewBox="0 0 24 24"
|
|
111
|
-
fill="none"
|
|
112
|
-
stroke="currentColor"
|
|
113
|
-
stroke-width="3"
|
|
114
|
-
stroke-linecap="round"
|
|
115
|
-
stroke-linejoin="round"
|
|
116
|
-
>
|
|
117
|
-
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
118
|
-
</svg>
|
|
119
|
-
`;
|
|
120
|
-
/**
|
|
121
|
-
* `<dui-checkbox>` — A checkbox input with optional indeterminate state.
|
|
122
|
-
*
|
|
123
|
-
* Supports controlled and uncontrolled usage, group context integration,
|
|
124
|
-
* and field context for form validation states.
|
|
125
|
-
*
|
|
126
|
-
* @csspart root - The checkbox box element.
|
|
127
|
-
* @csspart indicator - The check/indeterminate indicator.
|
|
128
|
-
*
|
|
129
|
-
* @fires checked-change - Fired when checked state changes. Detail: { checked, indeterminate }
|
|
130
|
-
*/
|
|
131
|
-
let DuiCheckbox = (() => {
|
|
132
|
-
let _classSuper = LitElement;
|
|
133
|
-
let _checked_decorators;
|
|
134
|
-
let _checked_initializers = [];
|
|
135
|
-
let _checked_extraInitializers = [];
|
|
136
|
-
let _defaultChecked_decorators;
|
|
137
|
-
let _defaultChecked_initializers = [];
|
|
138
|
-
let _defaultChecked_extraInitializers = [];
|
|
139
|
-
let _indeterminate_decorators;
|
|
140
|
-
let _indeterminate_initializers = [];
|
|
141
|
-
let _indeterminate_extraInitializers = [];
|
|
142
|
-
let _disabled_decorators;
|
|
143
|
-
let _disabled_initializers = [];
|
|
144
|
-
let _disabled_extraInitializers = [];
|
|
145
|
-
let _readOnly_decorators;
|
|
146
|
-
let _readOnly_initializers = [];
|
|
147
|
-
let _readOnly_extraInitializers = [];
|
|
148
|
-
let _required_decorators;
|
|
149
|
-
let _required_initializers = [];
|
|
150
|
-
let _required_extraInitializers = [];
|
|
151
|
-
let _name_decorators;
|
|
152
|
-
let _name_initializers = [];
|
|
153
|
-
let _name_extraInitializers = [];
|
|
154
|
-
let _value_decorators;
|
|
155
|
-
let _value_initializers = [];
|
|
156
|
-
let _value_extraInitializers = [];
|
|
157
|
-
let _parent_decorators;
|
|
158
|
-
let _parent_initializers = [];
|
|
159
|
-
let _parent_extraInitializers = [];
|
|
160
|
-
let _private_internalChecked_decorators;
|
|
161
|
-
let _private_internalChecked_initializers = [];
|
|
162
|
-
let _private_internalChecked_extraInitializers = [];
|
|
163
|
-
let _private_internalChecked_descriptor;
|
|
164
|
-
return class DuiCheckbox extends _classSuper {
|
|
165
|
-
static {
|
|
166
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
167
|
-
_checked_decorators = [property({ type: Boolean, reflect: true })];
|
|
168
|
-
_defaultChecked_decorators = [property({ type: Boolean, attribute: "default-checked" })];
|
|
169
|
-
_indeterminate_decorators = [property({ type: Boolean, reflect: true })];
|
|
170
|
-
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
171
|
-
_readOnly_decorators = [property({ type: Boolean, reflect: true, attribute: "read-only" })];
|
|
172
|
-
_required_decorators = [property({ type: Boolean, reflect: true })];
|
|
173
|
-
_name_decorators = [property()];
|
|
174
|
-
_value_decorators = [property()];
|
|
175
|
-
_parent_decorators = [property({ type: Boolean })];
|
|
176
|
-
_private_internalChecked_decorators = [state()];
|
|
177
|
-
__esDecorate(this, null, _checked_decorators, { kind: "accessor", name: "checked", static: false, private: false, access: { has: obj => "checked" in obj, get: obj => obj.checked, set: (obj, value) => { obj.checked = value; } }, metadata: _metadata }, _checked_initializers, _checked_extraInitializers);
|
|
178
|
-
__esDecorate(this, null, _defaultChecked_decorators, { kind: "accessor", name: "defaultChecked", static: false, private: false, access: { has: obj => "defaultChecked" in obj, get: obj => obj.defaultChecked, set: (obj, value) => { obj.defaultChecked = value; } }, metadata: _metadata }, _defaultChecked_initializers, _defaultChecked_extraInitializers);
|
|
179
|
-
__esDecorate(this, null, _indeterminate_decorators, { kind: "accessor", name: "indeterminate", static: false, private: false, access: { has: obj => "indeterminate" in obj, get: obj => obj.indeterminate, set: (obj, value) => { obj.indeterminate = value; } }, metadata: _metadata }, _indeterminate_initializers, _indeterminate_extraInitializers);
|
|
180
|
-
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
181
|
-
__esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
|
|
182
|
-
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
183
|
-
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
184
|
-
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
185
|
-
__esDecorate(this, null, _parent_decorators, { kind: "accessor", name: "parent", static: false, private: false, access: { has: obj => "parent" in obj, get: obj => obj.parent, set: (obj, value) => { obj.parent = value; } }, metadata: _metadata }, _parent_initializers, _parent_extraInitializers);
|
|
186
|
-
__esDecorate(this, _private_internalChecked_descriptor = { get: __setFunctionName(function () { return this.#internalChecked_accessor_storage; }, "#internalChecked", "get"), set: __setFunctionName(function (value) { this.#internalChecked_accessor_storage = value; }, "#internalChecked", "set") }, _private_internalChecked_decorators, { kind: "accessor", name: "#internalChecked", static: false, private: true, access: { has: obj => #internalChecked in obj, get: obj => obj.#internalChecked, set: (obj, value) => { obj.#internalChecked = value; } }, metadata: _metadata }, _private_internalChecked_initializers, _private_internalChecked_extraInitializers);
|
|
187
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
188
|
-
}
|
|
189
|
-
static tagName = "dui-checkbox";
|
|
190
|
-
static formAssociated = true;
|
|
191
|
-
static styles = [base, styles];
|
|
192
|
-
#internals;
|
|
193
|
-
constructor() {
|
|
194
|
-
super();
|
|
195
|
-
this.#internals = this.attachInternals();
|
|
196
|
-
}
|
|
197
|
-
#checked_accessor_storage = __runInitializers(this, _checked_initializers, undefined);
|
|
198
|
-
/** Whether the checkbox is checked (controlled). */
|
|
199
|
-
get checked() { return this.#checked_accessor_storage; }
|
|
200
|
-
set checked(value) { this.#checked_accessor_storage = value; }
|
|
201
|
-
#defaultChecked_accessor_storage = (__runInitializers(this, _checked_extraInitializers), __runInitializers(this, _defaultChecked_initializers, false));
|
|
202
|
-
/** Initial checked state for uncontrolled usage. */
|
|
203
|
-
get defaultChecked() { return this.#defaultChecked_accessor_storage; }
|
|
204
|
-
set defaultChecked(value) { this.#defaultChecked_accessor_storage = value; }
|
|
205
|
-
#indeterminate_accessor_storage = (__runInitializers(this, _defaultChecked_extraInitializers), __runInitializers(this, _indeterminate_initializers, false));
|
|
206
|
-
/** Whether the checkbox is in an indeterminate (mixed) state. */
|
|
207
|
-
get indeterminate() { return this.#indeterminate_accessor_storage; }
|
|
208
|
-
set indeterminate(value) { this.#indeterminate_accessor_storage = value; }
|
|
209
|
-
#disabled_accessor_storage = (__runInitializers(this, _indeterminate_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
210
|
-
/** Whether the checkbox is disabled. */
|
|
211
|
-
get disabled() { return this.#disabled_accessor_storage; }
|
|
212
|
-
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
213
|
-
#readOnly_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _readOnly_initializers, false));
|
|
214
|
-
/** Whether the checkbox is read-only. */
|
|
215
|
-
get readOnly() { return this.#readOnly_accessor_storage; }
|
|
216
|
-
set readOnly(value) { this.#readOnly_accessor_storage = value; }
|
|
217
|
-
#required_accessor_storage = (__runInitializers(this, _readOnly_extraInitializers), __runInitializers(this, _required_initializers, false));
|
|
218
|
-
/** Whether the checkbox is required for form submission. */
|
|
219
|
-
get required() { return this.#required_accessor_storage; }
|
|
220
|
-
set required(value) { this.#required_accessor_storage = value; }
|
|
221
|
-
#name_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _name_initializers, undefined));
|
|
222
|
-
/** The name attribute for form submission. */
|
|
223
|
-
get name() { return this.#name_accessor_storage; }
|
|
224
|
-
set name(value) { this.#name_accessor_storage = value; }
|
|
225
|
-
#value_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _value_initializers, undefined));
|
|
226
|
-
/** The value attribute for form submission. */
|
|
227
|
-
get value() { return this.#value_accessor_storage; }
|
|
228
|
-
set value(value) { this.#value_accessor_storage = value; }
|
|
229
|
-
#parent_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _parent_initializers, false));
|
|
230
|
-
/** When true, acts as a parent (select-all) checkbox within a group. */
|
|
231
|
-
get parent() { return this.#parent_accessor_storage; }
|
|
232
|
-
set parent(value) { this.#parent_accessor_storage = value; }
|
|
233
|
-
#internalChecked_accessor_storage = (__runInitializers(this, _parent_extraInitializers), __runInitializers(this, _private_internalChecked_initializers, false));
|
|
234
|
-
get #internalChecked() { return _private_internalChecked_descriptor.get.call(this); }
|
|
235
|
-
set #internalChecked(value) { return _private_internalChecked_descriptor.set.call(this, value); }
|
|
236
|
-
#groupCtx = (__runInitializers(this, _private_internalChecked_extraInitializers), new ContextConsumer(this, {
|
|
237
|
-
context: checkboxGroupContext,
|
|
238
|
-
subscribe: true,
|
|
239
|
-
}));
|
|
240
|
-
get #isChecked() {
|
|
241
|
-
const ctx = this.#groupCtx.value;
|
|
242
|
-
if (ctx && this.value !== undefined) {
|
|
243
|
-
if (this.parent) {
|
|
244
|
-
return (ctx.allValues.length > 0 &&
|
|
245
|
-
ctx.allValues.every((v) => ctx.checkedValues.includes(v)));
|
|
246
|
-
}
|
|
247
|
-
return ctx.checkedValues.includes(this.value);
|
|
248
|
-
}
|
|
249
|
-
return this.checked ?? this.#internalChecked;
|
|
250
|
-
}
|
|
251
|
-
get #isIndeterminate() {
|
|
252
|
-
const ctx = this.#groupCtx.value;
|
|
253
|
-
if (ctx && this.parent && this.value !== undefined) {
|
|
254
|
-
const count = ctx.allValues.filter((v) => ctx.checkedValues.includes(v)).length;
|
|
255
|
-
return count > 0 && count < ctx.allValues.length;
|
|
256
|
-
}
|
|
257
|
-
return this.indeterminate;
|
|
258
|
-
}
|
|
259
|
-
get #isDisabled() {
|
|
260
|
-
return (this.disabled ||
|
|
261
|
-
(this.#groupCtx.value?.disabled ?? false));
|
|
262
|
-
}
|
|
263
|
-
connectedCallback() {
|
|
264
|
-
super.connectedCallback();
|
|
265
|
-
if (this.checked === undefined && this.defaultChecked) {
|
|
266
|
-
this.#internalChecked = true;
|
|
267
|
-
}
|
|
268
|
-
this.addEventListener("click", this.#handleHostClick);
|
|
269
|
-
}
|
|
270
|
-
willUpdate() {
|
|
271
|
-
this.#syncFormValue();
|
|
272
|
-
}
|
|
273
|
-
#syncFormValue() {
|
|
274
|
-
if (this.#isChecked) {
|
|
275
|
-
this.#internals.setFormValue(this.value ?? "on");
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
this.#internals.setFormValue(null);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
disconnectedCallback() {
|
|
282
|
-
super.disconnectedCallback();
|
|
283
|
-
this.removeEventListener("click", this.#handleHostClick);
|
|
284
|
-
}
|
|
285
|
-
#handleHostClick = (_e) => {
|
|
286
|
-
this.#handleClick();
|
|
287
|
-
};
|
|
288
|
-
#handleClick = () => {
|
|
289
|
-
if (this.#isDisabled || this.readOnly)
|
|
290
|
-
return;
|
|
291
|
-
const ctx = this.#groupCtx.value;
|
|
292
|
-
// Within a group: delegate to context
|
|
293
|
-
if (ctx && this.value !== undefined) {
|
|
294
|
-
if (this.parent) {
|
|
295
|
-
ctx.toggleAll(!this.#isChecked);
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
ctx.toggle(this.value);
|
|
299
|
-
}
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
// Standalone behavior
|
|
303
|
-
const newChecked = !this.#isChecked;
|
|
304
|
-
if (this.checked === undefined) {
|
|
305
|
-
this.#internalChecked = newChecked;
|
|
306
|
-
this.indeterminate = false;
|
|
307
|
-
}
|
|
308
|
-
this.dispatchEvent(checkedChangeEvent({
|
|
309
|
-
checked: newChecked,
|
|
310
|
-
indeterminate: false,
|
|
311
|
-
}));
|
|
312
|
-
};
|
|
313
|
-
#handleKeyDown = (e) => {
|
|
314
|
-
if (e.key === " ") {
|
|
315
|
-
e.preventDefault();
|
|
316
|
-
this.#handleClick();
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
render() {
|
|
320
|
-
const isChecked = this.#isChecked;
|
|
321
|
-
const isIndeterminate = this.#isIndeterminate;
|
|
322
|
-
const isDisabled = this.#isDisabled;
|
|
323
|
-
const showIndicator = isChecked || isIndeterminate;
|
|
324
|
-
return html `
|
|
325
|
-
<span
|
|
326
|
-
part="root"
|
|
327
|
-
role="checkbox"
|
|
328
|
-
aria-checked="${isIndeterminate ? "mixed" : String(isChecked)}"
|
|
329
|
-
aria-disabled="${isDisabled ? "true" : nothing}"
|
|
330
|
-
aria-readonly="${this.readOnly ? "true" : nothing}"
|
|
331
|
-
aria-required="${this.required ? "true" : nothing}"
|
|
332
|
-
tabindex="${isDisabled ? nothing : "0"}"
|
|
333
|
-
?data-checked="${isChecked && !isIndeterminate}"
|
|
334
|
-
?data-unchecked="${!isChecked && !isIndeterminate}"
|
|
335
|
-
?data-indeterminate="${isIndeterminate}"
|
|
336
|
-
?data-disabled="${isDisabled}"
|
|
337
|
-
?data-readonly="${this.readOnly}"
|
|
338
|
-
?data-required="${this.required}"
|
|
339
|
-
@keydown="${this.#handleKeyDown}"
|
|
340
|
-
>
|
|
341
|
-
<span
|
|
342
|
-
part="indicator"
|
|
343
|
-
?data-checked="${isChecked && !isIndeterminate}"
|
|
344
|
-
?data-unchecked="${!isChecked && !isIndeterminate}"
|
|
345
|
-
?data-indeterminate="${isIndeterminate}"
|
|
346
|
-
>
|
|
347
|
-
${showIndicator
|
|
348
|
-
? isIndeterminate
|
|
349
|
-
? indeterminateIcon
|
|
350
|
-
: checkIcon
|
|
351
|
-
: nothing}
|
|
352
|
-
</span>
|
|
353
|
-
</span>
|
|
354
|
-
<slot></slot>
|
|
355
|
-
`;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
})();
|
|
359
|
-
export { DuiCheckbox };
|
|
58
|
+
export class DuiCheckbox extends DuiCheckboxPrimitive {
|
|
59
|
+
static styles = [...DuiCheckboxPrimitive.styles, styles];
|
|
60
|
+
}
|
|
61
|
+
customElements.define(DuiCheckbox.tagName, DuiCheckbox);
|