@kumix/ui 0.4.1 → 0.4.2

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 (224) hide show
  1. package/README.md +37 -30
  2. package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
  3. package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
  4. package/dist/components/agents/agent-code.js +1 -1
  5. package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -1
  6. package/dist/components/charts/donut-chart/context.d.ts.map +1 -1
  7. package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
  8. package/dist/components/charts/order-book.d.ts.map +1 -1
  9. package/dist/components/charts/treemap.d.ts.map +1 -1
  10. package/dist/components/charts/volume-profile.d.ts.map +1 -1
  11. package/dist/components/motion/action-swap.d.ts +1 -1
  12. package/dist/components/motion/action-swap.d.ts.map +1 -1
  13. package/dist/components/motion/action-swap.js +43 -20
  14. package/dist/components/motion/action-swap.js.map +1 -1
  15. package/dist/components/motion/animated-badge.d.ts +1 -1
  16. package/dist/components/motion/animated-badge.d.ts.map +1 -1
  17. package/dist/components/motion/animated-badge.js +60 -101
  18. package/dist/components/motion/animated-badge.js.map +1 -1
  19. package/dist/components/motion/animated-sidebar.js +1 -1
  20. package/dist/components/motion/animated-toast-stack.js +1 -1
  21. package/dist/components/motion/attachment-upload.js +1 -1
  22. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  23. package/dist/components/motion/availability-scheduler/day-row.js +1 -1
  24. package/dist/components/motion/availability-scheduler/index.js +1 -1
  25. package/dist/components/motion/bloom-menu.d.ts.map +1 -1
  26. package/dist/components/motion/bloom-menu.js +73 -8
  27. package/dist/components/motion/bloom-menu.js.map +1 -1
  28. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  29. package/dist/components/motion/bottom-sheet.js +6 -10
  30. package/dist/components/motion/bottom-sheet.js.map +1 -1
  31. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  32. package/dist/components/motion/bouncy-accordion.js +35 -22
  33. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  34. package/dist/components/motion/center-morph-modal.js +1 -1
  35. package/dist/components/motion/color-picker.d.ts.map +1 -1
  36. package/dist/components/motion/command-palette.js +1 -1
  37. package/dist/components/motion/context-menu.js +1 -1
  38. package/dist/components/motion/date-range-picker.d.ts.map +1 -1
  39. package/dist/components/motion/drawer.d.ts +1 -1
  40. package/dist/components/motion/drawer.d.ts.map +1 -1
  41. package/dist/components/motion/drawer.js +10 -10
  42. package/dist/components/motion/drawer.js.map +1 -1
  43. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
  44. package/dist/components/motion/feedback-widget.js +4 -1
  45. package/dist/components/motion/feedback-widget.js.map +1 -1
  46. package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
  47. package/dist/components/motion/morphing-lightbox.js +1 -1
  48. package/dist/components/motion/morphing-modal.d.ts +6 -1
  49. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  50. package/dist/components/motion/morphing-modal.js +37 -5
  51. package/dist/components/motion/morphing-modal.js.map +1 -1
  52. package/dist/components/motion/morphing-search.js +1 -1
  53. package/dist/components/motion/morphing-tabs.js +1 -1
  54. package/dist/components/motion/otp-input.js +19 -11
  55. package/dist/components/motion/otp-input.js.map +1 -1
  56. package/dist/components/motion/popover-morph.d.ts +4 -3
  57. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  58. package/dist/components/motion/popover-morph.js +47 -55
  59. package/dist/components/motion/popover-morph.js.map +1 -1
  60. package/dist/components/motion/popover.js +7 -1
  61. package/dist/components/motion/popover.js.map +1 -1
  62. package/dist/components/motion/prediction-market-card.js +1 -1
  63. package/dist/components/motion/prediction-market.js +1 -1
  64. package/dist/components/motion/project-folder.js +1 -1
  65. package/dist/components/motion/radio.d.ts +5 -1
  66. package/dist/components/motion/radio.d.ts.map +1 -1
  67. package/dist/components/motion/radio.js +53 -5
  68. package/dist/components/motion/radio.js.map +1 -1
  69. package/dist/components/motion/select-morph.d.ts +1 -1
  70. package/dist/components/motion/select-morph.d.ts.map +1 -1
  71. package/dist/components/motion/select-morph.js +89 -21
  72. package/dist/components/motion/select-morph.js.map +1 -1
  73. package/dist/components/motion/select.d.ts.map +1 -1
  74. package/dist/components/motion/select.js +153 -135
  75. package/dist/components/motion/select.js.map +1 -1
  76. package/dist/components/motion/shader-background.d.ts +3 -2
  77. package/dist/components/motion/shader-background.d.ts.map +1 -1
  78. package/dist/components/motion/shader-background.js +9 -3
  79. package/dist/components/motion/shader-background.js.map +1 -1
  80. package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
  81. package/dist/components/motion/shared-layout-bg.js +17 -3
  82. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  83. package/dist/components/motion/swipeable-list.d.ts.map +1 -1
  84. package/dist/components/motion/swipeable-list.js +61 -4
  85. package/dist/components/motion/swipeable-list.js.map +1 -1
  86. package/dist/components/motion/table/row-handle.js +1 -1
  87. package/dist/components/motion/table/table-header.js +1 -1
  88. package/dist/components/motion/tabs.d.ts +12 -3
  89. package/dist/components/motion/tabs.d.ts.map +1 -1
  90. package/dist/components/motion/tabs.js +248 -26
  91. package/dist/components/motion/tabs.js.map +1 -1
  92. package/dist/components/motion/theme-toggle.js +1 -1
  93. package/dist/components/reui/alert.d.ts +1 -1
  94. package/dist/components/reui/autocomplete.d.ts +1 -1
  95. package/dist/components/reui/autocomplete.d.ts.map +1 -1
  96. package/dist/components/reui/autocomplete.js +1 -1
  97. package/dist/components/reui/autocomplete.js.map +1 -1
  98. package/dist/components/reui/badge.d.ts +2 -2
  99. package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
  100. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
  101. package/dist/components/reui/cascader/cascader-async.js +61 -34
  102. package/dist/components/reui/cascader/cascader-async.js.map +1 -1
  103. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
  104. package/dist/components/reui/cascader/cascader-columns.js +5 -2
  105. package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
  106. package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
  107. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
  108. package/dist/components/reui/cascader/cascader-context.js.map +1 -1
  109. package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
  110. package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
  111. package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
  112. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
  113. package/dist/components/reui/cascader/cascader-lib.js +145 -29
  114. package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
  115. package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
  116. package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
  117. package/dist/components/reui/cascader/cascader.d.ts +13 -8
  118. package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
  119. package/dist/components/reui/cascader/cascader.js +31 -16
  120. package/dist/components/reui/cascader/cascader.js.map +1 -1
  121. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  122. package/dist/components/reui/color-picker.js +1 -1
  123. package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
  124. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
  125. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
  126. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
  127. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
  128. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  129. package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
  130. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
  131. package/dist/components/reui/data-grid/data-grid-column-header.js +7 -8
  132. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  133. package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
  134. package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
  135. package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
  136. package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
  137. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -0
  138. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  139. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
  140. package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -0
  141. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  142. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
  143. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +3 -2
  144. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  145. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
  146. package/dist/components/reui/data-grid/data-grid-table-dnd.js +2 -1
  147. package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
  148. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
  149. package/dist/components/reui/data-grid/data-grid-table-virtual.js +2 -1
  150. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  151. package/dist/components/reui/data-grid/data-grid-table.d.ts +6 -11
  152. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  153. package/dist/components/reui/data-grid/data-grid-table.js +22 -22
  154. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  155. package/dist/components/reui/data-grid/data-grid.d.ts +16 -1
  156. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  157. package/dist/components/reui/data-grid/data-grid.js +80 -22
  158. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  159. package/dist/components/reui/date-selector.d.ts.map +1 -1
  160. package/dist/components/reui/date-selector.js +21 -15
  161. package/dist/components/reui/date-selector.js.map +1 -1
  162. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
  163. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
  164. package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
  165. package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
  166. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
  167. package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
  168. package/dist/components/reui/event-calendar/event-calendar.js +34 -31
  169. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  170. package/dist/components/reui/file-type.d.ts +302 -6
  171. package/dist/components/reui/file-type.d.ts.map +1 -1
  172. package/dist/components/reui/file-type.js +416 -13
  173. package/dist/components/reui/file-type.js.map +1 -1
  174. package/dist/components/reui/filters/filters-builder.d.ts +1 -1
  175. package/dist/components/reui/filters/filters-lib.d.ts +1 -1
  176. package/dist/components/reui/frame.d.ts +1 -1
  177. package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
  178. package/dist/components/reui/gantt/gantt-nav.js +2 -2
  179. package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
  180. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  181. package/dist/components/reui/gantt/gantt.js +5 -2
  182. package/dist/components/reui/gantt/gantt.js.map +1 -1
  183. package/dist/components/reui/icon-tile.d.ts +2 -2
  184. package/dist/components/reui/number-field.d.ts +3 -3
  185. package/dist/components/reui/phone-input.js +30 -27
  186. package/dist/components/reui/phone-input.js.map +1 -1
  187. package/dist/components/reui/rating.d.ts +1 -1
  188. package/dist/components/reui/time-picker.js +1 -1
  189. package/dist/components/ui/attachment.d.ts +2 -2
  190. package/dist/components/ui/badge.d.ts +1 -1
  191. package/dist/components/ui/bubble.d.ts +1 -1
  192. package/dist/components/ui/button.d.ts +2 -2
  193. package/dist/components/ui/chart.d.ts.map +1 -1
  194. package/dist/components/ui/code-block.d.ts +29 -0
  195. package/dist/components/ui/code-block.d.ts.map +1 -0
  196. package/dist/components/ui/code-block.js +124 -0
  197. package/dist/components/ui/code-block.js.map +1 -0
  198. package/dist/components/ui/empty.d.ts +1 -1
  199. package/dist/components/ui/item.d.ts +2 -2
  200. package/dist/components/ui/marker.d.ts +1 -1
  201. package/dist/components/ui/sidebar.d.ts +1 -1
  202. package/dist/components/ui/toggle.d.ts +1 -1
  203. package/dist/components/ui/trace.d.ts +21 -0
  204. package/dist/components/ui/trace.d.ts.map +1 -0
  205. package/dist/components/ui/trace.js +77 -0
  206. package/dist/components/ui/trace.js.map +1 -0
  207. package/dist/context-BYXeJQnz.d.ts.map +1 -1
  208. package/dist/{copy-menu-BXUh52bu.js → copy-menu-DOg9Jh-U.js} +2 -2
  209. package/dist/{copy-menu-BXUh52bu.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
  210. package/dist/hooks/use-focus-trap.d.ts +22 -0
  211. package/dist/hooks/use-focus-trap.d.ts.map +1 -0
  212. package/dist/hooks/use-focus-trap.js +80 -0
  213. package/dist/hooks/use-focus-trap.js.map +1 -0
  214. package/dist/hooks/use-highlighted-code.d.ts +5 -0
  215. package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
  216. package/dist/hooks/use-highlighted-code.js +128 -0
  217. package/dist/hooks/use-highlighted-code.js.map +1 -0
  218. package/dist/hooks/use-listbox.d.ts +29 -0
  219. package/dist/hooks/use-listbox.d.ts.map +1 -0
  220. package/dist/hooks/use-listbox.js +75 -0
  221. package/dist/hooks/use-listbox.js.map +1 -0
  222. package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
  223. package/package.json +8 -8
  224. package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { SPRING_LAYOUT } from "../../lib/ease.js";
3
- import { Children, cloneElement, forwardRef, isValidElement, useId, useState } from "react";
3
+ import { Children, cloneElement, forwardRef, isValidElement, useId, useRef, useState } from "react";
4
4
  import { cn } from "@kumix/utils";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
@@ -24,10 +24,11 @@ const reducedVariants = {
24
24
  animate: { opacity: 1 },
25
25
  exit: (isActive) => !isActive ? { opacity: 0 } : {}
26
26
  };
27
- const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div", className, onMouseLeave, pillClassName, pillContainerClassName, inset = 20, ...props }, forwardedRef) {
27
+ const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div", className, onMouseLeave, onBlur, pillClassName, pillContainerClassName, inset = 20, ...props }, forwardedRef) {
28
28
  const [activeId, setActiveId] = useState(null);
29
29
  const uid = useId();
30
30
  const reduce = useReducedMotion();
31
+ const hovering = useRef(false);
31
32
  const renderedChildren = Children.toArray(children).filter(isValidElement).map((child, index) => {
32
33
  const el = child;
33
34
  const childKey = el.key ? String(el.key) : `item-${index}`;
@@ -36,6 +37,11 @@ const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div"
36
37
  className: cn("relative", el.props.className),
37
38
  onMouseEnter: () => {
38
39
  el.props.onMouseEnter?.();
40
+ hovering.current = true;
41
+ setActiveId(childKey);
42
+ },
43
+ onFocus: (event) => {
44
+ el.props.onFocus?.(event);
39
45
  setActiveId(childKey);
40
46
  }
41
47
  }, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AnimatePresence, {
@@ -63,14 +69,21 @@ const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div"
63
69
  })] }));
