@codbex/harmonia 1.9.1 → 1.10.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 +202 -11
- package/dist/harmonia.esm.min.js +2 -2
- package/dist/harmonia.esm.min.js.map +4 -4
- package/dist/harmonia.js +202 -11
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +4 -4
- package/package.json +9 -2
package/dist/harmonia.js
CHANGED
|
@@ -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({
|
|
@@ -3376,6 +3376,195 @@
|
|
|
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
|
+
"aria-expanded:outline-[calc(var(--spacing)*0.75)]",
|
|
3409
|
+
"aria-expanded:outline",
|
|
3410
|
+
"focus:outline-[calc(var(--spacing)*0.75)]",
|
|
3411
|
+
"focus:outline",
|
|
3412
|
+
"focus-visible:outline-[calc(var(--spacing)*0.75)]",
|
|
3413
|
+
"focus-visible:outline",
|
|
3414
|
+
"h-7",
|
|
3415
|
+
"gap-1.5",
|
|
3416
|
+
"px-2.5",
|
|
3417
|
+
"has-[>svg]:pl-1.5",
|
|
3418
|
+
"has-[>[data-slot=chip-close]]:pr-0",
|
|
3419
|
+
"has-[>[data-slot=spinner]]:px-2",
|
|
3420
|
+
"text-secondary-foreground",
|
|
3421
|
+
"border"
|
|
3422
|
+
);
|
|
3423
|
+
if (!el.hasAttribute("type")) {
|
|
3424
|
+
el.setAttribute("type", "button");
|
|
3425
|
+
}
|
|
3426
|
+
el.setAttribute("data-slot", "chip");
|
|
3427
|
+
const variants = {
|
|
3428
|
+
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"],
|
|
3429
|
+
primary: [
|
|
3430
|
+
"bg-primary/10",
|
|
3431
|
+
"border-primary/50",
|
|
3432
|
+
"[&>svg]:text-primary",
|
|
3433
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-primary/15",
|
|
3434
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-primary/20",
|
|
3435
|
+
"outline-primary/50"
|
|
3436
|
+
],
|
|
3437
|
+
positive: [
|
|
3438
|
+
"bg-positive/10",
|
|
3439
|
+
"border-positive/50",
|
|
3440
|
+
"[&>svg]:text-positive",
|
|
3441
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-positive/15",
|
|
3442
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-positive/20",
|
|
3443
|
+
"outline-positive/50"
|
|
3444
|
+
],
|
|
3445
|
+
negative: [
|
|
3446
|
+
"bg-negative/10",
|
|
3447
|
+
"border-negative/50",
|
|
3448
|
+
"[&>svg]:text-negative",
|
|
3449
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-negative/15",
|
|
3450
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-negative/20",
|
|
3451
|
+
"outline-negative/50"
|
|
3452
|
+
],
|
|
3453
|
+
warning: [
|
|
3454
|
+
"bg-warning/10",
|
|
3455
|
+
"border-warning/50",
|
|
3456
|
+
"[&>svg]:text-warning",
|
|
3457
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-warning/15",
|
|
3458
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-warning/20",
|
|
3459
|
+
"outline-warning/50"
|
|
3460
|
+
],
|
|
3461
|
+
information: [
|
|
3462
|
+
"bg-information/10",
|
|
3463
|
+
"border-information/50",
|
|
3464
|
+
"[&>svg]:text-information",
|
|
3465
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-information/15",
|
|
3466
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-information/20",
|
|
3467
|
+
"outline-information/50"
|
|
3468
|
+
],
|
|
3469
|
+
outline: [
|
|
3470
|
+
"bg-background",
|
|
3471
|
+
"[&>svg]:text-secondary-foreground",
|
|
3472
|
+
"[&:hover:not(:has([data-slot=chip-close]:hover)):not(:active)]:bg-secondary-hover",
|
|
3473
|
+
"[&:active:not(:has([data-slot=chip-close]:active))]:bg-secondary-active",
|
|
3474
|
+
"outline-ring/50"
|
|
3475
|
+
]
|
|
3476
|
+
};
|
|
3477
|
+
function setVariant(variant) {
|
|
3478
|
+
el._h_chip.variant = variant;
|
|
3479
|
+
for (const [_, value] of Object.entries(variants)) {
|
|
3480
|
+
el.classList.remove(...value);
|
|
3481
|
+
}
|
|
3482
|
+
if (Object.prototype.hasOwnProperty.call(variants, variant)) el.classList.add(...variants[variant]);
|
|
3483
|
+
}
|
|
3484
|
+
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
3485
|
+
const observer = new MutationObserver(() => {
|
|
3486
|
+
setVariant(el.getAttribute("data-variant") ?? "default");
|
|
3487
|
+
});
|
|
3488
|
+
observer.observe(el, { attributes: true, attributeFilter: ["data-variant"] });
|
|
3489
|
+
cleanup(() => {
|
|
3490
|
+
observer.disconnect();
|
|
3491
|
+
});
|
|
3492
|
+
});
|
|
3493
|
+
Alpine.directive("h-chip-close", (el, { original }, { effect, cleanup }) => {
|
|
3494
|
+
if (el.tagName === "BUTTON") {
|
|
3495
|
+
throw new Error(`${original} must NOT be a button element`);
|
|
3496
|
+
}
|
|
3497
|
+
const chip = Alpine.findClosest(el.parentElement, (parent) => Object.prototype.hasOwnProperty.call(parent, "_h_chip"));
|
|
3498
|
+
el.classList.add(
|
|
3499
|
+
"cursor-pointer",
|
|
3500
|
+
"inline-flex",
|
|
3501
|
+
"items-center",
|
|
3502
|
+
"justify-center",
|
|
3503
|
+
"pl-1",
|
|
3504
|
+
"pr-1.5",
|
|
3505
|
+
"h-full",
|
|
3506
|
+
"text-sm",
|
|
3507
|
+
"transition-all",
|
|
3508
|
+
"duration-100",
|
|
3509
|
+
"motion-reduce:transition-none",
|
|
3510
|
+
"disabled:pointer-events-none",
|
|
3511
|
+
"disabled:opacity-50",
|
|
3512
|
+
"bg-transparent",
|
|
3513
|
+
"text-secondary-foreground",
|
|
3514
|
+
"fill-secondary-foreground",
|
|
3515
|
+
"rounded-r-full",
|
|
3516
|
+
"border-l",
|
|
3517
|
+
"border-transparent",
|
|
3518
|
+
"outline-none",
|
|
3519
|
+
"focus-visible:inset-ring-[calc(var(--spacing)*0.75)]",
|
|
3520
|
+
"focus-visible:inset-ring",
|
|
3521
|
+
"hover:[[data-variant]>&]:border-inherit",
|
|
3522
|
+
"active:border-inherit",
|
|
3523
|
+
"aria-pressed:border-inherit"
|
|
3524
|
+
);
|
|
3525
|
+
el.setAttribute("data-slot", "chip-close");
|
|
3526
|
+
el.setAttribute("tabindex", "0");
|
|
3527
|
+
el.setAttribute("role", "button");
|
|
3528
|
+
el.appendChild(
|
|
3529
|
+
createSvg({
|
|
3530
|
+
icon: Close,
|
|
3531
|
+
classes: "size-3.5 shrink-0 pointer-events-none",
|
|
3532
|
+
attrs: {
|
|
3533
|
+
"aria-hidden": true,
|
|
3534
|
+
role: "presentation"
|
|
3535
|
+
}
|
|
3536
|
+
})
|
|
3537
|
+
);
|
|
3538
|
+
if (!el.hasAttribute("aria-labelledby") && !el.hasAttribute("aria-label")) {
|
|
3539
|
+
console.error(`${original}: Must have an "aria-label" or "aria-labelledby" attribute`, el);
|
|
3540
|
+
}
|
|
3541
|
+
const variants = {
|
|
3542
|
+
default: ["hover:border-foreground/20", "hover:bg-secondary-hover", "active:bg-secondary-active", "focus-visible:inset-ring-ring/50"],
|
|
3543
|
+
primary: ["hover:bg-primary/10", "active:bg-primary/15", "aria-pressed:bg-primary/15", "focus-visible:inset-ring-primary/50"],
|
|
3544
|
+
positive: ["hover:bg-positive/10", "active:bg-positive/15", "aria-pressed:bg-positive/15", "focus-visible:inset-ring-positive/50"],
|
|
3545
|
+
negative: ["hover:bg-negative/10", "active:bg-negative/15", "aria-pressed:bg-negative/15", "focus-visible:inset-ring-negative/50"],
|
|
3546
|
+
warning: ["hover:bg-warning/10", "active:bg-warning/15", "aria-pressed:bg-warning/15", "focus-visible:inset-ring-warning/50"],
|
|
3547
|
+
information: ["hover:bg-information/10", "active:bg-information/15", "aria-pressed:bg-information/15", "focus-visible:inset-ring-information/50"],
|
|
3548
|
+
outline: ["hover:bg-secondary-hover", "active:bg-secondary-active", "aria-pressed:bg-secondary-active", "focus-visible:inset-ring-ring/50"]
|
|
3549
|
+
};
|
|
3550
|
+
effect(() => {
|
|
3551
|
+
for (const [_, value] of Object.entries(variants)) {
|
|
3552
|
+
el.classList.remove(...value);
|
|
3553
|
+
}
|
|
3554
|
+
if (Object.prototype.hasOwnProperty.call(variants, chip._h_chip.variant)) {
|
|
3555
|
+
el.classList.add(...variants[chip._h_chip.variant]);
|
|
3556
|
+
}
|
|
3557
|
+
});
|
|
3558
|
+
const stopPropagation = (event) => {
|
|
3559
|
+
if (chip.getAttribute("aria-expanded") !== "true") event.stopPropagation();
|
|
3560
|
+
};
|
|
3561
|
+
el.addEventListener("click", stopPropagation);
|
|
3562
|
+
cleanup(() => {
|
|
3563
|
+
el.removeEventListener("click", stopPropagation);
|
|
3564
|
+
});
|
|
3565
|
+
});
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3379
3568
|
// src/common/input-size.js
|
|
3380
3569
|
function setSize(el, size3) {
|
|
3381
3570
|
if (size3 === "sm") {
|
|
@@ -3677,7 +3866,7 @@
|
|
|
3677
3866
|
el.classList.add("order-1", "text-lg", "leading-none", "font-semibold");
|
|
3678
3867
|
el.setAttribute("data-slot", "dialog-title");
|
|
3679
3868
|
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
3680
|
-
if (dialog &&
|
|
3869
|
+
if (dialog && !dialog.hasAttribute("aria-labelledby") && !dialog.hasAttribute("aria-label")) {
|
|
3681
3870
|
if (!el.hasAttribute("id")) {
|
|
3682
3871
|
const id = `dht${uuid_default()}`;
|
|
3683
3872
|
el.setAttribute("id", id);
|
|
@@ -3710,7 +3899,7 @@
|
|
|
3710
3899
|
el.classList.add("order-3", "col-span-full", "text-muted-foreground", "text-sm");
|
|
3711
3900
|
el.setAttribute("data-slot", "dialog-description");
|
|
3712
3901
|
const dialog = Alpine2.findClosest(el.parentElement, (parent) => parent.getAttribute("role") === "dialog");
|
|
3713
|
-
if (dialog &&
|
|
3902
|
+
if (dialog && !dialog.hasAttribute("aria-describedby") && !dialog.hasAttribute("aria-description")) {
|
|
3714
3903
|
if (!el.hasAttribute("id")) {
|
|
3715
3904
|
const id = `dhd${uuid_default()}`;
|
|
3716
3905
|
el.setAttribute("id", id);
|
|
@@ -4029,7 +4218,7 @@
|
|
|
4029
4218
|
});
|
|
4030
4219
|
Alpine.directive("h-info-page-content", (el) => {
|
|
4031
4220
|
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-
|
|
4221
|
+
el.setAttribute("data-slot", "info-page-content");
|
|
4033
4222
|
});
|
|
4034
4223
|
}
|
|
4035
4224
|
|
|
@@ -7839,6 +8028,7 @@
|
|
|
7839
8028
|
displayValue.innerText = value;
|
|
7840
8029
|
displayValue.classList.add("text-muted-foreground");
|
|
7841
8030
|
} else {
|
|
8031
|
+
displayValue.innerText = "";
|
|
7842
8032
|
displayValue.classList.remove("text-muted-foreground");
|
|
7843
8033
|
}
|
|
7844
8034
|
}
|
|
@@ -8316,7 +8506,7 @@
|
|
|
8316
8506
|
}
|
|
8317
8507
|
} else if (select._h_model.get() !== getValue()) {
|
|
8318
8508
|
select._h_model.set(getValue());
|
|
8319
|
-
} else {
|
|
8509
|
+
} else if (select.getAttribute("data-clearable") === "true") {
|
|
8320
8510
|
select._h_model.set("");
|
|
8321
8511
|
}
|
|
8322
8512
|
}
|
|
@@ -10857,13 +11047,13 @@
|
|
|
10857
11047
|
Alpine.directive("h-tooltip-trigger", (el, _, { Alpine: Alpine2, cleanup }) => {
|
|
10858
11048
|
el._tooltip = Alpine2.reactive({
|
|
10859
11049
|
id: void 0,
|
|
10860
|
-
controls: `
|
|
11050
|
+
controls: `htp${uuid_default()}`,
|
|
10861
11051
|
shown: false
|
|
10862
11052
|
});
|
|
10863
11053
|
if (el.hasAttribute("id")) {
|
|
10864
11054
|
el._tooltip.id = el.getAttribute("id");
|
|
10865
11055
|
} else {
|
|
10866
|
-
el._tooltip.id = `
|
|
11056
|
+
el._tooltip.id = `htt${uuid_default()}`;
|
|
10867
11057
|
el.setAttribute("id", el._tooltip.id);
|
|
10868
11058
|
}
|
|
10869
11059
|
el.setAttribute("aria-describedby", el._tooltip.controls);
|
|
@@ -11382,7 +11572,7 @@
|
|
|
11382
11572
|
}
|
|
11383
11573
|
|
|
11384
11574
|
// package.json
|
|
11385
|
-
var version = "1.
|
|
11575
|
+
var version = "1.10.1";
|
|
11386
11576
|
|
|
11387
11577
|
// src/index.js
|
|
11388
11578
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
|
|
@@ -11395,6 +11585,7 @@
|
|
|
11395
11585
|
window.Alpine.plugin(calendar_default);
|
|
11396
11586
|
window.Alpine.plugin(card_default);
|
|
11397
11587
|
window.Alpine.plugin(checkbox_default);
|
|
11588
|
+
window.Alpine.plugin(chip_default);
|
|
11398
11589
|
window.Alpine.plugin(datepicker_default);
|
|
11399
11590
|
window.Alpine.plugin(dialog_default);
|
|
11400
11591
|
window.Alpine.plugin(expansion_panel_default);
|