@kumix/ui 0.3.13 → 0.3.14

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 (522) hide show
  1. package/README.md +2 -2
  2. package/dist/components/agents/agent-activity/activity-row.js +1 -1
  3. package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
  4. package/dist/components/agents/agent-activity/index.js +1 -1
  5. package/dist/components/agents/agent-activity/index.js.map +1 -1
  6. package/dist/components/agents/agent-code.d.ts.map +1 -1
  7. package/dist/components/agents/agent-code.js +1 -1
  8. package/dist/components/agents/agent-code.js.map +1 -1
  9. package/dist/components/agents/agent-disclosure.js +1 -1
  10. package/dist/components/agents/agent-disclosure.js.map +1 -1
  11. package/dist/components/agents/ai-sidebar.js +1 -1
  12. package/dist/components/agents/ai-sidebar.js.map +1 -1
  13. package/dist/components/agents/approval-card/index.js +1 -1
  14. package/dist/components/agents/approval-card/index.js.map +1 -1
  15. package/dist/components/agents/chat-app.js +1 -1
  16. package/dist/components/agents/chat-app.js.map +1 -1
  17. package/dist/components/agents/citations.js +1 -1
  18. package/dist/components/agents/citations.js.map +1 -1
  19. package/dist/components/agents/code-block.js +1 -1
  20. package/dist/components/agents/code-block.js.map +1 -1
  21. package/dist/components/agents/file-diff.js +1 -1
  22. package/dist/components/agents/file-diff.js.map +1 -1
  23. package/dist/components/agents/image-generation.js +1 -1
  24. package/dist/components/agents/image-generation.js.map +1 -1
  25. package/dist/components/agents/loading-states/agent-progress.js +1 -1
  26. package/dist/components/agents/loading-states/agent-progress.js.map +1 -1
  27. package/dist/components/agents/loading-states/reasoning-text.js +1 -1
  28. package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
  29. package/dist/components/agents/loading-states/thinking-shimmer.js +1 -1
  30. package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -1
  31. package/dist/components/agents/message-bubble.js +1 -1
  32. package/dist/components/agents/message-bubble.js.map +1 -1
  33. package/dist/components/agents/message-scroller.js +1 -1
  34. package/dist/components/agents/message-scroller.js.map +1 -1
  35. package/dist/components/agents/message.js +1 -1
  36. package/dist/components/agents/message.js.map +1 -1
  37. package/dist/components/agents/prompt-input.js +1 -1
  38. package/dist/components/agents/prompt-input.js.map +1 -1
  39. package/dist/components/agents/streaming-response.js +1 -1
  40. package/dist/components/agents/streaming-response.js.map +1 -1
  41. package/dist/components/agents/todo-list.js +1 -1
  42. package/dist/components/agents/todo-list.js.map +1 -1
  43. package/dist/components/agents/tool-approval.js +1 -1
  44. package/dist/components/agents/tool-approval.js.map +1 -1
  45. package/dist/components/agents/tool-result.js +1 -1
  46. package/dist/components/agents/tool-result.js.map +1 -1
  47. package/dist/components/motion/action-swap.js +1 -1
  48. package/dist/components/motion/action-swap.js.map +1 -1
  49. package/dist/components/motion/adaptive-stepper.js +1 -1
  50. package/dist/components/motion/adaptive-stepper.js.map +1 -1
  51. package/dist/components/motion/animated-badge.js +1 -1
  52. package/dist/components/motion/animated-badge.js.map +1 -1
  53. package/dist/components/motion/animated-number.js +1 -1
  54. package/dist/components/motion/animated-number.js.map +1 -1
  55. package/dist/components/motion/animated-sidebar.js +1 -1
  56. package/dist/components/motion/animated-sidebar.js.map +1 -1
  57. package/dist/components/motion/animated-toast-stack.js +1 -1
  58. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  59. package/dist/components/motion/attachment-upload.js +1 -1
  60. package/dist/components/motion/attachment-upload.js.map +1 -1
  61. package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
  62. package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
  63. package/dist/components/motion/availability-scheduler/index.js +1 -1
  64. package/dist/components/motion/availability-scheduler/index.js.map +1 -1
  65. package/dist/components/motion/bloom-menu.js +1 -1
  66. package/dist/components/motion/bloom-menu.js.map +1 -1
  67. package/dist/components/motion/bottom-sheet.js +1 -1
  68. package/dist/components/motion/bottom-sheet.js.map +1 -1
  69. package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
  70. package/dist/components/motion/bounce-sidebar.js +1 -1
  71. package/dist/components/motion/bounce-sidebar.js.map +1 -1
  72. package/dist/components/motion/bouncy-accordion.js +1 -1
  73. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  74. package/dist/components/motion/button/base.js +1 -1
  75. package/dist/components/motion/button/base.js.map +1 -1
  76. package/dist/components/motion/button/metallic.js +1 -1
  77. package/dist/components/motion/button/metallic.js.map +1 -1
  78. package/dist/components/motion/card-folder.js +1 -1
  79. package/dist/components/motion/card-folder.js.map +1 -1
  80. package/dist/components/motion/center-morph-modal.js +1 -1
  81. package/dist/components/motion/center-morph-modal.js.map +1 -1
  82. package/dist/components/motion/checkbox.js +1 -1
  83. package/dist/components/motion/checkbox.js.map +1 -1
  84. package/dist/components/motion/chromatic-text-reveal.js +1 -1
  85. package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
  86. package/dist/components/motion/combobox/content.js +1 -1
  87. package/dist/components/motion/combobox/content.js.map +1 -1
  88. package/dist/components/motion/combobox/context.js +1 -1
  89. package/dist/components/motion/combobox/context.js.map +1 -1
  90. package/dist/components/motion/combobox/list.js +1 -1
  91. package/dist/components/motion/combobox/list.js.map +1 -1
  92. package/dist/components/motion/combobox/trigger.js +1 -1
  93. package/dist/components/motion/combobox/trigger.js.map +1 -1
  94. package/dist/components/motion/command-palette.js +1 -1
  95. package/dist/components/motion/command-palette.js.map +1 -1
  96. package/dist/components/motion/context-menu.js +1 -1
  97. package/dist/components/motion/context-menu.js.map +1 -1
  98. package/dist/components/motion/cylinder-carousel.js +1 -1
  99. package/dist/components/motion/cylinder-carousel.js.map +1 -1
  100. package/dist/components/motion/digit-swap.js +1 -1
  101. package/dist/components/motion/digit-swap.js.map +1 -1
  102. package/dist/components/motion/dock.js +1 -1
  103. package/dist/components/motion/dock.js.map +1 -1
  104. package/dist/components/motion/drawer.js +1 -1
  105. package/dist/components/motion/drawer.js.map +1 -1
  106. package/dist/components/motion/dynamic-island.js +1 -1
  107. package/dist/components/motion/dynamic-island.js.map +1 -1
  108. package/dist/components/motion/expandable-action-bar.js +1 -1
  109. package/dist/components/motion/expandable-action-bar.js.map +1 -1
  110. package/dist/components/motion/expandable-control.d.ts.map +1 -1
  111. package/dist/components/motion/expandable-control.js +1 -1
  112. package/dist/components/motion/expandable-control.js.map +1 -1
  113. package/dist/components/motion/expandable-tabs.js +1 -1
  114. package/dist/components/motion/expandable-tabs.js.map +1 -1
  115. package/dist/components/motion/expanding-arrow-button.js +1 -1
  116. package/dist/components/motion/expanding-arrow-button.js.map +1 -1
  117. package/dist/components/motion/feedback-widget.js +1 -1
  118. package/dist/components/motion/feedback-widget.js.map +1 -1
  119. package/dist/components/motion/file-tree.js +1 -1
  120. package/dist/components/motion/file-tree.js.map +1 -1
  121. package/dist/components/motion/file-upload.js +1 -1
  122. package/dist/components/motion/file-upload.js.map +1 -1
  123. package/dist/components/motion/hold-action-button.js +1 -1
  124. package/dist/components/motion/hold-action-button.js.map +1 -1
  125. package/dist/components/motion/infinite-masonry.js +1 -1
  126. package/dist/components/motion/infinite-masonry.js.map +1 -1
  127. package/dist/components/motion/input.d.ts.map +1 -1
  128. package/dist/components/motion/input.js +1 -1
  129. package/dist/components/motion/input.js.map +1 -1
  130. package/dist/components/motion/liquid.js +1 -1
  131. package/dist/components/motion/liquid.js.map +1 -1
  132. package/dist/components/motion/loader.js +1 -1
  133. package/dist/components/motion/loader.js.map +1 -1
  134. package/dist/components/motion/magnetic.js +1 -1
  135. package/dist/components/motion/magnetic.js.map +1 -1
  136. package/dist/components/motion/marquee.d.ts.map +1 -1
  137. package/dist/components/motion/marquee.js +1 -1
  138. package/dist/components/motion/marquee.js.map +1 -1
  139. package/dist/components/motion/morphing-modal.js +1 -1
  140. package/dist/components/motion/morphing-modal.js.map +1 -1
  141. package/dist/components/motion/morphing-search.js +1 -1
  142. package/dist/components/motion/morphing-search.js.map +1 -1
  143. package/dist/components/motion/morphing-tabs.js +1 -1
  144. package/dist/components/motion/morphing-tabs.js.map +1 -1
  145. package/dist/components/motion/multi-select/content.js +1 -1
  146. package/dist/components/motion/multi-select/content.js.map +1 -1
  147. package/dist/components/motion/multi-select/context.js +1 -1
  148. package/dist/components/motion/multi-select/context.js.map +1 -1
  149. package/dist/components/motion/multi-select/list.js +1 -1
  150. package/dist/components/motion/multi-select/list.js.map +1 -1
  151. package/dist/components/motion/multi-select/trigger.js +1 -1
  152. package/dist/components/motion/multi-select/trigger.js.map +1 -1
  153. package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
  154. package/dist/components/motion/not-found/magnetic.js +1 -1
  155. package/dist/components/motion/not-found/magnetic.js.map +1 -1
  156. package/dist/components/motion/not-found/shared.js +1 -1
  157. package/dist/components/motion/not-found/shared.js.map +1 -1
  158. package/dist/components/motion/not-found/spotlight.js +1 -1
  159. package/dist/components/motion/not-found/spotlight.js.map +1 -1
  160. package/dist/components/motion/notification-stack.js +1 -1
  161. package/dist/components/motion/notification-stack.js.map +1 -1
  162. package/dist/components/motion/number-ticker.js +1 -1
  163. package/dist/components/motion/number-ticker.js.map +1 -1
  164. package/dist/components/motion/otp-input.js +1 -1
  165. package/dist/components/motion/otp-input.js.map +1 -1
  166. package/dist/components/motion/overflow-actions.js +1 -1
  167. package/dist/components/motion/overflow-actions.js.map +1 -1
  168. package/dist/components/motion/parallax.d.ts.map +1 -1
  169. package/dist/components/motion/parallax.js +1 -1
  170. package/dist/components/motion/parallax.js.map +1 -1
  171. package/dist/components/motion/popover-morph.js +1 -1
  172. package/dist/components/motion/popover-morph.js.map +1 -1
  173. package/dist/components/motion/popover.js +1 -1
  174. package/dist/components/motion/popover.js.map +1 -1
  175. package/dist/components/motion/preview-rail.js +1 -1
  176. package/dist/components/motion/preview-rail.js.map +1 -1
  177. package/dist/components/motion/project-folder.js +1 -1
  178. package/dist/components/motion/project-folder.js.map +1 -1
  179. package/dist/components/motion/pull-to-refresh.js +1 -1
  180. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  181. package/dist/components/motion/radio.js +1 -1
  182. package/dist/components/motion/radio.js.map +1 -1
  183. package/dist/components/motion/range-slider-bubble.js +1 -1
  184. package/dist/components/motion/range-slider-bubble.js.map +1 -1
  185. package/dist/components/motion/range-slider-fluid.js +1 -1
  186. package/dist/components/motion/range-slider-fluid.js.map +1 -1
  187. package/dist/components/motion/range-slider-inline.d.ts +18 -0
  188. package/dist/components/motion/range-slider-inline.d.ts.map +1 -0
  189. package/dist/components/motion/range-slider-inline.js +267 -0
  190. package/dist/components/motion/range-slider-inline.js.map +1 -0
  191. package/dist/components/motion/range-slider-ruler.js +1 -1
  192. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  193. package/dist/components/motion/range-slider-wave.js +1 -1
  194. package/dist/components/motion/range-slider-wave.js.map +1 -1
  195. package/dist/components/motion/range-slider.d.ts.map +1 -1
  196. package/dist/components/motion/range-slider.js +27 -11
  197. package/dist/components/motion/range-slider.js.map +1 -1
  198. package/dist/components/motion/scroll-progress.js +1 -1
  199. package/dist/components/motion/scroll-progress.js.map +1 -1
  200. package/dist/components/motion/scroll-reveal.js +1 -1
  201. package/dist/components/motion/scroll-reveal.js.map +1 -1
  202. package/dist/components/motion/scroll-to.js +1 -1
  203. package/dist/components/motion/scroll-to.js.map +1 -1
  204. package/dist/components/motion/select-morph.d.ts.map +1 -1
  205. package/dist/components/motion/select-morph.js +1 -1
  206. package/dist/components/motion/select-morph.js.map +1 -1
  207. package/dist/components/motion/select.js +1 -1
  208. package/dist/components/motion/select.js.map +1 -1
  209. package/dist/components/motion/shader-background.d.ts.map +1 -1
  210. package/dist/components/motion/shader-background.js +1 -1
  211. package/dist/components/motion/shader-background.js.map +1 -1
  212. package/dist/components/motion/shared-layout-bg.js +1 -1
  213. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  214. package/dist/components/motion/signup-form.js +1 -1
  215. package/dist/components/motion/signup-form.js.map +1 -1
  216. package/dist/components/motion/slide-action-button.js +1 -1
  217. package/dist/components/motion/slide-action-button.js.map +1 -1
  218. package/dist/components/motion/swipeable-list.js +1 -1
  219. package/dist/components/motion/swipeable-list.js.map +1 -1
  220. package/dist/components/motion/switch.d.ts.map +1 -1
  221. package/dist/components/motion/switch.js +1 -1
  222. package/dist/components/motion/switch.js.map +1 -1
  223. package/dist/components/motion/table/index.js +1 -1
  224. package/dist/components/motion/table/index.js.map +1 -1
  225. package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
  226. package/dist/components/motion/table/skeleton-rows.js +1 -1
  227. package/dist/components/motion/table/skeleton-rows.js.map +1 -1
  228. package/dist/components/motion/table/table-header.js +1 -1
  229. package/dist/components/motion/table/table-header.js.map +1 -1
  230. package/dist/components/motion/table/table-menu.js +1 -1
  231. package/dist/components/motion/table/table-menu.js.map +1 -1
  232. package/dist/components/motion/tabs.js +1 -1
  233. package/dist/components/motion/tabs.js.map +1 -1
  234. package/dist/components/motion/text-reveal.js +1 -1
  235. package/dist/components/motion/text-reveal.js.map +1 -1
  236. package/dist/components/motion/text-scramble.d.ts.map +1 -1
  237. package/dist/components/motion/text-scramble.js +1 -1
  238. package/dist/components/motion/text-scramble.js.map +1 -1
  239. package/dist/components/motion/text-shimmer.js +1 -1
  240. package/dist/components/motion/text-shimmer.js.map +1 -1
  241. package/dist/components/motion/theme-toggle.js +1 -1
  242. package/dist/components/motion/theme-toggle.js.map +1 -1
  243. package/dist/components/motion/tilt-card.js +1 -1
  244. package/dist/components/motion/tilt-card.js.map +1 -1
  245. package/dist/components/motion/tooltip.js +1 -1
  246. package/dist/components/motion/tooltip.js.map +1 -1
  247. package/dist/components/motion/wheel-picker.js +1 -1
  248. package/dist/components/motion/wheel-picker.js.map +1 -1
  249. package/dist/components/reui/alert.d.ts +1 -1
  250. package/dist/components/reui/alert.d.ts.map +1 -1
  251. package/dist/components/reui/alert.js +1 -1
  252. package/dist/components/reui/alert.js.map +1 -1
  253. package/dist/components/reui/autocomplete.d.ts +1 -1
  254. package/dist/components/reui/autocomplete.js +1 -1
  255. package/dist/components/reui/autocomplete.js.map +1 -1
  256. package/dist/components/reui/badge.d.ts +2 -2
  257. package/dist/components/reui/badge.d.ts.map +1 -1
  258. package/dist/components/reui/badge.js +1 -1
  259. package/dist/components/reui/badge.js.map +1 -1
  260. package/dist/components/reui/cascader/cascader-columns.js +1 -1
  261. package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
  262. package/dist/components/reui/cascader/cascader-footer.js +1 -1
  263. package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
  264. package/dist/components/reui/cascader/cascader-item.js +1 -1
  265. package/dist/components/reui/cascader/cascader-item.js.map +1 -1
  266. package/dist/components/reui/cascader/cascader-nav.js +1 -1
  267. package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
  268. package/dist/components/reui/cascader/cascader.js +1 -1
  269. package/dist/components/reui/cascader/cascader.js.map +1 -1
  270. package/dist/components/reui/code-block/code-block.js +1 -1
  271. package/dist/components/reui/code-block/code-block.js.map +1 -1
  272. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
  273. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
  274. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
  275. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  276. package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
  277. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  278. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
  279. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  280. package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
  281. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  282. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
  283. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  284. package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
  285. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  286. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  287. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  288. package/dist/components/reui/data-grid/data-grid.js +1 -1
  289. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  290. package/dist/components/reui/date-selector.js +1 -1
  291. package/dist/components/reui/date-selector.js.map +1 -1
  292. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
  293. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
  294. package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
  295. package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
  296. package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
  297. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  298. package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
  299. package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
  300. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  301. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
  302. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
  303. package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
  304. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
  305. package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
  306. package/dist/components/reui/event-calendar/event-calendar.js +1 -1
  307. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  308. package/dist/components/reui/filters/filters-advanced.js +1 -1
  309. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  310. package/dist/components/reui/filters/filters-builder.js +2 -2
  311. package/dist/components/reui/filters/filters-builder.js.map +1 -1
  312. package/dist/components/reui/filters/filters-chip.js +1 -1
  313. package/dist/components/reui/filters/filters-chip.js.map +1 -1
  314. package/dist/components/reui/filters/filters-editors.js +2 -2
  315. package/dist/components/reui/filters/filters-editors.js.map +1 -1
  316. package/dist/components/reui/filters/filters.js +1 -1
  317. package/dist/components/reui/filters/filters.js.map +1 -1
  318. package/dist/components/reui/frame.d.ts +2 -2
  319. package/dist/components/reui/frame.d.ts.map +1 -1
  320. package/dist/components/reui/frame.js +1 -1
  321. package/dist/components/reui/frame.js.map +1 -1
  322. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  323. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  324. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  325. package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
  326. package/dist/components/reui/gantt/gantt-view.js +1 -1
  327. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  328. package/dist/components/reui/gantt/gantt.js +1 -1
  329. package/dist/components/reui/gantt/gantt.js.map +1 -1
  330. package/dist/components/reui/icon-stack.js +1 -1
  331. package/dist/components/reui/icon-stack.js.map +1 -1
  332. package/dist/components/reui/icon-tile.d.ts +2 -2
  333. package/dist/components/reui/icon-tile.d.ts.map +1 -1
  334. package/dist/components/reui/icon-tile.js +1 -1
  335. package/dist/components/reui/icon-tile.js.map +1 -1
  336. package/dist/components/reui/kanban.d.ts.map +1 -1
  337. package/dist/components/reui/kanban.js +1 -1
  338. package/dist/components/reui/kanban.js.map +1 -1
  339. package/dist/components/reui/number-field.d.ts +3 -3
  340. package/dist/components/reui/number-field.js +1 -1
  341. package/dist/components/reui/number-field.js.map +1 -1
  342. package/dist/components/reui/phone-input.js +1 -1
  343. package/dist/components/reui/phone-input.js.map +1 -1
  344. package/dist/components/reui/rating.d.ts +1 -1
  345. package/dist/components/reui/rating.d.ts.map +1 -1
  346. package/dist/components/reui/rating.js +1 -1
  347. package/dist/components/reui/rating.js.map +1 -1
  348. package/dist/components/reui/sortable.d.ts.map +1 -1
  349. package/dist/components/reui/sortable.js +1 -1
  350. package/dist/components/reui/sortable.js.map +1 -1
  351. package/dist/components/reui/stepper.d.ts.map +1 -1
  352. package/dist/components/reui/stepper.js +1 -1
  353. package/dist/components/reui/stepper.js.map +1 -1
  354. package/dist/components/reui/timeline.d.ts.map +1 -1
  355. package/dist/components/reui/timeline.js +1 -1
  356. package/dist/components/reui/timeline.js.map +1 -1
  357. package/dist/components/reui/tree.d.ts.map +1 -1
  358. package/dist/components/reui/tree.js +1 -1
  359. package/dist/components/reui/tree.js.map +1 -1
  360. package/dist/components/ui/accordion.d.ts.map +1 -1
  361. package/dist/components/ui/accordion.js +1 -1
  362. package/dist/components/ui/accordion.js.map +1 -1
  363. package/dist/components/ui/alert-dialog.js +1 -1
  364. package/dist/components/ui/alert-dialog.js.map +1 -1
  365. package/dist/components/ui/alert.d.ts.map +1 -1
  366. package/dist/components/ui/alert.js +1 -1
  367. package/dist/components/ui/alert.js.map +1 -1
  368. package/dist/components/ui/aspect-ratio.js +1 -1
  369. package/dist/components/ui/aspect-ratio.js.map +1 -1
  370. package/dist/components/ui/attachment.d.ts +1 -1
  371. package/dist/components/ui/attachment.js +1 -1
  372. package/dist/components/ui/attachment.js.map +1 -1
  373. package/dist/components/ui/avatar.d.ts.map +1 -1
  374. package/dist/components/ui/avatar.js +1 -1
  375. package/dist/components/ui/avatar.js.map +1 -1
  376. package/dist/components/ui/badge.d.ts +1 -1
  377. package/dist/components/ui/badge.d.ts.map +1 -1
  378. package/dist/components/ui/badge.js +1 -1
  379. package/dist/components/ui/badge.js.map +1 -1
  380. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  381. package/dist/components/ui/breadcrumb.js +1 -1
  382. package/dist/components/ui/breadcrumb.js.map +1 -1
  383. package/dist/components/ui/bubble.d.ts +1 -1
  384. package/dist/components/ui/bubble.d.ts.map +1 -1
  385. package/dist/components/ui/bubble.js +1 -1
  386. package/dist/components/ui/bubble.js.map +1 -1
  387. package/dist/components/ui/button-group.js +1 -1
  388. package/dist/components/ui/button-group.js.map +1 -1
  389. package/dist/components/ui/button.d.ts +2 -2
  390. package/dist/components/ui/button.d.ts.map +1 -1
  391. package/dist/components/ui/button.js +1 -1
  392. package/dist/components/ui/button.js.map +1 -1
  393. package/dist/components/ui/calendar.js +1 -1
  394. package/dist/components/ui/calendar.js.map +1 -1
  395. package/dist/components/ui/card.d.ts.map +1 -1
  396. package/dist/components/ui/card.js +1 -1
  397. package/dist/components/ui/card.js.map +1 -1
  398. package/dist/components/ui/carousel.js +1 -1
  399. package/dist/components/ui/carousel.js.map +1 -1
  400. package/dist/components/ui/chart.d.ts.map +1 -1
  401. package/dist/components/ui/chart.js +1 -1
  402. package/dist/components/ui/chart.js.map +1 -1
  403. package/dist/components/ui/checkbox.d.ts.map +1 -1
  404. package/dist/components/ui/checkbox.js +1 -1
  405. package/dist/components/ui/checkbox.js.map +1 -1
  406. package/dist/components/ui/combobox.js +1 -1
  407. package/dist/components/ui/combobox.js.map +1 -1
  408. package/dist/components/ui/command.js +1 -1
  409. package/dist/components/ui/command.js.map +1 -1
  410. package/dist/components/ui/context-menu.d.ts.map +1 -1
  411. package/dist/components/ui/context-menu.js +1 -1
  412. package/dist/components/ui/context-menu.js.map +1 -1
  413. package/dist/components/ui/dialog.js +1 -1
  414. package/dist/components/ui/dialog.js.map +1 -1
  415. package/dist/components/ui/drawer.d.ts.map +1 -1
  416. package/dist/components/ui/drawer.js +1 -1
  417. package/dist/components/ui/drawer.js.map +1 -1
  418. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  419. package/dist/components/ui/dropdown-menu.js +1 -1
  420. package/dist/components/ui/dropdown-menu.js.map +1 -1
  421. package/dist/components/ui/empty.d.ts.map +1 -1
  422. package/dist/components/ui/empty.js +1 -1
  423. package/dist/components/ui/empty.js.map +1 -1
  424. package/dist/components/ui/field.js +1 -1
  425. package/dist/components/ui/field.js.map +1 -1
  426. package/dist/components/ui/hover-card.d.ts.map +1 -1
  427. package/dist/components/ui/hover-card.js +1 -1
  428. package/dist/components/ui/hover-card.js.map +1 -1
  429. package/dist/components/ui/input-group.js +1 -1
  430. package/dist/components/ui/input-group.js.map +1 -1
  431. package/dist/components/ui/input-otp.d.ts.map +1 -1
  432. package/dist/components/ui/input-otp.js +1 -1
  433. package/dist/components/ui/input-otp.js.map +1 -1
  434. package/dist/components/ui/input.d.ts.map +1 -1
  435. package/dist/components/ui/input.js +1 -1
  436. package/dist/components/ui/input.js.map +1 -1
  437. package/dist/components/ui/item.d.ts +2 -2
  438. package/dist/components/ui/item.js +1 -1
  439. package/dist/components/ui/item.js.map +1 -1
  440. package/dist/components/ui/kbd.js +1 -1
  441. package/dist/components/ui/kbd.js.map +1 -1
  442. package/dist/components/ui/label.d.ts.map +1 -1
  443. package/dist/components/ui/label.js +1 -1
  444. package/dist/components/ui/label.js.map +1 -1
  445. package/dist/components/ui/marker.d.ts.map +1 -1
  446. package/dist/components/ui/marker.js +1 -1
  447. package/dist/components/ui/marker.js.map +1 -1
  448. package/dist/components/ui/menubar.js +1 -1
  449. package/dist/components/ui/menubar.js.map +1 -1
  450. package/dist/components/ui/message-scroller.js +1 -1
  451. package/dist/components/ui/message-scroller.js.map +1 -1
  452. package/dist/components/ui/message.d.ts.map +1 -1
  453. package/dist/components/ui/message.js +1 -1
  454. package/dist/components/ui/message.js.map +1 -1
  455. package/dist/components/ui/native-select.d.ts.map +1 -1
  456. package/dist/components/ui/native-select.js +1 -1
  457. package/dist/components/ui/native-select.js.map +1 -1
  458. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  459. package/dist/components/ui/navigation-menu.js +1 -1
  460. package/dist/components/ui/navigation-menu.js.map +1 -1
  461. package/dist/components/ui/pagination.js +1 -1
  462. package/dist/components/ui/pagination.js.map +1 -1
  463. package/dist/components/ui/popover.d.ts.map +1 -1
  464. package/dist/components/ui/popover.js +1 -1
  465. package/dist/components/ui/popover.js.map +1 -1
  466. package/dist/components/ui/progress.d.ts.map +1 -1
  467. package/dist/components/ui/progress.js +1 -1
  468. package/dist/components/ui/progress.js.map +1 -1
  469. package/dist/components/ui/questionnaire.js +1 -1
  470. package/dist/components/ui/questionnaire.js.map +1 -1
  471. package/dist/components/ui/radio-group.d.ts.map +1 -1
  472. package/dist/components/ui/radio-group.js +1 -1
  473. package/dist/components/ui/radio-group.js.map +1 -1
  474. package/dist/components/ui/resizable.d.ts.map +1 -1
  475. package/dist/components/ui/resizable.js +1 -1
  476. package/dist/components/ui/resizable.js.map +1 -1
  477. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  478. package/dist/components/ui/scroll-area.js +1 -1
  479. package/dist/components/ui/scroll-area.js.map +1 -1
  480. package/dist/components/ui/select.d.ts.map +1 -1
  481. package/dist/components/ui/select.js +1 -1
  482. package/dist/components/ui/select.js.map +1 -1
  483. package/dist/components/ui/separator.d.ts.map +1 -1
  484. package/dist/components/ui/separator.js +1 -1
  485. package/dist/components/ui/separator.js.map +1 -1
  486. package/dist/components/ui/sheet.js +1 -1
  487. package/dist/components/ui/sheet.js.map +1 -1
  488. package/dist/components/ui/sidebar.d.ts +2 -2
  489. package/dist/components/ui/sidebar.js +1 -1
  490. package/dist/components/ui/sidebar.js.map +1 -1
  491. package/dist/components/ui/skeleton.js +1 -1
  492. package/dist/components/ui/skeleton.js.map +1 -1
  493. package/dist/components/ui/slider.d.ts.map +1 -1
  494. package/dist/components/ui/slider.js +1 -1
  495. package/dist/components/ui/slider.js.map +1 -1
  496. package/dist/components/ui/spinner.d.ts.map +1 -1
  497. package/dist/components/ui/spinner.js +1 -1
  498. package/dist/components/ui/spinner.js.map +1 -1
  499. package/dist/components/ui/switch.d.ts.map +1 -1
  500. package/dist/components/ui/switch.js +1 -1
  501. package/dist/components/ui/switch.js.map +1 -1
  502. package/dist/components/ui/table.d.ts.map +1 -1
  503. package/dist/components/ui/table.js +1 -1
  504. package/dist/components/ui/table.js.map +1 -1
  505. package/dist/components/ui/tabs.d.ts.map +1 -1
  506. package/dist/components/ui/tabs.js +1 -1
  507. package/dist/components/ui/tabs.js.map +1 -1
  508. package/dist/components/ui/textarea.d.ts.map +1 -1
  509. package/dist/components/ui/textarea.js +1 -1
  510. package/dist/components/ui/textarea.js.map +1 -1
  511. package/dist/components/ui/toast.js +1 -1
  512. package/dist/components/ui/toast.js.map +1 -1
  513. package/dist/components/ui/toggle-group.js +1 -1
  514. package/dist/components/ui/toggle-group.js.map +1 -1
  515. package/dist/components/ui/toggle.d.ts +2 -2
  516. package/dist/components/ui/toggle.d.ts.map +1 -1
  517. package/dist/components/ui/toggle.js +1 -1
  518. package/dist/components/ui/toggle.js.map +1 -1
  519. package/dist/components/ui/tooltip.d.ts.map +1 -1
  520. package/dist/components/ui/tooltip.js +1 -1
  521. package/dist/components/ui/tooltip.js.map +1 -1
  522. package/package.json +8 -10