64
70
  });
65
71
  const handleMouseLeave = (event) => {
66
- setActiveId(null);
72
+ hovering.current = false;
73
+ if (!event.currentTarget.contains(document.activeElement)) setActiveId(null);
67
74
  onMouseLeave?.(event);
68
75
  };
76
+ const handleBlur = (event) => {
77
+ const next = event.relatedTarget;
78
+ if (!hovering.current && !(next instanceof Node && event.currentTarget.contains(next))) setActiveId(null);
79
+ onBlur?.(event);
80
+ };
69
81
  return as === "ul" ? /* @__PURE__ */ jsx(motion.ul, {
70
82
  ...props,
71
83
  ref: forwardedRef,
72
84
  layoutRoot: true,
73
85
  onMouseLeave: handleMouseLeave,
86
+ onBlur: handleBlur,
74
87
  className: cn("flex w-full flex-col", className),
75
88
  children: renderedChildren
76
89
  }) : /* @__PURE__ */ jsx(motion.div, {
@@ -78,6 +91,7 @@ const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div"
78
91
  ref: forwardedRef,
79
92
  layoutRoot: true,
80
93
  onMouseLeave: handleMouseLeave,
94
+ onBlur: handleBlur,
81
95
  className: cn("flex w-full flex-col", className),
82
96
  children: renderedChildren
83
97
  });
