stimulus_plumbers 0.2.2 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1abfd2ca5a0c575652d0d6c650acbde79e656b9b806a76b8f922e682cf2f7526
4
- data.tar.gz: 621aa551f6fb7b9f3a90c3313e4dedb6c901f475cb96f6631a9fc54edccf5bac
3
+ metadata.gz: c89886ba431e3857285faa6f16e80f5f54cb4b2bf9fb69582be6f8c1395ddd67
4
+ data.tar.gz: 66f92918cfcb2c729047555955b17570a94574bc7512d1ba65e68515e447163a
5
5
  SHA512:
6
- metadata.gz: e45e2a0ea994b0e8d22edc2098974d6f15c43bb552a92dc7c5baf2dc0700b9a8f22ef570ffa913c0cae84d6bc64ecbe6b6e09613e4b73ccaccc1613d93d898d3
7
- data.tar.gz: 1be1501a2b77cad35780730e84803bdb5506e6def24699c46cc1797196780aec94dfe7a451a0b4774b748258132a7b0eb3d6bae16c71c22bc7c733bf24c45f1c
6
+ metadata.gz: d1ae00ceb5a566aff19e6ac1cc81232fff4783dfe2729174b8ba19e578f90b324c09882101cd55bd380053f1f5498e05829d457b3aea1d52cb8cc31bb0fc6298
7
+ data.tar.gz: 0b8ce29fe76ee4bf93ba709ec1714c0cd191dab7352136123b807c03b1ba50d355d6475d88274694c2e05e17ef56255da6ea1eb09cafac4b4f014c759f290c6f
@@ -0,0 +1,1142 @@
1
+ import { Controller as e } from "@hotwired/stimulus";
2
+ //#region src/focus.js
3
+ var t = [
4
+ "a[href]",
5
+ "area[href]",
6
+ "button:not([disabled])",
7
+ "input:not([disabled])",
8
+ "select:not([disabled])",
9
+ "textarea:not([disabled])",
10
+ "[tabindex]:not([tabindex=\"-1\"])",
11
+ "audio[controls]",
12
+ "video[controls]",
13
+ "[contenteditable]:not([contenteditable=\"false\"])"
14
+ ].join(",");
15
+ function n(e) {
16
+ return Array.from(e.querySelectorAll(t)).filter((e) => r(e));
17
+ }
18
+ function r(e) {
19
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
20
+ }
21
+ function i(e) {
22
+ let t = n(e);
23
+ return t.length > 0 ? (t[0].focus(), !0) : !1;
24
+ }
25
+ var a = class {
26
+ constructor(e, t = {}) {
27
+ this.container = e, this.previouslyFocused = null, this.options = t, this.isActive = !1;
28
+ }
29
+ activate() {
30
+ this.isActive || (this.previouslyFocused = document.activeElement, this.isActive = !0, this.options.initialFocus ? this.options.initialFocus.focus() : i(this.container), this.container.addEventListener("keydown", this.handleKeyDown));
31
+ }
32
+ deactivate() {
33
+ if (!this.isActive) return;
34
+ this.isActive = !1, this.container.removeEventListener("keydown", this.handleKeyDown);
35
+ let e = this.options.returnFocus || this.previouslyFocused;
36
+ e && r(e) && e.focus();
37
+ }
38
+ handleKeyDown = (e) => {
39
+ if (e.key === "Escape" && this.options.escapeDeactivates) {
40
+ e.preventDefault(), this.deactivate();
41
+ return;
42
+ }
43
+ if (e.key !== "Tab") return;
44
+ let t = n(this.container);
45
+ if (t.length === 0) return;
46
+ let r = t[0], i = t[t.length - 1];
47
+ e.shiftKey && document.activeElement === r ? (e.preventDefault(), i.focus()) : !e.shiftKey && document.activeElement === i && (e.preventDefault(), r.focus());
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
+ };
60
+ //#endregion
61
+ //#region src/keyboard.js
62
+ function s(e, t) {
63
+ return e.key === t;
64
+ }
65
+ function c(e) {
66
+ return e.key === "Enter" || e.key === " ";
67
+ }
68
+ function l(e) {
69
+ return [
70
+ "ArrowUp",
71
+ "ArrowDown",
72
+ "ArrowLeft",
73
+ "ArrowRight"
74
+ ].includes(e.key);
75
+ }
76
+ function u(e) {
77
+ e.preventDefault(), e.stopPropagation();
78
+ }
79
+ var d = class {
80
+ constructor(e, t = 0) {
81
+ this.items = e, this.currentIndex = t, this.updateTabIndex();
82
+ }
83
+ handleKeyDown(e) {
84
+ let t;
85
+ switch (e.key) {
86
+ case "ArrowDown":
87
+ case "ArrowRight":
88
+ e.preventDefault(), t = (this.currentIndex + 1) % this.items.length;
89
+ break;
90
+ case "ArrowUp":
91
+ case "ArrowLeft":
92
+ e.preventDefault(), t = this.currentIndex === 0 ? this.items.length - 1 : this.currentIndex - 1;
93
+ break;
94
+ case "Home":
95
+ e.preventDefault(), t = 0;
96
+ break;
97
+ case "End":
98
+ e.preventDefault(), t = this.items.length - 1;
99
+ break;
100
+ default: return;
101
+ }
102
+ this.setCurrentIndex(t);
103
+ }
104
+ setCurrentIndex(e) {
105
+ e >= 0 && e < this.items.length && (this.currentIndex = e, this.updateTabIndex(), this.items[e].focus());
106
+ }
107
+ updateTabIndex() {
108
+ this.items.forEach((e, t) => {
109
+ e.tabIndex = t === this.currentIndex ? 0 : -1;
110
+ });
111
+ }
112
+ updateItems(e) {
113
+ this.items = e, this.currentIndex = Math.min(this.currentIndex, e.length - 1), this.updateTabIndex();
114
+ }
115
+ }, f = (e, t, n) => {
116
+ let r = document.querySelector(`[data-live-region="${e}"]`);
117
+ 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
+ };
119
+ function p(e, t = {}) {
120
+ let { politeness: n = "polite", atomic: r = !0, relevant: i = "additions text" } = t, a = f(n, r, i);
121
+ a.textContent = "", setTimeout(() => {
122
+ a.textContent = e;
123
+ }, 100);
124
+ }
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
+ e.setAttribute(t, n.toString());
127
+ }, _ = (e, t) => g(e, "aria-expanded", t), v = (e, t) => g(e, "aria-pressed", t), y = (e, t) => g(e, "aria-checked", t);
128
+ function ee(e, t) {
129
+ g(e, "aria-disabled", t), t ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex");
130
+ }
131
+ var b = {
132
+ menu: "menu",
133
+ listbox: "listbox",
134
+ tree: "tree",
135
+ grid: "grid",
136
+ dialog: "dialog"
137
+ }, x = (e, t, n) => {
138
+ Object.entries(t).forEach(([t, r]) => {
139
+ e.setAttribute(t, r), n[t] = r;
140
+ });
141
+ }, S = (e, t, n) => n || !e.hasAttribute(t);
142
+ function C({ trigger: e, target: t, role: n = null, override: r = !1 }) {
143
+ let i = {
144
+ trigger: {},
145
+ target: {}
146
+ };
147
+ if (!e || !t) return i;
148
+ let a = {}, o = {};
149
+ if (n && S(t, "role", r) && (o.role = n), t.id && (S(e, "aria-controls", r) && (a["aria-controls"] = t.id), n === "tooltip" && S(e, "aria-describedby", r) && (a["aria-describedby"] = t.id)), n && S(e, "aria-haspopup", r)) {
150
+ let e = b[n] || "true";
151
+ e && (a["aria-haspopup"] = e);
152
+ }
153
+ return x(t, o, i.target), x(e, a, i.trigger), i;
154
+ }
155
+ var w = (e, t) => {
156
+ t.forEach((t) => {
157
+ e.hasAttribute(t) && e.removeAttribute(t);
158
+ });
159
+ };
160
+ function T({ trigger: e, target: t, attributes: n = null }) {
161
+ !e || !t || (w(e, n || [
162
+ "aria-controls",
163
+ "aria-haspopup",
164
+ "aria-describedby"
165
+ ]), (!n || n.includes("role")) && w(t, ["role"]));
166
+ }
167
+ //#endregion
168
+ //#region src/plumbers/plumber/support.js
169
+ var E = {
170
+ get visibleOnly() {
171
+ return !0;
172
+ },
173
+ hiddenClass: null
174
+ }, D = {
175
+ get top() {
176
+ return "bottom";
177
+ },
178
+ get bottom() {
179
+ return "top";
180
+ },
181
+ get left() {
182
+ return "right";
183
+ },
184
+ get right() {
185
+ return "left";
186
+ }
187
+ };
188
+ function O({ x: e, y: t, width: n, height: r }) {
189
+ return {
190
+ x: e,
191
+ y: t,
192
+ width: n,
193
+ height: r,
194
+ left: e,
195
+ right: e + n,
196
+ top: t,
197
+ bottom: t + r
198
+ };
199
+ }
200
+ function k() {
201
+ return O({
202
+ x: 0,
203
+ y: 0,
204
+ width: window.innerWidth || document.documentElement.clientWidth,
205
+ height: window.innerHeight || document.documentElement.clientHeight
206
+ });
207
+ }
208
+ function A(e) {
209
+ if (!(e instanceof HTMLElement)) return !1;
210
+ let t = k(), n = e.getBoundingClientRect(), r = n.top <= t.height && n.top + n.height > 0, i = n.left <= t.width && n.left + n.width > 0;
211
+ return r && i;
212
+ }
213
+ function j(e) {
214
+ return e instanceof Date && !isNaN(e);
215
+ }
216
+ function M(...e) {
217
+ if (e.length === 0) throw "Missing values to parse as date";
218
+ if (e.length === 1) {
219
+ let t = new Date(e[0]);
220
+ if (e[0] && j(t)) return t;
221
+ } else {
222
+ let t = new Date(...e);
223
+ if (j(t)) return t;
224
+ }
225
+ }
226
+ //#endregion
227
+ //#region src/plumbers/plumber/index.js
228
+ var N = {
229
+ element: null,
230
+ visible: null,
231
+ dispatch: !0,
232
+ prefix: ""
233
+ }, P = class {
234
+ constructor(e, t = {}) {
235
+ this.controller = e;
236
+ let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({}, N, t);
237
+ this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r : E.visibleOnly, this.visibleCallback = typeof r == "string" ? r : null, this.notify = !!i, this.prefix = typeof a == "string" && a ? a : e.identifier;
238
+ }
239
+ get visible() {
240
+ return this.element instanceof HTMLElement ? this.visibleOnly ? A(this.element) && this.isVisible(this.element) : !0 : !1;
241
+ }
242
+ isVisible(e) {
243
+ if (this.visibleCallback) {
244
+ let t = this.findCallback(this.visibleCallback);
245
+ if (typeof t == "function") return t(e);
246
+ }
247
+ return e instanceof HTMLElement ? !e.hasAttribute("hidden") : !1;
248
+ }
249
+ dispatch(e, { target: t = null, prefix: n = null, detail: r = null } = {}) {
250
+ if (this.notify) return this.controller.dispatch(e, {
251
+ target: t || this.element,
252
+ prefix: n || this.prefix,
253
+ detail: r
254
+ });
255
+ }
256
+ findCallback(e) {
257
+ if (typeof e != "string") return;
258
+ let t = this, n = e.split(".").reduce((e, t) => e && e[t], t.controller);
259
+ if (typeof n == "function") return n.bind(t.controller);
260
+ let r = e.split(".").reduce((e, t) => e && e[t], t);
261
+ if (typeof r == "function") return r.bind(t);
262
+ }
263
+ async awaitCallback(e, ...t) {
264
+ if (typeof e == "string" && (e = this.findCallback(e)), typeof e == "function") {
265
+ let n = e(...t);
266
+ return n instanceof Promise ? await n : n;
267
+ }
268
+ }
269
+ }, F = 7, I = {
270
+ locales: ["default"],
271
+ today: "",
272
+ day: null,
273
+ month: null,
274
+ year: null,
275
+ since: null,
276
+ till: null,
277
+ disabledDates: [],
278
+ disabledWeekdays: [],
279
+ disabledDays: [],
280
+ disabledMonths: [],
281
+ disabledYears: [],
282
+ firstDayOfWeek: 0,
283
+ onNavigated: "navigated"
284
+ }, L = class extends P {
285
+ constructor(e, t = {}) {
286
+ super(e, t);
287
+ let n = Object.assign({}, I, t), { onNavigated: r, since: i, till: a, firstDayOfWeek: o } = n;
288
+ this.onNavigated = r, this.since = M(i), this.till = M(a), this.firstDayOfWeek = 0 <= o && o < 7 ? o : I.firstDayOfWeek;
289
+ let { disabledDates: s, disabledWeekdays: c, disabledDays: l, disabledMonths: u, disabledYears: d } = n;
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
+ let { today: f, day: p, month: m, year: h } = n;
292
+ this.now = M(f) || /* @__PURE__ */ new Date(), typeof h == "number" && typeof m == "number" && typeof p == "number" ? this.current = M(h, m, p) : this.current = this.now, this.build(), this.enhance();
293
+ }
294
+ build() {
295
+ this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear();
296
+ }
297
+ buildDaysOfWeek() {
298
+ 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 = [];
299
+ for (let i = this.firstDayOfWeek, a = i + 7; i < a; i++) {
300
+ let a = new Date(n);
301
+ a.setDate(n.getDate() + i), r.push({
302
+ date: a,
303
+ value: a.getDay(),
304
+ long: e.format(a),
305
+ short: t.format(a)
306
+ });
307
+ }
308
+ return r;
309
+ }
310
+ buildDaysOfMonth() {
311
+ let e = this.month, t = this.year, n = [], r = (e) => ({
312
+ current: this.month === e.getMonth() && this.year === e.getFullYear(),
313
+ date: e,
314
+ value: e.getDate(),
315
+ month: e.getMonth(),
316
+ year: e.getFullYear(),
317
+ iso: e.toISOString()
318
+ }), i = new Date(t, e).getDay(), a = this.firstDayOfWeek - i;
319
+ for (let i = a > 0 ? a - 7 : a; i < 0; i++) {
320
+ let a = new Date(t, e, i + 1);
321
+ n.push(r(a));
322
+ }
323
+ let o = new Date(t, e + 1, 0).getDate();
324
+ for (let i = 1; i <= o; i++) {
325
+ let a = new Date(t, e, i);
326
+ n.push(r(a));
327
+ }
328
+ let s = n.length % F, c = s === 0 ? 0 : F - s;
329
+ for (let i = 1; i <= c; i++) {
330
+ let a = new Date(t, e + 1, i);
331
+ n.push(r(a));
332
+ }
333
+ return n;
334
+ }
335
+ buildMonthsOfYear() {
336
+ 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 = [];
337
+ for (let i = 0; i < 12; i++) {
338
+ let a = new Date(this.year, i);
339
+ r.push({
340
+ date: a,
341
+ value: a.getMonth(),
342
+ long: e.format(a),
343
+ short: t.format(a),
344
+ numeric: n.format(a)
345
+ });
346
+ }
347
+ return r;
348
+ }
349
+ get today() {
350
+ return this.now;
351
+ }
352
+ set today(e) {
353
+ if (!j(e)) return;
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
+ this.now = new Date(n, t, i).toISOString();
356
+ }
357
+ get current() {
358
+ return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? M(this.year, this.month, this.day) : null;
359
+ }
360
+ set current(e) {
361
+ j(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
362
+ }
363
+ navigate = async (e) => {
364
+ if (!j(e)) return;
365
+ let t = this.current, n = e.toISOString(), r = t.toISOString();
366
+ this.dispatch("navigate", { detail: {
367
+ from: r,
368
+ to: n
369
+ } }), this.current = e, this.build(), await this.awaitCallback(this.onNavigated, {
370
+ from: r,
371
+ to: n
372
+ }), this.dispatch("navigated", { detail: {
373
+ from: r,
374
+ to: n
375
+ } });
376
+ };
377
+ step = async (e, t) => {
378
+ if (t === 0) return;
379
+ let n = this.current;
380
+ switch (e) {
381
+ case "year":
382
+ n.setFullYear(n.getFullYear() + t);
383
+ break;
384
+ case "month":
385
+ n.setMonth(n.getMonth() + t);
386
+ break;
387
+ case "day":
388
+ n.setDate(n.getDate() + t);
389
+ break;
390
+ default: return;
391
+ }
392
+ await this.navigate(n);
393
+ };
394
+ isDisabled = (e) => {
395
+ if (!j(e)) return !1;
396
+ if (this.disabledDates.length) {
397
+ let t = e.getTime();
398
+ for (let e of this.disabledDates) if (t === new Date(e).getTime()) return !0;
399
+ }
400
+ if (this.disabledWeekdays.length) {
401
+ let t = e.getDay(), n = this.daysOfWeek, r = n.findIndex((e) => e.value === t);
402
+ if (r >= 0) {
403
+ let e = n[r];
404
+ for (let t of this.disabledWeekdays) if (e.value == t || e.short === t || e.long === t) return !0;
405
+ }
406
+ }
407
+ if (this.disabledDays.length) {
408
+ let t = e.getDate();
409
+ for (let e of this.disabledDays) if (t == e) return !0;
410
+ }
411
+ if (this.disabledMonths.length) {
412
+ let t = e.getMonth(), n = this.monthsOfYear, r = n.findIndex((e) => e.value === t);
413
+ if (r >= 0) {
414
+ let e = n[r];
415
+ for (let t of this.disabledMonths) if (e.value == t || e.short === t || e.long === t) return !0;
416
+ }
417
+ }
418
+ if (this.disabledYears.length) {
419
+ let t = e.getFullYear();
420
+ for (let e of this.disabledYears) if (t == e) return !0;
421
+ }
422
+ return !1;
423
+ };
424
+ isWithinRange = (e) => {
425
+ if (!j(e)) return !1;
426
+ let t = !0;
427
+ return this.since && (t &&= e >= this.since), this.till && (t &&= e <= this.till), t;
428
+ };
429
+ enhance() {
430
+ let e = this;
431
+ Object.assign(this.controller, { get calendar() {
432
+ return {
433
+ get today() {
434
+ return e.today;
435
+ },
436
+ get current() {
437
+ return e.current;
438
+ },
439
+ get day() {
440
+ return e.day;
441
+ },
442
+ get month() {
443
+ return e.month;
444
+ },
445
+ get year() {
446
+ return e.year;
447
+ },
448
+ get since() {
449
+ return e.since;
450
+ },
451
+ get till() {
452
+ return e.till;
453
+ },
454
+ get firstDayOfWeek() {
455
+ return e.firstDayOfWeek;
456
+ },
457
+ get disabledDates() {
458
+ return e.disabledDates;
459
+ },
460
+ get disabledWeekdays() {
461
+ return e.disabledWeekdays;
462
+ },
463
+ get disabledDays() {
464
+ return e.disabledDays;
465
+ },
466
+ get disabledMonths() {
467
+ return e.disabledMonths;
468
+ },
469
+ get disabledYears() {
470
+ return e.disabledYears;
471
+ },
472
+ get daysOfWeek() {
473
+ return e.daysOfWeek;
474
+ },
475
+ get daysOfMonth() {
476
+ return e.daysOfMonth;
477
+ },
478
+ get monthsOfYear() {
479
+ return e.monthsOfYear;
480
+ },
481
+ navigate: async (t) => await e.navigate(t),
482
+ step: async (t, n) => await e.step(t, n),
483
+ isDisabled: (t) => e.isDisabled(t),
484
+ isWithinRange: (t) => e.isWithinRange(t)
485
+ };
486
+ } });
487
+ }
488
+ }, R = (e, t) => new L(e, t), z = {
489
+ content: null,
490
+ url: "",
491
+ reload: "never",
492
+ stale: 3600,
493
+ onLoad: "contentLoad",
494
+ onLoading: "contentLoading",
495
+ onLoaded: "contentLoaded"
496
+ }, B = class extends P {
497
+ constructor(e, t = {}) {
498
+ super(e, t);
499
+ let n = Object.assign({}, z, t), { content: r, url: i, reload: a, stale: o } = n;
500
+ this.content = r, this.url = i, this.reload = typeof a == "string" ? a : z.reload, this.stale = typeof o == "number" ? o : z.stale;
501
+ let { onLoad: s, onLoading: c, onLoaded: l } = n;
502
+ this.onLoad = s, this.onLoading = c, this.onLoaded = l, this.enhance();
503
+ }
504
+ get reloadable() {
505
+ switch (this.reload) {
506
+ case "never": return !1;
507
+ case "always": return !0;
508
+ default: {
509
+ let e = M(this.loadedAt);
510
+ return e && /* @__PURE__ */ new Date() - e > this.stale * 1e3;
511
+ }
512
+ }
513
+ }
514
+ contentLoadable = ({ url: e }) => !!e;
515
+ contentLoading = async ({ url: e }) => e ? await this.remoteContentLoader(e) : await this.contentLoader();
516
+ contentLoader = async () => "";
517
+ remoteContentLoader = async (e) => (await fetch(e)).text();
518
+ load = async () => {
519
+ if (this.loadedAt && !this.reloadable) return;
520
+ let e = this.findCallback(this.onLoad), t = await this.awaitCallback(e || this.contentLoadable, { url: this.url });
521
+ if (this.dispatch("load", { detail: { url: this.url } }), !t) return;
522
+ let n = this.url ? await this.remoteContentLoader(this.url) : await this.contentLoader();
523
+ this.dispatch("loading", { detail: { url: this.url } }), n && (await this.awaitCallback(this.onLoaded, {
524
+ url: this.url,
525
+ content: n
526
+ }), this.loadedAt = (/* @__PURE__ */ new Date()).getTime(), this.dispatch("loaded", { detail: {
527
+ url: this.url,
528
+ content: n
529
+ } }));
530
+ };
531
+ enhance() {
532
+ let e = this;
533
+ Object.assign(this.controller, { load: e.load.bind(e) });
534
+ }
535
+ }, V = (e, t) => new B(e, t), H = {
536
+ trigger: null,
537
+ events: ["click"],
538
+ onDismissed: "dismissed"
539
+ }, U = class extends P {
540
+ constructor(e, t = {}) {
541
+ super(e, t);
542
+ let { trigger: n, events: r, onDismissed: i } = Object.assign({}, H, t);
543
+ this.onDismissed = i, this.trigger = n || this.element, this.events = r, this.enhance(), this.observe();
544
+ }
545
+ dismiss = async (e) => {
546
+ let { target: t } = e;
547
+ t instanceof HTMLElement && (this.element.contains(t) || this.visible && (this.dispatch("dismiss"), await this.awaitCallback(this.onDismissed, { target: this.trigger }), this.dispatch("dismissed")));
548
+ };
549
+ observe() {
550
+ this.events.forEach((e) => {
551
+ window.addEventListener(e, this.dismiss, !0);
552
+ });
553
+ }
554
+ unobserve() {
555
+ this.events.forEach((e) => {
556
+ window.removeEventListener(e, this.dismiss, !0);
557
+ });
558
+ }
559
+ enhance() {
560
+ let e = this, t = e.controller.disconnect.bind(e.controller);
561
+ Object.assign(this.controller, { disconnect: () => {
562
+ e.unobserve(), t();
563
+ } });
564
+ }
565
+ }, W = (e, t) => new U(e, t), G = {
566
+ anchor: null,
567
+ events: ["click"],
568
+ placement: "bottom",
569
+ alignment: "start",
570
+ onFlipped: "flipped",
571
+ ariaRole: null,
572
+ respectMotion: !0
573
+ }, K = class extends P {
574
+ constructor(e, t = {}) {
575
+ super(e, t);
576
+ let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, G, t);
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 && C({
578
+ trigger: this.anchor,
579
+ target: this.element,
580
+ role: this.ariaRole
581
+ }), this.enhance(), this.observe();
582
+ }
583
+ flip = async () => {
584
+ if (!this.visible) return;
585
+ this.dispatch("flip"), window.getComputedStyle(this.element).position != "absolute" && (this.element.style.position = "absolute");
586
+ let e = this.flippedRect(this.anchor.getBoundingClientRect(), this.element.getBoundingClientRect());
587
+ this.element.style.transition = this.respectMotion && this.prefersReducedMotion ? "none" : "";
588
+ for (let [t, n] of Object.entries(e)) this.element.style[t] = n;
589
+ await this.awaitCallback(this.onFlipped, {
590
+ target: this.element,
591
+ placement: e
592
+ }), this.dispatch("flipped", { detail: { placement: e } });
593
+ };
594
+ flippedRect(e, t) {
595
+ let n = this.quadrumRect(e, k()), r = [this.placement, D[this.placement]], i = {};
596
+ for (; !Object.keys(i).length && r.length > 0;) {
597
+ let a = r.shift();
598
+ if (!this.biggerRectThan(n[a], t)) continue;
599
+ let o = this.quadrumPlacement(e, a, t), s = this.quadrumAlignment(e, a, o);
600
+ i.top = `${s.top + window.scrollY}px`, i.left = `${s.left + window.scrollX}px`;
601
+ }
602
+ return Object.keys(i).length || (i.top = "", i.left = ""), i;
603
+ }
604
+ quadrumRect(e, t) {
605
+ return {
606
+ left: O({
607
+ x: t.x,
608
+ y: t.y,
609
+ width: e.x - t.x,
610
+ height: t.height
611
+ }),
612
+ right: O({
613
+ x: e.x + e.width,
614
+ y: t.y,
615
+ width: t.width - (e.x + e.width),
616
+ height: t.height
617
+ }),
618
+ top: O({
619
+ x: t.x,
620
+ y: t.y,
621
+ width: t.width,
622
+ height: e.y - t.y
623
+ }),
624
+ bottom: O({
625
+ x: t.x,
626
+ y: e.y + e.height,
627
+ width: t.width,
628
+ height: t.height - (e.y + e.height)
629
+ })
630
+ };
631
+ }
632
+ quadrumPlacement(e, t, n) {
633
+ switch (t) {
634
+ case "top": return O({
635
+ x: n.x,
636
+ y: e.y - n.height,
637
+ width: n.width,
638
+ height: n.height
639
+ });
640
+ case "bottom": return O({
641
+ x: n.x,
642
+ y: e.y + e.height,
643
+ width: n.width,
644
+ height: n.height
645
+ });
646
+ case "left": return O({
647
+ x: e.x - n.width,
648
+ y: n.y,
649
+ width: n.width,
650
+ height: n.height
651
+ });
652
+ case "right": return O({
653
+ x: e.x + e.width,
654
+ y: n.y,
655
+ width: n.width,
656
+ height: n.height
657
+ });
658
+ default: throw `Unable place at the quadrum, ${t}`;
659
+ }
660
+ }
661
+ quadrumAlignment(e, t, n) {
662
+ switch (t) {
663
+ case "top":
664
+ case "bottom": {
665
+ 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), O({
667
+ x: t,
668
+ y: n.y,
669
+ width: n.width,
670
+ height: n.height
671
+ });
672
+ }
673
+ case "left":
674
+ case "right": {
675
+ 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), O({
677
+ x: n.x,
678
+ y: t,
679
+ width: n.width,
680
+ height: n.height
681
+ });
682
+ }
683
+ default: throw `Unable align at the quadrum, ${t}`;
684
+ }
685
+ }
686
+ biggerRectThan(e, t) {
687
+ return e.height >= t.height && e.width >= t.width;
688
+ }
689
+ observe() {
690
+ this.events.forEach((e) => {
691
+ window.addEventListener(e, this.flip, !0);
692
+ });
693
+ }
694
+ unobserve() {
695
+ this.events.forEach((e) => {
696
+ window.removeEventListener(e, this.flip, !0);
697
+ });
698
+ }
699
+ enhance() {
700
+ let e = this, t = e.controller.disconnect.bind(e.controller);
701
+ Object.assign(this.controller, {
702
+ disconnect: () => {
703
+ e.unobserve(), t();
704
+ },
705
+ flip: e.flip.bind(e)
706
+ });
707
+ }
708
+ }, q = (e, t) => new K(e, t), J = {
709
+ events: ["resize"],
710
+ boundaries: [
711
+ "top",
712
+ "left",
713
+ "right"
714
+ ],
715
+ onShifted: "shifted",
716
+ respectMotion: !0
717
+ }, Y = class extends P {
718
+ constructor(e, t = {}) {
719
+ super(e, t);
720
+ let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({}, J, t);
721
+ 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
+ }
723
+ shift = async () => {
724
+ if (!this.visible) return;
725
+ this.dispatch("shift");
726
+ let e = this.overflowRect(this.element.getBoundingClientRect(), this.elementTranslations(this.element)), t = e.left || e.right || 0, n = e.top || e.bottom || 0;
727
+ 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
+ };
729
+ overflowRect(e, t) {
730
+ let n = {}, r = k(), i = O({
731
+ x: e.x - t.x,
732
+ y: e.y - t.y,
733
+ width: e.width,
734
+ height: e.height
735
+ });
736
+ for (let e of this.boundaries) {
737
+ let t = this.directionDistance(i, e, r), a = D[e];
738
+ t < 0 ? i[a] + t >= r[a] && !n[a] && (n[e] = t) : n[e] = "";
739
+ }
740
+ return n;
741
+ }
742
+ directionDistance(e, t, n) {
743
+ switch (t) {
744
+ case "top":
745
+ case "left": return e[t] - n[t];
746
+ case "bottom":
747
+ case "right": return n[t] - e[t];
748
+ default: throw `Invalid direction to calcuate distance, ${t}`;
749
+ }
750
+ }
751
+ elementTranslations(e) {
752
+ let t = window.getComputedStyle(e), n = t.transform || t.webkitTransform || t.mozTransform;
753
+ if (n === "none" || n === void 0) return {
754
+ x: 0,
755
+ y: 0
756
+ };
757
+ let r = n.includes("3d") ? "3d" : "2d", i = n.match(/matrix.*\((.+)\)/)[1].split(", ");
758
+ return r === "2d" ? {
759
+ x: Number(i[4]),
760
+ y: Number(i[5])
761
+ } : {
762
+ x: 0,
763
+ y: 0
764
+ };
765
+ }
766
+ observe() {
767
+ this.events.forEach((e) => {
768
+ window.addEventListener(e, this.shift, !0);
769
+ });
770
+ }
771
+ unobserve() {
772
+ this.events.forEach((e) => {
773
+ window.removeEventListener(e, this.shift, !0);
774
+ });
775
+ }
776
+ enhance() {
777
+ let e = this, t = e.controller.disconnect.bind(e.controller);
778
+ Object.assign(this.controller, {
779
+ disconnect: () => {
780
+ e.unobserve(), t();
781
+ },
782
+ shift: e.shift.bind(e)
783
+ });
784
+ }
785
+ }, X = (e, t) => new Y(e, t), Z = {
786
+ visibility: "visibility",
787
+ onShown: "shown",
788
+ onHidden: "hidden"
789
+ }, Q = class extends P {
790
+ constructor(e, t = {}) {
791
+ 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
+ (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
+ }
794
+ isVisible(e) {
795
+ if (!(e instanceof HTMLElement)) return !1;
796
+ let t = E.hiddenClass;
797
+ return t ? !e.classList.contains(t) : !e.hasAttribute("hidden");
798
+ }
799
+ toggle(e, t) {
800
+ if (!(e instanceof HTMLElement)) return;
801
+ let n = E.hiddenClass;
802
+ n ? t ? e.classList.remove(n) : e.classList.add(n) : t ? e.removeAttribute("hidden") : e.setAttribute("hidden", !0);
803
+ }
804
+ activate(e) {
805
+ this.activator && this.activator.setAttribute("aria-expanded", e ? "true" : "false");
806
+ }
807
+ async show() {
808
+ !(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"));
809
+ }
810
+ async hide() {
811
+ !(this.element instanceof HTMLElement) || !this.isVisible(this.element) || (this.dispatch("hide"), this.toggle(this.element, !1), this.activate(!1), await this.awaitCallback(this.onHidden, { target: this.element }), this.dispatch("hidden"));
812
+ }
813
+ enhance() {
814
+ let e = this, t = {
815
+ show: e.show.bind(e),
816
+ hide: e.hide.bind(e)
817
+ };
818
+ Object.defineProperty(t, "visible", { get() {
819
+ return e.isVisible(e.element);
820
+ } }), Object.defineProperty(t, this.visibilityResolver, { value: e.isVisible.bind(e) }), Object.defineProperty(this.controller, this.visibility, { get() {
821
+ return t;
822
+ } });
823
+ }
824
+ }, $ = (e, t) => new Q(e, t), te = class extends e {
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 {
964
+ static targets = ["daysOfWeek", "daysOfMonth"];
965
+ static classes = ["dayOfWeek", "dayOfMonth"];
966
+ static values = {
967
+ locales: {
968
+ type: Array,
969
+ default: ["default"]
970
+ },
971
+ weekdayFormat: {
972
+ type: String,
973
+ default: "short"
974
+ },
975
+ dayFormat: {
976
+ type: String,
977
+ default: "numeric"
978
+ },
979
+ daysOfOtherMonth: {
980
+ type: Boolean,
981
+ default: !1
982
+ }
983
+ };
984
+ initialize() {
985
+ R(this);
986
+ }
987
+ connect() {
988
+ this.draw();
989
+ }
990
+ navigated() {
991
+ this.draw();
992
+ }
993
+ draw() {
994
+ this.drawDaysOfWeek(), this.drawDaysOfMonth();
995
+ }
996
+ createDayElement(e, { selectable: t = !1, disabled: n = !1 } = {}) {
997
+ let r = document.createElement(t ? "button" : "div");
998
+ 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;
999
+ }
1000
+ drawDaysOfWeek() {
1001
+ if (!this.hasDaysOfWeekTarget) return;
1002
+ let e = new Intl.DateTimeFormat(this.localesValue, { weekday: this.weekdayFormatValue }), t = [];
1003
+ for (let n of this.calendar.daysOfWeek) {
1004
+ let r = this.createDayElement(e.format(n.date));
1005
+ r.setAttribute("role", "columnheader"), r.title = n.long, this.hasDayOfWeekClass && r.classList.add(...this.dayOfWeekClasses), t.push(r);
1006
+ }
1007
+ let n = document.createElement("div");
1008
+ n.setAttribute("role", "row"), n.replaceChildren(...t), this.daysOfWeekTarget.replaceChildren(n);
1009
+ }
1010
+ drawDaysOfMonth() {
1011
+ if (!this.hasDaysOfMonthTarget) return;
1012
+ let e = this.calendar.today, t = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), n = [];
1013
+ for (let e of this.calendar.daysOfMonth) {
1014
+ let r = !e.current || this.calendar.isDisabled(e.date) || !this.calendar.isWithinRange(e.date), i = e.current || this.daysOfOtherMonthValue ? e.value : "", a = this.createDayElement(i, {
1015
+ selectable: e.current,
1016
+ disabled: r
1017
+ });
1018
+ t === e.date.getTime() && a.setAttribute("aria-current", "date"), this.hasDayOfMonthClass && a.classList.add(...this.dayOfMonthClasses);
1019
+ let o = document.createElement("time");
1020
+ o.dateTime = e.iso, a.appendChild(o), n.push(a);
1021
+ }
1022
+ let r = [];
1023
+ for (let e = 0; e < n.length; e += 7) {
1024
+ let t = document.createElement("div");
1025
+ t.setAttribute("role", "row");
1026
+ for (let r of n.slice(e, e + 7)) r.setAttribute("role", "gridcell"), t.appendChild(r);
1027
+ r.push(t);
1028
+ }
1029
+ this.daysOfMonthTarget.replaceChildren(...r);
1030
+ }
1031
+ }, oe = class extends e {
1032
+ select(e) {
1033
+ if (!(e.target instanceof HTMLElement)) return;
1034
+ e.preventDefault();
1035
+ let t = e.target instanceof HTMLTimeElement ? e.target.parentElement : e.target;
1036
+ if (t.disabled || t.getAttribute("aria-disabled") === "true") return;
1037
+ this.dispatch("select", { target: t });
1038
+ let n = e.target instanceof HTMLTimeElement ? e.target : e.target.querySelector("time");
1039
+ if (!n) return console.error(`unable to locate time element within ${t}`);
1040
+ let r = M(n.dateTime);
1041
+ if (!r) return console.error(`unable to parse ${n.dateTime} found within the time element`);
1042
+ this.dispatch("selected", {
1043
+ target: t,
1044
+ detail: {
1045
+ epoch: r.getTime(),
1046
+ iso: r.toISOString()
1047
+ }
1048
+ });
1049
+ }
1050
+ }, se = class extends e {
1051
+ static targets = [
1052
+ "previous",
1053
+ "next",
1054
+ "day",
1055
+ "month",
1056
+ "year",
1057
+ "input",
1058
+ "display"
1059
+ ];
1060
+ static outlets = ["calendar-month"];
1061
+ static values = {
1062
+ locales: {
1063
+ type: Array,
1064
+ default: ["default"]
1065
+ },
1066
+ dayFormat: {
1067
+ type: String,
1068
+ default: "numeric"
1069
+ },
1070
+ monthFormat: {
1071
+ type: String,
1072
+ default: "long"
1073
+ },
1074
+ yearFormat: {
1075
+ type: String,
1076
+ default: "numeric"
1077
+ }
1078
+ };
1079
+ initialize() {
1080
+ this.previous = this.previous.bind(this), this.next = this.next.bind(this);
1081
+ }
1082
+ async calendarMonthOutletConnected() {
1083
+ if (this.hasInputTarget && this.inputTarget.value) {
1084
+ let e = M(this.inputTarget.value);
1085
+ e && await this.calendarMonthOutlet.calendar.navigate(e);
1086
+ }
1087
+ this.draw();
1088
+ }
1089
+ selected(e) {
1090
+ this.hasInputTarget && (this.inputTarget.value = e.detail.iso), this.hasDisplayTarget && (this.displayTarget.value = this.formatDate(new Date(e.detail.iso)));
1091
+ }
1092
+ formatDate(e) {
1093
+ return new Intl.DateTimeFormat(this.localesValue, {
1094
+ day: this.dayFormatValue,
1095
+ month: this.monthFormatValue,
1096
+ year: this.yearFormatValue
1097
+ }).format(e);
1098
+ }
1099
+ previousTargetConnected(e) {
1100
+ e.addEventListener("click", this.previous);
1101
+ }
1102
+ previousTargetDisconnected(e) {
1103
+ e.removeEventListener("click", this.previous);
1104
+ }
1105
+ async previous() {
1106
+ await this.calendarMonthOutlet.calendar.step("month", -1), this.draw();
1107
+ }
1108
+ nextTargetConnected(e) {
1109
+ e.addEventListener("click", this.next);
1110
+ }
1111
+ nextTargetDisconnected(e) {
1112
+ e.removeEventListener("click", this.next);
1113
+ }
1114
+ async next() {
1115
+ await this.calendarMonthOutlet.calendar.step("month", 1), this.draw();
1116
+ }
1117
+ draw() {
1118
+ this.drawDay(), this.drawMonth(), this.drawYear();
1119
+ }
1120
+ drawDay() {
1121
+ if (!this.hasDayTarget || !this.hasCalendarMonthOutlet) return;
1122
+ let { year: e, month: t, day: n } = this.calendarMonthOutlet.calendar, r = new Intl.DateTimeFormat(this.localesValue, { day: this.dayFormatValue });
1123
+ this.dayTarget.textContent = r.format(new Date(e, t, n));
1124
+ }
1125
+ drawMonth() {
1126
+ if (!this.hasMonthTarget || !this.hasCalendarMonthOutlet) return;
1127
+ let { year: e, month: t } = this.calendarMonthOutlet.calendar, n = new Intl.DateTimeFormat(this.localesValue, { month: this.monthFormatValue });
1128
+ this.monthTarget.textContent = n.format(new Date(e, t));
1129
+ }
1130
+ drawYear() {
1131
+ if (!this.hasYearTarget || !this.hasCalendarMonthOutlet) return;
1132
+ let { year: e } = this.calendarMonthOutlet.calendar, t = new Intl.DateTimeFormat(this.localesValue, { year: this.yearFormatValue });
1133
+ this.yearTarget.textContent = t.format(new Date(e, 0));
1134
+ }
1135
+ }, ce = class extends e {
1136
+ static targets = ["content"];
1137
+ connect() {
1138
+ X(this, { element: this.hasContentTarget ? this.contentTarget : null });
1139
+ }
1140
+ };
1141
+ //#endregion
1142
+ export { b as ARIA_HASPOPUP_VALUES, ae as CalendarMonthController, oe as CalendarMonthObserverController, se as DatepickerController, ne as DismisserController, t as FOCUSABLE_SELECTOR, re as FlipperController, o as FocusRestoration, a as FocusTrap, te as ModalController, ce as PannerController, ie as PopoverController, d as RovingTabIndex, p as announce, C as connectTriggerToTarget, T 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, y as setChecked, ee as setDisabled, _ as setExpanded, v as setPressed };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@hotwired/stimulus`)):typeof define==`function`&&define.amd?define([`exports`,`@hotwired/stimulus`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.StimulusPlumbersControllers={},e.Stimulus))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function r(e){return Array.from(e.querySelectorAll(n)).filter(e=>i(e))}function i(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function a(e){let t=r(e);return t.length>0?(t[0].focus(),!0):!1}var o=class{constructor(e,t={}){this.container=e,this.previouslyFocused=null,this.options=t,this.isActive=!1}activate(){this.isActive||(this.previouslyFocused=document.activeElement,this.isActive=!0,this.options.initialFocus?this.options.initialFocus.focus():a(this.container),this.container.addEventListener(`keydown`,this.handleKeyDown))}deactivate(){if(!this.isActive)return;this.isActive=!1,this.container.removeEventListener(`keydown`,this.handleKeyDown);let e=this.options.returnFocus||this.previouslyFocused;e&&i(e)&&e.focus()}handleKeyDown=e=>{if(e.key===`Escape`&&this.options.escapeDeactivates){e.preventDefault(),this.deactivate();return}if(e.key!==`Tab`)return;let t=r(this.container);if(t.length===0)return;let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}},s=class{constructor(){this.savedElement=null}save(){this.savedElement=document.activeElement}restore(){this.savedElement&&i(this.savedElement)&&(this.savedElement.focus(),this.savedElement=null)}};function c(e,t){return e.key===t}function l(e){return e.key===`Enter`||e.key===` `}function u(e){return[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)}function d(e){e.preventDefault(),e.stopPropagation()}var f=class{constructor(e,t=0){this.items=e,this.currentIndex=t,this.updateTabIndex()}handleKeyDown(e){let t;switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),t=(this.currentIndex+1)%this.items.length;break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),t=this.currentIndex===0?this.items.length-1:this.currentIndex-1;break;case`Home`:e.preventDefault(),t=0;break;case`End`:e.preventDefault(),t=this.items.length-1;break;default:return}this.setCurrentIndex(t)}setCurrentIndex(e){e>=0&&e<this.items.length&&(this.currentIndex=e,this.updateTabIndex(),this.items[e].focus())}updateTabIndex(){this.items.forEach((e,t)=>{e.tabIndex=t===this.currentIndex?0:-1})}updateItems(e){this.items=e,this.currentIndex=Math.min(this.currentIndex,e.length-1),this.updateTabIndex()}},p=(e,t,n)=>{let r=document.querySelector(`[data-live-region="${e}"]`);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};function m(e,t={}){let{politeness:n=`polite`,atomic:r=!0,relevant:i=`additions text`}=t,a=p(n,r,i);a.textContent=``,setTimeout(()=>{a.textContent=e},100)}var h=(e=`a11y`)=>`${e}-${Math.random().toString(36).substr(2,9)}`,g=(e,t=`element`)=>e.id||=h(t),_=(e,t,n)=>{e.setAttribute(t,n.toString())},v=(e,t)=>_(e,`aria-expanded`,t),y=(e,t)=>_(e,`aria-pressed`,t),b=(e,t)=>_(e,`aria-checked`,t);function x(e,t){_(e,`aria-disabled`,t),t?e.setAttribute(`tabindex`,`-1`):e.removeAttribute(`tabindex`)}var S={menu:`menu`,listbox:`listbox`,tree:`tree`,grid:`grid`,dialog:`dialog`},C=(e,t,n)=>{Object.entries(t).forEach(([t,r])=>{e.setAttribute(t,r),n[t]=r})},w=(e,t,n)=>n||!e.hasAttribute(t);function T({trigger:e,target:t,role:n=null,override:r=!1}){let i={trigger:{},target:{}};if(!e||!t)return i;let a={},o={};if(n&&w(t,`role`,r)&&(o.role=n),t.id&&(w(e,`aria-controls`,r)&&(a[`aria-controls`]=t.id),n===`tooltip`&&w(e,`aria-describedby`,r)&&(a[`aria-describedby`]=t.id)),n&&w(e,`aria-haspopup`,r)){let e=S[n]||`true`;e&&(a[`aria-haspopup`]=e)}return C(t,o,i.target),C(e,a,i.trigger),i}var E=(e,t)=>{t.forEach(t=>{e.hasAttribute(t)&&e.removeAttribute(t)})};function ee({trigger:e,target:t,attributes:n=null}){!e||!t||(E(e,n||[`aria-controls`,`aria-haspopup`,`aria-describedby`]),(!n||n.includes(`role`))&&E(t,[`role`]))}var D={get visibleOnly(){return!0},hiddenClass:null},O={get top(){return`bottom`},get bottom(){return`top`},get left(){return`right`},get right(){return`left`}};function k({x:e,y:t,width:n,height:r}){return{x:e,y:t,width:n,height:r,left:e,right:e+n,top:t,bottom:t+r}}function A(){return k({x:0,y:0,width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight})}function j(e){if(!(e instanceof HTMLElement))return!1;let t=A(),n=e.getBoundingClientRect(),r=n.top<=t.height&&n.top+n.height>0,i=n.left<=t.width&&n.left+n.width>0;return r&&i}function M(e){return e instanceof Date&&!isNaN(e)}function N(...e){if(e.length===0)throw`Missing values to parse as date`;if(e.length===1){let t=new Date(e[0]);if(e[0]&&M(t))return t}else{let t=new Date(...e);if(M(t))return t}}var te={element:null,visible:null,dispatch:!0,prefix:``},P=class{constructor(e,t={}){this.controller=e;let{element:n,visible:r,dispatch:i,prefix:a}=Object.assign({},te,t);this.element=n||e.element,this.visibleOnly=typeof r==`boolean`?r:D.visibleOnly,this.visibleCallback=typeof r==`string`?r:null,this.notify=!!i,this.prefix=typeof a==`string`&&a?a:e.identifier}get visible(){return this.element instanceof HTMLElement?this.visibleOnly?j(this.element)&&this.isVisible(this.element):!0:!1}isVisible(e){if(this.visibleCallback){let t=this.findCallback(this.visibleCallback);if(typeof t==`function`)return t(e)}return e instanceof HTMLElement?!e.hasAttribute(`hidden`):!1}dispatch(e,{target:t=null,prefix:n=null,detail:r=null}={}){if(this.notify)return this.controller.dispatch(e,{target:t||this.element,prefix:n||this.prefix,detail:r})}findCallback(e){if(typeof e!=`string`)return;let t=this,n=e.split(`.`).reduce((e,t)=>e&&e[t],t.controller);if(typeof n==`function`)return n.bind(t.controller);let r=e.split(`.`).reduce((e,t)=>e&&e[t],t);if(typeof r==`function`)return r.bind(t)}async awaitCallback(e,...t){if(typeof e==`string`&&(e=this.findCallback(e)),typeof e==`function`){let n=e(...t);return n instanceof Promise?await n:n}}},F=7,I={locales:[`default`],today:``,day:null,month:null,year:null,since:null,till:null,disabledDates:[],disabledWeekdays:[],disabledDays:[],disabledMonths:[],disabledYears:[],firstDayOfWeek:0,onNavigated:`navigated`},L=class extends P{constructor(e,t={}){super(e,t);let n=Object.assign({},I,t),{onNavigated:r,since:i,till:a,firstDayOfWeek:o}=n;this.onNavigated=r,this.since=N(i),this.till=N(a),this.firstDayOfWeek=0<=o&&o<7?o:I.firstDayOfWeek;let{disabledDates:s,disabledWeekdays:c,disabledDays:l,disabledMonths:u,disabledYears:d}=n;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:[];let{today:f,day:p,month:m,year:h}=n;this.now=N(f)||new Date,typeof h==`number`&&typeof m==`number`&&typeof p==`number`?this.current=N(h,m,p):this.current=this.now,this.build(),this.enhance()}build(){this.daysOfWeek=this.buildDaysOfWeek(),this.daysOfMonth=this.buildDaysOfMonth(),this.monthsOfYear=this.buildMonthsOfYear()}buildDaysOfWeek(){let e=new Intl.DateTimeFormat(this.localesValue,{weekday:`long`}),t=new Intl.DateTimeFormat(this.localesValue,{weekday:`short`}),n=new Date(`2024-10-06`),r=[];for(let i=this.firstDayOfWeek,a=i+7;i<a;i++){let a=new Date(n);a.setDate(n.getDate()+i),r.push({date:a,value:a.getDay(),long:e.format(a),short:t.format(a)})}return r}buildDaysOfMonth(){let e=this.month,t=this.year,n=[],r=e=>({current:this.month===e.getMonth()&&this.year===e.getFullYear(),date:e,value:e.getDate(),month:e.getMonth(),year:e.getFullYear(),iso:e.toISOString()}),i=new Date(t,e).getDay(),a=this.firstDayOfWeek-i;for(let i=a>0?a-7:a;i<0;i++){let a=new Date(t,e,i+1);n.push(r(a))}let o=new Date(t,e+1,0).getDate();for(let i=1;i<=o;i++){let a=new Date(t,e,i);n.push(r(a))}let s=n.length%F,c=s===0?0:F-s;for(let i=1;i<=c;i++){let a=new Date(t,e+1,i);n.push(r(a))}return n}buildMonthsOfYear(){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=[];for(let i=0;i<12;i++){let a=new Date(this.year,i);r.push({date:a,value:a.getMonth(),long:e.format(a),short:t.format(a),numeric:n.format(a)})}return r}get today(){return this.now}set today(e){if(!M(e))return;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;this.now=new Date(n,t,i).toISOString()}get current(){return typeof this.year==`number`&&typeof this.month==`number`&&typeof this.day==`number`?N(this.year,this.month,this.day):null}set current(e){M(e)&&(this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear())}navigate=async e=>{if(!M(e))return;let t=this.current,n=e.toISOString(),r=t.toISOString();this.dispatch(`navigate`,{detail:{from:r,to:n}}),this.current=e,this.build(),await this.awaitCallback(this.onNavigated,{from:r,to:n}),this.dispatch(`navigated`,{detail:{from:r,to:n}})};step=async(e,t)=>{if(t===0)return;let n=this.current;switch(e){case`year`:n.setFullYear(n.getFullYear()+t);break;case`month`:n.setMonth(n.getMonth()+t);break;case`day`:n.setDate(n.getDate()+t);break;default:return}await this.navigate(n)};isDisabled=e=>{if(!M(e))return!1;if(this.disabledDates.length){let t=e.getTime();for(let e of this.disabledDates)if(t===new Date(e).getTime())return!0}if(this.disabledWeekdays.length){let t=e.getDay(),n=this.daysOfWeek,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledWeekdays)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledDays.length){let t=e.getDate();for(let e of this.disabledDays)if(t==e)return!0}if(this.disabledMonths.length){let t=e.getMonth(),n=this.monthsOfYear,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledMonths)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledYears.length){let t=e.getFullYear();for(let e of this.disabledYears)if(t==e)return!0}return!1};isWithinRange=e=>{if(!M(e))return!1;let t=!0;return this.since&&(t&&=e>=this.since),this.till&&(t&&=e<=this.till),t};enhance(){let e=this;Object.assign(this.controller,{get calendar(){return{get today(){return e.today},get current(){return e.current},get day(){return e.day},get month(){return e.month},get year(){return e.year},get since(){return e.since},get till(){return e.till},get firstDayOfWeek(){return e.firstDayOfWeek},get disabledDates(){return e.disabledDates},get disabledWeekdays(){return e.disabledWeekdays},get disabledDays(){return e.disabledDays},get disabledMonths(){return e.disabledMonths},get disabledYears(){return e.disabledYears},get daysOfWeek(){return e.daysOfWeek},get daysOfMonth(){return e.daysOfMonth},get monthsOfYear(){return e.monthsOfYear},navigate:async t=>await e.navigate(t),step:async(t,n)=>await e.step(t,n),isDisabled:t=>e.isDisabled(t),isWithinRange:t=>e.isWithinRange(t)}}})}},R=(e,t)=>new L(e,t),z={content:null,url:``,reload:`never`,stale:3600,onLoad:`contentLoad`,onLoading:`contentLoading`,onLoaded:`contentLoaded`},B=class extends P{constructor(e,t={}){super(e,t);let n=Object.assign({},z,t),{content:r,url:i,reload:a,stale:o}=n;this.content=r,this.url=i,this.reload=typeof a==`string`?a:z.reload,this.stale=typeof o==`number`?o:z.stale;let{onLoad:s,onLoading:c,onLoaded:l}=n;this.onLoad=s,this.onLoading=c,this.onLoaded=l,this.enhance()}get reloadable(){switch(this.reload){case`never`:return!1;case`always`:return!0;default:{let e=N(this.loadedAt);return e&&new Date-e>this.stale*1e3}}}contentLoadable=({url:e})=>!!e;contentLoading=async({url:e})=>e?await this.remoteContentLoader(e):await this.contentLoader();contentLoader=async()=>``;remoteContentLoader=async e=>(await fetch(e)).text();load=async()=>{if(this.loadedAt&&!this.reloadable)return;let e=this.findCallback(this.onLoad),t=await this.awaitCallback(e||this.contentLoadable,{url:this.url});if(this.dispatch(`load`,{detail:{url:this.url}}),!t)return;let n=this.url?await this.remoteContentLoader(this.url):await this.contentLoader();this.dispatch(`loading`,{detail:{url:this.url}}),n&&(await this.awaitCallback(this.onLoaded,{url:this.url,content:n}),this.loadedAt=new Date().getTime(),this.dispatch(`loaded`,{detail:{url:this.url,content:n}}))};enhance(){let e=this;Object.assign(this.controller,{load:e.load.bind(e)})}},V=(e,t)=>new B(e,t),H={trigger:null,events:[`click`],onDismissed:`dismissed`},U=class extends P{constructor(e,t={}){super(e,t);let{trigger:n,events:r,onDismissed:i}=Object.assign({},H,t);this.onDismissed=i,this.trigger=n||this.element,this.events=r,this.enhance(),this.observe()}dismiss=async e=>{let{target:t}=e;t instanceof HTMLElement&&(this.element.contains(t)||this.visible&&(this.dispatch(`dismiss`),await this.awaitCallback(this.onDismissed,{target:this.trigger}),this.dispatch(`dismissed`)))};observe(){this.events.forEach(e=>{window.addEventListener(e,this.dismiss,!0)})}unobserve(){this.events.forEach(e=>{window.removeEventListener(e,this.dismiss,!0)})}enhance(){let e=this,t=e.controller.disconnect.bind(e.controller);Object.assign(this.controller,{disconnect:()=>{e.unobserve(),t()}})}},W=(e,t)=>new U(e,t),G={anchor:null,events:[`click`],placement:`bottom`,alignment:`start`,onFlipped:`flipped`,ariaRole:null,respectMotion:!0},K=class extends P{constructor(e,t={}){super(e,t);let{anchor:n,events:r,placement:i,alignment:a,onFlipped:o,ariaRole:s,respectMotion:c}=Object.assign({},G,t);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&&T({trigger:this.anchor,target:this.element,role:this.ariaRole}),this.enhance(),this.observe()}flip=async()=>{if(!this.visible)return;this.dispatch(`flip`),window.getComputedStyle(this.element).position!=`absolute`&&(this.element.style.position=`absolute`);let e=this.flippedRect(this.anchor.getBoundingClientRect(),this.element.getBoundingClientRect());this.element.style.transition=this.respectMotion&&this.prefersReducedMotion?`none`:``;for(let[t,n]of Object.entries(e))this.element.style[t]=n;await this.awaitCallback(this.onFlipped,{target:this.element,placement:e}),this.dispatch(`flipped`,{detail:{placement:e}})};flippedRect(e,t){let n=this.quadrumRect(e,A()),r=[this.placement,O[this.placement]],i={};for(;!Object.keys(i).length&&r.length>0;){let a=r.shift();if(!this.biggerRectThan(n[a],t))continue;let o=this.quadrumPlacement(e,a,t),s=this.quadrumAlignment(e,a,o);i.top=`${s.top+window.scrollY}px`,i.left=`${s.left+window.scrollX}px`}return Object.keys(i).length||(i.top=``,i.left=``),i}quadrumRect(e,t){return{left:k({x:t.x,y:t.y,width:e.x-t.x,height:t.height}),right:k({x:e.x+e.width,y:t.y,width:t.width-(e.x+e.width),height:t.height}),top:k({x:t.x,y:t.y,width:t.width,height:e.y-t.y}),bottom:k({x:t.x,y:e.y+e.height,width:t.width,height:t.height-(e.y+e.height)})}}quadrumPlacement(e,t,n){switch(t){case`top`:return k({x:n.x,y:e.y-n.height,width:n.width,height:n.height});case`bottom`:return k({x:n.x,y:e.y+e.height,width:n.width,height:n.height});case`left`:return k({x:e.x-n.width,y:n.y,width:n.width,height:n.height});case`right`:return k({x:e.x+e.width,y:n.y,width:n.width,height:n.height});default:throw`Unable place at the quadrum, ${t}`}}quadrumAlignment(e,t,n){switch(t){case`top`:case`bottom`:{let t=e.x;return this.alignment===`center`?t=e.x+e.width/2-n.width/2:this.alignment===`end`&&(t=e.x+e.width-n.width),k({x:t,y:n.y,width:n.width,height:n.height})}case`left`:case`right`:{let t=e.y;return this.alignment===`center`?t=e.y+e.height/2-n.height/2:this.alignment===`end`&&(t=e.y+e.height-n.height),k({x:n.x,y:t,width:n.width,height:n.height})}default:throw`Unable align at the quadrum, ${t}`}}biggerRectThan(e,t){return e.height>=t.height&&e.width>=t.width}observe(){this.events.forEach(e=>{window.addEventListener(e,this.flip,!0)})}unobserve(){this.events.forEach(e=>{window.removeEventListener(e,this.flip,!0)})}enhance(){let e=this,t=e.controller.disconnect.bind(e.controller);Object.assign(this.controller,{disconnect:()=>{e.unobserve(),t()},flip:e.flip.bind(e)})}},q=(e,t)=>new K(e,t),J={events:[`resize`],boundaries:[`top`,`left`,`right`],onShifted:`shifted`,respectMotion:!0},Y=class extends P{constructor(e,t={}){super(e,t);let{onShifted:n,events:r,boundaries:i,respectMotion:a}=Object.assign({},J,t);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()}shift=async()=>{if(!this.visible)return;this.dispatch(`shift`);let e=this.overflowRect(this.element.getBoundingClientRect(),this.elementTranslations(this.element)),t=e.left||e.right||0,n=e.top||e.bottom||0;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})};overflowRect(e,t){let n={},r=A(),i=k({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height});for(let e of this.boundaries){let t=this.directionDistance(i,e,r),a=O[e];t<0?i[a]+t>=r[a]&&!n[a]&&(n[e]=t):n[e]=``}return n}directionDistance(e,t,n){switch(t){case`top`:case`left`:return e[t]-n[t];case`bottom`:case`right`:return n[t]-e[t];default:throw`Invalid direction to calcuate distance, ${t}`}}elementTranslations(e){let t=window.getComputedStyle(e),n=t.transform||t.webkitTransform||t.mozTransform;if(n===`none`||n===void 0)return{x:0,y:0};let r=n.includes(`3d`)?`3d`:`2d`,i=n.match(/matrix.*\((.+)\)/)[1].split(`, `);return r===`2d`?{x:Number(i[4]),y:Number(i[5])}:{x:0,y:0}}observe(){this.events.forEach(e=>{window.addEventListener(e,this.shift,!0)})}unobserve(){this.events.forEach(e=>{window.removeEventListener(e,this.shift,!0)})}enhance(){let e=this,t=e.controller.disconnect.bind(e.controller);Object.assign(this.controller,{disconnect:()=>{e.unobserve(),t()},shift:e.shift.bind(e)})}},X=(e,t)=>new Y(e,t),Z={visibility:`visibility`,onShown:`shown`,onHidden:`hidden`},ne=class extends P{constructor(e,t={}){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`;(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))}isVisible(e){if(!(e instanceof HTMLElement))return!1;let t=D.hiddenClass;return t?!e.classList.contains(t):!e.hasAttribute(`hidden`)}toggle(e,t){if(!(e instanceof HTMLElement))return;let n=D.hiddenClass;n?t?e.classList.remove(n):e.classList.add(n):t?e.removeAttribute(`hidden`):e.setAttribute(`hidden`,!0)}activate(e){this.activator&&this.activator.setAttribute(`aria-expanded`,e?`true`:`false`)}async show(){!(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`))}async hide(){!(this.element instanceof HTMLElement)||!this.isVisible(this.element)||(this.dispatch(`hide`),this.toggle(this.element,!1),this.activate(!1),await this.awaitCallback(this.onHidden,{target:this.element}),this.dispatch(`hidden`))}enhance(){let e=this,t={show:e.show.bind(e),hide:e.hide.bind(e)};Object.defineProperty(t,`visible`,{get(){return e.isVisible(e.element)}}),Object.defineProperty(t,this.visibilityResolver,{value:e.isVisible.bind(e)}),Object.defineProperty(this.controller,this.visibility,{get(){return t}})}},Q=(e,t)=>new ne(e,t),re=class extends t.Controller{static targets=[`modal`,`overlay`];connect(){if(!this.hasModalTarget){console.error(`ModalController requires a modal target. Add data-modal-target="modal" to your element.`);return}this.isNativeDialog=this.modalTarget instanceof HTMLDialogElement,this.isNativeDialog?(this.modalTarget.addEventListener(`cancel`,this.close),this.modalTarget.addEventListener(`click`,this.handleBackdropClick)):(this.focusTrap=new o(this.modalTarget,{escapeDeactivates:!0}),W(this,{element:this.modalTarget}))}dismissed=()=>{this.close()};disconnect(){this.isNativeDialog&&(this.modalTarget.removeEventListener(`cancel`,this.close),this.modalTarget.removeEventListener(`click`,this.handleBackdropClick))}open(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.previouslyFocused=document.activeElement,this.modalTarget.showModal();else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!1,document.body.style.overflow=`hidden`,this.focusTrap&&this.focusTrap.activate()}m(`Modal opened`)}}close(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.modalTarget.close(),this.previouslyFocused&&this.previouslyFocused.isConnected&&setTimeout(()=>{this.previouslyFocused.focus()},0);else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!0,document.body.style.overflow=``,this.focusTrap&&this.focusTrap.deactivate()}m(`Modal closed`)}}handleBackdropClick=e=>{let t=this.modalTarget.getBoundingClientRect();(e.clientY<t.top||e.clientY>t.bottom||e.clientX<t.left||e.clientX>t.right)&&this.close()}},ie=class extends t.Controller{static targets=[`trigger`];connect(){W(this,{trigger:this.hasTriggerTarget?this.triggerTarget:null})}},ae=class extends t.Controller{static targets=[`anchor`,`reference`];static values={placement:{type:String,default:`bottom`},alignment:{type:String,default:`start`},role:{type:String,default:`tooltip`}};connect(){if(!this.hasReferenceTarget){console.error(`FlipperController requires a reference target. Add data-flipper-target="reference" to your element.`);return}if(!this.hasAnchorTarget){console.error(`FlipperController requires an anchor target. Add data-flipper-target="anchor" to your element.`);return}q(this,{element:this.referenceTarget,anchor:this.anchorTarget,placement:this.placementValue,alignment:this.alignmentValue,ariaRole:this.roleValue})}},oe=class extends t.Controller{static targets=[`content`,`template`,`loader`,`activator`];static classes=[`hidden`];static values={url:String,loadedAt:String,reload:{type:String,default:`never`},staleAfter:{type:Number,default:3600}};connect(){V(this,{element:this.hasContentTarget?this.contentTarget:null,url:this.hasUrlValue?this.urlValue:null}),this.hasContentTarget&&Q(this,{element:this.contentTarget,activator:this.hasActivatorTarget?this.activatorTarget:null}),this.hasLoaderTarget&&Q(this,{element:this.loaderTarget,visibility:`contentLoaderVisibility`})}async show(){await this.visibility.show()}async hide(){await this.visibility.hide()}async shown(){await this.load()}contentLoad(){return this.hasContentTarget&&this.contentTarget.tagName.toLowerCase()===`turbo-frame`?(this.hasUrlValue&&this.contentTarget.setAttribute(`src`,this.urlValue),!1):!0}async contentLoading(){this.hasLoaderTarget&&await this.contentLoaderVisibility.show()}async contentLoaded({content:e}){this.hasContentTarget&&this.contentTarget.replaceChildren(this.getContentNode(e)),this.hasLoaderTarget&&await this.contentLoaderVisibility.hide()}getContentNode(e){if(typeof e==`string`){let t=document.createElement(`template`);return t.innerHTML=e,document.importNode(t.content,!0)}return document.importNode(e,!0)}contentLoader(){if(this.hasTemplateTarget)return this.templateTarget instanceof HTMLTemplateElement?this.templateTarget.content:this.templateTarget.innerHTML}},$=class extends t.Controller{static targets=[`daysOfWeek`,`daysOfMonth`];static classes=[`dayOfWeek`,`dayOfMonth`];static values={locales:{type:Array,default:[`default`]},weekdayFormat:{type:String,default:`short`},dayFormat:{type:String,default:`numeric`},daysOfOtherMonth:{type:Boolean,default:!1}};initialize(){R(this)}connect(){this.draw()}navigated(){this.draw()}draw(){this.drawDaysOfWeek(),this.drawDaysOfMonth()}createDayElement(e,{selectable:t=!1,disabled:n=!1}={}){let r=document.createElement(t?`button`:`div`);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}drawDaysOfWeek(){if(!this.hasDaysOfWeekTarget)return;let e=new Intl.DateTimeFormat(this.localesValue,{weekday:this.weekdayFormatValue}),t=[];for(let n of this.calendar.daysOfWeek){let r=this.createDayElement(e.format(n.date));r.setAttribute(`role`,`columnheader`),r.title=n.long,this.hasDayOfWeekClass&&r.classList.add(...this.dayOfWeekClasses),t.push(r)}let n=document.createElement(`div`);n.setAttribute(`role`,`row`),n.replaceChildren(...t),this.daysOfWeekTarget.replaceChildren(n)}drawDaysOfMonth(){if(!this.hasDaysOfMonthTarget)return;let e=this.calendar.today,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),n=[];for(let e of this.calendar.daysOfMonth){let r=!e.current||this.calendar.isDisabled(e.date)||!this.calendar.isWithinRange(e.date),i=e.current||this.daysOfOtherMonthValue?e.value:``,a=this.createDayElement(i,{selectable:e.current,disabled:r});t===e.date.getTime()&&a.setAttribute(`aria-current`,`date`),this.hasDayOfMonthClass&&a.classList.add(...this.dayOfMonthClasses);let o=document.createElement(`time`);o.dateTime=e.iso,a.appendChild(o),n.push(a)}let r=[];for(let e=0;e<n.length;e+=7){let t=document.createElement(`div`);t.setAttribute(`role`,`row`);for(let r of n.slice(e,e+7))r.setAttribute(`role`,`gridcell`),t.appendChild(r);r.push(t)}this.daysOfMonthTarget.replaceChildren(...r)}},se=class extends t.Controller{select(e){if(!(e.target instanceof HTMLElement))return;e.preventDefault();let t=e.target instanceof HTMLTimeElement?e.target.parentElement:e.target;if(t.disabled||t.getAttribute(`aria-disabled`)===`true`)return;this.dispatch(`select`,{target:t});let n=e.target instanceof HTMLTimeElement?e.target:e.target.querySelector(`time`);if(!n)return console.error(`unable to locate time element within ${t}`);let r=N(n.dateTime);if(!r)return console.error(`unable to parse ${n.dateTime} found within the time element`);this.dispatch(`selected`,{target:t,detail:{epoch:r.getTime(),iso:r.toISOString()}})}},ce=class extends t.Controller{static targets=[`previous`,`next`,`day`,`month`,`year`,`input`,`display`];static outlets=[`calendar-month`];static values={locales:{type:Array,default:[`default`]},dayFormat:{type:String,default:`numeric`},monthFormat:{type:String,default:`long`},yearFormat:{type:String,default:`numeric`}};initialize(){this.previous=this.previous.bind(this),this.next=this.next.bind(this)}async calendarMonthOutletConnected(){if(this.hasInputTarget&&this.inputTarget.value){let e=N(this.inputTarget.value);e&&await this.calendarMonthOutlet.calendar.navigate(e)}this.draw()}selected(e){this.hasInputTarget&&(this.inputTarget.value=e.detail.iso),this.hasDisplayTarget&&(this.displayTarget.value=this.formatDate(new Date(e.detail.iso)))}formatDate(e){return new Intl.DateTimeFormat(this.localesValue,{day:this.dayFormatValue,month:this.monthFormatValue,year:this.yearFormatValue}).format(e)}previousTargetConnected(e){e.addEventListener(`click`,this.previous)}previousTargetDisconnected(e){e.removeEventListener(`click`,this.previous)}async previous(){await this.calendarMonthOutlet.calendar.step(`month`,-1),this.draw()}nextTargetConnected(e){e.addEventListener(`click`,this.next)}nextTargetDisconnected(e){e.removeEventListener(`click`,this.next)}async next(){await this.calendarMonthOutlet.calendar.step(`month`,1),this.draw()}draw(){this.drawDay(),this.drawMonth(),this.drawYear()}drawDay(){if(!this.hasDayTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t,day:n}=this.calendarMonthOutlet.calendar,r=new Intl.DateTimeFormat(this.localesValue,{day:this.dayFormatValue});this.dayTarget.textContent=r.format(new Date(e,t,n))}drawMonth(){if(!this.hasMonthTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t}=this.calendarMonthOutlet.calendar,n=new Intl.DateTimeFormat(this.localesValue,{month:this.monthFormatValue});this.monthTarget.textContent=n.format(new Date(e,t))}drawYear(){if(!this.hasYearTarget||!this.hasCalendarMonthOutlet)return;let{year:e}=this.calendarMonthOutlet.calendar,t=new Intl.DateTimeFormat(this.localesValue,{year:this.yearFormatValue});this.yearTarget.textContent=t.format(new Date(e,0))}},le=class extends t.Controller{static targets=[`content`];connect(){X(this,{element:this.hasContentTarget?this.contentTarget:null})}};e.ARIA_HASPOPUP_VALUES=S,e.CalendarMonthController=$,e.CalendarMonthObserverController=se,e.DatepickerController=ce,e.DismisserController=ie,e.FOCUSABLE_SELECTOR=n,e.FlipperController=ae,e.FocusRestoration=s,e.FocusTrap=o,e.ModalController=re,e.PannerController=le,e.PopoverController=oe,e.RovingTabIndex=f,e.announce=m,e.connectTriggerToTarget=T,e.disconnectTriggerFromTarget=ee,e.ensureId=g,e.focusFirst=a,e.generateId=h,e.getFocusableElements=r,e.isActivationKey=l,e.isArrowKey=u,e.isKey=c,e.isVisible=i,e.preventDefault=d,e.setAriaState=_,e.setChecked=b,e.setDisabled=x,e.setExpanded=v,e.setPressed=y});
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusPlumbers
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_plumbers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Chang
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -40,6 +39,8 @@ extra_rdoc_files: []
40
39
  files:
41
40
  - README.md
42
41
  - app/assets/javascripts/stimulus-plumbers/.keep
42
+ - app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js
43
+ - app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js
43
44
  - app/assets/stylesheets/stimulus_plumbers/tokens.css
44
45
  - lib/stimulus_plumbers.rb
45
46
  - lib/stimulus_plumbers/components/action_list/renderer.rb
@@ -107,7 +108,6 @@ metadata:
107
108
  changelog_uri: https://github.com/ryancyq/stimulus-plumbers/blob/main/CHANGELOG.md
108
109
  homepage_uri: https://github.com/ryancyq/stimulus-plumbers
109
110
  source_code_uri: https://github.com/ryancyq/stimulus-plumbers/tree/main/stimulus-plumbers-rails
110
- post_install_message:
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib
@@ -122,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  - !ruby/object:Gem::Version
123
123
  version: 3.2.0
124
124
  requirements: []
125
- rubygems_version: 3.5.22
126
- signing_key:
125
+ rubygems_version: 3.6.9
127
126
  specification_version: 4
128
127
  summary: Accessible ActionView components for Rails with Stimulus controllers
129
128
  test_files: []