stimulus_plumbers 0.2.7 → 0.2.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +57 -41
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +734 -248
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +57 -0
- data/lib/stimulus_plumbers/components/combobox/date.rb +52 -0
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +41 -0
- data/lib/stimulus_plumbers/components/combobox/option.rb +27 -0
- data/lib/stimulus_plumbers/components/combobox/option_group.rb +52 -0
- data/lib/stimulus_plumbers/components/combobox/renderer.rb +78 -0
- data/lib/stimulus_plumbers/components/combobox/time.rb +103 -0
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +1 -1
- data/lib/stimulus_plumbers/components/plumber/html_options.rb +22 -3
- data/lib/stimulus_plumbers/components/time_picker/renderer.rb +38 -0
- data/lib/stimulus_plumbers/form/builder.rb +57 -12
- data/lib/stimulus_plumbers/form/field_component.rb +12 -10
- data/lib/stimulus_plumbers/form/fields/combobox.rb +41 -0
- data/lib/stimulus_plumbers/form/fields/password.rb +55 -0
- data/lib/stimulus_plumbers/form/fields/renderer.rb +1 -2
- data/lib/stimulus_plumbers/form/fields/search.rb +40 -0
- data/lib/stimulus_plumbers/form/fields/select.rb +8 -2
- data/lib/stimulus_plumbers/form/fields/text.rb +12 -4
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +74 -0
- data/lib/stimulus_plumbers/helpers.rb +2 -2
- data/lib/stimulus_plumbers/themes/{form.rb → base/form.rb} +6 -2
- data/lib/stimulus_plumbers/themes/base.rb +7 -7
- data/lib/stimulus_plumbers/themes/tailwind/form.rb +10 -6
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +18 -1
- metadata +21 -10
- data/lib/stimulus_plumbers/components/date_picker/renderer.rb +0 -82
- data/lib/stimulus_plumbers/helpers/date_picker_helper.rb +0 -17
- /data/lib/stimulus_plumbers/themes/{action_list.rb → base/action_list.rb} +0 -0
- /data/lib/stimulus_plumbers/themes/{avatar.rb → base/avatar.rb} +0 -0
- /data/lib/stimulus_plumbers/themes/{button.rb → base/button.rb} +0 -0
- /data/lib/stimulus_plumbers/themes/{calendar.rb → base/calendar.rb} +0 -0
- /data/lib/stimulus_plumbers/themes/{card.rb → base/card.rb} +0 -0
- /data/lib/stimulus_plumbers/themes/{layout.rb → base/layout.rb} +0 -0
|
@@ -124,54 +124,54 @@ function p(e, t = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
var m = (e = "a11y") => `${e}-${Math.random().toString(36).substr(2, 9)}`, h = (e, t = "element") => e.id ||= m(t), g = (e, t, n) => {
|
|
126
126
|
e.setAttribute(t, n.toString());
|
|
127
|
-
}, _ = (e, t) => g(e, "aria-expanded", t), v = (e, t) => g(e, "aria-pressed", t),
|
|
128
|
-
function
|
|
127
|
+
}, _ = (e, t) => g(e, "aria-expanded", t), v = (e, t) => g(e, "aria-pressed", t), ee = (e, t) => g(e, "aria-checked", t);
|
|
128
|
+
function te(e, t) {
|
|
129
129
|
g(e, "aria-disabled", t), t ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex");
|
|
130
130
|
}
|
|
131
|
-
var
|
|
131
|
+
var y = {
|
|
132
132
|
menu: "menu",
|
|
133
133
|
listbox: "listbox",
|
|
134
134
|
tree: "tree",
|
|
135
135
|
grid: "grid",
|
|
136
136
|
dialog: "dialog"
|
|
137
|
-
},
|
|
137
|
+
}, b = (e, t, n) => {
|
|
138
138
|
Object.entries(t).forEach(([t, r]) => {
|
|
139
139
|
e.setAttribute(t, r), n[t] = r;
|
|
140
140
|
});
|
|
141
|
-
},
|
|
142
|
-
function
|
|
141
|
+
}, x = (e, t, n) => n || !e.hasAttribute(t);
|
|
142
|
+
function S({ trigger: e, target: t, role: n = null, override: r = !1 }) {
|
|
143
143
|
let i = {
|
|
144
144
|
trigger: {},
|
|
145
145
|
target: {}
|
|
146
146
|
};
|
|
147
147
|
if (!e || !t) return i;
|
|
148
148
|
let a = {}, o = {};
|
|
149
|
-
if (n &&
|
|
150
|
-
let e =
|
|
149
|
+
if (n && x(t, "role", r) && (o.role = n), t.id && (x(e, "aria-controls", r) && (a["aria-controls"] = t.id), n === "tooltip" && x(e, "aria-describedby", r) && (a["aria-describedby"] = t.id)), n && x(e, "aria-haspopup", r)) {
|
|
150
|
+
let e = y[n] || "true";
|
|
151
151
|
e && (a["aria-haspopup"] = e);
|
|
152
152
|
}
|
|
153
|
-
return
|
|
153
|
+
return b(t, o, i.target), b(e, a, i.trigger), i;
|
|
154
154
|
}
|
|
155
|
-
var
|
|
155
|
+
var C = (e, t) => {
|
|
156
156
|
t.forEach((t) => {
|
|
157
157
|
e.hasAttribute(t) && e.removeAttribute(t);
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
-
function
|
|
161
|
-
!e || !t || (
|
|
160
|
+
function ne({ trigger: e, target: t, attributes: n = null }) {
|
|
161
|
+
!e || !t || (C(e, n || [
|
|
162
162
|
"aria-controls",
|
|
163
163
|
"aria-haspopup",
|
|
164
164
|
"aria-describedby"
|
|
165
|
-
]), (!n || n.includes("role")) &&
|
|
165
|
+
]), (!n || n.includes("role")) && C(t, ["role"]));
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/plumbers/plumber/support.js
|
|
169
|
-
var
|
|
169
|
+
var w = {
|
|
170
170
|
get visibleOnly() {
|
|
171
171
|
return !0;
|
|
172
172
|
},
|
|
173
173
|
hiddenClass: null
|
|
174
|
-
},
|
|
174
|
+
}, T = {
|
|
175
175
|
get top() {
|
|
176
176
|
return "bottom";
|
|
177
177
|
},
|
|
@@ -185,7 +185,7 @@ var E = {
|
|
|
185
185
|
return "left";
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
|
-
function
|
|
188
|
+
function E({ x: e, y: t, width: n, height: r }) {
|
|
189
189
|
return {
|
|
190
190
|
x: e,
|
|
191
191
|
y: t,
|
|
@@ -197,47 +197,47 @@ function O({ x: e, y: t, width: n, height: r }) {
|
|
|
197
197
|
bottom: t + r
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
200
|
+
function D() {
|
|
201
|
+
return E({
|
|
202
202
|
x: 0,
|
|
203
203
|
y: 0,
|
|
204
204
|
width: window.innerWidth || document.documentElement.clientWidth,
|
|
205
205
|
height: window.innerHeight || document.documentElement.clientHeight
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function re(e) {
|
|
209
209
|
if (!(e instanceof HTMLElement)) return !1;
|
|
210
|
-
let t =
|
|
210
|
+
let t = D(), n = e.getBoundingClientRect(), r = n.top <= t.height && n.top + n.height > 0, i = n.left <= t.width && n.left + n.width > 0;
|
|
211
211
|
return r && i;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function O(e) {
|
|
214
214
|
return e instanceof Date && !isNaN(e);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function k(...e) {
|
|
217
217
|
if (e.length === 0) throw "Missing values to parse as date";
|
|
218
218
|
if (e.length === 1) {
|
|
219
219
|
let t = new Date(e[0]);
|
|
220
|
-
if (e[0] &&
|
|
220
|
+
if (e[0] && O(t)) return t;
|
|
221
221
|
} else {
|
|
222
222
|
let t = new Date(...e);
|
|
223
|
-
if (
|
|
223
|
+
if (O(t)) return t;
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
//#endregion
|
|
227
227
|
//#region src/plumbers/plumber/index.js
|
|
228
|
-
var
|
|
228
|
+
var ie = {
|
|
229
229
|
element: null,
|
|
230
230
|
visible: null,
|
|
231
231
|
dispatch: !0,
|
|
232
232
|
prefix: ""
|
|
233
|
-
},
|
|
233
|
+
}, A = class {
|
|
234
234
|
constructor(e, t = {}) {
|
|
235
235
|
this.controller = e;
|
|
236
|
-
let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({},
|
|
237
|
-
this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r :
|
|
236
|
+
let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({}, ie, t);
|
|
237
|
+
this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r : w.visibleOnly, this.visibleCallback = typeof r == "string" ? r : null, this.notify = !!i, this.prefix = typeof a == "string" && a ? a : e.identifier;
|
|
238
238
|
}
|
|
239
239
|
get visible() {
|
|
240
|
-
return this.element instanceof HTMLElement ? this.visibleOnly ?
|
|
240
|
+
return this.element instanceof HTMLElement ? this.visibleOnly ? re(this.element) && this.isVisible(this.element) : !0 : !1;
|
|
241
241
|
}
|
|
242
242
|
isVisible(e) {
|
|
243
243
|
if (this.visibleCallback) {
|
|
@@ -266,7 +266,7 @@ var N = {
|
|
|
266
266
|
return n instanceof Promise ? await n : n;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
},
|
|
269
|
+
}, j = 7, M = {
|
|
270
270
|
locales: ["default"],
|
|
271
271
|
today: "",
|
|
272
272
|
day: null,
|
|
@@ -281,15 +281,15 @@ var N = {
|
|
|
281
281
|
disabledYears: [],
|
|
282
282
|
firstDayOfWeek: 0,
|
|
283
283
|
onNavigated: "navigated"
|
|
284
|
-
},
|
|
284
|
+
}, ae = class extends A {
|
|
285
285
|
constructor(e, t = {}) {
|
|
286
286
|
super(e, t);
|
|
287
|
-
let n = Object.assign({},
|
|
288
|
-
this.onNavigated = r, this.since =
|
|
287
|
+
let n = Object.assign({}, M, t), { onNavigated: r, since: i, till: a, firstDayOfWeek: o } = n;
|
|
288
|
+
this.onNavigated = r, this.since = k(i), this.till = k(a), this.firstDayOfWeek = 0 <= o && o < 7 ? o : M.firstDayOfWeek;
|
|
289
289
|
let { disabledDates: s, disabledWeekdays: c, disabledDays: l, disabledMonths: u, disabledYears: d } = n;
|
|
290
290
|
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 : [];
|
|
291
291
|
let { today: f, day: p, month: m, year: h } = n;
|
|
292
|
-
this.now =
|
|
292
|
+
this.now = k(f) || /* @__PURE__ */ new Date(), typeof h == "number" && typeof m == "number" && typeof p == "number" ? this.current = k(h, m, p) : this.current = this.now, this.build(), this.enhance();
|
|
293
293
|
}
|
|
294
294
|
build() {
|
|
295
295
|
this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear();
|
|
@@ -325,7 +325,7 @@ var N = {
|
|
|
325
325
|
let a = new Date(t, e, i);
|
|
326
326
|
n.push(r(a));
|
|
327
327
|
}
|
|
328
|
-
let s = n.length %
|
|
328
|
+
let s = n.length % j, c = s === 0 ? 0 : j - s;
|
|
329
329
|
for (let i = 1; i <= c; i++) {
|
|
330
330
|
let a = new Date(t, e + 1, i);
|
|
331
331
|
n.push(r(a));
|
|
@@ -350,18 +350,18 @@ var N = {
|
|
|
350
350
|
return this.now;
|
|
351
351
|
}
|
|
352
352
|
set today(e) {
|
|
353
|
-
if (!
|
|
353
|
+
if (!O(e)) return;
|
|
354
354
|
let t = this.month ? this.month : e.getMonth(), n = this.year ? this.year : e.getFullYear(), r = t == e.getMonth() && n == e.getFullYear(), i = this.hasDayValue ? this.day : r ? e.getDate() : 1;
|
|
355
355
|
this.now = new Date(n, t, i).toISOString();
|
|
356
356
|
}
|
|
357
357
|
get current() {
|
|
358
|
-
return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ?
|
|
358
|
+
return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? k(this.year, this.month, this.day) : null;
|
|
359
359
|
}
|
|
360
360
|
set current(e) {
|
|
361
|
-
|
|
361
|
+
O(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
|
|
362
362
|
}
|
|
363
363
|
navigate = async (e) => {
|
|
364
|
-
if (!
|
|
364
|
+
if (!O(e)) return;
|
|
365
365
|
let t = this.current, n = e.toISOString(), r = t.toISOString();
|
|
366
366
|
this.dispatch("navigate", { detail: {
|
|
367
367
|
from: r,
|
|
@@ -392,7 +392,7 @@ var N = {
|
|
|
392
392
|
await this.navigate(n);
|
|
393
393
|
};
|
|
394
394
|
isDisabled = (e) => {
|
|
395
|
-
if (!
|
|
395
|
+
if (!O(e)) return !1;
|
|
396
396
|
if (this.disabledDates.length) {
|
|
397
397
|
let t = e.getTime();
|
|
398
398
|
for (let e of this.disabledDates) if (t === new Date(e).getTime()) return !0;
|
|
@@ -422,7 +422,7 @@ var N = {
|
|
|
422
422
|
return !1;
|
|
423
423
|
};
|
|
424
424
|
isWithinRange = (e) => {
|
|
425
|
-
if (!
|
|
425
|
+
if (!O(e)) return !1;
|
|
426
426
|
let t = !0;
|
|
427
427
|
return this.since && (t &&= e >= this.since), this.till && (t &&= e <= this.till), t;
|
|
428
428
|
};
|
|
@@ -485,19 +485,61 @@ var N = {
|
|
|
485
485
|
};
|
|
486
486
|
} });
|
|
487
487
|
}
|
|
488
|
-
},
|
|
488
|
+
}, oe = (e, t) => new ae(e, t), se = class extends A {
|
|
489
|
+
constructor(e, t = {}) {
|
|
490
|
+
super(e, t), this.debounceTimer = null, this.abortController = null;
|
|
491
|
+
}
|
|
492
|
+
fuzzyFilter(e, t) {
|
|
493
|
+
let n = t.toLowerCase(), r = 0;
|
|
494
|
+
return e.querySelectorAll("[role=\"option\"]").forEach((e) => {
|
|
495
|
+
let t = this.fuzzyMatch(n, e.textContent.trim().toLowerCase());
|
|
496
|
+
e.hidden = !t, t && r++;
|
|
497
|
+
}), r;
|
|
498
|
+
}
|
|
499
|
+
fuzzyMatch(e, t) {
|
|
500
|
+
let n = 0;
|
|
501
|
+
for (let r = 0; r < t.length && n < e.length; r++) t[r] === e[n] && n++;
|
|
502
|
+
return n === e.length;
|
|
503
|
+
}
|
|
504
|
+
scheduleFetch(e, t, n) {
|
|
505
|
+
clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => this.fetch(e, n), t);
|
|
506
|
+
}
|
|
507
|
+
async fetch(e, { url: t, field: n, onLoading: r, onLoaded: i, onError: a }) {
|
|
508
|
+
this.abortController?.abort(), this.abortController = new AbortController(), r?.(!0);
|
|
509
|
+
let o = new URL(t, window.location.href);
|
|
510
|
+
o.searchParams.set(n, e);
|
|
511
|
+
try {
|
|
512
|
+
let e = await fetch(o, {
|
|
513
|
+
signal: this.abortController.signal,
|
|
514
|
+
headers: {
|
|
515
|
+
Accept: "text/html",
|
|
516
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
if (!e.ok) throw Error(`${e.status}`);
|
|
520
|
+
i?.(await e.text());
|
|
521
|
+
} catch (e) {
|
|
522
|
+
e.name !== "AbortError" && a?.(e);
|
|
523
|
+
} finally {
|
|
524
|
+
r?.(!1);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
cancel() {
|
|
528
|
+
clearTimeout(this.debounceTimer), this.abortController?.abort();
|
|
529
|
+
}
|
|
530
|
+
}, ce = (e, t) => new se(e, t), N = {
|
|
489
531
|
content: null,
|
|
490
532
|
url: "",
|
|
491
533
|
reload: "never",
|
|
492
534
|
stale: 3600,
|
|
493
|
-
onLoad: "
|
|
535
|
+
onLoad: "canLoad",
|
|
494
536
|
onLoading: "contentLoading",
|
|
495
537
|
onLoaded: "contentLoaded"
|
|
496
|
-
},
|
|
538
|
+
}, le = class extends A {
|
|
497
539
|
constructor(e, t = {}) {
|
|
498
540
|
super(e, t);
|
|
499
|
-
let n = Object.assign({},
|
|
500
|
-
this.content = r, this.url = i, this.reload = typeof a == "string" ? a :
|
|
541
|
+
let n = Object.assign({}, N, t), { content: r, url: i, reload: a, stale: o } = n;
|
|
542
|
+
this.content = r, this.url = i, this.reload = typeof a == "string" ? a : N.reload, this.stale = typeof o == "number" ? o : N.stale;
|
|
501
543
|
let { onLoad: s, onLoading: c, onLoaded: l } = n;
|
|
502
544
|
this.onLoad = s, this.onLoading = c, this.onLoaded = l, this.enhance();
|
|
503
545
|
}
|
|
@@ -506,7 +548,7 @@ var N = {
|
|
|
506
548
|
case "never": return !1;
|
|
507
549
|
case "always": return !0;
|
|
508
550
|
default: {
|
|
509
|
-
let e =
|
|
551
|
+
let e = k(this.loadedAt);
|
|
510
552
|
return e && /* @__PURE__ */ new Date() - e > this.stale * 1e3;
|
|
511
553
|
}
|
|
512
554
|
}
|
|
@@ -532,14 +574,14 @@ var N = {
|
|
|
532
574
|
let e = this;
|
|
533
575
|
Object.assign(this.controller, { load: e.load.bind(e) });
|
|
534
576
|
}
|
|
535
|
-
},
|
|
577
|
+
}, ue = (e, t) => new le(e, t), de = {
|
|
536
578
|
trigger: null,
|
|
537
579
|
events: ["click"],
|
|
538
580
|
onDismissed: "dismissed"
|
|
539
|
-
},
|
|
581
|
+
}, fe = class extends A {
|
|
540
582
|
constructor(e, t = {}) {
|
|
541
583
|
super(e, t);
|
|
542
|
-
let { trigger: n, events: r, onDismissed: i } = Object.assign({},
|
|
584
|
+
let { trigger: n, events: r, onDismissed: i } = Object.assign({}, de, t);
|
|
543
585
|
this.onDismissed = i, this.trigger = n || this.element, this.events = r, this.enhance(), this.observe();
|
|
544
586
|
}
|
|
545
587
|
dismiss = async (e) => {
|
|
@@ -562,7 +604,7 @@ var N = {
|
|
|
562
604
|
e.unobserve(), t();
|
|
563
605
|
} });
|
|
564
606
|
}
|
|
565
|
-
},
|
|
607
|
+
}, P = (e, t) => new fe(e, t), F = {
|
|
566
608
|
anchor: null,
|
|
567
609
|
events: ["click"],
|
|
568
610
|
placement: "bottom",
|
|
@@ -570,11 +612,11 @@ var N = {
|
|
|
570
612
|
onFlipped: "flipped",
|
|
571
613
|
ariaRole: null,
|
|
572
614
|
respectMotion: !0
|
|
573
|
-
},
|
|
615
|
+
}, I = class extends A {
|
|
574
616
|
constructor(e, t = {}) {
|
|
575
617
|
super(e, t);
|
|
576
|
-
let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({},
|
|
577
|
-
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 &&
|
|
618
|
+
let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, F, t);
|
|
619
|
+
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({
|
|
578
620
|
trigger: this.anchor,
|
|
579
621
|
target: this.element,
|
|
580
622
|
role: this.ariaRole
|
|
@@ -592,7 +634,7 @@ var N = {
|
|
|
592
634
|
}), this.dispatch("flipped", { detail: { placement: e } });
|
|
593
635
|
};
|
|
594
636
|
flippedRect(e, t) {
|
|
595
|
-
let n = this.quadrumRect(e,
|
|
637
|
+
let n = this.quadrumRect(e, D()), r = [this.placement, T[this.placement]], i = {};
|
|
596
638
|
for (; !Object.keys(i).length && r.length > 0;) {
|
|
597
639
|
let a = r.shift();
|
|
598
640
|
if (!this.biggerRectThan(n[a], t)) continue;
|
|
@@ -603,25 +645,25 @@ var N = {
|
|
|
603
645
|
}
|
|
604
646
|
quadrumRect(e, t) {
|
|
605
647
|
return {
|
|
606
|
-
left:
|
|
648
|
+
left: E({
|
|
607
649
|
x: t.x,
|
|
608
650
|
y: t.y,
|
|
609
651
|
width: e.x - t.x,
|
|
610
652
|
height: t.height
|
|
611
653
|
}),
|
|
612
|
-
right:
|
|
654
|
+
right: E({
|
|
613
655
|
x: e.x + e.width,
|
|
614
656
|
y: t.y,
|
|
615
657
|
width: t.width - (e.x + e.width),
|
|
616
658
|
height: t.height
|
|
617
659
|
}),
|
|
618
|
-
top:
|
|
660
|
+
top: E({
|
|
619
661
|
x: t.x,
|
|
620
662
|
y: t.y,
|
|
621
663
|
width: t.width,
|
|
622
664
|
height: e.y - t.y
|
|
623
665
|
}),
|
|
624
|
-
bottom:
|
|
666
|
+
bottom: E({
|
|
625
667
|
x: t.x,
|
|
626
668
|
y: e.y + e.height,
|
|
627
669
|
width: t.width,
|
|
@@ -631,25 +673,25 @@ var N = {
|
|
|
631
673
|
}
|
|
632
674
|
quadrumPlacement(e, t, n) {
|
|
633
675
|
switch (t) {
|
|
634
|
-
case "top": return
|
|
676
|
+
case "top": return E({
|
|
635
677
|
x: n.x,
|
|
636
678
|
y: e.y - n.height,
|
|
637
679
|
width: n.width,
|
|
638
680
|
height: n.height
|
|
639
681
|
});
|
|
640
|
-
case "bottom": return
|
|
682
|
+
case "bottom": return E({
|
|
641
683
|
x: n.x,
|
|
642
684
|
y: e.y + e.height,
|
|
643
685
|
width: n.width,
|
|
644
686
|
height: n.height
|
|
645
687
|
});
|
|
646
|
-
case "left": return
|
|
688
|
+
case "left": return E({
|
|
647
689
|
x: e.x - n.width,
|
|
648
690
|
y: n.y,
|
|
649
691
|
width: n.width,
|
|
650
692
|
height: n.height
|
|
651
693
|
});
|
|
652
|
-
case "right": return
|
|
694
|
+
case "right": return E({
|
|
653
695
|
x: e.x + e.width,
|
|
654
696
|
y: n.y,
|
|
655
697
|
width: n.width,
|
|
@@ -663,7 +705,7 @@ var N = {
|
|
|
663
705
|
case "top":
|
|
664
706
|
case "bottom": {
|
|
665
707
|
let t = e.x;
|
|
666
|
-
return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width),
|
|
708
|
+
return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width), E({
|
|
667
709
|
x: t,
|
|
668
710
|
y: n.y,
|
|
669
711
|
width: n.width,
|
|
@@ -673,7 +715,7 @@ var N = {
|
|
|
673
715
|
case "left":
|
|
674
716
|
case "right": {
|
|
675
717
|
let t = e.y;
|
|
676
|
-
return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height),
|
|
718
|
+
return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height), E({
|
|
677
719
|
x: n.x,
|
|
678
720
|
y: t,
|
|
679
721
|
width: n.width,
|
|
@@ -705,7 +747,196 @@ var N = {
|
|
|
705
747
|
flip: e.flip.bind(e)
|
|
706
748
|
});
|
|
707
749
|
}
|
|
708
|
-
},
|
|
750
|
+
}, L = (e, t) => new I(e, t), R = {
|
|
751
|
+
normalize(e) {
|
|
752
|
+
return typeof e == "string" ? e : "";
|
|
753
|
+
},
|
|
754
|
+
validate() {
|
|
755
|
+
return !0;
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/plumbers/input_format/formatters/credit_card.js
|
|
760
|
+
function z(e) {
|
|
761
|
+
let t = 0, n = !1;
|
|
762
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
763
|
+
let i = parseInt(e[r], 10);
|
|
764
|
+
n && (i *= 2, i > 9 && (i -= 9)), t += i, n = !n;
|
|
765
|
+
}
|
|
766
|
+
return t % 10 == 0;
|
|
767
|
+
}
|
|
768
|
+
var B = /\D/g, V = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
|
|
769
|
+
normalize(e) {
|
|
770
|
+
return typeof e == "string" ? e.replace(B, "") : "";
|
|
771
|
+
},
|
|
772
|
+
validate(e) {
|
|
773
|
+
return typeof e != "string" || !V.test(e) ? !1 : z(e);
|
|
774
|
+
},
|
|
775
|
+
format(e) {
|
|
776
|
+
return typeof e == "string" ? e.replace(pe, "$1 ") : "";
|
|
777
|
+
}
|
|
778
|
+
}, H = { 1: 10 }, U = /\D/g, he = /^\+\d{7,15}$/, ge = {
|
|
779
|
+
normalize(e) {
|
|
780
|
+
if (typeof e != "string") return "";
|
|
781
|
+
let t = e.trimStart().startsWith("+"), n = e.replace(U, "");
|
|
782
|
+
return t ? `+${n}` : n;
|
|
783
|
+
},
|
|
784
|
+
validate(e) {
|
|
785
|
+
if (typeof e != "string") return !1;
|
|
786
|
+
if (he.test(e)) return !0;
|
|
787
|
+
let t = e.replace(U, "");
|
|
788
|
+
return Object.values(H).includes(t.length);
|
|
789
|
+
},
|
|
790
|
+
format(e) {
|
|
791
|
+
if (typeof e != "string") return "";
|
|
792
|
+
let t = e.replace(U, "");
|
|
793
|
+
for (let [e, n] of Object.entries(H)) {
|
|
794
|
+
if (t.length === n) return `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6)}`;
|
|
795
|
+
let r = n + e.length;
|
|
796
|
+
if (t.length === r && t.startsWith(e)) {
|
|
797
|
+
let n = t.slice(e.length);
|
|
798
|
+
return `+${e} (${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
return e;
|
|
802
|
+
}
|
|
803
|
+
}, _e = /[^\d.,-]/g, ve = /^-?\d+(\.\d+)?$/, ye = {
|
|
804
|
+
normalize(e) {
|
|
805
|
+
if (typeof e != "string") return "";
|
|
806
|
+
let t = e.replace(_e, "");
|
|
807
|
+
if (!t) return "";
|
|
808
|
+
let n = t.lastIndexOf(","), r = t.lastIndexOf(".");
|
|
809
|
+
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;
|
|
810
|
+
},
|
|
811
|
+
validate(e) {
|
|
812
|
+
return typeof e == "string" ? ve.test(e) : !1;
|
|
813
|
+
},
|
|
814
|
+
format(e, t = {}) {
|
|
815
|
+
if (typeof e != "string") return "";
|
|
816
|
+
let n = parseFloat(e);
|
|
817
|
+
if (isNaN(n)) return e;
|
|
818
|
+
let r = t.locale || "en-US", i = t.currency || "USD", a = t.fractionDigits === void 0 ? {} : {
|
|
819
|
+
minimumFractionDigits: t.fractionDigits,
|
|
820
|
+
maximumFractionDigits: t.fractionDigits
|
|
821
|
+
};
|
|
822
|
+
try {
|
|
823
|
+
return new Intl.NumberFormat(r, {
|
|
824
|
+
style: "currency",
|
|
825
|
+
currency: i,
|
|
826
|
+
...a
|
|
827
|
+
}).format(n);
|
|
828
|
+
} catch {
|
|
829
|
+
return e;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}, W = /^\d{4}-\d{2}-\d{2}$/, be = /^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/, xe = /\D/g, G = {
|
|
833
|
+
normalize(e) {
|
|
834
|
+
if (typeof e != "string") return "";
|
|
835
|
+
let t = e.trim();
|
|
836
|
+
if (W.test(t)) return t;
|
|
837
|
+
let n = t.match(be);
|
|
838
|
+
if (n) {
|
|
839
|
+
let [, e, t, r] = n;
|
|
840
|
+
if (e.length === 4) return `${e}-${t.padStart(2, "0")}-${r.padStart(2, "0")}`;
|
|
841
|
+
if (r.length === 4) return `${r}-${e.padStart(2, "0")}-${t.padStart(2, "0")}`;
|
|
842
|
+
}
|
|
843
|
+
let r = t.replace(xe, "");
|
|
844
|
+
if (r.length === 8) {
|
|
845
|
+
let e = parseInt(r.slice(0, 4), 10);
|
|
846
|
+
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)}`;
|
|
847
|
+
}
|
|
848
|
+
return t;
|
|
849
|
+
},
|
|
850
|
+
validate(e) {
|
|
851
|
+
if (typeof e != "string") return !1;
|
|
852
|
+
let t = G.normalize(e);
|
|
853
|
+
if (!W.test(t)) return !1;
|
|
854
|
+
let n = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
|
|
855
|
+
return !isNaN(n.getTime()) && n.toISOString().startsWith(t);
|
|
856
|
+
},
|
|
857
|
+
format(e, t = {}) {
|
|
858
|
+
if (typeof e != "string") return "";
|
|
859
|
+
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
860
|
+
if (isNaN(n.getTime())) return e;
|
|
861
|
+
let r = t.locale || "en-US";
|
|
862
|
+
try {
|
|
863
|
+
return new Intl.DateTimeFormat(r, {
|
|
864
|
+
year: t.year || "numeric",
|
|
865
|
+
month: t.month || "2-digit",
|
|
866
|
+
day: t.day || "2-digit",
|
|
867
|
+
timeZone: t.timeZone || "UTC"
|
|
868
|
+
}).format(n);
|
|
869
|
+
} catch {
|
|
870
|
+
return e;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}, Se = /^([01]?\d|2[0-3]):([0-5]\d)$/, K = {
|
|
874
|
+
normalize(e) {
|
|
875
|
+
if (typeof e != "string") return "";
|
|
876
|
+
let t = e.trim();
|
|
877
|
+
if (Se.test(t)) {
|
|
878
|
+
let [e, n] = t.split(":");
|
|
879
|
+
return `${String(parseInt(e, 10)).padStart(2, "0")}:${n}`;
|
|
880
|
+
}
|
|
881
|
+
let n = t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
|
|
882
|
+
if (n) {
|
|
883
|
+
let e = parseInt(n[1], 10), t = n[2];
|
|
884
|
+
return e = n[3].toUpperCase() === "AM" ? e === 12 ? 0 : e : e === 12 ? 12 : e + 12, e > 23 || parseInt(t, 10) > 59 ? "" : `${String(e).padStart(2, "0")}:${t}`;
|
|
885
|
+
}
|
|
886
|
+
return "";
|
|
887
|
+
},
|
|
888
|
+
validate(e) {
|
|
889
|
+
return K.normalize(e) !== "";
|
|
890
|
+
},
|
|
891
|
+
format(e, t = {}) {
|
|
892
|
+
if (typeof e != "string") return "";
|
|
893
|
+
let n = e.match(/^(\d{2}):(\d{2})$/);
|
|
894
|
+
if (!n) return e;
|
|
895
|
+
let r = parseInt(n[1], 10), i = n[2];
|
|
896
|
+
if (t.format === "h24") return `${String(r).padStart(2, "0")}:${i}`;
|
|
897
|
+
let a = r < 12 ? "AM" : "PM";
|
|
898
|
+
return `${r % 12 || 12}:${i} ${a}`;
|
|
899
|
+
}
|
|
900
|
+
}, q = {
|
|
901
|
+
PLAIN: "plain",
|
|
902
|
+
CREDIT_CARD: "creditCard",
|
|
903
|
+
PHONE: "phone",
|
|
904
|
+
CURRENCY: "currency",
|
|
905
|
+
DATE: "date",
|
|
906
|
+
TIME: "time"
|
|
907
|
+
}, J = new Map([
|
|
908
|
+
[q.PLAIN, R],
|
|
909
|
+
[q.CREDIT_CARD, me],
|
|
910
|
+
[q.PHONE, ge],
|
|
911
|
+
[q.CURRENCY, ye],
|
|
912
|
+
[q.DATE, G],
|
|
913
|
+
[q.TIME, K]
|
|
914
|
+
]), Y = {
|
|
915
|
+
type: q.PLAIN,
|
|
916
|
+
options: {}
|
|
917
|
+
}, Ce = class extends A {
|
|
918
|
+
static register(e, t) {
|
|
919
|
+
J.set(e, t);
|
|
920
|
+
}
|
|
921
|
+
constructor(e, t = {}) {
|
|
922
|
+
super(e, t), this.type = t.type ?? Y.type, this.options = t.options ?? Y.options, this.enhance();
|
|
923
|
+
}
|
|
924
|
+
enhance() {
|
|
925
|
+
let e = this, t = J.get(e.type) ?? J.get(q.PLAIN), n = {
|
|
926
|
+
normalize: (n) => t.normalize?.(n, e.options) ?? (typeof n == "string" ? n : ""),
|
|
927
|
+
validate: (n) => t.validate?.(n, e.options) ?? !0,
|
|
928
|
+
format: (n) => t.format?.(n, e.options) ?? (typeof n == "string" ? n : ""),
|
|
929
|
+
mask: (n) => t.mask?.(n, e.options) ?? null,
|
|
930
|
+
maskable: () => typeof t.mask == "function"
|
|
931
|
+
};
|
|
932
|
+
Object.defineProperty(this.controller, "inputFormat", {
|
|
933
|
+
get() {
|
|
934
|
+
return n;
|
|
935
|
+
},
|
|
936
|
+
configurable: !0
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
}, X = (e, t) => new Ce(e, t), we = {
|
|
709
940
|
events: ["resize"],
|
|
710
941
|
boundaries: [
|
|
711
942
|
"top",
|
|
@@ -714,10 +945,10 @@ var N = {
|
|
|
714
945
|
],
|
|
715
946
|
onShifted: "shifted",
|
|
716
947
|
respectMotion: !0
|
|
717
|
-
},
|
|
948
|
+
}, Te = class extends A {
|
|
718
949
|
constructor(e, t = {}) {
|
|
719
950
|
super(e, t);
|
|
720
|
-
let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({},
|
|
951
|
+
let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({}, we, t);
|
|
721
952
|
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();
|
|
722
953
|
}
|
|
723
954
|
shift = async () => {
|
|
@@ -727,14 +958,14 @@ var N = {
|
|
|
727
958
|
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 });
|
|
728
959
|
};
|
|
729
960
|
overflowRect(e, t) {
|
|
730
|
-
let n = {}, r =
|
|
961
|
+
let n = {}, r = D(), i = E({
|
|
731
962
|
x: e.x - t.x,
|
|
732
963
|
y: e.y - t.y,
|
|
733
964
|
width: e.width,
|
|
734
965
|
height: e.height
|
|
735
966
|
});
|
|
736
967
|
for (let e of this.boundaries) {
|
|
737
|
-
let t = this.directionDistance(i, e, r), a =
|
|
968
|
+
let t = this.directionDistance(i, e, r), a = T[e];
|
|
738
969
|
t < 0 ? i[a] + t >= r[a] && !n[a] && (n[e] = t) : n[e] = "";
|
|
739
970
|
}
|
|
740
971
|
return n;
|
|
@@ -782,23 +1013,23 @@ var N = {
|
|
|
782
1013
|
shift: e.shift.bind(e)
|
|
783
1014
|
});
|
|
784
1015
|
}
|
|
785
|
-
},
|
|
1016
|
+
}, Ee = (e, t) => new Te(e, t), Z = {
|
|
786
1017
|
visibility: "visibility",
|
|
787
1018
|
onShown: "shown",
|
|
788
1019
|
onHidden: "hidden"
|
|
789
|
-
},
|
|
1020
|
+
}, De = class extends A {
|
|
790
1021
|
constructor(e, t = {}) {
|
|
791
1022
|
let { visibility: n, onShown: r, onHidden: i, activator: a } = Object.assign({}, Z, t), o = typeof n == "string" ? n : Z.namespace, s = typeof t.visible == "string" ? t.visible : "isVisible";
|
|
792
1023
|
(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));
|
|
793
1024
|
}
|
|
794
1025
|
isVisible(e) {
|
|
795
1026
|
if (!(e instanceof HTMLElement)) return !1;
|
|
796
|
-
let t =
|
|
1027
|
+
let t = w.hiddenClass;
|
|
797
1028
|
return t ? !e.classList.contains(t) : !e.hasAttribute("hidden");
|
|
798
1029
|
}
|
|
799
1030
|
toggle(e, t) {
|
|
800
1031
|
if (!(e instanceof HTMLElement)) return;
|
|
801
|
-
let n =
|
|
1032
|
+
let n = w.hiddenClass;
|
|
802
1033
|
n ? t ? e.classList.remove(n) : e.classList.add(n) : t ? e.removeAttribute("hidden") : e.setAttribute("hidden", !0);
|
|
803
1034
|
}
|
|
804
1035
|
activate(e) {
|
|
@@ -821,146 +1052,7 @@ var N = {
|
|
|
821
1052
|
return t;
|
|
822
1053
|
} });
|
|
823
1054
|
}
|
|
824
|
-
},
|
|
825
|
-
static targets = ["modal", "overlay"];
|
|
826
|
-
connect() {
|
|
827
|
-
if (!this.hasModalTarget) {
|
|
828
|
-
console.error("ModalController requires a modal target. Add data-modal-target=\"modal\" to your element.");
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
this.isNativeDialog = this.modalTarget instanceof HTMLDialogElement, this.isNativeDialog ? (this.modalTarget.addEventListener("cancel", this.close), this.modalTarget.addEventListener("click", this.handleBackdropClick)) : (this.focusTrap = new a(this.modalTarget, { escapeDeactivates: !0 }), W(this, { element: this.modalTarget }));
|
|
832
|
-
}
|
|
833
|
-
dismissed = () => {
|
|
834
|
-
this.close();
|
|
835
|
-
};
|
|
836
|
-
disconnect() {
|
|
837
|
-
this.isNativeDialog && (this.modalTarget.removeEventListener("cancel", this.close), this.modalTarget.removeEventListener("click", this.handleBackdropClick));
|
|
838
|
-
}
|
|
839
|
-
open(e) {
|
|
840
|
-
if (e && e.preventDefault(), this.hasModalTarget) {
|
|
841
|
-
if (this.isNativeDialog) this.previouslyFocused = document.activeElement, this.modalTarget.showModal();
|
|
842
|
-
else {
|
|
843
|
-
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
844
|
-
e.hidden = !1, document.body.style.overflow = "hidden", this.focusTrap && this.focusTrap.activate();
|
|
845
|
-
}
|
|
846
|
-
p("Modal opened");
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
close(e) {
|
|
850
|
-
if (e && e.preventDefault(), this.hasModalTarget) {
|
|
851
|
-
if (this.isNativeDialog) this.modalTarget.close(), this.previouslyFocused && this.previouslyFocused.isConnected && setTimeout(() => {
|
|
852
|
-
this.previouslyFocused.focus();
|
|
853
|
-
}, 0);
|
|
854
|
-
else {
|
|
855
|
-
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
856
|
-
e.hidden = !0, document.body.style.overflow = "", this.focusTrap && this.focusTrap.deactivate();
|
|
857
|
-
}
|
|
858
|
-
p("Modal closed");
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
handleBackdropClick = (e) => {
|
|
862
|
-
let t = this.modalTarget.getBoundingClientRect();
|
|
863
|
-
(e.clientY < t.top || e.clientY > t.bottom || e.clientX < t.left || e.clientX > t.right) && this.close();
|
|
864
|
-
};
|
|
865
|
-
}, ne = class extends e {
|
|
866
|
-
static targets = ["trigger"];
|
|
867
|
-
connect() {
|
|
868
|
-
W(this, { trigger: this.hasTriggerTarget ? this.triggerTarget : null });
|
|
869
|
-
}
|
|
870
|
-
}, re = class extends e {
|
|
871
|
-
static targets = ["anchor", "reference"];
|
|
872
|
-
static values = {
|
|
873
|
-
placement: {
|
|
874
|
-
type: String,
|
|
875
|
-
default: "bottom"
|
|
876
|
-
},
|
|
877
|
-
alignment: {
|
|
878
|
-
type: String,
|
|
879
|
-
default: "start"
|
|
880
|
-
},
|
|
881
|
-
role: {
|
|
882
|
-
type: String,
|
|
883
|
-
default: "tooltip"
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
connect() {
|
|
887
|
-
if (!this.hasReferenceTarget) {
|
|
888
|
-
console.error("FlipperController requires a reference target. Add data-flipper-target=\"reference\" to your element.");
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
if (!this.hasAnchorTarget) {
|
|
892
|
-
console.error("FlipperController requires an anchor target. Add data-flipper-target=\"anchor\" to your element.");
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
q(this, {
|
|
896
|
-
element: this.referenceTarget,
|
|
897
|
-
anchor: this.anchorTarget,
|
|
898
|
-
placement: this.placementValue,
|
|
899
|
-
alignment: this.alignmentValue,
|
|
900
|
-
ariaRole: this.roleValue
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
}, ie = class extends e {
|
|
904
|
-
static targets = [
|
|
905
|
-
"content",
|
|
906
|
-
"template",
|
|
907
|
-
"loader",
|
|
908
|
-
"activator"
|
|
909
|
-
];
|
|
910
|
-
static classes = ["hidden"];
|
|
911
|
-
static values = {
|
|
912
|
-
url: String,
|
|
913
|
-
loadedAt: String,
|
|
914
|
-
reload: {
|
|
915
|
-
type: String,
|
|
916
|
-
default: "never"
|
|
917
|
-
},
|
|
918
|
-
staleAfter: {
|
|
919
|
-
type: Number,
|
|
920
|
-
default: 3600
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
connect() {
|
|
924
|
-
V(this, {
|
|
925
|
-
element: this.hasContentTarget ? this.contentTarget : null,
|
|
926
|
-
url: this.hasUrlValue ? this.urlValue : null
|
|
927
|
-
}), this.hasContentTarget && $(this, {
|
|
928
|
-
element: this.contentTarget,
|
|
929
|
-
activator: this.hasActivatorTarget ? this.activatorTarget : null
|
|
930
|
-
}), this.hasLoaderTarget && $(this, {
|
|
931
|
-
element: this.loaderTarget,
|
|
932
|
-
visibility: "contentLoaderVisibility"
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
async show() {
|
|
936
|
-
await this.visibility.show();
|
|
937
|
-
}
|
|
938
|
-
async hide() {
|
|
939
|
-
await this.visibility.hide();
|
|
940
|
-
}
|
|
941
|
-
async shown() {
|
|
942
|
-
await this.load();
|
|
943
|
-
}
|
|
944
|
-
contentLoad() {
|
|
945
|
-
return this.hasContentTarget && this.contentTarget.tagName.toLowerCase() === "turbo-frame" ? (this.hasUrlValue && this.contentTarget.setAttribute("src", this.urlValue), !1) : !0;
|
|
946
|
-
}
|
|
947
|
-
async contentLoading() {
|
|
948
|
-
this.hasLoaderTarget && await this.contentLoaderVisibility.show();
|
|
949
|
-
}
|
|
950
|
-
async contentLoaded({ content: e }) {
|
|
951
|
-
this.hasContentTarget && this.contentTarget.replaceChildren(this.getContentNode(e)), this.hasLoaderTarget && await this.contentLoaderVisibility.hide();
|
|
952
|
-
}
|
|
953
|
-
getContentNode(e) {
|
|
954
|
-
if (typeof e == "string") {
|
|
955
|
-
let t = document.createElement("template");
|
|
956
|
-
return t.innerHTML = e, document.importNode(t.content, !0);
|
|
957
|
-
}
|
|
958
|
-
return document.importNode(e, !0);
|
|
959
|
-
}
|
|
960
|
-
contentLoader() {
|
|
961
|
-
if (this.hasTemplateTarget) return this.templateTarget instanceof HTMLTemplateElement ? this.templateTarget.content : this.templateTarget.innerHTML;
|
|
962
|
-
}
|
|
963
|
-
}, ae = class extends e {
|
|
1055
|
+
}, Q = (e, t) => new De(e, t), $ = class extends e {
|
|
964
1056
|
static targets = ["daysOfWeek", "daysOfMonth"];
|
|
965
1057
|
static classes = ["dayOfWeek", "dayOfMonth"];
|
|
966
1058
|
static values = {
|
|
@@ -982,7 +1074,7 @@ var N = {
|
|
|
982
1074
|
}
|
|
983
1075
|
};
|
|
984
1076
|
initialize() {
|
|
985
|
-
|
|
1077
|
+
oe(this);
|
|
986
1078
|
}
|
|
987
1079
|
connect() {
|
|
988
1080
|
this.draw();
|
|
@@ -1028,37 +1120,67 @@ var N = {
|
|
|
1028
1120
|
}
|
|
1029
1121
|
this.daysOfMonthTarget.replaceChildren(...r);
|
|
1030
1122
|
}
|
|
1031
|
-
},
|
|
1032
|
-
|
|
1123
|
+
}, Oe = class extends e {
|
|
1124
|
+
onSelect(e) {
|
|
1033
1125
|
if (!(e.target instanceof HTMLElement)) return;
|
|
1034
1126
|
e.preventDefault();
|
|
1035
1127
|
let t = e.target instanceof HTMLTimeElement ? e.target.parentElement : e.target;
|
|
1036
1128
|
if (t.disabled || t.getAttribute("aria-disabled") === "true") return;
|
|
1037
|
-
this.dispatch("
|
|
1129
|
+
this.dispatch("selecting", { target: t });
|
|
1038
1130
|
let n = e.target instanceof HTMLTimeElement ? e.target : e.target.querySelector("time");
|
|
1039
1131
|
if (!n) return console.error(`unable to locate time element within ${t}`);
|
|
1040
|
-
let r =
|
|
1132
|
+
let r = k(n.dateTime);
|
|
1041
1133
|
if (!r) return console.error(`unable to parse ${n.dateTime} found within the time element`);
|
|
1042
|
-
this.
|
|
1043
|
-
|
|
1134
|
+
this.select(r.toISOString());
|
|
1135
|
+
}
|
|
1136
|
+
select(e) {
|
|
1137
|
+
let t = k(e);
|
|
1138
|
+
t && this.dispatch("selected", { detail: {
|
|
1139
|
+
epoch: t.getTime(),
|
|
1140
|
+
iso: e
|
|
1141
|
+
} });
|
|
1142
|
+
}
|
|
1143
|
+
}, ke = class extends e {
|
|
1144
|
+
static targets = ["source"];
|
|
1145
|
+
static values = { type: {
|
|
1146
|
+
type: String,
|
|
1147
|
+
default: "text/plain"
|
|
1148
|
+
} };
|
|
1149
|
+
onPaste(e) {
|
|
1150
|
+
let t = e.clipboardData?.getData(this.typeValue) ?? "", n = Array.from(e.clipboardData?.types ?? []);
|
|
1151
|
+
e.preventDefault(), this.dispatch("pasted", {
|
|
1044
1152
|
detail: {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1153
|
+
text: t,
|
|
1154
|
+
types: n
|
|
1155
|
+
},
|
|
1156
|
+
bubbles: !0
|
|
1048
1157
|
});
|
|
1049
1158
|
}
|
|
1050
|
-
|
|
1159
|
+
async copy(e) {
|
|
1160
|
+
let t = e.params?.text ?? (this.hasSourceTarget ? this.sourceTarget.value ?? this.sourceTarget.textContent ?? "" : "");
|
|
1161
|
+
try {
|
|
1162
|
+
await navigator.clipboard.writeText(t), this.dispatch("copied", {
|
|
1163
|
+
detail: { text: t },
|
|
1164
|
+
bubbles: !0
|
|
1165
|
+
});
|
|
1166
|
+
} catch (e) {
|
|
1167
|
+
this.dispatch("copy-failed", {
|
|
1168
|
+
detail: { error: e },
|
|
1169
|
+
bubbles: !0
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}, Ae = class extends e {
|
|
1051
1174
|
static targets = [
|
|
1052
1175
|
"previous",
|
|
1053
1176
|
"next",
|
|
1054
1177
|
"day",
|
|
1055
1178
|
"month",
|
|
1056
|
-
"year"
|
|
1057
|
-
"input",
|
|
1058
|
-
"display"
|
|
1179
|
+
"year"
|
|
1059
1180
|
];
|
|
1060
1181
|
static outlets = ["calendar-month"];
|
|
1061
1182
|
static values = {
|
|
1183
|
+
date: String,
|
|
1062
1184
|
locales: {
|
|
1063
1185
|
type: Array,
|
|
1064
1186
|
default: ["default"]
|
|
@@ -1080,21 +1202,17 @@ var N = {
|
|
|
1080
1202
|
this.previous = this.previous.bind(this), this.next = this.next.bind(this);
|
|
1081
1203
|
}
|
|
1082
1204
|
async calendarMonthOutletConnected() {
|
|
1083
|
-
if (this.
|
|
1084
|
-
let e =
|
|
1205
|
+
if (this.dateValue) {
|
|
1206
|
+
let e = k(this.dateValue);
|
|
1085
1207
|
e && await this.calendarMonthOutlet.calendar.navigate(e);
|
|
1086
1208
|
}
|
|
1087
1209
|
this.draw();
|
|
1088
1210
|
}
|
|
1089
|
-
|
|
1090
|
-
this.
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
day: this.dayFormatValue,
|
|
1095
|
-
month: this.monthFormatValue,
|
|
1096
|
-
year: this.yearFormatValue
|
|
1097
|
-
}).format(e);
|
|
1211
|
+
onSelect(e) {
|
|
1212
|
+
this.dateValue = e.detail.iso, this.draw(), this.dispatch("selected", {
|
|
1213
|
+
detail: { value: e.detail.iso },
|
|
1214
|
+
bubbles: !0
|
|
1215
|
+
});
|
|
1098
1216
|
}
|
|
1099
1217
|
previousTargetConnected(e) {
|
|
1100
1218
|
e.addEventListener("click", this.previous);
|
|
@@ -1119,24 +1237,392 @@ var N = {
|
|
|
1119
1237
|
}
|
|
1120
1238
|
drawDay() {
|
|
1121
1239
|
if (!this.hasDayTarget || !this.hasCalendarMonthOutlet) return;
|
|
1122
|
-
let { year: e, month: t, day: n } = this.calendarMonthOutlet.calendar
|
|
1123
|
-
this.dayTarget.textContent =
|
|
1240
|
+
let { year: e, month: t, day: n } = this.calendarMonthOutlet.calendar;
|
|
1241
|
+
this.dayTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { day: this.dayFormatValue }).format(new Date(e, t, n));
|
|
1124
1242
|
}
|
|
1125
1243
|
drawMonth() {
|
|
1126
1244
|
if (!this.hasMonthTarget || !this.hasCalendarMonthOutlet) return;
|
|
1127
|
-
let { year: e, month: t } = this.calendarMonthOutlet.calendar
|
|
1128
|
-
this.monthTarget.textContent =
|
|
1245
|
+
let { year: e, month: t } = this.calendarMonthOutlet.calendar;
|
|
1246
|
+
this.monthTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { month: this.monthFormatValue }).format(new Date(e, t));
|
|
1129
1247
|
}
|
|
1130
1248
|
drawYear() {
|
|
1131
1249
|
if (!this.hasYearTarget || !this.hasCalendarMonthOutlet) return;
|
|
1132
|
-
let { year: e } = this.calendarMonthOutlet.calendar
|
|
1133
|
-
this.yearTarget.textContent =
|
|
1250
|
+
let { year: e } = this.calendarMonthOutlet.calendar;
|
|
1251
|
+
this.yearTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { year: this.yearFormatValue }).format(new Date(e, 0));
|
|
1252
|
+
}
|
|
1253
|
+
}, je = class extends e {
|
|
1254
|
+
static targets = [
|
|
1255
|
+
"listbox",
|
|
1256
|
+
"loading",
|
|
1257
|
+
"empty"
|
|
1258
|
+
];
|
|
1259
|
+
static values = {
|
|
1260
|
+
url: {
|
|
1261
|
+
type: String,
|
|
1262
|
+
default: ""
|
|
1263
|
+
},
|
|
1264
|
+
field: {
|
|
1265
|
+
type: String,
|
|
1266
|
+
default: "q"
|
|
1267
|
+
},
|
|
1268
|
+
delay: {
|
|
1269
|
+
type: Number,
|
|
1270
|
+
default: 300
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
initialize() {
|
|
1274
|
+
this.comboboxDropdown = ce(this);
|
|
1275
|
+
}
|
|
1276
|
+
onSelect(e) {
|
|
1277
|
+
let t = e.target.closest("[role=\"option\"]");
|
|
1278
|
+
!t || t.getAttribute("aria-disabled") === "true" || this.select(t.dataset.value ?? "");
|
|
1279
|
+
}
|
|
1280
|
+
select(e) {
|
|
1281
|
+
let t = this.listboxTarget.querySelectorAll("[role=\"option\"]");
|
|
1282
|
+
t.forEach((e) => e.setAttribute("aria-selected", "false"));
|
|
1283
|
+
let n = [...t].find((t) => t.dataset.value === e);
|
|
1284
|
+
n && n.setAttribute("aria-selected", "true"), this.dispatch("selected", {
|
|
1285
|
+
detail: { value: e },
|
|
1286
|
+
bubbles: !0
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
onNavigate(e) {
|
|
1290
|
+
if ([
|
|
1291
|
+
"ArrowUp",
|
|
1292
|
+
"ArrowDown",
|
|
1293
|
+
"Enter",
|
|
1294
|
+
" "
|
|
1295
|
+
].includes(e.key)) {
|
|
1296
|
+
if (e.preventDefault(), e.key === "Enter" || e.key === " ") {
|
|
1297
|
+
this.listboxTarget.querySelector("[aria-selected=\"true\"]")?.click();
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
this.step(e.key === "ArrowDown" ? 1 : -1);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
step(e) {
|
|
1304
|
+
let t = [...this.listboxTarget.querySelectorAll("[role=\"option\"]:not([aria-disabled=\"true\"]):not([hidden])")];
|
|
1305
|
+
if (!t.length) return;
|
|
1306
|
+
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)];
|
|
1307
|
+
!i || i === n || (t.forEach((e) => e.setAttribute("aria-selected", "false")), i.setAttribute("aria-selected", "true"), i.scrollIntoView({ block: "nearest" }));
|
|
1308
|
+
}
|
|
1309
|
+
filter(e) {
|
|
1310
|
+
if (this.urlValue) this.comboboxDropdown.scheduleFetch(e, this.delayValue, {
|
|
1311
|
+
url: this.urlValue,
|
|
1312
|
+
field: this.fieldValue,
|
|
1313
|
+
onLoading: (e) => this.setLoading(e),
|
|
1314
|
+
onLoaded: (e) => {
|
|
1315
|
+
this.listboxTarget.innerHTML = e, this.setEmpty(this.listboxTarget.querySelectorAll("[role=\"option\"]").length === 0);
|
|
1316
|
+
},
|
|
1317
|
+
onError: (e) => console.error("[combobox-dropdown] fetch failed", e)
|
|
1318
|
+
});
|
|
1319
|
+
else {
|
|
1320
|
+
let t = this.comboboxDropdown.fuzzyFilter(this.listboxTarget, e);
|
|
1321
|
+
this.setEmpty(t === 0);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
showAll() {
|
|
1325
|
+
this.listboxTarget.querySelectorAll("[role=\"option\"]").forEach((e) => e.hidden = !1), this.setEmpty(!1);
|
|
1326
|
+
}
|
|
1327
|
+
setLoading(e) {
|
|
1328
|
+
this.hasLoadingTarget && (this.loadingTarget.hidden = !e);
|
|
1329
|
+
}
|
|
1330
|
+
setEmpty(e) {
|
|
1331
|
+
this.hasEmptyTarget && (this.emptyTarget.hidden = !e);
|
|
1332
|
+
}
|
|
1333
|
+
disconnect() {
|
|
1334
|
+
this.comboboxDropdown.cancel();
|
|
1335
|
+
}
|
|
1336
|
+
}, Me = class extends e {
|
|
1337
|
+
static targets = [
|
|
1338
|
+
"hour",
|
|
1339
|
+
"minute",
|
|
1340
|
+
"period"
|
|
1341
|
+
];
|
|
1342
|
+
connect() {
|
|
1343
|
+
this.select(this.toH24());
|
|
1344
|
+
}
|
|
1345
|
+
onSelect(e) {
|
|
1346
|
+
let t = e.target.closest("[role=\"option\"]");
|
|
1347
|
+
t && (t.closest("[role=\"listbox\"]").querySelectorAll("[role=\"option\"]").forEach((e) => e.setAttribute("aria-selected", "false")), t.setAttribute("aria-selected", "true"), this.select(this.toH24()));
|
|
1348
|
+
}
|
|
1349
|
+
select(e) {
|
|
1350
|
+
e && this.dispatch("selected", {
|
|
1351
|
+
detail: { value: e },
|
|
1352
|
+
bubbles: !0
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
onNavigate(e) {
|
|
1356
|
+
["ArrowUp", "ArrowDown"].includes(e.key) && (e.preventDefault(), this.step(e.currentTarget, e.key === "ArrowDown" ? 1 : -1));
|
|
1357
|
+
}
|
|
1358
|
+
step(e, t) {
|
|
1359
|
+
let n = [...e.querySelectorAll("[role=\"option\"]")], r = e.querySelector("[aria-selected=\"true\"]"), i = n.indexOf(r), a = t > 0 ? n[Math.min(i + 1, n.length - 1)] : n[Math.max(i - 1, 0)];
|
|
1360
|
+
!a || a === r || (n.forEach((e) => e.setAttribute("aria-selected", "false")), a.setAttribute("aria-selected", "true"), a.scrollIntoView({ block: "nearest" }), this.select(this.toH24()));
|
|
1361
|
+
}
|
|
1362
|
+
toH24() {
|
|
1363
|
+
let e = this.selectedValue(this.hourTarget), t = this.selectedValue(this.minuteTarget);
|
|
1364
|
+
if (!e || !t) return null;
|
|
1365
|
+
if (!this.hasPeriodTarget) return `${e}:${t}`;
|
|
1366
|
+
let n = this.selectedValue(this.periodTarget), r = parseInt(e, 10);
|
|
1367
|
+
return r = n === "AM" ? r === 12 ? 0 : r : r === 12 ? 12 : r + 12, `${String(r).padStart(2, "0")}:${t}`;
|
|
1368
|
+
}
|
|
1369
|
+
selectedValue(e) {
|
|
1370
|
+
return e?.querySelector("[aria-selected=\"true\"]")?.dataset.value ?? null;
|
|
1371
|
+
}
|
|
1372
|
+
}, Ne = class extends e {
|
|
1373
|
+
static targets = ["trigger"];
|
|
1374
|
+
connect() {
|
|
1375
|
+
P(this, { trigger: this.hasTriggerTarget ? this.triggerTarget : null });
|
|
1376
|
+
}
|
|
1377
|
+
}, Pe = class extends e {
|
|
1378
|
+
static targets = ["anchor", "reference"];
|
|
1379
|
+
static values = {
|
|
1380
|
+
placement: {
|
|
1381
|
+
type: String,
|
|
1382
|
+
default: "bottom"
|
|
1383
|
+
},
|
|
1384
|
+
alignment: {
|
|
1385
|
+
type: String,
|
|
1386
|
+
default: "start"
|
|
1387
|
+
},
|
|
1388
|
+
role: {
|
|
1389
|
+
type: String,
|
|
1390
|
+
default: "tooltip"
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
connect() {
|
|
1394
|
+
if (!this.hasReferenceTarget) {
|
|
1395
|
+
console.error("FlipperController requires a reference target. Add data-flipper-target=\"reference\" to your element.");
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
if (!this.hasAnchorTarget) {
|
|
1399
|
+
console.error("FlipperController requires an anchor target. Add data-flipper-target=\"anchor\" to your element.");
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
L(this, {
|
|
1403
|
+
element: this.referenceTarget,
|
|
1404
|
+
anchor: this.anchorTarget,
|
|
1405
|
+
placement: this.placementValue,
|
|
1406
|
+
alignment: this.alignmentValue,
|
|
1407
|
+
ariaRole: this.roleValue
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
}, Fe = class extends e {
|
|
1411
|
+
static targets = [
|
|
1412
|
+
"trigger",
|
|
1413
|
+
"popover",
|
|
1414
|
+
"value"
|
|
1415
|
+
];
|
|
1416
|
+
static values = {
|
|
1417
|
+
value: String,
|
|
1418
|
+
minLength: {
|
|
1419
|
+
type: Number,
|
|
1420
|
+
default: 1
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
static outlets = ["combobox-dropdown"];
|
|
1424
|
+
open() {
|
|
1425
|
+
this.hasPopoverTarget && (this.popoverTarget.hidden = !1, this.hasTriggerTarget && _(this.triggerTarget, !0), this.focusFirstInPopover());
|
|
1426
|
+
}
|
|
1427
|
+
close() {
|
|
1428
|
+
this.hasPopoverTarget && (this.popoverTarget.hidden = !0, this.hasTriggerTarget && (_(this.triggerTarget, !1), this.triggerTarget.focus()));
|
|
1429
|
+
}
|
|
1430
|
+
toggle() {
|
|
1431
|
+
this.hasPopoverTarget && this.popoverTarget.hidden ? this.open() : this.close();
|
|
1432
|
+
}
|
|
1433
|
+
onSelect(e) {
|
|
1434
|
+
e.detail?.value !== void 0 && (this.valueValue = e.detail.value), this.close();
|
|
1435
|
+
}
|
|
1436
|
+
onInput(e) {
|
|
1437
|
+
if (e.target !== this.triggerTarget) return;
|
|
1438
|
+
let t = e.target.value.trim();
|
|
1439
|
+
if (t.length < this.minLengthValue) {
|
|
1440
|
+
this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.showAll();
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.filter(t);
|
|
1444
|
+
}
|
|
1445
|
+
valueValueChanged(e) {
|
|
1446
|
+
this.hasValueTarget && (this.valueTarget.value = e), this.dispatch("changed", { detail: { value: e } });
|
|
1447
|
+
}
|
|
1448
|
+
focusFirstInPopover() {
|
|
1449
|
+
this.hasPopoverTarget && this.popoverTarget.querySelector("button:not([disabled]), [href], input:not([type=\"hidden\"]):not([disabled]), [tabindex]:not([tabindex=\"-1\"])")?.focus();
|
|
1450
|
+
}
|
|
1451
|
+
}, Ie = class extends e {
|
|
1452
|
+
static targets = ["input", "toggle"];
|
|
1453
|
+
static values = {
|
|
1454
|
+
type: {
|
|
1455
|
+
type: String,
|
|
1456
|
+
default: "plain"
|
|
1457
|
+
},
|
|
1458
|
+
options: {
|
|
1459
|
+
type: Object,
|
|
1460
|
+
default: {}
|
|
1461
|
+
},
|
|
1462
|
+
revealed: {
|
|
1463
|
+
type: Boolean,
|
|
1464
|
+
default: !1
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
connect() {
|
|
1468
|
+
X(this, {
|
|
1469
|
+
type: this.typeValue,
|
|
1470
|
+
options: this.optionsValue
|
|
1471
|
+
}), this.format(this.readValue()), this.drawToggle();
|
|
1472
|
+
}
|
|
1473
|
+
typeValueChanged() {
|
|
1474
|
+
this.inputFormat && (X(this, {
|
|
1475
|
+
type: this.typeValue,
|
|
1476
|
+
options: this.optionsValue
|
|
1477
|
+
}), this.format(this.readValue()), this.drawToggle());
|
|
1478
|
+
}
|
|
1479
|
+
optionsValueChanged() {
|
|
1480
|
+
this.inputFormat && (X(this, {
|
|
1481
|
+
type: this.typeValue,
|
|
1482
|
+
options: this.optionsValue
|
|
1483
|
+
}), this.format(this.readValue()));
|
|
1484
|
+
}
|
|
1485
|
+
revealedValueChanged() {
|
|
1486
|
+
this.inputFormat && (this.format(this.readValue()), this.drawToggle());
|
|
1487
|
+
}
|
|
1488
|
+
onChange(e) {
|
|
1489
|
+
this.format(e?.detail?.value ?? "");
|
|
1490
|
+
}
|
|
1491
|
+
format(e) {
|
|
1492
|
+
this.inputFormat && this.onFormatting(e);
|
|
1493
|
+
}
|
|
1494
|
+
toggle() {
|
|
1495
|
+
!this.inputFormat.maskable() && this.typeValue !== "password" || (this.revealedValue = !this.revealedValue);
|
|
1496
|
+
}
|
|
1497
|
+
onPaste(e) {
|
|
1498
|
+
let t = e.detail?.text ?? "";
|
|
1499
|
+
if (!this.inputFormat || !t) return;
|
|
1500
|
+
let n = this.inputFormat.normalize(t);
|
|
1501
|
+
this.inputFormat.validate(n) && this.format(n);
|
|
1502
|
+
}
|
|
1503
|
+
drawToggle() {
|
|
1504
|
+
if (!this.hasToggleTarget) return;
|
|
1505
|
+
let e = this.inputFormat?.maskable() || this.typeValue === "password";
|
|
1506
|
+
this.toggleTarget.hidden = !e, e && v(this.toggleTarget, this.revealedValue);
|
|
1507
|
+
}
|
|
1508
|
+
readValue() {
|
|
1509
|
+
return this.hasInputTarget ? this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value : this.inputTarget.textContent : "";
|
|
1510
|
+
}
|
|
1511
|
+
onFormatting(e) {
|
|
1512
|
+
if (!this.inputFormat) return;
|
|
1513
|
+
if (this.typeValue === "password") {
|
|
1514
|
+
this.hasInputTarget && (this.inputTarget.type = this.revealedValue ? "text" : "password");
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
let t = this.inputFormat.normalize(e), n = this.revealedValue || !this.inputFormat.maskable() ? this.inputFormat.format(t) : this.inputFormat.mask(t);
|
|
1518
|
+
this.hasInputTarget && (this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value = n : this.inputTarget.textContent = n), this.dispatch("formatted", { detail: { value: n } });
|
|
1519
|
+
}
|
|
1520
|
+
}, Le = class extends e {
|
|
1521
|
+
static targets = ["modal", "overlay"];
|
|
1522
|
+
connect() {
|
|
1523
|
+
if (!this.hasModalTarget) {
|
|
1524
|
+
console.error("ModalController requires a modal target. Add data-modal-target=\"modal\" to your element.");
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
this.isNativeDialog = this.modalTarget instanceof HTMLDialogElement, this.isNativeDialog ? (this.modalTarget.addEventListener("cancel", this.close), this.modalTarget.addEventListener("click", this.onBackdropClick)) : (this.focusTrap = new a(this.modalTarget, { escapeDeactivates: !0 }), P(this, { element: this.modalTarget }));
|
|
1528
|
+
}
|
|
1529
|
+
dismissed = () => {
|
|
1530
|
+
this.close();
|
|
1531
|
+
};
|
|
1532
|
+
disconnect() {
|
|
1533
|
+
this.isNativeDialog && (this.modalTarget.removeEventListener("cancel", this.close), this.modalTarget.removeEventListener("click", this.onBackdropClick));
|
|
1534
|
+
}
|
|
1535
|
+
open(e) {
|
|
1536
|
+
if (e && e.preventDefault(), this.hasModalTarget) {
|
|
1537
|
+
if (this.isNativeDialog) this.previouslyFocused = document.activeElement, this.modalTarget.showModal();
|
|
1538
|
+
else {
|
|
1539
|
+
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
1540
|
+
e.hidden = !1, document.body.style.overflow = "hidden", this.focusTrap && this.focusTrap.activate();
|
|
1541
|
+
}
|
|
1542
|
+
p("Modal opened");
|
|
1543
|
+
}
|
|
1134
1544
|
}
|
|
1135
|
-
|
|
1545
|
+
close(e) {
|
|
1546
|
+
if (e && e.preventDefault(), this.hasModalTarget) {
|
|
1547
|
+
if (this.isNativeDialog) this.modalTarget.close(), this.previouslyFocused && this.previouslyFocused.isConnected && setTimeout(() => {
|
|
1548
|
+
this.previouslyFocused.focus();
|
|
1549
|
+
}, 0);
|
|
1550
|
+
else {
|
|
1551
|
+
let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
|
|
1552
|
+
e.hidden = !0, document.body.style.overflow = "", this.focusTrap && this.focusTrap.deactivate();
|
|
1553
|
+
}
|
|
1554
|
+
p("Modal closed");
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
onBackdropClick = (e) => {
|
|
1558
|
+
let t = this.modalTarget.getBoundingClientRect();
|
|
1559
|
+
(e.clientY < t.top || e.clientY > t.bottom || e.clientX < t.left || e.clientX > t.right) && this.close();
|
|
1560
|
+
};
|
|
1561
|
+
}, Re = class extends e {
|
|
1136
1562
|
static targets = ["content"];
|
|
1137
1563
|
connect() {
|
|
1138
|
-
|
|
1564
|
+
Ee(this, { element: this.hasContentTarget ? this.contentTarget : null });
|
|
1565
|
+
}
|
|
1566
|
+
}, ze = class extends e {
|
|
1567
|
+
static targets = [
|
|
1568
|
+
"content",
|
|
1569
|
+
"template",
|
|
1570
|
+
"loader",
|
|
1571
|
+
"activator"
|
|
1572
|
+
];
|
|
1573
|
+
static classes = ["hidden"];
|
|
1574
|
+
static values = {
|
|
1575
|
+
url: String,
|
|
1576
|
+
loadedAt: String,
|
|
1577
|
+
reload: {
|
|
1578
|
+
type: String,
|
|
1579
|
+
default: "never"
|
|
1580
|
+
},
|
|
1581
|
+
staleAfter: {
|
|
1582
|
+
type: Number,
|
|
1583
|
+
default: 3600
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
connect() {
|
|
1587
|
+
ue(this, {
|
|
1588
|
+
element: this.hasContentTarget ? this.contentTarget : null,
|
|
1589
|
+
url: this.hasUrlValue ? this.urlValue : null
|
|
1590
|
+
}), this.hasContentTarget && Q(this, {
|
|
1591
|
+
element: this.contentTarget,
|
|
1592
|
+
activator: this.hasActivatorTarget ? this.activatorTarget : null
|
|
1593
|
+
}), this.hasLoaderTarget && Q(this, {
|
|
1594
|
+
element: this.loaderTarget,
|
|
1595
|
+
visibility: "contentLoaderVisibility"
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
async show() {
|
|
1599
|
+
await this.visibility.show();
|
|
1600
|
+
}
|
|
1601
|
+
async hide() {
|
|
1602
|
+
await this.visibility.hide();
|
|
1603
|
+
}
|
|
1604
|
+
async shown() {
|
|
1605
|
+
await this.load();
|
|
1606
|
+
}
|
|
1607
|
+
canLoad() {
|
|
1608
|
+
return this.hasContentTarget && this.contentTarget.tagName.toLowerCase() === "turbo-frame" ? (this.hasUrlValue && this.contentTarget.setAttribute("src", this.urlValue), !1) : !0;
|
|
1609
|
+
}
|
|
1610
|
+
async contentLoading() {
|
|
1611
|
+
this.hasLoaderTarget && await this.contentLoaderVisibility.show();
|
|
1612
|
+
}
|
|
1613
|
+
async contentLoaded({ content: e }) {
|
|
1614
|
+
this.hasContentTarget && this.contentTarget.replaceChildren(this.getContentNode(e)), this.hasLoaderTarget && await this.contentLoaderVisibility.hide();
|
|
1615
|
+
}
|
|
1616
|
+
getContentNode(e) {
|
|
1617
|
+
if (typeof e == "string") {
|
|
1618
|
+
let t = document.createElement("template");
|
|
1619
|
+
return t.innerHTML = e, document.importNode(t.content, !0);
|
|
1620
|
+
}
|
|
1621
|
+
return document.importNode(e, !0);
|
|
1622
|
+
}
|
|
1623
|
+
contentLoader() {
|
|
1624
|
+
if (this.hasTemplateTarget) return this.templateTarget instanceof HTMLTemplateElement ? this.templateTarget.content : this.templateTarget.innerHTML;
|
|
1139
1625
|
}
|
|
1140
1626
|
};
|
|
1141
1627
|
//#endregion
|
|
1142
|
-
export {
|
|
1628
|
+
export { y as ARIA_HASPOPUP_VALUES, $ as CalendarMonthController, Oe as CalendarMonthObserverController, ke as ClipboardController, Ae as ComboboxDateController, je as ComboboxDropdownController, Me as ComboboxTimeController, Ne as DismisserController, t as FOCUSABLE_SELECTOR, Pe as FlipperController, o as FocusRestoration, a as FocusTrap, Fe as InputComboboxController, Ie as InputFormatController, Le as ModalController, Re as PannerController, ze as PopoverController, d as RovingTabIndex, p as announce, S as connectTriggerToTarget, ne as disconnectTriggerFromTarget, h as ensureId, i as focusFirst, m as generateId, n as getFocusableElements, c as isActivationKey, l as isArrowKey, s as isKey, r as isVisible, u as preventDefault, g as setAriaState, ee as setChecked, te as setDisabled, _ as setExpanded, v as setPressed };
|