@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
@@ -2,8 +2,8 @@
2
2
  import { SPRING_LAYOUT } from "../../lib/ease.js";
3
3
  import { createContext, useContext, useId, useMemo } from "react";
4
4
  import { cn } from "@kumix/utils";
5
- import { motion, useReducedMotion } from "motion/react";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/dock.tsx
8
8
  const DockContext = createContext(null);
9
9
  function Dock({ children, size = 44, className }) {
@@ -2,8 +2,8 @@
2
2
  import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
3
3
  import { useEffect } from "react";
4
4
  import { cn } from "@kumix/utils";
5
- import { AnimatePresence, motion, useReducedMotion } from "motion/react";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/drawer.tsx
8
8
  function Drawer({ open, onOpenChange, side = "right", children, className, backdropClassName, ariaLabel, dismissable = true }) {
9
9
  const reduce = useReducedMotion();
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/dynamic-island.d.ts
3
+ interface DynamicIslandProps {
4
+ /** Active view id. `null` shows the compact pill. */
5
+ view: string | null;
6
+ /** Compact pill content, shown when no view is active. */
7
+ compact?: ReactNode;
8
+ /** DynamicIslandView elements. */
9
+ children?: ReactNode;
10
+ className?: string;
11
+ }
12
+ declare function DynamicIsland({ view, compact, children, className }: DynamicIslandProps): import("react").JSX.Element;
13
+ interface DynamicIslandViewProps {
14
+ /** Matches the parent `view` prop when active. */
15
+ id: string;
16
+ children: ReactNode;
17
+ className?: string;
18
+ }
19
+ declare function DynamicIslandView({ id, children, className }: DynamicIslandViewProps): import("react").JSX.Element;
20
+ //#endregion
21
+ export { DynamicIsland, DynamicIslandProps, DynamicIslandView, DynamicIslandViewProps };
22
+ //# sourceMappingURL=dynamic-island.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-island.d.ts","names":[],"sources":["../../../src/components/motion/dynamic-island.tsx"],"mappings":";;UAiIiB;;EAEf;;EAEA,UAAU;;EAEV,WAAW;EACX;;iBAGc,gBAAgB,MAAM,SAAS,UAAU,aAAa,qCAAkB,IAAA;UAiDvE;;EAEf;EACA,UAAU;EACV;;iBAGc,oBAAoB,IAAI,UAAU,aAAa,yCAAsB,IAAA"}
@@ -0,0 +1,143 @@
1
+ "use client";
2
+ import { EASE_OUT } from "../../lib/ease.js";
3
+ import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { cn } from "@kumix/utils";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
+ //#region src/components/motion/dynamic-island.tsx
8
+ const IslandContext = createContext(null);
9
+ const SHELL_SPRING = {
10
+ type: "spring",
11
+ duration: .8,
12
+ bounce: .2
13
+ };
14
+ const CONTENT_SPRING = {
15
+ type: "spring",
16
+ duration: .8,
17
+ bounce: .35
18
+ };
19
+ const RADIUS = 32;
20
+ const PILL_WIDTH = 126;
21
+ const PILL_HEIGHT = 37;
22
+ /** Tracks the natural size of the content so the shell can spring to it. */
23
+ function useContentSize() {
24
+ const ref = useRef(null);
25
+ const [size, setSize] = useState(null);
26
+ useLayoutEffect(() => {
27
+ const el = ref.current;
28
+ if (!el) return;
29
+ setSize({
30
+ width: el.offsetWidth,
31
+ height: el.offsetHeight
32
+ });
33
+ }, []);
34
+ useEffect(() => {
35
+ const el = ref.current;
36
+ if (!el || typeof ResizeObserver === "undefined") return;
37
+ const observer = new ResizeObserver(() => {
38
+ setSize({
39
+ width: el.offsetWidth,
40
+ height: el.offsetHeight
41
+ });
42
+ });
43
+ observer.observe(el);
44
+ return () => observer.disconnect();
45
+ }, []);
46
+ return [ref, size];
47
+ }
48
+ function Slot({ keyId, children, className }) {
49
+ const reduce = useReducedMotion();
50
+ return /* @__PURE__ */ jsx(motion.div, {
51
+ initial: reduce ? {
52
+ opacity: 0,
53
+ filter: "blur(0px)"
54
+ } : {
55
+ opacity: 0,
56
+ scale: .9,
57
+ y: -8,
58
+ filter: "blur(5px)"
59
+ },
60
+ animate: reduce ? {
61
+ opacity: 1,
62
+ filter: "blur(0px)"
63
+ } : {
64
+ opacity: 1,
65
+ scale: 1,
66
+ y: 0,
67
+ filter: "blur(0px)"
68
+ },
69
+ exit: reduce ? {
70
+ opacity: 0,
71
+ filter: "blur(0px)",
72
+ transition: { duration: .1 }
73
+ } : {
74
+ opacity: 0,
75
+ scale: .9,
76
+ y: -6,
77
+ filter: "blur(0px)",
78
+ transition: {
79
+ duration: .08,
80
+ ease: EASE_OUT
81
+ }
82
+ },
83
+ transition: reduce ? { duration: .15 } : CONTENT_SPRING,
84
+ style: { transformOrigin: "top center" },
85
+ className: cn("flex items-center justify-center", className),
86
+ children
87
+ }, keyId);
88
+ }
89
+ function DynamicIsland({ view, compact, children, className }) {
90
+ const reduce = useReducedMotion();
91
+ const expanded = view !== null;
92
+ const [sizerRef, size] = useContentSize();
93
+ const contextValue = useMemo(() => ({ view }), [view]);
94
+ return /* @__PURE__ */ jsx(IslandContext.Provider, {
95
+ value: contextValue,
96
+ children: /* @__PURE__ */ jsx(motion.div, {
97
+ role: "status",
98
+ "aria-live": "polite",
99
+ initial: false,
100
+ animate: size ? {
101
+ width: size.width,
102
+ height: size.height
103
+ } : {
104
+ width: PILL_WIDTH,
105
+ height: PILL_HEIGHT
106
+ },
107
+ transition: reduce ? { duration: 0 } : SHELL_SPRING,
108
+ style: { borderRadius: RADIUS },
109
+ className: cn("relative inline-flex items-start justify-center overflow-hidden", "bg-foreground text-background shadow-2xl", className),
110
+ children: /* @__PURE__ */ jsxs("div", {
111
+ ref: sizerRef,
112
+ className: "w-max",
113
+ children: [/* @__PURE__ */ jsx(AnimatePresence, {
114
+ mode: "popLayout",
115
+ initial: false,
116
+ children: !expanded && compact ? /* @__PURE__ */ jsx(Slot, {
117
+ keyId: "compact",
118
+ className: "min-h-[37px] min-w-[126px] gap-2 px-4 py-1.5 font-medium text-xs",
119
+ children: compact
120
+ }) : null
121
+ }), children]
122
+ })
123
+ })
124
+ });
125
+ }
126
+ function DynamicIslandView({ id, children, className }) {
127
+ const ctx = useContext(IslandContext);
128
+ if (!ctx) throw new Error("DynamicIslandView must be used inside <DynamicIsland>");
129
+ const active = ctx.view === id;
130
+ return /* @__PURE__ */ jsx(AnimatePresence, {
131
+ mode: "popLayout",
132
+ initial: false,
133
+ children: active ? /* @__PURE__ */ jsx(Slot, {
134
+ keyId: id,
135
+ className: cn("px-6 py-4", className),
136
+ children
137
+ }) : null
138
+ });
139
+ }
140
+ //#endregion
141
+ export { DynamicIsland, DynamicIslandView };
142
+
143
+ //# sourceMappingURL=dynamic-island.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-island.js","names":[],"sources":["../../../src/components/motion/dynamic-island.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\ntype IslandContextValue = {\n view: string | null;\n};\n\nconst IslandContext = createContext<IslandContextValue | null>(null);\n\n// Shell physics in Apple's duration/bounce form one long perceptual glide with barely-there bounce, identical in\n// both directions. The shell animates real width/height (not transforms), so\n// slots are never scale-distorted.\nconst SHELL_SPRING = {\n type: \"spring\",\n duration: 0.8,\n bounce: 0.2,\n} as const;\n\n// Content gets a touch more life than the shell.\nconst CONTENT_SPRING = {\n type: \"spring\",\n duration: 0.8,\n bounce: 0.35,\n} as const;\n\n// Constant radius — never animated. The browser clamps it to half the shell\n// height, so the pill-to-rounded-rect morph falls out of the resize for free\n// with zero chance of corner glitches.\nconst RADIUS = 32;\n\n// iPhone pill dimensions. Also the shell's pre-measure animate target: if the\n// first commit already has a view active (e.g. a click replayed after\n// hydration), the shell blooms from the pill instead of rendering expanded\n// with no animation. Lives in `animate`, not `initial`, so server and client\n// markup agree.\nconst PILL_WIDTH = 126;\nconst PILL_HEIGHT = 37;\n\n/** Tracks the natural size of the content so the shell can spring to it. */\nfunction useContentSize() {\n const ref = useRef<HTMLDivElement | null>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n\n // Synchronous mount measure: the shell must own explicit dimensions before\n // the first interaction. ResizeObserver fires async after mount — a quick\n // first press could beat it, leaving the shell auto-sized so the view\n // snapped open instead of springing.\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setSize({ width: el.offsetWidth, height: el.offsetHeight });\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(() => {\n setSize({ width: el.offsetWidth, height: el.offsetHeight });\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n\n return [ref, size] as const;\n}\n\nfunction Slot({\n keyId,\n children,\n className,\n}: {\n keyId: string;\n children: ReactNode;\n className?: string;\n}) {\n const reduce = useReducedMotion();\n return (\n <motion.div\n key={keyId}\n initial={\n reduce\n ? { opacity: 0, filter: \"blur(0px)\" }\n : { opacity: 0, scale: 0.9, y: -8, filter: \"blur(5px)\" }\n }\n animate={\n reduce\n ? { opacity: 1, filter: \"blur(0px)\" }\n : { opacity: 1, scale: 1, y: 0, filter: \"blur(0px)\" }\n }\n // Exit gets sucked up into the pill — fast, blur-free, before the\n // shrinking shell can clip it.\n exit={\n reduce\n ? { opacity: 0, filter: \"blur(0px)\", transition: { duration: 0.1 } }\n : {\n opacity: 0,\n scale: 0.9,\n y: -6,\n filter: \"blur(0px)\",\n transition: { duration: 0.08, ease: EASE_OUT },\n }\n }\n // One spring drives transform, opacity and blur together — no per\n // property tweens, no delays. Content travels with the shell.\n transition={reduce ? { duration: 0.15 } : CONTENT_SPRING}\n // Anchored to the pill line: content unfurls downward out of it and is\n // sucked back up into it.\n style={{ transformOrigin: \"top center\" }}\n className={cn(\"flex items-center justify-center\", className)}\n >\n {children}\n </motion.div>\n );\n}\n\nexport interface DynamicIslandProps {\n /** Active view id. `null` shows the compact pill. */\n view: string | null;\n /** Compact pill content, shown when no view is active. */\n compact?: ReactNode;\n /** DynamicIslandView elements. */\n children?: ReactNode;\n className?: string;\n}\n\nexport function DynamicIsland({ view, compact, children, className }: DynamicIslandProps) {\n const reduce = useReducedMotion();\n const expanded = view !== null;\n const [sizerRef, size] = useContentSize();\n const contextValue = useMemo(() => ({ view }), [view]);\n\n return (\n <IslandContext.Provider value={contextValue}>\n <motion.div\n role=\"status\"\n aria-live=\"polite\"\n initial={false}\n animate={\n size\n ? { width: size.width, height: size.height }\n : { width: PILL_WIDTH, height: PILL_HEIGHT }\n }\n transition={reduce ? { duration: 0 } : SHELL_SPRING}\n style={{ borderRadius: RADIUS }}\n // items-start pins content to the top edge while the shell springs, so\n // expansion reads as unfurling downward out of the pill. Top-align the\n // island in its parent (like under a notch) to complete the effect.\n className={cn(\n \"relative inline-flex items-start justify-center overflow-hidden\",\n \"bg-foreground text-background shadow-2xl\",\n className,\n )}\n >\n {/* w-max keeps this at the natural size of the active content; the\n shell springs toward it. */}\n <div ref={sizerRef} className=\"w-max\">\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {!expanded && compact ? (\n <Slot\n keyId=\"compact\"\n // iPhone pill proportions: ~126 x 37.\n className=\"min-h-[37px] min-w-[126px] gap-2 px-4 py-1.5 font-medium text-xs\"\n >\n {compact}\n </Slot>\n ) : null}\n </AnimatePresence>\n {children}\n </div>\n </motion.div>\n </IslandContext.Provider>\n );\n}\n\nexport interface DynamicIslandViewProps {\n /** Matches the parent `view` prop when active. */\n id: string;\n children: ReactNode;\n className?: string;\n}\n\nexport function DynamicIslandView({ id, children, className }: DynamicIslandViewProps) {\n const ctx = useContext(IslandContext);\n if (!ctx) throw new Error(\"DynamicIslandView must be used inside <DynamicIsland>\");\n const active = ctx.view === id;\n\n return (\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {active ? (\n <Slot keyId={id} className={cn(\"px-6 py-4\", className)}>\n {children}\n </Slot>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,gBAAgB,cAAyC,IAAI;AAKnE,MAAM,eAAe;CACnB,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAGA,MAAM,iBAAiB;CACrB,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAKA,MAAM,SAAS;AAOf,MAAM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,SAAS,UAAU,aAAiC;CACxF,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,SAAS;CAC1B,MAAM,CAAC,UAAU,QAAQ,eAAe;CACxC,MAAM,eAAe,eAAe,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC;CAErD,OACE,oBAAC,cAAc,UAAf;EAAwB,OAAO;EAC7B,UAAA,oBAAC,OAAO,KAAR;GACE,MAAK;GACL,aAAU;GACV,SAAS;GACT,SACE,OACI;IAAE,OAAO,KAAK;IAAO,QAAQ,KAAK;GAAO,IACzC;IAAE,OAAO;IAAY,QAAQ;GAAY;GAE/C,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACvC,OAAO,EAAE,cAAc,OAAO;GAI9B,WAAW,GACT,mEACA,4CACA,SACF;GAIA,UAAA,qBAAC,OAAD;IAAK,KAAK;IAAU,WAAU;IAA9B,UAAA,CACE,oBAAC,iBAAD;KAAiB,MAAK;KAAY,SAAS;KACxC,UAAA,CAAC,YAAY,UACZ,oBAAC,MAAD;MACE,OAAM;MAEN,WAAU;MAET,UAAA;KACG,CAAA,IACJ;IACW,CAAA,GAChB,QACE;;EACK,CAAA;CACU,CAAA;AAE5B;AASA,SAAgB,kBAAkB,EAAE,IAAI,UAAU,aAAqC;CACrF,MAAM,MAAM,WAAW,aAAa;CACpC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,uDAAuD;CACjF,MAAM,SAAS,IAAI,SAAS;CAE5B,OACE,oBAAC,iBAAD;EAAiB,MAAK;EAAY,SAAS;EACxC,UAAA,SACC,oBAAC,MAAD;GAAM,OAAO;GAAI,WAAW,GAAG,aAAa,SAAS;GAClD;EACG,CAAA,IACJ;CACW,CAAA;AAErB"}
@@ -0,0 +1,52 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/expandable-action-bar.d.ts
3
+ type ExpandableActionBarSize = "sm" | "md";
4
+ type ExpandableActionBarItem = {
5
+ id: string;
6
+ label: ReactNode;
7
+ icon: ReactNode;
8
+ onClick?: () => void;
9
+ disabled?: boolean;
10
+ active?: boolean;
11
+ badge?: ReactNode;
12
+ shortcut?: ReactNode;
13
+ };
14
+ type ExpandableActionBarClassNames = {
15
+ root?: string;
16
+ track?: string;
17
+ item?: string;
18
+ activeItem?: string;
19
+ icon?: string;
20
+ label?: string;
21
+ badge?: string;
22
+ shortcut?: string;
23
+ };
24
+ interface ExpandableActionBarProps {
25
+ items: ExpandableActionBarItem[];
26
+ expanded?: boolean;
27
+ defaultExpanded?: boolean;
28
+ onExpandedChange?: (expanded: boolean) => void;
29
+ activeId?: string;
30
+ onAction?: (item: ExpandableActionBarItem) => void;
31
+ size?: ExpandableActionBarSize;
32
+ expandOnHover?: boolean;
33
+ expandOnFocus?: boolean;
34
+ collapseDelay?: number;
35
+ className?: string;
36
+ classNames?: ExpandableActionBarClassNames;
37
+ renderItem?: (item: ExpandableActionBarItem, state: {
38
+ expanded: boolean;
39
+ active: boolean;
40
+ }) => ReactNode;
41
+ }
42
+ declare function ExpandableActionBar({ items, expanded, defaultExpanded, onExpandedChange, activeId, onAction, size, expandOnHover, expandOnFocus, collapseDelay, className, classNames, renderItem }: ExpandableActionBarProps): import("react").JSX.Element;
43
+ declare function useExpandableActionBar(items: ExpandableActionBarItem[]): {
44
+ expanded: boolean;
45
+ setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
46
+ activeId: string;
47
+ setActiveId: import("react").Dispatch<import("react").SetStateAction<string>>;
48
+ activeItem: ExpandableActionBarItem | undefined;
49
+ };
50
+ //#endregion
51
+ export { ExpandableActionBar, ExpandableActionBarClassNames, ExpandableActionBarItem, ExpandableActionBarProps, ExpandableActionBarSize, useExpandableActionBar };
52
+ //# sourceMappingURL=expandable-action-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expandable-action-bar.d.ts","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"mappings":";;KAiBY;KAEA;EACV;EACA,OAAO;EACP,MAAM;EACN;EACA;EACA;EACA,QAAQ;EACR,WAAW;;KAGD;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,oBAAoB;EACpB;EACA,YAAY,MAAM;EAClB,OAAO;EACP;EACA;EACA;EACA;EACA,aAAa;EACb,cACE,MAAM,yBACN;IAAS;IAAmB;QACzB;;iBAwDS,sBACd,OACA,UACA,iBACA,kBACA,UACA,UACA,MACA,eACA,eACA,eACA,WACA,YACA,cACC,2CAAwB,IAAA;iBAmMX,uBAAuB,OAAO;;;;;cAAA"}
@@ -0,0 +1,191 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
3
+ import { cn } from "@kumix/utils";
4
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
+ import { LayoutGroup, motion, useReducedMotion } from "motion/react";
6
+ //#region src/components/motion/expandable-action-bar.tsx
7
+ const ITEM_TRANSITION = {
8
+ type: "spring",
9
+ stiffness: 460,
10
+ damping: 34,
11
+ mass: .62
12
+ };
13
+ const LABEL_TRANSITION = {
14
+ type: "spring",
15
+ stiffness: 380,
16
+ damping: 32,
17
+ mass: .7
18
+ };
19
+ const SIZE_CLASS = {
20
+ sm: "min-h-9 gap-1 p-1 text-xs",
21
+ md: "min-h-11 gap-1.5 p-1.5 text-sm"
22
+ };
23
+ const ITEM_SIZE_CLASS = {
24
+ sm: "h-7 min-w-7 px-1.5",
25
+ md: "h-8 min-w-8 px-2"
26
+ };
27
+ const ICON_SIZE_CLASS = {
28
+ sm: "h-3.5 w-3.5",
29
+ md: "h-4 w-4"
30
+ };
31
+ function useControllableExpanded({ expanded, defaultExpanded, onExpandedChange }) {
32
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);
33
+ const isControlled = expanded !== void 0;
34
+ return [expanded ?? internalExpanded, useCallback((next) => {
35
+ if (!isControlled) setInternalExpanded(next);
36
+ onExpandedChange?.(next);
37
+ }, [isControlled, onExpandedChange])];
38
+ }
39
+ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpandedChange, activeId, onAction, size = "md", expandOnHover = true, expandOnFocus = true, collapseDelay = 90, className, classNames, renderItem }) {
40
+ const reduce = useReducedMotion();
41
+ const layoutId = useId();
42
+ const [isExpanded, setIsExpanded] = useControllableExpanded({
43
+ expanded,
44
+ defaultExpanded,
45
+ onExpandedChange
46
+ });
47
+ const [hoveredId, setHoveredId] = useState(null);
48
+ const collapseTimer = useRef(null);
49
+ const clearCollapseTimer = useCallback(() => {
50
+ if (collapseTimer.current) window.clearTimeout(collapseTimer.current);
51
+ collapseTimer.current = null;
52
+ }, []);
53
+ const open = useCallback(() => {
54
+ clearCollapseTimer();
55
+ setIsExpanded(true);
56
+ }, [clearCollapseTimer, setIsExpanded]);
57
+ const close = useCallback(() => {
58
+ clearCollapseTimer();
59
+ const timer = window.setTimeout(() => {
60
+ setIsExpanded(false);
61
+ setHoveredId(null);
62
+ }, collapseDelay);
63
+ collapseTimer.current = timer;
64
+ }, [
65
+ clearCollapseTimer,
66
+ collapseDelay,
67
+ setIsExpanded
68
+ ]);
69
+ useEffect(() => clearCollapseTimer, [clearCollapseTimer]);
70
+ const onRootMouseEnter = () => {
71
+ if (expandOnHover) open();
72
+ };
73
+ const onRootMouseLeave = () => {
74
+ setHoveredId(null);
75
+ if (expandOnHover) close();
76
+ };
77
+ const onRootFocus = () => {
78
+ if (expandOnFocus) open();
79
+ };
80
+ const onRootBlur = (event) => {
81
+ if (!event.currentTarget.contains(event.relatedTarget) && expandOnFocus) close();
82
+ };
83
+ const activeItemId = activeId ?? items.find((item) => item.active)?.id;
84
+ const highlightId = hoveredId ?? activeItemId;
85
+ return /* @__PURE__ */ jsx(LayoutGroup, {
86
+ id: layoutId,
87
+ children: /* @__PURE__ */ jsx(motion.div, {
88
+ layout: "size",
89
+ onMouseEnter: onRootMouseEnter,
90
+ onMouseLeave: onRootMouseLeave,
91
+ onFocus: onRootFocus,
92
+ onBlur: onRootBlur,
93
+ transition: ITEM_TRANSITION,
94
+ className: cn("inline-flex", classNames?.root, className),
95
+ children: /* @__PURE__ */ jsx(motion.div, {
96
+ layout: "size",
97
+ className: cn("relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl", SIZE_CLASS[size], classNames?.track),
98
+ transition: ITEM_TRANSITION,
99
+ children: items.map((item) => {
100
+ const isActive = item.active || activeId === item.id;
101
+ const isHighlighted = highlightId === item.id;
102
+ return /* @__PURE__ */ jsxs(motion.button, {
103
+ layout: "position",
104
+ type: "button",
105
+ disabled: item.disabled,
106
+ title: typeof item.label === "string" ? item.label : void 0,
107
+ onMouseEnter: () => {
108
+ clearCollapseTimer();
109
+ setHoveredId(item.id);
110
+ },
111
+ onClick: (event) => {
112
+ event.currentTarget.blur();
113
+ item.onClick?.();
114
+ onAction?.(item);
115
+ },
116
+ whileTap: reduce || item.disabled ? void 0 : { scale: .96 },
117
+ transition: ITEM_TRANSITION,
118
+ className: cn("relative isolate inline-flex items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out", "focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40", isHighlighted && "text-foreground", ITEM_SIZE_CLASS[size], classNames?.item, isActive && classNames?.activeItem),
119
+ children: [isHighlighted ? /* @__PURE__ */ jsx(motion.span, {
120
+ layoutId: "action-bar-highlight",
121
+ className: "absolute inset-0 -z-10 rounded-full bg-primary/[0.07]",
122
+ transition: ITEM_TRANSITION
123
+ }) : null, renderItem ? renderItem(item, {
124
+ expanded: isExpanded,
125
+ active: isActive
126
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
127
+ /* @__PURE__ */ jsx("span", {
128
+ className: cn("inline-flex shrink-0 items-center justify-center", ICON_SIZE_CLASS[size], classNames?.icon),
129
+ children: item.icon
130
+ }),
131
+ /* @__PURE__ */ jsx(motion.span, {
132
+ "aria-hidden": !isExpanded,
133
+ animate: reduce ? {
134
+ width: isExpanded ? "auto" : 0,
135
+ opacity: isExpanded ? 1 : 0,
136
+ marginLeft: isExpanded ? 8 : 0,
137
+ x: 0,
138
+ filter: "blur(0px)"
139
+ } : {
140
+ width: isExpanded ? "auto" : 0,
141
+ opacity: isExpanded ? 1 : 0,
142
+ x: isExpanded ? 0 : -4,
143
+ marginLeft: isExpanded ? 8 : 0,
144
+ filter: isExpanded ? "blur(0px)" : "blur(3px)"
145
+ },
146
+ transition: reduce ? { duration: 0 } : LABEL_TRANSITION,
147
+ className: cn("inline-block overflow-hidden whitespace-nowrap", classNames?.label),
148
+ children: item.label
149
+ }),
150
+ item.shortcut ? /* @__PURE__ */ jsx(motion.span, {
151
+ "aria-hidden": !isExpanded,
152
+ animate: {
153
+ width: isExpanded ? "auto" : 0,
154
+ opacity: isExpanded ? 1 : 0,
155
+ marginLeft: isExpanded ? 4 : 0
156
+ },
157
+ transition: LABEL_TRANSITION,
158
+ className: cn("hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block", classNames?.shortcut),
159
+ children: item.shortcut
160
+ }) : null,
161
+ item.badge ? /* @__PURE__ */ jsx("span", {
162
+ className: cn("ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none", !isExpanded && "absolute top-0.5 right-0.5", classNames?.badge),
163
+ children: item.badge
164
+ }) : null
165
+ ] })]
166
+ }, item.id);
167
+ })
168
+ })
169
+ })
170
+ });
171
+ }
172
+ function useExpandableActionBar(items) {
173
+ const [expanded, setExpanded] = useState(false);
174
+ const [activeId, setActiveId] = useState(items[0]?.id);
175
+ const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);
176
+ return useMemo(() => ({
177
+ expanded,
178
+ setExpanded,
179
+ activeId,
180
+ setActiveId,
181
+ activeItem
182
+ }), [
183
+ activeId,
184
+ activeItem,
185
+ expanded
186
+ ]);
187
+ }
188
+ //#endregion
189
+ export { ExpandableActionBar, useExpandableActionBar };
190
+
191
+ //# sourceMappingURL=expandable-action-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expandable-action-bar.js","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nexport type ExpandableActionBarSize = \"sm\" | \"md\";\n\nexport type ExpandableActionBarItem = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n active?: boolean;\n badge?: ReactNode;\n shortcut?: ReactNode;\n};\n\nexport type ExpandableActionBarClassNames = {\n root?: string;\n track?: string;\n item?: string;\n activeItem?: string;\n icon?: string;\n label?: string;\n badge?: string;\n shortcut?: string;\n};\n\nexport interface ExpandableActionBarProps {\n items: ExpandableActionBarItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n activeId?: string;\n onAction?: (item: ExpandableActionBarItem) => void;\n size?: ExpandableActionBarSize;\n expandOnHover?: boolean;\n expandOnFocus?: boolean;\n collapseDelay?: number;\n className?: string;\n classNames?: ExpandableActionBarClassNames;\n renderItem?: (\n item: ExpandableActionBarItem,\n state: { expanded: boolean; active: boolean },\n ) => ReactNode;\n}\n\nconst ITEM_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 460,\n damping: 34,\n mass: 0.62,\n};\n\nconst LABEL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 380,\n damping: 32,\n mass: 0.7,\n};\n\nconst SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"min-h-9 gap-1 p-1 text-xs\",\n md: \"min-h-11 gap-1.5 p-1.5 text-sm\",\n};\n\nconst ITEM_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-7 min-w-7 px-1.5\",\n md: \"h-8 min-w-8 px-2\",\n};\n\nconst ICON_SIZE_CLASS: Record<ExpandableActionBarSize, 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 ExpandableActionBar({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n activeId,\n onAction,\n size = \"md\",\n expandOnHover = true,\n expandOnFocus = true,\n collapseDelay = 90,\n className,\n classNames,\n renderItem,\n}: ExpandableActionBarProps) {\n const reduce = useReducedMotion();\n const layoutId = useId();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n const collapseTimer = useRef<number | null>(null);\n\n const clearCollapseTimer = useCallback(() => {\n if (collapseTimer.current) window.clearTimeout(collapseTimer.current);\n collapseTimer.current = null;\n }, []);\n\n const open = useCallback(() => {\n clearCollapseTimer();\n setIsExpanded(true);\n }, [clearCollapseTimer, setIsExpanded]);\n\n const close = useCallback(() => {\n clearCollapseTimer();\n const timer = window.setTimeout(() => {\n setIsExpanded(false);\n setHoveredId(null);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n const onRootMouseEnter = () => {\n if (expandOnHover) open();\n };\n\n const onRootMouseLeave = () => {\n setHoveredId(null);\n if (expandOnHover) close();\n };\n\n const onRootFocus = () => {\n if (expandOnFocus) open();\n };\n\n const onRootBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node) && expandOnFocus) {\n close();\n }\n };\n\n const activeItemId = activeId ?? items.find((item) => item.active)?.id;\n const highlightId = hoveredId ?? activeItemId;\n\n return (\n <LayoutGroup id={layoutId}>\n <motion.div\n layout=\"size\"\n onMouseEnter={onRootMouseEnter}\n onMouseLeave={onRootMouseLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex\", classNames?.root, className)}\n >\n <motion.div\n layout=\"size\"\n className={cn(\n \"relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl\",\n SIZE_CLASS[size],\n classNames?.track,\n )}\n transition={ITEM_TRANSITION}\n >\n {items.map((item) => {\n const isActive = item.active || activeId === item.id;\n const isHighlighted = highlightId === item.id;\n\n return (\n <motion.button\n key={item.id}\n layout=\"position\"\n type=\"button\"\n disabled={item.disabled}\n title={typeof item.label === \"string\" ? item.label : undefined}\n onMouseEnter={() => {\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n item.onClick?.();\n onAction?.(item);\n }}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.96 }}\n transition={ITEM_TRANSITION}\n className={cn(\n \"relative isolate inline-flex items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out\",\n \"focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40\",\n isHighlighted && \"text-foreground\",\n ITEM_SIZE_CLASS[size],\n classNames?.item,\n isActive && classNames?.activeItem,\n )}\n >\n {isHighlighted ? (\n <motion.span\n layoutId=\"action-bar-highlight\"\n className=\"absolute inset-0 -z-10 rounded-full bg-primary/[0.07]\"\n transition={ITEM_TRANSITION}\n />\n ) : null}\n\n {renderItem ? (\n renderItem(item, { expanded: isExpanded, active: isActive })\n ) : (\n <>\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n\n <motion.span\n aria-hidden={!isExpanded}\n animate={\n reduce\n ? {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 8 : 0,\n x: 0,\n filter: \"blur(0px)\",\n }\n : {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n x: isExpanded ? 0 : -4,\n marginLeft: isExpanded ? 8 : 0,\n filter: isExpanded ? \"blur(0px)\" : \"blur(3px)\",\n }\n }\n transition={reduce ? { duration: 0 } : LABEL_TRANSITION}\n className={cn(\n \"inline-block overflow-hidden whitespace-nowrap\",\n classNames?.label,\n )}\n >\n {item.label}\n </motion.span>\n\n {item.shortcut ? (\n <motion.span\n aria-hidden={!isExpanded}\n animate={{\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 4 : 0,\n }}\n transition={LABEL_TRANSITION}\n className={cn(\n \"hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block\",\n classNames?.shortcut,\n )}\n >\n {item.shortcut}\n </motion.span>\n ) : null}\n\n {item.badge ? (\n <span\n className={cn(\n \"ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none\",\n !isExpanded && \"absolute top-0.5 right-0.5\",\n classNames?.badge,\n )}\n >\n {item.badge}\n </span>\n ) : null}\n </>\n )}\n </motion.button>\n );\n })}\n </motion.div>\n </motion.div>\n </LayoutGroup>\n );\n}\n\nexport function useExpandableActionBar(items: ExpandableActionBarItem[]) {\n const [expanded, setExpanded] = useState(false);\n const [activeId, setActiveId] = useState(items[0]?.id);\n\n const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);\n\n return useMemo(\n () => ({ expanded, setExpanded, activeId, setActiveId, activeItem }),\n [activeId, activeItem, expanded],\n );\n}\n"],"mappings":";;;;;;AA4DA,MAAM,kBAA8B;CAClC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,aAAsD;CAC1D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,KAAK;CACjF,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAgB,oBAAoB,EAClC,OACA,UACA,kBAAkB,OAClB,kBACA,UACA,UACA,OAAO,MACP,gBAAgB,MAChB,gBAAgB,MAChB,gBAAgB,IAChB,WACA,YACA,cAC2B;CAC3B,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,MAAM;CACvB,MAAM,CAAC,YAAY,iBAAiB,wBAAwB;EAC1D;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAC9D,MAAM,gBAAgB,OAAsB,IAAI;CAEhD,MAAM,qBAAqB,kBAAkB;EAC3C,IAAI,cAAc,SAAS,OAAO,aAAa,cAAc,OAAO;EACpE,cAAc,UAAU;CAC1B,GAAG,CAAC,CAAC;CAEL,MAAM,OAAO,kBAAkB;EAC7B,mBAAmB;EACnB,cAAc,IAAI;CACpB,GAAG,CAAC,oBAAoB,aAAa,CAAC;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AAA,KAAK,EA0GG;IAEnB,CAAC;GACS,CAAA;EACF,CAAA;CACD,CAAA;AAEjB;AAEA,SAAgB,uBAAuB,OAAkC;CACvE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,EAAE,EAAE,EAAE;CAErD,MAAM,aAAa,cAAc,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG,CAAC,UAAU,KAAK,CAAC;CAE9F,OAAO,eACE;EAAE;EAAU;EAAa;EAAU;EAAa;CAAW,IAClE;EAAC;EAAU;EAAY;CAAQ,CACjC;AACF"}
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/expandable-tabs.d.ts
3
+ type ExpandableTabsItem = {
4
+ id: string;
5
+ /** String label — shown inside the active tab and used as the button's accessible name. */
6
+ label: string;
7
+ icon: ReactNode;
8
+ /** Panel shown above the bar when this tab is active. */
9
+ content: ReactNode;
10
+ };
11
+ type ExpandableTabsClassNames = {
12
+ root?: string;
13
+ panel?: string;
14
+ bar?: string;
15
+ tab?: string;
16
+ activeTab?: string;
17
+ icon?: string;
18
+ label?: string;
19
+ pill?: string;
20
+ };
21
+ interface ExpandableTabsProps {
22
+ items: ExpandableTabsItem[];
23
+ /** Active tab id, or null/undefined for the closed (bar-only) state. */
24
+ value?: string | null;
25
+ defaultValue?: string | null;
26
+ onValueChange?: (id: string | null) => void;
27
+ className?: string;
28
+ classNames?: ExpandableTabsClassNames;
29
+ }
30
+ declare function ExpandableTabs({ items, value, defaultValue, onValueChange, className, classNames }: ExpandableTabsProps): import("react").JSX.Element;
31
+ //#endregion
32
+ export { ExpandableTabs, ExpandableTabsClassNames, ExpandableTabsItem, ExpandableTabsProps };
33
+ //# sourceMappingURL=expandable-tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expandable-tabs.d.ts","names":[],"sources":["../../../src/components/motion/expandable-tabs.tsx"],"mappings":";;KAQY;EACV;;EAEA;EACA,MAAM;;EAEN,SAAS;;KAGC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;;EAEP;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;;iBAqJC,iBACd,OACA,OACA,cACA,eACA,WACA,cACC,sCAAmB,IAAA"}