@wow-two-beta/ui 0.0.13 → 0.0.14

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.
Files changed (56) hide show
  1. package/dist/{chunk-PRRVOVUC.js → chunk-ASXB42MH.js} +524 -4
  2. package/dist/chunk-ASXB42MH.js.map +1 -0
  3. package/dist/{chunk-A4N52LL6.js → chunk-BQTO7XY6.js} +172 -313
  4. package/dist/chunk-BQTO7XY6.js.map +1 -0
  5. package/dist/{chunk-EU6JT5B4.js → chunk-FS6DTWWH.js} +117 -142
  6. package/dist/chunk-FS6DTWWH.js.map +1 -0
  7. package/dist/display/dataTable/DataTable.d.ts +34 -0
  8. package/dist/display/dataTable/DataTable.d.ts.map +1 -0
  9. package/dist/display/dataTable/index.d.ts +2 -0
  10. package/dist/display/dataTable/index.d.ts.map +1 -0
  11. package/dist/display/index.d.ts +5 -0
  12. package/dist/display/index.d.ts.map +1 -1
  13. package/dist/display/index.js +1 -1
  14. package/dist/display/list/List.d.ts +23 -0
  15. package/dist/display/list/List.d.ts.map +1 -0
  16. package/dist/display/list/List.variants.d.ts +89 -0
  17. package/dist/display/list/List.variants.d.ts.map +1 -0
  18. package/dist/display/list/index.d.ts +2 -0
  19. package/dist/display/list/index.d.ts.map +1 -0
  20. package/dist/display/table/Table.d.ts +35 -0
  21. package/dist/display/table/Table.d.ts.map +1 -0
  22. package/dist/display/table/index.d.ts +2 -0
  23. package/dist/display/table/index.d.ts.map +1 -0
  24. package/dist/display/timeline/Timeline.d.ts +29 -0
  25. package/dist/display/timeline/Timeline.d.ts.map +1 -0
  26. package/dist/display/timeline/index.d.ts +2 -0
  27. package/dist/display/timeline/index.d.ts.map +1 -0
  28. package/dist/display/tree/Tree.d.ts +30 -0
  29. package/dist/display/tree/Tree.d.ts.map +1 -0
  30. package/dist/display/tree/index.d.ts +2 -0
  31. package/dist/display/tree/index.d.ts.map +1 -0
  32. package/dist/forms/MonthGrid.d.ts +29 -0
  33. package/dist/forms/MonthGrid.d.ts.map +1 -0
  34. package/dist/forms/calendar/Calendar.d.ts.map +1 -1
  35. package/dist/forms/index.js +2 -2
  36. package/dist/forms/multiSelect/MultiSelect.d.ts +4 -5
  37. package/dist/forms/multiSelect/MultiSelect.d.ts.map +1 -1
  38. package/dist/forms/rangeCalendar/RangeCalendar.d.ts.map +1 -1
  39. package/dist/forms/select/Select.d.ts +5 -9
  40. package/dist/forms/select/Select.d.ts.map +1 -1
  41. package/dist/index.js +3 -3
  42. package/dist/overlays/OverlayChrome.d.ts +34 -0
  43. package/dist/overlays/OverlayChrome.d.ts.map +1 -0
  44. package/dist/overlays/dialog/Dialog.d.ts +7 -25
  45. package/dist/overlays/dialog/Dialog.d.ts.map +1 -1
  46. package/dist/overlays/dialog/index.d.ts +1 -1
  47. package/dist/overlays/dialog/index.d.ts.map +1 -1
  48. package/dist/overlays/drawer/Drawer.d.ts +7 -21
  49. package/dist/overlays/drawer/Drawer.d.ts.map +1 -1
  50. package/dist/overlays/drawer/index.d.ts +1 -1
  51. package/dist/overlays/drawer/index.d.ts.map +1 -1
  52. package/dist/overlays/index.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-A4N52LL6.js.map +0 -1
  55. package/dist/chunk-EU6JT5B4.js.map +0 -1
  56. package/dist/chunk-PRRVOVUC.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Popover, PopoverTrigger, PopoverContent } from './chunk-EU6JT5B4.js';
1
+ import { PopoverTrigger, Popover, PopoverContent } from './chunk-FS6DTWWH.js';
2
2
  import { useControlled } from './chunk-4P2TFUVW.js';
3
3
  import { useFormControl, FormControlProvider, RovingFocusGroup, useRovingFocusItem, Portal, AnchoredPositioner, DismissableLayer } from './chunk-YMSAS7M7.js';
4
4
  import { useId } from './chunk-KDXJQNB6.js';
@@ -9,8 +9,7 @@ import { cn } from './chunk-KZ4VFY2T.js';
9
9
  import * as React from 'react';
