@codbex/harmonia 1.5.2 → 1.6.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.
@@ -4768,11 +4768,11 @@ function checkbox_default(Alpine) {
4768
4768
  "bg-input-inner",
4769
4769
  "border",
4770
4770
  "border-input",
4771
- "dark:has-[aria-invalid=true]:ring-negative/40",
4771
+ "dark:has-[input[aria-invalid=true]]:ring-negative/40",
4772
4772
  "dark:has-[input:invalid]:ring-negative/40",
4773
4773
  "duration-200",
4774
- "has-[aria-invalid=true]:border-negative",
4775
- "has-[aria-invalid=true]:ring-negative/20",
4774
+ "has-[input[aria-invalid=true]]:border-negative",
4775
+ "has-[input[aria-invalid=true]]:ring-negative/20",
4776
4776
  "has-[input:checked]:bg-primary",
4777
4777
  "has-[input:checked]:border-primary",
4778
4778
  "has-[input:disabled]:cursor-not-allowed",
@@ -5731,14 +5731,14 @@ function list_default(Alpine) {
5731
5731
  break;
5732
5732
  }
5733
5733
  }
5734
- function onClick2(event) {
5734
+ function onClick(event) {
5735
5735
  if (event.target.getAttribute("data-slot") === "list-item") selectOption(event.target);
5736
5736
  }
5737
- el.addEventListener("click", onClick2);
5737
+ el.addEventListener("click", onClick);
5738
5738
  el.addEventListener("keydown", onKeyDown);
5739
5739
  cleanup(() => {
5740
5740
  el.removeEventListener("keydown", onKeyDown);
5741
- el.removeEventListener("click", onClick2);
5741
+ el.removeEventListener("click", onClick);
5742
5742
  });
5743
5743
  });
