@geomak/ui 4.0.0 → 5.0.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/index.cjs +281 -288
- 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 +281 -288
- package/dist/index.js.map +1 -1
- package/dist/styles.css +48 -58
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2837,7 +2837,7 @@ function NumberInput({
|
|
|
2837
2837
|
"div",
|
|
2838
2838
|
{
|
|
2839
2839
|
style,
|
|
2840
|
-
className: `flex items-center rounded-lg border ${hasError ? "border-status-error" : "border-border"} ${disabled ? "bg-surface-raised text-foreground-muted cursor-not-allowed" : "bg-surface text-foreground"} focus-within:ring-2 focus-within:ring-accent transition-colors`,
|
|
2840
|
+
className: `flex items-center rounded-lg border overflow-hidden ${hasError ? "border-status-error" : "border-border"} ${disabled ? "bg-surface-raised text-foreground-muted cursor-not-allowed" : "bg-surface text-foreground"} focus-within:ring-2 focus-within:ring-accent transition-colors`,
|
|
2841
2841
|
children: [
|
|
2842
2842
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2843
2843
|
"input",
|
|
@@ -3057,25 +3057,22 @@ function Switch({
|
|
|
3057
3057
|
uncheckedIcon
|
|
3058
3058
|
}) {
|
|
3059
3059
|
const id = React8.useId();
|
|
3060
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
}
|
|
3077
|
-
) })
|
|
3078
|
-
] });
|
|
3060
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "flex items-center cursor-pointer select-none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3061
|
+
SwitchPrimitive__namespace.Root,
|
|
3062
|
+
{
|
|
3063
|
+
id,
|
|
3064
|
+
checked,
|
|
3065
|
+
onCheckedChange: (c) => onChange?.({ target: { checked: c } }),
|
|
3066
|
+
className: "relative inline-flex h-6 w-14 items-center rounded-full bg-foreground-secondary data-[state=checked]:bg-accent transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",
|
|
3067
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3068
|
+
SwitchPrimitive__namespace.Thumb,
|
|
3069
|
+
{
|
|
3070
|
+
className: "pointer-events-none inline-flex h-8 w-8 items-center justify-center rounded-full bg-background text-foreground shadow transition-transform duration-200 data-[state=checked]:translate-x-[22px] data-[state=unchecked]:translate-x-[-4px]",
|
|
3071
|
+
children: checkedIcon && uncheckedIcon ? checked ? checkedIcon : uncheckedIcon : null
|
|
3072
|
+
}
|
|
3073
|
+
)
|
|
3074
|
+
}
|
|
3075
|
+
) }) });
|
|
3079
3076
|
}
|
|
3080
3077
|
function AutoComplete({
|
|
3081
3078
|
disabled,
|
|
@@ -3218,11 +3215,17 @@ function TreeSelect({
|
|
|
3218
3215
|
const [activeIndex, setActiveIndex] = React8.useState(0);
|
|
3219
3216
|
const listRef = React8.useRef(null);
|
|
3220
3217
|
const visible = React8.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
|
|
3218
|
+
const didSyncOnOpenRef = React8.useRef(false);
|
|
3221
3219
|
React8.useEffect(() => {
|
|
3222
|
-
if (!open)
|
|
3220
|
+
if (!open) {
|
|
3221
|
+
didSyncOnOpenRef.current = false;
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
if (didSyncOnOpenRef.current) return;
|
|
3223
3225
|
const selectedIdx = visible.findIndex((v) => v.node.key === value);
|
|
3224
3226
|
setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
|
|
3225
|
-
|
|
3227
|
+
didSyncOnOpenRef.current = true;
|
|
3228
|
+
}, [open, value]);
|
|
3226
3229
|
const selectedNode = React8.useMemo(
|
|
3227
3230
|
() => value != null ? findNodeByKey(items, value) : null,
|
|
3228
3231
|
[items, value]
|
|
@@ -3536,294 +3539,284 @@ function FileInput({
|
|
|
3536
3539
|
)
|
|
3537
3540
|
);
|
|
3538
3541
|
}
|
|
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
|
-
|
|
3542
|
+
var MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
3543
|
+
var WEEKDAY_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
3544
|
+
function isSameDay(a, b) {
|
|
3545
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
3546
|
+
}
|
|
3547
|
+
function startOfMonth(d) {
|
|
3548
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
3549
|
+
}
|
|
3550
|
+
function addDays(d, n) {
|
|
3551
|
+
const c = new Date(d);
|
|
3552
|
+
c.setDate(c.getDate() + n);
|
|
3553
|
+
return c;
|
|
3554
|
+
}
|
|
3555
|
+
function addMonths(d, n) {
|
|
3556
|
+
const c = new Date(d);
|
|
3557
|
+
c.setMonth(c.getMonth() + n);
|
|
3558
|
+
return c;
|
|
3559
|
+
}
|
|
3560
|
+
function defaultFormat(d) {
|
|
3561
|
+
const y = d.getFullYear().toString().padStart(4, "0");
|
|
3562
|
+
const m = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
3563
|
+
const day = d.getDate().toString().padStart(2, "0");
|
|
3564
|
+
return `${y}-${m}-${day}`;
|
|
3565
|
+
}
|
|
3566
|
+
function buildGrid(viewMonth, weekStartsOn) {
|
|
3567
|
+
const first = startOfMonth(viewMonth);
|
|
3568
|
+
const startOffset = (first.getDay() - weekStartsOn + 7) % 7;
|
|
3569
|
+
const gridStart = addDays(first, -startOffset);
|
|
3570
|
+
const cells = [];
|
|
3571
|
+
for (let i = 0; i < 42; i++) {
|
|
3572
|
+
const d = addDays(gridStart, i);
|
|
3573
|
+
cells.push({ date: d, outside: d.getMonth() !== viewMonth.getMonth() });
|
|
3568
3574
|
}
|
|
3569
|
-
|
|
3575
|
+
const rows = [];
|
|
3576
|
+
for (let r = 0; r < 6; r++) rows.push(cells.slice(r * 7, r * 7 + 7));
|
|
3577
|
+
return rows;
|
|
3570
3578
|
}
|
|
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({
|
|
3579
|
+
function DatePicker({
|
|
3575
3580
|
value,
|
|
3576
3581
|
onChange,
|
|
3577
|
-
layout,
|
|
3578
3582
|
label,
|
|
3583
|
+
placeholder = "Select a date\u2026",
|
|
3579
3584
|
htmlFor,
|
|
3580
|
-
name,
|
|
3581
|
-
|
|
3585
|
+
name: _name,
|
|
3586
|
+
layout = "horizontal",
|
|
3587
|
+
disabled,
|
|
3582
3588
|
errorMessage,
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3589
|
+
min,
|
|
3590
|
+
max,
|
|
3591
|
+
style,
|
|
3592
|
+
format = defaultFormat,
|
|
3593
|
+
weekStartsOn = 0,
|
|
3594
|
+
clearable = true
|
|
3586
3595
|
}) {
|
|
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;
|
|
3596
|
+
const errorId = React8.useId();
|
|
3597
|
+
const hasError = errorMessage != null;
|
|
3598
|
+
const [open, setOpen] = React8.useState(false);
|
|
3599
|
+
const [viewMonth, setViewMonth] = React8.useState(() => startOfMonth(value ?? /* @__PURE__ */ new Date()));
|
|
3600
|
+
const [focusDate, setFocusDate] = React8.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
3601
|
+
const gridRef = React8.useRef(null);
|
|
3602
|
+
React8.useEffect(() => {
|
|
3603
|
+
if (!open) return;
|
|
3604
|
+
const target = value ?? /* @__PURE__ */ new Date();
|
|
3605
|
+
setViewMonth(startOfMonth(target));
|
|
3606
|
+
setFocusDate(target);
|
|
3607
|
+
}, [open, value]);
|
|
3608
|
+
React8.useEffect(() => {
|
|
3609
|
+
if (!open) return;
|
|
3610
|
+
const cell = gridRef.current?.querySelector(`[data-day="${defaultFormat(focusDate)}"]`);
|
|
3611
|
+
cell?.focus();
|
|
3612
|
+
}, [open, focusDate]);
|
|
3613
|
+
const weekdays = React8.useMemo(() => {
|
|
3614
|
+
const ordered = WEEKDAY_SHORT.slice(weekStartsOn).concat(WEEKDAY_SHORT.slice(0, weekStartsOn));
|
|
3615
|
+
return ordered;
|
|
3616
|
+
}, [weekStartsOn]);
|
|
3617
|
+
const grid = React8.useMemo(() => buildGrid(viewMonth, weekStartsOn), [viewMonth, weekStartsOn]);
|
|
3618
|
+
const isDisabled = (d) => {
|
|
3619
|
+
if (min && d < min) return true;
|
|
3620
|
+
if (max && d > max) return true;
|
|
3616
3621
|
return false;
|
|
3617
3622
|
};
|
|
3618
|
-
const
|
|
3619
|
-
|
|
3620
|
-
onChange(
|
|
3621
|
-
|
|
3622
|
-
setCurrentYear(d.getFullYear());
|
|
3623
|
-
setCurrentMonth(d.getMonth() + 1);
|
|
3623
|
+
const selectDate = (d) => {
|
|
3624
|
+
if (isDisabled(d)) return;
|
|
3625
|
+
onChange?.(d);
|
|
3626
|
+
setOpen(false);
|
|
3624
3627
|
};
|
|
3625
|
-
const
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
if (
|
|
3632
|
-
|
|
3628
|
+
const onKey = (e) => {
|
|
3629
|
+
const next = (delta) => {
|
|
3630
|
+
const nd = addDays(focusDate, delta);
|
|
3631
|
+
setFocusDate(nd);
|
|
3632
|
+
if (nd.getMonth() !== viewMonth.getMonth()) setViewMonth(startOfMonth(nd));
|
|
3633
|
+
};
|
|
3634
|
+
if (e.key === "ArrowLeft") {
|
|
3635
|
+
e.preventDefault();
|
|
3636
|
+
next(-1);
|
|
3637
|
+
} else if (e.key === "ArrowRight") {
|
|
3638
|
+
e.preventDefault();
|
|
3639
|
+
next(1);
|
|
3640
|
+
} else if (e.key === "ArrowUp") {
|
|
3641
|
+
e.preventDefault();
|
|
3642
|
+
next(-7);
|
|
3643
|
+
} else if (e.key === "ArrowDown") {
|
|
3644
|
+
e.preventDefault();
|
|
3645
|
+
next(7);
|
|
3646
|
+
} else if (e.key === "PageUp") {
|
|
3647
|
+
e.preventDefault();
|
|
3648
|
+
const nm = addMonths(viewMonth, -1);
|
|
3649
|
+
setViewMonth(nm);
|
|
3650
|
+
setFocusDate((d) => addMonths(d, -1));
|
|
3651
|
+
} else if (e.key === "PageDown") {
|
|
3652
|
+
e.preventDefault();
|
|
3653
|
+
const nm = addMonths(viewMonth, 1);
|
|
3654
|
+
setViewMonth(nm);
|
|
3655
|
+
setFocusDate((d) => addMonths(d, 1));
|
|
3656
|
+
} else if (e.key === "Home") {
|
|
3657
|
+
e.preventDefault();
|
|
3658
|
+
const dow = (focusDate.getDay() - weekStartsOn + 7) % 7;
|
|
3659
|
+
setFocusDate(addDays(focusDate, -dow));
|
|
3660
|
+
} else if (e.key === "End") {
|
|
3661
|
+
e.preventDefault();
|
|
3662
|
+
const dow = (focusDate.getDay() - weekStartsOn + 7) % 7;
|
|
3663
|
+
setFocusDate(addDays(focusDate, 6 - dow));
|
|
3664
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
3665
|
+
e.preventDefault();
|
|
3666
|
+
selectDate(focusDate);
|
|
3667
|
+
} else if (e.key === "Escape") {
|
|
3668
|
+
e.preventDefault();
|
|
3669
|
+
setOpen(false);
|
|
3633
3670
|
}
|
|
3634
|
-
return ordered;
|
|
3635
3671
|
};
|
|
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",
|
|
3672
|
+
const displayValue = value ? format(value) : "";
|
|
3673
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex ${layout === "vertical" ? "flex-col gap-1" : "flex-row items-center gap-2"}`, children: [
|
|
3675
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3676
|
+
"label",
|
|
3654
3677
|
{
|
|
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
|
-
]
|
|
3678
|
+
className: "text-sm font-medium ml-1 max-content select-none text-foreground",
|
|
3679
|
+
htmlFor,
|
|
3680
|
+
children: label
|
|
3676
3681
|
}
|
|
3677
3682
|
),
|
|
3678
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3683
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
|
|
3684
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3685
|
+
"button",
|
|
3686
|
+
{
|
|
3687
|
+
id: htmlFor,
|
|
3688
|
+
type: "button",
|
|
3689
|
+
disabled,
|
|
3690
|
+
style,
|
|
3691
|
+
"aria-invalid": hasError || void 0,
|
|
3692
|
+
"aria-describedby": hasError ? errorId : void 0,
|
|
3693
|
+
"aria-haspopup": "dialog",
|
|
3694
|
+
"aria-expanded": open,
|
|
3695
|
+
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]" : ""}`,
|
|
3696
|
+
children: [
|
|
3697
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-sm truncate ${displayValue ? "" : "text-foreground-muted"}`, children: displayValue || placeholder }),
|
|
3698
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {})
|
|
3699
|
+
]
|
|
3700
|
+
}
|
|
3701
|
+
) }),
|
|
3702
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3703
|
+
Popover__namespace.Content,
|
|
3704
|
+
{
|
|
3705
|
+
align: "start",
|
|
3706
|
+
sideOffset: 4,
|
|
3707
|
+
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",
|
|
3708
|
+
onOpenAutoFocus: (e) => {
|
|
3709
|
+
e.preventDefault();
|
|
3710
|
+
},
|
|
3711
|
+
children: [
|
|
3712
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
3713
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3714
|
+
"button",
|
|
3715
|
+
{
|
|
3716
|
+
type: "button",
|
|
3717
|
+
onClick: () => setViewMonth(addMonths(viewMonth, -1)),
|
|
3718
|
+
"aria-label": "Previous month",
|
|
3719
|
+
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",
|
|
3720
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeft, {})
|
|
3721
|
+
}
|
|
3722
|
+
),
|
|
3723
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-semibold select-none", children: [
|
|
3724
|
+
MONTH_NAMES[viewMonth.getMonth()],
|
|
3725
|
+
" ",
|
|
3726
|
+
viewMonth.getFullYear()
|
|
3727
|
+
] }),
|
|
3728
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3729
|
+
"button",
|
|
3730
|
+
{
|
|
3731
|
+
type: "button",
|
|
3732
|
+
onClick: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
3733
|
+
"aria-label": "Next month",
|
|
3734
|
+
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",
|
|
3735
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRight3, {})
|
|
3736
|
+
}
|
|
3737
|
+
)
|
|
3691
3738
|
] }),
|
|
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",
|
|
3739
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3740
|
+
"table",
|
|
3699
3741
|
{
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3742
|
+
ref: gridRef,
|
|
3743
|
+
role: "grid",
|
|
3744
|
+
"aria-label": `${MONTH_NAMES[viewMonth.getMonth()]} ${viewMonth.getFullYear()}`,
|
|
3745
|
+
onKeyDown: onKey,
|
|
3746
|
+
className: "border-separate border-spacing-0",
|
|
3747
|
+
children: [
|
|
3748
|
+
/* @__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)) }) }),
|
|
3749
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: grid.map((row, ri) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: row.map(({ date, outside }) => {
|
|
3750
|
+
const dis = isDisabled(date);
|
|
3751
|
+
const sel = value ? isSameDay(date, value) : false;
|
|
3752
|
+
const focused = isSameDay(date, focusDate);
|
|
3753
|
+
const today = isSameDay(date, /* @__PURE__ */ new Date());
|
|
3754
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { role: "gridcell", className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3755
|
+
"button",
|
|
3756
|
+
{
|
|
3757
|
+
type: "button",
|
|
3758
|
+
disabled: dis,
|
|
3759
|
+
tabIndex: focused ? 0 : -1,
|
|
3760
|
+
"data-day": defaultFormat(date),
|
|
3761
|
+
"aria-label": defaultFormat(date),
|
|
3762
|
+
"aria-selected": sel || void 0,
|
|
3763
|
+
onClick: () => selectDate(date),
|
|
3764
|
+
className: [
|
|
3765
|
+
"w-8 h-8 rounded-md text-xs font-medium transition-colors duration-100",
|
|
3766
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface",
|
|
3767
|
+
"disabled:opacity-30 disabled:cursor-not-allowed",
|
|
3768
|
+
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"
|
|
3769
|
+
].join(" "),
|
|
3770
|
+
children: date.getDate()
|
|
3771
|
+
}
|
|
3772
|
+
) }, defaultFormat(date));
|
|
3773
|
+
}) }, ri)) })
|
|
3774
|
+
]
|
|
3775
|
+
}
|
|
3776
|
+
),
|
|
3777
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between gap-2 border-t border-border pt-2", children: [
|
|
3778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3779
|
+
"button",
|
|
3780
|
+
{
|
|
3781
|
+
type: "button",
|
|
3782
|
+
onClick: () => selectDate(/* @__PURE__ */ new Date()),
|
|
3783
|
+
className: "text-xs text-accent hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-sm px-1",
|
|
3784
|
+
children: "Today"
|
|
3785
|
+
}
|
|
3786
|
+
),
|
|
3787
|
+
clearable && value && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3788
|
+
"button",
|
|
3789
|
+
{
|
|
3790
|
+
type: "button",
|
|
3791
|
+
onClick: () => {
|
|
3792
|
+
onChange?.(null);
|
|
3793
|
+
setOpen(false);
|
|
3794
|
+
},
|
|
3795
|
+
className: "text-xs text-foreground-secondary hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-sm px-1",
|
|
3796
|
+
children: "Clear"
|
|
3797
|
+
}
|
|
3798
|
+
)
|
|
3799
|
+
] })
|
|
3800
|
+
]
|
|
3801
|
+
}
|
|
3802
|
+
) })
|
|
3803
|
+
] })
|
|
3722
3804
|
] }),
|
|
3723
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-
|
|
3805
|
+
hasError && /* @__PURE__ */ jsxRuntime.jsx("div", { id: errorId, className: "text-xs text-status-error ml-1", children: errorMessage })
|
|
3724
3806
|
] });
|
|
3725
3807
|
}
|
|
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 })
|
|
3808
|
+
function CalendarIcon() {
|
|
3809
|
+
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: [
|
|
3810
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
|
|
3811
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9h18M8 3v4M16 3v4", strokeLinecap: "round" })
|
|
3821
3812
|
] });
|
|
3822
3813
|
}
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3814
|
+
function ChevronLeft() {
|
|
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: "M15 19l-7-7 7-7" }) });
|
|
3816
|
+
}
|
|
3817
|
+
function ChevronRight3() {
|
|
3818
|
+
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" }) });
|
|
3819
|
+
}
|
|
3827
3820
|
|
|
3828
3821
|
Object.defineProperty(exports, "COLORS", {
|
|
3829
3822
|
enumerable: true,
|
|
@@ -3877,7 +3870,7 @@ exports.SkeletonText = SkeletonText;
|
|
|
3877
3870
|
exports.Switch = Switch;
|
|
3878
3871
|
exports.Table = Table;
|
|
3879
3872
|
exports.Tabs = Tabs;
|
|
3880
|
-
exports.Temporal =
|
|
3873
|
+
exports.Temporal = DatePicker;
|
|
3881
3874
|
exports.TextInput = TextInput;
|
|
3882
3875
|
exports.ThemeProvider = ThemeProvider;
|
|
3883
3876
|
exports.ThemeSwitch = ThemeSwitch;
|