10
10
  import { forwardRef, useRef, useImperativeHandle, useState, Children, isValidElement, cloneElement, useId as useId$1, createContext, useMemo, useCallback, useEffect, useContext } from 'react';
11
11
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
12
- import { Minus, Plus, EyeOff, Eye, Search, X, Check, Upload, ChevronDown, ChevronLeft, ChevronRight, Calendar as Calendar$1, Clock } from 'lucide-react';
13
- import { FocusScope } from '@radix-ui/react-focus-scope';
12
+ import { Minus, Plus, EyeOff, Eye, Search, X, Check, Upload, ChevronDown, Calendar as Calendar$1, Clock, ChevronLeft, ChevronRight } from 'lucide-react';
14
13
 
15
14
  var Label = forwardRef(
16
15
  ({ className, required, htmlFor, id, children, ...props }, ref) => {
@@ -1389,6 +1388,7 @@ function Select({
1389
1388
  defaultOpen = false,
1390
1389
  open: openProp,
1391
1390
  onOpenChange,
1391
+ placement = "bottom",
1392
1392
  children
1393
1393
  }) {
1394
1394
  const [openState, setOpenState] = useControlled({
@@ -1401,7 +1401,6 @@ function Select({
1401
1401
  default: defaultValue ?? "",
1402
1402
  onChange: onValueChange
1403
1403
  });
1404
- const triggerRef = useRef(null);
1405
1404
  const [labels, setLabels] = useState({});
1406
1405
  const registerLabel = useCallback((v, label) => {
1407
1406
  setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
@@ -1418,7 +1417,6 @@ function Select({
1418
1417
  (next) => {
1419
1418
  setValueState(next);
1420
1419
  setOpenState(false);
1421
- requestAnimationFrame(() => triggerRef.current?.focus());
1422
1420
  },
1423
1421
  [setValueState, setOpenState]
1424
1422
  );
@@ -1428,7 +1426,6 @@ function Select({
1428
1426
  setOpen: setOpenState,
1429
1427
  value: valueState,
1430
1428
  onSelect,
1431
- triggerRef,
1432
1429
  labels,
1433
1430
  registerLabel,
1434
1431
  unregisterLabel,
@@ -1449,26 +1446,27 @@ function Select({
1449
1446
  invalid
1450
1447
  ]
1451
1448
  );
1452
- return /* @__PURE__ */ jsx(SelectContext.Provider, { value: ctx, children });
1449
+ return /* @__PURE__ */ jsx(SelectContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
1450
+ Popover,
1451
+ {
1452
+ open: openState,
1453
+ onOpenChange: setOpenState,
1454
+ placement,
1455
+ offset: 6,
1456
+ children
1457
+ }
1458
+ ) });
1453
1459
  }
1454
1460
  var SelectTrigger = forwardRef(
1455
- function SelectTrigger2({ size, state, className, onClick, children, ...rest }, forwardedRef) {
1461
+ function SelectTrigger2({ size, state, className, children, ...rest }, ref) {
1456
1462
  const ctx = useSelectContext();
1457
1463
  const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
1458
- return /* @__PURE__ */ jsxs(
1464
+ return /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
1459
1465
  "button",
1460
1466
  {
1461
- ref: composeRefs(forwardedRef, ctx.triggerRef),
1467
+ ref,
1462
1468
  type: "button",
1463
- "aria-haspopup": "listbox",
1464
- "aria-expanded": ctx.open,
1465
- "data-state": ctx.open ? "open" : "closed",
1466
1469
  disabled: ctx.disabled,
1467
- onClick: (e) => {
1468
- onClick?.(e);
1469
- if (e.defaultPrevented) return;
1470
- ctx.setOpen(!ctx.open);
1471
- },
1472
1470
  className: cn(selectTriggerVariants({ size, state: triggerState }), className),
1473
1471
  ...rest,
1474
1472
  children: [
@@ -1484,7 +1482,7 @@ var SelectTrigger = forwardRef(
1484
1482
  )
1485
1483
  ]
1486
1484
  }
1487
- );
1485
+ ) });
1488
1486
  }
1489
1487
  );
1490
1488
  function SelectValue({ placeholder, children }) {
@@ -1493,35 +1491,18 @@ function SelectValue({ placeholder, children }) {
1493
1491
  const label = ctx.value ? ctx.labels[ctx.value] ?? ctx.value : null;
1494
1492
  return /* @__PURE__ */ jsx("span", { className: cn("truncate", !label && "text-subtle-foreground"), children: label ?? placeholder });
1495
1493
  }
1496
- function SelectContent({
1497
- className,
1498
- placement = "bottom",
1499
- offset = 6,
1500
- children
1501
- }) {
1494
+ function SelectContent({ className, children }) {
1502
1495
  const ctx = useSelectContext();
1503
- if (!ctx.open) return null;
1504
- return /* @__PURE__ */ jsxs(Portal, { children: [
1505
- /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
1506
- DismissableLayer,
1496
+ return /* @__PURE__ */ jsxs(PopoverContent, { bare: true, children: [
1497
+ /* @__PURE__ */ jsx(
1498
+ Listbox,
1507
1499
  {
1508
- onEscape: () => ctx.setOpen(false),
1509
- onOutsidePointerDown: (e) => {
1510
- if (ctx.triggerRef.current?.contains(e.target)) return;
1511
- ctx.setOpen(false);
1512
- },
1513
- children: /* @__PURE__ */ jsx(
1514
- Listbox,
1515
- {
1516
- value: ctx.value,
1517
- onValueChange: (v) => ctx.onSelect(v),
1518
- className: cn("min-w-[var(--radix-anchor-width)]", className),
1519
- style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
1520
- children
1521
- }
1522
- )
1500
+ value: ctx.value,
1501
+ onValueChange: (v) => ctx.onSelect(v),
1502
+ className: cn("min-w-[var(--anchor-width)]", className),
1503
+ children
1523
1504
  }
1524
- ) }) }),
1505
+ ),
1525
1506
  ctx.name && /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: ctx.value })
1526
1507
  ] });
1527
1508
  }
@@ -1556,6 +1537,7 @@ function MultiSelect({
1556
1537
  defaultOpen = false,
1557
1538
  open: openProp,
1558
1539
  onOpenChange,
1540
+ placement = "bottom",
1559
1541
  children
1560
1542
  }) {
1561
1543
  const [openState, setOpenState] = useControlled({
@@ -1568,7 +1550,6 @@ function MultiSelect({
1568
1550
  default: defaultValue ?? [],
1569
1551
  onChange: onValueChange
1570
1552
  });
1571
- const triggerRef = useRef(null);
1572
1553
  const [labels, setLabels] = useState({});
1573
1554
  const registerLabel = useCallback((v, label) => {
1574
1555
  setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
@@ -1587,7 +1568,6 @@ function MultiSelect({
1587
1568
  setOpen: setOpenState,
1588
1569
  values: valuesState,
1589
1570
  setValues: setValuesState,
1590
- triggerRef,
1591
1571
  labels,
1592
1572
  registerLabel,
1593
1573
  unregisterLabel,
@@ -1608,26 +1588,27 @@ function MultiSelect({
1608
1588
  invalid
1609
1589
  ]
1610
1590
  );
1611
- return /* @__PURE__ */ jsx(MultiSelectContext.Provider, { value: ctx, children });
1591
+ return /* @__PURE__ */ jsx(MultiSelectContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
1592
+ Popover,
1593
+ {
1594
+ open: openState,
1595
+ onOpenChange: setOpenState,
1596
+ placement,
1597
+ offset: 6,
1598
+ children
1599
+ }
1600
+ ) });
1612
1601
  }
1613
1602
  var MultiSelectTrigger = forwardRef(
1614
- function MultiSelectTrigger2({ size, state, className, onClick, onKeyDown, children, ...rest }, forwardedRef) {
1603
+ function MultiSelectTrigger2({ size, state, className, onKeyDown, children, ...rest }, ref) {
1615
1604
  const ctx = useMultiSelectContext();
1616
1605
  const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
1617
- return /* @__PURE__ */ jsxs(
1606
+ return /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
1618
1607
  "button",
1619
1608
  {
1620
- ref: composeRefs(forwardedRef, ctx.triggerRef),
1609
+ ref,
1621
1610
  type: "button",
1622
- "aria-haspopup": "listbox",
1623
- "aria-expanded": ctx.open,
1624
- "data-state": ctx.open ? "open" : "closed",
1625
1611
  disabled: ctx.disabled,
1626
- onClick: (e) => {
1627
- onClick?.(e);
1628
- if (e.defaultPrevented) return;
1629
- ctx.setOpen(!ctx.open);
1630
- },
1631
1612
  onKeyDown: (e) => {
1632
1613
  onKeyDown?.(e);
1633
1614
  if (e.defaultPrevented) return;
@@ -1654,7 +1635,7 @@ var MultiSelectTrigger = forwardRef(
1654
1635
  )
1655
1636
  ]
1656
1637
  }
1657
- );
1638
+ ) });
1658
1639
  }
1659
1640
  );
1660
1641
  function MultiSelectTags({ placeholder }) {
@@ -1688,39 +1669,19 @@ function MultiSelectTags({ placeholder }) {
1688
1669
  v
1689
1670
  )) });
1690
1671
  }
1691
- function MultiSelectContent({
1692
- className,
1693
- placement = "bottom",
1694
- offset = 6,
1695
- children
1696
- }) {
1672
+ function MultiSelectContent({ className, children }) {
1697
1673
  const ctx = useMultiSelectContext();
1698
- if (!ctx.open) return null;
1699
- return /* @__PURE__ */ jsxs(Portal, { children: [
1700
- /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
1701
- DismissableLayer,
1674
+ return /* @__PURE__ */ jsxs(PopoverContent, { bare: true, children: [
1675
+ /* @__PURE__ */ jsx(
1676
+ Listbox,
1702
1677
  {
1703
- onEscape: () => {
1704
- ctx.setOpen(false);
1705
- requestAnimationFrame(() => ctx.triggerRef.current?.focus());
1706
- },
1707
- onOutsidePointerDown: (e) => {
1708
- if (ctx.triggerRef.current?.contains(e.target)) return;
1709
- ctx.setOpen(false);
1710
- },
1711
- children: /* @__PURE__ */ jsx(
1712
- Listbox,
1713
- {
1714
- multiple: true,
1715
- value: ctx.values,
1716
- onValueChange: (v) => ctx.setValues(v),
1717
- className: cn(className),
1718
- style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
1719
- children
1720
- }
1721
- )
1678
+ multiple: true,
1679
+ value: ctx.values,
1680
+ onValueChange: (v) => ctx.setValues(v),
1681
+ className: cn("min-w-[var(--anchor-width)]", className),
1682
+ children
1722
1683
  }
1723
- ) }) }),
1684
+ ),
1724
1685
  ctx.name && ctx.values.map((v) => /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: v }, v))
1725
1686
  ] });
