@golemui/gui-lit 1.0.3 → 1.1.1-rc.0

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 (83) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/{button.element-3a7rRHbA.js → button.element-CJay43iR.js} +16 -13
  3. package/calendar-D31xNsxx.js +267 -0
  4. package/{range-calendar.element-_1bHW_c1.js → calendar.element-BhFrCsns.js} +16 -16
  5. package/{checkbox.element-CVskoXEc.js → checkbox.element-DAAVB651.js} +49 -49
  6. package/{currency.element-5GSakkxF.js → currency.element-D8A2ObpM.js} +15 -11
  7. package/{date-CDUlLuYy.js → date-DBuYpvcO.js} +88 -29
  8. package/date-input-DLiMreSS.js +204 -0
  9. package/date-picker.element-DeUQtbLg.js +357 -0
  10. package/date-time-calendar-DzU-FtVl.js +374 -0
  11. package/date-time-calendar.element-BLBcVsFu.js +95 -0
  12. package/date-time-input-DZaz2heD.js +246 -0
  13. package/date-time-picker.element-BUbLdV6i.js +440 -0
  14. package/date-time.element-B5onfSBG.js +93 -0
  15. package/{date.element-BZO0UQez.js → date.element-BsKhLrEc.js} +27 -19
  16. package/day-status-CsWStVQV.js +554 -0
  17. package/{dropdown.element-CyJbVAA5.js → dropdown.element-CXpMwJsU.js} +53 -37
  18. package/{errors-QjKhr6mA.js → errors-Byb2dIhK.js} +3 -2
  19. package/focus-leave.controller-2gV0pQd5.js +73 -0
  20. package/index.js +1635 -948
  21. package/index.umd.cjs +2046 -601
  22. package/lib/components/date-picker.element.d.ts +0 -11
  23. package/lib/components/date-time-calendar.element.d.ts +18 -0
  24. package/lib/components/date-time-picker.element.d.ts +18 -0
  25. package/lib/components/date-time.element.d.ts +18 -0
  26. package/lib/components/dropdown.element.d.ts +2 -0
  27. package/lib/components/range-calendar.element.d.ts +2 -1
  28. package/lib/components/range-date-picker.element.d.ts +0 -15
  29. package/lib/components/range-date-time-calendar.element.d.ts +18 -0
  30. package/lib/components/range-date-time-input.element.d.ts +18 -0
  31. package/lib/components/range-date-time-picker.element.d.ts +18 -0
  32. package/lib/components/range-time-input.element.d.ts +18 -0
  33. package/lib/components/range-time-picker.element.d.ts +18 -0
  34. package/lib/components/time-picker.element.d.ts +18 -0
  35. package/lib/components/time.element.d.ts +18 -0
  36. package/list-D730tmGN.js +297 -0
  37. package/{list.element-Co3V3Cn5.js → list.element-eo3DIOrp.js} +23 -23
  38. package/{markdown.element-p-kC47D7.js → markdown.element-FbtwdnAv.js} +310 -218
  39. package/{number.element-CBr47IiY.js → number.element-BEpOCzXy.js} +76 -61
  40. package/package.json +6 -6
  41. package/part-templates-VORbpgs2.js +691 -0
  42. package/{password.element-n-R9RbkB.js → password.element-CBaB8h5b.js} +19 -17
  43. package/pill-ranges-DpvWwP-3.js +48 -0
  44. package/{pills-B66qz_KX.js → pills-BDMO2NiR.js} +84 -59
  45. package/popup.controller-B33OvX_y.js +86 -0
  46. package/{radiogroup.element-CeQn623u.js → radiogroup.element-KWzBx8mx.js} +55 -51
  47. package/range-calendar-DO_woqcF.js +466 -0
  48. package/{calendar.element-DcnTyvfg.js → range-calendar.element-DHLZhpnj.js} +37 -29
  49. package/range-commit-8-MmYUyo.js +14 -0
  50. package/range-date-input-Br7XqQPK.js +311 -0
  51. package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-BdD4SlB4.js} +12 -8
  52. package/range-date-picker.element-DWRHiAoC.js +434 -0
  53. package/range-date-time-calendar-B3EMgN1E.js +734 -0
  54. package/range-date-time-calendar.element-Coea6RF4.js +97 -0
  55. package/range-date-time-input-Cu-T_nuC.js +353 -0
  56. package/range-date-time-input.element-Cti44iuW.js +87 -0
  57. package/range-date-time-picker.element-CDN2RL1y.js +472 -0
  58. package/range-selection-CU3hxLJE.js +25 -0
  59. package/range-time-input-BP9ZL9O8.js +348 -0
  60. package/range-time-input.element-B7wtHJoQ.js +84 -0
  61. package/range-time-picker.element-CPIAiQPC.js +470 -0
  62. package/{repeater.element-CtNgB4F5.js → repeater.element-BM1Keckd.js} +1 -1
  63. package/{select.element-jcDF1h-g.js → select.element-eepcXTpL.js} +117 -107
  64. package/{tabs.element-BvAyI71N.js → tabs.element-CvcIA8P3.js} +1 -0
  65. package/{tags.element-CX3vQL8L.js → tags.element-CPHgotb0.js} +21 -14
  66. package/templates-Dmr34nwp.js +88 -0
  67. package/{textarea.element-HThYqdR_.js → textarea.element-CiNEy9uq.js} +8 -7
  68. package/{textinput.element-CkXNzMUg.js → textinput.element-AL2Nr768.js} +10 -9
  69. package/time-input-5dkSm8UW.js +201 -0
  70. package/time-list-DLcq8BAp.js +217 -0
  71. package/time-picker-g337F8d0.js +299 -0
  72. package/time-picker.element-DLihegjg.js +89 -0
  73. package/time.element-BneqgMlQ.js +85 -0
  74. package/{toggle.element-C1kCw5H8.js → toggle.element-Cz91CRdp.js} +44 -43
  75. package/abstract-calendar-D0-077XJ.js +0 -545
  76. package/calendar-BclCC9VJ.js +0 -96
  77. package/date-input-DCdGWRio.js +0 -268
  78. package/date-picker.element-k7AJFQ5W.js +0 -168
  79. package/list-D1oKnH89.js +0 -283
  80. package/range-calendar-CBINu84w.js +0 -255
  81. package/range-date-input-BYXzqnr1.js +0 -395
  82. package/range-date-picker.element-BCBefgvY.js +0 -182
  83. package/templates-Dk1jxLwS.js +0 -75
