@stimulus-plumbers/controllers 0.3.3 → 0.4.1
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 +31 -8
- package/dist/controllers.manifest.json +386 -0
- package/dist/stimulus-plumbers-controllers.es.js +756 -304
- package/dist/stimulus-plumbers-controllers.umd.js +1 -1
- package/package.json +3 -4
- package/src/accessibility/aria.js +6 -0
- package/src/accessibility/focus.js +4 -20
- package/src/accessibility/keyboard.js +134 -28
- package/src/controllers/calendar_decade_controller.js +99 -0
- package/src/controllers/calendar_decade_selector_controller.js +14 -0
- package/src/controllers/calendar_month_controller.js +71 -19
- package/src/controllers/calendar_month_selector_controller.js +14 -0
- package/src/controllers/calendar_year_controller.js +104 -0
- package/src/controllers/calendar_year_selector_controller.js +14 -0
- package/src/controllers/combobox_date_controller.js +90 -5
- package/src/controllers/combobox_dropdown_controller.js +12 -25
- package/src/controllers/input_combobox_controller.js +2 -42
- package/src/controllers/modal_controller.js +4 -1
- package/src/controllers/popover_controller.js +39 -12
- package/src/controllers/timeline_controller.js +71 -0
- package/src/index.js +6 -1
- package/src/plumbers/calendar-selector.js +85 -0
- package/src/plumbers/calendar.js +44 -10
- package/src/plumbers/index.js +5 -0
- package/src/plumbers/visibility.js +3 -3
- package/src/controllers/calendar_month_observer_controller.js +0 -27
|
@@ -33,7 +33,7 @@ var a = class {
|
|
|
33
33
|
if (!this.isActive) return;
|
|
34
34
|
this.isActive = !1, this.container.removeEventListener("keydown", this.handleKeyDown);
|
|
35
35
|
let e = this.options.returnFocus || this.previouslyFocused;
|
|
36
|
-
e && r(e) && e.focus();
|
|
36
|
+
e && r(e) && e.focus(), typeof this.options.onDeactivate == "function" && this.options.onDeactivate();
|
|
37
37
|
}
|
|
38
38
|
handleKeyDown = (e) => {
|
|
39
39
|
if (e.key === "Escape" && this.options.escapeDeactivates) {
|
|
@@ -46,26 +46,16 @@ var a = class {
|
|
|
46
46
|
let r = t[0], i = t[t.length - 1];
|
|
47
47
|
e.shiftKey && document.activeElement === r ? (e.preventDefault(), i.focus()) : !e.shiftKey && document.activeElement === i && (e.preventDefault(), r.focus());
|
|
48
48
|
};
|
|
49
|
-
}, o = class {
|
|
50
|
-
constructor() {
|
|
51
|
-
this.savedElement = null;
|
|
52
|
-
}
|
|
53
|
-
save() {
|
|
54
|
-
this.savedElement = document.activeElement;
|
|
55
|
-
}
|
|
56
|
-
restore() {
|
|
57
|
-
this.savedElement && r(this.savedElement) && (this.savedElement.focus(), this.savedElement = null);
|
|
58
|
-
}
|
|
59
49
|
};
|
|
60
50
|
//#endregion
|
|
61
51
|
//#region src/accessibility/keyboard.js
|
|
62
|
-
function
|
|
52
|
+
function o(e, t) {
|
|
63
53
|
return e.key === t;
|
|
64
54
|
}
|
|
65
|
-
function
|
|
55
|
+
function s(e) {
|
|
66
56
|
return e.key === "Enter" || e.key === " ";
|
|
67
57
|
}
|
|
68
|
-
function
|
|
58
|
+
function c(e) {
|
|
69
59
|
return [
|
|
70
60
|
"ArrowUp",
|
|
71
61
|
"ArrowDown",
|
|
@@ -73,60 +63,135 @@ function l(e) {
|
|
|
73
63
|
"ArrowRight"
|
|
74
64
|
].includes(e.key);
|
|
75
65
|
}
|
|
76
|
-
function
|
|
66
|
+
function l(e) {
|
|
77
67
|
e.preventDefault(), e.stopPropagation();
|
|
78
68
|
}
|
|
79
|
-
var
|
|
80
|
-
constructor(e, t =
|
|
81
|
-
this.items = e, this.currentIndex = t, this.
|
|
69
|
+
var u = class {
|
|
70
|
+
constructor(e, t = {}) {
|
|
71
|
+
this.items = Array.from(e), this.currentIndex = t.initialIndex ?? 0, this.orientation = t.orientation ?? "both", this.wrap = t.wrap ?? !0, this._handleKeyDown = this._handleKeyDown.bind(this), this._handleClick = this._handleClick.bind(this);
|
|
82
72
|
}
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
activate() {
|
|
74
|
+
return this.updateTabIndex(), this.items.forEach((e) => {
|
|
75
|
+
e.addEventListener("keydown", this._handleKeyDown), e.addEventListener("click", this._handleClick);
|
|
76
|
+
}), this;
|
|
77
|
+
}
|
|
78
|
+
deactivate() {
|
|
79
|
+
this.items.forEach((e) => {
|
|
80
|
+
e.removeEventListener("keydown", this._handleKeyDown), e.removeEventListener("click", this._handleClick);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
updateItems(e) {
|
|
84
|
+
this.deactivate(), this.items = Array.from(e), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.items.length - 1)), this.activate();
|
|
85
|
+
}
|
|
86
|
+
setCurrentIndex(e) {
|
|
87
|
+
e >= 0 && e < this.items.length && (this.currentIndex = e, this.updateTabIndex(), this.items[e].focus());
|
|
88
|
+
}
|
|
89
|
+
updateTabIndex() {
|
|
90
|
+
this.items.forEach((e, t) => {
|
|
91
|
+
e.tabIndex = t === this.currentIndex ? 0 : -1;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
_handleClick(e) {
|
|
95
|
+
let t = this.items.indexOf(e.currentTarget);
|
|
96
|
+
t !== -1 && (this.currentIndex = t, this.updateTabIndex());
|
|
97
|
+
}
|
|
98
|
+
_handleKeyDown(e) {
|
|
99
|
+
let t = this.items.indexOf(e.currentTarget);
|
|
100
|
+
t !== -1 && t !== this.currentIndex && (this.currentIndex = t, this.updateTabIndex());
|
|
101
|
+
let n = this.orientation === "horizontal" ? [] : ["ArrowUp", "ArrowDown"], r = this.orientation === "vertical" ? [] : ["ArrowLeft", "ArrowRight"];
|
|
102
|
+
if (![
|
|
103
|
+
...n,
|
|
104
|
+
...r,
|
|
105
|
+
"Home",
|
|
106
|
+
"End"
|
|
107
|
+
].includes(e.key)) return;
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
let i = t === -1 ? this.currentIndex : t, a;
|
|
85
110
|
switch (e.key) {
|
|
86
111
|
case "ArrowDown":
|
|
87
112
|
case "ArrowRight":
|
|
88
|
-
|
|
113
|
+
a = this.wrap ? (i + 1) % this.items.length : Math.min(i + 1, this.items.length - 1);
|
|
89
114
|
break;
|
|
90
115
|
case "ArrowUp":
|
|
91
116
|
case "ArrowLeft":
|
|
92
|
-
|
|
117
|
+
a = this.wrap ? (i - 1 + this.items.length) % this.items.length : Math.max(i - 1, 0);
|
|
93
118
|
break;
|
|
94
119
|
case "Home":
|
|
95
|
-
|
|
120
|
+
a = 0;
|
|
96
121
|
break;
|
|
97
122
|
case "End":
|
|
98
|
-
|
|
123
|
+
a = this.items.length - 1;
|
|
99
124
|
break;
|
|
100
|
-
default: return;
|
|
101
125
|
}
|
|
102
|
-
this.setCurrentIndex(
|
|
126
|
+
this.setCurrentIndex(a);
|
|
103
127
|
}
|
|
104
|
-
|
|
105
|
-
|
|
128
|
+
}, d = class {
|
|
129
|
+
constructor(e, t = {}) {
|
|
130
|
+
this.listbox = e, this.itemSelector = t.itemSelector ?? "[role=\"option\"]:not([aria-disabled=\"true\"]):not([hidden])", this.wrap = t.wrap ?? !1, this.orientation = t.orientation ?? "vertical";
|
|
106
131
|
}
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
e.tabIndex = t === this.currentIndex ? 0 : -1;
|
|
110
|
-
});
|
|
132
|
+
get selectedItem() {
|
|
133
|
+
return this.listbox.querySelector(`${this.itemSelector}[aria-selected="true"]`) ?? null;
|
|
111
134
|
}
|
|
112
|
-
|
|
113
|
-
|
|
135
|
+
get currentIndex() {
|
|
136
|
+
return Array.from(this.listbox.querySelectorAll(this.itemSelector)).indexOf(this.selectedItem);
|
|
137
|
+
}
|
|
138
|
+
_selectItem(e) {
|
|
139
|
+
Array.from(this.listbox.querySelectorAll(this.itemSelector)).forEach((e) => e.setAttribute("aria-selected", "false")), e.setAttribute("aria-selected", "true"), e.scrollIntoView({ block: "nearest" });
|
|
140
|
+
}
|
|
141
|
+
step(e) {
|
|
142
|
+
let t = Array.from(this.listbox.querySelectorAll(this.itemSelector));
|
|
143
|
+
if (!t.length) return;
|
|
144
|
+
let n = this.listbox.querySelector(`${this.itemSelector}[aria-selected="true"]`), r = t.indexOf(n), i;
|
|
145
|
+
i = e > 0 ? this.wrap ? t[(r + 1) % t.length] : t[Math.min(r + 1, t.length - 1)] : this.wrap ? t[(r - 1 + t.length) % t.length] : t[Math.max(r - 1, 0)], !(!i || i === n) && this._selectItem(i);
|
|
146
|
+
}
|
|
147
|
+
handleKeyDown(e) {
|
|
148
|
+
let t = this.orientation === "horizontal" ? [] : ["ArrowUp", "ArrowDown"], n = this.orientation === "vertical" ? [] : ["ArrowLeft", "ArrowRight"];
|
|
149
|
+
if (![
|
|
150
|
+
...t,
|
|
151
|
+
...n,
|
|
152
|
+
"Home",
|
|
153
|
+
"End",
|
|
154
|
+
"Enter",
|
|
155
|
+
" "
|
|
156
|
+
].includes(e.key)) return;
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
let r = Array.from(this.listbox.querySelectorAll(this.itemSelector));
|
|
159
|
+
switch (e.key) {
|
|
160
|
+
case "ArrowDown":
|
|
161
|
+
case "ArrowRight":
|
|
162
|
+
this.step(1);
|
|
163
|
+
break;
|
|
164
|
+
case "ArrowUp":
|
|
165
|
+
case "ArrowLeft":
|
|
166
|
+
this.step(-1);
|
|
167
|
+
break;
|
|
168
|
+
case "Home":
|
|
169
|
+
r.length && this._selectItem(r[0]);
|
|
170
|
+
break;
|
|
171
|
+
case "End":
|
|
172
|
+
r.length && this._selectItem(r[r.length - 1]);
|
|
173
|
+
break;
|
|
174
|
+
case "Enter":
|
|
175
|
+
case " ":
|
|
176
|
+
this.listbox.querySelector(`${this.itemSelector}[aria-selected="true"]`)?.click();
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
114
179
|
}
|
|
115
|
-
},
|
|
180
|
+
}, ee = (e, t, n) => {
|
|
116
181
|
let r = document.querySelector(`[data-live-region="${e}"]`);
|
|
117
182
|
return r || (r = document.createElement("div"), r.className = "sr-only", r.dataset.liveRegion = e, r.setAttribute("aria-live", e), r.setAttribute("aria-atomic", t.toString()), r.setAttribute("aria-relevant", n), document.body.appendChild(r)), r;
|
|
118
183
|
};
|
|
119
|
-
function
|
|
120
|
-
let { politeness: n = "polite", atomic: r = !0, relevant: i = "additions text" } = t, a =
|
|
184
|
+
function f(e, t = {}) {
|
|
185
|
+
let { politeness: n = "polite", atomic: r = !0, relevant: i = "additions text" } = t, a = ee(n, r, i);
|
|
121
186
|
a.textContent = "", setTimeout(() => {
|
|
122
187
|
a.textContent = e;
|
|
123
188
|
}, 100);
|
|
124
189
|
}
|
|
125
|
-
var
|
|
190
|
+
var p = (e = "a11y") => `${e}-${Math.random().toString(36).substr(2, 9)}`, m = (e, t = "element") => e.id ||= p(t), h = (e, t, n) => {
|
|
126
191
|
e.setAttribute(t, n.toString());
|
|
127
|
-
},
|
|
128
|
-
function
|
|
129
|
-
|
|
192
|
+
}, g = (e, t) => h(e, "aria-expanded", t), _ = (e, t) => h(e, "aria-pressed", t), te = (e, t) => h(e, "aria-checked", t), v = (e, t) => t ? e.setAttribute("hidden", "") : e.removeAttribute("hidden");
|
|
193
|
+
function ne(e, t) {
|
|
194
|
+
h(e, "aria-disabled", t), t ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex");
|
|
130
195
|
}
|
|
131
196
|
var y = {
|
|
132
197
|
menu: "menu",
|
|
@@ -157,7 +222,7 @@ var C = (e, t) => {
|
|
|
157
222
|
e.hasAttribute(t) && e.removeAttribute(t);
|
|
158
223
|
});
|
|
159
224
|
};
|
|
160
|
-
function
|
|
225
|
+
function re({ trigger: e, target: t, attributes: n = null }) {
|
|
161
226
|
!e || !t || (C(e, n || [
|
|
162
227
|
"aria-controls",
|
|
163
228
|
"aria-haspopup",
|
|
@@ -193,28 +258,28 @@ function T(e, t) {
|
|
|
193
258
|
for (let r = 0; r < t.length && n < e.length; r++) t[r] === e[n] && n++;
|
|
194
259
|
return n === e.length;
|
|
195
260
|
}
|
|
196
|
-
function
|
|
261
|
+
function ie(e, t) {
|
|
197
262
|
return t.includes(e);
|
|
198
263
|
}
|
|
199
|
-
function
|
|
264
|
+
function ae(e, t) {
|
|
200
265
|
return t.startsWith(e);
|
|
201
266
|
}
|
|
202
|
-
function
|
|
203
|
-
return e === "contains" ?
|
|
267
|
+
function oe(e) {
|
|
268
|
+
return e === "contains" ? ie : e === "prefix" ? ae : T;
|
|
204
269
|
}
|
|
205
|
-
function
|
|
270
|
+
function se(e, t) {
|
|
206
271
|
return t === "textContent" ? e.textContent?.trim().toLowerCase() ?? "" : (e.getAttribute(t) ?? "").toLowerCase();
|
|
207
272
|
}
|
|
208
273
|
function E(e, t, n = {}) {
|
|
209
|
-
let { strategy: r = "fuzzy", matcher: i, fields: a = ["textContent"] } = n, o = typeof i == "function" ? i :
|
|
274
|
+
let { strategy: r = "fuzzy", matcher: i, fields: a = ["textContent"] } = n, o = typeof i == "function" ? i : oe(r), s = t.toLowerCase(), c = 0;
|
|
210
275
|
return e.querySelectorAll("[role=\"option\"]").forEach((e) => {
|
|
211
|
-
let t = a.some((t) => o(s,
|
|
276
|
+
let t = a.some((t) => o(s, se(e, t)));
|
|
212
277
|
e.hidden = !t, t && c++;
|
|
213
278
|
}), c;
|
|
214
279
|
}
|
|
215
280
|
//#endregion
|
|
216
281
|
//#region src/plumbers/plumber/geometry.js
|
|
217
|
-
var
|
|
282
|
+
var ce = {
|
|
218
283
|
get top() {
|
|
219
284
|
return "bottom";
|
|
220
285
|
},
|
|
@@ -228,7 +293,7 @@ var D = {
|
|
|
228
293
|
return "left";
|
|
229
294
|
}
|
|
230
295
|
};
|
|
231
|
-
function
|
|
296
|
+
function D({ x: e, y: t, width: n, height: r }) {
|
|
232
297
|
return {
|
|
233
298
|
x: e,
|
|
234
299
|
y: t,
|
|
@@ -240,39 +305,39 @@ function O({ x: e, y: t, width: n, height: r }) {
|
|
|
240
305
|
bottom: t + r
|
|
241
306
|
};
|
|
242
307
|
}
|
|
243
|
-
function
|
|
244
|
-
return
|
|
308
|
+
function O() {
|
|
309
|
+
return D({
|
|
245
310
|
x: 0,
|
|
246
311
|
y: 0,
|
|
247
312
|
width: window.innerWidth || document.documentElement.clientWidth,
|
|
248
313
|
height: window.innerHeight || document.documentElement.clientHeight
|
|
249
314
|
});
|
|
250
315
|
}
|
|
251
|
-
function
|
|
316
|
+
function le(e) {
|
|
252
317
|
if (!(e instanceof HTMLElement)) return !1;
|
|
253
|
-
let t =
|
|
318
|
+
let t = O(), n = e.getBoundingClientRect(), r = n.top <= t.height && n.top + n.height > 0, i = n.left <= t.width && n.left + n.width > 0;
|
|
254
319
|
return r && i;
|
|
255
320
|
}
|
|
256
321
|
//#endregion
|
|
257
322
|
//#region src/plumbers/plumber/config.js
|
|
258
|
-
var
|
|
323
|
+
var k = {
|
|
259
324
|
get visibleOnly() {
|
|
260
325
|
return !0;
|
|
261
326
|
},
|
|
262
327
|
hiddenClass: null
|
|
263
|
-
},
|
|
328
|
+
}, ue = {
|
|
264
329
|
element: null,
|
|
265
330
|
visible: null,
|
|
266
331
|
dispatch: !0,
|
|
267
332
|
prefix: ""
|
|
268
|
-
},
|
|
333
|
+
}, A = class {
|
|
269
334
|
constructor(e, t = {}) {
|
|
270
335
|
this.controller = e;
|
|
271
|
-
let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({},
|
|
272
|
-
this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r :
|
|
336
|
+
let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({}, ue, t);
|
|
337
|
+
this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r : k.visibleOnly, this.visibleCallback = typeof r == "string" ? r : null, this.notify = !!i, this.prefix = typeof a == "string" && a ? a : e.identifier;
|
|
273
338
|
}
|
|
274
339
|
get visible() {
|
|
275
|
-
return this.element instanceof HTMLElement ? this.visibleOnly ?
|
|
340
|
+
return this.element instanceof HTMLElement ? this.visibleOnly ? le(this.element) && this.isVisible(this.element) : !0 : !1;
|
|
276
341
|
}
|
|
277
342
|
isVisible(e) {
|
|
278
343
|
if (this.visibleCallback) {
|
|
@@ -301,7 +366,7 @@ var A = {
|
|
|
301
366
|
return n instanceof Promise ? await n : n;
|
|
302
367
|
}
|
|
303
368
|
}
|
|
304
|
-
},
|
|
369
|
+
}, de = {
|
|
305
370
|
normalize(e) {
|
|
306
371
|
return typeof e == "string" ? e : "";
|
|
307
372
|
},
|
|
@@ -311,7 +376,7 @@ var A = {
|
|
|
311
376
|
};
|
|
312
377
|
//#endregion
|
|
313
378
|
//#region src/plumbers/formatters/credit_card.js
|
|
314
|
-
function
|
|
379
|
+
function fe(e) {
|
|
315
380
|
let t = 0, n = !1;
|
|
316
381
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
317
382
|
let i = parseInt(e[r], 10);
|
|
@@ -319,32 +384,32 @@ function ue(e) {
|
|
|
319
384
|
}
|
|
320
385
|
return t % 10 == 0;
|
|
321
386
|
}
|
|
322
|
-
var
|
|
387
|
+
var pe = /\D/g, me = /^\d{13,19}$/, he = /(.{4})(?=.)/g, ge = {
|
|
323
388
|
normalize(e) {
|
|
324
|
-
return typeof e == "string" ? e.replace(
|
|
389
|
+
return typeof e == "string" ? e.replace(pe, "") : "";
|
|
325
390
|
},
|
|
326
391
|
validate(e) {
|
|
327
|
-
return typeof e != "string" || !
|
|
392
|
+
return typeof e != "string" || !me.test(e) ? !1 : fe(e);
|
|
328
393
|
},
|
|
329
394
|
format(e) {
|
|
330
|
-
return typeof e == "string" ? e.replace(
|
|
395
|
+
return typeof e == "string" ? e.replace(he, "$1 ") : "";
|
|
331
396
|
}
|
|
332
|
-
},
|
|
397
|
+
}, j = { 1: 10 }, M = /\D/g, _e = /^\+\d{7,15}$/, ve = {
|
|
333
398
|
normalize(e) {
|
|
334
399
|
if (typeof e != "string") return "";
|
|
335
|
-
let t = e.trimStart().startsWith("+"), n = e.replace(
|
|
400
|
+
let t = e.trimStart().startsWith("+"), n = e.replace(M, "");
|
|
336
401
|
return t ? `+${n}` : n;
|
|
337
402
|
},
|
|
338
403
|
validate(e) {
|
|
339
404
|
if (typeof e != "string") return !1;
|
|
340
|
-
if (
|
|
341
|
-
let t = e.replace(
|
|
342
|
-
return Object.values(
|
|
405
|
+
if (_e.test(e)) return !0;
|
|
406
|
+
let t = e.replace(M, "");
|
|
407
|
+
return Object.values(j).includes(t.length);
|
|
343
408
|
},
|
|
344
409
|
format(e) {
|
|
345
410
|
if (typeof e != "string") return "";
|
|
346
|
-
let t = e.replace(
|
|
347
|
-
for (let [e, n] of Object.entries(
|
|
411
|
+
let t = e.replace(M, "");
|
|
412
|
+
for (let [e, n] of Object.entries(j)) {
|
|
348
413
|
if (t.length === n) return `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6)}`;
|
|
349
414
|
let r = n + e.length;
|
|
350
415
|
if (t.length === r && t.startsWith(e)) {
|
|
@@ -354,16 +419,16 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
354
419
|
}
|
|
355
420
|
return e;
|
|
356
421
|
}
|
|
357
|
-
},
|
|
422
|
+
}, ye = /[^\d.,-]/g, be = /^-?\d+(\.\d+)?$/, xe = {
|
|
358
423
|
normalize(e) {
|
|
359
424
|
if (typeof e != "string") return "";
|
|
360
|
-
let t = e.replace(
|
|
425
|
+
let t = e.replace(ye, "");
|
|
361
426
|
if (!t) return "";
|
|
362
427
|
let n = t.lastIndexOf(","), r = t.lastIndexOf(".");
|
|
363
428
|
return n > -1 && r > -1 ? n > r ? t.replace(/\./g, "").replace(",", ".") : t.replace(/,/g, "") : n > -1 ? t.slice(n + 1).length <= 2 ? t.replace(",", ".") : t.replace(/,/g, "") : t;
|
|
364
429
|
},
|
|
365
430
|
validate(e) {
|
|
366
|
-
return typeof e == "string" ?
|
|
431
|
+
return typeof e == "string" ? be.test(e) : !1;
|
|
367
432
|
},
|
|
368
433
|
format(e, t = {}) {
|
|
369
434
|
if (typeof e != "string") return "";
|
|
@@ -383,18 +448,18 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
383
448
|
return e;
|
|
384
449
|
}
|
|
385
450
|
}
|
|
386
|
-
},
|
|
451
|
+
}, N = /^\d{4}-\d{2}-\d{2}$/, Se = /^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/, Ce = /\D/g, P = {
|
|
387
452
|
normalize(e) {
|
|
388
453
|
if (typeof e != "string") return "";
|
|
389
454
|
let t = e.trim();
|
|
390
|
-
if (
|
|
391
|
-
let n = t.match(
|
|
455
|
+
if (N.test(t)) return t;
|
|
456
|
+
let n = t.match(Se);
|
|
392
457
|
if (n) {
|
|
393
458
|
let [, e, t, r] = n;
|
|
394
459
|
if (e.length === 4) return `${e}-${t.padStart(2, "0")}-${r.padStart(2, "0")}`;
|
|
395
460
|
if (r.length === 4) return `${r}-${e.padStart(2, "0")}-${t.padStart(2, "0")}`;
|
|
396
461
|
}
|
|
397
|
-
let r = t.replace(
|
|
462
|
+
let r = t.replace(Ce, "");
|
|
398
463
|
if (r.length === 8) {
|
|
399
464
|
let e = parseInt(r.slice(0, 4), 10);
|
|
400
465
|
return e >= 1e3 && e <= 9999 ? `${r.slice(0, 4)}-${r.slice(4, 6)}-${r.slice(6, 8)}` : `${r.slice(4, 8)}-${r.slice(0, 2)}-${r.slice(2, 4)}`;
|
|
@@ -403,8 +468,8 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
403
468
|
},
|
|
404
469
|
validate(e) {
|
|
405
470
|
if (typeof e != "string") return !1;
|
|
406
|
-
let t =
|
|
407
|
-
if (!
|
|
471
|
+
let t = P.normalize(e);
|
|
472
|
+
if (!N.test(t)) return !1;
|
|
408
473
|
let n = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
|
|
409
474
|
return !isNaN(n.getTime()) && n.toISOString().startsWith(t);
|
|
410
475
|
},
|
|
@@ -424,11 +489,11 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
424
489
|
return e;
|
|
425
490
|
}
|
|
426
491
|
}
|
|
427
|
-
},
|
|
492
|
+
}, we = /^([01]?\d|2[0-3]):([0-5]\d)$/, F = {
|
|
428
493
|
normalize(e) {
|
|
429
494
|
if (typeof e != "string") return "";
|
|
430
495
|
let t = e.trim();
|
|
431
|
-
if (
|
|
496
|
+
if (we.test(t)) {
|
|
432
497
|
let [e, n] = t.split(":");
|
|
433
498
|
return `${String(parseInt(e, 10)).padStart(2, "0")}:${n}`;
|
|
434
499
|
}
|
|
@@ -440,7 +505,7 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
440
505
|
return "";
|
|
441
506
|
},
|
|
442
507
|
validate(e) {
|
|
443
|
-
return
|
|
508
|
+
return F.normalize(e) !== "";
|
|
444
509
|
},
|
|
445
510
|
format(e, t = {}) {
|
|
446
511
|
if (typeof e != "string") return "";
|
|
@@ -451,32 +516,32 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
451
516
|
let a = r < 12 ? "AM" : "PM";
|
|
452
517
|
return `${r % 12 || 12}:${i} ${a}`;
|
|
453
518
|
}
|
|
454
|
-
},
|
|
519
|
+
}, I = {
|
|
455
520
|
PLAIN: "plain",
|
|
456
521
|
CREDIT_CARD: "creditCard",
|
|
457
522
|
PHONE: "phone",
|
|
458
523
|
CURRENCY: "currency",
|
|
459
524
|
DATE: "date",
|
|
460
525
|
TIME: "time"
|
|
461
|
-
},
|
|
462
|
-
[
|
|
463
|
-
[
|
|
464
|
-
[
|
|
465
|
-
[
|
|
466
|
-
[
|
|
467
|
-
[
|
|
468
|
-
]),
|
|
469
|
-
type:
|
|
526
|
+
}, L = new Map([
|
|
527
|
+
[I.PLAIN, de],
|
|
528
|
+
[I.CREDIT_CARD, ge],
|
|
529
|
+
[I.PHONE, ve],
|
|
530
|
+
[I.CURRENCY, xe],
|
|
531
|
+
[I.DATE, P],
|
|
532
|
+
[I.TIME, F]
|
|
533
|
+
]), R = {
|
|
534
|
+
type: I.PLAIN,
|
|
470
535
|
options: {}
|
|
471
|
-
},
|
|
536
|
+
}, z = class extends A {
|
|
472
537
|
static register(e, t) {
|
|
473
|
-
|
|
538
|
+
L.set(e, t);
|
|
474
539
|
}
|
|
475
540
|
constructor(e, t = {}) {
|
|
476
|
-
super(e, t), this.type = t.type ??
|
|
541
|
+
super(e, t), this.type = t.type ?? R.type, this.options = t.options ?? R.options, this.enhance();
|
|
477
542
|
}
|
|
478
543
|
enhance() {
|
|
479
|
-
let e = this, t =
|
|
544
|
+
let e = this, t = L.get(e.type) ?? L.get(I.PLAIN), n = {
|
|
480
545
|
normalize: (n) => t.normalize?.(n, e.options) ?? (typeof n == "string" ? n : ""),
|
|
481
546
|
validate: (n) => t.validate?.(n, e.options) ?? !0,
|
|
482
547
|
format: (n) => t.format?.(n, e.options) ?? (typeof n == "string" ? n : ""),
|
|
@@ -490,30 +555,30 @@ var de = /\D/g, fe = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
|
490
555
|
configurable: !0
|
|
491
556
|
});
|
|
492
557
|
}
|
|
493
|
-
},
|
|
494
|
-
function
|
|
558
|
+
}, B = (e, t) => new z(e, t), Te = /^\d{4}-\d{2}-\d{2}$/;
|
|
559
|
+
function V(e) {
|
|
495
560
|
return e instanceof Date && !isNaN(e);
|
|
496
561
|
}
|
|
497
|
-
function
|
|
562
|
+
function H(...e) {
|
|
498
563
|
if (e.length === 0) throw "Missing values to parse as date";
|
|
499
564
|
if (e.length === 1) {
|
|
500
565
|
let t = e[0];
|
|
501
566
|
if (!t) return;
|
|
502
|
-
if (typeof t == "string" &&
|
|
567
|
+
if (typeof t == "string" && Te.test(t)) {
|
|
503
568
|
let [e, n, r] = t.split("-").map(Number), i = new Date(e, n - 1, r);
|
|
504
|
-
if (
|
|
569
|
+
if (V(i)) return i;
|
|
505
570
|
} else {
|
|
506
571
|
let e = new Date(t);
|
|
507
|
-
if (
|
|
572
|
+
if (V(e)) return e;
|
|
508
573
|
}
|
|
509
574
|
} else {
|
|
510
575
|
let t = new Date(...e);
|
|
511
|
-
if (
|
|
576
|
+
if (V(t)) return t;
|
|
512
577
|
}
|
|
513
578
|
}
|
|
514
579
|
//#endregion
|
|
515
580
|
//#region src/plumbers/calendar.js
|
|
516
|
-
var
|
|
581
|
+
var U = 7, Ee = 12, W = 10, G = {
|
|
517
582
|
locales: ["default"],
|
|
518
583
|
today: "",
|
|
519
584
|
day: null,
|
|
@@ -528,18 +593,18 @@ var K = 7, q = {
|
|
|
528
593
|
disabledYears: [],
|
|
529
594
|
firstDayOfWeek: 0,
|
|
530
595
|
onNavigated: "navigated"
|
|
531
|
-
},
|
|
596
|
+
}, De = class extends A {
|
|
532
597
|
constructor(e, t = {}) {
|
|
533
598
|
super(e, t);
|
|
534
|
-
let n = Object.assign({},
|
|
535
|
-
this.onNavigated = r, this.since =
|
|
599
|
+
let n = Object.assign({}, G, t), { onNavigated: r, since: i, till: a, firstDayOfWeek: o } = n;
|
|
600
|
+
this.onNavigated = r, this.since = H(i), this.till = H(a), this.firstDayOfWeek = 0 <= o && o < 7 ? o : G.firstDayOfWeek;
|
|
536
601
|
let { disabledDates: s, disabledWeekdays: c, disabledDays: l, disabledMonths: u, disabledYears: d } = n;
|
|
537
602
|
this.disabledDates = Array.isArray(s) ? s : [], this.disabledWeekdays = Array.isArray(c) ? c : [], this.disabledDays = Array.isArray(l) ? l : [], this.disabledMonths = Array.isArray(u) ? u : [], this.disabledYears = Array.isArray(d) ? d : [];
|
|
538
|
-
let { today:
|
|
539
|
-
this.now =
|
|
603
|
+
let { today: ee, day: f, month: p, year: m } = n;
|
|
604
|
+
this.now = H(ee) || /* @__PURE__ */ new Date(), typeof m == "number" && typeof p == "number" && typeof f == "number" ? this.current = H(m, p, f) : this.current = this.now, this.build(), this.enhance();
|
|
540
605
|
}
|
|
541
606
|
build() {
|
|
542
|
-
this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear();
|
|
607
|
+
this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear(), this.yearsOfDecade = this.buildYearsOfDecade();
|
|
543
608
|
}
|
|
544
609
|
buildDaysOfWeek() {
|
|
545
610
|
let e = new Intl.DateTimeFormat(this.localesValue, { weekday: "long" }), t = new Intl.DateTimeFormat(this.localesValue, { weekday: "short" }), n = /* @__PURE__ */ new Date("2024-10-06"), r = [];
|
|
@@ -572,7 +637,7 @@ var K = 7, q = {
|
|
|
572
637
|
let a = new Date(t, e, i);
|
|
573
638
|
n.push(r(a));
|
|
574
639
|
}
|
|
575
|
-
let s = n.length %
|
|
640
|
+
let s = n.length % U, c = s === 0 ? 0 : U - s;
|
|
576
641
|
for (let i = 1; i <= c; i++) {
|
|
577
642
|
let a = new Date(t, e + 1, i);
|
|
578
643
|
n.push(r(a));
|
|
@@ -581,34 +646,47 @@ var K = 7, q = {
|
|
|
581
646
|
}
|
|
582
647
|
buildMonthsOfYear() {
|
|
583
648
|
let e = new Intl.DateTimeFormat(this.localesValue, { month: "long" }), t = new Intl.DateTimeFormat(this.localesValue, { month: "short" }), n = new Intl.DateTimeFormat(this.localesValue, { month: "numeric" }), r = [];
|
|
584
|
-
for (let i = 0; i <
|
|
585
|
-
let a = new Date(this.year, i);
|
|
649
|
+
for (let i = 0; i < Ee; i++) {
|
|
650
|
+
let a = new Date(this.year, i), o = new Date(this.year, i, 1), s = new Date(this.year, i + 1, 0), c = t.format(a), l = e.format(a), u = this.since && s < this.since || this.till && o > this.till, d = this.disabledMonths.some((e) => i == e || c === e || l === e);
|
|
586
651
|
r.push({
|
|
587
652
|
date: a,
|
|
588
653
|
value: a.getMonth(),
|
|
589
|
-
long:
|
|
590
|
-
short:
|
|
591
|
-
numeric: n.format(a)
|
|
654
|
+
long: l,
|
|
655
|
+
short: c,
|
|
656
|
+
numeric: n.format(a),
|
|
657
|
+
disabled: u || d
|
|
592
658
|
});
|
|
593
659
|
}
|
|
594
660
|
return r;
|
|
595
661
|
}
|
|
662
|
+
buildYearsOfDecade() {
|
|
663
|
+
let e = Math.floor(this.year / W) * W, t = [];
|
|
664
|
+
for (let n = e - 1; n <= e + W; n++) {
|
|
665
|
+
let r = n < e || n > e + W - 1, i = this.since && n < this.since.getFullYear() || this.till && n > this.till.getFullYear(), a = this.disabledYears.some((e) => n == e);
|
|
666
|
+
t.push({
|
|
667
|
+
value: n,
|
|
668
|
+
current: n === this.year,
|
|
669
|
+
disabled: r || i || a
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
return t;
|
|
673
|
+
}
|
|
596
674
|
get today() {
|
|
597
675
|
return this.now;
|
|
598
676
|
}
|
|
599
677
|
set today(e) {
|
|
600
|
-
if (!
|
|
678
|
+
if (!V(e)) return;
|
|
601
679
|
let t = this.month ?? e.getMonth(), n = this.year ?? e.getFullYear(), r = t == e.getMonth() && n == e.getFullYear() ? e.getDate() : 1;
|
|
602
680
|
this.now = new Date(n, t, r);
|
|
603
681
|
}
|
|
604
682
|
get current() {
|
|
605
|
-
return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ?
|
|
683
|
+
return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? H(this.year, this.month, this.day) : null;
|
|
606
684
|
}
|
|
607
685
|
set current(e) {
|
|
608
|
-
|
|
686
|
+
V(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
|
|
609
687
|
}
|
|
610
688
|
navigate = async (e) => {
|
|
611
|
-
if (!
|
|
689
|
+
if (!V(e)) return;
|
|
612
690
|
let t = this.current, n = e.toISOString(), r = t.toISOString();
|
|
613
691
|
this.dispatch("navigate", { detail: {
|
|
614
692
|
from: r,
|
|
@@ -639,7 +717,7 @@ var K = 7, q = {
|
|
|
639
717
|
await this.navigate(n);
|
|
640
718
|
};
|
|
641
719
|
isDisabled = (e) => {
|
|
642
|
-
if (!
|
|
720
|
+
if (!V(e)) return !1;
|
|
643
721
|
if (this.disabledDates.length) {
|
|
644
722
|
let t = e.getTime();
|
|
645
723
|
for (let e of this.disabledDates) if (t === new Date(e).getTime()) return !0;
|
|
@@ -669,7 +747,7 @@ var K = 7, q = {
|
|
|
669
747
|
return !1;
|
|
670
748
|
};
|
|
671
749
|
isWithinRange = (e) => {
|
|
672
|
-
if (!
|
|
750
|
+
if (!V(e)) return !1;
|
|
673
751
|
let t = !0;
|
|
674
752
|
return this.since && (t &&= e >= this.since), this.till && (t &&= e <= this.till), t;
|
|
675
753
|
};
|
|
@@ -725,6 +803,9 @@ var K = 7, q = {
|
|
|
725
803
|
get monthsOfYear() {
|
|
726
804
|
return e.monthsOfYear;
|
|
727
805
|
},
|
|
806
|
+
get yearsOfDecade() {
|
|
807
|
+
return e.yearsOfDecade;
|
|
808
|
+
},
|
|
728
809
|
navigate: async (t) => await e.navigate(t),
|
|
729
810
|
step: async (t, n) => await e.step(t, n),
|
|
730
811
|
isDisabled: (t) => e.isDisabled(t),
|
|
@@ -732,18 +813,78 @@ var K = 7, q = {
|
|
|
732
813
|
};
|
|
733
814
|
} });
|
|
734
815
|
}
|
|
735
|
-
},
|
|
816
|
+
}, K = (e, t) => new De(e, t), Oe = class extends A {
|
|
817
|
+
constructor(e, t = {}) {
|
|
818
|
+
super(e, t), this.handle = this.handle.bind(this), this.onSelect = t.onSelect || null;
|
|
819
|
+
}
|
|
820
|
+
attach() {
|
|
821
|
+
this.element.addEventListener("click", this.handle);
|
|
822
|
+
}
|
|
823
|
+
detach() {
|
|
824
|
+
this.element.removeEventListener("click", this.handle);
|
|
825
|
+
}
|
|
826
|
+
handle(e) {
|
|
827
|
+
if (!(e.target instanceof HTMLElement)) return;
|
|
828
|
+
e.preventDefault();
|
|
829
|
+
let t = e.target instanceof HTMLTimeElement ? e.target.parentElement : e.target;
|
|
830
|
+
if (t.disabled || t.getAttribute("aria-disabled") === "true") return;
|
|
831
|
+
let n = e.target instanceof HTMLTimeElement ? e.target : e.target.querySelector("time");
|
|
832
|
+
if (!n) return;
|
|
833
|
+
let r = H(n.dateTime);
|
|
834
|
+
if (!r) return;
|
|
835
|
+
this.dispatch("selecting", { target: t });
|
|
836
|
+
let i = r.toISOString();
|
|
837
|
+
this.onSelect ? this.awaitCallback(this.onSelect, i) : this.dispatch("selected", { detail: {
|
|
838
|
+
epoch: r.getTime(),
|
|
839
|
+
iso: i
|
|
840
|
+
} });
|
|
841
|
+
}
|
|
842
|
+
}, ke = class extends A {
|
|
843
|
+
constructor(e, t = {}) {
|
|
844
|
+
super(e, t), this.handle = this.handle.bind(this);
|
|
845
|
+
}
|
|
846
|
+
attach() {
|
|
847
|
+
this.element.addEventListener("click", this.handle);
|
|
848
|
+
}
|
|
849
|
+
detach() {
|
|
850
|
+
this.element.removeEventListener("click", this.handle);
|
|
851
|
+
}
|
|
852
|
+
handle(e) {
|
|
853
|
+
let t = e.target.closest("button[data-month]");
|
|
854
|
+
if (!t || t.disabled || t.getAttribute("aria-disabled") === "true") return;
|
|
855
|
+
e.preventDefault();
|
|
856
|
+
let n = parseInt(t.dataset.month, 10);
|
|
857
|
+
isNaN(n) || this.dispatch("selected", { detail: { month: n } });
|
|
858
|
+
}
|
|
859
|
+
}, Ae = class extends A {
|
|
860
|
+
constructor(e, t = {}) {
|
|
861
|
+
super(e, t), this.handle = this.handle.bind(this);
|
|
862
|
+
}
|
|
863
|
+
attach() {
|
|
864
|
+
this.element.addEventListener("click", this.handle);
|
|
865
|
+
}
|
|
866
|
+
detach() {
|
|
867
|
+
this.element.removeEventListener("click", this.handle);
|
|
868
|
+
}
|
|
869
|
+
handle(e) {
|
|
870
|
+
let t = e.target.closest("button[data-year]");
|
|
871
|
+
if (!t || t.disabled || t.getAttribute("aria-disabled") === "true") return;
|
|
872
|
+
e.preventDefault();
|
|
873
|
+
let n = parseInt(t.dataset.year, 10);
|
|
874
|
+
isNaN(n) || this.dispatch("selected", { detail: { year: n } });
|
|
875
|
+
}
|
|
876
|
+
}, q = (e, t) => new Oe(e, t), J = (e, t) => new ke(e, t), Y = (e, t) => new Ae(e, t), X = {
|
|
736
877
|
content: null,
|
|
737
878
|
url: "",
|
|
738
879
|
reload: "never",
|
|
739
880
|
stale: 3600,
|
|
740
881
|
onLoad: "canLoad",
|
|
741
882
|
onLoaded: "contentLoaded"
|
|
742
|
-
},
|
|
883
|
+
}, je = class extends A {
|
|
743
884
|
constructor(e, t = {}) {
|
|
744
885
|
super(e, t);
|
|
745
|
-
let n = Object.assign({},
|
|
746
|
-
this.content = r, this.url = i, this.reload = typeof a == "string" ? a :
|
|
886
|
+
let n = Object.assign({}, X, t), { content: r, url: i, reload: a, stale: o } = n;
|
|
887
|
+
this.content = r, this.url = i, this.reload = typeof a == "string" ? a : X.reload, this.stale = typeof o == "number" ? o : X.stale;
|
|
747
888
|
let { onLoad: s, onLoaded: c } = n;
|
|
748
889
|
this.onLoad = s, this.onLoaded = c, this._requestor = new w(), this.enhance();
|
|
749
890
|
}
|
|
@@ -752,7 +893,7 @@ var K = 7, q = {
|
|
|
752
893
|
case "never": return !1;
|
|
753
894
|
case "always": return !0;
|
|
754
895
|
default: {
|
|
755
|
-
let e =
|
|
896
|
+
let e = H(this.loadedAt);
|
|
756
897
|
return e && /* @__PURE__ */ new Date() - e > this.stale * 1e3;
|
|
757
898
|
}
|
|
758
899
|
}
|
|
@@ -778,7 +919,7 @@ var K = 7, q = {
|
|
|
778
919
|
let e = this;
|
|
779
920
|
Object.assign(this.controller, { load: e.load.bind(e) });
|
|
780
921
|
}
|
|
781
|
-
},
|
|
922
|
+
}, Me = (e, t) => new je(e, t), Z = class extends A {
|
|
782
923
|
observe(e) {
|
|
783
924
|
this._handler = e, this.events.forEach((t) => window.addEventListener(t, e, !0));
|
|
784
925
|
}
|
|
@@ -791,21 +932,21 @@ var K = 7, q = {
|
|
|
791
932
|
e.unobserve(), t();
|
|
792
933
|
};
|
|
793
934
|
}
|
|
794
|
-
},
|
|
935
|
+
}, Ne = {
|
|
795
936
|
trigger: null,
|
|
796
937
|
events: ["click"],
|
|
797
938
|
onDismissed: "dismissed"
|
|
798
|
-
},
|
|
939
|
+
}, Pe = class extends Z {
|
|
799
940
|
constructor(e, t = {}) {
|
|
800
941
|
super(e, t);
|
|
801
|
-
let { trigger: n, events: r, onDismissed: i } = Object.assign({},
|
|
942
|
+
let { trigger: n, events: r, onDismissed: i } = Object.assign({}, Ne, t);
|
|
802
943
|
this.onDismissed = i, this.trigger = n || this.element, this.events = r, this.enhance(), this.observe(this.dismiss);
|
|
803
944
|
}
|
|
804
945
|
dismiss = async (e) => {
|
|
805
946
|
let { target: t } = e;
|
|
806
947
|
t instanceof HTMLElement && (this.element.contains(t) || this.visible && (this.dispatch("dismiss"), await this.awaitCallback(this.onDismissed, { target: this.trigger }), this.dispatch("dismissed")));
|
|
807
948
|
};
|
|
808
|
-
},
|
|
949
|
+
}, Q = (e, t) => new Pe(e, t), Fe = {
|
|
809
950
|
anchor: null,
|
|
810
951
|
events: ["click"],
|
|
811
952
|
placement: "bottom",
|
|
@@ -813,10 +954,10 @@ var K = 7, q = {
|
|
|
813
954
|
onFlipped: "flipped",
|
|
814
955
|
ariaRole: null,
|
|
815
956
|
respectMotion: !0
|
|
816
|
-
},
|
|
957
|
+
}, Ie = class extends Z {
|
|
817
958
|
constructor(e, t = {}) {
|
|
818
959
|
super(e, t);
|
|
819
|
-
let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({},
|
|
960
|
+
let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, Fe, t);
|
|
820
961
|
this.anchor = n, this.events = r, this.placement = i, this.alignment = a, this.onFlipped = o, this.ariaRole = s, this.respectMotion = c, this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.anchor && this.element && S({
|
|
821
962
|
trigger: this.anchor,
|
|
822
963
|
target: this.element,
|
|
@@ -835,7 +976,7 @@ var K = 7, q = {
|
|
|
835
976
|
}), this.dispatch("flipped", { detail: { placement: e } });
|
|
836
977
|
};
|
|
837
978
|
flippedRect(e, t) {
|
|
838
|
-
let n = this.quadrumRect(e,
|
|
979
|
+
let n = this.quadrumRect(e, O()), r = [this.placement, ce[this.placement]], i = {};
|
|
839
980
|
for (; !Object.keys(i).length && r.length > 0;) {
|
|
840
981
|
let a = r.shift();
|
|
841
982
|
if (!this.biggerRectThan(n[a], t)) continue;
|
|
@@ -846,25 +987,25 @@ var K = 7, q = {
|
|
|
846
987
|
}
|
|
847
988
|
quadrumRect(e, t) {
|
|
848
989
|
return {
|
|
849
|
-
left:
|
|
990
|
+
left: D({
|
|
850
991
|
x: t.x,
|
|
851
992
|
y: t.y,
|
|
852
993
|
width: e.x - t.x,
|
|
853
994
|
height: t.height
|
|
854
995
|
}),
|
|
855
|
-
right:
|
|
996
|
+
right: D({
|
|
856
997
|
x: e.x + e.width,
|
|
857
998
|
y: t.y,
|
|
858
999
|
width: t.width - (e.x + e.width),
|
|
859
1000
|
height: t.height
|
|
860
1001
|
}),
|
|
861
|
-
top:
|
|
1002
|
+
top: D({
|
|
862
1003
|
x: t.x,
|
|
863
1004
|
y: t.y,
|
|
864
1005
|
width: t.width,
|
|
865
1006
|
height: e.y - t.y
|
|
866
1007
|
}),
|
|
867
|
-
bottom:
|
|
1008
|
+
bottom: D({
|
|
868
1009
|
x: t.x,
|
|
869
1010
|
y: e.y + e.height,
|
|
870
1011
|
width: t.width,
|
|
@@ -874,25 +1015,25 @@ var K = 7, q = {
|
|
|
874
1015
|
}
|
|
875
1016
|
quadrumPlacement(e, t, n) {
|
|
876
1017
|
switch (t) {
|
|
877
|
-
case "top": return
|
|
1018
|
+
case "top": return D({
|
|
878
1019
|
x: n.x,
|
|
879
1020
|
y: e.y - n.height,
|
|
880
1021
|
width: n.width,
|
|
881
1022
|
height: n.height
|
|
882
1023
|
});
|
|
883
|
-
case "bottom": return
|
|
1024
|
+
case "bottom": return D({
|
|
884
1025
|
x: n.x,
|
|
885
1026
|
y: e.y + e.height,
|
|
886
1027
|
width: n.width,
|
|
887
1028
|
height: n.height
|
|
888
1029
|
});
|
|
889
|
-
case "left": return
|
|
1030
|
+
case "left": return D({
|
|
890
1031
|
x: e.x - n.width,
|
|
891
1032
|
y: n.y,
|
|
892
1033
|
width: n.width,
|
|
893
1034
|
height: n.height
|
|
894
1035
|
});
|
|
895
|
-
case "right": return
|
|
1036
|
+
case "right": return D({
|
|
896
1037
|
x: e.x + e.width,
|
|
897
1038
|
y: n.y,
|
|
898
1039
|
width: n.width,
|
|
@@ -906,7 +1047,7 @@ var K = 7, q = {
|
|
|
906
1047
|
case "top":
|
|
907
1048
|
case "bottom": {
|
|
908
1049
|
let t = e.x;
|
|
909
|
-
return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width),
|
|
1050
|
+
return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width), D({
|
|
910
1051
|
x: t,
|
|
911
1052
|
y: n.y,
|
|
912
1053
|
width: n.width,
|
|
@@ -916,7 +1057,7 @@ var K = 7, q = {
|
|
|
916
1057
|
case "left":
|
|
917
1058
|
case "right": {
|
|
918
1059
|
let t = e.y;
|
|
919
|
-
return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height),
|
|
1060
|
+
return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height), D({
|
|
920
1061
|
x: n.x,
|
|
921
1062
|
y: t,
|
|
922
1063
|
width: n.width,
|
|
@@ -932,7 +1073,7 @@ var K = 7, q = {
|
|
|
932
1073
|
enhance() {
|
|
933
1074
|
super.enhance(), this.controller.flip = this.flip;
|
|
934
1075
|
}
|
|
935
|
-
},
|
|
1076
|
+
}, Le = (e, t) => new Ie(e, t), Re = {
|
|
936
1077
|
events: ["resize"],
|
|
937
1078
|
boundaries: [
|
|
938
1079
|
"top",
|
|
@@ -941,10 +1082,10 @@ var K = 7, q = {
|
|
|
941
1082
|
],
|
|
942
1083
|
onShifted: "shifted",
|
|
943
1084
|
respectMotion: !0
|
|
944
|
-
},
|
|
1085
|
+
}, ze = class extends Z {
|
|
945
1086
|
constructor(e, t = {}) {
|
|
946
1087
|
super(e, t);
|
|
947
|
-
let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({},
|
|
1088
|
+
let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({}, Re, t);
|
|
948
1089
|
this.onShifted = n, this.events = r, this.boundaries = i, this.respectMotion = a, this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.enhance(), this.observe(this.shift);
|
|
949
1090
|
}
|
|
950
1091
|
shift = async () => {
|
|
@@ -954,14 +1095,14 @@ var K = 7, q = {
|
|
|
954
1095
|
this.element.style.transition = this.respectMotion && this.prefersReducedMotion ? "none" : "", this.element.style.transform = `translate(${t}px, ${n}px)`, await this.awaitCallback(this.onShifted, e), this.dispatch("shifted", { detail: e });
|
|
955
1096
|
};
|
|
956
1097
|
overflowRect(e, t) {
|
|
957
|
-
let n = {}, r =
|
|
1098
|
+
let n = {}, r = O(), i = D({
|
|
958
1099
|
x: e.x - t.x,
|
|
959
1100
|
y: e.y - t.y,
|
|
960
1101
|
width: e.width,
|
|
961
1102
|
height: e.height
|
|
962
1103
|
});
|
|
963
1104
|
for (let e of this.boundaries) {
|
|
964
|
-
let t = this.directionDistance(i, e, r), a =
|
|
1105
|
+
let t = this.directionDistance(i, e, r), a = ce[e];
|
|
965
1106
|
t < 0 ? i[a] + t >= r[a] && !n[a] && (n[e] = t) : n[e] = "";
|
|
966
1107
|
}
|
|
967
1108
|
return n;
|
|
@@ -993,27 +1134,27 @@ var K = 7, q = {
|
|
|
993
1134
|
enhance() {
|
|
994
1135
|
super.enhance(), this.controller.shift = this.shift;
|
|
995
1136
|
}
|
|
996
|
-
},
|
|
1137
|
+
}, Be = (e, t) => new ze(e, t), Ve = {
|
|
997
1138
|
visibility: "visibility",
|
|
998
1139
|
onShown: "shown",
|
|
999
1140
|
onHidden: "hidden"
|
|
1000
|
-
},
|
|
1141
|
+
}, He = class extends A {
|
|
1001
1142
|
constructor(e, t = {}) {
|
|
1002
|
-
let { visibility: n, onShown: r, onHidden: i, activator: a } = Object.assign({},
|
|
1143
|
+
let { visibility: n, onShown: r, onHidden: i, activator: a } = Object.assign({}, Ve, t), o = typeof n == "string" ? n : Ve.namespace, s = typeof t.visible == "string" ? t.visible : "isVisible";
|
|
1003
1144
|
(typeof t.visible != "boolean" || t.visible) && (t.visible = `${o}.${s}`), super(e, t), this.visibility = o, this.visibilityResolver = s, this.onShown = r, this.onHidden = i, this.activator = a instanceof HTMLElement ? a : null, this.enhance(), this.element instanceof HTMLElement && this.activate(this.isVisible(this.element));
|
|
1004
1145
|
}
|
|
1005
1146
|
isVisible(e) {
|
|
1006
1147
|
if (!(e instanceof HTMLElement)) return !1;
|
|
1007
|
-
let t =
|
|
1148
|
+
let t = k.hiddenClass;
|
|
1008
1149
|
return t ? !e.classList.contains(t) : !e.hasAttribute("hidden");
|
|
1009
1150
|
}
|
|
1010
1151
|
toggle(e, t) {
|
|
1011
1152
|
if (!(e instanceof HTMLElement)) return;
|
|
1012
|
-
let n =
|
|
1013
|
-
n ? t ? e.classList.remove(n) : e.classList.add(n) :
|
|
1153
|
+
let n = k.hiddenClass;
|
|
1154
|
+
n ? t ? e.classList.remove(n) : e.classList.add(n) : v(e, !t);
|
|
1014
1155
|
}
|
|
1015
1156
|
activate(e) {
|
|
1016
|
-
this.activator && this.activator
|
|
1157
|
+
this.activator && g(this.activator, e);
|
|
1017
1158
|
}
|
|
1018
1159
|
async show() {
|
|
1019
1160
|
!(this.element instanceof HTMLElement) || this.isVisible(this.element) || (this.dispatch("show"), this.toggle(this.element, !0), this.activate(!0), await this.awaitCallback(this.onShown, { target: this.element }), this.dispatch("shown"));
|
|
@@ -1032,14 +1173,118 @@ var K = 7, q = {
|
|
|
1032
1173
|
return t;
|
|
1033
1174
|
} });
|
|
1034
1175
|
}
|
|
1035
|
-
},
|
|
1176
|
+
}, Ue = (e, t) => new He(e, t), We = 4, Ge = class extends e {
|
|
1177
|
+
static targets = ["grid"];
|
|
1178
|
+
static values = {
|
|
1179
|
+
current: Number,
|
|
1180
|
+
today: {
|
|
1181
|
+
type: String,
|
|
1182
|
+
default: ""
|
|
1183
|
+
},
|
|
1184
|
+
selected: {
|
|
1185
|
+
type: String,
|
|
1186
|
+
default: ""
|
|
1187
|
+
},
|
|
1188
|
+
since: {
|
|
1189
|
+
type: String,
|
|
1190
|
+
default: ""
|
|
1191
|
+
},
|
|
1192
|
+
till: {
|
|
1193
|
+
type: String,
|
|
1194
|
+
default: ""
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
initialize() {
|
|
1198
|
+
this.selector = Y(this), K(this, {
|
|
1199
|
+
today: this.todayValue,
|
|
1200
|
+
year: this.currentValue || void 0,
|
|
1201
|
+
since: this.sinceValue || null,
|
|
1202
|
+
till: this.tillValue || null
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
connect() {
|
|
1206
|
+
this.selector.attach(), this.navigated();
|
|
1207
|
+
}
|
|
1208
|
+
disconnect() {
|
|
1209
|
+
this.selector.detach();
|
|
1210
|
+
}
|
|
1211
|
+
currentValueChanged() {
|
|
1212
|
+
!this.calendar || !this.hasCurrentValue || this.calendar.navigate(this.currentDate);
|
|
1213
|
+
}
|
|
1214
|
+
selectedValueChanged() {
|
|
1215
|
+
if (!this.hasGridTarget) return;
|
|
1216
|
+
let e = H(this.selectedValue), t = e ? e.getFullYear() : null;
|
|
1217
|
+
this.gridTarget.querySelectorAll("button[data-year]").forEach((e) => {
|
|
1218
|
+
let n = parseInt(e.dataset.year, 10);
|
|
1219
|
+
e.setAttribute("aria-selected", n === t ? "true" : "false");
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
navigate(e) {
|
|
1223
|
+
this.currentValue = e.getFullYear();
|
|
1224
|
+
}
|
|
1225
|
+
step(e, t) {
|
|
1226
|
+
return this.calendar.step(e, t);
|
|
1227
|
+
}
|
|
1228
|
+
navigated() {
|
|
1229
|
+
this.drawGrid();
|
|
1230
|
+
}
|
|
1231
|
+
get currentDate() {
|
|
1232
|
+
return new Date(this.currentValue, 0, 1);
|
|
1233
|
+
}
|
|
1234
|
+
drawGrid() {
|
|
1235
|
+
if (!this.hasGridTarget) return;
|
|
1236
|
+
let { yearsOfDecade: e } = this.calendar, t = this.calendar.today.getFullYear(), n = H(this.selectedValue), r = n ? n.getFullYear() : null, i = [];
|
|
1237
|
+
for (let n of e) {
|
|
1238
|
+
let e = document.createElement("button");
|
|
1239
|
+
e.type = "button", e.textContent = n.value, e.dataset.year = n.value, e.setAttribute("role", "gridcell"), e.setAttribute("aria-selected", n.value === r ? "true" : "false"), n.value === t && e.setAttribute("aria-current", "year"), n.disabled && e.setAttribute("aria-disabled", "true"), i.push(e);
|
|
1240
|
+
}
|
|
1241
|
+
let a = document.createElement("div");
|
|
1242
|
+
a.setAttribute("role", "rowgroup");
|
|
1243
|
+
for (let e = 0; e < i.length; e += We) {
|
|
1244
|
+
let t = document.createElement("div");
|
|
1245
|
+
t.setAttribute("role", "row");
|
|
1246
|
+
for (let n of i.slice(e, e + We)) t.appendChild(n);
|
|
1247
|
+
a.appendChild(t);
|
|
1248
|
+
}
|
|
1249
|
+
this.gridTarget.replaceChildren(a);
|
|
1250
|
+
}
|
|
1251
|
+
}, Ke = class extends e {
|
|
1252
|
+
initialize() {
|
|
1253
|
+
this.selector = Y(this);
|
|
1254
|
+
}
|
|
1255
|
+
connect() {
|
|
1256
|
+
this.selector.attach();
|
|
1257
|
+
}
|
|
1258
|
+
disconnect() {
|
|
1259
|
+
this.selector.detach();
|
|
1260
|
+
}
|
|
1261
|
+
}, qe = class extends e {
|
|
1036
1262
|
static targets = ["daysOfWeek", "daysOfMonth"];
|
|
1037
1263
|
static classes = [
|
|
1038
1264
|
"dayOfWeek",
|
|
1039
1265
|
"dayOfMonth",
|
|
1040
|
-
"
|
|
1266
|
+
"dayOfOtherMonth",
|
|
1267
|
+
"row"
|
|
1041
1268
|
];
|
|
1042
1269
|
static values = {
|
|
1270
|
+
year: Number,
|
|
1271
|
+
month: Number,
|
|
1272
|
+
today: {
|
|
1273
|
+
type: String,
|
|
1274
|
+
default: ""
|
|
1275
|
+
},
|
|
1276
|
+
selected: {
|
|
1277
|
+
type: String,
|
|
1278
|
+
default: ""
|
|
1279
|
+
},
|
|
1280
|
+
since: {
|
|
1281
|
+
type: String,
|
|
1282
|
+
default: ""
|
|
1283
|
+
},
|
|
1284
|
+
till: {
|
|
1285
|
+
type: String,
|
|
1286
|
+
default: ""
|
|
1287
|
+
},
|
|
1043
1288
|
locales: {
|
|
1044
1289
|
type: Array,
|
|
1045
1290
|
default: ["default"]
|
|
@@ -1055,41 +1300,60 @@ var K = 7, q = {
|
|
|
1055
1300
|
daysOfOtherMonth: {
|
|
1056
1301
|
type: Boolean,
|
|
1057
1302
|
default: !1
|
|
1058
|
-
},
|
|
1059
|
-
today: {
|
|
1060
|
-
type: String,
|
|
1061
|
-
default: ""
|
|
1062
|
-
},
|
|
1063
|
-
selected: {
|
|
1064
|
-
type: String,
|
|
1065
|
-
default: ""
|
|
1066
1303
|
}
|
|
1067
1304
|
};
|
|
1068
1305
|
initialize() {
|
|
1069
|
-
|
|
1306
|
+
this.selector = q(this, { onSelect: "select" }), K(this, {
|
|
1307
|
+
today: this.todayValue,
|
|
1308
|
+
since: this.sinceValue || null,
|
|
1309
|
+
till: this.tillValue || null
|
|
1310
|
+
});
|
|
1070
1311
|
}
|
|
1071
1312
|
connect() {
|
|
1072
|
-
this.
|
|
1313
|
+
this.selector.attach(), this.navigated();
|
|
1073
1314
|
}
|
|
1074
|
-
|
|
1075
|
-
this.
|
|
1315
|
+
disconnect() {
|
|
1316
|
+
this.selector.detach();
|
|
1317
|
+
}
|
|
1318
|
+
yearValueChanged() {
|
|
1319
|
+
!this.calendar || !this.hasYearValue || this._scheduleNavigate();
|
|
1320
|
+
}
|
|
1321
|
+
monthValueChanged() {
|
|
1322
|
+
!this.calendar || !this.hasYearValue || this._scheduleNavigate();
|
|
1323
|
+
}
|
|
1324
|
+
_scheduleNavigate() {
|
|
1325
|
+
this._navigatePending || (this._navigatePending = !0, queueMicrotask(async () => {
|
|
1326
|
+
this._navigatePending = !1, await this.calendar.navigate(this.currentDate), this.navigated();
|
|
1327
|
+
}));
|
|
1076
1328
|
}
|
|
1077
1329
|
selectedValueChanged() {
|
|
1078
1330
|
if (!this.hasDaysOfMonthTarget || (this.daysOfMonthTarget.querySelectorAll("[aria-selected]").forEach((e) => {
|
|
1079
1331
|
e.setAttribute("aria-selected", "false");
|
|
1080
1332
|
}), !this.selectedValue)) return;
|
|
1081
|
-
let e =
|
|
1333
|
+
let e = H(this.selectedValue);
|
|
1082
1334
|
if (!e) return;
|
|
1083
1335
|
let t = this.daysOfMonthTarget.querySelector(`time[datetime="${e.toISOString()}"]`);
|
|
1084
|
-
t && t.closest("[aria-selected]")
|
|
1336
|
+
t && t.closest("[aria-selected]")?.setAttribute("aria-selected", "true");
|
|
1085
1337
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
t && (this.selectedValue = t);
|
|
1338
|
+
navigate(e) {
|
|
1339
|
+
this.yearValue = e.getFullYear(), this.monthValue = e.getMonth();
|
|
1089
1340
|
}
|
|
1090
|
-
|
|
1341
|
+
step(e, t) {
|
|
1342
|
+
return this.calendar.step(e, t);
|
|
1343
|
+
}
|
|
1344
|
+
select(e) {
|
|
1345
|
+
let t = H(e);
|
|
1346
|
+
t && (this.selectedValue = e, (t.getMonth() !== this.calendar.month || t.getFullYear() !== this.calendar.year) && this.calendar.navigate(t), this.dispatch("selected", { detail: {
|
|
1347
|
+
epoch: t.getTime(),
|
|
1348
|
+
iso: e
|
|
1349
|
+
} }));
|
|
1350
|
+
}
|
|
1351
|
+
navigated() {
|
|
1091
1352
|
this.drawDaysOfWeek(), this.drawDaysOfMonth(), this.selectedValueChanged();
|
|
1092
1353
|
}
|
|
1354
|
+
get currentDate() {
|
|
1355
|
+
return new Date(this.yearValue, this.monthValue, 1);
|
|
1356
|
+
}
|
|
1093
1357
|
createDayElement(e, { selectable: t = !1, disabled: n = !1 } = {}) {
|
|
1094
1358
|
let r = document.createElement(t ? "button" : "div");
|
|
1095
1359
|
return r.tabIndex = -1, e ? r.textContent = e : r.setAttribute("aria-hidden", "true"), n && (r instanceof HTMLButtonElement ? r.disabled = !0 : r.setAttribute("aria-disabled", "true")), r;
|
|
@@ -1102,50 +1366,135 @@ var K = 7, q = {
|
|
|
1102
1366
|
r.setAttribute("role", "columnheader"), r.title = n.long, this.hasDayOfWeekClass && r.classList.add(...this.dayOfWeekClasses), t.push(r);
|
|
1103
1367
|
}
|
|
1104
1368
|
let n = document.createElement("div");
|
|
1105
|
-
n.setAttribute("role", "row"), this.
|
|
1369
|
+
n.setAttribute("role", "row"), this.hasRowClass && n.classList.add(...this.rowClasses), n.replaceChildren(...t), this.daysOfWeekTarget.replaceChildren(n);
|
|
1106
1370
|
}
|
|
1107
1371
|
drawDaysOfMonth() {
|
|
1108
1372
|
if (!this.hasDaysOfMonthTarget) return;
|
|
1109
1373
|
let e = this.calendar.today, t = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), n = [];
|
|
1110
1374
|
for (let e of this.calendar.daysOfMonth) {
|
|
1111
|
-
let r =
|
|
1112
|
-
selectable: e.current,
|
|
1113
|
-
disabled: r
|
|
1375
|
+
let r = this.calendar.isDisabled(e.date) || !this.calendar.isWithinRange(e.date), i = !e.current && this.daysOfOtherMonthValue && !r, a = e.current || this.daysOfOtherMonthValue ? e.value : "", o = this.createDayElement(a, {
|
|
1376
|
+
selectable: e.current || i,
|
|
1377
|
+
disabled: e.current ? r : !i
|
|
1114
1378
|
});
|
|
1115
|
-
t === e.date.getTime() &&
|
|
1116
|
-
let
|
|
1117
|
-
|
|
1379
|
+
t === e.date.getTime() && o.setAttribute("aria-current", "date"), (e.current || this.daysOfOtherMonthValue) && o.setAttribute("aria-selected", ""), !e.current && this.daysOfOtherMonthValue && this.hasDayOfOtherMonthClass ? o.classList.add(...this.dayOfOtherMonthClasses) : this.hasDayOfMonthClass && o.classList.add(...this.dayOfMonthClasses);
|
|
1380
|
+
let s = document.createElement("time");
|
|
1381
|
+
s.dateTime = e.iso, o.appendChild(s), n.push(o);
|
|
1118
1382
|
}
|
|
1119
1383
|
let r = [];
|
|
1120
1384
|
for (let e = 0; e < n.length; e += 7) {
|
|
1121
1385
|
let t = document.createElement("div");
|
|
1122
|
-
t.setAttribute("role", "row"), this.
|
|
1386
|
+
t.setAttribute("role", "row"), this.hasRowClass && t.classList.add(...this.rowClasses);
|
|
1123
1387
|
for (let r of n.slice(e, e + 7)) r.setAttribute("role", "gridcell"), t.appendChild(r);
|
|
1124
1388
|
r.push(t);
|
|
1125
1389
|
}
|
|
1126
1390
|
this.daysOfMonthTarget.replaceChildren(...r);
|
|
1127
1391
|
}
|
|
1128
|
-
},
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
e.preventDefault();
|
|
1132
|
-
let t = e.target instanceof HTMLTimeElement ? e.target.parentElement : e.target;
|
|
1133
|
-
if (t.disabled || t.getAttribute("aria-disabled") === "true") return;
|
|
1134
|
-
this.dispatch("selecting", { target: t });
|
|
1135
|
-
let n = e.target instanceof HTMLTimeElement ? e.target : e.target.querySelector("time");
|
|
1136
|
-
if (!n) return console.error(`unable to locate time element within ${t}`);
|
|
1137
|
-
let r = G(n.dateTime);
|
|
1138
|
-
if (!r) return console.error(`unable to parse ${n.dateTime} found within the time element`);
|
|
1139
|
-
this.select(r.toISOString());
|
|
1392
|
+
}, Je = class extends e {
|
|
1393
|
+
initialize() {
|
|
1394
|
+
this.selector = q(this);
|
|
1140
1395
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1396
|
+
connect() {
|
|
1397
|
+
this.selector.attach();
|
|
1398
|
+
}
|
|
1399
|
+
disconnect() {
|
|
1400
|
+
this.selector.detach();
|
|
1401
|
+
}
|
|
1402
|
+
}, Ye = 4, Xe = class extends e {
|
|
1403
|
+
static targets = ["grid"];
|
|
1404
|
+
static values = {
|
|
1405
|
+
current: Number,
|
|
1406
|
+
today: {
|
|
1407
|
+
type: String,
|
|
1408
|
+
default: ""
|
|
1409
|
+
},
|
|
1410
|
+
selected: {
|
|
1411
|
+
type: String,
|
|
1412
|
+
default: ""
|
|
1413
|
+
},
|
|
1414
|
+
since: {
|
|
1415
|
+
type: String,
|
|
1416
|
+
default: ""
|
|
1417
|
+
},
|
|
1418
|
+
till: {
|
|
1419
|
+
type: String,
|
|
1420
|
+
default: ""
|
|
1421
|
+
},
|
|
1422
|
+
locales: {
|
|
1423
|
+
type: Array,
|
|
1424
|
+
default: ["default"]
|
|
1425
|
+
},
|
|
1426
|
+
monthFormat: {
|
|
1427
|
+
type: String,
|
|
1428
|
+
default: "short"
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
initialize() {
|
|
1432
|
+
this.selector = J(this), K(this, {
|
|
1433
|
+
today: this.todayValue,
|
|
1434
|
+
year: this.currentValue || void 0,
|
|
1435
|
+
since: this.sinceValue || null,
|
|
1436
|
+
till: this.tillValue || null
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
connect() {
|
|
1440
|
+
this.selector.attach(), this.navigated();
|
|
1441
|
+
}
|
|
1442
|
+
disconnect() {
|
|
1443
|
+
this.selector.detach();
|
|
1444
|
+
}
|
|
1445
|
+
currentValueChanged() {
|
|
1446
|
+
!this.calendar || !this.hasCurrentValue || this.calendar.navigate(this.currentDate);
|
|
1447
|
+
}
|
|
1448
|
+
selectedValueChanged() {
|
|
1449
|
+
if (!this.hasGridTarget) return;
|
|
1450
|
+
let e = H(this.selectedValue);
|
|
1451
|
+
this.gridTarget.querySelectorAll("button[data-month]").forEach((t) => {
|
|
1452
|
+
let n = parseInt(t.dataset.month, 10) - 1;
|
|
1453
|
+
t.setAttribute("aria-selected", e && e.getMonth() === n ? "true" : "false");
|
|
1454
|
+
});
|
|
1147
1455
|
}
|
|
1148
|
-
|
|
1456
|
+
navigate(e) {
|
|
1457
|
+
this.currentValue = e.getFullYear();
|
|
1458
|
+
}
|
|
1459
|
+
step(e, t) {
|
|
1460
|
+
return this.calendar.step(e, t);
|
|
1461
|
+
}
|
|
1462
|
+
navigated() {
|
|
1463
|
+
this.drawGrid();
|
|
1464
|
+
}
|
|
1465
|
+
get currentDate() {
|
|
1466
|
+
return new Date(this.currentValue, 0, 1);
|
|
1467
|
+
}
|
|
1468
|
+
drawGrid() {
|
|
1469
|
+
if (!this.hasGridTarget) return;
|
|
1470
|
+
let { year: e, monthsOfYear: t } = this.calendar, n = this.calendar.today, r = H(this.selectedValue), i = [], a = new Intl.DateTimeFormat(this.localesValue, { month: this.monthFormatValue });
|
|
1471
|
+
for (let o of t) {
|
|
1472
|
+
let t = document.createElement("button");
|
|
1473
|
+
t.type = "button", t.textContent = a.format(o.date), t.dataset.month = o.value + 1, t.setAttribute("role", "gridcell");
|
|
1474
|
+
let s = r && r.getMonth() === o.value;
|
|
1475
|
+
t.setAttribute("aria-selected", s ? "true" : "false"), o.value === n.getMonth() && e === n.getFullYear() && t.setAttribute("aria-current", "month"), o.disabled && t.setAttribute("aria-disabled", "true"), i.push(t);
|
|
1476
|
+
}
|
|
1477
|
+
let o = document.createElement("div");
|
|
1478
|
+
o.setAttribute("role", "rowgroup");
|
|
1479
|
+
for (let e = 0; e < i.length; e += Ye) {
|
|
1480
|
+
let t = document.createElement("div");
|
|
1481
|
+
t.setAttribute("role", "row");
|
|
1482
|
+
for (let n of i.slice(e, e + Ye)) t.appendChild(n);
|
|
1483
|
+
o.appendChild(t);
|
|
1484
|
+
}
|
|
1485
|
+
this.gridTarget.replaceChildren(o);
|
|
1486
|
+
}
|
|
1487
|
+
}, Ze = class extends e {
|
|
1488
|
+
initialize() {
|
|
1489
|
+
this.selector = J(this);
|
|
1490
|
+
}
|
|
1491
|
+
connect() {
|
|
1492
|
+
this.selector.attach();
|
|
1493
|
+
}
|
|
1494
|
+
disconnect() {
|
|
1495
|
+
this.selector.detach();
|
|
1496
|
+
}
|
|
1497
|
+
}, Qe = class extends e {
|
|
1149
1498
|
static targets = ["source"];
|
|
1150
1499
|
static values = { contentType: {
|
|
1151
1500
|
type: String,
|
|
@@ -1175,17 +1524,30 @@ var K = 7, q = {
|
|
|
1175
1524
|
});
|
|
1176
1525
|
}
|
|
1177
1526
|
}
|
|
1178
|
-
},
|
|
1527
|
+
}, $ = [
|
|
1528
|
+
"month",
|
|
1529
|
+
"year",
|
|
1530
|
+
"decade"
|
|
1531
|
+
], $e = class extends e {
|
|
1179
1532
|
static targets = [
|
|
1180
1533
|
"previous",
|
|
1181
1534
|
"next",
|
|
1182
1535
|
"day",
|
|
1183
1536
|
"month",
|
|
1184
|
-
"year"
|
|
1537
|
+
"year",
|
|
1538
|
+
"viewTitle"
|
|
1539
|
+
];
|
|
1540
|
+
static outlets = [
|
|
1541
|
+
"calendar-month",
|
|
1542
|
+
"calendar-year",
|
|
1543
|
+
"calendar-decade"
|
|
1185
1544
|
];
|
|
1186
|
-
static outlets = ["calendar-month"];
|
|
1187
1545
|
static values = {
|
|
1188
1546
|
date: String,
|
|
1547
|
+
view: {
|
|
1548
|
+
type: String,
|
|
1549
|
+
default: "month"
|
|
1550
|
+
},
|
|
1189
1551
|
locales: {
|
|
1190
1552
|
type: Array,
|
|
1191
1553
|
default: ["default"]
|
|
@@ -1208,17 +1570,33 @@ var K = 7, q = {
|
|
|
1208
1570
|
}
|
|
1209
1571
|
async calendarMonthOutletConnected() {
|
|
1210
1572
|
if (this.dateValue) {
|
|
1211
|
-
let e =
|
|
1573
|
+
let e = H(this.dateValue);
|
|
1212
1574
|
e && await this.calendarMonthOutlet.calendar.navigate(e);
|
|
1213
1575
|
}
|
|
1214
1576
|
this.draw();
|
|
1215
1577
|
}
|
|
1216
|
-
|
|
1578
|
+
onDaySelect(e) {
|
|
1217
1579
|
this.dateValue = e.detail.iso, this.draw(), this.dispatch("selected", {
|
|
1218
1580
|
detail: { value: e.detail.iso },
|
|
1219
1581
|
bubbles: !0
|
|
1220
1582
|
});
|
|
1221
1583
|
}
|
|
1584
|
+
zoomOut() {
|
|
1585
|
+
let e = $.indexOf(this.viewValue);
|
|
1586
|
+
e < $.length - 1 && (this.viewValue = $[e + 1], this.draw());
|
|
1587
|
+
}
|
|
1588
|
+
async onMonthSelect(e) {
|
|
1589
|
+
let { month: t } = e.detail;
|
|
1590
|
+
if (!this.hasCalendarMonthOutlet) return;
|
|
1591
|
+
let { year: n } = this.calendarMonthOutlet.calendar;
|
|
1592
|
+
await this.calendarMonthOutlet.calendar.navigate(new Date(n, t - 1, 1)), this.viewValue = "month", this.draw();
|
|
1593
|
+
}
|
|
1594
|
+
async onYearSelect(e) {
|
|
1595
|
+
let { year: t } = e.detail;
|
|
1596
|
+
if (!this.hasCalendarMonthOutlet) return;
|
|
1597
|
+
let { month: n } = this.calendarMonthOutlet.calendar;
|
|
1598
|
+
await this.calendarMonthOutlet.calendar.navigate(new Date(t, n, 1)), this.hasCalendarYearOutlet && this.calendarYearOutlet.navigate(this.calendarMonthOutlet.calendar.current), this.viewValue = "year", this.draw();
|
|
1599
|
+
}
|
|
1222
1600
|
previousTargetConnected(e) {
|
|
1223
1601
|
e.addEventListener("click", this.previous);
|
|
1224
1602
|
}
|
|
@@ -1226,7 +1604,7 @@ var K = 7, q = {
|
|
|
1226
1604
|
e.removeEventListener("click", this.previous);
|
|
1227
1605
|
}
|
|
1228
1606
|
async previous() {
|
|
1229
|
-
await this.calendarMonthOutlet.calendar.step(
|
|
1607
|
+
await this.calendarMonthOutlet.calendar.step(...this.stepArgs(-1)), this.syncOutletValues(), this.draw();
|
|
1230
1608
|
}
|
|
1231
1609
|
nextTargetConnected(e) {
|
|
1232
1610
|
e.addEventListener("click", this.next);
|
|
@@ -1235,10 +1613,10 @@ var K = 7, q = {
|
|
|
1235
1613
|
e.removeEventListener("click", this.next);
|
|
1236
1614
|
}
|
|
1237
1615
|
async next() {
|
|
1238
|
-
await this.calendarMonthOutlet.calendar.step(
|
|
1616
|
+
await this.calendarMonthOutlet.calendar.step(...this.stepArgs(1)), this.syncOutletValues(), this.draw();
|
|
1239
1617
|
}
|
|
1240
1618
|
draw() {
|
|
1241
|
-
this.drawDay(), this.drawMonth(), this.drawYear();
|
|
1619
|
+
this.drawDay(), this.drawMonth(), this.drawYear(), this.drawViewTitle(), this.drawView();
|
|
1242
1620
|
}
|
|
1243
1621
|
drawDay() {
|
|
1244
1622
|
if (!this.hasDayTarget || !this.hasCalendarMonthOutlet) return;
|
|
@@ -1255,7 +1633,39 @@ var K = 7, q = {
|
|
|
1255
1633
|
let { year: e } = this.calendarMonthOutlet.calendar;
|
|
1256
1634
|
this.yearTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { year: this.yearFormatValue }).format(new Date(e, 0));
|
|
1257
1635
|
}
|
|
1258
|
-
|
|
1636
|
+
drawViewTitle() {
|
|
1637
|
+
if (!this.hasViewTitleTarget || !this.hasCalendarMonthOutlet) return;
|
|
1638
|
+
let { year: e, month: t } = this.calendarMonthOutlet.calendar;
|
|
1639
|
+
this.viewTitleTarget.textContent = this.viewTitleLabel(e, t);
|
|
1640
|
+
}
|
|
1641
|
+
syncOutletValues() {
|
|
1642
|
+
if (!this.hasCalendarMonthOutlet) return;
|
|
1643
|
+
let { current: e } = this.calendarMonthOutlet.calendar;
|
|
1644
|
+
e && (this.hasCalendarYearOutlet && this.calendarYearOutlet.navigate(e), this.hasCalendarDecadeOutlet && this.calendarDecadeOutlet.navigate(e));
|
|
1645
|
+
}
|
|
1646
|
+
stepArgs(e) {
|
|
1647
|
+
return this.viewValue === "year" ? ["year", e] : this.viewValue === "decade" ? ["year", e * 10] : ["month", e];
|
|
1648
|
+
}
|
|
1649
|
+
viewTitleLabel(e, t) {
|
|
1650
|
+
if (this.viewValue === "year") return String(e);
|
|
1651
|
+
if (this.viewValue === "decade") {
|
|
1652
|
+
let t = Math.floor(e / 10) * 10;
|
|
1653
|
+
return `${t}–${t + 9}`;
|
|
1654
|
+
}
|
|
1655
|
+
return new Intl.DateTimeFormat(this.localesValue, {
|
|
1656
|
+
month: "long",
|
|
1657
|
+
year: "numeric"
|
|
1658
|
+
}).format(new Date(e, t));
|
|
1659
|
+
}
|
|
1660
|
+
drawView() {
|
|
1661
|
+
let e = this.viewValue === "month", t = this.viewValue === "year", n = this.viewValue === "decade";
|
|
1662
|
+
if (this.hasCalendarMonthOutlet) {
|
|
1663
|
+
let t = this.calendarMonthOutlet;
|
|
1664
|
+
t.hasDaysOfWeekTarget && (t.daysOfWeekTarget.hidden = !e), t.hasDaysOfMonthTarget && (t.daysOfMonthTarget.hidden = !e);
|
|
1665
|
+
}
|
|
1666
|
+
this.hasCalendarYearOutlet && (this.calendarYearOutletElement.hidden = !t), this.hasCalendarDecadeOutlet && (this.calendarDecadeOutletElement.hidden = !n);
|
|
1667
|
+
}
|
|
1668
|
+
}, et = class extends e {
|
|
1259
1669
|
static targets = [
|
|
1260
1670
|
"listbox",
|
|
1261
1671
|
"loading",
|
|
@@ -1278,6 +1688,12 @@ var K = 7, q = {
|
|
|
1278
1688
|
initialize() {
|
|
1279
1689
|
this._requestor = new w();
|
|
1280
1690
|
}
|
|
1691
|
+
connect() {
|
|
1692
|
+
this.hasListboxTarget && (this.listboxNav = new d(this.listboxTarget));
|
|
1693
|
+
}
|
|
1694
|
+
disconnect() {
|
|
1695
|
+
this._requestor.cancel();
|
|
1696
|
+
}
|
|
1281
1697
|
onSelect(e) {
|
|
1282
1698
|
let t = e.target.closest("[role=\"option\"]");
|
|
1283
1699
|
!t || t.getAttribute("aria-disabled") === "true" || this.select(t.dataset.value ?? "");
|
|
@@ -1292,24 +1708,7 @@ var K = 7, q = {
|
|
|
1292
1708
|
});
|
|
1293
1709
|
}
|
|
1294
1710
|
onNavigate(e) {
|
|
1295
|
-
|
|
1296
|
-
"ArrowUp",
|
|
1297
|
-
"ArrowDown",
|
|
1298
|
-
"Enter",
|
|
1299
|
-
" "
|
|
1300
|
-
].includes(e.key)) {
|
|
1301
|
-
if (e.preventDefault(), e.key === "Enter" || e.key === " ") {
|
|
1302
|
-
this.listboxTarget.querySelector("[aria-selected=\"true\"]")?.click();
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
this.step(e.key === "ArrowDown" ? 1 : -1);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
step(e) {
|
|
1309
|
-
let t = [...this.listboxTarget.querySelectorAll("[role=\"option\"]:not([aria-disabled=\"true\"]):not([hidden])")];
|
|
1310
|
-
if (!t.length) return;
|
|
1311
|
-
let n = this.listboxTarget.querySelector("[aria-selected=\"true\"]"), r = t.indexOf(n), i = e > 0 ? t[Math.min(r + 1, t.length - 1)] : t[Math.max(r - 1, 0)];
|
|
1312
|
-
!i || i === n || (t.forEach((e) => e.setAttribute("aria-selected", "false")), i.setAttribute("aria-selected", "true"), i.scrollIntoView({ block: "nearest" }));
|
|
1711
|
+
this.listboxNav?.handleKeyDown(e);
|
|
1313
1712
|
}
|
|
1314
1713
|
filter(e) {
|
|
1315
1714
|
if (this.urlValue) {
|
|
@@ -1333,10 +1732,7 @@ var K = 7, q = {
|
|
|
1333
1732
|
setEmpty(e) {
|
|
1334
1733
|
this.hasEmptyTarget && (this.emptyTarget.hidden = !e);
|
|
1335
1734
|
}
|
|
1336
|
-
|
|
1337
|
-
this._requestor.cancel();
|
|
1338
|
-
}
|
|
1339
|
-
}, ze = class extends e {
|
|
1735
|
+
}, tt = class extends e {
|
|
1340
1736
|
static targets = [
|
|
1341
1737
|
"hour",
|
|
1342
1738
|
"minute",
|
|
@@ -1372,12 +1768,12 @@ var K = 7, q = {
|
|
|
1372
1768
|
selectedValue(e) {
|
|
1373
1769
|
return e?.querySelector("[aria-selected=\"true\"]")?.dataset.value ?? null;
|
|
1374
1770
|
}
|
|
1375
|
-
},
|
|
1771
|
+
}, nt = class extends e {
|
|
1376
1772
|
static targets = ["trigger"];
|
|
1377
1773
|
connect() {
|
|
1378
|
-
|
|
1774
|
+
Q(this, { trigger: this.hasTriggerTarget ? this.triggerTarget : null });
|
|
1379
1775
|
}
|
|
1380
|
-
},
|
|
1776
|
+
}, rt = class extends e {
|
|
1381
1777
|
static targets = ["anchor", "reference"];
|
|
1382
1778
|
static values = {
|
|
1383
1779
|
placement: {
|
|
@@ -1402,7 +1798,7 @@ var K = 7, q = {
|
|
|
1402
1798
|
console.error("FlipperController requires an anchor target. Add data-flipper-target=\"anchor\" to your element.");
|
|
1403
1799
|
return;
|
|
1404
1800
|
}
|
|
1405
|
-
|
|
1801
|
+
Le(this, {
|
|
1406
1802
|
element: this.referenceTarget,
|
|
1407
1803
|
anchor: this.anchorTarget,
|
|
1408
1804
|
placement: this.placementValue,
|
|
@@ -1410,12 +1806,8 @@ var K = 7, q = {
|
|
|
1410
1806
|
ariaRole: this.roleValue
|
|
1411
1807
|
});
|
|
1412
1808
|
}
|
|
1413
|
-
},
|
|
1414
|
-
static targets = [
|
|
1415
|
-
"trigger",
|
|
1416
|
-
"popover",
|
|
1417
|
-
"input"
|
|
1418
|
-
];
|
|
1809
|
+
}, it = class extends e {
|
|
1810
|
+
static targets = ["trigger", "input"];
|
|
1419
1811
|
static values = {
|
|
1420
1812
|
value: String,
|
|
1421
1813
|
minLength: {
|
|
@@ -1424,32 +1816,8 @@ var K = 7, q = {
|
|
|
1424
1816
|
}
|
|
1425
1817
|
};
|
|
1426
1818
|
static outlets = ["combobox-dropdown"];
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
element: this.popoverTarget,
|
|
1430
|
-
activator: this.hasTriggerTarget ? this.triggerTarget : null
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
async dismissed() {
|
|
1434
|
-
await this.close();
|
|
1435
|
-
}
|
|
1436
|
-
async open() {
|
|
1437
|
-
this.hasPopoverTarget && await this.visibility.show();
|
|
1438
|
-
}
|
|
1439
|
-
async close() {
|
|
1440
|
-
this.hasPopoverTarget && await this.visibility.hide();
|
|
1441
|
-
}
|
|
1442
|
-
async toggle() {
|
|
1443
|
-
this.visibility?.visible ? await this.close() : await this.open();
|
|
1444
|
-
}
|
|
1445
|
-
async shown() {
|
|
1446
|
-
this.hasPopoverTarget && i(this.popoverTarget);
|
|
1447
|
-
}
|
|
1448
|
-
async hidden() {
|
|
1449
|
-
this.hasTriggerTarget && this.triggerTarget.focus();
|
|
1450
|
-
}
|
|
1451
|
-
async onSelect(e) {
|
|
1452
|
-
e.detail?.value !== void 0 && (this.valueValue = e.detail.value), await this.close();
|
|
1819
|
+
onSelect(e) {
|
|
1820
|
+
e.detail?.value !== void 0 && (this.valueValue = e.detail.value);
|
|
1453
1821
|
}
|
|
1454
1822
|
onInput(e) {
|
|
1455
1823
|
if (e.target !== this.triggerTarget) return;
|
|
@@ -1463,7 +1831,7 @@ var K = 7, q = {
|
|
|
1463
1831
|
valueValueChanged(e) {
|
|
1464
1832
|
this.hasInputTarget && (this.inputTarget.value = e), this.dispatch("changed", { detail: { value: e } });
|
|
1465
1833
|
}
|
|
1466
|
-
},
|
|
1834
|
+
}, at = class extends e {
|
|
1467
1835
|
static targets = ["input", "toggle"];
|
|
1468
1836
|
static values = {
|
|
1469
1837
|
format: {
|
|
@@ -1480,19 +1848,19 @@ var K = 7, q = {
|
|
|
1480
1848
|
}
|
|
1481
1849
|
};
|
|
1482
1850
|
connect() {
|
|
1483
|
-
|
|
1851
|
+
B(this, {
|
|
1484
1852
|
type: this.formatValue,
|
|
1485
1853
|
options: this.optionsValue
|
|
1486
1854
|
}), this.format(this.readValue()), this.drawToggle();
|
|
1487
1855
|
}
|
|
1488
1856
|
formatValueChanged() {
|
|
1489
|
-
this.formatter && (
|
|
1857
|
+
this.formatter && (B(this, {
|
|
1490
1858
|
type: this.formatValue,
|
|
1491
1859
|
options: this.optionsValue
|
|
1492
1860
|
}), this.format(this.readValue()), this.drawToggle());
|
|
1493
1861
|
}
|
|
1494
1862
|
optionsValueChanged() {
|
|
1495
|
-
this.formatter && (
|
|
1863
|
+
this.formatter && (B(this, {
|
|
1496
1864
|
type: this.formatValue,
|
|
1497
1865
|
options: this.optionsValue
|
|
1498
1866
|
}), this.format(this.readValue()));
|
|
@@ -1532,7 +1900,7 @@ var K = 7, q = {
|
|
|
1532
1900
|
let t = this.formatter.normalize(e), n = this.revealedValue || !this.formatter.maskable() ? this.formatter.format(t) : this.formatter.mask(t);
|
|
1533
1901
|
this.hasInputTarget && (this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value = n : this.inputTarget.textContent = n), this.dispatch("formatted", { detail: { value: n } });
|
|
1534
1902
|
}
|
|
1535
|
-
},
|
|
1903
|
+
}, ot = class extends e {
|
|
1536
1904
|
static targets = ["input", "clear"];
|
|
1537
1905
|
initialize() {
|
|
1538
1906
|
this.onInput = this.draw.bind(this), this.onEscape = this.handleEscape.bind(this);
|
|
@@ -1555,7 +1923,7 @@ var K = 7, q = {
|
|
|
1555
1923
|
handleEscape(e) {
|
|
1556
1924
|
e.key === "Escape" && this.inputTarget.value !== "" && (e.preventDefault(), this.clear());
|
|
1557
1925
|
}
|
|
1558
|
-
},
|
|
1926
|
+
}, st = class extends e {
|
|
1559
1927
|
static targets = ["modal", "overlay"];
|
|
1560
1928
|
initialize() {
|
|
1561
1929
|
this.onCancel = this.close.bind(this);
|
|
@@ -1564,7 +1932,10 @@ var K = 7, q = {
|
|
|
1564
1932
|
this.hasModalTarget || console.error("ModalController requires a modal target. Add data-modal-target=\"modal\" to your element.");
|
|
1565
1933
|
}
|
|
1566
1934
|
modalTargetConnected(e) {
|
|
1567
|
-
this.isNativeDialog = e instanceof HTMLDialogElement, this.isNativeDialog ? (e.addEventListener("cancel", this.onCancel), e.addEventListener("click", this.onBackdropClick)) : (this.focusTrap = new a(e, {
|
|
1935
|
+
this.isNativeDialog = e instanceof HTMLDialogElement, this.isNativeDialog ? (e.addEventListener("cancel", this.onCancel), e.addEventListener("click", this.onBackdropClick)) : (this.focusTrap = new a(e, {
|
|
1936
|
+
escapeDeactivates: !0,
|
|
1937
|
+
onDeactivate: () => this.close()
|
|
1938
|
+
}), Q(this, { element: e }));
|
|
1568
1939
|
}
|
|
1569
1940
|
modalTargetDisconnected(e) {
|
|
1570
1941
|
this.isNativeDialog && (e.removeEventListener("cancel", this.onCancel), e.removeEventListener("click", this.onBackdropClick));
|
|
@@ -1579,7 +1950,7 @@ var K = 7, q = {
|
|
|
1579
1950
|
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
1580
1951
|
e.hidden = !1, document.body.style.overflow = "hidden", this.focusTrap && this.focusTrap.activate();
|
|
1581
1952
|
}
|
|
1582
|
-
|
|
1953
|
+
f("Modal opened");
|
|
1583
1954
|
}
|
|
1584
1955
|
}
|
|
1585
1956
|
close(e) {
|
|
@@ -1591,24 +1962,24 @@ var K = 7, q = {
|
|
|
1591
1962
|
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
1592
1963
|
e.hidden = !0, document.body.style.overflow = "", this.focusTrap && this.focusTrap.deactivate();
|
|
1593
1964
|
}
|
|
1594
|
-
|
|
1965
|
+
f("Modal closed");
|
|
1595
1966
|
}
|
|
1596
1967
|
}
|
|
1597
1968
|
onBackdropClick = (e) => {
|
|
1598
1969
|
let t = this.modalTarget.getBoundingClientRect();
|
|
1599
1970
|
(e.clientY < t.top || e.clientY > t.bottom || e.clientX < t.left || e.clientX > t.right) && this.close();
|
|
1600
1971
|
};
|
|
1601
|
-
},
|
|
1972
|
+
}, ct = class extends e {
|
|
1602
1973
|
static targets = ["content"];
|
|
1603
1974
|
connect() {
|
|
1604
|
-
|
|
1975
|
+
Be(this, { element: this.hasContentTarget ? this.contentTarget : null });
|
|
1605
1976
|
}
|
|
1606
|
-
},
|
|
1977
|
+
}, lt = class extends e {
|
|
1607
1978
|
static targets = [
|
|
1608
|
-
"
|
|
1979
|
+
"trigger",
|
|
1980
|
+
"panel",
|
|
1609
1981
|
"template",
|
|
1610
|
-
"loader"
|
|
1611
|
-
"activator"
|
|
1982
|
+
"loader"
|
|
1612
1983
|
];
|
|
1613
1984
|
static classes = ["hidden"];
|
|
1614
1985
|
static values = {
|
|
@@ -1621,37 +1992,61 @@ var K = 7, q = {
|
|
|
1621
1992
|
staleAfter: {
|
|
1622
1993
|
type: Number,
|
|
1623
1994
|
default: 3600
|
|
1995
|
+
},
|
|
1996
|
+
closeOnSelect: {
|
|
1997
|
+
type: Boolean,
|
|
1998
|
+
default: !0
|
|
1999
|
+
},
|
|
2000
|
+
announceOpen: {
|
|
2001
|
+
type: String,
|
|
2002
|
+
default: "Panel opened"
|
|
2003
|
+
},
|
|
2004
|
+
announceClose: {
|
|
2005
|
+
type: String,
|
|
2006
|
+
default: "Panel closed"
|
|
1624
2007
|
}
|
|
1625
2008
|
};
|
|
1626
2009
|
connect() {
|
|
1627
|
-
|
|
1628
|
-
element: this.
|
|
2010
|
+
Me(this, {
|
|
2011
|
+
element: this.hasPanelTarget ? this.panelTarget : null,
|
|
1629
2012
|
url: this.hasUrlValue ? this.urlValue : null
|
|
1630
|
-
}), this.
|
|
1631
|
-
element: this.
|
|
1632
|
-
activator: this.
|
|
1633
|
-
}), this.hasLoaderTarget &&
|
|
2013
|
+
}), this.hasPanelTarget && (Ue(this, {
|
|
2014
|
+
element: this.panelTarget,
|
|
2015
|
+
activator: this.hasTriggerTarget ? this.triggerTarget : null
|
|
2016
|
+
}), Q(this)), this.hasLoaderTarget && Ue(this, {
|
|
1634
2017
|
element: this.loaderTarget,
|
|
1635
2018
|
visibility: "contentLoaderVisibility"
|
|
1636
2019
|
});
|
|
1637
2020
|
}
|
|
1638
|
-
async
|
|
1639
|
-
await this.
|
|
2021
|
+
async dismissed() {
|
|
2022
|
+
await this.close();
|
|
1640
2023
|
}
|
|
1641
|
-
async
|
|
1642
|
-
await this.visibility.
|
|
2024
|
+
async open() {
|
|
2025
|
+
this.hasPanelTarget && await this.visibility.show();
|
|
2026
|
+
}
|
|
2027
|
+
async close() {
|
|
2028
|
+
this.hasPanelTarget && await this.visibility.hide();
|
|
2029
|
+
}
|
|
2030
|
+
async toggle() {
|
|
2031
|
+
this.visibility?.visible ? await this.close() : await this.open();
|
|
2032
|
+
}
|
|
2033
|
+
async closeOnSelect() {
|
|
2034
|
+
this.closeOnSelectValue && await this.close();
|
|
1643
2035
|
}
|
|
1644
2036
|
async shown() {
|
|
1645
|
-
await this.load();
|
|
2037
|
+
await this.load(), this.hasPanelTarget && i(this.panelTarget), f(this.announceOpenValue);
|
|
2038
|
+
}
|
|
2039
|
+
async hidden() {
|
|
2040
|
+
this.hasTriggerTarget && this.triggerTarget.focus(), f(this.announceCloseValue);
|
|
1646
2041
|
}
|
|
1647
2042
|
canLoad() {
|
|
1648
|
-
return this.
|
|
2043
|
+
return this.hasPanelTarget && this.panelTarget.tagName.toLowerCase() === "turbo-frame" ? (this.hasUrlValue && this.panelTarget.setAttribute("src", this.urlValue), !1) : !0;
|
|
1649
2044
|
}
|
|
1650
2045
|
async contentLoading() {
|
|
1651
2046
|
this.hasLoaderTarget && await this.contentLoaderVisibility.show();
|
|
1652
2047
|
}
|
|
1653
2048
|
async contentLoaded({ content: e }) {
|
|
1654
|
-
this.
|
|
2049
|
+
this.hasPanelTarget && this.panelTarget.replaceChildren(this.getContentNode(e)), this.hasLoaderTarget && await this.contentLoaderVisibility.hide();
|
|
1655
2050
|
}
|
|
1656
2051
|
getContentNode(e) {
|
|
1657
2052
|
if (typeof e == "string") {
|
|
@@ -1663,6 +2058,63 @@ var K = 7, q = {
|
|
|
1663
2058
|
contentLoader() {
|
|
1664
2059
|
if (this.hasTemplateTarget) return this.templateTarget instanceof HTMLTemplateElement ? this.templateTarget.content : this.templateTarget.innerHTML;
|
|
1665
2060
|
}
|
|
2061
|
+
}, ut = class extends e {
|
|
2062
|
+
static targets = [
|
|
2063
|
+
"trigger",
|
|
2064
|
+
"detail",
|
|
2065
|
+
"time"
|
|
2066
|
+
];
|
|
2067
|
+
static values = { dateFormat: {
|
|
2068
|
+
type: Object,
|
|
2069
|
+
default: {}
|
|
2070
|
+
} };
|
|
2071
|
+
connect() {
|
|
2072
|
+
this.rovingTabIndex = new u(this.triggerTargets, { orientation: "vertical" }), this.rovingTabIndex.activate();
|
|
2073
|
+
}
|
|
2074
|
+
disconnect() {
|
|
2075
|
+
this.rovingTabIndex?.deactivate(), this.rovingTabIndex = null;
|
|
2076
|
+
}
|
|
2077
|
+
toggle(e) {
|
|
2078
|
+
let t = e.currentTarget;
|
|
2079
|
+
t.getAttribute("aria-expanded") === "true" ? this.collapseItem(t) : this.expandItem(t);
|
|
2080
|
+
}
|
|
2081
|
+
expand(e) {
|
|
2082
|
+
this.expandItem(e.currentTarget);
|
|
2083
|
+
}
|
|
2084
|
+
collapse(e) {
|
|
2085
|
+
this.collapseItem(e.currentTarget);
|
|
2086
|
+
}
|
|
2087
|
+
expandItem(e) {
|
|
2088
|
+
let t = this.detailTargets.find((t) => t.id === e.getAttribute("aria-controls")) ?? null;
|
|
2089
|
+
this.dispatch("expand", { detail: {
|
|
2090
|
+
trigger: e,
|
|
2091
|
+
detail: t
|
|
2092
|
+
} }), g(e, !0), t && (v(t, !1), f(`${e.textContent.trim()} expanded`)), this.dispatch("expanded", { detail: {
|
|
2093
|
+
trigger: e,
|
|
2094
|
+
detail: t
|
|
2095
|
+
} });
|
|
2096
|
+
}
|
|
2097
|
+
collapseItem(e) {
|
|
2098
|
+
let t = this.detailTargets.find((t) => t.id === e.getAttribute("aria-controls")) ?? null;
|
|
2099
|
+
this.dispatch("collapse", { detail: {
|
|
2100
|
+
trigger: e,
|
|
2101
|
+
detail: t
|
|
2102
|
+
} }), g(e, !1), t && (v(t, !0), f(`${e.textContent.trim()} collapsed`)), this.dispatch("collapsed", { detail: {
|
|
2103
|
+
trigger: e,
|
|
2104
|
+
detail: t
|
|
2105
|
+
} });
|
|
2106
|
+
}
|
|
2107
|
+
triggerTargetConnected(e) {
|
|
2108
|
+
e.hasAttribute("aria-expanded") || e.setAttribute("aria-expanded", "false"), this.rovingTabIndex?.updateItems(this.triggerTargets);
|
|
2109
|
+
}
|
|
2110
|
+
triggerTargetDisconnected() {
|
|
2111
|
+
this.rovingTabIndex?.updateItems(this.triggerTargets);
|
|
2112
|
+
}
|
|
2113
|
+
timeTargetConnected(e) {
|
|
2114
|
+
if (!Object.keys(this.dateFormatValue).length || e.textContent.trim()) return;
|
|
2115
|
+
let t = P.format(e.getAttribute("datetime"), this.dateFormatValue);
|
|
2116
|
+
t && (e.textContent = t);
|
|
2117
|
+
}
|
|
1666
2118
|
};
|
|
1667
2119
|
//#endregion
|
|
1668
|
-
export { y as ARIA_HASPOPUP_VALUES,
|
|
2120
|
+
export { y as ARIA_HASPOPUP_VALUES, Ge as CalendarDecadeController, Ke as CalendarDecadeSelectorController, qe as CalendarMonthController, Je as CalendarMonthSelectorController, Xe as CalendarYearController, Ze as CalendarYearSelectorController, Qe as ClipboardController, $e as ComboboxDateController, et as ComboboxDropdownController, tt as ComboboxTimeController, nt as DismisserController, t as FOCUSABLE_SELECTOR, I as FORMATTER_TYPES, rt as FlipperController, a as FocusTrap, z as Formatter, ot as InputClearableController, it as InputComboboxController, at as InputFormatterController, d as ListboxNavigation, st as ModalController, ct as PannerController, lt as PopoverController, w as Requestor, u as RovingTabIndex, ut as TimelineController, f as announce, S as connectTriggerToTarget, re as disconnectTriggerFromTarget, m as ensureId, E as filterOptions, i as focusFirst, T as fuzzyMatcher, p as generateId, n as getFocusableElements, s as isActivationKey, c as isArrowKey, o as isKey, r as isVisible, l as preventDefault, h as setAriaState, te as setChecked, ne as setDisabled, g as setExpanded, v as setHidden, _ as setPressed };
|