@kumix/ui 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/README.md +52 -45
  2. package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
  3. package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
  4. package/dist/components/agents/agent-code.js +1 -1
  5. package/dist/components/agents/approval-card/index.d.ts +2 -0
  6. package/dist/components/agents/approval-card/index.d.ts.map +1 -1
  7. package/dist/components/agents/approval-card/index.js +2 -0
  8. package/dist/components/agents/approval-card/index.js.map +1 -1
  9. package/dist/components/agents/citations.d.ts +14 -2
  10. package/dist/components/agents/citations.d.ts.map +1 -1
  11. package/dist/components/agents/citations.js +11 -7
  12. package/dist/components/agents/citations.js.map +1 -1
  13. package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
  14. package/dist/components/agents/loading-states/reasoning-text.js +3 -0
  15. package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
  16. package/dist/components/charts/bump-chart/context.js +1 -2
  17. package/dist/components/charts/bump-chart/plot.js +1 -2
  18. package/dist/components/charts/bump-chart/point.js +1 -1
  19. package/dist/components/charts/bump-chart/series.d.ts +1 -0
  20. package/dist/components/charts/candlestick-chart/context.d.ts +79 -0
  21. package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -0
  22. package/dist/components/charts/candlestick-chart/context.js +69 -0
  23. package/dist/components/charts/candlestick-chart/context.js.map +1 -0
  24. package/dist/components/charts/candlestick-chart/legend.d.ts +12 -0
  25. package/dist/components/charts/candlestick-chart/legend.d.ts.map +1 -0
  26. package/dist/components/charts/candlestick-chart/legend.js +56 -0
  27. package/dist/components/charts/candlestick-chart/legend.js.map +1 -0
  28. package/dist/components/charts/candlestick-chart/plot.d.ts +9 -0
  29. package/dist/components/charts/candlestick-chart/plot.d.ts.map +1 -0
  30. package/dist/components/charts/candlestick-chart/plot.js +218 -0
  31. package/dist/components/charts/candlestick-chart/plot.js.map +1 -0
  32. package/dist/components/charts/candlestick-chart.d.ts +18 -0
  33. package/dist/components/charts/candlestick-chart.d.ts.map +1 -0
  34. package/dist/components/charts/candlestick-chart.js +34 -0
  35. package/dist/components/charts/candlestick-chart.js.map +1 -0
  36. package/dist/components/charts/composition-chart/context.js +1 -2
  37. package/dist/components/charts/composition-chart/plot.js +1 -1
  38. package/dist/components/charts/donut-chart/center.d.ts +16 -0
  39. package/dist/components/charts/donut-chart/center.d.ts.map +1 -0
  40. package/dist/components/charts/donut-chart/center.js +78 -0
  41. package/dist/components/charts/donut-chart/center.js.map +1 -0
  42. package/dist/components/charts/donut-chart/context.d.ts +68 -0
  43. package/dist/components/charts/donut-chart/context.d.ts.map +1 -0
  44. package/dist/components/charts/donut-chart/context.js +2 -0
  45. package/dist/components/charts/donut-chart/legend.d.ts +17 -0
  46. package/dist/components/charts/donut-chart/legend.d.ts.map +1 -0
  47. package/dist/components/charts/donut-chart/legend.js +85 -0
  48. package/dist/components/charts/donut-chart/legend.js.map +1 -0
  49. package/dist/components/charts/donut-chart/plot.d.ts +10 -0
  50. package/dist/components/charts/donut-chart/plot.d.ts.map +1 -0
  51. package/dist/components/charts/donut-chart/plot.js +108 -0
  52. package/dist/components/charts/donut-chart/plot.js.map +1 -0
  53. package/dist/components/charts/donut-chart.d.ts +22 -0
  54. package/dist/components/charts/donut-chart.d.ts.map +1 -0
  55. package/dist/components/charts/donut-chart.js +37 -0
  56. package/dist/components/charts/donut-chart.js.map +1 -0
  57. package/dist/components/charts/funnel-chart.d.ts.map +1 -1
  58. package/dist/components/charts/funnel-chart.js +1 -2
  59. package/dist/components/charts/funnel-chart.js.map +1 -1
  60. package/dist/components/charts/heat-calendar/tooltip.js +1 -1
  61. package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
  62. package/dist/components/charts/liquidity-heatmap.js +1 -1
  63. package/dist/components/charts/order-book/depth-row.d.ts +8 -2
  64. package/dist/components/charts/order-book/depth-row.d.ts.map +1 -1
  65. package/dist/components/charts/order-book/depth-row.js +11 -3
  66. package/dist/components/charts/order-book/depth-row.js.map +1 -1
  67. package/dist/components/charts/order-book.d.ts +33 -1
  68. package/dist/components/charts/order-book.d.ts.map +1 -1
  69. package/dist/components/charts/order-book.js +92 -17
  70. package/dist/components/charts/order-book.js.map +1 -1
  71. package/dist/components/charts/price-target-fan/tooltip.js +1 -1
  72. package/dist/components/charts/returns-calendar/tooltip.js +1 -1
  73. package/dist/components/charts/status-bar/tooltip.js +1 -1
  74. package/dist/components/charts/treemap/tooltip.js +1 -1
  75. package/dist/components/charts/treemap.d.ts.map +1 -1
  76. package/dist/components/charts/volume-profile/tooltip.js +1 -1
  77. package/dist/components/charts/volume-profile.d.ts.map +1 -1
  78. package/dist/components/custom/confirm-dialog.d.ts +1 -0
  79. package/dist/components/custom/toast.d.ts +1 -0
  80. package/dist/components/motion/action-swap.d.ts +1 -1
  81. package/dist/components/motion/action-swap.d.ts.map +1 -1
  82. package/dist/components/motion/action-swap.js +46 -20
  83. package/dist/components/motion/action-swap.js.map +1 -1
  84. package/dist/components/motion/animated-badge.d.ts +1 -1
  85. package/dist/components/motion/animated-badge.d.ts.map +1 -1
  86. package/dist/components/motion/animated-badge.js +60 -101
  87. package/dist/components/motion/animated-badge.js.map +1 -1
  88. package/dist/components/motion/animated-sidebar.d.ts +1 -0
  89. package/dist/components/motion/animated-sidebar.js +1 -1
  90. package/dist/components/motion/animated-toast-stack.js +1 -1
  91. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  92. package/dist/components/motion/attachment-upload.js +2 -3
  93. package/dist/components/motion/attachment-upload.js.map +1 -1
  94. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -2
  95. package/dist/components/motion/availability-scheduler/day-row.js +2 -2
  96. package/dist/components/motion/availability-scheduler/index.js +1 -1
  97. package/dist/components/motion/bloom-menu.d.ts +1 -0
  98. package/dist/components/motion/bloom-menu.d.ts.map +1 -1
  99. package/dist/components/motion/bloom-menu.js +73 -8
  100. package/dist/components/motion/bloom-menu.js.map +1 -1
  101. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  102. package/dist/components/motion/bottom-sheet.js +6 -10
  103. package/dist/components/motion/bottom-sheet.js.map +1 -1
  104. package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
  105. package/dist/components/motion/bounce-sidebar.js +34 -42
  106. package/dist/components/motion/bounce-sidebar.js.map +1 -1
  107. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  108. package/dist/components/motion/bouncy-accordion.js +35 -22
  109. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  110. package/dist/components/motion/button/stateful.d.ts.map +1 -1
  111. package/dist/components/motion/button/stateful.js +3 -0
  112. package/dist/components/motion/button/stateful.js.map +1 -1
  113. package/dist/components/motion/card.d.ts +44 -0
  114. package/dist/components/motion/card.d.ts.map +1 -0
  115. package/dist/components/motion/card.js +122 -0
  116. package/dist/components/motion/card.js.map +1 -0
  117. package/dist/components/motion/center-morph-modal.js +1 -1
  118. package/dist/components/motion/checkbox.d.ts +3 -1
  119. package/dist/components/motion/checkbox.d.ts.map +1 -1
  120. package/dist/components/motion/checkbox.js +18 -6
  121. package/dist/components/motion/checkbox.js.map +1 -1
  122. package/dist/components/motion/color-picker.d.ts +110 -0
  123. package/dist/components/motion/color-picker.d.ts.map +1 -0
  124. package/dist/components/motion/color-picker.js +1053 -0
  125. package/dist/components/motion/color-picker.js.map +1 -0
  126. package/dist/components/motion/color-selector.d.ts.map +1 -1
  127. package/dist/components/motion/color-selector.js +9 -2
  128. package/dist/components/motion/color-selector.js.map +1 -1
  129. package/dist/components/motion/combobox/content.d.ts +1 -0
  130. package/dist/components/motion/command-palette.js +3 -3
  131. package/dist/components/motion/command-palette.js.map +1 -1
  132. package/dist/components/motion/context-menu.d.ts +1 -0
  133. package/dist/components/motion/context-menu.js +1 -1
  134. package/dist/components/motion/date-range-picker.d.ts.map +1 -1
  135. package/dist/components/motion/digit-swap.d.ts +9 -1
  136. package/dist/components/motion/digit-swap.d.ts.map +1 -1
  137. package/dist/components/motion/digit-swap.js +18 -7
  138. package/dist/components/motion/digit-swap.js.map +1 -1
  139. package/dist/components/motion/drawer.d.ts +1 -1
  140. package/dist/components/motion/drawer.d.ts.map +1 -1
  141. package/dist/components/motion/drawer.js +10 -10
  142. package/dist/components/motion/drawer.js.map +1 -1
  143. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
  144. package/dist/components/motion/expandable-control.d.ts +1 -0
  145. package/dist/components/motion/feedback-widget.js +4 -1
  146. package/dist/components/motion/feedback-widget.js.map +1 -1
  147. package/dist/components/motion/knockout-wheel.d.ts.map +1 -1
  148. package/dist/components/motion/knockout-wheel.js +1 -2
  149. package/dist/components/motion/knockout-wheel.js.map +1 -1
  150. package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
  151. package/dist/components/motion/morphing-lightbox.js +1 -1
  152. package/dist/components/motion/morphing-modal.d.ts +6 -1
  153. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  154. package/dist/components/motion/morphing-modal.js +37 -5
  155. package/dist/components/motion/morphing-modal.js.map +1 -1
  156. package/dist/components/motion/morphing-search-chips.d.ts +54 -0
  157. package/dist/components/motion/morphing-search-chips.d.ts.map +1 -0
  158. package/dist/components/motion/morphing-search-chips.js +599 -0
  159. package/dist/components/motion/morphing-search-chips.js.map +1 -0
  160. package/dist/components/motion/morphing-search.js +1 -1
  161. package/dist/components/motion/morphing-tabs.js +1 -1
  162. package/dist/components/motion/multi-select/content.d.ts +1 -0
  163. package/dist/components/motion/not-found/shared.d.ts +1 -0
  164. package/dist/components/motion/number-ticker.d.ts +6 -1
  165. package/dist/components/motion/number-ticker.d.ts.map +1 -1
  166. package/dist/components/motion/number-ticker.js +19 -9
  167. package/dist/components/motion/number-ticker.js.map +1 -1
  168. package/dist/components/motion/otp-input.js +19 -11
  169. package/dist/components/motion/otp-input.js.map +1 -1
  170. package/dist/components/motion/parallax.js.map +1 -1
  171. package/dist/components/motion/popover-morph.d.ts +5 -3
  172. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  173. package/dist/components/motion/popover-morph.js +47 -52
  174. package/dist/components/motion/popover-morph.js.map +1 -1
  175. package/dist/components/motion/popover.d.ts +1 -0
  176. package/dist/components/motion/popover.js +7 -1
  177. package/dist/components/motion/popover.js.map +1 -1
  178. package/dist/components/motion/prediction-market-card.js +2 -3
  179. package/dist/components/motion/prediction-market-card.js.map +1 -1
  180. package/dist/components/motion/prediction-market.js +1 -1
  181. package/dist/components/motion/project-folder.js +1 -1
  182. package/dist/components/motion/radio.d.ts +8 -2
  183. package/dist/components/motion/radio.d.ts.map +1 -1
  184. package/dist/components/motion/radio.js +70 -10
  185. package/dist/components/motion/radio.js.map +1 -1
  186. package/dist/components/motion/scroll-progress.d.ts +1 -0
  187. package/dist/components/motion/select-morph.d.ts +1 -1
  188. package/dist/components/motion/select-morph.d.ts.map +1 -1
  189. package/dist/components/motion/select-morph.js +89 -21
  190. package/dist/components/motion/select-morph.js.map +1 -1
  191. package/dist/components/motion/select.d.ts.map +1 -1
  192. package/dist/components/motion/select.js +153 -135
  193. package/dist/components/motion/select.js.map +1 -1
  194. package/dist/components/motion/shader-background.d.ts +4 -2
  195. package/dist/components/motion/shader-background.d.ts.map +1 -1
  196. package/dist/components/motion/shader-background.js +9 -3
  197. package/dist/components/motion/shader-background.js.map +1 -1
  198. package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
  199. package/dist/components/motion/shared-layout-bg.js +17 -3
  200. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  201. package/dist/components/motion/sortable-list.d.ts +1 -0
  202. package/dist/components/motion/sortable-stack.js +1 -2
  203. package/dist/components/motion/swipeable-list.d.ts.map +1 -1
  204. package/dist/components/motion/swipeable-list.js +61 -4
  205. package/dist/components/motion/swipeable-list.js.map +1 -1
  206. package/dist/components/motion/table/row-handle.js +1 -1
  207. package/dist/components/motion/table/table-header.js +1 -1
  208. package/dist/components/motion/tabs.d.ts +13 -3
  209. package/dist/components/motion/tabs.d.ts.map +1 -1
  210. package/dist/components/motion/tabs.js +248 -26
  211. package/dist/components/motion/tabs.js.map +1 -1
  212. package/dist/components/motion/text-reveal.d.ts +1 -0
  213. package/dist/components/motion/theme-toggle.js +1 -1
  214. package/dist/components/motion/tooltip/positioner.d.ts +8 -26
  215. package/dist/components/motion/tooltip/positioner.d.ts.map +1 -1
  216. package/dist/components/motion/tooltip/positioner.js +1 -2
  217. package/dist/components/motion/tooltip.d.ts +62 -20
  218. package/dist/components/motion/tooltip.d.ts.map +1 -1
  219. package/dist/components/motion/tooltip.js +1 -135
  220. package/dist/components/motion/wallet-card/account-avatar.js +1 -2
  221. package/dist/components/reui/alert.d.ts +1 -1
  222. package/dist/components/reui/autocomplete.d.ts.map +1 -1
  223. package/dist/components/reui/autocomplete.js +1 -1
  224. package/dist/components/reui/autocomplete.js.map +1 -1
  225. package/dist/components/reui/badge.d.ts +1 -1
  226. package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
  227. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
  228. package/dist/components/reui/cascader/cascader-async.js +61 -34
  229. package/dist/components/reui/cascader/cascader-async.js.map +1 -1
  230. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
  231. package/dist/components/reui/cascader/cascader-columns.js +5 -2
  232. package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
  233. package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
  234. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
  235. package/dist/components/reui/cascader/cascader-context.js.map +1 -1
  236. package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
  237. package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
  238. package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
  239. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
  240. package/dist/components/reui/cascader/cascader-lib.js +145 -29
  241. package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
  242. package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
  243. package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
  244. package/dist/components/reui/cascader/cascader.d.ts +13 -8
  245. package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
  246. package/dist/components/reui/cascader/cascader.js +31 -16
  247. package/dist/components/reui/cascader/cascader.js.map +1 -1
  248. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  249. package/dist/components/reui/color-picker.d.ts +280 -0
  250. package/dist/components/reui/color-picker.d.ts.map +1 -0
  251. package/dist/components/reui/color-picker.js +2013 -0
  252. package/dist/components/reui/color-picker.js.map +1 -0
  253. package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
  254. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
  255. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
  256. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
  257. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
  258. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  259. package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
  260. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
  261. package/dist/components/reui/data-grid/data-grid-column-header.js +50 -29
  262. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  263. package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
  264. package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
  265. package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
  266. package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
  267. package/dist/components/reui/data-grid/data-grid-pagination.js +2 -1
  268. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  269. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
  270. package/dist/components/reui/data-grid/data-grid-scroll-area.js +10 -3
  271. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  272. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
  273. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +15 -10
  274. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  275. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
  276. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
  277. package/dist/components/reui/data-grid/data-grid-table-dnd.js +54 -14
  278. package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
  279. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
  280. package/dist/components/reui/data-grid/data-grid-table-virtual.js +37 -42
  281. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  282. package/dist/components/reui/data-grid/data-grid-table.d.ts +174 -16
  283. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  284. package/dist/components/reui/data-grid/data-grid-table.js +223 -89
  285. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  286. package/dist/components/reui/data-grid/data-grid.d.ts +55 -1
  287. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  288. package/dist/components/reui/data-grid/data-grid.js +112 -22
  289. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  290. package/dist/components/reui/date-selector.d.ts +1 -0
  291. package/dist/components/reui/date-selector.d.ts.map +1 -1
  292. package/dist/components/reui/date-selector.js +22 -16
  293. package/dist/components/reui/date-selector.js.map +1 -1
  294. package/dist/components/reui/emoji-picker.d.ts +367 -0
  295. package/dist/components/reui/emoji-picker.d.ts.map +1 -0
  296. package/dist/components/reui/emoji-picker.js +1768 -0
  297. package/dist/components/reui/emoji-picker.js.map +1 -0
  298. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
  299. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
  300. package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -1
  301. package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
  302. package/dist/components/reui/event-calendar/event-calendar-nav.js +4 -4
  303. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
  304. package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
  305. package/dist/components/reui/event-calendar/event-calendar.js +34 -31
  306. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  307. package/dist/components/reui/file-type.d.ts +792 -0
  308. package/dist/components/reui/file-type.d.ts.map +1 -0
  309. package/dist/components/reui/file-type.js +1367 -0
  310. package/dist/components/reui/file-type.js.map +1 -0
  311. package/dist/components/reui/filters/filters-advanced.d.ts +1 -0
  312. package/dist/components/reui/filters/filters-advanced.js +1 -1
  313. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  314. package/dist/components/reui/filters/filters-builder.d.ts +1 -1
  315. package/dist/components/reui/filters/filters-chip.d.ts +5 -1
  316. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
  317. package/dist/components/reui/filters/filters-chip.js +1 -1
  318. package/dist/components/reui/filters/filters-lib.d.ts +1 -1
  319. package/dist/components/reui/filters/filters-lib.d.ts.map +1 -1
  320. package/dist/components/reui/frame.d.ts.map +1 -1
  321. package/dist/components/reui/frame.js.map +1 -1
  322. package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
  323. package/dist/components/reui/gantt/gantt-nav.js +4 -4
  324. package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
  325. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  326. package/dist/components/reui/gantt/gantt.js +5 -2
  327. package/dist/components/reui/gantt/gantt.js.map +1 -1
  328. package/dist/components/reui/icon-tile.d.ts +1 -1
  329. package/dist/components/reui/icon-tile.js +8 -7
  330. package/dist/components/reui/icon-tile.js.map +1 -1
  331. package/dist/components/reui/kanban.d.ts.map +1 -1
  332. package/dist/components/reui/kanban.js +1 -1
  333. package/dist/components/reui/kanban.js.map +1 -1
  334. package/dist/components/reui/number-field.d.ts.map +1 -1
  335. package/dist/components/reui/number-field.js.map +1 -1
  336. package/dist/components/reui/phone-input.js +30 -27
  337. package/dist/components/reui/phone-input.js.map +1 -1
  338. package/dist/components/reui/scrollspy.d.ts +1 -0
  339. package/dist/components/reui/time-picker.js +1 -1
  340. package/dist/components/reui/time-picker.js.map +1 -1
  341. package/dist/components/ui/attachment.d.ts +1 -1
  342. package/dist/components/ui/button-group.d.ts +1 -1
  343. package/dist/components/ui/button.d.ts +1 -1
  344. package/dist/components/ui/chart.d.ts.map +1 -1
  345. package/dist/components/ui/code-block.d.ts +29 -0
  346. package/dist/components/ui/code-block.d.ts.map +1 -0
  347. package/dist/components/ui/code-block.js +124 -0
  348. package/dist/components/ui/code-block.js.map +1 -0
  349. package/dist/components/ui/command.d.ts.map +1 -1
  350. package/dist/components/ui/direction.js +1 -2
  351. package/dist/components/ui/field.d.ts +1 -1
  352. package/dist/components/ui/field.js +1 -1
  353. package/dist/components/ui/input-group.d.ts +1 -1
  354. package/dist/components/ui/marker.d.ts +1 -1
  355. package/dist/components/ui/message-scroller.d.ts.map +1 -1
  356. package/dist/components/ui/questionnaire.d.ts.map +1 -1
  357. package/dist/components/ui/sidebar.js +1 -1
  358. package/dist/components/ui/trace.d.ts +21 -0
  359. package/dist/components/ui/trace.d.ts.map +1 -0
  360. package/dist/components/ui/trace.js +77 -0
  361. package/dist/components/ui/trace.js.map +1 -0
  362. package/dist/context-BYXeJQnz.d.ts.map +1 -1
  363. package/dist/context-tTdLKYNf.js +99 -0
  364. package/dist/context-tTdLKYNf.js.map +1 -0
  365. package/dist/{copy-menu-C5GaT4Z-.js → copy-menu-DOg9Jh-U.js} +2 -2
  366. package/dist/{copy-menu-C5GaT4Z-.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
  367. package/dist/hooks/use-copy-to-clipboard.d.ts +1 -0
  368. package/dist/hooks/use-focus-trap.d.ts +22 -0
  369. package/dist/hooks/use-focus-trap.d.ts.map +1 -0
  370. package/dist/hooks/use-focus-trap.js +80 -0
  371. package/dist/hooks/use-focus-trap.js.map +1 -0
  372. package/dist/hooks/use-highlighted-code.d.ts +5 -0
  373. package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
  374. package/dist/hooks/use-highlighted-code.js +128 -0
  375. package/dist/hooks/use-highlighted-code.js.map +1 -0
  376. package/dist/hooks/use-hover-gesture.d.ts +1 -0
  377. package/dist/hooks/use-intersection-observer.d.ts +1 -0
  378. package/dist/hooks/use-listbox.d.ts +29 -0
  379. package/dist/hooks/use-listbox.d.ts.map +1 -0
  380. package/dist/hooks/use-listbox.js +75 -0
  381. package/dist/hooks/use-listbox.js.map +1 -0
  382. package/dist/hooks/use-scroll-position.d.ts +1 -0
  383. package/dist/hooks/use-slider-input.d.ts +1 -0
  384. package/dist/hooks/use-viewport.d.ts +1 -0
  385. package/dist/lib/tick-sound.d.ts +1 -0
  386. package/dist/model-NSIg2p7a.d.ts +20 -0
  387. package/dist/model-NSIg2p7a.d.ts.map +1 -0
  388. package/dist/model-_mRyI6V9.d.ts +18 -0
  389. package/dist/model-_mRyI6V9.d.ts.map +1 -0
  390. package/dist/{positioner-3mCqiebN.js → positioner-3r3cfkqT.js} +97 -33
  391. package/dist/positioner-3r3cfkqT.js.map +1 -0
  392. package/dist/tooltip-Bam5KeYe.js +535 -0
  393. package/dist/tooltip-Bam5KeYe.js.map +1 -0
  394. package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
  395. package/dist/use-position-DOi1gVL0.d.ts +32 -0
  396. package/dist/use-position-DOi1gVL0.d.ts.map +1 -0
  397. package/package.json +11 -11
  398. package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
  399. package/dist/components/motion/tooltip.js.map +0 -1
  400. package/dist/model-DfeFradZ.d.ts +0 -9
  401. package/dist/model-DfeFradZ.d.ts.map +0 -1
  402. package/dist/positioner-3mCqiebN.js.map +0 -1
@@ -0,0 +1,1768 @@
1
+ "use client";
2
+ import { Button } from "../ui/button.js";
3
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "../ui/dropdown-menu.js";
4
+ import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../ui/input-group.js";
5
+ import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
6
+ import { Tabs, TabsList, TabsTrigger } from "../ui/tabs.js";
7
+ import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty.js";
8
+ import { Skeleton } from "../ui/skeleton.js";
9
+ import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
10
+ import { cn } from "@kumix/utils";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
+ import { CarIcon, ClockIcon, CoffeeIcon, FlagIcon, HeartIcon, LeafIcon, LightbulbIcon, SearchIcon, SmileIcon, SmilePlusIcon, SparklesIcon, UserRoundIcon, VolleyballIcon, XIcon } from "lucide-react";
13
+ //#region src/components/reui/emoji-picker.tsx
14
+ const DEFAULT_EMOJI_PICKER_I18N = {
15
+ labels: {
16
+ trigger: "Add emoji",
17
+ panel: "Emoji picker",
18
+ search: "Search emoji",
19
+ clearSearch: "Clear search",
20
+ list: "Emoji",
21
+ categories: "Emoji categories",
22
+ frequent: "Frequently used",
23
+ recent: "Recently used",
24
+ searchResults: "Search results",
25
+ custom: "Custom",
26
+ smileys: "Smileys & emotion",
27
+ people: "People & body",
28
+ nature: "Animals & nature",
29
+ food: "Food & drink",
30
+ travel: "Travel & places",
31
+ activities: "Activities",
32
+ objects: "Objects",
33
+ symbols: "Symbols",
34
+ flags: "Flags",
35
+ skinTone: "Skin tone",
36
+ skinTones: [
37
+ "Default",
38
+ "Light",
39
+ "Medium-light",
40
+ "Medium",
41
+ "Medium-dark",
42
+ "Dark"
43
+ ],
44
+ empty: "No emoji found",
45
+ emptyHint: "Try another word or a shortcode",
46
+ loading: "Loading emoji",
47
+ error: "Couldn't load emoji",
48
+ retry: "Try again",
49
+ preview: "Pick an emoji"
50
+ },
51
+ functions: {
52
+ formatResultCount: (count) => count === 1 ? "1 emoji found" : `${count} emoji found`,
53
+ formatSelected: (label) => `${label} selected`,
54
+ formatLabel: (label) => label.charAt(0).toLocaleUpperCase() + label.slice(1)
55
+ }
56
+ };
57
+ /** Merges per section, so an override can carry one key without restating the rest. */
58
+ function mergeEmojiPickerI18n(overrides) {
59
+ if (!overrides?.labels && !overrides?.functions) return DEFAULT_EMOJI_PICKER_I18N;
60
+ return {
61
+ labels: {
62
+ ...DEFAULT_EMOJI_PICKER_I18N.labels,
63
+ ...overrides.labels
64
+ },
65
+ functions: {
66
+ ...DEFAULT_EMOJI_PICKER_I18N.functions,
67
+ ...overrides.functions
68
+ }
69
+ };
70
+ }
71
+ /** The pinned emojibase-data release fetched by default. An exact version caches for good. */
72
+ const EMOJI_PICKER_DATA_URL = "https://cdn.jsdelivr.net/npm/emojibase-data@17.0.0";
73
+ const EMOJI_PICKER_CATEGORIES = [
74
+ "smileys",
75
+ "people",
76
+ "nature",
77
+ "food",
78
+ "travel",
79
+ "activities",
80
+ "objects",
81
+ "symbols",
82
+ "flags"
83
+ ];
84
+ const GROUPS = [
85
+ "smileys",
86
+ "people",
87
+ null,
88
+ "nature",
89
+ "food",
90
+ "travel",
91
+ "activities",
92
+ "objects",
93
+ "symbols",
94
+ "flags"
95
+ ];
96
+ const MESSAGE_GROUPS = {
97
+ "smileys-emotion": "smileys",
98
+ "people-body": "people",
99
+ "animals-nature": "nature",
100
+ "food-drink": "food",
101
+ "travel-places": "travel",
102
+ activities: "activities",
103
+ objects: "objects",
104
+ symbols: "symbols",
105
+ flags: "flags"
106
+ };
107
+ const ENGLISH_ONLY_SHORTCODES = /* @__PURE__ */ new Set(["github", "iamcal"]);
108
+ const LOCALE_PATTERN = /^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i;
109
+ const asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
110
+ const asStrings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : typeof value === "string" ? [value] : [];
111
+ /**
112
+ * Turns emojibase's `data.json`, `messages.json` and shortcode files into
113
+ * picker data. Entries it cannot read are dropped rather than trusted.
114
+ */
115
+ function normalizeEmojibaseData(raw, options = {}) {
116
+ if (!Array.isArray(raw)) throw new Error("Unexpected emoji data");
117
+ const locale = options.locale ?? "en";
118
+ const codes = /* @__PURE__ */ new Map();
119
+ for (const map of options.shortcodes ?? []) {
120
+ if (!map || typeof map !== "object") continue;
121
+ for (const [hexcode, value] of Object.entries(map)) {
122
+ const known = codes.get(hexcode) ?? [];
123
+ const added = asStrings(value).filter((code) => !known.includes(code));
124
+ codes.set(hexcode, [...known, ...added]);
125
+ }
126
+ }
127
+ const sorted = [];
128
+ for (const item of raw) {
129
+ const category = typeof item?.group === "number" ? GROUPS[item.group] : void 0;
130
+ if (!category) continue;
131
+ if (typeof item.emoji !== "string" || typeof item.hexcode !== "string") continue;
132
+ const skins = [];
133
+ let skinVersion = 0;
134
+ for (const skin of Array.isArray(item.skins) ? item.skins : []) {
135
+ const tone = skin?.tone;
136
+ if (typeof tone !== "number" || tone < 1 || tone > 5) continue;
137
+ if (typeof skin.emoji !== "string") continue;
138
+ skins[tone - 1] = skin.emoji;
139
+ skinVersion = Math.max(skinVersion, asNumber(skin.version));
140
+ }
141
+ const version = asNumber(item.version);
142
+ sorted.push({
143
+ id: item.hexcode,
144
+ emoji: item.emoji,
145
+ label: typeof item.label === "string" ? item.label : "",
146
+ tags: asStrings(item.tags),
147
+ shortcodes: codes.get(item.hexcode) ?? [],
148
+ category,
149
+ version,
150
+ order: asNumber(item.order),
151
+ ...skins.filter(Boolean).length === 5 && {
152
+ skins,
153
+ ...skinVersion > version && { skinVersion }
154
+ }
155
+ });
156
+ }
157
+ sorted.sort((a, b) => a.order - b.order);
158
+ const emojis = sorted.map(({ order: _order, ...emoji }) => emoji);
159
+ const categories = {};
160
+ const groups = options.messages?.groups;
161
+ for (const group of Array.isArray(groups) ? groups : []) {
162
+ const key = MESSAGE_GROUPS[group?.key];
163
+ if (key && typeof group.message === "string" && group.message) categories[key] = group.message.charAt(0).toLocaleUpperCase(locale) + group.message.slice(1);
164
+ }
165
+ return {
166
+ locale,
167
+ emojis,
168
+ categories
169
+ };
170
+ }
171
+ const dataCache = /* @__PURE__ */ new Map();
172
+ const dataReady = /* @__PURE__ */ new Map();
173
+ function presetsOf(shortcodes) {
174
+ return shortcodes === false ? [] : [shortcodes ?? "github"].flat();
175
+ }
176
+ function dataKey(options) {
177
+ const presets = presetsOf(options.shortcodes);
178
+ return [
179
+ options.url ?? "https://cdn.jsdelivr.net/npm/emojibase-data@17.0.0",
180
+ options.locale ?? "en",
181
+ presets.join("+")
182
+ ].join("|");
183
+ }
184
+ async function fetchEmojiPickerData(options) {
185
+ const locale = options.locale ?? "en";
186
+ if (!LOCALE_PATTERN.test(locale)) throw new Error(`Invalid emoji locale: ${locale}`);
187
+ const base = (options.url ?? "https://cdn.jsdelivr.net/npm/emojibase-data@17.0.0").replace(/\/+$/, "");
188
+ const json = async (path) => {
189
+ const response = await fetch(`${base}/${path}`);
190
+ if (!response.ok) throw new Error(`${response.status} for ${path}`);
191
+ return response.json();
192
+ };
193
+ const optional = (path) => json(path).catch(() => void 0);
194
+ const [raw, messages, ...shortcodes] = await Promise.all([
195
+ json(`${locale}/data.json`),
196
+ optional(`${locale}/messages.json`),
197
+ ...presetsOf(options.shortcodes).map((preset) => optional(`${ENGLISH_ONLY_SHORTCODES.has(preset) ? "en" : locale}/shortcodes/${preset}.json`))
198
+ ]);
199
+ return normalizeEmojibaseData(raw, {
200
+ locale,
201
+ messages,
202
+ shortcodes
203
+ });
204
+ }
205
+ /**
206
+ * Fetches and normalizes emojibase data once per URL, locale and shortcode
207
+ * set; every picker on the page shares the request. A failed load is
208
+ * forgotten, so the next call retries.
209
+ */
210
+ function loadEmojiPickerData(options = {}) {
211
+ const key = dataKey(options);
212
+ let pending = dataCache.get(key);
213
+ if (!pending) {
214
+ pending = fetchEmojiPickerData(options).then((data) => {
215
+ dataReady.set(key, data);
216
+ return data;
217
+ }, (error) => {
218
+ dataCache.delete(key);
219
+ throw error;
220
+ });
221
+ dataCache.set(key, pending);
222
+ }
223
+ return pending;
224
+ }
225
+ /** Loads emoji data for a custom surface: a shortcode autocomplete, a reaction bar. */
226
+ function useEmojiPickerData(options = {}) {
227
+ const { data: provided, enabled = true, locale = "en", url } = options;
228
+ const presetKey = presetsOf(options.shortcodes).join("+");
229
+ const key = dataKey({
230
+ locale,
231
+ url,
232
+ shortcodes: options.shortcodes
233
+ });
234
+ const [result, setResult] = useState(null);
235
+ const [_attempt, setAttempt] = useState(0);
236
+ const ready = dataReady.get(key);
237
+ useEffect(() => {
238
+ if (provided || !enabled || dataReady.has(key)) return;
239
+ let alive = true;
240
+ const shortcodes = presetKey ? presetKey.split("+") : false;
241
+ loadEmojiPickerData({
242
+ locale,
243
+ url,
244
+ shortcodes
245
+ }).then((data) => alive && setResult({
246
+ key,
247
+ data
248
+ }), (error) => alive && setResult({
249
+ key,
250
+ error
251
+ }));
252
+ return () => {
253
+ alive = false;
254
+ };
255
+ }, [
256
+ provided,
257
+ enabled,
258
+ key,
259
+ locale,
260
+ url,
261
+ presetKey
262
+ ]);
263
+ const current = result?.key === key ? result : null;
264
+ const data = provided ?? current?.data ?? ready ?? null;
265
+ return {
266
+ data,
267
+ status: data ? "ready" : current?.error !== void 0 ? "error" : enabled ? "loading" : "idle",
268
+ error: current?.error,
269
+ retry: () => {
270
+ setResult(null);
271
+ setAttempt((count) => count + 1);
272
+ }
273
+ };
274
+ }
275
+ const EMOJI_FONT = "\"Apple Color Emoji\", \"Twemoji Mozilla\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\", sans-serif";
276
+ const FULL_SUPPORT = {
277
+ version: Infinity,
278
+ flags: true
279
+ };
280
+ const supportCache = /* @__PURE__ */ new WeakMap();
281
+ const PROBE = 20;
282
+ function drawsAsEmoji(context, text) {
283
+ const draw = (color) => {
284
+ context.clearRect(0, 0, 40, 40);
285
+ context.fillStyle = color;
286
+ context.fillText(text, 0, 0);
287
+ return context.getImageData(0, 0, 40, PROBE).data;
288
+ };
289
+ const red = draw("#f00");
290
+ const blue = draw("#00f");
291
+ let ink = false;
292
+ for (let index = 3; index < red.length; index += 4) {
293
+ if (!red[index] && !blue[index]) continue;
294
+ ink = true;
295
+ if (red[index - 3] !== blue[index - 3] || red[index - 1] !== blue[index - 1]) return false;
296
+ }
297
+ return ink && context.measureText(text).width < PROBE * 1.6;
298
+ }
299
+ /**
300
+ * The newest Emoji version this device draws, probed with the first emoji of
301
+ * each version in the data, newest first, plus a flag. A probe that fails
302
+ * even the oldest version is unreliable (blocked or noised canvas), so it
303
+ * reports full support rather than an empty grid.
304
+ */
305
+ function detectSupport(emojis) {
306
+ const cached = supportCache.get(emojis);
307
+ if (cached) return cached;
308
+ let support = FULL_SUPPORT;
309
+ const canvas = typeof document === "undefined" ? null : document.createElement("canvas");
310
+ canvas?.setAttribute("width", String(40));
311
+ canvas?.setAttribute("height", String(40));
312
+ const context = canvas?.getContext("2d", { willReadFrequently: true });
313
+ if (context) {
314
+ context.font = `${PROBE}px ${EMOJI_FONT}`;
315
+ context.textBaseline = "top";
316
+ const samples = /* @__PURE__ */ new Map();
317
+ for (const emoji of emojis) {
318
+ if (emoji.src || isRegionalFlag(emoji.emoji)) continue;
319
+ if (!samples.has(emoji.version)) samples.set(emoji.version, emoji.emoji);
320
+ }
321
+ const versions = [...samples.keys()].sort((a, b) => b - a);
322
+ const found = versions.find((version) => drawsAsEmoji(context, samples.get(version)));
323
+ if (found !== void 0) support = {
324
+ version: found === versions[0] ? Infinity : found,
325
+ flags: drawsAsEmoji(context, "🇪🇺")
326
+ };
327
+ }
328
+ supportCache.set(emojis, support);
329
+ return support;
330
+ }
331
+ function isRegionalFlag(text) {
332
+ return /^(?:[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0060}-\u{E007F}]+)$/u.test(text);
333
+ }
334
+ const subscribeNothing = () => () => {};
335
+ function useEmojiSupport(data, setting) {
336
+ const detected = useSyncExternalStore(subscribeNothing, () => setting === "auto" && data ? detectSupport(data.emojis) : FULL_SUPPORT, () => FULL_SUPPORT);
337
+ return useMemo(() => setting === "auto" ? detected : {
338
+ version: setting,
339
+ flags: true
340
+ }, [setting, detected]);
341
+ }
342
+ const fold = (text) => text.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[\u3041-\u3096]/g, (kana) => String.fromCharCode(kana.charCodeAt(0) + 96));
343
+ const searchIndexCache = /* @__PURE__ */ new WeakMap();
344
+ function searchIndexOf(emoji) {
345
+ let index = searchIndexCache.get(emoji);
346
+ if (!index) {
347
+ const label = fold(emoji.label);
348
+ index = {
349
+ label,
350
+ words: label.split(/[\s:,-]+/).filter(Boolean),
351
+ tags: emoji.tags.map(fold),
352
+ shortcodes: emoji.shortcodes.map(fold)
353
+ };
354
+ searchIndexCache.set(emoji, index);
355
+ }
356
+ return index;
357
+ }
358
+ function scoreTerm(index, term) {
359
+ let best = 0;
360
+ const take = (score) => {
361
+ if (score > best) best = score;
362
+ };
363
+ if (index.label === term) take(100);
364
+ for (const code of index.shortcodes) if (code === term) take(100);
365
+ else if (code.startsWith(term)) take(80);
366
+ else if (code.includes(term)) take(30);
367
+ if (index.label.startsWith(term)) take(75);
368
+ for (const word of index.words) if (word.startsWith(term)) take(70);
369
+ for (const tag of index.tags) if (tag === term) take(60);
370
+ else if (tag.startsWith(term)) take(50);
371
+ else if (tag.includes(term)) take(20);
372
+ if (best === 0 && index.label.includes(term)) take(35);
373
+ return best;
374
+ }
375
+ /**
376
+ * Ranks emoji against a query. Every word must match the name, a keyword or
377
+ * a shortcode; colons around a shortcode are ignored, so `:thumbsup:` works.
378
+ * Ties keep the input order.
379
+ */
380
+ function searchEmojis(emojis, query, options = {}) {
381
+ const terms = fold(query).replace(/:/g, " ").split(/\s+/).filter(Boolean);
382
+ if (terms.length === 0) return [];
383
+ const exact = query.trim();
384
+ const scored = [];
385
+ emojis.forEach((emoji, at) => {
386
+ if (exact && isEmojiValue(emoji, exact)) {
387
+ scored.push({
388
+ emoji,
389
+ score: 1e3,
390
+ at
391
+ });
392
+ return;
393
+ }
394
+ const index = searchIndexOf(emoji);
395
+ let score = 0;
396
+ for (const term of terms) {
397
+ const termScore = scoreTerm(index, term);
398
+ if (termScore === 0) return;
399
+ score += termScore;
400
+ }
401
+ scored.push({
402
+ emoji,
403
+ score,
404
+ at
405
+ });
406
+ });
407
+ scored.sort((a, b) => b.score - a.score || a.at - b.at);
408
+ const ranked = scored.map((entry) => entry.emoji);
409
+ return options.limit === void 0 ? ranked : ranked.slice(0, options.limit);
410
+ }
411
+ /** The value a pick stores: the toned native emoji, or `:shortcode:` for a custom one. */
412
+ function getEmojiValue(emoji, skinTone = 0) {
413
+ if (emoji.src) return `:${emoji.shortcodes[0] ?? emoji.id}:`;
414
+ return skinTone > 0 && emoji.skins?.[skinTone - 1] || emoji.emoji;
415
+ }
416
+ const bare = (text) => text.replace(/\uFE0F/g, "");
417
+ /** Whether a stored value is this emoji: any tone, with or without VS16. */
418
+ function isEmojiValue(emoji, value) {
419
+ const target = bare(value);
420
+ return bare(getEmojiValue(emoji)) === target || !!emoji.skins?.some((skin) => bare(skin) === target);
421
+ }
422
+ /** Finds the emoji a value came from, any tone, or a custom emoji's `:shortcode:`. */
423
+ function findEmoji(emojis, value) {
424
+ if (!value) return void 0;
425
+ return emojis.find((emoji) => isEmojiValue(emoji, value));
426
+ }
427
+ const storageListeners = /* @__PURE__ */ new Map();
428
+ const storageMemory = /* @__PURE__ */ new Map();
429
+ function readStored(key) {
430
+ if (storageMemory.has(key)) return storageMemory.get(key);
431
+ try {
432
+ return window.localStorage.getItem(key);
433
+ } catch {
434
+ return null;
435
+ }
436
+ }
437
+ function writeStored(key, value) {
438
+ try {
439
+ window.localStorage.setItem(key, value);
440
+ storageMemory.delete(key);
441
+ } catch {
442
+ storageMemory.set(key, value);
443
+ }
444
+ for (const listener of storageListeners.get(key) ?? []) listener();
445
+ }
446
+ function subscribeStored(key, listener) {
447
+ let listeners = storageListeners.get(key);
448
+ if (!listeners) {
449
+ listeners = /* @__PURE__ */ new Set();
450
+ storageListeners.set(key, listeners);
451
+ }
452
+ listeners.add(listener);
453
+ const onStorage = (event) => {
454
+ if (event.key !== key && event.key !== null) return;
455
+ storageMemory.delete(key);
456
+ listener();
457
+ };
458
+ window.addEventListener("storage", onStorage);
459
+ return () => {
460
+ listeners.delete(listener);
461
+ window.removeEventListener("storage", onStorage);
462
+ };
463
+ }
464
+ function useStored(key) {
465
+ const subscribe = useCallback((listener) => key ? subscribeStored(key, listener) : () => {}, [key]);
466
+ return useSyncExternalStore(subscribe, () => key ? readStored(key) : null, () => null);
467
+ }
468
+ function parseRecent(raw) {
469
+ if (!raw) return null;
470
+ try {
471
+ const list = JSON.parse(raw);
472
+ if (!Array.isArray(list)) return null;
473
+ return list.flatMap((entry) => entry && typeof entry.id === "string" ? [{
474
+ id: entry.id,
475
+ count: Math.max(1, asNumber(entry.count))
476
+ }] : []);
477
+ } catch {
478
+ return null;
479
+ }
480
+ }
481
+ function parseTone(raw) {
482
+ const tone = Number(raw);
483
+ return raw !== null && Number.isInteger(tone) && tone >= 0 && tone <= 5 ? tone : null;
484
+ }
485
+ const PADDING = 8;
486
+ const sizeOf = (cell, emoji, header) => ({
487
+ cell,
488
+ emoji,
489
+ header,
490
+ gutter: PADDING - (cell - emoji) / 2
491
+ });
492
+ const SIZES = {
493
+ sm: sizeOf(26, 16, 28),
494
+ default: sizeOf(30, 20, 28),
495
+ lg: sizeOf(38, 26, 32)
496
+ };
497
+ const VISIBLE_ROWS = 7;
498
+ const OVERSCAN = 4;
499
+ const RECENT_CAP = 48;
500
+ const FALLBACK_HEIGHT = 320;
501
+ const cellKey = (section, id) => `${section}\u0000${id}`;
502
+ function buildLayout(sections, columns, size) {
503
+ const layoutSections = [];
504
+ const rows = [];
505
+ const positions = /* @__PURE__ */ new Map();
506
+ let top = 0;
507
+ sections.forEach((section, index) => {
508
+ const firstRow = rows.length;
509
+ const count = Math.ceil(section.emojis.length / columns);
510
+ for (let row = 0; row < count; row++) {
511
+ const cells = section.emojis.slice(row * columns, (row + 1) * columns);
512
+ for (let col = 0; col < cells.length; col++) positions.set(cellKey(section.id, cells[col].id), {
513
+ row: rows.length,
514
+ col
515
+ });
516
+ rows.push({
517
+ section: index,
518
+ top: top + size.header + row * size.cell,
519
+ cells
520
+ });
521
+ }
522
+ const height = size.header + count * size.cell;
523
+ layoutSections.push({
524
+ section,
525
+ top,
526
+ height,
527
+ firstRow
528
+ });
529
+ top += height;
530
+ });
531
+ return {
532
+ sections: layoutSections,
533
+ rows,
534
+ height: top + size.gutter,
535
+ positions
536
+ };
537
+ }
538
+ function indexAt(items, offset) {
539
+ let low = 0;
540
+ let high = items.length - 1;
541
+ let found = 0;
542
+ while (low <= high) {
543
+ const middle = low + high >> 1;
544
+ if (items[middle].top <= offset) {
545
+ found = middle;
546
+ low = middle + 1;
547
+ } else high = middle - 1;
548
+ }
549
+ return found;
550
+ }
551
+ const CATEGORY_ICONS = {
552
+ recent: /* @__PURE__ */ jsx(ClockIcon, { "aria-hidden": "true" }),
553
+ smileys: /* @__PURE__ */ jsx(SmileIcon, { "aria-hidden": "true" }),
554
+ people: /* @__PURE__ */ jsx(UserRoundIcon, { "aria-hidden": "true" }),
555
+ nature: /* @__PURE__ */ jsx(LeafIcon, { "aria-hidden": "true" }),
556
+ food: /* @__PURE__ */ jsx(CoffeeIcon, { "aria-hidden": "true" }),
557
+ travel: /* @__PURE__ */ jsx(CarIcon, { "aria-hidden": "true" }),
558
+ activities: /* @__PURE__ */ jsx(VolleyballIcon, { "aria-hidden": "true" }),
559
+ objects: /* @__PURE__ */ jsx(LightbulbIcon, { "aria-hidden": "true" }),
560
+ symbols: /* @__PURE__ */ jsx(HeartIcon, { "aria-hidden": "true" }),
561
+ flags: /* @__PURE__ */ jsx(FlagIcon, { "aria-hidden": "true" }),
562
+ custom: /* @__PURE__ */ jsx(SparklesIcon, { "aria-hidden": "true" })
563
+ };
564
+ const TRIGGER_ICON = /* @__PURE__ */ jsx(SmilePlusIcon, { "aria-hidden": "true" });
565
+ const SEARCH_ICON = /* @__PURE__ */ jsx(SearchIcon, { "aria-hidden": "true" });
566
+ const CLEAR_ICON = /* @__PURE__ */ jsx(XIcon, { "aria-hidden": "true" });
567
+ const EmojiPickerContext = createContext(null);
568
+ /** "inline" unless a part renders inside `EmojiPickerContent`. */
569
+ const SurfaceContext = createContext("inline");
570
+ function useEmojiPickerContext(part) {
571
+ const context = useContext(EmojiPickerContext);
572
+ if (!context) throw new Error(`${part} must be used within an EmojiPicker`);
573
+ return context;
574
+ }
575
+ const EMPTY_RECENT = [];
576
+ const toValues = (value) => Array.isArray(value) ? value : value ? [value] : [];
577
+ function assignRef(ref, node) {
578
+ if (typeof ref === "function") ref(node);
579
+ else if (ref) ref.current = node;
580
+ }
581
+ function normalizeCustom(emoji) {
582
+ return {
583
+ id: emoji.id,
584
+ emoji: "",
585
+ label: emoji.label,
586
+ tags: emoji.tags ?? [],
587
+ shortcodes: emoji.shortcodes?.length ? emoji.shortcodes : [emoji.id],
588
+ category: emoji.category ?? "custom",
589
+ version: 0,
590
+ src: emoji.src
591
+ };
592
+ }
593
+ function EmojiPicker(props) {
594
+ const { onEmojiSelect, open: openProp, defaultOpen = false, onOpenChange, data: dataProp, locale = "en", dataUrl, shortcodes = "github", emojiVersion = "auto", categories, filter, customEmojis, customCategories, recentMode = "frequent", recentLimit, recent: recentProp, defaultRecent, onRecentChange, recentStorageKey = "reui-emoji-picker-recent", skinTone: skinToneProp, defaultSkinTone = 0, onSkinToneChange, skinToneStorageKey = "reui-emoji-picker-skin-tone", query: queryProp, onQueryChange, size = "default", columns = 8, renderEmoji, disabled = false, invalid = false, name, form, required = false, inputRef, id: idProp, "aria-label": label, "aria-labelledby": labelledBy, "aria-describedby": describedBy, i18n: i18nProp, className, children } = props;
595
+ const multiple = props.multiple === true;
596
+ const max = props.multiple ? props.max : void 0;
597
+ const closeOnSelect = props.closeOnSelect ?? !multiple;
598
+ const generatedId = useId();
599
+ const id = idProp ?? generatedId;
600
+ const listId = `${id}-list`;
601
+ const tokens = SIZES[size];
602
+ const [uncontrolled, setUncontrolled] = useState(() => toValues(props.defaultValue));
603
+ const [initialValues] = useState(uncontrolled);
604
+ const values = props.value !== void 0 ? toValues(props.value) : uncontrolled;
605
+ const valueMode = props.value !== void 0 || props.defaultValue !== void 0 || multiple || !!name;
606
+ const [openState, setOpenState] = useState(defaultOpen);
607
+ const open = openProp ?? openState;
608
+ const [queryState, setQueryState] = useState("");
609
+ const query = queryProp ?? queryState;
610
+ const [active, setActive] = useState(null);
611
+ const [focused, setFocused] = useState(false);
612
+ const [activeSection, setActiveSection] = useState(null);
613
+ const [jump, setJump] = useState(null);
614
+ const [measuredColumns, setMeasuredColumns] = useState(null);
615
+ const [hasSearch, setHasSearch] = useState(false);
616
+ const [wanted, setWanted] = useState(false);
617
+ const [announcement, setAnnouncement] = useState("");
618
+ const [seenOpen, setSeenOpen] = useState(open);
619
+ const [pinnedRecent, setPinnedRecent] = useState(null);
620
+ if (seenOpen !== open) {
621
+ setSeenOpen(open);
622
+ setQueryState("");
623
+ setActive(null);
624
+ setFocused(false);
625
+ setJump(null);
626
+ setAnnouncement("");
627
+ setPinnedRecent(null);
628
+ }
629
+ const [seenLocale, setSeenLocale] = useState(locale);
630
+ if (seenLocale !== locale) {
631
+ setSeenLocale(locale);
632
+ setAnnouncement("");
633
+ }
634
+ const searchRef = useRef(null);
635
+ const listRef = useRef(null);
636
+ const focusTarget = useRef(null);
637
+ const fieldRef = useRef(null);
638
+ const resetRef = useRef(() => {});
639
+ const pageRows = useRef(VISIBLE_ROWS);
640
+ const goalColumn = useRef(null);
641
+ const requestData = useCallback(() => setWanted(true), []);
642
+ const { data, status, retry } = useEmojiPickerData({
643
+ data: dataProp,
644
+ locale,
645
+ url: dataUrl,
646
+ shortcodes,
647
+ enabled: wanted || open
648
+ });
649
+ const support = useEmojiSupport(data, emojiVersion);
650
+ const i18n = useMemo(() => mergeEmojiPickerI18n(i18nProp), [i18nProp]);
651
+ const { labels } = i18n;
652
+ const columnCount = columns === "auto" ? measuredColumns ?? 8 : Math.max(1, columns);
653
+ const unicode = useMemo(() => {
654
+ if (!data) return [];
655
+ return data.emojis.flatMap((emoji) => {
656
+ if (emoji.version > support.version) return [];
657
+ if (!support.flags && isRegionalFlag(emoji.emoji)) return [];
658
+ if (filter && !filter(emoji)) return [];
659
+ return emoji.skins && (emoji.skinVersion ?? 0) > support.version ? [{
660
+ ...emoji,
661
+ skins: void 0,
662
+ skinVersion: void 0
663
+ }] : [emoji];
664
+ });
665
+ }, [
666
+ data,
667
+ support,
668
+ filter
669
+ ]);
670
+ const custom = useMemo(() => (customEmojis ?? []).map(normalizeCustom).filter((emoji) => !filter || filter(emoji)), [customEmojis, filter]);
671
+ const all = useMemo(() => [...custom, ...unicode], [custom, unicode]);
672
+ const byId = useMemo(() => new Map(all.map((emoji) => [emoji.id, emoji])), [all]);
673
+ const byValue = useMemo(() => {
674
+ const map = /* @__PURE__ */ new Map();
675
+ for (const emoji of [...custom, ...data?.emojis ?? []]) {
676
+ map.set(bare(getEmojiValue(emoji)), emoji);
677
+ for (const skin of emoji.skins ?? []) map.set(bare(skin), emoji);
678
+ }
679
+ return map;
680
+ }, [custom, data]);
681
+ const storedRecent = useStored(recentProp === void 0 ? recentStorageKey : null);
682
+ const parsedRecent = useMemo(() => parseRecent(storedRecent), [storedRecent]);
683
+ const [memoryRecent, setMemoryRecent] = useState(defaultRecent ?? EMPTY_RECENT);
684
+ const recentEntries = recentProp ?? (recentStorageKey ? parsedRecent ?? defaultRecent ?? EMPTY_RECENT : memoryRecent);
685
+ const shownRecent = recentLimit ?? columnCount * 2;
686
+ const shownEntries = pinnedRecent ?? recentEntries;
687
+ const recent = useMemo(() => {
688
+ return (recentMode === "frequent" ? [...shownEntries].sort((a, b) => b.count - a.count) : shownEntries).flatMap((entry) => byId.get(entry.id) ?? []).slice(0, shownRecent);
689
+ }, [
690
+ shownEntries,
691
+ recentMode,
692
+ byId,
693
+ shownRecent
694
+ ]);
695
+ const storedTone = useStored(skinToneProp === void 0 ? skinToneStorageKey : null);
696
+ const [memoryTone, setMemoryTone] = useState(defaultSkinTone);
697
+ const skinTone = skinToneProp ?? (skinToneStorageKey ? parseTone(storedTone) ?? defaultSkinTone : memoryTone);
698
+ const tabs = useMemo(() => {
699
+ const customIds = [.../* @__PURE__ */ new Set([...(customCategories ?? []).map((category) => category.id), ...custom.map((emoji) => emoji.category)])];
700
+ const order = categories ?? [
701
+ "recent",
702
+ ...customIds,
703
+ ...EMOJI_PICKER_CATEGORIES
704
+ ];
705
+ const grouped = /* @__PURE__ */ new Map();
706
+ for (const emoji of all) {
707
+ const list = grouped.get(emoji.category);
708
+ if (list) list.push(emoji);
709
+ else grouped.set(emoji.category, [emoji]);
710
+ }
711
+ const sections = [];
712
+ for (const key of new Set(order)) {
713
+ const emojis = key === "recent" ? recent : grouped.get(key);
714
+ if (!emojis?.length) continue;
715
+ const customCategory = customCategories?.find((item) => item.id === key);
716
+ sections.push({
717
+ id: key,
718
+ label: key === "recent" ? labels[recentMode] : customCategory?.label ?? categoryLabel(key, labels, i18nProp, data) ?? labels.custom,
719
+ emojis,
720
+ icon: customCategory?.icon ?? CATEGORY_ICONS[key] ?? CATEGORY_ICONS.custom
721
+ });
722
+ }
723
+ return sections;
724
+ }, [
725
+ all,
726
+ recent,
727
+ categories,
728
+ customCategories,
729
+ custom,
730
+ labels,
731
+ recentMode,
732
+ i18nProp,
733
+ data
734
+ ]);
735
+ const placeholderTabs = useMemo(() => (categories ?? EMOJI_PICKER_CATEGORIES).flatMap((key) => EMOJI_PICKER_CATEGORIES.includes(key) ? [{
736
+ id: key,
737
+ label: labels[key],
738
+ emojis: [],
739
+ icon: CATEGORY_ICONS[key]
740
+ }] : []), [categories, labels]);
741
+ const results = useMemo(() => query.trim() ? searchEmojis(all, query) : null, [all, query]);
742
+ const sections = useMemo(() => results ? results.length ? [{
743
+ id: "search",
744
+ label: labels.searchResults,
745
+ emojis: results,
746
+ icon: null
747
+ }] : [] : tabs, [
748
+ results,
749
+ tabs,
750
+ labels
751
+ ]);
752
+ const layout = useMemo(() => buildLayout(sections, columnCount, tokens), [
753
+ sections,
754
+ columnCount,
755
+ tokens
756
+ ]);
757
+ let activePosition = active ? layout.positions.get(cellKey(active.section, active.id)) : void 0;
758
+ if (!activePosition && results && layout.rows.length) activePosition = {
759
+ row: 0,
760
+ col: 0
761
+ };
762
+ const activeEmoji = activePosition ? layout.rows[activePosition.row].cells[activePosition.col] : null;
763
+ const selected = useMemo(() => new Set(values.map(bare)), [values]);
764
+ const isSelected = (emoji) => selected.has(bare(getEmojiValue(emoji))) || !!emoji.skins?.some((skin) => selected.has(bare(skin)));
765
+ const full = multiple && max !== void 0 && values.length >= max;
766
+ const setOpen = (next) => {
767
+ if (next && disabled) return;
768
+ if (openProp === void 0) setOpenState(next);
769
+ onOpenChange?.(next);
770
+ };
771
+ const setQuery = (next) => {
772
+ if (queryProp === void 0) setQueryState(next);
773
+ onQueryChange?.(next);
774
+ setActive(null);
775
+ setAnnouncement("");
776
+ };
777
+ const setSkinTone = (tone) => {
778
+ if (skinToneProp === void 0) {
779
+ if (skinToneStorageKey) writeStored(skinToneStorageKey, String(tone));
780
+ else setMemoryTone(tone);
781
+ }
782
+ onSkinToneChange?.(tone);
783
+ };
784
+ const commitValues = (next) => {
785
+ if (next.length === values.length && next.every((v, i) => v === values[i])) return;
786
+ if (props.value === void 0) setUncontrolled(next);
787
+ if (props.multiple) props.onValueChange?.(next);
788
+ else props.onValueChange?.(next[0] ?? null);
789
+ };
790
+ const recordRecent = (emojiId) => {
791
+ if (pinnedRecent === null) setPinnedRecent(recentEntries);
792
+ const next = [{
793
+ id: emojiId,
794
+ count: (recentEntries.find((entry) => entry.id === emojiId)?.count ?? 0) + 1
795
+ }, ...recentEntries.filter((entry) => entry.id !== emojiId)].slice(0, RECENT_CAP);
796
+ if (recentProp === void 0) {
797
+ if (recentStorageKey) writeStored(recentStorageKey, JSON.stringify(next));
798
+ else setMemoryRecent(next);
799
+ }
800
+ onRecentChange?.(next);
801
+ };
802
+ const pick = (emoji, event) => {
803
+ if (disabled) return;
804
+ const tone = emoji.skins ? skinTone : 0;
805
+ const value = getEmojiValue(emoji, tone);
806
+ if (multiple && isSelected(emoji)) {
807
+ commitValues(values.filter((item) => !isEmojiValue(emoji, item)));
808
+ return;
809
+ }
810
+ if (full) return;
811
+ commitValues(multiple ? [...values, value] : [value]);
812
+ onEmojiSelect?.({
813
+ value,
814
+ emoji,
815
+ skinTone: tone
816
+ });
817
+ recordRecent(emoji.id);
818
+ if (closeOnSelect && !event?.shiftKey && open) setOpen(false);
819
+ else setAnnouncement(i18n.functions.formatSelected(i18n.functions.formatLabel(emoji.label)));
820
+ };
821
+ const move = (to) => {
822
+ const { rows } = layout;
823
+ if (rows.length === 0) return;
824
+ const at = activePosition;
825
+ let row = 0;
826
+ let col = 0;
827
+ if (!at && to !== "first" && to !== "last") to = "visible";
828
+ if (to === "visible") {
829
+ const offset = (listRef.current?.scrollTop ?? 0) + tokens.header - 1;
830
+ row = indexAt(rows, offset);
831
+ if (rows[row].top < offset && row + 1 < rows.length) row++;
832
+ goalColumn.current = null;
833
+ } else if (at && to !== "first" && to !== "last") {
834
+ row = at.row;
835
+ col = at.col;
836
+ const vertical = to === "up" || to === "down" || to === "pageUp" || to === "pageDown";
837
+ if (vertical) col = goalColumn.current ?? col;
838
+ if (to === "next") {
839
+ if (col + 1 < rows[row].cells.length) col++;
840
+ else if (row + 1 < rows.length) [row, col] = [row + 1, 0];
841
+ } else if (to === "prev") {
842
+ if (col > 0) col--;
843
+ else if (row > 0) [row, col] = [row - 1, rows[row - 1].cells.length - 1];
844
+ } else if (to === "down") row = Math.min(row + 1, rows.length - 1);
845
+ else if (to === "pageDown") row = Math.min(row + pageRows.current, rows.length - 1);
846
+ else if (to === "pageUp") row = Math.max(row - pageRows.current, 0);
847
+ else if (to === "up") {
848
+ if (row === 0 && !results) {
849
+ setActive(null);
850
+ return;
851
+ }
852
+ row = Math.max(row - 1, 0);
853
+ }
854
+ goalColumn.current = vertical ? col : null;
855
+ col = Math.min(col, rows[row].cells.length - 1);
856
+ } else if (to === "last") {
857
+ row = rows.length - 1;
858
+ col = rows[row].cells.length - 1;
859
+ goalColumn.current = null;
860
+ } else goalColumn.current = null;
861
+ const cell = rows[row].cells[col];
862
+ setActive({
863
+ section: layout.sections[rows[row].section].section.id,
864
+ id: cell.id,
865
+ source: "keyboard"
866
+ });
867
+ };
868
+ const navigate = (event, fromSearch) => {
869
+ if (event.nativeEvent.isComposing || event.altKey || event.ctrlKey || event.metaKey) return;
870
+ const inGrid = !fromSearch || active?.source === "keyboard";
871
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
872
+ const run = (to) => {
873
+ event.preventDefault();
874
+ move(to);
875
+ };
876
+ switch (event.key) {
877
+ case "ArrowDown": return run(activePosition ? "down" : "visible");
878
+ case "ArrowUp":
879
+ if (activePosition) return run("up");
880
+ return fromSearch ? void 0 : run("visible");
881
+ case "ArrowRight":
882
+ case "ArrowLeft":
883
+ if (!inGrid) return;
884
+ return run(event.key === "ArrowRight" !== rtl ? "next" : "prev");
885
+ case "PageDown": return run("pageDown");
886
+ case "PageUp": return run("pageUp");
887
+ case "Home":
888
+ case "End":
889
+ if (fromSearch) return;
890
+ return run(event.key === "Home" ? "first" : "last");
891
+ case "Enter":
892
+ case " ":
893
+ if (event.key === " " && fromSearch) return;
894
+ if (!activeEmoji) return;
895
+ event.preventDefault();
896
+ return pick(activeEmoji, event);
897
+ }
898
+ };
899
+ const context = {
900
+ id,
901
+ listId,
902
+ data,
903
+ status,
904
+ retry,
905
+ requestData,
906
+ emojis: all,
907
+ i18n,
908
+ size: tokens,
909
+ columns,
910
+ columnCount,
911
+ setMeasuredColumns,
912
+ query,
913
+ setQuery,
914
+ skinTone,
915
+ setSkinTone,
916
+ tabs,
917
+ placeholderTabs,
918
+ layout,
919
+ active,
920
+ activePosition,
921
+ activeEmoji,
922
+ setActive: (cell) => {
923
+ goalColumn.current = null;
924
+ setActive(cell);
925
+ },
926
+ activeSection,
927
+ setActiveSection,
928
+ jump,
929
+ setJump,
930
+ jumpTo: (sectionId) => {
931
+ if (results) setQuery("");
932
+ setActive(null);
933
+ setJump(sectionId);
934
+ },
935
+ setPageRows: (rows) => {
936
+ pageRows.current = rows;
937
+ },
938
+ navigate,
939
+ move,
940
+ releaseKeyboard: () => setActive((current) => current?.source === "keyboard" ? {
941
+ ...current,
942
+ source: "pointer"
943
+ } : current),
944
+ focused,
945
+ setFocused,
946
+ pick,
947
+ clear: () => commitValues([]),
948
+ isSelected,
949
+ full,
950
+ valueMode,
951
+ multiple,
952
+ values,
953
+ findByValue: (value) => byValue.get(bare(value)),
954
+ renderEmoji,
955
+ announcement,
956
+ disabled,
957
+ invalid,
958
+ label,
959
+ labelledBy,
960
+ describedBy,
961
+ open,
962
+ setOpen,
963
+ hasSearch,
964
+ setHasSearch,
965
+ searchRef,
966
+ listRef,
967
+ registerFocusTarget: (node) => {
968
+ if (node) focusTarget.current = node;
969
+ }
970
+ };
971
+ useEffect(() => {
972
+ resetRef.current = () => commitValues(initialValues);
973
+ });
974
+ const hasField = !!name || required;
975
+ useEffect(() => {
976
+ const root = fieldRef.current?.getRootNode();
977
+ if (!root) return;
978
+ let pending = 0;
979
+ const onReset = (event) => {
980
+ if (event.target !== fieldRef.current?.form) return;
981
+ pending = window.setTimeout(() => {
982
+ if (!event.defaultPrevented) resetRef.current();
983
+ });
984
+ };
985
+ root.addEventListener("reset", onReset, true);
986
+ return () => {
987
+ root.removeEventListener("reset", onReset, true);
988
+ window.clearTimeout(pending);
989
+ };
990
+ }, []);
991
+ return /* @__PURE__ */ jsxs(EmojiPickerContext.Provider, {
992
+ value: context,
993
+ children: [/* @__PURE__ */ jsx(Popover, {
994
+ open,
995
+ onOpenChange: (next) => setOpen(next),
996
+ children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(EmojiPickerTrigger, { className }), /* @__PURE__ */ jsx(EmojiPickerContent, {})] }) : children
997
+ }), hasField && /* @__PURE__ */ jsx("input", {
998
+ ref: (node) => {
999
+ fieldRef.current = node;
1000
+ assignRef(inputRef, node);
1001
+ },
1002
+ type: "text",
1003
+ name,
1004
+ form,
1005
+ required,
1006
+ disabled,
1007
+ value: values.join(","),
1008
+ onChange: () => {},
1009
+ tabIndex: -1,
1010
+ "aria-hidden": "true",
1011
+ "data-slot": "emoji-picker-field",
1012
+ onFocus: (event) => {
1013
+ const target = focusTarget.current ?? searchRef.current;
1014
+ if (target) target.focus();
1015
+ else event.currentTarget.blur();
1016
+ },
1017
+ className: "pointer-events-none absolute size-px max-w-px opacity-0"
1018
+ })]
1019
+ });
1020
+ }
1021
+ function categoryLabel(key, labels, overrides, data) {
1022
+ if (!EMOJI_PICKER_CATEGORIES.includes(key)) return void 0;
1023
+ const category = key;
1024
+ return overrides?.labels?.[category] ?? (data && data.locale !== "en" ? data.categories[category] : void 0) ?? labels[category];
1025
+ }
1026
+ /** The picker's state and actions, inside an `EmojiPicker`. */
1027
+ function useEmojiPicker() {
1028
+ const context = useEmojiPickerContext("useEmojiPicker");
1029
+ return {
1030
+ data: context.data,
1031
+ status: context.status,
1032
+ retry: context.retry,
1033
+ emojis: context.emojis,
1034
+ query: context.query,
1035
+ setQuery: context.setQuery,
1036
+ skinTone: context.skinTone,
1037
+ setSkinTone: context.setSkinTone,
1038
+ activeEmoji: context.activeEmoji,
1039
+ value: context.values[0] ?? null,
1040
+ values: context.values,
1041
+ recent: context.tabs.find((section) => section.id === "recent")?.emojis ?? [],
1042
+ select: (emoji) => context.pick(emoji),
1043
+ clear: context.clear,
1044
+ open: context.open,
1045
+ setOpen: context.setOpen
1046
+ };
1047
+ }
1048
+ const EMOJI_FONT_CLASS = "font-[family-name:var(--emoji-picker-font,Apple_Color_Emoji,Twemoji_Mozilla,Segoe_UI_Emoji,Segoe_UI_Symbol,Noto_Color_Emoji,sans-serif)] leading-none";
1049
+ function EmojiGlyph({ emoji, value, className }) {
1050
+ const context = useContext(EmojiPickerContext);
1051
+ if (emoji && context?.renderEmoji) return /* @__PURE__ */ jsx(Fragment$1, { children: context.renderEmoji(emoji, value) });
1052
+ if (emoji?.src) return /* @__PURE__ */ jsx("img", {
1053
+ src: emoji.src,
1054
+ alt: "",
1055
+ width: 64,
1056
+ height: 64,
1057
+ loading: "lazy",
1058
+ decoding: "async",
1059
+ draggable: false,
1060
+ className: cn("size-[1em] object-contain", className)
1061
+ });
1062
+ return /* @__PURE__ */ jsx("span", {
1063
+ className: cn(EMOJI_FONT_CLASS, className),
1064
+ children: value
1065
+ });
1066
+ }
1067
+ /** An emoji value drawn like the grid draws it, custom images included. For triggers and readouts. */
1068
+ function EmojiPickerValue({ value: valueProp, placeholder, className, ...props }) {
1069
+ const context = useEmojiPickerContext("EmojiPickerValue");
1070
+ const value = valueProp === void 0 ? context.values[0] ?? null : valueProp;
1071
+ return /* @__PURE__ */ jsx("span", {
1072
+ "data-slot": "emoji-picker-value",
1073
+ "data-placeholder": value ? void 0 : "",
1074
+ className: cn("inline-flex items-center justify-center", className),
1075
+ ...props,
1076
+ children: value ? /* @__PURE__ */ jsx(EmojiGlyph, {
1077
+ emoji: context.findByValue(value),
1078
+ value
1079
+ }) : placeholder
1080
+ });
1081
+ }
1082
+ /**
1083
+ * A shadcn Button that opens the picker: the value, or a smiley. Hovering or
1084
+ * focusing it starts the data fetch, so the grid is ready on open.
1085
+ */
1086
+ function EmojiPickerTrigger({ className, variant = "outline", size = "icon", children, ref, onPointerEnter, onFocus, ...props }) {
1087
+ const context = useEmojiPickerContext("EmojiPickerTrigger");
1088
+ const value = context.multiple ? null : context.values[0] ?? null;
1089
+ const emoji = value ? context.findByValue(value) : void 0;
1090
+ const name = context.label ?? context.i18n.labels.trigger;
1091
+ const buttonProps = {
1092
+ type: "button",
1093
+ variant,
1094
+ size,
1095
+ disabled: context.disabled,
1096
+ "aria-label": context.labelledBy ? void 0 : emoji ? `${name}: ${context.i18n.functions.formatLabel(emoji.label)}` : value ? `${name}: ${value}` : name,
1097
+ "aria-labelledby": context.labelledBy,
1098
+ "aria-describedby": context.describedBy,
1099
+ ...context.invalid && {
1100
+ "aria-invalid": true,
1101
+ "data-invalid": ""
1102
+ },
1103
+ ...props,
1104
+ id: context.id,
1105
+ ref: (node) => {
1106
+ context.registerFocusTarget(node);
1107
+ assignRef(ref, node);
1108
+ },
1109
+ onPointerEnter: (event) => {
1110
+ onPointerEnter?.(event);
1111
+ context.requestData();
1112
+ },
1113
+ onFocus: (event) => {
1114
+ onFocus?.(event);
1115
+ context.requestData();
1116
+ },
1117
+ "data-slot": "emoji-picker-trigger",
1118
+ "data-placeholder": value ? void 0 : "",
1119
+ className: cn(value && children === void 0 && "text-lg", className)
1120
+ };
1121
+ const content = children === void 0 ? value ? /* @__PURE__ */ jsx(EmojiPickerValue, {}) : TRIGGER_ICON : children;
1122
+ return /* @__PURE__ */ jsx(PopoverTrigger, {
1123
+ id: context.id,
1124
+ render: /* @__PURE__ */ jsx(Button, { ...buttonProps }),
1125
+ children: content
1126
+ });
1127
+ }
1128
+ const TABBABLE = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1129
+ const isTouch = () => typeof window !== "undefined" && !!window.matchMedia?.("(pointer: coarse)").matches;
1130
+ function openFocusTarget(context) {
1131
+ return (isTouch() ? null : context.searchRef.current) ?? context.listRef.current ?? true;
1132
+ }
1133
+ /**
1134
+ * The popover. It wraps its children in an `EmojiPickerPanel`, so it takes the
1135
+ * same parts; with none it renders the default layout. Tab cycles inside it.
1136
+ */
1137
+ function EmojiPickerContent({ className, align = "start", returnFocus, onKeyDown, onClick, children, ...props }) {
1138
+ const context = useEmojiPickerContext("EmojiPickerContent");
1139
+ const focusProps = {
1140
+ initialFocus: () => openFocusTarget(context),
1141
+ finalFocus: returnFocus ?? true
1142
+ };
1143
+ return /* @__PURE__ */ jsx(PopoverContent, {
1144
+ align,
1145
+ "aria-labelledby": context.labelledBy,
1146
+ "aria-label": context.labelledBy ? void 0 : context.label ?? context.i18n.labels.panel,
1147
+ className: cn("max-h-[min(var(--available-height,100dvh),var(--radix-popover-content-available-height,100dvh))] w-auto gap-0 overflow-hidden p-0", className),
1148
+ onClick: (event) => {
1149
+ onClick?.(event);
1150
+ event.stopPropagation();
1151
+ },
1152
+ onKeyDown: (event) => {
1153
+ onKeyDown?.(event);
1154
+ if (event.defaultPrevented || event.key !== "Tab") return;
1155
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
1156
+ const items = Array.from(event.currentTarget.querySelectorAll(TABBABLE)).filter((item) => item.tabIndex >= 0);
1157
+ const activeElement = event.currentTarget.ownerDocument.activeElement;
1158
+ const first = items[0];
1159
+ const last = items[items.length - 1];
1160
+ if (!event.shiftKey && activeElement === last) {
1161
+ event.preventDefault();
1162
+ first?.focus();
1163
+ } else if (event.shiftKey && activeElement === first) {
1164
+ event.preventDefault();
1165
+ last?.focus();
1166
+ }
1167
+ },
1168
+ ...focusProps,
1169
+ ...props,
1170
+ children: /* @__PURE__ */ jsx(SurfaceContext.Provider, {
1171
+ value: "popup",
1172
+ children: /* @__PURE__ */ jsx(EmojiPickerPanel, { children })
1173
+ })
1174
+ });
1175
+ }
1176
+ /**
1177
+ * The picker surface. Inline, put it straight inside an `EmojiPicker` with no
1178
+ * trigger. Without children it renders the search, the tabs, the grid and a
1179
+ * footer with the preview and the skin tone; with children, only those parts,
1180
+ * in that order.
1181
+ */
1182
+ function EmojiPickerPanel({ className, style, children, ...props }) {
1183
+ const context = useEmojiPickerContext("EmojiPickerPanel");
1184
+ const inline = useContext(SurfaceContext) === "inline";
1185
+ const { requestData } = context;
1186
+ const { cell, emoji, header, gutter } = context.size;
1187
+ useEffect(() => {
1188
+ requestData();
1189
+ }, [requestData]);
1190
+ return /* @__PURE__ */ jsx("div", {
1191
+ role: inline ? "group" : void 0,
1192
+ "aria-labelledby": inline ? context.labelledBy : void 0,
1193
+ "aria-label": inline && !context.labelledBy ? context.label ?? context.i18n.labels.panel : void 0,
1194
+ "data-slot": "emoji-picker-panel",
1195
+ "data-columns": context.columns === "auto" ? "auto" : void 0,
1196
+ "data-disabled": context.disabled ? "" : void 0,
1197
+ style: {
1198
+ "--emoji-picker-cell": `${cell}px`,
1199
+ "--emoji-picker-emoji": `${emoji}px`,
1200
+ "--emoji-picker-header": `${header}px`,
1201
+ "--emoji-picker-gutter": `${gutter}px`,
1202
+ "--emoji-picker-padding": `${PADDING}px`,
1203
+ "--emoji-picker-columns": context.columnCount,
1204
+ "--emoji-picker-list-height": `${header + VISIBLE_ROWS * cell + gutter}px`,
1205
+ ...style
1206
+ },
1207
+ className: cn("flex min-h-0 w-[calc(var(--emoji-picker-columns)*var(--emoji-picker-cell)+var(--emoji-picker-gutter)*2)] min-w-0 max-w-full flex-col data-disabled:pointer-events-none data-[columns=auto]:w-full data-disabled:opacity-50", inline ? "[--emoji-picker-surface:var(--color-card)]" : "[--emoji-picker-surface:var(--color-popover)]", className),
1208
+ ...props,
1209
+ children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1210
+ /* @__PURE__ */ jsx(EmojiPickerHeader, { children: /* @__PURE__ */ jsx(EmojiPickerSearch, {}) }),
1211
+ /* @__PURE__ */ jsx(EmojiPickerCategories, {}),
1212
+ /* @__PURE__ */ jsx(EmojiPickerList, {}),
1213
+ /* @__PURE__ */ jsxs(EmojiPickerFooter, { children: [/* @__PURE__ */ jsx(EmojiPickerPreview, {}), /* @__PURE__ */ jsx(EmojiPickerSkinTone, {})] })
1214
+ ] }) : children
1215
+ });
1216
+ }
1217
+ /** The row above the grid, for the search and anything beside it. */
1218
+ function EmojiPickerHeader({ className, ...props }) {
1219
+ return /* @__PURE__ */ jsx("div", {
1220
+ "data-slot": "emoji-picker-header",
1221
+ className: cn("flex items-center gap-2 px-(--emoji-picker-padding) pt-(--emoji-picker-padding) pb-2", className),
1222
+ ...props
1223
+ });
1224
+ }
1225
+ /**
1226
+ * The search field, a default shadcn InputGroup. Focus stays here while the
1227
+ * arrow keys move through the grid (a combobox over the listbox); Enter picks
1228
+ * the highlighted emoji.
1229
+ */
1230
+ function EmojiPickerSearch({ className, placeholder, onChange, onKeyDown, onFocus, onBlur, ref, ...props }) {
1231
+ const context = useEmojiPickerContext("EmojiPickerSearch");
1232
+ const { setHasSearch, searchRef } = context;
1233
+ const { labels } = context.i18n;
1234
+ const activeId = context.activePosition ? optionId(context.listId, context.activePosition) : void 0;
1235
+ useEffect(() => {
1236
+ setHasSearch(true);
1237
+ return () => setHasSearch(false);
1238
+ }, [setHasSearch]);
1239
+ return /* @__PURE__ */ jsxs(InputGroup, {
1240
+ "data-slot": "emoji-picker-search",
1241
+ className: cn("flex-1", className),
1242
+ children: [
1243
+ /* @__PURE__ */ jsx(InputGroupAddon, { children: SEARCH_ICON }),
1244
+ /* @__PURE__ */ jsx(InputGroupInput, {
1245
+ type: "text",
1246
+ role: "combobox",
1247
+ "aria-expanded": "true",
1248
+ "aria-controls": context.listId,
1249
+ "aria-activedescendant": activeId,
1250
+ "aria-autocomplete": "list",
1251
+ "aria-label": labels.search,
1252
+ placeholder: placeholder ?? labels.search,
1253
+ autoComplete: "off",
1254
+ autoCorrect: "off",
1255
+ autoCapitalize: "off",
1256
+ spellCheck: false,
1257
+ enterKeyHint: "search",
1258
+ disabled: context.disabled,
1259
+ value: context.query,
1260
+ onChange: (event) => {
1261
+ onChange?.(event);
1262
+ context.setQuery(event.target.value);
1263
+ },
1264
+ onFocus: (event) => {
1265
+ onFocus?.(event);
1266
+ context.setFocused(true);
1267
+ },
1268
+ onBlur: (event) => {
1269
+ onBlur?.(event);
1270
+ context.setFocused(false);
1271
+ },
1272
+ onKeyDown: (event) => {
1273
+ onKeyDown?.(event);
1274
+ if (event.defaultPrevented) return;
1275
+ if (event.key === "Escape" && context.query && !context.open) {
1276
+ event.preventDefault();
1277
+ context.setQuery("");
1278
+ return;
1279
+ }
1280
+ context.navigate(event, true);
1281
+ },
1282
+ ...props,
1283
+ ref: (node) => {
1284
+ searchRef.current = node;
1285
+ assignRef(ref, node);
1286
+ }
1287
+ }),
1288
+ context.query && /* @__PURE__ */ jsx(InputGroupAddon, {
1289
+ align: "inline-end",
1290
+ children: /* @__PURE__ */ jsx(InputGroupButton, {
1291
+ type: "button",
1292
+ size: "icon-xs",
1293
+ "aria-label": labels.clearSearch,
1294
+ "data-slot": "emoji-picker-search-clear",
1295
+ onClick: () => {
1296
+ context.setQuery("");
1297
+ searchRef.current?.focus();
1298
+ },
1299
+ children: CLEAR_ICON
1300
+ })
1301
+ })
1302
+ ]
1303
+ });
1304
+ }
1305
+ const HAND = "✋";
1306
+ const TONE_MODIFIERS = [
1307
+ "",
1308
+ "🏻",
1309
+ "🏼",
1310
+ "🏽",
1311
+ "🏾",
1312
+ "🏿"
1313
+ ];
1314
+ const TONES = [
1315
+ 0,
1316
+ 1,
1317
+ 2,
1318
+ 3,
1319
+ 4,
1320
+ 5
1321
+ ];
1322
+ function ToneGlyph({ tone }) {
1323
+ return /* @__PURE__ */ jsx("span", {
1324
+ "aria-hidden": "true",
1325
+ className: cn(EMOJI_FONT_CLASS, "text-base"),
1326
+ children: HAND + TONE_MODIFIERS[tone]
1327
+ });
1328
+ }
1329
+ /**
1330
+ * A shadcn Button with a hand in the current tone that opens the six tones in
1331
+ * a shadcn DropdownMenu. The choice applies to every emoji that takes a tone
1332
+ * and is remembered under `skinToneStorageKey`. Ghost at `icon-sm` for the
1333
+ * footer by default; beside the search, `outline` at `icon` matches its
1334
+ * height in every style.
1335
+ */
1336
+ function EmojiPickerSkinTone({ variant = "ghost", size = "icon-sm", ref, ...props }) {
1337
+ const context = useEmojiPickerContext("EmojiPickerSkinTone");
1338
+ const { labels } = context.i18n;
1339
+ const tone = context.skinTone;
1340
+ const triggerRef = useRef(null);
1341
+ const buttonProps = {
1342
+ type: "button",
1343
+ variant,
1344
+ size,
1345
+ disabled: context.disabled,
1346
+ "aria-label": `${labels.skinTone}: ${labels.skinTones[tone]}`,
1347
+ "data-slot": "emoji-picker-skin-tone",
1348
+ ...props,
1349
+ ref: (node) => {
1350
+ triggerRef.current = node;
1351
+ assignRef(ref, node);
1352
+ }
1353
+ };
1354
+ return /* @__PURE__ */ jsxs(DropdownMenu, {
1355
+ onOpenChangeComplete: (open) => {
1356
+ if (open) return;
1357
+ requestAnimationFrame(() => {
1358
+ const doc = triggerRef.current?.ownerDocument;
1359
+ if (doc && (!doc.activeElement || doc.activeElement === doc.body)) triggerRef.current?.focus();
1360
+ });
1361
+ },
1362
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
1363
+ render: /* @__PURE__ */ jsx(Button, { ...buttonProps }),
1364
+ children: /* @__PURE__ */ jsx(ToneGlyph, { tone })
1365
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, {
1366
+ align: "end",
1367
+ className: "min-w-40",
1368
+ children: /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [/* @__PURE__ */ jsx(DropdownMenuLabel, { children: labels.skinTone }), /* @__PURE__ */ jsx(DropdownMenuRadioGroup, {
1369
+ value: String(tone),
1370
+ onValueChange: (next) => context.setSkinTone(Number(next)),
1371
+ children: TONES.map((option) => /* @__PURE__ */ jsxs(DropdownMenuRadioItem, {
1372
+ value: String(option),
1373
+ closeOnClick: true,
1374
+ children: [/* @__PURE__ */ jsx(ToneGlyph, { tone: option }), labels.skinTones[option]]
1375
+ }, option))
1376
+ })] })
1377
+ })]
1378
+ });
1379
+ }
1380
+ const TAB_CLASS = "max-w-9 min-w-0 px-0";
1381
+ /**
1382
+ * Category tabs, the shadcn Tabs in its line variant, that jump the grid and
1383
+ * follow its scroll. Arrow keys move between them; Enter or Space jumps. A
1384
+ * jump during a search clears it.
1385
+ */
1386
+ function EmojiPickerCategories({ className, ...props }) {
1387
+ const context = useEmojiPickerContext("EmojiPickerCategories");
1388
+ const searching = !!context.query.trim();
1389
+ const placeholder = context.status !== "ready";
1390
+ const tabs = placeholder ? context.placeholderTabs : context.tabs;
1391
+ const current = searching ? "" : context.activeSection ?? tabs[0]?.id ?? "";
1392
+ return /* @__PURE__ */ jsx("div", {
1393
+ "data-slot": "emoji-picker-categories",
1394
+ className: cn("shrink-0 border-b px-(--emoji-picker-padding) first:pt-(--emoji-picker-padding) last:pb-(--emoji-picker-padding) [[data-slot=emoji-picker-list]~&]:border-t [[data-slot=emoji-picker-list]~&]:border-b-0 [[data-slot=emoji-picker-list]~&]:pt-1", className),
1395
+ ...props,
1396
+ children: /* @__PURE__ */ jsx(Tabs, {
1397
+ value: current,
1398
+ children: /* @__PURE__ */ jsx(TabsList, {
1399
+ variant: "line",
1400
+ "aria-label": context.i18n.labels.categories,
1401
+ className: "w-full justify-between",
1402
+ children: tabs.map((tab) => /* @__PURE__ */ jsx(TabsTrigger, {
1403
+ value: tab.id,
1404
+ "aria-label": tab.label,
1405
+ "aria-controls": context.listId,
1406
+ title: tab.label,
1407
+ disabled: placeholder || context.disabled,
1408
+ "data-slot": "emoji-picker-category",
1409
+ "data-category": tab.id,
1410
+ className: TAB_CLASS,
1411
+ onClick: () => context.jumpTo(tab.id),
1412
+ children: tab.icon
1413
+ }, tab.id))
1414
+ })
1415
+ })
1416
+ });
1417
+ }
1418
+ const optionId = (listId, at) => `${listId}-${at.row}-${at.col}`;
1419
+ const SECTION_HEADER_CLASS = "sticky top-0 z-1 flex h-(--emoji-picker-header) items-center bg-(--emoji-picker-surface) px-(--emoji-picker-padding) pt-1 text-xs text-muted-foreground select-none font-medium";
1420
+ const CELL_CLASS = "mx-auto flex size-(--emoji-picker-cell) cursor-default items-center justify-center text-(length:--emoji-picker-emoji) transition-colors duration-100 select-none data-active:bg-muted aria-disabled:opacity-40 data-selected:bg-primary/10 data-selected:inset-ring-1 data-selected:inset-ring-primary/30 dark:data-selected:bg-primary/20 forced-colors:data-active:outline-2 forced-colors:data-active:outline-solid rounded-lg";
1421
+ const CELL_FOCUS_CLASS = "data-keyboard:z-2 data-keyboard:border data-keyboard:border-ring data-keyboard:ring-[length:min(3px,var(--emoji-picker-gutter))] data-keyboard:ring-ring/50";
1422
+ const LIST_CLASS = "relative h-(--emoji-picker-list-height) min-h-[calc(var(--emoji-picker-header)+var(--emoji-picker-cell)*2)] overflow-y-auto overscroll-contain outline-none [scrollbar-width:none] data-keyboard:[--emoji-picker-fade-size:0px] [&::-webkit-scrollbar]:hidden [mask-image:linear-gradient(to_bottom,#000_var(--emoji-picker-header),transparent_var(--emoji-picker-header),#000_calc(var(--emoji-picker-header)+var(--emoji-picker-fade-start,0px)),#000_calc(100%-var(--emoji-picker-fade-end,0px)),transparent)] data-overflow-start:[--emoji-picker-fade-start:var(--emoji-picker-fade-size,calc(var(--emoji-picker-cell)*2/3))] data-overflow-end:[--emoji-picker-fade-end:var(--emoji-picker-fade-size,calc(var(--emoji-picker-cell)*2/3))]";
1423
+ function scrollGrid(list, top, mark) {
1424
+ list.scrollTop = top;
1425
+ mark.current = list.scrollTop;
1426
+ }
1427
+ /**
1428
+ * The virtual grid: only the rows in view render, so a page of reaction
1429
+ * pickers or a 20,000 custom emoji library stays cheap. Section headers stick
1430
+ * while their rows scroll. Holds the loading, error and empty states.
1431
+ */
1432
+ function EmojiPickerList({ className, onKeyDown, onFocus, onBlur, onPointerDown, onScroll, ...props }) {
1433
+ const context = useEmojiPickerContext("EmojiPickerList");
1434
+ const { layout, size, requestData, setActiveSection, setMeasuredColumns, setJump, listRef, jump } = context;
1435
+ const { labels, functions } = context.i18n;
1436
+ const [range, setRange] = useState({
1437
+ start: 0,
1438
+ end: 11
1439
+ });
1440
+ const updateRef = useRef(() => {});
1441
+ const pointerDown = useRef(false);
1442
+ const scrolledTo = useRef(null);
1443
+ const update = () => {
1444
+ const list = listRef.current;
1445
+ if (!list) return;
1446
+ const height = list.clientHeight || FALLBACK_HEIGHT;
1447
+ const top = list.scrollTop;
1448
+ const last = Math.max(0, layout.rows.length - 1);
1449
+ const start = Math.max(0, indexAt(layout.rows, top) - OVERSCAN);
1450
+ const end = Math.min(last, indexAt(layout.rows, top + height) + OVERSCAN);
1451
+ setRange((previous) => previous.start === start && previous.end === end ? previous : {
1452
+ start,
1453
+ end
1454
+ });
1455
+ context.setPageRows(Math.max(1, Math.floor((height - size.header) / size.cell)));
1456
+ list.toggleAttribute("data-overflow-start", top > 1);
1457
+ list.toggleAttribute("data-overflow-end", top + list.clientHeight < list.scrollHeight - 1);
1458
+ setActiveSection(layout.sections[indexAt(layout.sections, top + 1)]?.section.id ?? null);
1459
+ };
1460
+ useLayoutEffect(() => {
1461
+ updateRef.current = update;
1462
+ });
1463
+ useEffect(() => {
1464
+ requestData();
1465
+ }, [requestData]);
1466
+ useLayoutEffect(() => {
1467
+ if (listRef.current) scrollGrid(listRef.current, 0, scrolledTo);
1468
+ updateRef.current();
1469
+ }, [listRef]);
1470
+ useLayoutEffect(() => {
1471
+ updateRef.current();
1472
+ }, []);
1473
+ useLayoutEffect(() => {
1474
+ const list = listRef.current;
1475
+ if (!jump || !list) return;
1476
+ const section = layout.sections.find((item) => item.section.id === jump);
1477
+ if (!section) return;
1478
+ scrollGrid(list, section.top, scrolledTo);
1479
+ updateRef.current();
1480
+ setJump(null);
1481
+ }, [
1482
+ jump,
1483
+ layout,
1484
+ listRef,
1485
+ setJump
1486
+ ]);
1487
+ const { active, activePosition } = context;
1488
+ useLayoutEffect(() => {
1489
+ const list = listRef.current;
1490
+ if (!list || active?.source !== "keyboard" || !activePosition) return;
1491
+ const row = layout.rows[activePosition.row];
1492
+ if (!row) return;
1493
+ const height = list.clientHeight || FALLBACK_HEIGHT;
1494
+ if (row.top - size.header < list.scrollTop) scrollGrid(list, row.top - size.header, scrolledTo);
1495
+ else if (row.top + size.cell + size.gutter > list.scrollTop + height) scrollGrid(list, row.top + size.cell + size.gutter - height, scrolledTo);
1496
+ updateRef.current();
1497
+ }, [
1498
+ active,
1499
+ activePosition,
1500
+ layout,
1501
+ listRef,
1502
+ size
1503
+ ]);
1504
+ const { columns } = context;
1505
+ useLayoutEffect(() => {
1506
+ const list = listRef.current;
1507
+ if (!list) return;
1508
+ const measure = () => {
1509
+ if (columns === "auto" && list.clientWidth > 0) setMeasuredColumns(Math.max(1, Math.floor((list.clientWidth - size.gutter * 2) / size.cell)));
1510
+ updateRef.current();
1511
+ };
1512
+ measure();
1513
+ if (typeof ResizeObserver === "undefined") return;
1514
+ const observer = new ResizeObserver(measure);
1515
+ observer.observe(list);
1516
+ return () => observer.disconnect();
1517
+ }, [
1518
+ columns,
1519
+ listRef,
1520
+ setMeasuredColumns,
1521
+ size
1522
+ ]);
1523
+ const rendered = /* @__PURE__ */ new Set();
1524
+ for (let row = range.start; row <= range.end && row < layout.rows.length; row++) rendered.add(row);
1525
+ if (activePosition) rendered.add(activePosition.row);
1526
+ const rowsBySection = /* @__PURE__ */ new Map();
1527
+ for (const row of [...rendered].sort((a, b) => a - b)) {
1528
+ const section = layout.rows[row]?.section;
1529
+ if (section === void 0) continue;
1530
+ const list = rowsBySection.get(section);
1531
+ if (list) list.push(row);
1532
+ else rowsBySection.set(section, [row]);
1533
+ }
1534
+ const searching = !!context.query.trim();
1535
+ const ready = context.status === "ready";
1536
+ const empty = ready && layout.rows.length === 0;
1537
+ const keyboard = context.focused && context.active?.source === "keyboard" && !!activePosition;
1538
+ const status = searching && ready ? functions.formatResultCount(layout.rows.reduce((sum, row) => sum + row.cells.length, 0)) : "";
1539
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
1540
+ ref: listRef,
1541
+ id: context.listId,
1542
+ role: "listbox",
1543
+ "aria-label": labels.list,
1544
+ "aria-multiselectable": context.multiple || void 0,
1545
+ "aria-busy": !ready || void 0,
1546
+ "aria-activedescendant": activePosition ? optionId(context.listId, activePosition) : void 0,
1547
+ tabIndex: context.disabled || !ready || empty ? -1 : 0,
1548
+ "data-slot": "emoji-picker-list",
1549
+ "data-keyboard": keyboard ? "" : void 0,
1550
+ className: cn(LIST_CLASS, className),
1551
+ onScroll: (event) => {
1552
+ onScroll?.(event);
1553
+ const mark = scrolledTo.current;
1554
+ if (mark === null || Math.abs(event.currentTarget.scrollTop - mark) > 1) context.releaseKeyboard();
1555
+ update();
1556
+ },
1557
+ onPointerDown: (event) => {
1558
+ onPointerDown?.(event);
1559
+ if (!event.defaultPrevented) pointerDown.current = true;
1560
+ },
1561
+ onFocus: (event) => {
1562
+ onFocus?.(event);
1563
+ context.setFocused(true);
1564
+ if (event.target !== event.currentTarget) return;
1565
+ const fromPointer = pointerDown.current || isTouch();
1566
+ pointerDown.current = false;
1567
+ if (!fromPointer && context.active?.source !== "keyboard") context.move("visible");
1568
+ },
1569
+ onBlur: (event) => {
1570
+ onBlur?.(event);
1571
+ pointerDown.current = false;
1572
+ context.setFocused(false);
1573
+ },
1574
+ onKeyDown: (event) => {
1575
+ onKeyDown?.(event);
1576
+ if (event.defaultPrevented || event.target !== event.currentTarget) return;
1577
+ const search = context.searchRef.current;
1578
+ const typed = event.key.length === 1 && event.key !== " " || event.key === "Backspace";
1579
+ if (search && typed && !event.nativeEvent.isComposing && !event.altKey && !event.ctrlKey && !event.metaKey) {
1580
+ search.focus();
1581
+ return;
1582
+ }
1583
+ context.navigate(event, false);
1584
+ },
1585
+ ...props,
1586
+ children: [
1587
+ ready && /* @__PURE__ */ jsx("div", {
1588
+ className: "relative",
1589
+ style: { height: layout.height },
1590
+ children: layout.sections.map((section, sectionIndex) => {
1591
+ const rows = rowsBySection.get(sectionIndex);
1592
+ if (!rows) return null;
1593
+ const headerId = `${context.listId}-${sectionIndex}`;
1594
+ return /* @__PURE__ */ jsxs("div", {
1595
+ role: "group",
1596
+ "aria-labelledby": headerId,
1597
+ "data-slot": "emoji-picker-section",
1598
+ "data-section": section.section.id,
1599
+ className: "absolute inset-x-0",
1600
+ style: {
1601
+ top: section.top,
1602
+ height: section.height
1603
+ },
1604
+ children: [/* @__PURE__ */ jsx("div", {
1605
+ id: headerId,
1606
+ "data-slot": "emoji-picker-section-header",
1607
+ className: SECTION_HEADER_CLASS,
1608
+ children: section.section.label
1609
+ }), rows.map((rowIndex) => {
1610
+ const row = layout.rows[rowIndex];
1611
+ const first = (rowIndex - section.firstRow) * context.columnCount;
1612
+ return /* @__PURE__ */ jsx("div", {
1613
+ role: "presentation",
1614
+ className: "absolute inset-x-(--emoji-picker-gutter) grid grid-cols-[repeat(var(--emoji-picker-columns),minmax(0,1fr))]",
1615
+ style: { top: row.top - section.top },
1616
+ children: row.cells.map((emoji, col) => {
1617
+ const at = {
1618
+ row: rowIndex,
1619
+ col
1620
+ };
1621
+ const isActive = activePosition?.row === rowIndex && activePosition.col === col;
1622
+ const isSelected = context.isSelected(emoji);
1623
+ const refused = context.full && !isSelected;
1624
+ const value = getEmojiValue(emoji, emoji.skins ? context.skinTone : 0);
1625
+ return /* @__PURE__ */ jsx("div", {
1626
+ id: optionId(context.listId, at),
1627
+ role: "option",
1628
+ "aria-label": functions.formatLabel(emoji.label),
1629
+ "aria-selected": context.valueMode ? isSelected : isActive,
1630
+ "aria-disabled": refused || void 0,
1631
+ "aria-posinset": first + col + 1,
1632
+ "aria-setsize": section.section.emojis.length,
1633
+ "data-slot": "emoji-picker-emoji",
1634
+ "data-active": isActive ? "" : void 0,
1635
+ "data-keyboard": keyboard && isActive ? "" : void 0,
1636
+ "data-selected": isSelected && context.valueMode ? "true" : void 0,
1637
+ className: cn(CELL_CLASS, CELL_FOCUS_CLASS),
1638
+ onPointerDown: (event) => {
1639
+ event.preventDefault();
1640
+ const { searchRef, listRef } = context;
1641
+ const focused = event.currentTarget.ownerDocument.activeElement;
1642
+ if (focused === searchRef.current || focused === listRef.current) return;
1643
+ const target = event.pointerType === "touch" ? listRef.current : searchRef.current ?? listRef.current;
1644
+ if (target === listRef.current) pointerDown.current = true;
1645
+ target?.focus({ preventScroll: true });
1646
+ },
1647
+ onPointerMove: () => {
1648
+ if (isActive && context.active?.source === "pointer") return;
1649
+ context.setActive({
1650
+ section: section.section.id,
1651
+ id: emoji.id,
1652
+ source: "pointer"
1653
+ });
1654
+ },
1655
+ onClick: (event) => {
1656
+ if (!refused) context.pick(emoji, event);
1657
+ },
1658
+ children: /* @__PURE__ */ jsx(EmojiGlyph, {
1659
+ emoji,
1660
+ value
1661
+ })
1662
+ }, emoji.id);
1663
+ })
1664
+ }, rowIndex);
1665
+ })]
1666
+ }, section.section.id);
1667
+ })
1668
+ }),
1669
+ !ready && context.status !== "error" && /* @__PURE__ */ jsxs("div", {
1670
+ role: "status",
1671
+ "aria-label": labels.loading,
1672
+ className: "flex flex-col",
1673
+ children: [/* @__PURE__ */ jsx("div", {
1674
+ className: "flex h-(--emoji-picker-header) items-center px-(--emoji-picker-padding) pt-1",
1675
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-24" })
1676
+ }), /* @__PURE__ */ jsx("div", {
1677
+ className: "grid grid-cols-[repeat(var(--emoji-picker-columns),minmax(0,1fr))] px-(--emoji-picker-gutter)",
1678
+ children: Array.from({ length: context.columnCount * 5 }, (_, index) => /* @__PURE__ */ jsx("div", {
1679
+ className: "flex size-(--emoji-picker-cell) items-center justify-center",
1680
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "size-(--emoji-picker-emoji) rounded-full" })
1681
+ }, index))
1682
+ })]
1683
+ }),
1684
+ context.status === "error" && /* @__PURE__ */ jsxs(Empty, {
1685
+ className: "h-full",
1686
+ children: [/* @__PURE__ */ jsx(EmptyHeader, { children: /* @__PURE__ */ jsx(EmptyTitle, { children: labels.error }) }), /* @__PURE__ */ jsx(EmptyContent, { children: /* @__PURE__ */ jsx(Button, {
1687
+ type: "button",
1688
+ variant: "outline",
1689
+ size: "sm",
1690
+ onClick: context.retry,
1691
+ children: labels.retry
1692
+ }) })]
1693
+ }),
1694
+ empty && /* @__PURE__ */ jsx(Empty, {
1695
+ "data-slot": "emoji-picker-empty",
1696
+ className: "h-full",
1697
+ children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
1698
+ /* @__PURE__ */ jsx(EmptyMedia, {
1699
+ variant: "icon",
1700
+ children: SEARCH_ICON
1701
+ }),
1702
+ /* @__PURE__ */ jsx(EmptyTitle, { children: labels.empty }),
1703
+ /* @__PURE__ */ jsx(EmptyDescription, { children: labels.emptyHint })
1704
+ ] })
1705
+ })
1706
+ ]
1707
+ }), /* @__PURE__ */ jsx("div", {
1708
+ role: "status",
1709
+ "aria-live": "polite",
1710
+ className: "sr-only",
1711
+ children: context.announcement || status
1712
+ })] });
1713
+ }
1714
+ /** The row under the grid: the preview and the skin tone by default. */
1715
+ function EmojiPickerFooter({ className, ...props }) {
1716
+ return /* @__PURE__ */ jsx("div", {
1717
+ "data-slot": "emoji-picker-footer",
1718
+ className: cn("flex h-10 shrink-0 items-center gap-2 border-t px-(--emoji-picker-padding)", className),
1719
+ ...props
1720
+ });
1721
+ }
1722
+ /**
1723
+ * The highlighted emoji, large, with its name and first shortcode; the value
1724
+ * while nothing is highlighted. Visual only: the grid already announces it.
1725
+ * It fills the space it is given, usually an `EmojiPickerFooter`.
1726
+ */
1727
+ function EmojiPickerPreview({ className, ...props }) {
1728
+ const context = useEmojiPickerContext("EmojiPickerPreview");
1729
+ const { labels, functions } = context.i18n;
1730
+ const fallback = !context.multiple && context.values[0] ? context.findByValue(context.values[0]) : void 0;
1731
+ const emoji = context.activeEmoji ?? fallback ?? null;
1732
+ const value = emoji ? context.activeEmoji ? getEmojiValue(emoji, emoji.skins ? context.skinTone : 0) : context.values[0] : "";
1733
+ const shortcode = emoji?.shortcodes[0];
1734
+ return /* @__PURE__ */ jsx("div", {
1735
+ "aria-hidden": "true",
1736
+ "data-slot": "emoji-picker-preview",
1737
+ className: cn("flex min-w-0 flex-1 select-none items-center gap-2", className),
1738
+ ...props,
1739
+ children: emoji ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(EmojiGlyph, {
1740
+ emoji,
1741
+ value,
1742
+ className: "shrink-0 text-[22px]"
1743
+ }), /* @__PURE__ */ jsxs("span", {
1744
+ className: "flex h-5 min-w-0 flex-1 flex-wrap items-baseline gap-x-2 overflow-hidden",
1745
+ children: [/* @__PURE__ */ jsx("span", {
1746
+ className: "max-w-full truncate font-medium text-sm leading-5",
1747
+ children: functions.formatLabel(emoji.label)
1748
+ }), shortcode && /* @__PURE__ */ jsxs("span", {
1749
+ className: "text-muted-foreground text-xs leading-5",
1750
+ children: [
1751
+ ":",
1752
+ shortcode,
1753
+ ":"
1754
+ ]
1755
+ })]
1756
+ })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1757
+ className: "flex size-[22px] shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-5",
1758
+ children: TRIGGER_ICON
1759
+ }), /* @__PURE__ */ jsx("span", {
1760
+ className: "truncate text-muted-foreground text-sm",
1761
+ children: labels.preview
1762
+ })] })
1763
+ });
1764
+ }
1765
+ //#endregion
1766
+ export { DEFAULT_EMOJI_PICKER_I18N, EMOJI_PICKER_CATEGORIES, EMOJI_PICKER_DATA_URL, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerFooter, EmojiPickerHeader, EmojiPickerList, EmojiPickerPanel, EmojiPickerPreview, EmojiPickerSearch, EmojiPickerSkinTone, EmojiPickerTrigger, EmojiPickerValue, findEmoji, getEmojiValue, isEmojiValue, loadEmojiPickerData, mergeEmojiPickerI18n, normalizeEmojibaseData, searchEmojis, useEmojiPicker, useEmojiPickerData };
1767
+
1768
+ //# sourceMappingURL=emoji-picker.js.map