@deepfuture/dui-components 0.0.12 → 0.0.14

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 -3
  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,12 +1,44 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/dialog */
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 } from "lit";
9
- import { property } from "lit/decorators.js";
41
+ import { property, state } from "lit/decorators.js";
10
42
  import { ContextConsumer } from "@lit/context";
11
43
  import { base } from "@deepfuture/dui-core/base";
12
44
  import { getComposedFocusableElements, queryComposedAutofocus, } from "@deepfuture/dui-core/dom";
@@ -60,181 +92,225 @@ const componentStyles = css `
60
92
  * @csspart title - The heading element wrapping the title slot.
61
93
  * @csspart description - The paragraph element wrapping the description slot.
62
94
  */
63
- export class DuiDialogPopup extends LitElement {
64
- static { this.tagName = "dui-dialog-popup"; }
65
- static { this.styles = [base, hostStyles, componentStyles]; }
66
- #keepMounted_accessor_storage = false;
67
- /** Keep the popup in the DOM when closed. */
68
- get keepMounted() { return this.#keepMounted_accessor_storage; }
69
- set keepMounted(value) { this.#keepMounted_accessor_storage = value; }
70
- #initialFocus_accessor_storage = undefined;
71
- /** CSS selector within the popup to focus when the dialog opens. */
72
- get initialFocus() { return this.#initialFocus_accessor_storage; }
73
- set initialFocus(value) { this.#initialFocus_accessor_storage = value; }
74
- #finalFocus_accessor_storage = undefined;
75
- /** CSS selector in the document to focus when the dialog closes. */
76
- get finalFocus() { return this.#finalFocus_accessor_storage; }
77
- set finalFocus(value) { this.#finalFocus_accessor_storage = value; }
78
- #width_accessor_storage = undefined;
79
- /** Width of the popup (CSS value, e.g. "32rem" or "600px"). Defaults to 24rem. */
80
- get width() { return this.#width_accessor_storage; }
81
- set width(value) { this.#width_accessor_storage = value; }
82
- #mounted_accessor_storage = false;
83
- get #mounted() { return this.#mounted_accessor_storage; }
84
- set #mounted(value) { this.#mounted_accessor_storage = value; }
85
- #startingStyle_accessor_storage = false;
86
- get #startingStyle() { return this.#startingStyle_accessor_storage; }
87
- set #startingStyle(value) { this.#startingStyle_accessor_storage = value; }
88
- #endingStyle_accessor_storage = false;
89
- get #endingStyle() { return this.#endingStyle_accessor_storage; }
90
- set #endingStyle(value) { this.#endingStyle_accessor_storage = value; }
91
- #previouslyFocused;
92
- #ctx = new ContextConsumer(this, {
93
- context: dialogContext,
94
- subscribe: true,
95
- });
96
- updated() {
97
- const isOpen = this.#ctx.value?.open ?? false;
98
- if (isOpen && !this.#mounted) {
99
- this.#animateOpen();
95
+ let DuiDialogPopup = (() => {
96
+ let _classSuper = LitElement;
97
+ let _keepMounted_decorators;
98
+ let _keepMounted_initializers = [];
99
+ let _keepMounted_extraInitializers = [];
100
+ let _initialFocus_decorators;
101
+ let _initialFocus_initializers = [];
102
+ let _initialFocus_extraInitializers = [];
103
+ let _finalFocus_decorators;
104
+ let _finalFocus_initializers = [];
105
+ let _finalFocus_extraInitializers = [];
106
+ let _width_decorators;
107
+ let _width_initializers = [];
108
+ let _width_extraInitializers = [];
109
+ let _private_mounted_decorators;
110
+ let _private_mounted_initializers = [];
111
+ let _private_mounted_extraInitializers = [];
112
+ let _private_mounted_descriptor;
113
+ let _private_startingStyle_decorators;
114
+ let _private_startingStyle_initializers = [];
115
+ let _private_startingStyle_extraInitializers = [];
116
+ let _private_startingStyle_descriptor;
117
+ let _private_endingStyle_decorators;
118
+ let _private_endingStyle_initializers = [];
119
+ let _private_endingStyle_extraInitializers = [];
120
+ let _private_endingStyle_descriptor;
121
+ return class DuiDialogPopup extends _classSuper {
122
+ static {
123
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
124
+ _keepMounted_decorators = [property({ type: Boolean, attribute: "keep-mounted" })];
125
+ _initialFocus_decorators = [property({ attribute: "initial-focus" })];
126
+ _finalFocus_decorators = [property({ attribute: "final-focus" })];
127
+ _width_decorators = [property()];
128
+ _private_mounted_decorators = [state()];
129
+ _private_startingStyle_decorators = [state()];
130
+ _private_endingStyle_decorators = [state()];
131
+ __esDecorate(this, null, _keepMounted_decorators, { kind: "accessor", name: "keepMounted", static: false, private: false, access: { has: obj => "keepMounted" in obj, get: obj => obj.keepMounted, set: (obj, value) => { obj.keepMounted = value; } }, metadata: _metadata }, _keepMounted_initializers, _keepMounted_extraInitializers);
132
+ __esDecorate(this, null, _initialFocus_decorators, { kind: "accessor", name: "initialFocus", static: false, private: false, access: { has: obj => "initialFocus" in obj, get: obj => obj.initialFocus, set: (obj, value) => { obj.initialFocus = value; } }, metadata: _metadata }, _initialFocus_initializers, _initialFocus_extraInitializers);
133
+ __esDecorate(this, null, _finalFocus_decorators, { kind: "accessor", name: "finalFocus", static: false, private: false, access: { has: obj => "finalFocus" in obj, get: obj => obj.finalFocus, set: (obj, value) => { obj.finalFocus = value; } }, metadata: _metadata }, _finalFocus_initializers, _finalFocus_extraInitializers);
134
+ __esDecorate(this, null, _width_decorators, { kind: "accessor", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
135
+ __esDecorate(this, _private_mounted_descriptor = { get: __setFunctionName(function () { return this.#mounted_accessor_storage; }, "#mounted", "get"), set: __setFunctionName(function (value) { this.#mounted_accessor_storage = value; }, "#mounted", "set") }, _private_mounted_decorators, { kind: "accessor", name: "#mounted", static: false, private: true, access: { has: obj => #mounted in obj, get: obj => obj.#mounted, set: (obj, value) => { obj.#mounted = value; } }, metadata: _metadata }, _private_mounted_initializers, _private_mounted_extraInitializers);
136
+ __esDecorate(this, _private_startingStyle_descriptor = { get: __setFunctionName(function () { return this.#startingStyle_accessor_storage; }, "#startingStyle", "get"), set: __setFunctionName(function (value) { this.#startingStyle_accessor_storage = value; }, "#startingStyle", "set") }, _private_startingStyle_decorators, { kind: "accessor", name: "#startingStyle", static: false, private: true, access: { has: obj => #startingStyle in obj, get: obj => obj.#startingStyle, set: (obj, value) => { obj.#startingStyle = value; } }, metadata: _metadata }, _private_startingStyle_initializers, _private_startingStyle_extraInitializers);
137
+ __esDecorate(this, _private_endingStyle_descriptor = { get: __setFunctionName(function () { return this.#endingStyle_accessor_storage; }, "#endingStyle", "get"), set: __setFunctionName(function (value) { this.#endingStyle_accessor_storage = value; }, "#endingStyle", "set") }, _private_endingStyle_decorators, { kind: "accessor", name: "#endingStyle", static: false, private: true, access: { has: obj => #endingStyle in obj, get: obj => obj.#endingStyle, set: (obj, value) => { obj.#endingStyle = value; } }, metadata: _metadata }, _private_endingStyle_initializers, _private_endingStyle_extraInitializers);
138
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
100
139
  }
101
- else if (!isOpen && this.#mounted && !this.#endingStyle) {
102
- this.#animateClose();
140
+ static tagName = "dui-dialog-popup";
141
+ static styles = [base, hostStyles, componentStyles];
142
+ #keepMounted_accessor_storage = __runInitializers(this, _keepMounted_initializers, false);
143
+ /** Keep the popup in the DOM when closed. */
144
+ get keepMounted() { return this.#keepMounted_accessor_storage; }
145
+ set keepMounted(value) { this.#keepMounted_accessor_storage = value; }
146
+ #initialFocus_accessor_storage = (__runInitializers(this, _keepMounted_extraInitializers), __runInitializers(this, _initialFocus_initializers, undefined));
147
+ /** CSS selector within the popup to focus when the dialog opens. */
148
+ get initialFocus() { return this.#initialFocus_accessor_storage; }
149
+ set initialFocus(value) { this.#initialFocus_accessor_storage = value; }
150
+ #finalFocus_accessor_storage = (__runInitializers(this, _initialFocus_extraInitializers), __runInitializers(this, _finalFocus_initializers, undefined));
151
+ /** CSS selector in the document to focus when the dialog closes. */
152
+ get finalFocus() { return this.#finalFocus_accessor_storage; }
153
+ set finalFocus(value) { this.#finalFocus_accessor_storage = value; }
154
+ #width_accessor_storage = (__runInitializers(this, _finalFocus_extraInitializers), __runInitializers(this, _width_initializers, undefined));
155
+ /** Width of the popup (CSS value, e.g. "32rem" or "600px"). Defaults to 24rem. */
156
+ get width() { return this.#width_accessor_storage; }
157
+ set width(value) { this.#width_accessor_storage = value; }
158
+ #mounted_accessor_storage = (__runInitializers(this, _width_extraInitializers), __runInitializers(this, _private_mounted_initializers, false));
159
+ get #mounted() { return _private_mounted_descriptor.get.call(this); }
160
+ set #mounted(value) { return _private_mounted_descriptor.set.call(this, value); }
161
+ #startingStyle_accessor_storage = (__runInitializers(this, _private_mounted_extraInitializers), __runInitializers(this, _private_startingStyle_initializers, false));
162
+ get #startingStyle() { return _private_startingStyle_descriptor.get.call(this); }
163
+ set #startingStyle(value) { return _private_startingStyle_descriptor.set.call(this, value); }
164
+ #endingStyle_accessor_storage = (__runInitializers(this, _private_startingStyle_extraInitializers), __runInitializers(this, _private_endingStyle_initializers, false));
165
+ get #endingStyle() { return _private_endingStyle_descriptor.get.call(this); }
166
+ set #endingStyle(value) { return _private_endingStyle_descriptor.set.call(this, value); }
167
+ #previouslyFocused = __runInitializers(this, _private_endingStyle_extraInitializers);
168
+ #ctx = new ContextConsumer(this, {
169
+ context: dialogContext,
170
+ subscribe: true,
171
+ });
172
+ updated() {
173
+ const isOpen = this.#ctx.value?.open ?? false;
174
+ if (isOpen && !this.#mounted) {
175
+ this.#animateOpen();
176
+ }
177
+ else if (!isOpen && this.#mounted && !this.#endingStyle) {
178
+ this.#animateClose();
179
+ }
103
180
  }
104
- }
105
- async #animateOpen() {
106
- this.#previouslyFocused =
107
- document.activeElement ?? undefined;
108
- this.#mounted = true;
109
- this.#startingStyle = true;
110
- await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
111
- this.#startingStyle = false;
112
- await this.updateComplete;
113
- this.#trapFocusIn();
114
- }
115
- #animateClose() {
116
- this.#endingStyle = true;
117
- const popup = this.shadowRoot?.querySelector('[part="popup"]');
118
- if (!popup) {
119
- this.#finishClose();
120
- return;
181
+ async #animateOpen() {
182
+ this.#previouslyFocused =
183
+ document.activeElement ?? undefined;
184
+ this.#mounted = true;
185
+ this.#startingStyle = true;
186
+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
187
+ this.#startingStyle = false;
188
+ await this.updateComplete;
189
+ this.#trapFocusIn();
121
190
  }
122
- let called = false;
123
- const done = () => {
124
- if (called)
191
+ #animateClose() {
192
+ this.#endingStyle = true;
193
+ const popup = this.shadowRoot?.querySelector('[part="popup"]');
194
+ if (!popup) {
195
+ this.#finishClose();
125
196
  return;
126
- called = true;
127
- popup.removeEventListener("transitionend", onEnd);
128
- clearTimeout(timer);
129
- this.#finishClose();
130
- };
131
- const onEnd = (e) => {
132
- if (e.propertyName === "opacity") {
133
- done();
134
197
  }
135
- };
136
- popup.addEventListener("transitionend", onEnd);
137
- const timer = setTimeout(done, 200);
138
- }
139
- #finishClose() {
140
- if (!this.#endingStyle && !this.#mounted)
141
- return;
142
- this.#endingStyle = false;
143
- if (!this.keepMounted) {
144
- this.#mounted = false;
198
+ let called = false;
199
+ const done = () => {
200
+ if (called)
201
+ return;
202
+ called = true;
203
+ popup.removeEventListener("transitionend", onEnd);
204
+ clearTimeout(timer);
205
+ this.#finishClose();
206
+ };
207
+ const onEnd = (e) => {
208
+ if (e.propertyName === "opacity") {
209
+ done();
210
+ }
211
+ };
212
+ popup.addEventListener("transitionend", onEnd);
213
+ const timer = setTimeout(done, 200);
145
214
  }
146
- this.#restoreFocus();
147
- }
148
- #trapFocusIn() {
149
- const popup = this.shadowRoot?.querySelector('[part="popup"]');
150
- if (!popup)
151
- return;
152
- if (this.initialFocus) {
153
- const target = popup.querySelector(this.initialFocus);
154
- if (target) {
155
- target.focus();
215
+ #finishClose() {
216
+ if (!this.#endingStyle && !this.#mounted)
156
217
  return;
218
+ this.#endingStyle = false;
219
+ if (!this.keepMounted) {
220
+ this.#mounted = false;
157
221
  }
222
+ this.#restoreFocus();
158
223
  }
159
- const autoEl = queryComposedAutofocus(popup);
160
- if (autoEl) {
161
- autoEl.focus();
162
- return;
224
+ #trapFocusIn() {
225
+ const popup = this.shadowRoot?.querySelector('[part="popup"]');
226
+ if (!popup)
227
+ return;
228
+ if (this.initialFocus) {
229
+ const target = popup.querySelector(this.initialFocus);
230
+ if (target) {
231
+ target.focus();
232
+ return;
233
+ }
234
+ }
235
+ const autoEl = queryComposedAutofocus(popup);
236
+ if (autoEl) {
237
+ autoEl.focus();
238
+ return;
239
+ }
240
+ const focusables = getComposedFocusableElements(popup);
241
+ if (focusables.length > 0) {
242
+ focusables[0].focus();
243
+ return;
244
+ }
245
+ popup.focus();
163
246
  }
164
- const focusables = getComposedFocusableElements(popup);
165
- if (focusables.length > 0) {
166
- focusables[0].focus();
167
- return;
247
+ #restoreFocus() {
248
+ if (this.finalFocus) {
249
+ const target = document.querySelector(this.finalFocus);
250
+ target?.focus();
251
+ return;
252
+ }
253
+ this.#previouslyFocused?.focus();
254
+ this.#previouslyFocused = undefined;
168
255
  }
169
- popup.focus();
170
- }
171
- #restoreFocus() {
172
- if (this.finalFocus) {
173
- const target = document.querySelector(this.finalFocus);
174
- target?.focus();
175
- return;
256
+ #handleKeyDown = (e) => {
257
+ if (e.key === "Escape") {
258
+ e.preventDefault();
259
+ e.stopPropagation();
260
+ this.#ctx.value?.closeDialog();
261
+ }
262
+ if (e.key === "Tab") {
263
+ this.#handleTabTrap(e);
264
+ }
265
+ };
266
+ #handleTabTrap(e) {
267
+ const popup = this.shadowRoot?.querySelector('[part="popup"]');
268
+ if (!popup)
269
+ return;
270
+ const focusables = getComposedFocusableElements(popup);
271
+ if (focusables.length === 0) {
272
+ e.preventDefault();
273
+ return;
274
+ }
275
+ const first = focusables[0];
276
+ const last = focusables[focusables.length - 1];
277
+ const isFirst = first.matches(":focus");
278
+ const isLast = last.matches(":focus");
279
+ const popupHasFocus = !focusables.some((el) => el.matches(":focus"));
280
+ if (e.shiftKey && (isFirst || popupHasFocus)) {
281
+ e.preventDefault();
282
+ last.focus();
283
+ }
284
+ else if (!e.shiftKey && isLast) {
285
+ e.preventDefault();
286
+ first.focus();
287
+ }
176
288
  }
177
- this.#previouslyFocused?.focus();
178
- this.#previouslyFocused = undefined;
179
- }
180
- #handleKeyDown = (e) => {
181
- if (e.key === "Escape") {
182
- e.preventDefault();
183
- e.stopPropagation();
289
+ #handleBackdropClick = () => {
184
290
  this.#ctx.value?.closeDialog();
291
+ };
292
+ willUpdate(changed) {
293
+ if (changed.has("width")) {
294
+ if (this.width)
295
+ this.style.setProperty("--popup-width", this.width);
296
+ else
297
+ this.style.removeProperty("--popup-width");
298
+ }
299
+ if (this.#mounted || this.keepMounted) {
300
+ this.setAttribute("mounted", "");
301
+ }
302
+ else {
303
+ this.removeAttribute("mounted");
304
+ }
185
305
  }
186
- if (e.key === "Tab") {
187
- this.#handleTabTrap(e);
188
- }
189
- };
190
- #handleTabTrap(e) {
191
- const popup = this.shadowRoot?.querySelector('[part="popup"]');
192
- if (!popup)
193
- return;
194
- const focusables = getComposedFocusableElements(popup);
195
- if (focusables.length === 0) {
196
- e.preventDefault();
197
- return;
198
- }
199
- const first = focusables[0];
200
- const last = focusables[focusables.length - 1];
201
- const isFirst = first.matches(":focus");
202
- const isLast = last.matches(":focus");
203
- const popupHasFocus = !focusables.some((el) => el.matches(":focus"));
204
- if (e.shiftKey && (isFirst || popupHasFocus)) {
205
- e.preventDefault();
206
- last.focus();
207
- }
208
- else if (!e.shiftKey && isLast) {
209
- e.preventDefault();
210
- first.focus();
211
- }
212
- }
213
- #handleBackdropClick = () => {
214
- this.#ctx.value?.closeDialog();
215
- };
216
- willUpdate(changed) {
217
- if (changed.has("width")) {
218
- if (this.width)
219
- this.style.setProperty("--popup-width", this.width);
220
- else
221
- this.style.removeProperty("--popup-width");
222
- }
223
- if (this.#mounted || this.keepMounted) {
224
- this.setAttribute("mounted", "");
225
- }
226
- else {
227
- this.removeAttribute("mounted");
228
- }
229
- }
230
- render() {
231
- const isOpen = this.#ctx.value?.open ?? false;
232
- const titleId = this.#ctx.value?.titleId ?? "";
233
- const descriptionId = this.#ctx.value?.descriptionId ?? "";
234
- if (!this.#mounted && !this.keepMounted) {
235
- return html ``;
236
- }
237
- return html `
306
+ render() {
307
+ const isOpen = this.#ctx.value?.open ?? false;
308
+ const titleId = this.#ctx.value?.titleId ?? "";
309
+ const descriptionId = this.#ctx.value?.descriptionId ?? "";
310
+ if (!this.#mounted && !this.keepMounted) {
311
+ return html ``;
312
+ }
313
+ return html `
238
314
  <div
239
315
  part="backdrop"
240
316
  ?data-open="${isOpen && !this.#endingStyle}"
@@ -261,17 +337,7 @@ export class DuiDialogPopup extends LitElement {
261
337
  <slot></slot>
262
338
  </div>
263
339
  `;
264
- }
265
- }
266
- __decorate([
267
- property({ type: Boolean, attribute: "keep-mounted" })
268
- ], DuiDialogPopup.prototype, "keepMounted", null);
269
- __decorate([
270
- property({ attribute: "initial-focus" })
271
- ], DuiDialogPopup.prototype, "initialFocus", null);
272
- __decorate([
273
- property({ attribute: "final-focus" })
274
- ], DuiDialogPopup.prototype, "finalFocus", null);
275
- __decorate([
276
- property()
277
- ], DuiDialogPopup.prototype, "width", null);
340
+ }
341
+ };
342
+ })();
343
+ export { DuiDialogPopup };
@@ -21,8 +21,8 @@ const componentStyles = css `
21
21
  * @slot - Content that triggers the dialog (usually a `<dui-button>`).
22
22
  */
23
23
  export class DuiDialogTrigger extends LitElement {
24
- static { this.tagName = "dui-dialog-trigger"; }
25
- static { this.styles = [base, hostStyles, componentStyles]; }
24
+ static tagName = "dui-dialog-trigger";
25
+ static styles = [base, hostStyles, componentStyles];
26
26
  #ctx = new ContextConsumer(this, {
27
27
  context: dialogContext,
28
28
  subscribe: true,