@webority/ui-elements 0.34.0 → 0.35.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 (62) hide show
  1. package/dist/WuiAutocomplete-ByxnwJNQ.js +283 -0
  2. package/dist/WuiCommandPalette-CtZ04JxZ.js +130 -0
  3. package/dist/WuiConsentBanner-oVe-jxCO.js +399 -0
  4. package/dist/WuiContextMenu-Bx_U2X3t.js +211 -0
  5. package/dist/WuiCountrySelect-CUAwKnL9.js +28 -0
  6. package/dist/WuiDatePicker-DkNbc-z7.js +325 -0
  7. package/dist/WuiDateRange-BocnVO6L.js +233 -0
  8. package/dist/WuiDock-BSDY9g8Q.js +57 -0
  9. package/dist/WuiImageCrop-1yaAONTk.js +462 -0
  10. package/dist/WuiMultiSelect-BrCGRNCt.js +416 -0
  11. package/dist/WuiOtp-D8-4Pqil.js +128 -0
  12. package/dist/WuiPhone-BvbhiP2r.js +731 -0
  13. package/dist/WuiSelect-BXrpiuXG.js +214 -0
  14. package/dist/WuiSlider-BcU0psYf.js +256 -0
  15. package/dist/WuiSortable-JjJqstSU.js +280 -0
  16. package/dist/WuiTagInput-D1ay3OcL.js +158 -0
  17. package/dist/WuiTimePicker-C7n-VFGt.js +370 -0
  18. package/dist/WuiTour-R5O9l--J.js +205 -0
  19. package/dist/WuiTree-Ds-8tNgs.js +393 -0
  20. package/dist/WuiWizardStep-BU5w9_Ds.js +221 -0
  21. package/dist/anchorOverlay-DluGZ8ef.js +23 -0
  22. package/dist/calendarMath-BAF2Jkg_.js +42 -0
  23. package/dist/countries-B-M_LTgS.js +1234 -0
  24. package/dist/elementBase-Bg1xpvup.js +9 -0
  25. package/dist/elements/autocomplete.js +6 -0
  26. package/dist/elements/command-palette.js +6 -0
  27. package/dist/elements/consent-banner.js +6 -0
  28. package/dist/elements/context-menu.js +6 -0
  29. package/dist/elements/country-select.js +6 -0
  30. package/dist/elements/date-range.js +6 -0
  31. package/dist/elements/datepicker.js +6 -0
  32. package/dist/elements/dock.js +6 -0
  33. package/dist/elements/image-crop.js +6 -0
  34. package/dist/elements/kanban.js +6 -0
  35. package/dist/elements/multiselect.js +6 -0
  36. package/dist/elements/otp.js +6 -0
  37. package/dist/elements/phone.js +6 -0
  38. package/dist/elements/select.js +6 -0
  39. package/dist/elements/slider.js +6 -0
  40. package/dist/elements/sortable.js +6 -0
  41. package/dist/elements/status-icon.js +6 -0
  42. package/dist/elements/taginput.js +6 -0
  43. package/dist/elements/timepicker.js +6 -0
  44. package/dist/elements/tour.js +6 -0
  45. package/dist/elements/tree.js +6 -0
  46. package/dist/elements/wizard.js +5 -0
  47. package/dist/formMirror-jGf5M4gk.js +29 -0
  48. package/dist/formatters-DusKbTyV.js +138 -0
  49. package/dist/helpers.js +5 -0
  50. package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
  51. package/dist/kanban-BeVAItir.js +972 -0
  52. package/dist/listboxKeyNav-zts_8d5e.js +36 -0
  53. package/dist/optionLabel-Dn-I7zyp.js +16 -0
  54. package/dist/statusIcons-C3zjycpa.js +37 -0
  55. package/dist/textMatch-DEUjlkdy.js +27 -0
  56. package/dist/themeTransition-BpCuMnjk.js +589 -0
  57. package/dist/tokenCommit-VWz-2jEf.js +20 -0
  58. package/dist/ui-elements.global.js +118 -129
  59. package/dist/ui-elements.js +253 -8864
  60. package/dist/ui-phone.global.js +14 -0
  61. package/dist/wuiHttp-m0yQadwQ.js +117 -0
  62. package/package.json +28 -3
