@deepfuture/dui-components 0.0.12 → 0.0.13

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.
Files changed (89) hide show
  1. package/_deprecated/center/center.js +2 -2
  2. package/_deprecated/hstack/hstack.js +79 -33
  3. package/_deprecated/page-inset/page-inset.js +104 -56
  4. package/_deprecated/vstack/vstack.js +61 -19
  5. package/accordion/accordion-item.js +217 -147
  6. package/accordion/accordion.js +214 -149
  7. package/alert-dialog/alert-dialog-close.js +2 -2
  8. package/alert-dialog/alert-dialog-popup.js +230 -166
  9. package/alert-dialog/alert-dialog-trigger.js +2 -2
  10. package/alert-dialog/alert-dialog.js +128 -73
  11. package/avatar/avatar.js +175 -115
  12. package/badge/badge.js +2 -2
  13. package/breadcrumb/breadcrumb-ellipsis.js +2 -2
  14. package/breadcrumb/breadcrumb-item.js +2 -2
  15. package/breadcrumb/breadcrumb-link.js +2 -2
  16. package/breadcrumb/breadcrumb-page.js +2 -2
  17. package/breadcrumb/breadcrumb-separator.js +2 -2
  18. package/breadcrumb/breadcrumb.js +2 -2
  19. package/button/button.js +109 -65
  20. package/calendar/calendar.js +368 -290
  21. package/checkbox/checkbox-group.js +146 -87
  22. package/checkbox/checkbox.js +232 -167
  23. package/collapsible/collapsible.js +210 -132
  24. package/combobox/combobox.js +318 -252
  25. package/command/command-empty.js +67 -25
  26. package/command/command-group.js +87 -47
  27. package/command/command-input.js +84 -44
  28. package/command/command-item.js +168 -124
  29. package/command/command-list.js +60 -18
  30. package/command/command-separator.js +2 -2
  31. package/command/command-shortcut.js +2 -2
  32. package/command/command.js +297 -232
  33. package/data-table/data-table.js +225 -153
  34. package/dialog/dialog-close.js +2 -2
  35. package/dialog/dialog-popup.js +247 -181
  36. package/dialog/dialog-trigger.js +2 -2
  37. package/dialog/dialog.js +128 -73
  38. package/dropzone/dropzone.js +310 -249
  39. package/icon/icon.js +2 -2
  40. package/input/input.js +204 -143
  41. package/link/link.js +62 -24
  42. package/menu/menu-item.js +66 -24
  43. package/menu/menu.js +189 -136
  44. package/menubar/menubar.js +142 -91
  45. package/number-field/number-field.js +277 -204
  46. package/package.json +2 -2
  47. package/popover/popover-close.js +2 -2
  48. package/popover/popover-popup.js +126 -76
  49. package/popover/popover-trigger.js +2 -2
  50. package/popover/popover.js +181 -120
  51. package/portal/portal.js +128 -86
  52. package/preview-card/preview-card-popup.js +114 -66
  53. package/preview-card/preview-card-trigger.js +2 -2
  54. package/preview-card/preview-card.js +211 -142
  55. package/progress/progress.js +91 -45
  56. package/radio/radio-group.js +153 -90
  57. package/radio/radio.js +137 -94
  58. package/scroll-area/scroll-area.js +382 -283
  59. package/select/select.js +260 -203
  60. package/separator/separator.js +60 -18
  61. package/sidebar/sidebar-content.js +2 -2
  62. package/sidebar/sidebar-footer.js +2 -2
  63. package/sidebar/sidebar-group-label.js +2 -2
  64. package/sidebar/sidebar-group.js +2 -2
  65. package/sidebar/sidebar-header.js +2 -2
  66. package/sidebar/sidebar-inset.js +2 -2
  67. package/sidebar/sidebar-menu-button.js +118 -74
  68. package/sidebar/sidebar-menu-item.js +2 -2
  69. package/sidebar/sidebar-menu.js +2 -2
  70. package/sidebar/sidebar-provider.js +202 -129
  71. package/sidebar/sidebar-separator.js +2 -2
  72. package/sidebar/sidebar-trigger.js +2 -2
  73. package/sidebar/sidebar.js +150 -85
  74. package/slider/slider.js +217 -159
  75. package/spinner/spinner.js +70 -28
  76. package/switch/switch.js +174 -111
  77. package/tabs/tab.js +89 -47
  78. package/tabs/tabs-indicator.js +2 -2
  79. package/tabs/tabs-list.js +92 -54
  80. package/tabs/tabs-panel.js +90 -44
  81. package/tabs/tabs.js +130 -71
  82. package/textarea/textarea.js +153 -95
  83. package/toggle/toggle-group.js +184 -125
  84. package/toggle/toggle.js +131 -76
  85. package/toolbar/toolbar.js +79 -33
  86. package/tooltip/tooltip-popup.js +108 -60
  87. package/tooltip/tooltip-trigger.js +93 -55
  88. package/tooltip/tooltip.js +225 -154
  89. package/trunc/trunc.js +78 -34