5744
5744
  Alpine.directive("h-list", (el) => {
@@ -5823,6 +5823,9 @@ function menu_default(Alpine) {
5823
5823
  while (sibling && !sibling.hasOwnProperty("_menu_trigger")) {
5824
5824
  sibling = sibling.previousElementSibling;
5825
5825
  }
5826
+ if (!sibling.hasOwnProperty("_menu_trigger")) {
5827
+ throw new Error(`${original2} must be placed after the menu trigger`);
5828
+ }
5826
5829
  return sibling;
5827
5830
  })();
5828
5831
  if (!isSubmenu && !menuTrigger) {
@@ -5846,8 +5849,8 @@ function menu_default(Alpine) {
5846
5849
  left: "0px",
5847
5850
  top: "0px"
5848
5851
  });
5849
- top.removeEventListener("contextmenu", onClick2);
5850
- top.removeEventListener("click", onClick2);
5852
+ top.removeEventListener("contextmenu", onClick);
5853
+ top.removeEventListener("click", onClick);
5851
5854
  el.removeEventListener("keydown", onKeyDown);
5852
5855
  if (isSubmenu) {
5853
5856
  if (closeParent) {
@@ -5879,7 +5882,7 @@ function menu_default(Alpine) {
5879
5882
  }
5880
5883
  return false;
5881
5884
  }
5882
- function onClick2(event) {
5885
+ function onClick(event) {
5883
5886
  if (event.type === "contextmenu") event.preventDefault();
5884
5887
  close(isSubmenu);
5885
5888
  }
@@ -5997,8 +6000,8 @@ function menu_default(Alpine) {
5997
6000
  listenForTrigger(false);
5998
6001
  }
5999
6002
  Alpine2.nextTick(() => {
6000
- top.addEventListener("contextmenu", onClick2);
6001
- top.addEventListener("click", onClick2);
6003
+ top.addEventListener("contextmenu", onClick);
6004
+ top.addEventListener("click", onClick);
6002
6005
  el.addEventListener("keydown", onKeyDown);
6003
6006
  });
6004
6007
  Object.assign(el.style, {
@@ -6039,9 +6042,9 @@ function menu_default(Alpine) {
6039
6042
  listenForTrigger(true);
6040
6043
  }
6041
6044
  cleanup(() => {
6042
- listenForTrigger(false);
6043
- top.removeEventListener("click", onClick2);
6044
- top.removeEventListener("contextmenu", onClick2);
6045
+ if (menuTrigger) listenForTrigger(false);
6046
+ top.removeEventListener("click", onClick);
6047
+ top.removeEventListener("contextmenu", onClick);
6045
6048
  el.removeEventListener("keydown", onKeyDown);
6046
6049
  });
6047
6050
  });
@@ -6641,10 +6644,10 @@ function radio_default(Alpine) {
6641
6644
  "bg-input-inner",
6642
6645
  "border",
6643
6646
  "border-input",
6644
- "dark:has-[aria-invalid=true]:ring-negative/40",
6647
+ "dark:has-[input[aria-invalid=true]]:ring-negative/40",
6645
6648
  "dark:has-[input:invalid]:ring-negative/40",
6646
- "has-[aria-invalid=true]:border-negative",
6647
- "has-[aria-invalid=true]:ring-negative/20",
6649
+ "has-[input[aria-invalid=true]]:border-negative",
6650
+ "has-[input[aria-invalid=true]]:ring-negative/20",
6648
6651
  "has-[input:checked]:before:visible",
6649
6652
  "has-[input:disabled]:cursor-not-allowed",
6650
6653
  "has-[input:disabled]:opacity-50",
@@ -6716,10 +6719,10 @@ function select_default(Alpine) {
6716
6719
  "has-focus-visible:border-ring",
6717
6720
  "has-focus-visible:ring-[calc(var(--spacing)*0.75)]",
6718
6721
  "has-focus-visible:ring-ring/50",
6719
- "dark:has-[aria-invalid=true]:ring-negative/40",
6722
+ "dark:has-[input[aria-invalid=true]]:ring-negative/40",
6720
6723
  "dark:has-[input:invalid]:ring-negative/40",
6721
- "has-[aria-invalid=true]:border-negative",
6722
- "has-[aria-invalid=true]:ring-negative/20",
6724
+ "has-[input[aria-invalid=true]]:border-negative",
6725
+ "has-[input[aria-invalid=true]]:ring-negative/20",
6723
6726
  "has-[input:invalid]:border-negative",
6724
6727
  "has-[input:invalid]:ring-negative/20",
6725
6728
  "hover:bg-secondary-hover",
@@ -6950,7 +6953,7 @@ function select_default(Alpine) {
6950
6953
  }
6951
6954
  }
6952
6955
  };
6953
- const onClick2 = () => {
6956
+ const onClick = () => {
6954
6957
  select._h_select.expanded = !select._h_select.expanded;
6955
6958
  if (select._h_select.expanded) {
6956
6959
  if (!content) content = select.querySelector(`#${select._h_select.controls}`);
@@ -6971,14 +6974,14 @@ function select_default(Alpine) {
6971
6974
  if (event.key === "Escape" && select._h_select.expanded) close(true);
6972
6975
  else if (event.key === "Enter") {
6973
6976
  event.preventDefault();
6974
- onClick2();
6977
+ onClick();
6975
6978
  } else if (event.key === " ") {
6976
6979
  event.preventDefault();
6977
- setTimeout(() => onClick2(), 0);
6980
+ setTimeout(() => onClick(), 0);
6978
6981
  }
6979
6982
  };
6980
6983
  fakeTrigger.addEventListener("keydown", onPress);
6981
- fakeTrigger.addEventListener("click", onClick2);
6984
+ fakeTrigger.addEventListener("click", onClick);
6982
6985
  const chevronDown = createSvg({
6983
6986
  icon: ChevronDown,
6984
6987
  classes: "opacity-70 text-foreground size-4 shrink-0 pointer-events-none transition-transform duration-200",
@@ -7001,7 +7004,7 @@ function select_default(Alpine) {
7001
7004
  select._h_select.refreshLabel = onInputChange;
7002
7005
  el.addEventListener("change", onInputChange);
7003
7006
  cleanup(() => {
7004
- fakeTrigger.removeEventListener("click", onClick2);
7007
+ fakeTrigger.removeEventListener("click", onClick);
7005
7008
  fakeTrigger.removeEventListener("keydown", onPress);
7006
7009
  el.parentElement.removeEventListener("keydown", onKeyDown);
7007
7010
  top.removeEventListener("click", close);
@@ -7098,11 +7101,11 @@ function select_default(Alpine) {
7098
7101
  }
7099
7102
  el.addEventListener("click", onActivate);
7100
7103
  el.addEventListener("keydown", onActivate);
7104
+ function onInput() {
7105
+ select._h_select.search = searchInput.value.toLowerCase();
7106
+ }
7101
7107
  if (select._h_select.filterType !== FilterType.none) {
7102
- let onInput2 = function() {
7103
- select._h_select.search = searchInput.value.toLowerCase();
7104
- };
7105
- searchInput.addEventListener("keyup", onInput2);
7108
+ searchInput.addEventListener("keyup", onInput);
7106
7109
  }
7107
7110
  effect(() => {
7108
7111
  if (select._h_select.expanded) searchInput.focus({ preventScroll: true });
@@ -7301,14 +7304,14 @@ function sheet_default(Alpine) {
7301
7304
  el.setAttribute("data-open", isOpen);
7302
7305
  });
7303
7306
  });
7304
- const onClick2 = (event) => {
7307
+ const onClick = (event) => {
7305
7308
  if (event.target.getAttribute("data-slot") === "sheet-overlay") {
7306
7309
  evaluate2(`${expression} = false`);
7307
7310
  }
7308
7311
  };
7309
- el.addEventListener("click", onClick2);
7312
+ el.addEventListener("click", onClick);
7310
7313
  cleanup(() => {
7311
- el.removeEventListener("click", onClick2);
7314
+ el.removeEventListener("click", onClick);
7312
7315
  });
7313
7316
  });
7314
7317
  Alpine.directive("h-sheet", (el, _, { cleanup }) => {
@@ -7787,6 +7790,7 @@ function spinner_default(Alpine) {
7787
7790
  "rounded-full",
7788
7791
  "animate-spin"
7789
7792
  );
7793
+ if (el.tagName === "SPAN") el.classList.add("inline-block");
7790
7794
  el.setAttribute("role", "status");
7791
7795
  el.setAttribute("data-slot", "spinner");
7792
7796
  if (!el.hasAttribute("aria-label")) el.setAttribute("aria-label", "Loading");
@@ -7930,7 +7934,8 @@ function split_default(Alpine) {
7930
7934
  });
7931
7935
  };
7932
7936
  const refreshGutters = () => {
7933
- panels.forEach((p, i) => p.setGutter(i === panels.length - 1));
7937
+ const lastPanelIndex = panels.length - 1;
7938
+ panels.forEach((p, i) => p.setGutter(i === lastPanelIndex));
7934
7939
  };
7935
7940
  el._h_split = {
7936
7941
  state,
@@ -7995,7 +8000,19 @@ function split_default(Alpine) {
7995
8000
  if (!split) {
7996
8001
  throw new Error(`${original2} must be inside an split element`);
7997
8002
  }
7998
- el.classList.add("flex", "shrink", "grow-0", "box-border", "min-w-0", "min-h-0", "overflow-visible");
8003
+ el.classList.add(
8004
+ "flex",
8005
+ "shrink",
8006
+ "grow-0",
8007
+ "box-border",
8008
+ "overflow-visible",
8009
+ "[[data-orientation=horizontal]_&]:min-w-(--h-split-panel-min)",
8010
+ "[[data-orientation=horizontal]_&]:max-w-(--h-split-panel-max)",
8011
+ "[[data-orientation=horizontal]_&]:min-h-0",
8012
+ "[[data-orientation=vertical]_&]:min-h-(--h-split-panel-min)",
8013
+ "[[data-orientation=vertical]_&]:max-h-(--h-split-panel-max)",
8014
+ "[[data-orientation=vertical]_&]:min-w-0"
8015
+ );
7999
8016
  el.setAttribute("tabindex", "-1");
8000
8017
  el.setAttribute("data-slot", "split-panel");
8001
8018
  let gutterless = el.getAttribute("data-gutterless") === "true";
@@ -8102,6 +8119,7 @@ function split_default(Alpine) {
8102
8119
  effect(setVariant);
8103
8120
  const initialSize = split._h_split.normalize(el.getAttribute("data-size"));
8104
8121
  let handleSize = 0;
8122
+ let layoutFrame = null;
8105
8123
  const panel = {
8106
8124
  el,
8107
8125
  gutter,
@@ -8122,9 +8140,13 @@ function split_default(Alpine) {
8122
8140
  setGutter(last) {
8123
8141
  if (this.hidden || gutterless || last) {
8124
8142
  gutter.remove();
8125
- } else if (!gutter.parentElement) {
8126
- el.after(gutter);
8127
- handleSize = this.getHandleSize();
8143
+ } else {
8144
+ if (layoutFrame) cancelAnimationFrame(layoutFrame);
8145
+ layoutFrame = requestAnimationFrame(() => {
8146
+ el.after(gutter);
8147
+ handleSize = this.getHandleSize();
8148
+ layoutFrame = null;
8149
+ });
8128
8150
  }
8129
8151
  },
8130
8152
  setHandleOffset() {
@@ -8150,6 +8172,7 @@ function split_default(Alpine) {
8150
8172
  },
8151
8173
  setLocked(locked = false) {
8152
8174
  const panelLocked = el.getAttribute("data-locked") === "true";
8175
+ gutter.setAttribute("aria-disabled", locked || panelLocked);
8153
8176
  if (locked) {
8154
8177
  gutter.classList.add("pointer-events-none");
8155
8178
  } else if (panelLocked) {
@@ -8159,6 +8182,10 @@ function split_default(Alpine) {
8159
8182
  }
8160
8183
  }
8161
8184
  };
8185
+ el.style.setProperty("--h-split-panel-min", `${panel.min}px`);
8186
+ if (panel.max < Infinity) {
8187
+ el.style.setProperty("--h-split-panel-max", `${panel.max}px`);
8188
+ }
8162
8189
  split._h_split.addPanel(panel);
8163
8190
  const drag = (e) => {
8164
8191
  e.preventDefault();
@@ -9519,10 +9546,10 @@ function timepicker_default(Alpine) {
9519
9546
  periodList.classList.add("hidden");
9520
9547
  }
9521
9548
  }
9522
- const onClick2 = (event) => {
9549
+ const onClick = (event) => {
9523
9550
  event.stopPropagation();
9524
9551
  };
9525
- el.addEventListener("click", onClick2);
9552
+ el.addEventListener("click", onClick);
9526
9553
  let autoUpdateCleanup;
9527
9554
  let focusFirstItem = true;
9528
9555
  function updatePosition() {
@@ -9565,20 +9592,10 @@ function timepicker_default(Alpine) {
9565
9592
  });
9566
9593
  cleanup(() => {
9567
9594
  el.removeEventListener("keydown", onKeyDown);
9568
- el.removeEventListener("click", onClick2);
9595
+ el.removeEventListener("click", onClick);
9569
9596
  okButton.removeEventListener("click", timepicker._h_timepicker.close);
9570
- for (let h = 0; h < hoursList.children.length; h++) {
9571
- hoursList.children[h].removeEventListener("click", setHour);
9572
- }
9573
- for (let m = 0; m < minutesList.children.length; m++) {
9574
- minutesList.children[m].removeEventListener("click", setMinute);
9575
- }
9576
- for (let s = 0; s < secondsList.children.length; s++) {
9577
- secondsList.children[s].removeEventListener("click", setSecond);
9578
- }
9579
- for (let p = 0; p < periodList.children.length; p++) {
9580
- periodList.children[p].removeEventListener("click", setPeriod);
9581
- }
9597
+ nowButton.removeEventListener("click", getCurrentTime);
9598
+ timeContainer.removeEventListener("click", setTime);
9582
9599
  });
9583
9600
  });
9584
9601
  }
@@ -9613,17 +9630,34 @@ function toolbar_default(Alpine) {
9613
9630
  el.classList.add("size-8", "[[data-size=md]_&]:size-7", "[[data-size=sm]_&]:size-6");
9614
9631
  el.setAttribute("data-slot", "toolbar-image");
9615
9632
  });
9633
+ Alpine.directive("h-toolbar-branding", (el) => {
9634
+ el.classList.add(
9635
+ "flex",
9636
+ "flex-col",
9637
+ "pl-2",
9638
+ "[[data-slot=toolbar-image]~&]:pl-1",
9639
+ "[[data-size=sm]_&,[data-size=md]_&]:flex-row",
9640
+ "[[data-size=sm]_&,[data-size=md]_&]:items-baseline",
9641
+ "[[data-size=sm]_&,[data-size=md]_&]:gap-1",
9642
+ "[[data-size=sm]_&_[data-slot=toolbar-subtitle],[data-size=md]_&_[data-slot=toolbar-subtitle]]:pl-0"
9643
+ );
9644
+ el.setAttribute("data-slot", "toolbar-branding");
9645
+ });
9616
9646
  Alpine.directive("h-toolbar-title", (el) => {
9617
- el.classList.add("text", "[[data-size=sm]_&]:text-sm", "[[data-size=md]_&]:text-sm", "first-of-type:pl-2", "font-medium", "whitespace-nowrap", "text-ellipsis", "overflow-hidden");
9647
+ el.classList.add("pl-2", "[[data-slot=toolbar-branding]_&]:pl-0", "font-medium", "whitespace-nowrap", "text-ellipsis", "overflow-hidden");
9618
9648
  el.setAttribute("data-slot", "toolbar-title");
9619
9649
  });
9650
+ Alpine.directive("h-toolbar-subtitle", (el) => {
9651
+ el.classList.add("text-xs", "font-normal", "whitespace-nowrap", "text-ellipsis", "overflow-hidden");
9652
+ el.setAttribute("data-slot", "toolbar-subtitle");
9653
+ });
9620
9654
  Alpine.directive("h-toolbar-spacer", (el) => {
9621
9655
  el.classList.add("flex-[1_auto]", "h-full");
9622
9656
  el.setAttribute("tabindex", "-1");
9623
9657
  el.setAttribute("data-slot", "toolbar-spacer");
9624
9658
  });
9625
9659
  Alpine.directive("h-toolbar-separator", (el) => {
9626
- el.classList.add("w-px", "h-8", "[[data-size=md]_&]:h-6", "[[data-size=sm]_&]:h-6", "border-l");
9660
+ el.classList.add("w-px", "h-8", "[[data-size=md]_&,[data-size=sm]_&]:h-6", "border-l");
9627
9661
  el.setAttribute("data-slot", "toolbar-separator");
9628
9662
  });
9629
9663
  }
@@ -9806,7 +9840,7 @@ function tree_default(Alpine) {
9806
9840
  el.setAttribute("role", "tree");
9807
9841
  el.addEventListener("keydown", onKeyDown);
9808
9842
  cleanup(() => {
9809
- el.removeEventListener("keydown", onClick);
9843
+ el.removeEventListener("keydown", onKeyDown);
9810
9844
  });
9811
9845
  }
9812
9846
  });
@@ -9836,7 +9870,7 @@ function tree_default(Alpine) {
9836
9870
  effect(() => {
9837
9871
  if (!el.closest('[role="tree"]')) return;
9838
9872
  });
9839
- const onClick2 = (event) => {
9873
+ const onClick = (event) => {
9840
9874
  if (event.target === el || event.target.parentElement === el) {
9841
9875
  if (el._h_tree_item.hasSubtree) {
9842
9876
  if (expression === "false" || expression === "true") {
@@ -9851,9 +9885,9 @@ function tree_default(Alpine) {
9851
9885
  el.setAttribute("tabindex", "0");
9852
9886
  }
9853
9887
  };
9854
- el.addEventListener("click", onClick2);
9888
+ el.addEventListener("click", onClick);
9855
9889
  cleanup(() => {
9856
- el.removeEventListener("click", onClick2);
9890
+ el.removeEventListener("click", onClick);
9857
9891
  });
9858
9892
  if (el._h_tree_item.hasSubtree) {
9859
9893
  const setExpanded = (expanded) => {
@@ -9933,7 +9967,7 @@ function tree_default(Alpine) {
9933
9967
  }
9934
9968
 
9935
9969
  // package.json
9936
- var version = "1.5.2";
9970
+ var version = "1.6.1";
9937
9971
 
9938
9972
  // src/utils/breakpoint-listener.js
9939
9973
  function getBreakpointListener(handler, breakpoint = 768) {
@@ -10008,10 +10042,7 @@ var setColorScheme = (mode) => {
10008
10042
  var getColorScheme = () => {
10009
10043
  const theme = localStorage.getItem(colorSchemeKey);
10010
10044
  if (theme) return theme;
10011
- else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
10012
- return "dark";
10013
- }
10014
- return "light";
10045
+ return "auto";
10015
10046
  };
10016
10047
  var getSystemColorScheme = () => {
10017
10048
  if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
@@ -10046,32 +10077,59 @@ function focus_default(Alpine) {
10046
10077
 
10047
10078
  // src/utils/include.js
10048
10079
  function include_default(Alpine) {
10049
- Alpine.directive("h-include", (el, { modifiers, expression }, { evaluateLater, effect }) => {
10080
+ Alpine.directive("h-include", (el, { modifiers, expression }, { evaluateLater, effect, cleanup, Alpine: Alpine2 }) => {
10050
10081
  const getUrl = evaluateLater(expression);
10082
+ function executeScript(oldScript) {
10083
+ return new Promise((resolve, reject) => {
10084
+ const newScript = document.createElement("script");
10085
+ for (const attr of oldScript.attributes) {
10086
+ newScript.setAttribute(attr.name, attr.value);
10087
+ }
10088
+ if (oldScript.src) {
10089
+ newScript.src = oldScript.src;
10090
+ newScript.onload = resolve;
10091
+ newScript.onerror = reject;
10092
+ } else {
10093
+ newScript.textContent = oldScript.textContent;
10094
+ resolve();
10095
+ }
10096
+ el.appendChild(newScript);
10097
+ });
10098
+ }
10099
+ function initTree() {
10100
+ for (let i = 0; i < el.children.length; i++) {
10101
+ if (el.children[i].tagName !== "SCRIPT") Alpine2.initTree(el.children[i]);
10102
+ }
10103
+ }
10104
+ function destroyTree() {
10105
+ if (el.children.length) {
10106
+ for (let i = 0; i < el.children.length; i++) {
10107
+ if (el.children[i].tagName !== "SCRIPT") Alpine2.initTree(el.children[i]);
10108
+ }
10109
+ }
10110
+ }
10051
10111
  function getHtml(url) {
10052
10112
  const parsed = new URL(url, window.location.origin);
10053
10113
  if (parsed.origin === window.location.origin) {
10054
10114
  fetch(url).then((response) => {
10055
10115
  if (response.status === 200) return response.text();
10056
10116
  throw response;
10057
- }).then((content) => {
10117
+ }).then(async (content) => {
10058
10118
  if (modifiers.includes("js")) {
10059
10119
  const container = document.createElement("div");
10060
10120
  container.innerHTML = content;
10061
- let staticScript = container.querySelector("script");
10062
- const script = document.createElement("script");
10063
- for (let a = 0; a < staticScript.attributes.length; a++) {
10064
- script.setAttribute(staticScript.attributes[a].name, staticScript.attributes[a].value);
10065
- }
10066
- script.appendChild(document.createTextNode(staticScript.innerHTML));
10067
- staticScript.remove();
10121
+ const scripts = [...container.querySelectorAll("script")];
10122
+ scripts.forEach((script) => script.remove());
10068
10123
  while (container.childNodes.length > 0) {
10069
10124
  el.appendChild(container.childNodes[0]);
10070
10125
  }
10071
- el.appendChild(script);
10126
+ for (const oldScript of scripts) {
10127
+ await executeScript(oldScript);
10128
+ }
10072
10129
  } else {
10073
10130
  el.innerHTML = content;
10074
10131
  }
10132
+ initTree();
10075
10133
  }).catch((response) => {
10076
10134
  console.error(response);
10077
10135
  });
@@ -10081,10 +10139,14 @@ function include_default(Alpine) {
10081
10139
  }
10082
10140
  effect(() => {
10083
10141
  getUrl((url) => {
10142
+ destroyTree();
10143
+ el.innerHTML = "";
10084
10144
  if (url) getHtml(url);
10085
- else el.innerHTML = "";
10086
10145
  });
10087
10146
  });
10147
+ cleanup(() => {
10148
+ destroyTree();
10149
+ });
10088
10150
  }).before("bind");
10089
10151
  }
10090
10152