@codbex/harmonia 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/harmonia.js CHANGED
@@ -9,23 +9,18 @@
9
9
  }
10
10
 
11
11
  // node_modules/uuid/dist/rng.js
12
- var getRandomValues;
13
12
  var rnds8 = new Uint8Array(16);
14
13
  function rng() {
15
- if (!getRandomValues) {
16
- if (typeof crypto === "undefined" || !crypto.getRandomValues) {
17
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
18
- }
19
- getRandomValues = crypto.getRandomValues.bind(crypto);
20
- }
21
- return getRandomValues(rnds8);
14
+ return crypto.getRandomValues(rnds8);
22
15
  }
23
16
 
24
- // node_modules/uuid/dist/native.js
25
- var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
26
- var native_default = { randomUUID };
27
-
28
17
  // node_modules/uuid/dist/v4.js
18
+ function v4(options, buf, offset4) {
19
+ if (!buf && !options && crypto.randomUUID) {
20
+ return crypto.randomUUID();
21
+ }
22
+ return _v4(options, buf, offset4);
23
+ }
29
24
  function _v4(options, buf, offset4) {
30
25
  options = options || {};
31
26
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -46,12 +41,6 @@
46
41
  }
47
42
  return unsafeStringify(rnds);
48
43
  }
49
- function v4(options, buf, offset4) {
50
- if (native_default.randomUUID && !buf && !options) {
51
- return native_default.randomUUID();
52
- }
53
- return _v4(options, buf, offset4);
54
- }
55
44
  var v4_default = v4;
56
45
 
57
46
  // src/common/icons.js
@@ -304,10 +293,10 @@
304
293
  }) : { single: false };
305
294
  el.setAttribute("data-slot", "accordion");
306
295
  });
