@codbex/harmonia 1.3.0 → 1.4.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.
@@ -6543,7 +6543,7 @@ function popover_default(Alpine) {
6543
6543
  if (!popover) {
6544
6544
  throw new Error(`${original} must be placed after a popover element`);
6545
6545
  }
6546
- 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-scroll");
6546
+ 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");
6547
6547
  el.setAttribute("data-slot", "popover");
6548
6548
  el.setAttribute("role", "dialog");
6549
6549
  el.setAttribute("tabindex", "-1");
@@ -6696,7 +6696,8 @@ var FilterType = Object.freeze({
6696
6696
  function select_default(Alpine) {
6697
6697
  Alpine.directive("h-select", (el, { modifiers }, { Alpine: Alpine2, cleanup }) => {
6698
6698
  el._h_select = Alpine2.reactive({
6699
- id: void 0,
6699
+ fieldLabelId: void 0,
6700
+ trigger: void 0,
6700
6701
  controls: `hsc${v4_default()}`,
6701
6702
  expanded: false,
6702
6703
  multiple: false,
@@ -6745,9 +6746,16 @@ function select_default(Alpine) {
6745
6746
  });
6746
6747
  Alpine.directive("h-select-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
6747
6748
  if (el.tagName !== "INPUT") {
6748
- throw new Error(`${original} must be a readonly input of type "text"`);
6749
+ throw new Error(`${original} must be an input of type "text"`);
6749
6750
  }
6750
6751
  const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
6752
+ const label = (() => {
6753
+ const field = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "field");
6754
+ if (field) {
6755
+ return field.querySelector("[data-slot=field-label]");
6756
+ }
6757
+ return;
6758
+ })();
6751
6759
  if (!select) {
6752
6760
  throw new Error(`${original} must be inside a select element`);
6753
6761
  } else if (el.hasOwnProperty("_x_model")) {
@@ -6787,6 +6795,19 @@ function select_default(Alpine) {
6787
6795
  fakeTrigger.setAttribute("data-slot", "select-value");
6788
6796
  fakeTrigger.setAttribute("tabindex", "0");
6789
6797
  fakeTrigger.classList.add("flex", "items-center", "justify-between", "gap-2", "outline-none", "pl-3", "pr-2", "size-full", "[&[data-state=open]>svg]:rotate-180");
6798
+ select._h_select.trigger = fakeTrigger;
6799
+ let labelObserver;
6800
+ if (label) {
6801
+ if (!label.hasAttribute("id")) {
6802
+ label.setAttribute("id", `hsil${v4_default()}`);
6803
+ }
6804
+ select._h_select.fieldLabelId = label.getAttribute("id");
6805
+ fakeTrigger.setAttribute("aria-labelledby", label.getAttribute("id"));
6806
+ labelObserver = new MutationObserver(() => {
6807
+ select._h_select.fieldLabelId = label.getAttribute("id");
6808
+ });
6809
+ labelObserver.observe(label, { attributes: true, attributeFilter: ["id"] });
6810
+ }
6790
6811
  function getPlaceholder() {
6791
6812
  if (!el.value) {
6792
6813
  const value = el.getAttribute("placeholder");
@@ -6799,17 +6820,10 @@ function select_default(Alpine) {
6799
6820
  }
6800
6821
  }
6801
6822
  getPlaceholder();
6802
- const observer = new MutationObserver((mutations) => {
6803
- mutations.forEach((mutation) => {
6804
- if (mutation.attributeName === "data-id") {
6805
- select._h_select.id = el.getAttribute("data-id");
6806
- fakeTrigger.setAttribute("id", select._h_select.id);
6807
- } else if (mutation.attributeName === "placeholder" && !select._h_select.label.length) {
6808
- getPlaceholder();
6809
- }
6810
- });
6823
+ const observer = new MutationObserver(() => {
6824
+ getPlaceholder();
6811
6825
  });
6812
- observer.observe(el, { attributes: true, attributeFilter: ["data-id", "placeholder"] });
6826
+ observer.observe(el, { attributes: true, attributeFilter: ["placeholder"] });
6813
6827
  effect(() => {
6814
6828
  if (select._h_select.label.length === 1) {
6815
6829
  displayValue.innerText = select._h_select.label[0];
@@ -6822,8 +6836,6 @@ function select_default(Alpine) {
6822
6836
  }
6823
6837
  });
6824
6838
  fakeTrigger.setAttribute("data-slot", "select-input");
6825
- select._h_select.id = el.hasAttribute("data-id") ? el.getAttribute("data-id") : `hs${v4_default()}`;
6826
- fakeTrigger.setAttribute("id", select._h_select.id);
6827
6839
  fakeTrigger.setAttribute("aria-controls", select._h_select.controls);
6828
6840
  fakeTrigger.setAttribute("aria-haspopup", "listbox");
6829
6841
  fakeTrigger.setAttribute("aria-autocomplete", "none");
@@ -6985,9 +6997,9 @@ function select_default(Alpine) {
6985
6997
  const onInputChange = () => {
6986
6998
  select._h_select.label.length = 0;
6987
6999
  for (let i = 0; i < select._h_select.listeners.length; i++) {
6988
- const label = select._h_select.listeners[i](select._h_model.get());
6989
- if (label) {
6990
- select._h_select.label.push(label);
7000
+ const label2 = select._h_select.listeners[i](select._h_model.get());
7001
+ if (label2) {
7002
+ select._h_select.label.push(label2);
6991
7003
  }
6992
7004
  }
6993
7005
  };
@@ -7000,6 +7012,9 @@ function select_default(Alpine) {
7000
7012
  top.removeEventListener("click", close);
7001
7013
  el.removeEventListener("change", onInputChange);
7002
7014
  observer.disconnect();
7015
+ if (labelObserver) {
7016
+ labelObserver.disconnect();
7017
+ }
7003
7018
  });
7004
7019
  });
7005
7020
  Alpine.directive("h-select-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
@@ -7010,17 +7025,15 @@ function select_default(Alpine) {
7010
7025
  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");
7011
7026
  el.setAttribute("data-slot", "select-content");
7012
7027
  el.setAttribute("role", "listbox");
7013
- el.setAttribute("role", "presentation");
7014
7028
  el.setAttribute("id", select._h_select.controls);
7015
7029
  el.setAttribute("tabindex", "-1");
7016
7030
  el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
7017
- const control = select.querySelector(`#${select._h_select.id}`);
7018
- if (!control) {
7031
+ if (!select._h_select.trigger) {
7019
7032
  throw new Error(`${original}: trigger not found`);
7020
7033
  }
7021
7034
  let autoUpdateCleanup;
7022
7035
  function updatePosition() {
7023
- computePosition2(control, el, {
7036
+ computePosition2(select._h_select.trigger, el, {
7024
7037
  placement: el.getAttribute("data-align") || "bottom-start",
7025
7038
  middleware: [
7026
7039
  offset2(4),
@@ -7043,12 +7056,12 @@ function select_default(Alpine) {
7043
7056
  });
7044
7057
  }
7045
7058
  effect(() => {
7046
- el.setAttribute("aria-labelledby", select._h_select.id);
7059
+ el.setAttribute("aria-labelledby", select._h_select.fieldLabelId);
7047
7060
  });
7048
7061
  effect(() => {
7049
7062
  el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
7050
7063
  if (select._h_select.expanded) {
7051
- autoUpdateCleanup = autoUpdate(control, el, updatePosition);
7064
+ autoUpdateCleanup = autoUpdate(select._h_select.trigger, el, updatePosition);
7052
7065
  } else {
7053
7066
  if (autoUpdateCleanup) autoUpdateCleanup();
7054
7067
  Object.assign(el.style, {
@@ -7364,7 +7377,7 @@ function sidebar_default(Alpine) {
7364
7377
  el.setAttribute("data-slot", "sidebar-header");
7365
7378
  });
7366
7379
  Alpine.directive("h-sidebar-content", (el) => {
7367
- el.classList.add("vbox", "min-h-0", "flex-1", "gap-2", "overflow-auto", "group-data-[collapsed=true]/sidebar:overflow-hidden");
7380
+ el.classList.add("vbox", "min-h-0", "flex-1", "overflow-auto", "scrollbar-none");
7368
7381
  el.setAttribute("data-slot", "sidebar-content");
7369
7382
  });
7370
7383
  Alpine.directive("h-sidebar-group", (el, { expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
@@ -7688,13 +7701,16 @@ function sidebar_default(Alpine) {
7688
7701
  });
7689
7702
  Alpine.directive("h-sidebar-menu-skeleton", (el, { modifiers }) => {
7690
7703
  el.classList.add("flex", "h-8", "items-center", "gap-2", "rounded-md", "px-2");
7704
+ const skeleton = document.createElement("div");
7705
+ skeleton.classList.add("h-4", "flex-1", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
7691
7706
  if (modifiers.includes("icon")) {
7707
+ skeleton.classList.add("group-data-[collapsed=true]/sidebar:!hidden");
7692
7708
  const icon = document.createElement("div");
7693
7709
  icon.classList.add("size-4", "rounded-md", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
7694
7710
  el.appendChild(icon);
7711
+ } else {
7712
+ skeleton.classList.add("group-data-[collapsed=true]/sidebar:!w-4", "group-data-[collapsed=true]/sidebar:!max-w-4");
7695
7713
  }
7696
- const skeleton = document.createElement("div");
7697
- skeleton.classList.add("h-4", "flex-1", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
7698
7714
  skeleton.style.maxWidth = `${Math.floor(Math.random() * 40) + 50}%`;
7699
7715
  el.appendChild(skeleton);
7700
7716
  el.setAttribute("data-slot", "sidebar-menu-skeleton");
@@ -9302,7 +9318,7 @@ function timepicker_default(Alpine) {
9302
9318
  timeContainer.addEventListener("click", setTime);
9303
9319
  el.appendChild(timeContainer);
9304
9320
  const hoursList = document.createElement("ul");
9305
- hoursList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9321
+ hoursList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9306
9322
  hoursList.setAttribute("role", "listbox");
9307
9323
  hoursList.setAttribute("tabindex", "-1");
9308
9324
  hoursList.setAttribute("aria-label", el.dataset.labelHours ?? "Select hour");
@@ -9319,7 +9335,7 @@ function timepicker_default(Alpine) {
9319
9335
  hoursList.appendChild(hour);
9320
9336
  }
9321
9337
  const minutesList = document.createElement("ul");
9322
- minutesList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9338
+ minutesList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9323
9339
  minutesList.setAttribute("role", "listbox");
9324
9340
  minutesList.setAttribute("tabindex", "-1");
9325
9341
  minutesList.setAttribute("aria-label", el.dataset.labelMinutes ?? "Select minute");
@@ -9336,7 +9352,7 @@ function timepicker_default(Alpine) {
9336
9352
  minutesList.appendChild(minute);
9337
9353
  }
9338
9354
  const secondsList = document.createElement("ul");
9339
- secondsList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9355
+ secondsList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9340
9356
  if (!timepicker._h_timepicker.seconds) {
9341
9357
  secondsList.classList.add("hidden");
9342
9358
  }
@@ -9356,7 +9372,7 @@ function timepicker_default(Alpine) {
9356
9372
  secondsList.appendChild(second);
9357
9373
  }
9358
9374
  const periodList = document.createElement("ul");
9359
- periodList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9375
+ periodList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9360
9376
  if (!timepicker._h_timepicker.is12Hour) {
9361
9377
  periodList.classList.add("hidden");
9362
9378
  }
@@ -9914,7 +9930,7 @@ function tree_default(Alpine) {
9914
9930
  }
9915
9931
 
9916
9932
  // package.json
9917
- var version = "1.3.0";
9933
+ var version = "1.4.1";
9918
9934
 
9919
9935
  // src/utils/breakpoint-listener.js
9920
9936
  function getBreakpointListener(handler, breakpoint = 768) {