@@ -1 +1 @@
1
- {"version":3,"file":"context-menu.js","names":[],"sources":["../../../src/components/motion/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { Check } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { holdSelection, TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\ntype OpenModality = \"pointer\" | \"keyboard\" | \"touch\";\ntype MenuPoint = { x: number; y: number };\n\nconst VIEWPORT_PADDING = 8;\nconst LONG_PRESS_DELAY = 520;\nconst LONG_PRESS_TOLERANCE = 10;\nconst MORPH_DURATION = 0.3;\n\ntype TriggerElementProps = React.HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n};\n\ninterface ContextMenuContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n openAt: (point: MenuPoint, modality: OpenModality) => void;\n point: MenuPoint;\n modality: OpenModality;\n invocation: number;\n menuId: string;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n activeId: string | null;\n setActiveId: (id: string | null) => void;\n reduce: boolean;\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null);\n\nfunction useContextMenuContext(component: string) {\n const context = useContext(ContextMenuContext);\n if (!context) {\n throw new Error(`${component} must be used within <ContextMenu>`);\n }\n return context;\n}\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n\nfunction getEnabledItems(container: HTMLElement | null) {\n if (!container) return [];\n return Array.from(\n container.querySelectorAll<HTMLElement>(\n '[data-context-menu-item=\"true\"]:not([data-disabled=\"true\"])',\n ),\n );\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction collapsedClip(origin: MenuPoint, size: { width: number; height: number }) {\n const half = 8;\n const top = clamp(origin.y - half, 0, size.height);\n const right = clamp(size.width - origin.x - half, 0, size.width);\n const bottom = clamp(size.height - origin.y - half, 0, size.height);\n const left = clamp(origin.x - half, 0, size.width);\n return `inset(${top}px ${right}px ${bottom}px ${left}px round 10px)`;\n}\n\nexport interface ContextMenuProps {\n children: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\nexport function ContextMenu({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: ContextMenuProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [point, setPoint] = useState<MenuPoint>({ x: 0, y: 0 });\n const [modality, setModality] = useState<OpenModality>(\"pointer\");\n const [invocation, setInvocation] = useState(0);\n const [activeId, setActiveId] = useState<string | null>(null);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n const reduce = useReducedMotion() ?? false;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n if (!next) setActiveId(null);\n },\n [controlled, onOpenChange],\n );\n\n const openAt = useCallback(\n (nextPoint: MenuPoint, nextModality: OpenModality) => {\n setPoint(nextPoint);\n setModality(nextModality);\n setInvocation((current) => current + 1);\n setActiveId(null);\n setOpen(true);\n },\n [setOpen],\n );\n\n useEffect(() => {\n if (!open) return;\n\n const onPointerDown = (event: PointerEvent) => {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n };\n const onWindowChange = () => setOpen(false);\n\n window.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"resize\", onWindowChange);\n window.addEventListener(\"scroll\", onWindowChange);\n return () => {\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"resize\", onWindowChange);\n window.removeEventListener(\"scroll\", onWindowChange);\n };\n }, [open, setOpen]);\n\n const value = useMemo<ContextMenuContextValue>(\n () => ({\n open,\n setOpen,\n openAt,\n point,\n modality,\n invocation,\n menuId,\n triggerRef,\n contentRef,\n activeId,\n setActiveId,\n reduce,\n }),\n [open, setOpen, openAt, point, modality, invocation, menuId, activeId, reduce],\n );\n\n return (\n <ContextMenuContext.Provider value={value}>\n <div className={cn(\"contents\", className)}>{children}</div>\n </ContextMenuContext.Provider>\n );\n}\n\nexport interface ContextMenuTriggerProps {\n children: ReactElement<TriggerElementProps>;\n disabled?: boolean;\n className?: string;\n}\n\nexport function ContextMenuTrigger({\n children,\n disabled = false,\n className,\n}: ContextMenuTriggerProps) {\n const context = useContextMenuContext(\"ContextMenuTrigger\");\n const longPressTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchOrigin = useRef<MenuPoint | null>(null);\n const releaseSelection = useRef<(() => void) | null>(null);\n\n const cancelLongPress = useCallback(() => {\n if (longPressTimer.current) {\n clearTimeout(longPressTimer.current);\n longPressTimer.current = null;\n }\n touchOrigin.current = null;\n }, []);\n\n // Held for the whole press, not just the timer: a gesture that turned into a\n // drag must not paint a selection under the finger either.\n const endPress = useCallback(() => {\n cancelLongPress();\n releaseSelection.current?.();\n releaseSelection.current = null;\n }, [cancelLongPress]);\n\n useEffect(() => endPress, [endPress]);\n\n if (!isValidElement(children)) {\n throw new Error(\"<ContextMenuTrigger> requires a single React element\");\n }\n\n const childProps = children.props;\n const childRef = children.props.ref;\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerDown?.(event);\n // A pen presses the same way a finger does and gets no `contextmenu` out\n // of the platform for it, so it holds to open too. A mouse has the right\n // button and is left to `onContextMenu`.\n const pressToOpen = event.pointerType === \"touch\" || event.pointerType === \"pen\";\n if (event.defaultPrevented || disabled || !pressToOpen) return;\n\n // `pointer-coarse:select-none` misses this press on a laptop whose mouse\n // is the primary pointer and whose touchscreen is not, and the platform's\n // own long-press selection then claims the gesture and cancels ours. The\n // press is the only thing that knows which input is on the glass, so it\n // takes selection away itself — for its own duration, and no longer.\n releaseSelection.current?.();\n releaseSelection.current = holdSelection(event.currentTarget);\n\n const origin = { x: event.clientX, y: event.clientY };\n touchOrigin.current = origin;\n longPressTimer.current = setTimeout(() => {\n context.openAt(origin, \"touch\");\n longPressTimer.current = null;\n touchOrigin.current = null;\n }, LONG_PRESS_DELAY);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerMove?.(event);\n const origin = touchOrigin.current;\n if (\n origin &&\n Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > LONG_PRESS_TOLERANCE\n ) {\n cancelLongPress();\n }\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n childProps.onKeyDown?.(event);\n if (event.defaultPrevented || disabled) return;\n if (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\")) return;\n\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n context.openAt(\n { x: rect.left + Math.min(24, rect.width / 2), y: rect.top + rect.height / 2 },\n \"keyboard\",\n );\n };\n\n return cloneElement(children, {\n ref: (node: HTMLElement | null) => {\n context.triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-controls\": context.open ? context.menuId : undefined,\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": context.open,\n // The long press is ours: without this iOS runs its own on the same\n // gesture and drops the selection callout and its handles on top of the\n // menu we just opened. Only the press gesture is ours though — the child\n // is the consumer's content, so a mouse can still select the text in it\n // and right-click the selection. `touch-none` stays off too: the page\n // still has to scroll from the trigger.\n className: cn(TOUCH_GESTURE_CONTENT_CLASS, childProps.className, className),\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n childProps.onContextMenu?.(event);\n if (event.defaultPrevented || disabled) return;\n event.preventDefault();\n endPress();\n context.openAt({ x: event.clientX, y: event.clientY }, \"pointer\");\n },\n onKeyDown,\n onPointerDown,\n onPointerMove,\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerUp?.(event);\n endPress();\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerCancel?.(event);\n endPress();\n },\n });\n}\n\nexport interface ContextMenuContentProps {\n children: ReactNode;\n className?: string;\n ariaLabel?: string;\n}\n\nexport function ContextMenuContent({\n children,\n className,\n ariaLabel = \"Context menu\",\n}: ContextMenuContentProps) {\n const context = useContextMenuContext(\"ContextMenuContent\");\n const [mounted, setMounted] = useState(false);\n const [position, setPosition] = useState<MenuPoint>(context.point);\n const [origin, setOrigin] = useState<MenuPoint>({ x: 0, y: 0 });\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [morphReady, setMorphReady] = useState(false);\n const typeahead = useRef(\"\");\n const typeaheadTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => setMounted(true), []);\n\n useLayoutEffect(() => {\n if (!context.open) {\n setMorphReady(false);\n return;\n }\n const content = context.contentRef.current;\n if (!content) return;\n content.dataset.invocation = String(context.invocation);\n\n const rect = content.getBoundingClientRect();\n const left = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.x, VIEWPORT_PADDING),\n window.innerWidth - rect.width - VIEWPORT_PADDING,\n ),\n );\n const top = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.y, VIEWPORT_PADDING),\n window.innerHeight - rect.height - VIEWPORT_PADDING,\n ),\n );\n\n setPosition({ x: left, y: top });\n setSize({ width: rect.width, height: rect.height });\n setOrigin({\n x: clamp(context.point.x - left, 12, Math.max(12, rect.width - 12)),\n y: clamp(context.point.y - top, 12, Math.max(12, rect.height - 12)),\n });\n setMorphReady(false);\n\n if (context.reduce || context.modality === \"keyboard\") {\n setMorphReady(true);\n return;\n }\n\n // Let the measured collapsed clip paint once before expanding it. Without\n // this preparation frame, the first invocation can batch both states and\n // appear at full size without the morph.\n let openFrame = 0;\n const prepareFrame = requestAnimationFrame(() => {\n openFrame = requestAnimationFrame(() => setMorphReady(true));\n });\n return () => {\n cancelAnimationFrame(prepareFrame);\n cancelAnimationFrame(openFrame);\n };\n }, [\n context.open,\n context.point,\n context.contentRef,\n context.invocation,\n context.modality,\n context.reduce,\n ]);\n\n useEffect(() => {\n if (!context.open) return;\n const frame = requestAnimationFrame(() => {\n const first = getEnabledItems(context.contentRef.current)[0];\n first?.focus({ preventScroll: true });\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, context.contentRef]);\n\n useEffect(\n () => () => {\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n },\n [],\n );\n\n const moveFocus = (direction: 1 | -1) => {\n const items = getEnabledItems(context.contentRef.current);\n if (items.length === 0) return;\n const current = items.indexOf(document.activeElement as HTMLElement);\n const next = current < 0 ? 0 : (current + direction + items.length) % items.length;\n items[next]?.focus();\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n context.setOpen(false);\n context.triggerRef.current?.focus();\n return;\n }\n if (event.key === \"Tab\") {\n context.setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n moveFocus(event.key === \"ArrowDown\" ? 1 : -1);\n return;\n }\n if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n const items = getEnabledItems(context.contentRef.current);\n items[event.key === \"Home\" ? 0 : items.length - 1]?.focus();\n return;\n }\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n typeahead.current += event.key.toLocaleLowerCase();\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n typeaheadTimer.current = setTimeout(() => {\n typeahead.current = \"\";\n }, 500);\n const match = getEnabledItems(context.contentRef.current).find((item) =>\n (item.dataset.label ?? item.textContent ?? \"\")\n .trim()\n .toLocaleLowerCase()\n .startsWith(typeahead.current),\n );\n match?.focus();\n }\n };\n\n if (!mounted) return null;\n\n const visualOpen = context.open && morphReady;\n const clipHidden = collapsedClip(origin, size);\n const clipShown = \"inset(0px 0px 0px 0px round 12px)\";\n\n return createPortal(\n <div\n data-context-menu-portal=\"\"\n aria-hidden={!context.open}\n inert={!context.open}\n style={{ left: position.x, top: position.y }}\n className={cn(\n \"filter-[drop-shadow(0_18px_28px_rgba(0,0,0,0.2))] fixed z-100\",\n context.open ? \"pointer-events-auto\" : \"pointer-events-none\",\n )}\n >\n <motion.div\n ref={context.contentRef}\n id={context.menuId}\n role=\"menu\"\n aria-label={ariaLabel}\n data-morph-ready={morphReady ? \"true\" : \"false\"}\n tabIndex={-1}\n initial={false}\n animate={{\n opacity: visualOpen ? 1 : 0,\n clipPath:\n context.reduce || context.modality === \"keyboard\" || visualOpen\n ? clipShown\n : clipHidden,\n }}\n transition={\n context.modality === \"keyboard\"\n ? { duration: 0 }\n : context.reduce\n ? { duration: 0.1, ease: EASE_OUT }\n : {\n clipPath: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n opacity: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n }\n }\n onKeyDown={onKeyDown}\n onContextMenu={(event) => event.preventDefault()}\n className={cn(\n \"min-w-56 overflow-hidden rounded-xl border border-border bg-card p-1.5 text-foreground outline-none\",\n className,\n )}\n >\n {children}\n </motion.div>\n </div>,\n document.body,\n );\n}\n\ntype ContextMenuItemTone = \"default\" | \"destructive\";\n\nexport interface ContextMenuItemProps {\n children: ReactNode;\n onSelect?: () => void;\n disabled?: boolean;\n closeOnSelect?: boolean;\n tone?: ContextMenuItemTone;\n inset?: boolean;\n className?: string;\n textValue?: string;\n}\n\nfunction ContextMenuItemBase({\n children,\n onSelect,\n disabled = false,\n closeOnSelect = true,\n tone = \"default\",\n inset = false,\n className,\n textValue,\n role = \"menuitem\",\n ariaChecked,\n}: ContextMenuItemProps & {\n role?: \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\";\n ariaChecked?: boolean;\n}) {\n const context = useContextMenuContext(\"ContextMenuItem\");\n const id = useId();\n const active = context.activeId === id;\n const checkedProps = role === \"menuitem\" ? {} : { \"aria-checked\": ariaChecked };\n\n return (\n <button\n type=\"button\"\n id={id}\n role={role}\n {...checkedProps}\n disabled={disabled}\n data-context-menu-item=\"true\"\n data-disabled={disabled ? \"true\" : undefined}\n data-label={textValue}\n tabIndex={-1}\n onFocus={() => context.setActiveId(id)}\n onPointerMove={(event) => {\n if (!disabled && event.pointerType !== \"touch\") event.currentTarget.focus();\n }}\n onClick={() => {\n if (disabled) return;\n onSelect?.();\n if (closeOnSelect) context.setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full select-none items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/15\",\n \"disabled:pointer-events-none disabled:opacity-40\",\n inset && \"pl-8\",\n tone === \"destructive\" ? \"text-destructive\" : \"text-foreground\",\n className,\n )}\n >\n {active ? (\n <motion.span\n layoutId={`${context.menuId}-active`}\n className={cn(\n \"absolute inset-0 -z-10 rounded-lg\",\n tone === \"destructive\" ? \"bg-destructive/10\" : \"bg-foreground/6.5\",\n )}\n transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n {children}\n </button>\n );\n}\n\nexport function ContextMenuItem(props: ContextMenuItemProps) {\n return <ContextMenuItemBase {...props} />;\n}\n\nexport interface ContextMenuCheckboxItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function ContextMenuCheckboxItem({\n checked,\n onCheckedChange,\n children,\n ...props\n}: ContextMenuCheckboxItemProps) {\n const context = useContextMenuContext(\"ContextMenuCheckboxItem\");\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemcheckbox\"\n ariaChecked={checked}\n onSelect={() => onCheckedChange?.(!checked)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <AnimatePresence initial={false}>\n {checked ? (\n <motion.span\n key=\"check\"\n initial={context.reduce ? false : { opacity: 0, scale: 0.75 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: context.reduce ? 1 : 0.75 }}\n transition={context.reduce ? { duration: 0.08 } : SPRING_PANEL}\n >\n <Check aria-hidden=\"true\" className=\"h-3.5 w-3.5\" strokeWidth={2.4} />\n </motion.span>\n ) : null}\n </AnimatePresence>\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\ninterface ContextMenuRadioGroupContextValue {\n value: string;\n onValueChange?: (value: string) => void;\n}\n\nconst ContextMenuRadioGroupContext = createContext<ContextMenuRadioGroupContextValue | null>(null);\n\nexport interface ContextMenuRadioGroupProps {\n value: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuRadioGroup({\n value,\n onValueChange,\n children,\n className,\n}: ContextMenuRadioGroupProps) {\n const context = useMemo(() => ({ value, onValueChange }), [value, onValueChange]);\n return (\n <ContextMenuRadioGroupContext.Provider value={context}>\n <div className={className}>{children}</div>\n </ContextMenuRadioGroupContext.Provider>\n );\n}\n\nexport interface ContextMenuRadioItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n value: string;\n}\n\nexport function ContextMenuRadioItem({ value, children, ...props }: ContextMenuRadioItemProps) {\n const group = useContext(ContextMenuRadioGroupContext);\n if (!group) {\n throw new Error(\"ContextMenuRadioItem must be used within <ContextMenuRadioGroup>\");\n }\n const checked = group.value === value;\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemradio\"\n ariaChecked={checked}\n onSelect={() => group.onValueChange?.(value)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <span\n className={cn(\n \"h-1.5 w-1.5 rounded-full bg-current transition-opacity\",\n checked ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\nexport interface ContextMenuLabelProps {\n children: ReactNode;\n inset?: boolean;\n className?: string;\n}\n\nexport function ContextMenuLabel({ children, inset = false, className }: ContextMenuLabelProps) {\n return (\n <div\n className={cn(\n \"px-2.5 pt-1.5 pb-1 font-semibold text-[10px] text-muted-foreground uppercase tracking-[0.12em]\",\n inset && \"pl-8\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ContextMenuSeparatorProps {\n className?: string;\n}\n\nexport function ContextMenuSeparator({ className }: ContextMenuSeparatorProps) {\n return <hr className={cn(\"-mx-1 my-1 h-px border-0 bg-border\", className)} />;\n}\n\nexport interface ContextMenuShortcutProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuShortcut({ children, className }: ContextMenuShortcutProps) {\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"ml-auto pl-4 font-medium text-[10px] text-muted-foreground tracking-wide\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AAqBvB,MAAM,qBAAqB,cAA8C,IAAI;AAE7E,SAAS,sBAAsB,WAAmB;CAChD,MAAM,UAA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":3,"file":"context-menu.js","names":[],"sources":["../../../src/components/motion/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { holdSelection, TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\ntype OpenModality = \"pointer\" | \"keyboard\" | \"touch\";\ntype MenuPoint = { x: number; y: number };\n\nconst VIEWPORT_PADDING = 8;\nconst LONG_PRESS_DELAY = 520;\nconst LONG_PRESS_TOLERANCE = 10;\nconst MORPH_DURATION = 0.3;\n\ntype TriggerElementProps = React.HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n};\n\ninterface ContextMenuContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n openAt: (point: MenuPoint, modality: OpenModality) => void;\n point: MenuPoint;\n modality: OpenModality;\n invocation: number;\n menuId: string;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n activeId: string | null;\n setActiveId: (id: string | null) => void;\n reduce: boolean;\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null);\n\nfunction useContextMenuContext(component: string) {\n const context = useContext(ContextMenuContext);\n if (!context) {\n throw new Error(`${component} must be used within <ContextMenu>`);\n }\n return context;\n}\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n\nfunction getEnabledItems(container: HTMLElement | null) {\n if (!container) return [];\n return Array.from(\n container.querySelectorAll<HTMLElement>(\n '[data-context-menu-item=\"true\"]:not([data-disabled=\"true\"])',\n ),\n );\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction collapsedClip(origin: MenuPoint, size: { width: number; height: number }) {\n const half = 8;\n const top = clamp(origin.y - half, 0, size.height);\n const right = clamp(size.width - origin.x - half, 0, size.width);\n const bottom = clamp(size.height - origin.y - half, 0, size.height);\n const left = clamp(origin.x - half, 0, size.width);\n return `inset(${top}px ${right}px ${bottom}px ${left}px round 10px)`;\n}\n\nexport interface ContextMenuProps {\n children: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\nexport function ContextMenu({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: ContextMenuProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [point, setPoint] = useState<MenuPoint>({ x: 0, y: 0 });\n const [modality, setModality] = useState<OpenModality>(\"pointer\");\n const [invocation, setInvocation] = useState(0);\n const [activeId, setActiveId] = useState<string | null>(null);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n const reduce = useReducedMotion() ?? false;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n if (!next) setActiveId(null);\n },\n [controlled, onOpenChange],\n );\n\n const openAt = useCallback(\n (nextPoint: MenuPoint, nextModality: OpenModality) => {\n setPoint(nextPoint);\n setModality(nextModality);\n setInvocation((current) => current + 1);\n setActiveId(null);\n setOpen(true);\n },\n [setOpen],\n );\n\n useEffect(() => {\n if (!open) return;\n\n const onPointerDown = (event: PointerEvent) => {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n };\n const onWindowChange = () => setOpen(false);\n\n window.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"resize\", onWindowChange);\n window.addEventListener(\"scroll\", onWindowChange);\n return () => {\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"resize\", onWindowChange);\n window.removeEventListener(\"scroll\", onWindowChange);\n };\n }, [open, setOpen]);\n\n const value = useMemo<ContextMenuContextValue>(\n () => ({\n open,\n setOpen,\n openAt,\n point,\n modality,\n invocation,\n menuId,\n triggerRef,\n contentRef,\n activeId,\n setActiveId,\n reduce,\n }),\n [open, setOpen, openAt, point, modality, invocation, menuId, activeId, reduce],\n );\n\n return (\n <ContextMenuContext.Provider value={value}>\n <div className={cn(\"contents\", className)}>{children}</div>\n </ContextMenuContext.Provider>\n );\n}\n\nexport interface ContextMenuTriggerProps {\n children: ReactElement<TriggerElementProps>;\n disabled?: boolean;\n className?: string;\n}\n\nexport function ContextMenuTrigger({\n children,\n disabled = false,\n className,\n}: ContextMenuTriggerProps) {\n const context = useContextMenuContext(\"ContextMenuTrigger\");\n const longPressTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchOrigin = useRef<MenuPoint | null>(null);\n const releaseSelection = useRef<(() => void) | null>(null);\n\n const cancelLongPress = useCallback(() => {\n if (longPressTimer.current) {\n clearTimeout(longPressTimer.current);\n longPressTimer.current = null;\n }\n touchOrigin.current = null;\n }, []);\n\n // Held for the whole press, not just the timer: a gesture that turned into a\n // drag must not paint a selection under the finger either.\n const endPress = useCallback(() => {\n cancelLongPress();\n releaseSelection.current?.();\n releaseSelection.current = null;\n }, [cancelLongPress]);\n\n useEffect(() => endPress, [endPress]);\n\n if (!isValidElement(children)) {\n throw new Error(\"<ContextMenuTrigger> requires a single React element\");\n }\n\n const childProps = children.props;\n const childRef = children.props.ref;\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerDown?.(event);\n // A pen presses the same way a finger does and gets no `contextmenu` out\n // of the platform for it, so it holds to open too. A mouse has the right\n // button and is left to `onContextMenu`.\n const pressToOpen = event.pointerType === \"touch\" || event.pointerType === \"pen\";\n if (event.defaultPrevented || disabled || !pressToOpen) return;\n\n // `pointer-coarse:select-none` misses this press on a laptop whose mouse\n // is the primary pointer and whose touchscreen is not, and the platform's\n // own long-press selection then claims the gesture and cancels ours. The\n // press is the only thing that knows which input is on the glass, so it\n // takes selection away itself — for its own duration, and no longer.\n releaseSelection.current?.();\n releaseSelection.current = holdSelection(event.currentTarget);\n\n const origin = { x: event.clientX, y: event.clientY };\n touchOrigin.current = origin;\n longPressTimer.current = setTimeout(() => {\n context.openAt(origin, \"touch\");\n longPressTimer.current = null;\n touchOrigin.current = null;\n }, LONG_PRESS_DELAY);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerMove?.(event);\n const origin = touchOrigin.current;\n if (\n origin &&\n Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > LONG_PRESS_TOLERANCE\n ) {\n cancelLongPress();\n }\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n childProps.onKeyDown?.(event);\n if (event.defaultPrevented || disabled) return;\n if (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\")) return;\n\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n context.openAt(\n { x: rect.left + Math.min(24, rect.width / 2), y: rect.top + rect.height / 2 },\n \"keyboard\",\n );\n };\n\n return cloneElement(children, {\n ref: (node: HTMLElement | null) => {\n context.triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-controls\": context.open ? context.menuId : undefined,\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": context.open,\n // The long press is ours: without this iOS runs its own on the same\n // gesture and drops the selection callout and its handles on top of the\n // menu we just opened. Only the press gesture is ours though — the child\n // is the consumer's content, so a mouse can still select the text in it\n // and right-click the selection. `touch-none` stays off too: the page\n // still has to scroll from the trigger.\n className: cn(TOUCH_GESTURE_CONTENT_CLASS, childProps.className, className),\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n childProps.onContextMenu?.(event);\n if (event.defaultPrevented || disabled) return;\n event.preventDefault();\n endPress();\n context.openAt({ x: event.clientX, y: event.clientY }, \"pointer\");\n },\n onKeyDown,\n onPointerDown,\n onPointerMove,\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerUp?.(event);\n endPress();\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerCancel?.(event);\n endPress();\n },\n });\n}\n\nexport interface ContextMenuContentProps {\n children: ReactNode;\n className?: string;\n ariaLabel?: string;\n}\n\nexport function ContextMenuContent({\n children,\n className,\n ariaLabel = \"Context menu\",\n}: ContextMenuContentProps) {\n const context = useContextMenuContext(\"ContextMenuContent\");\n const [mounted, setMounted] = useState(false);\n const [position, setPosition] = useState<MenuPoint>(context.point);\n const [origin, setOrigin] = useState<MenuPoint>({ x: 0, y: 0 });\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [morphReady, setMorphReady] = useState(false);\n const typeahead = useRef(\"\");\n const typeaheadTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => setMounted(true), []);\n\n useLayoutEffect(() => {\n if (!context.open) {\n setMorphReady(false);\n return;\n }\n const content = context.contentRef.current;\n if (!content) return;\n content.dataset.invocation = String(context.invocation);\n\n const rect = content.getBoundingClientRect();\n const left = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.x, VIEWPORT_PADDING),\n window.innerWidth - rect.width - VIEWPORT_PADDING,\n ),\n );\n const top = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.y, VIEWPORT_PADDING),\n window.innerHeight - rect.height - VIEWPORT_PADDING,\n ),\n );\n\n setPosition({ x: left, y: top });\n setSize({ width: rect.width, height: rect.height });\n setOrigin({\n x: clamp(context.point.x - left, 12, Math.max(12, rect.width - 12)),\n y: clamp(context.point.y - top, 12, Math.max(12, rect.height - 12)),\n });\n setMorphReady(false);\n\n if (context.reduce || context.modality === \"keyboard\") {\n setMorphReady(true);\n return;\n }\n\n // Let the measured collapsed clip paint once before expanding it. Without\n // this preparation frame, the first invocation can batch both states and\n // appear at full size without the morph.\n let openFrame = 0;\n const prepareFrame = requestAnimationFrame(() => {\n openFrame = requestAnimationFrame(() => setMorphReady(true));\n });\n return () => {\n cancelAnimationFrame(prepareFrame);\n cancelAnimationFrame(openFrame);\n };\n }, [\n context.open,\n context.point,\n context.contentRef,\n context.invocation,\n context.modality,\n context.reduce,\n ]);\n\n useEffect(() => {\n if (!context.open) return;\n const frame = requestAnimationFrame(() => {\n const first = getEnabledItems(context.contentRef.current)[0];\n first?.focus({ preventScroll: true });\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, context.contentRef]);\n\n useEffect(\n () => () => {\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n },\n [],\n );\n\n const moveFocus = (direction: 1 | -1) => {\n const items = getEnabledItems(context.contentRef.current);\n if (items.length === 0) return;\n const current = items.indexOf(document.activeElement as HTMLElement);\n const next = current < 0 ? 0 : (current + direction + items.length) % items.length;\n items[next]?.focus();\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n context.setOpen(false);\n context.triggerRef.current?.focus();\n return;\n }\n if (event.key === \"Tab\") {\n context.setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n moveFocus(event.key === \"ArrowDown\" ? 1 : -1);\n return;\n }\n if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n const items = getEnabledItems(context.contentRef.current);\n items[event.key === \"Home\" ? 0 : items.length - 1]?.focus();\n return;\n }\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n typeahead.current += event.key.toLocaleLowerCase();\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n typeaheadTimer.current = setTimeout(() => {\n typeahead.current = \"\";\n }, 500);\n const match = getEnabledItems(context.contentRef.current).find((item) =>\n (item.dataset.label ?? item.textContent ?? \"\")\n .trim()\n .toLocaleLowerCase()\n .startsWith(typeahead.current),\n );\n match?.focus();\n }\n };\n\n if (!mounted) return null;\n\n const visualOpen = context.open && morphReady;\n const clipHidden = collapsedClip(origin, size);\n const clipShown = \"inset(0px 0px 0px 0px round 12px)\";\n\n return createPortal(\n <div\n data-context-menu-portal=\"\"\n aria-hidden={!context.open}\n inert={!context.open}\n style={{ left: position.x, top: position.y }}\n className={cn(\n \"filter-[drop-shadow(0_18px_28px_rgba(0,0,0,0.2))] fixed z-100\",\n context.open ? \"pointer-events-auto\" : \"pointer-events-none\",\n )}\n >\n <motion.div\n ref={context.contentRef}\n id={context.menuId}\n role=\"menu\"\n aria-label={ariaLabel}\n data-morph-ready={morphReady ? \"true\" : \"false\"}\n tabIndex={-1}\n initial={false}\n animate={{\n opacity: visualOpen ? 1 : 0,\n clipPath:\n context.reduce || context.modality === \"keyboard\" || visualOpen\n ? clipShown\n : clipHidden,\n }}\n transition={\n context.modality === \"keyboard\"\n ? { duration: 0 }\n : context.reduce\n ? { duration: 0.1, ease: EASE_OUT }\n : {\n clipPath: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n opacity: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n }\n }\n onKeyDown={onKeyDown}\n onContextMenu={(event) => event.preventDefault()}\n className={cn(\n \"min-w-56 overflow-hidden rounded-xl border border-border bg-card p-1.5 text-foreground outline-none\",\n className,\n )}\n >\n {children}\n </motion.div>\n </div>,\n document.body,\n );\n}\n\ntype ContextMenuItemTone = \"default\" | \"destructive\";\n\nexport interface ContextMenuItemProps {\n children: ReactNode;\n onSelect?: () => void;\n disabled?: boolean;\n closeOnSelect?: boolean;\n tone?: ContextMenuItemTone;\n inset?: boolean;\n className?: string;\n textValue?: string;\n}\n\nfunction ContextMenuItemBase({\n children,\n onSelect,\n disabled = false,\n closeOnSelect = true,\n tone = \"default\",\n inset = false,\n className,\n textValue,\n role = \"menuitem\",\n ariaChecked,\n}: ContextMenuItemProps & {\n role?: \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\";\n ariaChecked?: boolean;\n}) {\n const context = useContextMenuContext(\"ContextMenuItem\");\n const id = useId();\n const active = context.activeId === id;\n const checkedProps = role === \"menuitem\" ? {} : { \"aria-checked\": ariaChecked };\n\n return (\n <button\n type=\"button\"\n id={id}\n role={role}\n {...checkedProps}\n disabled={disabled}\n data-context-menu-item=\"true\"\n data-disabled={disabled ? \"true\" : undefined}\n data-label={textValue}\n tabIndex={-1}\n onFocus={() => context.setActiveId(id)}\n onPointerMove={(event) => {\n if (!disabled && event.pointerType !== \"touch\") event.currentTarget.focus();\n }}\n onClick={() => {\n if (disabled) return;\n onSelect?.();\n if (closeOnSelect) context.setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full select-none items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/15\",\n \"disabled:pointer-events-none disabled:opacity-40\",\n inset && \"pl-8\",\n tone === \"destructive\" ? \"text-destructive\" : \"text-foreground\",\n className,\n )}\n >\n {active ? (\n <motion.span\n layoutId={`${context.menuId}-active`}\n className={cn(\n \"absolute inset-0 -z-10 rounded-lg\",\n tone === \"destructive\" ? \"bg-destructive/10\" : \"bg-foreground/6.5\",\n )}\n transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n {children}\n </button>\n );\n}\n\nexport function ContextMenuItem(props: ContextMenuItemProps) {\n return <ContextMenuItemBase {...props} />;\n}\n\nexport interface ContextMenuCheckboxItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function ContextMenuCheckboxItem({\n checked,\n onCheckedChange,\n children,\n ...props\n}: ContextMenuCheckboxItemProps) {\n const context = useContextMenuContext(\"ContextMenuCheckboxItem\");\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemcheckbox\"\n ariaChecked={checked}\n onSelect={() => onCheckedChange?.(!checked)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <AnimatePresence initial={false}>\n {checked ? (\n <motion.span\n key=\"check\"\n initial={context.reduce ? false : { opacity: 0, scale: 0.75 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: context.reduce ? 1 : 0.75 }}\n transition={context.reduce ? { duration: 0.08 } : SPRING_PANEL}\n >\n <Check aria-hidden=\"true\" className=\"h-3.5 w-3.5\" strokeWidth={2.4} />\n </motion.span>\n ) : null}\n </AnimatePresence>\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\ninterface ContextMenuRadioGroupContextValue {\n value: string;\n onValueChange?: (value: string) => void;\n}\n\nconst ContextMenuRadioGroupContext = createContext<ContextMenuRadioGroupContextValue | null>(null);\n\nexport interface ContextMenuRadioGroupProps {\n value: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuRadioGroup({\n value,\n onValueChange,\n children,\n className,\n}: ContextMenuRadioGroupProps) {\n const context = useMemo(() => ({ value, onValueChange }), [value, onValueChange]);\n return (\n <ContextMenuRadioGroupContext.Provider value={context}>\n <div className={className}>{children}</div>\n </ContextMenuRadioGroupContext.Provider>\n );\n}\n\nexport interface ContextMenuRadioItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n value: string;\n}\n\nexport function ContextMenuRadioItem({ value, children, ...props }: ContextMenuRadioItemProps) {\n const group = useContext(ContextMenuRadioGroupContext);\n if (!group) {\n throw new Error(\"ContextMenuRadioItem must be used within <ContextMenuRadioGroup>\");\n }\n const checked = group.value === value;\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemradio\"\n ariaChecked={checked}\n onSelect={() => group.onValueChange?.(value)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <span\n className={cn(\n \"h-1.5 w-1.5 rounded-full bg-current transition-opacity\",\n checked ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\nexport interface ContextMenuLabelProps {\n children: ReactNode;\n inset?: boolean;\n className?: string;\n}\n\nexport function ContextMenuLabel({ children, inset = false, className }: ContextMenuLabelProps) {\n return (\n <div\n className={cn(\n \"px-2.5 pt-1.5 pb-1 font-semibold text-[10px] text-muted-foreground uppercase tracking-[0.12em]\",\n inset && \"pl-8\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ContextMenuSeparatorProps {\n className?: string;\n}\n\nexport function ContextMenuSeparator({ className }: ContextMenuSeparatorProps) {\n return <hr className={cn(\"-mx-1 my-1 h-px border-0 bg-border\", className)} />;\n}\n\nexport interface ContextMenuShortcutProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuShortcut({ children, className }: ContextMenuShortcutProps) {\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"ml-auto pl-4 font-medium text-[10px] text-muted-foreground tracking-wide\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AAqBvB,MAAM,qBAAqB,cAA8C,IAAI;AAE7E,SAAS,sBAAsB,WAAmB;CAChD,MAAM,UAAU,WAAW,kBAAkB;CAC7C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,UAAU,mCAAmC;CAElE,OAAO;AACT;AAEA,SAAS,UAAa,KAAyB,OAAiB;CAC9D,IAAI,OAAO,QAAQ,YACjB,IAAI,KAAK;MACJ,IAAI,KACT,IAAI,UAAU;AAElB;AAEA,SAAS,gBAAgB,WAA+B;CACtD,IAAI,CAAC,WAAW,OAAO,CAAC;CACxB,OAAO,MAAM,KAC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C,OAAO,aAAa,CAAC;CAChF,OACE,oBAAC,6BAA6B,UAA9B;EAAuC,OAAO;EAC5C,UAAA,oBAAC,OAAD;GAAgB;GAAY;EAAc,CAAA;CACL,CAAA;AAE3C;AAMA,SAAgB,qBAAqB,EAAE,OAAO,UAAU,GAAG,SAAoC;CAC7F,MAAM,QAAQ,WAAW,4BAA4B;CACrD,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,kEAAkE;CAEpF,MAAM,UAAU,MAAM,UAAU;CAChC,OACE,qBAAC,qBAAD;EACE,GAAI;EACJ,MAAK;EACL,aAAa;EACb,gBAAgB,MAAM,gBAAgB,KAAK;EAJ7C,UAAA,CAME,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,QAAD,EACE,WAAW,GACT,0DACA,UAAU,gBAAgB,WAC5B,EACD,CAAA;EACG,CAAA,GACL,QACkB;;AAEzB;AAQA,SAAgB,iBAAiB,EAAE,UAAU,QAAQ,OAAO,aAAoC;CAC9F,OACE,oBAAC,OAAD;EACE,WAAW,GACT,kGACA,SAAS,QACT,SACF;EAEC;CACE,CAAA;AAET;AAMA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,OAAO,oBAAC,MAAD,EAAI,WAAW,GAAG,sCAAsC,SAAS,EAAI,CAAA;AAC9E;AAOA,SAAgB,oBAAoB,EAAE,UAAU,aAAuC;CACrF,OACE,oBAAC,QAAD;EACE,eAAY;EACZ,WAAW,GACT,4EACA,SACF;EAEC;CACG,CAAA;AAEV"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { TOUCH_GESTURE_CLASS, capturePointer, releasePointer } from "../../lib/touch.js";
3
3
  import { Children, useCallback, useEffect, useRef, useState } from "react";
4
- import { cn } from "cn";
4
+ import { cn } from "@kumix/utils";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
7
7
  //#region src/components/motion/cylinder-carousel.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"cylinder-carousel.js","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type WheelEvent as ReactWheelEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport {\n type AnimationPlaybackControls,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { capturePointer, releasePointer, TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\n\n// Carousel-specific: a soft spring that receives the release velocity, so a\n// flick keeps rolling freely, drifts past the snap point and eases back.\nconst GLIDE_SPRING = { stiffness: 40, damping: 20, mass: 3 };\n\n// How far a flick keeps rolling: projected items = release velocity * momentum.\nconst FLICK_MOMENTUM = 0.45;\nconst MAX_FLICK_ITEMS = 6;\n\nexport interface CylinderCarouselProps {\n children: ReactNode;\n /** Max item box size in px (square) at full size, i.e. at the container\n * edge. Balls shrink below this automatically so the row keeps breathing\n * room in narrow containers. */\n itemSize?: number;\n /** How many item slots span the container width. */\n visibleItems?: number;\n /** \"concave\" (default): inside of the cylinder — center ball smallest and\n * dipped, growing toward the edges. \"convex\": outside of the cylinder —\n * center ball biggest and raised, shrinking toward the edges. */\n variant?: \"concave\" | \"convex\";\n /** Scale of the smallest ball (center for concave, edges for convex);\n * the biggest reaches 1. */\n minScale?: number;\n /** Items rolled per item-width dragged — above 1 the wall outruns the\n * pointer, which reads as a lighter, freer roll. */\n dragSpeed?: number;\n /** Curve depth in px: for concave, how far the edge balls ride above the\n * center one (valley); for convex, how far below (arch). 0 = flat line.\n * Defaults to 35% of the item size. */\n arc?: number;\n /** Snap to the nearest item when the roll settles. */\n snap?: boolean;\n /** Roll on its own until interacted with. */\n autoRotate?: boolean;\n /** Auto-roll speed in items per second. */\n autoRotateSpeed?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n /** Stage height in px. Defaults to `itemSize`. */\n height?: number;\n className?: string;\n}\n\n// The frame edge sits at this wall angle; how far the wall curves in frame.\nconst THETA_EDGE = (72 * Math.PI) / 180;\n// Wall angle past which a ball is parked far off-stage (always hidden there).\nconst THETA_CLAMP = (95 * Math.PI) / 180;\n\n/**\n * One ball on the inside wall of the cylinder, rendered through a single\n * perspective projection: the ball sits at wall angle θ, the camera slightly\n * above the ball line, so horizontal position, size and height all share one\n * 1/(cosθ + k) depth term. Center = far wall: smallest, highest, moving\n * slowest; edges = nearest: full size, level, moving fastest, sliding off to\n * be clipped. Nothing overlaps, fades or reorders — the edge is the exit.\n */\nfunction CarouselBall({\n scroll,\n index,\n count,\n alpha,\n k,\n projection,\n gap,\n edgeOffset,\n minScale,\n convex,\n arc,\n halfWidth,\n itemSize,\n children,\n}: {\n scroll: MotionValue<number>;\n index: number;\n count: number;\n /** Wall angle per item step, in radians. */\n alpha: number;\n /** Camera distance term for the horizontal projection. */\n k: number;\n /** Projection strength: maps sinθ/(cosθ+k) to px so θE lands on the edge. */\n projection: number;\n /** Uniform slot width in px — convex spacing. */\n gap: number;\n /** Offset at which a ball's center sits on the container edge. */\n edgeOffset: number;\n minScale: number;\n convex: boolean;\n /** Curve depth in px between the center ball and the edge balls. */\n arc: number;\n halfWidth: number;\n itemSize: number;\n children: ReactNode;\n}) {\n // Nearest wrapped offset so items loop around continuously.\n const offset = useTransform(scroll, (s) => {\n let o = index - s;\n o -= Math.round(o / count) * count;\n return o;\n });\n // Concave spacing follows the interior perspective (slow, tight center);\n // convex pairs its big center balls with uniform spacing — the interior\n // projection would collapse them into each other.\n const x = useTransform(offset, (o) => {\n if (convex) return o * gap;\n const th = Math.max(-THETA_CLAMP, Math.min(THETA_CLAMP, o * alpha));\n return (projection * Math.sin(th)) / (Math.cos(th) + k);\n });\n // Linear in wall angle, not in depth (the depth curve is near-flat around\n // the center, which made the middle three read as equal): every step is\n // visibly bigger than the last — growing outward (concave) or inward\n // (convex).\n const scale = useTransform(offset, (o) => {\n const t = Math.min(Math.abs(o) / edgeOffset, THETA_CLAMP / THETA_EDGE);\n return convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n });\n // Parabola centered on the stage — valley for concave (center ball dips\n // arc/2 below the midline, edges rise arc/2 above), arch for convex — and\n // deliberately unclamped: a ball keeps following the same curve as it\n // crosses the edge, so entries never pop.\n const y = useTransform(x, (px) => {\n const t = px / halfWidth;\n const valley = arc * (0.5 - t * t);\n return convex ? -valley : valley;\n });\n // Fully off-stage balls stop painting (matters for canvas/shader children).\n const visibility = useTransform(x, (px) =>\n Math.abs(px) > halfWidth + itemSize ? \"hidden\" : \"visible\",\n );\n\n return (\n <motion.div\n className=\"absolute top-1/2 left-1/2\"\n style={{\n x,\n y,\n scale,\n visibility,\n width: itemSize,\n height: itemSize,\n marginLeft: -itemSize / 2,\n marginTop: -itemSize / 2,\n }}\n >\n {children}\n </motion.div>\n );\n}\n\nexport function CylinderCarousel({\n children,\n itemSize = 200,\n visibleItems = 5,\n variant = \"concave\",\n minScale = 0.55,\n dragSpeed = 1.5,\n arc: arcProp,\n snap = true,\n autoRotate = false,\n autoRotateSpeed = 0.4,\n defaultIndex = 0,\n onIndexChange,\n height,\n className,\n}: CylinderCarouselProps) {\n const reduce = useReducedMotion() ?? false;\n const items = Children.toArray(children);\n const count = items.length;\n\n const stageRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n useEffect(() => {\n const el = stageRef.current;\n if (!el) return;\n const ro = new ResizeObserver(([entry]) => {\n setWidth(entry.contentRect.width);\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n // Sized so `visibleItems` balls sit fully in frame and the next one out on\n // each side straddles the container edge, half visible.\n const stageWidth = width || 800;\n const halfWidth = stageWidth / 2;\n const edgeOffset = (visibleItems + 1) / 2;\n\n // Fit: the resting row's diameters may take at most ~66% of the stage — the\n // rest is air between balls plus the half-visible ball on each edge.\n // `itemSize` only caps the result.\n const convex = variant === \"convex\";\n let scaleSum = 0;\n for (let i = 0; i < visibleItems; i++) {\n const t = Math.abs(i - (visibleItems - 1) / 2) / edgeOffset;\n scaleSum += convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n }\n const size = Math.min(itemSize, (stageWidth * 0.65) / scaleSum);\n\n const gap = stageWidth / (visibleItems + 1);\n const arc = arcProp ?? size * 0.35;\n\n // Perspective constants. The ball one slot past the frame edge sits at wall\n // angle THETA_EDGE with its center right on the container edge — scale 1,\n // half of it in view; k falls out of the requested minScale (clamped so the\n // projection stays monotonic up to THETA_CLAMP).\n const alpha = THETA_EDGE / edgeOffset;\n const k = Math.max(0.2, (minScale - Math.cos(THETA_EDGE)) / (1 - minScale));\n const projection = (halfWidth * (Math.cos(THETA_EDGE) + k)) / Math.sin(THETA_EDGE);\n\n // scroll is in item units (continuous); item i sits at x = (i - scroll) * gap.\n // Drags write it 1:1 so the wall sticks to the pointer; releases hand the\n // pointer velocity to a soft spring so the roll glides on and settles free.\n const scroll = useMotionValue(defaultIndex);\n const indexRef = useRef(defaultIndex);\n const [, setActiveIndex] = useState(defaultIndex);\n const glideRef = useRef<AnimationPlaybackControls | null>(null);\n const draggingRef = useRef(false);\n const hoverRef = useRef(false);\n\n useEffect(() => {\n if (count === 0) return;\n const unsub = scroll.on(\"change\", (v) => {\n const idx = ((Math.round(v) % count) + count) % count;\n if (idx !== indexRef.current) {\n indexRef.current = idx;\n setActiveIndex(idx);\n onIndexChange?.(idx);\n }\n });\n return unsub;\n }, [scroll, count, onIndexChange]);\n\n const stopGlide = useCallback(() => {\n glideRef.current?.stop();\n glideRef.current = null;\n }, []);\n\n // Spring toward `to`, carrying `velocity` (items/s) through so motion never\n // steps — the roll leaves the finger at finger speed.\n const glideTo = useCallback(\n (to: number, velocity: number) => {\n stopGlide();\n if (reduce) {\n scroll.set(to);\n return;\n }\n glideRef.current = animate(scroll, to, {\n type: \"spring\",\n ...GLIDE_SPRING,\n velocity,\n restDelta: 0.001,\n restSpeed: 0.005,\n });\n },\n [scroll, stopGlide, reduce],\n );\n\n const settle = useCallback(\n (velocity: number) => {\n const projected =\n scroll.get() +\n Math.max(-MAX_FLICK_ITEMS, Math.min(MAX_FLICK_ITEMS, velocity * FLICK_MOMENTUM));\n glideTo(snap ? Math.round(projected) : projected, velocity);\n },\n [scroll, snap, glideTo],\n );\n\n const drag = useRef({\n startX: 0,\n startScroll: 0,\n lastX: 0,\n lastT: 0,\n prevX: 0,\n prevT: 0,\n });\n\n const onPointerDown = useCallback(\n (e: ReactPointerEvent) => {\n e.preventDefault();\n stopGlide();\n draggingRef.current = true;\n capturePointer(e.currentTarget, e.pointerId);\n const now = performance.now();\n drag.current = {\n startX: e.clientX,\n startScroll: scroll.get(),\n lastX: e.clientX,\n lastT: now,\n prevX: e.clientX,\n prevT: now,\n };\n },\n [scroll, stopGlide],\n );\n\n const onPointerMove = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n const d = drag.current;\n scroll.set(d.startScroll - ((e.clientX - d.startX) * dragSpeed) / gap);\n d.prevX = d.lastX;\n d.prevT = d.lastT;\n d.lastX = e.clientX;\n d.lastT = performance.now();\n },\n [scroll, gap, dragSpeed],\n );\n\n const onPointerUp = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n draggingRef.current = false;\n releasePointer(e.currentTarget, e.pointerId);\n const d = drag.current;\n const dt = d.lastT - d.prevT;\n const vpx = dt > 0 ? (d.lastX - d.prevX) / dt : 0; // px per ms\n settle((-vpx * dragSpeed * 1000) / gap); // items per second\n },\n [settle, gap, dragSpeed],\n );\n\n const rollBy = useCallback(\n (dir: number) => {\n glideTo(Math.round(scroll.get()) + dir, scroll.getVelocity());\n },\n [scroll, glideTo],\n );\n\n const wheelSettleRef = useRef<number | undefined>(undefined);\n const onWheel = useCallback(\n (e: ReactWheelEvent) => {\n stopGlide();\n const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;\n scroll.set(scroll.get() + delta / gap);\n if (wheelSettleRef.current) window.clearTimeout(wheelSettleRef.current);\n wheelSettleRef.current = window.setTimeout(() => settle(scroll.getVelocity()), 140);\n },\n [scroll, gap, settle, stopGlide],\n );\n\n useEffect(() => {\n if (!autoRotate || reduce || count === 0) return;\n let raf = 0;\n let last = performance.now();\n const tick = (now: number) => {\n const dt = (now - last) / 1000;\n last = now;\n if (!draggingRef.current && !hoverRef.current && !glideRef.current) {\n scroll.set(scroll.get() + autoRotateSpeed * dt);\n }\n raf = requestAnimationFrame(tick);\n };\n raf = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(raf);\n }, [autoRotate, autoRotateSpeed, reduce, count, scroll]);\n\n const stageHeight = height ?? size;\n\n return (\n <div\n ref={stageRef}\n role=\"application\"\n aria-roledescription=\"carousel\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: focusable custom carousel widget\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n rollBy(1);\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n rollBy(-1);\n }\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n onPointerEnter={() => {\n hoverRef.current = true;\n }}\n onPointerLeave={() => {\n hoverRef.current = false;\n }}\n className={cn(\n // clip-path, not overflow: it also clips the GPU-composited balls\n \"relative w-full touch-none outline-none [clip-path:inset(0)]\",\n // The stage drives the roll from the press itself, so iOS must not\n // claim the same touch for its callout or a slide drag.\n TOUCH_GESTURE_CLASS,\n \"cursor-grab active:cursor-grabbing\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/20\",\n className,\n )}\n style={{ height: stageHeight }}\n >\n {items.map((item, i) => (\n <CarouselBall\n key={i}\n scroll={scroll}\n index={i}\n count={count}\n alpha={alpha}\n k={k}\n projection={projection}\n gap={gap}\n edgeOffset={edgeOffset}\n minScale={minScale}\n convex={convex}\n arc={arc}\n halfWidth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,UAAU,OAAO,iBAAiB,OAAO,OAAO,YAAY,CAAC,GAAG,GAAG;CACpF,GACA;EAAC;EAAQ;EAAK;EAAQ;CAAS,CACjC;CAEA,gBAAgB;EACd,IAAI,CAAC,cAAc,UAAU,UAAU,GAAG;EAC1C,IAAI,MAAM;EACV,IAAI,OAAO,YAAY,IAAI;EAC3B,MAAM,QAAQ,QAAgB;GAC5B,MAAM,MAAM,MAAM,QAAQ;GAC1B,OAAO;GACP,IAAI,CAAC,YAAY,WAAW,CAAC,SAAS,WAAW,CAAC,SAAS,SACzD,OAAO,IAAI,OAAO,IAAI,IAAI,kBAAkB,EAAE;GAEhD,MAAM,sBAAsB,IAAI;EAClC;EACA,MAAM,sBAAsB,IAAI;EAChC,aAAa,qBAAqB,GAAG;CACvC,GAAG;EAAC;EAAY;EAAiB;EAAQ;EAAO;CAAM,CAAC;CAEvD,MAAM,cAAc,UAAU;CAE9B,OACE,oBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,wBAAqB;EAErB,UAAU;EACV,YAAY,MAAM;GAChB,IAAI,EAAE,QAAQ,cAAc;IAC1B,EAAE,eAAe;IACjB,OAAO,CAAC;GACV,OAAO,IAAI,EAAE,QAAQ,aAAa;IAChC,EAAE,eAAe;IACjB,OAAO,EAAE;GACX;EACF;EACe;EACA;EACF;EACb,iBAAiB;EACR;EACT,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,WAAW,GAET,gEAGA,qBACA,sCACA,yDACA,SACF;EACA,OAAO,EAAE,QAAQ,YAAY;EAE5B,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,cAAD;GAEU;GACR,OAAO;GACA;GACA;GACJ;GACS;GACP;GACO;GACF;GACF;GACH;GACM;GACX,UAAU;GAET,UAAA;EACW,GAhBP,CAgBO,CACf;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"cylinder-carousel.js","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type WheelEvent as ReactWheelEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport {\n type AnimationPlaybackControls,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { capturePointer, releasePointer, TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\n\n// Carousel-specific: a soft spring that receives the release velocity, so a\n// flick keeps rolling freely, drifts past the snap point and eases back.\nconst GLIDE_SPRING = { stiffness: 40, damping: 20, mass: 3 };\n\n// How far a flick keeps rolling: projected items = release velocity * momentum.\nconst FLICK_MOMENTUM = 0.45;\nconst MAX_FLICK_ITEMS = 6;\n\nexport interface CylinderCarouselProps {\n children: ReactNode;\n /** Max item box size in px (square) at full size, i.e. at the container\n * edge. Balls shrink below this automatically so the row keeps breathing\n * room in narrow containers. */\n itemSize?: number;\n /** How many item slots span the container width. */\n visibleItems?: number;\n /** \"concave\" (default): inside of the cylinder — center ball smallest and\n * dipped, growing toward the edges. \"convex\": outside of the cylinder —\n * center ball biggest and raised, shrinking toward the edges. */\n variant?: \"concave\" | \"convex\";\n /** Scale of the smallest ball (center for concave, edges for convex);\n * the biggest reaches 1. */\n minScale?: number;\n /** Items rolled per item-width dragged — above 1 the wall outruns the\n * pointer, which reads as a lighter, freer roll. */\n dragSpeed?: number;\n /** Curve depth in px: for concave, how far the edge balls ride above the\n * center one (valley); for convex, how far below (arch). 0 = flat line.\n * Defaults to 35% of the item size. */\n arc?: number;\n /** Snap to the nearest item when the roll settles. */\n snap?: boolean;\n /** Roll on its own until interacted with. */\n autoRotate?: boolean;\n /** Auto-roll speed in items per second. */\n autoRotateSpeed?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n /** Stage height in px. Defaults to `itemSize`. */\n height?: number;\n className?: string;\n}\n\n// The frame edge sits at this wall angle; how far the wall curves in frame.\nconst THETA_EDGE = (72 * Math.PI) / 180;\n// Wall angle past which a ball is parked far off-stage (always hidden there).\nconst THETA_CLAMP = (95 * Math.PI) / 180;\n\n/**\n * One ball on the inside wall of the cylinder, rendered through a single\n * perspective projection: the ball sits at wall angle θ, the camera slightly\n * above the ball line, so horizontal position, size and height all share one\n * 1/(cosθ + k) depth term. Center = far wall: smallest, highest, moving\n * slowest; edges = nearest: full size, level, moving fastest, sliding off to\n * be clipped. Nothing overlaps, fades or reorders — the edge is the exit.\n */\nfunction CarouselBall({\n scroll,\n index,\n count,\n alpha,\n k,\n projection,\n gap,\n edgeOffset,\n minScale,\n convex,\n arc,\n halfWidth,\n itemSize,\n children,\n}: {\n scroll: MotionValue<number>;\n index: number;\n count: number;\n /** Wall angle per item step, in radians. */\n alpha: number;\n /** Camera distance term for the horizontal projection. */\n k: number;\n /** Projection strength: maps sinθ/(cosθ+k) to px so θE lands on the edge. */\n projection: number;\n /** Uniform slot width in px — convex spacing. */\n gap: number;\n /** Offset at which a ball's center sits on the container edge. */\n edgeOffset: number;\n minScale: number;\n convex: boolean;\n /** Curve depth in px between the center ball and the edge balls. */\n arc: number;\n halfWidth: number;\n itemSize: number;\n children: ReactNode;\n}) {\n // Nearest wrapped offset so items loop around continuously.\n const offset = useTransform(scroll, (s) => {\n let o = index - s;\n o -= Math.round(o / count) * count;\n return o;\n });\n // Concave spacing follows the interior perspective (slow, tight center);\n // convex pairs its big center balls with uniform spacing — the interior\n // projection would collapse them into each other.\n const x = useTransform(offset, (o) => {\n if (convex) return o * gap;\n const th = Math.max(-THETA_CLAMP, Math.min(THETA_CLAMP, o * alpha));\n return (projection * Math.sin(th)) / (Math.cos(th) + k);\n });\n // Linear in wall angle, not in depth (the depth curve is near-flat around\n // the center, which made the middle three read as equal): every step is\n // visibly bigger than the last — growing outward (concave) or inward\n // (convex).\n const scale = useTransform(offset, (o) => {\n const t = Math.min(Math.abs(o) / edgeOffset, THETA_CLAMP / THETA_EDGE);\n return convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n });\n // Parabola centered on the stage — valley for concave (center ball dips\n // arc/2 below the midline, edges rise arc/2 above), arch for convex — and\n // deliberately unclamped: a ball keeps following the same curve as it\n // crosses the edge, so entries never pop.\n const y = useTransform(x, (px) => {\n const t = px / halfWidth;\n const valley = arc * (0.5 - t * t);\n return convex ? -valley : valley;\n });\n // Fully off-stage balls stop painting (matters for canvas/shader children).\n const visibility = useTransform(x, (px) =>\n Math.abs(px) > halfWidth + itemSize ? \"hidden\" : \"visible\",\n );\n\n return (\n <motion.div\n className=\"absolute top-1/2 left-1/2\"\n style={{\n x,\n y,\n scale,\n visibility,\n width: itemSize,\n height: itemSize,\n marginLeft: -itemSize / 2,\n marginTop: -itemSize / 2,\n }}\n >\n {children}\n </motion.div>\n );\n}\n\nexport function CylinderCarousel({\n children,\n itemSize = 200,\n visibleItems = 5,\n variant = \"concave\",\n minScale = 0.55,\n dragSpeed = 1.5,\n arc: arcProp,\n snap = true,\n autoRotate = false,\n autoRotateSpeed = 0.4,\n defaultIndex = 0,\n onIndexChange,\n height,\n className,\n}: CylinderCarouselProps) {\n const reduce = useReducedMotion() ?? false;\n const items = Children.toArray(children);\n const count = items.length;\n\n const stageRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n useEffect(() => {\n const el = stageRef.current;\n if (!el) return;\n const ro = new ResizeObserver(([entry]) => {\n setWidth(entry.contentRect.width);\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n // Sized so `visibleItems` balls sit fully in frame and the next one out on\n // each side straddles the container edge, half visible.\n const stageWidth = width || 800;\n const halfWidth = stageWidth / 2;\n const edgeOffset = (visibleItems + 1) / 2;\n\n // Fit: the resting row's diameters may take at most ~66% of the stage — the\n // rest is air between balls plus the half-visible ball on each edge.\n // `itemSize` only caps the result.\n const convex = variant === \"convex\";\n let scaleSum = 0;\n for (let i = 0; i < visibleItems; i++) {\n const t = Math.abs(i - (visibleItems - 1) / 2) / edgeOffset;\n scaleSum += convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n }\n const size = Math.min(itemSize, (stageWidth * 0.65) / scaleSum);\n\n const gap = stageWidth / (visibleItems + 1);\n const arc = arcProp ?? size * 0.35;\n\n // Perspective constants. The ball one slot past the frame edge sits at wall\n // angle THETA_EDGE with its center right on the container edge — scale 1,\n // half of it in view; k falls out of the requested minScale (clamped so the\n // projection stays monotonic up to THETA_CLAMP).\n const alpha = THETA_EDGE / edgeOffset;\n const k = Math.max(0.2, (minScale - Math.cos(THETA_EDGE)) / (1 - minScale));\n const projection = (halfWidth * (Math.cos(THETA_EDGE) + k)) / Math.sin(THETA_EDGE);\n\n // scroll is in item units (continuous); item i sits at x = (i - scroll) * gap.\n // Drags write it 1:1 so the wall sticks to the pointer; releases hand the\n // pointer velocity to a soft spring so the roll glides on and settles free.\n const scroll = useMotionValue(defaultIndex);\n const indexRef = useRef(defaultIndex);\n const [, setActiveIndex] = useState(defaultIndex);\n const glideRef = useRef<AnimationPlaybackControls | null>(null);\n const draggingRef = useRef(false);\n const hoverRef = useRef(false);\n\n useEffect(() => {\n if (count === 0) return;\n const unsub = scroll.on(\"change\", (v) => {\n const idx = ((Math.round(v) % count) + count) % count;\n if (idx !== indexRef.current) {\n indexRef.current = idx;\n setActiveIndex(idx);\n onIndexChange?.(idx);\n }\n });\n return unsub;\n }, [scroll, count, onIndexChange]);\n\n const stopGlide = useCallback(() => {\n glideRef.current?.stop();\n glideRef.current = null;\n }, []);\n\n // Spring toward `to`, carrying `velocity` (items/s) through so motion never\n // steps — the roll leaves the finger at finger speed.\n const glideTo = useCallback(\n (to: number, velocity: number) => {\n stopGlide();\n if (reduce) {\n scroll.set(to);\n return;\n }\n glideRef.current = animate(scroll, to, {\n type: \"spring\",\n ...GLIDE_SPRING,\n velocity,\n restDelta: 0.001,\n restSpeed: 0.005,\n });\n },\n [scroll, stopGlide, reduce],\n );\n\n const settle = useCallback(\n (velocity: number) => {\n const projected =\n scroll.get() +\n Math.max(-MAX_FLICK_ITEMS, Math.min(MAX_FLICK_ITEMS, velocity * FLICK_MOMENTUM));\n glideTo(snap ? Math.round(projected) : projected, velocity);\n },\n [scroll, snap, glideTo],\n );\n\n const drag = useRef({\n startX: 0,\n startScroll: 0,\n lastX: 0,\n lastT: 0,\n prevX: 0,\n prevT: 0,\n });\n\n const onPointerDown = useCallback(\n (e: ReactPointerEvent) => {\n e.preventDefault();\n stopGlide();\n draggingRef.current = true;\n capturePointer(e.currentTarget, e.pointerId);\n const now = performance.now();\n drag.current = {\n startX: e.clientX,\n startScroll: scroll.get(),\n lastX: e.clientX,\n lastT: now,\n prevX: e.clientX,\n prevT: now,\n };\n },\n [scroll, stopGlide],\n );\n\n const onPointerMove = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n const d = drag.current;\n scroll.set(d.startScroll - ((e.clientX - d.startX) * dragSpeed) / gap);\n d.prevX = d.lastX;\n d.prevT = d.lastT;\n d.lastX = e.clientX;\n d.lastT = performance.now();\n },\n [scroll, gap, dragSpeed],\n );\n\n const onPointerUp = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n draggingRef.current = false;\n releasePointer(e.currentTarget, e.pointerId);\n const d = drag.current;\n const dt = d.lastT - d.prevT;\n const vpx = dt > 0 ? (d.lastX - d.prevX) / dt : 0; // px per ms\n settle((-vpx * dragSpeed * 1000) / gap); // items per second\n },\n [settle, gap, dragSpeed],\n );\n\n const rollBy = useCallback(\n (dir: number) => {\n glideTo(Math.round(scroll.get()) + dir, scroll.getVelocity());\n },\n [scroll, glideTo],\n );\n\n const wheelSettleRef = useRef<number | undefined>(undefined);\n const onWheel = useCallback(\n (e: ReactWheelEvent) => {\n stopGlide();\n const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;\n scroll.set(scroll.get() + delta / gap);\n if (wheelSettleRef.current) window.clearTimeout(wheelSettleRef.current);\n wheelSettleRef.current = window.setTimeout(() => settle(scroll.getVelocity()), 140);\n },\n [scroll, gap, settle, stopGlide],\n );\n\n useEffect(() => {\n if (!autoRotate || reduce || count === 0) return;\n let raf = 0;\n let last = performance.now();\n const tick = (now: number) => {\n const dt = (now - last) / 1000;\n last = now;\n if (!draggingRef.current && !hoverRef.current && !glideRef.current) {\n scroll.set(scroll.get() + autoRotateSpeed * dt);\n }\n raf = requestAnimationFrame(tick);\n };\n raf = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(raf);\n }, [autoRotate, autoRotateSpeed, reduce, count, scroll]);\n\n const stageHeight = height ?? size;\n\n return (\n <div\n ref={stageRef}\n role=\"application\"\n aria-roledescription=\"carousel\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: focusable custom carousel widget\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n rollBy(1);\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n rollBy(-1);\n }\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n onPointerEnter={() => {\n hoverRef.current = true;\n }}\n onPointerLeave={() => {\n hoverRef.current = false;\n }}\n className={cn(\n // clip-path, not overflow: it also clips the GPU-composited balls\n \"relative w-full touch-none outline-none [clip-path:inset(0)]\",\n // The stage drives the roll from the press itself, so iOS must not\n // claim the same touch for its callout or a slide drag.\n TOUCH_GESTURE_CLASS,\n \"cursor-grab active:cursor-grabbing\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/20\",\n className,\n )}\n style={{ height: stageHeight }}\n >\n {items.map((item, i) => (\n <CarouselBall\n key={i}\n scroll={scroll}\n index={i}\n count={count}\n alpha={alpha}\n k={k}\n projection={projection}\n gap={gap}\n edgeOffset={edgeOffset}\n minScale={minScale}\n convex={convex}\n arc={arc}\n halfWidth={halfWidth}\n itemSize={size}\n >\n {item}\n </CarouselBall>\n ))}\n </div>\n );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;CACpF,GACA;EAAC;EAAQ;EAAK;EAAQ;CAAS,CACjC;CAEA,gBAAgB;EACd,IAAI,CAAC,cAAc,UAAU,UAAU,GAAG;EAC1C,IAAI,MAAM;EACV,IAAI,OAAO,YAAY,IAAI;EAC3B,MAAM,QAAQ,QAAgB;GAC5B,MAAM,MAAM,MAAM,QAAQ;GAC1B,OAAO;GACP,IAAI,CAAC,YAAY,WAAW,CAAC,SAAS,WAAW,CAAC,SAAS,SACzD,OAAO,IAAI,OAAO,IAAI,IAAI,kBAAkB,EAAE;GAEhD,MAAM,sBAAsB,IAAI;EAClC;EACA,MAAM,sBAAsB,IAAI;EAChC,aAAa,qBAAqB,GAAG;CACvC,GAAG;EAAC;EAAY;EAAiB;EAAQ;EAAO;CAAM,CAAC;CAEvD,MAAM,cAAc,UAAU;CAE9B,OACE,oBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,wBAAqB;EAErB,UAAU;EACV,YAAY,MAAM;GAChB,IAAI,EAAE,QAAQ,cAAc;IAC1B,EAAE,eAAe;IACjB,OAAO,CAAC;GACV,OAAO,IAAI,EAAE,QAAQ,aAAa;IAChC,EAAE,eAAe;IACjB,OAAO,EAAE;GACX;EACF;EACe;EACA;EACF;EACb,iBAAiB;EACR;EACT,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,WAAW,GAET,gEAGA,qBACA,sCACA,yDACA,SACF;EACA,OAAO,EAAE,QAAQ,YAAY;EAE5B,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,cAAD;GAEU;GACR,OAAO;GACA;GACA;GACJ;GACS;GACP;GACO;GACF;GACF;GACH;GACM;GACX,UAAU;GAET,UAAA;EACW,GAhBP,CAgBO,CACf;CACE,CAAA;AAET"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { EASE_OUT } from "../../lib/ease.js";
3
- import { cn } from "cn";
3
+ import { cn } from "@kumix/utils";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
6
6
  //#region src/components/motion/digit-swap.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"digit-swap.js","names":[],"sources":["../../../src/components/motion/digit-swap.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"cn\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type DigitSwapDirection = \"up\" | \"down\";\n\nexport interface DigitSwapProps {\n /** Numeric or masked value rendered in fixed character slots. */\n value: string | number;\n /** Replays every glyph when the value itself contains unchanged characters. */\n animationKey?: string | number;\n /** Direction the next glyph enters from. */\n direction?: DigitSwapDirection;\n /** Per-glyph transition duration in seconds. */\n duration?: number;\n /** Delay in seconds between neighboring glyphs. */\n stagger?: number;\n /** Number of final characters that receive `suffixClassName`. */\n suffixLength?: number;\n className?: string;\n glyphClassName?: string;\n suffixClassName?: string;\n}\n\ntype GlyphMotionContext = {\n direction: DigitSwapDirection;\n reduceMotion: boolean;\n};\n\nconst GLYPH_VARIANTS = {\n enter: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n opacity: 0,\n transform: reduceMotion ? \"none\" : `translateY(${direction === \"up\" ? \"45%\" : \"-45%\"})`,\n }),\n visible: {\n opacity: 1,\n transform: \"translateY(0%)\",\n },\n exit: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n opacity: 0,\n transform: reduceMotion ? \"none\" : `translateY(${direction === \"up\" ? \"-45%\" : \"45%\"})`,\n }),\n};\n\n/** Fixed-slot digits and mask glyphs that roll when their value changes. */\nexport function DigitSwap({\n value,\n animationKey,\n direction = \"up\",\n duration = 0.18,\n stagger = 0.006,\n suffixLength = 0,\n className,\n glyphClassName,\n suffixClassName,\n}: DigitSwapProps) {\n const reduceMotion = useReducedMotion() ?? false;\n const text = String(value);\n const suffixStart = Math.max(0, text.length - Math.max(0, suffixLength));\n const motionContext: GlyphMotionContext = { direction, reduceMotion };\n const glyphs = Array.from(text, (character, position) => ({\n character,\n id: `glyph-${position}`,\n position,\n }));\n\n return (\n <span\n data-slot=\"digit-swap\"\n data-direction={direction}\n className={cn(\"inline-flex items-center whitespace-nowrap\", className)}\n >\n <span className=\"sr-only\">{text}</span>\n <span aria-hidden=\"true\" className=\"inline-flex items-center\">\n {glyphs.map(({ character, id, position }) => {\n if (character === \" \") {\n return <span key={id} className=\"inline-block w-[0.7ch]\" />;\n }\n\n const glyphKey =\n animationKey === undefined\n ? `${id}-${character}`\n : `${id}-${character}-${animationKey}`;\n\n return (\n <span\n key={id}\n data-slot=\"digit-swap-glyph\"\n className=\"relative inline-block h-[1.1em] w-[1ch] shrink-0 overflow-hidden align-bottom\"\n >\n <AnimatePresence initial={false} custom={motionContext}>\n <motion.span\n key={glyphKey}\n custom={motionContext}\n variants={GLYPH_VARIANTS}\n initial=\"enter\"\n animate=\"visible\"\n exit=\"exit\"\n transition={{\n duration: reduceMotion ? Math.min(duration, 0.12) : duration,\n delay: reduceMotion ? 0 : position * stagger,\n ease: EASE_OUT,\n }}\n className={cn(\n \"absolute inset-0 flex items-center justify-center leading-none\",\n glyphClassName,\n position >= suffixStart ? suffixClassName : undefined,\n )}\n >\n {character}\n </motion.span>\n </AnimatePresence>\n </span>\n );\n })}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;AAgCA,MAAM,iBAAiB;CACrB,QAAQ,EAAE,WAAW,oBAAwC;EAC3D,SAAS;EACT,WAAW,eAAe,SAAS,cAAc,cAAc,OAAO,QAAQ,OAAO;CACvF;CACA,SAAS;EACP,SAAS;EACT,WAAW;CACb;CACA,OAAO,EAAE,WAAW,oBAAwC;EAC1D,SAAS;EACT,WAAW,eAAe,SAAS,cAAc,cAAc,OAAO,SAAS,MAAM;CACvF;AACF;;AAGA,SAAgB,UAAU,EACxB,OACA,cACA,YAAY,MACZ,WAAW,KACX,UAAU,MACV,eAAe,GACf,WACA,gBACA,mBACiB;CACjB,MAAM,eAAe,iBAAiB,KAAK;CAC3C,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,cAAc,KAAK,IAAI,GAAG,KAAK,SAAS,KAAK,IAAI,GAAG,YAAY,CAAC;CACvE,MAAM,gBAAoC;EAAE;EAAW;CAAa;CACpE,MAAM,SAAS,MAAM,KAAK,OAAO,WAAW,cAAc;EACxD;EACA,IAAI,SAAS;EACb;CACF,EAAE;CAEF,OACE,qBAAC,QAAD;EACE,aAAU;EACV,kBAAgB;EAChB,WAAW,GAAG,8CAA8C,SAAS;EAHvE,UAAA,CAKE,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAW,CAAA,GACtC,oBAAC,QAAD;GAAM,eAAY;GAAO,WAAU;GAChC,UAAA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe;IAC3C,IAAI,cAAc,KAChB,OAAO,oBAAC,QAAD,EAAe,WAAU,yBAA0B,GAAxC,EAAwC;IAG5D,MAAM,WACJ,iBAAiB,KAAA,IACb,GAAG,GAAG,GAAG,cACT,GAAG,GAAG,GAAG,UAAU,GAAG;IAE5B,OACE,oBAAC,QAAD;KAEE,aAAU;KACV,WAAU;KAEV,UAAA,oBAAC,iBAAD;MAAiB,SAAS;MAAO,QAAQ;MACvC,UAAA,oBAAC,OAAO,MAAR;OAEE,QAAQ;OACR,UAAU;OACV,SAAQ;OACR,SAAQ;OACR,MAAK;OACL,YAAY;QACV,UAAU,eAAe,KAAK,IAAI,UAAU,GAAI,IAAI;QACpD,OAAO,eAAe,IAAI,WAAW;QACrC,MAAM;OACR;OACA,WAAW,GACT,kEACA,gBACA,YAAY,cAAc,kBAAkB,KAAA,CAC9C;OAEC,UAAA;MACU,GAlBN,QAkBM;KACE,CAAA;IACb,GA1BC,EA0BD;GAEV,CAAC;EACG,CAAA,CACF;;AAEV"}
1
+ {"version":3,"file":"digit-swap.js","names":[],"sources":["../../../src/components/motion/digit-swap.tsx"],"sourcesContent":["\"use client\";\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type DigitSwapDirection = \"up\" | \"down\";\n\nexport interface DigitSwapProps {\n /** Numeric or masked value rendered in fixed character slots. */\n value: string | number;\n /** Replays every glyph when the value itself contains unchanged characters. */\n animationKey?: string | number;\n /** Direction the next glyph enters from. */\n direction?: DigitSwapDirection;\n /** Per-glyph transition duration in seconds. */\n duration?: number;\n /** Delay in seconds between neighboring glyphs. */\n stagger?: number;\n /** Number of final characters that receive `suffixClassName`. */\n suffixLength?: number;\n className?: string;\n glyphClassName?: string;\n suffixClassName?: string;\n}\n\ntype GlyphMotionContext = {\n direction: DigitSwapDirection;\n reduceMotion: boolean;\n};\n\nconst GLYPH_VARIANTS = {\n enter: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n opacity: 0,\n transform: reduceMotion ? \"none\" : `translateY(${direction === \"up\" ? \"45%\" : \"-45%\"})`,\n }),\n visible: {\n opacity: 1,\n transform: \"translateY(0%)\",\n },\n exit: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n opacity: 0,\n transform: reduceMotion ? \"none\" : `translateY(${direction === \"up\" ? \"-45%\" : \"45%\"})`,\n }),\n};\n\n/** Fixed-slot digits and mask glyphs that roll when their value changes. */\nexport function DigitSwap({\n value,\n animationKey,\n direction = \"up\",\n duration = 0.18,\n stagger = 0.006,\n suffixLength = 0,\n className,\n glyphClassName,\n suffixClassName,\n}: DigitSwapProps) {\n const reduceMotion = useReducedMotion() ?? false;\n const text = String(value);\n const suffixStart = Math.max(0, text.length - Math.max(0, suffixLength));\n const motionContext: GlyphMotionContext = { direction, reduceMotion };\n const glyphs = Array.from(text, (character, position) => ({\n character,\n id: `glyph-${position}`,\n position,\n }));\n\n return (\n <span\n data-slot=\"digit-swap\"\n data-direction={direction}\n className={cn(\"inline-flex items-center whitespace-nowrap\", className)}\n >\n <span className=\"sr-only\">{text}</span>\n <span aria-hidden=\"true\" className=\"inline-flex items-center\">\n {glyphs.map(({ character, id, position }) => {\n if (character === \" \") {\n return <span key={id} className=\"inline-block w-[0.7ch]\" />;\n }\n\n const glyphKey =\n animationKey === undefined\n ? `${id}-${character}`\n : `${id}-${character}-${animationKey}`;\n\n return (\n <span\n key={id}\n data-slot=\"digit-swap-glyph\"\n className=\"relative inline-block h-[1.1em] w-[1ch] shrink-0 overflow-hidden align-bottom\"\n >\n <AnimatePresence initial={false} custom={motionContext}>\n <motion.span\n key={glyphKey}\n custom={motionContext}\n variants={GLYPH_VARIANTS}\n initial=\"enter\"\n animate=\"visible\"\n exit=\"exit\"\n transition={{\n duration: reduceMotion ? Math.min(duration, 0.12) : duration,\n delay: reduceMotion ? 0 : position * stagger,\n ease: EASE_OUT,\n }}\n className={cn(\n \"absolute inset-0 flex items-center justify-center leading-none\",\n glyphClassName,\n position >= suffixStart ? suffixClassName : undefined,\n )}\n >\n {character}\n </motion.span>\n </AnimatePresence>\n </span>\n );\n })}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;AAgCA,MAAM,iBAAiB;CACrB,QAAQ,EAAE,WAAW,oBAAwC;EAC3D,SAAS;EACT,WAAW,eAAe,SAAS,cAAc,cAAc,OAAO,QAAQ,OAAO;CACvF;CACA,SAAS;EACP,SAAS;EACT,WAAW;CACb;CACA,OAAO,EAAE,WAAW,oBAAwC;EAC1D,SAAS;EACT,WAAW,eAAe,SAAS,cAAc,cAAc,OAAO,SAAS,MAAM;CACvF;AACF;;AAGA,SAAgB,UAAU,EACxB,OACA,cACA,YAAY,MACZ,WAAW,KACX,UAAU,MACV,eAAe,GACf,WACA,gBACA,mBACiB;CACjB,MAAM,eAAe,iBAAiB,KAAK;CAC3C,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,cAAc,KAAK,IAAI,GAAG,KAAK,SAAS,KAAK,IAAI,GAAG,YAAY,CAAC;CACvE,MAAM,gBAAoC;EAAE;EAAW;CAAa;CACpE,MAAM,SAAS,MAAM,KAAK,OAAO,WAAW,cAAc;EACxD;EACA,IAAI,SAAS;EACb;CACF,EAAE;CAEF,OACE,qBAAC,QAAD;EACE,aAAU;EACV,kBAAgB;EAChB,WAAW,GAAG,8CAA8C,SAAS;EAHvE,UAAA,CAKE,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAW,CAAA,GACtC,oBAAC,QAAD;GAAM,eAAY;GAAO,WAAU;GAChC,UAAA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe;IAC3C,IAAI,cAAc,KAChB,OAAO,oBAAC,QAAD,EAAe,WAAU,yBAA0B,GAAxC,EAAwC;IAG5D,MAAM,WACJ,iBAAiB,KAAA,IACb,GAAG,GAAG,GAAG,cACT,GAAG,GAAG,GAAG,UAAU,GAAG;IAE5B,OACE,oBAAC,QAAD;KAEE,aAAU;KACV,WAAU;KAEV,UAAA,oBAAC,iBAAD;MAAiB,SAAS;MAAO,QAAQ;MACvC,UAAA,oBAAC,OAAO,MAAR;OAEE,QAAQ;OACR,UAAU;OACV,SAAQ;OACR,SAAQ;OACR,MAAK;OACL,YAAY;QACV,UAAU,eAAe,KAAK,IAAI,UAAU,GAAI,IAAI;QACpD,OAAO,eAAe,IAAI,WAAW;QACrC,MAAM;OACR;OACA,WAAW,GACT,kEACA,gBACA,YAAY,cAAc,kBAAkB,KAAA,CAC9C;OAEC,UAAA;MACU,GAlBN,QAkBM;KACE,CAAA;IACb,GA1BC,EA0BD;GAEV,CAAC;EACG,CAAA,CACF;;AAEV"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { SPRING_LAYOUT } from "../../lib/ease.js";
3
3
  import { createContext, useContext, useId, useMemo } from "react";
4
- import { cn } from "cn";
4
+ import { cn } from "@kumix/utils";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/dock.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { cn } from \"cn\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-primary/5\"\n />\n ) : null;\n const sharedStyle = { width: size, height: size };\n const sharedClass = cn(\n \"relative flex shrink-0 items-center justify-center rounded-full text-foreground\",\n className,\n );\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={rest[\"aria-label\"]}\n aria-pressed={active}\n style={sharedStyle}\n className={cn(\n sharedClass,\n \"cursor-pointer border-0 bg-transparent p-0 outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n )}\n >\n {pill}\n {children}\n </button>\n );\n }\n\n // Children carry their own link or button (and its accessible name).\n return (\n <div style={sharedStyle} className={sharedClass}>\n {pill}\n {children}\n </div>\n );\n}\n\nexport function DockSeparator({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"mx-1 h-6 w-px self-center bg-border\", className)} />;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc,cAAuC,IAAI;AAS/D,SAAgB,KAAK,EAAE,UAAU,OAAO,IAAI,aAAwB;CAClE,MAAM,eAAe,MAAM;CAC3B,MAAM,MAAM,eAAiC;EAAE;EAAM;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,0HACA,SACF;GAEC;EACE,CAAA;CACe,CAAA;AAE1B;AAWA,SAAgB,SAAS,EAAE,UAAU,WAAW,SAAS,QAAQ,GAAG,QAAuB;CACzF,MAAM,OAAO,WAAW,WAAW;CACnC,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAE3C,MAAM,OAAO,SACX,oBAAC,OAAO,MAAR;EACE,UAAU;EACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACvC,WAAU;CACX,CAAA,IACC;CACJ,MAAM,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAChD,MAAM,cAAc,GAClB,mFACA,SACF;CAEA,IAAI,SACF,OACE,qBAAC,UAAD;EACE,MAAK;EACI;EACT,cAAY,KAAK;EACjB,gBAAc;EACd,OAAO;EACP,WAAW,GACT,aACA,2DACA,+GACF;EAVF,UAAA,CAYG,MACA,QACK;;CAKZ,OACE,qBAAC,OAAD;EAAK,OAAO;EAAa,WAAW;EAApC,UAAA,CACG,MACA,QACE;;AAET;AAEA,SAAgB,cAAc,EAAE,aAAqC;CACnE,OAAO,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,uCAAuC,SAAS;CAAI,CAAA;AAC7F"}
1
+ {"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-primary/5\"\n />\n ) : null;\n const sharedStyle = { width: size, height: size };\n const sharedClass = cn(\n \"relative flex shrink-0 items-center justify-center rounded-full text-foreground\",\n className,\n );\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={rest[\"aria-label\"]}\n aria-pressed={active}\n style={sharedStyle}\n className={cn(\n sharedClass,\n \"cursor-pointer border-0 bg-transparent p-0 outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n )}\n >\n {pill}\n {children}\n </button>\n );\n }\n\n // Children carry their own link or button (and its accessible name).\n return (\n <div style={sharedStyle} className={sharedClass}>\n {pill}\n {children}\n </div>\n );\n}\n\nexport function DockSeparator({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"mx-1 h-6 w-px self-center bg-border\", className)} />;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc,cAAuC,IAAI;AAS/D,SAAgB,KAAK,EAAE,UAAU,OAAO,IAAI,aAAwB;CAClE,MAAM,eAAe,MAAM;CAC3B,MAAM,MAAM,eAAiC;EAAE;EAAM;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,0HACA,SACF;GAEC;EACE,CAAA;CACe,CAAA;AAE1B;AAWA,SAAgB,SAAS,EAAE,UAAU,WAAW,SAAS,QAAQ,GAAG,QAAuB;CACzF,MAAM,OAAO,WAAW,WAAW;CACnC,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAE3C,MAAM,OAAO,SACX,oBAAC,OAAO,MAAR;EACE,UAAU;EACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACvC,WAAU;CACX,CAAA,IACC;CACJ,MAAM,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAChD,MAAM,cAAc,GAClB,mFACA,SACF;CAEA,IAAI,SACF,OACE,qBAAC,UAAD;EACE,MAAK;EACI;EACT,cAAY,KAAK;EACjB,gBAAc;EACd,OAAO;EACP,WAAW,GACT,aACA,2DACA,+GACF;EAVF,UAAA,CAYG,MACA,QACK;;CAKZ,OACE,qBAAC,OAAD;EAAK,OAAO;EAAa,WAAW;EAApC,UAAA,CACG,MACA,QACE;;AAET;AAEA,SAAgB,cAAc,EAAE,aAAqC;CACnE,OAAO,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,uCAAuC,SAAS;CAAI,CAAA;AAC7F"}
@@ -2,7 +2,7 @@
2
2
  import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
3
3
  import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
4
4
  import { useEffect } from "react";
5
- import { cn } from "cn";
5
+ import { cn } from "@kumix/utils";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
8
8
  //#region src/components/motion/drawer.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/motion/drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { cn } from \"cn\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface DrawerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n side?: \"left\" | \"right\";\n children: ReactNode;\n /** Class for the panel surface. */\n className?: string;\n /** Class for the backdrop. */\n backdropClassName?: string;\n ariaLabel?: string;\n /** Close when the backdrop is clicked. Default true. */\n dismissable?: boolean;\n}\n\nexport function Drawer({\n open,\n onOpenChange,\n side = \"right\",\n children,\n className,\n backdropClassName,\n ariaLabel,\n dismissable = true,\n}: DrawerProps) {\n const reduce = useReducedMotion();\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onOpenChange(false);\n };\n window.addEventListener(\"keydown\", onKey);\n const prevOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n document.body.style.overflow = prevOverflow;\n };\n }, [open, onOpenChange]);\n\n const offscreen = side === \"right\" ? \"100%\" : \"-100%\";\n\n // Two fixed siblings, no wrapper: the backdrop spans the viewport edges but\n // paints the scrim, and the panel is inset off one side and paints its own\n // surface, so neither is a transparent edge-spanning layer. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n return (\n <AnimatePresence>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close\"\n tabIndex={dismissable ? 0 : -1}\n onClick={() => dismissable && onOpenChange(false)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.25, ease: EASE_OUT }}\n {...gate}\n className={cn(\n \"fixed inset-0 z-50 h-full w-full cursor-default bg-black/40 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n )}\n </PresenceGate>\n ) : null}\n {open ? (\n <PresenceGate key=\"panel\">\n {({ gate }) => (\n <motion.aside\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n initial={reduce ? { opacity: 0 } : { x: offscreen }}\n animate={reduce ? { opacity: 1 } : { x: 0 }}\n exit={reduce ? { opacity: 0 } : { x: offscreen }}\n transition={reduce ? { duration: 0.2, ease: EASE_OUT } : SPRING_PANEL}\n {...gate}\n className={cn(\n \"fixed inset-y-0 z-50 flex w-80 max-w-[85vw] flex-col bg-background shadow-2xl\",\n side === \"right\"\n ? \"right-0 border-border border-l\"\n : \"left-0 border-border border-r\",\n className,\n )}\n >\n {children}\n </motion.aside>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;;AAuBA,SAAgB,OAAO,EACrB,MACA,cACA,OAAO,SACP,UACA,WACA,mBACA,WACA,cAAc,QACA;CACd,MAAM,SAAS,iBAAiB;CAEhC,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,SAAS,MAAqB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use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface DrawerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n side?: \"left\" | \"right\";\n children: ReactNode;\n /** Class for the panel surface. */\n className?: string;\n /** Class for the backdrop. */\n backdropClassName?: string;\n ariaLabel?: string;\n /** Close when the backdrop is clicked. Default true. */\n dismissable?: boolean;\n}\n\nexport function Drawer({\n open,\n onOpenChange,\n side = \"right\",\n children,\n className,\n backdropClassName,\n ariaLabel,\n dismissable = true,\n}: DrawerProps) {\n const reduce = useReducedMotion();\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onOpenChange(false);\n };\n window.addEventListener(\"keydown\", onKey);\n const prevOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n document.body.style.overflow = prevOverflow;\n };\n }, [open, onOpenChange]);\n\n const offscreen = side === \"right\" ? \"100%\" : \"-100%\";\n\n // Two fixed siblings, no wrapper: the backdrop spans the viewport edges but\n // paints the scrim, and the panel is inset off one side and paints its own\n // surface, so neither is a transparent edge-spanning layer. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n return (\n <AnimatePresence>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close\"\n tabIndex={dismissable ? 0 : -1}\n onClick={() => dismissable && onOpenChange(false)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.25, ease: EASE_OUT }}\n {...gate}\n className={cn(\n \"fixed inset-0 z-50 h-full w-full cursor-default bg-black/40 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n )}\n </PresenceGate>\n ) : null}\n {open ? (\n <PresenceGate key=\"panel\">\n {({ gate }) => (\n <motion.aside\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n initial={reduce ? { opacity: 0 } : { x: offscreen }}\n animate={reduce ? { opacity: 1 } : { x: 0 }}\n exit={reduce ? { opacity: 0 } : { x: offscreen }}\n transition={reduce ? { duration: 0.2, ease: EASE_OUT } : SPRING_PANEL}\n {...gate}\n className={cn(\n \"fixed inset-y-0 z-50 flex w-80 max-w-[85vw] flex-col bg-background shadow-2xl\",\n side === \"right\"\n ? \"right-0 border-border border-l\"\n : \"left-0 border-border border-r\",\n className,\n )}\n >\n {children}\n </motion.aside>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;;AAuBA,SAAgB,OAAO,EACrB,MACA,cACA,OAAO,SACP,UACA,WACA,mBACA,WACA,cAAc,QACA;CACd,MAAM,SAAS,iBAAiB;CAEhC,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,SAAS,MAAqB;GAClC,IAAI,EAAE,QAAQ,UAAU,aAAa,KAAK;EAC5C;EACA,OAAO,iBAAiB,WAAW,KAAK;EACxC,MAAM,eAAe,SAAS,KAAK,MAAM;EACzC,SAAS,KAAK,MAAM,WAAW;EAC/B,aAAa;GACX,OAAO,oBAAoB,WAAW,KAAK;GAC3C,SAAS,KAAK,MAAM,WAAW;EACjC;CACF,GAAG,CAAC,MAAM,YAAY,CAAC;CAEvB,MAAM,YAAY,SAAS,UAAU,SAAS;CAM9C,OACE,qBAAC,iBAAD,EAAA,UAAA,CACG,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WACF,oBAAC,OAAO,QAAR;EACE,MAAK;EACL,cAAW;EACX,UAAU,cAAc,IAAI;EAC5B,eAAe,eAAe,aAAa,KAAK;EAChD,SAAS,EAAE,SAAS,EAAE;EACtB,SAAS,EAAE,SAAS,EAAE;EACtB,MAAM,EAAE,SAAS,EAAE;EACnB,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;EAC7C,GAAI;EACJ,WAAW,GACT,gFACA,iBACF;CACD,CAAA,EAES,GAlBI,UAkBJ,IACZ,MACH,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WACF,oBAAC,OAAO,OAAR;EACE,MAAK;EACL,cAAW;EACX,cAAY;EACZ,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU;EAClD,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE;EAC1C,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU;EAC/C,YAAY,SAAS;GAAE,UAAU;GAAK,MAAM;EAAS,IAAI;EACzD,GAAI;EACJ,WAAW,GACT,iFACA,SAAS,UACL,mCACA,iCACJ,SACF;EAEC;CACW,CAAA,EAEJ,GAtBI,OAsBJ,IACZ,IACW,EAAA,CAAA;AAErB"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { EASE_OUT } from "../../lib/ease.js";
3
3
  import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
- import { cn } from "cn";
4
+ import { cn } from "@kumix/utils";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/dynamic-island.tsx
@@ -1 +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 { cn } from \"cn\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\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,aAAa;AACnB,MAAM,cAAc;;AAGpB,SAAS,iBAAiB;CACxB,MAAM,MAAM,OAA8B,IAAI;CAC9C,MAAM,CAAC,MAAM,WAAW,SAAmD,IAAI;CAM/E,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,QAAQ;GAAE,OAAO,GAAG;GAAa,QAAQ,GAAG;EAAa,CAAC;CAC5D,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,MAAM,OAAO,mBAAmB,aAAa;EAClD,MAAM,WAAW,IAAI,qBAAqB;GACxC,QAAQ;IAAE,OAAO,GAAG;IAAa,QAAQ,GAAG;GAAa,CAAC;EAC5D,CAAC;EACD,SAAS,QAAQ,EAAE;EACnB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,CA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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"}
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,aAAa;AACnB,MAAM,cAAc;;AAGpB,SAAS,iBAAiB;CACxB,MAAM,MAAM,OAA8B,IAAI;CAC9C,MAAM,CAAC,MAAM,WAAW,SAAmD,IAAI;CAM/E,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,QAAQ;GAAE,OAAO,GAAG;GAAa,QAAQ,GAAG;EAAa,CAAC;CAC5D,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,MAAM,OAAO,mBAAmB,aAAa;EAClD,MAAM,WAAW,IAAI,qBAAqB;GACxC,QAAQ;IAAE,OAAO,GAAG;IAAa,QAAQ,GAAG;GAAa,CAAC;EAC5D,CAAC;EACD,SAAS,QAAQ,EAAE;EACnB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,CAAC;CAEL,OAAO,CAAC,KAAK,IAAI;AACnB;AAEA,SAAS,KAAK,EACZ,OACA,UACA,aAKC;CACD,MAAM,SAAS,iBAAiB;CAChC,OACE,oBAAC,OAAO,KAAR;EAEE,SACE,SACI;GAAE,SAAS;GAAG,QAAQ;EAAY,IAClC;GAAE,SAAS;GAAG,OAAO;GAAK,GAAG;GAAI,QAAQ;EAAY;EAE3D,SACE,SACI;GAAE,SAAS;GAAG,QAAQ;EAAY,IAClC;GAAE,SAAS;GAAG,OAAO;GAAG,GAAG;GAAG,QAAQ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AS,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"}
@@ -3,7 +3,7 @@ import { useDismiss } from "../../hooks/use-dismiss.js";
3
3
  import { useHoverGesture } from "../../hooks/use-hover-gesture.js";
4
4
  import { useTapGesture } from "../../hooks/use-tap-gesture.js";
5
5
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
6
- import { cn } from "cn";
6
+ import { cn } from "@kumix/utils";
7
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { LayoutGroup, motion, useReducedMotion } from "motion/react";
9
9
  //#region src/components/motion/expandable-action-bar.tsx
@@ -1 +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 PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\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 /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\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 // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\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 setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\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 // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-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 onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\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 shrink-0 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":";;;;;;;;;AAs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I;SAC1B,YAAY,aAAa,IAAI;SAC7B,GAAG;SACH,QAAQ;QACV,IACA;SACE,OAAO,aAAa,SAAS;SAC7B,SAAS,aAAa,IAAI;SAC1B,GAAG,aAAa,IAAI;SACpB,YAAY,aAAa,IAAI;SAC7B,QAAQ,aAAa,cAAc;QACrC;QAEN,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;QACvC,WAAW,GACT,kDACA,YAAY,KACd;QAEC,UAAA,KAAK;OACK,CAAA;OAEZ,KAAK,WACJ,oBAAC,OAAO,MAAR;QACE,eAAa,CAAC;QACd,SAAS;SACP,OAAO,aAAa,SAAS;SAC7B,SAAS,aAAa,IAAI;SAC1B,YAAY,aAAa,IAAI;QAC/B;QACA,YAAY;QACZ,WAAW,GACT,8FACA,YAAY,QACd;QAEC,UAAA,KAAK;OACK,CAAA,IACX;OAEH,KAAK,QACJ,oBAAC,QAAD;QACE,WAAW,GACT,gJACA,CAAC,cAAc,8BACf,YAAY,KACd;QAEC,UAAA,KAAK;OACF,CAAA,IACJ;MACJ,EAAA,CAAA,CAES;KAxIR,GAAA,KAAK,EAwIG;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"}
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 PointerEvent,\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\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\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 /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\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 // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\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 setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\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 // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-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 onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\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 shrink-0 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":";;;;;;;;;AAsEA,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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;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"expandable-control.d.ts","names":[],"sources":["../../../src/components/motion/expandable-control.tsx"],"mappings":";;;KA4BK;EACH;EACA;EACA,oBAAoB;;iBAGL,8BACP,KAAK,wCACX;EACF,MAAM;EACN,OAAO;;iBAGQ,4BAA4B;EAC3C,OAAO;EACP,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;;wBAyBc,mBACd,MACA,OACA,UACA,iBACA,kBACA,WACA,SACA,UACA,oBACc,cACX,SACF,wCAAqB,IAAA;wBAiER,iBACd,OACA,YACA,aACA,UACA,kBACA,UACA,iBACA,kBACA,UACA,WACA,gBACA,mBACC,sCAAmB,IAAA"}
1
+ {"version":3,"file":"expandable-control.d.ts","names":[],"sources":["../../../src/components/motion/expandable-control.tsx"],"mappings":";;;KA6BK;EACH;EACA;EACA,oBAAoB;;iBAGL,8BACP,KAAK,wCACX;EACF,MAAM;EACN,OAAO;;iBAGQ,4BAA4B;EAC3C,OAAO;EACP,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;;wBAyBc,mBACd,MACA,OACA,UACA,iBACA,kBACA,WACA,SACA,UACA,oBACc,cACX,SACF,wCAAqB,IAAA;wBAiER,iBACd,OACA,YACA,aACA,UACA,kBACA,UACA,iBACA,kBACA,UACA,WACA,gBACA,mBACC,sCAAmB,IAAA"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useCallback, useRef, useState } from "react";
3
- import { cn } from "cn";
3
+ import { cn } from "@kumix/utils";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
6
6
  //#region src/components/motion/expandable-control.tsx