@editora/ui-core 0.1.10 → 0.1.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 +5 -5
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +39 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-icon.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +2 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +2 -2
- package/dist/context-menu.esm.js +2 -2
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +2 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +100 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +98 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +76 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +132 -101
- package/dist/date-time-utils-378ecc21.js +1 -0
- package/dist/{date-time-utils-bdceb7af.mjs → date-time-utils-a8b17ea7.mjs} +128 -102
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +3 -13
- package/dist/floating-toolbar.esm.js +17 -27
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/{icon-eaa486b3.js → icon-9e9da03b.js} +4 -4
- package/dist/{icon-9ed13093.mjs → icon-e2a85cc1.mjs} +22 -18
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +246 -244
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/{portal-1cf392ca.mjs → portal-9060f7a6.mjs} +7 -7
- package/dist/portal-d9bae456.js +1 -0
- package/dist/{positioner-fbd61bf1.mjs → positioner-16f3cca1.mjs} +16 -16
- package/dist/positioner-43b1c75a.js +1 -0
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-5f282bc8.js → runtime-668914fe.js} +1 -1
- package/dist/{runtime-4ac0107b.mjs → runtime-864efe2f.mjs} +1 -1
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +2 -2
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +137 -62
- package/dist/split-button.esm.js +235 -145
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +14 -14
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +99 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +1 -1
- package/package.json +2 -2
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import { a as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { p as T, c as M, s as O, e as Y, a as A } from "./calendar-2c11b824.mjs";
|
|
2
|
+
import { a as z } from "./scroll-lock-31da444f.mjs";
|
|
3
|
+
const N = /* @__PURE__ */ new Map(), P = 24;
|
|
4
|
+
function D(t, n, e) {
|
|
5
5
|
return Math.max(n, Math.min(e, t));
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function u(t) {
|
|
8
8
|
return String(t).padStart(2, "0");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function b(t) {
|
|
11
11
|
if (!/^-?\d+$/.test(t))
|
|
12
12
|
return null;
|
|
13
13
|
const n = Number(t);
|
|
14
14
|
return Number.isFinite(n) ? Math.trunc(n) : null;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function x(t) {
|
|
17
17
|
return t.replace(/[.\-]/g, "/").replace(/\s+/g, " ").trim();
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function k(t) {
|
|
20
20
|
const n = [];
|
|
21
21
|
for (let e = 0; e < 12; e += 1)
|
|
22
22
|
n.push(
|
|
@@ -27,7 +27,7 @@ function I(t) {
|
|
|
27
27
|
);
|
|
28
28
|
return n;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function B(t) {
|
|
31
31
|
const n = [];
|
|
32
32
|
for (let e = 0; e < 12; e += 1)
|
|
33
33
|
n.push(
|
|
@@ -38,114 +38,127 @@ function O(t) {
|
|
|
38
38
|
);
|
|
39
39
|
return n;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function H(t, n = !1) {
|
|
42
42
|
if (t == null)
|
|
43
43
|
return n;
|
|
44
44
|
const e = t.trim().toLowerCase();
|
|
45
45
|
return e ? e !== "false" && e !== "0" && e !== "off" && e !== "no" : !0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Z(t, n) {
|
|
48
|
+
const e = typeof t.composedPath == "function" ? t.composedPath() : [];
|
|
49
|
+
for (const o of n)
|
|
50
|
+
if (o && e.includes(o))
|
|
51
|
+
return !0;
|
|
52
|
+
const r = t.target;
|
|
53
|
+
if (!(r instanceof Node))
|
|
54
|
+
return !1;
|
|
55
|
+
for (const o of n)
|
|
56
|
+
if (o instanceof Node && o.contains(r))
|
|
57
|
+
return !0;
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
function _(t) {
|
|
48
61
|
const n = (t || "").trim();
|
|
49
62
|
return n || (typeof navigator < "u" && navigator.language ? navigator.language : "en-US");
|
|
50
63
|
}
|
|
51
|
-
function
|
|
64
|
+
function h(t) {
|
|
52
65
|
if (!t)
|
|
53
66
|
return null;
|
|
54
|
-
const n =
|
|
55
|
-
return n ? `${n.y}-${
|
|
67
|
+
const n = T(t);
|
|
68
|
+
return n ? `${n.y}-${u(n.m)}-${u(n.d)}` : null;
|
|
56
69
|
}
|
|
57
|
-
function
|
|
70
|
+
function y(t) {
|
|
58
71
|
if (!t)
|
|
59
72
|
return null;
|
|
60
73
|
const n = /^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t.trim());
|
|
61
74
|
if (!n)
|
|
62
75
|
return null;
|
|
63
|
-
const e =
|
|
76
|
+
const e = h(n[1]);
|
|
64
77
|
if (!e)
|
|
65
78
|
return null;
|
|
66
|
-
const r =
|
|
79
|
+
const r = w(n[2], !0);
|
|
67
80
|
if (!r)
|
|
68
81
|
return null;
|
|
69
82
|
const o = n[2].split(":").length === 3;
|
|
70
83
|
return { date: e, time: S(r, o) };
|
|
71
84
|
}
|
|
72
|
-
function
|
|
85
|
+
function X(t, n) {
|
|
73
86
|
if (!t || !n)
|
|
74
87
|
return null;
|
|
75
|
-
const e =
|
|
88
|
+
const e = h(t), r = w(n, !0);
|
|
76
89
|
return !e || !r ? null : `${e}T${S(r, n.split(":").length >= 3)}`;
|
|
77
90
|
}
|
|
78
|
-
function
|
|
91
|
+
function j(t) {
|
|
79
92
|
if (!t)
|
|
80
93
|
return null;
|
|
81
|
-
const n =
|
|
94
|
+
const n = h(t);
|
|
82
95
|
if (n)
|
|
83
96
|
return n;
|
|
84
|
-
const e =
|
|
97
|
+
const e = y(t);
|
|
85
98
|
return (e == null ? void 0 : e.date) || null;
|
|
86
99
|
}
|
|
87
|
-
function
|
|
100
|
+
function G(t) {
|
|
88
101
|
if (!t)
|
|
89
102
|
return null;
|
|
90
|
-
const n =
|
|
103
|
+
const n = y(t);
|
|
91
104
|
if (n)
|
|
92
105
|
return n;
|
|
93
|
-
const e =
|
|
106
|
+
const e = h(t);
|
|
94
107
|
return e ? { date: e, time: "00:00" } : null;
|
|
95
108
|
}
|
|
96
|
-
function
|
|
97
|
-
const r =
|
|
109
|
+
function W(t, n, e) {
|
|
110
|
+
const r = T(t);
|
|
98
111
|
if (!r)
|
|
99
112
|
return t;
|
|
100
113
|
const o = `${n}::${JSON.stringify(e || {})}`;
|
|
101
|
-
let i =
|
|
114
|
+
let i = N.get(o);
|
|
102
115
|
return i || (i = new Intl.DateTimeFormat(n, {
|
|
103
116
|
year: "numeric",
|
|
104
117
|
month: "short",
|
|
105
118
|
day: "2-digit",
|
|
106
119
|
timeZone: "UTC",
|
|
107
120
|
...e || {}
|
|
108
|
-
}),
|
|
121
|
+
}), N.set(o, i)), i.format(new Date(Date.UTC(r.y, r.m - 1, r.d)));
|
|
109
122
|
}
|
|
110
|
-
function
|
|
123
|
+
function J(t, n, e, r) {
|
|
111
124
|
if (!t)
|
|
112
125
|
return "";
|
|
113
126
|
if (e === "iso")
|
|
114
127
|
return t;
|
|
115
128
|
if (e === "custom" && r) {
|
|
116
|
-
const o =
|
|
129
|
+
const o = T(t);
|
|
117
130
|
if (!o)
|
|
118
131
|
return t;
|
|
119
|
-
const i =
|
|
120
|
-
return r.replace(/YYYY/g, String(o.y)).replace(/MMM/g, i[o.m - 1] || "").replace(/MMMM/g,
|
|
132
|
+
const i = k(n), s = B(n);
|
|
133
|
+
return r.replace(/YYYY/g, String(o.y)).replace(/MMM/g, i[o.m - 1] || "").replace(/MMMM/g, s[o.m - 1] || "").replace(/MM/g, u(o.m)).replace(/DD/g, u(o.d));
|
|
121
134
|
}
|
|
122
|
-
return
|
|
135
|
+
return W(t, n);
|
|
123
136
|
}
|
|
124
|
-
function
|
|
125
|
-
const e =
|
|
137
|
+
function K(t, n) {
|
|
138
|
+
const e = h(t.trim());
|
|
126
139
|
if (e)
|
|
127
140
|
return e;
|
|
128
|
-
const r =
|
|
141
|
+
const r = x(t);
|
|
129
142
|
if (!r)
|
|
130
143
|
return null;
|
|
131
|
-
const o =
|
|
144
|
+
const o = h(r);
|
|
132
145
|
if (o)
|
|
133
146
|
return o;
|
|
134
|
-
const i = r.split("/").map((
|
|
147
|
+
const i = r.split("/").map((f) => f.trim()).filter(Boolean);
|
|
135
148
|
if (i.length !== 3)
|
|
136
149
|
return null;
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
150
|
+
const s = b(i[0]), a = b(i[1]), l = b(i[2]);
|
|
151
|
+
if (s == null || a == null || l == null)
|
|
139
152
|
return null;
|
|
140
|
-
let c =
|
|
153
|
+
let c = l;
|
|
141
154
|
c < 100 && (c += c >= 70 ? 1900 : 2e3);
|
|
142
|
-
const
|
|
143
|
-
if (c < 1e3 ||
|
|
155
|
+
const m = n.toLowerCase().startsWith("en-us"), d = m ? s : a, p = m ? a : s;
|
|
156
|
+
if (c < 1e3 || d < 1 || d > 12 || p < 1 || p > 31)
|
|
144
157
|
return null;
|
|
145
|
-
const
|
|
146
|
-
return
|
|
158
|
+
const g = `${c}-${u(d)}-${u(p)}`;
|
|
159
|
+
return h(g);
|
|
147
160
|
}
|
|
148
|
-
function
|
|
161
|
+
function w(t, n) {
|
|
149
162
|
const e = t.trim().toLowerCase();
|
|
150
163
|
if (!e)
|
|
151
164
|
return null;
|
|
@@ -153,8 +166,8 @@ function f(t, n) {
|
|
|
153
166
|
if (!r)
|
|
154
167
|
return null;
|
|
155
168
|
let o = Number(r[1]);
|
|
156
|
-
const i = Number(r[2] ?? "0"),
|
|
157
|
-
if (!Number.isFinite(o) || !Number.isFinite(i) || !Number.isFinite(
|
|
169
|
+
const i = Number(r[2] ?? "0"), s = Number(r[3] ?? "0");
|
|
170
|
+
if (!Number.isFinite(o) || !Number.isFinite(i) || !Number.isFinite(s) || i < 0 || i > 59 || s < 0 || s > 59 || !n && s !== 0)
|
|
158
171
|
return null;
|
|
159
172
|
const a = r[4];
|
|
160
173
|
if (a) {
|
|
@@ -162,19 +175,19 @@ function f(t, n) {
|
|
|
162
175
|
return null;
|
|
163
176
|
a === "pm" && o < 12 && (o += 12), a === "am" && o === 12 && (o = 0);
|
|
164
177
|
}
|
|
165
|
-
return o < 0 || o > 23 ? null : { hours: o, minutes: i, seconds:
|
|
178
|
+
return o < 0 || o > 23 ? null : { hours: o, minutes: i, seconds: s };
|
|
166
179
|
}
|
|
167
180
|
function S(t, n = !1) {
|
|
168
181
|
if (!t)
|
|
169
182
|
return "";
|
|
170
|
-
const e =
|
|
183
|
+
const e = u(D(t.hours, 0, 23)), r = u(D(t.minutes, 0, 59));
|
|
171
184
|
if (!n)
|
|
172
185
|
return `${e}:${r}`;
|
|
173
|
-
const o =
|
|
186
|
+
const o = u(D(t.seconds, 0, 59));
|
|
174
187
|
return `${e}:${r}:${o}`;
|
|
175
188
|
}
|
|
176
|
-
function
|
|
177
|
-
const e =
|
|
189
|
+
function V(t, n) {
|
|
190
|
+
const e = w(t, !0);
|
|
178
191
|
if (!e)
|
|
179
192
|
return t;
|
|
180
193
|
const r = /* @__PURE__ */ new Date();
|
|
@@ -185,53 +198,65 @@ function P(t, n) {
|
|
|
185
198
|
hour12: !0
|
|
186
199
|
}).format(r);
|
|
187
200
|
}
|
|
188
|
-
function
|
|
189
|
-
const e =
|
|
201
|
+
function $(t, n) {
|
|
202
|
+
const e = w(t, !0), r = w(n, !0);
|
|
190
203
|
if (!e || !r)
|
|
191
204
|
return t.localeCompare(n);
|
|
192
205
|
const o = e.hours * 3600 + e.minutes * 60 + e.seconds, i = r.hours * 3600 + r.minutes * 60 + r.seconds;
|
|
193
206
|
return o - i;
|
|
194
207
|
}
|
|
195
|
-
function
|
|
196
|
-
const r =
|
|
208
|
+
function Q(t, n, e) {
|
|
209
|
+
const r = w(t, !0);
|
|
197
210
|
if (!r)
|
|
198
211
|
return t;
|
|
199
212
|
let o = S(r, t.split(":").length >= 3);
|
|
200
|
-
return n &&
|
|
213
|
+
return n && $(o, n) < 0 && (o = n), e && $(o, e) > 0 && (o = e), o;
|
|
201
214
|
}
|
|
202
|
-
function
|
|
215
|
+
function R(t, n, e) {
|
|
203
216
|
let r = t;
|
|
204
|
-
return n &&
|
|
217
|
+
return n && M(r, n) < 0 && (r = n), e && M(r, e) > 0 && (r = e), r;
|
|
205
218
|
}
|
|
206
|
-
function
|
|
207
|
-
const e =
|
|
219
|
+
function tt(t, n) {
|
|
220
|
+
const e = y(t), r = y(n);
|
|
208
221
|
if (!e || !r)
|
|
209
222
|
return t.localeCompare(n);
|
|
210
|
-
const o =
|
|
211
|
-
return o !== 0 ? o :
|
|
223
|
+
const o = M(e.date, r.date);
|
|
224
|
+
return o !== 0 ? o : $(e.time, r.time);
|
|
212
225
|
}
|
|
213
|
-
function
|
|
214
|
-
const n =
|
|
226
|
+
function nt(t) {
|
|
227
|
+
const n = T(t);
|
|
215
228
|
if (!n)
|
|
216
229
|
return { start: t, end: t };
|
|
217
|
-
const e =
|
|
230
|
+
const e = O(n.y, n.m), r = Y(n.y, n.m);
|
|
218
231
|
return {
|
|
219
|
-
start: `${e.y}-${
|
|
220
|
-
end: `${r.y}-${
|
|
232
|
+
start: `${e.y}-${u(e.m)}-${u(e.d)}`,
|
|
233
|
+
end: `${r.y}-${u(r.m)}-${u(r.d)}`
|
|
221
234
|
};
|
|
222
235
|
}
|
|
223
|
-
function
|
|
224
|
-
const e =
|
|
236
|
+
function et(t, n) {
|
|
237
|
+
const e = D(n, 1, 366);
|
|
225
238
|
return {
|
|
226
|
-
start:
|
|
239
|
+
start: A(t, -(e - 1)),
|
|
227
240
|
end: t
|
|
228
241
|
};
|
|
229
242
|
}
|
|
230
|
-
function
|
|
231
|
-
const
|
|
232
|
-
|
|
243
|
+
function rt(t, n, e = 8, r = 8, o = null) {
|
|
244
|
+
const i = typeof window < "u" ? window.innerWidth : 1200, s = typeof window < "u" ? window.innerHeight : 800, a = typeof window < "u" && window.scrollY || 0, l = typeof window < "u" && window.scrollX || 0, c = s - t.bottom - r - e, m = t.top - r - e, d = c >= n.height, p = m >= n.height, g = o === "top" ? "top" : "bottom";
|
|
245
|
+
let f;
|
|
246
|
+
if (d && !p)
|
|
247
|
+
f = "bottom";
|
|
248
|
+
else if (p && !d)
|
|
249
|
+
f = "top";
|
|
250
|
+
else if (p && d)
|
|
251
|
+
f = g;
|
|
252
|
+
else {
|
|
253
|
+
const C = g === "bottom" ? c : m, I = g === "bottom" ? m : c;
|
|
254
|
+
C > 0 && I <= C + P ? f = g : f = c >= m ? "bottom" : "top";
|
|
255
|
+
}
|
|
256
|
+
const v = f === "bottom" ? t.bottom + r + a : t.top - n.height - r + a, L = t.left + l, F = l + i - n.width - e, U = D(L, l + e, Math.max(l + e, F));
|
|
257
|
+
return { top: v, left: U, placement: f };
|
|
233
258
|
}
|
|
234
|
-
function
|
|
259
|
+
function ot(t) {
|
|
235
260
|
let n = 0;
|
|
236
261
|
return { run: () => {
|
|
237
262
|
n || (n = requestAnimationFrame(() => {
|
|
@@ -241,33 +266,34 @@ function Q(t) {
|
|
|
241
266
|
n && (cancelAnimationFrame(n), n = 0);
|
|
242
267
|
} };
|
|
243
268
|
}
|
|
244
|
-
function
|
|
269
|
+
function it(t) {
|
|
245
270
|
return (t || "popover") === "inline" || typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(max-width: 639px)").matches;
|
|
246
271
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
272
|
+
function st() {
|
|
273
|
+
return z();
|
|
249
274
|
}
|
|
250
275
|
export {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
R as a,
|
|
277
|
+
_ as b,
|
|
278
|
+
rt as c,
|
|
279
|
+
K as d,
|
|
280
|
+
Z as e,
|
|
281
|
+
J as f,
|
|
282
|
+
et as g,
|
|
283
|
+
nt as h,
|
|
284
|
+
H as i,
|
|
285
|
+
X as j,
|
|
286
|
+
y as k,
|
|
287
|
+
st as l,
|
|
288
|
+
tt as m,
|
|
289
|
+
h as n,
|
|
290
|
+
G as o,
|
|
291
|
+
j as p,
|
|
292
|
+
w as q,
|
|
293
|
+
ot as r,
|
|
294
|
+
it as s,
|
|
295
|
+
V as t,
|
|
296
|
+
S as u,
|
|
297
|
+
Q as v,
|
|
298
|
+
$ as w
|
|
273
299
|
};
|
package/dist/dialog.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("./ElementBase-1b301e7f.js"),F=require("./scroll-lock-d7b0df21.js"),M=require("./dismissable-layer-193e3bed.js"),R=require("./focus-scope-2b12b4e7.js"),P=`
|
|
2
2
|
:host {
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
isolation: isolate;
|
|
9
9
|
color-scheme: light dark;
|
|
10
10
|
--ui-dialog-backdrop: color-mix(in srgb, #020617 58%, transparent);
|
|
11
|
+
--ui-dialog-backdrop-filter: none;
|
|
11
12
|
--ui-dialog-bg: linear-gradient(
|
|
12
13
|
180deg,
|
|
13
14
|
color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent) 0%,
|
|
@@ -65,11 +66,16 @@
|
|
|
65
66
|
box-sizing: border-box;
|
|
66
67
|
pointer-events: auto;
|
|
67
68
|
background: var(--ui-dialog-backdrop);
|
|
68
|
-
backdrop-filter:
|
|
69
|
+
-webkit-backdrop-filter: var(--ui-dialog-backdrop-filter);
|
|
70
|
+
backdrop-filter: var(--ui-dialog-backdrop-filter);
|
|
69
71
|
opacity: 0;
|
|
70
72
|
transition: opacity var(--ui-dialog-duration) var(--ui-dialog-easing);
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
.overlay[hidden] {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
.overlay[data-open='true'] {
|
|
74
80
|
opacity: 1;
|
|
75
81
|
}
|
|
@@ -87,17 +93,19 @@
|
|
|
87
93
|
color: var(--ui-dialog-color);
|
|
88
94
|
box-shadow: var(--ui-dialog-shadow);
|
|
89
95
|
padding: var(--ui-dialog-padding-y) var(--ui-dialog-padding-x);
|
|
90
|
-
transform:
|
|
96
|
+
transform: translate3d(0, 12px, 0) scale(0.985);
|
|
91
97
|
opacity: 0;
|
|
92
98
|
transition:
|
|
93
99
|
transform var(--ui-dialog-duration) var(--ui-dialog-easing),
|
|
94
100
|
opacity var(--ui-dialog-duration) var(--ui-dialog-easing),
|
|
95
101
|
border-color var(--ui-dialog-duration) var(--ui-dialog-easing),
|
|
96
102
|
box-shadow var(--ui-dialog-duration) var(--ui-dialog-easing);
|
|
103
|
+
will-change: transform, opacity;
|
|
104
|
+
backface-visibility: hidden;
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
.overlay[data-open='true'] .panel {
|
|
100
|
-
transform:
|
|
108
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
101
109
|
opacity: 1;
|
|
102
110
|
}
|
|
103
111
|
|
|
@@ -364,43 +372,44 @@
|
|
|
364
372
|
box-shadow: none;
|
|
365
373
|
}
|
|
366
374
|
}
|
|
367
|
-
`,R='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function b(u,t){if(u==null)return t;const i=u.trim().toLowerCase();return i!=="false"&&i!=="0"&&i!=="off"}function a(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function S(){return typeof window<"u"&&typeof document<"u"}const E=class n extends I.ElementBase{constructor(){super(),this._isActive=!1,this._uid=Math.random().toString(36).slice(2,10),this._dialogId=this._uid,this._lastFocused=null,this._terminalEmitted=!1,this._closeMeta=null,this._runtimeError="",this._config={},this._dismissableLayer=null,this._focusScope=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onSubmit=this._onSubmit.bind(this)}static get observedAttributes(){return["open","headless","title","description","closable","dismissible","close-on-overlay","close-on-backdrop","close-on-esc","lock-while-loading","size","state","role","initial-focus","submit-text","cancel-text","loading-text","error-message","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.addEventListener("submit",this._onSubmit),this._syncFromAttributes(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("submit",this._onSubmit),this._isActive&&!this._terminalEmitted&&this.close("dismiss","unmount"),this._destroyRuntimeControllers(),this._deactivate(),super.disconnectedCallback()}attributeChangedCallback(t,i,e){if(i!==e){if(t==="open"){this._syncOpenState();return}t==="state"&&e!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get dismissible(){return b(this.getAttribute("dismissible")??this.getAttribute("closable"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t)),this.setAttribute("closable",String(t))}get closeOnOverlay(){return b(this.getAttribute("close-on-overlay")??this.getAttribute("close-on-backdrop"),!0)}set closeOnOverlay(t){this.setAttribute("close-on-overlay",String(t)),this.setAttribute("close-on-backdrop",String(t))}get closeOnEsc(){return b(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get lockWhileLoading(){return b(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"||t==="success"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnOverlay!=null&&(this.closeOnOverlay=!!this._config.closeOnOverlay),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.size&&this.setAttribute("size",this._config.size),this._config.role&&this.setAttribute("role",this._config.role),this._config.initialFocus&&this.setAttribute("initial-focus",this._config.initialFocus),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.errorMessage&&(this._runtimeError=this._config.errorMessage),this.requestRender()}openDialog(){this.setAttribute("open","")}closeDialog(t="programmatic"){if(!this.hasAttribute("open"))return;const i=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i);const e=new CustomEvent("ui-request-close",{detail:{id:this.dialogId||this._uid,reason:t},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(e),!(i.defaultPrevented||e.defaultPrevented)){if(t==="submit"){this.close("submit");return}if(t==="cancel"){this.close("cancel");return}if(t==="overlay"){this.close("dismiss","overlay");return}if(t==="escape"){this.close("dismiss","esc");return}if(t==="button"){this.close("dismiss","close-icon");return}this.close("dismiss","programmatic")}}close(t="dismiss",i,e){this._terminalEmitted||(this._closeMeta={action:t,source:i,reason:e},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}_syncFromAttributes(){!this.hasAttribute("dismissible")&&this.hasAttribute("closable")&&this.setAttribute("dismissible",this.getAttribute("closable")||"true"),!this.hasAttribute("closable")&&this.hasAttribute("dismissible")&&this.setAttribute("closable",this.getAttribute("dismissible")||"true"),!this.hasAttribute("close-on-overlay")&&this.hasAttribute("close-on-backdrop")&&this.setAttribute("close-on-overlay",this.getAttribute("close-on-backdrop")||"true"),!this.hasAttribute("close-on-backdrop")&&this.hasAttribute("close-on-overlay")&&this.setAttribute("close-on-backdrop",this.getAttribute("close-on-overlay")||"true"),this.hasAttribute("role")||this.setAttribute("role","dialog")}_syncOpenState(){const t=this.hasAttribute("open");if(t&&!this._isActive){this._activate();return}!t&&this._isActive&&this._deactivate()}_activate(){this._isActive=!0,this._terminalEmitted=!1,this._closeMeta=null,n._openStack.includes(this)||n._openStack.push(this),this._lastFocused=document.activeElement||null,w.acquireBodyScrollLock();const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this.requestRender()}_deactivate(){if(!this._isActive)return;this._isActive=!1,this._destroyRuntimeControllers();const t=n._openStack.lastIndexOf(this);if(t>=0&&n._openStack.splice(t,1),w.releaseBodyScrollLock(),!this._terminalEmitted){const e=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;e.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:e.source||"abort",reason:e.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:e.action,source:e.source,reason:e.reason}),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0})),this._terminalEmitted=!0,this._closeMeta=null}const i=this._lastFocused;this._lastFocused=null,i&&this._canRestoreFocus(i)&&setTimeout(()=>{try{this._canRestoreFocus(i)&&i.focus()}catch{}},0),this.requestRender()}_dispatchWithLegacy(t,i,e,s=!1){const o=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const r=new CustomEvent(i,{detail:e,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(r),o}_isTopMost(){if(!this._isActive)return!1;const t=n._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".panel")}_canRestoreFocus(t){if(!t||!t.isConnected||t.disabled||t.getAttribute("aria-hidden")==="true")return!1;if(!S())return!0;const i=window.getComputedStyle(t);return i.display!=="none"&&i.visibility!=="hidden"}_collectFocusable(t){return Array.from(t.querySelectorAll(R)).filter(i=>{if(i.disabled||i.getAttribute("aria-hidden")==="true")return!1;const s=S()?window.getComputedStyle(i):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";if(i){const r=t.querySelector(i);if(r&&typeof r.focus=="function"){r.focus();return}}const e=this._collectFocusable(t),o=e.find(r=>r.hasAttribute("autofocus"))||e[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_onFocusIn(t){!this.open||this._isTopMost()}_handleTab(t){t.key}_destroyRuntimeControllers(){var t,i;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,(i=this._focusScope)==null||i.destroy(),this._focusScope=null}_syncRuntimeControllers(){if(this._destroyRuntimeControllers(),!this.open||!this._isTopMost())return;const t=this._queryPanel();t&&(this._dismissableLayer=B.createDismissableLayer({node:t,closeOnEscape:this.closeOnEsc,closeOnPointerOutside:this.closeOnOverlay,closeOnFocusOutside:!1,onBeforeDismiss:(i,e)=>this._isInteractionLocked()?!1:i==="escape-key"?(this.closeDialog("escape"),!1):(i==="outside-pointer"&&this.closeDialog("overlay"),!1)}),this._focusScope=z.createFocusScope({node:t,trapped:!0,loop:!0,restoreFocus:!1,autoFocus:"first",initialFocus:()=>{const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";return i?t.querySelector(i):null}}))}_collectFormData(t){const i=this._queryPanel(),e=t||this.querySelector("form")||(i==null?void 0:i.querySelector("form"))||null;if(!(e instanceof HTMLFormElement)||typeof FormData>"u")return;const s=new FormData(e),o={};for(const[r,h]of s.entries()){const l=String(h);if(o[r]==null){o[r]=l;continue}const c=o[r];Array.isArray(c)?c.push(l):o[r]=[c,l]}return Object.keys(o).length?o:void 0}_resolveSubmitForm(t){var s;if(t){const o=t.closest("form");if(o instanceof HTMLFormElement&&this.contains(o))return o}const i=this.querySelector("form");if(i instanceof HTMLFormElement)return i;const e=(s=this._queryPanel())==null?void 0:s.querySelector("form");return e instanceof HTMLFormElement?e:null}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,i){if(!this._isInteractionLocked()){if(t==="overlay"){this.closeDialog("overlay");return}if(t==="esc"){this.closeDialog("escape");return}if(t==="close-icon"){this.closeDialog("button");return}this.close("dismiss",t,i)}}_handleSubmit(t){if(this._isInteractionLocked())return;const i=t??this._resolveSubmitForm();if(i&&typeof i.reportValidity=="function"&&!i.reportValidity())return;const e={id:this.dialogId||this._uid,formData:this._collectFormData(i)};this._dispatchWithLegacy("ui-submit","submit",e,!0).defaultPrevented||this.closeDialog("submit")}_handleCancel(){this._isInteractionLocked()||this.closeDialog("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const i=t.target;if(i){if(!i.closest(".panel")&&i.closest(".overlay")&&this.closeOnOverlay){this._requestDismiss("overlay");return}if(i.closest(".close")){this._requestDismiss("close-icon");return}if(i.closest(".btn-submit")){this._handleSubmit();return}i.closest(".btn-cancel")&&this._handleCancel()}}_onSubmit(t){if(!this.open||!this._isTopMost())return;const i=t.target;i&&i!==this&&this.contains(i)&&(t.preventDefault(),t.stopPropagation(),this._handleSubmit(i))}_onKeyDown(t){if(!(!this.open||!this._isTopMost())&&t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}}render(){if(!this.open){this._destroyRuntimeControllers(),this.setContent("");return}const t=this._config.title??this.getAttribute("title")??"",i=this._config.description??this.getAttribute("description")??"",e=this._config.submitText??this.getAttribute("submit-text")??"Submit",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",r=t.trim(),h=i.trim(),l=!!this.querySelector('[slot="title"]'),c=!!this.querySelector('[slot="description"]'),p=!!(r||l),f=!!(h||c),L=!!this.querySelector('[slot="content"]'),F=!!this.querySelector('[slot="footer"]'),D=this._config.showCancel??!0,q=this._config.showClose??this.dismissible,m=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",g=this.state==="loading",_=`ui-dialog-title-${this._uid}`,y=`ui-dialog-description-${this._uid}`,x=`ui-dialog-error-${this._uid}`,O=this.getAttribute("aria-label")||"",$=this.getAttribute("aria-labelledby")||"",A=this.getAttribute("aria-describedby")||"",v=$||(p?_:""),k=O||(v?"":"Dialog"),d=[];A?d.push(A):(f&&d.push(y),m&&d.push(x));const T=p||f?`
|
|
375
|
+
`,W='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function g(n,t){if(n==null)return t;const i=n.trim().toLowerCase();return i!=="false"&&i!=="0"&&i!=="off"}function a(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function S(){return typeof window<"u"&&typeof document<"u"}function C(n){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>n()):window.setTimeout(n,16)}function p(n){if(n){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(n);return}window.clearTimeout(n)}}const E=class l extends z.ElementBase{constructor(){super(),this._isActive=!1,this._uid=Math.random().toString(36).slice(2,10),this._dialogId=this._uid,this._lastFocused=null,this._terminalEmitted=!1,this._closeMeta=null,this._runtimeError="",this._config={},this._dismissableLayer=null,this._focusScope=null,this._disconnectCleanupFrame=0,this._restoreFocusFrame=0,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onSubmit=this._onSubmit.bind(this)}static get observedAttributes(){return["open","headless","title","description","closable","dismissible","close-on-overlay","close-on-backdrop","close-on-esc","lock-while-loading","size","state","role","initial-focus","submit-text","cancel-text","loading-text","error-message","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this._disconnectCleanupFrame&&(p(this._disconnectCleanupFrame),this._disconnectCleanupFrame=0),super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.addEventListener("submit",this._onSubmit),this._syncFromAttributes(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("submit",this._onSubmit),this._disconnectCleanupFrame&&p(this._disconnectCleanupFrame),this._restoreFocusFrame&&(p(this._restoreFocusFrame),this._restoreFocusFrame=0),this._disconnectCleanupFrame=C(()=>{this._disconnectCleanupFrame=0,!this.isConnected&&(this._isActive&&!this._terminalEmitted?this.close("dismiss","unmount"):(this._destroyRuntimeControllers(),this._deactivate()),super.disconnectedCallback())})}attributeChangedCallback(t,i,e){if(i!==e){if(t==="open"){this._syncOpenState();return}t==="state"&&e!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get dismissible(){return g(this.getAttribute("dismissible")??this.getAttribute("closable"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t)),this.setAttribute("closable",String(t))}get closeOnOverlay(){return g(this.getAttribute("close-on-overlay")??this.getAttribute("close-on-backdrop"),!0)}set closeOnOverlay(t){this.setAttribute("close-on-overlay",String(t)),this.setAttribute("close-on-backdrop",String(t))}get closeOnEsc(){return g(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get lockWhileLoading(){return g(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"||t==="success"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnOverlay!=null&&(this.closeOnOverlay=!!this._config.closeOnOverlay),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.size&&this.setAttribute("size",this._config.size),this._config.role&&this.setAttribute("role",this._config.role),this._config.initialFocus&&this.setAttribute("initial-focus",this._config.initialFocus),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.errorMessage&&(this._runtimeError=this._config.errorMessage),this.requestRender()}openDialog(){this.setAttribute("open","")}closeDialog(t="programmatic"){if(!this.hasAttribute("open"))return;const i=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i);const e=new CustomEvent("ui-request-close",{detail:{id:this.dialogId||this._uid,reason:t},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(e),!(i.defaultPrevented||e.defaultPrevented)){if(t==="submit"){this.close("submit");return}if(t==="cancel"){this.close("cancel");return}if(t==="overlay"){this.close("dismiss","overlay");return}if(t==="escape"){this.close("dismiss","esc");return}if(t==="button"){this.close("dismiss","close-icon");return}this.close("dismiss","programmatic")}}close(t="dismiss",i,e){this._terminalEmitted||(this._closeMeta={action:t,source:i,reason:e},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}_syncFromAttributes(){!this.hasAttribute("dismissible")&&this.hasAttribute("closable")&&this.setAttribute("dismissible",this.getAttribute("closable")||"true"),!this.hasAttribute("closable")&&this.hasAttribute("dismissible")&&this.setAttribute("closable",this.getAttribute("dismissible")||"true"),!this.hasAttribute("close-on-overlay")&&this.hasAttribute("close-on-backdrop")&&this.setAttribute("close-on-overlay",this.getAttribute("close-on-backdrop")||"true"),!this.hasAttribute("close-on-backdrop")&&this.hasAttribute("close-on-overlay")&&this.setAttribute("close-on-backdrop",this.getAttribute("close-on-overlay")||"true"),this.hasAttribute("role")||this.setAttribute("role","dialog")}_syncOpenState(){const t=this.hasAttribute("open");t&&!this._isActive?this._activate():!t&&this._isActive&&this._deactivate(),this._syncOpenUi()}_activate(){this._isActive=!0,this._terminalEmitted=!1,this._closeMeta=null,l._openStack.includes(this)||l._openStack.push(this),this._lastFocused=document.activeElement||null,F.acquireBodyScrollLock();const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this._syncOpenUi(),this._syncRuntimeControllers()}_deactivate(){if(!this._isActive)return;this._isActive=!1,this._destroyRuntimeControllers();const t=l._openStack.lastIndexOf(this);if(t>=0&&l._openStack.splice(t,1),F.releaseBodyScrollLock(),!this._terminalEmitted){const e=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;e.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:e.source||"abort",reason:e.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:e.action,source:e.source,reason:e.reason}),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0})),this._terminalEmitted=!0,this._closeMeta=null}const i=this._lastFocused;this._lastFocused=null,i&&this._canRestoreFocus(i)&&(this._restoreFocusFrame&&p(this._restoreFocusFrame),this._restoreFocusFrame=C(()=>{this._restoreFocusFrame=0;try{this._canRestoreFocus(i)&&i.focus()}catch{}})),this._syncOpenUi()}_dispatchWithLegacy(t,i,e,s=!1){const o=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const r=new CustomEvent(i,{detail:e,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(r),o}_isTopMost(){if(!this._isActive)return!1;const t=l._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".panel")}_canRestoreFocus(t){if(!t||!t.isConnected||t.disabled||t.getAttribute("aria-hidden")==="true")return!1;if(!S())return!0;const i=window.getComputedStyle(t);return i.display!=="none"&&i.visibility!=="hidden"}_collectFocusable(t){return Array.from(t.querySelectorAll(W)).filter(i=>{if(i.disabled||i.getAttribute("aria-hidden")==="true")return!1;const s=S()?window.getComputedStyle(i):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";if(i){const r=t.querySelector(i);if(r&&typeof r.focus=="function"){r.focus();return}}const e=this._collectFocusable(t),o=e.find(r=>r.hasAttribute("autofocus"))||e[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_onFocusIn(t){!this.open||this._isTopMost()}_handleTab(t){t.key}_destroyRuntimeControllers(){var t,i;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,(i=this._focusScope)==null||i.destroy(),this._focusScope=null}_syncOpenUi(){const t=this.root.querySelector(".overlay"),i=this._queryPanel(),e=this.open;!t||!i||(t.hidden=!e,t.setAttribute("data-open",String(e)),t.setAttribute("aria-hidden",e?"false":"true"),i.setAttribute("aria-hidden",e?"false":"true"))}_syncRuntimeControllers(){if(this._destroyRuntimeControllers(),!this.open||!this._isTopMost())return;const t=this._queryPanel();t&&(this._dismissableLayer=M.createDismissableLayer({node:t,closeOnEscape:this.closeOnEsc,closeOnPointerOutside:this.closeOnOverlay,closeOnFocusOutside:!1,onBeforeDismiss:(i,e)=>this._isInteractionLocked()?!1:i==="escape-key"?(this.closeDialog("escape"),!1):(i==="outside-pointer"&&this.closeDialog("overlay"),!1)}),this._focusScope=R.createFocusScope({node:t,trapped:!0,loop:!0,restoreFocus:!1,autoFocus:"first",initialFocus:()=>{const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";return i?t.querySelector(i):null}}))}_collectFormData(t){const i=this._queryPanel(),e=t||this.querySelector("form")||(i==null?void 0:i.querySelector("form"))||null;if(!(e instanceof HTMLFormElement)||typeof FormData>"u")return;const s=new FormData(e),o={};for(const[r,h]of s.entries()){const c=String(h);if(o[r]==null){o[r]=c;continue}const d=o[r];Array.isArray(d)?d.push(c):o[r]=[d,c]}return Object.keys(o).length?o:void 0}_resolveSubmitForm(t){var s;if(t){const o=t.closest("form");if(o instanceof HTMLFormElement&&this.contains(o))return o}const i=this.querySelector("form");if(i instanceof HTMLFormElement)return i;const e=(s=this._queryPanel())==null?void 0:s.querySelector("form");return e instanceof HTMLFormElement?e:null}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,i){if(!this._isInteractionLocked()){if(t==="overlay"){this.closeDialog("overlay");return}if(t==="esc"){this.closeDialog("escape");return}if(t==="close-icon"){this.closeDialog("button");return}this.close("dismiss",t,i)}}_handleSubmit(t){if(this._isInteractionLocked())return;const i=t??this._resolveSubmitForm();if(i&&typeof i.reportValidity=="function"&&!i.reportValidity())return;const e={id:this.dialogId||this._uid,formData:this._collectFormData(i)};this._dispatchWithLegacy("ui-submit","submit",e,!0).defaultPrevented||this.closeDialog("submit")}_handleCancel(){this._isInteractionLocked()||this.closeDialog("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const i=t.target;if(i){if(!i.closest(".panel")&&i.closest(".overlay")&&this.closeOnOverlay){this._requestDismiss("overlay");return}if(i.closest(".close")){this._requestDismiss("close-icon");return}if(i.closest(".btn-submit")){this._handleSubmit();return}i.closest(".btn-cancel")&&this._handleCancel()}}_onSubmit(t){if(!this.open||!this._isTopMost())return;const i=t.target;i&&i!==this&&this.contains(i)&&(t.preventDefault(),t.stopPropagation(),this._handleSubmit(i))}_onKeyDown(t){if(!(!this.open||!this._isTopMost())&&t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}}render(){const t=this._config.title??this.getAttribute("title")??"",i=this._config.description??this.getAttribute("description")??"",e=this._config.submitText??this.getAttribute("submit-text")??"Submit",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",r=t.trim(),h=i.trim(),c=!!this.querySelector('[slot="title"]'),d=!!this.querySelector('[slot="description"]'),f=!!(r||c),m=!!(h||d),O=!!this.querySelector('[slot="content"]'),D=!!this.querySelector('[slot="footer"]'),q=this._config.showCancel??!0,$=this._config.showClose??this.dismissible,v=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",b=this.state==="loading",y=`ui-dialog-title-${this._uid}`,x=`ui-dialog-description-${this._uid}`,A=`ui-dialog-error-${this._uid}`,T=this.getAttribute("aria-label")||"",I=this.getAttribute("aria-labelledby")||"",k=this.getAttribute("aria-describedby")||"",_=I||(f?y:""),w=T||(_?"":"Dialog"),u=[];k?u.push(k):(m&&u.push(x),v&&u.push(A));const B=f||m?`
|
|
368
376
|
<header class="header" part="header">
|
|
369
|
-
${
|
|
370
|
-
${
|
|
377
|
+
${f?`<h2 id="${y}" class="title" part="title"><slot name="title">${a(r)}</slot></h2>`:""}
|
|
378
|
+
${m?`<p id="${x}" class="description" part="description"><slot name="description">${a(h)}</slot></p>`:""}
|
|
371
379
|
</header>
|
|
372
380
|
`:"";this._destroyRuntimeControllers(),this.setContent(`
|
|
373
|
-
${this.hasAttribute("headless")?"":`<style>${
|
|
374
|
-
<div class="overlay" part="overlay" data-open="${String(this.open)}">
|
|
381
|
+
${this.hasAttribute("headless")?"":`<style>${P}</style>`}
|
|
382
|
+
<div class="overlay" part="overlay" data-open="${String(this.open)}" ${this.open?"":"hidden"} aria-hidden="${this.open?"false":"true"}">
|
|
375
383
|
<section
|
|
376
384
|
class="panel"
|
|
377
385
|
part="panel"
|
|
378
386
|
role="${a(this.getAttribute("role")||"dialog")}"
|
|
379
387
|
aria-modal="true"
|
|
380
|
-
${
|
|
381
|
-
${
|
|
382
|
-
${
|
|
388
|
+
${w?`aria-label="${a(w)}"`:""}
|
|
389
|
+
${_?`aria-labelledby="${a(_)}"`:""}
|
|
390
|
+
${u.length?`aria-describedby="${a(u.join(" "))}"`:""}
|
|
391
|
+
aria-hidden="${this.open?"false":"true"}"
|
|
383
392
|
tabindex="-1"
|
|
384
393
|
>
|
|
385
|
-
${
|
|
394
|
+
${$?`<button class="close" part="close" aria-label="Close dialog" type="button" ${b?"disabled":""}>
|
|
386
395
|
<svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
|
|
387
396
|
<path d="M3.5 3.5L12.5 12.5"></path>
|
|
388
397
|
<path d="M12.5 3.5L3.5 12.5"></path>
|
|
389
398
|
</svg>
|
|
390
399
|
</button>`:""}
|
|
391
|
-
${
|
|
400
|
+
${B}
|
|
392
401
|
<div class="body" part="body">
|
|
393
|
-
${
|
|
402
|
+
${O?'<slot name="content"></slot>':"<slot></slot>"}
|
|
394
403
|
</div>
|
|
395
404
|
|
|
396
|
-
<div class="error" id="${
|
|
405
|
+
<div class="error" id="${A}" part="error" aria-live="polite" data-empty="${String(!v)}">${a(v)}</div>
|
|
397
406
|
|
|
398
407
|
<footer class="footer" part="footer">
|
|
399
|
-
${
|
|
408
|
+
${b?`<span class="loading" part="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>`:'<span aria-hidden="true"></span>'}
|
|
400
409
|
|
|
401
|
-
${
|
|
402
|
-
<button class="btn btn-submit" part="submit" type="button" ${
|
|
410
|
+
${D?'<slot name="footer"></slot>':`${q?`<button class="btn btn-cancel" part="cancel" type="button" ${b?"disabled":""}>${a(s)}</button>`:""}
|
|
411
|
+
<button class="btn btn-submit" part="submit" type="button" ${b?"disabled":""}>${a(e)}</button>`}
|
|
403
412
|
</footer>
|
|
404
413
|
</section>
|
|
405
414
|
</div>
|
|
406
|
-
`),this._syncRuntimeControllers()}};E._openStack=[];let
|
|
415
|
+
`),this._syncOpenUi(),this.open?this._syncRuntimeControllers():this._destroyRuntimeControllers()}};E._openStack=[];let L=E;typeof customElements<"u"&&!customElements.get("ui-dialog")&&customElements.define("ui-dialog",L);exports.UIDialog=L;
|