307
- Alpine.directive("h-accordion-item", (el, { original, expression, modifiers }, { effect, Alpine: Alpine2 }) => {
296
+ Alpine.directive("h-accordion-item", (el, { original: original2, expression, modifiers }, { effect, Alpine: Alpine2 }) => {
308
297
  const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
309
298
  if (!accordion) {
310
- throw new Error(`${original} must be inside an accordion`);
299
+ throw new Error(`${original2} must be inside an accordion`);
311
300
  }
312
301
  el.classList.add("border-b", "last:border-b-0", "[[data-variant=header]_&]:data-[state=closed]:border-b-0");
313
302
  el.setAttribute("data-slot", "accordion-item");
@@ -335,14 +324,14 @@
335
324
  setAttributes();
336
325
  effect(setAttributes);
337
326
  });
338
- Alpine.directive("h-accordion-trigger", (el, { original, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
327
+ Alpine.directive("h-accordion-trigger", (el, { original: original2, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
339
328
  if (el.tagName.length !== 2 && !el.tagName.startsWith("H")) {
340
- throw new Error(`${original} must be a header element`);
329
+ throw new Error(`${original2} must be a header element`);
341
330
  }
342
331
  const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
343
332
  const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordionItem"));
344
333
  if (!accordionItem || !accordion) {
345
- throw new Error(`${original} must have an accordion and accordion item parent elements`);
334
+ throw new Error(`${original2} must have an accordion and accordion item parent elements`);
346
335
  }
347
336
  el.classList.add(
348
337
  "flex",
@@ -527,10 +516,10 @@
527
516
  el.classList.add("cursor-pointer", "hover:bg-secondary-hover", "active:bg-secondary-active");
528
517
  }
529
518
  });
530
- Alpine.directive("h-avatar-image", (el, { original }, { cleanup }) => {
519
+ Alpine.directive("h-avatar-image", (el, { original: original2 }, { cleanup }) => {
531
520
  const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
532
521
  if (!avatar) {
533
- throw new Error(`${original} must be inside an avatar element`);
522
+ throw new Error(`${original2} must be inside an avatar element`);
534
523
  }
535
524
  el.classList.add("aspect-square", "size-full");
536
525
  el.setAttribute("data-slot", "avatar-image");
@@ -561,10 +550,10 @@
561
550
  observer.disconnect();
562
551
  });
563
552
  });
564
- Alpine.directive("h-avatar-fallback", (el, { original }, { effect }) => {
553
+ Alpine.directive("h-avatar-fallback", (el, { original: original2 }, { effect }) => {
565
554
  const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
566
555
  if (!avatar) {
567
- throw new Error(`${original} must be inside an avatar element`);
556
+ throw new Error(`${original2} must be inside an avatar element`);
568
557
  }
569
558
  el.classList.add("hidden", "bg-muted", "flex", "size-full", "items-center", "justify-center");
570
559
  el.setAttribute("data-slot", "avatar-fallback");
@@ -773,7 +762,7 @@
773
762
  }
774
763
  };
775
764
  function button_default(Alpine) {
776
- Alpine.directive("h-button", (el, { original, modifiers }, { cleanup }) => {
765
+ Alpine.directive("h-button", (el, { original: original2, modifiers }, { cleanup }) => {
777
766
  setButtonClasses(el);
778
767
  if (!el.hasAttribute("data-slot")) {
779
768
  el.setAttribute("data-slot", "button");
@@ -790,7 +779,7 @@
790
779
  el.classList.remove(...getButtonSize(lastSize, isAddon));
791
780
  el.classList.add(...getButtonSize(size3, isAddon));
792
781
  if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
793
- console.error(`${original}: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute`, el);
782
+ console.error(`${original2}: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute`, el);
794
783
  }
795
784
  lastSize = size3;
796
785
  }
@@ -2344,7 +2333,7 @@
2344
2333
 
2345
2334
  // src/components/calendar.js
2346
2335
  function calendar_default(Alpine) {
2347
- Alpine.directive("h-calendar", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
2336
+ Alpine.directive("h-calendar", (el, { original: original2, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
2348
2337
  const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
2349
2338
  el.classList.add("border", "rounded-control", "gap-2", "p-2");
2350
2339
  el.setAttribute("tabindex", "-1");
@@ -2388,7 +2377,7 @@
2388
2377
  const onInputChange = () => {
2389
2378
  const newValue = new Date(datepicker._h_datepicker.input.value);
2390
2379
  if (isNaN(newValue)) {
2391
- console.error(`${original}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
2380
+ console.error(`${original2}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
2392
2381
  datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
2393
2382
  return;
2394
2383
  } else if (selected.getTime() !== newValue.getTime()) {
@@ -2405,7 +2394,7 @@
2405
2394
  if (el.hasOwnProperty("_x_model") && el._x_model.get()) {
2406
2395
  selected = new Date(el._x_model.get());
2407
2396
  if (isNaN(selected)) {
2408
- console.error(`${original}: input value is not a valid date - ${el._x_model.get()}`);
2397
+ console.error(`${original2}: input value is not a valid date - ${el._x_model.get()}`);
2409
2398
  if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
2410
2399
  else el.setAttribute("data-invalid", "true");
2411
2400
  } else if (datepicker) {
@@ -2914,10 +2903,10 @@
2914
2903
  });
2915
2904
  }
2916
2905
  });
2917
- Alpine.directive("h-collapsible-trigger", (el, { original, modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
2906
+ Alpine.directive("h-collapsible-trigger", (el, { original: original2, modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
2918
2907
  const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2919
2908
  if (!collapsible) {
2920
- throw new Error(`${original} must be inside a collapsible element`);
2909
+ throw new Error(`${original2} must be inside a collapsible element`);
2921
2910
  }
2922
2911
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-trigger");
2923
2912
  if (modifiers.includes("chevron")) {
@@ -2936,10 +2925,10 @@
2936
2925
  el.removeEventListener("click", handler);
2937
2926
  });
2938
2927
  });
2939
- Alpine.directive("h-collapsible-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
2928
+ Alpine.directive("h-collapsible-content", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
2940
2929
  const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2941
2930
  if (!collapsible) {
2942
- throw new Error(`${original} must be inside an h-collapsible element`);
2931
+ throw new Error(`${original2} must be inside an h-collapsible element`);
2943
2932
  }
2944
2933
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-content");
2945
2934
  el.classList.add("data-[state=closed]:!hidden");
@@ -2970,7 +2959,7 @@
2970
2959
 
2971
2960
  // src/components/datepicker.js
2972
2961
  function datepicker_default(Alpine) {
2973
- Alpine.directive("h-date-picker", (el, { original, modifiers }, { Alpine: Alpine2, cleanup }) => {
2962
+ Alpine.directive("h-date-picker", (el, { original: original2, modifiers }, { Alpine: Alpine2, cleanup }) => {
2974
2963
  const state = Alpine2.reactive({
2975
2964
  expanded: false
2976
2965
  });
@@ -2983,7 +2972,7 @@
2983
2972
  };
2984
2973
  el._h_datepicker.input = el.querySelector("input");
2985
2974
  if (!el._h_datepicker.input || el._h_datepicker.input.tagName !== "INPUT") {
2986
- throw new Error(`${original} must contain an input`);
2975
+ throw new Error(`${original2} must contain an input`);
2987
2976
  } else if (el._h_datepicker.input.hasAttribute("id")) {
2988
2977
  el._h_datepicker.id = el._h_datepicker.input.getAttribute("id");
2989
2978
  } else {
@@ -3060,16 +3049,16 @@
3060
3049
  observer.disconnect();
3061
3050
  });
3062
3051
  });
3063
- Alpine.directive("h-date-picker-trigger", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
3052
+ Alpine.directive("h-date-picker-trigger", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
3064
3053
  if (el.tagName !== "BUTTON") {
3065
- throw new Error(`${original} must be a button`);
3054
+ throw new Error(`${original2} must be a button`);
3066
3055
  }
3067
3056
  if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
3068
- throw new Error(`${original}: must have an "aria-label" or "aria-labelledby" attribute`);
3057
+ throw new Error(`${original2}: must have an "aria-label" or "aria-labelledby" attribute`);
3069
3058
  }
3070
3059
  const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
3071
3060
  if (!datepicker) {
3072
- throw new Error(`${original} must be inside an date-picker element`);
3061
+ throw new Error(`${original2} must be inside an date-picker element`);
3073
3062
  }
3074
3063
  el.classList.add("cursor-pointer", "inline-flex", "items-center", "justify-center", "h-full", "aspect-square", "bg-transparent", "hover:bg-secondary", "active:bg-secondary-active", "outline-none");
3075
3064
  if (datepicker._h_datepicker.inTable) {
@@ -3349,13 +3338,13 @@
3349
3338
 
3350
3339
  // src/components/icon.js
3351
3340
  function icon_default(Alpine) {
3352
- Alpine.directive("h-icon", (el, { original, modifiers }) => {
3341
+ Alpine.directive("h-icon", (el, { original: original2, modifiers }) => {
3353
3342
  if (el.tagName.toLowerCase() !== "svg") {
3354
- throw new Error(`${original} works only on svg elements`);
3343
+ throw new Error(`${original2} works only on svg elements`);
3355
3344
  } else if (!el.hasAttribute("role")) {
3356
- throw new Error(`${original} must have a role`);
3345
+ throw new Error(`${original2} must have a role`);
3357
3346
  } else if (el.getAttribute("role") === "img" && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
3358
- throw new Error(`${original}: svg images with the role of img must have an "aria-label" or "aria-labelledby" attribute`);
3347
+ throw new Error(`${original2}: svg images with the role of img must have an "aria-label" or "aria-labelledby" attribute`);
3359
3348
  }
3360
3349
  el.classList.add("fill-current");
3361
3350
  el.setAttribute("data-slot", "icon");
@@ -3572,7 +3561,7 @@
3572
3561
  el.classList.add("text-muted-foreground", "flex", "items-center", "gap-2", "text-sm", "[&_svg]:pointer-events-none", "[&_svg:not([class*='size-'])]:size-4");
3573
3562
  el.setAttribute("data-slot", "label");
3574
3563
  });
3575
- Alpine.directive("h-input-number", (el, { original }, { cleanup }) => {
3564
+ Alpine.directive("h-input-number", (el, { original: original2 }, { cleanup }) => {
3576
3565
  el.classList.add(
3577
3566
  "overflow-hidden",
3578
3567
  "group/input-number",
@@ -3605,7 +3594,7 @@
3605
3594
  el.setAttribute("data-slot", "input-number");
3606
3595
  const input = el.querySelector("input");
3607
3596
  if (!input || input.getAttribute("type") !== "number") {
3608
- throw new Error(`${original} must contain an input of type 'number'`);
3597
+ throw new Error(`${original2} must contain an input of type 'number'`);
3609
3598
  }
3610
3599
  if (!input.hasAttribute("type")) input.setAttribute("type", "number");
3611
3600
  if (!input.hasAttribute("inputmode")) input.setAttribute("inputmode", "numeric");
@@ -3851,13 +3840,13 @@
3851
3840
  el.setAttribute("data-slot", "list");
3852
3841
  el.setAttribute("role", "group");
3853
3842
  });
3854
- Alpine.directive("h-list-header", (el, { original }, { Alpine: Alpine2 }) => {
3843
+ Alpine.directive("h-list-header", (el, { original: original2 }, { Alpine: Alpine2 }) => {
3855
3844
  el.classList.add("font-medium", "flex", "items-center", "p-2", "gap-2", "align-middle", "bg-table-header", "text-table-header-foreground");
3856
3845
  el.setAttribute("role", "presentation");
3857
3846
  el.setAttribute("data-slot", "list-header");
3858
3847
  const list = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "list");
3859
3848
  if (!list) {
3860
- throw new Error(`${original} must be placed inside a list element`);
3849
+ throw new Error(`${original2} must be placed inside a list element`);
3861
3850
  }
3862
3851
  if (!el.hasAttribute("id")) {
3863
3852
  const id = `lbh${v4_default()}`;
@@ -3909,9 +3898,9 @@
3909
3898
  };
3910
3899
  el.setAttribute("data-state", "closed");
3911
3900
  });
3912
- Alpine.directive("h-menu", (el, { original, modifiers }, { cleanup, Alpine: Alpine2 }) => {
3901
+ Alpine.directive("h-menu", (el, { original: original2, modifiers }, { cleanup, Alpine: Alpine2 }) => {
3913
3902
  if (el.tagName !== "UL") {
3914
- throw new Error(`${original} must be an ul element`);
3903
+ throw new Error(`${original2} must be an ul element`);
3915
3904
  }
3916
3905
  el.classList.add("hidden", "fixed", "bg-popover", "text-popover-foreground", "font-normal", "z-50", "min-w-[8rem]", "overflow-x-hidden", "overflow-y-auto", "rounded-md", "p-1", "shadow-md", "border", "outline-none");
3917
3906
  el.setAttribute("role", "menu");
@@ -3919,7 +3908,7 @@
3919
3908
  el.setAttribute("tabindex", "-1");
3920
3909
  el.setAttribute("data-slot", "menu");
3921
3910
  if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
3922
- throw new Error(`${original} must have an "aria-label" or "aria-labelledby" attribute`);
3911
+ throw new Error(`${original2} must have an "aria-label" or "aria-labelledby" attribute`);
3923
3912
  }
3924
3913
  const isSubmenu = modifiers.includes("sub");
3925
3914
  const menuTrigger = (() => {
@@ -3931,7 +3920,7 @@
3931
3920
  return sibling;
3932
3921
  })();
3933
3922
  if (!isSubmenu && !menuTrigger) {
3934
- throw new Error(`${original} menu must be placed after a menu trigger element`);
3923
+ throw new Error(`${original2} menu must be placed after a menu trigger element`);
3935
3924
  }
3936
3925
  let menuSubItem;
3937
3926
  if (isSubmenu) menuSubItem = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "menu-sub");
@@ -4150,9 +4139,9 @@
4150
4139
  el.removeEventListener("keydown", onKeyDown);
4151
4140
  });
4152
4141
  });
4153
- Alpine.directive("h-menu-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4142
+ Alpine.directive("h-menu-item", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4154
4143
  if (el.tagName !== "LI") {
4155
- throw new Error(`${original} must be a li element`);
4144
+ throw new Error(`${original2} must be a li element`);
4156
4145
  }
4157
4146
  el.classList.add(
4158
4147
  "focus:bg-secondary-hover",
@@ -4206,7 +4195,7 @@
4206
4195
  el.removeEventListener("mouseleave", focusOut);
4207
4196
  });
4208
4197
  });
4209
- Alpine.directive("h-menu-sub", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4198
+ Alpine.directive("h-menu-sub", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4210
4199
  el.classList.add(
4211
4200
  "focus:bg-secondary-hover",
4212
4201
  "hover:bg-secondary-hover",
@@ -4238,7 +4227,7 @@
4238
4227
  const chevronRight = createSvg({ icon: ChevronRight, classes: "size-4 ml-auto", attrs: { "aria-hidden": true, role: "presentation" } });
4239
4228
  el.appendChild(chevronRight);
4240
4229
  const parentMenu = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "menu");
4241
- if (!parentMenu) throw new Error(`${original} must have a parent`);
4230
+ if (!parentMenu) throw new Error(`${original2} must have a parent`);
4242
4231
  el._menu_sub = {
4243
4232
  open: void 0,
4244
4233
  close: void 0,
@@ -4332,9 +4321,9 @@
4332
4321
  el.classList.add("text-foreground", "px-2", "py-1.5", "text-sm", "font-semibold", "text-left", "data-[inset=true]:pl-8");
4333
4322
  el.setAttribute("data-slot", "menu-label");
4334
4323
  });
4335
- Alpine.directive("h-menu-checkbox-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4324
+ Alpine.directive("h-menu-checkbox-item", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4336
4325
  if (el.tagName !== "LI" && el.tagName !== "DIV") {
4337
- throw new Error(`${original} must be a li or div element`);
4326
+ throw new Error(`${original2} must be a li or div element`);
4338
4327
  }
4339
4328
  el.classList.add(
4340
4329
  "focus:bg-secondary-hover",
@@ -4400,9 +4389,9 @@
4400
4389
  el.removeEventListener("mouseleave", focusOut);
4401
4390
  });
4402
4391
  });
4403
- Alpine.directive("h-menu-radio-item", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
4392
+ Alpine.directive("h-menu-radio-item", (el, { original: original2, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
4404
4393
  if (el.tagName !== "LI" && el.tagName !== "DIV") {
4405
- throw new Error(`${original} must be a li or div element`);
4394
+ throw new Error(`${original2} must be a li or div element`);
4406
4395
  }
4407
4396
  el.classList.add(
4408
4397
  "focus:bg-secondary-hover",
@@ -4631,7 +4620,7 @@
4631
4620
  });
4632
4621
  }
4633
4622
  });
4634
- Alpine.directive("h-popover", (el, { original, modifiers }, { effect }) => {
4623
+ Alpine.directive("h-popover", (el, { original: original2, modifiers }, { effect }) => {
4635
4624
  const popover = (() => {
4636
4625
  let sibling = el.previousElementSibling;
4637
4626
  while (sibling && !sibling.hasOwnProperty("_popover")) {
@@ -4640,7 +4629,7 @@
4640
4629
  return sibling;
4641
4630
  })();
4642
4631
  if (!popover) {
4643
- throw new Error(`${original} must be placed after a popover element`);
4632
+ throw new Error(`${original2} must be placed after a popover element`);
4644
4633
  }
4645
4634
  el.classList.add("absolute", "bg-popover", "text-popover-foreground", "data-[state=closed]:hidden", "top-0", "left-0", "z-50", "min-w-[1rem]", "rounded-md", "border", "shadow-md", "outline-hidden", "overflow-auto");
4646
4635
  el.setAttribute("data-slot", "popover");
@@ -6702,9 +6691,9 @@
6702
6691
  });
6703
6692
  }
6704
6693
  });
6705
- Alpine.directive("h-select-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
6694
+ Alpine.directive("h-select-input", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
6706
6695
  if (el.tagName !== "INPUT") {
6707
- throw new Error(`${original} must be an input of type "text"`);
6696
+ throw new Error(`${original2} must be an input of type "text"`);
6708
6697
  }
6709
6698
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6710
6699
  const label = (() => {
@@ -6715,7 +6704,7 @@
6715
6704
  return;
6716
6705
  })();
6717
6706
  if (!select) {
6718
- throw new Error(`${original} must be inside a select element`);
6707
+ throw new Error(`${original2} must be inside a select element`);
6719
6708
  } else if (el.hasOwnProperty("_x_model")) {
6720
6709
  select._h_select.multiple = Array.isArray(el._x_model.get());
6721
6710
  select._h_model.set = (value) => {
@@ -6735,6 +6724,7 @@
6735
6724
  } else {
6736
6725
  el._x_model.set("");
6737
6726
  }
6727
+ el.dispatchEvent(new Event("change", { bubbles: true }));
6738
6728
  };
6739
6729
  select._h_model.get = el._x_model.get;
6740
6730
  } else {
@@ -6975,10 +6965,10 @@
6975
6965
  }
6976
6966
  });
6977
6967
  });
6978
- Alpine.directive("h-select-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
6968
+ Alpine.directive("h-select-content", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
6979
6969
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6980
6970
  if (!select) {
6981
- throw new Error(`${original} must be inside a select element`);
6971
+ throw new Error(`${original2} must be inside a select element`);
6982
6972
  }
6983
6973
  el.classList.add("absolute", "bg-popover", "text-popover-foreground", "data-[state=closed]:hidden", "p-1", "top-0", "left-0", "z-50", "min-w-[1rem]", "overflow-x-hidden", "overflow-y-auto", "rounded-md", "border", "shadow-md");
6984
6974
  el.setAttribute("data-slot", "select-content");
@@ -6987,7 +6977,7 @@
6987
6977
  el.setAttribute("tabindex", "-1");
6988
6978
  el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
6989
6979
  if (!select._h_select.trigger) {
6990
- throw new Error(`${original}: trigger not found`);
6980
+ throw new Error(`${original2}: trigger not found`);
6991
6981
  }
6992
6982
  let autoUpdateCleanup;
6993
6983
  function updatePosition() {
@@ -7029,10 +7019,10 @@
7029
7019
  }
7030
7020
  });
7031
7021
  });
7032
- Alpine.directive("h-select-search", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
7022
+ Alpine.directive("h-select-search", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
7033
7023
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
7034
7024
  if (!select) {
7035
- throw new Error(`${original} must be inside an h-select element`);
7025
+ throw new Error(`${original2} must be inside an h-select element`);
7036
7026
  } else {
7037
7027
  select._h_select.filterType = FilterType[el.getAttribute("data-filter")] ?? FilterType["starts-with"];
7038
7028
  }
@@ -7104,10 +7094,10 @@
7104
7094
  selectGroup._h_selectGroup.labelledby = id;
7105
7095
  }
7106
7096
  });
7107
- Alpine.directive("h-select-option", (el, { original, expression }, { effect, evaluateLater, cleanup }) => {
7097
+ Alpine.directive("h-select-option", (el, { original: original2, expression }, { effect, evaluateLater, cleanup }) => {
7108
7098
  const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
7109
7099
  if (!select) {
7110
- throw new Error(`${original} must be inside an h-select element`);
7100
+ throw new Error(`${original2} must be inside an h-select element`);
7111
7101
  }
7112
7102
  el.classList.add(
7113
7103
  "focus:bg-primary",
@@ -7361,10 +7351,10 @@
7361
7351
  });
7362
7352
  }
7363
7353
  });
7364
- Alpine.directive("h-sidebar-group-label", (el, { original }, { cleanup }) => {
7354
+ Alpine.directive("h-sidebar-group-label", (el, { original: original2 }, { cleanup }) => {
7365
7355
  const group = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_group"));
7366
7356
  if (!group) {
7367
- throw new Error(`${original} must be placed inside a sidebar group`);
7357
+ throw new Error(`${original2} must be placed inside a sidebar group`);
7368
7358
  }
7369
7359
  el.classList.add(
7370
7360
  "ring-sidebar-ring",
@@ -7451,10 +7441,10 @@
7451
7441
  }
7452
7442
  el.setAttribute("data-slot", "sidebar-group-action");
7453
7443
  });
7454
- Alpine.directive("h-sidebar-group-content", (el, { original }, { effect }) => {
7444
+ Alpine.directive("h-sidebar-group-content", (el, { original: original2 }, { effect }) => {
7455
7445
  const group = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_group"));
7456
7446
  if (!group) {
7457
- throw new Error(`${original} must be placed inside a sidebar group`);
7447
+ throw new Error(`${original2} must be placed inside a sidebar group`);
7458
7448
  }
7459
7449
  el.classList.add("w-full", "text-sm", "data-[collapsed=true]:hidden", "group-data-[collapsed=true]/sidebar:!block");
7460
7450
  el.setAttribute("data-slot", "sidebar-group-content");
@@ -7467,16 +7457,16 @@
7467
7457
  });
7468
7458
  }
7469
7459
  });
7470
- Alpine.directive("h-sidebar-menu", (el, { original }) => {
7460
+ Alpine.directive("h-sidebar-menu", (el, { original: original2 }) => {
7471
7461
  if (el.tagName !== "UL") {
7472
- throw new Error(`${original} must be an ul element`);
7462
+ throw new Error(`${original2} must be an ul element`);
7473
7463
  }
7474
7464
  el.classList.add("vbox", "w-full", "min-w-0", "gap-1");
7475
7465
  el.setAttribute("data-slot", "sidebar-menu");
7476
7466
  });
7477
- Alpine.directive("h-sidebar-menu-item", (el, { original, expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
7467
+ Alpine.directive("h-sidebar-menu-item", (el, { original: original2, expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
7478
7468
  if (el.tagName !== "LI") {
7479
- throw new Error(`${original} must be a li element`);
7469
+ throw new Error(`${original2} must be a li element`);
7480
7470
  }
7481
7471
  el._h_sidebar_menu_item = {
7482
7472
  isSub: false,
@@ -7512,9 +7502,9 @@
7512
7502
  });
7513
7503
  }
7514
7504
  });
7515
- Alpine.directive("h-sidebar-menu-button", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
7505
+ Alpine.directive("h-sidebar-menu-button", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
7516
7506
  if (el.tagName !== "BUTTON" && el.tagName !== "A") {
7517
- throw new Error(`${original} must be a button or a link`);
7507
+ throw new Error(`${original2} must be a button or a link`);
7518
7508
  } else if (el.tagName === "BUTTON") {
7519
7509
  el.setAttribute("type", "button");
7520
7510
  }
@@ -7650,9 +7640,9 @@
7650
7640
  }
7651
7641
  el.setAttribute("data-slot", "sidebar-menu-action");
7652
7642
  });
7653
- Alpine.directive("h-sidebar-menu-badge", (el, { original }) => {
7643
+ Alpine.directive("h-sidebar-menu-badge", (el, { original: original2 }) => {
7654
7644
  if (el.tagName !== "SPAN") {
7655
- throw new Error(`${original} must be a span element`);
7645
+ throw new Error(`${original2} must be a span element`);
7656
7646
  }
7657
7647
  el.classList.add("flex-1", "pointer-events-none", "flex", "h-full", "min-w-min", "items-center", "justify-end", "text-xs", "font-medium", "tabular-nums", "select-none", "group-data-[collapsed=true]/sidebar:hidden");
7658
7648
  el.setAttribute("data-slot", "sidebar-menu-badge");
@@ -7678,13 +7668,13 @@
7678
7668
  el.setAttribute("data-slot", "sidebar-separator");
7679
7669
  el.setAttribute("role", "none");
7680
7670
  });
7681
- Alpine.directive("h-sidebar-menu-sub", (el, { original }, { effect, Alpine: Alpine2 }) => {
7671
+ Alpine.directive("h-sidebar-menu-sub", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
7682
7672
  if (el.tagName !== "UL") {
7683
- throw new Error(`${original} must be an ul element`);
7673
+ throw new Error(`${original2} must be an ul element`);
7684
7674
  }
7685
7675
  const menuItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_menu_item"));
7686
7676
  if (!menuItem) {
7687
- throw new Error(`${original} must be placed inside a sidebar menu item`);
7677
+ throw new Error(`${original2} must be placed inside a sidebar menu item`);
7688
7678
  }
7689
7679
  el.classList.add("vbox", "min-w-0", "translate-x-px", "gap-1", "pl-2.5", "py-0.5", "ml-3.5", "data-[collapsed=true]:!hidden", "group-data-[collapsed=true]/sidebar:!hidden");
7690
7680
  if (el.getAttribute("data-line") !== "false") {
@@ -7953,10 +7943,10 @@
7953
7943
  observer.disconnect();
7954
7944
  });
7955
7945
  });
7956
- Alpine.directive("h-split-panel", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
7946
+ Alpine.directive("h-split-panel", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
7957
7947
  const split = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_split"));
7958
7948
  if (!split) {
7959
- throw new Error(`${original} must be inside an split element`);
7949
+ throw new Error(`${original2} must be inside an split element`);
7960
7950
  }
7961
7951
  el.classList.add("flex", "shrink", "grow-0", "box-border", "min-w-0", "min-h-0", "overflow-visible");
7962
7952
  el.setAttribute("tabindex", "-1");
@@ -8480,7 +8470,7 @@
8480
8470
  el.setAttribute("role", "tablist");
8481
8471
  el.setAttribute("data-slot", "tab-list");
8482
8472
  });
8483
- Alpine.directive("h-tab", (el, { original }) => {
8473
+ Alpine.directive("h-tab", (el, { original: original2 }) => {
8484
8474
  el.classList.add(
8485
8475
  "cursor-pointer",
8486
8476
  "focus-visible:border-ring",
@@ -8527,8 +8517,8 @@
8527
8517
  );
8528
8518
  el.setAttribute("role", "tab");
8529
8519
  el.setAttribute("data-slot", "tab");
8530
- if (!el.hasAttribute("id")) throw new Error(`${original}: Tabs must have an id`);
8531
- if (!el.hasAttribute("aria-controls")) throw new Error(`${original}: aria-controls must be set to the tab-content id.`);
8520
+ if (!el.hasAttribute("id")) throw new Error(`${original2}: Tabs must have an id`);
8521
+ if (!el.hasAttribute("aria-controls")) throw new Error(`${original2}: aria-controls must be set to the tab-content id.`);
8532
8522
  });
8533
8523
  Alpine.directive("h-tab-action", (el) => {
8534
8524
  el.classList.add("cursor-pointer", "ml-auto", "rounded-md", "text-foreground", "hover:bg-secondary", "hover:text-secondary-foreground", "active:bg-secondary-active");
@@ -8562,13 +8552,13 @@
8562
8552
  el.setAttribute("role", "button");
8563
8553
  el.setAttribute("data-slot", "tab-list-action");
8564
8554
  });
8565
- Alpine.directive("h-tabs-content", (el, { original }) => {
8555
+ Alpine.directive("h-tabs-content", (el, { original: original2 }) => {
8566
8556
  el.classList.add("flex-1", "outline-none");
8567
8557
  el.setAttribute("role", "tabpanel");
8568
8558
  el.setAttribute("tabindex", "0");
8569
8559
  el.setAttribute("data-slot", "tabs-content");
8570
- if (!el.hasAttribute("id")) throw new Error(`${original}: Tab content must have an id`);
8571
- if (!el.hasAttribute("aria-labelledby")) throw new Error(`${original}: aria-labelledby must be set to the tab id.`);
8560
+ if (!el.hasAttribute("id")) throw new Error(`${original2}: Tab content must have an id`);
8561
+ if (!el.hasAttribute("aria-labelledby")) throw new Error(`${original2}: aria-labelledby must be set to the tab id.`);
8572
8562
  });
8573
8563
  }
8574
8564
 
@@ -8961,13 +8951,13 @@
8961
8951
  top.removeEventListener("click", el._h_timepicker.close);
8962
8952
  });
8963
8953
  });
8964
- Alpine.directive("h-time-picker-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
8954
+ Alpine.directive("h-time-picker-input", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
8965
8955
  if (el.tagName !== "INPUT") {
8966
- throw new Error(`${original} must be a readonly input of type "text"`);
8956
+ throw new Error(`${original2} must be a readonly input of type "text"`);
8967
8957
  }
8968
8958
  const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
8969
8959
  if (!timepicker) {
8970
- throw new Error(`${original} must be inside a time-picker element`);
8960
+ throw new Error(`${original2} must be inside a time-picker element`);
8971
8961
  }
8972
8962
  timepicker._h_timepicker.focusInput = () => {
8973
8963
  el.focus();
@@ -9616,7 +9606,7 @@
9616
9606
  el.removeEventListener("pointerleave", handler);
9617
9607
  });
9618
9608
  });
9619
- Alpine.directive("h-tooltip", (el, { original }, { effect }) => {
9609
+ Alpine.directive("h-tooltip", (el, { original: original2 }, { effect }) => {
9620
9610
  const tooltip = (() => {
9621
9611
  let sibling = el.previousElementSibling;
9622
9612
  while (sibling && !sibling.hasOwnProperty("_tooltip")) {
@@ -9625,7 +9615,7 @@
9625
9615
  return sibling;
9626
9616
  })();
9627
9617
  if (!tooltip) {
9628
- throw new Error(`${original} must be placed after a tooltip trigger element`);
9618
+ throw new Error(`${original2} must be placed after a tooltip trigger element`);
9629
9619
  }
9630
9620
  el.classList.add("absolute", "bg-foreground", "text-background", "z-50", "w-fit", "rounded-md", "px-3", "py-1.5", "text-xs", "text-balance");
9631
9621
  el.setAttribute("data-slot", "tooltip");
@@ -9831,9 +9821,9 @@
9831
9821
  });
9832
9822
  }
9833
9823
  });
9834
- Alpine.directive("h-tree-button", (el, { original }, { effect }) => {
9824
+ Alpine.directive("h-tree-button", (el, { original: original2 }, { effect }) => {
9835
9825
  const treeItem = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_tree_item"));
9836
- if (!treeItem) throw new Error(`${original} must be inside a tree item`);
9826
+ if (!treeItem) throw new Error(`${original2} must be inside a tree item`);
9837
9827
  el.classList.add(
9838
9828
  "flex",
9839
9829
  "w-full",
@@ -9956,6 +9946,12 @@
9956
9946
  }
9957
9947
  return "light";
9958
9948
  };
9949
+ var getSystemColorScheme = () => {
9950
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
9951
+ return "dark";
9952
+ }
9953
+ return "light";
9954
+ };
9959
9955
  var addColorSchemeListener = (callback) => {
9960
9956
  callbacks.push(callback);
9961
9957
  };
@@ -9988,7 +9984,7 @@
9988
9984
 
9989
9985
  // src/utils/template.js
9990
9986
  function template_default(Alpine) {
9991
- Alpine.directive("h-template", (el, { original, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
9987
+ Alpine.directive("h-template", (el, { original: original2, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
9992
9988
  if (el.hasAttribute(Alpine2.prefixed("data"))) {
9993
9989
  const template = evaluate2(expression);
9994
9990
  const clone = template.content.cloneNode(true).firstElementChild;
@@ -10002,11 +9998,55 @@
10002
9998
  clone.remove();
10003
9999
  });
10004
10000
  } else {
10005
- console.error(`${original}: ${Alpine2.prefixed("data")} directive is missing`);
10001
+ console.error(`${original2}: ${Alpine2.prefixed("data")} directive is missing`);
10006
10002
  }
10007
10003
  });
10008
10004
  }
10009
10005
 
10006
+ // src/utils/include.js
10007
+ function include_default(Alpine) {
10008
+ Alpine.directive("h-include", (el, { modifiers, expression }, { evaluateLater, effect }) => {
10009
+ const getUrl = evaluateLater(expression);
10010
+ function getHtml(url) {
10011
+ const parsed = new URL(url, window.location.origin);
10012
+ if (parsed.origin === window.location.origin) {
10013
+ fetch(url).then((response) => {
10014
+ if (response.status === 200) return response.text();
10015
+ throw response;
10016
+ }).then((content) => {
10017
+ if (modifiers.includes("js")) {
10018
+ const container = document.createElement("div");
10019
+ container.innerHTML = content;
10020
+ let staticScript = container.querySelector("script");
10021
+ const script = document.createElement("script");
10022
+ for (let a = 0; a < staticScript.attributes.length; a++) {
10023
+ script.setAttribute(staticScript.attributes[a].name, staticScript.attributes[a].value);
10024
+ }
10025
+ script.appendChild(document.createTextNode(staticScript.innerHTML));
10026
+ staticScript.remove();
10027
+ while (container.childNodes.length > 0) {
10028
+ el.appendChild(container.childNodes[0]);
10029
+ }
10030
+ el.appendChild(script);
10031
+ } else {
10032
+ el.innerHTML = content;
10033
+ }
10034
+ }).catch((response) => {
10035
+ console.error(response);
10036
+ });
10037
+ } else {
10038
+ throw new Error(`${original}: external requests not allowed`);
10039
+ }
10040
+ }
10041
+ effect(() => {
10042
+ getUrl((url) => {
10043
+ if (url) getHtml(url);
10044
+ else el.innerHTML = "";
10045
+ });
10046
+ });
10047
+ }).before("bind");
10048
+ }
10049
+
10010
10050
  // src/utils/focus.js
10011
10051
  function focus_default(Alpine) {
10012
10052
  Alpine.directive("h-focus", (el, { expression }, { effect, evaluateLater }) => {
@@ -10020,10 +10060,10 @@
10020
10060
  }
10021
10061
 
10022
10062
  // package.json
10023
- var version = "1.4.2";
10063
+ var version = "1.5.1";
10024
10064
 
10025
10065
  // src/index.js
10026
- window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, version };
10066
+ window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
10027
10067
  document.addEventListener("alpine:init", () => {
10028
10068
  window.Alpine.plugin(accordion_default);
10029
10069
  window.Alpine.plugin(alert_default);
@@ -10068,5 +10108,6 @@
10068
10108
  window.Alpine.plugin(tree_default);
10069
10109
  window.Alpine.plugin(focus_default);
10070
10110
  window.Alpine.plugin(template_default);
10111
+ window.Alpine.plugin(include_default);
10071
10112
  });
10072
10113
  })();