@kumix/ui 0.3.0 → 0.3.1

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 (242) hide show
  1. package/README.md +14 -1
  2. package/dist/components/custom/confirm-dialog.d.ts +16 -0
  3. package/dist/components/custom/confirm-dialog.d.ts.map +1 -0
  4. package/dist/components/custom/confirm-dialog.js +93 -0
  5. package/dist/components/custom/confirm-dialog.js.map +1 -0
  6. package/dist/components/custom/toast.d.ts +20 -0
  7. package/dist/components/custom/toast.d.ts.map +1 -0
  8. package/dist/components/custom/toast.js +73 -0
  9. package/dist/components/custom/toast.js.map +1 -0
  10. package/dist/components/motion/action-swap.js +1 -1
  11. package/dist/components/motion/animated-badge.js +2 -2
  12. package/dist/components/motion/animated-number.js +1 -1
  13. package/dist/components/motion/animated-sidebar.js +2 -2
  14. package/dist/components/motion/animated-toast-stack.js +4 -4
  15. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  16. package/dist/components/motion/attachment-upload.d.ts +47 -0
  17. package/dist/components/motion/attachment-upload.d.ts.map +1 -0
  18. package/dist/components/motion/attachment-upload.js +737 -0
  19. package/dist/components/motion/attachment-upload.js.map +1 -0
  20. package/dist/components/motion/availability-scheduler/copy-menu.d.ts +10 -0
  21. package/dist/components/motion/availability-scheduler/copy-menu.d.ts.map +1 -0
  22. package/dist/components/motion/availability-scheduler/copy-menu.js +3 -0
  23. package/dist/components/motion/availability-scheduler/day-row.d.ts +15 -0
  24. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -0
  25. package/dist/components/motion/availability-scheduler/day-row.js +181 -0
  26. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -0
  27. package/dist/components/motion/availability-scheduler/icon-button.d.ts +15 -0
  28. package/dist/components/motion/availability-scheduler/icon-button.d.ts.map +1 -0
  29. package/dist/components/motion/availability-scheduler/icon-button.js +24 -0
  30. package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -0
  31. package/dist/components/motion/availability-scheduler/index.d.ts +14 -0
  32. package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -0
  33. package/dist/components/motion/availability-scheduler/index.js +59 -0
  34. package/dist/components/motion/availability-scheduler/index.js.map +1 -0
  35. package/dist/components/motion/availability-scheduler/time-select.d.ts +10 -0
  36. package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -0
  37. package/dist/components/motion/availability-scheduler/time-select.js +26 -0
  38. package/dist/components/motion/availability-scheduler/time-select.js.map +1 -0
  39. package/dist/components/motion/bloom-menu.d.ts +17 -0
  40. package/dist/components/motion/bloom-menu.d.ts.map +1 -0
  41. package/dist/components/motion/bloom-menu.js +170 -0
  42. package/dist/components/motion/bloom-menu.js.map +1 -0
  43. package/dist/components/motion/bottom-sheet.js +1 -1
  44. package/dist/components/motion/bounce-sidebar.js +1 -1
  45. package/dist/components/motion/bouncy-accordion.js +2 -2
  46. package/dist/components/motion/button/base.js +1 -1
  47. package/dist/components/motion/button/index.d.ts +4 -0
  48. package/dist/components/motion/button/index.js +5 -0
  49. package/dist/components/motion/button/magnetic.js +1 -1
  50. package/dist/components/motion/button/stateful.js +2 -2
  51. package/dist/components/motion/center-morph-modal.js +2 -2
  52. package/dist/components/motion/checkbox.js +1 -1
  53. package/dist/components/motion/chromatic-text-reveal.js +1 -1
  54. package/dist/components/motion/command-palette.d.ts +26 -0
  55. package/dist/components/motion/command-palette.d.ts.map +1 -0
  56. package/dist/components/motion/command-palette.js +246 -0
  57. package/dist/components/motion/command-palette.js.map +1 -0
  58. package/dist/components/motion/context-menu.js +2 -2
  59. package/dist/components/motion/cylinder-carousel.js +1 -1
  60. package/dist/components/motion/dock.js +1 -1
  61. package/dist/components/motion/drawer.js +1 -1
  62. package/dist/components/motion/dynamic-island.d.ts +22 -0
  63. package/dist/components/motion/dynamic-island.d.ts.map +1 -0
  64. package/dist/components/motion/dynamic-island.js +143 -0
  65. package/dist/components/motion/dynamic-island.js.map +1 -0
  66. package/dist/components/motion/expandable-action-bar.d.ts +52 -0
  67. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -0
  68. package/dist/components/motion/expandable-action-bar.js +191 -0
  69. package/dist/components/motion/expandable-action-bar.js.map +1 -0
  70. package/dist/components/motion/expandable-tabs.d.ts +33 -0
  71. package/dist/components/motion/expandable-tabs.d.ts.map +1 -0
  72. package/dist/components/motion/expandable-tabs.js +291 -0
  73. package/dist/components/motion/expandable-tabs.js.map +1 -0
  74. package/dist/components/motion/feedback-widget.d.ts +18 -0
  75. package/dist/components/motion/feedback-widget.d.ts.map +1 -0
  76. package/dist/components/motion/feedback-widget.js +413 -0
  77. package/dist/components/motion/feedback-widget.js.map +1 -0
  78. package/dist/components/motion/file-upload.d.ts +48 -0
  79. package/dist/components/motion/file-upload.d.ts.map +1 -0
  80. package/dist/components/motion/file-upload.js +382 -0
  81. package/dist/components/motion/file-upload.js.map +1 -0
  82. package/dist/components/motion/hold-action-button.js +1 -1
  83. package/dist/components/motion/infinite-masonry.d.ts +31 -0
  84. package/dist/components/motion/infinite-masonry.d.ts.map +1 -0
  85. package/dist/components/motion/infinite-masonry.js +223 -0
  86. package/dist/components/motion/infinite-masonry.js.map +1 -0
  87. package/dist/components/motion/input.js +1 -1
  88. package/dist/components/motion/loader.js +1 -1
  89. package/dist/components/motion/magnetic.js +1 -1
  90. package/dist/components/motion/morphing-modal.js +1 -1
  91. package/dist/components/motion/not-found/glitch.d.ts +6 -0
  92. package/dist/components/motion/not-found/glitch.d.ts.map +1 -0
  93. package/dist/components/motion/not-found/glitch.js +90 -0
  94. package/dist/components/motion/not-found/glitch.js.map +1 -0
  95. package/dist/components/motion/not-found/magnetic.d.ts +6 -0
  96. package/dist/components/motion/not-found/magnetic.d.ts.map +1 -0
  97. package/dist/components/motion/not-found/magnetic.js +47 -0
  98. package/dist/components/motion/not-found/magnetic.js.map +1 -0
  99. package/dist/components/motion/not-found/shared.d.ts +32 -0
  100. package/dist/components/motion/not-found/shared.d.ts.map +1 -0
  101. package/dist/components/motion/not-found/shared.js +52 -0
  102. package/dist/components/motion/not-found/shared.js.map +1 -0
  103. package/dist/components/motion/not-found/spotlight.d.ts +6 -0
  104. package/dist/components/motion/not-found/spotlight.d.ts.map +1 -0
  105. package/dist/components/motion/not-found/spotlight.js +70 -0
  106. package/dist/components/motion/not-found/spotlight.js.map +1 -0
  107. package/dist/components/motion/not-found/stacked.d.ts +6 -0
  108. package/dist/components/motion/not-found/stacked.d.ts.map +1 -0
  109. package/dist/components/motion/not-found/stacked.js +95 -0
  110. package/dist/components/motion/not-found/stacked.js.map +1 -0
  111. package/dist/components/motion/not-found/terminal.d.ts +6 -0
  112. package/dist/components/motion/not-found/terminal.d.ts.map +1 -0
  113. package/dist/components/motion/not-found/terminal.js +90 -0
  114. package/dist/components/motion/not-found/terminal.js.map +1 -0
  115. package/dist/components/motion/notification-stack.d.ts +35 -0
  116. package/dist/components/motion/notification-stack.d.ts.map +1 -0
  117. package/dist/components/motion/notification-stack.js +187 -0
  118. package/dist/components/motion/notification-stack.js.map +1 -0
  119. package/dist/components/motion/number-ticker.js +1 -1
  120. package/dist/components/motion/otp-input.d.ts +32 -0
  121. package/dist/components/motion/otp-input.d.ts.map +1 -0
  122. package/dist/components/motion/otp-input.js +272 -0
  123. package/dist/components/motion/otp-input.js.map +1 -0
  124. package/dist/components/motion/overflow-actions.d.ts +39 -0
  125. package/dist/components/motion/overflow-actions.d.ts.map +1 -0
  126. package/dist/components/motion/overflow-actions.js +220 -0
  127. package/dist/components/motion/overflow-actions.js.map +1 -0
  128. package/dist/components/motion/parallax.js +1 -1
  129. package/dist/components/motion/popover-morph.js +2 -2
  130. package/dist/components/motion/popover-morph.js.map +1 -1
  131. package/dist/components/motion/popover.js +1 -1
  132. package/dist/components/motion/preview-rail.js +1 -1
  133. package/dist/components/motion/pull-to-refresh.js +2 -2
  134. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  135. package/dist/components/motion/radio.js +1 -1
  136. package/dist/components/motion/range-slider-bubble.js +1 -1
  137. package/dist/components/motion/range-slider-fluid.js +1 -1
  138. package/dist/components/motion/range-slider-ruler.js +2 -2
  139. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  140. package/dist/components/motion/range-slider-wave.js +1 -1
  141. package/dist/components/motion/range-slider.js +1 -1
  142. package/dist/components/motion/scroll-progress.js +1 -1
  143. package/dist/components/motion/scroll-reveal.js +1 -1
  144. package/dist/components/motion/select-morph.js +2 -2
  145. package/dist/components/motion/select.js +2 -2
  146. package/dist/components/motion/shader-background.js +1 -1
  147. package/dist/components/motion/shared-layout-bg.js +2 -2
  148. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  149. package/dist/components/motion/slide-action-button.js +1 -1
  150. package/dist/components/motion/smooth-scroll.js +1 -1
  151. package/dist/components/motion/swipeable-list.d.ts +60 -0
  152. package/dist/components/motion/swipeable-list.d.ts.map +1 -0
  153. package/dist/components/motion/swipeable-list.js +254 -0
  154. package/dist/components/motion/swipeable-list.js.map +1 -0
  155. package/dist/components/motion/switch.js +1 -1
  156. package/dist/components/motion/table/index.js +1 -1
  157. package/dist/components/motion/table/row-handle.js +1 -1
  158. package/dist/components/motion/table/table-header.js +2 -2
  159. package/dist/components/motion/table/table-menu.js +1 -1
  160. package/dist/components/motion/tabs.js +1 -1
  161. package/dist/components/motion/text-reveal.js +1 -1
  162. package/dist/components/motion/text-shimmer.js +1 -1
  163. package/dist/components/motion/text-shimmer.js.map +1 -1
  164. package/dist/components/motion/theme-toggle.js +2 -2
  165. package/dist/components/motion/tilt-card.js +1 -1
  166. package/dist/components/motion/tooltip.js +1 -1
  167. package/dist/components/motion/wheel-picker.js +1 -1
  168. package/dist/components/reui/alert.d.ts +1 -1
  169. package/dist/components/reui/alert.js +1 -1
  170. package/dist/components/reui/autocomplete.js +1 -1
  171. package/dist/components/reui/badge.d.ts +1 -1
  172. package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
  173. package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
  174. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
  175. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
  176. package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
  177. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  178. package/dist/components/reui/date-selector.js +2 -2
  179. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
  180. package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
  181. package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
  182. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  183. package/dist/components/reui/filters.js +2 -2
  184. package/dist/components/reui/frame.d.ts +1 -1
  185. package/dist/components/reui/frame.js +1 -1
  186. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  187. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  188. package/dist/components/reui/gantt/gantt-view.js +2 -2
  189. package/dist/components/reui/number-field.js +1 -1
  190. package/dist/components/reui/phone-input.js +2 -2
  191. package/dist/components/reui/rating.js +1 -1
  192. package/dist/components/reui/tree.js +1 -1
  193. package/dist/components/ui/accordion.js +1 -1
  194. package/dist/components/ui/alert-dialog.js +1 -1
  195. package/dist/components/ui/alert.js +1 -1
  196. package/dist/components/ui/attachment.d.ts +1 -1
  197. package/dist/components/ui/attachment.js +1 -1
  198. package/dist/components/ui/badge.d.ts +1 -1
  199. package/dist/components/ui/breadcrumb.js +1 -1
  200. package/dist/components/ui/bubble.d.ts +1 -1
  201. package/dist/components/ui/bubble.js +1 -1
  202. package/dist/components/ui/button-group.d.ts +1 -1
  203. package/dist/components/ui/button-group.js +1 -1
  204. package/dist/components/ui/button.d.ts +2 -2
  205. package/dist/components/ui/button.js +2 -2
  206. package/dist/components/ui/calendar.js +1 -1
  207. package/dist/components/ui/carousel.js +1 -1
  208. package/dist/components/ui/checkbox.js +1 -1
  209. package/dist/components/ui/combobox.js +1 -1
  210. package/dist/components/ui/command.js +1 -1
  211. package/dist/components/ui/context-menu.js +1 -1
  212. package/dist/components/ui/dialog.js +1 -1
  213. package/dist/components/ui/dropdown-menu.js +1 -1
  214. package/dist/components/ui/empty.js +1 -1
  215. package/dist/components/ui/field.d.ts +1 -1
  216. package/dist/components/ui/field.js +1 -1
  217. package/dist/components/ui/input-group.js +1 -1
  218. package/dist/components/ui/input-otp.js +1 -1
  219. package/dist/components/ui/item.d.ts +2 -2
  220. package/dist/components/ui/item.js +1 -1
  221. package/dist/components/ui/marker.d.ts +1 -1
  222. package/dist/components/ui/marker.js +1 -1
  223. package/dist/components/ui/menubar.js +1 -1
  224. package/dist/components/ui/message-scroller.js +1 -1
  225. package/dist/components/ui/native-select.js +1 -1
  226. package/dist/components/ui/navigation-menu.js +1 -1
  227. package/dist/components/ui/pagination.js +1 -1
  228. package/dist/components/ui/select.js +1 -1
  229. package/dist/components/ui/sheet.js +1 -1
  230. package/dist/components/ui/sidebar.d.ts +1 -1
  231. package/dist/components/ui/sidebar.js +1 -1
  232. package/dist/components/ui/sonner.js +1 -1
  233. package/dist/components/ui/spinner.js +1 -1
  234. package/dist/components/ui/tabs.js +1 -1
  235. package/dist/components/ui/toast.js +1 -1
  236. package/dist/components/ui/toggle.d.ts +1 -1
  237. package/dist/components/ui/toggle.js +1 -1
  238. package/dist/copy-menu-BJ-MXnkN.js +201 -0
  239. package/dist/copy-menu-BJ-MXnkN.js.map +1 -0
  240. package/dist/types-smkWN_7x.d.ts +20 -0
  241. package/dist/types-smkWN_7x.d.ts.map +1 -0
  242. package/package.json +2 -2
