@deepfuture/dui-components 0.0.11 → 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.
- package/README.md +191 -0
- package/_deprecated/center/center.js +2 -2
- package/_deprecated/center/index.d.ts +3 -1
- package/_deprecated/center/index.js +3 -1
- package/_deprecated/hstack/hstack.js +79 -33
- package/_deprecated/hstack/index.d.ts +3 -1
- package/_deprecated/hstack/index.js +3 -1
- package/_deprecated/page-inset/index.d.ts +3 -1
- package/_deprecated/page-inset/index.js +3 -1
- package/_deprecated/page-inset/page-inset.js +104 -56
- package/_deprecated/vstack/index.d.ts +3 -1
- package/_deprecated/vstack/index.js +3 -1
- package/_deprecated/vstack/vstack.js +61 -19
- package/accordion/accordion-item.js +217 -147
- package/accordion/accordion.js +214 -149
- package/accordion/index.d.ts +5 -2
- package/accordion/index.js +5 -2
- package/alert-dialog/alert-dialog-close.js +2 -2
- package/alert-dialog/alert-dialog-popup.js +230 -166
- package/alert-dialog/alert-dialog-trigger.js +2 -2
- package/alert-dialog/alert-dialog.js +128 -73
- package/alert-dialog/index.d.ts +9 -4
- package/alert-dialog/index.js +9 -4
- package/avatar/avatar.js +175 -115
- package/avatar/index.d.ts +3 -1
- package/avatar/index.js +3 -1
- package/badge/badge.js +2 -2
- package/badge/index.d.ts +3 -1
- package/badge/index.js +3 -1
- package/breadcrumb/breadcrumb-ellipsis.js +2 -2
- package/breadcrumb/breadcrumb-item.js +2 -2
- package/breadcrumb/breadcrumb-link.js +2 -2
- package/breadcrumb/breadcrumb-page.js +2 -2
- package/breadcrumb/breadcrumb-separator.js +2 -2
- package/breadcrumb/breadcrumb.js +2 -2
- package/breadcrumb/index.d.ts +13 -6
- package/breadcrumb/index.js +13 -6
- package/button/button.js +109 -65
- package/button/index.d.ts +3 -1
- package/button/index.js +3 -1
- package/calendar/calendar.js +368 -290
- package/calendar/index.d.ts +3 -1
- package/calendar/index.js +3 -1
- package/checkbox/checkbox-group.js +146 -87
- package/checkbox/checkbox.js +232 -167
- package/checkbox/index.d.ts +5 -2
- package/checkbox/index.js +5 -2
- package/collapsible/collapsible.js +210 -132
- package/collapsible/index.d.ts +3 -1
- package/collapsible/index.js +3 -1
- package/combobox/combobox.js +318 -252
- package/combobox/index.d.ts +3 -1
- package/combobox/index.js +3 -1
- package/command/command-empty.js +67 -25
- package/command/command-group.js +87 -47
- package/command/command-input.js +84 -44
- package/command/command-item.js +168 -124
- package/command/command-list.js +60 -18
- package/command/command-separator.js +2 -2
- package/command/command-shortcut.js +2 -2
- package/command/command.js +297 -232
- package/command/index.d.ts +17 -8
- package/command/index.js +17 -8
- package/data-table/data-table.js +225 -153
- package/data-table/index.d.ts +3 -1
- package/data-table/index.js +3 -1
- package/dialog/dialog-close.js +2 -2
- package/dialog/dialog-popup.js +247 -181
- package/dialog/dialog-trigger.js +2 -2
- package/dialog/dialog.js +128 -73
- package/dialog/index.d.ts +9 -4
- package/dialog/index.js +9 -4
- package/dropzone/dropzone.js +310 -249
- package/dropzone/index.d.ts +3 -1
- package/dropzone/index.js +3 -1
- package/icon/icon.js +2 -2
- package/icon/index.d.ts +3 -1
- package/icon/index.js +3 -1
- package/input/index.d.ts +3 -1
- package/input/index.js +3 -1
- package/input/input.js +204 -143
- package/link/index.d.ts +3 -1
- package/link/index.js +3 -1
- package/link/link.js +62 -24
- package/menu/index.d.ts +5 -2
- package/menu/index.js +5 -2
- package/menu/menu-item.js +66 -24
- package/menu/menu.js +189 -136
- package/menubar/index.d.ts +3 -1
- package/menubar/index.js +3 -1
- package/menubar/menubar.js +142 -91
- package/number-field/index.d.ts +3 -1
- package/number-field/index.js +3 -1
- package/number-field/number-field.js +277 -204
- package/package.json +5 -4
- package/popover/index.d.ts +9 -4
- package/popover/index.js +9 -4
- package/popover/popover-close.js +2 -2
- package/popover/popover-popup.js +126 -76
- package/popover/popover-trigger.js +2 -2
- package/popover/popover.js +181 -120
- package/portal/index.d.ts +3 -1
- package/portal/index.js +3 -1
- package/portal/portal.js +128 -86
- package/preview-card/index.d.ts +7 -3
- package/preview-card/index.js +7 -3
- package/preview-card/preview-card-popup.js +114 -66
- package/preview-card/preview-card-trigger.js +2 -2
- package/preview-card/preview-card.js +211 -142
- package/progress/index.d.ts +3 -1
- package/progress/index.js +3 -1
- package/progress/progress.js +91 -45
- package/radio/index.d.ts +5 -2
- package/radio/index.js +5 -2
- package/radio/radio-group.js +153 -90
- package/radio/radio.js +137 -94
- package/scroll-area/index.d.ts +3 -1
- package/scroll-area/index.js +3 -1
- package/scroll-area/scroll-area.js +382 -276
- package/select/index.d.ts +3 -1
- package/select/index.js +3 -1
- package/select/select.js +260 -203
- package/separator/index.d.ts +3 -1
- package/separator/index.js +3 -1
- package/separator/separator.js +60 -18
- package/sidebar/index.d.ts +27 -13
- package/sidebar/index.js +32 -13
- package/sidebar/sidebar-content.js +2 -2
- package/sidebar/sidebar-footer.js +2 -2
- package/sidebar/sidebar-group-label.js +2 -2
- package/sidebar/sidebar-group.js +2 -2
- package/sidebar/sidebar-header.js +2 -2
- package/sidebar/sidebar-inset.js +2 -2
- package/sidebar/sidebar-menu-button.js +118 -74
- package/sidebar/sidebar-menu-item.js +2 -2
- package/sidebar/sidebar-menu.js +2 -2
- package/sidebar/sidebar-provider.js +202 -129
- package/sidebar/sidebar-separator.js +2 -2
- package/sidebar/sidebar-trigger.js +2 -2
- package/sidebar/sidebar.js +150 -85
- package/slider/index.d.ts +3 -1
- package/slider/index.js +3 -1
- package/slider/slider.js +217 -159
- package/spinner/index.d.ts +3 -1
- package/spinner/index.js +3 -1
- package/spinner/spinner.js +70 -28
- package/switch/index.d.ts +3 -1
- package/switch/index.js +3 -1
- package/switch/switch.js +174 -111
- package/tabs/index.d.ts +11 -5
- package/tabs/index.js +11 -5
- package/tabs/tab.js +89 -47
- package/tabs/tabs-indicator.js +2 -2
- package/tabs/tabs-list.js +92 -54
- package/tabs/tabs-panel.js +90 -44
- package/tabs/tabs.js +130 -71
- package/textarea/index.d.ts +3 -1
- package/textarea/index.js +3 -1
- package/textarea/textarea.js +153 -95
- package/toggle/index.d.ts +5 -2
- package/toggle/index.js +5 -2
- package/toggle/toggle-group.js +184 -125
- package/toggle/toggle.js +131 -76
- package/toolbar/index.d.ts +3 -1
- package/toolbar/index.js +3 -1
- package/toolbar/toolbar.js +79 -33
- package/tooltip/index.d.ts +7 -3
- package/tooltip/index.js +7 -3
- package/tooltip/tooltip-popup.js +108 -60
- package/tooltip/tooltip-trigger.js +93 -55
- package/tooltip/tooltip.js +225 -154
- package/trunc/index.d.ts +3 -1
- package/trunc/index.js +3 -1
- package/trunc/trunc.js +78 -34
- package/accordion/register.d.ts +0 -1
- package/accordion/register.js +0 -8
- package/alert-dialog/register.d.ts +0 -1
- package/alert-dialog/register.js +0 -16
- package/avatar/register.d.ts +0 -1
- package/avatar/register.js +0 -4
- package/badge/register.d.ts +0 -1
- package/badge/register.js +0 -4
- package/breadcrumb/register.d.ts +0 -1
- package/breadcrumb/register.js +0 -14
- package/button/register.d.ts +0 -1
- package/button/register.js +0 -4
- package/calendar/register.d.ts +0 -1
- package/calendar/register.js +0 -4
- package/checkbox/register.d.ts +0 -1
- package/checkbox/register.js +0 -8
- package/collapsible/register.d.ts +0 -1
- package/collapsible/register.js +0 -4
- package/combobox/register.d.ts +0 -1
- package/combobox/register.js +0 -4
- package/command/register.d.ts +0 -1
- package/command/register.js +0 -22
- package/data-table/register.d.ts +0 -1
- package/data-table/register.js +0 -4
- package/dialog/register.d.ts +0 -1
- package/dialog/register.js +0 -16
- package/dropzone/register.d.ts +0 -1
- package/dropzone/register.js +0 -4
- package/icon/register.d.ts +0 -1
- package/icon/register.js +0 -4
- package/input/register.d.ts +0 -1
- package/input/register.js +0 -4
- package/link/register.d.ts +0 -1
- package/link/register.js +0 -4
- package/menu/register.d.ts +0 -1
- package/menu/register.js +0 -8
- package/menubar/register.d.ts +0 -1
- package/menubar/register.js +0 -4
- package/number-field/register.d.ts +0 -1
- package/number-field/register.js +0 -4
- package/popover/register.d.ts +0 -1
- package/popover/register.js +0 -16
- package/portal/register.d.ts +0 -1
- package/portal/register.js +0 -4
- package/preview-card/register.d.ts +0 -1
- package/preview-card/register.js +0 -12
- package/progress/register.d.ts +0 -1
- package/progress/register.js +0 -4
- package/radio/register.d.ts +0 -1
- package/radio/register.js +0 -8
- package/scroll-area/register.d.ts +0 -1
- package/scroll-area/register.js +0 -4
- package/select/register.d.ts +0 -1
- package/select/register.js +0 -4
- package/separator/register.d.ts +0 -1
- package/separator/register.js +0 -4
- package/sidebar/register.d.ts +0 -1
- package/sidebar/register.js +0 -52
- package/slider/register.d.ts +0 -1
- package/slider/register.js +0 -4
- package/spinner/register.d.ts +0 -1
- package/spinner/register.js +0 -4
- package/switch/register.d.ts +0 -1
- package/switch/register.js +0 -4
- package/tabs/register.d.ts +0 -1
- package/tabs/register.js +0 -10
- package/textarea/register.d.ts +0 -1
- package/textarea/register.js +0 -4
- package/toggle/register.d.ts +0 -1
- package/toggle/register.js +0 -8
- package/toolbar/register.d.ts +0 -1
- package/toolbar/register.js +0 -4
- package/tooltip/register.d.ts +0 -1
- package/tooltip/register.js +0 -12
- package/trunc/register.d.ts +0 -1
- package/trunc/register.js +0 -4
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/alert-dialog */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
280
|
+
willUpdate() {
|
|
281
|
+
if (this.#mounted || this.keepMounted) {
|
|
282
|
+
this.setAttribute("mounted", "");
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
this.removeAttribute("mounted");
|
|
286
|
+
}
|
|
223
287
|
}
|
|
224
|
-
|
|
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
|
-
|
|
253
|
-
|
|
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
|
|
25
|
-
static
|
|
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,
|