@codbex/harmonia 1.9.0 → 1.10.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.css +1 -1
- package/dist/harmonia.esm.js +389 -188
- package/dist/harmonia.esm.min.js +2 -2
- package/dist/harmonia.esm.min.js.map +4 -4
- package/dist/harmonia.js +389 -188
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +4 -4
- package/package.json +15 -2
package/dist/harmonia.js
CHANGED
|
@@ -597,10 +597,10 @@
|
|
|
597
597
|
}) : { single: false };
|
|
598
598
|
el.setAttribute("data-slot", "accordion");
|
|
599
599
|
});
|
|
600
|
-
Alpine.directive("h-accordion-item", (el, { original
|
|
601
|
-
const accordion = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
600
|
+
Alpine.directive("h-accordion-item", (el, { original, expression, modifiers }, { Alpine: Alpine2 }) => {
|
|
601
|
+
const accordion = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_accordion"));
|
|
602
602
|
if (!accordion) {
|
|
603
|
-
throw new Error(`${
|
|
603
|
+
throw new Error(`${original} must be inside an accordion`);
|
|
604
604
|
}
|
|
605
605
|
el.classList.add("border-b", "last:border-b-0");
|
|
606
606
|
el.setAttribute("data-slot", "accordion-item");
|
|
@@ -623,14 +623,14 @@
|
|
|
623
623
|
expanded: getIsExpanded()
|
|
624
624
|
});
|
|
625
625
|
});
|
|
626
|
-
Alpine.directive("h-accordion-trigger", (el, { original
|
|
626
|
+
Alpine.directive("h-accordion-trigger", (el, { original, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
|
|
627
627
|
if (el.tagName.length !== 2 && !el.tagName.startsWith("H")) {
|
|
628
|
-
throw new Error(`${
|
|
628
|
+
throw new Error(`${original} must be a header element`);
|
|
629
629
|
}
|
|
630
|
-
const accordion = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
631
|
-
const accordionItem = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
630
|
+
const accordion = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_accordion"));
|
|
631
|
+
const accordionItem = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_accordionItem"));
|
|
632
632
|
if (!accordionItem || !accordion) {
|
|
633
|
-
throw new Error(`${
|
|
633
|
+
throw new Error(`${original} must have an accordion and accordion item parent elements`);
|
|
634
634
|
}
|
|
635
635
|
el.classList.add("flex", "h-12", "min-h-12", "[[data-size=md]_&]:h-10", "[[data-size=md]_&]:min-h-10", "[[data-size=sm]_&]:h-8", "[[data-size=sm]_&]:min-h-8");
|
|
636
636
|
el.setAttribute("tabIndex", "-1");
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
Alpine.directive("h-accordion-content", (el, _, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
704
704
|
el.classList.add("pb-0", "overflow-hidden", "text-sm", "hidden", "transition-[opacity,max-height,padding-bottom]", "motion-reduce:transition-none", "duration-200", "ease-out", "opacity-0");
|
|
705
705
|
el.setAttribute("data-slot", "accordion-content");
|
|
706
|
-
const parent = Alpine2.findClosest(el.parentElement, (parent2) =>
|
|
706
|
+
const parent = Alpine2.findClosest(el.parentElement, (parent2) => Object.prototype.hasOwnProperty.call(parent2, "_h_accordionItem"));
|
|
707
707
|
if (parent) {
|
|
708
708
|
let onTransitionEnd = function(event) {
|
|
709
709
|
if (event.target === el && event.target.classList.contains("opacity-0")) {
|
|
@@ -780,7 +780,7 @@
|
|
|
780
780
|
for (const [_, value] of Object.entries(variants)) {
|
|
781
781
|
el.classList.remove(...value);
|
|
782
782
|
}
|
|
783
|
-
if (
|
|
783
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
784
784
|
}
|
|
785
785
|
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
786
786
|
const observer = new MutationObserver(() => {
|
|
@@ -861,10 +861,10 @@
|
|
|
861
861
|
el.classList.add("cursor-pointer", "hover:bg-secondary-hover", "active:bg-secondary-active");
|
|
862
862
|
}
|
|
863
863
|
});
|
|
864
|
-
Alpine.directive("h-avatar-image", (el, { original
|
|
865
|
-
const avatar = Alpine.findClosest(el.parentElement, (parent) =>
|
|
864
|
+
Alpine.directive("h-avatar-image", (el, { original }, { cleanup }) => {
|
|
865
|
+
const avatar = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_avatar"));
|
|
866
866
|
if (!avatar) {
|
|
867
|
-
throw new Error(`${
|
|
867
|
+
throw new Error(`${original} must be inside an avatar element`);
|
|
868
868
|
}
|
|
869
869
|
el.classList.add("aspect-square", "size-full", "rounded-[inherit]");
|
|
870
870
|
el.setAttribute("data-slot", "avatar-image");
|
|
@@ -895,10 +895,10 @@
|
|
|
895
895
|
observer.disconnect();
|
|
896
896
|
});
|
|
897
897
|
});
|
|
898
|
-
Alpine.directive("h-avatar-fallback", (el, { original
|
|
899
|
-
const avatar = Alpine.findClosest(el.parentElement, (parent) =>
|
|
898
|
+
Alpine.directive("h-avatar-fallback", (el, { original }, { effect }) => {
|
|
899
|
+
const avatar = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_avatar"));
|
|
900
900
|
if (!avatar) {
|
|
901
|
-
throw new Error(`${
|
|
901
|
+
throw new Error(`${original} must be inside an avatar element`);
|
|
902
902
|
}
|
|
903
903
|
el.classList.add("hidden", "bg-muted", "flex", "size-full", "items-center", "justify-center", "rounded-[inherit]");
|
|
904
904
|
el.setAttribute("data-slot", "avatar-fallback");
|
|
@@ -951,7 +951,7 @@
|
|
|
951
951
|
for (const [_2, value] of Object.entries(variants)) {
|
|
952
952
|
el.classList.remove(...value);
|
|
953
953
|
}
|
|
954
|
-
if (
|
|
954
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
955
955
|
}
|
|
956
956
|
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
957
957
|
const observer = new MutationObserver(() => {
|
|
@@ -1004,7 +1004,7 @@
|
|
|
1004
1004
|
for (const [_2, value] of Object.entries(variants)) {
|
|
1005
1005
|
el.classList.remove(...value);
|
|
1006
1006
|
}
|
|
1007
|
-
if (
|
|
1007
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
1008
1008
|
}
|
|
1009
1009
|
setVariant(el.getAttribute("data-variant") ?? "primary");
|
|
1010
1010
|
const observer = new MutationObserver(() => {
|
|
@@ -1194,7 +1194,7 @@
|
|
|
1194
1194
|
}
|
|
1195
1195
|
};
|
|
1196
1196
|
function button_default(Alpine) {
|
|
1197
|
-
Alpine.directive("h-button", (el, { original
|
|
1197
|
+
Alpine.directive("h-button", (el, { original, modifiers }, { cleanup }) => {
|
|
1198
1198
|
setButtonClasses(el);
|
|
1199
1199
|
if (!el.hasAttribute("data-slot")) {
|
|
1200
1200
|
el.setAttribute("data-slot", "button");
|
|
@@ -1205,13 +1205,13 @@
|
|
|
1205
1205
|
for (const [_, value] of Object.entries(buttonVariants)) {
|
|
1206
1206
|
el.classList.remove(...value);
|
|
1207
1207
|
}
|
|
1208
|
-
if (
|
|
1208
|
+
if (Object.prototype.hasOwnProperty.call(buttonVariants, variant)) el.classList.add(...buttonVariants[variant]);
|
|
1209
1209
|
}
|
|
1210
1210
|
function setSize2(size3 = "default") {
|
|
1211
1211
|
el.classList.remove(...getButtonSize(lastSize, isAddon));
|
|
1212
1212
|
el.classList.add(...getButtonSize(size3, isAddon));
|
|
1213
1213
|
if (size3.startsWith("icon") && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
1214
|
-
console.error(`${
|
|
1214
|
+
console.error(`${original}: Icon-only buttons must have an "aria-label" or "aria-labelledby" attribute`, el);
|
|
1215
1215
|
}
|
|
1216
1216
|
lastSize = size3;
|
|
1217
1217
|
}
|
|
@@ -1264,7 +1264,7 @@
|
|
|
1264
1264
|
for (const [_, value] of Object.entries(variants)) {
|
|
1265
1265
|
el.classList.remove(...value);
|
|
1266
1266
|
}
|
|
1267
|
-
if (
|
|
1267
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
1268
1268
|
}
|
|
1269
1269
|
setVariant(el.getAttribute("data-orientation") ?? "horizontal");
|
|
1270
1270
|
});
|
|
@@ -1290,8 +1290,8 @@
|
|
|
1290
1290
|
bottom: "top",
|
|
1291
1291
|
top: "bottom"
|
|
1292
1292
|
};
|
|
1293
|
-
function clamp(start, value,
|
|
1294
|
-
return max(start, min(value,
|
|
1293
|
+
function clamp(start, value, end) {
|
|
1294
|
+
return max(start, min(value, end));
|
|
1295
1295
|
}
|
|
1296
1296
|
function evaluate(value, param) {
|
|
1297
1297
|
return typeof value === "function" ? value(param) : value;
|
|
@@ -2765,8 +2765,8 @@
|
|
|
2765
2765
|
|
|
2766
2766
|
// src/components/calendar.js
|
|
2767
2767
|
function calendar_default(Alpine) {
|
|
2768
|
-
Alpine.directive("h-calendar", (el, { original
|
|
2769
|
-
const datepicker = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
2768
|
+
Alpine.directive("h-calendar", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
|
|
2769
|
+
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_datepicker"));
|
|
2770
2770
|
el.classList.add("border", "rounded-control", "gap-2", "p-2");
|
|
2771
2771
|
el.setAttribute("tabindex", "-1");
|
|
2772
2772
|
if (datepicker) {
|
|
@@ -2823,7 +2823,7 @@
|
|
|
2823
2823
|
const onInputChange = () => {
|
|
2824
2824
|
const newValue = new Date(datepicker._h_datepicker.input.value);
|
|
2825
2825
|
if (isNaN(newValue)) {
|
|
2826
|
-
console.error(`${
|
|
2826
|
+
console.error(`${original}: input value is not a valid date - ${datepicker._h_datepicker.input.value}`);
|
|
2827
2827
|
datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2828
2828
|
return;
|
|
2829
2829
|
} else if (selected.getTime() !== newValue.getTime()) {
|
|
@@ -2839,7 +2839,7 @@
|
|
|
2839
2839
|
function setFromModel() {
|
|
2840
2840
|
selected = new Date(el._x_model.get());
|
|
2841
2841
|
if (isNaN(selected)) {
|
|
2842
|
-
console.error(`${
|
|
2842
|
+
console.error(`${original}: input value is not a valid date - ${el._x_model.get()}`);
|
|
2843
2843
|
if (datepicker) datepicker._h_datepicker.input.setCustomValidity("Input value is not a valid date.");
|
|
2844
2844
|
else el.setAttribute("data-invalid", "true");
|
|
2845
2845
|
} else if (datepicker) {
|
|
@@ -2847,7 +2847,7 @@
|
|
|
2847
2847
|
}
|
|
2848
2848
|
}
|
|
2849
2849
|
function checkForModel() {
|
|
2850
|
-
if (
|
|
2850
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model") && el._x_model.get()) {
|
|
2851
2851
|
setFromModel();
|
|
2852
2852
|
}
|
|
2853
2853
|
}
|
|
@@ -2909,7 +2909,7 @@
|
|
|
2909
2909
|
];
|
|
2910
2910
|
const previousYearBtn = document.createElement("button");
|
|
2911
2911
|
previousYearBtn.classList.add(...buttonClasses);
|
|
2912
|
-
previousYearBtn.setAttribute("aria-label", el.hasAttribute("data-aria-prev-year") ? el.
|
|
2912
|
+
previousYearBtn.setAttribute("aria-label", el.hasAttribute("data-aria-prev-year") ? el.getAttribute("data-aria-prev-year") : "previous year");
|
|
2913
2913
|
previousYearBtn.setAttribute("type", "button");
|
|
2914
2914
|
previousYearBtn.appendChild(
|
|
2915
2915
|
createSvg({
|
|
@@ -2928,7 +2928,7 @@
|
|
|
2928
2928
|
header.appendChild(previousYearBtn);
|
|
2929
2929
|
const previousMonthBtn = document.createElement("button");
|
|
2930
2930
|
previousMonthBtn.classList.add(...buttonClasses);
|
|
2931
|
-
previousMonthBtn.setAttribute("aria-label", el.hasAttribute("data-aria-prev-month") ? el.
|
|
2931
|
+
previousMonthBtn.setAttribute("aria-label", el.hasAttribute("data-aria-prev-month") ? el.getAttribute("data-aria-prev-month") : "previous month");
|
|
2932
2932
|
previousMonthBtn.setAttribute("type", "button");
|
|
2933
2933
|
previousMonthBtn.appendChild(
|
|
2934
2934
|
createSvg({
|
|
@@ -2952,7 +2952,7 @@
|
|
|
2952
2952
|
header.appendChild(headerLabel);
|
|
2953
2953
|
const nextMonthBtn = document.createElement("button");
|
|
2954
2954
|
nextMonthBtn.classList.add(...buttonClasses);
|
|
2955
|
-
nextMonthBtn.setAttribute("aria-label", el.hasAttribute("data-aria-next-month") ? el.
|
|
2955
|
+
nextMonthBtn.setAttribute("aria-label", el.hasAttribute("data-aria-next-month") ? el.getAttribute("data-aria-next-month") : "next month");
|
|
2956
2956
|
nextMonthBtn.setAttribute("type", "button");
|
|
2957
2957
|
nextMonthBtn.appendChild(
|
|
2958
2958
|
createSvg({
|
|
@@ -2971,7 +2971,7 @@
|
|
|
2971
2971
|
header.appendChild(nextMonthBtn);
|
|
2972
2972
|
const nextYearBtn = document.createElement("button");
|
|
2973
2973
|
nextYearBtn.classList.add(...buttonClasses);
|
|
2974
|
-
nextYearBtn.setAttribute("aria-label", el.hasAttribute("data-aria-next-year") ? el.
|
|
2974
|
+
nextYearBtn.setAttribute("aria-label", el.hasAttribute("data-aria-next-year") ? el.getAttribute("data-aria-next-year") : "next year");
|
|
2975
2975
|
nextYearBtn.setAttribute("type", "button");
|
|
2976
2976
|
nextYearBtn.appendChild(
|
|
2977
2977
|
createSvg({
|
|
@@ -3051,8 +3051,8 @@
|
|
|
3051
3051
|
const year = date.getFullYear();
|
|
3052
3052
|
const month = date.getMonth();
|
|
3053
3053
|
const start = new Date(year, month, 1);
|
|
3054
|
-
const
|
|
3055
|
-
const days =
|
|
3054
|
+
const end = new Date(year, month + 1, 0);
|
|
3055
|
+
const days = end.getDate();
|
|
3056
3056
|
const prevEndDay = new Date(year, month, 1);
|
|
3057
3057
|
prevEndDay.setDate(prevEndDay.getDate() - 1);
|
|
3058
3058
|
let lastPrevMonthDay = prevEndDay.getDate();
|
|
@@ -3159,7 +3159,7 @@
|
|
|
3159
3159
|
break;
|
|
3160
3160
|
case "End":
|
|
3161
3161
|
event.preventDefault();
|
|
3162
|
-
newDay.setDate(
|
|
3162
|
+
newDay.setDate(new Date(newDay.getFullYear(), newDay.getMonth() + 1, 0).getDate());
|
|
3163
3163
|
break;
|
|
3164
3164
|
case "PageUp":
|
|
3165
3165
|
event.preventDefault();
|
|
@@ -3268,7 +3268,7 @@
|
|
|
3268
3268
|
if (datepicker) {
|
|
3269
3269
|
el.addEventListener("transitionend", onTransitionEnd);
|
|
3270
3270
|
}
|
|
3271
|
-
if (
|
|
3271
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
3272
3272
|
const modelExpression = el.getAttribute("x-model");
|
|
3273
3273
|
const evaluateModel = evaluateLater(modelExpression);
|
|
3274
3274
|
effect(() => {
|
|
@@ -3376,6 +3376,192 @@
|
|
|
3376
3376
|
});
|
|
3377
3377
|
}
|
|
3378
3378
|
|
|
3379
|
+
// src/components/chip.js
|
|
3380
|
+
function chip_default(Alpine) {
|
|
3381
|
+
Alpine.directive("h-chip", (el, { original }, { cleanup }) => {
|
|
3382
|
+
if (el.tagName !== "BUTTON") {
|
|
3383
|
+
throw new Error(`${original} must be a button element`);
|
|
3384
|
+
}
|
|
3385
|
+
el._h_chip = Alpine.reactive({
|
|
3386
|
+
variant: "default"
|
|
3387
|
+
});
|
|
3388
|
+
el.classList.add(
|
|
3389
|
+
"cursor-pointer",
|
|
3390
|
+
"inline-flex",
|
|
3391
|
+
"items-center",
|
|
3392
|
+
"justify-center",
|
|
3393
|
+
"whitespace-nowrap",
|
|
3394
|
+
"rounded-full",
|
|
3395
|
+
"text-sm",
|
|
3396
|
+
"leading-none",
|
|
3397
|
+
"transform-gpu",
|
|
3398
|
+
"overflow-hidden",
|
|
3399
|
+
"transition-all",
|
|
3400
|
+
"duration-100",
|
|
3401
|
+
"motion-reduce:transition-none",
|
|
3402
|
+
"disabled:pointer-events-none",
|
|
3403
|
+
"disabled:opacity-50",
|
|
3404
|
+
"[&_svg]:pointer-events-none",
|
|
3405
|
+
"[&_svg:not([class*='size-'])]:size-4",
|
|
3406
|
+
"shrink-0",
|
|
3407
|
+
"[&_svg]:shrink-0",
|
|
3408
|
+
"focus-visible:outline-[calc(var(--spacing)*0.75)]",
|
|
3409
|
+
"focus-visible:outline",
|
|
3410
|
+
"h-7",
|
|
3411
|
+
"gap-1.5",
|
|
3412
|
+
"px-2.5",
|
|
3413
|
+
"has-[>svg]:pl-1.5",
|
|
3414
|
+
"has-[>[data-slot=chip-close]]:pr-0",
|
|
3415
|
+
"has-[>[data-slot=spinner]]:px-2",
|
|
3416
|
+
"text-secondary-foreground",
|
|
3417
|
+
"fill-secondary-foreground",
|
|
3418
|
+
"border"
|
|
3419
|
+
);
|
|
3420
|
+
if (!el.hasAttribute("type")) {
|
|
3421
|
+
el.setAttribute("type", "button");
|
|
3422
|
+
}
|
|
3423
|
+
el.setAttribute("data-slot", "chip");
|
|
3424
|
+
const variants = {
|
|
3425
|
+
default: ["bg-secondary", "[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-secondary-hover", "[&:active:not(:has([data-slot=chip-close]:active))]:bg-secondary-active", "outline-ring/50"],
|
|
3426
|
+
primary: [
|
|
3427
|
+
"bg-primary/10",
|
|
3428
|
+
"border-primary/50",
|
|
3429
|
+
"[&>svg]:fill-primary",
|
|
3430
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-primary/15",
|
|
3431
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-primary/20",
|
|
3432
|
+
"outline-primary/50"
|
|
3433
|
+
],
|
|
3434
|
+
positive: [
|
|
3435
|
+
"bg-positive/10",
|
|
3436
|
+
"border-positive/50",
|
|
3437
|
+
"[&>svg]:fill-positive",
|
|
3438
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-positive/15",
|
|
3439
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-positive/20",
|
|
3440
|
+
"outline-positive/50"
|
|
3441
|
+
],
|
|
3442
|
+
negative: [
|
|
3443
|
+
"bg-negative/10",
|
|
3444
|
+
"border-negative/50",
|
|
3445
|
+
"[&>svg]:fill-negative",
|
|
3446
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-negative/15",
|
|
3447
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-negative/20",
|
|
3448
|
+
"outline-negative/50"
|
|
3449
|
+
],
|
|
3450
|
+
warning: [
|
|
3451
|
+
"bg-warning/10",
|
|
3452
|
+
"border-warning/50",
|
|
3453
|
+
"[&>svg]:fill-warning",
|
|
3454
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-warning/15",
|
|
3455
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-warning/20",
|
|
3456
|
+
"outline-warning/50"
|
|
3457
|
+
],
|
|
3458
|
+
information: [
|
|
3459
|
+
"bg-information/10",
|
|
3460
|
+
"border-information/50",
|
|
3461
|
+
"[&>svg]:fill-information",
|
|
3462
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-information/15",
|
|
3463
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-information/20",
|
|
3464
|
+
"outline-information/50"
|
|
3465
|
+
],
|
|
3466
|
+
outline: [
|
|
3467
|
+
"bg-background",
|
|
3468
|
+
"[&>svg]:fill-secondary-foreground",
|
|
3469
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-secondary-hover",
|
|
3470
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-secondary-active",
|
|
3471
|
+
"outline-ring/50"
|
|
3472
|
+
]
|
|
3473
|
+
};
|
|
3474
|
+
function setVariant(variant) {
|
|
3475
|
+
el._h_chip.variant = variant;
|
|
3476
|
+
for (const [_, value] of Object.entries(variants)) {
|
|
3477
|
+
el.classList.remove(...value);
|
|
3478
|
+
}
|
|
3479
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
3480
|
+
}
|
|
3481
|
+
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
3482
|
+
const observer = new MutationObserver(() => {
|
|
3483
|
+
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
3484
|
+
});
|
|
3485
|
+
observer.observe(el, { attributes: true, attributeFilter: ["data-variant"] });
|
|
3486
|
+
cleanup(() => {
|
|
3487
|
+
observer.disconnect();
|
|
3488
|
+
});
|
|
3489
|
+
});
|
|
3490
|
+
Alpine.directive("h-chip-close", (el, { original }, { effect, cleanup }) => {
|
|
3491
|
+
if (el.tagName === "BUTTON") {
|
|
3492
|
+
throw new Error(`${original} must NOT be a button element`);
|
|
3493
|
+
}
|
|
3494
|
+
const chip = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_chip"));
|
|
3495
|
+
el.classList.add(
|
|
3496
|
+
"cursor-pointer",
|
|
3497
|
+
"inline-flex",
|
|
3498
|
+
"items-center",
|
|
3499
|
+
"justify-center",
|
|
3500
|
+
"pl-1",
|
|
3501
|
+
"pr-1.5",
|
|
3502
|
+
"h-full",
|
|
3503
|
+
"text-sm",
|
|
3504
|
+
"transition-all",
|
|
3505
|
+
"duration-100",
|
|
3506
|
+
"motion-reduce:transition-none",
|
|
3507
|
+
"disabled:pointer-events-none",
|
|
3508
|
+
"disabled:opacity-50",
|
|
3509
|
+
"bg-transparent",
|
|
3510
|
+
"text-secondary-foreground",
|
|
3511
|
+
"fill-secondary-foreground",
|
|
3512
|
+
"rounded-r-full",
|
|
3513
|
+
"border-l",
|
|
3514
|
+
"border-transparent",
|
|
3515
|
+
"outline-none",
|
|
3516
|
+
"focus-visible:inset-ring-[calc(var(--spacing)*0.75)]",
|
|
3517
|
+
"focus-visible:inset-ring",
|
|
3518
|
+
"hover:[[data-variant]>&]:border-inherit",
|
|
3519
|
+
"active:border-inherit",
|
|
3520
|
+
"aria-pressed:border-inherit"
|
|
3521
|
+
);
|
|
3522
|
+
el.setAttribute("data-slot", "chip-close");
|
|
3523
|
+
el.setAttribute("tabindex", "0");
|
|
3524
|
+
el.setAttribute("role", "button");
|
|
3525
|
+
el.appendChild(
|
|
3526
|
+
createSvg({
|
|
3527
|
+
icon: Close,
|
|
3528
|
+
classes: "size-3.5 shrink-0 pointer-events-none",
|
|
3529
|
+
attrs: {
|
|
3530
|
+
"aria-hidden": true,
|
|
3531
|
+
role: "presentation"
|
|
3532
|
+
}
|
|
3533
|
+
})
|
|
3534
|
+
);
|
|
3535
|
+
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
3536
|
+
console.error(`${original}: Must have an "aria-label" or "aria-labelledby" attribute`, el);
|
|
3537
|
+
}
|
|
3538
|
+
const variants = {
|
|
3539
|
+
default: ["hover:border-foreground/20", "hover:bg-secondary-hover", "active:bg-secondary-active", "focus-visible:inset-ring-ring/50"],
|
|
3540
|
+
primary: ["hover:bg-primary/10", "active:bg-primary/15", "aria-pressed:bg-primary/15", "focus-visible:inset-ring-primary/50"],
|
|
3541
|
+
positive: ["hover:bg-positive/10", "active:bg-positive/15", "aria-pressed:bg-positive/15", "focus-visible:inset-ring-positive/50"],
|
|
3542
|
+
negative: ["hover:bg-negative/10", "active:bg-negative/15", "aria-pressed:bg-negative/15", "focus-visible:inset-ring-negative/50"],
|
|
3543
|
+
warning: ["hover:bg-warning/10", "active:bg-warning/15", "aria-pressed:bg-warning/15", "focus-visible:inset-ring-warning/50"],
|
|
3544
|
+
information: ["hover:bg-information/10", "active:bg-information/15", "aria-pressed:bg-information/15", "focus-visible:inset-ring-information/50"],
|
|
3545
|
+
outline: ["hover:bg-secondary-hover", "active:bg-secondary-active", "aria-pressed:bg-secondary-active", "focus-visible:inset-ring-ring/50"]
|
|
3546
|
+
};
|
|
3547
|
+
effect(() => {
|
|
3548
|
+
for (const [_, value] of Object.entries(variants)) {
|
|
3549
|
+
el.classList.remove(...value);
|
|
3550
|
+
}
|
|
3551
|
+
if (Object.prototype.hasOwnProperty.call(variants, chip._h_chip.variant)) {
|
|
3552
|
+
el.classList.add(...variants[chip._h_chip.variant]);
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3555
|
+
const stopPropagation = (event) => {
|
|
3556
|
+
if (chip.getAttribute("aria-expanded") !== "true") event.stopPropagation();
|
|
3557
|
+
};
|
|
3558
|
+
el.addEventListener("click", stopPropagation);
|
|
3559
|
+
cleanup(() => {
|
|
3560
|
+
el.removeEventListener("click", stopPropagation);
|
|
3561
|
+
});
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3379
3565
|
// src/common/input-size.js
|
|
3380
3566
|
function setSize(el, size3) {
|
|
3381
3567
|
if (size3 === "sm") {
|
|
@@ -3397,7 +3583,7 @@
|
|
|
3397
3583
|
|
|
3398
3584
|
// src/components/datepicker.js
|
|
3399
3585
|
function datepicker_default(Alpine) {
|
|
3400
|
-
Alpine.directive("h-date-picker", (el, { original
|
|
3586
|
+
Alpine.directive("h-date-picker", (el, { original, modifiers }, { Alpine: Alpine2, cleanup }) => {
|
|
3401
3587
|
const state = Alpine2.reactive({
|
|
3402
3588
|
expanded: false
|
|
3403
3589
|
});
|
|
@@ -3410,7 +3596,7 @@
|
|
|
3410
3596
|
};
|
|
3411
3597
|
el._h_datepicker.input = el.querySelector("input");
|
|
3412
3598
|
if (!el._h_datepicker.input || el._h_datepicker.input.tagName !== "INPUT") {
|
|
3413
|
-
throw new Error(`${
|
|
3599
|
+
throw new Error(`${original} must contain an input`);
|
|
3414
3600
|
} else if (el._h_datepicker.input.hasAttribute("id")) {
|
|
3415
3601
|
el._h_datepicker.id = el._h_datepicker.input.getAttribute("id");
|
|
3416
3602
|
} else {
|
|
@@ -3489,16 +3675,16 @@
|
|
|
3489
3675
|
observer.disconnect();
|
|
3490
3676
|
});
|
|
3491
3677
|
});
|
|
3492
|
-
Alpine.directive("h-date-picker-trigger", (el, { original
|
|
3678
|
+
Alpine.directive("h-date-picker-trigger", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
3493
3679
|
if (el.tagName !== "BUTTON") {
|
|
3494
|
-
throw new Error(`${
|
|
3680
|
+
throw new Error(`${original} must be a button`);
|
|
3495
3681
|
}
|
|
3496
3682
|
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
3497
|
-
throw new Error(`${
|
|
3683
|
+
throw new Error(`${original}: must have an "aria-label" or "aria-labelledby" attribute`);
|
|
3498
3684
|
}
|
|
3499
|
-
const datepicker = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
3685
|
+
const datepicker = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_datepicker"));
|
|
3500
3686
|
if (!datepicker) {
|
|
3501
|
-
throw new Error(`${
|
|
3687
|
+
throw new Error(`${original} must be inside an date-picker element`);
|
|
3502
3688
|
}
|
|
3503
3689
|
el.classList.add(
|
|
3504
3690
|
"cursor-pointer",
|
|
@@ -3677,7 +3863,7 @@
|
|
|
3677
3863
|
el.classList.add("order-1", "text-lg", "leading-none", "font-semibold");
|
|
3678
3864
|
el.setAttribute("data-slot", "dialog-title");
|
|
3679
3865
|
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
3680
|
-
if (dialog &&
|
|
3866
|
+
if (dialog && !dialog.hasAttribute("aria-labelledby") && !dialog.hasAttribute("aria-label")) {
|
|
3681
3867
|
if (!el.hasAttribute("id")) {
|
|
3682
3868
|
const id = `dht${uuid_default()}`;
|
|
3683
3869
|
el.setAttribute("id", id);
|
|
@@ -3710,7 +3896,7 @@
|
|
|
3710
3896
|
el.classList.add("order-3", "col-span-full", "text-muted-foreground", "text-sm");
|
|
3711
3897
|
el.setAttribute("data-slot", "dialog-description");
|
|
3712
3898
|
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
3713
|
-
if (dialog &&
|
|
3899
|
+
if (dialog && !dialog.hasAttribute("aria-describedby") && !dialog.hasAttribute("aria-description")) {
|
|
3714
3900
|
if (!el.hasAttribute("id")) {
|
|
3715
3901
|
const id = `dhd${uuid_default()}`;
|
|
3716
3902
|
el.setAttribute("id", id);
|
|
@@ -3786,13 +3972,13 @@
|
|
|
3786
3972
|
});
|
|
3787
3973
|
}
|
|
3788
3974
|
});
|
|
3789
|
-
Alpine.directive("h-exp-panel-trigger", (el, { original
|
|
3975
|
+
Alpine.directive("h-exp-panel-trigger", (el, { original, expression }, { effect, evaluateLater, Alpine: Alpine2, cleanup }) => {
|
|
3790
3976
|
if (el.tagName.length !== 2 && !el.tagName.startsWith("H")) {
|
|
3791
|
-
throw new Error(`${
|
|
3977
|
+
throw new Error(`${original} must be a header element`);
|
|
3792
3978
|
}
|
|
3793
|
-
const expPanelItem = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
3979
|
+
const expPanelItem = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_expPanelItem"));
|
|
3794
3980
|
if (!expPanelItem) {
|
|
3795
|
-
throw new Error(`${
|
|
3981
|
+
throw new Error(`${original} must have an exp-panel-item parent element`);
|
|
3796
3982
|
}
|
|
3797
3983
|
el.classList.add(
|
|
3798
3984
|
"bg-object-header",
|
|
@@ -3973,13 +4159,13 @@
|
|
|
3973
4159
|
|
|
3974
4160
|
// src/components/icon.js
|
|
3975
4161
|
function icon_default(Alpine) {
|
|
3976
|
-
Alpine.directive("h-icon", (el, { original
|
|
4162
|
+
Alpine.directive("h-icon", (el, { original, modifiers }) => {
|
|
3977
4163
|
if (el.tagName.toLowerCase() !== "svg") {
|
|
3978
|
-
throw new Error(`${
|
|
4164
|
+
throw new Error(`${original} works only on svg elements`);
|
|
3979
4165
|
} else if (!el.hasAttribute("role")) {
|
|
3980
|
-
throw new Error(`${
|
|
4166
|
+
throw new Error(`${original} must have a role`);
|
|
3981
4167
|
} else if (el.getAttribute("role") === "img" && !el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
3982
|
-
throw new Error(`${
|
|
4168
|
+
throw new Error(`${original}: svg images with the role of img must have an "aria-label" or "aria-labelledby" attribute`);
|
|
3983
4169
|
}
|
|
3984
4170
|
el.classList.add("fill-current");
|
|
3985
4171
|
el.setAttribute("data-slot", "icon");
|
|
@@ -4029,7 +4215,7 @@
|
|
|
4029
4215
|
});
|
|
4030
4216
|
Alpine.directive("h-info-page-content", (el) => {
|
|
4031
4217
|
el.classList.add("vbox", "w-full", "max-w-sm", "min-w-0", "items-center", "gap-4", "text-sm", "text-balance");
|
|
4032
|
-
el.setAttribute("data-slot", "info-page-
|
|
4218
|
+
el.setAttribute("data-slot", "info-page-content");
|
|
4033
4219
|
});
|
|
4034
4220
|
}
|
|
4035
4221
|
|
|
@@ -4180,7 +4366,7 @@
|
|
|
4180
4366
|
"block-end": ["order-last", "w-full", "justify-start", "px-3", "pb-3", "[.border-t]:pt-3", "group-has-[>input]/input-group:pb-2.5"]
|
|
4181
4367
|
};
|
|
4182
4368
|
function setVariant(variant) {
|
|
4183
|
-
if (
|
|
4369
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
4184
4370
|
}
|
|
4185
4371
|
setVariant(el.getAttribute("data-align") ?? "inline-start");
|
|
4186
4372
|
const handler = (event) => {
|
|
@@ -4200,7 +4386,7 @@
|
|
|
4200
4386
|
el.classList.add("text-muted-foreground", "flex", "items-center", "gap-2", "text-sm", "[&_svg]:pointer-events-none", "[&_svg:not([class*='size-'])]:size-4");
|
|
4201
4387
|
el.setAttribute("data-slot", "label");
|
|
4202
4388
|
});
|
|
4203
|
-
Alpine.directive("h-input-number", (el, { original
|
|
4389
|
+
Alpine.directive("h-input-number", (el, { original }, { cleanup }) => {
|
|
4204
4390
|
el.classList.add(
|
|
4205
4391
|
"overflow-hidden",
|
|
4206
4392
|
"group/input-number",
|
|
@@ -4236,7 +4422,7 @@
|
|
|
4236
4422
|
el.setAttribute("data-slot", "input-number");
|
|
4237
4423
|
const input = el.querySelector("input");
|
|
4238
4424
|
if (!input || input.getAttribute("type") !== "number") {
|
|
4239
|
-
throw new Error(`${
|
|
4425
|
+
throw new Error(`${original} must contain an input of type 'number'`);
|
|
4240
4426
|
}
|
|
4241
4427
|
if (!input.hasAttribute("type")) input.setAttribute("type", "number");
|
|
4242
4428
|
if (!input.hasAttribute("inputmode")) input.setAttribute("inputmode", "numeric");
|
|
@@ -4450,7 +4636,8 @@
|
|
|
4450
4636
|
focusLastOption(el);
|
|
4451
4637
|
break;
|
|
4452
4638
|
case "Up":
|
|
4453
|
-
case "ArrowUp":
|
|
4639
|
+
case "ArrowUp": {
|
|
4640
|
+
event.preventDefault();
|
|
4454
4641
|
let prevElem = event.target.previousElementSibling;
|
|
4455
4642
|
if (prevElem && prevElem.getAttribute("data-slot") !== "list-header") {
|
|
4456
4643
|
prevElem.focus();
|
|
@@ -4461,8 +4648,10 @@
|
|
|
4461
4648
|
}
|
|
4462
4649
|
}
|
|
4463
4650
|
break;
|
|
4651
|
+
}
|
|
4464
4652
|
case "Down":
|
|
4465
|
-
case "ArrowDown":
|
|
4653
|
+
case "ArrowDown": {
|
|
4654
|
+
event.preventDefault();
|
|
4466
4655
|
let nextElem = event.target.nextElementSibling;
|
|
4467
4656
|
if (nextElem) {
|
|
4468
4657
|
nextElem.focus();
|
|
@@ -4473,6 +4662,7 @@
|
|
|
4473
4662
|
}
|
|
4474
4663
|
}
|
|
4475
4664
|
break;
|
|
4665
|
+
}
|
|
4476
4666
|
case " ":
|
|
4477
4667
|
case "Enter":
|
|
4478
4668
|
selectOption(event.target);
|
|
@@ -4496,13 +4686,13 @@
|
|
|
4496
4686
|
el.setAttribute("data-slot", "list");
|
|
4497
4687
|
el.setAttribute("role", "group");
|
|
4498
4688
|
});
|
|
4499
|
-
Alpine.directive("h-list-header", (el, { original
|
|
4689
|
+
Alpine.directive("h-list-header", (el, { original }, { Alpine: Alpine2 }) => {
|
|
4500
4690
|
el.classList.add("font-medium", "flex", "items-center", "p-2", "gap-2", "align-middle", "bg-table-header", "text-table-header-foreground");
|
|
4501
4691
|
el.setAttribute("role", "presentation");
|
|
4502
4692
|
el.setAttribute("data-slot", "list-header");
|
|
4503
4693
|
const list = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "list");
|
|
4504
4694
|
if (!list) {
|
|
4505
|
-
throw new Error(`${
|
|
4695
|
+
throw new Error(`${original} must be placed inside a list element`);
|
|
4506
4696
|
}
|
|
4507
4697
|
if (!el.hasAttribute("id")) {
|
|
4508
4698
|
const id = `lbh${uuid_default()}`;
|
|
@@ -4560,9 +4750,9 @@
|
|
|
4560
4750
|
}
|
|
4561
4751
|
}
|
|
4562
4752
|
});
|
|
4563
|
-
Alpine.directive("h-menu", (el, { original
|
|
4753
|
+
Alpine.directive("h-menu", (el, { original, modifiers }, { cleanup, Alpine: Alpine2 }) => {
|
|
4564
4754
|
if (el.tagName !== "UL") {
|
|
4565
|
-
throw new Error(`${
|
|
4755
|
+
throw new Error(`${original} must be an ul element`);
|
|
4566
4756
|
}
|
|
4567
4757
|
el.classList.add(
|
|
4568
4758
|
"hidden",
|
|
@@ -4594,11 +4784,11 @@
|
|
|
4594
4784
|
const menuTrigger = (() => {
|
|
4595
4785
|
if (isSubmenu) return;
|
|
4596
4786
|
let sibling = el.previousElementSibling;
|
|
4597
|
-
while (sibling && !
|
|
4787
|
+
while (sibling && !Object.prototype.hasOwnProperty.call(sibling, "_menu_trigger")) {
|
|
4598
4788
|
sibling = sibling.previousElementSibling;
|
|
4599
4789
|
}
|
|
4600
|
-
if (!
|
|
4601
|
-
throw new Error(`${
|
|
4790
|
+
if (!Object.prototype.hasOwnProperty.call(sibling, "_menu_trigger")) {
|
|
4791
|
+
throw new Error(`${original} menu must be placed after a menu trigger element`);
|
|
4602
4792
|
}
|
|
4603
4793
|
return sibling;
|
|
4604
4794
|
})();
|
|
@@ -4607,7 +4797,7 @@
|
|
|
4607
4797
|
if (parent && parent.hasAttribute("id")) {
|
|
4608
4798
|
el.setAttribute("aria-labelledby", parent.id);
|
|
4609
4799
|
} else {
|
|
4610
|
-
throw new Error(`${
|
|
4800
|
+
throw new Error(`${original} must have an "aria-label" or "aria-labelledby" attribute`);
|
|
4611
4801
|
}
|
|
4612
4802
|
}
|
|
4613
4803
|
}
|
|
@@ -4615,7 +4805,7 @@
|
|
|
4615
4805
|
if (isSubmenu) {
|
|
4616
4806
|
menuSubItem = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "menu-sub");
|
|
4617
4807
|
if (!menuSubItem) {
|
|
4618
|
-
throw new Error(`${
|
|
4808
|
+
throw new Error(`${original} must be placed inside a ${Alpine2.prefixed("h-menu-sub")} element`);
|
|
4619
4809
|
}
|
|
4620
4810
|
setAriaAttrubutes(menuSubItem);
|
|
4621
4811
|
} else if (menuTrigger) {
|
|
@@ -4723,7 +4913,7 @@
|
|
|
4723
4913
|
}
|
|
4724
4914
|
break;
|
|
4725
4915
|
case "Up":
|
|
4726
|
-
case "ArrowUp":
|
|
4916
|
+
case "ArrowUp": {
|
|
4727
4917
|
event.preventDefault();
|
|
4728
4918
|
let menuitems = el.querySelectorAll(':scope > [role^=menuitem][tabIndex="-1"]:has(~ [role^=menuitem][tabIndex="0"])');
|
|
4729
4919
|
if (menuitems.length) {
|
|
@@ -4735,6 +4925,7 @@
|
|
|
4735
4925
|
menuitem.focus();
|
|
4736
4926
|
}
|
|
4737
4927
|
break;
|
|
4928
|
+
}
|
|
4738
4929
|
case "Home":
|
|
4739
4930
|
case "PageUp":
|
|
4740
4931
|
event.preventDefault();
|
|
@@ -4856,9 +5047,9 @@
|
|
|
4856
5047
|
el.removeEventListener("transitionend", onTransitionEnd);
|
|
4857
5048
|
});
|
|
4858
5049
|
});
|
|
4859
|
-
Alpine.directive("h-menu-item", (el, { original
|
|
5050
|
+
Alpine.directive("h-menu-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
4860
5051
|
if (el.tagName !== "LI") {
|
|
4861
|
-
throw new Error(`${
|
|
5052
|
+
throw new Error(`${original} must be a li element`);
|
|
4862
5053
|
}
|
|
4863
5054
|
el.classList.add(
|
|
4864
5055
|
"focus:bg-secondary-hover",
|
|
@@ -4912,7 +5103,7 @@
|
|
|
4912
5103
|
el.removeEventListener("mouseleave", focusOut);
|
|
4913
5104
|
});
|
|
4914
5105
|
});
|
|
4915
|
-
Alpine.directive("h-menu-sub", (el, { original
|
|
5106
|
+
Alpine.directive("h-menu-sub", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
4916
5107
|
el.classList.add(
|
|
4917
5108
|
"focus:bg-secondary-hover",
|
|
4918
5109
|
"hover:bg-secondary-hover",
|
|
@@ -4944,7 +5135,7 @@
|
|
|
4944
5135
|
const chevronRight = createSvg({ icon: ChevronRight, classes: "size-4 ml-auto", attrs: { "aria-hidden": true, role: "presentation" } });
|
|
4945
5136
|
el.appendChild(chevronRight);
|
|
4946
5137
|
const parentMenu = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "menu");
|
|
4947
|
-
if (!parentMenu) throw new Error(`${
|
|
5138
|
+
if (!parentMenu) throw new Error(`${original} must have a parent`);
|
|
4948
5139
|
if (!el.hasAttribute("id")) {
|
|
4949
5140
|
el.setAttribute("id", `ms${uuid_default()}`);
|
|
4950
5141
|
}
|
|
@@ -5041,9 +5232,9 @@
|
|
|
5041
5232
|
el.classList.add("text-foreground", "px-2", "py-1.5", "text-sm", "font-semibold", "text-left", "data-[inset=true]:pl-8");
|
|
5042
5233
|
el.setAttribute("data-slot", "menu-label");
|
|
5043
5234
|
});
|
|
5044
|
-
Alpine.directive("h-menu-checkbox-item", (el, { original
|
|
5235
|
+
Alpine.directive("h-menu-checkbox-item", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
5045
5236
|
if (el.tagName !== "LI" && el.tagName !== "DIV") {
|
|
5046
|
-
throw new Error(`${
|
|
5237
|
+
throw new Error(`${original} must be a li or div element`);
|
|
5047
5238
|
}
|
|
5048
5239
|
el.classList.add(
|
|
5049
5240
|
"focus:bg-secondary-hover",
|
|
@@ -5083,7 +5274,7 @@
|
|
|
5083
5274
|
el._x_model.set(!el._x_model.get());
|
|
5084
5275
|
setState(el._x_model.get());
|
|
5085
5276
|
}
|
|
5086
|
-
if (
|
|
5277
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
5087
5278
|
setState(el._x_model.get(), false);
|
|
5088
5279
|
el.addEventListener("click", onActivate);
|
|
5089
5280
|
}
|
|
@@ -5100,7 +5291,7 @@
|
|
|
5100
5291
|
el.addEventListener("mouseenter", focusIn);
|
|
5101
5292
|
el.addEventListener("focus", focusIn);
|
|
5102
5293
|
cleanup(() => {
|
|
5103
|
-
if (
|
|
5294
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
5104
5295
|
el.removeEventListener("click", onActivate);
|
|
5105
5296
|
el.removeEventListener("keydown", onActivate);
|
|
5106
5297
|
}
|
|
@@ -5110,9 +5301,9 @@
|
|
|
5110
5301
|
el.removeEventListener("mouseleave", focusOut);
|
|
5111
5302
|
});
|
|
5112
5303
|
});
|
|
5113
|
-
Alpine.directive("h-menu-radio-item", (el, { original
|
|
5304
|
+
Alpine.directive("h-menu-radio-item", (el, { original, expression }, { effect, evaluateLater, cleanup, Alpine: Alpine2 }) => {
|
|
5114
5305
|
if (el.tagName !== "LI" && el.tagName !== "DIV") {
|
|
5115
|
-
throw new Error(`${
|
|
5306
|
+
throw new Error(`${original} must be a li or div element`);
|
|
5116
5307
|
}
|
|
5117
5308
|
el.classList.add(
|
|
5118
5309
|
"focus:bg-secondary-hover",
|
|
@@ -5168,7 +5359,7 @@
|
|
|
5168
5359
|
el._x_model.set(value);
|
|
5169
5360
|
}
|
|
5170
5361
|
}
|
|
5171
|
-
if (
|
|
5362
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
5172
5363
|
effect(() => {
|
|
5173
5364
|
setState(el._x_model.get() === value);
|
|
5174
5365
|
});
|
|
@@ -5188,7 +5379,7 @@
|
|
|
5188
5379
|
el.addEventListener("mouseenter", focusIn);
|
|
5189
5380
|
el.addEventListener("focus", focusIn);
|
|
5190
5381
|
cleanup(() => {
|
|
5191
|
-
if (
|
|
5382
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
5192
5383
|
el.removeEventListener("click", onActivate);
|
|
5193
5384
|
el.removeEventListener("keydown", onActivate);
|
|
5194
5385
|
}
|
|
@@ -5236,7 +5427,7 @@
|
|
|
5236
5427
|
};
|
|
5237
5428
|
this.items.push(item);
|
|
5238
5429
|
this.listeners.forEach((listener) => {
|
|
5239
|
-
if (
|
|
5430
|
+
if (Object.prototype.hasOwnProperty.call(listener, "added")) listener.added(item);
|
|
5240
5431
|
});
|
|
5241
5432
|
},
|
|
5242
5433
|
update(id, data) {
|
|
@@ -5249,7 +5440,7 @@
|
|
|
5249
5440
|
this.items[index].data[key] = value;
|
|
5250
5441
|
}
|
|
5251
5442
|
this.listeners.forEach((listener) => {
|
|
5252
|
-
if (
|
|
5443
|
+
if (Object.prototype.hasOwnProperty.call(listener, "updated")) listener.updated(id, data);
|
|
5253
5444
|
});
|
|
5254
5445
|
} else {
|
|
5255
5446
|
console.error(`Notification with id "${id}" does not exist`);
|
|
@@ -5260,7 +5451,7 @@
|
|
|
5260
5451
|
throw new Error("Cannot remove a notification if an ID is not provided");
|
|
5261
5452
|
}
|
|
5262
5453
|
this.listeners.forEach((listener) => {
|
|
5263
|
-
if (
|
|
5454
|
+
if (Object.prototype.hasOwnProperty.call(listener, "removed")) listener.removed(id);
|
|
5264
5455
|
});
|
|
5265
5456
|
this.items = this.items.filter((n) => n.id !== id);
|
|
5266
5457
|
}
|
|
@@ -5285,9 +5476,9 @@
|
|
|
5285
5476
|
}
|
|
5286
5477
|
};
|
|
5287
5478
|
});
|
|
5288
|
-
Alpine.directive("h-notification-overlay", (el, { original
|
|
5479
|
+
Alpine.directive("h-notification-overlay", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
5289
5480
|
if (el.tagName !== "SECTION") {
|
|
5290
|
-
throw new Error(`${
|
|
5481
|
+
throw new Error(`${original} must be a button`);
|
|
5291
5482
|
}
|
|
5292
5483
|
const notificationTemplates = {};
|
|
5293
5484
|
el.querySelectorAll("template").forEach((template) => {
|
|
@@ -5422,17 +5613,17 @@
|
|
|
5422
5613
|
xlBreakpointListener.remove();
|
|
5423
5614
|
});
|
|
5424
5615
|
});
|
|
5425
|
-
Alpine.directive("h-notification-list", (el, { original
|
|
5616
|
+
Alpine.directive("h-notification-list", (el, { original }) => {
|
|
5426
5617
|
if (el.tagName !== "OL" && el.tagName !== "UL") {
|
|
5427
|
-
throw new Error(`${
|
|
5618
|
+
throw new Error(`${original} must be a list element`);
|
|
5428
5619
|
}
|
|
5429
5620
|
el.classList.add("flex", "flex-col", "divide-solid", "divide-y");
|
|
5430
5621
|
el.setAttribute("data-slot", "notification-list");
|
|
5431
5622
|
el.setAttribute("role", "group");
|
|
5432
5623
|
});
|
|
5433
|
-
Alpine.directive("h-notification", (el, { original
|
|
5624
|
+
Alpine.directive("h-notification", (el, { original, modifiers }) => {
|
|
5434
5625
|
if (el.tagName !== "LI") {
|
|
5435
|
-
throw new Error(`${
|
|
5626
|
+
throw new Error(`${original} must be a list item element`);
|
|
5436
5627
|
}
|
|
5437
5628
|
el.classList.add("pointer-events-auto", "p-3", "flex", "gap-2");
|
|
5438
5629
|
if (modifiers.includes("floating")) {
|
|
@@ -5468,7 +5659,7 @@
|
|
|
5468
5659
|
el.classList.add("flex", "gap-2", "data-[orientation=vertical]:flex-col");
|
|
5469
5660
|
el.setAttribute("data-slot", "notification-actions");
|
|
5470
5661
|
});
|
|
5471
|
-
Alpine.directive("h-notification-close", (el, { original
|
|
5662
|
+
Alpine.directive("h-notification-close", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
5472
5663
|
if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "notification-close");
|
|
5473
5664
|
let nId;
|
|
5474
5665
|
function close() {
|
|
@@ -5487,7 +5678,7 @@
|
|
|
5487
5678
|
el.removeEventListener("click", close);
|
|
5488
5679
|
});
|
|
5489
5680
|
} else {
|
|
5490
|
-
console.error(`${
|
|
5681
|
+
console.error(`${original} must be inside a notification with an id`);
|
|
5491
5682
|
}
|
|
5492
5683
|
});
|
|
5493
5684
|
}
|
|
@@ -5576,7 +5767,7 @@
|
|
|
5576
5767
|
// src/components/popover.js
|
|
5577
5768
|
function popover_default(Alpine) {
|
|
5578
5769
|
Alpine.directive("h-popover-trigger", (el, { expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2, cleanup }) => {
|
|
5579
|
-
el.
|
|
5770
|
+
el._h_popover = Alpine2.reactive({
|
|
5580
5771
|
id: void 0,
|
|
5581
5772
|
controls: `hpc${uuid_default()}`,
|
|
5582
5773
|
auto: expression ? false : true,
|
|
@@ -5586,7 +5777,7 @@
|
|
|
5586
5777
|
const getExpanded = evaluateLater(expression);
|
|
5587
5778
|
effect(() => {
|
|
5588
5779
|
getExpanded((expanded) => {
|
|
5589
|
-
el.
|
|
5780
|
+
el._h_popover.expanded = expanded;
|
|
5590
5781
|
});
|
|
5591
5782
|
});
|
|
5592
5783
|
}
|
|
@@ -5596,33 +5787,33 @@
|
|
|
5596
5787
|
}
|
|
5597
5788
|
if (!el.hasAttribute("data-slot")) el.setAttribute("data-slot", "popover-trigger");
|
|
5598
5789
|
if (el.hasAttribute("id")) {
|
|
5599
|
-
el.
|
|
5790
|
+
el._h_popover.id = el.getAttribute("id");
|
|
5600
5791
|
} else {
|
|
5601
|
-
el.
|
|
5602
|
-
el.setAttribute("id", el.
|
|
5792
|
+
el._h_popover.id = `hp${uuid_default()}`;
|
|
5793
|
+
el.setAttribute("id", el._h_popover.id);
|
|
5603
5794
|
}
|
|
5604
|
-
el.setAttribute("aria-controls", el.
|
|
5795
|
+
el.setAttribute("aria-controls", el._h_popover.controls);
|
|
5605
5796
|
el.setAttribute("aria-haspopup", "dialog");
|
|
5606
5797
|
const setAttributes = () => {
|
|
5607
|
-
el.setAttribute("aria-expanded", el.
|
|
5798
|
+
el.setAttribute("aria-expanded", el._h_popover.expanded);
|
|
5608
5799
|
};
|
|
5609
5800
|
const close = () => {
|
|
5610
|
-
el.
|
|
5801
|
+
el._h_popover.expanded = false;
|
|
5611
5802
|
el.addEventListener("click", handler);
|
|
5612
5803
|
setAttributes();
|
|
5613
5804
|
};
|
|
5614
5805
|
const handler = () => {
|
|
5615
|
-
el.
|
|
5806
|
+
el._h_popover.expanded = !el._h_popover.expanded;
|
|
5616
5807
|
setAttributes();
|
|
5617
5808
|
Alpine2.nextTick(() => {
|
|
5618
|
-
if (el.
|
|
5809
|
+
if (el._h_popover.auto && el._h_popover.expanded) {
|
|
5619
5810
|
top.addEventListener("click", close, { once: true });
|
|
5620
5811
|
el.removeEventListener("click", handler);
|
|
5621
5812
|
}
|
|
5622
5813
|
});
|
|
5623
5814
|
};
|
|
5624
5815
|
setAttributes();
|
|
5625
|
-
if (el.
|
|
5816
|
+
if (el._h_popover.auto) {
|
|
5626
5817
|
el.addEventListener("click", handler);
|
|
5627
5818
|
cleanup(() => {
|
|
5628
5819
|
el.removeEventListener("click", handler);
|
|
@@ -5634,16 +5825,16 @@
|
|
|
5634
5825
|
});
|
|
5635
5826
|
}
|
|
5636
5827
|
});
|
|
5637
|
-
Alpine.directive("h-popover", (el, { original
|
|
5828
|
+
Alpine.directive("h-popover", (el, { original, modifiers }, { effect, cleanup }) => {
|
|
5638
5829
|
const popover = (() => {
|
|
5639
5830
|
let sibling = el.previousElementSibling;
|
|
5640
|
-
while (sibling && !
|
|
5831
|
+
while (sibling && !Object.prototype.hasOwnProperty.call(sibling, "_h_popover")) {
|
|
5641
5832
|
sibling = sibling.previousElementSibling;
|
|
5642
5833
|
}
|
|
5643
5834
|
return sibling;
|
|
5644
5835
|
})();
|
|
5645
5836
|
if (!popover) {
|
|
5646
|
-
throw new Error(`${
|
|
5837
|
+
throw new Error(`${original} must be placed after a popover element`);
|
|
5647
5838
|
}
|
|
5648
5839
|
el.classList.add(
|
|
5649
5840
|
"absolute",
|
|
@@ -5669,8 +5860,8 @@
|
|
|
5669
5860
|
el.setAttribute("data-slot", "popover");
|
|
5670
5861
|
el.setAttribute("role", "dialog");
|
|
5671
5862
|
el.setAttribute("tabindex", "-1");
|
|
5672
|
-
el.setAttribute("id", popover.
|
|
5673
|
-
el.setAttribute("aria-labelledby", popover.
|
|
5863
|
+
el.setAttribute("id", popover._h_popover.controls);
|
|
5864
|
+
el.setAttribute("aria-labelledby", popover._h_popover.id);
|
|
5674
5865
|
let noScroll = modifiers.includes("no-scroll");
|
|
5675
5866
|
if (noScroll) {
|
|
5676
5867
|
el.classList.remove("overflow-auto");
|
|
@@ -5708,7 +5899,7 @@
|
|
|
5708
5899
|
});
|
|
5709
5900
|
}
|
|
5710
5901
|
effect(() => {
|
|
5711
|
-
if (popover.
|
|
5902
|
+
if (popover._h_popover.expanded) {
|
|
5712
5903
|
el.classList.remove("hidden");
|
|
5713
5904
|
autoUpdateCleanup = autoUpdate(popover, el, updatePosition);
|
|
5714
5905
|
} else {
|
|
@@ -7680,7 +7871,7 @@
|
|
|
7680
7871
|
el.classList.add("harmonia-slider");
|
|
7681
7872
|
el.setAttribute("data-slot", "range");
|
|
7682
7873
|
initialize(el, evaluate2(expression));
|
|
7683
|
-
if (
|
|
7874
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
7684
7875
|
el.noUiSlider.on("change", (values) => {
|
|
7685
7876
|
el._x_model.set(values);
|
|
7686
7877
|
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
@@ -7762,11 +7953,11 @@
|
|
|
7762
7953
|
});
|
|
7763
7954
|
}
|
|
7764
7955
|
});
|
|
7765
|
-
Alpine.directive("h-select-input", (el, { original
|
|
7956
|
+
Alpine.directive("h-select-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
7766
7957
|
if (el.tagName !== "INPUT") {
|
|
7767
|
-
throw new Error(`${
|
|
7958
|
+
throw new Error(`${original} must be an input of type "text"`);
|
|
7768
7959
|
}
|
|
7769
|
-
const select = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
7960
|
+
const select = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_select"));
|
|
7770
7961
|
const label = (() => {
|
|
7771
7962
|
const field = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("data-slot") === "field");
|
|
7772
7963
|
if (field) {
|
|
@@ -7775,8 +7966,8 @@
|
|
|
7775
7966
|
return;
|
|
7776
7967
|
})();
|
|
7777
7968
|
if (!select) {
|
|
7778
|
-
throw new Error(`${
|
|
7779
|
-
} else if (
|
|
7969
|
+
throw new Error(`${original} must be inside a select element`);
|
|
7970
|
+
} else if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
7780
7971
|
select._h_select.multiple = Array.isArray(el._x_model.get());
|
|
7781
7972
|
select._h_model.set = (value) => {
|
|
7782
7973
|
if (select._h_select.multiple) {
|
|
@@ -7834,6 +8025,7 @@
|
|
|
7834
8025
|
displayValue.innerText = value;
|
|
7835
8026
|
displayValue.classList.add("text-muted-foreground");
|
|
7836
8027
|
} else {
|
|
8028
|
+
displayValue.innerText = "";
|
|
7837
8029
|
displayValue.classList.remove("text-muted-foreground");
|
|
7838
8030
|
}
|
|
7839
8031
|
}
|
|
@@ -7874,7 +8066,7 @@
|
|
|
7874
8066
|
const onKeyDown = (event) => {
|
|
7875
8067
|
switch (event.key) {
|
|
7876
8068
|
case "Down":
|
|
7877
|
-
case "ArrowDown":
|
|
8069
|
+
case "ArrowDown": {
|
|
7878
8070
|
event.preventDefault();
|
|
7879
8071
|
let nextIndex = 0;
|
|
7880
8072
|
for (let o = 0; o < options.length; o++) {
|
|
@@ -7896,8 +8088,9 @@
|
|
|
7896
8088
|
options[nextIndex].setAttribute("tabindex", "0");
|
|
7897
8089
|
options[nextIndex].focus();
|
|
7898
8090
|
break;
|
|
8091
|
+
}
|
|
7899
8092
|
case "Up":
|
|
7900
|
-
case "ArrowUp":
|
|
8093
|
+
case "ArrowUp": {
|
|
7901
8094
|
event.preventDefault();
|
|
7902
8095
|
let prevIndex = options.length - 1;
|
|
7903
8096
|
for (let o = options.length - 1; o >= 0; o--) {
|
|
@@ -7919,6 +8112,7 @@
|
|
|
7919
8112
|
options[prevIndex].setAttribute("tabindex", "0");
|
|
7920
8113
|
options[prevIndex].focus();
|
|
7921
8114
|
break;
|
|
8115
|
+
}
|
|
7922
8116
|
case "Home":
|
|
7923
8117
|
case "PageUp":
|
|
7924
8118
|
event.preventDefault();
|
|
@@ -8035,10 +8229,10 @@
|
|
|
8035
8229
|
}
|
|
8036
8230
|
});
|
|
8037
8231
|
});
|
|
8038
|
-
Alpine.directive("h-select-content", (el, { original
|
|
8039
|
-
const select = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
8232
|
+
Alpine.directive("h-select-content", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
8233
|
+
const select = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_select"));
|
|
8040
8234
|
if (!select) {
|
|
8041
|
-
throw new Error(`${
|
|
8235
|
+
throw new Error(`${original} must be inside a select element`);
|
|
8042
8236
|
}
|
|
8043
8237
|
el.classList.add(
|
|
8044
8238
|
"absolute",
|
|
@@ -8067,7 +8261,7 @@
|
|
|
8067
8261
|
el.setAttribute("id", select._h_select.controls);
|
|
8068
8262
|
el.setAttribute("tabindex", "-1");
|
|
8069
8263
|
if (!select._h_select.trigger) {
|
|
8070
|
-
throw new Error(`${
|
|
8264
|
+
throw new Error(`${original}: trigger not found`);
|
|
8071
8265
|
}
|
|
8072
8266
|
let autoUpdateCleanup;
|
|
8073
8267
|
function updatePosition() {
|
|
@@ -8128,10 +8322,10 @@
|
|
|
8128
8322
|
el.removeEventListener("transitionend", onTransitionEnd);
|
|
8129
8323
|
});
|
|
8130
8324
|
});
|
|
8131
|
-
Alpine.directive("h-select-search", (el, { original
|
|
8132
|
-
const select = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
8325
|
+
Alpine.directive("h-select-search", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
8326
|
+
const select = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_select"));
|
|
8133
8327
|
if (!select) {
|
|
8134
|
-
throw new Error(`${
|
|
8328
|
+
throw new Error(`${original} must be inside an h-select element`);
|
|
8135
8329
|
} else {
|
|
8136
8330
|
select._h_select.filterType = FilterType[el.getAttribute("data-filter")] ?? FilterType["starts-with"];
|
|
8137
8331
|
}
|
|
@@ -8196,17 +8390,17 @@
|
|
|
8196
8390
|
Alpine.directive("h-select-label", (el) => {
|
|
8197
8391
|
el.classList.add("text-muted-foreground", "px-2", "py-1.5", "text-xs");
|
|
8198
8392
|
el.setAttribute("data-slot", "select-label");
|
|
8199
|
-
const selectGroup = Alpine.findClosest(el.parentElement, (parent) =>
|
|
8393
|
+
const selectGroup = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_selectGroup"));
|
|
8200
8394
|
if (selectGroup) {
|
|
8201
8395
|
const id = `hsl${uuid_default()}`;
|
|
8202
8396
|
el.setAttribute("id", id);
|
|
8203
8397
|
selectGroup._h_selectGroup.labelledby = id;
|
|
8204
8398
|
}
|
|
8205
8399
|
});
|
|
8206
|
-
Alpine.directive("h-select-option", (el, { original
|
|
8207
|
-
const select = Alpine.findClosest(el.parentElement, (parent) =>
|
|
8400
|
+
Alpine.directive("h-select-option", (el, { original, expression }, { effect, evaluateLater, cleanup }) => {
|
|
8401
|
+
const select = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_select"));
|
|
8208
8402
|
if (!select) {
|
|
8209
|
-
throw new Error(`${
|
|
8403
|
+
throw new Error(`${original} must be inside an h-select element`);
|
|
8210
8404
|
}
|
|
8211
8405
|
el.classList.add(
|
|
8212
8406
|
"focus:bg-primary",
|
|
@@ -8309,7 +8503,7 @@
|
|
|
8309
8503
|
}
|
|
8310
8504
|
} else if (select._h_model.get() !== getValue()) {
|
|
8311
8505
|
select._h_model.set(getValue());
|
|
8312
|
-
} else {
|
|
8506
|
+
} else if (select.getAttribute("data-clearable") === "true") {
|
|
8313
8507
|
select._h_model.set("");
|
|
8314
8508
|
}
|
|
8315
8509
|
}
|
|
@@ -8402,10 +8596,10 @@
|
|
|
8402
8596
|
el.removeEventListener("transitionend", onTransitionEnd);
|
|
8403
8597
|
});
|
|
8404
8598
|
});
|
|
8405
|
-
Alpine.directive("h-sheet", (el, { original
|
|
8406
|
-
const overlay = Alpine.findClosest(el.parentElement, (parent) =>
|
|
8599
|
+
Alpine.directive("h-sheet", (el, { original }, { effect, cleanup }) => {
|
|
8600
|
+
const overlay = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_sheet_overlay"));
|
|
8407
8601
|
if (!overlay) {
|
|
8408
|
-
throw new Error(`${
|
|
8602
|
+
throw new Error(`${original} must be placed inside a sheet overlay`);
|
|
8409
8603
|
}
|
|
8410
8604
|
el.classList.add("hidden", "bg-background", "fixed", "shadow-lg", "transform", "transition-all", "motion-reduce:transition-none", "duration-200", "ease-out");
|
|
8411
8605
|
el.setAttribute("data-slot", "sheet");
|
|
@@ -8528,10 +8722,10 @@
|
|
|
8528
8722
|
});
|
|
8529
8723
|
}
|
|
8530
8724
|
});
|
|
8531
|
-
Alpine.directive("h-sidebar-group-label", (el, { original
|
|
8532
|
-
const group = Alpine.findClosest(el.parentElement, (parent) =>
|
|
8725
|
+
Alpine.directive("h-sidebar-group-label", (el, { original }, { cleanup }) => {
|
|
8726
|
+
const group = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_sidebar_group"));
|
|
8533
8727
|
if (!group) {
|
|
8534
|
-
throw new Error(`${
|
|
8728
|
+
throw new Error(`${original} must be placed inside a sidebar group`);
|
|
8535
8729
|
}
|
|
8536
8730
|
el.classList.add(
|
|
8537
8731
|
"ring-sidebar-ring",
|
|
@@ -8620,10 +8814,10 @@
|
|
|
8620
8814
|
}
|
|
8621
8815
|
el.setAttribute("data-slot", "sidebar-group-action");
|
|
8622
8816
|
});
|
|
8623
|
-
Alpine.directive("h-sidebar-group-content", (el, { original
|
|
8624
|
-
const group = Alpine.findClosest(el.parentElement, (parent) =>
|
|
8817
|
+
Alpine.directive("h-sidebar-group-content", (el, { original }, { effect }) => {
|
|
8818
|
+
const group = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_sidebar_group"));
|
|
8625
8819
|
if (!group) {
|
|
8626
|
-
throw new Error(`${
|
|
8820
|
+
throw new Error(`${original} must be placed inside a sidebar group`);
|
|
8627
8821
|
}
|
|
8628
8822
|
el.classList.add("w-full", "text-sm", "data-[collapsed=true]:hidden", "group-data-[collapsed=true]/sidebar:!block");
|
|
8629
8823
|
el.setAttribute("data-slot", "sidebar-group-content");
|
|
@@ -8636,16 +8830,16 @@
|
|
|
8636
8830
|
});
|
|
8637
8831
|
}
|
|
8638
8832
|
});
|
|
8639
|
-
Alpine.directive("h-sidebar-menu", (el, { original
|
|
8833
|
+
Alpine.directive("h-sidebar-menu", (el, { original }) => {
|
|
8640
8834
|
if (el.tagName !== "UL") {
|
|
8641
|
-
throw new Error(`${
|
|
8835
|
+
throw new Error(`${original} must be an ul element`);
|
|
8642
8836
|
}
|
|
8643
8837
|
el.classList.add("vbox", "w-full", "min-w-0", "gap-1");
|
|
8644
8838
|
el.setAttribute("data-slot", "sidebar-menu");
|
|
8645
8839
|
});
|
|
8646
|
-
Alpine.directive("h-sidebar-menu-item", (el, { original
|
|
8840
|
+
Alpine.directive("h-sidebar-menu-item", (el, { original, expression, modifiers }, { effect, evaluate: evaluate2, evaluateLater, Alpine: Alpine2 }) => {
|
|
8647
8841
|
if (el.tagName !== "LI") {
|
|
8648
|
-
throw new Error(`${
|
|
8842
|
+
throw new Error(`${original} must be a li element`);
|
|
8649
8843
|
}
|
|
8650
8844
|
el._h_sidebar_menu_item = {
|
|
8651
8845
|
isSub: false,
|
|
@@ -8681,13 +8875,13 @@
|
|
|
8681
8875
|
});
|
|
8682
8876
|
}
|
|
8683
8877
|
});
|
|
8684
|
-
Alpine.directive("h-sidebar-menu-button", (el, { original
|
|
8878
|
+
Alpine.directive("h-sidebar-menu-button", (el, { original }, { cleanup, Alpine: Alpine2 }) => {
|
|
8685
8879
|
if (el.tagName !== "BUTTON" && el.tagName !== "A") {
|
|
8686
|
-
throw new Error(`${
|
|
8880
|
+
throw new Error(`${original} must be a button or a link`);
|
|
8687
8881
|
} else if (el.tagName === "BUTTON") {
|
|
8688
8882
|
el.setAttribute("type", "button");
|
|
8689
8883
|
}
|
|
8690
|
-
const menuItem = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
8884
|
+
const menuItem = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_sidebar_menu_item"));
|
|
8691
8885
|
el.classList.add(
|
|
8692
8886
|
"flex",
|
|
8693
8887
|
"w-full",
|
|
@@ -8720,7 +8914,7 @@
|
|
|
8720
8914
|
lg: ["h-12", "text-sm", "group-data-[collapsed=true]/sidebar:p-0!"]
|
|
8721
8915
|
};
|
|
8722
8916
|
function setSize2(size3) {
|
|
8723
|
-
if (
|
|
8917
|
+
if (Object.prototype.hasOwnProperty.call(sizes, size3)) {
|
|
8724
8918
|
el.classList.add(...sizes[size3]);
|
|
8725
8919
|
}
|
|
8726
8920
|
}
|
|
@@ -8821,9 +9015,9 @@
|
|
|
8821
9015
|
}
|
|
8822
9016
|
el.setAttribute("data-slot", "sidebar-menu-action");
|
|
8823
9017
|
});
|
|
8824
|
-
Alpine.directive("h-sidebar-menu-badge", (el, { original
|
|
9018
|
+
Alpine.directive("h-sidebar-menu-badge", (el, { original }) => {
|
|
8825
9019
|
if (el.tagName !== "SPAN") {
|
|
8826
|
-
throw new Error(`${
|
|
9020
|
+
throw new Error(`${original} must be a span element`);
|
|
8827
9021
|
}
|
|
8828
9022
|
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");
|
|
8829
9023
|
el.setAttribute("data-slot", "sidebar-menu-badge");
|
|
@@ -8849,13 +9043,13 @@
|
|
|
8849
9043
|
el.setAttribute("data-slot", "sidebar-separator");
|
|
8850
9044
|
el.setAttribute("role", "none");
|
|
8851
9045
|
});
|
|
8852
|
-
Alpine.directive("h-sidebar-menu-sub", (el, { original
|
|
9046
|
+
Alpine.directive("h-sidebar-menu-sub", (el, { original }, { effect, Alpine: Alpine2 }) => {
|
|
8853
9047
|
if (el.tagName !== "UL") {
|
|
8854
|
-
throw new Error(`${
|
|
9048
|
+
throw new Error(`${original} must be an ul element`);
|
|
8855
9049
|
}
|
|
8856
|
-
const menuItem = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
9050
|
+
const menuItem = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_sidebar_menu_item"));
|
|
8857
9051
|
if (!menuItem) {
|
|
8858
|
-
throw new Error(`${
|
|
9052
|
+
throw new Error(`${original} must be placed inside a sidebar menu item`);
|
|
8859
9053
|
}
|
|
8860
9054
|
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");
|
|
8861
9055
|
if (el.getAttribute("data-line") !== "false") {
|
|
@@ -8930,7 +9124,7 @@
|
|
|
8930
9124
|
|
|
8931
9125
|
// src/components/split.js
|
|
8932
9126
|
function split_default(Alpine) {
|
|
8933
|
-
Alpine.directive("h-split", (el,
|
|
9127
|
+
Alpine.directive("h-split", (el, _, { cleanup, Alpine: Alpine2 }) => {
|
|
8934
9128
|
const panels = [];
|
|
8935
9129
|
const state = Alpine2.reactive({
|
|
8936
9130
|
isHorizontal: el.getAttribute("data-orientation") === "horizontal",
|
|
@@ -9126,10 +9320,10 @@
|
|
|
9126
9320
|
observer.disconnect();
|
|
9127
9321
|
});
|
|
9128
9322
|
});
|
|
9129
|
-
Alpine.directive("h-split-panel", (el, { original
|
|
9130
|
-
const split = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
9323
|
+
Alpine.directive("h-split-panel", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
9324
|
+
const split = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_split"));
|
|
9131
9325
|
if (!split) {
|
|
9132
|
-
throw new Error(`${
|
|
9326
|
+
throw new Error(`${original} must be inside an split element`);
|
|
9133
9327
|
}
|
|
9134
9328
|
el.classList.add(
|
|
9135
9329
|
"flex",
|
|
@@ -9680,7 +9874,7 @@
|
|
|
9680
9874
|
el.setAttribute("role", "tablist");
|
|
9681
9875
|
el.setAttribute("data-slot", "tab-list");
|
|
9682
9876
|
});
|
|
9683
|
-
Alpine.directive("h-tab", (el, { original
|
|
9877
|
+
Alpine.directive("h-tab", (el, { original }) => {
|
|
9684
9878
|
el.classList.add(
|
|
9685
9879
|
"cursor-pointer",
|
|
9686
9880
|
"focus-visible:border-ring",
|
|
@@ -9729,8 +9923,8 @@
|
|
|
9729
9923
|
);
|
|
9730
9924
|
el.setAttribute("role", "tab");
|
|
9731
9925
|
el.setAttribute("data-slot", "tab");
|
|
9732
|
-
if (!el.hasAttribute("id")) throw new Error(`${
|
|
9733
|
-
if (!el.hasAttribute("aria-controls")) throw new Error(`${
|
|
9926
|
+
if (!el.hasAttribute("id")) throw new Error(`${original}: Tabs must have an id`);
|
|
9927
|
+
if (!el.hasAttribute("aria-controls")) throw new Error(`${original}: aria-controls must be set to the tab-content id.`);
|
|
9734
9928
|
});
|
|
9735
9929
|
Alpine.directive("h-tab-action", (el) => {
|
|
9736
9930
|
el.classList.add("cursor-pointer", "ml-auto", "rounded-md", "text-foreground", "hover:bg-secondary", "hover:text-secondary-foreground", "active:bg-secondary-active");
|
|
@@ -9764,13 +9958,13 @@
|
|
|
9764
9958
|
el.setAttribute("role", "button");
|
|
9765
9959
|
el.setAttribute("data-slot", "tab-list-action");
|
|
9766
9960
|
});
|
|
9767
|
-
Alpine.directive("h-tabs-content", (el, { original
|
|
9961
|
+
Alpine.directive("h-tabs-content", (el, { original }) => {
|
|
9768
9962
|
el.classList.add("flex-1", "outline-none");
|
|
9769
9963
|
el.setAttribute("role", "tabpanel");
|
|
9770
9964
|
el.setAttribute("tabindex", "0");
|
|
9771
9965
|
el.setAttribute("data-slot", "tabs-content");
|
|
9772
|
-
if (!el.hasAttribute("id")) throw new Error(`${
|
|
9773
|
-
if (!el.hasAttribute("aria-labelledby")) throw new Error(`${
|
|
9966
|
+
if (!el.hasAttribute("id")) throw new Error(`${original}: Tab content must have an id`);
|
|
9967
|
+
if (!el.hasAttribute("aria-labelledby")) throw new Error(`${original}: aria-labelledby must be set to the tab id.`);
|
|
9774
9968
|
});
|
|
9775
9969
|
}
|
|
9776
9970
|
|
|
@@ -10181,13 +10375,13 @@
|
|
|
10181
10375
|
top.removeEventListener("click", el._h_timepicker.close);
|
|
10182
10376
|
});
|
|
10183
10377
|
});
|
|
10184
|
-
Alpine.directive("h-time-picker-input", (el, { original
|
|
10378
|
+
Alpine.directive("h-time-picker-input", (el, { original }, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
10185
10379
|
if (el.tagName !== "INPUT") {
|
|
10186
|
-
throw new Error(`${
|
|
10380
|
+
throw new Error(`${original} must be a readonly input of type "text"`);
|
|
10187
10381
|
}
|
|
10188
|
-
const timepicker = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
10382
|
+
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_timepicker"));
|
|
10189
10383
|
if (!timepicker) {
|
|
10190
|
-
throw new Error(`${
|
|
10384
|
+
throw new Error(`${original} must be inside a time-picker element`);
|
|
10191
10385
|
}
|
|
10192
10386
|
timepicker._h_timepicker.focusInput = () => {
|
|
10193
10387
|
el.focus();
|
|
@@ -10197,7 +10391,7 @@
|
|
|
10197
10391
|
el.dispatchEvent(new Event("change"));
|
|
10198
10392
|
});
|
|
10199
10393
|
};
|
|
10200
|
-
if (
|
|
10394
|
+
if (Object.prototype.hasOwnProperty.call(el, "_x_model")) {
|
|
10201
10395
|
timepicker._h_timepicker.model = el._x_model;
|
|
10202
10396
|
} else {
|
|
10203
10397
|
timepicker._h_timepicker.model = {
|
|
@@ -10285,7 +10479,7 @@
|
|
|
10285
10479
|
});
|
|
10286
10480
|
});
|
|
10287
10481
|
Alpine.directive("h-time-picker-popup", (el, _, { effect, cleanup, Alpine: Alpine2 }) => {
|
|
10288
|
-
const timepicker = Alpine2.findClosest(el.parentElement, (parent) =>
|
|
10482
|
+
const timepicker = Alpine2.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_timepicker"));
|
|
10289
10483
|
el.classList.add(
|
|
10290
10484
|
"overflow-hidden",
|
|
10291
10485
|
"outline-none",
|
|
@@ -10385,7 +10579,7 @@
|
|
|
10385
10579
|
}
|
|
10386
10580
|
switch (event.key) {
|
|
10387
10581
|
case "Up":
|
|
10388
|
-
case "ArrowUp":
|
|
10582
|
+
case "ArrowUp": {
|
|
10389
10583
|
event.target.setAttribute("tabindex", "-1");
|
|
10390
10584
|
let prevElem = event.target.previousElementSibling;
|
|
10391
10585
|
if (prevElem === null || prevElem.classList.contains("hidden")) {
|
|
@@ -10398,8 +10592,9 @@
|
|
|
10398
10592
|
prevElem.setAttribute("tabindex", "0");
|
|
10399
10593
|
prevElem.focus();
|
|
10400
10594
|
break;
|
|
10595
|
+
}
|
|
10401
10596
|
case "Down":
|
|
10402
|
-
case "ArrowDown":
|
|
10597
|
+
case "ArrowDown": {
|
|
10403
10598
|
event.target.setAttribute("tabindex", "-1");
|
|
10404
10599
|
let nextElem = event.target.nextElementSibling;
|
|
10405
10600
|
if (nextElem === null || nextElem.classList.contains("hidden")) {
|
|
@@ -10412,8 +10607,9 @@
|
|
|
10412
10607
|
nextElem.setAttribute("tabindex", "0");
|
|
10413
10608
|
nextElem.focus();
|
|
10414
10609
|
break;
|
|
10610
|
+
}
|
|
10415
10611
|
case "Home":
|
|
10416
|
-
case "PageUp":
|
|
10612
|
+
case "PageUp": {
|
|
10417
10613
|
let firstChild;
|
|
10418
10614
|
if (list.firstChild === event.target) {
|
|
10419
10615
|
break;
|
|
@@ -10430,8 +10626,9 @@
|
|
|
10430
10626
|
firstChild.setAttribute("tabindex", "0");
|
|
10431
10627
|
firstChild.focus();
|
|
10432
10628
|
break;
|
|
10629
|
+
}
|
|
10433
10630
|
case "End":
|
|
10434
|
-
case "PageDown":
|
|
10631
|
+
case "PageDown": {
|
|
10435
10632
|
let lastElem;
|
|
10436
10633
|
if (list.lastChild === event.target) {
|
|
10437
10634
|
break;
|
|
@@ -10448,22 +10645,25 @@
|
|
|
10448
10645
|
lastElem.setAttribute("tabindex", "0");
|
|
10449
10646
|
lastElem.focus();
|
|
10450
10647
|
break;
|
|
10648
|
+
}
|
|
10451
10649
|
case "Right":
|
|
10452
|
-
case "ArrowRight":
|
|
10650
|
+
case "ArrowRight": {
|
|
10453
10651
|
let nextColumn = event.target.parentElement.nextElementSibling;
|
|
10454
10652
|
if (nextColumn) {
|
|
10455
10653
|
const child = nextColumn.querySelector('li[tabindex="0"]');
|
|
10456
10654
|
child.focus();
|
|
10457
10655
|
}
|
|
10458
10656
|
break;
|
|
10657
|
+
}
|
|
10459
10658
|
case "Left":
|
|
10460
|
-
case "ArrowLeft":
|
|
10659
|
+
case "ArrowLeft": {
|
|
10461
10660
|
let prevColumn = event.target.parentElement.previousElementSibling;
|
|
10462
10661
|
if (prevColumn) {
|
|
10463
10662
|
const child = prevColumn.querySelector('li[tabindex="0"]');
|
|
10464
10663
|
child.focus();
|
|
10465
10664
|
}
|
|
10466
10665
|
break;
|
|
10666
|
+
}
|
|
10467
10667
|
case "Enter":
|
|
10468
10668
|
case " ":
|
|
10469
10669
|
event.target.click();
|
|
@@ -10844,13 +11044,13 @@
|
|
|
10844
11044
|
Alpine.directive("h-tooltip-trigger", (el, _, { Alpine: Alpine2, cleanup }) => {
|
|
10845
11045
|
el._tooltip = Alpine2.reactive({
|
|
10846
11046
|
id: void 0,
|
|
10847
|
-
controls: `
|
|
11047
|
+
controls: `htp${uuid_default()}`,
|
|
10848
11048
|
shown: false
|
|
10849
11049
|
});
|
|
10850
11050
|
if (el.hasAttribute("id")) {
|
|
10851
11051
|
el._tooltip.id = el.getAttribute("id");
|
|
10852
11052
|
} else {
|
|
10853
|
-
el._tooltip.id = `
|
|
11053
|
+
el._tooltip.id = `htt${uuid_default()}`;
|
|
10854
11054
|
el.setAttribute("id", el._tooltip.id);
|
|
10855
11055
|
}
|
|
10856
11056
|
el.setAttribute("aria-describedby", el._tooltip.controls);
|
|
@@ -10864,16 +11064,16 @@
|
|
|
10864
11064
|
el.removeEventListener("pointerleave", handler);
|
|
10865
11065
|
});
|
|
10866
11066
|
});
|
|
10867
|
-
Alpine.directive("h-tooltip", (el, { original
|
|
11067
|
+
Alpine.directive("h-tooltip", (el, { original }, { effect, cleanup }) => {
|
|
10868
11068
|
const tooltip = (() => {
|
|
10869
11069
|
let sibling = el.previousElementSibling;
|
|
10870
|
-
while (sibling && !
|
|
11070
|
+
while (sibling && !Object.prototype.hasOwnProperty.call(sibling, "_tooltip")) {
|
|
10871
11071
|
sibling = sibling.previousElementSibling;
|
|
10872
11072
|
}
|
|
10873
11073
|
return sibling;
|
|
10874
11074
|
})();
|
|
10875
11075
|
if (!tooltip) {
|
|
10876
|
-
throw new Error(`${
|
|
11076
|
+
throw new Error(`${original} must be placed after a tooltip trigger element`);
|
|
10877
11077
|
}
|
|
10878
11078
|
el.classList.add(
|
|
10879
11079
|
"absolute",
|
|
@@ -10978,7 +11178,7 @@
|
|
|
10978
11178
|
);
|
|
10979
11179
|
el.setAttribute("data-slot", "subtree");
|
|
10980
11180
|
el.setAttribute("role", "group");
|
|
10981
|
-
const treeItem = Alpine.findClosest(el.parentElement, (parent) =>
|
|
11181
|
+
const treeItem = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_tree_item"));
|
|
10982
11182
|
effect(() => {
|
|
10983
11183
|
if (treeItem._h_tree_item.expanded) {
|
|
10984
11184
|
el.classList.remove("!hidden");
|
|
@@ -11118,9 +11318,9 @@
|
|
|
11118
11318
|
});
|
|
11119
11319
|
}
|
|
11120
11320
|
});
|
|
11121
|
-
Alpine.directive("h-tree-button", (el, { original
|
|
11122
|
-
const treeItem = Alpine.findClosest(el.parentElement, (parent) =>
|
|
11123
|
-
if (!treeItem) throw new Error(`${
|
|
11321
|
+
Alpine.directive("h-tree-button", (el, { original }, { effect }) => {
|
|
11322
|
+
const treeItem = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_tree_item"));
|
|
11323
|
+
if (!treeItem) throw new Error(`${original} must be inside a tree item`);
|
|
11124
11324
|
el.classList.add(
|
|
11125
11325
|
"flex",
|
|
11126
11326
|
"w-full",
|
|
@@ -11262,7 +11462,7 @@
|
|
|
11262
11462
|
|
|
11263
11463
|
// src/utils/template.js
|
|
11264
11464
|
function template_default(Alpine) {
|
|
11265
|
-
Alpine.directive("h-template", (el, { original
|
|
11465
|
+
Alpine.directive("h-template", (el, { original, expression }, { evaluate: evaluate2, Alpine: Alpine2, cleanup }) => {
|
|
11266
11466
|
if (el.hasAttribute(Alpine2.prefixed("data"))) {
|
|
11267
11467
|
const template = evaluate2(expression);
|
|
11268
11468
|
const clone = template.content.cloneNode(true).firstElementChild;
|
|
@@ -11276,14 +11476,14 @@
|
|
|
11276
11476
|
clone.remove();
|
|
11277
11477
|
});
|
|
11278
11478
|
} else {
|
|
11279
|
-
console.error(`${
|
|
11479
|
+
console.error(`${original}: ${Alpine2.prefixed("data")} directive is missing`);
|
|
11280
11480
|
}
|
|
11281
11481
|
});
|
|
11282
11482
|
}
|
|
11283
11483
|
|
|
11284
11484
|
// src/utils/include.js
|
|
11285
11485
|
function include_default(Alpine) {
|
|
11286
|
-
Alpine.directive("h-include", (el, { modifiers, expression }, { evaluateLater, effect, cleanup, Alpine: Alpine2 }) => {
|
|
11486
|
+
Alpine.directive("h-include", (el, { original, modifiers, expression }, { evaluateLater, effect, cleanup, Alpine: Alpine2 }) => {
|
|
11287
11487
|
const getUrl = evaluateLater(expression);
|
|
11288
11488
|
function executeScript(oldScript) {
|
|
11289
11489
|
return new Promise((resolve, reject) => {
|
|
@@ -11369,7 +11569,7 @@
|
|
|
11369
11569
|
}
|
|
11370
11570
|
|
|
11371
11571
|
// package.json
|
|
11372
|
-
var version = "1.
|
|
11572
|
+
var version = "1.10.0";
|
|
11373
11573
|
|
|
11374
11574
|
// src/index.js
|
|
11375
11575
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
|
|
@@ -11382,6 +11582,7 @@
|
|
|
11382
11582
|
window.Alpine.plugin(calendar_default);
|
|
11383
11583
|
window.Alpine.plugin(card_default);
|
|
11384
11584
|
window.Alpine.plugin(checkbox_default);
|
|
11585
|
+
window.Alpine.plugin(chip_default);
|
|
11385
11586
|
window.Alpine.plugin(datepicker_default);
|
|
11386
11587
|
window.Alpine.plugin(dialog_default);
|
|
11387
11588
|
window.Alpine.plugin(expansion_panel_default);
|