@@ -0,0 +1,272 @@
1
+ "use client";
2
+ import { EASE_OUT } from "../../lib/ease.js";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { cn } from "@kumix/utils";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AnimatePresence, animate, motion, useReducedMotion } from "motion/react";
7
+ //#region src/components/motion/otp-input.tsx
8
+ function OTPInput({ length = 6, value: controlledValue, defaultValue = "", onChange, onComplete, label, hint, successMessage, errorMessage, status = "idle", mask = false, disabled = false, autoFocus = false, "aria-label": ariaLabel = "One-time passcode", className }) {
9
+ const uid = useId();
10
+ const reduce = useReducedMotion();
11
+ const inputRef = useRef(null);
12
+ const slotsRef = useRef(null);
13
+ const controlled = controlledValue !== void 0;
14
+ const [slots, setSlots] = useState(() => toSlots(controlled ? controlledValue : defaultValue, length));
15
+ const [focused, setFocused] = useState(false);
16
+ const [active, setActive] = useState(0);
17
+ const joined = slots.join("");
18
+ const joinedRef = useRef(joined);
19
+ useEffect(() => {
20
+ joinedRef.current = joined;
21
+ }, [joined]);
22
+ useEffect(() => {
23
+ if (!controlled) return;
24
+ const incoming = sanitize(controlledValue, length);
25
+ if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));
26
+ }, [
27
+ controlled,
28
+ controlledValue,
29
+ length
30
+ ]);
31
+ const commit = (next) => {
32
+ const wasComplete = slots.every((c) => c !== "");
33
+ setSlots(next);
34
+ const str = next.join("");
35
+ onChange?.(str);
36
+ if (!wasComplete && next.every((c) => c !== "")) onComplete?.(str);
37
+ };
38
+ const clearSlot = (idx) => {
39
+ const next = [...slots];
40
+ next[idx] = "";
41
+ commit(next);
42
+ };
43
+ const slotFromClientX = (clientX) => {
44
+ const els = slotsRef.current?.children;
45
+ if (!els) return 0;
46
+ for (let i = 0; i < els.length; i++) if (clientX < els[i].getBoundingClientRect().right) return i;
47
+ return length - 1;
48
+ };
49
+ const insert = (raw, from = active) => {
50
+ const digits = raw.replace(/\D/g, "");
51
+ if (!digits) return;
52
+ const next = [...slots];
53
+ let i = from;
54
+ for (const ch of digits) {
55
+ if (i >= length) break;
56
+ next[i] = ch;
57
+ i++;
58
+ }
59
+ commit(next);
60
+ setActive(Math.min(i, length - 1));
61
+ };
62
+ const onKeyDown = (e) => {
63
+ if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;
64
+ const k = e.key;
65
+ if (/^[0-9]$/.test(k)) {
66
+ e.preventDefault();
67
+ insert(k);
68
+ } else if (k === "Backspace") {
69
+ e.preventDefault();
70
+ if (slots[active]) clearSlot(active);
71
+ else if (active > 0) {
72
+ clearSlot(active - 1);
73
+ setActive((current) => Math.max(current - 1, 0));
74
+ }
75
+ } else if (k === "Delete") {
76
+ e.preventDefault();
77
+ clearSlot(active);
78
+ } else if (k === "ArrowLeft") {
79
+ e.preventDefault();
80
+ setActive((a) => Math.max(a - 1, 0));
81
+ } else if (k === "ArrowRight") {
82
+ e.preventDefault();
83
+ setActive((a) => Math.min(a + 1, length - 1));
84
+ } else if (k === "Home") {
85
+ e.preventDefault();
86
+ setActive(0);
87
+ } else if (k === "End") {
88
+ e.preventDefault();
89
+ setActive(length - 1);
90
+ }
91
+ };
92
+ const onPaste = (e) => {
93
+ if (disabled) return;
94
+ e.preventDefault();
95
+ insert(e.clipboardData.getData("text"), active);
96
+ };
97
+ const onChangeNative = (e) => {
98
+ const digits = sanitize(e.target.value, length);
99
+ if (!digits) return;
100
+ commit(toSlots(digits, length));
101
+ setActive(Math.min(digits.length, length - 1));
102
+ };
103
+ useEffect(() => {
104
+ if (status !== "error" || reduce || !slotsRef.current) return;
105
+ animate(slotsRef.current, { x: [
106
+ 0,
107
+ -5,
108
+ 5,
109
+ -3,
110
+ 3,
111
+ -1,
112
+ 0
113
+ ] }, {
114
+ duration: .45,
115
+ ease: EASE_OUT
116
+ });
117
+ }, [status, reduce]);
118
+ const showSuccess = status === "success";
119
+ const activeIndex = focused ? active : -1;
120
+ const message = showSuccess ? successMessage : status === "error" ? errorMessage : hint;
121
+ return /* @__PURE__ */ jsxs("div", {
122
+ className: cn("inline-flex flex-col gap-2", className),
123
+ children: [
124
+ label ? /* @__PURE__ */ jsx("label", {
125
+ htmlFor: `${uid}-input`,
126
+ className: "font-medium text-foreground text-sm",
127
+ children: label
128
+ }) : null,
129
+ /* @__PURE__ */ jsxs("fieldset", {
130
+ className: "relative m-0 inline-flex w-max border-0 p-0",
131
+ onMouseDown: (e) => {
132
+ if (disabled) return;
133
+ e.preventDefault();
134
+ const firstEmpty = slots.indexOf("");
135
+ const cap = firstEmpty === -1 ? length - 1 : firstEmpty;
136
+ setActive(Math.min(slotFromClientX(e.clientX), cap));
137
+ inputRef.current?.focus();
138
+ },
139
+ children: [
140
+ /* @__PURE__ */ jsx("input", {
141
+ ref: inputRef,
142
+ id: `${uid}-input`,
143
+ inputMode: "numeric",
144
+ autoComplete: "one-time-code",
145
+ autoFocus,
146
+ disabled,
147
+ "aria-label": ariaLabel,
148
+ "aria-invalid": status === "error",
149
+ value: "",
150
+ maxLength: length,
151
+ onKeyDown,
152
+ onChange: onChangeNative,
153
+ onPaste,
154
+ onFocus: () => setFocused(true),
155
+ onBlur: () => setFocused(false),
156
+ className: "absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed"
157
+ }),
158
+ /* @__PURE__ */ jsx("div", {
159
+ ref: slotsRef,
160
+ className: "flex items-center gap-2",
161
+ children: Array.from({ length }, (_, i) => {
162
+ const char = slots[i] ?? "";
163
+ const isActive = i === activeIndex;
164
+ return /* @__PURE__ */ jsxs("div", {
165
+ "data-active": isActive,
166
+ "data-filled": char !== "",
167
+ className: cn("relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200", showSuccess ? "border-emerald-500/60 text-foreground" : status === "error" ? "border-destructive/60 text-foreground" : char ? "border-border-strong text-foreground" : "border-border text-muted-foreground", isActive && !showSuccess && status !== "error" && "border-foreground", disabled && "opacity-50"),
168
+ children: [isActive && !showSuccess ? /* @__PURE__ */ jsx(motion.span, {
169
+ "aria-hidden": true,
170
+ animate: reduce ? void 0 : { opacity: [
171
+ 1,
172
+ 1,
173
+ 0,
174
+ 0
175
+ ] },
176
+ transition: reduce ? void 0 : {
177
+ duration: 1,
178
+ repeat: Number.POSITIVE_INFINITY,
179
+ ease: "linear"
180
+ },
181
+ className: cn("pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground", char ? "right-3" : "left-1/2 -translate-x-1/2")
182
+ }) : null, /* @__PURE__ */ jsx(AnimatePresence, {
183
+ initial: false,
184
+ children: char ? /* @__PURE__ */ jsx(motion.span, {
185
+ initial: reduce ? { opacity: 0 } : {
186
+ y: 14,
187
+ opacity: 0,
188
+ filter: "blur(4px)"
189
+ },
190
+ animate: reduce ? { opacity: 1 } : {
191
+ y: 0,
192
+ opacity: 1,
193
+ filter: "blur(0px)"
194
+ },
195
+ exit: reduce ? { opacity: 0 } : {
196
+ y: -14,
197
+ opacity: 0,
198
+ filter: "blur(4px)"
199
+ },
200
+ transition: reduce ? { duration: 0 } : {
201
+ duration: .22,
202
+ ease: EASE_OUT
203
+ },
204
+ className: "absolute inset-0 grid place-items-center leading-none",
205
+ children: mask ? "•" : char
206
+ }, char) : null
207
+ })]
208
+ }, `${uid}-${i}`);
209
+ })
210
+ }),
211
+ /* @__PURE__ */ jsx(AnimatePresence, { children: showSuccess ? /* @__PURE__ */ jsx(motion.span, {
212
+ initial: reduce ? { opacity: 0 } : {
213
+ scale: .6,
214
+ opacity: 0
215
+ },
216
+ animate: reduce ? { opacity: 1 } : {
217
+ scale: 1,
218
+ opacity: 1
219
+ },
220
+ exit: reduce ? { opacity: 0 } : {
221
+ scale: .6,
222
+ opacity: 0
223
+ },
224
+ transition: reduce ? { duration: 0 } : {
225
+ type: "spring",
226
+ stiffness: 500,
227
+ damping: 28
228
+ },
229
+ className: "pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500",
230
+ "aria-hidden": true,
231
+ children: /* @__PURE__ */ jsxs("svg", {
232
+ width: "20",
233
+ height: "20",
234
+ viewBox: "0 0 24 24",
235
+ fill: "none",
236
+ stroke: "currentColor",
237
+ strokeWidth: 3,
238
+ strokeLinecap: "round",
239
+ strokeLinejoin: "round",
240
+ children: [/* @__PURE__ */ jsx("title", { children: "Verified" }), /* @__PURE__ */ jsx(motion.path, {
241
+ d: "M5 13l4 4L19 7",
242
+ initial: reduce ? { pathLength: 1 } : { pathLength: 0 },
243
+ animate: { pathLength: 1 },
244
+ transition: reduce ? { duration: 0 } : {
245
+ duration: .35,
246
+ ease: EASE_OUT,
247
+ delay: .1
248
+ }
249
+ })]
250
+ })
251
+ }) : null })
252
+ ]
253
+ }),
254
+ message ? /* @__PURE__ */ jsx("p", {
255
+ "aria-live": "polite",
256
+ className: cn("text-sm", showSuccess ? "text-emerald-500" : status === "error" ? "text-destructive" : "text-muted-foreground"),
257
+ children: message
258
+ }) : null
259
+ ]
260
+ });
261
+ }
262
+ function sanitize(raw, length) {
263
+ return raw.replace(/\D/g, "").slice(0, length);
264
+ }
265
+ function toSlots(raw, length) {
266
+ const digits = sanitize(raw, length);
267
+ return Array.from({ length }, (_, i) => digits[i] ?? "");
268
+ }
269
+ //#endregion
270
+ export { OTPInput };
271
+
272
+ //# sourceMappingURL=otp-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otp-input.js","names":[],"sources":["../../../src/components/motion/otp-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OTPStatus = \"idle\" | \"error\" | \"success\";\n\nexport interface OTPInputProps {\n /** Number of slots. Default 6. */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Fires once every slot is filled. */\n onComplete?: (value: string) => void;\n /** Optional label rendered above the slots. */\n label?: string;\n /** Helper text shown below the slots while idle. */\n hint?: string;\n /** Message shown below the slots when status is \"success\". */\n successMessage?: string;\n /** Message shown below the slots when status is \"error\". */\n errorMessage?: string;\n /** External validation feedback. \"error\" shakes, \"success\" draws a check. */\n status?: OTPStatus;\n /** Render dots instead of the typed digits. */\n mask?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Accessible label for the underlying input. */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function OTPInput({\n length = 6,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onComplete,\n label,\n hint,\n successMessage,\n errorMessage,\n status = \"idle\",\n mask = false,\n disabled = false,\n autoFocus = false,\n \"aria-label\": ariaLabel = \"One-time passcode\",\n className,\n}: OTPInputProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const inputRef = useRef<HTMLInputElement>(null);\n const slotsRef = useRef<HTMLDivElement>(null);\n\n const controlled = controlledValue !== undefined;\n\n // Source of truth is a fixed-length array, so a cleared middle slot stays an\n // in-place hole instead of collapsing the digits after it to the left.\n const [slots, setSlots] = useState<string[]>(() =>\n toSlots(controlled ? controlledValue : defaultValue, length),\n );\n const [focused, setFocused] = useState(false);\n const [active, setActive] = useState(0);\n\n const joined = slots.join(\"\");\n const joinedRef = useRef(joined);\n\n useEffect(() => {\n joinedRef.current = joined;\n }, [joined]);\n\n // Pull in external value changes; skip when the parent is just echoing our own\n // onChange, so internal holes survive the controlled round-trip.\n useEffect(() => {\n if (!controlled) return;\n const incoming = sanitize(controlledValue, length);\n if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));\n }, [controlled, controlledValue, length]);\n\n const commit = (next: string[]) => {\n const wasComplete = slots.every((c) => c !== \"\");\n setSlots(next);\n const str = next.join(\"\");\n onChange?.(str);\n // Fire only on the empty→full transition, not on every edit of a full code.\n if (!wasComplete && next.every((c) => c !== \"\")) onComplete?.(str);\n };\n\n const clearSlot = (idx: number) => {\n const next = [...slots];\n next[idx] = \"\";\n commit(next);\n };\n\n const slotFromClientX = (clientX: number) => {\n const els = slotsRef.current?.children;\n if (!els) return 0;\n for (let i = 0; i < els.length; i++) {\n if (clientX < els[i].getBoundingClientRect().right) return i;\n }\n return length - 1;\n };\n\n // Single insertion path: one digit overwrites the active slot and advances; a\n // multi-digit chunk (paste / SMS autofill) fills forward from the active slot.\n const insert = (raw: string, from = active) => {\n const digits = raw.replace(/\\D/g, \"\");\n if (!digits) return;\n const next = [...slots];\n let i = from;\n for (const ch of digits) {\n if (i >= length) break;\n next[i] = ch;\n i++;\n }\n commit(next);\n setActive(Math.min(i, length - 1));\n };\n\n // The keyboard is the single source of truth: preventDefault on keydown\n // reliably blocks native insertion (unlike beforeinput in React), so the hidden\n // input never accumulates a competing string and slot holes survive.\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;\n const k = e.key;\n if (/^[0-9]$/.test(k)) {\n e.preventDefault();\n insert(k);\n } else if (k === \"Backspace\") {\n e.preventDefault();\n // A filled slot clears in place; an empty slot steps back and clears there.\n if (slots[active]) {\n clearSlot(active);\n } else if (active > 0) {\n clearSlot(active - 1);\n setActive((current) => Math.max(current - 1, 0));\n }\n } else if (k === \"Delete\") {\n e.preventDefault();\n clearSlot(active);\n } else if (k === \"ArrowLeft\") {\n e.preventDefault();\n setActive((a) => Math.max(a - 1, 0));\n } else if (k === \"ArrowRight\") {\n e.preventDefault();\n setActive((a) => Math.min(a + 1, length - 1));\n } else if (k === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (k === \"End\") {\n e.preventDefault();\n setActive(length - 1);\n }\n };\n\n const onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n if (disabled) return;\n // preventDefault suppresses the duplicate onChange, keeping that path autofill-only.\n e.preventDefault();\n insert(e.clipboardData.getData(\"text\"), active);\n };\n\n // Autofill path: SMS one-time-code arrives as a whole value in one shot.\n // Keystrokes go through onKeyDown and paste through onPaste, so only autofill\n // reaches here — spread it across the slots from the start.\n const onChangeNative = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = sanitize(e.target.value, length);\n if (!digits) return;\n commit(toSlots(digits, length));\n setActive(Math.min(digits.length, length - 1));\n };\n\n // Error shake — imperative so it replays on every transition into \"error\".\n useEffect(() => {\n if (status !== \"error\" || reduce || !slotsRef.current) return;\n animate(slotsRef.current, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.45, ease: EASE_OUT });\n }, [status, reduce]);\n\n const showSuccess = status === \"success\";\n const activeIndex = focused ? active : -1;\n const message = showSuccess ? successMessage : status === \"error\" ? errorMessage : hint;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n {label ? (\n <label htmlFor={`${uid}-input`} className=\"font-medium text-foreground text-sm\">\n {label}\n </label>\n ) : null}\n <fieldset\n className=\"relative m-0 inline-flex w-max border-0 p-0\"\n onMouseDown={(e) => {\n if (disabled) return;\n // Suppress the native click-caret; we drive the active slot ourselves.\n e.preventDefault();\n // Clamp to the first empty slot so a click can't jump ahead of progress.\n const firstEmpty = slots.indexOf(\"\");\n const cap = firstEmpty === -1 ? length - 1 : firstEmpty;\n setActive(Math.min(slotFromClientX(e.clientX), cap));\n inputRef.current?.focus();\n }}\n >\n <input\n ref={inputRef}\n id={`${uid}-input`}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-invalid={status === \"error\"}\n // Kept empty on purpose — our state owns the digits, native holds none.\n value=\"\"\n maxLength={length}\n onKeyDown={onKeyDown}\n onChange={onChangeNative}\n onPaste={onPaste}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n // Transparent overlay owns focus, the soft keyboard, paste and autofill;\n // the slots below are purely presentational.\n className=\"absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed\"\n />\n\n <div ref={slotsRef} className=\"flex items-center gap-2\">\n {Array.from({ length }, (_, i) => {\n const char = slots[i] ?? \"\";\n const isActive = i === activeIndex;\n return (\n <div\n key={`${uid}-${i}`}\n data-active={isActive}\n data-filled={char !== \"\"}\n className={cn(\n \"relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200\",\n showSuccess\n ? \"border-emerald-500/60 text-foreground\"\n : status === \"error\"\n ? \"border-destructive/60 text-foreground\"\n : char\n ? \"border-border-strong text-foreground\"\n : \"border-border text-muted-foreground\",\n // Active slot reads stronger; twMerge lets this win the border.\n isActive && !showSuccess && status !== \"error\" && \"border-foreground\",\n disabled && \"opacity-50\",\n )}\n >\n {/* Blinking caret marks the active slot — centered when empty,\n trailing the digit when the slot is already filled. */}\n {isActive && !showSuccess ? (\n <motion.span\n aria-hidden\n animate={reduce ? undefined : { opacity: [1, 1, 0, 0] }}\n transition={\n reduce\n ? undefined\n : { duration: 1, repeat: Number.POSITIVE_INFINITY, ease: \"linear\" }\n }\n className={cn(\n \"pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground\",\n char ? \"right-3\" : \"left-1/2 -translate-x-1/2\",\n )}\n />\n ) : null}\n\n {/* Digits roll vertically. Each is absolutely centered so enter and\n exit overlap in place — no in-flow reflow, no sideways drift. */}\n <AnimatePresence initial={false}>\n {char ? (\n <motion.span\n key={char}\n initial={reduce ? { opacity: 0 } : { y: 14, opacity: 0, filter: \"blur(4px)\" }}\n animate={reduce ? { opacity: 1 } : { y: 0, opacity: 1, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { y: -14, opacity: 0, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.22, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center leading-none\"\n >\n {mask ? \"•\" : char}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </div>\n );\n })}\n </div>\n\n <AnimatePresence>\n {showSuccess ? (\n <motion.span\n initial={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n animate={reduce ? { opacity: 1 } : { scale: 1, opacity: 1 }}\n exit={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n transition={\n reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 28 }\n }\n className=\"pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500\"\n aria-hidden\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <title>Verified</title>\n <motion.path\n d=\"M5 13l4 4L19 7\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce ? { duration: 0 } : { duration: 0.35, ease: EASE_OUT, delay: 0.1 }\n }\n />\n </svg>\n </motion.span>\n ) : null}\n </AnimatePresence>\n </fieldset>\n\n {message ? (\n <p\n aria-live=\"polite\"\n className={cn(\n \"text-sm\",\n showSuccess\n ? \"text-emerald-500\"\n : status === \"error\"\n ? \"text-destructive\"\n : \"text-muted-foreground\",\n )}\n >\n {message}\n </p>\n ) : null}\n </div>\n );\n}\n\nfunction sanitize(raw: string, length: number) {\n return raw.replace(/\\D/g, \"\").slice(0, length);\n}\n\nfunction toSlots(raw: string, length: number) {\n const digits = sanitize(raw, length);\n return Array.from({ length }, (_, i) => digits[i] ?? \"\");\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,SAAS,EACvB,SAAS,GACT,OAAO,iBACP,eAAe,IACf,UACA,YACA,OACA,MACA,gBACA,cACA,SAAS,QACT,OAAO,OACP,WAAW,OACX,YAAY,OACZ,cAAc,YAAY,qBAC1B,aACgB;CAChB,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,WAAW,OAAuB,IAAI;CAE5C,MAAM,aAAa,oBAAoB,KAAA;CAIvC,MAAM,CAAC,OAAO,YAAY,eACxB,QAAQ,aAAa,kBAAkB,cAAc,MAAM,CAC7D;CACA,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CAEtC,MAAM,SAAS,MAAM,KAAK,EAAE;CAC5B,MAAM,YAAY,OAAO,MAAM;CAE/B,gBAAgB;EACd,UAAU,UAAU;CACtB,GAAG,CAAC,MAAM,CAAC;CAIX,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,EAAE,YAAY,EAAE;QACtD,SAAS,EAAE,YAAY,EAAE;QACzB,YACE,SAAS,EAAE,UAAU,EAAE,IAAI;SAAE,UAAU;SAAM,MAAM;SAAU,OAAO;QAAI;OAE3E,CAAA,CACE;;KACM,CAAA,IACX,KACW,CAAA;IACT;;GAET,UACC,oBAAC,KAAD;IACE,aAAU;IACV,WAAW,GACT,WACA,cACI,qBACA,WAAW,UACT,qBACA,uBACR;IAEC,UAAA;GACA,CAAA,IACD;EACD;;AAET;AAEA,SAAS,SAAS,KAAa,QAAgB;CAC7C,OAAO,IAAI,QAAQ,OAAO,EAAE,CAAC,CAAC,MAAM,GAAG,MAAM;AAC/C;AAEA,SAAS,QAAQ,KAAa,QAAgB;CAC5C,MAAM,SAAS,SAAS,KAAK,MAAM;CACnC,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,MAAM,OAAO,MAAM,EAAE;AACzD"}
@@ -0,0 +1,39 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/overflow-actions.d.ts
3
+ type OverflowActionsSize = "sm" | "md";
4
+ type OverflowActionItem = {
5
+ id: string;
6
+ label: ReactNode;
7
+ icon?: ReactNode;
8
+ onClick?: () => void;
9
+ disabled?: boolean;
10
+ ariaLabel?: string;
11
+ };
12
+ type OverflowActionsClassNames = {
13
+ root?: string;
14
+ track?: string;
15
+ action?: string;
16
+ primaryAction?: string;
17
+ overflowAction?: string;
18
+ toggle?: string;
19
+ icon?: string;
20
+ label?: string;
21
+ };
22
+ interface OverflowActionsProps {
23
+ primaryActions: OverflowActionItem[];
24
+ overflowActions: OverflowActionItem[];
25
+ expanded?: boolean;
26
+ defaultExpanded?: boolean;
27
+ onExpandedChange?: (expanded: boolean) => void;
28
+ onAction?: (item: OverflowActionItem) => void;
29
+ collapseOnAction?: boolean;
30
+ size?: OverflowActionsSize;
31
+ openLabel?: string;
32
+ closeLabel?: string;
33
+ className?: string;
34
+ classNames?: OverflowActionsClassNames;
35
+ }
36
+ declare function OverflowActions({ primaryActions, overflowActions, expanded, defaultExpanded, onExpandedChange, onAction, collapseOnAction, size, openLabel, closeLabel, className, classNames }: OverflowActionsProps): import("react").JSX.Element;
37
+ //#endregion
38
+ export { OverflowActionItem, OverflowActions, OverflowActionsClassNames, OverflowActionsProps, OverflowActionsSize };
39
+ //# sourceMappingURL=overflow-actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overflow-actions.d.ts","names":[],"sources":["../../../src/components/motion/overflow-actions.tsx"],"mappings":";;KAgBY;KAEA;EACV;EACA,OAAO;EACP,OAAO;EACP;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,gBAAgB;EAChB,iBAAiB;EACjB;EACA;EACA,oBAAoB;EACpB,YAAY,MAAM;EAClB;EACA,OAAO;EACP;EACA;EACA;EACA,aAAa;;iBAiFC,kBACd,gBACA,iBACA,UACA,iBACA,kBACA,UACA,kBACA,MACA,WACA,YACA,WACA,cACC,uCAAoB,IAAA"}
@@ -0,0 +1,220 @@
1
+ "use client";
2
+ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
+ import { EASE_OUT } from "../../lib/ease.js";
4
+ import { useCallback, useId, useLayoutEffect, useRef, useState } from "react";
5
+ import { cn } from "@kumix/utils";
6
+ import { MoreHorizontal, X } from "lucide-react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
9
+ //#region src/components/motion/overflow-actions.tsx
10
+ const SHELL_TRANSITION = {
11
+ type: "spring",
12
+ stiffness: 220,
13
+ damping: 17,
14
+ mass: .85
15
+ };
16
+ const ICON_VARIANTS = {
17
+ hidden: {
18
+ opacity: 0,
19
+ filter: "blur(3px)"
20
+ },
21
+ visible: {
22
+ opacity: 1,
23
+ filter: "blur(0px)",
24
+ transition: {
25
+ duration: .18,
26
+ ease: EASE_OUT
27
+ }
28
+ },
29
+ exit: {
30
+ opacity: 0,
31
+ filter: "blur(3px)",
32
+ transition: {
33
+ duration: .18,
34
+ ease: EASE_OUT
35
+ }
36
+ }
37
+ };
38
+ const OVERFLOW_ACTION_VARIANTS = {
39
+ hidden: {
40
+ opacity: 0,
41
+ filter: "blur(4px)"
42
+ },
43
+ visible: {
44
+ opacity: 1,
45
+ filter: "blur(0px)"
46
+ },
47
+ exit: {
48
+ opacity: 0,
49
+ filter: "blur(4px)"
50
+ }
51
+ };
52
+ const TRACK_SIZE_CLASS = {
53
+ sm: "gap-1 p-1 text-xs",
54
+ md: "gap-1.5 p-1.5 text-sm"
55
+ };
56
+ const GROUP_GAP_CLASS = {
57
+ sm: "gap-1",
58
+ md: "gap-1.5"
59
+ };
60
+ const ACTION_SIZE_CLASS = {
61
+ sm: "h-8 min-w-8 gap-1.5 px-3",
62
+ md: "h-9 min-w-9 gap-2 px-3.5"
63
+ };
64
+ const TOGGLE_SIZE_CLASS = {
65
+ sm: "h-8 w-8",
66
+ md: "h-9 w-9"
67
+ };
68
+ const ICON_SIZE_CLASS = {
69
+ sm: "h-3.5 w-3.5",
70
+ md: "h-4 w-4"
71
+ };
72
+ function useControllableExpanded({ expanded, defaultExpanded, onExpandedChange }) {
73
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);
74
+ const isControlled = expanded !== void 0;
75
+ return [expanded ?? internalExpanded, useCallback((next) => {
76
+ if (!isControlled) setInternalExpanded(next);
77
+ onExpandedChange?.(next);
78
+ }, [isControlled, onExpandedChange])];
79
+ }
80
+ function OverflowActions({ primaryActions, overflowActions, expanded, defaultExpanded = false, onExpandedChange, onAction, collapseOnAction = false, size = "md", openLabel = "Show extra actions", closeLabel = "Hide extra actions", className, classNames }) {
81
+ const reduce = useReducedMotion();
82
+ const canHover = useHoverCapable();
83
+ const overflowId = useId();
84
+ const overflowWrapperRef = useRef(null);
85
+ const overflowWrapperLeftRef = useRef(0);
86
+ const [isExpanded, setIsExpanded] = useControllableExpanded({
87
+ expanded,
88
+ defaultExpanded,
89
+ onExpandedChange
90
+ });
91
+ const transition = reduce ? { duration: 0 } : SHELL_TRANSITION;
92
+ useLayoutEffect(() => {
93
+ const overflowNode = overflowWrapperRef.current;
94
+ if (!overflowNode) return;
95
+ if (!isExpanded) {
96
+ overflowNode.style.left = `${overflowWrapperLeftRef.current - overflowNode.getBoundingClientRect().left}px`;
97
+ return;
98
+ }
99
+ overflowNode.style.left = "";
100
+ overflowWrapperLeftRef.current = overflowNode.getBoundingClientRect().left;
101
+ }, [isExpanded]);
102
+ const handleAction = (item) => {
103
+ item.onClick?.();
104
+ onAction?.(item);
105
+ if (collapseOnAction) setIsExpanded(false);
106
+ };
107
+ return /* @__PURE__ */ jsx(motion.div, {
108
+ layout: true,
109
+ transition,
110
+ className: cn("inline-flex", classNames?.root, className),
111
+ children: /* @__PURE__ */ jsxs(motion.div, {
112
+ layout: true,
113
+ transition,
114
+ className: cn("relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card", TRACK_SIZE_CLASS[size], classNames?.track),
115
+ children: [
116
+ /* @__PURE__ */ jsx(motion.div, {
117
+ layout: true,
118
+ transition,
119
+ className: cn("inline-flex items-center", GROUP_GAP_CLASS[size]),
120
+ children: primaryActions.map((item) => /* @__PURE__ */ jsx(ActionButton, {
121
+ item,
122
+ size,
123
+ reduce,
124
+ canHover,
125
+ onAction: handleAction,
126
+ layoutTransition: transition,
127
+ className: cn(classNames?.action, classNames?.primaryAction),
128
+ iconClassName: classNames?.icon,
129
+ labelClassName: classNames?.label
130
+ }, item.id))
131
+ }),
132
+ /* @__PURE__ */ jsx(AnimatePresence, {
133
+ mode: "popLayout",
134
+ initial: false,
135
+ children: isExpanded ? /* @__PURE__ */ jsx(motion.div, {
136
+ ref: overflowWrapperRef,
137
+ id: overflowId,
138
+ layout: true,
139
+ "aria-hidden": !isExpanded,
140
+ transition,
141
+ className: cn("relative inline-flex w-max items-center", GROUP_GAP_CLASS[size]),
142
+ children: overflowActions.map((item) => /* @__PURE__ */ jsx(ActionButton, {
143
+ item,
144
+ size,
145
+ reduce,
146
+ canHover,
147
+ overflow: true,
148
+ visible: isExpanded,
149
+ variants: OVERFLOW_ACTION_VARIANTS,
150
+ onAction: handleAction,
151
+ layoutTransition: transition,
152
+ className: cn(classNames?.action, classNames?.overflowAction),
153
+ iconClassName: classNames?.icon,
154
+ labelClassName: classNames?.label
155
+ }, item.id))
156
+ }, "overflow-actions") : null
157
+ }),
158
+ /* @__PURE__ */ jsx(motion.button, {
159
+ type: "button",
160
+ layout: true,
161
+ "aria-expanded": isExpanded,
162
+ "aria-controls": isExpanded ? overflowId : void 0,
163
+ "aria-label": isExpanded ? closeLabel : openLabel,
164
+ title: isExpanded ? closeLabel : openLabel,
165
+ onClick: () => setIsExpanded(!isExpanded),
166
+ whileTap: reduce ? void 0 : { scale: .96 },
167
+ whileHover: reduce || !canHover ? void 0 : { scale: 1.03 },
168
+ transition,
169
+ className: cn("relative inline-grid shrink-0 place-items-center rounded-full bg-primary text-primary-foreground outline-none disabled:pointer-events-none disabled:opacity-50", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", TOGGLE_SIZE_CLASS[size], classNames?.toggle),
170
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
171
+ mode: "popLayout",
172
+ initial: false,
173
+ children: /* @__PURE__ */ jsx(motion.span, {
174
+ variants: ICON_VARIANTS,
175
+ initial: reduce ? { opacity: 0 } : "hidden",
176
+ animate: reduce ? { opacity: 1 } : "visible",
177
+ exit: reduce ? { opacity: 0 } : "exit",
178
+ className: "inline-grid place-items-center",
179
+ children: isExpanded ? /* @__PURE__ */ jsx(X, { className: ICON_SIZE_CLASS[size] }) : /* @__PURE__ */ jsx(MoreHorizontal, { className: ICON_SIZE_CLASS[size] })
180
+ }, isExpanded ? "close" : "open")
181
+ })
182
+ })
183
+ ]
184
+ })
185
+ });
186
+ }
187
+ function ActionButton({ item, size, reduce, canHover, overflow, visible = true, variants, onAction, layoutTransition, className, iconClassName, labelClassName }) {
188
+ const label = typeof item.label === "string" ? item.label : void 0;
189
+ return /* @__PURE__ */ jsx(motion.span, {
190
+ layout: "position",
191
+ variants,
192
+ initial: variants ? reduce ? { opacity: 0 } : "hidden" : void 0,
193
+ animate: variants ? reduce ? { opacity: 1 } : "visible" : void 0,
194
+ exit: variants ? reduce ? { opacity: 0 } : "exit" : void 0,
195
+ whileTap: reduce || item.disabled ? void 0 : { scale: .97 },
196
+ whileHover: reduce || !canHover || item.disabled ? void 0 : { scale: 1.008 },
197
+ transition: layoutTransition,
198
+ className: "inline-flex shrink-0",
199
+ children: /* @__PURE__ */ jsxs("button", {
200
+ type: "button",
201
+ disabled: item.disabled,
202
+ "aria-label": item.ariaLabel,
203
+ tabIndex: overflow && !visible ? -1 : void 0,
204
+ title: label,
205
+ onClick: () => onAction(item),
206
+ className: cn("inline-flex shrink-0 items-center justify-center rounded-full bg-background font-medium text-foreground outline-none", "disabled:pointer-events-none disabled:opacity-45", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", ACTION_SIZE_CLASS[size], className),
207
+ children: [item.icon ? /* @__PURE__ */ jsx("span", {
208
+ className: cn("inline-flex shrink-0 items-center justify-center", ICON_SIZE_CLASS[size], iconClassName),
209
+ children: item.icon
210
+ }) : null, /* @__PURE__ */ jsx("span", {
211
+ className: cn("whitespace-nowrap", labelClassName),
212
+ children: item.label
213
+ })]
214
+ })
215
+ });
216
+ }
217
+ //#endregion
218
+ export { OverflowActions };
219
+
220
+ //# sourceMappingURL=overflow-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overflow-actions.js","names":[],"sources":["../../../src/components/motion/overflow-actions.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { MoreHorizontal, X } from \"lucide-react\";\nimport {\n AnimatePresence,\n motion,\n type Transition,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OverflowActionsSize = \"sm\" | \"md\";\n\nexport type OverflowActionItem = {\n id: string;\n label: ReactNode;\n icon?: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n};\n\nexport type OverflowActionsClassNames = {\n root?: string;\n track?: string;\n action?: string;\n primaryAction?: string;\n overflowAction?: string;\n toggle?: string;\n icon?: string;\n label?: string;\n};\n\nexport interface OverflowActionsProps {\n primaryActions: OverflowActionItem[];\n overflowActions: OverflowActionItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onAction?: (item: OverflowActionItem) => void;\n collapseOnAction?: boolean;\n size?: OverflowActionsSize;\n openLabel?: string;\n closeLabel?: string;\n className?: string;\n classNames?: OverflowActionsClassNames;\n}\n\n// This needs a softer layout spring than the app defaults so the overflow group\n// stays visually attached to the toggle while entering and leaving.\nconst SHELL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 220,\n damping: 17,\n mass: 0.85,\n};\n\nconst ICON_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(3px)\" },\n visible: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n exit: {\n opacity: 0,\n filter: \"blur(3px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n};\n\nconst OVERFLOW_ACTION_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(4px)\" },\n visible: { opacity: 1, filter: \"blur(0px)\" },\n exit: { opacity: 0, filter: \"blur(4px)\" },\n};\n\nconst TRACK_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1 p-1 text-xs\",\n md: \"gap-1.5 p-1.5 text-sm\",\n};\n\nconst GROUP_GAP_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1\",\n md: \"gap-1.5\",\n};\n\nconst ACTION_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 min-w-8 gap-1.5 px-3\",\n md: \"h-9 min-w-9 gap-2 px-3.5\",\n};\n\nconst TOGGLE_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 w-8\",\n md: \"h-9 w-9\",\n};\n\nconst ICON_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function OverflowActions({\n primaryActions,\n overflowActions,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onAction,\n collapseOnAction = false,\n size = \"md\",\n openLabel = \"Show extra actions\",\n closeLabel = \"Hide extra actions\",\n className,\n classNames,\n}: OverflowActionsProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const overflowId = useId();\n const overflowWrapperRef = useRef<HTMLDivElement>(null);\n const overflowWrapperLeftRef = useRef(0);\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n\n const transition = reduce ? { duration: 0 } : SHELL_TRANSITION;\n\n useLayoutEffect(() => {\n const overflowNode = overflowWrapperRef.current;\n if (!overflowNode) return;\n\n if (!isExpanded) {\n overflowNode.style.left = `${\n overflowWrapperLeftRef.current - overflowNode.getBoundingClientRect().left\n }px`;\n return;\n }\n\n overflowNode.style.left = \"\";\n overflowWrapperLeftRef.current = overflowNode.getBoundingClientRect().left;\n }, [isExpanded]);\n\n const handleAction = (item: OverflowActionItem) => {\n item.onClick?.();\n onAction?.(item);\n if (collapseOnAction) setIsExpanded(false);\n };\n\n return (\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex\", classNames?.root, className)}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\n \"relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card\",\n TRACK_SIZE_CLASS[size],\n classNames?.track,\n )}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex items-center\", GROUP_GAP_CLASS[size])}\n >\n {primaryActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.primaryAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"overflow-actions\"\n ref={overflowWrapperRef}\n id={overflowId}\n layout\n aria-hidden={!isExpanded}\n transition={transition}\n className={cn(\"relative inline-flex w-max items-center\", GROUP_GAP_CLASS[size])}\n >\n {overflowActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n overflow\n visible={isExpanded}\n variants={OVERFLOW_ACTION_VARIANTS}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.overflowAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <motion.button\n type=\"button\"\n layout\n aria-expanded={isExpanded}\n aria-controls={isExpanded ? overflowId : undefined}\n aria-label={isExpanded ? closeLabel : openLabel}\n title={isExpanded ? closeLabel : openLabel}\n onClick={() => setIsExpanded(!isExpanded)}\n whileTap={reduce ? undefined : { scale: 0.96 }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.03 }}\n transition={transition}\n className={cn(\n \"relative inline-grid shrink-0 place-items-center rounded-full bg-primary text-primary-foreground outline-none disabled:pointer-events-none disabled:opacity-50\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n TOGGLE_SIZE_CLASS[size],\n classNames?.toggle,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={isExpanded ? \"close\" : \"open\"}\n variants={ICON_VARIANTS}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"visible\"}\n exit={reduce ? { opacity: 0 } : \"exit\"}\n className=\"inline-grid place-items-center\"\n >\n {isExpanded ? (\n <X className={ICON_SIZE_CLASS[size]} />\n ) : (\n <MoreHorizontal className={ICON_SIZE_CLASS[size]} />\n )}\n </motion.span>\n </AnimatePresence>\n </motion.button>\n </motion.div>\n </motion.div>\n );\n}\n\nfunction ActionButton({\n item,\n size,\n reduce,\n canHover,\n overflow,\n visible = true,\n variants,\n onAction,\n layoutTransition,\n className,\n iconClassName,\n labelClassName,\n}: {\n item: OverflowActionItem;\n size: OverflowActionsSize;\n reduce: boolean | null;\n canHover: boolean;\n overflow?: boolean;\n visible?: boolean;\n variants?: Variants;\n onAction: (item: OverflowActionItem) => void;\n layoutTransition: Transition;\n className?: string;\n iconClassName?: string;\n labelClassName?: string;\n}) {\n const label = typeof item.label === \"string\" ? item.label : undefined;\n\n return (\n <motion.span\n layout=\"position\"\n variants={variants}\n initial={variants ? (reduce ? { opacity: 0 } : \"hidden\") : undefined}\n animate={variants ? (reduce ? { opacity: 1 } : \"visible\") : undefined}\n exit={variants ? (reduce ? { opacity: 0 } : \"exit\") : undefined}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.97 }}\n whileHover={reduce || !canHover || item.disabled ? undefined : { scale: 1.008 }}\n transition={layoutTransition}\n className=\"inline-flex shrink-0\"\n >\n <button\n type=\"button\"\n disabled={item.disabled}\n aria-label={item.ariaLabel}\n tabIndex={overflow && !visible ? -1 : undefined}\n title={label}\n onClick={() => onAction(item)}\n className={cn(\n \"inline-flex shrink-0 items-center justify-center rounded-full bg-background font-medium text-foreground outline-none\",\n \"disabled:pointer-events-none disabled:opacity-45\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n ACTION_SIZE_CLASS[size],\n className,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n iconClassName,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span className={cn(\"whitespace-nowrap\", labelClassName)}>{item.label}</span>\n </button>\n </motion.span>\n );\n}\n"],"mappings":";;;;;;;;;AAuDA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,gBAA0B;CAC9B,QAAQ;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC1C,SAAS;EACP,SAAS;EACT,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;CAC/C;CACA,MAAM;EACJ,SAAS;EACT,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;CAC/C;AACF;AAEA,MAAM,2BAAqC;CACzC,QAAQ;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC1C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,MAAM;EAAE,SAAS;EAAG,QAAQ;CAAY;AAC1C;AAEA,MAAM,mBAAwD;CAC5D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAAuD;CAC3D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,oBAAyD;CAC7D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,oBAAyD;CAC7D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAAuD;CAC3D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC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@
1
1
  "use client";
2
2
  import { useRef } from "react";
3
3
  import { cn } from "@kumix/utils";
4
- import { motion, useReducedMotion, useScroll, useSpring, useTransform } from "motion/react";
5
4
  import { jsx } from "react/jsx-runtime";
5
+ import { motion, useReducedMotion, useScroll, useSpring, useTransform } from "motion/react";
6
6
  //#region src/components/motion/parallax.tsx
7
7
  const PARALLAX_SPRING = {
8
8
  stiffness: 120,
@@ -3,8 +3,8 @@ import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
3
3
  import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.js";
4
4
  import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
5
5
  import { cn } from "@kumix/utils";
6
- import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
6
  import { jsx } from "react/jsx-runtime";
7
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
8
8
  import { createPortal } from "react-dom";
9
9
  //#region src/components/motion/popover-morph.tsx
10
10
  const MorphContext = createContext(null);
@@ -148,7 +148,7 @@ function MorphPopoverContent({ children, side = "bottom", align = "end", sideOff
148
148
  visibility: layout ? "visible" : "hidden",
149
149
  transformOrigin: originFor(side, align)
150
150
  },
151
- className: "fixed z-[9999] [filter:drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]",
151
+ className: "filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))] fixed z-9999",
152
152
  children: /* @__PURE__ */ jsx(motion.div, {
153
153
  ref: ctx.contentRef,
154
154
  id: ctx.contentId,