1726
1687
  }
@@ -2130,29 +2091,17 @@ function isInRange(d, start, end) {
2130
2091
  const e = startOfDay(end).getTime();
2131
2092
  return t >= Math.min(s, e) && t <= Math.max(s, e);
2132
2093
  }
2133
- var Calendar = forwardRef(function Calendar2({
2134
- value,
2135
- defaultValue,
2136
- onChange,
2137
- defaultMonth,
2138
- min,
2139
- max,
2140
- isDisabled,
2094
+ function MonthGrid({
2095
+ viewMonth,
2096
+ onViewMonthChange,
2097
+ focusedDate,
2098
+ onFocusedDateChange,
2099
+ isDayDisabled,
2100
+ onDayActivate,
2101
+ dayProps,
2141
2102
  "aria-label": ariaLabel = "Calendar",
2142
- className,
2143
- ...rest
2144
- }, ref) {
2145
- const [selected, setSelected] = useControlled({
2146
- controlled: value,
2147
- default: defaultValue ?? null,
2148
- onChange
2149
- });
2150
- const [viewMonth, setViewMonth] = useState(
2151
- () => startOfMonth(defaultMonth ?? selected ?? /* @__PURE__ */ new Date())
2152
- );
2153
- const [focusedDate, setFocusedDate] = useState(
2154
- () => selected ?? /* @__PURE__ */ new Date()
2155
- );
2103
+ className
2104
+ }) {
2156
2105
  const gridRef = useRef(null);
2157
2106
  useEffect(() => {
2158
2107
  const cell = gridRef.current?.querySelector(
@@ -2163,14 +2112,14 @@ var Calendar = forwardRef(function Calendar2({
2163
2112
  const moveFocus = useCallback(
2164
2113
  (next) => {
2165
2114
  if (next.getMonth() !== viewMonth.getMonth() || next.getFullYear() !== viewMonth.getFullYear()) {
2166
- setViewMonth(startOfMonth(next));
2115
+ onViewMonthChange(startOfMonth(next));
2167
2116
  }
2168
- setFocusedDate(next);
2117
+ onFocusedDateChange(next);
2169
2118
  },
2170
- [viewMonth]
2119
+ [viewMonth, onViewMonthChange, onFocusedDateChange]
2171
2120
  );
2172
2121
  const onCellKeyDown = useCallback(
2173
- (e, date) => {
2122
+ (e, date, outOfMonth) => {
2174
2123
  switch (e.key) {
2175
2124
  case "ArrowRight":
2176
2125
  e.preventDefault();
@@ -2207,26 +2156,22 @@ var Calendar = forwardRef(function Calendar2({
2207
2156
  case "Enter":
2208
2157
  case " ":
2209
2158
  e.preventDefault();
2210
- if (!isDateDisabled(date, { min, max, isDisabled })) {
2211
- setSelected(date);
2212
- }
2159
+ if (!isDayDisabled?.(date)) onDayActivate?.(date, { outOfMonth });
2213
2160
  break;
2214
2161
  }
2215
2162
  },
2216
- [moveFocus, setSelected, min, max, isDisabled]
2163
+ [moveFocus, onDayActivate, isDayDisabled]
2217
2164
  );
2218
2165
  const cells = buildMonthGrid(viewMonth.getFullYear(), viewMonth.getMonth());
2219
2166
  return /* @__PURE__ */ jsxs(
2220
2167
  "div",
2221
2168
  {
2222
- ref,
2223
2169
  role: "application",
2224
2170
  "aria-label": ariaLabel,
2225
2171
  className: cn(
2226
2172
  "inline-flex flex-col gap-2 rounded-md border border-border bg-popover p-3 text-popover-foreground",
2227
2173
  className
2228
2174
  ),
2229
- ...rest,
2230
2175
  children: [
2231
2176
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [
2232
2177
  /* @__PURE__ */ jsx(
@@ -2234,7 +2179,7 @@ var Calendar = forwardRef(function Calendar2({
2234
2179
  {
2235
2180
  type: "button",
2236
2181
  "aria-label": "Previous month",
2237
- onClick: () => setViewMonth((m) => addMonths(m, -1)),
2182
+ onClick: () => onViewMonthChange(addMonths(viewMonth, -1)),
2238
2183
  className: "grid h-7 w-7 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2239
2184
  children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
2240
2185
  }
@@ -2249,7 +2194,7 @@ var Calendar = forwardRef(function Calendar2({
2249
2194
  {
2250
2195
  type: "button",
2251
2196
  "aria-label": "Next month",
2252
- onClick: () => setViewMonth((m) => addMonths(m, 1)),
2197
+ onClick: () => onViewMonthChange(addMonths(viewMonth, 1)),
2253
2198
  className: "grid h-7 w-7 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2254
2199
  children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
2255
2200
  }
@@ -2264,18 +2209,17 @@ var Calendar = forwardRef(function Calendar2({
2264
2209
  w
2265
2210
  )) }),
2266
2211
  /* @__PURE__ */ jsx("div", { ref: gridRef, className: "grid grid-cols-7 gap-0 px-1", role: "grid", children: cells.map(({ date, outOfMonth }) => {
2267
- const disabled = isDateDisabled(date, { min, max, isDisabled });
2268
- const isSelectedCell = isSameDay(selected, date);
2212
+ const disabled = isDayDisabled?.(date) ?? false;
2269
2213
  const isFocusedCell = isSameDay(focusedDate, date);
2214
+ const consumerProps = dayProps?.(date, { outOfMonth }) ?? {};
2215
+ const { className: cellClassName, ...consumerRest } = consumerProps;
2270
2216
  return /* @__PURE__ */ jsx(
2271
2217
  "button",
2272
2218
  {
2273
2219
  type: "button",
2274
2220
  role: "gridcell",
2275
2221
  "data-date": date.toDateString(),
2276
- "aria-selected": isSelectedCell,
2277
2222
  "aria-disabled": disabled || void 0,
2278
- "data-selected": isSelectedCell ? "" : void 0,
2279
2223
  "data-today": isToday(date) ? "" : void 0,
2280
2224
  "data-out-of-month": outOfMonth ? "" : void 0,
2281
2225
  "data-disabled": disabled ? "" : void 0,
@@ -2283,19 +2227,19 @@ var Calendar = forwardRef(function Calendar2({
2283
2227
  disabled,
2284
2228
  onClick: () => {
2285
2229
  if (disabled) return;
2286
- setSelected(date);
2287
- setFocusedDate(date);
2288
- if (outOfMonth) setViewMonth(startOfMonth(date));
2230
+ onDayActivate?.(date, { outOfMonth });
2231
+ onFocusedDateChange(date);
2232
+ if (outOfMonth) onViewMonthChange(startOfMonth(date));
2289
2233
  },
2290
- onKeyDown: (e) => onCellKeyDown(e, date),
2234
+ onKeyDown: (e) => onCellKeyDown(e, date, outOfMonth),
2235
+ ...consumerRest,
2291
2236
  className: cn(
2292
- "grid h-9 w-9 place-items-center rounded-sm text-sm transition-colors",
2237
+ "grid h-9 w-9 place-items-center text-sm transition-colors",
2293
2238
  "hover:bg-muted hover:text-foreground",
2294
2239
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2295
2240
  outOfMonth && "text-muted-foreground/60",
2296
- isToday(date) && !isSelectedCell && "border border-border",
2297
- isSelectedCell && "bg-primary text-primary-foreground hover:bg-primary",
2298
- disabled && "pointer-events-none opacity-40"
2241
+ disabled && "pointer-events-none opacity-40",
2242
+ cellClassName
2299
2243
  ),
2300
2244
  children: date.getDate()
2301
2245
  },
@@ -2305,6 +2249,52 @@ var Calendar = forwardRef(function Calendar2({
2305
2249
  ]
2306
2250
  }
2307
2251
  );
2252
+ }
2253
+ var Calendar = forwardRef(function Calendar2({
2254
+ value,
2255
+ defaultValue,
2256
+ onChange,
2257
+ defaultMonth,
2258
+ min,
2259
+ max,
2260
+ isDisabled,
2261
+ "aria-label": ariaLabel = "Calendar",
2262
+ className,
2263
+ ...rest
2264
+ }, ref) {
2265
+ const [selected, setSelected] = useControlled({
2266
+ controlled: value,
2267
+ default: defaultValue ?? null,
2268
+ onChange
2269
+ });
2270
+ const [viewMonth, setViewMonth] = useState(
2271
+ () => startOfMonth(defaultMonth ?? selected ?? /* @__PURE__ */ new Date())
2272
+ );
2273
+ const [focusedDate, setFocusedDate] = useState(() => selected ?? /* @__PURE__ */ new Date());
2274
+ return /* @__PURE__ */ jsx("div", { ref, className: cn(className), ...rest, children: /* @__PURE__ */ jsx(
2275
+ MonthGrid,
2276
+ {
2277
+ viewMonth,
2278
+ onViewMonthChange: setViewMonth,
2279
+ focusedDate,
2280
+ onFocusedDateChange: setFocusedDate,
2281
+ isDayDisabled: (d) => isDateDisabled(d, { min, max, isDisabled }),
2282
+ onDayActivate: (d) => setSelected(d),
2283
+ dayProps: (date) => {
2284
+ const isSelectedCell = isSameDay(selected, date);
2285
+ return {
2286
+ "aria-selected": isSelectedCell,
2287
+ "data-selected": isSelectedCell ? "" : void 0,
2288
+ className: cn(
2289
+ "rounded-sm",
2290
+ isToday(date) && !isSelectedCell && "border border-border",
2291
+ isSelectedCell && "bg-primary text-primary-foreground hover:bg-primary"
2292
+ )
2293
+ };
2294
+ },
2295
+ "aria-label": ariaLabel
2296
+ }
2297
+ ) });
2308
2298
  });
2309
2299
  var DateField = forwardRef(function DateField2({ value, defaultValue, onChange, min, max, size, state, className, id, disabled, required, ...rest }, ref) {
2310
2300
  const ctx = useFormControl();
@@ -2383,190 +2373,59 @@ var RangeCalendar = forwardRef(
2383
2373
  const [viewMonth, setViewMonth] = useState(
2384
2374
  () => startOfMonth(defaultMonth ?? range?.start ?? /* @__PURE__ */ new Date())
2385
2375
  );
2386
- const [focusedDate, setFocusedDate] = useState(
2387
- () => range?.start ?? /* @__PURE__ */ new Date()
2388
- );
2376
+ const [focusedDate, setFocusedDate] = useState(() => range?.start ?? /* @__PURE__ */ new Date());
2389
2377
  const [hoveredDate, setHoveredDate] = useState(null);
2390
2378
  const [pendingStart, setPendingStart] = useState(null);
2391
- const gridRef = useRef(null);
2392
- useEffect(() => {
2393
- const cell = gridRef.current?.querySelector(
2394
- `[data-date="${focusedDate.toDateString()}"]`
2395
- );
2396
- cell?.focus();
2397
- }, [focusedDate]);
2398
- const moveFocus = useCallback(
2399
- (next) => {
2400
- if (next.getMonth() !== viewMonth.getMonth() || next.getFullYear() !== viewMonth.getFullYear()) {
2401
- setViewMonth(startOfMonth(next));
2402
- }
2403
- setFocusedDate(next);
2404
- },
2405
- [viewMonth]
2406
- );
2407
- const onSelectDay = useCallback(
2408
- (date) => {
2409
- if (isDateDisabled(date, { min, max, isDisabled })) return;
2410
- if (!pendingStart) {
2411
- setPendingStart(date);
2412
- setRange({ start: date, end: null });
2413
- return;
2414
- }
2415
- const startTime = startOfDay(pendingStart).getTime();
2416
- const endTime = startOfDay(date).getTime();
2417
- const finalStart = startTime <= endTime ? pendingStart : date;
2418
- const finalEnd = startTime <= endTime ? date : pendingStart;
2419
- setRange({ start: finalStart, end: finalEnd });
2420
- setPendingStart(null);
2421
- },
2422
- [pendingStart, setRange, min, max, isDisabled]
2423
- );
2424
- const onCellKeyDown = useCallback(
2425
- (e, date) => {
2426
- switch (e.key) {
2427
- case "ArrowRight":
2428
- e.preventDefault();
2429
- moveFocus(addDays(date, 1));
2430
- break;
2431
- case "ArrowLeft":
2432
- e.preventDefault();
2433
- moveFocus(addDays(date, -1));
2434
- break;
2435
- case "ArrowDown":
2436
- e.preventDefault();
2437
- moveFocus(addDays(date, 7));
2438
- break;
2439
- case "ArrowUp":
2440
- e.preventDefault();
2441
- moveFocus(addDays(date, -7));
2442
- break;
2443
- case "Home":
2444
- e.preventDefault();
2445
- moveFocus(addDays(date, -date.getDay()));
2446
- break;
2447
- case "End":
2448
- e.preventDefault();
2449
- moveFocus(addDays(date, 6 - date.getDay()));
2450
- break;
2451
- case "PageDown":
2452
- e.preventDefault();
2453
- moveFocus(addMonths(date, e.shiftKey ? 12 : 1));
2454
- break;
2455
- case "PageUp":
2456
- e.preventDefault();
2457
- moveFocus(addMonths(date, e.shiftKey ? -12 : -1));
2458
- break;
2459
- case "Enter":
2460
- case " ":
2461
- e.preventDefault();
2462
- onSelectDay(date);
2463
- break;
2464
- }
2465
- },
2466
- [moveFocus, onSelectDay]
2467
- );
2468
- const cells = buildMonthGrid(viewMonth.getFullYear(), viewMonth.getMonth());
2379
+ const handleActivate = (date) => {
2380
+ if (!pendingStart) {
2381
+ setPendingStart(date);
2382
+ setRange({ start: date, end: null });
2383
+ return;
2384
+ }
2385
+ const startTime = startOfDay(pendingStart).getTime();
2386
+ const endTime = startOfDay(date).getTime();
2387
+ const finalStart = startTime <= endTime ? pendingStart : date;
2388
+ const finalEnd = startTime <= endTime ? date : pendingStart;
2389
+ setRange({ start: finalStart, end: finalEnd });
2390
+ setPendingStart(null);
2391
+ };
2469
2392
  const previewEnd = pendingStart ? hoveredDate : range?.end;
2470
2393
  const isStart = (d) => isSameDay(d, range?.start ?? null) || isSameDay(d, pendingStart);
2471
2394
  const isEnd = (d) => isSameDay(d, range?.end ?? null);
2472
2395
  const inRange = (d) => isInRange(d, pendingStart ?? range?.start, previewEnd ?? null);
2473
- return /* @__PURE__ */ jsxs(
2474
- "div",
2396
+ return /* @__PURE__ */ jsx("div", { ref, className: cn(className), ...rest, children: /* @__PURE__ */ jsx(
2397
+ MonthGrid,
2475
2398
  {
2476
- ref,
2477
- role: "application",
2478
- "aria-label": ariaLabel,
2479
- className: cn(
2480
- "inline-flex flex-col gap-2 rounded-md border border-border bg-popover p-3 text-popover-foreground",
2481
- className
2482
- ),
2483
- ...rest,
2484
- children: [
2485
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [
2486
- /* @__PURE__ */ jsx(
2487
- "button",
2488
- {
2489
- type: "button",
2490
- "aria-label": "Previous month",
2491
- onClick: () => setViewMonth((m) => addMonths(m, -1)),
2492
- className: "grid h-7 w-7 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2493
- children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
2494
- }
2495
- ),
2496
- /* @__PURE__ */ jsxs("div", { className: "text-sm font-medium", "aria-live": "polite", children: [
2497
- MONTHS_LONG[viewMonth.getMonth()],
2498
- " ",
2499
- viewMonth.getFullYear()
2500
- ] }),
2501
- /* @__PURE__ */ jsx(
2502
- "button",
2503
- {
2504
- type: "button",
2505
- "aria-label": "Next month",
2506
- onClick: () => setViewMonth((m) => addMonths(m, 1)),
2507
- className: "grid h-7 w-7 place-items-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2508
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
2509
- }
2399
+ viewMonth,
2400
+ onViewMonthChange: setViewMonth,
2401
+ focusedDate,
2402
+ onFocusedDateChange: setFocusedDate,
2403
+ isDayDisabled: (d) => isDateDisabled(d, { min, max, isDisabled }),
2404
+ onDayActivate: handleActivate,
2405
+ dayProps: (date) => {
2406
+ const startCell = isStart(date);
2407
+ const endCell = isEnd(date);
2408
+ const rangeCell = inRange(date) && !startCell && !endCell;
2409
+ const selected = startCell || endCell;
2410
+ return {
2411
+ "aria-selected": selected,
2412
+ "data-range-start": startCell ? "" : void 0,
2413
+ "data-range-end": endCell ? "" : void 0,
2414
+ "data-in-range": rangeCell ? "" : void 0,
2415
+ onPointerEnter: () => setHoveredDate(date),
2416
+ onPointerLeave: () => setHoveredDate((h) => isSameDay(h, date) ? null : h),
2417
+ className: cn(
2418
+ isToday(date) && !startCell && !endCell && "border border-border rounded-sm",
2419
+ rangeCell && "bg-primary-soft text-primary-soft-foreground",
2420
+ startCell && "bg-primary text-primary-foreground rounded-l-sm",
2421
+ endCell && "bg-primary text-primary-foreground rounded-r-sm",
2422
+ !startCell && !endCell && !rangeCell && "rounded-sm"
2510
2423
  )
2511
- ] }),
2512
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-0 px-1", children: WEEKDAYS_SHORT.map((w) => /* @__PURE__ */ jsx(
2513
- "div",
2514
- {
2515
- className: "grid h-7 w-9 place-items-center text-xs font-medium text-muted-foreground",
2516
- children: w
2517
- },
2518
- w
2519
- )) }),
2520
- /* @__PURE__ */ jsx("div", { ref: gridRef, className: "grid grid-cols-7 gap-0 px-1", role: "grid", children: cells.map(({ date, outOfMonth }) => {
2521
- const disabled = isDateDisabled(date, { min, max, isDisabled });
2522
- const startCell = isStart(date);
2523
- const endCell = isEnd(date);
2524
- const rangeCell = inRange(date) && !startCell && !endCell;
2525
- const isFocusedCell = isSameDay(focusedDate, date);
2526
- return /* @__PURE__ */ jsx(
2527
- "button",
2528
- {
2529
- type: "button",
2530
- role: "gridcell",
2531
- "data-date": date.toDateString(),
2532
- "data-range-start": startCell ? "" : void 0,
2533
- "data-range-end": endCell ? "" : void 0,
2534
- "data-in-range": rangeCell ? "" : void 0,
2535
- "data-today": isToday(date) ? "" : void 0,
2536
- "data-out-of-month": outOfMonth ? "" : void 0,
2537
- "data-disabled": disabled ? "" : void 0,
2538
- "aria-selected": startCell || endCell,
2539
- "aria-disabled": disabled || void 0,
2540
- tabIndex: isFocusedCell ? 0 : -1,
2541
- disabled,
2542
- onPointerEnter: () => setHoveredDate(date),
2543
- onPointerLeave: () => setHoveredDate((h) => isSameDay(h, date) ? null : h),
2544
- onClick: () => {
2545
- onSelectDay(date);
2546
- setFocusedDate(date);
2547
- if (outOfMonth) setViewMonth(startOfMonth(date));
2548
- },
2549
- onKeyDown: (e) => onCellKeyDown(e, date),
2550
- className: cn(
2551
- "grid h-9 w-9 place-items-center text-sm transition-colors",
2552
- "hover:bg-muted hover:text-foreground",
2553
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2554
- outOfMonth && "text-muted-foreground/60",
2555
- isToday(date) && !startCell && !endCell && "border border-border rounded-sm",
2556
- rangeCell && "bg-primary-soft text-primary-soft-foreground",
2557
- startCell && "bg-primary text-primary-foreground rounded-l-sm",
2558
- endCell && "bg-primary text-primary-foreground rounded-r-sm",
2559
- !startCell && !endCell && !rangeCell && "rounded-sm",
2560
- disabled && "pointer-events-none opacity-40"
2561
- ),
2562
- children: date.getDate()
2563
- },
2564
- date.toDateString()
2565
- );
2566
- }) })
2567
- ]
2424
+ };
2425
+ },
2426
+ "aria-label": ariaLabel
2568
2427
  }
2569
- );
2428
+ ) });
2570
2429
  }
2571
2430
  );
2572
2431
  var defaultFormat = (d) => d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
@@ -3868,5 +3727,5 @@ Stepper.Step = StepperStep;
3868
3727
  Stepper.Panel = StepperPanel;
3869
3728
 
3870
3729
  export { Calendar, CharacterCount, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatch, ColorSwatchPicker, ColorWheel, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxSeparator, CurrencyInput, DateField, DatePicker, DateRangePicker, EmailInput, Fieldset, FilePicker, FormErrorMessage, FormField, FormHelperText, InputAddon, InputGroup, Label, LabeledInput, Legend, Listbox, ListboxEmpty, ListboxGroup, ListboxItem, ListboxSeparator, MaskedInput, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTags, MultiSelectTrigger, NumberInput, PasswordInput, PasswordStrength, PercentInput, PinInput, Radio, RadioField, RadioGroup, RangeCalendar, SearchInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Stepper, StepperList, StepperPanel, StepperStep, Switch, SwitchField, TelInput, TextInput, Textarea, TimeField, TimePicker, UrlInput, colorSwatchVariants };
3871
- //# sourceMappingURL=chunk-A4N52LL6.js.map
3872
- //# sourceMappingURL=chunk-A4N52LL6.js.map
3730
+ //# sourceMappingURL=chunk-BQTO7XY6.js.map
3731
+ //# sourceMappingURL=chunk-BQTO7XY6.js.map