@tarragon-ui/js 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/tarragon-ui.js +419 -324
  2. package/package.json +1 -1
@@ -1,38 +1,39 @@
1
- const y = "tui-", V = `data-${y}`, h = (e) => V + e, A = (e, t) => `[${h(e)}${t ? `="${t}"` : ""}]`, v = "hidden", R = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', K = 1e3;
2
- var f = /* @__PURE__ */ ((e) => (e.Click = "click", e.DoubleClick = "dblclick", e.MouseUp = "mouseup", e.MouseDown = "mousedown", e.ContextMenu = "contextmenu", e.MouseWheel = "mousewheel", e.DOMMouseScroll = "DOMMouseScroll", e.MouseOver = "mouseover", e.MouseOut = "mouseout", e.MouseMove = "mousemove", e.SelectStart = "selectstart", e.SelectEnd = "selectend", e.KeyDown = "keydown", e.KeyPress = "keypress", e.KeyUp = "keyup", e.OrientationChange = "orientationchange", e.TouchStart = "touchstart", e.TouchMove = "touchmove", e.TouchEnd = "touchend", e.TouchCancel = "touchcancel", e.PointerDown = "pointerdown", e.PointerMove = "pointermove", e.PointerUp = "pointerup", e.PointerLeave = "pointerleave", e.PointerCancel = "pointercancel", e.GestureStart = "gesturestart", e.GestureChange = "gesturechange", e.GestureEnd = "gestureend", e.Focus = "focus", e.Blur = "blur", e.Change = "change", e.Reset = "reset", e.Select = "select", e.Submit = "submit", e.FocusIn = "focusin", e.FocusOut = "focusout", e.Load = "load", e.Unload = "unload", e.BeforeUnload = "beforeunload", e.BeforeToggle = "beforetoggle", e.Resize = "resize", e.Move = "move", e.DOMContentLoaded = "DOMContentLoaded", e.ReadyStateChange = "readystatechange", e.Error = "error", e.Abort = "abort", e.Scroll = "scroll", e.Input = "input", e.Toggle = "toggle", e.Close = "close", e))(f || {});
3
- const a = {
1
+ const k = "tui-", K = `data-${k}`, h = (e) => K + e, S = (e, t) => `[${h(e)}${t ? `="${t}"` : ""}]`, v = "hidden", B = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', R = 1e3;
2
+ var m = /* @__PURE__ */ ((e) => (e.Click = "click", e.DoubleClick = "dblclick", e.MouseUp = "mouseup", e.MouseDown = "mousedown", e.ContextMenu = "contextmenu", e.MouseWheel = "mousewheel", e.DOMMouseScroll = "DOMMouseScroll", e.MouseOver = "mouseover", e.MouseOut = "mouseout", e.MouseMove = "mousemove", e.SelectStart = "selectstart", e.SelectEnd = "selectend", e.KeyDown = "keydown", e.KeyPress = "keypress", e.KeyUp = "keyup", e.OrientationChange = "orientationchange", e.TouchStart = "touchstart", e.TouchMove = "touchmove", e.TouchEnd = "touchend", e.TouchCancel = "touchcancel", e.PointerDown = "pointerdown", e.PointerMove = "pointermove", e.PointerUp = "pointerup", e.PointerLeave = "pointerleave", e.PointerCancel = "pointercancel", e.GestureStart = "gesturestart", e.GestureChange = "gesturechange", e.GestureEnd = "gestureend", e.Focus = "focus", e.Blur = "blur", e.Change = "change", e.Reset = "reset", e.Select = "select", e.Submit = "submit", e.FocusIn = "focusin", e.FocusOut = "focusout", e.Load = "load", e.Unload = "unload", e.BeforeUnload = "beforeunload", e.BeforeToggle = "beforetoggle", e.Resize = "resize", e.Move = "move", e.DOMContentLoaded = "DOMContentLoaded", e.ReadyStateChange = "readystatechange", e.Error = "error", e.Abort = "abort", e.Scroll = "scroll", e.Input = "input", e.Toggle = "toggle", e.Close = "close", e))(m || {});
3
+ const c = {
4
4
  AjaxForm: {
5
- Name: `${y}ajax-form`,
5
+ Name: `${k}ajax-form`,
6
6
  Event: { Form: "form" }
7
7
  },
8
8
  AjaxHtml: {
9
- Name: `${y}ajax-html`
9
+ Name: `${k}ajax-html`
10
10
  },
11
11
  Dropdown: {
12
- Name: `${y}dropdown`
12
+ Name: `${k}dropdown`
13
13
  },
14
14
  ExclusiveCheckbox: {
15
- Name: `${y}exclusive-checkbox`,
15
+ Name: `${k}exclusive-checkbox`,
16
16
  Event: { Toggle: "toggle" }
17
17
  },
18
- SelectAll: { Name: `${y}select-all`, Event: { Toggle: "toggle" } },
19
- SearchFilter: { Name: `${y}search-filter` },
20
- UntilSelected: { Name: `${y}until-selected` },
18
+ SelectAll: { Name: `${k}select-all`, Event: { Toggle: "toggle" } },
19
+ SearchFilter: { Name: `${k}search-filter` },
20
+ Tabs: { Name: `${k}tabs` },
21
+ UntilSelected: { Name: `${k}until-selected` },
21
22
  ValidateForm: {
22
- Name: `${y}validate-form`,
23
+ Name: `${k}validate-form`,
23
24
  Event: { Validate: "validate" }
24
25
  }
25
26
  };
26
- function w(e, t, n, s = !1) {
27
- const c = new Event(`${e}:${t}`, {
27
+ function A(e, t, s, n = !1) {
28
+ const a = new Event(`${e}:${t}`, {
28
29
  bubbles: !0,
29
- cancelable: s
30
+ cancelable: n
30
31
  });
31
- return n.dispatchEvent(c);
32
+ return s.dispatchEvent(a);
32
33
  }
33
- const O = "validate-group";
34
+ const q = "validate-group";
34
35
  customElements.define(
35
- a.ValidateForm.Name,
36
+ c.ValidateForm.Name,
36
37
  class extends HTMLElement {
37
38
  form = null;
38
39
  groups = void 0;
@@ -42,8 +43,8 @@ customElements.define(
42
43
  return;
43
44
  }
44
45
  this.groups = Array.from(
45
- this.form.querySelectorAll(A(O))
46
- ), this.form.setAttribute("novalidate", ""), this.form.addEventListener("submit", this.onSubmit), this.form.addEventListener("input", this.onInput), this.form.addEventListener("blur", this.onBlur, { capture: !0 }), w(a.ValidateForm.Name, a.ValidateForm.Event.Validate, this), this.setAttribute(h("is-ready"), "");
46
+ this.form.querySelectorAll(S(q))
47
+ ), this.form.setAttribute("novalidate", ""), this.form.addEventListener("submit", this.onSubmit), this.form.addEventListener("input", this.onInput), this.form.addEventListener("blur", this.onBlur, { capture: !0 }), A(c.ValidateForm.Name, c.ValidateForm.Event.Validate, this), this.setAttribute(h("is-ready"), "");
47
48
  }
48
49
  disconnectedCallback() {
49
50
  this.form && (this.form.removeEventListener("submit", this.onSubmit), this.form.removeEventListener("input", this.onInput), this.form.removeEventListener("blur", this.onBlur, { capture: !0 }));
@@ -54,13 +55,13 @@ customElements.define(
54
55
  */
55
56
  onInput = (e) => {
56
57
  if (!(e.target instanceof Element)) return;
57
- const t = e.target.closest(A(O)), n = t ?? e.target;
58
- if (t?.setAttribute(h(O), "interacted"), !(!t && n.getAttribute("aria-invalid") !== "true")) {
58
+ const t = e.target.closest(S(q)), s = t ?? e.target;
59
+ if (t?.setAttribute(h(q), "interacted"), !(!t && s.getAttribute("aria-invalid") !== "true")) {
59
60
  if (t) {
60
61
  this.isGroupValid(t);
61
62
  return;
62
63
  }
63
- this.isFieldValid(n);
64
+ this.isFieldValid(s);
64
65
  }
65
66
  };
66
67
  /**
@@ -69,7 +70,7 @@ customElements.define(
69
70
  */
70
71
  onBlur = (e) => {
71
72
  if (!(e.target instanceof Element)) return;
72
- const t = e.target.closest(`[${O}="interacted"]`);
73
+ const t = e.target.closest(`[${q}="interacted"]`);
73
74
  if (t) {
74
75
  this.isGroupValid(t);
75
76
  return;
@@ -85,20 +86,20 @@ customElements.define(
85
86
  * @param {Event} event The event object
86
87
  */
87
88
  onSubmit = (e) => {
88
- if (!w(
89
- a.ValidateForm.Name,
90
- a.ValidateForm.Event.Validate,
89
+ if (!A(
90
+ c.ValidateForm.Name,
91
+ c.ValidateForm.Event.Validate,
91
92
  this,
92
93
  !0
93
94
  )) return;
94
- const n = this.checkGroupValidity();
95
- if (this.checkFieldValidity() && n) {
96
- w(a.ValidateForm.Name, a.ValidateForm.Event.Validate, this);
95
+ const s = this.checkGroupValidity();
96
+ if (this.checkFieldValidity() && s) {
97
+ A(c.ValidateForm.Name, c.ValidateForm.Event.Validate, this);
97
98
  return;
98
99
  }
99
100
  e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.form?.querySelector(
100
101
  'input:invalid, [aria-invalid="true"] :is([type="checkbox"], [type="radio"])'
101
- )?.focus({ focusVisible: !0 }), w(a.ValidateForm.Name, a.ValidateForm.Event.Validate, this);
102
+ )?.focus({ focusVisible: !0 }), A(c.ValidateForm.Name, c.ValidateForm.Event.Validate, this);
102
103
  };
103
104
  /**
104
105
  * Check the validity of fields that can be validated with HTMLFormElement.checkValidity().
@@ -146,36 +147,36 @@ customElements.define(
146
147
  * @param {Boolean} isGroup If true, field is a fieldset input group
147
148
  */
148
149
  showError(e, t = !1) {
149
- const n = this.getMessage(e, t);
150
- if (!n) return;
150
+ const s = this.getMessage(e, t);
151
+ if (!s) return;
151
152
  e.setAttribute("aria-invalid", "true");
152
- const s = this.querySelector(
153
- A("validation-message-template")
154
- ), c = !!s, l = e.getAttribute("aria-describedby"), u = l ?? `${y}${crypto.randomUUID()}`;
153
+ const n = this.querySelector(
154
+ S("validation-message-template")
155
+ ), a = !!n, l = e.getAttribute("aria-describedby"), u = l ?? `${k}${crypto.randomUUID()}`;
155
156
  if (l) {
156
- const m = this.form?.querySelector(`#${l}`);
157
- if (m) {
158
- if (c) {
159
- const p = m.querySelector(
160
- A("slot", "form-message")
157
+ const f = this.form?.querySelector(`#${l}`);
158
+ if (f) {
159
+ if (a) {
160
+ const p = f.querySelector(
161
+ S("slot", "form-message")
161
162
  );
162
- p && (p.textContent = n), m.id = u, e.setAttribute("aria-describedby", u);
163
+ p && (p.textContent = s), f.id = u, e.setAttribute("aria-describedby", u);
163
164
  return;
164
165
  }
165
- m.textContent = n, m.id = u, e.setAttribute("aria-describedby", u);
166
+ f.textContent = s, f.id = u, e.setAttribute("aria-describedby", u);
166
167
  return;
167
168
  }
168
169
  }
169
- let b;
170
- if (c) {
171
- b = s.content.cloneNode(!0).firstElementChild, b.id = u;
172
- const p = b.querySelector(
173
- A("slot", "form-message")
170
+ let g;
171
+ if (a) {
172
+ g = n.content.cloneNode(!0).firstElementChild, g.id = u;
173
+ const p = g.querySelector(
174
+ S("slot", "form-message")
174
175
  );
175
- p && (p.textContent = n);
176
+ p && (p.textContent = s);
176
177
  } else
177
- b = document.createElement("p"), b.textContent = n, b.id = u, b.className = "form-message";
178
- e.setAttribute("aria-describedby", u), t ? e.append(b) : e.after(b);
178
+ g = document.createElement("p"), g.textContent = s, g.id = u, g.className = "form-message";
179
+ e.setAttribute("aria-describedby", u), t ? e.append(g) : e.after(g);
179
180
  }
180
181
  /**
181
182
  * Get the error message text
@@ -184,11 +185,11 @@ customElements.define(
184
185
  * @return {String} The error message
185
186
  */
186
187
  getMessage(e, t = !1) {
187
- const n = e.getAttribute(h("validate-message"));
188
- if (n) return n;
188
+ const s = e.getAttribute(h("validate-message"));
189
+ if (s) return s;
189
190
  if (t) {
190
- const c = this.getAttribute(h("checkbox-group-message")) ?? "Please select at least one option.", l = this.getAttribute(h("radio-group-message")) ?? "Please select an option.";
191
- return e.querySelector('[type="checkbox"]') ? c : l;
191
+ const a = this.getAttribute(h("checkbox-group-message")) ?? "Please select at least one option.", l = this.getAttribute(h("radio-group-message")) ?? "Please select an option.";
192
+ return e.querySelector('[type="checkbox"]') ? a : l;
192
193
  }
193
194
  return "validationMessage" in e ? e.validationMessage : "";
194
195
  }
@@ -203,7 +204,7 @@ customElements.define(
203
204
  }
204
205
  }
205
206
  );
206
- class S {
207
+ class C {
207
208
  static instance = void 0;
208
209
  baseHeaders = void 0;
209
210
  constructor(t = {}) {
@@ -213,18 +214,18 @@ class S {
213
214
  // Subsequent calls without arguments will return the existing instance.
214
215
  // If arguments are provided, it reconfigures the existing instance or creates a new one.
215
216
  static getInstance(t) {
216
- return S.instance ? t && (S.instance.baseHeaders = {
217
- ...S.instance.baseHeaders,
217
+ return C.instance ? t && (C.instance.baseHeaders = {
218
+ ...C.instance.baseHeaders,
218
219
  ...t
219
- }) : S.instance = new S(t), S.instance;
220
+ }) : C.instance = new C(t), C.instance;
220
221
  }
221
222
  isMethod(t) {
222
223
  return ["GET", "PUT", "POST", "PATCH", "DELETE"].includes(t.toUpperCase());
223
224
  }
224
225
  buildQueryString(t) {
225
226
  if (!t) return "";
226
- const n = new URLSearchParams(t).toString();
227
- return n ? `?${n}` : "";
227
+ const s = new URLSearchParams(t).toString();
228
+ return s ? `?${s}` : "";
228
229
  }
229
230
  buildHeaders(t) {
230
231
  return {
@@ -232,64 +233,64 @@ class S {
232
233
  ...t
233
234
  };
234
235
  }
235
- async send(t, n, s) {
236
+ async send(t, s, n) {
236
237
  try {
237
- const c = n.toUpperCase(), l = this.buildQueryString(s.queryParameters), u = `${t}${l}`, b = {
238
- method: c,
239
- headers: this.buildHeaders(s.headers)
238
+ const a = s.toUpperCase(), l = this.buildQueryString(n.queryParameters), u = `${t}${l}`, g = {
239
+ method: a,
240
+ headers: this.buildHeaders(n.headers)
240
241
  };
241
- c !== "GET" && "data" in s && s.data && (b.body = s.data);
242
- const m = await fetch(u, b);
243
- if (!m.ok) {
244
- const g = {
242
+ a !== "GET" && "data" in n && n.data && (g.body = n.data);
243
+ const f = await fetch(u, g);
244
+ if (!f.ok) {
245
+ const b = {
245
246
  message: "Request failed",
246
- status: m.status
247
+ status: f.status
247
248
  };
248
- if (m.headers.get("content-type")?.includes("application/json"))
249
+ if (f.headers.get("content-type")?.includes("application/json"))
249
250
  try {
250
- const k = await m.json();
251
- g.message = k.message ?? k.error ?? g.message;
252
- } catch (k) {
253
- g.message = `Failed to parse error JSON: ${g.message}`, g.error = k instanceof Error ? k : new Error(String(k));
251
+ const y = await f.json();
252
+ b.message = y.message ?? y.error ?? b.message;
253
+ } catch (y) {
254
+ b.message = `Failed to parse error JSON: ${b.message}`, b.error = y instanceof Error ? y : new Error(String(y));
254
255
  }
255
256
  else {
256
- const k = await m.text();
257
- k && (g.message = `Server responded with an error: ${k.substring(0, 100)}`);
257
+ const y = await f.text();
258
+ y && (b.message = `Server responded with an error: ${y.substring(0, 100)}`);
258
259
  }
259
- return [g, void 0];
260
+ return [b, void 0];
260
261
  }
261
- const p = m.headers.get("content-type");
262
+ const p = f.headers.get("content-type");
262
263
  if (p?.includes("application/json"))
263
- return [void 0, await m.json()];
264
+ return [void 0, await f.json()];
264
265
  if (p?.includes("text/html")) {
265
- const g = await m.text();
266
- return [void 0, { type: "html", document: new DOMParser().parseFromString(g, "text/html") }];
266
+ const b = await f.text();
267
+ return [void 0, { type: "html", document: new DOMParser().parseFromString(b, "text/html") }];
267
268
  } else if (p?.includes("text/plain"))
268
- return [void 0, { type: "json", message: await m.text() }];
269
+ return [void 0, { type: "json", message: await f.text() }];
269
270
  return [void 0, { type: "json", message: "Request successful, no content." }];
270
- } catch (c) {
271
- return c instanceof Error ? [{ message: "Network error", error: c }, void 0] : [{ message: "An unknown error occurred" }, void 0];
271
+ } catch (a) {
272
+ return a instanceof Error ? [{ message: "Network error", error: a }, void 0] : [{ message: "An unknown error occurred" }, void 0];
272
273
  }
273
274
  }
274
- get(t, n) {
275
- return this.send(t, "GET", n ?? {});
275
+ get(t, s) {
276
+ return this.send(t, "GET", s ?? {});
276
277
  }
277
- put(t, n) {
278
- return this.send(t, "PUT", n ?? {});
278
+ put(t, s) {
279
+ return this.send(t, "PUT", s ?? {});
279
280
  }
280
- post(t, n) {
281
- return this.send(t, "POST", n ?? {});
281
+ post(t, s) {
282
+ return this.send(t, "POST", s ?? {});
282
283
  }
283
- patch(t, n) {
284
- return this.send(t, "PATCH", n ?? {});
284
+ patch(t, s) {
285
+ return this.send(t, "PATCH", s ?? {});
285
286
  }
286
- delete(t, n) {
287
- return this.send(t, "DELETE", n ?? {});
287
+ delete(t, s) {
288
+ return this.send(t, "DELETE", s ?? {});
288
289
  }
289
290
  }
290
- const F = S.getInstance({
291
+ const F = C.getInstance({
291
292
  "Content-Type": "application/json"
292
- }), H = {
293
+ }), P = {
293
294
  staleTime: 0
294
295
  };
295
296
  class L {
@@ -301,32 +302,32 @@ class L {
301
302
  return L.instance ??= new L(), L.instance;
302
303
  }
303
304
  // Centralized state update logic
304
- updateQueryState(t, n, s) {
305
- const c = this.cache.get(t), l = c ? { ...c } : {
305
+ updateQueryState(t, s, n) {
306
+ const a = this.cache.get(t), l = a ? { ...a } : {
306
307
  data: void 0,
307
308
  isFetching: !1,
308
309
  error: null,
309
- meta: { ...H }
310
+ meta: { ...P }
310
311
  };
311
- s && (l.meta = { ...l.meta, ...s });
312
- const u = { ...l, ...n };
312
+ n && (l.meta = { ...l.meta, ...n });
313
+ const u = { ...l, ...s };
313
314
  u.meta = {
314
- ...H,
315
+ ...P,
315
316
  ...l.meta
316
317
  }, this.cache.set(t, u), this.notifySubscribers(t, u), this.manageRefetchInterval(t, u.meta.staleTime);
317
318
  }
318
- notifySubscribers(t, n) {
319
- this.subscriptions.get(t)?.forEach((s) => {
320
- s(n);
319
+ notifySubscribers(t, s) {
320
+ this.subscriptions.get(t)?.forEach((n) => {
321
+ n(s);
321
322
  });
322
323
  }
323
- manageRefetchInterval(t, n) {
324
- const s = this.refetchIntervals.get(t);
325
- if (s && (clearInterval(s), this.refetchIntervals.delete(t)), n && n > 0 && this.subscriptions.has(t) && this.subscriptions.get(t).size > 0) {
326
- const c = window.setInterval(() => {
324
+ manageRefetchInterval(t, s) {
325
+ const n = this.refetchIntervals.get(t);
326
+ if (n && (clearInterval(n), this.refetchIntervals.delete(t)), s && s > 0 && this.subscriptions.has(t) && this.subscriptions.get(t).size > 0) {
327
+ const a = window.setInterval(() => {
327
328
  this.invalidateQuery(t);
328
- }, n);
329
- this.refetchIntervals.set(t, c);
329
+ }, s);
330
+ this.refetchIntervals.set(t, a);
330
331
  }
331
332
  }
332
333
  /**
@@ -336,11 +337,11 @@ class L {
336
337
  * @param options Query options that might affect initial state or refetch behavior.
337
338
  * @returns An unsubscribe function.
338
339
  */
339
- subscribe(t, n, s) {
340
- this.subscriptions.has(t) || this.subscriptions.set(t, /* @__PURE__ */ new Set()), this.subscriptions.get(t).add(n), this.updateQueryState(t, {}, s);
340
+ subscribe(t, s, n) {
341
+ this.subscriptions.has(t) || this.subscriptions.set(t, /* @__PURE__ */ new Set()), this.subscriptions.get(t).add(s), this.updateQueryState(t, {}, n);
341
342
  const l = this.cache.get(t);
342
- return l && n(l), this.manageRefetchInterval(t, l?.meta.staleTime ?? 0), () => {
343
- this.subscriptions.get(t)?.delete(n), this.subscriptions.get(t)?.size === 0 && (this.subscriptions.delete(t), this.manageRefetchInterval(t, 0));
343
+ return l && s(l), this.manageRefetchInterval(t, l?.meta.staleTime ?? 0), () => {
344
+ this.subscriptions.get(t)?.delete(s), this.subscriptions.get(t)?.size === 0 && (this.subscriptions.delete(t), this.manageRefetchInterval(t, 0));
344
345
  };
345
346
  }
346
347
  /**
@@ -349,9 +350,9 @@ class L {
349
350
  * @returns The current QueryResult, or undefined if not initialized.
350
351
  */
351
352
  get(t) {
352
- const n = this.cache.get(t);
353
- if (n)
354
- return n;
353
+ const s = this.cache.get(t);
354
+ if (s)
355
+ return s;
355
356
  }
356
357
  /**
357
358
  * Sets the data for a query key and notifies subscribers.
@@ -360,39 +361,39 @@ class L {
360
361
  * @param data The data to set.
361
362
  * @param options Options for this query.
362
363
  */
363
- setQueryData(t, n, s) {
364
+ setQueryData(t, s, n) {
364
365
  this.updateQueryState(
365
366
  t,
366
367
  {
367
- data: n,
368
+ data: s,
368
369
  error: null,
369
370
  isFetching: !1
370
371
  },
371
- s
372
+ n
372
373
  );
373
374
  }
374
375
  /**
375
376
  * Fetches data for a query key. This is an internal method called by subscribe/invalidate.
376
377
  * It ensures only one fetch is active at a time for a given key.
377
378
  */
378
- async fetchQuery(t, n) {
379
- const s = this.cache.get(t);
380
- if (!s || s.isFetching)
379
+ async fetchQuery(t, s) {
380
+ const n = this.cache.get(t);
381
+ if (!n || n.isFetching)
381
382
  return;
382
383
  this.updateQueryState(t, {
383
384
  isFetching: !0,
384
385
  // Always true when a fetch is in progress
385
386
  error: null
386
387
  });
387
- const [c, l] = await F.get(t);
388
- if (c) {
388
+ const [a, l] = await F.get(t);
389
+ if (a) {
389
390
  this.updateQueryState(
390
391
  t,
391
392
  {
392
- error: c.message,
393
+ error: a.message,
393
394
  isFetching: !1
394
395
  },
395
- n
396
+ s
396
397
  );
397
398
  return;
398
399
  }
@@ -403,7 +404,7 @@ class L {
403
404
  isFetching: !1,
404
405
  error: null
405
406
  },
406
- n
407
+ s
407
408
  );
408
409
  }
409
410
  /**
@@ -411,17 +412,17 @@ class L {
411
412
  * @param key The query key.
412
413
  */
413
414
  invalidateQuery(t) {
414
- const n = this.cache.get(t);
415
- if (!n) {
415
+ const s = this.cache.get(t);
416
+ if (!s) {
416
417
  console.warn(`No query exists for key: ${t}`);
417
418
  return;
418
419
  }
419
- n.isFetching || this.fetchQuery(t);
420
+ s.isFetching || this.fetchQuery(t);
420
421
  }
421
422
  }
422
423
  const M = L.getInstance();
423
424
  customElements.define(
424
- a.AjaxForm.Name,
425
+ c.AjaxForm.Name,
425
426
  class extends HTMLElement {
426
427
  form = null;
427
428
  announce = null;
@@ -450,22 +451,22 @@ customElements.define(
450
451
  async handleSubmit(e) {
451
452
  if (!this.form || (e.preventDefault(), this.isDisabled())) return;
452
453
  this.disable(), this.showStatus(this.messageSubmitting, "pending");
453
- const { action: t, method: n } = this.form;
454
- if (!F.isMethod(n)) {
454
+ const { action: t, method: s } = this.form;
455
+ if (!F.isMethod(s)) {
455
456
  console.error("Method is not a valid value"), this.showStatus(this.messageError, "error");
456
457
  return;
457
458
  }
458
- let s = null;
459
- this.spinner && (s = this.form.querySelector(":focus"));
460
- const [c, l] = await F.send(t, n, {
459
+ let n = null;
460
+ this.spinner && (n = this.form.querySelector(":focus"));
461
+ const [a, l] = await F.send(t, s, {
461
462
  data: this.serialize(),
462
463
  headers: {
463
464
  "Content-Type": "application/x-www-form-urlencoded",
464
465
  "X-Requested-With": "XMLHttpRequest"
465
466
  }
466
467
  });
467
- if (this.enable(), s?.focus(), c) {
468
- console.error("An error occurred", c), this.showStatus(this.messageError, "error");
468
+ if (this.enable(), n?.focus(), a) {
469
+ console.error("An error occurred", a), this.showStatus(this.messageError, "error");
469
470
  return;
470
471
  }
471
472
  if (this.actionOnSuccess === "remove-form" && this.form.remove(), this.keepFields || this.reset(), l.type === "html") {
@@ -477,7 +478,7 @@ customElements.define(
477
478
  window.location.href = l.redirectUrl;
478
479
  return;
479
480
  }
480
- l.queryKey && M.invalidateQuery(l.queryKey), this.queryKeyToInvalidate && M.invalidateQuery(this.queryKeyToInvalidate), w(a.AjaxForm.Name, a.AjaxForm.Event.Form, this);
481
+ l.queryKey && M.invalidateQuery(l.queryKey), this.queryKeyToInvalidate && M.invalidateQuery(this.queryKeyToInvalidate), A(c.AjaxForm.Name, c.AjaxForm.Event.Form, this);
481
482
  }
482
483
  disable() {
483
484
  this.setAttribute(h(this.isSubmittingAttribute), "");
@@ -494,7 +495,7 @@ customElements.define(
494
495
  case "success":
495
496
  this.announce.className = "alert success", this.actionOnSuccess === "remove-message" && setTimeout(() => {
496
497
  !this.announce || !this.announceTitle || (this.announceTitle.textContent = "", this.announce.className = "", this.showStatusIcon("pending"));
497
- }, 6 * K);
498
+ }, 6 * R);
498
499
  break;
499
500
  case "error":
500
501
  this.announce.className = "alert danger";
@@ -507,27 +508,27 @@ customElements.define(
507
508
  showStatusIcon(e) {
508
509
  if (!this.announce) return;
509
510
  const t = this.announce.querySelector(
510
- A("announce-success-icon")
511
- ), n = this.announce.querySelector(
512
- A("announce-error-icon")
511
+ S("announce-success-icon")
512
+ ), s = this.announce.querySelector(
513
+ S("announce-error-icon")
513
514
  );
514
515
  switch (e) {
515
516
  case "success":
516
- t?.removeAttribute(v), n?.setAttribute(v, "");
517
+ t?.removeAttribute(v), s?.setAttribute(v, "");
517
518
  break;
518
519
  case "error":
519
- t?.setAttribute(v, ""), n?.removeAttribute(v);
520
+ t?.setAttribute(v, ""), s?.removeAttribute(v);
520
521
  break;
521
522
  case "pending":
522
- t?.setAttribute(v, ""), n?.setAttribute(v, "");
523
+ t?.setAttribute(v, ""), s?.setAttribute(v, "");
523
524
  break;
524
525
  }
525
526
  }
526
527
  serialize() {
527
528
  if (!this.form) return "";
528
529
  const e = new FormData(this.form), t = new URLSearchParams();
529
- for (const [n, s] of e)
530
- s instanceof File || t.append(n, s);
530
+ for (const [s, n] of e)
531
+ n instanceof File || t.append(s, n);
531
532
  return t.toString();
532
533
  }
533
534
  reset() {
@@ -536,7 +537,7 @@ customElements.define(
536
537
  }
537
538
  );
538
539
  customElements.define(
539
- a.AjaxHtml.Name,
540
+ c.AjaxHtml.Name,
540
541
  class extends HTMLElement {
541
542
  queryKey = null;
542
543
  unsubscribe = null;
@@ -546,11 +547,11 @@ customElements.define(
546
547
  staleTime;
547
548
  connectedCallback() {
548
549
  if (!this.id) {
549
- console.warn(`${a.AjaxHtml.Name} requires a "id" attribute.`, this);
550
+ console.warn(`${c.AjaxHtml.Name} requires a "id" attribute.`, this);
550
551
  return;
551
552
  }
552
553
  if (this.queryKey = this.getAttribute(h("query-key")), !this.queryKey) {
553
- console.warn(`${a.AjaxHtml.Name} requires a "query-key" attribute.`, this);
554
+ console.warn(`${c.AjaxHtml.Name} requires a "query-key" attribute.`, this);
554
555
  return;
555
556
  }
556
557
  this.staleTime = this.hasAttribute(h("stale-time")) ? (
@@ -603,9 +604,9 @@ customElements.define(
603
604
  }
604
605
  renderContent(e) {
605
606
  if (!this.initialFetchTriggered || !e.data || e.data.type !== "html") return;
606
- const t = e.data.document, n = t.querySelector(`#${this.id}`);
607
- if (n && n.id === this.id) {
608
- this.innerHTML = n.innerHTML;
607
+ const t = e.data.document, s = t.querySelector(`#${this.id}`);
608
+ if (s && s.id === this.id) {
609
+ this.innerHTML = s.innerHTML;
609
610
  return;
610
611
  }
611
612
  if (t.body.innerHTML.trim().length > 0) {
@@ -616,12 +617,12 @@ customElements.define(
616
617
  }
617
618
  }
618
619
  );
619
- const $ = "[popover]", P = (e) => `[popovertarget="${e}"]`, q = {
620
+ const H = "[popover]", $ = (e) => `[popovertarget="${e}"]`, O = {
620
621
  open: "open",
621
622
  closed: "closed"
622
623
  };
623
624
  customElements.define(
624
- a.Dropdown.Name,
625
+ c.Dropdown.Name,
625
626
  class extends HTMLElement {
626
627
  popoverElement = null;
627
628
  trigger = null;
@@ -629,31 +630,31 @@ customElements.define(
629
630
  searchString = "";
630
631
  searchTimeout = -1;
631
632
  connectedCallback() {
632
- const e = this.querySelector($);
633
+ const e = this.querySelector(H);
633
634
  if (!e) {
634
635
  console.error(
635
- `${a.Dropdown.Name} component: Missing element with selector "${$}"`
636
+ `${c.Dropdown.Name} component: Missing element with selector "${H}"`
636
637
  );
637
638
  return;
638
639
  }
639
640
  this.popoverElement = e;
640
641
  const t = this.querySelector(
641
- P(this.popoverElement.id)
642
+ $(this.popoverElement.id)
642
643
  );
643
644
  if (!t) {
644
645
  console.error(
645
- `${a.Dropdown.Name} component: Missing element with selector "${P(this.popoverElement.id)}"`
646
+ `${c.Dropdown.Name} component: Missing element with selector "${$(this.popoverElement.id)}"`
646
647
  );
647
648
  return;
648
649
  }
649
- this.trigger = t, this.focusableElements = this.getFocusableElementsForTrap(), this.popoverElement.setAttribute(h("state"), q.closed), this.addEventListener(f.KeyDown, this.handleKeydown), this.popoverElement.addEventListener(f.Toggle, this.handleToggle), this.setAttribute(h("state"), "ready");
650
+ this.trigger = t, this.focusableElements = this.getFocusableElementsForTrap(), this.popoverElement.setAttribute(h("state"), O.closed), this.addEventListener(m.KeyDown, this.handleKeydown), this.popoverElement.addEventListener(m.Toggle, this.handleToggle), this.setAttribute(h("state"), "ready");
650
651
  }
651
652
  disconnectedCallback() {
652
- this.removeEventListener(f.KeyDown, this.handleKeydown), this.popoverElement?.removeEventListener(f.Toggle, this.handleToggle);
653
+ this.removeEventListener(m.KeyDown, this.handleKeydown), this.popoverElement?.removeEventListener(m.Toggle, this.handleToggle);
653
654
  }
654
655
  getFocusableElementsForTrap() {
655
656
  return this.popoverElement ? [...Array.from(
656
- this.popoverElement.querySelectorAll(R)
657
+ this.popoverElement.querySelectorAll(B)
657
658
  )].filter(Boolean) : [];
658
659
  }
659
660
  handleToggle = (e) => {
@@ -664,13 +665,13 @@ customElements.define(
664
665
  this.onPopoverClose();
665
666
  };
666
667
  onPopoverOpen() {
667
- this.popoverElement && this.popoverElement.setAttribute(h("state"), q.open);
668
+ this.popoverElement && this.popoverElement.setAttribute(h("state"), O.open);
668
669
  }
669
670
  onPopoverClose() {
670
- this.popoverElement && this.popoverElement.setAttribute(h("state"), q.closed);
671
+ this.popoverElement && this.popoverElement.setAttribute(h("state"), O.closed);
671
672
  }
672
673
  isOpen() {
673
- return this.popoverElement ? this.popoverElement.getAttribute(h("state")) === q.open : !1;
674
+ return this.popoverElement ? this.popoverElement.getAttribute(h("state")) === O.open : !1;
674
675
  }
675
676
  handleKeydown = (e) => {
676
677
  if (this.isOpen()) {
@@ -730,16 +731,16 @@ customElements.define(
730
731
  triggerAction = (e) => {
731
732
  e.target instanceof HTMLAnchorElement && e.target.click();
732
733
  };
733
- focusOptionByStep = (e, t, n) => {
734
- const s = this.focusableElements;
735
- if (!s.length) return;
736
- const c = e, l = s.indexOf(c);
737
- if (n.preventDefault(), l === -1) {
738
- s[0]?.focus();
734
+ focusOptionByStep = (e, t, s) => {
735
+ const n = this.focusableElements;
736
+ if (!n.length) return;
737
+ const a = e, l = n.indexOf(a);
738
+ if (s.preventDefault(), l === -1) {
739
+ n[0]?.focus();
739
740
  return;
740
741
  }
741
- const u = (l + t + s.length) % s.length;
742
- u >= s.length || u < 0 || s[u]?.focus();
742
+ const u = (l + t + n.length) % n.length;
743
+ u >= n.length || u < 0 || n[u]?.focus();
743
744
  };
744
745
  focusOptionByIndex(e) {
745
746
  if (!this.focusableElements.length) return;
@@ -748,16 +749,16 @@ customElements.define(
748
749
  }
749
750
  handleSearchString(e) {
750
751
  if (clearTimeout(this.searchTimeout), this.searchString += e.toLowerCase(), !this.focusableElements.length) return;
751
- const t = this.getActiveOption(), n = this.searchString.length === 1 && t ? this.focusableElements.indexOf(t) + 1 : 0, s = this.findOptionBySearchString(this.focusableElements, n) ?? this.findOptionBySearchString(this.focusableElements, 0);
752
- s && s.focus(), this.searchTimeout = window.setTimeout(() => {
752
+ const t = this.getActiveOption(), s = this.searchString.length === 1 && t ? this.focusableElements.indexOf(t) + 1 : 0, n = this.findOptionBySearchString(this.focusableElements, s) ?? this.findOptionBySearchString(this.focusableElements, 0);
753
+ n && n.focus(), this.searchTimeout = window.setTimeout(() => {
753
754
  this.searchString = "";
754
755
  }, 500);
755
756
  }
756
757
  findOptionBySearchString(e, t) {
757
- for (let n = 0; n < e.length; n++) {
758
- const s = (t + n) % e.length;
759
- if (e[s]?.textContent.trim().toLowerCase()?.startsWith(this.searchString))
760
- return e[s] ?? null;
758
+ for (let s = 0; s < e.length; s++) {
759
+ const n = (t + s) % e.length;
760
+ if (e[n]?.textContent.trim().toLowerCase()?.startsWith(this.searchString))
761
+ return e[n] ?? null;
761
762
  }
762
763
  return null;
763
764
  }
@@ -768,7 +769,7 @@ customElements.define(
768
769
  }
769
770
  );
770
771
  customElements.define(
771
- a.ExclusiveCheckbox.Name,
772
+ c.ExclusiveCheckbox.Name,
772
773
  class extends HTMLElement {
773
774
  targetName = null;
774
775
  exclusiveCheckbox = null;
@@ -782,17 +783,17 @@ customElements.define(
782
783
  }
783
784
  disconnectedCallback() {
784
785
  if (this.exclusiveCheckbox && this.exclusiveCheckbox.removeEventListener(
785
- f.Change,
786
+ m.Change,
786
787
  this.handleExclusiveChange
787
788
  ), this.checkboxes)
788
789
  for (const e of this.checkboxes)
789
- e.removeEventListener(f.Change, this.handleCheckboxChange);
790
+ e.removeEventListener(m.Change, this.handleCheckboxChange);
790
791
  }
791
792
  addEvents() {
792
793
  if (!(!this.exclusiveCheckbox || !this.targetName || !this.parentElement || !this.checkboxes)) {
793
794
  this.exclusiveCheckbox.addEventListener("change", this.handleExclusiveChange);
794
795
  for (const e of this.checkboxes)
795
- e.disabled || e.addEventListener(f.Change, this.handleCheckboxChange);
796
+ e.disabled || e.addEventListener(m.Change, this.handleCheckboxChange);
796
797
  }
797
798
  }
798
799
  handleExclusiveChange = () => {
@@ -800,9 +801,9 @@ customElements.define(
800
801
  const e = this.exclusiveCheckbox.checked;
801
802
  for (const t of this.checkboxes)
802
803
  t.disabled || e && (t.checked = !1);
803
- this.exclusiveCheckbox.indeterminate = !1, w(
804
- a.ExclusiveCheckbox.Name,
805
- a.ExclusiveCheckbox.Event.Toggle,
804
+ this.exclusiveCheckbox.indeterminate = !1, A(
805
+ c.ExclusiveCheckbox.Name,
806
+ c.ExclusiveCheckbox.Event.Toggle,
806
807
  this.exclusiveCheckbox
807
808
  );
808
809
  };
@@ -811,16 +812,16 @@ customElements.define(
811
812
  const e = this.checkboxes.some(
812
813
  (t) => !t.disabled && t.checked
813
814
  );
814
- this.exclusiveCheckbox.checked = !e, w(
815
- a.ExclusiveCheckbox.Name,
816
- a.ExclusiveCheckbox.Event.Toggle,
815
+ this.exclusiveCheckbox.checked = !e, A(
816
+ c.ExclusiveCheckbox.Name,
817
+ c.ExclusiveCheckbox.Event.Toggle,
817
818
  this.exclusiveCheckbox
818
819
  );
819
820
  };
820
821
  }
821
822
  );
822
823
  customElements.define(
823
- a.SelectAll.Name,
824
+ c.SelectAll.Name,
824
825
  class extends HTMLElement {
825
826
  targetName = null;
826
827
  selectAllCheckbox = null;
@@ -834,11 +835,11 @@ customElements.define(
834
835
  }
835
836
  disconnectedCallback() {
836
837
  if (this.selectAllCheckbox && this.selectAllCheckbox.removeEventListener(
837
- f.Change,
838
+ m.Change,
838
839
  this.handleSelectAllChange
839
840
  ), this.checkboxes)
840
841
  for (const e of this.checkboxes)
841
- e.removeEventListener(f.Change, this.handleCheckboxChange);
842
+ e.removeEventListener(m.Change, this.handleCheckboxChange);
842
843
  }
843
844
  ready() {
844
845
  this.setAttribute(h("state"), "ready");
@@ -847,7 +848,7 @@ customElements.define(
847
848
  if (!(!this.selectAllCheckbox || !this.targetName || !this.parentElement || !this.checkboxes)) {
848
849
  this.selectAllCheckbox.addEventListener("change", this.handleSelectAllChange);
849
850
  for (const e of this.checkboxes)
850
- e.disabled || (e.parentElement?.classList.add("padding-inline-start-lg"), e.addEventListener(f.Change, this.handleCheckboxChange));
851
+ e.disabled || (e.parentElement?.classList.add("padding-inline-start-lg"), e.addEventListener(m.Change, this.handleCheckboxChange));
851
852
  }
852
853
  }
853
854
  handleSelectAllChange = () => {
@@ -855,27 +856,121 @@ customElements.define(
855
856
  const e = this.selectAllCheckbox.checked;
856
857
  for (const t of this.checkboxes)
857
858
  t.disabled || (t.checked = e);
858
- this.selectAllCheckbox.indeterminate = !1, w(
859
- a.SelectAll.Name,
860
- a.SelectAll.Event.Toggle,
859
+ this.selectAllCheckbox.indeterminate = !1, A(
860
+ c.SelectAll.Name,
861
+ c.SelectAll.Event.Toggle,
861
862
  this.selectAllCheckbox
862
863
  );
863
864
  };
864
865
  handleCheckboxChange = () => {
865
866
  if (!this.selectAllCheckbox || !this.checkboxes || this.checkboxes.length === 0) return;
866
867
  const e = this.checkboxes.filter(
867
- (c) => !c.disabled && c.checked
868
- ).length, t = this.checkboxes.length, n = e === t, s = e === 0;
869
- this.selectAllCheckbox.indeterminate = !n && !s, this.selectAllCheckbox.checked = n, w(
870
- a.SelectAll.Name,
871
- a.SelectAll.Event.Toggle,
868
+ (a) => !a.disabled && a.checked
869
+ ).length, t = this.checkboxes.length, s = e === t, n = e === 0;
870
+ this.selectAllCheckbox.indeterminate = !s && !n, this.selectAllCheckbox.checked = s, A(
871
+ c.SelectAll.Name,
872
+ c.SelectAll.Event.Toggle,
872
873
  this.selectAllCheckbox
873
874
  );
874
875
  };
875
876
  }
876
877
  );
877
878
  customElements.define(
878
- a.UntilSelected.Name,
879
+ c.Tabs.Name,
880
+ class extends HTMLElement {
881
+ tabs = [];
882
+ tabList = null;
883
+ tabPanels = [];
884
+ connectedCallback() {
885
+ if (this.tabList = this.querySelector(".tablist"), this.tabs = Array.from(this.querySelectorAll(".tablist a")), this.tabPanels = this.tabs.map((e) => {
886
+ const t = e.getAttribute("href");
887
+ if (t != null)
888
+ return document.querySelector(t);
889
+ }).filter((e) => e != null), !this.tabList || this.tabs.length === 0 || this.tabPanels.length === 0) {
890
+ console.error("Tabs component: Missing some of elements .tablist, .tabpanel", this);
891
+ return;
892
+ }
893
+ this.ready(), this.setTabListAttributes(), this.setTabsAttributes(), this.setPanelsAttributes(), this.setEventListeners();
894
+ }
895
+ disconnectedCallback() {
896
+ for (const e of this.tabs)
897
+ e.removeEventListener(m.Click, this.handleTabClick), e.removeEventListener(m.KeyDown, this.onKeyDown);
898
+ }
899
+ setEventListeners() {
900
+ for (const e of this.tabs)
901
+ e.addEventListener(m.Click, this.handleTabClick), e.addEventListener(m.KeyDown, this.onKeyDown);
902
+ }
903
+ ready() {
904
+ this.setAttribute(h("state"), "ready");
905
+ }
906
+ setTabListAttributes() {
907
+ if (!this.tabList) return;
908
+ this.tabList.setAttribute("role", "tablist"), this.tabList.querySelectorAll("li").forEach((t) => {
909
+ t.setAttribute("role", "presentation");
910
+ });
911
+ }
912
+ setTabsAttributes() {
913
+ const e = parseInt(this.getAttribute(h("start-index")) ?? "0");
914
+ this.tabs.forEach((t, s) => {
915
+ t.setAttribute("role", "tab"), s === e ? t.setAttribute("aria-selected", "true") : (t.setAttribute("aria-selected", "false"), t.setAttribute("tabindex", "-1"), this.tabPanels[s]?.setAttribute("hidden", "")), this.tabPanels[s] && t.setAttribute("aria-controls", this.tabPanels[s].id);
916
+ });
917
+ }
918
+ setPanelsAttributes() {
919
+ this.tabPanels.forEach((e) => {
920
+ e.setAttribute("role", "tabpanel"), e.querySelector(B) || e.setAttribute("tabindex", "0");
921
+ });
922
+ }
923
+ handleTabClick = (e) => {
924
+ e.preventDefault();
925
+ const t = e.target;
926
+ this.changeTab(t);
927
+ };
928
+ changeTab(e) {
929
+ const t = e.getAttribute("href")?.substring(1), s = this.tabPanels.find((n) => n.id == t);
930
+ this.tabs.forEach((n) => {
931
+ n.setAttribute("aria-selected", "false"), n.setAttribute("tabindex", "-1");
932
+ }), s && (this.tabPanels.forEach((n) => {
933
+ n.setAttribute("hidden", "");
934
+ }), s.removeAttribute("hidden")), e.setAttribute("aria-selected", "true"), e.setAttribute("tabindex", "0"), e.focus();
935
+ }
936
+ moveTab(e) {
937
+ const t = this.tabs.filter(
938
+ (l) => l.getAttribute("aria-disabled") !== "true"
939
+ );
940
+ if (t.length === 0) return;
941
+ const s = t.indexOf(document.activeElement);
942
+ if (s === -1) return;
943
+ const n = (s + e + t.length) % t.length, a = t[n];
944
+ a && this.changeTab(a);
945
+ }
946
+ onKeyDown = (e) => {
947
+ if (e.key === "ArrowLeft") {
948
+ this.moveTab(-1);
949
+ return;
950
+ }
951
+ if (e.key === "ArrowRight") {
952
+ this.moveTab(1);
953
+ return;
954
+ }
955
+ if (e.key === "Home") {
956
+ e.preventDefault();
957
+ const t = this.tabs.find(
958
+ (s) => s.getAttribute("aria-disabled") !== "true"
959
+ );
960
+ t && this.changeTab(t);
961
+ return;
962
+ }
963
+ if (e.key === "End") {
964
+ e.preventDefault();
965
+ const t = [...this.tabs].reverse().find((s) => s.getAttribute("aria-disabled") !== "true");
966
+ t && this.changeTab(t);
967
+ return;
968
+ }
969
+ };
970
+ }
971
+ );
972
+ customElements.define(
973
+ c.UntilSelected.Name,
879
974
  class extends HTMLElement {
880
975
  target = null;
881
976
  targetElement = null;
@@ -885,50 +980,50 @@ customElements.define(
885
980
  connectedCallback() {
886
981
  if (this.target = this.getAttribute(h("target")), !this.target) return;
887
982
  try {
888
- const s = document.getElementById(this.target);
889
- if (!(s instanceof HTMLInputElement)) {
983
+ const n = document.getElementById(this.target);
984
+ if (!(n instanceof HTMLInputElement)) {
890
985
  console.warn("Element was not found");
891
986
  return;
892
987
  }
893
- this.targetElement = s;
894
- } catch (s) {
895
- console.warn("Could not select element", s);
988
+ this.targetElement = n;
989
+ } catch (n) {
990
+ console.warn("Could not select element", n);
896
991
  }
897
992
  if (!this.targetElement) return;
898
993
  const e = this.getAttribute(h("focus-target"));
899
994
  if (e)
900
995
  try {
901
996
  this.focusTargetElement = document.getElementById(e);
902
- } catch (s) {
903
- console.warn("Could not select focus target", s);
997
+ } catch (n) {
998
+ console.warn("Could not select focus target", n);
904
999
  }
905
1000
  const t = this.getAttribute(h("events"));
906
- t && (this.events = t.split(",").map((s) => s.trim())), this.showWhen = this.getAttribute(h("show-when")) === "not-checked" ? "not-checked" : "checked";
907
- const n = this.targetElement.checked;
1001
+ t && (this.events = t.split(",").map((n) => n.trim())), this.showWhen = this.getAttribute(h("show-when")) === "not-checked" ? "not-checked" : "checked";
1002
+ const s = this.targetElement.checked;
908
1003
  this.toggleAttribute(
909
1004
  v,
910
- this.showWhen === "checked" ? !n : n
1005
+ this.showWhen === "checked" ? !s : s
911
1006
  ), this.addEvents();
912
1007
  }
913
1008
  disconnectedCallback() {
914
1009
  if (document.removeEventListener(
915
- `${a.ExclusiveCheckbox.Name}:${a.ExclusiveCheckbox.Event.Toggle}`,
1010
+ `${c.ExclusiveCheckbox.Name}:${c.ExclusiveCheckbox.Event.Toggle}`,
916
1011
  this.handleTargetChange
917
1012
  ), document.removeEventListener(
918
- `${a.SelectAll.Name}:${a.ExclusiveCheckbox.Event.Toggle}`,
1013
+ `${c.SelectAll.Name}:${c.ExclusiveCheckbox.Event.Toggle}`,
919
1014
  this.handleTargetChange
920
- ), this.targetElement && this.targetElement.removeEventListener(f.Change, this.handleTargetChange), this.events && this.events.length > 0)
1015
+ ), this.targetElement && this.targetElement.removeEventListener(m.Change, this.handleTargetChange), this.events && this.events.length > 0)
921
1016
  for (const e of this.events)
922
1017
  document.removeEventListener(e, this.handleTargetChange);
923
1018
  }
924
1019
  addEvents() {
925
1020
  if (document.addEventListener(
926
- `${a.ExclusiveCheckbox.Name}:${a.ExclusiveCheckbox.Event.Toggle}`,
1021
+ `${c.ExclusiveCheckbox.Name}:${c.ExclusiveCheckbox.Event.Toggle}`,
927
1022
  this.handleTargetChange
928
1023
  ), document.addEventListener(
929
- `${a.SelectAll.Name}:${a.ExclusiveCheckbox.Event.Toggle}`,
1024
+ `${c.SelectAll.Name}:${c.ExclusiveCheckbox.Event.Toggle}`,
930
1025
  this.handleTargetChange
931
- ), this.targetElement && this.targetElement.addEventListener(f.Change, this.handleTargetChange), this.events && this.events.length > 0)
1026
+ ), this.targetElement && this.targetElement.addEventListener(m.Change, this.handleTargetChange), this.events && this.events.length > 0)
932
1027
  for (const e of this.events)
933
1028
  document.addEventListener(e, this.handleTargetChange);
934
1029
  }
@@ -940,15 +1035,15 @@ customElements.define(
940
1035
  }
941
1036
  );
942
1037
  function j(e, t) {
943
- let n;
944
- return function(...s) {
945
- clearTimeout(n), n = setTimeout(() => {
946
- e.apply(this, s);
1038
+ let s;
1039
+ return function(...n) {
1040
+ clearTimeout(s), s = setTimeout(() => {
1041
+ e.apply(this, n);
947
1042
  }, t);
948
1043
  };
949
1044
  }
950
1045
  customElements.define(
951
- a.SearchFilter.Name,
1046
+ c.SearchFilter.Name,
952
1047
  class extends HTMLElement {
953
1048
  // TODO Add an aria-live region to announce number of results found
954
1049
  // TODO handle focus management for accessibility
@@ -964,7 +1059,7 @@ customElements.define(
964
1059
  const e = this.getAttribute(h("collection-selector"));
965
1060
  if (!e) {
966
1061
  console.warn(
967
- `${a.SearchFilter.Name} requires a "collection-selector" attribute.`,
1062
+ `${c.SearchFilter.Name} requires a "collection-selector" attribute.`,
968
1063
  this
969
1064
  );
970
1065
  return;
@@ -972,32 +1067,32 @@ customElements.define(
972
1067
  const t = this.getAttribute(h("target-selector"));
973
1068
  if (!t) {
974
1069
  console.warn(
975
- `${a.SearchFilter.Name} requires a "target-selector" attribute.`,
1070
+ `${c.SearchFilter.Name} requires a "target-selector" attribute.`,
976
1071
  this
977
1072
  );
978
1073
  return;
979
1074
  }
980
- const n = Array.from(
1075
+ const s = Array.from(
981
1076
  document.querySelectorAll(e)
982
1077
  );
983
- if (n.length !== 0) {
984
- for (const s of n) {
985
- const c = Array.from(
986
- s.querySelectorAll(t)
1078
+ if (s.length !== 0) {
1079
+ for (const n of s) {
1080
+ const a = Array.from(
1081
+ n.querySelectorAll(t)
987
1082
  );
988
1083
  this.collections.push({
989
- element: s,
990
- targetElements: c.map((l) => ({
1084
+ element: n,
1085
+ targetElements: a.map((l) => ({
991
1086
  element: l,
992
1087
  text: l.textContent.toLocaleLowerCase()
993
1088
  }))
994
1089
  });
995
1090
  }
996
- this.collections.length !== 0 && (this.inputElement.addEventListener(f.Input, this.debouncedFilterTargets), this.searchButton.addEventListener(f.Click, this.onSearchClick));
1091
+ this.collections.length !== 0 && (this.inputElement.addEventListener(m.Input, this.debouncedFilterTargets), this.searchButton.addEventListener(m.Click, this.onSearchClick));
997
1092
  }
998
1093
  }
999
1094
  disconnectedCallback() {
1000
- this.inputElement?.removeEventListener(f.Input, this.debouncedFilterTargets), this.searchButton?.removeEventListener(f.Click, this.onSearchClick);
1095
+ this.inputElement?.removeEventListener(m.Input, this.debouncedFilterTargets), this.searchButton?.removeEventListener(m.Click, this.onSearchClick);
1001
1096
  }
1002
1097
  onSearchClick = (e) => {
1003
1098
  e.preventDefault(), this.filterTargets();
@@ -1008,16 +1103,16 @@ customElements.define(
1008
1103
  if (!e) {
1009
1104
  for (const t of this.collections) {
1010
1105
  t.element.removeAttribute(v);
1011
- for (const n of t.targetElements)
1012
- n.element.removeAttribute(v);
1106
+ for (const s of t.targetElements)
1107
+ s.element.removeAttribute(v);
1013
1108
  }
1014
1109
  return;
1015
1110
  }
1016
1111
  this.collections.forEach((t) => {
1017
- let n = !1;
1018
- for (const s of t.targetElements)
1019
- s.text.includes(e) ? (s.element.removeAttribute(v), n = !0) : s.element.setAttribute(v, "");
1020
- n ? t.element.removeAttribute(v) : t.element.setAttribute(v, "");
1112
+ let s = !1;
1113
+ for (const n of t.targetElements)
1114
+ n.text.includes(e) ? (n.element.removeAttribute(v), s = !0) : n.element.setAttribute(v, "");
1115
+ s ? t.element.removeAttribute(v) : t.element.setAttribute(v, "");
1021
1116
  });
1022
1117
  };
1023
1118
  }
@@ -1039,23 +1134,23 @@ function U() {
1039
1134
  },
1040
1135
  !0
1041
1136
  );
1042
- function e(r, i, o = !0) {
1043
- Object.defineProperty(r, i, {
1044
- ...Object.getOwnPropertyDescriptor(r, i),
1045
- enumerable: o
1137
+ function e(r, o, i = !0) {
1138
+ Object.defineProperty(r, o, {
1139
+ ...Object.getOwnPropertyDescriptor(r, o),
1140
+ enumerable: i
1046
1141
  });
1047
1142
  }
1048
1143
  function t(r) {
1049
1144
  return r && typeof r.getRootNode == "function" ? r.getRootNode() : r && r.parentNode ? t(r.parentNode) : r;
1050
1145
  }
1051
- const n = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap();
1052
- class c extends Event {
1053
- constructor(i, o = {}) {
1054
- super(i, o);
1055
- const { source: d, command: E } = o;
1146
+ const s = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
1147
+ class a extends Event {
1148
+ constructor(o, i = {}) {
1149
+ super(o, i);
1150
+ const { source: d, command: E } = i;
1056
1151
  if (d != null && !(d instanceof Element))
1057
1152
  throw new TypeError("source must be an element");
1058
- n.set(this, d || null), s.set(
1153
+ s.set(this, d || null), n.set(
1059
1154
  this,
1060
1155
  E !== void 0 ? String(E) : ""
1061
1156
  );
@@ -1064,17 +1159,17 @@ function U() {
1064
1159
  return "CommandEvent";
1065
1160
  }
1066
1161
  get source() {
1067
- if (!n.has(this))
1162
+ if (!s.has(this))
1068
1163
  throw new TypeError("illegal invocation");
1069
- const i = n.get(this);
1070
- if (!(i instanceof Element)) return null;
1071
- const o = t(i);
1072
- return o !== t(this.target || document) ? o.host : i;
1164
+ const o = s.get(this);
1165
+ if (!(o instanceof Element)) return null;
1166
+ const i = t(o);
1167
+ return i !== t(this.target || document) ? i.host : o;
1073
1168
  }
1074
1169
  get command() {
1075
- if (!s.has(this))
1170
+ if (!n.has(this))
1076
1171
  throw new TypeError("illegal invocation");
1077
- return s.get(this);
1172
+ return n.get(this);
1078
1173
  }
1079
1174
  get action() {
1080
1175
  throw new Error(
@@ -1087,21 +1182,21 @@ function U() {
1087
1182
  );
1088
1183
  }
1089
1184
  }
1090
- e(c.prototype, "source"), e(c.prototype, "command");
1185
+ e(a.prototype, "source"), e(a.prototype, "command");
1091
1186
  class l extends Event {
1092
- constructor(i, o = {}) {
1093
- throw super(i, o), new Error(
1187
+ constructor(o, i = {}) {
1188
+ throw super(o, i), new Error(
1094
1189
  "InvokeEvent has been deprecated, it has been renamed to `CommandEvent`"
1095
1190
  );
1096
1191
  }
1097
1192
  }
1098
1193
  const u = /* @__PURE__ */ new WeakMap();
1099
- function b(r) {
1194
+ function g(r) {
1100
1195
  Object.defineProperties(r.prototype, {
1101
1196
  commandForElement: {
1102
1197
  enumerable: !0,
1103
1198
  configurable: !0,
1104
- set(i) {
1199
+ set(o) {
1105
1200
  if (this.hasAttribute("invokeaction"))
1106
1201
  throw new TypeError(
1107
1202
  "Element has deprecated `invokeaction` attribute, replace with `command`"
@@ -1110,12 +1205,12 @@ function U() {
1110
1205
  throw new TypeError(
1111
1206
  "Element has deprecated `invoketarget` attribute, replace with `commandfor`"
1112
1207
  );
1113
- if (i === null)
1208
+ if (o === null)
1114
1209
  this.removeAttribute("commandfor"), u.delete(this);
1115
- else if (i instanceof Element) {
1210
+ else if (o instanceof Element) {
1116
1211
  this.setAttribute("commandfor", "");
1117
- const o = t(i);
1118
- t(this) === o || o === this.ownerDocument ? u.set(this, i) : u.delete(this);
1212
+ const i = t(o);
1213
+ t(this) === i || i === this.ownerDocument ? u.set(this, o) : u.delete(this);
1119
1214
  } else
1120
1215
  throw new TypeError("commandForElement must be an element or null");
1121
1216
  },
@@ -1132,33 +1227,33 @@ function U() {
1132
1227
  return console.warn(
1133
1228
  "Element with `commandFor` is a form participant. It should explicitly set `type=button` in order for `commandFor` to work"
1134
1229
  ), null;
1135
- const i = u.get(this);
1136
- if (i)
1137
- return i.isConnected ? i : (u.delete(this), null);
1138
- const o = t(this), d = this.getAttribute("commandfor");
1139
- return (o instanceof Document || o instanceof ShadowRoot) && d && o.getElementById(d) || null;
1230
+ const o = u.get(this);
1231
+ if (o)
1232
+ return o.isConnected ? o : (u.delete(this), null);
1233
+ const i = t(this), d = this.getAttribute("commandfor");
1234
+ return (i instanceof Document || i instanceof ShadowRoot) && d && i.getElementById(d) || null;
1140
1235
  }
1141
1236
  },
1142
1237
  command: {
1143
1238
  enumerable: !0,
1144
1239
  configurable: !0,
1145
1240
  get() {
1146
- const i = this.getAttribute("command") || "";
1147
- if (i.startsWith("--")) return i;
1148
- const o = i.toLowerCase();
1149
- switch (o) {
1241
+ const o = this.getAttribute("command") || "";
1242
+ if (o.startsWith("--")) return o;
1243
+ const i = o.toLowerCase();
1244
+ switch (i) {
1150
1245
  case "show-modal":
1151
1246
  case "request-close":
1152
1247
  case "close":
1153
1248
  case "toggle-popover":
1154
1249
  case "hide-popover":
1155
1250
  case "show-popover":
1156
- return o;
1251
+ return i;
1157
1252
  }
1158
1253
  return "";
1159
1254
  },
1160
- set(i) {
1161
- this.setAttribute("command", i);
1255
+ set(o) {
1256
+ this.setAttribute("command", o);
1162
1257
  }
1163
1258
  },
1164
1259
  invokeAction: {
@@ -1169,7 +1264,7 @@ function U() {
1169
1264
  "invokeAction is deprecated. It has been renamed to command"
1170
1265
  );
1171
1266
  },
1172
- set(i) {
1267
+ set(o) {
1173
1268
  throw new Error(
1174
1269
  "invokeAction is deprecated. It has been renamed to command"
1175
1270
  );
@@ -1183,7 +1278,7 @@ function U() {
1183
1278
  "invokeTargetElement is deprecated. It has been renamed to command"
1184
1279
  );
1185
1280
  },
1186
- set(i) {
1281
+ set(o) {
1187
1282
  throw new Error(
1188
1283
  "invokeTargetElement is deprecated. It has been renamed to command"
1189
1284
  );
@@ -1191,17 +1286,17 @@ function U() {
1191
1286
  }
1192
1287
  });
1193
1288
  }
1194
- const m = /* @__PURE__ */ new WeakMap();
1289
+ const f = /* @__PURE__ */ new WeakMap();
1195
1290
  Object.defineProperties(HTMLElement.prototype, {
1196
1291
  oncommand: {
1197
1292
  enumerable: !0,
1198
1293
  configurable: !0,
1199
1294
  get() {
1200
- return g.takeRecords(), m.get(this) || null;
1295
+ return b.takeRecords(), f.get(this) || null;
1201
1296
  },
1202
1297
  set(r) {
1203
- const i = m.get(this) || null;
1204
- i && this.removeEventListener("command", i), m.set(
1298
+ const o = f.get(this) || null;
1299
+ o && this.removeEventListener("command", o), f.set(
1205
1300
  this,
1206
1301
  typeof r == "object" || typeof r == "function" ? r : null
1207
1302
  ), typeof r == "function" && this.addEventListener("command", r);
@@ -1209,86 +1304,86 @@ function U() {
1209
1304
  }
1210
1305
  });
1211
1306
  function p(r) {
1212
- for (const i of r)
1213
- i.oncommand = new Function("event", i.getAttribute("oncommand"));
1307
+ for (const o of r)
1308
+ o.oncommand = new Function("event", o.getAttribute("oncommand"));
1214
1309
  }
1215
- const g = new MutationObserver((r) => {
1216
- for (const i of r) {
1217
- const { target: o } = i;
1218
- i.type === "childList" ? p(o.querySelectorAll("[oncommand]")) : p([o]);
1310
+ const b = new MutationObserver((r) => {
1311
+ for (const o of r) {
1312
+ const { target: i } = o;
1313
+ o.type === "childList" ? p(i.querySelectorAll("[oncommand]")) : p([i]);
1219
1314
  }
1220
1315
  });
1221
- g.observe(document, {
1316
+ b.observe(document, {
1222
1317
  subtree: !0,
1223
1318
  childList: !0,
1224
1319
  attributeFilter: ["oncommand"]
1225
1320
  }), p(document.querySelectorAll("[oncommand]"));
1226
1321
  const I = /* @__PURE__ */ new WeakSet();
1227
- function k(r) {
1322
+ function y(r) {
1228
1323
  if (I.has(r) || (I.add(r), r.defaultPrevented) || r.type !== "click") return;
1229
- const i = r.target.closest(
1324
+ const o = r.target.closest(
1230
1325
  "button[invoketarget], button[invokeaction], input[invoketarget], input[invokeaction]"
1231
1326
  );
1232
- if (i && (console.warn(
1327
+ if (o && (console.warn(
1233
1328
  "Elements with `invoketarget` or `invokeaction` are deprecated and should be renamed to use `commandfor` and `command` respectively"
1234
- ), i.matches("input")))
1329
+ ), o.matches("input")))
1235
1330
  throw new Error("Input elements no longer support `commandfor`");
1236
- const o = r.target.closest("button[commandfor], button[command]");
1237
- if (!o) return;
1238
- if (o.form && o.getAttribute("type") !== "button")
1331
+ const i = r.target.closest("button[commandfor], button[command]");
1332
+ if (!i) return;
1333
+ if (i.form && i.getAttribute("type") !== "button")
1239
1334
  throw r.preventDefault(), new Error(
1240
1335
  "Element with `commandFor` is a form participant. It should explicitly set `type=button` in order for `commandFor` to work. In order for it to act as a Submit button, it must not have command or commandfor attributes"
1241
1336
  );
1242
- if (o.hasAttribute("command") !== o.hasAttribute("commandfor")) {
1243
- const C = o.hasAttribute("command") ? "command" : "commandfor", T = o.hasAttribute("command") ? "commandfor" : "command";
1337
+ if (i.hasAttribute("command") !== i.hasAttribute("commandfor")) {
1338
+ const w = i.hasAttribute("command") ? "command" : "commandfor", T = i.hasAttribute("command") ? "commandfor" : "command";
1244
1339
  throw new Error(
1245
- `Element with ${C} attribute must also have a ${T} attribute to function.`
1340
+ `Element with ${w} attribute must also have a ${T} attribute to function.`
1246
1341
  );
1247
1342
  }
1248
- if (o.command !== "show-popover" && o.command !== "hide-popover" && o.command !== "toggle-popover" && o.command !== "show-modal" && o.command !== "request-close" && o.command !== "close" && !o.command.startsWith("--")) {
1343
+ if (i.command !== "show-popover" && i.command !== "hide-popover" && i.command !== "toggle-popover" && i.command !== "show-modal" && i.command !== "request-close" && i.command !== "close" && !i.command.startsWith("--")) {
1249
1344
  console.warn(
1250
- `"${o.command}" is not a valid command value. Custom commands must begin with --`
1345
+ `"${i.command}" is not a valid command value. Custom commands must begin with --`
1251
1346
  );
1252
1347
  return;
1253
1348
  }
1254
- const d = o.commandForElement;
1349
+ const d = i.commandForElement;
1255
1350
  if (!d) return;
1256
- const E = new c("command", {
1257
- command: o.command,
1258
- source: o,
1351
+ const E = new a("command", {
1352
+ command: i.command,
1353
+ source: i,
1259
1354
  cancelable: !0
1260
1355
  });
1261
1356
  if (d.dispatchEvent(E), E.defaultPrevented)
1262
1357
  return;
1263
1358
  const x = E.command.toLowerCase();
1264
1359
  if (d.popover) {
1265
- const C = !d.matches(":popover-open");
1266
- C && (x === "toggle-popover" || x === "show-popover") ? d.showPopover({ source: o }) : !C && x === "hide-popover" && d.hidePopover();
1360
+ const w = !d.matches(":popover-open");
1361
+ w && (x === "toggle-popover" || x === "show-popover") ? d.showPopover({ source: i }) : !w && x === "hide-popover" && d.hidePopover();
1267
1362
  } else if (d.localName === "dialog") {
1268
- const C = !d.hasAttribute("open");
1269
- C && x == "show-modal" ? d.showModal() : !C && x == "close" ? d.close(o.value ? o.value : void 0) : !C && x == "request-close" && (HTMLDialogElement.prototype.requestClose || (HTMLDialogElement.prototype.requestClose = function() {
1363
+ const w = !d.hasAttribute("open");
1364
+ w && x == "show-modal" ? d.showModal() : !w && x == "close" ? d.close(i.value ? i.value : void 0) : !w && x == "request-close" && (HTMLDialogElement.prototype.requestClose || (HTMLDialogElement.prototype.requestClose = function() {
1270
1365
  const T = new Event("cancel", { cancelable: !0 });
1271
1366
  this.dispatchEvent(T), T.defaultPrevented || this.close();
1272
- }), d.requestClose(o.value ? o.value : void 0));
1367
+ }), d.requestClose(i.value ? i.value : void 0));
1273
1368
  }
1274
1369
  }
1275
1370
  function D(r) {
1276
- r.addEventListener("click", k, !0);
1371
+ r.addEventListener("click", y, !0);
1277
1372
  }
1278
- function B(r, i) {
1279
- const o = r.prototype.attachShadow;
1373
+ function V(r, o) {
1374
+ const i = r.prototype.attachShadow;
1280
1375
  r.prototype.attachShadow = function(E) {
1281
- const x = o.call(this, E);
1282
- return i(x), x;
1376
+ const x = i.call(this, E);
1377
+ return o(x), x;
1283
1378
  };
1284
1379
  const d = r.prototype.attachInternals;
1285
1380
  r.prototype.attachInternals = function() {
1286
1381
  const E = d.call(this);
1287
- return E.shadowRoot && i(E.shadowRoot), E;
1382
+ return E.shadowRoot && o(E.shadowRoot), E;
1288
1383
  };
1289
1384
  }
1290
- b(HTMLButtonElement), B(HTMLElement, (r) => {
1291
- D(r), g.observe(r, { attributeFilter: ["oncommand"] }), p(r.querySelectorAll("[oncommand]"));
1292
- }), D(document), Object.assign(globalThis, { CommandEvent: c, InvokeEvent: l });
1385
+ g(HTMLButtonElement), V(HTMLElement, (r) => {
1386
+ D(r), b.observe(r, { attributeFilter: ["oncommand"] }), p(r.querySelectorAll("[oncommand]"));
1387
+ }), D(document), Object.assign(globalThis, { CommandEvent: a, InvokeEvent: l });
1293
1388
  }
1294
1389
  N() || U();