@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.
- package/dist/harmonia.css +1 -1
- package/dist/harmonia.esm.js +48 -32
- package/dist/harmonia.esm.min.js +2 -2
- package/dist/harmonia.esm.min.js.map +3 -3
- package/dist/harmonia.js +48 -32
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +3 -3
- package/package.json +1 -1
package/dist/harmonia.js
CHANGED
|
@@ -4637,7 +4637,7 @@
|
|
|
4637
4637
|
if (!popover) {
|
|
4638
4638
|
throw new Error(`${original} must be placed after a popover element`);
|
|
4639
4639
|
}
|
|
4640
|
-
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-
|
|
4640
|
+
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");
|
|
4641
4641
|
el.setAttribute("data-slot", "popover");
|
|
4642
4642
|
el.setAttribute("role", "dialog");
|
|
4643
4643
|
el.setAttribute("tabindex", "-1");
|
|
@@ -6649,7 +6649,8 @@
|
|
|
6649
6649
|
function select_default(Alpine) {
|
|
6650
6650
|
Alpine.directive("h-select", (el, { modifiers }, { Alpine: Alpine2, cleanup }) => {
|
|
6651
6651
|
el._h_select = Alpine2.reactive({
|
|
6652
|
-
|
|
6652
|
+
fieldLabelId: void 0,
|
|
6653
|
+
trigger: void 0,
|
|
6653
6654
|
controls: `hsc${v4_default()}`,
|
|
6654
6655
|
expanded: false,
|
|
6655
6656
|
multiple: false,
|
|
@@ -6698,9 +6699,16 @@
|
|
|
6698
6699
|
});
|
|
6699
6700
|
Alpine.directive("h-select-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
6700
6701
|
if (el.tagName !== "INPUT") {
|
|
6701
|
-
throw new Error(`${original} must be
|
|
6702
|
+
throw new Error(`${original} must be an input of type "text"`);
|
|
6702
6703
|
}
|
|
6703
6704
|
const select = Alpine2.findClosest(el.parentElement, (parent) => parent.hasOwnProperty("_h_select"));
|
|
6705
|
+
const label = (() => {
|
|
6706
|
+
const field = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "field");
|
|
6707
|
+
if (field) {
|
|
6708
|
+
return field.querySelector("[data-slot=field-label]");
|
|
6709
|
+
}
|
|
6710
|
+
return;
|
|
6711
|
+
})();
|
|
6704
6712
|
if (!select) {
|
|
6705
6713
|
throw new Error(`${original} must be inside a select element`);
|
|
6706
6714
|
} else if (el.hasOwnProperty("_x_model")) {
|
|
@@ -6740,6 +6748,19 @@
|
|
|
6740
6748
|
fakeTrigger.setAttribute("data-slot", "select-value");
|
|
6741
6749
|
fakeTrigger.setAttribute("tabindex", "0");
|
|
6742
6750
|
fakeTrigger.classList.add("flex", "items-center", "justify-between", "gap-2", "outline-none", "pl-3", "pr-2", "size-full", "[&[data-state=open]>svg]:rotate-180");
|
|
6751
|
+
select._h_select.trigger = fakeTrigger;
|
|
6752
|
+
let labelObserver;
|
|
6753
|
+
if (label) {
|
|
6754
|
+
if (!label.hasAttribute("id")) {
|
|
6755
|
+
label.setAttribute("id", `hsil${v4_default()}`);
|
|
6756
|
+
}
|
|
6757
|
+
select._h_select.fieldLabelId = label.getAttribute("id");
|
|
6758
|
+
fakeTrigger.setAttribute("aria-labelledby", label.getAttribute("id"));
|
|
6759
|
+
labelObserver = new MutationObserver(() => {
|
|
6760
|
+
select._h_select.fieldLabelId = label.getAttribute("id");
|
|
6761
|
+
});
|
|
6762
|
+
labelObserver.observe(label, { attributes: true, attributeFilter: ["id"] });
|
|
6763
|
+
}
|
|
6743
6764
|
function getPlaceholder() {
|
|
6744
6765
|
if (!el.value) {
|
|
6745
6766
|
const value = el.getAttribute("placeholder");
|
|
@@ -6752,17 +6773,10 @@
|
|
|
6752
6773
|
}
|
|
6753
6774
|
}
|
|
6754
6775
|
getPlaceholder();
|
|
6755
|
-
const observer = new MutationObserver((
|
|
6756
|
-
|
|
6757
|
-
if (mutation.attributeName === "data-id") {
|
|
6758
|
-
select._h_select.id = el.getAttribute("data-id");
|
|
6759
|
-
fakeTrigger.setAttribute("id", select._h_select.id);
|
|
6760
|
-
} else if (mutation.attributeName === "placeholder" && !select._h_select.label.length) {
|
|
6761
|
-
getPlaceholder();
|
|
6762
|
-
}
|
|
6763
|
-
});
|
|
6776
|
+
const observer = new MutationObserver(() => {
|
|
6777
|
+
getPlaceholder();
|
|
6764
6778
|
});
|
|
6765
|
-
observer.observe(el, { attributes: true, attributeFilter: ["
|
|
6779
|
+
observer.observe(el, { attributes: true, attributeFilter: ["placeholder"] });
|
|
6766
6780
|
effect(() => {
|
|
6767
6781
|
if (select._h_select.label.length === 1) {
|
|
6768
6782
|
displayValue.innerText = select._h_select.label[0];
|
|
@@ -6775,8 +6789,6 @@
|
|
|
6775
6789
|
}
|
|
6776
6790
|
});
|
|
6777
6791
|
fakeTrigger.setAttribute("data-slot", "select-input");
|
|
6778
|
-
select._h_select.id = el.hasAttribute("data-id") ? el.getAttribute("data-id") : `hs${v4_default()}`;
|
|
6779
|
-
fakeTrigger.setAttribute("id", select._h_select.id);
|
|
6780
6792
|
fakeTrigger.setAttribute("aria-controls", select._h_select.controls);
|
|
6781
6793
|
fakeTrigger.setAttribute("aria-haspopup", "listbox");
|
|
6782
6794
|
fakeTrigger.setAttribute("aria-autocomplete", "none");
|
|
@@ -6938,9 +6950,9 @@
|
|
|
6938
6950
|
const onInputChange = () => {
|
|
6939
6951
|
select._h_select.label.length = 0;
|
|
6940
6952
|
for (let i = 0; i < select._h_select.listeners.length; i++) {
|
|
6941
|
-
const
|
|
6942
|
-
if (
|
|
6943
|
-
select._h_select.label.push(
|
|
6953
|
+
const label2 = select._h_select.listeners[i](select._h_model.get());
|
|
6954
|
+
if (label2) {
|
|
6955
|
+
select._h_select.label.push(label2);
|
|
6944
6956
|
}
|
|
6945
6957
|
}
|
|
6946
6958
|
};
|
|
@@ -6953,6 +6965,9 @@
|
|
|
6953
6965
|
top.removeEventListener("click", close);
|
|
6954
6966
|
el.removeEventListener("change", onInputChange);
|
|
6955
6967
|
observer.disconnect();
|
|
6968
|
+
if (labelObserver) {
|
|
6969
|
+
labelObserver.disconnect();
|
|
6970
|
+
}
|
|
6956
6971
|
});
|
|
6957
6972
|
});
|
|
6958
6973
|
Alpine.directive("h-select-content", (el, { original }, { effect, Alpine: Alpine2 }) => {
|
|
@@ -6963,17 +6978,15 @@
|
|
|
6963
6978
|
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");
|
|
6964
6979
|
el.setAttribute("data-slot", "select-content");
|
|
6965
6980
|
el.setAttribute("role", "listbox");
|
|
6966
|
-
el.setAttribute("role", "presentation");
|
|
6967
6981
|
el.setAttribute("id", select._h_select.controls);
|
|
6968
6982
|
el.setAttribute("tabindex", "-1");
|
|
6969
6983
|
el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
|
|
6970
|
-
|
|
6971
|
-
if (!control) {
|
|
6984
|
+
if (!select._h_select.trigger) {
|
|
6972
6985
|
throw new Error(`${original}: trigger not found`);
|
|
6973
6986
|
}
|
|
6974
6987
|
let autoUpdateCleanup;
|
|
6975
6988
|
function updatePosition() {
|
|
6976
|
-
computePosition2(
|
|
6989
|
+
computePosition2(select._h_select.trigger, el, {
|
|
6977
6990
|
placement: el.getAttribute("data-align") || "bottom-start",
|
|
6978
6991
|
middleware: [
|
|
6979
6992
|
offset2(4),
|
|
@@ -6996,12 +7009,12 @@
|
|
|
6996
7009
|
});
|
|
6997
7010
|
}
|
|
6998
7011
|
effect(() => {
|
|
6999
|
-
el.setAttribute("aria-labelledby", select._h_select.
|
|
7012
|
+
el.setAttribute("aria-labelledby", select._h_select.fieldLabelId);
|
|
7000
7013
|
});
|
|
7001
7014
|
effect(() => {
|
|
7002
7015
|
el.setAttribute("data-state", select._h_select.expanded ? "open" : "closed");
|
|
7003
7016
|
if (select._h_select.expanded) {
|
|
7004
|
-
autoUpdateCleanup = autoUpdate(
|
|
7017
|
+
autoUpdateCleanup = autoUpdate(select._h_select.trigger, el, updatePosition);
|
|
7005
7018
|
} else {
|
|
7006
7019
|
if (autoUpdateCleanup) autoUpdateCleanup();
|
|
7007
7020
|
Object.assign(el.style, {
|
|
@@ -7317,7 +7330,7 @@
|
|
|
7317
7330
|
el.setAttribute("data-slot", "sidebar-header");
|
|
7318
7331
|
});
|
|
7319
7332
|
Alpine.directive("h-sidebar-content", (el) => {
|
|
7320
|
-
el.classList.add("vbox", "min-h-0", "flex-1", "
|
|
7333
|
+
el.classList.add("vbox", "min-h-0", "flex-1", "overflow-auto", "scrollbar-none");
|
|
7321
7334
|
el.setAttribute("data-slot", "sidebar-content");
|
|
7322
7335
|
});
|
|
7323
7336
|
Alpine.directive("h-sidebar-group", (el, { expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
|
|
@@ -7641,13 +7654,16 @@
|
|
|
7641
7654
|
});
|
|
7642
7655
|
Alpine.directive("h-sidebar-menu-skeleton", (el, { modifiers }) => {
|
|
7643
7656
|
el.classList.add("flex", "h-8", "items-center", "gap-2", "rounded-md", "px-2");
|
|
7657
|
+
const skeleton = document.createElement("div");
|
|
7658
|
+
skeleton.classList.add("h-4", "flex-1", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
|
|
7644
7659
|
if (modifiers.includes("icon")) {
|
|
7660
|
+
skeleton.classList.add("group-data-[collapsed=true]/sidebar:!hidden");
|
|
7645
7661
|
const icon = document.createElement("div");
|
|
7646
7662
|
icon.classList.add("size-4", "rounded-md", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
|
|
7647
7663
|
el.appendChild(icon);
|
|
7664
|
+
} else {
|
|
7665
|
+
skeleton.classList.add("group-data-[collapsed=true]/sidebar:!w-4", "group-data-[collapsed=true]/sidebar:!max-w-4");
|
|
7648
7666
|
}
|
|
7649
|
-
const skeleton = document.createElement("div");
|
|
7650
|
-
skeleton.classList.add("h-4", "flex-1", "bg-sidebar-secondary", "animate-pulse", "rounded-md");
|
|
7651
7667
|
skeleton.style.maxWidth = `${Math.floor(Math.random() * 40) + 50}%`;
|
|
7652
7668
|
el.appendChild(skeleton);
|
|
7653
7669
|
el.setAttribute("data-slot", "sidebar-menu-skeleton");
|
|
@@ -9255,7 +9271,7 @@
|
|
|
9255
9271
|
timeContainer.addEventListener("click", setTime);
|
|
9256
9272
|
el.appendChild(timeContainer);
|
|
9257
9273
|
const hoursList = document.createElement("ul");
|
|
9258
|
-
hoursList.classList.add("flex-1", "overflow-y-
|
|
9274
|
+
hoursList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
|
|
9259
9275
|
hoursList.setAttribute("role", "listbox");
|
|
9260
9276
|
hoursList.setAttribute("tabindex", "-1");
|
|
9261
9277
|
hoursList.setAttribute("aria-label", el.dataset.labelHours ?? "Select hour");
|
|
@@ -9272,7 +9288,7 @@
|
|
|
9272
9288
|
hoursList.appendChild(hour);
|
|
9273
9289
|
}
|
|
9274
9290
|
const minutesList = document.createElement("ul");
|
|
9275
|
-
minutesList.classList.add("flex-1", "overflow-y-
|
|
9291
|
+
minutesList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
|
|
9276
9292
|
minutesList.setAttribute("role", "listbox");
|
|
9277
9293
|
minutesList.setAttribute("tabindex", "-1");
|
|
9278
9294
|
minutesList.setAttribute("aria-label", el.dataset.labelMinutes ?? "Select minute");
|
|
@@ -9289,7 +9305,7 @@
|
|
|
9289
9305
|
minutesList.appendChild(minute);
|
|
9290
9306
|
}
|
|
9291
9307
|
const secondsList = document.createElement("ul");
|
|
9292
|
-
secondsList.classList.add("flex-1", "overflow-y-
|
|
9308
|
+
secondsList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
|
|
9293
9309
|
if (!timepicker._h_timepicker.seconds) {
|
|
9294
9310
|
secondsList.classList.add("hidden");
|
|
9295
9311
|
}
|
|
@@ -9309,7 +9325,7 @@
|
|
|
9309
9325
|
secondsList.appendChild(second);
|
|
9310
9326
|
}
|
|
9311
9327
|
const periodList = document.createElement("ul");
|
|
9312
|
-
periodList.classList.add("flex-1", "overflow-y-
|
|
9328
|
+
periodList.classList.add("flex-1", "overflow-y-auto", "[scrollbar-width:thin]");
|
|
9313
9329
|
if (!timepicker._h_timepicker.is12Hour) {
|
|
9314
9330
|
periodList.classList.add("hidden");
|
|
9315
9331
|
}
|
|
@@ -9991,7 +10007,7 @@
|
|
|
9991
10007
|
}
|
|
9992
10008
|
|
|
9993
10009
|
// package.json
|
|
9994
|
-
var version = "1.
|
|
10010
|
+
var version = "1.4.1";
|
|
9995
10011
|
|
|
9996
10012
|
// src/index.js
|
|
9997
10013
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, version };
|