@justanarthur/modo-ui 0.0.0-stage → 0.1.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.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE.beui +21 -0
  3. package/LICENSE.fluid-functionalism +21 -0
  4. package/LICENSE.motion-primitives +21 -0
  5. package/LICENSE.sileo +21 -0
  6. package/README.md +608 -2
  7. package/dist/base.css +994 -0
  8. package/dist/blocks/sidebar-app/index.d.ts +34 -0
  9. package/dist/blocks/sidebar-app/index.js +34 -0
  10. package/dist/components/badge/index.d.ts +59 -0
  11. package/dist/components/badge/index.js +18 -0
  12. package/dist/components/button/index.d.ts +59 -0
  13. package/dist/components/button/index.js +16 -0
  14. package/dist/components/card/index.d.ts +141 -0
  15. package/dist/components/card/index.js +44 -0
  16. package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
  17. package/dist/components/inputs/checkbox-group/index.js +23 -0
  18. package/dist/components/inputs/color-picker/index.d.ts +137 -0
  19. package/dist/components/inputs/color-picker/index.js +37 -0
  20. package/dist/components/inputs/combobox/index.d.ts +161 -0
  21. package/dist/components/inputs/combobox/index.js +41 -0
  22. package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
  23. package/dist/components/inputs/date-time/calendar/index.js +20 -0
  24. package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
  25. package/dist/components/inputs/date-time/date-picker/index.js +34 -0
  26. package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
  27. package/dist/components/inputs/date-time/date-range-picker/index.js +33 -0
  28. package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
  29. package/dist/components/inputs/date-time/duration-picker/index.js +33 -0
  30. package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
  31. package/dist/components/inputs/date-time/month-picker/index.js +32 -0
  32. package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
  33. package/dist/components/inputs/date-time/time-picker/index.js +33 -0
  34. package/dist/components/inputs/input/index.d.ts +84 -0
  35. package/dist/components/inputs/input/index.js +20 -0
  36. package/dist/components/inputs/input-copy/index.d.ts +44 -0
  37. package/dist/components/inputs/input-copy/index.js +18 -0
  38. package/dist/components/inputs/input-message/index.d.ts +125 -0
  39. package/dist/components/inputs/input-message/index.js +27 -0
  40. package/dist/components/inputs/radio-group/index.d.ts +58 -0
  41. package/dist/components/inputs/radio-group/index.js +22 -0
  42. package/dist/components/inputs/search/index.d.ts +83 -0
  43. package/dist/components/inputs/search/index.js +28 -0
  44. package/dist/components/inputs/select/index.d.ts +105 -0
  45. package/dist/components/inputs/select/index.js +37 -0
  46. package/dist/components/inputs/slider/index.d.ts +108 -0
  47. package/dist/components/inputs/slider/index.js +16 -0
  48. package/dist/components/inputs/switch/index.d.ts +43 -0
  49. package/dist/components/inputs/switch/index.js +16 -0
  50. package/dist/components/navigation/accordion/index.d.ts +117 -0
  51. package/dist/components/navigation/accordion/index.js +30 -0
  52. package/dist/components/navigation/sidebar/index.d.ts +388 -0
  53. package/dist/components/navigation/sidebar/index.js +101 -0
  54. package/dist/components/navigation/tabs/index.d.ts +70 -0
  55. package/dist/components/navigation/tabs/index.js +25 -0
  56. package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
  57. package/dist/components/navigation/tabs-subtle/index.js +23 -0
  58. package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
  59. package/dist/components/overlays/alert-dialog/index.js +24 -0
  60. package/dist/components/overlays/command/index.d.ts +121 -0
  61. package/dist/components/overlays/command/index.js +39 -0
  62. package/dist/components/overlays/context-menu/index.d.ts +97 -0
  63. package/dist/components/overlays/context-menu/index.js +32 -0
  64. package/dist/components/overlays/dialog/index.d.ts +130 -0
  65. package/dist/components/overlays/dialog/index.js +39 -0
  66. package/dist/components/overlays/dropdown/index.d.ts +222 -0
  67. package/dist/components/overlays/dropdown/index.js +47 -0
  68. package/dist/components/overlays/popover/index.d.ts +87 -0
  69. package/dist/components/overlays/popover/index.js +28 -0
  70. package/dist/components/overlays/preview-card/index.d.ts +75 -0
  71. package/dist/components/overlays/preview-card/index.js +21 -0
  72. package/dist/components/overlays/sheet/index.d.ts +67 -0
  73. package/dist/components/overlays/sheet/index.js +26 -0
  74. package/dist/components/overlays/toast/index.d.ts +107 -0
  75. package/dist/components/overlays/toast/index.js +23 -0
  76. package/dist/components/overlays/tooltip/index.d.ts +75 -0
  77. package/dist/components/overlays/tooltip/index.js +19 -0
  78. package/dist/components/table/index.d.ts +44 -0
  79. package/dist/components/table/index.js +28 -0
  80. package/dist/components/thinking-indicator/index.d.ts +32 -0
  81. package/dist/components/thinking-indicator/index.js +15 -0
  82. package/dist/index.d.ts +3926 -0
  83. package/dist/index.js +513 -0
  84. package/dist/preset.d.ts +104 -0
  85. package/dist/preset.js +124 -0
  86. package/dist/primitives/code/index.d.ts +23 -0
  87. package/dist/primitives/code/index.js +12 -0
  88. package/dist/primitives/craft/index.d.ts +31 -0
  89. package/dist/primitives/craft/index.js +13 -0
  90. package/dist/primitives/fluid-hover/index.d.ts +233 -0
  91. package/dist/primitives/fluid-hover/index.js +27 -0
  92. package/dist/primitives/morph/index.d.ts +127 -0
  93. package/dist/primitives/morph/index.js +21 -0
  94. package/dist/primitives/motion/index.d.ts +115 -0
  95. package/dist/primitives/motion/index.js +20 -0
  96. package/dist/primitives/scroll-area/index.d.ts +41 -0
  97. package/dist/primitives/scroll-area/index.js +13 -0
  98. package/dist/primitives/sizes/index.d.ts +128 -0
  99. package/dist/primitives/sizes/index.js +22 -0
  100. package/dist/primitives/surface/index.d.ts +69 -0
  101. package/dist/primitives/surface/index.js +18 -0
  102. package/dist/shared/components-0f0as45n.js +17 -0
  103. package/dist/shared/components-40j34hdb.js +986 -0
  104. package/dist/shared/components-4hh0gm0v.js +292 -0
  105. package/dist/shared/components-4xxddc44.js +15 -0
  106. package/dist/shared/components-4xxtggzp.js +110 -0
  107. package/dist/shared/components-54nf2x99.js +293 -0
  108. package/dist/shared/components-5pkcfprd.js +232 -0
  109. package/dist/shared/components-5vxtcp88.js +9 -0
  110. package/dist/shared/components-5zry9te1.js +152 -0
  111. package/dist/shared/components-61ckf42z.js +220 -0
  112. package/dist/shared/components-6hzwfmfd.js +58 -0
  113. package/dist/shared/components-6phwsry6.js +361 -0
  114. package/dist/shared/components-6t6nr33r.js +86 -0
  115. package/dist/shared/components-6y1th6k4.js +111 -0
  116. package/dist/shared/components-74c20v2f.js +32 -0
  117. package/dist/shared/components-7cqq1sqy.js +193 -0
  118. package/dist/shared/components-7gv95yfy.js +496 -0
  119. package/dist/shared/components-7nww01w4.js +375 -0
  120. package/dist/shared/components-7zp99w5d.js +62 -0
  121. package/dist/shared/components-8hk9ve3r.js +1200 -0
  122. package/dist/shared/components-8hzbsfbd.js +123 -0
  123. package/dist/shared/components-9p8s8n5q.js +171 -0
  124. package/dist/shared/components-aaq3yk4f.js +304 -0
  125. package/dist/shared/components-bf2d9k02.js +484 -0
  126. package/dist/shared/components-bkvb6nem.js +63 -0
  127. package/dist/shared/components-brnzrp2t.js +262 -0
  128. package/dist/shared/components-csxz9f52.js +42 -0
  129. package/dist/shared/components-de8xsm9y.js +22 -0
  130. package/dist/shared/components-dg0w8g5p.js +26 -0
  131. package/dist/shared/components-dphg9gjr.js +42 -0
  132. package/dist/shared/components-e46kf6cp.js +298 -0
  133. package/dist/shared/components-ed7cmssr.js +105 -0
  134. package/dist/shared/components-ess3ch6w.js +137 -0
  135. package/dist/shared/components-gjfrycb5.js +984 -0
  136. package/dist/shared/components-gndm6am4.js +128 -0
  137. package/dist/shared/components-hjkrv00c.js +191 -0
  138. package/dist/shared/components-hzfp4tjb.js +270 -0
  139. package/dist/shared/components-j65qt1mq.js +719 -0
  140. package/dist/shared/components-jw16snbn.js +19 -0
  141. package/dist/shared/components-jxgznftn.js +146 -0
  142. package/dist/shared/components-kf2ehztc.js +216 -0
  143. package/dist/shared/components-kpbcms10.js +9 -0
  144. package/dist/shared/components-m5br529r.js +141 -0
  145. package/dist/shared/components-nn6xezy2.js +1828 -0
  146. package/dist/shared/components-nnnd2xef.js +9 -0
  147. package/dist/shared/components-p2vmyfe1.js +345 -0
  148. package/dist/shared/components-peg09pzs.js +79 -0
  149. package/dist/shared/components-r22vtgqc.js +45 -0
  150. package/dist/shared/components-r2gke5p6.js +1759 -0
  151. package/dist/shared/components-r43mqnd6.js +160 -0
  152. package/dist/shared/components-r4jt6hgd.js +58 -0
  153. package/dist/shared/components-rc63qsy6.js +159 -0
  154. package/dist/shared/components-s3yfvfkr.js +149 -0
  155. package/dist/shared/components-s5pkbjx1.js +445 -0
  156. package/dist/shared/components-tad5h7ta.js +346 -0
  157. package/dist/shared/components-taxmgbnh.js +120 -0
  158. package/dist/shared/components-tm88ghva.js +215 -0
  159. package/dist/shared/components-v7es8aan.js +144 -0
  160. package/dist/shared/components-vb033rns.js +28 -0
  161. package/dist/shared/components-vc1k7yv2.js +30 -0
  162. package/dist/shared/components-vktws5r6.js +667 -0
  163. package/dist/shared/components-x2xyckd5.js +198 -0
  164. package/dist/shared/components-x3rz4cyn.js +61 -0
  165. package/dist/shared/components-xszag63d.js +141 -0
  166. package/dist/shared/components-y3cqdrgy.js +291 -0
  167. package/dist/shared/components-zvb11ker.js +288 -0
  168. package/dist/shared/components-zx2hr57f.js +124 -0
  169. package/dist/styles.css +1949 -0
  170. package/dist/tailwind.css +219 -0
  171. package/dist/tokens.css +345 -0
  172. package/package.json +102 -3