@@ -1 +1 @@
1
- {"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface SharedLayoutBgProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n children: ReactNode;\n /** Semantic container used for the children. */\n as?: \"div\" | \"ul\";\n /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n pillClassName?: string;\n /** Horizontal inset of the pill relative to each row (px). Default 20. */\n inset?: number;\n /** Optional positioning override for the pill wrapper inside each item. */\n pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n initial: { opacity: 0, filter: \"blur(6px)\" },\n animate: { opacity: 1, filter: \"blur(0px)\" },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0, filter: \"blur(6px)\" } : {}),\n};\n\nconst reducedVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(function SharedLayoutBg(\n {\n children,\n as = \"div\",\n className,\n onMouseLeave,\n pillClassName,\n pillContainerClassName,\n inset = 20,\n ...props\n },\n forwardedRef,\n) {\n const [activeId, setActiveId] = useState<string | null>(null);\n const uid = useId();\n const reduce = useReducedMotion();\n\n const renderedChildren = Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const el = child as ReactElement<{\n className?: string;\n onMouseEnter?: () => void;\n children?: ReactNode;\n }>;\n const childKey = el.key ? String(el.key) : `item-${index}`;\n return cloneElement(\n el,\n {\n key: childKey,\n className: cn(\"relative\", el.props.className),\n onMouseEnter: () => {\n el.props.onMouseEnter?.();\n setActiveId(childKey);\n },\n },\n <>\n <AnimatePresence custom={activeId !== null}>\n {activeId !== null ? (\n <motion.div\n variants={reduce ? reducedVariants : variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n custom={activeId !== null}\n className={cn(\"pointer-events-none absolute inset-y-0\", pillContainerClassName)}\n style={{ left: -inset, right: -inset }}\n >\n {activeId === childKey ? (\n <motion.div\n layoutId={`shared-bg-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"pointer-events-none h-full w-full rounded-2xl bg-muted/80\",\n pillClassName,\n )}\n />\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n <div className=\"relative z-10\">{el.props.children}</div>\n </>,\n );\n });\n\n const handleMouseLeave = (event: MouseEvent<HTMLElement>) => {\n setActiveId(null);\n onMouseLeave?.(event);\n };\n\n // layoutRoot scopes the pill's layout projection to this list, so fixed or\n // scrolled ancestors can't smear scroll offsets into its movement.\n return as === \"ul\" ? (\n <motion.ul\n {...(props as HTMLMotionProps<\"ul\">)}\n ref={forwardedRef as Ref<HTMLUListElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.ul>\n ) : (\n <motion.div\n {...(props as HTMLMotionProps<\"div\">)}\n ref={forwardedRef as Ref<HTMLDivElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.div>\n );\n});\n"],"mappings":";;;;;;;AAsCA,MAAM,WAAqB;CACzB,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,OAAO,aAAuB,CAAC,WAAW;EAAE,SAAS;EAAG,QAAQ;CAAY,IAAI,CAAC;AACnF;AAEA,MAAM,kBAA4B;CAChC,SAAS,EAAE,SAAS,EAAE;CACtB,SAAS,EAAE,SAAS,EAAE;CACtB,OAAO,aAAuB,CAAC,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC;AAC9D;AAEA,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EACE,UACA,KAAK,OACL,WACA,cACA,eACA,wBACA,QAAQ,IACR,GAAG,SAEL,cACA;CACA,MAAM,CAAC,UAAU,eAAe,SAAwB,IAAI;CAC5D,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAEhC,MAAM,mBAAmB,SAAS,QAAQ,QAAQ,CAAC,CAChD,OAAO,cAAc,CAAC,CACtB,KAAK,OAAO,UAAU;EACrB,MAAM,KAAK;EAKX,MAAM,WAAW,GAAG,MAAM,OAAO,GAAG,GAAG,IAAI,QAAQ;EACnD,OAAO,aACL,IACA;GACE,KAAK;GACL,WAAW,GAAG,YAAY,GAAG,MAAM,SAAS;GAC5C,oBAAoB;IAClB,GAAG,MAAM,eAAe;IACxB,YAAY,QAAQ;GACtB;EACF,GACA,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,iBAAD;GAAiB,QAAQ,aAAa;GACnC,UAAA,aAAa,OACZ,oBAAC,OAAO,KAAR;IACE,UAAU,SAAS,kBAAkB;IACrC,SAAQ;IACR,SAAQ;IACR,MAAK;IACL,QAAQ,aAAa;IACrB,WAAW,GAAG,0CAA0C,sBAAsB;IAC9E,OAAO;KAAE,MAAM,CAAC;KAAO,OAAO,CAAC;IAAM;IAEpC,UAAA,aAAa,WACZ,oBAAC,OAAO,KAAR;KACE,UAAU,aAAa;KACvB,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;KACvC,WAAW,GACT,6DACA,aACF;IACD,CAAA,IACC;GACM,CAAA,IACV;EACW,CAAA,GACjB,oBAAC,OAAD;GAAK,WAAU;GAAiB,UAAA,GAAG,MAAM;EAAc,CAAA,CACvD,EAAA,CAAA,CACJ;CACF,CAAC;CAEH,MAAM,oBAAoB,UAAmC;EAC3D,YAAY,IAAI;EAChB,eAAe,KAAK;CACtB;CAIA,OAAO,OAAO,OACZ,oBAAC,OAAO,IAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACQ,CAAA,IAEX,oBAAC,OAAO,KAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACS,CAAA;AAEhB,CAAC"}
1
+ {"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n type FocusEvent,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface SharedLayoutBgProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n children: ReactNode;\n /** Semantic container used for the children. */\n as?: \"div\" | \"ul\";\n /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n pillClassName?: string;\n /** Horizontal inset of the pill relative to each row (px). Default 20. */\n inset?: number;\n /** Optional positioning override for the pill wrapper inside each item. */\n pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n initial: { opacity: 0, filter: \"blur(6px)\" },\n animate: { opacity: 1, filter: \"blur(0px)\" },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0, filter: \"blur(6px)\" } : {}),\n};\n\nconst reducedVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(function SharedLayoutBg(\n {\n children,\n as = \"div\",\n className,\n onMouseLeave,\n onBlur,\n pillClassName,\n pillContainerClassName,\n inset = 20,\n ...props\n },\n forwardedRef,\n) {\n const [activeId, setActiveId] = useState<string | null>(null);\n const uid = useId();\n const reduce = useReducedMotion();\n // Focus leaving the list only clears the pill when the pointer is not\n // still resting on an item.\n const hovering = useRef(false);\n\n const renderedChildren = Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const el = child as ReactElement<{\n className?: string;\n onMouseEnter?: () => void;\n onFocus?: (event: FocusEvent<HTMLElement>) => void;\n children?: ReactNode;\n }>;\n const childKey = el.key ? String(el.key) : `item-${index}`;\n return cloneElement(\n el,\n {\n key: childKey,\n className: cn(\"relative\", el.props.className),\n onMouseEnter: () => {\n el.props.onMouseEnter?.();\n hovering.current = true;\n setActiveId(childKey);\n },\n // Focus bubbles in React, so a link or button anywhere inside the\n // item brings the pill to it for keyboard users too.\n onFocus: (event: FocusEvent<HTMLElement>) => {\n el.props.onFocus?.(event);\n setActiveId(childKey);\n },\n },\n <>\n <AnimatePresence custom={activeId !== null}>\n {activeId !== null ? (\n <motion.div\n variants={reduce ? reducedVariants : variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n custom={activeId !== null}\n className={cn(\"pointer-events-none absolute inset-y-0\", pillContainerClassName)}\n style={{ left: -inset, right: -inset }}\n >\n {activeId === childKey ? (\n <motion.div\n layoutId={`shared-bg-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"pointer-events-none h-full w-full rounded-2xl bg-muted/80\",\n pillClassName,\n )}\n />\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n <div className=\"relative z-10\">{el.props.children}</div>\n </>,\n );\n });\n\n const handleMouseLeave = (event: MouseEvent<HTMLElement>) => {\n hovering.current = false;\n // Keep the pill on a focused item so keyboard position stays visible.\n if (!event.currentTarget.contains(document.activeElement)) setActiveId(null);\n onMouseLeave?.(event);\n };\n\n const handleBlur = (event: FocusEvent<HTMLElement>) => {\n const next = event.relatedTarget;\n if (!hovering.current && !(next instanceof Node && event.currentTarget.contains(next)))\n setActiveId(null);\n onBlur?.(event);\n };\n\n // layoutRoot scopes the pill's layout projection to this list, so fixed or\n // scrolled ancestors can't smear scroll offsets into its movement.\n return as === \"ul\" ? (\n <motion.ul\n {...(props as HTMLMotionProps<\"ul\">)}\n ref={forwardedRef as Ref<HTMLUListElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n onBlur={handleBlur}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.ul>\n ) : (\n <motion.div\n {...(props as HTMLMotionProps<\"div\">)}\n ref={forwardedRef as Ref<HTMLDivElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n onBlur={handleBlur}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.div>\n );\n});\n"],"mappings":";;;;;;;AAwCA,MAAM,WAAqB;CACzB,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,OAAO,aAAuB,CAAC,WAAW;EAAE,SAAS;EAAG,QAAQ;CAAY,IAAI,CAAC;AACnF;AAEA,MAAM,kBAA4B;CAChC,SAAS,EAAE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,OAAD;GAAK,WAAU;GAAiB,UAAA,GAAG,MAAM;EAAc,CAAA,CACvD,EAAA,CAAA,CACJ;CACF,CAAC;CAEH,MAAM,oBAAoB,UAAmC;EAC3D,SAAS,UAAU;EAEnB,IAAI,CAAC,MAAM,cAAc,SAAS,SAAS,aAAa,GAAG,YAAY,IAAI;EAC3E,eAAe,KAAK;CACtB;CAEA,MAAM,cAAc,UAAmC;EACrD,MAAM,OAAO,MAAM;EACnB,IAAI,CAAC,SAAS,WAAW,EAAE,gBAAgB,QAAQ,MAAM,cAAc,SAAS,IAAI,IAClF,YAAY,IAAI;EAClB,SAAS,KAAK;CAChB;CAIA,OAAO,OAAO,OACZ,oBAAC,OAAO,IAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,QAAQ;EACR,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACQ,CAAA,IAEX,oBAAC,OAAO,KAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,QAAQ;EACR,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACS,CAAA;AAEhB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"swipeable-list.d.ts","names":[],"sources":["../../../src/components/motion/swipeable-list.tsx"],"mappings":";;YAQY;YAEA;EACV;EACA,MAAM;;YAGI;YAEA;EACV;EACA,OAAO;EACP,MAAM;EACN,OAAO;EACP;EACA,WAAW,MAAM;;YAGP;EACV;EACA,QAAQ;EACR,cAAc;EACd,OAAO;EACP,UAAU;EACV,UAAU;EACV,cAAc;EACd,eAAe;EACf;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP,QAAQ;EACR,eAAe;EACf,iBAAiB,OAAO;EACxB,YAAY;IAAW,MAAM;IAAmB,QAAQ;IAAa,MAAM;;EAC3E;EACA;EACA;EACA;EACA,aAAa;EACb,cAAc,MAAM,sBAAsB;;wBAuV5B,gBACd,OACA,OACA,cACA,eACA,UACA,aACA,iBACA,eACA,WACA,YACA,cACC,qCAAkB,IAAA"}
1
+ {"version":3,"file":"swipeable-list.d.ts","names":[],"sources":["../../../src/components/motion/swipeable-list.tsx"],"mappings":";;YAiBY;YAEA;EACV;EACA,MAAM;;YAGI;YAEA;EACV;EACA,OAAO;EACP,MAAM;EACN,OAAO;EACP;EACA,WAAW,MAAM;;YAGP;EACV;EACA,QAAQ;EACR,cAAc;EACd,OAAO;EACP,UAAU;EACV,UAAU;EACV,cAAc;EACd,eAAe;EACf;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP,QAAQ;EACR,eAAe;EACf,iBAAiB,OAAO;EACxB,YAAY;IAAW,MAAM;IAAmB,QAAQ;IAAa,MAAM;;EAC3E;EACA;EACA;EACA;EACA,aAAa;EACb,cAAc,MAAM,sBAAsB;;wBA+Z5B,gBACd,OACA,OACA,cACA,eACA,UACA,aACA,iBACA,eACA,WACA,YACA,cACC,qCAAkB,IAAA"}
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
  import { TOUCH_GESTURE_CONTENT_CLASS } from "../../lib/touch.js";
