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