@@ -0,0 +1,198 @@
1
+ import {
2
+ FluidHoverHighlight
3
+ } from "./components-r22vtgqc.js";
4
+ import {
5
+ useFluidHover,
6
+ useRegisterFluidHoverItem
7
+ } from "./components-e46kf6cp.js";
8
+ import {
9
+ useShape
10
+ } from "./components-7zp99w5d.js";
11
+ import {
12
+ useReduceMotion
13
+ } from "./components-nnnd2xef.js";
14
+ import {
15
+ useSize
16
+ } from "./components-x3rz4cyn.js";
17
+ import {
18
+ cn
19
+ } from "./components-0f0as45n.js";
20
+
21
+ // lib/date-locale.ts
22
+ import { isValid, parse } from "date-fns";
23
+ import { enUS } from "react-day-picker/locale";
24
+ var defaultLocale = enUS;
25
+ function hourCycleOf(locale) {
26
+ return new Intl.DateTimeFormat(locale.code, { hour: "numeric" }).resolvedOptions().hourCycle ?? "h23";
27
+ }
28
+ function parseWith(text, patterns, locale, reference) {
29
+ for (const pattern of patterns) {
30
+ const date = parse(text.trim(), pattern, reference, { locale });
31
+ if (isValid(date) && date.getFullYear() >= 1000)
32
+ return date;
33
+ }
34
+ return null;
35
+ }
36
+ function parseDateText(text, locale, reference = new Date) {
37
+ return parseWith(text, ["P", "PP", "PPP", "PPPP"], locale, reference);
38
+ }
39
+ function parseTimeText(text, locale, reference = new Date) {
40
+ return parseWith(text, ["p", "HH:mm", "H:mm"], locale, reference);
41
+ }
42
+ function parseMonthText(text, locale, reference = new Date) {
43
+ return parseWith(text, ["LLLL y", "LLL y", "MM/y", "M/y", "MM.y"], locale, reference);
44
+ }
45
+ function fieldLabel(locale, field) {
46
+ return new Intl.DisplayNames(locale.code, { type: "dateTimeField" }).of(field) ?? field;
47
+ }
48
+
49
+ // lib/scroll-column.tsx
50
+ import { useEffect, useRef } from "react";
51
+ import { jsx, jsxs } from "react/jsx-runtime";
52
+ function centre(list, item, behavior) {
53
+ const l = list.getBoundingClientRect();
54
+ const i = item.getBoundingClientRect();
55
+ const sx = l.width / list.offsetWidth || 1;
56
+ const sy = l.height / list.offsetHeight || 1;
57
+ list.scrollTo({
58
+ top: list.scrollTop + (i.top - l.top) / sy - (list.clientHeight - item.offsetHeight) / 2,
59
+ left: list.scrollLeft + (i.left - l.left) / sx - (list.clientWidth - item.offsetWidth) / 2,
60
+ behavior
61
+ });
62
+ }
63
+ var dividedColumns = "flex [&>*+*]:border-s [&>*]:border-border";
64
+ var STEP = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 };
65
+ function ScrollColumn({
66
+ label,
67
+ options,
68
+ value,
69
+ onValueChange,
70
+ inView,
71
+ follow = value,
72
+ orientation = "vertical",
73
+ className
74
+ }) {
75
+ const listRef = useRef(null);
76
+ const containerRef = useRef(null);
77
+ const pointerInside = useRef(false);
78
+ const centred = useRef(false);
79
+ const reduceMotion = useReduceMotion();
80
+ const horizontal = orientation === "horizontal";
81
+ const hover = useFluidHover(containerRef, { axis: horizontal ? "x" : "y" });
82
+ const shape = useShape();
83
+ const axis = useRef(horizontal);
84
+ useEffect(() => {
85
+ const list = listRef.current;
86
+ const item = list?.querySelector(`[data-value="${follow}"]`);
87
+ if (!list || !item || pointerInside.current)
88
+ return;
89
+ const glide = centred.current && axis.current === horizontal && !reduceMotion;
90
+ centre(list, item, glide ? "smooth" : "instant");
91
+ centred.current = true;
92
+ axis.current = horizontal;
93
+ }, [follow, horizontal]);
94
+ const followed = useRef(follow);
95
+ followed.current = follow;
96
+ useEffect(() => {
97
+ const list = listRef.current;
98
+ if (!list)
99
+ return;
100
+ const observer = new ResizeObserver(() => {
101
+ const item = list.querySelector(`[data-value="${followed.current}"]`);
102
+ if (item && !pointerInside.current)
103
+ centre(list, item, "instant");
104
+ });
105
+ observer.observe(list);
106
+ return () => observer.disconnect();
107
+ }, []);
108
+ const banded = options.map((o) => inView?.(o.value) ?? false);
109
+ const tabStop = options.some((o) => o.value === value) ? value : follow ?? options[0]?.value;
110
+ const onKeyDown = (e) => {
111
+ const items = [
112
+ ...containerRef.current?.querySelectorAll('[role="option"]:not(:disabled)') ?? []
113
+ ];
114
+ const at = items.indexOf(document.activeElement);
115
+ const next = e.key === "Home" ? 0 : e.key === "End" ? items.length - 1 : STEP[e.key] ? at + (STEP[e.key] ?? 0) : undefined;
116
+ if (next === undefined)
117
+ return;
118
+ e.preventDefault();
119
+ const item = items[Math.max(0, Math.min(items.length - 1, next))];
120
+ item?.focus({ preventScroll: true });
121
+ if (item && listRef.current)
122
+ centre(listRef.current, item, reduceMotion ? "instant" : "smooth");
123
+ };
124
+ return /* @__PURE__ */ jsx("div", {
125
+ ref: listRef,
126
+ role: "listbox",
127
+ "aria-label": label,
128
+ "aria-orientation": orientation,
129
+ onKeyDown,
130
+ onPointerEnter: () => {
131
+ pointerInside.current = true;
132
+ },
133
+ onPointerLeave: () => {
134
+ pointerInside.current = false;
135
+ },
136
+ className: cn("scrollbar-hide [--scroll-fade-size:24px]", horizontal ? "overflow-x-auto overflow-y-hidden scroll-fade-x" : "overflow-y-auto overflow-x-hidden scroll-fade", className),
137
+ children: /* @__PURE__ */ jsxs("div", {
138
+ ref: containerRef,
139
+ onMouseMove: hover.handlers.onMouseMove,
140
+ onMouseEnter: hover.handlers.onMouseEnter,
141
+ onMouseLeave: hover.handlers.onMouseLeave,
142
+ onClick: hover.handlers.onClick,
143
+ className: cn("relative flex p-1", horizontal ? "w-max flex-row" : "flex-col"),
144
+ children: [
145
+ /* @__PURE__ */ jsx(FluidHoverHighlight, {
146
+ hover,
147
+ className: shape.bg
148
+ }),
149
+ options.map((option, index) => /* @__PURE__ */ jsx(ScrollColumnItem, {
150
+ index,
151
+ registerItem: hover.registerItem,
152
+ option,
153
+ selected: option.value === value,
154
+ band: !banded[index] ? undefined : banded[index - 1] ? banded[index + 1] ? "middle" : "end" : banded[index + 1] ? "start" : "single",
155
+ horizontal,
156
+ tabStop: option.value === tabStop,
157
+ onSelect: () => onValueChange(option.value)
158
+ }, option.value))
159
+ ]
160
+ })
161
+ });
162
+ }
163
+ function ScrollColumnItem({
164
+ index,
165
+ registerItem,
166
+ option,
167
+ selected,
168
+ band,
169
+ horizontal,
170
+ tabStop,
171
+ onSelect
172
+ }) {
173
+ const ref = useRef(null);
174
+ useRegisterFluidHoverItem(registerItem, index, ref);
175
+ const shape = useShape();
176
+ const sizeClasses = useSize();
177
+ return /* @__PURE__ */ jsxs("button", {
178
+ ref,
179
+ type: "button",
180
+ role: "option",
181
+ "aria-selected": selected,
182
+ tabIndex: tabStop ? 0 : -1,
183
+ disabled: option.disabled,
184
+ "data-value": option.value,
185
+ "data-fluid-hover-index": index,
186
+ onClick: onSelect,
187
+ className: cn("relative z-[1] flex shrink-0 items-center justify-center px-2 tabular-nums whitespace-nowrap outline-none", "transition-[color,background-color] duration-fast focus-visible:ring-1 focus-visible:ring-focus-ring", "disabled:opacity-50 disabled:pointer-events-none", sizeClasses.segmentItem, sizeClasses.text, shape.item, band && !selected && "bg-accent/20 dark:bg-accent/12", selected && "bg-active", band && band !== "single" && "rounded-none", band === "start" && (horizontal ? "rounded-s-lg" : "rounded-t-lg"), band === "end" && (horizontal ? "rounded-e-lg" : "rounded-b-lg"), selected ? "text-foreground weight-semibold" : band ? "text-foreground" : "text-muted-foreground"),
188
+ children: [
189
+ selected && /* @__PURE__ */ jsx("span", {
190
+ "aria-hidden": true,
191
+ className: "absolute start-1 top-1/2 size-1 -translate-y-1/2 rounded-full bg-current"
192
+ }),
193
+ option.label
194
+ ]
195
+ });
196
+ }
197
+
198
+ export { defaultLocale, hourCycleOf, parseDateText, parseTimeText, parseMonthText, fieldLabel, dividedColumns, ScrollColumn };
@@ -0,0 +1,61 @@
1
+ // lib/size-context.tsx
2
+ import { createContext, useContext } from "react";
3
+ var sizeMap = {
4
+ default: {
5
+ variant: "default",
6
+ control: "h-9",
7
+ controlHeight: 36,
8
+ segmentItem: "h-7",
9
+ segmentPad: "p-1",
10
+ text: "text-body",
11
+ px: "px-3",
12
+ itemPx: "px-2",
13
+ gap: "gap-2",
14
+ icon: 16
15
+ },
16
+ compact: {
17
+ variant: "compact",
18
+ control: "h-7",
19
+ controlHeight: 28,
20
+ segmentItem: "h-6",
21
+ segmentPad: "p-0.5",
22
+ text: "text-body-compact",
23
+ px: "px-2.5",
24
+ itemPx: "px-1.5",
25
+ gap: "gap-1",
26
+ icon: 14
27
+ }
28
+ };
29
+ var typeScale = {
30
+ display: { default: 28, compact: 24 },
31
+ title: { default: 16, compact: 15 },
32
+ subtitle: { default: 14, compact: 13 },
33
+ body: { default: 13, compact: 12 },
34
+ caption: { default: 12, compact: 11 }
35
+ };
36
+ function useTypeScale(override) {
37
+ const variant = useSizeVariant(override);
38
+ return {
39
+ display: typeScale.display[variant],
40
+ title: typeScale.title[variant],
41
+ subtitle: typeScale.subtitle[variant],
42
+ body: typeScale.body[variant],
43
+ caption: typeScale.caption[variant]
44
+ };
45
+ }
46
+ var SizeContext = createContext(null);
47
+ function useSizeVariant(override) {
48
+ const ctx = useContext(SizeContext);
49
+ return override ?? ctx?.size ?? "default";
50
+ }
51
+ function useSize(override) {
52
+ return sizeMap[useSizeVariant(override)];
53
+ }
54
+ function useSizeContext() {
55
+ const ctx = useContext(SizeContext);
56
+ if (!ctx)
57
+ throw new Error("useSizeContext must be used within a SizeProvider");
58
+ return ctx;
59
+ }
60
+
61
+ export { sizeMap, typeScale, useTypeScale, SizeContext, useSizeVariant, useSize, useSizeContext };
@@ -0,0 +1,141 @@
1
+ import {
2
+ calendar_default
3
+ } from "./components-6phwsry6.js";
4
+ import {
5
+ PickerInput,
6
+ PickerShell
7
+ } from "./components-hzfp4tjb.js";
8
+ import {
9
+ defaultLocale,
10
+ parseDateText
11
+ } from "./components-x2xyckd5.js";
12
+ import {
13
+ useControllableState
14
+ } from "./components-dg0w8g5p.js";
15
+
16
+ // components/inputs/date-time/date-range-picker/index.tsx
17
+ import { endOfMonth, format } from "date-fns";
18
+ import { useRef, useState } from "react";
19
+ import { dateMatchModifiers } from "react-day-picker";
20
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
21
+ function DateRangePicker({
22
+ value: valueProp,
23
+ defaultValue = null,
24
+ onValueChange,
25
+ locale = defaultLocale,
26
+ placeholder,
27
+ disabled,
28
+ startMonth,
29
+ endMonth,
30
+ invalid,
31
+ size,
32
+ open: openProp,
33
+ defaultOpen = false,
34
+ onOpenChange,
35
+ dir,
36
+ columnsSide,
37
+ id,
38
+ from: growFrom,
39
+ effect,
40
+ hideSource,
41
+ tier,
42
+ className
43
+ }) {
44
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
45
+ const [open, setOpenState] = useControllableState(openProp, defaultOpen, onOpenChange);
46
+ const [picking, setPicking] = useState(false);
47
+ const fromInput = useRef(null);
48
+ const off = typeof disabled === "boolean" && disabled;
49
+ const days = off ? undefined : disabled;
50
+ const from = value?.from;
51
+ const to = value?.to;
52
+ const setOpen = (next) => {
53
+ setPicking(false);
54
+ setOpenState(next);
55
+ };
56
+ const allowed = (date) => (!startMonth || date >= startMonth) && (!endMonth || date <= endOfMonth(endMonth)) && !(days && dateMatchModifiers(date, days));
57
+ const pick = (day) => {
58
+ if (!picking || !from) {
59
+ setValue({ from: day, to: undefined });
60
+ setPicking(true);
61
+ return;
62
+ }
63
+ setValue(day < from ? { from: day, to: from } : { from, to: day });
64
+ setOpen(false);
65
+ };
66
+ const readEnd = (end) => (text) => {
67
+ if (!text.trim()) {
68
+ setValue(end === "from" ? null : from ? { from, to: undefined } : null);
69
+ return true;
70
+ }
71
+ const date = parseDateText(text, locale, (end === "from" ? from : to) ?? undefined);
72
+ if (!date || !allowed(date))
73
+ return false;
74
+ if (end === "from")
75
+ setValue({ from: date, to: to && to >= date ? to : undefined });
76
+ else if (!from || date < from)
77
+ return false;
78
+ else
79
+ setValue({ from, to: date });
80
+ return true;
81
+ };
82
+ const display = from ? to ? new Intl.DateTimeFormat(locale.code, { dateStyle: "medium" }).formatRange(from, to) : `${format(from, "PP", { locale })} –` : "";
83
+ const header = /* @__PURE__ */ jsxs(Fragment, {
84
+ children: [
85
+ /* @__PURE__ */ jsx(PickerInput, {
86
+ ref: fromInput,
87
+ "aria-label": "Start date",
88
+ placeholder,
89
+ formatted: from ? format(from, "PP", { locale }) : "",
90
+ onText: readEnd("from"),
91
+ onEnter: () => setOpen(false),
92
+ className: "min-w-0 flex-1"
93
+ }),
94
+ /* @__PURE__ */ jsx("span", {
95
+ "aria-hidden": true,
96
+ className: "px-0.5 text-muted-foreground",
97
+ children: "–"
98
+ }),
99
+ /* @__PURE__ */ jsx(PickerInput, {
100
+ "aria-label": "End date",
101
+ formatted: to ? format(to, "PP", { locale }) : "",
102
+ onText: readEnd("to"),
103
+ onEnter: () => setOpen(false),
104
+ className: "min-w-0 flex-1"
105
+ })
106
+ ]
107
+ });
108
+ return /* @__PURE__ */ jsx(PickerShell, {
109
+ open,
110
+ onOpenChange: setOpen,
111
+ size,
112
+ invalid,
113
+ disabled: off,
114
+ icon: "calendar",
115
+ display,
116
+ placeholder,
117
+ header,
118
+ initialFocus: fromInput,
119
+ id,
120
+ dir,
121
+ from: growFrom,
122
+ effect,
123
+ hideSource,
124
+ tier,
125
+ className,
126
+ children: /* @__PURE__ */ jsx(calendar_default, {
127
+ mode: "range",
128
+ locale,
129
+ selected: value ?? undefined,
130
+ onSelect: (_, day) => pick(day),
131
+ disabled: days,
132
+ startMonth,
133
+ endMonth,
134
+ dir,
135
+ columnsSide
136
+ })
137
+ });
138
+ }
139
+ var date_range_picker_default = DateRangePicker;
140
+
141
+ export { DateRangePicker, date_range_picker_default };
@@ -0,0 +1,291 @@
1
+ import {
2
+ SelectionBackgrounds,
3
+ useMergeSplitBlocks,
4
+ useSelectionRuns
5
+ } from "./components-rc63qsy6.js";
6
+ import {
7
+ SizeProvider
8
+ } from "./components-vb033rns.js";
9
+ import {
10
+ FluidHoverHighlight
11
+ } from "./components-r22vtgqc.js";
12
+ import {
13
+ useFluidHover,
14
+ useRegisterFluidHoverItem
15
+ } from "./components-e46kf6cp.js";
16
+ import {
17
+ useShape
18
+ } from "./components-7zp99w5d.js";
19
+ import {
20
+ useControllableState
21
+ } from "./components-dg0w8g5p.js";
22
+ import {
23
+ spring
24
+ } from "./components-vc1k7yv2.js";
25
+ import {
26
+ useSize
27
+ } from "./components-x3rz4cyn.js";
28
+ import {
29
+ cn
30
+ } from "./components-0f0as45n.js";
31
+
32
+ // components/inputs/checkbox-group/index.tsx
33
+ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
34
+ import { AnimatePresence, motion } from "motion/react";
35
+ import {
36
+ createContext,
37
+ forwardRef,
38
+ useCallback,
39
+ useContext,
40
+ useEffect,
41
+ useRef,
42
+ useState
43
+ } from "react";
44
+ import { jsx, jsxs } from "react/jsx-runtime";
45
+ var CheckboxGroupContext = createContext(null);
46
+ function useCheckboxGroup() {
47
+ const ctx = useContext(CheckboxGroupContext);
48
+ if (!ctx)
49
+ throw new Error("useCheckboxGroup must be used within a CheckboxGroup");
50
+ return ctx;
51
+ }
52
+ var CheckboxGroup = forwardRef(({
53
+ children,
54
+ checkedIndices: checkedIndicesProp,
55
+ defaultCheckedIndices,
56
+ onCheckedIndicesChange,
57
+ size,
58
+ className,
59
+ ...props
60
+ }, ref) => {
61
+ const containerRef = useRef(null);
62
+ const [checkedIndices, setCheckedIndices] = useControllableState(checkedIndicesProp, new Set(defaultCheckedIndices), onCheckedIndicesChange);
63
+ const setItemChecked = useCallback((index, checked) => {
64
+ setCheckedIndices((prev) => {
65
+ if (prev.has(index) === checked)
66
+ return prev;
67
+ const next = new Set(prev);
68
+ if (checked)
69
+ next.add(index);
70
+ else
71
+ next.delete(index);
72
+ return next;
73
+ });
74
+ }, [setCheckedIndices]);
75
+ const hover = useFluidHover(containerRef);
76
+ const { activeIndex, setActiveIndex, itemRects, handlers, registerItem } = hover;
77
+ const checkedGroups = useSelectionRuns([...checkedIndices]);
78
+ const [focusedIndex, setFocusedIndex] = useState(null);
79
+ const focusRect = focusedIndex !== null ? itemRects[focusedIndex] : null;
80
+ const shape = useShape();
81
+ const blocks = useMergeSplitBlocks(checkedGroups, itemRects, shape.mergedRadius);
82
+ const group = /* @__PURE__ */ jsx(CheckboxGroupContext.Provider, {
83
+ value: { registerItem, activeIndex, checkedIndices, setItemChecked },
84
+ children: /* @__PURE__ */ jsxs("div", {
85
+ ref: (node) => {
86
+ containerRef.current = node;
87
+ if (typeof ref === "function")
88
+ ref(node);
89
+ else if (ref)
90
+ ref.current = node;
91
+ },
92
+ onMouseEnter: handlers.onMouseEnter,
93
+ onMouseMove: handlers.onMouseMove,
94
+ onMouseLeave: handlers.onMouseLeave,
95
+ onClick: handlers.onClick,
96
+ onFocus: (e) => {
97
+ const indexAttr = e.target.closest("[data-fluid-hover-index]")?.getAttribute("data-fluid-hover-index");
98
+ if (indexAttr != null) {
99
+ const idx = Number(indexAttr);
100
+ setActiveIndex(idx);
101
+ setFocusedIndex(e.target.matches(":focus-visible") ? idx : null);
102
+ }
103
+ },
104
+ onBlur: (e) => {
105
+ if (containerRef.current?.contains(e.relatedTarget))
106
+ return;
107
+ setFocusedIndex(null);
108
+ setActiveIndex(null);
109
+ },
110
+ onKeyDown: (e) => {
111
+ const items = Array.from(containerRef.current?.querySelectorAll("[data-fluid-hover-index]") ?? []);
112
+ const currentIdx = items.indexOf(e.target);
113
+ if (currentIdx === -1)
114
+ return;
115
+ if (["ArrowDown", "ArrowUp"].includes(e.key)) {
116
+ e.preventDefault();
117
+ const next = e.key === "ArrowDown" ? (currentIdx + 1) % items.length : (currentIdx - 1 + items.length) % items.length;
118
+ items[next]?.focus();
119
+ } else if (e.key === "Home") {
120
+ e.preventDefault();
121
+ items[0]?.focus();
122
+ } else if (e.key === "End") {
123
+ e.preventDefault();
124
+ items[items.length - 1]?.focus();
125
+ }
126
+ },
127
+ role: "group",
128
+ className: cn("relative flex flex-col w-72 max-w-full select-none", className),
129
+ ...props,
130
+ children: [
131
+ /* @__PURE__ */ jsx(SelectionBackgrounds, {
132
+ blocks
133
+ }),
134
+ /* @__PURE__ */ jsx(FluidHoverHighlight, {
135
+ hover,
136
+ className: shape.bg
137
+ }),
138
+ /* @__PURE__ */ jsx(AnimatePresence, {
139
+ children: focusRect && /* @__PURE__ */ jsx(motion.div, {
140
+ className: `absolute ${shape.focusRing} pointer-events-none z-20 border border-focus-ring`,
141
+ initial: false,
142
+ animate: {
143
+ left: focusRect.left - 2,
144
+ top: focusRect.top - 2,
145
+ width: focusRect.width + 4,
146
+ height: focusRect.height + 4
147
+ },
148
+ exit: { opacity: 0, transition: spring.fast.exit },
149
+ transition: {
150
+ ...spring.fast,
151
+ opacity: { duration: spring.fast.duration }
152
+ }
153
+ })
154
+ }),
155
+ children
156
+ ]
157
+ })
158
+ });
159
+ return size ? /* @__PURE__ */ jsx(SizeProvider, {
160
+ size,
161
+ children: group
162
+ }) : group;
163
+ });
164
+ CheckboxGroup.displayName = "CheckboxGroup";
165
+ var CheckboxItem = forwardRef(({ label, index, checked: checkedProp, onToggle: onToggleProp, className, ...props }, ref) => {
166
+ const internalRef = useRef(null);
167
+ const hasMounted = useRef(false);
168
+ const { registerItem, activeIndex, checkedIndices, setItemChecked } = useCheckboxGroup();
169
+ const checked = checkedProp ?? checkedIndices.has(index);
170
+ const onToggle = () => {
171
+ onToggleProp?.();
172
+ setItemChecked(index, !checked);
173
+ };
174
+ useRegisterFluidHoverItem(registerItem, index, internalRef);
175
+ useEffect(() => {
176
+ hasMounted.current = true;
177
+ }, []);
178
+ const isActive = activeIndex === index;
179
+ const skipAnimation = !hasMounted.current;
180
+ const shape = useShape();
181
+ const sizeClasses = useSize();
182
+ const compact = sizeClasses.variant === "compact";
183
+ return /* @__PURE__ */ jsxs("div", {
184
+ ref: (node) => {
185
+ internalRef.current = node;
186
+ if (typeof ref === "function")
187
+ ref(node);
188
+ else if (ref)
189
+ ref.current = node;
190
+ },
191
+ "data-fluid-hover-index": index,
192
+ tabIndex: 0,
193
+ role: "checkbox",
194
+ "aria-checked": checked,
195
+ "aria-label": label,
196
+ onClick: onToggle,
197
+ onMouseDown: (e) => {
198
+ const interactive = e.target.closest('button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
199
+ if (interactive && interactive !== e.currentTarget)
200
+ return;
201
+ e.preventDefault();
202
+ e.currentTarget.focus();
203
+ },
204
+ onKeyDown: (e) => {
205
+ if (e.key === " " || e.key === "Enter") {
206
+ e.preventDefault();
207
+ onToggle();
208
+ }
209
+ },
210
+ className: cn(`relative z-10 flex ${sizeClasses.control} items-center ${sizeClasses.gap} ${shape.item} ${sizeClasses.px} cursor-pointer outline-none`, className),
211
+ ...props,
212
+ children: [
213
+ /* @__PURE__ */ jsxs(CheckboxPrimitive.Root, {
214
+ checked,
215
+ onCheckedChange: () => onToggle(),
216
+ tabIndex: -1,
217
+ "aria-hidden": true,
218
+ className: cn("relative shrink-0 appearance-none bg-transparent p-0 border-0 outline-none cursor-pointer", compact ? "w-[14px] h-[14px]" : "w-[16px] h-[16px]"),
219
+ onClick: (e) => e.stopPropagation(),
220
+ children: [
221
+ /* @__PURE__ */ jsx("div", {
222
+ className: cn("absolute inset-0 border-solid transition-all duration-fast", compact ? "rounded-sm" : "rounded-box", checked ? "border-[1.5px] border-transparent" : isActive ? "border-[1.5px] border-control" : "border-[1.5px] border-border")
223
+ }),
224
+ /* @__PURE__ */ jsx(AnimatePresence, {
225
+ children: checked && /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, {
226
+ keepMounted: true,
227
+ render: (indicatorProps) => {
228
+ const {
229
+ style: _s,
230
+ onDrag: _onDrag,
231
+ onDragStart: _onDragStart,
232
+ onDragEnd: _onDragEnd,
233
+ onAnimationStart: _onAnimationStart,
234
+ onAnimationEnd: _onAnimationEnd,
235
+ onAnimationIteration: _onAnimationIteration,
236
+ ...rest
237
+ } = indicatorProps;
238
+ return /* @__PURE__ */ jsx(motion.svg, {
239
+ ...rest,
240
+ width: compact ? 16 : 18,
241
+ height: compact ? 16 : 18,
242
+ viewBox: "0 0 24 24",
243
+ fill: "none",
244
+ stroke: "currentColor",
245
+ strokeWidth: 2,
246
+ strokeLinecap: "round",
247
+ strokeLinejoin: "round",
248
+ className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-foreground",
249
+ initial: { opacity: 1 },
250
+ animate: { opacity: 1 },
251
+ exit: { opacity: 1 },
252
+ children: /* @__PURE__ */ jsx(motion.path, {
253
+ d: "M6 12L10 16L18 8",
254
+ initial: { pathLength: skipAnimation ? 1 : 0 },
255
+ animate: {
256
+ pathLength: 1,
257
+ transition: { duration: spring.fast.duration, ease: "easeOut" }
258
+ },
259
+ exit: {
260
+ pathLength: 0,
261
+ transition: { duration: 0.04, ease: "easeIn" }
262
+ }
263
+ })
264
+ });
265
+ }
266
+ })
267
+ })
268
+ ]
269
+ }),
270
+ /* @__PURE__ */ jsxs("span", {
271
+ className: cn("inline-grid", sizeClasses.text),
272
+ children: [
273
+ /* @__PURE__ */ jsx("span", {
274
+ className: "col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic] weight-semibold",
275
+ "aria-hidden": "true",
276
+ children: label
277
+ }),
278
+ /* @__PURE__ */ jsx("span", {
279
+ className: cn("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-fast [text-box:trim-both_cap_alphabetic]", checked || isActive ? "text-foreground" : "text-muted-foreground", checked ? "weight-semibold" : "weight-normal"),
280
+ children: label
281
+ })
282
+ ]
283
+ })
284
+ ]
285
+ });
286
+ });
287
+ CheckboxItem.displayName = "CheckboxItem";
288
+ Object.assign(CheckboxGroup, { Item: CheckboxItem });
289
+ var checkbox_group_default = CheckboxGroup;
290
+
291
+ export { CheckboxGroup, CheckboxItem, checkbox_group_default };