3
- import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
4
4
  import { cn } from "@kumix/utils";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { animate, motion, useMotionValue, useReducedMotion } from "motion/react";
7
+ import { Ellipsis } from "lucide-react";
7
8
  //#region src/components/motion/swipeable-list.tsx
8
9
  const ROW_SETTLE = {
9
10
  type: "spring",
@@ -60,6 +61,10 @@ function SwipeActionButton({ action, actionWidth, side, focusable, onAction, cla
60
61
  }
61
62
  function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOpenValue, closeOnAction, onAction, classNames, renderItem }) {
62
63
  const reduce = useReducedMotion();
64
+ const railId = useId();
65
+ const railRef = useRef(null);
66
+ const toggleRef = useRef(null);
67
+ const focusActions = useRef(false);
63
68
  const x = useMotionValue(0);
64
69
  const animationRef = useRef(null);
65
70
  const commandedTargetRef = useRef(0);
@@ -155,13 +160,47 @@ function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOp
155
160
  action,
156
161
  side
157
162
  });
158
- if (closeOnAction) snapTo(null);
163
+ if (closeOnAction) {
164
+ if (railRef.current?.contains(document.activeElement)) toggleRef.current?.focus();
165
+ snapTo(null);
166
+ }
159
167
  }, [
160
168
  closeOnAction,
161
169
  item,
162
170
  onAction,
163
171
  snapTo
164
172
  ]);
