@geomak/ui 4.0.0 → 5.0.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/index.cjs +256 -266
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -52
- package/dist/index.d.ts +55 -52
- package/dist/index.js +256 -266
- package/dist/index.js.map +1 -1
- package/dist/styles.css +28 -56
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3536,294 +3536,284 @@ function FileInput({
|
|
|
3536
3536
|
)
|
|
3537
3537
|
);
|
|
3538
3538
|
}
|
|
3539
|
-
var
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
const
|
|
3559
|
-
const
|
|
3560
|
-
|
|
3561
|
-
}
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3539
|
+
var MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
3540
|
+
var WEEKDAY_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
3541
|
+
function isSameDay(a, b) {
|
|
3542
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
3543
|
+
}
|
|
3544
|
+
function startOfMonth(d) {
|
|
3545
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
3546
|
+
}
|
|
3547
|
+
function addDays(d, n) {
|
|
3548
|
+
const c = new Date(d);
|
|
3549
|
+
c.setDate(c.getDate() + n);
|
|
3550
|
+
return c;
|
|
3551
|
+
}
|
|
3552
|
+
function addMonths(d, n) {
|
|
3553
|
+
const c = new Date(d);
|
|
3554
|
+
c.setMonth(c.getMonth() + n);
|
|
3555
|
+
return c;
|
|
3556
|
+
}
|
|
3557
|
+
function defaultFormat(d) {
|
|
3558
|
+
const y = d.getFullYear().toString().padStart(4, "0");
|
|
3559
|
+
const m = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
3560
|
+
const day = d.getDate().toString().padStart(2, "0");
|
|
3561
|
+
return `${y}-${m}-${day}`;
|
|
3562
|
+
}
|
|
3563
|
+
function buildGrid(viewMonth, weekStartsOn) {
|
|
3564
|
+
const first = startOfMonth(viewMonth);
|
|
3565
|
+
const startOffset = (first.getDay() - weekStartsOn + 7) % 7;
|
|
3566
|
+
const gridStart = addDays(first, -startOffset);
|
|
3567
|
+
const cells = [];
|
|
3568
|
+
for (let i = 0; i < 42; i++) {
|
|
3569
|
+
const d = addDays(gridStart, i);
|
|
3570
|
+
cells.push({ date: d, outside: d.getMonth() !== viewMonth.getMonth() });
|
|
3568
3571
|
}
|
|
3569
|
-
|
|
3572
|
+
const rows = [];
|
|
3573
|
+
for (let r = 0; r < 6; r++) rows.push(cells.slice(r * 7, r * 7 + 7));
|
|
3574
|
+
return rows;
|
|
3570
3575
|
}
|
|
3571
|
-
|
|
3572
|
-
var DoubleChevronRight2 = ({ color = chunk255PCZIW_cjs.colors_default.PALETTE["prussian-blue"] }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: 2, className: "w-4 h-4", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M13 5l7 7-7 7M5 5l7 7-7 7" }) });
|
|
3573
|
-
var ChevronDown2 = ({ color = chunk255PCZIW_cjs.colors_default.PALETTE["prussian-blue"] }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: 2, className: "w-4 h-4", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) });
|
|
3574
|
-
function DatePickerBase({
|
|
3576
|
+
function DatePicker({
|
|
3575
3577
|
value,
|
|
3576
3578
|
onChange,
|
|
3577
|
-
layout,
|
|
3578
3579
|
label,
|
|
3580
|
+
placeholder = "Select a date\u2026",
|
|
3579
3581
|
htmlFor,
|
|
3580
|
-
name,
|
|
3581
|
-
|
|
3582
|
+
name: _name,
|
|
3583
|
+
layout = "horizontal",
|
|
3584
|
+
disabled,
|
|
3582
3585
|
errorMessage,
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
+
min,
|
|
3587
|
+
max,
|
|
3588
|
+
style,
|
|
3589
|
+
format = defaultFormat,
|
|
3590
|
+
weekStartsOn = 0,
|
|
3591
|
+
clearable = true
|
|
3586
3592
|
}) {
|
|
3587
|
-
const
|
|
3588
|
-
const
|
|
3589
|
-
const [
|
|
3590
|
-
const [
|
|
3591
|
-
const [
|
|
3592
|
-
const
|
|
3593
|
-
|
|
3594
|
-
if (!
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
};
|
|
3608
|
-
const
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
const isSelected = (d) => value.getDate() === d.getDate() && value.getMonth() === d.getMonth() && value.getFullYear() === d.getFullYear();
|
|
3613
|
-
const isDateDisabled = (d) => {
|
|
3614
|
-
if (disableBefore && d.getTime() < new Date(disableBefore).getTime()) return true;
|
|
3615
|
-
if (disableAfter && d.getTime() > new Date(disableAfter).getTime()) return true;
|
|
3593
|
+
const errorId = React8.useId();
|
|
3594
|
+
const hasError = errorMessage != null;
|
|
3595
|
+
const [open, setOpen] = React8.useState(false);
|
|
3596
|
+
const [viewMonth, setViewMonth] = React8.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
3597
|
+
const [focusDate, setFocusDate] = React8.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
3598
|
+
const gridRef = React8.useRef(null);
|
|
3599
|
+
React8.useEffect(() => {
|
|
3600
|
+
if (!open) return;
|
|
3601
|
+
const target = value ?? /* @__PURE__ */ new Date();
|
|
3602
|
+
setViewMonth(startOfMonth(target));
|
|
3603
|
+
setFocusDate(target);
|
|
3604
|
+
}, [open, value]);
|
|
3605
|
+
React8.useEffect(() => {
|
|
3606
|
+
if (!open) return;
|
|
3607
|
+
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
3608
|
+
cell?.focus();
|
|
3609
|
+
}, [open, focusDate]);
|
|
3610
|
+
const weekdays = React8.useMemo(() => {
|
|
3611
|
+
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
3612
|
+
return ordered;
|
|
3613
|
+
}, [weekStartsOn]);
|
|
3614
|
+
const grid = React8.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
3615
|
+
const isDisabled = (d) => {
|
|
3616
|
+
if (min && d < min) return true;
|
|
3617
|
+
if (max && d > max) return true;
|
|
3616
3618
|
return false;
|
|
3617
3619
|
};
|
|
3618
|
-
const
|
|
3619
|
-
|
|
3620
|
-
onChange(
|
|
3621
|
-
|
|
3622
|
-
setCurrentYear(d.getFullYear());
|
|
3623
|
-
setCurrentMonth(d.getMonth() + 1);
|
|
3620
|
+
const selectDate = (d) => {
|
|
3621
|
+
if (isDisabled(d)) return;
|
|
3622
|
+
onChange?.(d);
|
|
3623
|
+
setOpen(false);
|
|
3624
3624
|
};
|
|
3625
|
-
const
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
if (
|
|
3632
|
-
|
|
3625
|
+
const onKey = (e) => {
|
|
3626
|
+
const next = (delta) => {
|
|
3627
|
+
const nd = addDays(focusDate, delta);
|
|
3628
|
+
setFocusDate(nd);
|
|
3629
|
+
if (nd.getMonth() !== viewMonth.getMonth()) setViewMonth(startOfMonth(nd));
|
|
3630
|
+
};
|
|
3631
|
+
if (e.key === "ArrowLeft") {
|
|
3632
|
+
e.preventDefault();
|
|
3633
|
+
next(-1);
|
|
3634
|
+
} else if (e.key === "ArrowRight") {
|
|
3635
|
+
e.preventDefault();
|
|
3636
|
+
next(1);
|
|
3637
|
+
} else if (e.key === "ArrowUp") {
|
|
3638
|
+
e.preventDefault();
|
|
3639
|
+
next(-7);
|
|
3640
|
+
} else if (e.key === "ArrowDown") {
|
|
3641
|
+
e.preventDefault();
|
|
3642
|
+
next(7);
|
|
3643
|
+
} else if (e.key === "PageUp") {
|
|
3644
|
+
e.preventDefault();
|
|
3645
|
+
const nm = addMonths(viewMonth, -1);
|
|
3646
|
+
setViewMonth(nm);
|
|
3647
|
+
setFocusDate((d) => addMonths(d, -1));
|
|
3648
|
+
} else if (e.key === "PageDown") {
|
|
3649
|
+
e.preventDefault();
|
|
3650
|
+
const nm = addMonths(viewMonth, 1);
|
|
3651
|
+
setViewMonth(nm);
|
|
3652
|
+
setFocusDate((d) => addMonths(d, 1));
|
|
3653
|
+
} else if (e.key === "Home") {
|
|
3654
|
+
e.preventDefault();
|
|
3655
|
+
const dow = (focusDate.getDay() - weekStartsOn + 7) % 7;
|
|
3656
|
+
setFocusDate(addDays(focusDate, -dow));
|
|
3657
|
+
} else if (e.key === "End") {
|
|
3658
|
+
e.preventDefault();
|
|
3659
|
+
const dow = (focusDate.getDay() - weekStartsOn + 7) % 7;
|
|
3660
|
+
setFocusDate(addDays(focusDate, 6 - dow));
|
|
3661
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
3662
|
+
e.preventDefault();
|
|
3663
|
+
selectDate(focusDate);
|
|
3664
|
+
} else if (e.key === "Escape") {
|
|
3665
|
+
e.preventDefault();
|
|
3666
|
+
setOpen(false);
|
|
3633
3667
|
}
|
|
3634
|
-
return ordered;
|
|
3635
3668
|
};
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
return () => document.removeEventListener("mousedown", clickAway);
|
|
3642
|
-
}, []);
|
|
3643
|
-
React8.useEffect(() => {
|
|
3644
|
-
const bbox = pickerRef.current?.getBoundingClientRect();
|
|
3645
|
-
if (bbox && (bbox.y > window.innerHeight - 220 || bbox.bottom > window.innerHeight - 400)) {
|
|
3646
|
-
setCloseToBottom(true);
|
|
3647
|
-
} else setCloseToBottom(false);
|
|
3648
|
-
}, []);
|
|
3649
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
3650
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex relative ${layout === "vertical" ? "flex-col" : "flex-row items-center gap-2"}`, children: [
|
|
3651
|
-
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-md font-bold ml-1 max-content text-prussian-blue dark:text-white", children: label }),
|
|
3652
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3653
|
-
"div",
|
|
3669
|
+
const displayValue = value ? format(value) : "";
|
|
3670
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3671
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex ${layout === "vertical" ? "flex-col gap-1" : "flex-row items-center gap-2"}`, children: [
|
|
3672
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3673
|
+
"label",
|
|
3654
3674
|
{
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
children: [
|
|
3659
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3660
|
-
"div",
|
|
3661
|
-
{
|
|
3662
|
-
onClick: toggle,
|
|
3663
|
-
className: `h-7 focus:outline-none text-prussian-blue ${disabled ? "cursor-not-allowed" : "cursor-pointer"} ${!style.width ? "min-w-[240px]" : ""} flex items-center gap-1`,
|
|
3664
|
-
children: formatDate(value)
|
|
3665
|
-
}
|
|
3666
|
-
),
|
|
3667
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3668
|
-
"div",
|
|
3669
|
-
{
|
|
3670
|
-
onClick: toggle,
|
|
3671
|
-
className: `transition-all duration-300 ml-2 ${isExpanded ? "rotate-180" : "rotate-0 w-4 h-4"}`,
|
|
3672
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, {})
|
|
3673
|
-
}
|
|
3674
|
-
)
|
|
3675
|
-
]
|
|
3675
|
+
className: "text-sm font-medium ml-1 max-content select-none text-foreground",
|
|
3676
|
+
htmlFor,
|
|
3677
|
+
children: label
|
|
3676
3678
|
}
|
|
3677
3679
|
),
|
|
3678
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3680
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
|
|
3681
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3682
|
+
"button",
|
|
3683
|
+
{
|
|
3684
|
+
id: htmlFor,
|
|
3685
|
+
type: "button",
|
|
3686
|
+
disabled,
|
|
3687
|
+
style,
|
|
3688
|
+
"aria-invalid": hasError || void 0,
|
|
3689
|
+
"aria-describedby": hasError ? errorId : void 0,
|
|
3690
|
+
"aria-haspopup": "dialog",
|
|
3691
|
+
"aria-expanded": open,
|
|
3692
|
+
className: `flex items-center justify-between h-9 rounded-lg border px-3 cursor-pointer select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${hasError ? "border-status-error" : "border-border"} ${disabled ? "cursor-not-allowed bg-surface-raised text-foreground-muted" : "bg-surface text-foreground"} ${!style?.width ? "min-w-[200px]" : ""}`,
|
|
3693
|
+
children: [
|
|
3694
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-sm truncate ${displayValue ? "" : "text-foreground-muted"}`, children: displayValue || placeholder }),
|
|
3695
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {})
|
|
3696
|
+
]
|
|
3697
|
+
}
|
|
3698
|
+
) }),
|
|
3699
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3700
|
+
Popover__namespace.Content,
|
|
3701
|
+
{
|
|
3702
|
+
align: "start",
|
|
3703
|
+
sideOffset: 4,
|
|
3704
|
+
className: "bg-surface text-foreground border border-border rounded-lg shadow-md z-50 p-3 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
3705
|
+
onOpenAutoFocus: (e) => {
|
|
3706
|
+
e.preventDefault();
|
|
3707
|
+
},
|
|
3708
|
+
children: [
|
|
3709
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
3710
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3711
|
+
"button",
|
|
3712
|
+
{
|
|
3713
|
+
type: "button",
|
|
3714
|
+
onClick: () => setViewMonth(addMonths(viewMonth, -1)),
|
|
3715
|
+
"aria-label": "Previous month",
|
|
3716
|
+
className: "w-7 h-7 inline-flex items-center justify-center rounded-md hover:bg-surface-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-accent transition-colors",
|
|
3717
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeft, {})
|
|
3718
|
+
}
|
|
3719
|
+
),
|
|
3720
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-semibold select-none", children: [
|
|
3721
|
+
MONTH_NAMES[viewMonth.getMonth()],
|
|
3722
|
+
" ",
|
|
3723
|
+
viewMonth.getFullYear()
|
|
3724
|
+
] }),
|
|
3725
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3726
|
+
"button",
|
|
3727
|
+
{
|
|
3728
|
+
type: "button",
|
|
3729
|
+
onClick: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
3730
|
+
"aria-label": "Next month",
|
|
3731
|
+
className: "w-7 h-7 inline-flex items-center justify-center rounded-md hover:bg-surface-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-accent transition-colors",
|
|
3732
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRight3, {})
|
|
3733
|
+
}
|
|
3734
|
+
)
|
|
3691
3735
|
] }),
|
|
3692
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3693
|
-
|
|
3694
|
-
] }),
|
|
3695
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3 p-2", children: renderCalendar().map((weekDay, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
3696
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center font-bold text-sm text-prussian-blue", children: weekDay[0] ? DAYS[weekDay[0].getDay()] : "" }),
|
|
3697
|
-
weekDay.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3698
|
-
"div",
|
|
3736
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3737
|
+
"table",
|
|
3699
3738
|
{
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3739
|
+
ref: gridRef,
|
|
3740
|
+
role: "grid",
|
|
3741
|
+
"aria-label": `${MONTH_NAMES[viewMonth.getMonth()]} ${viewMonth.getFullYear()}`,
|
|
3742
|
+
onKeyDown: onKey,
|
|
3743
|
+
className: "border-separate border-spacing-0",
|
|
3744
|
+
children: [
|
|
3745
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: weekdays.map((w) => /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: "text-[11px] font-medium text-foreground-muted uppercase tracking-wide w-8 h-8", children: w }, w)) }) }),
|
|
3746
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: grid.map((row, ri) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: row.map(({ date, outside }) => {
|
|
3747
|
+
const dis = isDisabled(date);
|
|
3748
|
+
const sel = value ? isSameDay(date, value) : false;
|
|
3749
|
+
const focused = isSameDay(date, focusDate);
|
|
3750
|
+
const today = isSameDay(date, /* @__PURE__ */ new Date());
|
|
3751
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { role: "gridcell", className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3752
|
+
"button",
|
|
3753
|
+
{
|
|
3754
|
+
type: "button",
|
|
3755
|
+
disabled: dis,
|
|
3756
|
+
tabIndex: focused ? 0 : -1,
|
|
3757
|
+
"data-day": defaultFormat(date),
|
|
3758
|
+
"aria-label": defaultFormat(date),
|
|
3759
|
+
"aria-selected": sel || void 0,
|
|
3760
|
+
onClick: () => selectDate(date),
|
|
3761
|
+
className: [
|
|
3762
|
+
"w-8 h-8 rounded-md text-xs font-medium transition-colors duration-100",
|
|
3763
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface",
|
|
3764
|
+
"disabled:opacity-30 disabled:cursor-not-allowed",
|
|
3765
|
+
sel ? "bg-accent text-accent-fg" : today ? "bg-surface-raised text-foreground ring-1 ring-inset ring-accent" : outside ? "text-foreground-muted hover:bg-surface-raised" : "text-foreground hover:bg-surface-raised"
|
|
3766
|
+
].join(" "),
|
|
3767
|
+
children: date.getDate()
|
|
3768
|
+
}
|
|
3769
|
+
) }, defaultFormat(date));
|
|
3770
|
+
}) }, ri)) })
|
|
3771
|
+
]
|
|
3772
|
+
}
|
|
3773
|
+
),
|
|
3774
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between gap-2 border-t border-border pt-2", children: [
|
|
3775
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3776
|
+
"button",
|
|
3777
|
+
{
|
|
3778
|
+
type: "button",
|
|
3779
|
+
onClick: () => selectDate(/* @__PURE__ */ new Date()),
|
|
3780
|
+
className: "text-xs text-accent hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-sm px-1",
|
|
3781
|
+
children: "Today"
|
|
3782
|
+
}
|
|
3783
|
+
),
|
|
3784
|
+
clearable && value && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3785
|
+
"button",
|
|
3786
|
+
{
|
|
3787
|
+
type: "button",
|
|
3788
|
+
onClick: () => {
|
|
3789
|
+
onChange?.(null);
|
|
3790
|
+
setOpen(false);
|
|
3791
|
+
},
|
|
3792
|
+
className: "text-xs text-foreground-secondary hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-sm px-1",
|
|
3793
|
+
children: "Clear"
|
|
3794
|
+
}
|
|
3795
|
+
)
|
|
3796
|
+
] })
|
|
3797
|
+
]
|
|
3798
|
+
}
|
|
3799
|
+
) })
|
|
3800
|
+
] })
|
|
3722
3801
|
] }),
|
|
3723
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-
|
|
3802
|
+
hasError && /* @__PURE__ */ jsxRuntime.jsx("div", { id: errorId, className: "text-xs text-status-error ml-1", children: errorMessage })
|
|
3724
3803
|
] });
|
|
3725
3804
|
}
|
|
3726
|
-
function
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
upperLimit = (/* @__PURE__ */ new Date()).getFullYear(),
|
|
3731
|
-
errorMessage,
|
|
3732
|
-
label,
|
|
3733
|
-
layout,
|
|
3734
|
-
style = {}
|
|
3735
|
-
}) {
|
|
3736
|
-
const pickerRef = React8.useRef(null);
|
|
3737
|
-
const calendarRef = React8.useRef(null);
|
|
3738
|
-
const valueRefs = React8.useRef([]);
|
|
3739
|
-
const [isExpanded, setExpanded] = React8.useState(false);
|
|
3740
|
-
const [isCloseToBottom, setCloseToBottom] = React8.useState(false);
|
|
3741
|
-
const innerValues = React8.useMemo(() => {
|
|
3742
|
-
const vals = [];
|
|
3743
|
-
for (let i = lowerLimit; i <= upperLimit; i++) vals.push(i);
|
|
3744
|
-
return vals;
|
|
3745
|
-
}, [lowerLimit, upperLimit]);
|
|
3746
|
-
React8.useEffect(() => {
|
|
3747
|
-
const clickAway = (e) => {
|
|
3748
|
-
if (pickerRef.current && !pickerRef.current.contains(e.target) && calendarRef.current && !calendarRef.current.contains(e.target)) setExpanded(false);
|
|
3749
|
-
};
|
|
3750
|
-
document.addEventListener("mousedown", clickAway);
|
|
3751
|
-
return () => document.removeEventListener("mousedown", clickAway);
|
|
3752
|
-
}, []);
|
|
3753
|
-
React8.useEffect(() => {
|
|
3754
|
-
const bbox = pickerRef.current?.getBoundingClientRect();
|
|
3755
|
-
if (bbox && bbox.y > window.innerHeight - 220) setCloseToBottom(true);
|
|
3756
|
-
else setCloseToBottom(false);
|
|
3757
|
-
}, []);
|
|
3758
|
-
React8.useEffect(() => {
|
|
3759
|
-
if (!isExpanded) return;
|
|
3760
|
-
const t = setTimeout(() => {
|
|
3761
|
-
const node = valueRefs.current.find((n) => n.value === value);
|
|
3762
|
-
node?.ref.scrollIntoView({ block: "end", inline: "nearest", behavior: "smooth" });
|
|
3763
|
-
}, 150);
|
|
3764
|
-
return () => clearTimeout(t);
|
|
3765
|
-
}, [isExpanded, value]);
|
|
3766
|
-
const navigate = (delta) => {
|
|
3767
|
-
const next = value + delta;
|
|
3768
|
-
if (next < lowerLimit || next > upperLimit) return;
|
|
3769
|
-
onChange({ target: { value: next } });
|
|
3770
|
-
const node = valueRefs.current.find((n) => n.value === next);
|
|
3771
|
-
node?.ref.scrollIntoView({ block: "end", inline: "nearest", behavior: "smooth" });
|
|
3772
|
-
};
|
|
3773
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
|
|
3774
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex relative ${layout === "vertical" ? "flex-col" : "flex-row items-center gap-2"}`, children: [
|
|
3775
|
-
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-md font-bold ml-1 max-content text-prussian-blue dark:text-white", children: label }),
|
|
3776
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3777
|
-
"div",
|
|
3778
|
-
{
|
|
3779
|
-
style,
|
|
3780
|
-
ref: pickerRef,
|
|
3781
|
-
className: "flex items-center justify-between relative h-9 bg-white rounded-lg p-2 cursor-pointer",
|
|
3782
|
-
children: [
|
|
3783
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3784
|
-
"div",
|
|
3785
|
-
{
|
|
3786
|
-
onClick: () => setExpanded((p) => !p),
|
|
3787
|
-
className: `h-7 ${!style.width ? "min-w-[240px]" : ""} focus:outline-none text-prussian-blue cursor-pointer flex items-center gap-1`,
|
|
3788
|
-
children: innerValues.includes(value) ? value : "N/A"
|
|
3789
|
-
}
|
|
3790
|
-
),
|
|
3791
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => setExpanded((p) => !p), className: `transition-all duration-300 ml-2 ${isExpanded ? "rotate-180" : "rotate-0 w-4 h-4"}`, children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, {}) })
|
|
3792
|
-
]
|
|
3793
|
-
}
|
|
3794
|
-
),
|
|
3795
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3796
|
-
"div",
|
|
3797
|
-
{
|
|
3798
|
-
style: { width: style.width },
|
|
3799
|
-
ref: calendarRef,
|
|
3800
|
-
className: `${!style.width ? "w-[280px]" : ""} bg-ice absolute z-10 ${isCloseToBottom ? "bottom-[40px]" : "top-10"} rounded-lg shadow-md transition-all duration-150 right-0 overflow-hidden ${isExpanded ? "h-max scale-100" : "scale-0 pointer-events-none"}`,
|
|
3801
|
-
children: [
|
|
3802
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => navigate(-1), className: "flex items-center justify-center rotate-180 transition-all duration-300 hover:bg-ice-dark cursor-pointer rounded-br-lg rounded-bl-lg", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, {}) }),
|
|
3803
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 overflow-hidden", children: innerValues.map((val) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3804
|
-
"div",
|
|
3805
|
-
{
|
|
3806
|
-
ref: (ref) => {
|
|
3807
|
-
if (!valueRefs.current.find((n) => n.value === val) && ref)
|
|
3808
|
-
valueRefs.current.push({ value: val, ref });
|
|
3809
|
-
},
|
|
3810
|
-
className: "font-bold text-center text-lg",
|
|
3811
|
-
children: val
|
|
3812
|
-
},
|
|
3813
|
-
val
|
|
3814
|
-
)) }),
|
|
3815
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => navigate(1), className: "flex items-center justify-center transition-all hover:bg-ice-dark cursor-pointer rounded-br-lg rounded-bl-lg", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, {}) })
|
|
3816
|
-
]
|
|
3817
|
-
}
|
|
3818
|
-
)
|
|
3819
|
-
] }),
|
|
3820
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-error dark:text-prussian-blue min-h-0", children: errorMessage })
|
|
3805
|
+
function CalendarIcon() {
|
|
3806
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, className: "w-4 h-4 flex-shrink-0", "aria-hidden": "true", children: [
|
|
3807
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
|
|
3808
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9h18M8 3v4M16 3v4", strokeLinecap: "round" })
|
|
3821
3809
|
] });
|
|
3822
3810
|
}
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3811
|
+
function ChevronLeft() {
|
|
3812
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "w-4 h-4", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 19l-7-7 7-7" }) });
|
|
3813
|
+
}
|
|
3814
|
+
function ChevronRight3() {
|
|
3815
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "w-4 h-4", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) });
|
|
3816
|
+
}
|
|
3827
3817
|
|
|
3828
3818
|
Object.defineProperty(exports, "COLORS", {
|
|
3829
3819
|
enumerable: true,
|
|
@@ -3877,7 +3867,7 @@ exports.SkeletonText = SkeletonText;
|
|
|
3877
3867
|
exports.Switch = Switch;
|
|
3878
3868
|
exports.Table = Table;
|
|
3879
3869
|
exports.Tabs = Tabs;
|
|
3880
|
-
exports.Temporal =
|
|
3870
|
+
exports.Temporal = DatePicker;
|
|
3881
3871
|
exports.TextInput = TextInput;
|
|
3882
3872
|
exports.ThemeProvider = ThemeProvider;
|
|
3883
3873
|
exports.ThemeSwitch = ThemeSwitch;
|