stimulus_plumbers 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/README.md +60 -41
  4. data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +760 -237
  5. data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
  6. data/lib/stimulus_plumbers/components/action_list/item.rb +27 -0
  7. data/lib/stimulus_plumbers/components/action_list/section.rb +21 -0
  8. data/lib/stimulus_plumbers/components/action_list.rb +23 -0
  9. data/lib/stimulus_plumbers/components/avatar.rb +72 -0
  10. data/lib/stimulus_plumbers/components/button/group.rb +17 -0
  11. data/lib/stimulus_plumbers/components/button.rb +27 -0
  12. data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +2 -2
  13. data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +2 -2
  14. data/lib/stimulus_plumbers/components/calendar/month/turbo.rb +55 -0
  15. data/lib/stimulus_plumbers/components/calendar.rb +33 -0
  16. data/lib/stimulus_plumbers/components/card/section.rb +25 -0
  17. data/lib/stimulus_plumbers/components/card.rb +27 -0
  18. data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +53 -0
  19. data/lib/stimulus_plumbers/components/combobox/date.rb +50 -0
  20. data/lib/stimulus_plumbers/components/combobox/dropdown.rb +38 -0
  21. data/lib/stimulus_plumbers/components/combobox/options/option.rb +34 -0
  22. data/lib/stimulus_plumbers/components/combobox/options/option_group.rb +29 -0
  23. data/lib/stimulus_plumbers/components/combobox/options.rb +59 -0
  24. data/lib/stimulus_plumbers/components/combobox/popover.rb +20 -0
  25. data/lib/stimulus_plumbers/components/combobox/time/drum.rb +37 -0
  26. data/lib/stimulus_plumbers/components/combobox/time.rb +120 -0
  27. data/lib/stimulus_plumbers/components/combobox/trigger.rb +38 -0
  28. data/lib/stimulus_plumbers/components/combobox.rb +59 -0
  29. data/lib/stimulus_plumbers/components/date_picker/navigation.rb +1 -1
  30. data/lib/stimulus_plumbers/components/date_picker/navigator.rb +1 -1
  31. data/lib/stimulus_plumbers/components/icon.rb +49 -0
  32. data/lib/stimulus_plumbers/components/popover/builder.rb +25 -0
  33. data/lib/stimulus_plumbers/components/popover.rb +26 -0
  34. data/lib/stimulus_plumbers/form/builder.rb +64 -17
  35. data/lib/stimulus_plumbers/form/{field_component.rb → field.rb} +13 -11
  36. data/lib/stimulus_plumbers/form/fields/combobox.rb +41 -0
  37. data/lib/stimulus_plumbers/form/fields/error.rb +14 -0
  38. data/lib/stimulus_plumbers/form/fields/group.rb +14 -0
  39. data/lib/stimulus_plumbers/form/fields/hint.rb +14 -0
  40. data/lib/stimulus_plumbers/form/fields/label.rb +21 -0
  41. data/lib/stimulus_plumbers/form/fields/password.rb +55 -0
  42. data/lib/stimulus_plumbers/form/fields/renderer.rb +16 -21
  43. data/lib/stimulus_plumbers/form/fields/search.rb +54 -0
  44. data/lib/stimulus_plumbers/form/fields/select.rb +8 -2
  45. data/lib/stimulus_plumbers/form/fields/submit.rb +23 -0
  46. data/lib/stimulus_plumbers/form/fields/text.rb +12 -4
  47. data/lib/stimulus_plumbers/helpers/action_list_helper.rb +2 -2
  48. data/lib/stimulus_plumbers/helpers/avatar_helper.rb +2 -2
  49. data/lib/stimulus_plumbers/helpers/button_helper.rb +2 -2
  50. data/lib/stimulus_plumbers/helpers/calendar_helper.rb +1 -1
  51. data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +1 -1
  52. data/lib/stimulus_plumbers/helpers/card_helper.rb +2 -2
  53. data/lib/stimulus_plumbers/helpers/combobox_helper.rb +74 -0
  54. data/lib/stimulus_plumbers/helpers/popover_helper.rb +2 -2
  55. data/lib/stimulus_plumbers/helpers.rb +2 -2
  56. data/lib/stimulus_plumbers/plumber/base.rb +20 -0
  57. data/lib/stimulus_plumbers/plumber/dispatcher.rb +111 -0
  58. data/lib/stimulus_plumbers/plumber/html_options.rb +51 -0
  59. data/lib/stimulus_plumbers/plumber/renderer.rb +89 -0
  60. data/lib/stimulus_plumbers/themes/base.rb +9 -15
  61. data/lib/stimulus_plumbers/themes/schema/ranges.rb +5 -5
  62. data/lib/stimulus_plumbers/themes/schema.rb +97 -0
  63. data/lib/stimulus_plumbers/themes/tailwind/calendar.rb +48 -2
  64. data/lib/stimulus_plumbers/themes/tailwind/combobox.rb +75 -0
  65. data/lib/stimulus_plumbers/themes/tailwind/form.rb +10 -6
  66. data/lib/stimulus_plumbers/themes/tailwind_theme.rb +2 -0
  67. data/lib/stimulus_plumbers/version.rb +1 -1
  68. data/lib/stimulus_plumbers.rb +41 -14
  69. metadata +42 -23
  70. data/lib/stimulus_plumbers/components/action_list/renderer.rb +0 -47
  71. data/lib/stimulus_plumbers/components/avatar/renderer.rb +0 -74
  72. data/lib/stimulus_plumbers/components/button/renderer.rb +0 -33
  73. data/lib/stimulus_plumbers/components/calendar/month/turbo/renderer.rb +0 -57
  74. data/lib/stimulus_plumbers/components/calendar/renderer.rb +0 -35
  75. data/lib/stimulus_plumbers/components/card/renderer.rb +0 -41
  76. data/lib/stimulus_plumbers/components/date_picker/renderer.rb +0 -82
  77. data/lib/stimulus_plumbers/components/icon/renderer.rb +0 -51
  78. data/lib/stimulus_plumbers/components/plumber/base.rb +0 -22
  79. data/lib/stimulus_plumbers/components/plumber/dispatcher.rb +0 -113
  80. data/lib/stimulus_plumbers/components/plumber/html_options.rb +0 -34
  81. data/lib/stimulus_plumbers/components/plumber/renderer.rb +0 -91
  82. data/lib/stimulus_plumbers/components/popover/renderer.rb +0 -46
  83. data/lib/stimulus_plumbers/helpers/date_picker_helper.rb +0 -17
  84. data/lib/stimulus_plumbers/themes/action_list.rb +0 -14
  85. data/lib/stimulus_plumbers/themes/avatar.rb +0 -14
  86. data/lib/stimulus_plumbers/themes/button.rb +0 -18
  87. data/lib/stimulus_plumbers/themes/calendar.rb +0 -15
  88. data/lib/stimulus_plumbers/themes/card.rb +0 -12
  89. data/lib/stimulus_plumbers/themes/form.rb +0 -30
  90. data/lib/stimulus_plumbers/themes/layout.rb +0 -12
