@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,346 @@
1
+ import {
2
+ slotRender
3
+ } from "./components-5vxtcp88.js";
4
+ import {
5
+ button_default
6
+ } from "./components-5pkcfprd.js";
7
+ import {
8
+ SURFACE_BG,
9
+ SURFACE_SHADOW,
10
+ SurfaceProvider,
11
+ useSurface
12
+ } from "./components-csxz9f52.js";
13
+ import {
14
+ GooFilter
15
+ } from "./components-jxgznftn.js";
16
+ import {
17
+ useShape
18
+ } from "./components-7zp99w5d.js";
19
+ import {
20
+ GOO_BLUR_RATIO,
21
+ holdExit
22
+ } from "./components-7nww01w4.js";
23
+ import {
24
+ useReduceMotion
25
+ } from "./components-nnnd2xef.js";
26
+ import {
27
+ spring
28
+ } from "./components-vc1k7yv2.js";
29
+ import {
30
+ sizeMap
31
+ } from "./components-x3rz4cyn.js";
32
+ import {
33
+ cn
34
+ } from "./components-0f0as45n.js";
35
+
36
+ // components/overlays/toast/index.tsx
37
+ import { Toast as ToastPrimitive } from "@base-ui/react/toast";
38
+ import { ArrowRight, Check, CircleAlert, Info, LoaderCircle, X } from "lucide-react";
39
+ import { AnimatePresence, motion } from "motion/react";
40
+ import {
41
+ cloneElement,
42
+ createContext,
43
+ forwardRef,
44
+ useContext,
45
+ useEffect,
46
+ useId,
47
+ useLayoutEffect,
48
+ useMemo,
49
+ useRef,
50
+ useState
51
+ } from "react";
52
+ import { jsx, jsxs } from "react/jsx-runtime";
53
+ var ICONS = {
54
+ success: Check,
55
+ loading: LoaderCircle,
56
+ error: X,
57
+ warning: CircleAlert,
58
+ info: Info,
59
+ action: ArrowRight
60
+ };
61
+ var TONES = {
62
+ success: "text-status-success bg-status-success/16",
63
+ loading: "text-status-loading bg-status-loading/16",
64
+ error: "text-status-error bg-status-error/16",
65
+ warning: "text-status-warning bg-status-warning/16",
66
+ info: "text-status-info bg-status-info/16",
67
+ action: "text-status-action bg-status-action/16"
68
+ };
69
+ var VIEWPORT = {
70
+ "top-left": "top-4 left-4 items-start",
71
+ "top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
72
+ "top-right": "top-4 right-4 items-end",
73
+ "bottom-left": "bottom-4 left-4 flex-col-reverse items-start",
74
+ "bottom-center": "bottom-4 left-1/2 -translate-x-1/2 flex-col-reverse items-center",
75
+ "bottom-right": "bottom-4 right-4 flex-col-reverse items-end"
76
+ };
77
+ var PILL = sizeMap.default.controlHeight;
78
+ var BLUR = PILL / 2 * GOO_BLUR_RATIO;
79
+ var SNAP = { duration: 0 };
80
+ var AUTO_EXPAND_MS = 150;
81
+ var AUTO_COLLAPSE_BEFORE_MS = 2000;
82
+ var ToastSettings = createContext({
83
+ position: "top-right",
84
+ timeout: 6000
85
+ });
86
+ function useToast() {
87
+ const manager = ToastPrimitive.useToastManager();
88
+ return useMemo(() => {
89
+ const options = ({ action, ...rest }, type) => ({
90
+ ...rest,
91
+ type,
92
+ actionProps: action && { children: action.label, onClick: action.onClick }
93
+ });
94
+ const show = (o) => manager.add(options(o, o.type ?? "info"));
95
+ return {
96
+ show,
97
+ success: (o) => show({ ...o, type: "success" }),
98
+ error: (o) => show({ ...o, type: "error" }),
99
+ warning: (o) => show({ ...o, type: "warning" }),
100
+ info: (o) => show({ ...o, type: "info" }),
101
+ promise: (promise, o) => manager.promise(promise, {
102
+ loading: options(o.loading, "loading"),
103
+ success: options(o.success, "success"),
104
+ error: options(o.error, "error")
105
+ }),
106
+ close: manager.close
107
+ };
108
+ }, [manager]);
109
+ }
110
+ function Shape({ box, className, shapeRef }) {
111
+ const reduced = useReduceMotion();
112
+ return /* @__PURE__ */ jsx(motion.div, {
113
+ ref: shapeRef,
114
+ "aria-hidden": true,
115
+ className: cn("pointer-events-none absolute top-0 left-0", className),
116
+ initial: false,
117
+ animate: { ...box },
118
+ transition: reduced ? SNAP : spring.slow
119
+ });
120
+ }
121
+ function ToastItem({ toast }) {
122
+ const { position, timeout } = useContext(ToastSettings);
123
+ const shape = useShape();
124
+ const level = Math.min(useSurface() + 2, 8);
125
+ const gooId = `toast-goo-${useId().replace(/:/g, "")}`;
126
+ const type = toast.type ?? "info";
127
+ const Icon = ICONS[type];
128
+ const top = position.startsWith("top");
129
+ const ending = toast.transitionStatus === "ending";
130
+ const hasBody = Boolean(toast.description || toast.actionProps);
131
+ const [hovered, setHovered] = useState(false);
132
+ const [auto, setAuto] = useState(false);
133
+ const expanded = hasBody && type !== "loading" && !ending && (hovered || auto);
134
+ const root = useRef(null);
135
+ const header = useRef(null);
136
+ const body = useRef(null);
137
+ const bodyShape = useRef(null);
138
+ const [size, setSize] = useState({ width: 0, pill: PILL, body: 0, radius: 0 });
139
+ useEffect(() => {
140
+ if (!hasBody || type === "loading")
141
+ return;
142
+ const life = toast.timeout ?? timeout;
143
+ const open = setTimeout(() => setAuto(true), AUTO_EXPAND_MS);
144
+ const close = life > 0 ? setTimeout(() => setAuto(false), Math.max(AUTO_EXPAND_MS, life - AUTO_COLLAPSE_BEFORE_MS)) : undefined;
145
+ return () => {
146
+ clearTimeout(open);
147
+ clearTimeout(close);
148
+ };
149
+ }, [hasBody, type, toast.timeout, timeout]);
150
+ useLayoutEffect(() => {
151
+ const measure = () => setSize({
152
+ width: root.current?.offsetWidth ?? 0,
153
+ pill: Math.max(PILL, header.current?.offsetWidth ?? 0),
154
+ body: body.current?.offsetHeight ?? 0,
155
+ radius: bodyShape.current ? Number.parseFloat(getComputedStyle(bodyShape.current).borderTopLeftRadius) || 0 : 0
156
+ });
157
+ const observer = new ResizeObserver(measure);
158
+ for (const el of [header.current, body.current])
159
+ if (el)
160
+ observer.observe(el);
161
+ measure();
162
+ return () => observer.disconnect();
163
+ }, [hasBody]);
164
+ useLayoutEffect(() => {
165
+ if (!ending || !root.current)
166
+ return;
167
+ const hold = holdExit(root.current, "moderate");
168
+ return () => hold.cancel();
169
+ }, [ending]);
170
+ const bodyHeight = expanded ? size.body : 0;
171
+ const height = PILL + bodyHeight;
172
+ const pillX = position.endsWith("left") ? 0 : position.endsWith("right") ? size.width - size.pill : (size.width - size.pill) / 2;
173
+ const pillHeight = PILL + Math.min(bodyHeight, size.radius);
174
+ const pill = { x: pillX, y: top ? 0 : height - pillHeight, width: size.pill, height: pillHeight };
175
+ const bodyBox = { x: 0, y: top ? PILL : 0, width: size.width, height: bodyHeight };
176
+ const reduced = useReduceMotion();
177
+ const away = reduced ? { opacity: 0 } : { opacity: 0, y: top ? -6 : 6, scale: 0.95 };
178
+ const move = reduced ? SNAP : spring.slow;
179
+ return /* @__PURE__ */ jsxs(ToastPrimitive.Root, {
180
+ ref: root,
181
+ toast,
182
+ swipeDirection: [top ? "up" : "down", position.endsWith("left") ? "left" : "right"],
183
+ onMouseEnter: () => setHovered(true),
184
+ onMouseLeave: () => setHovered(false),
185
+ render: /* @__PURE__ */ jsx(motion.div, {
186
+ initial: { ...away, height: PILL },
187
+ animate: ending ? { ...away, height } : { opacity: 1, y: 0, scale: 1, height },
188
+ transition: ending ? spring.moderate.exit : { ...spring.moderate, height: move }
189
+ }),
190
+ className: "relative w-[min(22rem,calc(100vw-2rem))] select-none outline-none [translate:var(--toast-swipe-movement-x)_var(--toast-swipe-movement-y)]",
191
+ children: [
192
+ /* @__PURE__ */ jsx(GooFilter, {
193
+ id: gooId,
194
+ blur: BLUR
195
+ }),
196
+ /* @__PURE__ */ jsx(Shape, {
197
+ box: pill,
198
+ className: cn("rounded-full", SURFACE_SHADOW[3])
199
+ }),
200
+ hasBody && /* @__PURE__ */ jsx(Shape, {
201
+ box: bodyBox,
202
+ className: cn(shape.container, SURFACE_SHADOW[3])
203
+ }),
204
+ /* @__PURE__ */ jsxs("div", {
205
+ "aria-hidden": true,
206
+ className: "pointer-events-none absolute inset-0",
207
+ style: { filter: `url(#${gooId})` },
208
+ children: [
209
+ /* @__PURE__ */ jsx(Shape, {
210
+ box: pill,
211
+ className: cn("rounded-full", SURFACE_BG[level])
212
+ }),
213
+ hasBody && /* @__PURE__ */ jsx(Shape, {
214
+ box: bodyBox,
215
+ shapeRef: bodyShape,
216
+ className: cn(shape.container, SURFACE_BG[level])
217
+ })
218
+ ]
219
+ }),
220
+ /* @__PURE__ */ jsxs(SurfaceProvider, {
221
+ value: level,
222
+ children: [
223
+ /* @__PURE__ */ jsx(motion.div, {
224
+ ref: header,
225
+ className: "absolute top-0 left-0 flex h-9 w-max items-center py-1.5 pr-4 pl-1.5",
226
+ initial: false,
227
+ animate: { x: pillX, y: top ? 0 : height - PILL },
228
+ transition: move,
229
+ children: /* @__PURE__ */ jsx(ToastPrimitive.Title, {
230
+ className: "relative inline-flex items-center whitespace-nowrap",
231
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
232
+ mode: "popLayout",
233
+ initial: false,
234
+ children: /* @__PURE__ */ jsxs(motion.span, {
235
+ className: "inline-flex items-center gap-2",
236
+ initial: { opacity: 0, filter: "blur(4px)" },
237
+ animate: { opacity: 1, filter: "blur(0px)" },
238
+ exit: { opacity: 0, filter: "blur(4px)", transition: spring.moderate.exit },
239
+ transition: spring.moderate,
240
+ children: [
241
+ /* @__PURE__ */ jsx("span", {
242
+ className: cn("flex size-6 items-center justify-center rounded-full", TONES[type]),
243
+ children: /* @__PURE__ */ jsx(Icon, {
244
+ size: 14,
245
+ strokeWidth: 2.5,
246
+ className: type === "loading" ? "animate-spin" : undefined
247
+ })
248
+ }),
249
+ /* @__PURE__ */ jsx("span", {
250
+ className: "text-body weight-medium text-foreground",
251
+ children: toast.title
252
+ })
253
+ ]
254
+ }, `${type}-${toast.title}`)
255
+ })
256
+ })
257
+ }),
258
+ hasBody && /* @__PURE__ */ jsx(motion.div, {
259
+ className: "absolute top-0 left-0 w-full overflow-hidden",
260
+ initial: false,
261
+ animate: { y: bodyBox.y, height: bodyHeight, opacity: expanded ? 1 : 0 },
262
+ transition: { ...move, opacity: expanded ? spring.slow : spring.slow.exit },
263
+ children: /* @__PURE__ */ jsxs("div", {
264
+ ref: body,
265
+ className: cn("flex flex-col items-start gap-3 p-4", top ? "pt-6" : "pb-6"),
266
+ children: [
267
+ /* @__PURE__ */ jsx(ToastPrimitive.Description, {
268
+ className: "text-caption text-muted-foreground"
269
+ }),
270
+ toast.actionProps && /* @__PURE__ */ jsx(ToastPrimitive.Action, {
271
+ render: /* @__PURE__ */ jsx(button_default, {
272
+ size: "compact",
273
+ variant: "secondary"
274
+ })
275
+ })
276
+ ]
277
+ })
278
+ })
279
+ ]
280
+ })
281
+ ]
282
+ });
283
+ }
284
+ function ToastList() {
285
+ const { toasts } = ToastPrimitive.useToastManager();
286
+ return toasts.map((toast) => /* @__PURE__ */ jsx(ToastItem, {
287
+ toast
288
+ }, toast.id));
289
+ }
290
+ var ToastTrigger = forwardRef(({
291
+ title,
292
+ description,
293
+ type,
294
+ timeout,
295
+ action,
296
+ promise,
297
+ success,
298
+ error,
299
+ render,
300
+ asChild,
301
+ children,
302
+ onClick,
303
+ ...props
304
+ }, ref) => {
305
+ const toast = useToast();
306
+ const el = slotRender(render, asChild, children);
307
+ const press = (event) => {
308
+ onClick?.(event);
309
+ if (promise) {
310
+ toast.promise(promise(), { loading: { title, description }, success: success ?? {}, error: error ?? {} }).catch(() => {});
311
+ return;
312
+ }
313
+ toast.show({ title, description, type, timeout, action });
314
+ };
315
+ return el ? cloneElement(el, { ...props, ref, onClick: press }) : /* @__PURE__ */ jsx("button", {
316
+ ref,
317
+ type: "button",
318
+ ...props,
319
+ onClick: press,
320
+ children
321
+ });
322
+ });
323
+ ToastTrigger.displayName = "ToastTrigger";
324
+ function Toast({ position = "top-right", limit = 3, timeout = 6000, children }) {
325
+ const settings = useMemo(() => ({ position, timeout }), [position, timeout]);
326
+ return /* @__PURE__ */ jsx(ToastPrimitive.Provider, {
327
+ limit,
328
+ timeout,
329
+ children: /* @__PURE__ */ jsxs(ToastSettings.Provider, {
330
+ value: settings,
331
+ children: [
332
+ children,
333
+ /* @__PURE__ */ jsx(ToastPrimitive.Portal, {
334
+ children: /* @__PURE__ */ jsx(ToastPrimitive.Viewport, {
335
+ className: cn("fixed z-[60] flex flex-col gap-2 outline-none", VIEWPORT[position]),
336
+ children: /* @__PURE__ */ jsx(ToastList, {})
337
+ })
338
+ })
339
+ ]
340
+ })
341
+ });
342
+ }
343
+ Toast.Trigger = ToastTrigger;
344
+ var toast_default = Toast;
345
+
346
+ export { useToast, ToastTrigger, Toast, toast_default };
@@ -0,0 +1,120 @@
1
+ import {
2
+ pad
3
+ } from "./components-r4jt6hgd.js";
4
+ import {
5
+ PickerInput,
6
+ PickerShell
7
+ } from "./components-hzfp4tjb.js";
8
+ import {
9
+ ScrollColumn,
10
+ defaultLocale,
11
+ dividedColumns,
12
+ fieldLabel
13
+ } from "./components-x2xyckd5.js";
14
+ import {
15
+ useControllableState
16
+ } from "./components-dg0w8g5p.js";
17
+ import {
18
+ cn
19
+ } from "./components-0f0as45n.js";
20
+
21
+ // components/inputs/date-time/duration-picker/index.tsx
22
+ import { formatDuration } from "date-fns";
23
+ import { useMemo, useRef } from "react";
24
+ import { jsx, jsxs } from "react/jsx-runtime";
25
+ var TYPED = /^\s*(\d{1,3})(?::(\d{1,2}))?\s*$/;
26
+ function DurationPicker({
27
+ value: valueProp,
28
+ defaultValue = null,
29
+ onValueChange,
30
+ maxHours = 99,
31
+ minuteStep = 1,
32
+ locale = defaultLocale,
33
+ placeholder,
34
+ disabled,
35
+ invalid,
36
+ size,
37
+ open: openProp,
38
+ defaultOpen = false,
39
+ onOpenChange,
40
+ id,
41
+ from,
42
+ effect,
43
+ hideSource,
44
+ tier,
45
+ className
46
+ }) {
47
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
48
+ const [open, setOpen] = useControllableState(openProp, defaultOpen, onOpenChange);
49
+ const input = useRef(null);
50
+ const hours = value?.hours ?? 0;
51
+ const minutes = value?.minutes ?? 0;
52
+ const display = value ? hours || minutes ? formatDuration({ hours, minutes }, { locale, format: ["hours", "minutes"] }) : formatDuration({ minutes: 0 }, { locale, format: ["minutes"], zero: true }) : "";
53
+ const readDuration = (text) => {
54
+ if (!text.trim()) {
55
+ setValue(null);
56
+ return true;
57
+ }
58
+ const match = TYPED.exec(text);
59
+ const h = Number(match?.[1]);
60
+ const m = Number(match?.[2] ?? 0);
61
+ if (!match || h > maxHours || m > 59)
62
+ return false;
63
+ setValue({ hours: h, minutes: m });
64
+ return true;
65
+ };
66
+ const hourOptions = useMemo(() => Array.from({ length: maxHours + 1 }, (_, h) => ({ value: h, label: String(h) })), [maxHours]);
67
+ const minuteOptions = useMemo(() => Array.from({ length: Math.ceil(60 / minuteStep) }, (_, i) => ({
68
+ value: i * minuteStep,
69
+ label: pad(i * minuteStep)
70
+ })), [minuteStep]);
71
+ return /* @__PURE__ */ jsx(PickerShell, {
72
+ open,
73
+ onOpenChange: setOpen,
74
+ size,
75
+ invalid,
76
+ disabled,
77
+ icon: "clock",
78
+ display,
79
+ placeholder,
80
+ header: /* @__PURE__ */ jsx(PickerInput, {
81
+ ref: input,
82
+ "aria-label": placeholder ?? "Duration",
83
+ placeholder: "0:00",
84
+ formatted: value ? `${hours}:${pad(minutes)}` : "",
85
+ onText: readDuration,
86
+ onEnter: () => setOpen(false),
87
+ className: "flex-1"
88
+ }),
89
+ initialFocus: input,
90
+ popupClassName: "w-[max(var(--anchor-width,0px),14rem)]",
91
+ id,
92
+ from,
93
+ effect,
94
+ hideSource,
95
+ tier,
96
+ className,
97
+ children: /* @__PURE__ */ jsxs("div", {
98
+ className: cn(dividedColumns, "h-56"),
99
+ children: [
100
+ /* @__PURE__ */ jsx(ScrollColumn, {
101
+ label: fieldLabel(locale, "hour"),
102
+ options: hourOptions,
103
+ value: value ? hours : null,
104
+ onValueChange: (h) => setValue({ hours: h, minutes }),
105
+ className: "min-w-0 flex-1"
106
+ }),
107
+ /* @__PURE__ */ jsx(ScrollColumn, {
108
+ label: fieldLabel(locale, "minute"),
109
+ options: minuteOptions,
110
+ value: value ? minutes : null,
111
+ onValueChange: (m) => setValue({ hours, minutes: m }),
112
+ className: "min-w-0 flex-1"
113
+ })
114
+ ]
115
+ })
116
+ });
117
+ }
118
+ var duration_picker_default = DurationPicker;
119
+
120
+ export { DurationPicker, duration_picker_default };
@@ -0,0 +1,215 @@
1
+ import {
2
+ DropdownContext,
3
+ DropdownLabel,
4
+ DropdownSeparator,
5
+ MenuItem
6
+ } from "./components-40j34hdb.js";
7
+ import {
8
+ SizeProvider
9
+ } from "./components-vb033rns.js";
10
+ import {
11
+ isDisabledRow,
12
+ popupScrollAreaClass,
13
+ popupViewportClass
14
+ } from "./components-jw16snbn.js";
15
+ import {
16
+ ScrollArea
17
+ } from "./components-ed7cmssr.js";
18
+ import {
19
+ SURFACE_BG,
20
+ SURFACE_SHADOW,
21
+ SurfaceProvider,
22
+ useSurface
23
+ } from "./components-csxz9f52.js";
24
+ import {
25
+ MorphSurface
26
+ } from "./components-jxgznftn.js";
27
+ import {
28
+ FluidHoverHighlight
29
+ } from "./components-r22vtgqc.js";
30
+ import {
31
+ useFluidHover
32
+ } from "./components-e46kf6cp.js";
33
+ import {
34
+ shapeMap
35
+ } from "./components-7zp99w5d.js";
36
+ import {
37
+ useControllableState
38
+ } from "./components-dg0w8g5p.js";
39
+ import {
40
+ useMorph,
41
+ useMorphOrigin
42
+ } from "./components-7nww01w4.js";
43
+ import {
44
+ useSize
45
+ } from "./components-x3rz4cyn.js";
46
+ import {
47
+ cn
48
+ } from "./components-0f0as45n.js";
49
+
50
+ // components/overlays/context-menu/index.tsx
51
+ import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu";
52
+ import {
53
+ createContext,
54
+ forwardRef,
55
+ useContext,
56
+ useEffect,
57
+ useImperativeHandle,
58
+ useMemo,
59
+ useRef
60
+ } from "react";
61
+ import { jsx, jsxs } from "react/jsx-runtime";
62
+ var shape = shapeMap.rounded;
63
+ var ContextMenuContext = createContext({ open: false, origin: { current: {} } });
64
+ var ShortcutContext = createContext(undefined);
65
+ function RowShortcut() {
66
+ const shortcut = useContext(ShortcutContext);
67
+ const compact = useSize().variant === "compact";
68
+ if (!shortcut)
69
+ return null;
70
+ return /* @__PURE__ */ jsx("kbd", {
71
+ className: cn("shrink-0 pl-4 font-sans text-muted-foreground", compact ? "text-caption-compact" : "text-caption"),
72
+ children: shortcut
73
+ });
74
+ }
75
+ function renderMenuItem({
76
+ radio,
77
+ checkbox,
78
+ checked,
79
+ disabled,
80
+ label,
81
+ closeOnClick,
82
+ onClick,
83
+ element,
84
+ children
85
+ }) {
86
+ return radio || checkbox ? /* @__PURE__ */ jsxs(ContextMenuPrimitive.CheckboxItem, {
87
+ checked,
88
+ disabled,
89
+ label,
90
+ closeOnClick,
91
+ onClick,
92
+ render: element,
93
+ children: [
94
+ children,
95
+ /* @__PURE__ */ jsx(RowShortcut, {})
96
+ ]
97
+ }) : /* @__PURE__ */ jsxs(ContextMenuPrimitive.Item, {
98
+ disabled,
99
+ label,
100
+ closeOnClick,
101
+ onClick,
102
+ render: element,
103
+ children: [
104
+ children,
105
+ /* @__PURE__ */ jsx(RowShortcut, {})
106
+ ]
107
+ });
108
+ }
109
+ var ContextMenuItem = forwardRef(({ shortcut, ...props }, ref) => /* @__PURE__ */ jsx(ShortcutContext.Provider, {
110
+ value: shortcut,
111
+ children: /* @__PURE__ */ jsx(MenuItem, {
112
+ ref,
113
+ ...props
114
+ })
115
+ }));
116
+ ContextMenuItem.displayName = "ContextMenuItem";
117
+ var ContextMenuContent = forwardRef(({ from = "pointer", effect, hideSource, tier = "moderate", container, className, children }, ref) => {
118
+ const { open, origin } = useContext(ContextMenuContext);
119
+ const morph = useMorph(open, origin, { from, effect, hideSource, tier });
120
+ useImperativeHandle(ref, () => morph.popup, [morph.popup]);
121
+ const level = Math.min(useSurface() + 2, 8);
122
+ const containerRef = useRef(null);
123
+ const hover = useFluidHover(containerRef, { isItemDisabled: isDisabledRow });
124
+ const { activeIndex, setActiveIndex, handlers, registerItem, remeasure } = hover;
125
+ useEffect(() => {
126
+ if (open)
127
+ remeasure();
128
+ else
129
+ setActiveIndex(null);
130
+ }, [open, remeasure, setActiveIndex]);
131
+ const rows = useMemo(() => ({ registerItem, activeIndex, inMenu: true, renderMenuItem }), [registerItem, activeIndex]);
132
+ return /* @__PURE__ */ jsx(ContextMenuPrimitive.Portal, {
133
+ container: container ?? undefined,
134
+ children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Positioner, {
135
+ className: "z-50 outline-none",
136
+ children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Popup, {
137
+ ref: morph.popupRef,
138
+ onMouseEnter: handlers.onMouseEnter,
139
+ onMouseMove: handlers.onMouseMove,
140
+ onMouseLeave: handlers.onMouseLeave,
141
+ onClick: handlers.onClick,
142
+ onFocus: (e) => {
143
+ const index = e.target.closest("[data-fluid-hover-index]")?.getAttribute("data-fluid-hover-index");
144
+ if (index != null)
145
+ setActiveIndex(Number(index));
146
+ },
147
+ onBlur: (e) => {
148
+ if (!e.currentTarget.contains(e.relatedTarget))
149
+ setActiveIndex(null);
150
+ },
151
+ className: "relative select-none outline-none",
152
+ children: /* @__PURE__ */ jsx(SurfaceProvider, {
153
+ value: level,
154
+ children: /* @__PURE__ */ jsx(MorphSurface, {
155
+ morph,
156
+ bg: SURFACE_BG[level],
157
+ shadow: SURFACE_SHADOW[3],
158
+ radius: shape.container,
159
+ className: cn("flex w-56 max-h-[min(480px,var(--available-height))] flex-col overflow-hidden", shape.container, className),
160
+ children: /* @__PURE__ */ jsx(ScrollArea, {
161
+ className: popupScrollAreaClass,
162
+ viewportClassName: cn(popupViewportClass, "scroll-fade"),
163
+ children: /* @__PURE__ */ jsxs("div", {
164
+ ref: containerRef,
165
+ className: "relative flex flex-col p-1",
166
+ children: [
167
+ /* @__PURE__ */ jsx(FluidHoverHighlight, {
168
+ hover,
169
+ hidden: !open,
170
+ className: shape.bg
171
+ }),
172
+ /* @__PURE__ */ jsx(DropdownContext.Provider, {
173
+ value: rows,
174
+ children
175
+ })
176
+ ]
177
+ })
178
+ })
179
+ })
180
+ })
181
+ })
182
+ })
183
+ });
184
+ });
185
+ ContextMenuContent.displayName = "ContextMenuContent";
186
+ function ContextMenu({ open, defaultOpen = false, onOpenChange, disabled = false, size, children }) {
187
+ const [current, setCurrent] = useControllableState(open, defaultOpen, onOpenChange);
188
+ const { origin, capture } = useMorphOrigin();
189
+ const ctx = useMemo(() => ({ open: current, origin }), [current, origin]);
190
+ const root = /* @__PURE__ */ jsx(ContextMenuContext.Provider, {
191
+ value: ctx,
192
+ children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Root, {
193
+ open: current,
194
+ disabled,
195
+ onOpenChange: (next, details) => {
196
+ if (next)
197
+ capture(details);
198
+ setCurrent(next);
199
+ },
200
+ children
201
+ })
202
+ });
203
+ return size ? /* @__PURE__ */ jsx(SizeProvider, {
204
+ size,
205
+ children: root
206
+ }) : root;
207
+ }
208
+ ContextMenu.Trigger = ContextMenuPrimitive.Trigger;
209
+ ContextMenu.Content = ContextMenuContent;
210
+ ContextMenu.Item = ContextMenuItem;
211
+ ContextMenu.Label = DropdownLabel;
212
+ ContextMenu.Separator = DropdownSeparator;
213
+ var context_menu_default = ContextMenu;
214
+
215
+ export { ContextMenuItem, ContextMenuContent, ContextMenu, context_menu_default };