@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,292 @@
1
+ import {
2
+ DialogContent,
3
+ DialogState,
4
+ DialogTrigger
5
+ } from "./components-61ckf42z.js";
6
+ import {
7
+ useIcon
8
+ } from "./components-m5br529r.js";
9
+ import {
10
+ isDisabledRow,
11
+ popupScrollAreaClass,
12
+ popupViewportClass
13
+ } from "./components-jw16snbn.js";
14
+ import {
15
+ ScrollArea
16
+ } from "./components-ed7cmssr.js";
17
+ import {
18
+ FluidHoverHighlight
19
+ } from "./components-r22vtgqc.js";
20
+ import {
21
+ useFluidHover,
22
+ useRegisterFluidHoverItem
23
+ } from "./components-e46kf6cp.js";
24
+ import {
25
+ shapeMap
26
+ } from "./components-7zp99w5d.js";
27
+ import {
28
+ useSize
29
+ } from "./components-x3rz4cyn.js";
30
+ import {
31
+ cn
32
+ } from "./components-0f0as45n.js";
33
+
34
+ // components/overlays/command/index.tsx
35
+ import { Autocomplete } from "@base-ui/react/autocomplete";
36
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
37
+ import {
38
+ createContext,
39
+ forwardRef,
40
+ useContext,
41
+ useEffect,
42
+ useImperativeHandle,
43
+ useMemo,
44
+ useRef,
45
+ useState
46
+ } from "react";
47
+ import { jsx, jsxs } from "react/jsx-runtime";
48
+ var listShape = shapeMap.rounded;
49
+ var CommandContext = createContext({
50
+ trigger: { current: null },
51
+ close: () => {},
52
+ session: 0
53
+ });
54
+ var CommandHighlight = createContext(null);
55
+ var CommandRows = createContext(undefined);
56
+ var isGrouped = (items) => items[0] !== undefined && ("items" in items[0]);
57
+ function CommandListRoot({ items, ...props }) {
58
+ const [highlight, setHighlight] = useState(null);
59
+ const { contains } = Autocomplete.useFilter();
60
+ return /* @__PURE__ */ jsx(CommandHighlight.Provider, {
61
+ value: highlight,
62
+ children: /* @__PURE__ */ jsx(Autocomplete.Root, {
63
+ ...props,
64
+ items,
65
+ itemToStringValue: (item) => item.label,
66
+ filter: (item, query) => contains([item.label, ...item.keywords ?? []].join(" "), query),
67
+ onItemHighlighted: (item, details) => setHighlight(item ? details.index : null)
68
+ })
69
+ });
70
+ }
71
+ function CommandShortcut({ className, ...props }) {
72
+ return /* @__PURE__ */ jsx("kbd", {
73
+ className: cn("ml-auto shrink-0 font-sans text-caption text-muted-foreground", className),
74
+ ...props
75
+ });
76
+ }
77
+ function CommandRow({
78
+ item,
79
+ index,
80
+ onPick
81
+ }) {
82
+ const registerItem = useContext(CommandRows);
83
+ const active = useContext(CommandHighlight) === index;
84
+ const ref = useRef(null);
85
+ const size = useSize();
86
+ useRegisterFluidHoverItem(registerItem, index, ref);
87
+ const Icon = item.icon;
88
+ return /* @__PURE__ */ jsxs(Autocomplete.Item, {
89
+ ref,
90
+ value: item,
91
+ disabled: item.disabled,
92
+ onClick: () => onPick(item),
93
+ className: cn("relative z-10 flex shrink-0 cursor-pointer select-none items-center outline-none transition-[color] duration-fast", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", size.control, size.gap, size.itemPx, size.text, listShape.item, active ? "text-foreground" : "text-muted-foreground"),
94
+ children: [
95
+ Icon && /* @__PURE__ */ jsx(Icon, {
96
+ size: size.icon,
97
+ strokeWidth: active ? 2 : 1.5,
98
+ className: "shrink-0 transition-[color,stroke-width] duration-fast"
99
+ }),
100
+ /* @__PURE__ */ jsx("span", {
101
+ className: "min-w-0 flex-1 truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1",
102
+ children: item.label
103
+ }),
104
+ item.shortcut && /* @__PURE__ */ jsx(CommandShortcut, {
105
+ children: item.shortcut
106
+ })
107
+ ]
108
+ });
109
+ }
110
+ function CommandList({ onPick, emptyMessage, className }) {
111
+ const filtered = Autocomplete.useFilteredItems();
112
+ const highlight = useContext(CommandHighlight);
113
+ const compact = useSize().variant === "compact";
114
+ const containerRef = useRef(null);
115
+ const { itemRects, isMeasured, registerItem } = useFluidHover(containerRef, { isItemDisabled: isDisabledRow });
116
+ const rect = isMeasured && highlight !== null ? itemRects[highlight] ?? null : null;
117
+ const rows = (items, start2) => items.map((item, i) => /* @__PURE__ */ jsx(CommandRow, {
118
+ item,
119
+ index: start2 + i,
120
+ onPick
121
+ }, item.label));
122
+ let start = 0;
123
+ return /* @__PURE__ */ jsx(CommandRows.Provider, {
124
+ value: registerItem,
125
+ children: /* @__PURE__ */ jsxs(ScrollArea, {
126
+ className: cn(popupScrollAreaClass, className),
127
+ viewportClassName: cn(popupViewportClass, "scroll-fade"),
128
+ children: [
129
+ /* @__PURE__ */ jsx(Autocomplete.Empty, {
130
+ className: "px-4 py-6 text-center text-body text-muted-foreground empty:hidden",
131
+ children: emptyMessage
132
+ }),
133
+ /* @__PURE__ */ jsxs(Autocomplete.List, {
134
+ ref: containerRef,
135
+ className: "relative flex flex-col p-1 outline-none data-[empty]:p-0",
136
+ children: [
137
+ /* @__PURE__ */ jsx(FluidHoverHighlight, {
138
+ rect,
139
+ session: 0,
140
+ className: listShape.bg
141
+ }),
142
+ isGrouped(filtered) ? filtered.map((group) => {
143
+ const first = start;
144
+ start += group.items.length;
145
+ return /* @__PURE__ */ jsxs(Autocomplete.Group, {
146
+ className: "flex flex-col",
147
+ children: [
148
+ /* @__PURE__ */ jsx(Autocomplete.GroupLabel, {
149
+ className: cn("shrink-0 px-2 pt-2 pb-1 text-muted-foreground", compact ? "text-caption-compact" : "text-caption"),
150
+ children: group.label
151
+ }),
152
+ rows(group.items, first)
153
+ ]
154
+ }, group.label);
155
+ }) : rows(filtered, 0)
156
+ ]
157
+ })
158
+ ]
159
+ })
160
+ });
161
+ }
162
+ function CommandPalette({
163
+ items,
164
+ placeholder = "Type a command or search…",
165
+ emptyMessage = "No results found.",
166
+ className
167
+ }) {
168
+ const { close } = useContext(CommandContext);
169
+ const SearchIcon = useIcon("search");
170
+ const size = useSize();
171
+ const [query, setQuery] = useState("");
172
+ return /* @__PURE__ */ jsx(CommandListRoot, {
173
+ items,
174
+ inline: true,
175
+ open: true,
176
+ autoHighlight: "always",
177
+ keepHighlight: true,
178
+ value: query,
179
+ onValueChange: (next, details) => {
180
+ if (details.reason === "item-press")
181
+ return;
182
+ setQuery(next);
183
+ },
184
+ children: /* @__PURE__ */ jsxs("div", {
185
+ className: cn("flex flex-col", className),
186
+ children: [
187
+ /* @__PURE__ */ jsxs("div", {
188
+ className: "flex h-12 shrink-0 items-center gap-2 border-b border-border px-4",
189
+ children: [
190
+ /* @__PURE__ */ jsx(SearchIcon, {
191
+ size: size.icon,
192
+ strokeWidth: 1.5,
193
+ className: "shrink-0 text-muted-foreground"
194
+ }),
195
+ /* @__PURE__ */ jsx(Autocomplete.Input, {
196
+ placeholder,
197
+ className: cn("h-full min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground", size.text)
198
+ })
199
+ ]
200
+ }),
201
+ /* @__PURE__ */ jsx(CommandList, {
202
+ emptyMessage,
203
+ className: "max-h-80",
204
+ onPick: (item) => {
205
+ item.onSelect?.();
206
+ close();
207
+ }
208
+ })
209
+ ]
210
+ })
211
+ });
212
+ }
213
+ var CommandTrigger = forwardRef((props, ref) => {
214
+ const { trigger } = useContext(CommandContext);
215
+ useImperativeHandle(ref, () => trigger.current);
216
+ return /* @__PURE__ */ jsx(DialogTrigger, {
217
+ ref: trigger,
218
+ ...props
219
+ });
220
+ });
221
+ CommandTrigger.displayName = "CommandTrigger";
222
+ var CommandContent = forwardRef(({ items, placeholder, emptyMessage, className, label = "Command menu", ...morph }, ref) => {
223
+ const { session } = useContext(CommandContext);
224
+ return /* @__PURE__ */ jsx(DialogContent, {
225
+ ref,
226
+ position: "top",
227
+ size: "lg",
228
+ showCloseButton: false,
229
+ "aria-label": label,
230
+ className: "p-0",
231
+ ...morph,
232
+ children: /* @__PURE__ */ jsx(CommandPalette, {
233
+ items,
234
+ placeholder,
235
+ emptyMessage,
236
+ className
237
+ }, session)
238
+ });
239
+ });
240
+ CommandContent.displayName = "CommandContent";
241
+ function CommandScope({ open, onOpenChange, hotkey, children }) {
242
+ const trigger = useRef(null);
243
+ const change = useRef(onOpenChange);
244
+ change.current = onOpenChange;
245
+ const [session, setSession] = useState(0);
246
+ const [wasOpen, setWasOpen] = useState(open);
247
+ if (open !== wasOpen) {
248
+ setWasOpen(open);
249
+ if (open)
250
+ setSession(session + 1);
251
+ }
252
+ useEffect(() => {
253
+ if (!hotkey)
254
+ return;
255
+ const onKey = (event) => {
256
+ if (event.defaultPrevented || !(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== hotkey)
257
+ return;
258
+ event.preventDefault();
259
+ change.current(!open, { trigger: trigger.current ?? undefined });
260
+ };
261
+ window.addEventListener("keydown", onKey, open);
262
+ return () => window.removeEventListener("keydown", onKey, open);
263
+ }, [hotkey, open]);
264
+ const ctx = useMemo(() => ({ trigger, close: () => change.current(false, {}), session }), [session]);
265
+ return /* @__PURE__ */ jsx(CommandContext.Provider, {
266
+ value: ctx,
267
+ children: /* @__PURE__ */ jsx(DialogPrimitive.Root, {
268
+ open,
269
+ onOpenChange,
270
+ children
271
+ })
272
+ });
273
+ }
274
+ function Command({ open, defaultOpen, onOpenChange, hotkey = "k", children }) {
275
+ return /* @__PURE__ */ jsx(DialogState, {
276
+ open,
277
+ defaultOpen,
278
+ onOpenChange,
279
+ children: (root) => /* @__PURE__ */ jsx(CommandScope, {
280
+ ...root,
281
+ hotkey,
282
+ children
283
+ })
284
+ });
285
+ }
286
+ Command.Trigger = CommandTrigger;
287
+ Command.Content = CommandContent;
288
+ Command.Palette = CommandPalette;
289
+ Command.Shortcut = CommandShortcut;
290
+ var command_default = Command;
291
+
292
+ export { CommandListRoot, CommandShortcut, CommandList, CommandPalette, CommandTrigger, CommandContent, Command, command_default };
@@ -0,0 +1,15 @@
1
+ // lib/use-is-mobile.ts
2
+ import { useEffect, useState } from "react";
3
+ function useIsMobile(breakpoint) {
4
+ const [isMobile, setIsMobile] = useState(undefined);
5
+ useEffect(() => {
6
+ const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
7
+ const onChange = () => setIsMobile(mql.matches);
8
+ onChange();
9
+ mql.addEventListener("change", onChange);
10
+ return () => mql.removeEventListener("change", onChange);
11
+ }, [breakpoint]);
12
+ return !!isMobile;
13
+ }
14
+
15
+ export { useIsMobile };
@@ -0,0 +1,110 @@
1
+ import {
2
+ TimeColumns,
3
+ pad
4
+ } from "./components-r4jt6hgd.js";
5
+ import {
6
+ PickerInput,
7
+ PickerShell
8
+ } from "./components-hzfp4tjb.js";
9
+ import {
10
+ defaultLocale,
11
+ dividedColumns,
12
+ hourCycleOf,
13
+ parseTimeText
14
+ } from "./components-x2xyckd5.js";
15
+ import {
16
+ useControllableState
17
+ } from "./components-dg0w8g5p.js";
18
+ import {
19
+ cn
20
+ } from "./components-0f0as45n.js";
21
+
22
+ // components/inputs/date-time/time-picker/index.tsx
23
+ import { format, set } from "date-fns";
24
+ import { useRef } from "react";
25
+ import { jsx } from "react/jsx-runtime";
26
+ var toTime = (value) => {
27
+ const [hours, minutes] = value?.split(":").map(Number) ?? [];
28
+ return hours === undefined || minutes === undefined ? null : { hours, minutes };
29
+ };
30
+ var toValue = ({ hours, minutes }) => `${pad(hours)}:${pad(minutes)}`;
31
+ function TimePicker({
32
+ value: valueProp,
33
+ defaultValue = null,
34
+ onValueChange,
35
+ hourCycle,
36
+ minuteStep = 1,
37
+ locale = defaultLocale,
38
+ placeholder,
39
+ disabled,
40
+ invalid,
41
+ size,
42
+ open: openProp,
43
+ defaultOpen = false,
44
+ onOpenChange,
45
+ id,
46
+ from,
47
+ effect,
48
+ hideSource,
49
+ tier,
50
+ className
51
+ }) {
52
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
53
+ const [open, setOpen] = useControllableState(openProp, defaultOpen, onOpenChange);
54
+ const input = useRef(null);
55
+ const time = toTime(value);
56
+ const formatted = time ? format(set(new Date, time), "p", { locale }) : "";
57
+ const readTime = (text) => {
58
+ if (!text.trim()) {
59
+ setValue(null);
60
+ return true;
61
+ }
62
+ const read = parseTimeText(text, locale);
63
+ if (!read)
64
+ return false;
65
+ setValue(toValue({ hours: read.getHours(), minutes: read.getMinutes() }));
66
+ return true;
67
+ };
68
+ return /* @__PURE__ */ jsx(PickerShell, {
69
+ open,
70
+ onOpenChange: setOpen,
71
+ size,
72
+ invalid,
73
+ disabled,
74
+ icon: "clock",
75
+ display: formatted,
76
+ placeholder,
77
+ header: /* @__PURE__ */ jsx(PickerInput, {
78
+ ref: input,
79
+ "aria-label": placeholder ?? "Time",
80
+ placeholder,
81
+ formatted,
82
+ onText: readTime,
83
+ onEnter: () => setOpen(false),
84
+ className: "flex-1"
85
+ }),
86
+ initialFocus: input,
87
+ popupClassName: "w-[max(var(--anchor-width,0px),14rem)]",
88
+ id,
89
+ from,
90
+ effect,
91
+ hideSource,
92
+ tier,
93
+ className,
94
+ children: /* @__PURE__ */ jsx("div", {
95
+ className: cn(dividedColumns, "h-56"),
96
+ children: /* @__PURE__ */ jsx(TimeColumns, {
97
+ value: time,
98
+ onValueChange: (next) => setValue(toValue(next)),
99
+ hourCycle: hourCycle ?? hourCycleOf(locale),
100
+ minuteStep,
101
+ locale,
102
+ orientation: "vertical",
103
+ fill: true
104
+ })
105
+ })
106
+ });
107
+ }
108
+ var time_picker_default = TimePicker;
109
+
110
+ export { TimePicker, time_picker_default };