@@ -0,0 +1,325 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { n as t, r as n, t as r } from "./anchorOverlay-DluGZ8ef.js";
3
+ import { t as i } from "./formMirror-jGf5M4gk.js";
4
+ import { t as a } from "./iconGlyphs.g-Cpg1BUHm.js";
5
+ import { n as o } from "./optionLabel-Dn-I7zyp.js";
6
+ import { a as s, i as c, n as l, o as u, r as d, s as f, t as p } from "./calendarMath-BAF2Jkg_.js";
7
+ //#region src/WuiDatePicker.js
8
+ var m = class extends e {
9
+ static formAssociated = !0;
10
+ static get observedAttributes() {
11
+ return [
12
+ "value",
13
+ "min",
14
+ "max",
15
+ "placeholder",
16
+ "disabled",
17
+ "first-day",
18
+ "size",
19
+ "aria-label",
20
+ "aria-describedby",
21
+ "aria-invalid"
22
+ ];
23
+ }
24
+ constructor() {
25
+ super();
26
+ try {
27
+ this._internals = this.attachInternals();
28
+ } catch {
29
+ this._internals = null;
30
+ }
31
+ this._value = "";
32
+ let e = new Date(2e3, 0, 1);
33
+ this._viewY = e.getFullYear(), this._viewM = e.getMonth(), this._mode = "days", this._focus = null, this._slide = "";
34
+ }
35
+ connectedCallback() {
36
+ if (!this._rendered) {
37
+ this.render();
38
+ return;
39
+ }
40
+ this._bindGlobal?.();
41
+ }
42
+ attributeChangedCallback(e, t, n) {
43
+ if (e === "aria-invalid") {
44
+ this._syncInvalid();
45
+ return;
46
+ }
47
+ this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
48
+ }
49
+ _syncInvalid() {
50
+ let e = this.querySelector(".datepicker-trigger");
51
+ e && (this.hasAttribute("aria-invalid") ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"));
52
+ }
53
+ formResetCallback() {
54
+ this.value = this._defaultValue || "";
55
+ }
56
+ get value() {
57
+ return this._value;
58
+ }
59
+ set value(e) {
60
+ this._value = e || "", i(this, this._value), this._syncTrigger();
61
+ }
62
+ _firstDay() {
63
+ let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
64
+ return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
65
+ }
66
+ render() {
67
+ this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
68
+ let e = this.getAttribute("placeholder") || "Enter Date", t = u(this._value);
69
+ t && (this._viewY = t.y, this._viewM = t.m);
70
+ let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "", c = this.getAttribute("aria-label"), l = this.getAttribute("aria-describedby");
71
+ this.innerHTML = `
72
+ <div class="datepicker">
73
+ <button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""}${c ? ` aria-label="${o(c)}"` : ""}${l ? ` aria-describedby="${o(l)}"` : ""}>
74
+ <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? s(this._value) : o(e)}</span>
75
+ ${a("calendar-dots")}
76
+ </button>
77
+ <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
78
+ </div>`, this._rendered = !0, i(this, this._value), this._wire();
79
+ }
80
+ _syncFormValue() {
81
+ i(this, this._value);
82
+ }
83
+ _syncTrigger() {
84
+ let e = this.querySelector(".datepicker-trigger"), t = this.querySelector("[data-trigger-label]");
85
+ if (!t) return;
86
+ let n = u(this._value);
87
+ t.textContent = n ? s(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
88
+ }
89
+ _limits() {
90
+ let e = u(this.getAttribute("min")), t = u(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
91
+ return {
92
+ dayDisabled: (e, t, i) => {
93
+ let a = new Date(e, t, i).getTime();
94
+ return a < n || a > r;
95
+ },
96
+ monthDisabled: (e, t) => {
97
+ let i = new Date(e, t, 1).getTime();
98
+ return new Date(e, t, c(e, t)).getTime() < n || i > r;
99
+ },
100
+ yearDisabled: (e) => {
101
+ let t = new Date(e, 0, 1).getTime();
102
+ return new Date(e, 11, 31).getTime() < n || t > r;
103
+ }
104
+ };
105
+ }
106
+ _renderView() {
107
+ let e = this.querySelector(".datepicker-pop");
108
+ e && (this._mode === "months" ? e.innerHTML = this._monthsHtml() : this._mode === "years" ? e.innerHTML = this._yearsHtml() : e.innerHTML = this._daysHtml(), this._focusActive());
109
+ }
110
+ _daysHtml() {
111
+ let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = c(this._viewY, this._viewM), r = u(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: o } = this._limits(), s = this._focus || r || {
112
+ y: this._viewY,
113
+ m: this._viewM,
114
+ d: 1
115
+ }, m = (e, t, n, a) => {
116
+ let c = f(e, t, n), l = r && r.y === e && r.m === t && r.d === n, u = i.getFullYear() === e && i.getMonth() === t && i.getDate() === n, d = s.y === e && s.m === t && s.d === n, p = o(e, t, n);
117
+ return `<button type="button" class="${[
118
+ "datepicker-day",
119
+ a ? "is-outside" : "",
120
+ u ? "is-today" : "",
121
+ l ? "is-selected" : ""
122
+ ].filter(Boolean).join(" ")}" data-iso="${c}" role="gridcell" tabindex="${d && !p ? "0" : "-1"}"${l ? " aria-selected=\"true\"" : ""}${p ? " disabled aria-disabled=\"true\"" : ""}>${n}</button>`;
123
+ }, h = "", g = d(this._viewY, this._viewM - 1), _ = c(g.y, g.m);
124
+ for (let e = t - 1; e >= 0; e--) h += m(g.y, g.m, _ - e, !0);
125
+ for (let e = 1; e <= n; e++) h += m(this._viewY, this._viewM, e, !1);
126
+ let v = d(this._viewY, this._viewM + 1), y = (7 - (t + n) % 7) % 7;
127
+ for (let e = 1; e <= y; e++) h += m(v.y, v.m, e, !0);
128
+ let b = o(i.getFullYear(), i.getMonth(), i.getDate()), x = l.map((t, n) => l[(n + e) % 7]).map((e) => `<span>${e}</span>`).join("");
129
+ return `
130
+ <div class="datepicker-head">
131
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${a("chevron-left")}</button>
132
+ <button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${p[this._viewM]} ${this._viewY}</button>
133
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${a("chevron-right")}</button>
134
+ </div>
135
+ <div class="datepicker-weekdays">${x}</div>
136
+ <div class="datepicker-grid${this._slide ? ` ${this._slide}` : ""}" role="grid">${h}</div>
137
+ <div class="datepicker-foot">
138
+ <button type="button" class="datepicker-link" data-today${b ? " disabled" : ""}>Today</button>
139
+ <button type="button" class="datepicker-link" data-clear>Clear</button>
140
+ </div>`;
141
+ }
142
+ _monthsHtml() {
143
+ let e = u(this._value), t = /* @__PURE__ */ new Date(), { monthDisabled: n } = this._limits(), r = "";
144
+ for (let i = 0; i < 12; i++) {
145
+ let a = e && e.y === this._viewY && e.m === i, o = t.getFullYear() === this._viewY && t.getMonth() === i, s = n(this._viewY, i), c = [
146
+ "datepicker-cell",
147
+ o ? "is-today" : "",
148
+ a ? "is-selected" : ""
149
+ ].filter(Boolean).join(" ");
150
+ r += `<button type="button" class="${c}" data-month="${i}"${s ? " disabled" : ""}>${p[i].slice(0, 3)}</button>`;
151
+ }
152
+ return `
153
+ <div class="datepicker-head">
154
+ <button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year">${a("chevron-left")}</button>
155
+ <button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
156
+ <button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year">${a("chevron-right")}</button>
157
+ </div>
158
+ <div class="datepicker-cells">${r}</div>`;
159
+ }
160
+ _yearsHtml() {
161
+ let e = u(this._value), t = (/* @__PURE__ */ new Date()).getFullYear(), { yearDisabled: n } = this._limits(), r = this._viewY - (this._viewY % 10 + 10) % 10 - 1, i = "";
162
+ for (let a = 0; a < 12; a++) {
163
+ let o = r + a, s = e && e.y === o, c = t === o, l = n(o), u = [
164
+ "datepicker-cell",
165
+ c ? "is-today" : "",
166
+ s ? "is-selected" : ""
167
+ ].filter(Boolean).join(" ");
168
+ i += `<button type="button" class="${u}" data-year="${o}"${l ? " disabled" : ""}>${o}</button>`;
169
+ }
170
+ return `
171
+ <div class="datepicker-head">
172
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${a("chevron-left")}</button>
173
+ <span class="datepicker-month">${r + 1} to ${r + 10}</span>
174
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${a("chevron-right")}</button>
175
+ </div>
176
+ <div class="datepicker-cells">${i}</div>`;
177
+ }
178
+ _focusActive() {
179
+ let e = this.querySelector(".datepicker-pop"), t = e?.querySelector("[tabindex=\"0\"]") || e?.querySelector(".is-selected") || e?.querySelector(".datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)");
180
+ t && e.contains(document.activeElement) && t.focus();
181
+ }
182
+ _position(e, t) {
183
+ r(e, t, { clampHeight: !0 });
184
+ }
185
+ _setFocus(e, t, n, r) {
186
+ let { y: i, m: a } = d(e, t);
187
+ this._focus = {
188
+ y: i,
189
+ m: a,
190
+ d: n
191
+ };
192
+ let o = i !== this._viewY || a !== this._viewM;
193
+ this._viewY = i, this._viewM = a, this._slide = o && r || "", this._renderView(), this._slide = "", this.querySelector(`.datepicker-day[data-iso="${f(i, a, n)}"]`)?.focus();
194
+ }
195
+ _onKey(e) {
196
+ if (this._mode !== "days") {
197
+ e.key === "Escape" && this._close();
198
+ return;
199
+ }
200
+ let t = this._focus || u(this._value) || {
201
+ y: this._viewY,
202
+ m: this._viewM,
203
+ d: 1
204
+ }, n = (n, r) => {
205
+ e.preventDefault();
206
+ let i = new Date(t.y, t.m, t.d + n);
207
+ this._setFocus(i.getFullYear(), i.getMonth(), i.getDate(), r);
208
+ };
209
+ switch (e.key) {
210
+ case "ArrowLeft": return n(-1, "slide-prev");
211
+ case "ArrowRight": return n(1, "slide-next");
212
+ case "ArrowUp": return n(-7, "slide-prev");
213
+ case "ArrowDown": return n(7, "slide-next");
214
+ case "Home": return n(-((new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7), "slide-prev");
215
+ case "End": return n(6 - (new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7, "slide-next");
216
+ case "PageUp": {
217
+ e.preventDefault();
218
+ let n = d(t.y, t.m - (e.shiftKey ? 12 : 1));
219
+ return this._setFocus(n.y, n.m, Math.min(t.d, c(n.y, n.m)), "slide-prev");
220
+ }
221
+ case "PageDown": {
222
+ e.preventDefault();
223
+ let n = d(t.y, t.m + (e.shiftKey ? 12 : 1));
224
+ return this._setFocus(n.y, n.m, Math.min(t.d, c(n.y, n.m)), "slide-next");
225
+ }
226
+ case "Enter":
227
+ case " ":
228
+ e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = f(t.y, t.m, t.d), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
229
+ return;
230
+ case "Escape": return this._close();
231
+ default:
232
+ }
233
+ }
234
+ _wire() {
235
+ this._teardown();
236
+ let e = this.querySelector(".datepicker-trigger"), r = this.querySelector(".datepicker-pop"), i = this.querySelector(".datepicker");
237
+ if (!e || !r) return;
238
+ let a = () => !r.hidden, o = () => {
239
+ a() && this._position(e, r);
240
+ };
241
+ this._open = () => {
242
+ let n = /* @__PURE__ */ new Date(), a = u(this._value);
243
+ (a || !this._viewNavigated) && (this._viewY = n.getFullYear(), this._viewM = n.getMonth()), this._mode = "days";
244
+ let s = n.getFullYear() === this._viewY && n.getMonth() === this._viewM, c = a && a.y === this._viewY && a.m === this._viewM;
245
+ this._focus = c ? a : {
246
+ y: this._viewY,
247
+ m: this._viewM,
248
+ d: s ? n.getDate() : 1
249
+ }, this._renderView(), r.hidden = !1, i?.classList.add("open"), this._position(e, r), t(this, o), e.setAttribute("aria-expanded", "true"), r.querySelector("[tabindex=\"0\"]")?.focus();
250
+ }, this._close = () => {
251
+ r.hidden = !0, i?.classList.remove("open"), e.setAttribute("aria-expanded", "false"), n(this), e.focus();
252
+ }, e.addEventListener("click", () => a() ? this._close() : this._open()), r.addEventListener("click", (e) => {
253
+ this._popClick = !0;
254
+ let t = e.target.closest("[data-nav]");
255
+ if (t) {
256
+ this._viewNavigated = !0, this._slide = Number(t.dataset.nav) < 0 ? "slide-prev" : "slide-next";
257
+ let e = d(this._viewY, this._viewM + Number(t.dataset.nav));
258
+ this._viewY = e.y, this._viewM = e.m, this._focus = {
259
+ y: e.y,
260
+ m: e.m,
261
+ d: 1
262
+ }, this._renderView(), this._slide = "";
263
+ return;
264
+ }
265
+ let n = e.target.closest("[data-nav-year]");
266
+ if (n) {
267
+ this._viewY += Number(n.dataset.navYear), this._renderView();
268
+ return;
269
+ }
270
+ let r = e.target.closest("[data-nav-decade]");
271
+ if (r) {
272
+ this._viewY += Number(r.dataset.navDecade) * 10, this._renderView();
273
+ return;
274
+ }
275
+ let i = e.target.closest("[data-view]");
276
+ if (i) {
277
+ this._mode = i.dataset.view, this._renderView();
278
+ return;
279
+ }
280
+ let a = e.target.closest("[data-month]");
281
+ if (a && !a.disabled) {
282
+ this._viewNavigated = !0, this._viewM = Number(a.dataset.month), this._mode = "days", this._focus = {
283
+ y: this._viewY,
284
+ m: this._viewM,
285
+ d: 1
286
+ }, this._renderView();
287
+ return;
288
+ }
289
+ let o = e.target.closest("[data-year]");
290
+ if (o && !o.disabled) {
291
+ this._viewNavigated = !0, this._viewY = Number(o.dataset.year), this._mode = "months", this._renderView();
292
+ return;
293
+ }
294
+ if (e.target.closest("[data-today]")) {
295
+ let e = /* @__PURE__ */ new Date();
296
+ if (this._limits().dayDisabled(e.getFullYear(), e.getMonth(), e.getDate())) return;
297
+ this.value = f(e.getFullYear(), e.getMonth(), e.getDate()), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
298
+ return;
299
+ }
300
+ if (e.target.closest("[data-clear]")) {
301
+ this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
302
+ return;
303
+ }
304
+ let s = e.target.closest(".datepicker-day[data-iso]");
305
+ s && !s.disabled && (this.value = s.dataset.iso, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
306
+ }), this._onKeyBound = (e) => {
307
+ a() && this._onKey(e);
308
+ }, r.addEventListener("keydown", this._onKeyBound), this._bindGlobal = () => {
309
+ this._teardown(), this._onDocClick = (e) => {
310
+ let t = this._popClick;
311
+ this._popClick = !1, a() && !t && !this.contains(e.target) && this._close();
312
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
313
+ a() && e.key === "Escape" && this._close();
314
+ }, document.addEventListener("keydown", this._onDocKey), a() && t(this, o);
315
+ }, this._bindGlobal(), this._syncFormValue();
316
+ }
317
+ _teardown() {
318
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), n(this);
319
+ }
320
+ disconnectedCallback() {
321
+ this._teardown();
322
+ }
323
+ };
324
+ //#endregion
325
+ export { m as t };
@@ -0,0 +1,233 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { n as t, r as n, t as r } from "./anchorOverlay-DluGZ8ef.js";
3
+ import { t as i } from "./iconGlyphs.g-Cpg1BUHm.js";
4
+ import { n as a } from "./optionLabel-Dn-I7zyp.js";
5
+ import { a as o, i as s, n as c, o as l, r as u, s as d, t as f } from "./calendarMath-BAF2Jkg_.js";
6
+ //#region src/WuiDateRange.js
7
+ var p = class extends e {
8
+ static formAssociated = !0;
9
+ static get observedAttributes() {
10
+ return [
11
+ "start",
12
+ "end",
13
+ "min",
14
+ "max",
15
+ "placeholder",
16
+ "disabled",
17
+ "first-day",
18
+ "size",
19
+ "aria-label",
20
+ "aria-describedby",
21
+ "name",
22
+ "start-name",
23
+ "end-name",
24
+ "aria-invalid"
25
+ ];
26
+ }
27
+ constructor() {
28
+ super();
29
+ try {
30
+ this._internals = this.attachInternals();
31
+ } catch {
32
+ this._internals = null;
33
+ }
34
+ this._start = "", this._end = "", this._hover = "";
35
+ let e = new Date(2e3, 0, 1);
36
+ this._viewY = e.getFullYear(), this._viewM = e.getMonth();
37
+ }
38
+ connectedCallback() {
39
+ if (!this._rendered) {
40
+ this.render();
41
+ return;
42
+ }
43
+ this._bindGlobal?.();
44
+ }
45
+ attributeChangedCallback(e, t, n) {
46
+ if (e === "aria-invalid") {
47
+ this._syncInvalid();
48
+ return;
49
+ }
50
+ this._rendered && (e === "start" || e === "end" ? (this._start = this.getAttribute("start") || "", this._end = this.getAttribute("end") || "", this._syncTrigger(), this._syncMirrors()) : this.render());
51
+ }
52
+ _syncInvalid() {
53
+ let e = this.querySelector(".daterange-trigger");
54
+ e && (this.hasAttribute("aria-invalid") ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"));
55
+ }
56
+ get value() {
57
+ return {
58
+ start: this._start,
59
+ end: this._end
60
+ };
61
+ }
62
+ set value(e) {
63
+ this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors();
64
+ }
65
+ _firstDay() {
66
+ let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
67
+ return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
68
+ }
69
+ _label() {
70
+ let e = this.getAttribute("placeholder") || "Start to End";
71
+ return !this._start && !this._end ? {
72
+ text: e,
73
+ empty: !0
74
+ } : {
75
+ text: `${o(this._start) || "Start"} to ${o(this._end) || "End"}`,
76
+ empty: !1
77
+ };
78
+ }
79
+ render() {
80
+ this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || "", this._start = this._defaultStart || this._start, this._end = this._defaultEnd || this._end);
81
+ let e = l(this._start);
82
+ e && (this._viewY = e.y, this._viewM = e.m);
83
+ let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: o } = this._label(), s = this.getAttribute("aria-label"), c = this.getAttribute("aria-describedby");
84
+ this.innerHTML = `
85
+ <div class="daterange">
86
+ <button type="button" class="input daterange-trigger${n}${o ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""}${s ? ` aria-label="${a(s)}"` : ""}${c ? ` aria-describedby="${a(c)}"` : ""}>
87
+ <span data-range-label class="${o ? "search-select-placeholder" : ""}">${a(r)}</span>
88
+ ${i("calendar")}
89
+ </button>
90
+ <div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
91
+ </div>`, this._rendered = !0, this._syncMirrors(), this._wire();
92
+ }
93
+ formResetCallback() {
94
+ this.value = {
95
+ start: this._defaultStart || "",
96
+ end: this._defaultEnd || ""
97
+ };
98
+ }
99
+ _syncTrigger() {
100
+ let e = this.querySelector(".daterange-trigger"), t = this.querySelector("[data-range-label]");
101
+ if (!t) return;
102
+ let { text: n, empty: r } = this._label();
103
+ t.textContent = n, t.classList.toggle("search-select-placeholder", r), e?.classList.toggle("has-value", !r);
104
+ }
105
+ _syncMirrors() {
106
+ let e = this.getAttribute("start-name") || this.getAttribute("name"), t = this.getAttribute("end-name");
107
+ this._mirror("start", e, this._start), this._mirror("end", t, this._end);
108
+ }
109
+ _mirror(e, t, n) {
110
+ if (!t) return;
111
+ let r = this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`);
112
+ r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-range-mirror", e), this.appendChild(r)), r.name = t, r.value = n || "", r.disabled = this.hasAttribute("disabled");
113
+ }
114
+ _limits() {
115
+ let e = l(this.getAttribute("min")), t = l(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
116
+ return (e, t, i) => {
117
+ let a = new Date(e, t, i).getTime();
118
+ return a < n || a > r;
119
+ };
120
+ }
121
+ _monthHtml(e, t) {
122
+ let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = s(e, t), a = this._limits(), o = c.map((e, t) => c[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), l = (e, t, n, r) => {
123
+ let i = d(e, t, n), o = a(e, t, n);
124
+ return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
125
+ }, p = "", m = u(e, t - 1), h = s(m.y, m.m);
126
+ for (let e = r - 1; e >= 0; e--) p += l(m.y, m.m, h - e, !0);
127
+ for (let n = 1; n <= i; n++) p += l(e, t, n, !1);
128
+ let g = u(e, t + 1), _ = (7 - (r + i) % 7) % 7;
129
+ for (let e = 1; e <= _; e++) p += l(g.y, g.m, e, !0);
130
+ return `
131
+ <div class="daterange-cal">
132
+ <div class="datepicker-month-label">${f[t]} ${e}</div>
133
+ <div class="datepicker-weekdays">${o}</div>
134
+ <div class="datepicker-grid" role="grid">${p}</div>
135
+ </div>`;
136
+ }
137
+ _renderView() {
138
+ let e = this.querySelector(".daterange-pop");
139
+ if (!e) return;
140
+ let t = u(this._viewY, this._viewM + 1);
141
+ e.innerHTML = `
142
+ <div class="daterange-head">
143
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${i("chevron-left")}</button>
144
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${i("chevron-right")}</button>
145
+ </div>
146
+ <div class="daterange-cals">
147
+ ${this._monthHtml(this._viewY, this._viewM)}
148
+ ${this._monthHtml(t.y, t.m)}
149
+ </div>
150
+ <div class="datepicker-foot">
151
+ <span class="daterange-hint" data-range-hint></span>
152
+ <button type="button" class="datepicker-link" data-clear>Clear</button>
153
+ </div>`, this._paint();
154
+ }
155
+ _paint() {
156
+ let e = this.querySelector(".daterange-pop");
157
+ if (!e) return;
158
+ let t = this._start ? new Date(this._start).getTime() : null, n = this._end;
159
+ t && !this._end && this._hover && new Date(this._hover).getTime() >= t && (n = this._hover);
160
+ let r = n ? new Date(n).getTime() : null;
161
+ for (let n of e.querySelectorAll(".datepicker-day[data-iso]")) {
162
+ let e = new Date(n.dataset.iso).getTime(), i = t != null && e === t, a = r != null && e === r, o = t != null && r != null && e > t && e < r;
163
+ n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
164
+ }
165
+ let i = e.querySelector("[data-range-hint]");
166
+ i && (i.textContent = this._start ? this._end ? `${o(this._start)} to ${o(this._end)}` : "Pick an end date" : "Pick a start date");
167
+ }
168
+ _position(e, t) {
169
+ r(e, t, { clampHeight: !0 });
170
+ }
171
+ _pick(e) {
172
+ if (!this._start || this._start && this._end) {
173
+ this._start = e, this._end = "", this._hover = "", this._syncTrigger(), this._syncMirrors(), this._paint();
174
+ return;
175
+ }
176
+ if (new Date(e).getTime() < new Date(this._start).getTime()) {
177
+ this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
178
+ return;
179
+ }
180
+ this._end = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
181
+ }
182
+ _wire() {
183
+ this._teardown();
184
+ let e = this.querySelector(".daterange-trigger"), r = this.querySelector(".daterange-pop"), i = this.querySelector(".daterange");
185
+ if (!e || !r) return;
186
+ let a = () => !r.hidden, o = () => {
187
+ a() && this._position(e, r);
188
+ };
189
+ this._open = () => {
190
+ let n = l(this._start);
191
+ if (n) this._viewY = n.y, this._viewM = n.m;
192
+ else {
193
+ let e = /* @__PURE__ */ new Date();
194
+ this._viewY = e.getFullYear(), this._viewM = e.getMonth();
195
+ }
196
+ this._renderView(), r.hidden = !1, i?.classList.add("open"), this._position(e, r), t(this, o), e.setAttribute("aria-expanded", "true");
197
+ }, this._close = () => {
198
+ r.hidden = !0, this._hover = "", i?.classList.remove("open"), e.setAttribute("aria-expanded", "false"), n(this);
199
+ }, e.addEventListener("click", () => a() ? this._close() : this._open()), r.addEventListener("click", (e) => {
200
+ this._popClick = !0;
201
+ let t = e.target.closest("[data-nav]");
202
+ if (t) {
203
+ let e = u(this._viewY, this._viewM + Number(t.dataset.nav));
204
+ this._viewY = e.y, this._viewM = e.m, this._renderView();
205
+ return;
206
+ }
207
+ if (e.target.closest("[data-clear]")) {
208
+ this._start = "", this._end = "", this._hover = "", this._syncTrigger(), this._syncMirrors(), this._renderView(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
209
+ return;
210
+ }
211
+ let n = e.target.closest(".datepicker-day[data-iso]");
212
+ n && !n.disabled && this._pick(n.dataset.iso);
213
+ }), r.addEventListener("mouseover", (e) => {
214
+ let t = e.target.closest(".datepicker-day[data-iso]");
215
+ t && this._start && !this._end && (this._hover = t.dataset.iso, this._paint());
216
+ }), this._bindGlobal = () => {
217
+ this._teardown(), this._onDocClick = (e) => {
218
+ let t = this._popClick;
219
+ this._popClick = !1, a() && !t && !this.contains(e.target) && this._close();
220
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
221
+ a() && e.key === "Escape" && this._close();
222
+ }, document.addEventListener("keydown", this._onDocKey), a() && t(this, o);
223
+ }, this._bindGlobal(), this._syncMirrors();
224
+ }
225
+ _teardown() {
226
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), n(this);
227
+ }
228
+ disconnectedCallback() {
229
+ this._teardown();
230
+ }
231
+ };
232
+ //#endregion
233
+ export { p as t };
@@ -0,0 +1,57 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ //#region src/WuiDock.js
3
+ var t = class extends e {
4
+ static get observedAttributes() {
5
+ return [
6
+ "static",
7
+ "max-scale",
8
+ "radius"
9
+ ];
10
+ }
11
+ constructor() {
12
+ super(), this._pointerMoveListener = null, this._pointerLeaveListener = null, this._frame = 0, this._pointerX = 0;
13
+ }
14
+ connectedCallback() {
15
+ this._wire();
16
+ }
17
+ disconnectedCallback() {
18
+ this._teardown();
19
+ }
20
+ attributeChangedCallback(e, t, n) {
21
+ e === "static" && this.isConnected && this._wire();
22
+ }
23
+ _maxScale() {
24
+ return n(this.getAttribute("max-scale"), 1.6);
25
+ }
26
+ _radius() {
27
+ return n(this.getAttribute("radius"), 100);
28
+ }
29
+ _magnifyEnabled() {
30
+ return !(this.hasAttribute("static") || typeof matchMedia == "function" && (matchMedia("(pointer: coarse)").matches || matchMedia("(prefers-reduced-motion: reduce)").matches));
31
+ }
32
+ _applyMagnification() {
33
+ this._frame = 0;
34
+ let e = this._maxScale(), t = this._radius();
35
+ for (let n of this.querySelectorAll(".dock-item")) {
36
+ let r = n.getBoundingClientRect(), i = Math.abs(this._pointerX - (r.left + r.width / 2)), a = Math.max(0, 1 - i / t), o = 1 + (e - 1) * a;
37
+ n.style.setProperty("--wui-dock-mag", o.toFixed(3));
38
+ }
39
+ }
40
+ _resetMagnification() {
41
+ this._frame &&= (cancelAnimationFrame(this._frame), 0);
42
+ for (let e of this.querySelectorAll(".dock-item")) e.style.removeProperty("--wui-dock-mag");
43
+ }
44
+ _wire() {
45
+ this._teardown(), this._magnifyEnabled() && (this._pointerMoveListener = (e) => {
46
+ this._pointerX = e.clientX, this._frame ||= requestAnimationFrame(() => this._applyMagnification());
47
+ }, this._pointerLeaveListener = () => this._resetMagnification(), this.addEventListener("pointermove", this._pointerMoveListener), this.addEventListener("pointerleave", this._pointerLeaveListener));
48
+ }
49
+ _teardown() {
50
+ this._pointerMoveListener &&= (this.removeEventListener("pointermove", this._pointerMoveListener), null), this._pointerLeaveListener &&= (this.removeEventListener("pointerleave", this._pointerLeaveListener), null), this._resetMagnification();
51
+ }
52
+ }, n = (e, t) => {
53
+ let n = Number.parseFloat(e);
54
+ return Number.isFinite(n) ? n : t;
55
+ };
56
+ //#endregion
57
+ export { t };