@kumix/ui 0.3.12 → 0.3.13

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 (530) hide show
  1. package/README.md +1 -1
  2. package/dist/components/agents/agent-activity/activity-row.js +2 -2
  3. package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
  4. package/dist/components/agents/agent-activity/index.js +2 -2
  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 +2 -2
  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 +2 -2
  12. package/dist/components/agents/ai-sidebar.js.map +1 -1
  13. package/dist/components/agents/approval-card/index.js +2 -2
  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 +2 -2
  18. package/dist/components/agents/citations.js.map +1 -1
  19. package/dist/components/agents/code-block.js +2 -2
  20. package/dist/components/agents/code-block.js.map +1 -1
  21. package/dist/components/agents/file-diff.js +2 -2
  22. package/dist/components/agents/file-diff.js.map +1 -1
  23. package/dist/components/agents/image-generation.js +2 -2
  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 +2 -2
  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 +2 -2
  38. package/dist/components/agents/prompt-input.js.map +1 -1
  39. package/dist/components/agents/streaming-response.js +2 -2
  40. package/dist/components/agents/streaming-response.js.map +1 -1
  41. package/dist/components/agents/todo-list.js +2 -2
  42. package/dist/components/agents/todo-list.js.map +1 -1
  43. package/dist/components/agents/tool-approval.js +2 -2
  44. package/dist/components/agents/tool-approval.js.map +1 -1
  45. package/dist/components/agents/tool-result.js +2 -2
  46. package/dist/components/agents/tool-result.js.map +1 -1
  47. package/dist/components/custom/confirm-dialog.js +1 -1
  48. package/dist/components/motion/action-swap.js +1 -1
  49. package/dist/components/motion/action-swap.js.map +1 -1
  50. package/dist/components/motion/adaptive-stepper.js +2 -2
  51. package/dist/components/motion/adaptive-stepper.js.map +1 -1
  52. package/dist/components/motion/animated-badge.js +2 -2
  53. package/dist/components/motion/animated-badge.js.map +1 -1
  54. package/dist/components/motion/animated-number.js +1 -1
  55. package/dist/components/motion/animated-number.js.map +1 -1
  56. package/dist/components/motion/animated-sidebar.js +2 -2
  57. package/dist/components/motion/animated-sidebar.js.map +1 -1
  58. package/dist/components/motion/animated-toast-stack.js +2 -2
  59. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  60. package/dist/components/motion/attachment-upload.js +2 -2
  61. package/dist/components/motion/attachment-upload.js.map +1 -1
  62. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  63. package/dist/components/motion/availability-scheduler/day-row.js +2 -2
  64. package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
  65. package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
  66. package/dist/components/motion/availability-scheduler/index.js +2 -2
  67. package/dist/components/motion/availability-scheduler/index.js.map +1 -1
  68. package/dist/components/motion/bloom-menu.js +2 -2
  69. package/dist/components/motion/bloom-menu.js.map +1 -1
  70. package/dist/components/motion/bottom-sheet.js +1 -1
  71. package/dist/components/motion/bottom-sheet.js.map +1 -1
  72. package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
  73. package/dist/components/motion/bounce-sidebar.js +1 -1
  74. package/dist/components/motion/bounce-sidebar.js.map +1 -1
  75. package/dist/components/motion/bouncy-accordion.js +2 -2
  76. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  77. package/dist/components/motion/button/base.js +1 -1
  78. package/dist/components/motion/button/base.js.map +1 -1
  79. package/dist/components/motion/button/metallic.js +1 -1
  80. package/dist/components/motion/button/metallic.js.map +1 -1
  81. package/dist/components/motion/button/stateful.js +1 -1
  82. package/dist/components/motion/card-folder.d.ts +30 -0
  83. package/dist/components/motion/card-folder.d.ts.map +1 -0
  84. package/dist/components/motion/card-folder.js +254 -0
  85. package/dist/components/motion/card-folder.js.map +1 -0
  86. package/dist/components/motion/center-morph-modal.js +2 -2
  87. package/dist/components/motion/center-morph-modal.js.map +1 -1
  88. package/dist/components/motion/checkbox.js +1 -1
  89. package/dist/components/motion/checkbox.js.map +1 -1
  90. package/dist/components/motion/chromatic-text-reveal.js +1 -1
  91. package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
  92. package/dist/components/motion/combobox/content.js +1 -1
  93. package/dist/components/motion/combobox/content.js.map +1 -1
  94. package/dist/components/motion/combobox/context.js +1 -1
  95. package/dist/components/motion/combobox/context.js.map +1 -1
  96. package/dist/components/motion/combobox/list.js +2 -2
  97. package/dist/components/motion/combobox/list.js.map +1 -1
  98. package/dist/components/motion/combobox/trigger.js +2 -2
  99. package/dist/components/motion/combobox/trigger.js.map +1 -1
  100. package/dist/components/motion/command-palette.js +2 -2
  101. package/dist/components/motion/command-palette.js.map +1 -1
  102. package/dist/components/motion/context-menu.js +2 -2
  103. package/dist/components/motion/context-menu.js.map +1 -1
  104. package/dist/components/motion/cylinder-carousel.js +1 -1
  105. package/dist/components/motion/cylinder-carousel.js.map +1 -1
  106. package/dist/components/motion/digit-swap.d.ts +23 -0
  107. package/dist/components/motion/digit-swap.d.ts.map +1 -0
  108. package/dist/components/motion/digit-swap.js +77 -0
  109. package/dist/components/motion/digit-swap.js.map +1 -0
  110. package/dist/components/motion/dock.js +1 -1
  111. package/dist/components/motion/dock.js.map +1 -1
  112. package/dist/components/motion/drawer.js +1 -1
  113. package/dist/components/motion/drawer.js.map +1 -1
  114. package/dist/components/motion/dynamic-island.js +1 -1
  115. package/dist/components/motion/dynamic-island.js.map +1 -1
  116. package/dist/components/motion/expandable-action-bar.js +1 -1
  117. package/dist/components/motion/expandable-action-bar.js.map +1 -1
  118. package/dist/components/motion/expandable-control.d.ts.map +1 -1
  119. package/dist/components/motion/expandable-control.js +1 -1
  120. package/dist/components/motion/expandable-control.js.map +1 -1
  121. package/dist/components/motion/expandable-tabs.js +1 -1
  122. package/dist/components/motion/expandable-tabs.js.map +1 -1
  123. package/dist/components/motion/expanding-arrow-button.js +1 -1
  124. package/dist/components/motion/expanding-arrow-button.js.map +1 -1
  125. package/dist/components/motion/feedback-widget.js +2 -2
  126. package/dist/components/motion/feedback-widget.js.map +1 -1
  127. package/dist/components/motion/file-tree.js +2 -2
  128. package/dist/components/motion/file-tree.js.map +1 -1
  129. package/dist/components/motion/file-upload.js +2 -2
  130. package/dist/components/motion/file-upload.js.map +1 -1
  131. package/dist/components/motion/hold-action-button.js +1 -1
  132. package/dist/components/motion/hold-action-button.js.map +1 -1
  133. package/dist/components/motion/infinite-masonry.js +2 -2
  134. package/dist/components/motion/infinite-masonry.js.map +1 -1
  135. package/dist/components/motion/input.d.ts.map +1 -1
  136. package/dist/components/motion/input.js +1 -1
  137. package/dist/components/motion/input.js.map +1 -1
  138. package/dist/components/motion/liquid.js +1 -1
  139. package/dist/components/motion/liquid.js.map +1 -1
  140. package/dist/components/motion/loader.js +1 -1
  141. package/dist/components/motion/loader.js.map +1 -1
  142. package/dist/components/motion/magnetic.js +1 -1
  143. package/dist/components/motion/magnetic.js.map +1 -1
  144. package/dist/components/motion/marquee.d.ts.map +1 -1
  145. package/dist/components/motion/marquee.js +1 -1
  146. package/dist/components/motion/marquee.js.map +1 -1
  147. package/dist/components/motion/morphing-modal.js +1 -1
  148. package/dist/components/motion/morphing-modal.js.map +1 -1
  149. package/dist/components/motion/morphing-search.js +2 -2
  150. package/dist/components/motion/morphing-search.js.map +1 -1
  151. package/dist/components/motion/morphing-tabs.js +2 -2
  152. package/dist/components/motion/morphing-tabs.js.map +1 -1
  153. package/dist/components/motion/multi-select/content.js +1 -1
  154. package/dist/components/motion/multi-select/content.js.map +1 -1
  155. package/dist/components/motion/multi-select/context.js +1 -1
  156. package/dist/components/motion/multi-select/context.js.map +1 -1
  157. package/dist/components/motion/multi-select/list.js +2 -2
  158. package/dist/components/motion/multi-select/list.js.map +1 -1
  159. package/dist/components/motion/multi-select/trigger.js +2 -2
  160. package/dist/components/motion/multi-select/trigger.js.map +1 -1
  161. package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
  162. package/dist/components/motion/not-found/magnetic.js +1 -1
  163. package/dist/components/motion/not-found/magnetic.js.map +1 -1
  164. package/dist/components/motion/not-found/shared.js +1 -1
  165. package/dist/components/motion/not-found/shared.js.map +1 -1
  166. package/dist/components/motion/not-found/spotlight.js +1 -1
  167. package/dist/components/motion/not-found/spotlight.js.map +1 -1
  168. package/dist/components/motion/notification-stack.js +2 -2
  169. package/dist/components/motion/notification-stack.js.map +1 -1
  170. package/dist/components/motion/number-ticker.js +1 -1
  171. package/dist/components/motion/number-ticker.js.map +1 -1
  172. package/dist/components/motion/otp-input.js +1 -1
  173. package/dist/components/motion/otp-input.js.map +1 -1
  174. package/dist/components/motion/overflow-actions.js +2 -2
  175. package/dist/components/motion/overflow-actions.js.map +1 -1
  176. package/dist/components/motion/parallax.d.ts.map +1 -1
  177. package/dist/components/motion/parallax.js +1 -1
  178. package/dist/components/motion/parallax.js.map +1 -1
  179. package/dist/components/motion/popover-morph.js +1 -1
  180. package/dist/components/motion/popover-morph.js.map +1 -1
  181. package/dist/components/motion/popover.js +1 -1
  182. package/dist/components/motion/popover.js.map +1 -1
  183. package/dist/components/motion/preview-rail.js +1 -1
  184. package/dist/components/motion/preview-rail.js.map +1 -1
  185. package/dist/components/motion/project-folder.js +2 -2
  186. package/dist/components/motion/project-folder.js.map +1 -1
  187. package/dist/components/motion/pull-to-refresh.js +1 -1
  188. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  189. package/dist/components/motion/radio.js +1 -1
  190. package/dist/components/motion/radio.js.map +1 -1
  191. package/dist/components/motion/range-slider-bubble.js +1 -1
  192. package/dist/components/motion/range-slider-bubble.js.map +1 -1
  193. package/dist/components/motion/range-slider-fluid.js +1 -1
  194. package/dist/components/motion/range-slider-fluid.js.map +1 -1
  195. package/dist/components/motion/range-slider-ruler.js +1 -1
  196. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  197. package/dist/components/motion/range-slider-wave.js +1 -1
  198. package/dist/components/motion/range-slider-wave.js.map +1 -1
  199. package/dist/components/motion/range-slider.js +1 -1
  200. package/dist/components/motion/range-slider.js.map +1 -1
  201. package/dist/components/motion/scroll-progress.js +1 -1
  202. package/dist/components/motion/scroll-progress.js.map +1 -1
  203. package/dist/components/motion/scroll-reveal.js +1 -1
  204. package/dist/components/motion/scroll-reveal.js.map +1 -1
  205. package/dist/components/motion/scroll-to.js +1 -1
  206. package/dist/components/motion/scroll-to.js.map +1 -1
  207. package/dist/components/motion/select-morph.d.ts.map +1 -1
  208. package/dist/components/motion/select-morph.js +2 -2
  209. package/dist/components/motion/select-morph.js.map +1 -1
  210. package/dist/components/motion/select.js +2 -2
  211. package/dist/components/motion/select.js.map +1 -1
  212. package/dist/components/motion/shader-background.d.ts.map +1 -1
  213. package/dist/components/motion/shader-background.js +1 -1
  214. package/dist/components/motion/shader-background.js.map +1 -1
  215. package/dist/components/motion/shared-layout-bg.js +1 -1
  216. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  217. package/dist/components/motion/signup-form.js +2 -2
  218. package/dist/components/motion/signup-form.js.map +1 -1
  219. package/dist/components/motion/slide-action-button.js +1 -1
  220. package/dist/components/motion/slide-action-button.js.map +1 -1
  221. package/dist/components/motion/swipeable-list.js +1 -1
  222. package/dist/components/motion/swipeable-list.js.map +1 -1
  223. package/dist/components/motion/switch.d.ts.map +1 -1
  224. package/dist/components/motion/switch.js +1 -1
  225. package/dist/components/motion/switch.js.map +1 -1
  226. package/dist/components/motion/table/index.js +1 -1
  227. package/dist/components/motion/table/index.js.map +1 -1
  228. package/dist/components/motion/table/row-handle.js +1 -1
  229. package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
  230. package/dist/components/motion/table/skeleton-rows.js +1 -1
  231. package/dist/components/motion/table/skeleton-rows.js.map +1 -1
  232. package/dist/components/motion/table/table-header.js +2 -2
  233. package/dist/components/motion/table/table-header.js.map +1 -1
  234. package/dist/components/motion/table/table-menu.js +1 -1
  235. package/dist/components/motion/table/table-menu.js.map +1 -1
  236. package/dist/components/motion/tabs.js +1 -1
  237. package/dist/components/motion/tabs.js.map +1 -1
  238. package/dist/components/motion/text-reveal.js +1 -1
  239. package/dist/components/motion/text-reveal.js.map +1 -1
  240. package/dist/components/motion/text-scramble.d.ts.map +1 -1
  241. package/dist/components/motion/text-scramble.js +1 -1
  242. package/dist/components/motion/text-scramble.js.map +1 -1
  243. package/dist/components/motion/text-shimmer.js +1 -1
  244. package/dist/components/motion/text-shimmer.js.map +1 -1
  245. package/dist/components/motion/theme-toggle.js +2 -2
  246. package/dist/components/motion/theme-toggle.js.map +1 -1
  247. package/dist/components/motion/tilt-card.js +1 -1
  248. package/dist/components/motion/tilt-card.js.map +1 -1
  249. package/dist/components/motion/tooltip.js +1 -1
  250. package/dist/components/motion/tooltip.js.map +1 -1
  251. package/dist/components/motion/wheel-picker.js +1 -1
  252. package/dist/components/motion/wheel-picker.js.map +1 -1
  253. package/dist/components/reui/alert.d.ts +1 -1
  254. package/dist/components/reui/alert.d.ts.map +1 -1
  255. package/dist/components/reui/alert.js +2 -2
  256. package/dist/components/reui/alert.js.map +1 -1
  257. package/dist/components/reui/autocomplete.d.ts +1 -1
  258. package/dist/components/reui/autocomplete.js +2 -2
  259. package/dist/components/reui/autocomplete.js.map +1 -1
  260. package/dist/components/reui/badge.d.ts +2 -2
  261. package/dist/components/reui/badge.d.ts.map +1 -1
  262. package/dist/components/reui/badge.js +1 -1
  263. package/dist/components/reui/badge.js.map +1 -1
  264. package/dist/components/reui/cascader/cascader-columns.js +2 -2
  265. package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
  266. package/dist/components/reui/cascader/cascader-footer.js +2 -2
  267. package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
  268. package/dist/components/reui/cascader/cascader-item.js +2 -2
  269. package/dist/components/reui/cascader/cascader-item.js.map +1 -1
  270. package/dist/components/reui/cascader/cascader-nav.js +2 -2
  271. package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
  272. package/dist/components/reui/cascader/cascader.js +2 -2
  273. package/dist/components/reui/cascader/cascader.js.map +1 -1
  274. package/dist/components/reui/code-block/code-block.js +1 -1
  275. package/dist/components/reui/code-block/code-block.js.map +1 -1
  276. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
  277. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
  278. package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
  279. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  280. package/dist/components/reui/data-grid/data-grid-column-header.js +2 -2
  281. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  282. package/dist/components/reui/data-grid/data-grid-pagination.js +2 -2
  283. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  284. package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
  285. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  286. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +2 -2
  287. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  288. package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
  289. package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
  290. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  291. package/dist/components/reui/data-grid/data-grid-table.js +2 -2
  292. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  293. package/dist/components/reui/data-grid/data-grid.js +1 -1
  294. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  295. package/dist/components/reui/date-selector.js +2 -2
  296. package/dist/components/reui/date-selector.js.map +1 -1
  297. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +2 -2
  298. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
  299. package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
  300. package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
  301. package/dist/components/reui/event-calendar/event-calendar-event.js +2 -2
  302. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  303. package/dist/components/reui/event-calendar/event-calendar-month-view.js +2 -2
  304. package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
  305. package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
  306. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
  307. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
  308. package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
  309. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
  310. package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
  311. package/dist/components/reui/event-calendar/event-calendar.js +1 -1
  312. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  313. package/dist/components/reui/filters/filters-advanced.js +2 -2
  314. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  315. package/dist/components/reui/filters/filters-builder.js +3 -3
  316. package/dist/components/reui/filters/filters-builder.js.map +1 -1
  317. package/dist/components/reui/filters/filters-chip.js +2 -2
  318. package/dist/components/reui/filters/filters-chip.js.map +1 -1
  319. package/dist/components/reui/filters/filters-editors.js +3 -3
  320. package/dist/components/reui/filters/filters-editors.js.map +1 -1
  321. package/dist/components/reui/filters/filters.js +2 -2
  322. package/dist/components/reui/filters/filters.js.map +1 -1
  323. package/dist/components/reui/frame.d.ts +2 -2
  324. package/dist/components/reui/frame.d.ts.map +1 -1
  325. package/dist/components/reui/frame.js +2 -2
  326. package/dist/components/reui/frame.js.map +1 -1
  327. package/dist/components/reui/gantt/gantt-bar.js +2 -2
  328. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  329. package/dist/components/reui/gantt/gantt-nav.js +2 -2
  330. package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
  331. package/dist/components/reui/gantt/gantt-view.js +2 -2
  332. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  333. package/dist/components/reui/gantt/gantt.js +1 -1
  334. package/dist/components/reui/gantt/gantt.js.map +1 -1
  335. package/dist/components/reui/icon-stack.js +1 -1
  336. package/dist/components/reui/icon-stack.js.map +1 -1
  337. package/dist/components/reui/icon-tile.d.ts +2 -2
  338. package/dist/components/reui/icon-tile.d.ts.map +1 -1
  339. package/dist/components/reui/icon-tile.js +1 -1
  340. package/dist/components/reui/icon-tile.js.map +1 -1
  341. package/dist/components/reui/kanban.d.ts.map +1 -1
  342. package/dist/components/reui/kanban.js +1 -1
  343. package/dist/components/reui/kanban.js.map +1 -1
  344. package/dist/components/reui/number-field.d.ts +3 -3
  345. package/dist/components/reui/number-field.js +2 -2
  346. package/dist/components/reui/number-field.js.map +1 -1
  347. package/dist/components/reui/phone-input.js +2 -2
  348. package/dist/components/reui/phone-input.js.map +1 -1
  349. package/dist/components/reui/rating.d.ts +1 -1
  350. package/dist/components/reui/rating.d.ts.map +1 -1
  351. package/dist/components/reui/rating.js +2 -2
  352. package/dist/components/reui/rating.js.map +1 -1
  353. package/dist/components/reui/sortable.d.ts.map +1 -1
  354. package/dist/components/reui/sortable.js +1 -1
  355. package/dist/components/reui/sortable.js.map +1 -1
  356. package/dist/components/reui/stepper.d.ts.map +1 -1
  357. package/dist/components/reui/stepper.js +1 -1
  358. package/dist/components/reui/stepper.js.map +1 -1
  359. package/dist/components/reui/timeline.d.ts.map +1 -1
  360. package/dist/components/reui/timeline.js +1 -1
  361. package/dist/components/reui/timeline.js.map +1 -1
  362. package/dist/components/reui/tree.d.ts.map +1 -1
  363. package/dist/components/reui/tree.js +2 -2
  364. package/dist/components/reui/tree.js.map +1 -1
  365. package/dist/components/ui/accordion.d.ts.map +1 -1
  366. package/dist/components/ui/accordion.js +2 -2
  367. package/dist/components/ui/accordion.js.map +1 -1
  368. package/dist/components/ui/alert-dialog.js +2 -2
  369. package/dist/components/ui/alert-dialog.js.map +1 -1
  370. package/dist/components/ui/alert.d.ts.map +1 -1
  371. package/dist/components/ui/alert.js +2 -2
  372. package/dist/components/ui/alert.js.map +1 -1
  373. package/dist/components/ui/aspect-ratio.js +1 -1
  374. package/dist/components/ui/aspect-ratio.js.map +1 -1
  375. package/dist/components/ui/attachment.d.ts +1 -1
  376. package/dist/components/ui/attachment.js +2 -2
  377. package/dist/components/ui/attachment.js.map +1 -1
  378. package/dist/components/ui/avatar.d.ts.map +1 -1
  379. package/dist/components/ui/avatar.js +1 -1
  380. package/dist/components/ui/avatar.js.map +1 -1
  381. package/dist/components/ui/badge.d.ts +1 -1
  382. package/dist/components/ui/badge.d.ts.map +1 -1
  383. package/dist/components/ui/badge.js +1 -1
  384. package/dist/components/ui/badge.js.map +1 -1
  385. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  386. package/dist/components/ui/breadcrumb.js +2 -2
  387. package/dist/components/ui/breadcrumb.js.map +1 -1
  388. package/dist/components/ui/bubble.d.ts +1 -1
  389. package/dist/components/ui/bubble.d.ts.map +1 -1
  390. package/dist/components/ui/bubble.js +2 -2
  391. package/dist/components/ui/bubble.js.map +1 -1
  392. package/dist/components/ui/button-group.js +2 -2
  393. package/dist/components/ui/button-group.js.map +1 -1
  394. package/dist/components/ui/button.d.ts +2 -2
  395. package/dist/components/ui/button.d.ts.map +1 -1
  396. package/dist/components/ui/button.js +2 -2
  397. package/dist/components/ui/button.js.map +1 -1
  398. package/dist/components/ui/calendar.js +2 -2
  399. package/dist/components/ui/calendar.js.map +1 -1
  400. package/dist/components/ui/card.d.ts.map +1 -1
  401. package/dist/components/ui/card.js +1 -1
  402. package/dist/components/ui/card.js.map +1 -1
  403. package/dist/components/ui/carousel.js +2 -2
  404. package/dist/components/ui/carousel.js.map +1 -1
  405. package/dist/components/ui/chart.d.ts.map +1 -1
  406. package/dist/components/ui/chart.js +1 -1
  407. package/dist/components/ui/chart.js.map +1 -1
  408. package/dist/components/ui/checkbox.d.ts.map +1 -1
  409. package/dist/components/ui/checkbox.js +3 -3
  410. package/dist/components/ui/checkbox.js.map +1 -1
  411. package/dist/components/ui/combobox.js +2 -2
  412. package/dist/components/ui/combobox.js.map +1 -1
  413. package/dist/components/ui/command.js +2 -2
  414. package/dist/components/ui/command.js.map +1 -1
  415. package/dist/components/ui/context-menu.d.ts.map +1 -1
  416. package/dist/components/ui/context-menu.js +2 -2
  417. package/dist/components/ui/context-menu.js.map +1 -1
  418. package/dist/components/ui/dialog.js +2 -2
  419. package/dist/components/ui/dialog.js.map +1 -1
  420. package/dist/components/ui/drawer.d.ts.map +1 -1
  421. package/dist/components/ui/drawer.js +1 -1
  422. package/dist/components/ui/drawer.js.map +1 -1
  423. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  424. package/dist/components/ui/dropdown-menu.js +2 -2
  425. package/dist/components/ui/dropdown-menu.js.map +1 -1
  426. package/dist/components/ui/empty.d.ts.map +1 -1
  427. package/dist/components/ui/empty.js +2 -2
  428. package/dist/components/ui/empty.js.map +1 -1
  429. package/dist/components/ui/field.js +3 -3
  430. package/dist/components/ui/field.js.map +1 -1
  431. package/dist/components/ui/hover-card.d.ts.map +1 -1
  432. package/dist/components/ui/hover-card.js +1 -1
  433. package/dist/components/ui/hover-card.js.map +1 -1
  434. package/dist/components/ui/input-group.d.ts +1 -1
  435. package/dist/components/ui/input-group.js +2 -2
  436. package/dist/components/ui/input-group.js.map +1 -1
  437. package/dist/components/ui/input-otp.d.ts.map +1 -1
  438. package/dist/components/ui/input-otp.js +2 -2
  439. package/dist/components/ui/input-otp.js.map +1 -1
  440. package/dist/components/ui/input.d.ts.map +1 -1
  441. package/dist/components/ui/input.js +1 -1
  442. package/dist/components/ui/input.js.map +1 -1
  443. package/dist/components/ui/item.d.ts +1 -1
  444. package/dist/components/ui/item.js +2 -2
  445. package/dist/components/ui/item.js.map +1 -1
  446. package/dist/components/ui/kbd.js +1 -1
  447. package/dist/components/ui/kbd.js.map +1 -1
  448. package/dist/components/ui/label.d.ts.map +1 -1
  449. package/dist/components/ui/label.js +1 -1
  450. package/dist/components/ui/label.js.map +1 -1
  451. package/dist/components/ui/marker.d.ts.map +1 -1
  452. package/dist/components/ui/marker.js +2 -2
  453. package/dist/components/ui/marker.js.map +1 -1
  454. package/dist/components/ui/menubar.js +2 -2
  455. package/dist/components/ui/menubar.js.map +1 -1
  456. package/dist/components/ui/message-scroller.js +2 -2
  457. package/dist/components/ui/message-scroller.js.map +1 -1
  458. package/dist/components/ui/message.d.ts.map +1 -1
  459. package/dist/components/ui/message.js +1 -1
  460. package/dist/components/ui/message.js.map +1 -1
  461. package/dist/components/ui/native-select.d.ts.map +1 -1
  462. package/dist/components/ui/native-select.js +2 -2
  463. package/dist/components/ui/native-select.js.map +1 -1
  464. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  465. package/dist/components/ui/navigation-menu.js +2 -2
  466. package/dist/components/ui/navigation-menu.js.map +1 -1
  467. package/dist/components/ui/pagination.js +2 -2
  468. package/dist/components/ui/pagination.js.map +1 -1
  469. package/dist/components/ui/popover.d.ts.map +1 -1
  470. package/dist/components/ui/popover.js +1 -1
  471. package/dist/components/ui/popover.js.map +1 -1
  472. package/dist/components/ui/progress.d.ts.map +1 -1
  473. package/dist/components/ui/progress.js +1 -1
  474. package/dist/components/ui/progress.js.map +1 -1
  475. package/dist/components/ui/questionnaire.js +4 -4
  476. package/dist/components/ui/questionnaire.js.map +1 -1
  477. package/dist/components/ui/radio-group.d.ts.map +1 -1
  478. package/dist/components/ui/radio-group.js +2 -2
  479. package/dist/components/ui/radio-group.js.map +1 -1
  480. package/dist/components/ui/resizable.d.ts.map +1 -1
  481. package/dist/components/ui/resizable.js +1 -1
  482. package/dist/components/ui/resizable.js.map +1 -1
  483. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  484. package/dist/components/ui/scroll-area.js +1 -1
  485. package/dist/components/ui/scroll-area.js.map +1 -1
  486. package/dist/components/ui/select.d.ts.map +1 -1
  487. package/dist/components/ui/select.js +2 -2
  488. package/dist/components/ui/select.js.map +1 -1
  489. package/dist/components/ui/separator.d.ts.map +1 -1
  490. package/dist/components/ui/separator.js +1 -1
  491. package/dist/components/ui/separator.js.map +1 -1
  492. package/dist/components/ui/sheet.js +2 -2
  493. package/dist/components/ui/sheet.js.map +1 -1
  494. package/dist/components/ui/sidebar.d.ts +1 -1
  495. package/dist/components/ui/sidebar.js +2 -2
  496. package/dist/components/ui/sidebar.js.map +1 -1
  497. package/dist/components/ui/skeleton.js +1 -1
  498. package/dist/components/ui/skeleton.js.map +1 -1
  499. package/dist/components/ui/slider.d.ts.map +1 -1
  500. package/dist/components/ui/slider.js +1 -1
  501. package/dist/components/ui/slider.js.map +1 -1
  502. package/dist/components/ui/spinner.d.ts.map +1 -1
  503. package/dist/components/ui/spinner.js +2 -2
  504. package/dist/components/ui/spinner.js.map +1 -1
  505. package/dist/components/ui/switch.d.ts.map +1 -1
  506. package/dist/components/ui/switch.js +2 -2
  507. package/dist/components/ui/switch.js.map +1 -1
  508. package/dist/components/ui/table.d.ts.map +1 -1
  509. package/dist/components/ui/table.js +1 -1
  510. package/dist/components/ui/table.js.map +1 -1
  511. package/dist/components/ui/tabs.d.ts.map +1 -1
  512. package/dist/components/ui/tabs.js +2 -2
  513. package/dist/components/ui/tabs.js.map +1 -1
  514. package/dist/components/ui/textarea.d.ts.map +1 -1
  515. package/dist/components/ui/textarea.js +1 -1
  516. package/dist/components/ui/textarea.js.map +1 -1
  517. package/dist/components/ui/toast.js +3 -3
  518. package/dist/components/ui/toast.js.map +1 -1
  519. package/dist/components/ui/toggle-group.js +1 -1
  520. package/dist/components/ui/toggle-group.js.map +1 -1
  521. package/dist/components/ui/toggle.d.ts +1 -1
  522. package/dist/components/ui/toggle.d.ts.map +1 -1
  523. package/dist/components/ui/toggle.js +2 -2
  524. package/dist/components/ui/toggle.js.map +1 -1
  525. package/dist/components/ui/tooltip.d.ts.map +1 -1
  526. package/dist/components/ui/tooltip.js +1 -1
  527. package/dist/components/ui/tooltip.js.map +1 -1
  528. package/dist/{copy-menu-TIKvPaAZ.js → copy-menu-C5GaT4Z-.js} +2 -2
  529. package/dist/{copy-menu-TIKvPaAZ.js.map → copy-menu-C5GaT4Z-.js.map} +1 -1
  530. package/package.json +5 -3
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { type HoverGesture, useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\n// `onPointerEnter`/`onPointerLeave` rather than the mouse pair: a tap fires\n// compatibility mouseenter/mouseleave that carry no pointerType at all, and\n// they are what made the panel flicker open and shut under a finger. The\n// gesture pairs the two, so the panel a pen tap opened is not closed again by\n// the boundary event that ends the same tap.\nfunction makeHoverHandlers(hover: HoverGesture, enter: () => void, leave: () => void) {\n return {\n onPointerEnter: (event: React.PointerEvent) => {\n if (hover.enter(event)) enter();\n },\n onPointerLeave: (event: React.PointerEvent) => {\n if (hover.leave(event)) leave();\n },\n };\n}\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\nfunction roundedRectPath(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const n = (value: number) => value.toFixed(3);\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const arc = `A${n(radius)} ${n(radius)} 0 0 1`;\n\n // A zero radius makes every arc degenerate to a line, so this also draws\n // plain rectangles.\n return (\n `M${n(x1 + radius)} ${n(y1)}` +\n `H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}` +\n `V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}` +\n `H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}` +\n `V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`\n );\n}\n\n// The goo layer is portalled above the page, so its copy of the trigger pill\n// would cover the real trigger's label and focus ring. Punching the trigger\n// back out keeps the real one visible and clips the blur to the layer box.\n// This is a clip path rather than a CSS mask on purpose: WebKit silently\n// ignores `mask: url(#id)` pointing at an SVG <mask> element, which left the\n// label hidden behind the goo in Safari.\nfunction triggerCutout(geo: Geo) {\n const layer = { x: 0, y: 0, w: geo.layerW, h: geo.layerH, r: 0 };\n return `path(evenodd, \"${roundedRectPath(layer)} ${roundedRectPath(geo.trigger)}\")`;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const rootHover = useHoverGesture();\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: Escape hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (inPanel) triggerRef.current?.focus();\n }, [setOpen]);\n // The panel is portalled, so both trees participate in outside detection.\n const ignoreContent = useCallback(\n (target: Element) => Boolean(contentRef.current?.contains(target)),\n [],\n );\n // A hover trigger opens on tap as well now, so it needs the same outside\n // dismissal the click trigger always had. The gesture passes through to\n // whatever it landed on, which is the light-dismiss bargain the platform's\n // own popovers strike.\n useDismiss(open, close, rootRef, { ignore: ignoreContent });\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? makeHoverHandlers(rootHover, openHover, scheduleClose) : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n // What the last gesture on the trigger was, and whether the panel was\n // already open when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n <E extends { defaultPrevented?: boolean }>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler(event);\n };\n\n // Observation, not action. `compose` steps aside for a child that handled\n // the event itself, which is right for anything that *does* something — but\n // a child preventing the pointerdown default (to hold focus, say) has not\n // said the gesture didn't happen. Skipping the record there left the panel\n // reading whatever the gesture before it had put in.\n const observe =\n <E,>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n handler(event);\n };\n\n // The hover trigger keeps its hover path and *adds* a tap one, rather than\n // swapping mode on a device that reports a touchscreen: a touchscreen laptop\n // has both inputs and the mouse must keep working. A hovering pointer has\n // already opened the panel on its way in, and a keyboard press arrives with\n // no pointerdown behind it, so only a tap toggles here. Which panel state\n // the tap acts on is read from the gesture's start, because a browser that\n // focuses the trigger on contact would otherwise open it mid-gesture and let\n // the click close it again.\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n onPointerDown: observe<React.PointerEvent>(\"onPointerDown\", (event) =>\n tap.start(event, ctx.open),\n ),\n onPointerCancel: observe(\"onPointerCancel\", tap.drop),\n onKeyDown: observe(\"onKeyDown\", tap.drop),\n onClick: compose(\"onClick\", () => {\n const gesture = tap.take();\n if (!gesture || gesture.pointerType === \"mouse\") return;\n ctx.setOpen(!gesture.state);\n }),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const panelHover = useHoverGesture();\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n const hoverHandlers =\n triggerMode === \"hover\" ? makeHoverHandlers(panelHover, openHover, scheduleClose) : {};\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n clipPath: triggerCutout(geo),\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;AAuCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAOrB,SAAS,kBAAkB,OAAqB,OAAmB,OAAmB;CACpF,OAAO;EACL,iBAAiB,UAA8B;GAC7C,IAAI,MAAM,MAAM,KAAK,GAAG,MAAM;EAChC;EACA,iBAAiB,UAA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KACL,WAAU;KACV,OAAO,EACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK,EACtD;IACD,CAAA,CACE;;GAIL,oBAAC,OAAD;IACE,WAAU;IACV,OAAO;KACL,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;IACd;IAEA,UAAA,oBAAC,OAAD;KACE,KAAK;KACL,OAAO,CAAC;KACR,WAAU;KACV,OAAO;MACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK;MACpD,eAAe,OAAO,SAAS;KACjC;KAEA,UAAA,oBAAC,OAAD;MACE,KAAK;MACL,IAAI;MACJ,MAAK;MACL,GAAI;MACJ,OAAO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\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 {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { type HoverGesture, useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\n// `onPointerEnter`/`onPointerLeave` rather than the mouse pair: a tap fires\n// compatibility mouseenter/mouseleave that carry no pointerType at all, and\n// they are what made the panel flicker open and shut under a finger. The\n// gesture pairs the two, so the panel a pen tap opened is not closed again by\n// the boundary event that ends the same tap.\nfunction makeHoverHandlers(hover: HoverGesture, enter: () => void, leave: () => void) {\n return {\n onPointerEnter: (event: React.PointerEvent) => {\n if (hover.enter(event)) enter();\n },\n onPointerLeave: (event: React.PointerEvent) => {\n if (hover.leave(event)) leave();\n },\n };\n}\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\nfunction roundedRectPath(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const n = (value: number) => value.toFixed(3);\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const arc = `A${n(radius)} ${n(radius)} 0 0 1`;\n\n // A zero radius makes every arc degenerate to a line, so this also draws\n // plain rectangles.\n return (\n `M${n(x1 + radius)} ${n(y1)}` +\n `H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}` +\n `V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}` +\n `H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}` +\n `V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`\n );\n}\n\n// The goo layer is portalled above the page, so its copy of the trigger pill\n// would cover the real trigger's label and focus ring. Punching the trigger\n// back out keeps the real one visible and clips the blur to the layer box.\n// This is a clip path rather than a CSS mask on purpose: WebKit silently\n// ignores `mask: url(#id)` pointing at an SVG <mask> element, which left the\n// label hidden behind the goo in Safari.\nfunction triggerCutout(geo: Geo) {\n const layer = { x: 0, y: 0, w: geo.layerW, h: geo.layerH, r: 0 };\n return `path(evenodd, \"${roundedRectPath(layer)} ${roundedRectPath(geo.trigger)}\")`;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const rootHover = useHoverGesture();\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: Escape hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (inPanel) triggerRef.current?.focus();\n }, [setOpen]);\n // The panel is portalled, so both trees participate in outside detection.\n const ignoreContent = useCallback(\n (target: Element) => Boolean(contentRef.current?.contains(target)),\n [],\n );\n // A hover trigger opens on tap as well now, so it needs the same outside\n // dismissal the click trigger always had. The gesture passes through to\n // whatever it landed on, which is the light-dismiss bargain the platform's\n // own popovers strike.\n useDismiss(open, close, rootRef, { ignore: ignoreContent });\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? makeHoverHandlers(rootHover, openHover, scheduleClose) : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n // What the last gesture on the trigger was, and whether the panel was\n // already open when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n <E extends { defaultPrevented?: boolean }>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler(event);\n };\n\n // Observation, not action. `compose` steps aside for a child that handled\n // the event itself, which is right for anything that *does* something — but\n // a child preventing the pointerdown default (to hold focus, say) has not\n // said the gesture didn't happen. Skipping the record there left the panel\n // reading whatever the gesture before it had put in.\n const observe =\n <E,>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n handler(event);\n };\n\n // The hover trigger keeps its hover path and *adds* a tap one, rather than\n // swapping mode on a device that reports a touchscreen: a touchscreen laptop\n // has both inputs and the mouse must keep working. A hovering pointer has\n // already opened the panel on its way in, and a keyboard press arrives with\n // no pointerdown behind it, so only a tap toggles here. Which panel state\n // the tap acts on is read from the gesture's start, because a browser that\n // focuses the trigger on contact would otherwise open it mid-gesture and let\n // the click close it again.\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n onPointerDown: observe<React.PointerEvent>(\"onPointerDown\", (event) =>\n tap.start(event, ctx.open),\n ),\n onPointerCancel: observe(\"onPointerCancel\", tap.drop),\n onKeyDown: observe(\"onKeyDown\", tap.drop),\n onClick: compose(\"onClick\", () => {\n const gesture = tap.take();\n if (!gesture || gesture.pointerType === \"mouse\") return;\n ctx.setOpen(!gesture.state);\n }),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const panelHover = useHoverGesture();\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n const hoverHandlers =\n triggerMode === \"hover\" ? makeHoverHandlers(panelHover, openHover, scheduleClose) : {};\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n clipPath: triggerCutout(geo),\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;AAuCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAOrB,SAAS,kBAAkB,OAAqB,OAAmB,OAAmB;CACpF,OAAO;EACL,iBAAiB,UAA8B;GAC7C,IAAI,MAAM,MAAM,KAAK,G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AAA,GACD,oBAAC,OAAD;KACE,KAAK;KACL,WAAU;KACV,OAAO,EACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK,EACtD;IACD,CAAA,CACE;;GAIL,oBAAC,OAAD;IACE,WAAU;IACV,OAAO;KACL,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;IACd;IAEA,UAAA,oBAAC,OAAD;KACE,KAAK;KACL,OAAO,CAAC;KACR,WAAU;KACV,OAAO;MACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK;MACpD,eAAe,OAAO,SAAS;KACjC;KAEA,UAAA,oBAAC,OAAD;MACE,KAAK;MACL,IAAI;MACJ,MAAK;MACL,GAAI;MACJ,OAAO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
@@ -4,7 +4,7 @@ import { useHoverGesture } from "../../hooks/use-hover-gesture.js";
4
4
  import { useTapGesture } from "../../hooks/use-tap-gesture.js";
5
5
  import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
6
6
  import { useCallback, useId, useRef, useState } from "react";
7
- import { cn } from "@kumix/utils";
7
+ import { cn } from "cn";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
10
10
  //#region src/components/motion/preview-rail.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"preview-rail.js","names":[],"sources":["../../../src/components/motion/preview-rail.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, motion, 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\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface PreviewRailItem {\n id: string;\n label: string;\n ariaLabel?: string;\n description?: ReactNode;\n href?: string;\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n rel?: string;\n}\n\nexport interface PreviewRailProps {\n items: PreviewRailItem[];\n label?: string;\n orientation?: \"vertical\" | \"horizontal\";\n activeId?: string;\n defaultActiveId?: string;\n onActiveChange?: (id: string) => void;\n onItemSelect?: (item: PreviewRailItem) => void;\n renderPreview?: (item: PreviewRailItem) => ReactNode;\n showPreview?: boolean;\n previewSide?: \"before\" | \"after\";\n highlightActive?: boolean;\n itemSize?: number;\n children?: ReactNode;\n className?: string;\n railClassName?: string;\n previewContainerClassName?: string;\n previewClassName?: string;\n}\n\nfunction DefaultPreview({ item }: { item: PreviewRailItem }) {\n return (\n <div\n data-slot=\"preview-rail-card\"\n className=\"rounded-2xl border border-border bg-card p-4 shadow-sm\"\n >\n <p data-slot=\"preview-rail-title\" className=\"font-medium text-card-foreground\">\n {item.label}\n </p>\n {item.description ? (\n <div\n data-slot=\"preview-rail-description\"\n className=\"mt-1 text-muted-foreground text-sm leading-6\"\n >\n {item.description}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function PreviewRail({\n items,\n label = \"Section navigation\",\n orientation = \"vertical\",\n activeId,\n defaultActiveId,\n onActiveChange,\n onItemSelect,\n renderPreview,\n showPreview = true,\n previewSide = \"after\",\n highlightActive = false,\n itemSize = 24,\n children,\n className,\n railClassName,\n previewContainerClassName,\n previewClassName,\n}: PreviewRailProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const rootRef = useRef<HTMLDivElement>(null);\n const [internalActiveId, setInternalActiveId] = useState(defaultActiveId ?? items[0]?.id ?? \"\");\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // A finger cannot hover, so a tap lights the tick instead. Kept apart from\n // the hovered one: they end in different ways, and a stray mouse move must\n // not clear a tick the keyboard or a tap chose.\n const [pinnedId, setPinnedId] = useState<string | null>(null);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n // A click carries no pointerType, so the pointerdown before it is what says\n // whether the activation was a tap. Keyboard activation has none at all.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearPinned = useCallback(() => setPinnedId(null), []);\n\n // The next tap outside the rail stands in for the pointer leaving it. The\n // card is a preview, so that tap passes through to whatever it landed on.\n useDismiss(pinnedId !== null, clearPinned, rootRef);\n\n const requestedActiveId = activeId ?? internalActiveId;\n const selectedId = items.some((item) => item.id === requestedActiveId)\n ? requestedActiveId\n : (items[0]?.id ?? \"\");\n const displayedId = hoveredId ?? pinnedId ?? focusedId ?? \"\";\n const highlightedId = displayedId || (highlightActive ? selectedId : \"\");\n const displayedIndex = items.findIndex((item) => item.id === highlightedId);\n const rowTemplate = items.length ? `repeat(${items.length}, ${itemSize}px)` : undefined;\n const isHorizontal = orientation === \"horizontal\";\n\n const selectItem = (id: string) => {\n if (activeId === undefined) setInternalActiveId(id);\n onActiveChange?.(id);\n };\n\n return (\n <motion.div\n layoutRoot\n ref={rootRef}\n onBlur={(event) => {\n // Both tick sources leave with the focus: a tap does not always land\n // focus, but when it does, tabbing away must not strand the card.\n if (!event.currentTarget.contains(event.relatedTarget)) {\n setFocusedId(null);\n setPinnedId(null);\n }\n }}\n className={cn(\n \"relative isolate flex w-full overflow-visible\",\n isHorizontal ? \"min-h-64 flex-col items-center justify-center\" : \"min-h-80\",\n className,\n )}\n >\n <nav\n aria-label={label}\n onPointerLeave={(event) => {\n // A touch pointer leaves on lift, which would clear the tick the tap\n // just chose — that one is cleared by the outside tap instead.\n if (hover.leave(event)) setHoveredId(null);\n }}\n style={\n isHorizontal ? { gridTemplateColumns: rowTemplate } : { gridTemplateRows: rowTemplate }\n }\n className={cn(\n \"relative z-10 grid shrink-0\",\n isHorizontal ? \"h-12 w-fit max-w-full justify-center self-center\" : \"w-12 content-center\",\n railClassName,\n )}\n >\n {items.map((item, index) => {\n const selected = item.id === selectedId;\n const highlighted = item.id === highlightedId;\n const distance =\n displayedIndex < 0 ? Number.POSITIVE_INFINITY : Math.abs(index - displayedIndex);\n const scale = highlighted ? 1 : distance === 1 ? 0.68 : distance === 2 ? 0.44 : 0.25;\n\n const itemContent = (\n <>\n <motion.span\n data-slot=\"preview-rail-tick\"\n aria-hidden=\"true\"\n animate={isHorizontal ? { scaleY: scale } : { scaleX: scale }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"block bg-current\",\n isHorizontal ? \"h-12 w-0.5 origin-bottom\" : \"h-0.5 w-12 origin-left\",\n highlighted ? \"text-foreground\" : undefined,\n )}\n />\n </>\n );\n\n const sharedClassName = cn(\n \"relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n isHorizontal ? \"h-12 w-6 items-end justify-center\" : \"h-6 w-12 items-center\",\n );\n const sharedStyle = isHorizontal ? { width: itemSize } : { height: itemSize };\n const handlePointerEnter = (event: PointerEvent<HTMLElement>) => {\n if (hover.enter(event)) setHoveredId(item.id);\n };\n const handlePointerDown = (event: PointerEvent<HTMLElement>) => {\n tap.start(event, pinnedId === item.id);\n setFocusedId(null);\n };\n // A gesture the platform takes away sends no click, and a key press\n // starts an activation that never had a pointer behind it: either\n // one leaves a record the next click would read as a tap of its own.\n const dropGesture = () => tap.drop();\n const handleFocus = (currentTarget: HTMLElement) => {\n if (currentTarget.matches(\":focus-visible\")) {\n setFocusedId(item.id);\n }\n };\n const handleSelect = (event: MouseEvent<HTMLElement>) => {\n const gesture = tap.take();\n const tapped = gesture !== null && gesture.pointerType !== \"mouse\";\n\n if (tapped) {\n // A link would otherwise show its preview and leave the page in\n // the same tap, so the card is never read: the first tap lights\n // the tick, the second follows the link.\n if (item.href && !gesture.state) {\n event.preventDefault();\n setPinnedId(item.id);\n return;\n }\n setPinnedId(item.id);\n }\n\n selectItem(item.id);\n onItemSelect?.(item);\n };\n\n return item.href ? (\n <a\n key={item.id}\n data-slot=\"preview-rail-item\"\n href={item.href}\n target={item.target}\n rel={item.rel ?? (item.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n aria-label={item.ariaLabel ?? item.label}\n aria-current={selected ? \"page\" : undefined}\n onPointerEnter={handlePointerEnter}\n onPointerDown={handlePointerDown}\n onPointerCancel={dropGesture}\n onKeyDown={dropGesture}\n onFocus={(event) => handleFocus(event.currentTarget)}\n onClick={handleSelect}\n style={sharedStyle}\n className={sharedClassName}\n >\n {itemContent}\n </a>\n ) : (\n <button\n key={item.id}\n data-slot=\"preview-rail-item\"\n type=\"button\"\n aria-label={item.ariaLabel ?? item.label}\n aria-current={selected ? \"location\" : undefined}\n onPointerEnter={handlePointerEnter}\n onPointerDown={handlePointerDown}\n onPointerCancel={dropGesture}\n onKeyDown={dropGesture}\n onFocus={(event) => handleFocus(event.currentTarget)}\n onClick={handleSelect}\n style={sharedStyle}\n className={sharedClassName}\n >\n {itemContent}\n </button>\n );\n })}\n </nav>\n\n {showPreview ? (\n <div\n aria-hidden=\"true\"\n style={\n isHorizontal ? { gridTemplateColumns: rowTemplate } : { gridTemplateRows: rowTemplate }\n }\n className={cn(\n \"pointer-events-none absolute z-50 grid\",\n isHorizontal\n ? \"top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center\"\n : previewSide === \"before\"\n ? \"inset-y-0 right-16 left-4 content-center\"\n : \"inset-y-0 right-4 left-16 content-center\",\n previewContainerClassName,\n )}\n >\n {items.map((item) => (\n <div\n key={item.id}\n style={isHorizontal ? { width: itemSize } : { height: itemSize }}\n className={cn(\n \"relative flex items-center\",\n isHorizontal ? \"justify-center\" : undefined,\n )}\n >\n {item.id === displayedId ? (\n <div\n className={cn(\n isHorizontal\n ? \"absolute bottom-12 left-1/2 w-72 -translate-x-1/2\"\n : cn(\"w-full max-w-sm\", previewSide === \"before\" && \"ml-auto\"),\n previewClassName,\n )}\n >\n <motion.div\n layoutId={`preview-rail-card-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n >\n <AnimatePresence mode=\"wait\" initial={false}>\n <motion.div\n key={item.id}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 4, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }\n }\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n y: -2,\n filter: \"blur(4px)\",\n transition: {\n duration: 0.12,\n ease: EASE_OUT,\n },\n }\n }\n transition={{\n duration: reduce ? 0 : 0.18,\n ease: EASE_OUT,\n }}\n >\n {renderPreview ? renderPreview(item) : <DefaultPreview item={item} />}\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </div>\n ) : null}\n </div>\n ))}\n </div>\n ) : null}\n\n {children ? <div className=\"min-h-0 min-w-0 flex-1\">{children}</div> : null}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;;;;AAiDA,SAAS,eAAe,EAAE,QAAmC;CAC3D,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA,CAIE,oBAAC,KAAD;GAAG,aAAU;GAAqB,WAAU;GACzC,UAAA,KAAK;EACL,CAAA,GACF,KAAK,cACJ,oBAAC,OAAD;GACE,aAAU;GACV,WAAU;GAET,UAAA,KAAK;EACH,CAAA,IACH,IACD;;AAET;AAEA,SAAgB,YAAY,EAC1B,OACA,QAAQ,sBACR,cAAc,YACd,UACA,iBACA,gBACA,cACA,eACA,cAAc,MACd,cAAc,SACd,kBAAkB,OAClB,WAAW,IACX,UACA,WACA,eACA,2BACA,oBACmB;CACnB,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS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,UAAU,EAAE,IAAI;OAEvC,UAAA,oBAAC,iBAAD;QAAiB,MAAK;QAAO,SAAS;QACpC,UAAA,oBAAC,OAAO,KAAR;SAEE,SACE,SAAS,EAAE,SAAS,EAAE,IAAI;UAAE,SAAS;UAAG,GAAG;UAAG,QAAQ;SAAY;SAEpE,SACE,SAAS,EAAE,SAAS,EAAE,IAAI;UAAE,SAAS;UAAG,GAAG;UAAG,QAAQ;SAAY;SAEpE,MACE,SACI,EAAE,SAAS,EAAE,IACb;UACE,SAAS;UACT,GAAG;UACH,QAAQ;UACR,YAAY;WACV,UAAU;WACV,MAAM;UACR;SACF;SAEN,YAAY;UACV,UAAU,SAAS,IAAI;UACvB,MAAM;SACR;SAEC,UAAA,gBAAgB,cAAc,IAAI,IAAI,oBAAC,gBAAD,EAAsB,KAAO,CAAA;QAC1D,GA1BL,KAAK,EA0BA;OACG,CAAA;MACP,CAAA;KACT,CAAA,IACH;IACD,GArDE,KAAK,EAqDP,CACN;GACE,CAAA,IACH;GAEH,WAAW,oBAAC,OAAD;IAAK,WAAU;IAA0B;GAAc,CAAA,IAAI;EAC7D;;AAEhB"}
1
+ {"version":3,"file":"preview-rail.js","names":[],"sources":["../../../src/components/motion/preview-rail.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { AnimatePresence, motion, 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\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface PreviewRailItem {\n id: string;\n label: string;\n ariaLabel?: string;\n description?: ReactNode;\n href?: string;\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n rel?: string;\n}\n\nexport interface PreviewRailProps {\n items: PreviewRailItem[];\n label?: string;\n orientation?: \"vertical\" | \"horizontal\";\n activeId?: string;\n defaultActiveId?: string;\n onActiveChange?: (id: string) => void;\n onItemSelect?: (item: PreviewRailItem) => void;\n renderPreview?: (item: PreviewRailItem) => ReactNode;\n showPreview?: boolean;\n previewSide?: \"before\" | \"after\";\n highlightActive?: boolean;\n itemSize?: number;\n children?: ReactNode;\n className?: string;\n railClassName?: string;\n previewContainerClassName?: string;\n previewClassName?: string;\n}\n\nfunction DefaultPreview({ item }: { item: PreviewRailItem }) {\n return (\n <div\n data-slot=\"preview-rail-card\"\n className=\"rounded-2xl border border-border bg-card p-4 shadow-sm\"\n >\n <p data-slot=\"preview-rail-title\" className=\"font-medium text-card-foreground\">\n {item.label}\n </p>\n {item.description ? (\n <div\n data-slot=\"preview-rail-description\"\n className=\"mt-1 text-muted-foreground text-sm leading-6\"\n >\n {item.description}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function PreviewRail({\n items,\n label = \"Section navigation\",\n orientation = \"vertical\",\n activeId,\n defaultActiveId,\n onActiveChange,\n onItemSelect,\n renderPreview,\n showPreview = true,\n previewSide = \"after\",\n highlightActive = false,\n itemSize = 24,\n children,\n className,\n railClassName,\n previewContainerClassName,\n previewClassName,\n}: PreviewRailProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const rootRef = useRef<HTMLDivElement>(null);\n const [internalActiveId, setInternalActiveId] = useState(defaultActiveId ?? items[0]?.id ?? \"\");\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // A finger cannot hover, so a tap lights the tick instead. Kept apart from\n // the hovered one: they end in different ways, and a stray mouse move must\n // not clear a tick the keyboard or a tap chose.\n const [pinnedId, setPinnedId] = useState<string | null>(null);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n // A click carries no pointerType, so the pointerdown before it is what says\n // whether the activation was a tap. Keyboard activation has none at all.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearPinned = useCallback(() => setPinnedId(null), []);\n\n // The next tap outside the rail stands in for the pointer leaving it. The\n // card is a preview, so that tap passes through to whatever it landed on.\n useDismiss(pinnedId !== null, clearPinned, rootRef);\n\n const requestedActiveId = activeId ?? internalActiveId;\n const selectedId = items.some((item) => item.id === requestedActiveId)\n ? requestedActiveId\n : (items[0]?.id ?? \"\");\n const displayedId = hoveredId ?? pinnedId ?? focusedId ?? \"\";\n const highlightedId = displayedId || (highlightActive ? selectedId : \"\");\n const displayedIndex = items.findIndex((item) => item.id === highlightedId);\n const rowTemplate = items.length ? `repeat(${items.length}, ${itemSize}px)` : undefined;\n const isHorizontal = orientation === \"horizontal\";\n\n const selectItem = (id: string) => {\n if (activeId === undefined) setInternalActiveId(id);\n onActiveChange?.(id);\n };\n\n return (\n <motion.div\n layoutRoot\n ref={rootRef}\n onBlur={(event) => {\n // Both tick sources leave with the focus: a tap does not always land\n // focus, but when it does, tabbing away must not strand the card.\n if (!event.currentTarget.contains(event.relatedTarget)) {\n setFocusedId(null);\n setPinnedId(null);\n }\n }}\n className={cn(\n \"relative isolate flex w-full overflow-visible\",\n isHorizontal ? \"min-h-64 flex-col items-center justify-center\" : \"min-h-80\",\n className,\n )}\n >\n <nav\n aria-label={label}\n onPointerLeave={(event) => {\n // A touch pointer leaves on lift, which would clear the tick the tap\n // just chose — that one is cleared by the outside tap instead.\n if (hover.leave(event)) setHoveredId(null);\n }}\n style={\n isHorizontal ? { gridTemplateColumns: rowTemplate } : { gridTemplateRows: rowTemplate }\n }\n className={cn(\n \"relative z-10 grid shrink-0\",\n isHorizontal ? \"h-12 w-fit max-w-full justify-center self-center\" : \"w-12 content-center\",\n railClassName,\n )}\n >\n {items.map((item, index) => {\n const selected = item.id === selectedId;\n const highlighted = item.id === highlightedId;\n const distance =\n displayedIndex < 0 ? Number.POSITIVE_INFINITY : Math.abs(index - displayedIndex);\n const scale = highlighted ? 1 : distance === 1 ? 0.68 : distance === 2 ? 0.44 : 0.25;\n\n const itemContent = (\n <>\n <motion.span\n data-slot=\"preview-rail-tick\"\n aria-hidden=\"true\"\n animate={isHorizontal ? { scaleY: scale } : { scaleX: scale }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"block bg-current\",\n isHorizontal ? \"h-12 w-0.5 origin-bottom\" : \"h-0.5 w-12 origin-left\",\n highlighted ? \"text-foreground\" : undefined,\n )}\n />\n </>\n );\n\n const sharedClassName = cn(\n \"relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n isHorizontal ? \"h-12 w-6 items-end justify-center\" : \"h-6 w-12 items-center\",\n );\n const sharedStyle = isHorizontal ? { width: itemSize } : { height: itemSize };\n const handlePointerEnter = (event: PointerEvent<HTMLElement>) => {\n if (hover.enter(event)) setHoveredId(item.id);\n };\n const handlePointerDown = (event: PointerEvent<HTMLElement>) => {\n tap.start(event, pinnedId === item.id);\n setFocusedId(null);\n };\n // A gesture the platform takes away sends no click, and a key press\n // starts an activation that never had a pointer behind it: either\n // one leaves a record the next click would read as a tap of its own.\n const dropGesture = () => tap.drop();\n const handleFocus = (currentTarget: HTMLElement) => {\n if (currentTarget.matches(\":focus-visible\")) {\n setFocusedId(item.id);\n }\n };\n const handleSelect = (event: MouseEvent<HTMLElement>) => {\n const gesture = tap.take();\n const tapped = gesture !== null && gesture.pointerType !== \"mouse\";\n\n if (tapped) {\n // A link would otherwise show its preview and leave the page in\n // the same tap, so the card is never read: the first tap lights\n // the tick, the second follows the link.\n if (item.href && !gesture.state) {\n event.preventDefault();\n setPinnedId(item.id);\n return;\n }\n setPinnedId(item.id);\n }\n\n selectItem(item.id);\n onItemSelect?.(item);\n };\n\n return item.href ? (\n <a\n key={item.id}\n data-slot=\"preview-rail-item\"\n href={item.href}\n target={item.target}\n rel={item.rel ?? (item.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n aria-label={item.ariaLabel ?? item.label}\n aria-current={selected ? \"page\" : undefined}\n onPointerEnter={handlePointerEnter}\n onPointerDown={handlePointerDown}\n onPointerCancel={dropGesture}\n onKeyDown={dropGesture}\n onFocus={(event) => handleFocus(event.currentTarget)}\n onClick={handleSelect}\n style={sharedStyle}\n className={sharedClassName}\n >\n {itemContent}\n </a>\n ) : (\n <button\n key={item.id}\n data-slot=\"preview-rail-item\"\n type=\"button\"\n aria-label={item.ariaLabel ?? item.label}\n aria-current={selected ? \"location\" : undefined}\n onPointerEnter={handlePointerEnter}\n onPointerDown={handlePointerDown}\n onPointerCancel={dropGesture}\n onKeyDown={dropGesture}\n onFocus={(event) => handleFocus(event.currentTarget)}\n onClick={handleSelect}\n style={sharedStyle}\n className={sharedClassName}\n >\n {itemContent}\n </button>\n );\n })}\n </nav>\n\n {showPreview ? (\n <div\n aria-hidden=\"true\"\n style={\n isHorizontal ? { gridTemplateColumns: rowTemplate } : { gridTemplateRows: rowTemplate }\n }\n className={cn(\n \"pointer-events-none absolute z-50 grid\",\n isHorizontal\n ? \"top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center\"\n : previewSide === \"before\"\n ? \"inset-y-0 right-16 left-4 content-center\"\n : \"inset-y-0 right-4 left-16 content-center\",\n previewContainerClassName,\n )}\n >\n {items.map((item) => (\n <div\n key={item.id}\n style={isHorizontal ? { width: itemSize } : { height: itemSize }}\n className={cn(\n \"relative flex items-center\",\n isHorizontal ? \"justify-center\" : undefined,\n )}\n >\n {item.id === displayedId ? (\n <div\n className={cn(\n isHorizontal\n ? \"absolute bottom-12 left-1/2 w-72 -translate-x-1/2\"\n : cn(\"w-full max-w-sm\", previewSide === \"before\" && \"ml-auto\"),\n previewClassName,\n )}\n >\n <motion.div\n layoutId={`preview-rail-card-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n >\n <AnimatePresence mode=\"wait\" initial={false}>\n <motion.div\n key={item.id}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 4, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }\n }\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n y: -2,\n filter: \"blur(4px)\",\n transition: {\n duration: 0.12,\n ease: EASE_OUT,\n },\n }\n }\n transition={{\n duration: reduce ? 0 : 0.18,\n ease: EASE_OUT,\n }}\n >\n {renderPreview ? renderPreview(item) : <DefaultPreview item={item} />}\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </div>\n ) : null}\n </div>\n ))}\n </div>\n ) : null}\n\n {children ? <div className=\"min-h-0 min-w-0 flex-1\">{children}</div> : null}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;;;;AAiDA,SAAS,eAAe,EAAE,QAAmC;CAC3D,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA,CAIE,oBAAC,KAAD;GAAG,aAAU;GAAqB,WAAU;GACzC,UAAA,KAAK;EACL,CAAA,GACF,KAAK,cACJ,oBAAC,OAAD;GACE,aAAU;GACV,WAAU;GAET,UAAA,KAAK;EACH,CAAA,IACH,IACD;;AAET;AAEA,SAAgB,YAAY,EAC1B,OACA,QAAQ,sBACR,cAAc,YACd,UACA,iBACA,gBACA,cACA,eACA,cAAc,MACd,cAAc,SACd,kBAAkB,OAClB,WAAW,IACX,UACA,WACA,eACA,2BACA,oBACmB;CACnB,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,MAAM,EAAE,EAAE,MAAM,EAAE;CAC9F,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAI9D,MAAM,CAAC,UAAU,eAAe,SAAwB,IAAI;CAC5D,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAG9D,MAAM,MAAM,cAAuB;CACnC,MAAM,QAAQ,gBAAgB;CAE9B,MAAM,cAAc,kBAAkB,YAAY,IAAI,GAA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WACV,UAAU;WACV,MAAM;UACR;SACF;SAEN,YAAY;UACV,UAAU,SAAS,IAAI;UACvB,MAAM;SACR;SAEC,UAAA,gBAAgB,cAAc,IAAI,IAAI,oBAAC,gBAAD,EAAsB,KAAO,CAAA;QAC1D,GA1BL,KAAK,EA0BA;OACG,CAAA;MACP,CAAA;KACT,CAAA,IACH;IACD,GArDE,KAAK,EAqDP,CACN;GACE,CAAA,IACH;GAEH,WAAW,oBAAC,OAAD;IAAK,WAAU;IAA0B;GAAc,CAAA,IAAI;EAC7D;;AAEhB"}
@@ -2,10 +2,10 @@
2
2
  import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
3
  import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
4
4
  import { useCallback, useEffect, useId, useRef, useState } from "react";
5
- import { cn } from "@kumix/utils";
6
- import { X } from "lucide-react";
5
+ import { cn } from "cn";
7
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
7
  import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
8
+ import { X } from "lucide-react";
9
9
  import { createPortal } from "react-dom";
10
10
  //#region src/components/motion/project-folder.tsx
11
11
  const MAX_PREVIEWS = 5;
@@ -1 +1 @@
1
- {"version":3,"file":"project-folder.js","names":[],"sources":["../../../src/components/motion/project-folder.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport {\n AnimatePresence,\n LayoutGroup,\n motion,\n type Transition,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport type ProjectFolderPreview = {\n id: string;\n content: ReactNode;\n};\n\nexport interface ProjectFolderProps {\n title: string;\n description?: string;\n previews?: ProjectFolderPreview[];\n count?: number;\n itemLabel?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n className?: string;\n}\n\nconst MAX_PREVIEWS = 5;\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nfunction getPreviewTransform(index: number, count: number) {\n const offset = index - (count - 1) / 2;\n const distance = Math.abs(offset);\n const centerLift = Math.max(0, 2 - distance) * 8;\n\n return {\n x: offset * 44,\n y: 8 - centerLift,\n rotate: offset * 6,\n scale: distance === 0 ? 1.04 : distance === 1 ? 0.95 : 0.88,\n opacity: distance === 0 ? 1 : distance === 1 ? 0.78 : 0.58,\n zIndex: 10 - distance,\n };\n}\n\nexport function ProjectFolder({\n title,\n description = \"Updated recently\",\n previews = [],\n count = previews.length,\n itemLabel = \"file\",\n open,\n defaultOpen = false,\n onOpenChange,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onClick,\n disabled = false,\n ariaLabel,\n className,\n}: ProjectFolderProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const layoutGroupId = useId();\n const dialogTitleId = `${layoutGroupId}-title`;\n const hoveredRef = useRef(false);\n const focusedRef = useRef(false);\n const restoringFocusRef = useRef(false);\n const folderButtonRef = useRef<HTMLButtonElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n const [mounted, setMounted] = useState(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const [isClosing, setIsClosing] = useState(false);\n const openControlled = open !== undefined;\n const expandedControlled = expanded !== undefined;\n const isExpanded = expanded ?? internalExpanded;\n const isOpen = (open ?? internalOpen) || isExpanded;\n const previewItems = previews.slice(0, MAX_PREVIEWS);\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const countText = `${count} ${itemLabel}${count === 1 ? \"\" : \"s\"}`;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (disabled) return;\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [disabled, onOpenChange, openControlled],\n );\n\n const setExpanded = useCallback(\n (next: boolean) => {\n if (disabled || previewItems.length === 0) return;\n if (!expandedControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [disabled, expandedControlled, onExpandedChange, previewItems.length],\n );\n\n const finishClose = useCallback(() => {\n setIsClosing(false);\n restoringFocusRef.current = true;\n requestAnimationFrame(() => folderButtonRef.current?.focus());\n }, []);\n\n const closeOverlay = useCallback(() => {\n setIsClosing(true);\n setOpen(false);\n setExpanded(false);\n }, [setExpanded, setOpen]);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (reduce && isClosing) finishClose();\n }, [finishClose, isClosing, reduce]);\n\n useEffect(() => {\n if (!isExpanded) return;\n\n const previousOverflow = document.body.style.overflow;\n const focusFrame = requestAnimationFrame(() => closeButtonRef.current?.focus());\n\n document.body.style.overflow = \"hidden\";\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeOverlay();\n return;\n }\n if (event.key !== \"Tab\" || !dialogRef.current) return;\n\n const focusable = Array.from(\n dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),\n ).filter((element) => element.tabIndex >= 0);\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) return;\n\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n cancelAnimationFrame(focusFrame);\n document.body.style.overflow = previousOverflow;\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [closeOverlay, isExpanded]);\n\n const handleFolderClick = () => {\n setIsClosing(false);\n setExpanded(true);\n setOpen(true);\n onClick?.();\n };\n\n // The chrome is two siblings: a backdrop spanning the viewport edges that\n // paints the scrim, and a transparent dialog inset off every edge that lays\n // out and scrolls the panel. The backdrop cannot nest inside that scroll box —\n // WebKit resolves a `position: fixed` descendant of an accelerated overflow\n // scroller against the scroller, not the viewport, so the insets would go\n // unscrimmed on a phone. The scroll box takes no pointer events and the panel\n // takes them back, so gutter presses still close the overlay. Accepted: the\n // 2rem inset sits outside the scroll box, so it stays put rather than\n // scrolling away with the content.\n const overlay =\n isExpanded || isClosing ? (\n <>\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.button\n key=\"project-files-backdrop\"\n type=\"button\"\n tabIndex={-1}\n aria-label=\"Close file overlay\"\n onClick={closeOverlay}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className={cn(\n \"fixed inset-0 z-50 cursor-default bg-background/80 backdrop-blur-xl\",\n isClosing && \"pointer-events-none\",\n )}\n />\n ) : null}\n </AnimatePresence>\n\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={dialogTitleId}\n aria-hidden={isExpanded ? undefined : \"true\"}\n className=\"pointer-events-none fixed inset-x-6 inset-y-8 z-50 flex items-start justify-center overflow-y-auto sm:items-center\"\n >\n {/* 61rem, not `max-w-5xl`: the cap is on a padding-free box, so it has to\n be the 64rem border box less the 3rem the gutters take. */}\n <div\n className={cn(\n \"pointer-events-auto relative z-10 w-full max-w-[61rem]\",\n isClosing && \"pointer-events-none\",\n )}\n >\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"project-files-header\"\n initial={{ opacity: 0, y: reduce ? 0 : 8 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduce ? 0 : -8 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className=\"mb-6 flex items-center justify-between gap-4\"\n >\n <div>\n <h2 id={dialogTitleId} className=\"font-medium text-foreground text-xl\">\n {title}\n </h2>\n <p className=\"mt-1 text-muted-foreground text-sm\">{countText}</p>\n </div>\n <button\n ref={closeButtonRef}\n type=\"button\"\n onClick={closeOverlay}\n aria-label={`Close ${title}`}\n className=\"flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </button>\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <div className=\"grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5\">\n {isExpanded\n ? previewItems.map((preview) => (\n <motion.div\n key={preview.id}\n layoutId={`file-${preview.id}`}\n transition={transition}\n className=\"aspect-3/4 w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl\"\n >\n {preview.content}\n </motion.div>\n ))\n : null}\n </div>\n </div>\n </div>\n </>\n ) : null;\n\n return (\n <LayoutGroup id={layoutGroupId}>\n <motion.button\n ref={folderButtonRef}\n type=\"button\"\n disabled={disabled}\n aria-label={ariaLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={isExpanded}\n data-open={isOpen ? \"true\" : \"false\"}\n data-expanded={isExpanded ? \"true\" : \"false\"}\n tabIndex={isExpanded ? -1 : undefined}\n onPointerEnter={() => {\n if (!canHover) return;\n hoveredRef.current = true;\n setOpen(true);\n }}\n onPointerLeave={() => {\n if (!canHover) return;\n hoveredRef.current = false;\n if (!isExpanded && !isClosing) setOpen(focusedRef.current);\n }}\n onFocus={() => {\n if (restoringFocusRef.current) {\n restoringFocusRef.current = false;\n focusedRef.current = false;\n return;\n }\n focusedRef.current = true;\n setOpen(true);\n }}\n onBlur={() => {\n focusedRef.current = false;\n if (!isExpanded && !isClosing) setOpen(hoveredRef.current);\n }}\n onClick={handleFolderClick}\n whileTap={reduce || disabled ? undefined : { scale: 0.98 }}\n transition={reduce ? { duration: 0 } : SPRING_PRESS}\n className={cn(\n \"perspective-[1200px] relative block h-56 w-72 select-none rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n >\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotateX: isOpen && !reduce ? 15 : 0 }}\n transition={transition}\n className=\"absolute inset-0 origin-[center_bottom] rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl\"\n />\n\n <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\">\n <span className=\"absolute top-0 left-1/2 block h-0 w-0\">\n <AnimatePresence initial={false}>\n {!isExpanded\n ? previewItems.map((preview, index) => {\n const opened = getPreviewTransform(index, previewItems.length);\n return (\n <motion.span\n key={preview.id}\n layoutId={`file-${preview.id}`}\n initial={false}\n animate={\n isOpen && !reduce\n ? {\n x: opened.x * 1.4,\n y: opened.y - 8,\n rotate: opened.rotate * 1.3,\n scale: opened.scale * 1.02,\n opacity: Math.min(1, opened.opacity + 0.18),\n }\n : {\n x: opened.x,\n y: opened.y,\n rotate: opened.rotate,\n scale: opened.scale,\n opacity: opened.opacity,\n }\n }\n transition={transition}\n onLayoutAnimationComplete={() => {\n if (isClosing && index === 0) finishClose();\n }}\n className=\"absolute top-0 left-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg\"\n style={{ zIndex: opened.zIndex }}\n >\n {preview.content}\n </motion.span>\n );\n })\n : null}\n </AnimatePresence>\n </span>\n </span>\n\n <motion.span\n initial={false}\n animate={{ rotateX: isOpen && !reduce ? -25 : 0 }}\n transition={transition}\n className=\"backface-hidden absolute inset-x-0 bottom-0 z-20 origin-[center_bottom] overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl\"\n >\n <span className=\"flex h-16 items-center px-4\">\n <span className=\"line-clamp-2 font-medium text-foreground text-xl leading-tight\">\n {title}\n </span>\n </span>\n <span className=\"flex h-12 items-center justify-between gap-3 border-foreground/10 border-t px-4\">\n <span className=\"shrink-0 font-medium text-foreground/70 text-sm\">{countText}</span>\n <span className=\"truncate text-muted-foreground text-sm\">{description}</span>\n </span>\n </motion.span>\n </motion.button>\n\n {mounted ? createPortal(overlay, document.body) : null}\n </LayoutGroup>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,MAAM,eAAe;AACrB,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,SAAS,oBAAoB,OAAe,OAAe;CACzD,MAAM,SAAS,SAAS,QAAQ,KAAK;CACrC,MAAM,WAAW,KAAK,IAAI,MAAM;CAChC,MAAM,aAAa,KAAK,IAAI,GAAG,IAAI,QAAQ,IAAI;CAE/C,OAAO;EACL,GAAG,SAAS;EACZ,GAAG,IAAI;EACP,QAAQ,SAAS;EACjB,OAAO,aAAa,IAAI,OAAO,aAAa,IAAI,MAAO;EACvD,SAAS,aAAa,IAAI,IAAI,aAAa,IAAI,MAAO;EACtD,QAAQ,KAAK;CACf;AACF;AAEA,SAAgB,cAAc,EAC5B,OACA,cAAc,oBACd,WAAW,CAAC,GACZ,QAAQ,SAAS,QACjB,YAAY,QACZ,MACA,cAAc,OACd,cACA,UACA,kBAAkB,OAClB,kBACA,SACA,WAAW,OACX,WACA,aACqB;CACrB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,gBAAgB,MAAM;CAC5B,MAAM,gBAAgB,GAAG,cAAc;CACvC,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,kBAAkB,OA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G,OAAO,IAAI;UACd,QAAQ,OAAO,SAAS;UACxB,OAAO,OAAO,QAAQ;UACtB,SAAS,KAAK,IAAI,GAAG,OAAO,UAAU,GAAI;SAC5C,IACA;UACE,GAAG,OAAO;UACV,GAAG,OAAO;UACV,QAAQ,OAAO;UACf,OAAO,OAAO;UACd,SAAS,OAAO;SAClB;SAEM;SACZ,iCAAiC;UAC/B,IAAI,aAAa,UAAU,GAAG,YAAY;SAC5C;SACA,WAAU;SACV,OAAO,EAAE,QAAQ,OAAO,OAAO;SAE9B,UAAA,QAAQ;QACE,GA5BN,QAAQ,EA4BF;OAEjB,CAAC,IACD;MACW,CAAA;KACb,CAAA;IACF,CAAA;IAEN,qBAAC,OAAO,MAAR;KACE,SAAS;KACT,SAAS,EAAE,SAAS,UAAU,CAAC,SAAS,MAAM,EAAE;KACpC;KACZ,WAAU;KAJZ,UAAA,CAME,oBAAC,QAAD;MAAM,WAAU;MACd,UAAA,oBAAC,QAAD;OAAM,WAAU;OACb,UAAA;MACG,CAAA;KACF,CAAA,GACN,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAmD,UAAA;MAAgB,CAAA,GACnF,oBAAC,QAAD;OAAM,WAAU;OAA0C,UAAA;MAAkB,CAAA,CACxE;KACK,CAAA,CAAA;;GACA;EAEd,CAAA,GAAA,UAAU,aAAa,SAAS,SAAS,IAAI,IAAI,IACvC;;AAEjB"}
1
+ {"version":3,"file":"project-folder.js","names":[],"sources":["../../../src/components/motion/project-folder.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { X } from \"lucide-react\";\nimport {\n AnimatePresence,\n LayoutGroup,\n motion,\n type Transition,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport type ProjectFolderPreview = {\n id: string;\n content: ReactNode;\n};\n\nexport interface ProjectFolderProps {\n title: string;\n description?: string;\n previews?: ProjectFolderPreview[];\n count?: number;\n itemLabel?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n className?: string;\n}\n\nconst MAX_PREVIEWS = 5;\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nfunction getPreviewTransform(index: number, count: number) {\n const offset = index - (count - 1) / 2;\n const distance = Math.abs(offset);\n const centerLift = Math.max(0, 2 - distance) * 8;\n\n return {\n x: offset * 44,\n y: 8 - centerLift,\n rotate: offset * 6,\n scale: distance === 0 ? 1.04 : distance === 1 ? 0.95 : 0.88,\n opacity: distance === 0 ? 1 : distance === 1 ? 0.78 : 0.58,\n zIndex: 10 - distance,\n };\n}\n\nexport function ProjectFolder({\n title,\n description = \"Updated recently\",\n previews = [],\n count = previews.length,\n itemLabel = \"file\",\n open,\n defaultOpen = false,\n onOpenChange,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onClick,\n disabled = false,\n ariaLabel,\n className,\n}: ProjectFolderProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const layoutGroupId = useId();\n const dialogTitleId = `${layoutGroupId}-title`;\n const hoveredRef = useRef(false);\n const focusedRef = useRef(false);\n const restoringFocusRef = useRef(false);\n const folderButtonRef = useRef<HTMLButtonElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n const [mounted, setMounted] = useState(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const [isClosing, setIsClosing] = useState(false);\n const openControlled = open !== undefined;\n const expandedControlled = expanded !== undefined;\n const isExpanded = expanded ?? internalExpanded;\n const isOpen = (open ?? internalOpen) || isExpanded;\n const previewItems = previews.slice(0, MAX_PREVIEWS);\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const countText = `${count} ${itemLabel}${count === 1 ? \"\" : \"s\"}`;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (disabled) return;\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [disabled, onOpenChange, openControlled],\n );\n\n const setExpanded = useCallback(\n (next: boolean) => {\n if (disabled || previewItems.length === 0) return;\n if (!expandedControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [disabled, expandedControlled, onExpandedChange, previewItems.length],\n );\n\n const finishClose = useCallback(() => {\n setIsClosing(false);\n restoringFocusRef.current = true;\n requestAnimationFrame(() => folderButtonRef.current?.focus());\n }, []);\n\n const closeOverlay = useCallback(() => {\n setIsClosing(true);\n setOpen(false);\n setExpanded(false);\n }, [setExpanded, setOpen]);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (reduce && isClosing) finishClose();\n }, [finishClose, isClosing, reduce]);\n\n useEffect(() => {\n if (!isExpanded) return;\n\n const previousOverflow = document.body.style.overflow;\n const focusFrame = requestAnimationFrame(() => closeButtonRef.current?.focus());\n\n document.body.style.overflow = \"hidden\";\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeOverlay();\n return;\n }\n if (event.key !== \"Tab\" || !dialogRef.current) return;\n\n const focusable = Array.from(\n dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),\n ).filter((element) => element.tabIndex >= 0);\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) return;\n\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n cancelAnimationFrame(focusFrame);\n document.body.style.overflow = previousOverflow;\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [closeOverlay, isExpanded]);\n\n const handleFolderClick = () => {\n setIsClosing(false);\n setExpanded(true);\n setOpen(true);\n onClick?.();\n };\n\n // The chrome is two siblings: a backdrop spanning the viewport edges that\n // paints the scrim, and a transparent dialog inset off every edge that lays\n // out and scrolls the panel. The backdrop cannot nest inside that scroll box —\n // WebKit resolves a `position: fixed` descendant of an accelerated overflow\n // scroller against the scroller, not the viewport, so the insets would go\n // unscrimmed on a phone. The scroll box takes no pointer events and the panel\n // takes them back, so gutter presses still close the overlay. Accepted: the\n // 2rem inset sits outside the scroll box, so it stays put rather than\n // scrolling away with the content.\n const overlay =\n isExpanded || isClosing ? (\n <>\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.button\n key=\"project-files-backdrop\"\n type=\"button\"\n tabIndex={-1}\n aria-label=\"Close file overlay\"\n onClick={closeOverlay}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className={cn(\n \"fixed inset-0 z-50 cursor-default bg-background/80 backdrop-blur-xl\",\n isClosing && \"pointer-events-none\",\n )}\n />\n ) : null}\n </AnimatePresence>\n\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={dialogTitleId}\n aria-hidden={isExpanded ? undefined : \"true\"}\n className=\"pointer-events-none fixed inset-x-6 inset-y-8 z-50 flex items-start justify-center overflow-y-auto sm:items-center\"\n >\n {/* 61rem, not `max-w-5xl`: the cap is on a padding-free box, so it has to\n be the 64rem border box less the 3rem the gutters take. */}\n <div\n className={cn(\n \"pointer-events-auto relative z-10 w-full max-w-[61rem]\",\n isClosing && \"pointer-events-none\",\n )}\n >\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"project-files-header\"\n initial={{ opacity: 0, y: reduce ? 0 : 8 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduce ? 0 : -8 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className=\"mb-6 flex items-center justify-between gap-4\"\n >\n <div>\n <h2 id={dialogTitleId} className=\"font-medium text-foreground text-xl\">\n {title}\n </h2>\n <p className=\"mt-1 text-muted-foreground text-sm\">{countText}</p>\n </div>\n <button\n ref={closeButtonRef}\n type=\"button\"\n onClick={closeOverlay}\n aria-label={`Close ${title}`}\n className=\"flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </button>\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <div className=\"grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5\">\n {isExpanded\n ? previewItems.map((preview) => (\n <motion.div\n key={preview.id}\n layoutId={`file-${preview.id}`}\n transition={transition}\n className=\"aspect-3/4 w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl\"\n >\n {preview.content}\n </motion.div>\n ))\n : null}\n </div>\n </div>\n </div>\n </>\n ) : null;\n\n return (\n <LayoutGroup id={layoutGroupId}>\n <motion.button\n ref={folderButtonRef}\n type=\"button\"\n disabled={disabled}\n aria-label={ariaLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={isExpanded}\n data-open={isOpen ? \"true\" : \"false\"}\n data-expanded={isExpanded ? \"true\" : \"false\"}\n tabIndex={isExpanded ? -1 : undefined}\n onPointerEnter={() => {\n if (!canHover) return;\n hoveredRef.current = true;\n setOpen(true);\n }}\n onPointerLeave={() => {\n if (!canHover) return;\n hoveredRef.current = false;\n if (!isExpanded && !isClosing) setOpen(focusedRef.current);\n }}\n onFocus={() => {\n if (restoringFocusRef.current) {\n restoringFocusRef.current = false;\n focusedRef.current = false;\n return;\n }\n focusedRef.current = true;\n setOpen(true);\n }}\n onBlur={() => {\n focusedRef.current = false;\n if (!isExpanded && !isClosing) setOpen(hoveredRef.current);\n }}\n onClick={handleFolderClick}\n whileTap={reduce || disabled ? undefined : { scale: 0.98 }}\n transition={reduce ? { duration: 0 } : SPRING_PRESS}\n className={cn(\n \"perspective-[1200px] relative block h-56 w-72 select-none rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n >\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotateX: isOpen && !reduce ? 15 : 0 }}\n transition={transition}\n className=\"absolute inset-0 origin-[center_bottom] rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl\"\n />\n\n <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\">\n <span className=\"absolute top-0 left-1/2 block h-0 w-0\">\n <AnimatePresence initial={false}>\n {!isExpanded\n ? previewItems.map((preview, index) => {\n const opened = getPreviewTransform(index, previewItems.length);\n return (\n <motion.span\n key={preview.id}\n layoutId={`file-${preview.id}`}\n initial={false}\n animate={\n isOpen && !reduce\n ? {\n x: opened.x * 1.4,\n y: opened.y - 8,\n rotate: opened.rotate * 1.3,\n scale: opened.scale * 1.02,\n opacity: Math.min(1, opened.opacity + 0.18),\n }\n : {\n x: opened.x,\n y: opened.y,\n rotate: opened.rotate,\n scale: opened.scale,\n opacity: opened.opacity,\n }\n }\n transition={transition}\n onLayoutAnimationComplete={() => {\n if (isClosing && index === 0) finishClose();\n }}\n className=\"absolute top-0 left-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg\"\n style={{ zIndex: opened.zIndex }}\n >\n {preview.content}\n </motion.span>\n );\n })\n : null}\n </AnimatePresence>\n </span>\n </span>\n\n <motion.span\n initial={false}\n animate={{ rotateX: isOpen && !reduce ? -25 : 0 }}\n transition={transition}\n className=\"backface-hidden absolute inset-x-0 bottom-0 z-20 origin-[center_bottom] overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl\"\n >\n <span className=\"flex h-16 items-center px-4\">\n <span className=\"line-clamp-2 font-medium text-foreground text-xl leading-tight\">\n {title}\n </span>\n </span>\n <span className=\"flex h-12 items-center justify-between gap-3 border-foreground/10 border-t px-4\">\n <span className=\"shrink-0 font-medium text-foreground/70 text-sm\">{countText}</span>\n <span className=\"truncate text-muted-foreground text-sm\">{description}</span>\n </span>\n </motion.span>\n </motion.button>\n\n {mounted ? createPortal(overlay, document.body) : null}\n </LayoutGroup>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,MAAM,eAAe;AACrB,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,SAAS,oBAAoB,OAAe,OAAe;CACzD,MAAM,SAAS,SAAS,QAAQ,KAAK;CACrC,MAAM,WAAW,KAAK,IAAI,MAAM;CAChC,MAAM,aAAa,KAAK,IAAI,GAAG,IAAI,QAAQ,IAAI;CAE/C,OAAO;EACL,GAAG,SAAS;EACZ,GAAG,IAAI;EACP,QAAQ,SAAS;EACjB,OAAO,aAAa,IAAI,OAAO,aAAa,IAAI,MAAO;EACvD,SAAS,aAAa,IAAI,IAAI,aAAa,IAAI,MAAO;EACtD,QAAQ,KAAK;CACf;AACF;AAEA,SAAgB,cAAc,EAC5B,OACA,cAAc,oBACd,WAAW,CAAC,GACZ,QAAQ,SAAS,QACjB,YAAY,QACZ,MACA,cAAc,OACd,cACA,UACA,kBAAkB,OAClB,kBACA,SACA,WAAW,OACX,WACA,aACqB;CACrB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,gBAAgB,MAAM;CAC5B,MAAM,gBAAgB,GA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AC7D,OACE,oBAAC,OAAO,MAAR;SAEE,UAAU,QAAQ,QAAQ;SAC1B,SAAS;SACT,SACE,UAAU,CAAC,SACP;UACE,GAAG,OAAO,IAAI;UACd,GAAG,OAAO,IAAI;UACd,QAAQ,OAAO,SAAS;UACxB,OAAO,OAAO,QAAQ;UACtB,SAAS,KAAK,IAAI,GAAG,OAAO,UAAU,GAAI;SAC5C,IACA;UACE,GAAG,OAAO;UACV,GAAG,OAAO;UACV,QAAQ,OAAO;UACf,OAAO,OAAO;UACd,SAAS,OAAO;SAClB;SAEM;SACZ,iCAAiC;UAC/B,IAAI,aAAa,UAAU,GAAG,YAAY;SAC5C;SACA,WAAU;SACV,OAAO,EAAE,QAAQ,OAAO,OAAO;SAE9B,UAAA,QAAQ;QACE,GA5BN,QAAQ,EA4BF;OAEjB,CAAC,IACD;MACW,CAAA;KACb,CAAA;IACF,CAAA;IAEN,qBAAC,OAAO,MAAR;KACE,SAAS;KACT,SAAS,EAAE,SAAS,UAAU,CAAC,SAAS,MAAM,EAAE;KACpC;KACZ,WAAU;KAJZ,UAAA,CAME,oBAAC,QAAD;MAAM,WAAU;MACd,UAAA,oBAAC,QAAD;OAAM,WAAU;OACb,UAAA;MACG,CAAA;KACF,CAAA,GACN,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAmD,UAAA;MAAgB,CAAA,GACnF,oBAAC,QAAD;OAAM,WAAU;OAA0C,UAAA;MAAkB,CAAA,CACxE;KACK,CAAA,CAAA;;GACA;EAEd,CAAA,GAAA,UAAU,aAAa,SAAS,SAAS,IAAI,IAAI,IACvC;;AAEjB"}
@@ -2,7 +2,7 @@
2
2
  import { TOUCH_GESTURE_CONTENT_CLASS, capturePointer } from "../../lib/touch.js";
3
3
  import { EASE_IN_OUT, EASE_OUT, SPRING_PANEL, SPRING_SWAP } from "../../lib/ease.js";
4
4
  import { useCallback, useEffect, useRef, useState } from "react";
5
- import { cn } from "@kumix/utils";
5
+ import { cn } from "cn";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
8
8
  //#region src/components/motion/pull-to-refresh.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"pull-to-refresh.js","names":[],"sources":["../../../src/components/motion/pull-to-refresh.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN_OUT, EASE_OUT, SPRING_PANEL, SPRING_SWAP } from \"../../lib/ease\";\nimport { capturePointer, TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\nexport type PullToRefreshStatus = \"idle\" | \"pulling\" | \"ready\" | \"refreshing\";\n\nexport interface PullToRefreshProps {\n /** Runs after the user pulls beyond the threshold and releases. */\n onRefresh: () => void | Promise<void>;\n children: ReactNode;\n /** Keeps the indicator active while an externally managed refresh runs. */\n refreshing?: boolean;\n disabled?: boolean;\n /** Resisted pull distance in pixels required to refresh. */\n threshold?: number;\n /** Maximum resisted pull distance in pixels. */\n maxPull?: number;\n /** Content offset in pixels while refreshing. */\n holdDistance?: number;\n pullingLabel?: ReactNode;\n releaseLabel?: ReactNode;\n refreshingLabel?: ReactNode;\n ariaLabel?: string;\n className?: string;\n contentClassName?: string;\n indicatorClassName?: string;\n}\n\ntype Gesture = {\n active: boolean;\n startX: number;\n startY: number;\n pointerId: number | null;\n};\n\nconst EMPTY_GESTURE: Gesture = {\n active: false,\n startX: 0,\n startY: 0,\n pointerId: null,\n};\n\n// This character needs a compact repeating rhythm rather than a settling\n// spring: a small orbit and blink that read as activity without feeling busy.\nconst CHARACTER_LOOP = {\n duration: 0.9,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst CALM_PULSE = {\n duration: 1.2,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst LABEL_SWAP = { duration: 0.16, ease: EASE_OUT } as const;\n\nfunction resistedDistance(distance: number, maxPull: number) {\n return maxPull * (1 - Math.exp(-Math.max(0, distance) / maxPull));\n}\n\nfunction RefreshBuddy({\n progress,\n status,\n reduce,\n}: {\n progress: MotionValue<number>;\n status: PullToRefreshStatus;\n reduce: boolean;\n}) {\n const lift = useTransform(progress, [0, 1], [-7, 0]);\n const tilt = useTransform(progress, [0, 1], [-10, 0]);\n const stretch = useTransform(progress, [0, 0.55, 1], [0.68, 1.1, 0.92]);\n const ready = status === \"ready\";\n const refreshing = status === \"refreshing\";\n\n return (\n <motion.span\n style={reduce ? undefined : { y: lift, rotate: tilt, scaleY: stretch }}\n className=\"block h-9 w-9 origin-bottom\"\n >\n <motion.svg\n aria-hidden=\"true\"\n viewBox=\"0 0 36 36\"\n style={{ opacity: 1 }}\n className=\"h-full w-full overflow-visible\"\n animate={\n refreshing\n ? reduce\n ? { opacity: [0.55, 1, 0.55] }\n : { y: [0, -2, 0], rotate: [-3, 3, -3] }\n : reduce\n ? { opacity: 1 }\n : { y: 0, rotate: 0, scale: ready ? 1.08 : 1 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n >\n <motion.g\n style={{ transformOrigin: \"18px 18px\" }}\n animate={\n refreshing && !reduce\n ? { rotate: [0, 360] }\n : reduce\n ? undefined\n : { rotate: ready ? 0 : -35 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n className={cn(\n \"transition-opacity duration-150\",\n ready || refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n <path\n d=\"M18 2.5a15.5 15.5 0 0 1 12.7 6.6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className=\"text-muted-foreground\"\n />\n <circle cx=\"31.3\" cy=\"10.2\" r=\"2.2\" className=\"fill-foreground\" />\n </motion.g>\n\n <rect x=\"7\" y=\"7\" width=\"22\" height=\"22\" rx=\"9\" className=\"fill-foreground\" />\n\n <motion.g\n style={{ opacity: 1, transformOrigin: \"18px 16px\" }}\n animate={\n refreshing && !reduce\n ? { scaleY: [1, 1, 0.15, 1, 1] }\n : reduce\n ? { opacity: 1 }\n : { scaleY: ready ? 1.18 : 1 }\n }\n transition={refreshing && !reduce ? CHARACTER_LOOP : SPRING_SWAP}\n >\n <circle cx=\"14.2\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n <circle cx=\"21.8\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n </motion.g>\n\n <path\n d=\"M14.5 21h7\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready || refreshing ? \"opacity-0\" : \"opacity-100\",\n )}\n />\n <path\n d=\"M14 20.5c1 2.4 7 2.4 8 0\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n <circle\n cx=\"18\"\n cy=\"21\"\n r=\"1.6\"\n className={cn(\n \"fill-background transition-opacity duration-150\",\n refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </motion.svg>\n </motion.span>\n );\n}\n\nexport function PullToRefresh({\n onRefresh,\n children,\n refreshing = false,\n disabled = false,\n threshold = 76,\n maxPull = 132,\n holdDistance = 68,\n pullingLabel = \"Pull to refresh\",\n releaseLabel = \"Release to refresh\",\n refreshingLabel = \"Refreshing\",\n ariaLabel = \"Refreshable content\",\n className,\n contentClassName,\n indicatorClassName,\n}: PullToRefreshProps) {\n const rootRef = useRef<HTMLElement>(null);\n const gestureRef = useRef<Gesture>({ ...EMPTY_GESTURE });\n const animationRef = useRef<{ stop: () => void } | null>(null);\n const statusRef = useRef<PullToRefreshStatus>(\"idle\");\n const disabledRef = useRef(disabled);\n const externalRefreshingRef = useRef(refreshing);\n const refreshingRef = useRef(refreshing);\n const [status, setStatusState] = useState<PullToRefreshStatus>(\"idle\");\n const [internalRefreshing, setInternalRefreshing] = useState(false);\n const reduce = useReducedMotion();\n const pullThreshold = Math.max(24, threshold);\n const pullLimit = Math.max(maxPull, pullThreshold + 24);\n const restingDistance = Math.min(Math.max(0, holdDistance), pullThreshold);\n const y = useMotionValue(0);\n const progress = useTransform(y, [0, pullThreshold], [0, 1]);\n const indicatorOpacity = useTransform(y, [0, 10, pullThreshold], [0, 0.45, 1]);\n const indicatorScale = useTransform(y, [0, pullThreshold], [0.86, 1]);\n const isRefreshing = refreshing || internalRefreshing;\n\n disabledRef.current = disabled;\n externalRefreshingRef.current = refreshing;\n refreshingRef.current = isRefreshing;\n\n const setStatus = useCallback((next: PullToRefreshStatus) => {\n if (statusRef.current === next) return;\n statusRef.current = next;\n setStatusState(next);\n }, []);\n\n const settle = useCallback(\n (target: number) => {\n animationRef.current?.stop();\n\n if (reduce) {\n y.set(target);\n return;\n }\n\n animationRef.current = animate(y, target, SPRING_PANEL);\n },\n [reduce, y],\n );\n\n const updatePull = useCallback(\n (distance: number) => {\n if (disabledRef.current || refreshingRef.current) return;\n animationRef.current?.stop();\n\n const next = resistedDistance(distance, pullLimit);\n y.set(next);\n setStatus(next >= pullThreshold ? \"ready\" : \"pulling\");\n },\n [pullLimit, pullThreshold, setStatus, y],\n );\n\n const runRefresh = useCallback(async () => {\n if (disabledRef.current || refreshingRef.current) return;\n\n setInternalRefreshing(true);\n setStatus(\"refreshing\");\n settle(restingDistance);\n\n try {\n await onRefresh();\n } finally {\n setInternalRefreshing(false);\n\n // A synchronous refresh can resolve before React commits the temporary\n // internal state, so release here instead of relying only on the effect.\n if (!externalRefreshingRef.current) {\n setStatus(\"idle\");\n settle(0);\n }\n }\n }, [onRefresh, restingDistance, setStatus, settle]);\n\n const finishPull = useCallback(() => {\n const shouldRefresh =\n y.get() >= pullThreshold && !disabledRef.current && !refreshingRef.current;\n\n gestureRef.current = { ...EMPTY_GESTURE };\n\n if (shouldRefresh) {\n void runRefresh();\n return;\n }\n\n setStatus(\"idle\");\n settle(0);\n }, [pullThreshold, runRefresh, setStatus, settle, y]);\n\n useEffect(() => {\n if (isRefreshing) {\n setStatus(\"refreshing\");\n settle(restingDistance);\n return;\n }\n\n if (statusRef.current === \"refreshing\") {\n setStatus(\"idle\");\n settle(0);\n }\n }, [isRefreshing, restingDistance, setStatus, settle]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const onTouchStart = (event: TouchEvent) => {\n if (\n event.touches.length !== 1 ||\n root.scrollTop > 0 ||\n disabledRef.current ||\n refreshingRef.current\n ) {\n return;\n }\n\n const touch = event.touches[0];\n gestureRef.current = {\n active: true,\n startX: touch.clientX,\n startY: touch.clientY,\n pointerId: null,\n };\n };\n\n const onTouchMove = (event: TouchEvent) => {\n const gesture = gestureRef.current;\n const touch = event.touches[0];\n if (!gesture.active || !touch) return;\n\n const deltaX = touch.clientX - gesture.startX;\n const deltaY = touch.clientY - gesture.startY;\n\n if (root.scrollTop > 0 || deltaY < 0) {\n gestureRef.current = { ...EMPTY_GESTURE };\n return;\n }\n\n if (Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const onTouchEnd = () => {\n if (gestureRef.current.active) finishPull();\n };\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n root.addEventListener(\"touchend\", onTouchEnd);\n root.addEventListener(\"touchcancel\", onTouchEnd);\n\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart);\n root.removeEventListener(\"touchmove\", onTouchMove);\n root.removeEventListener(\"touchend\", onTouchEnd);\n root.removeEventListener(\"touchcancel\", onTouchEnd);\n };\n }, [finishPull, updatePull]);\n\n useEffect(() => {\n return () => animationRef.current?.stop();\n }, []);\n\n const startPointerPull = (event: ReactPointerEvent<HTMLElement>) => {\n // Everything but touch: a finger is driven by the native listeners above,\n // which can `preventDefault` the page scroll a passive React handler\n // cannot. A pen fires no touch events at all, so this is its only route.\n if (\n event.pointerType === \"touch\" ||\n event.button !== 0 ||\n event.currentTarget.scrollTop > 0 ||\n disabled ||\n isRefreshing\n ) {\n return;\n }\n\n capturePointer(event.currentTarget, event.pointerId);\n gestureRef.current = {\n active: true,\n startX: event.clientX,\n startY: event.clientY,\n pointerId: event.pointerId,\n };\n };\n\n const movePointerPull = (event: ReactPointerEvent<HTMLElement>) => {\n const gesture = gestureRef.current;\n if (!gesture.active || gesture.pointerId !== event.pointerId) return;\n\n const deltaX = event.clientX - gesture.startX;\n const deltaY = event.clientY - gesture.startY;\n if (deltaY < 0 || Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const label =\n status === \"refreshing\" ? refreshingLabel : status === \"ready\" ? releaseLabel : pullingLabel;\n\n return (\n <section\n ref={rootRef}\n aria-label={ariaLabel}\n aria-busy={isRefreshing}\n data-state={status}\n data-disabled={disabled || undefined}\n onPointerDown={startPointerPull}\n onPointerMove={movePointerPull}\n onPointerUp={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n onPointerCancel={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n className={cn(\n \"relative w-full overflow-y-auto overscroll-contain bg-background\",\n // No `touch-none` here — this element is the scroller, and the pull\n // only takes over once the content is already at the top. The callout\n // has to be off from the first frame though: iOS decides on it while\n // the finger is still resting, long before the pull is recognised.\n // Whatever the consumer renders inside stays selectable with a mouse;\n // only the pull itself suppresses selection, and only while it runs,\n // so dragging the page down cannot highlight it on the way.\n TOUCH_GESTURE_CONTENT_CLASS,\n status === \"pulling\" || status === \"ready\" ? \"cursor-grabbing select-none\" : \"cursor-grab\",\n (disabled || isRefreshing) && \"cursor-default\",\n className,\n )}\n >\n <motion.div\n aria-live=\"polite\"\n aria-atomic=\"true\"\n style={\n reduce\n ? { opacity: indicatorOpacity }\n : { opacity: indicatorOpacity, scale: indicatorScale }\n }\n className={cn(\n \"pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-linear-to-b from-background via-background/95 to-transparent font-medium text-[11px] text-muted-foreground\",\n indicatorClassName,\n )}\n >\n <RefreshBuddy progress={progress} status={status} reduce={Boolean(reduce)} />\n <span className=\"relative h-4 min-w-24 text-center\">\n <AnimatePresence initial={false} mode=\"wait\">\n <motion.span\n key={status}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 3 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={LABEL_SWAP}\n className=\"absolute inset-x-0 whitespace-nowrap\"\n >\n {label}\n </motion.span>\n </AnimatePresence>\n </span>\n </motion.div>\n\n <motion.div\n style={reduce ? undefined : { y }}\n className={cn(\n \"relative z-10 min-h-full bg-inherit will-change-transform\",\n contentClassName,\n )}\n >\n {children}\n </motion.div>\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAuDA,MAAM,gBAAyB;CAC7B,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;AACb;AAIA,MAAM,iBAAiB;CACrB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CACjB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CAAE,UAAU;CAAM,MAAM;AAAS;AAEpD,SAAS,iBAAiB,UAAkB,SAAiB;CAC3D,OAAO,WAAW,IAAI,KAAK,IAAI,CAAC,KAAK,IAAI,GAAG,QAAQ,IAAI,OAAO;AACjE;AAEA,SAAS,aAAa,EACpB,UACA,Q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A,oBAAC,OAAO,KAAR;GACE,OAAO,SAAS,KAAA,IAAY,EAAE,EAAE;GAChC,WAAW,GACT,6DACA,gBACF;GAEC;EACS,CAAA,CACL;;AAEb"}
1
+ {"version":3,"file":"pull-to-refresh.js","names":[],"sources":["../../../src/components/motion/pull-to-refresh.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport {\n AnimatePresence,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { EASE_IN_OUT, EASE_OUT, SPRING_PANEL, SPRING_SWAP } from \"../../lib/ease\";\nimport { capturePointer, TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\nexport type PullToRefreshStatus = \"idle\" | \"pulling\" | \"ready\" | \"refreshing\";\n\nexport interface PullToRefreshProps {\n /** Runs after the user pulls beyond the threshold and releases. */\n onRefresh: () => void | Promise<void>;\n children: ReactNode;\n /** Keeps the indicator active while an externally managed refresh runs. */\n refreshing?: boolean;\n disabled?: boolean;\n /** Resisted pull distance in pixels required to refresh. */\n threshold?: number;\n /** Maximum resisted pull distance in pixels. */\n maxPull?: number;\n /** Content offset in pixels while refreshing. */\n holdDistance?: number;\n pullingLabel?: ReactNode;\n releaseLabel?: ReactNode;\n refreshingLabel?: ReactNode;\n ariaLabel?: string;\n className?: string;\n contentClassName?: string;\n indicatorClassName?: string;\n}\n\ntype Gesture = {\n active: boolean;\n startX: number;\n startY: number;\n pointerId: number | null;\n};\n\nconst EMPTY_GESTURE: Gesture = {\n active: false,\n startX: 0,\n startY: 0,\n pointerId: null,\n};\n\n// This character needs a compact repeating rhythm rather than a settling\n// spring: a small orbit and blink that read as activity without feeling busy.\nconst CHARACTER_LOOP = {\n duration: 0.9,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst CALM_PULSE = {\n duration: 1.2,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst LABEL_SWAP = { duration: 0.16, ease: EASE_OUT } as const;\n\nfunction resistedDistance(distance: number, maxPull: number) {\n return maxPull * (1 - Math.exp(-Math.max(0, distance) / maxPull));\n}\n\nfunction RefreshBuddy({\n progress,\n status,\n reduce,\n}: {\n progress: MotionValue<number>;\n status: PullToRefreshStatus;\n reduce: boolean;\n}) {\n const lift = useTransform(progress, [0, 1], [-7, 0]);\n const tilt = useTransform(progress, [0, 1], [-10, 0]);\n const stretch = useTransform(progress, [0, 0.55, 1], [0.68, 1.1, 0.92]);\n const ready = status === \"ready\";\n const refreshing = status === \"refreshing\";\n\n return (\n <motion.span\n style={reduce ? undefined : { y: lift, rotate: tilt, scaleY: stretch }}\n className=\"block h-9 w-9 origin-bottom\"\n >\n <motion.svg\n aria-hidden=\"true\"\n viewBox=\"0 0 36 36\"\n style={{ opacity: 1 }}\n className=\"h-full w-full overflow-visible\"\n animate={\n refreshing\n ? reduce\n ? { opacity: [0.55, 1, 0.55] }\n : { y: [0, -2, 0], rotate: [-3, 3, -3] }\n : reduce\n ? { opacity: 1 }\n : { y: 0, rotate: 0, scale: ready ? 1.08 : 1 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n >\n <motion.g\n style={{ transformOrigin: \"18px 18px\" }}\n animate={\n refreshing && !reduce\n ? { rotate: [0, 360] }\n : reduce\n ? undefined\n : { rotate: ready ? 0 : -35 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n className={cn(\n \"transition-opacity duration-150\",\n ready || refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n <path\n d=\"M18 2.5a15.5 15.5 0 0 1 12.7 6.6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className=\"text-muted-foreground\"\n />\n <circle cx=\"31.3\" cy=\"10.2\" r=\"2.2\" className=\"fill-foreground\" />\n </motion.g>\n\n <rect x=\"7\" y=\"7\" width=\"22\" height=\"22\" rx=\"9\" className=\"fill-foreground\" />\n\n <motion.g\n style={{ opacity: 1, transformOrigin: \"18px 16px\" }}\n animate={\n refreshing && !reduce\n ? { scaleY: [1, 1, 0.15, 1, 1] }\n : reduce\n ? { opacity: 1 }\n : { scaleY: ready ? 1.18 : 1 }\n }\n transition={refreshing && !reduce ? CHARACTER_LOOP : SPRING_SWAP}\n >\n <circle cx=\"14.2\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n <circle cx=\"21.8\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n </motion.g>\n\n <path\n d=\"M14.5 21h7\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready || refreshing ? \"opacity-0\" : \"opacity-100\",\n )}\n />\n <path\n d=\"M14 20.5c1 2.4 7 2.4 8 0\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n <circle\n cx=\"18\"\n cy=\"21\"\n r=\"1.6\"\n className={cn(\n \"fill-background transition-opacity duration-150\",\n refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </motion.svg>\n </motion.span>\n );\n}\n\nexport function PullToRefresh({\n onRefresh,\n children,\n refreshing = false,\n disabled = false,\n threshold = 76,\n maxPull = 132,\n holdDistance = 68,\n pullingLabel = \"Pull to refresh\",\n releaseLabel = \"Release to refresh\",\n refreshingLabel = \"Refreshing\",\n ariaLabel = \"Refreshable content\",\n className,\n contentClassName,\n indicatorClassName,\n}: PullToRefreshProps) {\n const rootRef = useRef<HTMLElement>(null);\n const gestureRef = useRef<Gesture>({ ...EMPTY_GESTURE });\n const animationRef = useRef<{ stop: () => void } | null>(null);\n const statusRef = useRef<PullToRefreshStatus>(\"idle\");\n const disabledRef = useRef(disabled);\n const externalRefreshingRef = useRef(refreshing);\n const refreshingRef = useRef(refreshing);\n const [status, setStatusState] = useState<PullToRefreshStatus>(\"idle\");\n const [internalRefreshing, setInternalRefreshing] = useState(false);\n const reduce = useReducedMotion();\n const pullThreshold = Math.max(24, threshold);\n const pullLimit = Math.max(maxPull, pullThreshold + 24);\n const restingDistance = Math.min(Math.max(0, holdDistance), pullThreshold);\n const y = useMotionValue(0);\n const progress = useTransform(y, [0, pullThreshold], [0, 1]);\n const indicatorOpacity = useTransform(y, [0, 10, pullThreshold], [0, 0.45, 1]);\n const indicatorScale = useTransform(y, [0, pullThreshold], [0.86, 1]);\n const isRefreshing = refreshing || internalRefreshing;\n\n disabledRef.current = disabled;\n externalRefreshingRef.current = refreshing;\n refreshingRef.current = isRefreshing;\n\n const setStatus = useCallback((next: PullToRefreshStatus) => {\n if (statusRef.current === next) return;\n statusRef.current = next;\n setStatusState(next);\n }, []);\n\n const settle = useCallback(\n (target: number) => {\n animationRef.current?.stop();\n\n if (reduce) {\n y.set(target);\n return;\n }\n\n animationRef.current = animate(y, target, SPRING_PANEL);\n },\n [reduce, y],\n );\n\n const updatePull = useCallback(\n (distance: number) => {\n if (disabledRef.current || refreshingRef.current) return;\n animationRef.current?.stop();\n\n const next = resistedDistance(distance, pullLimit);\n y.set(next);\n setStatus(next >= pullThreshold ? \"ready\" : \"pulling\");\n },\n [pullLimit, pullThreshold, setStatus, y],\n );\n\n const runRefresh = useCallback(async () => {\n if (disabledRef.current || refreshingRef.current) return;\n\n setInternalRefreshing(true);\n setStatus(\"refreshing\");\n settle(restingDistance);\n\n try {\n await onRefresh();\n } finally {\n setInternalRefreshing(false);\n\n // A synchronous refresh can resolve before React commits the temporary\n // internal state, so release here instead of relying only on the effect.\n if (!externalRefreshingRef.current) {\n setStatus(\"idle\");\n settle(0);\n }\n }\n }, [onRefresh, restingDistance, setStatus, settle]);\n\n const finishPull = useCallback(() => {\n const shouldRefresh =\n y.get() >= pullThreshold && !disabledRef.current && !refreshingRef.current;\n\n gestureRef.current = { ...EMPTY_GESTURE };\n\n if (shouldRefresh) {\n void runRefresh();\n return;\n }\n\n setStatus(\"idle\");\n settle(0);\n }, [pullThreshold, runRefresh, setStatus, settle, y]);\n\n useEffect(() => {\n if (isRefreshing) {\n setStatus(\"refreshing\");\n settle(restingDistance);\n return;\n }\n\n if (statusRef.current === \"refreshing\") {\n setStatus(\"idle\");\n settle(0);\n }\n }, [isRefreshing, restingDistance, setStatus, settle]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const onTouchStart = (event: TouchEvent) => {\n if (\n event.touches.length !== 1 ||\n root.scrollTop > 0 ||\n disabledRef.current ||\n refreshingRef.current\n ) {\n return;\n }\n\n const touch = event.touches[0];\n gestureRef.current = {\n active: true,\n startX: touch.clientX,\n startY: touch.clientY,\n pointerId: null,\n };\n };\n\n const onTouchMove = (event: TouchEvent) => {\n const gesture = gestureRef.current;\n const touch = event.touches[0];\n if (!gesture.active || !touch) return;\n\n const deltaX = touch.clientX - gesture.startX;\n const deltaY = touch.clientY - gesture.startY;\n\n if (root.scrollTop > 0 || deltaY < 0) {\n gestureRef.current = { ...EMPTY_GESTURE };\n return;\n }\n\n if (Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const onTouchEnd = () => {\n if (gestureRef.current.active) finishPull();\n };\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n root.addEventListener(\"touchend\", onTouchEnd);\n root.addEventListener(\"touchcancel\", onTouchEnd);\n\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart);\n root.removeEventListener(\"touchmove\", onTouchMove);\n root.removeEventListener(\"touchend\", onTouchEnd);\n root.removeEventListener(\"touchcancel\", onTouchEnd);\n };\n }, [finishPull, updatePull]);\n\n useEffect(() => {\n return () => animationRef.current?.stop();\n }, []);\n\n const startPointerPull = (event: ReactPointerEvent<HTMLElement>) => {\n // Everything but touch: a finger is driven by the native listeners above,\n // which can `preventDefault` the page scroll a passive React handler\n // cannot. A pen fires no touch events at all, so this is its only route.\n if (\n event.pointerType === \"touch\" ||\n event.button !== 0 ||\n event.currentTarget.scrollTop > 0 ||\n disabled ||\n isRefreshing\n ) {\n return;\n }\n\n capturePointer(event.currentTarget, event.pointerId);\n gestureRef.current = {\n active: true,\n startX: event.clientX,\n startY: event.clientY,\n pointerId: event.pointerId,\n };\n };\n\n const movePointerPull = (event: ReactPointerEvent<HTMLElement>) => {\n const gesture = gestureRef.current;\n if (!gesture.active || gesture.pointerId !== event.pointerId) return;\n\n const deltaX = event.clientX - gesture.startX;\n const deltaY = event.clientY - gesture.startY;\n if (deltaY < 0 || Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const label =\n status === \"refreshing\" ? refreshingLabel : status === \"ready\" ? releaseLabel : pullingLabel;\n\n return (\n <section\n ref={rootRef}\n aria-label={ariaLabel}\n aria-busy={isRefreshing}\n data-state={status}\n data-disabled={disabled || undefined}\n onPointerDown={startPointerPull}\n onPointerMove={movePointerPull}\n onPointerUp={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n onPointerCancel={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n className={cn(\n \"relative w-full overflow-y-auto overscroll-contain bg-background\",\n // No `touch-none` here — this element is the scroller, and the pull\n // only takes over once the content is already at the top. The callout\n // has to be off from the first frame though: iOS decides on it while\n // the finger is still resting, long before the pull is recognised.\n // Whatever the consumer renders inside stays selectable with a mouse;\n // only the pull itself suppresses selection, and only while it runs,\n // so dragging the page down cannot highlight it on the way.\n TOUCH_GESTURE_CONTENT_CLASS,\n status === \"pulling\" || status === \"ready\" ? \"cursor-grabbing select-none\" : \"cursor-grab\",\n (disabled || isRefreshing) && \"cursor-default\",\n className,\n )}\n >\n <motion.div\n aria-live=\"polite\"\n aria-atomic=\"true\"\n style={\n reduce\n ? { opacity: indicatorOpacity }\n : { opacity: indicatorOpacity, scale: indicatorScale }\n }\n className={cn(\n \"pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-linear-to-b from-background via-background/95 to-transparent font-medium text-[11px] text-muted-foreground\",\n indicatorClassName,\n )}\n >\n <RefreshBuddy progress={progress} status={status} reduce={Boolean(reduce)} />\n <span className=\"relative h-4 min-w-24 text-center\">\n <AnimatePresence initial={false} mode=\"wait\">\n <motion.span\n key={status}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 3 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={LABEL_SWAP}\n className=\"absolute inset-x-0 whitespace-nowrap\"\n >\n {label}\n </motion.span>\n </AnimatePresence>\n </span>\n </motion.div>\n\n <motion.div\n style={reduce ? undefined : { y }}\n className={cn(\n \"relative z-10 min-h-full bg-inherit will-change-transform\",\n contentClassName,\n )}\n >\n {children}\n </motion.div>\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAuDA,MAAM,gBAAyB;CAC7B,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;AACb;AAIA,MAAM,iBAAiB;CACrB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CACjB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CAAE,UAAU;CAAM,MAAM;AAAS;AAEpD,SAAS,iBAAiB,UAAkB,SAAiB;CAC3D,OAAO,WAAW,IAAI,KAAK,IAAI,CAAC,KAAK,IAAI,GAAG,QAAQ,IAAI,OAAO;AACjE;AAEA,SAAS,aAAa,EACpB,UACA,QACA,UAKC;CACD,MAAM,OAAO,aAAa,UAAU,CAAC,G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AAY,EAAE,EAAE;GAChC,WAAW,GACT,6DACA,gBACF;GAEC;EACS,CAAA,CACL;;AAEb"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
3
3
  import { createContext, useCallback, useContext, useId, useMemo, useState } from "react";
4
- import { cn } from "@kumix/utils";
4
+ import { cn } from "cn";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { MotionConfig, motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/radio.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/motion/radio.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype RadioCtx = {\n value: string;\n setValue: (value: string) => void;\n layoutId: string;\n};\n\nconst RadioCtx = createContext<RadioCtx | null>(null);\n\nfunction useRadioGroup() {\n const ctx = useContext(RadioCtx);\n if (!ctx) {\n throw new Error(\"RadioGroupItem must be used inside <RadioGroup>\");\n }\n return ctx;\n}\n\nexport interface RadioGroupProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n orientation?: \"vertical\" | \"horizontal\";\n}\n\nexport function RadioGroup({\n value,\n defaultValue = \"\",\n onValueChange,\n children,\n className,\n orientation = \"vertical\",\n}: RadioGroupProps) {\n const [internal, setInternal] = useState(defaultValue);\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId }),\n [current, layoutId, setValue],\n );\n\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : SPRING_LAYOUT}>\n <RadioCtx.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n className={cn(\n \"flex gap-3\",\n orientation === \"vertical\" ? \"flex-col\" : \"flex-row flex-wrap\",\n className,\n )}\n >\n {children}\n </div>\n </RadioCtx.Provider>\n </MotionConfig>\n );\n}\n\nexport interface RadioGroupItemProps {\n value: string;\n label?: string;\n disabled?: boolean;\n className?: string;\n id?: string;\n}\n\nexport function RadioGroupItem({\n value,\n label,\n disabled,\n className,\n id: idProp,\n}: RadioGroupItemProps) {\n const { value: groupValue, setValue, layoutId } = useRadioGroup();\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const selected = groupValue === value;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex items-center gap-3\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n disabled={disabled}\n onClick={() => !disabled && setValue(value)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={selected ? \"checked\" : \"unchecked\"}\n className={cn(\n \"relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n selected ? \"border-primary\" : \"border-muted-foreground/50 hover:border-muted-foreground\",\n )}\n >\n {selected ? (\n <motion.span\n layoutId={layoutId}\n className=\"absolute inset-1 rounded-full bg-primary\"\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </motion.button>\n {label ? (\n <span className={cn(\"select-none text-foreground text-sm\", disabled && \"opacity-60\")}>\n {label}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;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Y,SAAS,KAAK;GAC1C,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;GACzD,YAAY;GACZ,cAAY,WAAW,YAAY;GACnC,WAAW,GACT,uIACA,iHACA,mDACA,WAAW,mBAAmB,0DAChC;GAEC,UAAA,WACC,oBAAC,OAAO,MAAR;IACY;IACV,WAAU;IACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACxC,CAAA,IACC;EACS,CAAA,GACd,QACC,oBAAC,QAAD;GAAM,WAAW,GAAG,uCAAuC,YAAY,YAAY;GAChF,UAAA;EACG,CAAA,IACJ,IACC;;AAEX"}
1
+ {"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/motion/radio.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { MotionConfig, motion, useReducedMotion } from \"motion/react\";\n\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype RadioCtx = {\n value: string;\n setValue: (value: string) => void;\n layoutId: string;\n};\n\nconst RadioCtx = createContext<RadioCtx | null>(null);\n\nfunction useRadioGroup() {\n const ctx = useContext(RadioCtx);\n if (!ctx) {\n throw new Error(\"RadioGroupItem must be used inside <RadioGroup>\");\n }\n return ctx;\n}\n\nexport interface RadioGroupProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n orientation?: \"vertical\" | \"horizontal\";\n}\n\nexport function RadioGroup({\n value,\n defaultValue = \"\",\n onValueChange,\n children,\n className,\n orientation = \"vertical\",\n}: RadioGroupProps) {\n const [internal, setInternal] = useState(defaultValue);\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId }),\n [current, layoutId, setValue],\n );\n\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : SPRING_LAYOUT}>\n <RadioCtx.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n className={cn(\n \"flex gap-3\",\n orientation === \"vertical\" ? \"flex-col\" : \"flex-row flex-wrap\",\n className,\n )}\n >\n {children}\n </div>\n </RadioCtx.Provider>\n </MotionConfig>\n );\n}\n\nexport interface RadioGroupItemProps {\n value: string;\n label?: string;\n disabled?: boolean;\n className?: string;\n id?: string;\n}\n\nexport function RadioGroupItem({\n value,\n label,\n disabled,\n className,\n id: idProp,\n}: RadioGroupItemProps) {\n const { value: groupValue, setValue, layoutId } = useRadioGroup();\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const selected = groupValue === value;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex items-center gap-3\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n disabled={disabled}\n onClick={() => !disabled && setValue(value)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={selected ? \"checked\" : \"unchecked\"}\n className={cn(\n \"relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n selected ? \"border-primary\" : \"border-muted-foreground/50 hover:border-muted-foreground\",\n )}\n >\n {selected ? (\n <motion.span\n layoutId={layoutId}\n className=\"absolute inset-1 rounded-full bg-primary\"\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </motion.button>\n {label ? (\n <span className={cn(\"select-none text-foreground text-sm\", disabled && \"opacity-60\")}>\n {label}\n </span>\n ) : null}\n </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J;GACV,eAAe,CAAC,YAAY,SAAS,KAAK;GAC1C,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;GACzD,YAAY;GACZ,cAAY,WAAW,YAAY;GACnC,WAAW,GACT,uIACA,iHACA,mDACA,WAAW,mBAAmB,0DAChC;GAEC,UAAA,WACC,oBAAC,OAAO,MAAR;IACY;IACV,WAAU;IACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACxC,CAAA,IACC;EACS,CAAA,GACd,QACC,oBAAC,QAAD;GAAM,WAAW,GAAG,uCAAuC,YAAY,YAAY;GAChF,UAAA;EACG,CAAA,IACJ,IACC;;AAEX"}
@@ -3,7 +3,7 @@ import { TOUCH_GESTURE_CLASS } from "../../lib/touch.js";
3
3
  import { useSlider } from "../../hooks/use-slider.js";
4
4
  import { SPRING_GLIDE, SPRING_PANEL, SPRING_PRESS } from "../../lib/ease.js";
5
5
  import { useEffect } from "react";
6
- import { cn } from "@kumix/utils";
6
+ import { cn } from "cn";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { AnimatePresence, motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform, useVelocity } from "motion/react";
9
9
  //#region src/components/motion/range-slider-bubble.tsx