@codbex/harmonia 1.9.1 → 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 +199 -11
- package/dist/harmonia.esm.min.js +2 -2
- package/dist/harmonia.esm.min.js.map +4 -4
- package/dist/harmonia.js +199 -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,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") {
|
|
@@ -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);
|
|
@@ -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
|
|
|
@@ -7839,6 +8025,7 @@
|
|
|
7839
8025
|
displayValue.innerText = value;
|
|
7840
8026
|
displayValue.classList.add("text-muted-foreground");
|
|
7841
8027
|
} else {
|
|
8028
|
+
displayValue.innerText = "";
|
|
7842
8029
|
displayValue.classList.remove("text-muted-foreground");
|
|
7843
8030
|
}
|
|
7844
8031
|
}
|
|
@@ -8316,7 +8503,7 @@
|
|
|
8316
8503
|
}
|
|
8317
8504
|
} else if (select._h_model.get() !== getValue()) {
|
|
8318
8505
|
select._h_model.set(getValue());
|
|
8319
|
-
} else {
|
|
8506
|
+
} else if (select.getAttribute("data-clearable") === "true") {
|
|
8320
8507
|
select._h_model.set("");
|
|
8321
8508
|
}
|
|
8322
8509
|
}
|
|
@@ -10857,13 +11044,13 @@
|
|
|
10857
11044
|
Alpine.directive("h-tooltip-trigger", (el, _, { Alpine: Alpine2, cleanup }) => {
|
|
10858
11045
|
el._tooltip = Alpine2.reactive({
|
|
10859
11046
|
id: void 0,
|
|
10860
|
-
controls: `
|
|
11047
|
+
controls: `htp${uuid_default()}`,
|
|
10861
11048
|
shown: false
|
|
10862
11049
|
});
|
|
10863
11050
|
if (el.hasAttribute("id")) {
|
|
10864
11051
|
el._tooltip.id = el.getAttribute("id");
|
|
10865
11052
|
} else {
|
|
10866
|
-
el._tooltip.id = `
|
|
11053
|
+
el._tooltip.id = `htt${uuid_default()}`;
|
|
10867
11054
|
el.setAttribute("id", el._tooltip.id);
|
|
10868
11055
|
}
|
|
10869
11056
|
el.setAttribute("aria-describedby", el._tooltip.controls);
|
|
@@ -11382,7 +11569,7 @@
|
|
|
11382
11569
|
}
|
|
11383
11570
|
|
|
11384
11571
|
// package.json
|
|
11385
|
-
var version = "1.
|
|
11572
|
+
var version = "1.10.0";
|
|
11386
11573
|
|
|
11387
11574
|
// src/index.js
|
|
11388
11575
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
|
|
@@ -11395,6 +11582,7 @@
|
|
|
11395
11582
|
window.Alpine.plugin(calendar_default);
|
|
11396
11583
|
window.Alpine.plugin(card_default);
|
|
11397
11584
|
window.Alpine.plugin(checkbox_default);
|
|
11585
|
+
window.Alpine.plugin(chip_default);
|
|
11398
11586
|
window.Alpine.plugin(datepicker_default);
|
|
11399
11587
|
window.Alpine.plugin(dialog_default);
|
|
11400
11588
|
window.Alpine.plugin(expansion_panel_default);
|