@codbex/harmonia 1.3.0 → 1.4.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.
@@ -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, {
@@ -9302,7 +9315,7 @@ function timepicker_default(Alpine) {
9302
9315
  timeContainer.addEventListener("click", setTime);
9303
9316
  el.appendChild(timeContainer);
9304
9317
  const hoursList = document.createElement("ul");
9305
- hoursList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9318
+ hoursList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9306
9319
  hoursList.setAttribute("role", "listbox");
9307
9320
  hoursList.setAttribute("tabindex", "-1");
9308
9321
  hoursList.setAttribute("aria-label", el.dataset.labelHours ?? "Select hour");
@@ -9319,7 +9332,7 @@ function timepicker_default(Alpine) {
9319
9332
  hoursList.appendChild(hour);
9320
9333
  }
9321
9334
  const minutesList = document.createElement("ul");
9322
- minutesList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9335
+ minutesList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9323
9336
  minutesList.setAttribute("role", "listbox");
9324
9337
  minutesList.setAttribute("tabindex", "-1");
9325
9338
  minutesList.setAttribute("aria-label", el.dataset.labelMinutes ?? "Select minute");
@@ -9336,7 +9349,7 @@ function timepicker_default(Alpine) {
9336
9349
  minutesList.appendChild(minute);
9337
9350
  }
9338
9351
  const secondsList = document.createElement("ul");
9339
- secondsList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9352
+ secondsList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9340
9353
  if (!timepicker._h_timepicker.seconds) {
9341
9354
  secondsList.classList.add("hidden");
9342
9355
  }
@@ -9356,7 +9369,7 @@ function timepicker_default(Alpine) {
9356
9369
  secondsList.appendChild(second);
9357
9370
  }
9358
9371
  const periodList = document.createElement("ul");
9359
- periodList.classList.add("flex-1", "overflow-y-scroll", "[scrollbar-width:thin]");
9372
+ periodList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
9360
9373
  if (!timepicker._h_timepicker.is12Hour) {
9361
9374
  periodList.classList.add("hidden");
9362
9375
  }
@@ -9914,7 +9927,7 @@ function tree_default(Alpine) {
9914
9927
  }
9915
9928
 
9916
9929
  // package.json
9917
- var version = "1.3.0";
9930
+ var version = "1.4.0";
9918
9931
 
9919
9932
  // src/utils/breakpoint-listener.js
9920
9933
  function getBreakpointListener(handler, breakpoint = 768) {