@@ -124,8 +124,8 @@ 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), y = (e, t) => g(e, "aria-checked", t);
128
- function ee(e, t) {
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 y(e, t) {
129
129
  g(e, "aria-disabled", t), t ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex");
130
130
  }
131
131
  var b = {
@@ -157,7 +157,7 @@ var w = (e, t) => {
157
157
  e.hasAttribute(t) && e.removeAttribute(t);
158
158
  });
159
159
  };
160
- function T({ trigger: e, target: t, attributes: n = null }) {
160
+ function te({ trigger: e, target: t, attributes: n = null }) {
161
161
  !e || !t || (w(e, n || [
162
162
  "aria-controls",
163
163
  "aria-haspopup",
@@ -166,12 +166,12 @@ function T({ trigger: e, target: t, attributes: n = null }) {
166
166
  }
167
167
  //#endregion
168
168
  //#region src/plumbers/plumber/support.js
169
- var E = {
169
+ var T = {
170
170
  get visibleOnly() {
171
171
  return !0;
172
172
  },
173
173
  hiddenClass: null
174
- }, D = {
174
+ }, E = {
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 O({ x: e, y: t, width: n, height: r }) {
188
+ function D({ 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 k() {
201
- return O({
200
+ function O() {
201
+ return D({
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 A(e) {
208
+ function ne(e) {
209
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;
210
+ let t = O(), n = e.getBoundingClientRect(), r = n.top <= t.height && n.top + n.height > 0, i = n.left <= t.width && n.left + n.width > 0;
211
211
  return r && i;
212
212
  }
213
- function j(e) {
213
+ function k(e) {
214
214
  return e instanceof Date && !isNaN(e);
215
215
  }
216
- function M(...e) {
216
+ function A(...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] && j(t)) return t;
220
+ if (e[0] && k(t)) return t;
221
221
  } else {
222
222
  let t = new Date(...e);
223
- if (j(t)) return t;
223
+ if (k(t)) return t;
224
224
  }
225
225
  }
226
226
  //#endregion
227
227
  //#region src/plumbers/plumber/index.js
228
- var N = {
228
+ var j = {
229
229
  element: null,
230
230
  visible: null,
231
231
  dispatch: !0,
232
232
  prefix: ""
233
- }, P = class {
233
+ }, M = class {
234
234
  constructor(e, t = {}) {
235
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;
236
+ let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({}, j, t);
237
+ this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r : T.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 ? A(this.element) && this.isVisible(this.element) : !0 : !1;
240
+ return this.element instanceof HTMLElement ? this.visibleOnly ? ne(this.element) && this.isVisible(this.element) : !0 : !1;
241
241
  }
242
242
  isVisible(e) {
243
243
  if (this.visibleCallback) {
@@ -266,7 +266,196 @@ var N = {
266
266
  return n instanceof Promise ? await n : n;
267
267
  }
268
268
  }
269
- }, F = 7, I = {
269
+ }, re = {
270
+ normalize(e) {
271
+ return typeof e == "string" ? e : "";
272
+ },
273
+ validate() {
274
+ return !0;
275
+ }
276
+ };
277
+ //#endregion
278
+ //#region src/plumbers/formatters/credit_card.js
279
+ function ie(e) {
280
+ let t = 0, n = !1;
281
+ for (let r = e.length - 1; r >= 0; r--) {
282
+ let i = parseInt(e[r], 10);
283
+ n && (i *= 2, i > 9 && (i -= 9)), t += i, n = !n;
284
+ }
285
+ return t % 10 == 0;
286
+ }
287
+ var ae = /\D/g, oe = /^\d{13,19}$/, se = /(.{4})(?=.)/g, ce = {
288
+ normalize(e) {
289
+ return typeof e == "string" ? e.replace(ae, "") : "";
290
+ },
291
+ validate(e) {
292
+ return typeof e != "string" || !oe.test(e) ? !1 : ie(e);
293
+ },
294
+ format(e) {
295
+ return typeof e == "string" ? e.replace(se, "$1 ") : "";
296
+ }
297
+ }, N = { 1: 10 }, P = /\D/g, le = /^\+\d{7,15}$/, ue = {
298
+ normalize(e) {
299
+ if (typeof e != "string") return "";
300
+ let t = e.trimStart().startsWith("+"), n = e.replace(P, "");
301
+ return t ? `+${n}` : n;
302
+ },
303
+ validate(e) {
304
+ if (typeof e != "string") return !1;
305
+ if (le.test(e)) return !0;
306
+ let t = e.replace(P, "");
307
+ return Object.values(N).includes(t.length);
308
+ },
309
+ format(e) {
310
+ if (typeof e != "string") return "";
311
+ let t = e.replace(P, "");
312
+ for (let [e, n] of Object.entries(N)) {
313
+ if (t.length === n) return `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6)}`;
314
+ let r = n + e.length;
315
+ if (t.length === r && t.startsWith(e)) {
316
+ let n = t.slice(e.length);
317
+ return `+${e} (${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
318
+ }
319
+ }
320
+ return e;
321
+ }
322
+ }, de = /[^\d.,-]/g, fe = /^-?\d+(\.\d+)?$/, F = {
323
+ normalize(e) {
324
+ if (typeof e != "string") return "";
325
+ let t = e.replace(de, "");
326
+ if (!t) return "";
327
+ let n = t.lastIndexOf(","), r = t.lastIndexOf(".");
328
+ 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;
329
+ },
330
+ validate(e) {
331
+ return typeof e == "string" ? fe.test(e) : !1;
332
+ },
333
+ format(e, t = {}) {
334
+ if (typeof e != "string") return "";
335
+ let n = parseFloat(e);
336
+ if (isNaN(n)) return e;
337
+ let r = t.locale || "en-US", i = t.currency || "USD", a = t.fractionDigits === void 0 ? {} : {
338
+ minimumFractionDigits: t.fractionDigits,
339
+ maximumFractionDigits: t.fractionDigits
340
+ };
341
+ try {
342
+ return new Intl.NumberFormat(r, {
343
+ style: "currency",
344
+ currency: i,
345
+ ...a
346
+ }).format(n);
347
+ } catch {
348
+ return e;
349
+ }
350
+ }
351
+ }, I = /^\d{4}-\d{2}-\d{2}$/, L = /^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/, R = /\D/g, z = {
352
+ normalize(e) {
353
+ if (typeof e != "string") return "";
354
+ let t = e.trim();
355
+ if (I.test(t)) return t;
356
+ let n = t.match(L);
357
+ if (n) {
358
+ let [, e, t, r] = n;
359
+ if (e.length === 4) return `${e}-${t.padStart(2, "0")}-${r.padStart(2, "0")}`;
360
+ if (r.length === 4) return `${r}-${e.padStart(2, "0")}-${t.padStart(2, "0")}`;
361
+ }
362
+ let r = t.replace(R, "");
363
+ if (r.length === 8) {
364
+ let e = parseInt(r.slice(0, 4), 10);
365
+ 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)}`;
366
+ }
367
+ return t;
368
+ },
369
+ validate(e) {
370
+ if (typeof e != "string") return !1;
371
+ let t = z.normalize(e);
372
+ if (!I.test(t)) return !1;
373
+ let n = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
374
+ return !isNaN(n.getTime()) && n.toISOString().startsWith(t);
375
+ },
376
+ format(e, t = {}) {
377
+ if (typeof e != "string") return "";
378
+ let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
379
+ if (isNaN(n.getTime())) return e;
380
+ let r = t.locale || "en-US";
381
+ try {
382
+ return new Intl.DateTimeFormat(r, {
383
+ year: t.year || "numeric",
384
+ month: t.month || "2-digit",
385
+ day: t.day || "2-digit",
386
+ timeZone: t.timeZone || "UTC"
387
+ }).format(n);
388
+ } catch {
389
+ return e;
390
+ }
391
+ }
392
+ }, B = /^([01]?\d|2[0-3]):([0-5]\d)$/, V = {
393
+ normalize(e) {
394
+ if (typeof e != "string") return "";
395
+ let t = e.trim();
396
+ if (B.test(t)) {
397
+ let [e, n] = t.split(":");
398
+ return `${String(parseInt(e, 10)).padStart(2, "0")}:${n}`;
399
+ }
400
+ let n = t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
401
+ if (n) {
402
+ let e = parseInt(n[1], 10), t = n[2];
403
+ 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}`;
404
+ }
405
+ return "";
406
+ },
407
+ validate(e) {
408
+ return V.normalize(e) !== "";
409
+ },
410
+ format(e, t = {}) {
411
+ if (typeof e != "string") return "";
412
+ let n = e.match(/^(\d{2}):(\d{2})$/);
413
+ if (!n) return e;
414
+ let r = parseInt(n[1], 10), i = n[2];
415
+ if (t.format === "h24") return `${String(r).padStart(2, "0")}:${i}`;
416
+ let a = r < 12 ? "AM" : "PM";
417
+ return `${r % 12 || 12}:${i} ${a}`;
418
+ }
419
+ }, H = {
420
+ PLAIN: "plain",
421
+ CREDIT_CARD: "creditCard",
422
+ PHONE: "phone",
423
+ CURRENCY: "currency",
424
+ DATE: "date",
425
+ TIME: "time"
426
+ }, U = new Map([
427
+ [H.PLAIN, re],
428
+ [H.CREDIT_CARD, ce],
429
+ [H.PHONE, ue],
430
+ [H.CURRENCY, F],
431
+ [H.DATE, z],
432
+ [H.TIME, V]
433
+ ]), W = {
434
+ type: H.PLAIN,
435
+ options: {}
436
+ }, G = class extends M {
437
+ static register(e, t) {
438
+ U.set(e, t);
439
+ }
440
+ constructor(e, t = {}) {
441
+ super(e, t), this.type = t.type ?? W.type, this.options = t.options ?? W.options, this.enhance();
442
+ }
443
+ enhance() {
444
+ let e = this, t = U.get(e.type) ?? U.get(H.PLAIN), n = {
445
+ normalize: (n) => t.normalize?.(n, e.options) ?? (typeof n == "string" ? n : ""),
446
+ validate: (n) => t.validate?.(n, e.options) ?? !0,
447
+ format: (n) => t.format?.(n, e.options) ?? (typeof n == "string" ? n : ""),
448
+ mask: (n) => t.mask?.(n, e.options) ?? null,
449
+ maskable: () => typeof t.mask == "function"
450
+ };
451
+ Object.defineProperty(this.controller, "formatter", {
452
+ get() {
453
+ return n;
454
+ },
455
+ configurable: !0
456
+ });
457
+ }
458
+ }, K = (e, t) => new G(e, t), q = 7, J = {
270
459
  locales: ["default"],
271
460
  today: "",
272
461
  day: null,
@@ -281,15 +470,15 @@ var N = {
281
470
  disabledYears: [],
282
471
  firstDayOfWeek: 0,
283
472
  onNavigated: "navigated"
284
- }, L = class extends P {
473
+ }, pe = class extends M {
285
474
  constructor(e, t = {}) {
286
475
  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;
476
+ let n = Object.assign({}, J, t), { onNavigated: r, since: i, till: a, firstDayOfWeek: o } = n;
477
+ this.onNavigated = r, this.since = A(i), this.till = A(a), this.firstDayOfWeek = 0 <= o && o < 7 ? o : J.firstDayOfWeek;
289
478
  let { disabledDates: s, disabledWeekdays: c, disabledDays: l, disabledMonths: u, disabledYears: d } = n;
290
479
  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
480
  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();
481
+ this.now = A(f) || /* @__PURE__ */ new Date(), typeof h == "number" && typeof m == "number" && typeof p == "number" ? this.current = A(h, m, p) : this.current = this.now, this.build(), this.enhance();
293
482
  }
294
483
  build() {
295
484
  this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear();
@@ -325,7 +514,7 @@ var N = {
325
514
  let a = new Date(t, e, i);
326
515
  n.push(r(a));
327
516
  }
328
- let s = n.length % F, c = s === 0 ? 0 : F - s;
517
+ let s = n.length % q, c = s === 0 ? 0 : q - s;
329
518
  for (let i = 1; i <= c; i++) {
330
519
  let a = new Date(t, e + 1, i);
331
520
  n.push(r(a));
@@ -350,18 +539,18 @@ var N = {
350
539
  return this.now;
351
540
  }
352
541
  set today(e) {
353
- if (!j(e)) return;
542
+ if (!k(e)) return;
354
543
  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
544
  this.now = new Date(n, t, i).toISOString();
356
545
  }
357
546
  get current() {
358
- return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? M(this.year, this.month, this.day) : null;
547
+ return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? A(this.year, this.month, this.day) : null;
359
548
  }
360
549
  set current(e) {
361
- j(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
550
+ k(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
362
551
  }
363
552
  navigate = async (e) => {
364
- if (!j(e)) return;
553
+ if (!k(e)) return;
365
554
  let t = this.current, n = e.toISOString(), r = t.toISOString();
366
555
  this.dispatch("navigate", { detail: {
367
556
  from: r,
@@ -392,7 +581,7 @@ var N = {
392
581
  await this.navigate(n);
393
582
  };
394
583
  isDisabled = (e) => {
395
- if (!j(e)) return !1;
584
+ if (!k(e)) return !1;
396
585
  if (this.disabledDates.length) {
397
586
  let t = e.getTime();
398
587
  for (let e of this.disabledDates) if (t === new Date(e).getTime()) return !0;
@@ -422,7 +611,7 @@ var N = {
422
611
  return !1;
423
612
  };
424
613
  isWithinRange = (e) => {
425
- if (!j(e)) return !1;
614
+ if (!k(e)) return !1;
426
615
  let t = !0;
427
616
  return this.since && (t &&= e >= this.since), this.till && (t &&= e <= this.till), t;
428
617
  };
@@ -485,19 +674,61 @@ var N = {
485
674
  };
486
675
  } });
487
676
  }
488
- }, R = (e, t) => new L(e, t), z = {
677
+ }, me = (e, t) => new pe(e, t), he = class extends M {
678
+ constructor(e, t = {}) {
679
+ super(e, t), this.debounceTimer = null, this.abortController = null;
680
+ }
681
+ fuzzyFilter(e, t) {
682
+ let n = t.toLowerCase(), r = 0;
683
+ return e.querySelectorAll("[role=\"option\"]").forEach((e) => {
684
+ let t = this.fuzzyMatch(n, e.textContent.trim().toLowerCase());
685
+ e.hidden = !t, t && r++;
686
+ }), r;
687
+ }
688
+ fuzzyMatch(e, t) {
689
+ let n = 0;
690
+ for (let r = 0; r < t.length && n < e.length; r++) t[r] === e[n] && n++;
691
+ return n === e.length;
692
+ }
693
+ scheduleFetch(e, t, n) {
694
+ clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => this.fetch(e, n), t);
695
+ }
696
+ async fetch(e, { url: t, field: n, onLoading: r, onLoaded: i, onError: a }) {
697
+ this.abortController?.abort(), this.abortController = new AbortController(), r?.(!0);
698
+ let o = new URL(t, window.location.href);
699
+ o.searchParams.set(n, e);
700
+ try {
701
+ let e = await fetch(o, {
702
+ signal: this.abortController.signal,
703
+ headers: {
704
+ Accept: "text/html",
705
+ "X-Requested-With": "XMLHttpRequest"
706
+ }
707
+ });
708
+ if (!e.ok) throw Error(`${e.status}`);
709
+ i?.(await e.text());
710
+ } catch (e) {
711
+ e.name !== "AbortError" && a?.(e);
712
+ } finally {
713
+ r?.(!1);
714
+ }
715
+ }
716
+ cancel() {
717
+ clearTimeout(this.debounceTimer), this.abortController?.abort();
718
+ }
719
+ }, ge = (e, t) => new he(e, t), Y = {
489
720
  content: null,
490
721
  url: "",
491
722
  reload: "never",
492
723
  stale: 3600,
493
- onLoad: "contentLoad",
724
+ onLoad: "canLoad",
494
725
  onLoading: "contentLoading",
495
726
  onLoaded: "contentLoaded"
496
- }, B = class extends P {
727
+ }, _e = class extends M {
497
728
  constructor(e, t = {}) {
498
729
  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;
730
+ let n = Object.assign({}, Y, t), { content: r, url: i, reload: a, stale: o } = n;
731
+ this.content = r, this.url = i, this.reload = typeof a == "string" ? a : Y.reload, this.stale = typeof o == "number" ? o : Y.stale;
501
732
  let { onLoad: s, onLoading: c, onLoaded: l } = n;
502
733
  this.onLoad = s, this.onLoading = c, this.onLoaded = l, this.enhance();
503
734
  }
@@ -506,7 +737,7 @@ var N = {
506
737
  case "never": return !1;
507
738
  case "always": return !0;
508
739
  default: {
509
- let e = M(this.loadedAt);
740
+ let e = A(this.loadedAt);
510
741
  return e && /* @__PURE__ */ new Date() - e > this.stale * 1e3;
511
742
  }
512
743
  }
@@ -532,14 +763,14 @@ var N = {
532
763
  let e = this;
533
764
  Object.assign(this.controller, { load: e.load.bind(e) });
534
765
  }
535
- }, V = (e, t) => new B(e, t), H = {
766
+ }, ve = (e, t) => new _e(e, t), ye = {
536
767
  trigger: null,
537
768
  events: ["click"],
538
769
  onDismissed: "dismissed"
539
- }, U = class extends P {
770
+ }, be = class extends M {
540
771
  constructor(e, t = {}) {
541
772
  super(e, t);
542
- let { trigger: n, events: r, onDismissed: i } = Object.assign({}, H, t);
773
+ let { trigger: n, events: r, onDismissed: i } = Object.assign({}, ye, t);
543
774
  this.onDismissed = i, this.trigger = n || this.element, this.events = r, this.enhance(), this.observe();
544
775
  }
545
776
  dismiss = async (e) => {
@@ -562,7 +793,7 @@ var N = {
562
793
  e.unobserve(), t();
563
794
  } });
564
795
  }
565
- }, W = (e, t) => new U(e, t), G = {
796
+ }, X = (e, t) => new be(e, t), xe = {
566
797
  anchor: null,
567
798
  events: ["click"],
568
799
  placement: "bottom",
@@ -570,10 +801,10 @@ var N = {
570
801
  onFlipped: "flipped",
571
802
  ariaRole: null,
572
803
  respectMotion: !0
573
- }, K = class extends P {
804
+ }, Se = class extends M {
574
805
  constructor(e, t = {}) {
575
806
  super(e, t);
576
- let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, G, t);
807
+ let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, xe, t);
577
808
  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
809
  trigger: this.anchor,
579
810
  target: this.element,
@@ -592,7 +823,7 @@ var N = {
592
823
  }), this.dispatch("flipped", { detail: { placement: e } });
593
824
  };
594
825
  flippedRect(e, t) {
595
- let n = this.quadrumRect(e, k()), r = [this.placement, D[this.placement]], i = {};
826
+ let n = this.quadrumRect(e, O()), r = [this.placement, E[this.placement]], i = {};
596
827
  for (; !Object.keys(i).length && r.length > 0;) {
597
828
  let a = r.shift();
598
829
  if (!this.biggerRectThan(n[a], t)) continue;
@@ -603,25 +834,25 @@ var N = {
603
834
  }
604
835
  quadrumRect(e, t) {
605
836
  return {
606
- left: O({
837
+ left: D({
607
838
  x: t.x,
608
839
  y: t.y,
609
840
  width: e.x - t.x,
610
841
  height: t.height
611
842
  }),
612
- right: O({
843
+ right: D({
613
844
  x: e.x + e.width,
614
845
  y: t.y,
615
846
  width: t.width - (e.x + e.width),
616
847
  height: t.height
617
848
  }),
618
- top: O({
849
+ top: D({
619
850
  x: t.x,
620
851
  y: t.y,
621
852
  width: t.width,
622
853
  height: e.y - t.y
623
854
  }),
624
- bottom: O({
855
+ bottom: D({
625
856
  x: t.x,
626
857
  y: e.y + e.height,
627
858
  width: t.width,
@@ -631,25 +862,25 @@ var N = {
631
862
  }
632
863
  quadrumPlacement(e, t, n) {
633
864
  switch (t) {
634
- case "top": return O({
865
+ case "top": return D({
635
866
  x: n.x,
636
867
  y: e.y - n.height,
637
868
  width: n.width,
638
869
  height: n.height
639
870
  });
640
- case "bottom": return O({
871
+ case "bottom": return D({
641
872
  x: n.x,
642
873
  y: e.y + e.height,
643
874
  width: n.width,
644
875
  height: n.height
645
876
  });
646
- case "left": return O({
877
+ case "left": return D({
647
878
  x: e.x - n.width,
648
879
  y: n.y,
649
880
  width: n.width,
650
881
  height: n.height
651
882
  });
652
- case "right": return O({
883
+ case "right": return D({
653
884
  x: e.x + e.width,
654
885
  y: n.y,
655
886
  width: n.width,
@@ -663,7 +894,7 @@ var N = {
663
894
  case "top":
664
895
  case "bottom": {
665
896
  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({
897
+ return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width), D({
667
898
  x: t,
668
899
  y: n.y,
669
900
  width: n.width,
@@ -673,7 +904,7 @@ var N = {
673
904
  case "left":
674
905
  case "right": {
675
906
  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({
907
+ return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height), D({
677
908
  x: n.x,
678
909
  y: t,
679
910
  width: n.width,
@@ -705,7 +936,7 @@ var N = {
705
936
  flip: e.flip.bind(e)
706
937
  });
707
938
  }
708
- }, q = (e, t) => new K(e, t), J = {
939
+ }, Ce = (e, t) => new Se(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
- }, Y = class extends P {
948
+ }, Te = class extends M {
718
949
  constructor(e, t = {}) {
719
950
  super(e, t);
720
- let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({}, J, t);
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 = k(), i = O({
961
+ let n = {}, r = O(), i = D({
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 = D[e];
968
+ let t = this.directionDistance(i, e, r), a = E[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
- }, X = (e, t) => new Y(e, t), Z = {
1016
+ }, Ee = (e, t) => new Te(e, t), Z = {
786
1017
  visibility: "visibility",
787
1018
  onShown: "shown",
788
1019
  onHidden: "hidden"
789
- }, Q = class extends P {
1020
+ }, De = class extends M {
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 = E.hiddenClass;
1027
+ let t = T.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 = E.hiddenClass;
1032
+ let n = T.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
- }, $ = (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 {
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
- R(this);
1077
+ me(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
- }, oe = class extends e {
1032
- select(e) {
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("select", { target: t });
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 = M(n.dateTime);
1132
+ let r = A(n.dateTime);
1041
1133
  if (!r) return console.error(`unable to parse ${n.dateTime} found within the time element`);
1042
- this.dispatch("selected", {
1043
- target: t,
1134
+ this.select(r.toISOString());
1135
+ }
1136
+ select(e) {
1137
+ let t = A(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
- epoch: r.getTime(),
1046
- iso: r.toISOString()
1047
- }
1153
+ text: t,
1154
+ types: n
1155
+ },
1156
+ bubbles: !0
1048
1157
  });
1049
1158
  }
1050
- }, se = class extends e {
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.hasInputTarget && this.inputTarget.value) {
1084
- let e = M(this.inputTarget.value);
1205
+ if (this.dateValue) {
1206
+ let e = A(this.dateValue);
1085
1207
  e && await this.calendarMonthOutlet.calendar.navigate(e);
1086
1208
  }
1087
1209
  this.draw();
1088
1210
  }
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);
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,429 @@ 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, r = new Intl.DateTimeFormat(this.localesValue, { day: this.dayFormatValue });
1123
- this.dayTarget.textContent = r.format(new Date(e, t, n));
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, n = new Intl.DateTimeFormat(this.localesValue, { month: this.monthFormatValue });
1128
- this.monthTarget.textContent = n.format(new Date(e, t));
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, t = new Intl.DateTimeFormat(this.localesValue, { year: this.yearFormatValue });
1133
- this.yearTarget.textContent = t.format(new Date(e, 0));
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 = ge(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
+ });
1134
1288
  }
1135
- }, ce = class extends e {
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
+ X(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
+ Ce(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
+ connect() {
1425
+ X(this), this.hasPopoverTarget && Q(this, {
1426
+ element: this.popoverTarget,
1427
+ activator: this.hasTriggerTarget ? this.triggerTarget : null
1428
+ });
1429
+ }
1430
+ async dismissed() {
1431
+ await this.close();
1432
+ }
1433
+ async open() {
1434
+ this.hasPopoverTarget && await this.visibility.show();
1435
+ }
1436
+ async close() {
1437
+ this.hasPopoverTarget && await this.visibility.hide();
1438
+ }
1439
+ async toggle() {
1440
+ this.visibility?.visible ? await this.close() : await this.open();
1441
+ }
1442
+ async shown() {
1443
+ this.hasPopoverTarget && i(this.popoverTarget);
1444
+ }
1445
+ async hidden() {
1446
+ this.hasTriggerTarget && this.triggerTarget.focus();
1447
+ }
1448
+ async onSelect(e) {
1449
+ e.detail?.value !== void 0 && (this.valueValue = e.detail.value), await this.close();
1450
+ }
1451
+ onInput(e) {
1452
+ if (e.target !== this.triggerTarget) return;
1453
+ let t = e.target.value.trim();
1454
+ if (t.length < this.minLengthValue) {
1455
+ this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.showAll();
1456
+ return;
1457
+ }
1458
+ this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.filter(t);
1459
+ }
1460
+ valueValueChanged(e) {
1461
+ this.hasValueTarget && (this.valueTarget.value = e), this.dispatch("changed", { detail: { value: e } });
1462
+ }
1463
+ }, Ie = class extends e {
1464
+ static targets = ["input", "toggle"];
1465
+ static values = {
1466
+ type: {
1467
+ type: String,
1468
+ default: "plain"
1469
+ },
1470
+ options: {
1471
+ type: Object,
1472
+ default: {}
1473
+ },
1474
+ revealed: {
1475
+ type: Boolean,
1476
+ default: !1
1477
+ }
1478
+ };
1479
+ connect() {
1480
+ K(this, {
1481
+ type: this.typeValue,
1482
+ options: this.optionsValue
1483
+ }), this.format(this.readValue()), this.drawToggle();
1484
+ }
1485
+ typeValueChanged() {
1486
+ this.formatter && (K(this, {
1487
+ type: this.typeValue,
1488
+ options: this.optionsValue
1489
+ }), this.format(this.readValue()), this.drawToggle());
1490
+ }
1491
+ optionsValueChanged() {
1492
+ this.formatter && (K(this, {
1493
+ type: this.typeValue,
1494
+ options: this.optionsValue
1495
+ }), this.format(this.readValue()));
1496
+ }
1497
+ revealedValueChanged() {
1498
+ this.formatter && (this.format(this.readValue()), this.drawToggle());
1499
+ }
1500
+ onChange(e) {
1501
+ this.format(e?.detail?.value ?? "");
1502
+ }
1503
+ format(e) {
1504
+ this.formatter && this.onFormatting(e);
1505
+ }
1506
+ toggle() {
1507
+ !this.formatter.maskable() && this.typeValue !== "password" || (this.revealedValue = !this.revealedValue);
1508
+ }
1509
+ onPaste(e) {
1510
+ let t = e.detail?.text ?? "";
1511
+ if (!this.formatter || !t) return;
1512
+ let n = this.formatter.normalize(t);
1513
+ this.formatter.validate(n) && this.format(n);
1514
+ }
1515
+ drawToggle() {
1516
+ if (!this.hasToggleTarget) return;
1517
+ let e = this.formatter?.maskable() || this.typeValue === "password";
1518
+ this.toggleTarget.hidden = !e, e && v(this.toggleTarget, this.revealedValue);
1519
+ }
1520
+ readValue() {
1521
+ return this.hasInputTarget ? this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value : this.inputTarget.textContent : "";
1522
+ }
1523
+ onFormatting(e) {
1524
+ if (!this.formatter) return;
1525
+ if (this.typeValue === "password") {
1526
+ this.hasInputTarget && (this.inputTarget.type = this.revealedValue ? "text" : "password");
1527
+ return;
1528
+ }
1529
+ let t = this.formatter.normalize(e), n = this.revealedValue || !this.formatter.maskable() ? this.formatter.format(t) : this.formatter.mask(t);
1530
+ this.hasInputTarget && (this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value = n : this.inputTarget.textContent = n), this.dispatch("formatted", { detail: { value: n } });
1531
+ }
1532
+ }, Le = class extends e {
1533
+ static targets = ["input", "clear"];
1534
+ initialize() {
1535
+ this.onInput = this.draw.bind(this), this.onEscape = this.handleEscape.bind(this);
1536
+ }
1537
+ connect() {
1538
+ this.draw();
1539
+ }
1540
+ inputTargetConnected(e) {
1541
+ e.addEventListener("input", this.onInput), e.addEventListener("keydown", this.onEscape);
1542
+ }
1543
+ inputTargetDisconnected(e) {
1544
+ e.removeEventListener("input", this.onInput), e.removeEventListener("keydown", this.onEscape);
1545
+ }
1546
+ clear() {
1547
+ this.hasInputTarget && (this.inputTarget.value = "", this.draw(), this.inputTarget.focus(), this.inputTarget.dispatchEvent(new Event("input", { bubbles: !0 })));
1548
+ }
1549
+ draw() {
1550
+ !this.hasInputTarget || !this.hasClearTarget || (this.clearTarget.hidden = this.inputTarget.value.length === 0);
1551
+ }
1552
+ handleEscape(e) {
1553
+ e.key === "Escape" && this.inputTarget.value !== "" && (e.preventDefault(), this.clear());
1554
+ }
1555
+ }, Re = class extends e {
1556
+ static targets = ["modal", "overlay"];
1557
+ initialize() {
1558
+ this.onCancel = this.close.bind(this);
1559
+ }
1560
+ connect() {
1561
+ this.hasModalTarget || console.error("ModalController requires a modal target. Add data-modal-target=\"modal\" to your element.");
1562
+ }
1563
+ modalTargetConnected(e) {
1564
+ this.isNativeDialog = e instanceof HTMLDialogElement, this.isNativeDialog ? (e.addEventListener("cancel", this.onCancel), e.addEventListener("click", this.onBackdropClick)) : (this.focusTrap = new a(e, { escapeDeactivates: !0 }), X(this, { element: e }));
1565
+ }
1566
+ modalTargetDisconnected(e) {
1567
+ this.isNativeDialog && (e.removeEventListener("cancel", this.onCancel), e.removeEventListener("click", this.onBackdropClick));
1568
+ }
1569
+ dismissed = () => {
1570
+ this.close();
1571
+ };
1572
+ open(e) {
1573
+ if (e && e.preventDefault(), this.hasModalTarget) {
1574
+ if (this.isNativeDialog) this.previouslyFocused = document.activeElement, this.modalTarget.showModal();
1575
+ else {
1576
+ let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
1577
+ e.hidden = !1, document.body.style.overflow = "hidden", this.focusTrap && this.focusTrap.activate();
1578
+ }
1579
+ p("Modal opened");
1580
+ }
1581
+ }
1582
+ close(e) {
1583
+ if (e && e.preventDefault(), this.hasModalTarget) {
1584
+ if (this.isNativeDialog) this.modalTarget.close(), this.previouslyFocused && this.previouslyFocused.isConnected && setTimeout(() => {
1585
+ this.previouslyFocused.focus();
1586
+ }, 0);
1587
+ else {
1588
+ let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
1589
+ e.hidden = !0, document.body.style.overflow = "", this.focusTrap && this.focusTrap.deactivate();
1590
+ }
1591
+ p("Modal closed");
1592
+ }
1593
+ }
1594
+ onBackdropClick = (e) => {
1595
+ let t = this.modalTarget.getBoundingClientRect();
1596
+ (e.clientY < t.top || e.clientY > t.bottom || e.clientX < t.left || e.clientX > t.right) && this.close();
1597
+ };
1598
+ }, ze = class extends e {
1136
1599
  static targets = ["content"];
1137
1600
  connect() {
1138
- X(this, { element: this.hasContentTarget ? this.contentTarget : null });
1601
+ Ee(this, { element: this.hasContentTarget ? this.contentTarget : null });
1602
+ }
1603
+ }, Be = class extends e {
1604
+ static targets = [
1605
+ "content",
1606
+ "template",
1607
+ "loader",
1608
+ "activator"
1609
+ ];
1610
+ static classes = ["hidden"];
1611
+ static values = {
1612
+ url: String,
1613
+ loadedAt: String,
1614
+ reload: {
1615
+ type: String,
1616
+ default: "never"
1617
+ },
1618
+ staleAfter: {
1619
+ type: Number,
1620
+ default: 3600
1621
+ }
1622
+ };
1623
+ connect() {
1624
+ ve(this, {
1625
+ element: this.hasContentTarget ? this.contentTarget : null,
1626
+ url: this.hasUrlValue ? this.urlValue : null
1627
+ }), this.hasContentTarget && Q(this, {
1628
+ element: this.contentTarget,
1629
+ activator: this.hasActivatorTarget ? this.activatorTarget : null
1630
+ }), this.hasLoaderTarget && Q(this, {
1631
+ element: this.loaderTarget,
1632
+ visibility: "contentLoaderVisibility"
1633
+ });
1634
+ }
1635
+ async show() {
1636
+ await this.visibility.show();
1637
+ }
1638
+ async hide() {
1639
+ await this.visibility.hide();
1640
+ }
1641
+ async shown() {
1642
+ await this.load();
1643
+ }
1644
+ canLoad() {
1645
+ return this.hasContentTarget && this.contentTarget.tagName.toLowerCase() === "turbo-frame" ? (this.hasUrlValue && this.contentTarget.setAttribute("src", this.urlValue), !1) : !0;
1646
+ }
1647
+ async contentLoading() {
1648
+ this.hasLoaderTarget && await this.contentLoaderVisibility.show();
1649
+ }
1650
+ async contentLoaded({ content: e }) {
1651
+ this.hasContentTarget && this.contentTarget.replaceChildren(this.getContentNode(e)), this.hasLoaderTarget && await this.contentLoaderVisibility.hide();
1652
+ }
1653
+ getContentNode(e) {
1654
+ if (typeof e == "string") {
1655
+ let t = document.createElement("template");
1656
+ return t.innerHTML = e, document.importNode(t.content, !0);
1657
+ }
1658
+ return document.importNode(e, !0);
1659
+ }
1660
+ contentLoader() {
1661
+ if (this.hasTemplateTarget) return this.templateTarget instanceof HTMLTemplateElement ? this.templateTarget.content : this.templateTarget.innerHTML;
1139
1662
  }
1140
1663
  };
1141
1664
  //#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 };
1665
+ export { b 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, H as FORMATTER_TYPES, Pe as FlipperController, o as FocusRestoration, a as FocusTrap, G as Formatter, Fe as InputComboboxController, Ie as InputFormatController, Le as InputSearchController, Re as ModalController, ze as PannerController, Be as PopoverController, d as RovingTabIndex, p as announce, C as connectTriggerToTarget, te 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, y as setDisabled, _ as setExpanded, v as setPressed };