@@ -0,0 +1,691 @@
1
+ import { html as D, nothing as I } from "lit";
2
+ import { p as b, s as V, u as C, I as O, b as R, v, x, t as B } from "./date-DBuYpvcO.js";
3
+ import { live as H } from "lit/directives/live.js";
4
+ import { repeat as T } from "lit-html/directives/repeat.js";
5
+ const A = new Date(2025, 0, 15, 9, 5, 0);
6
+ function K(n, t) {
7
+ if (t === "12" || t === "24") return t;
8
+ const { hourCycle: r } = new Intl.DateTimeFormat(n ?? "en", {
9
+ hour: "numeric"
10
+ }).resolvedOptions();
11
+ return r === "h11" || r === "h12" ? "12" : "24";
12
+ }
13
+ function ct(n, t) {
14
+ return new Intl.DateTimeFormat(n ?? "en", {
15
+ hour: "numeric",
16
+ minute: "numeric",
17
+ hourCycle: t === "12" ? "h12" : "h23"
18
+ }).formatToParts(A);
19
+ }
20
+ function lt(n, t) {
21
+ return new Intl.DateTimeFormat(n ?? "en", {
22
+ year: "numeric",
23
+ month: "numeric",
24
+ day: "numeric",
25
+ hour: "numeric",
26
+ minute: "numeric",
27
+ hourCycle: t === "12" ? "h12" : "h23"
28
+ }).formatToParts(A);
29
+ }
30
+ function U(n) {
31
+ const t = new Intl.DateTimeFormat(n ?? "en", {
32
+ hour: "numeric",
33
+ hourCycle: "h12"
34
+ }), r = (e) => t.formatToParts(new Date(2025, 0, 15, e, 0, 0)).find((s) => s.type === "dayPeriod")?.value ?? "";
35
+ return { am: r(9) || "AM", pm: r(21) || "PM" };
36
+ }
37
+ function $(n) {
38
+ const t = n.getFullYear(), r = String(n.getMonth() + 1).padStart(2, "0"), e = String(n.getDate()).padStart(2, "0"), s = String(n.getHours()).padStart(2, "0"), i = String(n.getMinutes()).padStart(2, "0"), a = String(n.getSeconds()).padStart(2, "0");
39
+ return `${t}-${r}-${e}T${s}:${i}:${a}`;
40
+ }
41
+ function S(n) {
42
+ const t = String(n.getHours()).padStart(2, "0"), r = String(n.getMinutes()).padStart(2, "0"), e = String(n.getSeconds()).padStart(2, "0");
43
+ return `${t}:${r}:${e}`;
44
+ }
45
+ function P(n) {
46
+ const t = /^([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?$/.exec(n);
47
+ return t ? {
48
+ hours: Number(t[1]),
49
+ minutes: Number(t[2]),
50
+ seconds: Number(t[3] ?? 0)
51
+ } : null;
52
+ }
53
+ function d(n) {
54
+ const t = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(n);
55
+ return t ? new Date(
56
+ Number(t[1]),
57
+ Number(t[2]) - 1,
58
+ Number(t[3]),
59
+ Number(t[4] ?? 0),
60
+ Number(t[5] ?? 0),
61
+ Number(t[6] ?? 0)
62
+ ) : new Date(n);
63
+ }
64
+ const dt = "No available times";
65
+ function f(n, t) {
66
+ const r = (i) => i.length === 5 ? `${i}:00` : i, e = r(n), s = r(t);
67
+ return e < s ? -1 : e > s ? 1 : 0;
68
+ }
69
+ function mt(n, t) {
70
+ const r = P(n);
71
+ if (!r) return;
72
+ const e = r.hours * 60 + r.minutes + (t || 30);
73
+ if (!(e >= 1440))
74
+ return S(new Date(1970, 0, 1, Math.floor(e / 60), e % 60, 0));
75
+ }
76
+ function ht(n, t) {
77
+ if (!n?.length) return [];
78
+ const r = b(t).getDay();
79
+ return n.filter(
80
+ (e) => (e.date == null || e.date === t) && (e.weekdays == null || e.weekdays.includes(r))
81
+ ).map(({ start: e, end: s }) => ({ start: e, end: s }));
82
+ }
83
+ function q(n, t) {
84
+ return t?.length ? t.some(
85
+ (r) => f(n, r.start) >= 0 && f(n, r.end ?? r.start) <= 0
86
+ ) : !1;
87
+ }
88
+ function ft(n, t, r) {
89
+ if (!r?.length) return !1;
90
+ const e = t ?? n;
91
+ return r.some((s) => {
92
+ const i = s.end ?? s.start;
93
+ return f(n, i) <= 0 && f(s.start, e) <= 0;
94
+ });
95
+ }
96
+ function w(n) {
97
+ return n.length === 5 ? `${n}:00` : n;
98
+ }
99
+ function pt(n) {
100
+ if (!n.length) return [];
101
+ const t = n.map((e) => ({ start: w(e.start), end: w(e.end ?? e.start) })).sort((e, s) => f(e.start, s.start)), r = [];
102
+ for (const e of t) {
103
+ const s = r[r.length - 1];
104
+ s && f(e.start, s.end) <= 0 ? f(e.end, s.end) > 0 && (s.end = e.end) : r.push({ ...e });
105
+ }
106
+ return r;
107
+ }
108
+ function gt(n, t) {
109
+ return d(n).getTime() <= d(t).getTime() ? { start: n, end: t } : { start: t, end: n };
110
+ }
111
+ function yt(n) {
112
+ if (!n.length) return [];
113
+ const t = n.map((e) => ({
114
+ start: d(e.start).getTime(),
115
+ end: d(e.end ?? e.start).getTime()
116
+ })).sort((e, s) => e.start - s.start), r = [];
117
+ for (const e of t) {
118
+ const s = r[r.length - 1];
119
+ s && e.start <= s.end ? e.end > s.end && (s.end = e.end) : r.push({ start: e.start, end: e.end });
120
+ }
121
+ return r.map((e) => ({
122
+ start: $(new Date(e.start)),
123
+ end: $(new Date(e.end))
124
+ }));
125
+ }
126
+ function St(n, t) {
127
+ if (!t?.length) return !1;
128
+ const r = d(n.start).getTime(), e = d(n.end ?? n.start).getTime();
129
+ return t.some((s) => {
130
+ const i = d(s.start).getTime(), a = d(s.end ?? s.start).getTime();
131
+ return r < a && i < e;
132
+ });
133
+ }
134
+ function Tt(n, t) {
135
+ if (!t?.length) return !1;
136
+ const r = d(`${n}T00:00:00`).getTime(), e = d(`${n}T23:59:59`).getTime();
137
+ return t.some((s) => {
138
+ const i = d(s.start).getTime(), a = d(s.end ?? s.start).getTime();
139
+ return i <= r && a >= e;
140
+ });
141
+ }
142
+ function Dt(n, t) {
143
+ if (!n?.length) return [];
144
+ const r = d(`${t}T00:00:00`).getTime(), e = d(`${t}T23:59:59`).getTime(), s = [];
145
+ for (const i of n) {
146
+ const a = d(i.start).getTime(), o = d(i.end ?? i.start).getTime();
147
+ if (o < r || a > e) continue;
148
+ const u = a <= r ? "00:00:00" : S(new Date(a)), c = o >= e ? "23:59:59" : S(new Date(o));
149
+ s.push({ start: u, end: c });
150
+ }
151
+ return s;
152
+ }
153
+ function Pt(n) {
154
+ const t = n.minuteStep || 30, r = P(n.minTime ?? "") ?? { hours: 0, minutes: 0, seconds: 0 }, e = S(new Date(1970, 0, 1, r.hours, r.minutes, r.seconds)), s = n.maxTime ?? "23:59:59", i = [];
155
+ for (let a = r.hours * 60 + r.minutes; a < 1440; a += t) {
156
+ const o = S(
157
+ new Date(1970, 0, 1, Math.floor(a / 60), a % 60, 0)
158
+ );
159
+ if (f(o, s) > 0) break;
160
+ f(o, e) < 0 || i.push({ value: o, disabled: q(o, n.disabledRanges) });
161
+ }
162
+ return i;
163
+ }
164
+ function _t(n, t, r) {
165
+ const e = P(n);
166
+ return e ? new Intl.DateTimeFormat(t ?? "en", {
167
+ hour: "numeric",
168
+ minute: "numeric",
169
+ hourCycle: r === "12" ? "h12" : "h23"
170
+ }).format(new Date(2025, 0, 15, e.hours, e.minutes, e.seconds)) : n;
171
+ }
172
+ function It(n, t, r) {
173
+ const e = d(n);
174
+ return isNaN(e.getTime()) ? n : new Intl.DateTimeFormat(t ?? "en", {
175
+ year: "numeric",
176
+ month: "2-digit",
177
+ day: "2-digit",
178
+ hour: "2-digit",
179
+ minute: "2-digit",
180
+ hour12: r === "12"
181
+ }).format(e);
182
+ }
183
+ function $t(n, t, r, e) {
184
+ const s = d(n).getTime();
185
+ if (isNaN(s)) return null;
186
+ if (t) {
187
+ const i = d(t);
188
+ if (!isNaN(i.getTime()) && s < i.getTime())
189
+ return e?.minDateTimeMessage ?? V;
190
+ }
191
+ if (r) {
192
+ const i = d(r);
193
+ if (!isNaN(i.getTime()) && s > i.getTime())
194
+ return e?.maxDateTimeMessage ?? C;
195
+ }
196
+ return null;
197
+ }
198
+ function M(n, t) {
199
+ const r = n % 12;
200
+ return t === "pm" ? r + 12 : r;
201
+ }
202
+ function Y(n) {
203
+ const t = n >= 12 ? "pm" : "am";
204
+ return { hour12: n % 12 === 0 ? 12 : n % 12, period: t };
205
+ }
206
+ const W = {
207
+ day: "Day",
208
+ month: "Month",
209
+ year: "Year",
210
+ hour: "Hour",
211
+ minute: "Minute",
212
+ second: "Second",
213
+ dayPeriod: "AM/PM"
214
+ };
215
+ function z() {
216
+ return {
217
+ day: { type: "day", kind: "numeric", maxLength: 2, min: 1, max: 31, placeholder: "dd" },
218
+ month: { type: "month", kind: "numeric", maxLength: 2, min: 1, max: 12, placeholder: "mm" },
219
+ year: {
220
+ type: "year",
221
+ kind: "numeric",
222
+ maxLength: 4,
223
+ min: 1e3,
224
+ // TODO: Add a prop to set the default minimum year, like 1979 or 2000
225
+ max: 9999,
226
+ placeholder: "yyyy"
227
+ }
228
+ };
229
+ }
230
+ function j(n, t, r) {
231
+ return {
232
+ hour: n === "12" ? {
233
+ type: "hour",
234
+ kind: "numeric",
235
+ maxLength: 2,
236
+ min: 1,
237
+ max: 12,
238
+ placeholder: "hh"
239
+ } : {
240
+ type: "hour",
241
+ kind: "numeric",
242
+ maxLength: 2,
243
+ min: 0,
244
+ max: 23,
245
+ placeholder: "hh",
246
+ incrementFallback: 0
247
+ },
248
+ minute: {
249
+ type: "minute",
250
+ kind: "numeric",
251
+ maxLength: 2,
252
+ min: 0,
253
+ max: 59,
254
+ placeholder: "mm",
255
+ step: t,
256
+ incrementFallback: 0,
257
+ wrap: !0
258
+ },
259
+ dayPeriod: {
260
+ type: "dayPeriod",
261
+ kind: "dayPeriod",
262
+ maxLength: 8,
263
+ min: 0,
264
+ max: 0,
265
+ placeholder: r
266
+ }
267
+ };
268
+ }
269
+ function L(n, t, r) {
270
+ return n[t]?.[r] ?? "";
271
+ }
272
+ function G(n, t, r, e) {
273
+ return { ...n, [t]: { ...n[t], [r]: e } };
274
+ }
275
+ function X(n, t) {
276
+ return { ...n, [t]: {} };
277
+ }
278
+ function J(n, t, r) {
279
+ if (r !== "12") return n;
280
+ let e = n;
281
+ for (const s of t)
282
+ L(e, s, "dayPeriod") || (e = G(e, s, "dayPeriod", "am"));
283
+ return e;
284
+ }
285
+ function Q(n, t) {
286
+ if (isNaN(t)) return { value: t };
287
+ if (!n) return { value: t };
288
+ const r = Math.max(n.min, Math.min(n.max, t));
289
+ return r === t ? { value: t } : {
290
+ value: r,
291
+ writeBack: r.toString().padStart(n.maxLength ?? 2, "0")
292
+ };
293
+ }
294
+ function p(n, t, r, e) {
295
+ const s = parseInt(n[r] ?? "", 10), { value: i, writeBack: a } = Q(t[r], s);
296
+ return a !== void 0 && (e[r] = a), i;
297
+ }
298
+ function kt(n, t) {
299
+ const r = {}, e = p(n, t.descriptors, "year", r), s = p(n, t.descriptors, "month", r), i = p(n, t.descriptors, "day", r), a = !isNaN(e) && String(e).length === 4, o = !isNaN(s) && s > 0, u = !isNaN(i) && i > 0;
300
+ if (!(a && o && u))
301
+ return { result: { kind: "incomplete" }, writeBacks: r };
302
+ if (i > v(s, e))
303
+ return {
304
+ result: { kind: "invalid", message: t.invalidDateMessage ?? x },
305
+ writeBacks: r
306
+ };
307
+ const c = new Date(e, s - 1, i);
308
+ return { result: { kind: "valid", iso: B(c), instant: c }, writeBacks: r };
309
+ }
310
+ function Et(n, t) {
311
+ const r = t.hourFormat === "12", e = {}, s = p(n, t.descriptors, "hour", e), i = p(n, t.descriptors, "minute", e), a = n.dayPeriod ?? "";
312
+ if (isNaN(s) || isNaN(i)) return { result: { kind: "incomplete" }, writeBacks: e };
313
+ if (r && a !== "am" && a !== "pm")
314
+ return { result: { kind: "incomplete" }, writeBacks: e };
315
+ const o = r ? M(s, a) : s, u = new Date(1970, 0, 1, o, i, 0);
316
+ return { result: { kind: "valid", iso: S(u), instant: u }, writeBacks: e };
317
+ }
318
+ function wt(n, t) {
319
+ const r = t.hourFormat === "12", e = {}, s = p(n, t.descriptors, "year", e), i = p(n, t.descriptors, "month", e), a = p(n, t.descriptors, "day", e), o = p(n, t.descriptors, "hour", e), u = p(n, t.descriptors, "minute", e), c = n.dayPeriod ?? "", l = !isNaN(s) && String(s).length === 4, m = !isNaN(i) && i > 0, h = !isNaN(a) && a > 0, g = !isNaN(o), y = !isNaN(u);
320
+ if (!(l && m && h && g && y && (!r || c === "am" || c === "pm")))
321
+ return { result: { kind: "incomplete" }, writeBacks: e };
322
+ if (a > v(i, s))
323
+ return {
324
+ result: { kind: "invalid", message: t.invalidDateMessage ?? x },
325
+ writeBacks: e
326
+ };
327
+ const _ = r ? M(o, c) : o, E = new Date(s, i - 1, a, _, u, 0);
328
+ return { result: { kind: "valid", iso: $(E), instant: E }, writeBacks: e };
329
+ }
330
+ function Nt(n, t) {
331
+ return t.minTime && f(n, t.minTime) < 0 ? t.minTimeMessage ?? O : t.maxTime && f(n, t.maxTime) > 0 ? t.maxTimeMessage ?? R : null;
332
+ }
333
+ const Z = [
334
+ "Backspace",
335
+ "Tab",
336
+ "ArrowUp",
337
+ "ArrowDown",
338
+ "ArrowLeft",
339
+ "ArrowRight",
340
+ "Delete",
341
+ "Enter"
342
+ ];
343
+ function F(n) {
344
+ return /^[0-9]$/.test(n);
345
+ }
346
+ function tt(n, t) {
347
+ return Z.includes(n.key) || n.ctrlKey || n.metaKey || t ? !1 : !F(n.key);
348
+ }
349
+ function et(n, t, r) {
350
+ const e = n?.step ?? 1, s = n?.incrementFallback ?? 1, i = r === "up" ? e : -e, a = parseInt(t, 10);
351
+ let o;
352
+ if (isNaN(a))
353
+ o = s;
354
+ else if (o = a + i, n?.wrap) {
355
+ const u = n.max - n.min + 1;
356
+ o = ((o - n.min) % u + u) % u + n.min;
357
+ } else n && (o = Math.max(n.min, Math.min(n.max, o)));
358
+ return o.toString().padStart(n?.maxLength ?? 2, "0");
359
+ }
360
+ const N = /* @__PURE__ */ new Map();
361
+ function bt(n, t, r, e = !1) {
362
+ const s = r || 1, i = `${n ?? ""}|${t ?? ""}|${s}|${e ? "dt" : "t"}`, a = N.get(i);
363
+ if (a) return a;
364
+ const o = K(n, t), u = U(n), c = j(o, s, u.am), l = e ? { ...z(), ...c } : c, m = { effectiveHourFormat: o, dayPeriodLabels: u, descriptors: l };
365
+ return N.set(i, m), m;
366
+ }
367
+ class vt {
368
+ constructor(t, r) {
369
+ this._values = {}, this._hasSurfacedInputError = !1, this.getPartDisplay = (e, s) => {
370
+ const i = this.getPart(e, s);
371
+ if (s === "dayPeriod" && (i === "am" || i === "pm")) {
372
+ const a = this.options.getDayPeriodLabels?.();
373
+ if (a) return a[i];
374
+ }
375
+ return i;
376
+ }, this.handleKeyDown = (e, s, i) => {
377
+ e.key === "Enter" && this.options.onEnter && (e.preventDefault(), e.target instanceof HTMLInputElement && this.setPart(s, i, e.target.value.replace(/[^0-9]/g, ""))), tt(e, this.options.isReadonly()) && e.preventDefault();
378
+ }, this.handleDayPeriodKeyDown = (e) => {
379
+ (e.key === "ArrowUp" || e.key === "ArrowDown") && e.preventDefault(), e.key === "Enter" && e.preventDefault();
380
+ }, this.handleFocus = (e) => {
381
+ this.host.dispatchEvent(new CustomEvent("focus", { detail: e }));
382
+ }, this.handleKeyUp = (e, s, i) => {
383
+ if (this.options.isReadonly()) return;
384
+ const a = window.getComputedStyle(this.host).direction === "rtl", o = e.target, u = o, c = this.getGroupInputs(s), l = c.indexOf(o), m = this.options.getDescriptor(i);
385
+ switch (o instanceof HTMLInputElement && u.value.length === u.maxLength && F(e.key) && (l === c.length - 1 ? this.autoAdvanceFromGroupEnd(s) : c[l + 1].focus()), e.key) {
386
+ case "Enter": {
387
+ this.options.onEnter?.(e, s);
388
+ break;
389
+ }
390
+ case "ArrowUp":
391
+ case "ArrowDown": {
392
+ if (m?.kind === "dayPeriod") {
393
+ this.toggleDayPeriod(s, i);
394
+ break;
395
+ }
396
+ const h = et(
397
+ m,
398
+ u.value,
399
+ e.key === "ArrowUp" ? "up" : "down"
400
+ );
401
+ this.setPart(s, i, h), this.selectPart(o), this.options.commitGroup(s);
402
+ break;
403
+ }
404
+ case "ArrowLeft":
405
+ case "ArrowRight": {
406
+ const h = [...c].sort(
407
+ (k, _) => k.getBoundingClientRect().left - _.getBoundingClientRect().left
408
+ ), g = h.indexOf(o), y = e.key === "ArrowRight" ? g + 1 : g - 1;
409
+ y >= 0 && y < h.length ? (h[y].focus(), this.selectPart(h[y])) : this.navigatePastGroupEdge(e.key, s, a);
410
+ break;
411
+ }
412
+ }
413
+ }, this.handleChange = (e, s, i) => {
414
+ if (e.stopImmediatePropagation(), this.options.isReadonly() || this.options.getDescriptor(i)?.kind === "dayPeriod") return;
415
+ const u = e.target.value.replace(/[^0-9]/g, "");
416
+ this.setPart(s, i, u), this.options.commitGroup(s);
417
+ }, this.handleBlur = (e, s, i) => {
418
+ const a = this.options.getDescriptor(i);
419
+ if (a?.kind !== "dayPeriod") {
420
+ const o = e.target, u = parseInt(o.value, 10);
421
+ !isNaN(u) && (u > 0 || a?.min === 0) ? o.value = u.toString().padStart(a?.maxLength ?? 2, "0") : this.options.onEmptyPartBlur();
422
+ }
423
+ this.host.dispatchEvent(new CustomEvent("blur"));
424
+ }, this.toggleDayPeriod = (e, s) => {
425
+ if (this.options.isReadonly() || this.options.isDisabled()) return;
426
+ const i = this.getPart(e, s);
427
+ this.setPart(e, s, i === "am" ? "pm" : "am"), this.options.commitGroup(e);
428
+ }, this.host = t, this.options = r, t.addController(this);
429
+ }
430
+ hostConnected() {
431
+ }
432
+ get values() {
433
+ return this._values;
434
+ }
435
+ getPart(t, r) {
436
+ return L(this._values, t, r);
437
+ }
438
+ setPart(t, r, e) {
439
+ this._values = G(this._values, t, r, e), this.host.requestUpdate();
440
+ }
441
+ clearGroup(t) {
442
+ this._values = X(this._values, t), this.host.requestUpdate();
443
+ }
444
+ /** Writes clamp corrections back into the state. */
445
+ applyWriteBacks(t, r) {
446
+ for (const [e, s] of Object.entries(r))
447
+ s !== void 0 && this.setPart(t, e, s);
448
+ }
449
+ /**
450
+ * Seeds each group's day-period toggle to 'am' when the effective format is
451
+ * 12h (the twins' seedDayPeriods). Requests an update only when something
452
+ * was actually seeded, matching the conditional setPartValue calls.
453
+ *
454
+ * @param {readonly string[]} [groups] - The groups to seed; defaults to all.
455
+ */
456
+ seedDayPeriods(t = this.options.groups) {
457
+ this.seedWith(t, this.options.getHourFormat?.() ?? "24");
458
+ }
459
+ seedWith(t, r) {
460
+ const e = J(this._values, t, r);
461
+ e !== this._values && (this._values = e, this.host.requestUpdate());
462
+ }
463
+ /**
464
+ * Seeds a group's parts from an ISO value; a null/empty value clears the
465
+ * group (re-seeding its day period for time-aware shapes) and an
466
+ * unparseable one leaves the state untouched.
467
+ *
468
+ * @param {string} group - The group to seed.
469
+ * @param {string | null} iso - The ISO value, or null/'' to clear.
470
+ * @param {GroupSeedShape} shape - Which parts the value carries.
471
+ * @param {HourFormat} [hourFormat] - The effective hour format; defaults to
472
+ * the `getHourFormat` option (then '24').
473
+ */
474
+ setGroupFromISO(t, r, e, s) {
475
+ const i = s ?? this.options.getHourFormat?.() ?? "24";
476
+ if (!r) {
477
+ this.clearGroup(t), e !== "date" && this.seedWith([t], i);
478
+ return;
479
+ }
480
+ if (e === "date") {
481
+ const o = b(r);
482
+ if (isNaN(o.getTime())) return;
483
+ this.setPart(t, "year", String(o.getFullYear()).padStart(4, "0")), this.setPart(t, "month", String(o.getMonth() + 1).padStart(2, "0")), this.setPart(t, "day", String(o.getDate()).padStart(2, "0"));
484
+ return;
485
+ }
486
+ if (e === "time") {
487
+ let o = P(r);
488
+ if (!o) {
489
+ const u = d(r);
490
+ if (isNaN(u.getTime())) return;
491
+ o = { hours: u.getHours(), minutes: u.getMinutes(), seconds: u.getSeconds() };
492
+ }
493
+ this.writeTimeParts(t, o.hours, o.minutes, i);
494
+ return;
495
+ }
496
+ const a = d(r);
497
+ isNaN(a.getTime()) || (this.setPart(t, "day", String(a.getDate()).padStart(2, "0")), this.setPart(t, "month", String(a.getMonth() + 1).padStart(2, "0")), this.setPart(t, "year", String(a.getFullYear()).padStart(4, "0")), this.writeTimeParts(t, a.getHours(), a.getMinutes(), i));
498
+ }
499
+ writeTimeParts(t, r, e, s) {
500
+ if (s === "12") {
501
+ const { hour12: i, period: a } = Y(r);
502
+ this.setPart(t, "hour", i.toString().padStart(2, "0")), this.setPart(t, "dayPeriod", a);
503
+ } else
504
+ this.setPart(t, "hour", r.toString().padStart(2, "0"));
505
+ this.setPart(t, "minute", e.toString().padStart(2, "0"));
506
+ }
507
+ /**
508
+ * Focusable part elements of a group in DOM order. Numeric parts are
509
+ * inputs; dayPeriod parts are toggle buttons.
510
+ */
511
+ getGroupInputs(t) {
512
+ return this.options.groups.length > 1 ? Array.from(this.host.querySelectorAll(`[data-group="${t}"]`)) : Array.from(this.host.querySelectorAll(`.${this.options.blockClass}__part`));
513
+ }
514
+ /** Selects an input's text; a no-op for non-input parts (the toggle button). */
515
+ selectPart(t) {
516
+ t instanceof HTMLInputElement && t.select();
517
+ }
518
+ focusFirst(t) {
519
+ requestAnimationFrame(() => {
520
+ this.getGroupInputs(t)[0]?.focus();
521
+ });
522
+ }
523
+ /**
524
+ * Auto-advance past the last input of a group, or into the next
525
+ * group's first input, if it has more than one group (like ranged inputs).
526
+ */
527
+ autoAdvanceFromGroupEnd(t) {
528
+ const r = this.options.groups;
529
+ if (r.length > 1) {
530
+ const e = r[r.indexOf(t) + 1];
531
+ e !== void 0 && this.getGroupInputs(e)[0]?.focus();
532
+ return;
533
+ }
534
+ this.getGroupInputs(t)[0]?.focus();
535
+ }
536
+ /**
537
+ * ArrowLeft/ArrowRight past a group's visual edge.
538
+ */
539
+ navigatePastGroupEdge(t, r, e) {
540
+ const s = this.options.groups;
541
+ if (s.length <= 1) return;
542
+ const i = s[0], a = s[s.length - 1];
543
+ if (t === "ArrowLeft") {
544
+ const o = e ? a : i;
545
+ if (r !== o) {
546
+ const u = this.getGroupInputs(o), c = u[u.length - 1];
547
+ c && (c.focus(), this.selectPart(c));
548
+ }
549
+ } else {
550
+ const o = e ? i : a;
551
+ if (r !== o) {
552
+ const u = this.getGroupInputs(o);
553
+ u[0] && (u[0].focus(), this.selectPart(u[0]));
554
+ }
555
+ }
556
+ }
557
+ /** Whether an inputError has been surfaced and not yet cleared. */
558
+ get hasSurfacedInputError() {
559
+ return this._hasSurfacedInputError;
560
+ }
561
+ /**
562
+ * Surfaces an inputError through `onInputErrorSurfaced` and remembers it so
563
+ * it can later be cleared.
564
+ */
565
+ surfaceInputError(t) {
566
+ this._hasSurfacedInputError = !0, this.options.onInputErrorSurfaced?.(t);
567
+ }
568
+ /**
569
+ * Clears a previously-surfaced inputError by echoing the given (unchanged)
570
+ * value through `onSurfacedErrorCleared`; a no-op when nothing is surfaced.
571
+ */
572
+ clearSurfacedInputError(t) {
573
+ this._hasSurfacedInputError && (this._hasSurfacedInputError = !1, this.options.onSurfacedErrorCleared?.(t));
574
+ }
575
+ resetSurfacedInputError() {
576
+ this._hasSurfacedInputError = !1;
577
+ }
578
+ }
579
+ const nt = (n, t) => D`<span class="${t}__separator">${n.value}</span>`;
580
+ function xt(n, t, r) {
581
+ const e = t.formatParts, s = t.groups.length > 1, i = (l) => s ? `${n}-${l.type}` : l.type, a = (l, m) => {
582
+ if (l.type === "literal")
583
+ return nt(l, t.blockClass);
584
+ const h = t.getDescriptor(l.type);
585
+ if (!h) return "";
586
+ const g = n === t.groups[0] && m === 0 ? 0 : -1;
587
+ return rt(n, h, g, t, r);
588
+ }, o = (l) => l.type === "hour" || l.type === "minute" || l.type === "second", u = e.findIndex(o);
589
+ if (u === -1)
590
+ return T(e, i, a);
591
+ let c = e.length - 1;
592
+ for (; !o(e[c]); ) c--;
593
+ return D`
594
+ ${T(e.slice(0, u), i, a)}
595
+ <div class="gui-parts__time-cluster ${t.blockClass}__time-cluster" dir="ltr">
596
+ ${T(e.slice(u, c + 1), i, (l, m) => a(l, u + m))}
597
+ </div>
598
+ ${T(e.slice(c + 1), i, (l, m) => a(l, c + 1 + m))}
599
+ `;
600
+ }
601
+ function rt(n, t, r, e, s) {
602
+ const i = e.blockClass, a = t.type;
603
+ if (t.kind === "dayPeriod")
604
+ return st(n, t, r, e, s);
605
+ const o = a === "year" ? `gui-parts__year ${i}__year` : "", u = e.getDisplayValue(n, a), c = parseInt(u, 10);
606
+ return D`
607
+ <div class="gui-parts__touch-target ${i}__touch-target">
608
+ <input
609
+ type="text"
610
+ inputmode="numeric"
611
+ role="spinbutton"
612
+ class="gui-parts__part ${i}__part ${o}"
613
+ data-type=${a}
614
+ data-group=${e.groups.length > 1 ? n : I}
615
+ maxlength=${t.maxLength}
616
+ placeholder=${t.placeholder}
617
+ tabindex=${r}
618
+ aria-label=${e.getPartAriaLabel?.(n, a) ?? W[a]}
619
+ aria-valuemin=${t.min}
620
+ aria-valuemax=${t.max}
621
+ aria-valuenow=${isNaN(c) ? I : c}
622
+ ?disabled=${e.disabled}
623
+ ?readonly=${e.partsReadonly}
624
+ autocomplete="off"
625
+ .value=${H(e.getDisplayValue(n, a))}
626
+ @keydown=${(l) => s.handleKeyDown(l, n, a)}
627
+ @keyup=${(l) => s.handleKeyUp(l, n, a)}
628
+ @focus=${s.handleFocus}
629
+ @blur=${(l) => s.handleBlur(l, n, a)}
630
+ @change=${(l) => s.handleChange(l, n, a)}
631
+ />
632
+ <div class="gui-parts__visual-underline ${i}__visual-underline"></div>
633
+ </div>
634
+ `;
635
+ }
636
+ function st(n, t, r, e, s) {
637
+ const i = e.blockClass, a = t.type;
638
+ return D`
639
+ <div class="gui-parts__touch-target ${i}__touch-target">
640
+ <button
641
+ type="button"
642
+ class="gui-parts__part gui-parts__dayperiod ${i}__part ${i}__dayperiod"
643
+ data-type=${a}
644
+ data-group=${e.groups.length > 1 ? n : I}
645
+ tabindex=${r}
646
+ ?disabled=${e.disabled}
647
+ aria-label=${e.dayPeriodAriaLabel ?? "AM/PM"}
648
+ @click=${() => s.toggleDayPeriod(n, a)}
649
+ @keydown=${s.handleDayPeriodKeyDown}
650
+ @keyup=${(o) => s.handleKeyUp(o, n, a)}
651
+ @focus=${s.handleFocus}
652
+ @blur=${(o) => s.handleBlur(o, n, a)}
653
+ >
654
+ ${e.getDisplayValue(n, a)}
655
+ </button>
656
+ <div class="gui-parts__visual-underline ${i}__visual-underline"></div>
657
+ </div>
658
+ `;
659
+ }
660
+ export {
661
+ Pt as A,
662
+ vt as G,
663
+ dt as N,
664
+ W as P,
665
+ lt as a,
666
+ wt as b,
667
+ St as c,
668
+ $t as d,
669
+ K as e,
670
+ It as f,
671
+ bt as g,
672
+ q as h,
673
+ Tt as i,
674
+ Dt as j,
675
+ mt as k,
676
+ _t as l,
677
+ yt as m,
678
+ z as n,
679
+ gt as o,
680
+ d as p,
681
+ kt as q,
682
+ xt as r,
683
+ f as s,
684
+ ft as t,
685
+ ct as u,
686
+ Et as v,
687
+ Nt as w,
688
+ pt as x,
689
+ ht as y,
690
+ S as z
691
+ };