@@ -1,9 +1,41 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/checkbox */
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
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 });
7
39
  };
8
40
  import { css, html, LitElement, nothing } from "lit";
9
41
  import { property, state } from "lit/decorators.js";
@@ -105,139 +137,201 @@ const indeterminateIcon = html `
105
137
  *
106
138
  * @fires checked-change - Fired when checked state changes. Detail: { checked, indeterminate }
107
139
  */
108
- export class DuiCheckbox extends LitElement {
109
- static { this.tagName = "dui-checkbox"; }
110
- static { this.styles = [base, styles]; }
111
- #checked_accessor_storage = undefined;
112
- /** Whether the checkbox is checked (controlled). */
113
- get checked() { return this.#checked_accessor_storage; }
114
- set checked(value) { this.#checked_accessor_storage = value; }
115
- #defaultChecked_accessor_storage = false;
116
- /** Initial checked state for uncontrolled usage. */
117
- get defaultChecked() { return this.#defaultChecked_accessor_storage; }
118
- set defaultChecked(value) { this.#defaultChecked_accessor_storage = value; }
119
- #indeterminate_accessor_storage = false;
120
- /** Whether the checkbox is in an indeterminate (mixed) state. */
121
- get indeterminate() { return this.#indeterminate_accessor_storage; }
122
- set indeterminate(value) { this.#indeterminate_accessor_storage = value; }
123
- #disabled_accessor_storage = false;
124
- /** Whether the checkbox is disabled. */
125
- get disabled() { return this.#disabled_accessor_storage; }
126
- set disabled(value) { this.#disabled_accessor_storage = value; }
127
- #readOnly_accessor_storage = false;
128
- /** Whether the checkbox is read-only. */
129
- get readOnly() { return this.#readOnly_accessor_storage; }
130
- set readOnly(value) { this.#readOnly_accessor_storage = value; }
131
- #required_accessor_storage = false;
132
- /** Whether the checkbox is required for form submission. */
133
- get required() { return this.#required_accessor_storage; }
134
- set required(value) { this.#required_accessor_storage = value; }
135
- #name_accessor_storage = undefined;
136
- /** The name attribute for form submission. */
137
- get name() { return this.#name_accessor_storage; }
138
- set name(value) { this.#name_accessor_storage = value; }
139
- #value_accessor_storage = undefined;
140
- /** The value attribute for form submission. */
141
- get value() { return this.#value_accessor_storage; }
142
- set value(value) { this.#value_accessor_storage = value; }
143
- #parent_accessor_storage = false;
144
- /** When true, acts as a parent (select-all) checkbox within a group. */
145
- get parent() { return this.#parent_accessor_storage; }
146
- set parent(value) { this.#parent_accessor_storage = value; }
147
- #internalChecked_accessor_storage = false;
148
- get #internalChecked() { return this.#internalChecked_accessor_storage; }
149
- set #internalChecked(value) { this.#internalChecked_accessor_storage = value; }
150
- #groupCtx = new ContextConsumer(this, {
151
- context: checkboxGroupContext,
152
- subscribe: true,
153
- });
154
- #_fieldCtx_accessor_storage;
155
- get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
156
- set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
157
- get #isChecked() {
158
- const ctx = this.#groupCtx.value;
159
- if (ctx && this.value !== undefined) {
160
- if (this.parent) {
161
- return (ctx.allValues.length > 0 &&
162
- ctx.allValues.every((v) => ctx.checkedValues.includes(v)));
140
+ let DuiCheckbox = (() => {
141
+ let _classSuper = LitElement;
142
+ let _checked_decorators;
143
+ let _checked_initializers = [];
144
+ let _checked_extraInitializers = [];
145
+ let _defaultChecked_decorators;
146
+ let _defaultChecked_initializers = [];
147
+ let _defaultChecked_extraInitializers = [];
148
+ let _indeterminate_decorators;
149
+ let _indeterminate_initializers = [];
150
+ let _indeterminate_extraInitializers = [];
151
+ let _disabled_decorators;
152
+ let _disabled_initializers = [];
153
+ let _disabled_extraInitializers = [];
154
+ let _readOnly_decorators;
155
+ let _readOnly_initializers = [];
156
+ let _readOnly_extraInitializers = [];
157
+ let _required_decorators;
158
+ let _required_initializers = [];
159
+ let _required_extraInitializers = [];
160
+ let _name_decorators;
161
+ let _name_initializers = [];
162
+ let _name_extraInitializers = [];
163
+ let _value_decorators;
164
+ let _value_initializers = [];
165
+ let _value_extraInitializers = [];
166
+ let _parent_decorators;
167
+ let _parent_initializers = [];
168
+ let _parent_extraInitializers = [];
169
+ let _private_internalChecked_decorators;
170
+ let _private_internalChecked_initializers = [];
171
+ let _private_internalChecked_extraInitializers = [];
172
+ let _private_internalChecked_descriptor;
173
+ let __fieldCtx_decorators;
174
+ let __fieldCtx_initializers = [];
175
+ let __fieldCtx_extraInitializers = [];
176
+ return class DuiCheckbox extends _classSuper {
177
+ static {
178
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
179
+ _checked_decorators = [property({ type: Boolean, reflect: true })];
180
+ _defaultChecked_decorators = [property({ type: Boolean, attribute: "default-checked" })];
181
+ _indeterminate_decorators = [property({ type: Boolean, reflect: true })];
182
+ _disabled_decorators = [property({ type: Boolean, reflect: true })];
183
+ _readOnly_decorators = [property({ type: Boolean, reflect: true, attribute: "read-only" })];
184
+ _required_decorators = [property({ type: Boolean, reflect: true })];
185
+ _name_decorators = [property()];
186
+ _value_decorators = [property()];
187
+ _parent_decorators = [property({ type: Boolean })];
188
+ _private_internalChecked_decorators = [state()];
189
+ __fieldCtx_decorators = [consume({ context: fieldContext, subscribe: true }), state()];
190
+ __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);
191
+ __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);
192
+ __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);
193
+ __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);
194
+ __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);
195
+ __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);
196
+ __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);
197
+ __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);
198
+ __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);
199
+ __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);
200
+ __esDecorate(this, null, __fieldCtx_decorators, { kind: "accessor", name: "_fieldCtx", static: false, private: false, access: { has: obj => "_fieldCtx" in obj, get: obj => obj._fieldCtx, set: (obj, value) => { obj._fieldCtx = value; } }, metadata: _metadata }, __fieldCtx_initializers, __fieldCtx_extraInitializers);
201
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
202
+ }
203
+ static tagName = "dui-checkbox";
204
+ static styles = [base, styles];
205
+ #checked_accessor_storage = __runInitializers(this, _checked_initializers, undefined);
206
+ /** Whether the checkbox is checked (controlled). */
207
+ get checked() { return this.#checked_accessor_storage; }
208
+ set checked(value) { this.#checked_accessor_storage = value; }
209
+ #defaultChecked_accessor_storage = (__runInitializers(this, _checked_extraInitializers), __runInitializers(this, _defaultChecked_initializers, false));
210
+ /** Initial checked state for uncontrolled usage. */
211
+ get defaultChecked() { return this.#defaultChecked_accessor_storage; }
212
+ set defaultChecked(value) { this.#defaultChecked_accessor_storage = value; }
213
+ #indeterminate_accessor_storage = (__runInitializers(this, _defaultChecked_extraInitializers), __runInitializers(this, _indeterminate_initializers, false));
214
+ /** Whether the checkbox is in an indeterminate (mixed) state. */
215
+ get indeterminate() { return this.#indeterminate_accessor_storage; }
216
+ set indeterminate(value) { this.#indeterminate_accessor_storage = value; }
217
+ #disabled_accessor_storage = (__runInitializers(this, _indeterminate_extraInitializers), __runInitializers(this, _disabled_initializers, false));
218
+ /** Whether the checkbox is disabled. */
219
+ get disabled() { return this.#disabled_accessor_storage; }
220
+ set disabled(value) { this.#disabled_accessor_storage = value; }
221
+ #readOnly_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _readOnly_initializers, false));
222
+ /** Whether the checkbox is read-only. */
223
+ get readOnly() { return this.#readOnly_accessor_storage; }
224
+ set readOnly(value) { this.#readOnly_accessor_storage = value; }
225
+ #required_accessor_storage = (__runInitializers(this, _readOnly_extraInitializers), __runInitializers(this, _required_initializers, false));
226
+ /** Whether the checkbox is required for form submission. */
227
+ get required() { return this.#required_accessor_storage; }
228
+ set required(value) { this.#required_accessor_storage = value; }
229
+ #name_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _name_initializers, undefined));
230
+ /** The name attribute for form submission. */
231
+ get name() { return this.#name_accessor_storage; }
232
+ set name(value) { this.#name_accessor_storage = value; }
233
+ #value_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _value_initializers, undefined));
234
+ /** The value attribute for form submission. */
235
+ get value() { return this.#value_accessor_storage; }
236
+ set value(value) { this.#value_accessor_storage = value; }
237
+ #parent_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _parent_initializers, false));
238
+ /** When true, acts as a parent (select-all) checkbox within a group. */
239
+ get parent() { return this.#parent_accessor_storage; }
240
+ set parent(value) { this.#parent_accessor_storage = value; }
241
+ #internalChecked_accessor_storage = (__runInitializers(this, _parent_extraInitializers), __runInitializers(this, _private_internalChecked_initializers, false));
242
+ get #internalChecked() { return _private_internalChecked_descriptor.get.call(this); }
243
+ set #internalChecked(value) { return _private_internalChecked_descriptor.set.call(this, value); }
244
+ #groupCtx = (__runInitializers(this, _private_internalChecked_extraInitializers), new ContextConsumer(this, {
245
+ context: checkboxGroupContext,
246
+ subscribe: true,
247
+ }));
248
+ #_fieldCtx_accessor_storage = __runInitializers(this, __fieldCtx_initializers, void 0);
249
+ get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
250
+ set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
251
+ get #isChecked() {
252
+ const ctx = this.#groupCtx.value;
253
+ if (ctx && this.value !== undefined) {
254
+ if (this.parent) {
255
+ return (ctx.allValues.length > 0 &&
256
+ ctx.allValues.every((v) => ctx.checkedValues.includes(v)));
257
+ }
258
+ return ctx.checkedValues.includes(this.value);
163
259
  }
164
- return ctx.checkedValues.includes(this.value);
260
+ return this.checked ?? this.#internalChecked;
165
261
  }
166
- return this.checked ?? this.#internalChecked;
167
- }
168
- get #isIndeterminate() {
169
- const ctx = this.#groupCtx.value;
170
- if (ctx && this.parent && this.value !== undefined) {
171
- const count = ctx.allValues.filter((v) => ctx.checkedValues.includes(v)).length;
172
- return count > 0 && count < ctx.allValues.length;
262
+ get #isIndeterminate() {
263
+ const ctx = this.#groupCtx.value;
264
+ if (ctx && this.parent && this.value !== undefined) {
265
+ const count = ctx.allValues.filter((v) => ctx.checkedValues.includes(v)).length;
266
+ return count > 0 && count < ctx.allValues.length;
267
+ }
268
+ return this.indeterminate;
173
269
  }
174
- return this.indeterminate;
175
- }
176
- get #isDisabled() {
177
- return (this.disabled ||
178
- (this.#groupCtx.value?.disabled ?? false) ||
179
- (this._fieldCtx?.disabled ?? false));
180
- }
181
- get #isInvalid() {
182
- return this._fieldCtx?.invalid ?? false;
183
- }
184
- connectedCallback() {
185
- super.connectedCallback();
186
- if (this.checked === undefined && this.defaultChecked) {
187
- this.#internalChecked = true;
270
+ get #isDisabled() {
271
+ return (this.disabled ||
272
+ (this.#groupCtx.value?.disabled ?? false) ||
273
+ (this._fieldCtx?.disabled ?? false));
188
274
  }
189
- this.addEventListener("click", this.#handleHostClick);
190
- }
191
- disconnectedCallback() {
192
- super.disconnectedCallback();
193
- this.removeEventListener("click", this.#handleHostClick);
194
- }
195
- #handleHostClick = (_e) => {
196
- this.#handleClick();
197
- };
198
- #handleClick = () => {
199
- if (this.#isDisabled || this.readOnly)
200
- return;
201
- const ctx = this.#groupCtx.value;
202
- // Within a group: delegate to context
203
- if (ctx && this.value !== undefined) {
204
- if (this.parent) {
205
- ctx.toggleAll(!this.#isChecked);
206
- }
207
- else {
208
- ctx.toggle(this.value);
275
+ get #isInvalid() {
276
+ return this._fieldCtx?.invalid ?? false;
277
+ }
278
+ connectedCallback() {
279
+ super.connectedCallback();
280
+ if (this.checked === undefined && this.defaultChecked) {
281
+ this.#internalChecked = true;
209
282
  }
210
- this._fieldCtx?.markDirty();
211
- this._fieldCtx?.markTouched();
212
- return;
283
+ this.addEventListener("click", this.#handleHostClick);
213
284
  }
214
- // Standalone behavior
215
- const newChecked = !this.#isChecked;
216
- if (this.checked === undefined) {
217
- this.#internalChecked = newChecked;
218
- this.indeterminate = false;
285
+ disconnectedCallback() {
286
+ super.disconnectedCallback();
287
+ this.removeEventListener("click", this.#handleHostClick);
219
288
  }
220
- this._fieldCtx?.markDirty();
221
- this._fieldCtx?.markTouched();
222
- this.dispatchEvent(checkedChangeEvent({
223
- checked: newChecked,
224
- indeterminate: false,
225
- }));
226
- };
227
- #handleKeyDown = (e) => {
228
- if (e.key === " ") {
229
- e.preventDefault();
289
+ #handleHostClick = (__runInitializers(this, __fieldCtx_extraInitializers), (_e) => {
230
290
  this.#handleClick();
231
- }
232
- };
233
- render() {
234
- const isChecked = this.#isChecked;
235
- const isIndeterminate = this.#isIndeterminate;
236
- const isDisabled = this.#isDisabled;
237
- const isInvalid = this.#isInvalid;
238
- const showIndicator = isChecked || isIndeterminate;
239
- const controlId = this._fieldCtx?.controlId ?? "";
240
- return html `
291
+ });
292
+ #handleClick = () => {
293
+ if (this.#isDisabled || this.readOnly)
294
+ return;
295
+ const ctx = this.#groupCtx.value;
296
+ // Within a group: delegate to context
297
+ if (ctx && this.value !== undefined) {
298
+ if (this.parent) {
299
+ ctx.toggleAll(!this.#isChecked);
300
+ }
301
+ else {
302
+ ctx.toggle(this.value);
303
+ }
304
+ this._fieldCtx?.markDirty();
305
+ this._fieldCtx?.markTouched();
306
+ return;
307
+ }
308
+ // Standalone behavior
309
+ const newChecked = !this.#isChecked;
310
+ if (this.checked === undefined) {
311
+ this.#internalChecked = newChecked;
312
+ this.indeterminate = false;
313
+ }
314
+ this._fieldCtx?.markDirty();
315
+ this._fieldCtx?.markTouched();
316
+ this.dispatchEvent(checkedChangeEvent({
317
+ checked: newChecked,
318
+ indeterminate: false,
319
+ }));
320
+ };
321
+ #handleKeyDown = (e) => {
322
+ if (e.key === " ") {
323
+ e.preventDefault();
324
+ this.#handleClick();
325
+ }
326
+ };
327
+ render() {
328
+ const isChecked = this.#isChecked;
329
+ const isIndeterminate = this.#isIndeterminate;
330
+ const isDisabled = this.#isDisabled;
331
+ const isInvalid = this.#isInvalid;
332
+ const showIndicator = isChecked || isIndeterminate;
333
+ const controlId = this._fieldCtx?.controlId ?? "";
334
+ return html `
241
335
  <span
242
336
  part="root"
243
337
  role="checkbox"
@@ -264,10 +358,10 @@ export class DuiCheckbox extends LitElement {
264
358
  ?data-indeterminate="${isIndeterminate}"
265
359
  >
266
360
  ${showIndicator
267
- ? isIndeterminate
268
- ? indeterminateIcon
269
- : checkIcon
270
- : nothing}
361
+ ? isIndeterminate
362
+ ? indeterminateIcon
363
+ : checkIcon
364
+ : nothing}
271
365
  </span>
272
366
  <input
273
367
  type="checkbox"
@@ -284,36 +378,7 @@ export class DuiCheckbox extends LitElement {
284
378
  </span>
285
379
  <slot></slot>
286
380
  `;
287
- }
288
- }
289
- __decorate([
290
- property({ type: Boolean, reflect: true })
291
- ], DuiCheckbox.prototype, "checked", null);
292
- __decorate([
293
- property({ type: Boolean, attribute: "default-checked" })
294
- ], DuiCheckbox.prototype, "defaultChecked", null);
295
- __decorate([
296
- property({ type: Boolean, reflect: true })
297
- ], DuiCheckbox.prototype, "indeterminate", null);
298
- __decorate([
299
- property({ type: Boolean, reflect: true })
300
- ], DuiCheckbox.prototype, "disabled", null);
301
- __decorate([
302
- property({ type: Boolean, reflect: true, attribute: "read-only" })
303
- ], DuiCheckbox.prototype, "readOnly", null);
304
- __decorate([
305
- property({ type: Boolean, reflect: true })
306
- ], DuiCheckbox.prototype, "required", null);
307
- __decorate([
308
- property()
309
- ], DuiCheckbox.prototype, "name", null);
310
- __decorate([
311
- property()
312
- ], DuiCheckbox.prototype, "value", null);
313
- __decorate([
314
- property({ type: Boolean })
315
- ], DuiCheckbox.prototype, "parent", null);
316
- __decorate([
317
- consume({ context: fieldContext, subscribe: true }),
318
- state()
319
- ], DuiCheckbox.prototype, "_fieldCtx", null);
381
+ }
382
+ };
383
+ })();
384
+ export { DuiCheckbox };