@geomak/ui 3.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 CHANGED
@@ -3176,6 +3176,26 @@ function AutoComplete({
3176
3176
  }
3177
3177
  ) });
3178
3178
  }
3179
+ function flattenVisible(items, expanded, depth = 0, out = []) {
3180
+ for (const node of items) {
3181
+ const isParent2 = !!node.children && node.children.length > 0;
3182
+ out.push({ node, depth, isParent: isParent2 });
3183
+ if (isParent2 && expanded.has(node.key)) {
3184
+ flattenVisible(node.children, expanded, depth + 1, out);
3185
+ }
3186
+ }
3187
+ return out;
3188
+ }
3189
+ function findNodeByKey(items, key) {
3190
+ for (const n of items) {
3191
+ if (n.key === key) return n;
3192
+ if (n.children) {
3193
+ const found = findNodeByKey(n.children, key);
3194
+ if (found) return found;
3195
+ }
3196
+ }
3197
+ return null;
3198
+ }
3179
3199
  function TreeSelect({
3180
3200
  label,
3181
3201
  name,
@@ -3184,106 +3204,231 @@ function TreeSelect({
3184
3204
  disabled,
3185
3205
  layout = "horizontal",
3186
3206
  errorMessage,
3187
- style = {},
3207
+ style,
3188
3208
  htmlFor,
3189
- items = []
3209
+ items = [],
3210
+ placeholder = "Select\u2026",
3211
+ parentsSelectable = true,
3212
+ defaultExpandedKeys = []
3190
3213
  }) {
3214
+ const errorId = React8.useId();
3215
+ const hasError = errorMessage != null;
3191
3216
  const [open, setOpen] = React8.useState(false);
3192
- const [hoveredItem, setHoveredItem] = React8.useState(null);
3193
- const [innerItems, setInnerItems] = React8.useState([]);
3217
+ const [expanded, setExpanded] = React8.useState(() => new Set(defaultExpandedKeys));
3218
+ const [activeIndex, setActiveIndex] = React8.useState(0);
3219
+ const listRef = React8.useRef(null);
3220
+ const visible = React8.useMemo(() => flattenVisible(items, expanded), [items, expanded]);
3194
3221
  React8.useEffect(() => {
3195
- setInnerItems(items);
3196
- }, [items]);
3197
- const selectItem = (key) => {
3222
+ if (!open) return;
3223
+ const selectedIdx = visible.findIndex((v) => v.node.key === value);
3224
+ setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
3225
+ }, [open, visible, value]);
3226
+ const selectedNode = React8.useMemo(
3227
+ () => value != null ? findNodeByKey(items, value) : null,
3228
+ [items, value]
3229
+ );
3230
+ const toggleExpand = (key) => {
3231
+ setExpanded((prev) => {
3232
+ const next = new Set(prev);
3233
+ if (next.has(key)) next.delete(key);
3234
+ else next.add(key);
3235
+ return next;
3236
+ });
3237
+ };
3238
+ const selectKey = (key) => {
3198
3239
  onChange?.({ target: { value: key, id: htmlFor, name } });
3199
3240
  setOpen(false);
3200
3241
  };
3201
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
3202
- /* @__PURE__ */ jsxRuntime.jsxs(
3203
- "div",
3204
- {
3205
- className: `flex ${layout === "vertical" ? "flex-col" : "flex-row items-center gap-2"}`,
3206
- children: [
3207
- label && /* @__PURE__ */ jsxRuntime.jsx(
3208
- "label",
3209
- {
3210
- className: "text-md font-bold ml-1 max-content select-none text-prussian-blue dark:text-white",
3211
- htmlFor,
3212
- children: label
3213
- }
3214
- ),
3215
- /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
3216
- /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
3242
+ const onListKey = (e) => {
3243
+ if (visible.length === 0) return;
3244
+ const cur = visible[activeIndex];
3245
+ if (e.key === "ArrowDown") {
3246
+ e.preventDefault();
3247
+ setActiveIndex((i) => Math.min(i + 1, visible.length - 1));
3248
+ } else if (e.key === "ArrowUp") {
3249
+ e.preventDefault();
3250
+ setActiveIndex((i) => Math.max(i - 1, 0));
3251
+ } else if (e.key === "ArrowRight") {
3252
+ e.preventDefault();
3253
+ if (cur.isParent) {
3254
+ if (!expanded.has(cur.node.key)) toggleExpand(cur.node.key);
3255
+ else setActiveIndex((i) => Math.min(i + 1, visible.length - 1));
3256
+ }
3257
+ } else if (e.key === "ArrowLeft") {
3258
+ e.preventDefault();
3259
+ if (cur.isParent && expanded.has(cur.node.key)) {
3260
+ toggleExpand(cur.node.key);
3261
+ } else if (cur.depth > 0) {
3262
+ for (let i = activeIndex - 1; i >= 0; i--) {
3263
+ if (visible[i].depth < cur.depth) {
3264
+ setActiveIndex(i);
3265
+ break;
3266
+ }
3267
+ }
3268
+ }
3269
+ } else if (e.key === "Enter" || e.key === " ") {
3270
+ e.preventDefault();
3271
+ if (cur.node.disabled) return;
3272
+ if (cur.isParent && !parentsSelectable) {
3273
+ toggleExpand(cur.node.key);
3274
+ } else {
3275
+ selectKey(cur.node.key);
3276
+ }
3277
+ } else if (e.key === "Escape") {
3278
+ e.preventDefault();
3279
+ setOpen(false);
3280
+ }
3281
+ };
3282
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
3283
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex ${layout === "vertical" ? "flex-col gap-1" : "flex-row items-center gap-2"}`, children: [
3284
+ label && /* @__PURE__ */ jsxRuntime.jsx(
3285
+ "label",
3286
+ {
3287
+ className: "text-sm font-medium ml-1 max-content select-none text-foreground",
3288
+ htmlFor,
3289
+ children: label
3290
+ }
3291
+ ),
3292
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
3293
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
3294
+ "button",
3295
+ {
3296
+ id: htmlFor,
3297
+ type: "button",
3298
+ style,
3299
+ role: "combobox",
3300
+ "aria-expanded": open,
3301
+ "aria-haspopup": "listbox",
3302
+ "aria-invalid": hasError || void 0,
3303
+ "aria-describedby": hasError ? errorId : void 0,
3304
+ disabled,
3305
+ className: `flex items-center justify-between h-9 rounded-lg border ${hasError ? "border-status-error" : "border-border"} px-3 cursor-pointer select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${disabled ? "cursor-not-allowed bg-surface-raised text-foreground-muted" : "bg-surface text-foreground"} ${!style?.width ? "min-w-[240px]" : ""}`,
3306
+ children: [
3307
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm truncate text-left", children: selectedNode ? selectedNode.label : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground-muted", children: placeholder }) }),
3308
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: `h-4 w-4 flex-shrink-0 transition-transform duration-200 ${open ? "rotate-180" : ""}`, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) })
3309
+ ]
3310
+ }
3311
+ ) }),
3312
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
3313
+ Popover__namespace.Content,
3314
+ {
3315
+ align: "start",
3316
+ sideOffset: 4,
3317
+ style: { width: style?.width || 280 },
3318
+ className: "bg-surface text-foreground border border-border rounded-lg shadow-md z-50 p-1 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",
3319
+ onOpenAutoFocus: (e) => {
3320
+ e.preventDefault();
3321
+ listRef.current?.focus();
3322
+ },
3323
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3217
3324
  "div",
3218
3325
  {
3219
- id: htmlFor,
3220
- style,
3221
- role: "combobox",
3222
- "aria-expanded": open,
3223
- "aria-haspopup": "listbox",
3224
- className: `flex items-center justify-between relative h-9 rounded-lg p-2 cursor-pointer ${disabled ? "cursor-not-allowed bg-disabled" : "bg-white"}`,
3225
- tabIndex: disabled ? -1 : 0,
3226
- children: [
3227
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `h-7 ${!style?.width ? "min-w-[240px]" : ""} focus:outline-none text-prussian-blue flex items-center gap-1`, children: Array.isArray(value) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3228
- value.slice(0, 1).map((val, id) => /* @__PURE__ */ jsxRuntime.jsx(
3229
- DropdownPill,
3230
- {
3231
- hasSiblings: value.length > 1,
3232
- value: innerItems.find((it) => it.key === val)?.label
3233
- },
3234
- id
3235
- )),
3236
- value.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(DropdownPill, { value: `+${value.length - 1} more` })
3237
- ] }) : value != null ? /* @__PURE__ */ jsxRuntime.jsx(DropdownPill, { value: innerItems.find((it) => it.key === value)?.label }) : null }),
3238
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `transition-transform duration-300 ml-2 ${open ? "rotate-180" : "rotate-0"}`, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: chunk255PCZIW_cjs.colors_default.PALETTE["prussian-blue"], strokeWidth: 2, className: "h-4 w-4", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) }) })
3239
- ]
3240
- }
3241
- ) }),
3242
- /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
3243
- Popover__namespace.Content,
3244
- {
3245
- align: "start",
3246
- sideOffset: 4,
3247
- style: { width: style?.width || 240 },
3248
- className: "bg-ice rounded-lg shadow-md z-50 p-2 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",
3249
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { role: "listbox", className: "max-h-40 overflow-y-auto", children: innerItems.map((item, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
3250
- "div",
3326
+ ref: listRef,
3327
+ role: "tree",
3328
+ tabIndex: -1,
3329
+ "aria-activedescendant": visible[activeIndex] ? `tree-opt-${visible[activeIndex].node.key}` : void 0,
3330
+ onKeyDown: onListKey,
3331
+ className: "max-h-72 overflow-y-auto outline-none",
3332
+ children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-4 text-sm text-foreground-secondary text-center", children: "No items" }) : visible.map((v, idx) => /* @__PURE__ */ jsxRuntime.jsx(
3333
+ TreeNodeRow,
3251
3334
  {
3252
- role: "option",
3253
- "aria-selected": value === item.key,
3254
- "aria-rowindex": idx,
3255
- className: `flex items-center justify-between p-2 hover:bg-prussian-blue hover:text-white transition-all duration-150 text-sm text-prussian-blue rounded-lg cursor-pointer`,
3256
- onClick: () => selectItem(item.key),
3257
- onMouseEnter: () => setHoveredItem(item.key),
3258
- onMouseLeave: () => setHoveredItem(null),
3259
- children: [
3260
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
3261
- item.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { children: item.icon }),
3262
- item.label
3263
- ] }),
3264
- value === item.key && /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
3265
- "path",
3266
- {
3267
- d: "M4 10l4.5 4.5L16 6",
3268
- stroke: hoveredItem === item.key ? "#fff" : chunk255PCZIW_cjs.colors_default.PALETTE["prussian-blue"],
3269
- strokeWidth: "2",
3270
- strokeLinecap: "round",
3271
- strokeLinejoin: "round"
3272
- }
3273
- ) })
3274
- ]
3335
+ node: v.node,
3336
+ depth: v.depth,
3337
+ isParent: v.isParent,
3338
+ isExpanded: expanded.has(v.node.key),
3339
+ isActive: idx === activeIndex,
3340
+ isSelected: value === v.node.key,
3341
+ parentsSelectable,
3342
+ onActivate: () => {
3343
+ if (v.node.disabled) return;
3344
+ if (v.isParent && !parentsSelectable) toggleExpand(v.node.key);
3345
+ else selectKey(v.node.key);
3346
+ },
3347
+ onToggle: () => toggleExpand(v.node.key),
3348
+ onHover: () => setActiveIndex(idx)
3275
3349
  },
3276
- item.key
3277
- )) })
3350
+ v.node.key
3351
+ ))
3278
3352
  }
3279
- ) })
3280
- ] })
3281
- ]
3282
- }
3283
- ),
3284
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-error dark:text-prussian-blue min-h-0", children: errorMessage })
3353
+ )
3354
+ }
3355
+ ) })
3356
+ ] })
3357
+ ] }),
3358
+ hasError && /* @__PURE__ */ jsxRuntime.jsx("div", { id: errorId, className: "text-xs text-status-error ml-1", children: errorMessage })
3285
3359
  ] });
3286
3360
  }
3361
+ function TreeNodeRow({
3362
+ node,
3363
+ depth,
3364
+ isParent: isParent2,
3365
+ isExpanded,
3366
+ isActive,
3367
+ isSelected,
3368
+ parentsSelectable,
3369
+ onActivate,
3370
+ onToggle,
3371
+ onHover
3372
+ }) {
3373
+ const disabled = node.disabled;
3374
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3375
+ "div",
3376
+ {
3377
+ id: `tree-opt-${node.key}`,
3378
+ role: "treeitem",
3379
+ "aria-selected": isSelected,
3380
+ "aria-expanded": isParent2 ? isExpanded : void 0,
3381
+ "aria-disabled": disabled || void 0,
3382
+ "data-active": isActive ? "" : void 0,
3383
+ onMouseEnter: onHover,
3384
+ className: `flex items-center gap-1 rounded-md px-1 py-1.5 select-none cursor-pointer transition-colors duration-100 ${disabled ? "opacity-40 cursor-not-allowed" : isActive ? "bg-accent text-accent-fg" : isSelected ? "bg-surface-raised" : "hover:bg-surface-raised"}`,
3385
+ style: { paddingLeft: depth * 16 + 4 },
3386
+ children: [
3387
+ isParent2 ? /* @__PURE__ */ jsxRuntime.jsx(
3388
+ "button",
3389
+ {
3390
+ type: "button",
3391
+ onClick: (e) => {
3392
+ e.stopPropagation();
3393
+ onToggle();
3394
+ },
3395
+ "aria-label": isExpanded ? "Collapse" : "Expand",
3396
+ tabIndex: -1,
3397
+ className: "w-5 h-5 inline-flex items-center justify-center rounded hover:bg-black/10 focus:outline-none",
3398
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3399
+ "svg",
3400
+ {
3401
+ viewBox: "0 0 24 24",
3402
+ fill: "none",
3403
+ stroke: "currentColor",
3404
+ strokeWidth: 2.5,
3405
+ className: `h-3 w-3 transition-transform duration-150 ${isExpanded ? "rotate-0" : "-rotate-90"}`,
3406
+ "aria-hidden": "true",
3407
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
3408
+ }
3409
+ )
3410
+ }
3411
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-5 h-5 inline-block", "aria-hidden": "true" }),
3412
+ /* @__PURE__ */ jsxRuntime.jsxs(
3413
+ "button",
3414
+ {
3415
+ type: "button",
3416
+ onClick: onActivate,
3417
+ disabled,
3418
+ tabIndex: -1,
3419
+ className: "flex-1 flex items-center gap-2 text-sm text-left focus:outline-none disabled:cursor-not-allowed",
3420
+ children: [
3421
+ node.icon,
3422
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: node.label }),
3423
+ isParent2 && !parentsSelectable && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto text-xs text-foreground-muted", children: "parent" })
3424
+ ]
3425
+ }
3426
+ ),
3427
+ isSelected && /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", className: "ml-1", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 10l4.5 4.5L16 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
3428
+ ]
3429
+ }
3430
+ );
3431
+ }
3287
3432
  function FileInput({
3288
3433
  allowMultiple = false,
3289
3434
  onChange,
@@ -3391,294 +3536,284 @@ function FileInput({
3391
3536
  )
3392
3537
  );
3393
3538
  }
3394
- var MONTHS = {
3395
- 1: "January",
3396
- 2: "February",
3397
- 3: "March",
3398
- 4: "April",
3399
- 5: "May",
3400
- 6: "June",
3401
- 7: "July",
3402
- 8: "August",
3403
- 9: "September",
3404
- 10: "October",
3405
- 11: "November",
3406
- 12: "December"
3407
- };
3408
- var DAYS = { 0: "Sun", 1: "Mon", 2: "Tue", 3: "Wed", 4: "Thu", 5: "Fri", 6: "Sat" };
3409
- function formatDate(date) {
3410
- const fmt = new Intl.DateTimeFormat("en-GB", { year: "numeric", month: "numeric", day: "numeric" });
3411
- const parts = fmt.formatToParts(date);
3412
- const d = parts.find((x) => x.type === "day").value;
3413
- const m = parts.find((x) => x.type === "month").value;
3414
- const y = parts.find((x) => x.type === "year").value;
3415
- return `${y}-${m}-${d}`;
3416
- }
3417
- function getMonthDays(year, month) {
3418
- const days = [];
3419
- for (let i = 1; i <= 31; i++) {
3420
- const d = new Date(year, month - 1, i);
3421
- if (d.getMonth() + 1 > month) break;
3422
- days.push(d);
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() });
3423
3571
  }
3424
- return days;
3572
+ const rows = [];
3573
+ for (let r = 0; r < 6; r++) rows.push(cells.slice(r * 7, r * 7 + 7));
3574
+ return rows;
3425
3575
  }
3426
- var ChevronRight3 = ({ 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: "M9 5l7 7-7 7" }) });
3427
- 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" }) });
3428
- 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" }) });
3429
- function DatePickerBase({
3576
+ function DatePicker({
3430
3577
  value,
3431
3578
  onChange,
3432
- layout,
3433
3579
  label,
3580
+ placeholder = "Select a date\u2026",
3434
3581
  htmlFor,
3435
- name,
3436
- style = {},
3582
+ name: _name,
3583
+ layout = "horizontal",
3584
+ disabled,
3437
3585
  errorMessage,
3438
- disableBefore,
3439
- disableAfter,
3440
- disabled
3586
+ min,
3587
+ max,
3588
+ style,
3589
+ format = defaultFormat,
3590
+ weekStartsOn = 0,
3591
+ clearable = true
3441
3592
  }) {
3442
- const pickerRef = React8.useRef(null);
3443
- const calendarRef = React8.useRef(null);
3444
- const [isExpanded, setExpanded] = React8.useState(false);
3445
- const [isCloseToBottom, setCloseToBottom] = React8.useState(false);
3446
- const [currentYear, setCurrentYear] = React8.useState(value.getFullYear());
3447
- const [currentMonth, setCurrentMonth] = React8.useState(value.getMonth() + 1);
3448
- const toggle = () => {
3449
- if (!disabled) setExpanded((p) => !p);
3450
- };
3451
- const toNextMonth = () => {
3452
- if (currentMonth + 1 > 12) {
3453
- setCurrentMonth(1);
3454
- setCurrentYear((y) => y + 1);
3455
- } else setCurrentMonth((m) => m + 1);
3456
- };
3457
- const toPrevMonth = () => {
3458
- if (currentMonth - 1 === 0) {
3459
- setCurrentMonth(12);
3460
- setCurrentYear((y) => y - 1);
3461
- } else setCurrentMonth((m) => m - 1);
3462
- };
3463
- const isToday = (d) => {
3464
- const t = /* @__PURE__ */ new Date();
3465
- return t.getDate() === d.getDate() && t.getMonth() === d.getMonth() && t.getFullYear() === d.getFullYear();
3466
- };
3467
- const isSelected = (d) => value.getDate() === d.getDate() && value.getMonth() === d.getMonth() && value.getFullYear() === d.getFullYear();
3468
- const isDateDisabled = (d) => {
3469
- if (disableBefore && d.getTime() < new Date(disableBefore).getTime()) return true;
3470
- 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;
3471
3618
  return false;
3472
3619
  };
3473
- const onDateClick = (d) => {
3474
- const next = new Date(formatDate(d));
3475
- onChange({ target: { value: next, id: htmlFor, name } });
3476
- setExpanded(false);
3477
- setCurrentYear(d.getFullYear());
3478
- setCurrentMonth(d.getMonth() + 1);
3620
+ const selectDate = (d) => {
3621
+ if (isDisabled(d)) return;
3622
+ onChange?.(d);
3623
+ setOpen(false);
3479
3624
  };
3480
- const renderCalendar = () => {
3481
- const days = getMonthDays(currentYear, currentMonth);
3482
- const firstDay = days[0].getDay();
3483
- const cols = [[], [], [], [], [], [], []];
3484
- days.forEach((d) => cols[d.getDay()].push(d));
3485
- let ordered = [...cols];
3486
- if (firstDay > 0) {
3487
- ordered = [...ordered.splice(firstDay), ...ordered];
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);
3488
3667
  }
3489
- return ordered;
3490
3668
  };
3491
- React8.useEffect(() => {
3492
- const clickAway = (e) => {
3493
- if (pickerRef.current && !pickerRef.current.contains(e.target) && calendarRef.current && !calendarRef.current.contains(e.target)) setExpanded(false);
3494
- };
3495
- document.addEventListener("mousedown", clickAway);
3496
- return () => document.removeEventListener("mousedown", clickAway);
3497
- }, []);
3498
- React8.useEffect(() => {
3499
- const bbox = pickerRef.current?.getBoundingClientRect();
3500
- if (bbox && (bbox.y > window.innerHeight - 220 || bbox.bottom > window.innerHeight - 400)) {
3501
- setCloseToBottom(true);
3502
- } else setCloseToBottom(false);
3503
- }, []);
3504
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
3505
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex relative ${layout === "vertical" ? "flex-col" : "flex-row items-center gap-2"}`, children: [
3506
- label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-md font-bold ml-1 max-content text-prussian-blue dark:text-white", children: label }),
3507
- /* @__PURE__ */ jsxRuntime.jsxs(
3508
- "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",
3509
3674
  {
3510
- style,
3511
- ref: pickerRef,
3512
- className: `flex items-center justify-between relative h-9 ${disabled ? "bg-disabled cursor-not-allowed" : "bg-white cursor-pointer"} rounded-lg p-2`,
3513
- children: [
3514
- /* @__PURE__ */ jsxRuntime.jsx(
3515
- "div",
3516
- {
3517
- onClick: toggle,
3518
- 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`,
3519
- children: formatDate(value)
3520
- }
3521
- ),
3522
- /* @__PURE__ */ jsxRuntime.jsx(
3523
- "div",
3524
- {
3525
- onClick: toggle,
3526
- className: `transition-all duration-300 ml-2 ${isExpanded ? "rotate-180" : "rotate-0 w-4 h-4"}`,
3527
- children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, {})
3528
- }
3529
- )
3530
- ]
3675
+ className: "text-sm font-medium ml-1 max-content select-none text-foreground",
3676
+ htmlFor,
3677
+ children: label
3531
3678
  }
3532
3679
  ),
3533
- /* @__PURE__ */ jsxRuntime.jsx(
3534
- "div",
3535
- {
3536
- ref: calendarRef,
3537
- className: `w-[280px] bg-ice absolute ${isCloseToBottom ? "bottom-[40px]" : "top-[60px]"} z-10 rounded-lg shadow-md transition-all duration-150 ${isExpanded ? "h-max scale-100" : "scale-0 pointer-events-none"}`,
3538
- children: isExpanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-3", children: [
3539
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center mx-auto w-max", children: [
3540
- /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => setCurrentYear((y) => y - 1), className: "cursor-pointer rotate-180 p-1 rounded-lg hover:bg-ice-dark transition-all duration-300", children: /* @__PURE__ */ jsxRuntime.jsx(DoubleChevronRight2, {}) }),
3541
- /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: toPrevMonth, className: "cursor-pointer rotate-180 p-1 rounded-lg hover:bg-ice-dark transition-all duration-300", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRight3, {}) }),
3542
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-prussian-blue select-none w-[130px] text-center", children: [
3543
- currentYear,
3544
- " ",
3545
- MONTHS[currentMonth]
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
+ )
3546
3735
  ] }),
3547
- /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: toNextMonth, className: "cursor-pointer p-1 rounded-lg hover:bg-ice-dark transition-all duration-300", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRight3, {}) }),
3548
- /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => setCurrentYear((y) => y + 1), className: "cursor-pointer p-1 rounded-lg hover:bg-ice-dark transition-all duration-300", children: /* @__PURE__ */ jsxRuntime.jsx(DoubleChevronRight2, {}) })
3549
- ] }),
3550
- /* @__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: [
3551
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center font-bold text-sm text-prussian-blue", children: weekDay[0] ? DAYS[weekDay[0].getDay()] : "" }),
3552
- weekDay.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
3553
- "div",
3736
+ /* @__PURE__ */ jsxRuntime.jsxs(
3737
+ "table",
3554
3738
  {
3555
- onClick: () => !isDateDisabled(day) && onDateClick(day),
3556
- className: `cursor-pointer flex items-center justify-center text-prussian-blue rounded-md w-6 h-6 transition-all duration-300
3557
- ${isToday(day) ? "border border-prussian-blue" : ""}
3558
- ${isSelected(day) ? "bg-prussian-blue text-white" : ""}
3559
- ${!isSelected(day) ? "hover:bg-ice-dark" : ""}
3560
- ${isDateDisabled(day) ? "bg-ice-dark text-roman-silver cursor-not-allowed pointer-events-none" : ""}`,
3561
- children: day.getDate()
3562
- },
3563
- day.getDate()
3564
- ))
3565
- ] }, index)) }),
3566
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-2 pr-2 flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
3567
- Button,
3568
- {
3569
- onClick: () => onDateClick(/* @__PURE__ */ new Date()),
3570
- content: "Today",
3571
- style: { width: "max-content", padding: "0px 5px", margin: "0" }
3572
- }
3573
- ) })
3574
- ] })
3575
- }
3576
- )
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
+ ] })
3577
3801
  ] }),
3578
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-error dark:text-prussian-blue min-h-0", children: errorMessage })
3802
+ hasError && /* @__PURE__ */ jsxRuntime.jsx("div", { id: errorId, className: "text-xs text-status-error ml-1", children: errorMessage })
3579
3803
  ] });
3580
3804
  }
3581
- function TemporalPickerBase({
3582
- value,
3583
- onChange,
3584
- lowerLimit = 2e3,
3585
- upperLimit = (/* @__PURE__ */ new Date()).getFullYear(),
3586
- errorMessage,
3587
- label,
3588
- layout,
3589
- style = {}
3590
- }) {
3591
- const pickerRef = React8.useRef(null);
3592
- const calendarRef = React8.useRef(null);
3593
- const valueRefs = React8.useRef([]);
3594
- const [isExpanded, setExpanded] = React8.useState(false);
3595
- const [isCloseToBottom, setCloseToBottom] = React8.useState(false);
3596
- const innerValues = React8.useMemo(() => {
3597
- const vals = [];
3598
- for (let i = lowerLimit; i <= upperLimit; i++) vals.push(i);
3599
- return vals;
3600
- }, [lowerLimit, upperLimit]);
3601
- React8.useEffect(() => {
3602
- const clickAway = (e) => {
3603
- if (pickerRef.current && !pickerRef.current.contains(e.target) && calendarRef.current && !calendarRef.current.contains(e.target)) setExpanded(false);
3604
- };
3605
- document.addEventListener("mousedown", clickAway);
3606
- return () => document.removeEventListener("mousedown", clickAway);
3607
- }, []);
3608
- React8.useEffect(() => {
3609
- const bbox = pickerRef.current?.getBoundingClientRect();
3610
- if (bbox && bbox.y > window.innerHeight - 220) setCloseToBottom(true);
3611
- else setCloseToBottom(false);
3612
- }, []);
3613
- React8.useEffect(() => {
3614
- if (!isExpanded) return;
3615
- const t = setTimeout(() => {
3616
- const node = valueRefs.current.find((n) => n.value === value);
3617
- node?.ref.scrollIntoView({ block: "end", inline: "nearest", behavior: "smooth" });
3618
- }, 150);
3619
- return () => clearTimeout(t);
3620
- }, [isExpanded, value]);
3621
- const navigate = (delta) => {
3622
- const next = value + delta;
3623
- if (next < lowerLimit || next > upperLimit) return;
3624
- onChange({ target: { value: next } });
3625
- const node = valueRefs.current.find((n) => n.value === next);
3626
- node?.ref.scrollIntoView({ block: "end", inline: "nearest", behavior: "smooth" });
3627
- };
3628
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
3629
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex relative ${layout === "vertical" ? "flex-col" : "flex-row items-center gap-2"}`, children: [
3630
- label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-md font-bold ml-1 max-content text-prussian-blue dark:text-white", children: label }),
3631
- /* @__PURE__ */ jsxRuntime.jsxs(
3632
- "div",
3633
- {
3634
- style,
3635
- ref: pickerRef,
3636
- className: "flex items-center justify-between relative h-9 bg-white rounded-lg p-2 cursor-pointer",
3637
- children: [
3638
- /* @__PURE__ */ jsxRuntime.jsx(
3639
- "div",
3640
- {
3641
- onClick: () => setExpanded((p) => !p),
3642
- className: `h-7 ${!style.width ? "min-w-[240px]" : ""} focus:outline-none text-prussian-blue cursor-pointer flex items-center gap-1`,
3643
- children: innerValues.includes(value) ? value : "N/A"
3644
- }
3645
- ),
3646
- /* @__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, {}) })
3647
- ]
3648
- }
3649
- ),
3650
- /* @__PURE__ */ jsxRuntime.jsxs(
3651
- "div",
3652
- {
3653
- style: { width: style.width },
3654
- ref: calendarRef,
3655
- 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"}`,
3656
- children: [
3657
- /* @__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, {}) }),
3658
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 overflow-hidden", children: innerValues.map((val) => /* @__PURE__ */ jsxRuntime.jsx(
3659
- "div",
3660
- {
3661
- ref: (ref) => {
3662
- if (!valueRefs.current.find((n) => n.value === val) && ref)
3663
- valueRefs.current.push({ value: val, ref });
3664
- },
3665
- className: "font-bold text-center text-lg",
3666
- children: val
3667
- },
3668
- val
3669
- )) }),
3670
- /* @__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, {}) })
3671
- ]
3672
- }
3673
- )
3674
- ] }),
3675
- /* @__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" })
3676
3809
  ] });
3677
3810
  }
3678
- var Temporal = {};
3679
- Temporal.DatePicker = DatePickerBase;
3680
- Temporal.TemporalPicker = TemporalPickerBase;
3681
- var DatePicker_default = Temporal;
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
+ }
3682
3817
 
3683
3818
  Object.defineProperty(exports, "COLORS", {
3684
3819
  enumerable: true,
@@ -3732,7 +3867,7 @@ exports.SkeletonText = SkeletonText;
3732
3867
  exports.Switch = Switch;
3733
3868
  exports.Table = Table;
3734
3869
  exports.Tabs = Tabs;
3735
- exports.Temporal = DatePicker_default;
3870
+ exports.Temporal = DatePicker;
3736
3871
  exports.TextInput = TextInput;
3737
3872
  exports.ThemeProvider = ThemeProvider;
3738
3873
  exports.ThemeSwitch = ThemeSwitch;