@codbex/harmonia 1.4.2 → 1.5.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.
package/dist/harmonia.js CHANGED
@@ -304,10 +304,10 @@
304
304
  }) : { single: false };
305
305
  el.setAttribute("data-slot", "accordion");
306
306
  });
307
- Alpine.directive("h-accordion-item", (el, { original, expression, modifiers }, { effect, Alpine: Alpine2 }) => {
307
+ Alpine.directive("h-accordion-item", (el, { original: original2, expression, modifiers }, { effect, Alpine: Alpine2 }) => {
308
308
  const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
309
309
  if (!accordion) {
310
- throw new Error(`${original} must be inside an accordion`);
310
+ throw new Error(`${original2} must be inside an accordion`);
311
311
  }
312
312
  el.classList.add("border-b", "last:border-b-0", "[[data-variant=header]_&]:data-[state=closed]:border-b-0");
313
313
  el.setAttribute("data-slot", "accordion-item");
@@ -335,14 +335,14 @@
335
335
  setAttributes();
336
336
  effect(setAttributes);
337
337
  });
338
- Alpine.directive("h-accordion-trigger", (el, { original, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
338
+ Alpine.directive("h-accordion-trigger", (el, { original: original2, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
339
339
  if (el.tagName.length !== 2 && !el.tagName.startsWith("H")) {
340
- throw new Error(`${original} must be a header element`);
340
+ throw new Error(`${original2} must be a header element`);
341
341
  }
342
342
  const accordion = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordion"));
343
343
  const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_accordionItem"));
344
344
  if (!accordionItem || !accordion) {
345
- throw new Error(`${original} must have an accordion and accordion item parent elements`);
345
+ throw new Error(`${original2} must have an accordion and accordion item parent elements`);
346
346
  }
347
347
  el.classList.add(
348
348
  "flex",
@@ -527,10 +527,10 @@
527
527
  el.classList.add("cursor-pointer", "hover:bg-secondary-hover", "active:bg-secondary-active");
528
528
  }
529
529
  });
530
- Alpine.directive("h-avatar-image", (el, { original }, { cleanup }) => {
530
+ Alpine.directive("h-avatar-image", (el, { original: original2 }, { cleanup }) => {
531
531
  const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
532
532
  if (!avatar) {
533
- throw new Error(`${original} must be inside an avatar element`);
533
+ throw new Error(`${original2} must be inside an avatar element`);
534
534
  }
535
535
  el.classList.add("aspect-square", "size-full");
536
536
  el.setAttribute("data-slot", "avatar-image");
@@ -561,10 +561,10 @@
561
561
  observer.disconnect();
562
562
  });
563
563
  });
564
- Alpine.directive("h-avatar-fallback", (el, { original }, { effect }) => {
564
+ Alpine.directive("h-avatar-fallback", (el, { original: original2 }, { effect }) => {
565
565
  const avatar = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_avatar"));
566
566
  if (!avatar) {
567
- throw new Error(`${original} must be inside an avatar element`);
567
+ throw new Error(`${original2} must be inside an avatar element`);
568
568
  }
569
569
  el.classList.add("hidden", "bg-muted", "flex", "size-full", "items-center", "justify-center");
570
570
  el.setAttribute("data-slot", "avatar-fallback");
@@ -773,7 +773,7 @@
773
773
  }
774
774
  };
775
775
  function button_default(Alpine) {
776
- Alpine.directive("h-button", (el, { original, modifiers }, { cleanup }) => {
776
+ Alpine.directive("h-button", (el, { original: original2, modifiers }, { cleanup }) => {
777
777
  setButtonClasses(el);
778
778
  if (!el.hasAttribute("data-slot")) {
779
779
  el.setAttribute("data-slot", "button");
@@ -790,7 +790,7 @@
790
790
  el.classList.remove(...getButtonSize(lastSize, isAddon));
791
791
  el.classList.add(...getButtonSize(size3, isAddon));
792
792
  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);
793
+ console.error(`${original2}: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute`, el);
794
794
  }
795
795
  lastSize = size3;
796
796
  }
@@ -2344,7 +2344,7 @@
2344
2344
 
2345
2345
  // src/components/calendar.js
2346
2346
  function calendar_default(Alpine) {
2347
- Alpine.directive("h-calendar", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
2347
+ Alpine.directive("h-calendar", (el, { original: original2, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
2348
2348
  const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
2349
2349
  el.classList.add("border", "rounded-control", "gap-2", "p-2");
2350
2350
  el.setAttribute("tabindex", "-1");
@@ -2388,7 +2388,7 @@
2388
2388
  const onInputChange = () => {
2389
2389
  const newValue = new Date(datepicker._h_datepicker.input.value);
2390
2390
  if (isNaN(newValue)) {
2391
- console.error(`${original}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
2391
+ console.error(`${original2}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
2392
2392
  datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
2393
2393
  return;
2394
2394
  } else if (selected.getTime() !== newValue.getTime()) {
@@ -2405,7 +2405,7 @@
2405
2405
  if (el.hasOwnProperty("_x_model") && el._x_model.get()) {
2406
2406
  selected = new Date(el._x_model.get());
2407
2407
  if (isNaN(selected)) {
2408
- console.error(`${original}: input value is not a valid date - ${el._x_model.get()}`);
2408
+ console.error(`${original2}: input value is not a valid date - ${el._x_model.get()}`);
2409
2409
  if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
2410
2410
  else el.setAttribute("data-invalid", "true");
2411
2411
  } else if (datepicker) {
@@ -2914,10 +2914,10 @@
2914
2914
  });
2915
2915
  }
2916
2916
  });
2917
- Alpine.directive("h-collapsible-trigger", (el, { original, modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
2917
+ Alpine.directive("h-collapsible-trigger", (el, { original: original2, modifiers }, { effect, Alpine: Alpine2, cleanup }) => {
2918
2918
  const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2919
2919
  if (!collapsible) {
2920
- throw new Error(`${original} must be inside a collapsible element`);
2920
+ throw new Error(`${original2} must be inside a collapsible element`);
2921
2921
  }
2922
2922
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-trigger");
2923
2923
  if (modifiers.includes("chevron")) {
@@ -2936,10 +2936,10 @@
2936
2936
  el.removeEventListener("click", handler);
2937
2937
  });
2938
2938
  });
2939
- Alpine.directive("h-collapsible-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
2939
+ Alpine.directive("h-collapsible-content", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
2940
2940
  const collapsible = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_collapsible"));
2941
2941
  if (!collapsible) {
2942
- throw new Error(`${original} must be inside an h-collapsible element`);
2942
+ throw new Error(`${original2} must be inside an h-collapsible element`);
2943
2943
  }
2944
2944
  if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "collapsible-content");
2945
2945
  el.classList.add("data-[state=closed]:!hidden");
@@ -2970,7 +2970,7 @@
2970
2970
 
2971
2971
  // src/components/datepicker.js
2972
2972
  function datepicker_default(Alpine) {
2973
- Alpine.directive("h-date-picker", (el, { original, modifiers }, { Alpine: Alpine2, cleanup }) => {
2973
+ Alpine.directive("h-date-picker", (el, { original: original2, modifiers }, { Alpine: Alpine2, cleanup }) => {
2974
2974
  const state = Alpine2.reactive({
2975
2975
  expanded: false
2976
2976
  });
@@ -2983,7 +2983,7 @@
2983
2983
  };
2984
2984
  el._h_datepicker.input = el.querySelector("input");
2985
2985
  if (!el._h_datepicker.input || el._h_datepicker.input.tagName !== "INPUT") {
2986
- throw new Error(`${original} must contain an input`);
2986
+ throw new Error(`${original2} must contain an input`);
2987
2987
  } else if (el._h_datepicker.input.hasAttribute("id")) {
2988
2988
  el._h_datepicker.id = el._h_datepicker.input.getAttribute("id");
2989
2989
  } else {
@@ -3060,16 +3060,16 @@
3060
3060
  observer.disconnect();
3061
3061
  });
3062
3062
  });
3063
- Alpine.directive("h-date-picker-trigger", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
3063
+ Alpine.directive("h-date-picker-trigger", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
3064
3064
  if (el.tagName !== "BUTTON") {
3065
- throw new Error(`${original} must be a button`);
3065
+ throw new Error(`${original2} must be a button`);
3066
3066
  }
3067
3067
  if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
3068
- throw new Error(`${original}: must have an "aria-label" or "aria-labelledby" attribute`);
3068
+ throw new Error(`${original2}: must have an "aria-label" or "aria-labelledby" attribute`);
3069
3069
  }
3070
3070
  const datepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_datepicker"));
3071
3071
  if (!datepicker) {
3072
- throw new Error(`${original} must be inside an date-picker element`);
3072
+ throw new Error(`${original2} must be inside an date-picker element`);
3073
3073
  }
3074
3074
  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
3075
  if (datepicker._h_datepicker.inTable) {
@@ -3349,13 +3349,13 @@
3349
3349
 
3350
3350
  // src/components/icon.js
3351
3351
  function icon_default(Alpine) {
3352
- Alpine.directive("h-icon", (el, { original, modifiers }) => {
3352
+ Alpine.directive("h-icon", (el, { original: original2, modifiers }) => {
3353
3353
  if (el.tagName.toLowerCase() !== "svg") {
3354
- throw new Error(`${original} works only on svg elements`);
3354
+ throw new Error(`${original2} works only on svg elements`);
3355
3355
  } else if (!el.hasAttribute("role")) {
3356
- throw new Error(`${original} must have a role`);
3356
+ throw new Error(`${original2} must have a role`);
3357
3357
  } 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`);
3358
+ throw new Error(`${original2}: svg images with the role of img must have an "aria-label" or "aria-labelledby" attribute`);
3359
3359
  }
3360
3360
  el.classList.add("fill-current");
3361
3361
  el.setAttribute("data-slot", "icon");
@@ -3572,7 +3572,7 @@
3572
3572
  el.classList.add("text-muted-foreground", "flex", "items-center", "gap-2", "text-sm", "[&_svg]:pointer-events-none", "[&_svg:not([class*='size-'])]:size-4");
3573
3573
  el.setAttribute("data-slot", "label");
3574
3574
  });
3575
- Alpine.directive("h-input-number", (el, { original }, { cleanup }) => {
3575
+ Alpine.directive("h-input-number", (el, { original: original2 }, { cleanup }) => {
3576
3576
  el.classList.add(
3577
3577
  "overflow-hidden",
3578
3578
  "group/input-number",
@@ -3605,7 +3605,7 @@
3605
3605
  el.setAttribute("data-slot", "input-number");
3606
3606
  const input = el.querySelector("input");
3607
3607
  if (!input || input.getAttribute("type") !== "number") {
3608
- throw new Error(`${original} must contain an input of type 'number'`);
3608
+ throw new Error(`${original2} must contain an input of type 'number'`);
3609
3609
  }
3610
3610
  if (!input.hasAttribute("type")) input.setAttribute("type", "number");
3611
3611
  if (!input.hasAttribute("inputmode")) input.setAttribute("inputmode", "numeric");
@@ -3851,13 +3851,13 @@
3851
3851
  el.setAttribute("data-slot", "list");
3852
3852
  el.setAttribute("role", "group");
3853
3853
  });
3854
- Alpine.directive("h-list-header", (el, { original }, { Alpine: Alpine2 }) => {
3854
+ Alpine.directive("h-list-header", (el, { original: original2 }, { Alpine: Alpine2 }) => {
3855
3855
  el.classList.add("font-medium", "flex", "items-center", "p-2", "gap-2", "align-middle", "bg-table-header", "text-table-header-foreground");
3856
3856
  el.setAttribute("role", "presentation");
3857
3857
  el.setAttribute("data-slot", "list-header");
3858
3858
  const list = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "list");
3859
3859
  if (!list) {
3860
- throw new Error(`${original} must be placed inside a list element`);
3860
+ throw new Error(`${original2} must be placed inside a list element`);
3861
3861
  }
3862
3862
  if (!el.hasAttribute("id")) {
3863
3863
  const id = `lbh${v4_default()}`;
@@ -3909,9 +3909,9 @@
3909
3909
  };
3910
3910
  el.setAttribute("data-state", "closed");
3911
3911
  });
3912
- Alpine.directive("h-menu", (el, { original, modifiers }, { cleanup, Alpine: Alpine2 }) => {
3912
+ Alpine.directive("h-menu", (el, { original: original2, modifiers }, { cleanup, Alpine: Alpine2 }) => {
3913
3913
  if (el.tagName !== "UL") {
3914
- throw new Error(`${original} must be an ul element`);
3914
+ throw new Error(`${original2} must be an ul element`);
3915
3915
  }
3916
3916
  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
3917
  el.setAttribute("role", "menu");
@@ -3919,7 +3919,7 @@
3919
3919
  el.setAttribute("tabindex", "-1");
3920
3920
  el.setAttribute("data-slot", "menu");
3921
3921
  if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
3922
- throw new Error(`${original} must have an "aria-label" or "aria-labelledby" attribute`);
3922
+ throw new Error(`${original2} must have an "aria-label" or "aria-labelledby" attribute`);
3923
3923
  }
3924
3924
  const isSubmenu = modifiers.includes("sub");
3925
3925
  const menuTrigger = (() => {
@@ -3931,7 +3931,7 @@
3931
3931
  return sibling;
3932
3932
  })();
3933
3933
  if (!isSubmenu && !menuTrigger) {
3934
- throw new Error(`${original} menu must be placed after a menu trigger element`);
3934
+ throw new Error(`${original2} menu must be placed after a menu trigger element`);
3935
3935
  }
3936
3936
  let menuSubItem;
3937
3937
  if (isSubmenu) menuSubItem = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "menu-sub");
@@ -4150,9 +4150,9 @@
4150
4150
  el.removeEventListener("keydown", onKeyDown);
4151
4151
  });
4152
4152
  });
4153
- Alpine.directive("h-menu-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4153
+ Alpine.directive("h-menu-item", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4154
4154
  if (el.tagName !== "LI") {
4155
- throw new Error(`${original} must be a li element`);
4155
+ throw new Error(`${original2} must be a li element`);
4156
4156
  }
4157
4157
  el.classList.add(
4158
4158
  "focus:bg-secondary-hover",
@@ -4206,7 +4206,7 @@
4206
4206
  el.removeEventListener("mouseleave", focusOut);
4207
4207
  });
4208
4208
  });
4209
- Alpine.directive("h-menu-sub", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4209
+ Alpine.directive("h-menu-sub", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4210
4210
  el.classList.add(
4211
4211
  "focus:bg-secondary-hover",
4212
4212
  "hover:bg-secondary-hover",
@@ -4238,7 +4238,7 @@
4238
4238
  const chevronRight = createSvg({ icon: ChevronRight, classes: "size-4 ml-auto", attrs: { "aria-hidden": true, role: "presentation" } });
4239
4239
  el.appendChild(chevronRight);
4240
4240
  const parentMenu = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "menu");
4241
- if (!parentMenu) throw new Error(`${original} must have a parent`);
4241
+ if (!parentMenu) throw new Error(`${original2} must have a parent`);
4242
4242
  el._menu_sub = {
4243
4243
  open: void 0,
4244
4244
  close: void 0,
@@ -4332,9 +4332,9 @@
4332
4332
  el.classList.add("text-foreground", "px-2", "py-1.5", "text-sm", "font-semibold", "text-left", "data-[inset=true]:pl-8");
4333
4333
  el.setAttribute("data-slot", "menu-label");
4334
4334
  });
4335
- Alpine.directive("h-menu-checkbox-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
4335
+ Alpine.directive("h-menu-checkbox-item", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
4336
4336
  if (el.tagName !== "LI" && el.tagName !== "DIV") {
4337
- throw new Error(`${original} must be a li or div element`);
4337
+ throw new Error(`${original2} must be a li or div element`);
4338
4338
  }
4339
4339
  el.classList.add(
4340
4340
  "focus:bg-secondary-hover",
@@ -4400,9 +4400,9 @@
4400
4400
  el.removeEventListener("mouseleave", focusOut);
4401
4401
  });
4402
4402
  });
4403
- Alpine.directive("h-menu-radio-item", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
4403
+ Alpine.directive("h-menu-radio-item", (el, { original: original2, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
4404
4404
  if (el.tagName !== "LI" && el.tagName !== "DIV") {
4405
- throw new Error(`${original} must be a li or div element`);
4405
+ throw new Error(`${original2} must be a li or div element`);
4406
4406
  }
4407
4407
  el.classList.add(
4408
4408
  "focus:bg-secondary-hover",
@@ -4631,7 +4631,7 @@
4631
4631
  });
4632
4632
  }
4633
4633
  });
4634
- Alpine.directive("h-popover", (el, { original, modifiers }, { effect }) => {
4634
+ Alpine.directive("h-popover", (el, { original: original2, modifiers }, { effect }) => {
4635
4635
  const popover = (() => {
4636
4636
  let sibling = el.previousElementSibling;
4637
4637
  while (sibling && !sibling.hasOwnProperty("_popover")) {
@@ -4640,7 +4640,7 @@
4640
4640
  return sibling;
4641
4641
  })();
4642
4642
  if (!popover) {
4643
- throw new Error(`${original} must be placed after a popover element`);
4643
+ throw new Error(`${original2} must be placed after a popover element`);
4644
4644
  }
4645
4645
  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
4646
  el.setAttribute("data-slot", "popover");
@@ -6702,9 +6702,9 @@
6702
6702
  });
6703
6703
  }
6704
6704
  });
6705
- Alpine.directive("h-select-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
6705
+ Alpine.directive("h-select-input", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
6706
6706
  if (el.tagName !== "INPUT") {
6707
- throw new Error(`${original} must be an input of type "text"`);
6707
+ throw new Error(`${original2} must be an input of type "text"`);
6708
6708
  }
6709
6709
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6710
6710
  const label = (() => {
@@ -6715,7 +6715,7 @@
6715
6715
  return;
6716
6716
  })();
6717
6717
  if (!select) {
6718
- throw new Error(`${original} must be inside a select element`);
6718
+ throw new Error(`${original2} must be inside a select element`);
6719
6719
  } else if (el.hasOwnProperty("_x_model")) {
6720
6720
  select._h_select.multiple = Array.isArray(el._x_model.get());
6721
6721
  select._h_model.set = (value) => {
@@ -6735,6 +6735,7 @@
6735
6735
  } else {
6736
6736
  el._x_model.set("");
6737
6737
  }
6738
+ el.dispatchEvent(new Event("change", { bubbles: true }));
6738
6739
  };
6739
6740
  select._h_model.get = el._x_model.get;
6740
6741
  } else {
@@ -6975,10 +6976,10 @@
6975
6976
  }
6976
6977
  });
6977
6978
  });
6978
- Alpine.directive("h-select-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
6979
+ Alpine.directive("h-select-content", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
6979
6980
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6980
6981
  if (!select) {
6981
- throw new Error(`${original} must be inside a select element`);
6982
+ throw new Error(`${original2} must be inside a select element`);
6982
6983
  }
6983
6984
  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
6985
  el.setAttribute("data-slot", "select-content");
@@ -6987,7 +6988,7 @@
6987
6988
  el.setAttribute("tabindex", "-1");
6988
6989
  el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
6989
6990
  if (!select._h_select.trigger) {
6990
- throw new Error(`${original}: trigger not found`);
6991
+ throw new Error(`${original2}: trigger not found`);
6991
6992
  }
6992
6993
  let autoUpdateCleanup;
6993
6994
  function updatePosition() {
@@ -7029,10 +7030,10 @@
7029
7030
  }
7030
7031
  });
7031
7032
  });
7032
- Alpine.directive("h-select-search", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
7033
+ Alpine.directive("h-select-search", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
7033
7034
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
7034
7035
  if (!select) {
7035
- throw new Error(`${original} must be inside an h-select element`);
7036
+ throw new Error(`${original2} must be inside an h-select element`);
7036
7037
  } else {
7037
7038
  select._h_select.filterType = FilterType[el.getAttribute("data-filter")] ?? FilterType["starts-with"];
7038
7039
  }
@@ -7104,10 +7105,10 @@
7104
7105
  selectGroup._h_selectGroup.labelledby = id;
7105
7106
  }
7106
7107
  });
7107
- Alpine.directive("h-select-option", (el, { original, expression }, { effect, evaluateLater, cleanup }) => {
7108
+ Alpine.directive("h-select-option", (el, { original: original2, expression }, { effect, evaluateLater, cleanup }) => {
7108
7109
  const select = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
7109
7110
  if (!select) {
7110
- throw new Error(`${original} must be inside an h-select element`);
7111
+ throw new Error(`${original2} must be inside an h-select element`);
7111
7112
  }
7112
7113
  el.classList.add(
7113
7114
  "focus:bg-primary",
@@ -7361,10 +7362,10 @@
7361
7362
  });
7362
7363
  }
7363
7364
  });
7364
- Alpine.directive("h-sidebar-group-label", (el, { original }, { cleanup }) => {
7365
+ Alpine.directive("h-sidebar-group-label", (el, { original: original2 }, { cleanup }) => {
7365
7366
  const group = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_group"));
7366
7367
  if (!group) {
7367
- throw new Error(`${original} must be placed inside a sidebar group`);
7368
+ throw new Error(`${original2} must be placed inside a sidebar group`);
7368
7369
  }
7369
7370
  el.classList.add(
7370
7371
  "ring-sidebar-ring",
@@ -7451,10 +7452,10 @@
7451
7452
  }
7452
7453
  el.setAttribute("data-slot", "sidebar-group-action");
7453
7454
  });
7454
- Alpine.directive("h-sidebar-group-content", (el, { original }, { effect }) => {
7455
+ Alpine.directive("h-sidebar-group-content", (el, { original: original2 }, { effect }) => {
7455
7456
  const group = Alpine.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_group"));
7456
7457
  if (!group) {
7457
- throw new Error(`${original} must be placed inside a sidebar group`);
7458
+ throw new Error(`${original2} must be placed inside a sidebar group`);
7458
7459
  }
7459
7460
  el.classList.add("w-full", "text-sm", "data-[collapsed=true]:hidden", "group-data-[collapsed=true]/sidebar:!block");
7460
7461
  el.setAttribute("data-slot", "sidebar-group-content");
@@ -7467,16 +7468,16 @@
7467
7468
  });
7468
7469
  }
7469
7470
  });
7470
- Alpine.directive("h-sidebar-menu", (el, { original }) => {
7471
+ Alpine.directive("h-sidebar-menu", (el, { original: original2 }) => {
7471
7472
  if (el.tagName !== "UL") {
7472
- throw new Error(`${original} must be an ul element`);
7473
+ throw new Error(`${original2} must be an ul element`);
7473
7474
  }
7474
7475
  el.classList.add("vbox", "w-full", "min-w-0", "gap-1");
7475
7476
  el.setAttribute("data-slot", "sidebar-menu");
7476
7477
  });
7477
- Alpine.directive("h-sidebar-menu-item", (el, { original, expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
7478
+ Alpine.directive("h-sidebar-menu-item", (el, { original: original2, expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
7478
7479
  if (el.tagName !== "LI") {
7479
- throw new Error(`${original} must be a li element`);
7480
+ throw new Error(`${original2} must be a li element`);
7480
7481
  }
7481
7482
  el._h_sidebar_menu_item = {
7482
7483
  isSub: false,
@@ -7512,9 +7513,9 @@
7512
7513
  });
7513
7514
  }
7514
7515
  });
7515
- Alpine.directive("h-sidebar-menu-button", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
7516
+ Alpine.directive("h-sidebar-menu-button", (el, { original: original2 }, { cleanup, Alpine: Alpine2 }) => {
7516
7517
  if (el.tagName !== "BUTTON" && el.tagName !== "A") {
7517
- throw new Error(`${original} must be a button or a link`);
7518
+ throw new Error(`${original2} must be a button or a link`);
7518
7519
  } else if (el.tagName === "BUTTON") {
7519
7520
  el.setAttribute("type", "button");
7520
7521
  }
@@ -7650,9 +7651,9 @@
7650
7651
  }
7651
7652
  el.setAttribute("data-slot", "sidebar-menu-action");
7652
7653
  });
7653
- Alpine.directive("h-sidebar-menu-badge", (el, { original }) => {
7654
+ Alpine.directive("h-sidebar-menu-badge", (el, { original: original2 }) => {
7654
7655
  if (el.tagName !== "SPAN") {
7655
- throw new Error(`${original} must be a span element`);
7656
+ throw new Error(`${original2} must be a span element`);
7656
7657
  }
7657
7658
  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
7659
  el.setAttribute("data-slot", "sidebar-menu-badge");
@@ -7678,13 +7679,13 @@
7678
7679
  el.setAttribute("data-slot", "sidebar-separator");
7679
7680
  el.setAttribute("role", "none");
7680
7681
  });
7681
- Alpine.directive("h-sidebar-menu-sub", (el, { original }, { effect, Alpine: Alpine2 }) => {
7682
+ Alpine.directive("h-sidebar-menu-sub", (el, { original: original2 }, { effect, Alpine: Alpine2 }) => {
7682
7683
  if (el.tagName !== "UL") {
7683
- throw new Error(`${original} must be an ul element`);
7684
+ throw new Error(`${original2} must be an ul element`);
7684
7685
  }
7685
7686
  const menuItem = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_sidebar_menu_item"));
7686
7687
  if (!menuItem) {
7687
- throw new Error(`${original} must be placed inside a sidebar menu item`);
7688
+ throw new Error(`${original2} must be placed inside a sidebar menu item`);
7688
7689
  }
7689
7690
  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
7691
  if (el.getAttribute("data-line") !== "false") {
@@ -7953,10 +7954,10 @@
7953
7954
  observer.disconnect();
7954
7955
  });
7955
7956
  });
7956
- Alpine.directive("h-split-panel", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
7957
+ Alpine.directive("h-split-panel", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
7957
7958
  const split = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_split"));
7958
7959
  if (!split) {
7959
- throw new Error(`${original} must be inside an split element`);
7960
+ throw new Error(`${original2} must be inside an split element`);
7960
7961
  }
7961
7962
  el.classList.add("flex", "shrink", "grow-0", "box-border", "min-w-0", "min-h-0", "overflow-visible");
7962
7963
  el.setAttribute("tabindex", "-1");
@@ -8480,7 +8481,7 @@
8480
8481
  el.setAttribute("role", "tablist");
8481
8482
  el.setAttribute("data-slot", "tab-list");
8482
8483
  });
8483
- Alpine.directive("h-tab", (el, { original }) => {
8484
+ Alpine.directive("h-tab", (el, { original: original2 }) => {
8484
8485
  el.classList.add(
8485
8486
  "cursor-pointer",
8486
8487
  "focus-visible:border-ring",
@@ -8527,8 +8528,8 @@
8527
8528
  );
8528
8529
  el.setAttribute("role", "tab");
8529
8530
  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.`);
8531
+ if (!el.hasAttribute("id")) throw new Error(`${original2}: Tabs must have an id`);
8532
+ if (!el.hasAttribute("aria-controls")) throw new Error(`${original2}: aria-controls must be set to the tab-content id.`);
8532
8533
  });
8533
8534
  Alpine.directive("h-tab-action", (el) => {
8534
8535
  el.classList.add("cursor-pointer", "ml-auto", "rounded-md", "text-foreground", "hover:bg-secondary", "hover:text-secondary-foreground", "active:bg-secondary-active");
@@ -8562,13 +8563,13 @@
8562
8563
  el.setAttribute("role", "button");
8563
8564
  el.setAttribute("data-slot", "tab-list-action");
8564
8565
  });
8565
- Alpine.directive("h-tabs-content", (el, { original }) => {
8566
+ Alpine.directive("h-tabs-content", (el, { original: original2 }) => {
8566
8567
  el.classList.add("flex-1", "outline-none");
8567
8568
  el.setAttribute("role", "tabpanel");
8568
8569
  el.setAttribute("tabindex", "0");
8569
8570
  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.`);
8571
+ if (!el.hasAttribute("id")) throw new Error(`${original2}: Tab content must have an id`);
8572
+ if (!el.hasAttribute("aria-labelledby")) throw new Error(`${original2}: aria-labelledby must be set to the tab id.`);
8572
8573
  });
8573
8574
  }
8574
8575
 
@@ -8961,13 +8962,13 @@
8961
8962
  top.removeEventListener("click", el._h_timepicker.close);
8962
8963
  });
8963
8964
  });
8964
- Alpine.directive("h-time-picker-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
8965
+ Alpine.directive("h-time-picker-input", (el, { original: original2 }, { effect, cleanup, Alpine: Alpine2 }) => {
8965
8966
  if (el.tagName !== "INPUT") {
8966
- throw new Error(`${original} must be a readonly input of type "text"`);
8967
+ throw new Error(`${original2} must be a readonly input of type "text"`);
8967
8968
  }
8968
8969
  const timepicker = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_timepicker"));
8969
8970
  if (!timepicker) {
8970
- throw new Error(`${original} must be inside a time-picker element`);
8971
+ throw new Error(`${original2} must be inside a time-picker element`);
8971
8972
  }
8972
8973
  timepicker._h_timepicker.focusInput = () => {
8973
8974
  el.focus();
@@ -9616,7 +9617,7 @@
9616
9617
  el.removeEventListener("pointerleave", handler);
9617
9618
  });
9618
9619
  });
9619
- Alpine.directive("h-tooltip", (el, { original }, { effect }) => {
9620
+ Alpine.directive("h-tooltip", (el, { original: original2 }, { effect }) => {
9620
9621
  const tooltip = (() => {
9621
9622
  let sibling = el.previousElementSibling;
9622
9623
  while (sibling && !sibling.hasOwnProperty("_tooltip")) {
@@ -9625,7 +9626,7 @@
9625
9626
  return sibling;
9626
9627
  })();
9627
9628
  if (!tooltip) {
9628
- throw new Error(`${original} must be placed after a tooltip trigger element`);
9629
+ throw new Error(`${original2} must be placed after a tooltip trigger element`);
9629
9630
  }
9630
9631
  el.classList.add("absolute", "bg-foreground", "text-background", "z-50", "w-fit", "rounded-md", "px-3", "py-1.5", "text-xs", "text-balance");
9631
9632
  el.setAttribute("data-slot", "tooltip");
@@ -9831,9 +9832,9 @@
9831
9832
  });
9832
9833
  }
9833
9834
  });
9834
- Alpine.directive("h-tree-button", (el, { original }, { effect }) => {
9835
+ Alpine.directive("h-tree-button", (el, { original: original2 }, { effect }) => {
9835
9836
  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`);
9837
+ if (!treeItem) throw new Error(`${original2} must be inside a tree item`);
9837
9838
  el.classList.add(
9838
9839
  "flex",
9839
9840
  "w-full",
@@ -9956,6 +9957,12 @@
9956
9957
  }
9957
9958
  return "light";
9958
9959
  };
9960
+ var getSystemColorScheme = () => {
9961
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
9962
+ return "dark";
9963
+ }
9964
+ return "light";
9965
+ };
9959
9966
  var addColorSchemeListener = (callback) => {
9960
9967
  callbacks.push(callback);
9961
9968
  };
@@ -9988,7 +9995,7 @@
9988
9995
 
9989
9996
  // src/utils/template.js
9990
9997
  function template_default(Alpine) {
9991
- Alpine.directive("h-template", (el, { original, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
9998
+ Alpine.directive("h-template", (el, { original: original2, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
9992
9999
  if (el.hasAttribute(Alpine2.prefixed("data"))) {
9993
10000
  const template = evaluate2(expression);
9994
10001
  const clone = template.content.cloneNode(true).firstElementChild;
@@ -10002,11 +10009,55 @@
10002
10009
  clone.remove();
10003
10010
  });
10004
10011
  } else {
10005
- console.error(`${original}: ${Alpine2.prefixed("data")} directive is missing`);
10012
+ console.error(`${original2}: ${Alpine2.prefixed("data")} directive is missing`);
10006
10013
  }
10007
10014
  });
10008
10015
  }
10009
10016
 
10017
+ // src/utils/include.js
10018
+ function include_default(Alpine) {
10019
+ Alpine.directive("h-include", (el, { modifiers, expression }, { evaluateLater, effect }) => {
10020
+ const getUrl = evaluateLater(expression);
10021
+ function getHtml(url) {
10022
+ const parsed = new URL(url, window.location.origin);
10023
+ if (parsed.origin === window.location.origin) {
10024
+ fetch(url).then((response) => {
10025
+ if (response.status === 200) return response.text();
10026
+ throw response;
10027
+ }).then((content) => {
10028
+ if (modifiers.includes("js")) {
10029
+ const container = document.createElement("div");
10030
+ container.innerHTML = content;
10031
+ let staticScript = container.querySelector("script");
10032
+ const script = document.createElement("script");
10033
+ for (let a = 0; a < staticScript.attributes.length; a++) {
10034
+ script.setAttribute(staticScript.attributes[a].name, staticScript.attributes[a].value);
10035
+ }
10036
+ script.appendChild(document.createTextNode(staticScript.innerHTML));
10037
+ staticScript.remove();
10038
+ while (container.childNodes.length > 0) {
10039
+ el.appendChild(container.childNodes[0]);
10040
+ }
10041
+ el.appendChild(script);
10042
+ } else {
10043
+ el.innerHTML = content;
10044
+ }
10045
+ }).catch((response) => {
10046
+ console.error(response);
10047
+ });
10048
+ } else {
10049
+ throw new Error(`${original}: external requests not allowed`);
10050
+ }
10051
+ }
10052
+ effect(() => {
10053
+ getUrl((url) => {
10054
+ if (url) getHtml(url);
10055
+ else el.innerHTML = "";
10056
+ });
10057
+ });
10058
+ }).before("bind");
10059
+ }
10060
+
10010
10061
  // src/utils/focus.js
10011
10062
  function focus_default(Alpine) {
10012
10063
  Alpine.directive("h-focus", (el, { expression }, { effect, evaluateLater }) => {
@@ -10020,10 +10071,10 @@
10020
10071
  }
10021
10072
 
10022
10073
  // package.json
10023
- var version = "1.4.2";
10074
+ var version = "1.5.0";
10024
10075
 
10025
10076
  // src/index.js
10026
- window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, version };
10077
+ window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
10027
10078
  document.addEventListener("alpine:init", () => {
10028
10079
  window.Alpine.plugin(accordion_default);
10029
10080
  window.Alpine.plugin(alert_default);
@@ -10068,5 +10119,6 @@
10068
10119
  window.Alpine.plugin(tree_default);
10069
10120
  window.Alpine.plugin(focus_default);
10070
10121
  window.Alpine.plugin(template_default);
10122
+ window.Alpine.plugin(include_default);
10071
10123
  });
10072
10124
  })();