173
+ useEffect(() => {
174
+ if (!openSide || !focusActions.current) return;
175
+ focusActions.current = false;
176
+ railRef.current?.querySelector(`[data-side="${openSide}"] button:not(:disabled)`)?.focus();
177
+ }, [openSide]);
178
+ const hasActions = leftWidth > 0 || rightWidth > 0;
179
+ const openFromKeyboard = (side) => {
180
+ if ((side === "left" ? leftWidth : rightWidth) === 0) return;
181
+ focusActions.current = true;
182
+ snapTo(side);
183
+ };
184
+ const onToggleKeyDown = (event) => {
185
+ if (event.key === "ArrowLeft") {
186
+ event.preventDefault();
187
+ if (openSide === "left") snapTo(null);
188
+ else openFromKeyboard("right");
189
+ } else if (event.key === "ArrowRight") {
190
+ event.preventDefault();
191
+ if (openSide === "right") snapTo(null);
192
+ else openFromKeyboard("left");
193
+ } else if (event.key === "Escape" && openSide) {
194
+ event.preventDefault();
195
+ snapTo(null);
196
+ }
197
+ };
198
+ const onRailKeyDown = (event) => {
199
+ if (event.key !== "Escape") return;
200
+ event.preventDefault();
201
+ toggleRef.current?.focus();
202
+ snapTo(null);
203
+ };
165
204
  const defaultContent = /* @__PURE__ */ jsxs("div", {
166
205
  className: "flex min-w-0 items-center gap-3",
167
206
  children: [
@@ -188,10 +227,14 @@ function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOp
188
227
  return /* @__PURE__ */ jsxs("div", {
189
228
  className: cn("relative isolate overflow-hidden rounded-2xl bg-muted", item.disabled && "opacity-60", classNames?.item),
190
229
  children: [/* @__PURE__ */ jsxs("div", {
230
+ ref: railRef,
231
+ id: railId,
191
232
  "aria-hidden": !openSide,
192
233
  inert: !openSide,
234
+ onKeyDown: onRailKeyDown,
193
235
  className: cn("absolute inset-0 z-0 flex overflow-hidden rounded-2xl", classNames?.rail),
194
236
  children: [/* @__PURE__ */ jsx("div", {
237
+ "data-side": "left",
195
238
  className: "flex h-full overflow-hidden rounded-l-2xl",
196
239
  children: leftActions.map((action) => /* @__PURE__ */ jsx(SwipeActionButton, {
197
240
  action,
@@ -202,6 +245,7 @@ function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOp
202
245
  side: "left"
203
246
  }, action.id))
204
247
  }), /* @__PURE__ */ jsx("div", {
248
+ "data-side": "right",
205
249
  className: "ml-auto flex h-full overflow-hidden rounded-r-2xl",
206
250
  children: rightActions.map((action) => /* @__PURE__ */ jsx(SwipeActionButton, {
207
251
  action,
@@ -212,7 +256,7 @@ function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOp
212
256
  side: "right"
213
257
  }, action.id))
214
258
  })]
215
- }), /* @__PURE__ */ jsx(motion.div, {
259
+ }), /* @__PURE__ */ jsxs(motion.div, {
216
260
  drag: item.disabled ? false : "x",
217
261
  dragConstraints: {
218
262
  left: -rightWidth,
@@ -224,7 +268,20 @@ function SwipeableListRow({ item, actionWidth, revealThreshold, openValue, setOp
224
268
  onDragEnd,
225
269
  style: { x },
226
270
  className: cn("relative z-10 min-h-[72px] cursor-grab touch-pan-y rounded-2xl border border-border bg-card px-4 py-3 shadow-sm active:cursor-grabbing", TOUCH_GESTURE_CONTENT_CLASS, classNames?.surface),
227
- children: renderItem ? renderItem(item) : item.content ?? defaultContent
271
+ children: [renderItem ? renderItem(item) : item.content ?? defaultContent, hasActions && !item.disabled ? /* @__PURE__ */ jsx("button", {
272
+ ref: toggleRef,
273
+ type: "button",
274
+ "aria-label": typeof item.title === "string" ? `Actions for ${item.title}` : "Show actions",
275
+ "aria-expanded": openSide !== null,
276
+ "aria-controls": railId,
277
+ onClick: () => openSide ? snapTo(null) : openFromKeyboard(rightWidth > 0 ? "right" : "left"),
278
+ onKeyDown: onToggleKeyDown,
279
+ className: cn("sr-only grid place-items-center rounded-full bg-muted text-muted-foreground outline-none", "focus-visible:not-sr-only focus-visible:absolute focus-visible:top-1/2 focus-visible:right-3 focus-visible:h-8 focus-visible:w-8 focus-visible:-translate-y-1/2 focus-visible:ring-2 focus-visible:ring-ring"),
280
+ children: /* @__PURE__ */ jsx(Ellipsis, {
281
+ "aria-hidden": true,
282
+ className: "h-4 w-4"
283
+ })
284
+ }) : null]
228
285
  })]
229
286
  });
230
287
  }
@@ -1 +1 @@
1
- {"version":3,"file":"swipeable-list.js","names":[],"sources":["../../../src/components/motion/swipeable-list.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useRef, useState } from \"react\";\nimport { animate, motion, type PanInfo, useMotionValue, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\nexport type SwipeSide = \"left\" | \"right\";\n\nexport type SwipeableListValue = {\n id: string;\n side: SwipeSide;\n};\n\nexport type SwipeActionTone = \"neutral\" | \"primary\" | \"success\" | \"warning\" | \"danger\";\n\nexport type SwipeAction = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n tone?: SwipeActionTone;\n disabled?: boolean;\n onClick?: (item: SwipeableListItem) => void;\n};\n\nexport type SwipeableListItem = {\n id: string;\n title?: ReactNode;\n description?: ReactNode;\n meta?: ReactNode;\n leading?: ReactNode;\n content?: ReactNode;\n leftActions?: SwipeAction[];\n rightActions?: SwipeAction[];\n disabled?: boolean;\n};\n\nexport type SwipeableListClassNames = {\n root?: string;\n item?: string;\n rail?: string;\n action?: string;\n surface?: string;\n leading?: string;\n content?: string;\n title?: string;\n description?: string;\n meta?: string;\n};\n\nexport interface SwipeableListProps {\n items: SwipeableListItem[];\n value?: SwipeableListValue | null;\n defaultValue?: SwipeableListValue | null;\n onValueChange?: (value: SwipeableListValue | null) => void;\n onAction?: (payload: { item: SwipeableListItem; action: SwipeAction; side: SwipeSide }) => void;\n actionWidth?: number;\n revealThreshold?: number;\n closeOnAction?: boolean;\n className?: string;\n classNames?: SwipeableListClassNames;\n renderItem?: (item: SwipeableListItem) => ReactNode;\n}\n\n// Distance-based release spring keeps short rebounds and full reveals feeling\n// equally direct, closer to native mobile list interactions.\nconst ROW_SETTLE = {\n type: \"spring\",\n stiffness: 560,\n damping: 48,\n mass: 0.82,\n restDelta: 0.5,\n restSpeed: 8,\n} as const;\nconst OPEN_DISTANCE_RATIO = 0.46;\nconst CLOSE_DISTANCE_RATIO = 0.72;\nconst OPEN_VELOCITY = 720;\nconst CLOSE_VELOCITY = 320;\nconst FLING_DISTANCE = 14;\nconst RELEASE_VELOCITY_LIMIT = 1500;\n\nconst ACTION_TONE_CLASS: Record<SwipeActionTone, string> = {\n neutral: \"text-muted-foreground group-hover:text-foreground\",\n primary: \"text-foreground\",\n success: \"text-emerald-600 dark:text-emerald-400\",\n warning: \"text-amber-600 dark:text-amber-400\",\n danger: \"text-destructive\",\n};\n\nfunction useControllableSwipeValue({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: SwipeableListValue | null;\n defaultValue?: SwipeableListValue | null;\n onValueChange?: (value: SwipeableListValue | null) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? null);\n const isControlled = value !== undefined;\n const currentValue = value ?? internalValue;\n\n const setValue = useCallback(\n (next: SwipeableListValue | null) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction isActionableSide(value: number, sideWidth: number) {\n return sideWidth > 0 && Math.abs(value) > 0;\n}\n\nfunction clampReleaseVelocity(velocity: number) {\n return Math.max(-RELEASE_VELOCITY_LIMIT, Math.min(RELEASE_VELOCITY_LIMIT, velocity));\n}\n\nfunction SwipeActionButton({\n action,\n actionWidth,\n side,\n focusable,\n onAction,\n className,\n}: {\n action: SwipeAction;\n actionWidth: number;\n side: SwipeSide;\n focusable: boolean;\n onAction: (action: SwipeAction, side: SwipeSide) => void;\n className?: string;\n}) {\n return (\n <button\n type=\"button\"\n disabled={action.disabled}\n tabIndex={focusable ? 0 : -1}\n aria-label={typeof action.label === \"string\" ? action.label : undefined}\n onClick={() => onAction(action, side)}\n className={cn(\n \"group flex h-full shrink-0 items-center justify-center outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n style={{ width: actionWidth }}\n >\n <span\n className={cn(\n \"grid h-9 w-9 place-items-center rounded-full transition-[background-color,color,transform] duration-150 group-hover:bg-background group-active:scale-95\",\n ACTION_TONE_CLASS[action.tone ?? \"neutral\"],\n )}\n >\n {action.icon}\n </span>\n <span className=\"sr-only\">{action.label}</span>\n </button>\n );\n}\n\nfunction SwipeableListRow({\n item,\n actionWidth,\n revealThreshold,\n openValue,\n setOpenValue,\n closeOnAction,\n onAction,\n classNames,\n renderItem,\n}: {\n item: SwipeableListItem;\n actionWidth: number;\n revealThreshold: number;\n openValue: SwipeableListValue | null;\n setOpenValue: (value: SwipeableListValue | null) => void;\n closeOnAction: boolean;\n onAction?: SwipeableListProps[\"onAction\"];\n classNames?: SwipeableListClassNames;\n renderItem?: (item: SwipeableListItem) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const x = useMotionValue(0);\n const animationRef = useRef<{ stop: () => void } | null>(null);\n const commandedTargetRef = useRef(0);\n const leftActions = item.leftActions ?? [];\n const rightActions = item.rightActions ?? [];\n const leftWidth = leftActions.length * actionWidth;\n const rightWidth = rightActions.length * actionWidth;\n const openSide = openValue?.id === item.id ? openValue.side : null;\n const targetX = openSide === \"left\" ? leftWidth : openSide === \"right\" ? -rightWidth : 0;\n\n const settleX = useCallback(\n (nextX: number, velocity = 0) => {\n commandedTargetRef.current = nextX;\n animationRef.current?.stop();\n\n if (reduce) {\n x.set(nextX);\n return;\n }\n\n animationRef.current = animate(x, nextX, {\n ...ROW_SETTLE,\n velocity: clampReleaseVelocity(velocity),\n onComplete: () => x.set(nextX),\n });\n },\n [reduce, x],\n );\n\n useEffect(() => {\n return () => animationRef.current?.stop();\n }, []);\n\n useEffect(() => {\n if (commandedTargetRef.current === targetX) {\n return;\n }\n\n settleX(targetX);\n }, [settleX, targetX]);\n\n const getTargetX = useCallback(\n (side: SwipeSide | null) => (side === \"left\" ? leftWidth : side === \"right\" ? -rightWidth : 0),\n [leftWidth, rightWidth],\n );\n\n const snapTo = useCallback(\n (side: SwipeSide | null, velocity = 0) => {\n setOpenValue(side ? { id: item.id, side } : null);\n settleX(getTargetX(side), velocity);\n },\n [getTargetX, item.id, setOpenValue, settleX],\n );\n\n const onDragStart = useCallback(() => {\n animationRef.current?.stop();\n\n if (openValue && openValue.id !== item.id) {\n setOpenValue(null);\n }\n }, [item.id, openValue, setOpenValue]);\n\n const onDragEnd = useCallback(\n (_: PointerEvent, info: PanInfo) => {\n const velocity = info.velocity.x;\n const latest = x.get();\n const leftOpenThreshold = Math.max(revealThreshold, leftWidth * OPEN_DISTANCE_RATIO);\n const rightOpenThreshold = Math.max(revealThreshold, rightWidth * OPEN_DISTANCE_RATIO);\n\n if (openSide === \"left\") {\n if (latest < leftWidth * CLOSE_DISTANCE_RATIO || velocity < -CLOSE_VELOCITY) {\n snapTo(null, velocity);\n return;\n }\n\n snapTo(\"left\", velocity);\n return;\n }\n\n if (openSide === \"right\") {\n if (Math.abs(latest) < rightWidth * CLOSE_DISTANCE_RATIO || velocity > CLOSE_VELOCITY) {\n snapTo(null, velocity);\n return;\n }\n\n snapTo(\"right\", velocity);\n return;\n }\n\n if (\n isActionableSide(latest, leftWidth) &&\n (latest > leftOpenThreshold || (velocity > OPEN_VELOCITY && latest > FLING_DISTANCE))\n ) {\n snapTo(\"left\", velocity);\n return;\n }\n\n if (\n isActionableSide(latest, rightWidth) &&\n (latest < -rightOpenThreshold || (velocity < -OPEN_VELOCITY && latest < -FLING_DISTANCE))\n ) {\n snapTo(\"right\", velocity);\n return;\n }\n\n snapTo(null, velocity);\n },\n [leftWidth, openSide, revealThreshold, rightWidth, snapTo, x],\n );\n\n const handleAction = useCallback(\n (action: SwipeAction, side: SwipeSide) => {\n action.onClick?.(item);\n onAction?.({ item, action, side });\n\n if (closeOnAction) {\n snapTo(null);\n }\n },\n [closeOnAction, item, onAction, snapTo],\n );\n\n const defaultContent = (\n <div className=\"flex min-w-0 items-center gap-3\">\n {item.leading ? (\n <div className={cn(\"shrink-0\", classNames?.leading)}>{item.leading}</div>\n ) : null}\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n {item.title ? (\n <div className={cn(\"truncate font-medium text-foreground text-sm\", classNames?.title)}>\n {item.title}\n </div>\n ) : null}\n {item.description ? (\n <div\n className={cn(\"mt-0.5 truncate text-muted-foreground text-xs\", classNames?.description)}\n >\n {item.description}\n </div>\n ) : null}\n </div>\n {item.meta ? (\n <div className={cn(\"shrink-0 font-medium text-muted-foreground text-xs\", classNames?.meta)}>\n {item.meta}\n </div>\n ) : null}\n </div>\n );\n\n return (\n <div\n className={cn(\n \"relative isolate overflow-hidden rounded-2xl bg-muted\",\n item.disabled && \"opacity-60\",\n classNames?.item,\n )}\n >\n <div\n aria-hidden={!openSide}\n inert={!openSide}\n className={cn(\"absolute inset-0 z-0 flex overflow-hidden rounded-2xl\", classNames?.rail)}\n >\n <div className=\"flex h-full overflow-hidden rounded-l-2xl\">\n {leftActions.map((action) => (\n <SwipeActionButton\n key={action.id}\n action={action}\n actionWidth={actionWidth}\n className={classNames?.action}\n focusable={openSide === \"left\"}\n onAction={handleAction}\n side=\"left\"\n />\n ))}\n </div>\n <div className=\"ml-auto flex h-full overflow-hidden rounded-r-2xl\">\n {rightActions.map((action) => (\n <SwipeActionButton\n key={action.id}\n action={action}\n actionWidth={actionWidth}\n className={classNames?.action}\n focusable={openSide === \"right\"}\n onAction={handleAction}\n side=\"right\"\n />\n ))}\n </div>\n </div>\n\n <motion.div\n drag={item.disabled ? false : \"x\"}\n dragConstraints={{ left: -rightWidth, right: leftWidth }}\n dragElastic={0.04}\n dragMomentum={false}\n onDragStart={onDragStart}\n onDragEnd={onDragEnd}\n style={{ x }}\n className={cn(\n // `touch-pan-y`, not `touch-none`: the row owns the horizontal\n // swipe, the page keeps the vertical scroll through it.\n \"relative z-10 min-h-[72px] cursor-grab touch-pan-y rounded-2xl border border-border bg-card px-4 py-3 shadow-sm active:cursor-grabbing\",\n // The swipe is the row's, but what it carries is the consumer's:\n // selection is only suppressed where the platform runs its own press\n // gestures, so a mouse can still select and copy the row's text.\n TOUCH_GESTURE_CONTENT_CLASS,\n classNames?.surface,\n )}\n >\n {renderItem ? renderItem(item) : (item.content ?? defaultContent)}\n </motion.div>\n </div>\n );\n}\n\nexport function SwipeableList({\n items,\n value,\n defaultValue = null,\n onValueChange,\n onAction,\n actionWidth = 56,\n revealThreshold = 34,\n closeOnAction = true,\n className,\n classNames,\n renderItem,\n}: SwipeableListProps) {\n const [openValue, setOpenValue] = useControllableSwipeValue({\n value,\n defaultValue,\n onValueChange,\n });\n\n return (\n <div className={cn(\"flex w-full flex-col gap-2\", className, classNames?.root)}>\n {items.map((item) => (\n <SwipeableListRow\n key={item.id}\n item={item}\n actionWidth={actionWidth}\n revealThreshold={revealThreshold}\n openValue={openValue}\n setOpenValue={setOpenValue}\n closeOnAction={closeOnAction}\n onAction={onAction}\n classNames={classNames}\n renderItem={renderItem}\n />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAmEA,MAAM,aAAa;CACjB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;CACN,WAAW;CACX,WAAW;AACb;AACA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM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MAChB,WACA,YACA,cACqB;CACrB,MAAM,CAAC,WAAW,gBAAgB,0BAA0B;EAC1D;EACA;EACA;CACF,CAAC;CAED,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,8BAA8B,WAAW,YAAY,IAAI;EACzE,UAAA,MAAM,KAAK,SACV,oBAAC,kBAAD;GAEQ;GACO;GACI;GACN;GACG;GACC;GACL;GACE;GACA;EACb,GAVM,KAAK,EAUX,CACF;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"swipeable-list.js","names":[],"sources":["../../../src/components/motion/swipeable-list.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { Ellipsis } from \"lucide-react\";\nimport { animate, motion, type PanInfo, useMotionValue, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\nexport type SwipeSide = \"left\" | \"right\";\n\nexport type SwipeableListValue = {\n id: string;\n side: SwipeSide;\n};\n\nexport type SwipeActionTone = \"neutral\" | \"primary\" | \"success\" | \"warning\" | \"danger\";\n\nexport type SwipeAction = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n tone?: SwipeActionTone;\n disabled?: boolean;\n onClick?: (item: SwipeableListItem) => void;\n};\n\nexport type SwipeableListItem = {\n id: string;\n title?: ReactNode;\n description?: ReactNode;\n meta?: ReactNode;\n leading?: ReactNode;\n content?: ReactNode;\n leftActions?: SwipeAction[];\n rightActions?: SwipeAction[];\n disabled?: boolean;\n};\n\nexport type SwipeableListClassNames = {\n root?: string;\n item?: string;\n rail?: string;\n action?: string;\n surface?: string;\n leading?: string;\n content?: string;\n title?: string;\n description?: string;\n meta?: string;\n};\n\nexport interface SwipeableListProps {\n items: SwipeableListItem[];\n value?: SwipeableListValue | null;\n defaultValue?: SwipeableListValue | null;\n onValueChange?: (value: SwipeableListValue | null) => void;\n onAction?: (payload: { item: SwipeableListItem; action: SwipeAction; side: SwipeSide }) => void;\n actionWidth?: number;\n revealThreshold?: number;\n closeOnAction?: boolean;\n className?: string;\n classNames?: SwipeableListClassNames;\n renderItem?: (item: SwipeableListItem) => ReactNode;\n}\n\n// Distance-based release spring keeps short rebounds and full reveals feeling\n// equally direct, closer to native mobile list interactions.\nconst ROW_SETTLE = {\n type: \"spring\",\n stiffness: 560,\n damping: 48,\n mass: 0.82,\n restDelta: 0.5,\n restSpeed: 8,\n} as const;\nconst OPEN_DISTANCE_RATIO = 0.46;\nconst CLOSE_DISTANCE_RATIO = 0.72;\nconst OPEN_VELOCITY = 720;\nconst CLOSE_VELOCITY = 320;\nconst FLING_DISTANCE = 14;\nconst RELEASE_VELOCITY_LIMIT = 1500;\n\nconst ACTION_TONE_CLASS: Record<SwipeActionTone, string> = {\n neutral: \"text-muted-foreground group-hover:text-foreground\",\n primary: \"text-foreground\",\n success: \"text-emerald-600 dark:text-emerald-400\",\n warning: \"text-amber-600 dark:text-amber-400\",\n danger: \"text-destructive\",\n};\n\nfunction useControllableSwipeValue({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: SwipeableListValue | null;\n defaultValue?: SwipeableListValue | null;\n onValueChange?: (value: SwipeableListValue | null) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? null);\n const isControlled = value !== undefined;\n const currentValue = value ?? internalValue;\n\n const setValue = useCallback(\n (next: SwipeableListValue | null) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction isActionableSide(value: number, sideWidth: number) {\n return sideWidth > 0 && Math.abs(value) > 0;\n}\n\nfunction clampReleaseVelocity(velocity: number) {\n return Math.max(-RELEASE_VELOCITY_LIMIT, Math.min(RELEASE_VELOCITY_LIMIT, velocity));\n}\n\nfunction SwipeActionButton({\n action,\n actionWidth,\n side,\n focusable,\n onAction,\n className,\n}: {\n action: SwipeAction;\n actionWidth: number;\n side: SwipeSide;\n focusable: boolean;\n onAction: (action: SwipeAction, side: SwipeSide) => void;\n className?: string;\n}) {\n return (\n <button\n type=\"button\"\n disabled={action.disabled}\n tabIndex={focusable ? 0 : -1}\n aria-label={typeof action.label === \"string\" ? action.label : undefined}\n onClick={() => onAction(action, side)}\n className={cn(\n \"group flex h-full shrink-0 items-center justify-center outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n style={{ width: actionWidth }}\n >\n <span\n className={cn(\n \"grid h-9 w-9 place-items-center rounded-full transition-[background-color,color,transform] duration-150 group-hover:bg-background group-active:scale-95\",\n ACTION_TONE_CLASS[action.tone ?? \"neutral\"],\n )}\n >\n {action.icon}\n </span>\n <span className=\"sr-only\">{action.label}</span>\n </button>\n );\n}\n\nfunction SwipeableListRow({\n item,\n actionWidth,\n revealThreshold,\n openValue,\n setOpenValue,\n closeOnAction,\n onAction,\n classNames,\n renderItem,\n}: {\n item: SwipeableListItem;\n actionWidth: number;\n revealThreshold: number;\n openValue: SwipeableListValue | null;\n setOpenValue: (value: SwipeableListValue | null) => void;\n closeOnAction: boolean;\n onAction?: SwipeableListProps[\"onAction\"];\n classNames?: SwipeableListClassNames;\n renderItem?: (item: SwipeableListItem) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const railId = useId();\n const railRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n // Set when the keyboard opens a side, so focus follows into its actions once\n // the rail stops being inert.\n const focusActions = useRef(false);\n const x = useMotionValue(0);\n const animationRef = useRef<{ stop: () => void } | null>(null);\n const commandedTargetRef = useRef(0);\n const leftActions = item.leftActions ?? [];\n const rightActions = item.rightActions ?? [];\n const leftWidth = leftActions.length * actionWidth;\n const rightWidth = rightActions.length * actionWidth;\n const openSide = openValue?.id === item.id ? openValue.side : null;\n const targetX = openSide === \"left\" ? leftWidth : openSide === \"right\" ? -rightWidth : 0;\n\n const settleX = useCallback(\n (nextX: number, velocity = 0) => {\n commandedTargetRef.current = nextX;\n animationRef.current?.stop();\n\n if (reduce) {\n x.set(nextX);\n return;\n }\n\n animationRef.current = animate(x, nextX, {\n ...ROW_SETTLE,\n velocity: clampReleaseVelocity(velocity),\n onComplete: () => x.set(nextX),\n });\n },\n [reduce, x],\n );\n\n useEffect(() => {\n return () => animationRef.current?.stop();\n }, []);\n\n useEffect(() => {\n if (commandedTargetRef.current === targetX) {\n return;\n }\n\n settleX(targetX);\n }, [settleX, targetX]);\n\n const getTargetX = useCallback(\n (side: SwipeSide | null) => (side === \"left\" ? leftWidth : side === \"right\" ? -rightWidth : 0),\n [leftWidth, rightWidth],\n );\n\n const snapTo = useCallback(\n (side: SwipeSide | null, velocity = 0) => {\n setOpenValue(side ? { id: item.id, side } : null);\n settleX(getTargetX(side), velocity);\n },\n [getTargetX, item.id, setOpenValue, settleX],\n );\n\n const onDragStart = useCallback(() => {\n animationRef.current?.stop();\n\n if (openValue && openValue.id !== item.id) {\n setOpenValue(null);\n }\n }, [item.id, openValue, setOpenValue]);\n\n const onDragEnd = useCallback(\n (_: PointerEvent, info: PanInfo) => {\n const velocity = info.velocity.x;\n const latest = x.get();\n const leftOpenThreshold = Math.max(revealThreshold, leftWidth * OPEN_DISTANCE_RATIO);\n const rightOpenThreshold = Math.max(revealThreshold, rightWidth * OPEN_DISTANCE_RATIO);\n\n if (openSide === \"left\") {\n if (latest < leftWidth * CLOSE_DISTANCE_RATIO || velocity < -CLOSE_VELOCITY) {\n snapTo(null, velocity);\n return;\n }\n\n snapTo(\"left\", velocity);\n return;\n }\n\n if (openSide === \"right\") {\n if (Math.abs(latest) < rightWidth * CLOSE_DISTANCE_RATIO || velocity > CLOSE_VELOCITY) {\n snapTo(null, velocity);\n return;\n }\n\n snapTo(\"right\", velocity);\n return;\n }\n\n if (\n isActionableSide(latest, leftWidth) &&\n (latest > leftOpenThreshold || (velocity > OPEN_VELOCITY && latest > FLING_DISTANCE))\n ) {\n snapTo(\"left\", velocity);\n return;\n }\n\n if (\n isActionableSide(latest, rightWidth) &&\n (latest < -rightOpenThreshold || (velocity < -OPEN_VELOCITY && latest < -FLING_DISTANCE))\n ) {\n snapTo(\"right\", velocity);\n return;\n }\n\n snapTo(null, velocity);\n },\n [leftWidth, openSide, revealThreshold, rightWidth, snapTo, x],\n );\n\n const handleAction = useCallback(\n (action: SwipeAction, side: SwipeSide) => {\n action.onClick?.(item);\n onAction?.({ item, action, side });\n\n if (closeOnAction) {\n // The rail turns inert as the row closes; keep focus on the row.\n if (railRef.current?.contains(document.activeElement)) toggleRef.current?.focus();\n snapTo(null);\n }\n },\n [closeOnAction, item, onAction, snapTo],\n );\n\n useEffect(() => {\n if (!openSide || !focusActions.current) return;\n focusActions.current = false;\n railRef.current\n ?.querySelector<HTMLButtonElement>(`[data-side=\"${openSide}\"] button:not(:disabled)`)\n ?.focus();\n }, [openSide]);\n\n const hasActions = leftWidth > 0 || rightWidth > 0;\n const openFromKeyboard = (side: SwipeSide) => {\n if ((side === \"left\" ? leftWidth : rightWidth) === 0) return;\n focusActions.current = true;\n snapTo(side);\n };\n\n // Keyboard stand-in for the swipe: the arrow keys move the row the way a\n // swipe would, Enter or Space opens the trailing actions, and Escape closes.\n const onToggleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (openSide === \"left\") snapTo(null);\n else openFromKeyboard(\"right\");\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (openSide === \"right\") snapTo(null);\n else openFromKeyboard(\"left\");\n } else if (event.key === \"Escape\" && openSide) {\n event.preventDefault();\n snapTo(null);\n }\n };\n\n const onRailKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n toggleRef.current?.focus();\n snapTo(null);\n };\n\n const defaultContent = (\n <div className=\"flex min-w-0 items-center gap-3\">\n {item.leading ? (\n <div className={cn(\"shrink-0\", classNames?.leading)}>{item.leading}</div>\n ) : null}\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n {item.title ? (\n <div className={cn(\"truncate font-medium text-foreground text-sm\", classNames?.title)}>\n {item.title}\n </div>\n ) : null}\n {item.description ? (\n <div\n className={cn(\"mt-0.5 truncate text-muted-foreground text-xs\", classNames?.description)}\n >\n {item.description}\n </div>\n ) : null}\n </div>\n {item.meta ? (\n <div className={cn(\"shrink-0 font-medium text-muted-foreground text-xs\", classNames?.meta)}>\n {item.meta}\n </div>\n ) : null}\n </div>\n );\n\n return (\n <div\n className={cn(\n \"relative isolate overflow-hidden rounded-2xl bg-muted\",\n item.disabled && \"opacity-60\",\n classNames?.item,\n )}\n >\n <div\n ref={railRef}\n id={railId}\n aria-hidden={!openSide}\n inert={!openSide}\n onKeyDown={onRailKeyDown}\n className={cn(\"absolute inset-0 z-0 flex overflow-hidden rounded-2xl\", classNames?.rail)}\n >\n <div data-side=\"left\" className=\"flex h-full overflow-hidden rounded-l-2xl\">\n {leftActions.map((action) => (\n <SwipeActionButton\n key={action.id}\n action={action}\n actionWidth={actionWidth}\n className={classNames?.action}\n focusable={openSide === \"left\"}\n onAction={handleAction}\n side=\"left\"\n />\n ))}\n </div>\n <div data-side=\"right\" className=\"ml-auto flex h-full overflow-hidden rounded-r-2xl\">\n {rightActions.map((action) => (\n <SwipeActionButton\n key={action.id}\n action={action}\n actionWidth={actionWidth}\n className={classNames?.action}\n focusable={openSide === \"right\"}\n onAction={handleAction}\n side=\"right\"\n />\n ))}\n </div>\n </div>\n\n <motion.div\n drag={item.disabled ? false : \"x\"}\n dragConstraints={{ left: -rightWidth, right: leftWidth }}\n dragElastic={0.04}\n dragMomentum={false}\n onDragStart={onDragStart}\n onDragEnd={onDragEnd}\n style={{ x }}\n className={cn(\n // `touch-pan-y`, not `touch-none`: the row owns the horizontal\n // swipe, the page keeps the vertical scroll through it.\n \"relative z-10 min-h-[72px] cursor-grab touch-pan-y rounded-2xl border border-border bg-card px-4 py-3 shadow-sm active:cursor-grabbing\",\n // The swipe is the row's, but what it carries is the consumer's:\n // selection is only suppressed where the platform runs its own press\n // gestures, so a mouse can still select and copy the row's text.\n TOUCH_GESTURE_CONTENT_CLASS,\n classNames?.surface,\n )}\n >\n {renderItem ? renderItem(item) : (item.content ?? defaultContent)}\n {hasActions && !item.disabled ? (\n // Only visible while focused from the keyboard; pointers swipe.\n <button\n ref={toggleRef}\n type=\"button\"\n aria-label={\n typeof item.title === \"string\" ? `Actions for ${item.title}` : \"Show actions\"\n }\n aria-expanded={openSide !== null}\n aria-controls={railId}\n onClick={() =>\n openSide ? snapTo(null) : openFromKeyboard(rightWidth > 0 ? \"right\" : \"left\")\n }\n onKeyDown={onToggleKeyDown}\n className={cn(\n \"sr-only grid place-items-center rounded-full bg-muted text-muted-foreground outline-none\",\n \"focus-visible:not-sr-only focus-visible:absolute focus-visible:top-1/2 focus-visible:right-3 focus-visible:h-8 focus-visible:w-8 focus-visible:-translate-y-1/2 focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <Ellipsis aria-hidden className=\"h-4 w-4\" />\n </button>\n ) : null}\n </motion.div>\n </div>\n );\n}\n\nexport function SwipeableList({\n items,\n value,\n defaultValue = null,\n onValueChange,\n onAction,\n actionWidth = 56,\n revealThreshold = 34,\n closeOnAction = true,\n className,\n classNames,\n renderItem,\n}: SwipeableListProps) {\n const [openValue, setOpenValue] = useControllableSwipeValue({\n value,\n defaultValue,\n onValueChange,\n });\n\n return (\n <div className={cn(\"flex w-full flex-col gap-2\", className, classNames?.root)}>\n {items.map((item) => (\n <SwipeableListRow\n key={item.id}\n item={item}\n actionWidth={actionWidth}\n revealThreshold={revealThreshold}\n openValue={openValue}\n setOpenValue={setOpenValue}\n closeOnAction={closeOnAction}\n onAction={onAction}\n classNames={classNames}\n renderItem={renderItem}\n />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;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,KAAK,UAAU;IAEjE,iBAAe,aAAa;IAC5B,iBAAe;IACf,eACE,WAAW,OAAO,IAAI,IAAI,iBAAiB,aAAa,IAAI,UAAU,MAAM;IAE9E,WAAW;IACX,WAAW,GACT,4FACA,8MACF;IAEA,UAAA,oBAAC,UAAD;KAAU,eAAA;KAAY,WAAU;IAAW,CAAA;GACrC,CAAA,IACN,IACM;EACT,CAAA,CAAA;;AAET;AAEA,SAAgB,cAAc,EAC5B,OACA,OACA,eAAe,MACf,eACA,UACA,cAAc,IACd,kBAAkB,IAClB,gBAAgB,MAChB,WACA,YACA,cACqB;CACrB,MAAM,CAAC,WAAW,gBAAgB,0BAA0B;EAC1D;EACA;EACA;CACF,CAAC;CAED,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,8BAA8B,WAAW,YAAY,IAAI;EACzE,UAAA,MAAM,KAAK,SACV,oBAAC,kBAAD;GAEQ;GACO;GACI;GACN;GACG;GACC;GACL;GACE;GACA;EACb,GAVM,KAAK,EAUX,CACF;CACE,CAAA;AAET"}
@@ -2,8 +2,8 @@
2
2
  import { TableMenu } from "./table-menu.js";
3
3
  import { useEffect } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { ArrowDownToLine, ArrowUpToLine, MoreVertical, Trash2 } from "lucide-react";
6
5
  import { createPortal } from "react-dom";
6
+ import { ArrowDownToLine, ArrowUpToLine, MoreVertical, Trash2 } from "lucide-react";
7
7
  //#region src/components/motion/table/row-handle.tsx
8
8
  /** The row handle, portaled so it can sit on the row's left border without the
9
9
  * scroll container clipping it. Straddles the border to bridge hover. */
@@ -8,8 +8,8 @@ import { useEffect } from "react";
8
8
  import { cn } from "@kumix/utils";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { motion } from "motion/react";
11
- import { ArrowLeftToLine, ArrowRightToLine, ChevronUp, GripVertical, MoreHorizontal, Trash2 } from "lucide-react";
12
11
  import { createPortal } from "react-dom";
12
+ import { ArrowLeftToLine, ArrowRightToLine, ChevronUp, GripVertical, MoreHorizontal, Trash2 } from "lucide-react";
13
13
  //#region src/components/motion/table/table-header.tsx
14
14
  /** Column insert / delete menu items shared by the header cell and the portal handle. */
15
15
  function columnMenuItems(column, index, onInsertColumn, onDeleteColumn) {
@@ -1,19 +1,28 @@
1
1
  import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from "react";
2
2
  //#region src/components/motion/tabs.d.ts
3
3
  type Variant = "pill" | "underline" | "segment";
4
- export declare function Tabs({ defaultValue, value, onValueChange, variant, children, className }: {
4
+ /** Whether trigger icons show on every tab or only on the selected one. */
5
+ type IconDisplay = "always" | "selected";
6
+ export declare function Tabs({ defaultValue, value, onValueChange, variant, icons, children, className }: {
5
7
  defaultValue?: string;
6
8
  value?: string;
7
9
  onValueChange?: (v: string) => void;
8
10
  variant?: Variant;
11
+ /**
12
+ * With "selected", a trigger's icon springs open only on the selected tab
13
+ * and folds away when another is chosen. Defaults to "always".
14
+ */
15
+ icons?: IconDisplay;
9
16
  children: ReactNode;
10
17
  className?: string;
11
18
  }): import("react").JSX.Element;
12
- export declare function TabsList({ children, className, wrapperClassName, ...props }: {
19
+ export declare function TabsList({ children, className, wrapperClassName, onKeyDown, ...props }: {
13
20
  wrapperClassName?: string;
14
21
  } & HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
15
- export declare function TabsTrigger({ value, children, className, indicatorClassName, onClick, ...props }: {
22
+ export declare function TabsTrigger({ value, icon, children, className, indicatorClassName, onClick, ...props }: {
16
23
  value: string;
24
+ /** An icon before the label, such as a Lucide icon element. */
25
+ icon?: ReactNode;
17
26
  indicatorClassName?: string;
18
27
  } & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value">): import("react").JSX.Element;
19
28
  export declare function TabsContent({ value, children, className }: {
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.d.ts","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"mappings":";;KA4BK;wBA2BW,OACd,cACA,OACA,eACA,SACA,UACA;EAEA;EACA;EACA,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV;oBACD,IAAA;wBAsCe,WACd,UACA,WACA,qBACG;EAEH;IACE,eAAe,kCAAe,IAAA;wBAgOlB,cACd,OACA,UACA,WACA,oBACA,YACG;EAEH;EACA;IACE,KAAK,qBAAqB,+CAA4B,IAAA;wBAgF1C,cACd,OACA,UACA;EAEA;EACA,UAAU;EACV;oBACD,IAAA"}
1
+ {"version":3,"file":"tabs.d.ts","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"mappings":";;KA+BK;;KAEA;wBAiDW,OACd,cACA,OACA,eACA,SACA,OACA,UACA;EAEA;EACA;EACA,iBAAiB;EACjB,UAAU;;;;;EAKV,QAAQ;EACR,UAAU;EACV;oBACD,IAAA;wBAqHe,WACd,UACA,WACA,kBACA,cACG;EAEH;IACE,eAAe,kCAAe,IAAA;wBAyWlB,cACd,OACA,MACA,UACA,WACA,oBACA,YACG;EAEH;;EAEA,OAAO;EACP;IACE,KAAK,qBAAqB,+CAA4B,IAAA;wBAmI1C,cACd,OACA,UACA;EAEA;EACA,UAAU;EACV;oBACD,IAAA"}