@coffer-org/web-ui 4.0.0

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 (387) hide show
  1. package/README.md +87 -0
  2. package/dist/Markdown.d.ts +4 -0
  3. package/dist/Markdown.js +13 -0
  4. package/dist/MarkdownEditor.d.ts +6 -0
  5. package/dist/MarkdownEditor.js +83 -0
  6. package/dist/actions/ActionButton.d.ts +7 -0
  7. package/dist/actions/ActionButton.js +54 -0
  8. package/dist/actions/PopupBody.d.ts +4 -0
  9. package/dist/actions/PopupBody.js +8 -0
  10. package/dist/actions/TemplateHost.d.ts +4 -0
  11. package/dist/actions/TemplateHost.js +36 -0
  12. package/dist/actions/registry.d.ts +20 -0
  13. package/dist/actions/registry.js +9 -0
  14. package/dist/components/ExtendReasonInfo.d.ts +6 -0
  15. package/dist/components/ExtendReasonInfo.js +12 -0
  16. package/dist/components/FavoriteButton.d.ts +8 -0
  17. package/dist/components/FavoriteButton.js +7 -0
  18. package/dist/components/Icon.d.ts +6 -0
  19. package/dist/components/Icon.js +12 -0
  20. package/dist/components/PageBody.d.ts +4 -0
  21. package/dist/components/PageBody.js +4 -0
  22. package/dist/components/RecordInline.d.ts +8 -0
  23. package/dist/components/RecordInline.js +29 -0
  24. package/dist/components/SaveStatus.d.ts +1 -0
  25. package/dist/components/SaveStatus.js +11 -0
  26. package/dist/components/Toolbar.d.ts +5 -0
  27. package/dist/components/Toolbar.js +4 -0
  28. package/dist/components/icons/color.d.ts +2 -0
  29. package/dist/components/icons/color.js +10 -0
  30. package/dist/components/icons/flag.d.ts +2 -0
  31. package/dist/components/icons/flag.js +6 -0
  32. package/dist/components/icons/lucide.d.ts +2 -0
  33. package/dist/components/icons/lucide.js +111 -0
  34. package/dist/components/icons/registry.d.ts +4 -0
  35. package/dist/components/icons/registry.js +22 -0
  36. package/dist/components/icons/simple.d.ts +2 -0
  37. package/dist/components/icons/simple.js +15 -0
  38. package/dist/components/icons/tabler.d.ts +2 -0
  39. package/dist/components/icons/tabler.js +11 -0
  40. package/dist/components/ui/FieldLabel.d.ts +9 -0
  41. package/dist/components/ui/FieldLabel.js +4 -0
  42. package/dist/components/ui/badge.d.ts +9 -0
  43. package/dist/components/ui/badge.js +19 -0
  44. package/dist/components/ui/button.d.ts +11 -0
  45. package/dist/components/ui/button.js +33 -0
  46. package/dist/components/ui/calendar.d.ts +8 -0
  47. package/dist/components/ui/calendar.js +72 -0
  48. package/dist/components/ui/card.d.ts +8 -0
  49. package/dist/components/ui/card.js +16 -0
  50. package/dist/components/ui/checkbox.d.ts +4 -0
  51. package/dist/components/ui/checkbox.js +8 -0
  52. package/dist/components/ui/chip-cls.d.ts +1 -0
  53. package/dist/components/ui/chip-cls.js +1 -0
  54. package/dist/components/ui/combobox.d.ts +24 -0
  55. package/dist/components/ui/combobox.js +58 -0
  56. package/dist/components/ui/confirm.d.ts +10 -0
  57. package/dist/components/ui/confirm.js +37 -0
  58. package/dist/components/ui/date-picker.d.ts +5 -0
  59. package/dist/components/ui/date-picker.js +16 -0
  60. package/dist/components/ui/dialog.d.ts +16 -0
  61. package/dist/components/ui/dialog.js +27 -0
  62. package/dist/components/ui/dropdown-menu.d.ts +15 -0
  63. package/dist/components/ui/dropdown-menu.js +18 -0
  64. package/dist/components/ui/input-group.d.ts +16 -0
  65. package/dist/components/ui/input-group.js +56 -0
  66. package/dist/components/ui/input.d.ts +3 -0
  67. package/dist/components/ui/input.js +6 -0
  68. package/dist/components/ui/label.d.ts +4 -0
  69. package/dist/components/ui/label.js +7 -0
  70. package/dist/components/ui/mask-input.d.ts +61 -0
  71. package/dist/components/ui/mask-input.js +1052 -0
  72. package/dist/components/ui/month-year-picker.d.ts +10 -0
  73. package/dist/components/ui/month-year-picker.js +46 -0
  74. package/dist/components/ui/option-icon.d.ts +15 -0
  75. package/dist/components/ui/option-icon.js +19 -0
  76. package/dist/components/ui/phone-input.d.ts +13 -0
  77. package/dist/components/ui/phone-input.js +53 -0
  78. package/dist/components/ui/popover.d.ts +11 -0
  79. package/dist/components/ui/popover.js +28 -0
  80. package/dist/components/ui/rating.d.ts +44 -0
  81. package/dist/components/ui/rating.js +501 -0
  82. package/dist/components/ui/scroll-area.d.ts +5 -0
  83. package/dist/components/ui/scroll-area.js +11 -0
  84. package/dist/components/ui/select-combobox.d.ts +25 -0
  85. package/dist/components/ui/select-combobox.js +36 -0
  86. package/dist/components/ui/select.d.ts +13 -0
  87. package/dist/components/ui/select.js +24 -0
  88. package/dist/components/ui/separator.d.ts +4 -0
  89. package/dist/components/ui/separator.js +7 -0
  90. package/dist/components/ui/switch.d.ts +4 -0
  91. package/dist/components/ui/switch.js +7 -0
  92. package/dist/components/ui/textarea.d.ts +3 -0
  93. package/dist/components/ui/textarea.js +6 -0
  94. package/dist/components/ui/time-picker.d.ts +84 -0
  95. package/dist/components/ui/time-picker.js +1258 -0
  96. package/dist/components/visually-hidden-input.d.ts +10 -0
  97. package/dist/components/visually-hidden-input.js +96 -0
  98. package/dist/hooks/use-as-ref.d.ts +3 -0
  99. package/dist/hooks/use-as-ref.js +10 -0
  100. package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
  101. package/dist/hooks/use-isomorphic-layout-effect.js +3 -0
  102. package/dist/hooks/use-lazy-ref.d.ts +3 -0
  103. package/dist/hooks/use-lazy-ref.js +9 -0
  104. package/dist/hooks/use-media-query.d.ts +3 -0
  105. package/dist/hooks/use-media-query.js +26 -0
  106. package/dist/host-services.d.ts +47 -0
  107. package/dist/host-services.js +35 -0
  108. package/dist/index.d.ts +70 -0
  109. package/dist/index.js +69 -0
  110. package/dist/layout.d.ts +29 -0
  111. package/dist/layout.js +323 -0
  112. package/dist/lib/cat-color.d.ts +1 -0
  113. package/dist/lib/cat-color.js +7 -0
  114. package/dist/lib/compose-refs.d.ts +5 -0
  115. package/dist/lib/compose-refs.js +38 -0
  116. package/dist/lib/date-format.d.ts +9 -0
  117. package/dist/lib/date-format.js +31 -0
  118. package/dist/lib/format.d.ts +14 -0
  119. package/dist/lib/format.js +34 -0
  120. package/dist/lib/json.d.ts +1 -0
  121. package/dist/lib/json.js +12 -0
  122. package/dist/lib/multi-value.d.ts +3 -0
  123. package/dist/lib/multi-value.js +22 -0
  124. package/dist/lib/record-option.d.ts +7 -0
  125. package/dist/lib/record-option.js +52 -0
  126. package/dist/lib/use-record-labels.d.ts +14 -0
  127. package/dist/lib/use-record-labels.js +130 -0
  128. package/dist/lib/utils.d.ts +2 -0
  129. package/dist/lib/utils.js +5 -0
  130. package/dist/list-view.d.ts +26 -0
  131. package/dist/list-view.js +11 -0
  132. package/dist/markdown/blocks.d.ts +10 -0
  133. package/dist/markdown/blocks.js +57 -0
  134. package/dist/markdown/extensions.d.ts +6 -0
  135. package/dist/markdown/extensions.js +25 -0
  136. package/dist/markdown/slash.d.ts +23 -0
  137. package/dist/markdown/slash.js +27 -0
  138. package/dist/markdown/toolbar.d.ts +13 -0
  139. package/dist/markdown/toolbar.js +119 -0
  140. package/dist/plugin-ui.d.ts +43 -0
  141. package/dist/plugin-ui.js +37 -0
  142. package/dist/registry.d.ts +26 -0
  143. package/dist/registry.js +169 -0
  144. package/dist/render/blocks/accordion.d.ts +1 -0
  145. package/dist/render/blocks/accordion.js +15 -0
  146. package/dist/render/blocks/aside.d.ts +1 -0
  147. package/dist/render/blocks/aside.js +14 -0
  148. package/dist/render/blocks/balance.d.ts +1 -0
  149. package/dist/render/blocks/balance.js +14 -0
  150. package/dist/render/blocks/bento.d.ts +1 -0
  151. package/dist/render/blocks/bento.js +24 -0
  152. package/dist/render/blocks/block-shell.d.ts +15 -0
  153. package/dist/render/blocks/block-shell.js +20 -0
  154. package/dist/render/blocks/calendar.d.ts +1 -0
  155. package/dist/render/blocks/calendar.js +142 -0
  156. package/dist/render/blocks/callout.d.ts +1 -0
  157. package/dist/render/blocks/callout.js +21 -0
  158. package/dist/render/blocks/chart.d.ts +1 -0
  159. package/dist/render/blocks/chart.js +46 -0
  160. package/dist/render/blocks/compare.d.ts +1 -0
  161. package/dist/render/blocks/compare.js +16 -0
  162. package/dist/render/blocks/countdown.d.ts +1 -0
  163. package/dist/render/blocks/countdown.js +36 -0
  164. package/dist/render/blocks/deck.d.ts +1 -0
  165. package/dist/render/blocks/deck.js +29 -0
  166. package/dist/render/blocks/epigraph.d.ts +1 -0
  167. package/dist/render/blocks/epigraph.js +13 -0
  168. package/dist/render/blocks/facets.d.ts +1 -0
  169. package/dist/render/blocks/facets.js +23 -0
  170. package/dist/render/blocks/figure.d.ts +1 -0
  171. package/dist/render/blocks/figure.js +13 -0
  172. package/dist/render/blocks/grid.d.ts +1 -0
  173. package/dist/render/blocks/grid.js +21 -0
  174. package/dist/render/blocks/heatmap.d.ts +1 -0
  175. package/dist/render/blocks/heatmap.js +135 -0
  176. package/dist/render/blocks/idcard.d.ts +1 -0
  177. package/dist/render/blocks/idcard.js +30 -0
  178. package/dist/render/blocks/identity.d.ts +1 -0
  179. package/dist/render/blocks/identity.js +46 -0
  180. package/dist/render/blocks/index.d.ts +40 -0
  181. package/dist/render/blocks/index.js +40 -0
  182. package/dist/render/blocks/journal.d.ts +1 -0
  183. package/dist/render/blocks/journal.js +50 -0
  184. package/dist/render/blocks/ledger.d.ts +1 -0
  185. package/dist/render/blocks/ledger.js +23 -0
  186. package/dist/render/blocks/manifest.d.ts +1 -0
  187. package/dist/render/blocks/manifest.js +50 -0
  188. package/dist/render/blocks/masthead.d.ts +1 -0
  189. package/dist/render/blocks/masthead.js +15 -0
  190. package/dist/render/blocks/meter.d.ts +1 -0
  191. package/dist/render/blocks/meter.js +32 -0
  192. package/dist/render/blocks/nutrition.d.ts +1 -0
  193. package/dist/render/blocks/nutrition.js +27 -0
  194. package/dist/render/blocks/people.d.ts +1 -0
  195. package/dist/render/blocks/people.js +35 -0
  196. package/dist/render/blocks/plaque.d.ts +1 -0
  197. package/dist/render/blocks/plaque.js +15 -0
  198. package/dist/render/blocks/properties.d.ts +1 -0
  199. package/dist/render/blocks/properties.js +22 -0
  200. package/dist/render/blocks/prose.d.ts +1 -0
  201. package/dist/render/blocks/prose.js +17 -0
  202. package/dist/render/blocks/receipt.d.ts +1 -0
  203. package/dist/render/blocks/receipt.js +23 -0
  204. package/dist/render/blocks/registry.d.ts +16 -0
  205. package/dist/render/blocks/registry.js +7 -0
  206. package/dist/render/blocks/relation-source.d.ts +2 -0
  207. package/dist/render/blocks/relation-source.js +6 -0
  208. package/dist/render/blocks/route.d.ts +1 -0
  209. package/dist/render/blocks/route.js +23 -0
  210. package/dist/render/blocks/score.d.ts +1 -0
  211. package/dist/render/blocks/score.js +15 -0
  212. package/dist/render/blocks/series.d.ts +23 -0
  213. package/dist/render/blocks/series.js +57 -0
  214. package/dist/render/blocks/specimen.d.ts +1 -0
  215. package/dist/render/blocks/specimen.js +19 -0
  216. package/dist/render/blocks/split.d.ts +1 -0
  217. package/dist/render/blocks/split.js +15 -0
  218. package/dist/render/blocks/spread.d.ts +1 -0
  219. package/dist/render/blocks/spread.js +15 -0
  220. package/dist/render/blocks/stack.d.ts +1 -0
  221. package/dist/render/blocks/stack.js +15 -0
  222. package/dist/render/blocks/stats.d.ts +1 -0
  223. package/dist/render/blocks/stats.js +23 -0
  224. package/dist/render/blocks/status.d.ts +1 -0
  225. package/dist/render/blocks/status.js +18 -0
  226. package/dist/render/blocks/table.d.ts +11 -0
  227. package/dist/render/blocks/table.js +136 -0
  228. package/dist/render/blocks/tabs.d.ts +1 -0
  229. package/dist/render/blocks/tabs.js +17 -0
  230. package/dist/render/blocks/terminal.d.ts +1 -0
  231. package/dist/render/blocks/terminal.js +18 -0
  232. package/dist/render/blocks/timeline.d.ts +1 -0
  233. package/dist/render/blocks/timeline.js +31 -0
  234. package/dist/render/box.d.ts +5 -0
  235. package/dist/render/box.js +23 -0
  236. package/dist/render/chrome.d.ts +64 -0
  237. package/dist/render/chrome.js +92 -0
  238. package/dist/render/core/amount.d.ts +1 -0
  239. package/dist/render/core/amount.js +19 -0
  240. package/dist/render/core/attachment.d.ts +29 -0
  241. package/dist/render/core/attachment.js +102 -0
  242. package/dist/render/core/choice.d.ts +1 -0
  243. package/dist/render/core/choice.js +40 -0
  244. package/dist/render/core/composite.d.ts +1 -0
  245. package/dist/render/core/composite.js +132 -0
  246. package/dist/render/core/datetime.d.ts +2 -0
  247. package/dist/render/core/datetime.js +215 -0
  248. package/dist/render/core/dimensions.d.ts +1 -0
  249. package/dist/render/core/dimensions.js +44 -0
  250. package/dist/render/core/embed.d.ts +11 -0
  251. package/dist/render/core/embed.js +99 -0
  252. package/dist/render/core/file.d.ts +12 -0
  253. package/dist/render/core/file.js +238 -0
  254. package/dist/render/core/illustrated.d.ts +39 -0
  255. package/dist/render/core/illustrated.js +113 -0
  256. package/dist/render/core/index.d.ts +23 -0
  257. package/dist/render/core/index.js +23 -0
  258. package/dist/render/core/layout-elements.d.ts +1 -0
  259. package/dist/render/core/layout-elements.js +78 -0
  260. package/dist/render/core/localpath.d.ts +6 -0
  261. package/dist/render/core/localpath.js +73 -0
  262. package/dist/render/core/money.d.ts +1 -0
  263. package/dist/render/core/money.js +39 -0
  264. package/dist/render/core/number.d.ts +17 -0
  265. package/dist/render/core/number.js +104 -0
  266. package/dist/render/core/period.d.ts +1 -0
  267. package/dist/render/core/period.js +60 -0
  268. package/dist/render/core/range.d.ts +1 -0
  269. package/dist/render/core/range.js +55 -0
  270. package/dist/render/core/reminder.d.ts +2 -0
  271. package/dist/render/core/reminder.js +56 -0
  272. package/dist/render/core/source.d.ts +3 -0
  273. package/dist/render/core/source.js +65 -0
  274. package/dist/render/core/stepper.d.ts +1 -0
  275. package/dist/render/core/stepper.js +81 -0
  276. package/dist/render/core/storage-group.d.ts +1 -0
  277. package/dist/render/core/storage-group.js +30 -0
  278. package/dist/render/core/text.d.ts +15 -0
  279. package/dist/render/core/text.js +370 -0
  280. package/dist/render/core/tristate.d.ts +1 -0
  281. package/dist/render/core/tristate.js +42 -0
  282. package/dist/render/core/weight.d.ts +4 -0
  283. package/dist/render/core/weight.js +38 -0
  284. package/dist/render/dispatch.d.ts +12 -0
  285. package/dist/render/dispatch.js +53 -0
  286. package/dist/render/display-override.d.ts +25 -0
  287. package/dist/render/display-override.js +23 -0
  288. package/dist/render/editor-mode.d.ts +4 -0
  289. package/dist/render/editor-mode.js +11 -0
  290. package/dist/render/field-address.d.ts +14 -0
  291. package/dist/render/field-address.js +10 -0
  292. package/dist/render/field-errors.d.ts +8 -0
  293. package/dist/render/field-errors.js +25 -0
  294. package/dist/render/field-frame.d.ts +20 -0
  295. package/dist/render/field-frame.js +78 -0
  296. package/dist/render/field-scope.d.ts +8 -0
  297. package/dist/render/field-scope.js +25 -0
  298. package/dist/render/field-width.d.ts +7 -0
  299. package/dist/render/field-width.js +12 -0
  300. package/dist/render/form-types.d.ts +12 -0
  301. package/dist/render/form-types.js +1 -0
  302. package/dist/render/hybrid-scope.d.ts +5 -0
  303. package/dist/render/hybrid-scope.js +9 -0
  304. package/dist/render/image.d.ts +64 -0
  305. package/dist/render/image.js +322 -0
  306. package/dist/render/live-kind.d.ts +7 -0
  307. package/dist/render/live-kind.js +104 -0
  308. package/dist/render/markdown-view.d.ts +5 -0
  309. package/dist/render/markdown-view.js +17 -0
  310. package/dist/render/multi.d.ts +10 -0
  311. package/dist/render/multi.js +26 -0
  312. package/dist/render/multiple-chips.d.ts +24 -0
  313. package/dist/render/multiple-chips.js +18 -0
  314. package/dist/render/option-list.d.ts +15 -0
  315. package/dist/render/option-list.js +47 -0
  316. package/dist/render/option-value.d.ts +20 -0
  317. package/dist/render/option-value.js +41 -0
  318. package/dist/render/picker-scrim.d.ts +7 -0
  319. package/dist/render/picker-scrim.js +32 -0
  320. package/dist/render/picker-surface.d.ts +5 -0
  321. package/dist/render/picker-surface.js +9 -0
  322. package/dist/render/popover-field.d.ts +16 -0
  323. package/dist/render/popover-field.js +153 -0
  324. package/dist/render/record-save-ctx.d.ts +11 -0
  325. package/dist/render/record-save-ctx.js +41 -0
  326. package/dist/render/shared.d.ts +92 -0
  327. package/dist/render/shared.js +182 -0
  328. package/dist/render/slot.d.ts +45 -0
  329. package/dist/render/slot.js +194 -0
  330. package/dist/render/sort-rows.d.ts +3 -0
  331. package/dist/render/sort-rows.js +38 -0
  332. package/dist/render/use-collection-rows.d.ts +10 -0
  333. package/dist/render/use-collection-rows.js +11 -0
  334. package/dist/render/use-field-edit.d.ts +28 -0
  335. package/dist/render/use-field-edit.js +50 -0
  336. package/dist/render/use-file-upload.d.ts +10 -0
  337. package/dist/render/use-file-upload.js +35 -0
  338. package/dist/render/use-form-bridge.d.ts +21 -0
  339. package/dist/render/use-form-bridge.js +53 -0
  340. package/dist/render/use-hybrid.d.ts +2 -0
  341. package/dist/render/use-hybrid.js +5 -0
  342. package/dist/render/widgets/attachment-group.d.ts +1 -0
  343. package/dist/render/widgets/attachment-group.js +35 -0
  344. package/dist/render/widgets/checklist-content.d.ts +15 -0
  345. package/dist/render/widgets/checklist-content.js +12 -0
  346. package/dist/render/widgets/checklist-group.d.ts +11 -0
  347. package/dist/render/widgets/checklist-group.js +47 -0
  348. package/dist/render/widgets/checklist-row.d.ts +14 -0
  349. package/dist/render/widgets/checklist-row.js +14 -0
  350. package/dist/render/widgets/display.d.ts +33 -0
  351. package/dist/render/widgets/display.js +97 -0
  352. package/dist/render/widgets/edit.d.ts +63 -0
  353. package/dist/render/widgets/edit.js +283 -0
  354. package/dist/render/widgets/fixed-collection.d.ts +11 -0
  355. package/dist/render/widgets/fixed-collection.js +34 -0
  356. package/dist/render/widgets/flow-row.d.ts +14 -0
  357. package/dist/render/widgets/flow-row.js +27 -0
  358. package/dist/render/widgets/group-edit.d.ts +9 -0
  359. package/dist/render/widgets/group-edit.js +23 -0
  360. package/dist/render/widgets/group-field.d.ts +9 -0
  361. package/dist/render/widgets/group-field.js +42 -0
  362. package/dist/render/widgets/group-widgets.d.ts +2 -0
  363. package/dist/render/widgets/group-widgets.js +41 -0
  364. package/dist/render/widgets/group.d.ts +26 -0
  365. package/dist/render/widgets/group.js +139 -0
  366. package/dist/render/widgets/illustrated-group.d.ts +1 -0
  367. package/dist/render/widgets/illustrated-group.js +41 -0
  368. package/dist/render/widgets/table-group.d.ts +11 -0
  369. package/dist/render/widgets/table-group.js +58 -0
  370. package/dist/render/widgets/two-cell-group.d.ts +21 -0
  371. package/dist/render/widgets/two-cell-group.js +42 -0
  372. package/dist/render/widgets/url-widget.d.ts +7 -0
  373. package/dist/render/widgets/url-widget.js +15 -0
  374. package/dist/render/widgets/weekday-grid.d.ts +13 -0
  375. package/dist/render/widgets/weekday-grid.js +47 -0
  376. package/dist/render/write.d.ts +5 -0
  377. package/dist/render/write.js +14 -0
  378. package/dist/schema-registry.d.ts +6 -0
  379. package/dist/schema-registry.js +25 -0
  380. package/dist/site-links.d.ts +13 -0
  381. package/dist/site-links.js +18 -0
  382. package/dist/strip-markdown.d.ts +1 -0
  383. package/dist/strip-markdown.js +11 -0
  384. package/dist/theme.css +189 -0
  385. package/dist/types.d.ts +84 -0
  386. package/dist/types.js +1 -0
  387. package/package.json +85 -0
@@ -0,0 +1,501 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Star } from 'lucide-react';
4
+ import * as SlotPrimitive from '@radix-ui/react-slot';
5
+ import * as DirectionPrimitive from '@radix-ui/react-direction';
6
+ import * as React from 'react';
7
+ import { useComposedRefs } from "../../lib/compose-refs.js";
8
+ import { cn } from "../../lib/utils.js";
9
+ import { VisuallyHiddenInput } from "../visually-hidden-input.js";
10
+ import { useAsRef } from "../../hooks/use-as-ref.js";
11
+ import { useIsomorphicLayoutEffect } from "../../hooks/use-isomorphic-layout-effect.js";
12
+ import { useLazyRef } from "../../hooks/use-lazy-ref.js";
13
+ const ROOT_NAME = 'Rating';
14
+ const ITEM_NAME = 'RatingItem';
15
+ const ENTRY_FOCUS = 'ratingFocusGroup.onEntryFocus';
16
+ const EVENT_OPTIONS = { bubbles: false, cancelable: true };
17
+ function getItemId(id, value) {
18
+ return `${id}-item-${value}`;
19
+ }
20
+ function getPartialFillGradientId(id, step) {
21
+ return `partial-fill-gradient-${id}-${step}`;
22
+ }
23
+ const MAP_KEY_TO_FOCUS_INTENT = {
24
+ ArrowLeft: 'prev',
25
+ ArrowUp: 'prev',
26
+ ArrowRight: 'next',
27
+ ArrowDown: 'next',
28
+ Home: 'first',
29
+ End: 'last',
30
+ };
31
+ function getDirectionAwareKey(key, dir) {
32
+ if (dir !== 'rtl')
33
+ return key;
34
+ return key === 'ArrowLeft' ? 'ArrowRight' : key === 'ArrowRight' ? 'ArrowLeft' : key;
35
+ }
36
+ function getFocusIntent(event, dir, orientation) {
37
+ const key = getDirectionAwareKey(event.key, dir);
38
+ if (orientation === 'horizontal' && ['ArrowUp', 'ArrowDown'].includes(key))
39
+ return undefined;
40
+ if (orientation === 'vertical' && ['ArrowLeft', 'ArrowRight'].includes(key))
41
+ return undefined;
42
+ return MAP_KEY_TO_FOCUS_INTENT[key];
43
+ }
44
+ function focusFirst(candidates, preventScroll = false) {
45
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
46
+ for (const candidateRef of candidates) {
47
+ const candidate = candidateRef.current;
48
+ if (!candidate)
49
+ continue;
50
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
51
+ return;
52
+ candidate.focus({ preventScroll });
53
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT)
54
+ return;
55
+ }
56
+ }
57
+ const StoreContext = React.createContext(null);
58
+ function useStoreContext(consumerName) {
59
+ const context = React.useContext(StoreContext);
60
+ if (!context) {
61
+ throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
62
+ }
63
+ return context;
64
+ }
65
+ function useStore(selector, ogStore) {
66
+ const contextStore = React.useContext(StoreContext);
67
+ const store = ogStore ?? contextStore;
68
+ if (!store) {
69
+ throw new Error(`\`useStore\` must be used within \`${ROOT_NAME}\``);
70
+ }
71
+ const getSnapshot = React.useCallback(() => selector(store.getState()), [store, selector]);
72
+ return React.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
73
+ }
74
+ const RatingContext = React.createContext(null);
75
+ function useRatingContext(consumerName) {
76
+ const context = React.useContext(RatingContext);
77
+ if (!context) {
78
+ throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
79
+ }
80
+ return context;
81
+ }
82
+ const FocusContext = React.createContext(null);
83
+ function useFocusContext(consumerName) {
84
+ const context = React.useContext(FocusContext);
85
+ if (!context) {
86
+ throw new Error(`\`${consumerName}\` must be used within \`FocusProvider\``);
87
+ }
88
+ return context;
89
+ }
90
+ function Rating(props) {
91
+ const { value: valueProp, defaultValue = 0, onValueChange, onHover, onFocus: onFocusProp, onMouseDown: onMouseDownProp, dir: dirProp, orientation = 'horizontal', activationMode = 'automatic', size = 'default', max = 5, step = 1, clearable = false, asChild, disabled = false, readOnly = false, required = false, className, id, name, ref, ...rootProps } = props;
92
+ const dir = DirectionPrimitive.useDirection(dirProp);
93
+ const instanceId = React.useId();
94
+ const rootId = id ?? instanceId;
95
+ const listenersRef = useLazyRef(() => new Set());
96
+ const stateRef = useLazyRef(() => ({
97
+ value: valueProp ?? defaultValue,
98
+ hoveredValue: null,
99
+ }));
100
+ const propsRef = useAsRef({
101
+ onValueChange,
102
+ onHover,
103
+ onFocus: onFocusProp,
104
+ onMouseDown: onMouseDownProp,
105
+ step,
106
+ });
107
+ const store = React.useMemo(() => {
108
+ return {
109
+ subscribe: (cb) => {
110
+ listenersRef.current.add(cb);
111
+ return () => listenersRef.current.delete(cb);
112
+ },
113
+ getState: () => stateRef.current,
114
+ setState: (key, value) => {
115
+ if (Object.is(stateRef.current[key], value))
116
+ return;
117
+ if (key === 'value' && typeof value === 'number') {
118
+ stateRef.current.value = value;
119
+ propsRef.current.onValueChange?.(value);
120
+ }
121
+ else if (key === 'hoveredValue') {
122
+ stateRef.current.hoveredValue = value;
123
+ propsRef.current.onHover?.(value);
124
+ }
125
+ else {
126
+ stateRef.current[key] = value;
127
+ }
128
+ store.notify();
129
+ },
130
+ notify: () => {
131
+ for (const cb of listenersRef.current) {
132
+ cb();
133
+ }
134
+ },
135
+ };
136
+ }, [listenersRef, stateRef, propsRef]);
137
+ useIsomorphicLayoutEffect(() => {
138
+ if (valueProp === undefined || Object.is(stateRef.current.value, valueProp))
139
+ return;
140
+ stateRef.current.value = valueProp;
141
+ store.notify();
142
+ }, [valueProp]);
143
+ const value = useStore((state) => state.value, store);
144
+ const [formTrigger, setFormTrigger] = React.useState(null);
145
+ const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
146
+ const isFormControl = formTrigger ? !!formTrigger.closest('form') : true;
147
+ const [tabStopId, setTabStopId] = React.useState(null);
148
+ const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
149
+ const [focusableItemCount, setFocusableItemCount] = React.useState(0);
150
+ const isClickFocusRef = React.useRef(false);
151
+ const itemsRef = React.useRef(new Map());
152
+ const autoIndexMapRef = React.useRef(new Map());
153
+ const nextAutoIndexRef = React.useRef(0);
154
+ const getAutoIndex = React.useCallback((instanceId) => {
155
+ const existingIndex = autoIndexMapRef.current.get(instanceId);
156
+ if (existingIndex !== undefined) {
157
+ return existingIndex;
158
+ }
159
+ const newIndex = nextAutoIndexRef.current++;
160
+ autoIndexMapRef.current.set(instanceId, newIndex);
161
+ return newIndex;
162
+ }, []);
163
+ const onItemFocus = React.useCallback((tabStopId) => {
164
+ setTabStopId(tabStopId);
165
+ }, []);
166
+ const onItemShiftTab = React.useCallback(() => {
167
+ setIsTabbingBackOut(true);
168
+ }, []);
169
+ const onFocusableItemAdd = React.useCallback(() => {
170
+ setFocusableItemCount((prevCount) => prevCount + 1);
171
+ }, []);
172
+ const onFocusableItemRemove = React.useCallback(() => {
173
+ setFocusableItemCount((prevCount) => prevCount - 1);
174
+ }, []);
175
+ const onItemRegister = React.useCallback((item) => {
176
+ itemsRef.current.set(item.id, item);
177
+ }, []);
178
+ const onItemUnregister = React.useCallback((id) => {
179
+ itemsRef.current.delete(id);
180
+ }, []);
181
+ const getItems = React.useCallback(() => {
182
+ return Array.from(itemsRef.current.values())
183
+ .filter((item) => item.ref.current)
184
+ .sort((a, b) => {
185
+ const elementA = a.ref.current;
186
+ const elementB = b.ref.current;
187
+ if (!elementA || !elementB)
188
+ return 0;
189
+ const position = elementA.compareDocumentPosition(elementB);
190
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
191
+ return -1;
192
+ }
193
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
194
+ return 1;
195
+ }
196
+ return 0;
197
+ });
198
+ }, []);
199
+ const onBlur = React.useCallback((event) => {
200
+ rootProps.onBlur?.(event);
201
+ if (event.defaultPrevented)
202
+ return;
203
+ setIsTabbingBackOut(false);
204
+ }, [rootProps.onBlur]);
205
+ const onFocus = React.useCallback((event) => {
206
+ propsRef.current.onFocus?.(event);
207
+ if (event.defaultPrevented)
208
+ return;
209
+ const isKeyboardFocus = !isClickFocusRef.current;
210
+ if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
211
+ const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
212
+ event.currentTarget.dispatchEvent(entryFocusEvent);
213
+ if (!entryFocusEvent.defaultPrevented) {
214
+ const items = Array.from(itemsRef.current.values()).filter((item) => !item.disabled);
215
+ const selectedItem = propsRef.current.step < 1
216
+ ? items.find((item) => item.value === Math.ceil(value))
217
+ : items.find((item) => item.value === value);
218
+ const currentItem = items.find((item) => item.id === tabStopId);
219
+ const candidateItems = [selectedItem, currentItem, ...items].filter(Boolean);
220
+ const candidateRefs = candidateItems.map((item) => item.ref);
221
+ focusFirst(candidateRefs, false);
222
+ }
223
+ }
224
+ isClickFocusRef.current = false;
225
+ }, [propsRef, isTabbingBackOut, value, tabStopId]);
226
+ const onMouseDown = React.useCallback((event) => {
227
+ propsRef.current.onMouseDown?.(event);
228
+ if (event.defaultPrevented)
229
+ return;
230
+ isClickFocusRef.current = true;
231
+ }, [propsRef]);
232
+ const contextValue = React.useMemo(() => ({
233
+ rootId,
234
+ dir,
235
+ orientation,
236
+ activationMode,
237
+ disabled,
238
+ readOnly,
239
+ size,
240
+ max,
241
+ step,
242
+ clearable,
243
+ getAutoIndex,
244
+ }), [rootId, dir, orientation, activationMode, disabled, readOnly, size, max, step, clearable, getAutoIndex]);
245
+ const focusContextValue = React.useMemo(() => ({
246
+ tabStopId,
247
+ onItemFocus,
248
+ onItemShiftTab,
249
+ onFocusableItemAdd,
250
+ onFocusableItemRemove,
251
+ onItemRegister,
252
+ onItemUnregister,
253
+ getItems,
254
+ }), [
255
+ tabStopId,
256
+ onItemFocus,
257
+ onItemShiftTab,
258
+ onFocusableItemAdd,
259
+ onFocusableItemRemove,
260
+ onItemRegister,
261
+ onItemUnregister,
262
+ getItems,
263
+ ]);
264
+ const RootPrimitive = asChild ? SlotPrimitive.Slot : 'div';
265
+ return (_jsx(StoreContext.Provider, { value: store, children: _jsx(RatingContext.Provider, { value: contextValue, children: _jsxs(FocusContext.Provider, { value: focusContextValue, children: [_jsx(RootPrimitive, { id: rootId, role: "radiogroup", "aria-orientation": orientation, "data-disabled": disabled ? '' : undefined, "data-readonly": readOnly ? '' : undefined, "data-orientation": orientation, "data-slot": "rating", dir: dir, tabIndex: isTabbingBackOut || focusableItemCount === 0 ? -1 : 0, ...rootProps, ref: composedRef, className: cn('flex gap-1 text-primary outline-none', orientation === 'horizontal' ? 'flex-row items-center' : 'flex-col items-start', className), onBlur: onBlur, onFocus: onFocus, onMouseDown: onMouseDown }), _jsx("svg", { width: "0", height: "0", style: { position: 'absolute' }, children: _jsx("defs", { children: _jsx("linearGradient", { id: getPartialFillGradientId(rootId, step), children: dir === 'rtl' ? (_jsxs(_Fragment, { children: [_jsx("stop", { offset: "50%", stopColor: "transparent" }), _jsx("stop", { offset: "50%", stopColor: "currentColor" })] })) : (_jsxs(_Fragment, { children: [_jsx("stop", { offset: "50%", stopColor: "currentColor" }), _jsx("stop", { offset: "50%", stopColor: "transparent" })] })) }) }) }), isFormControl && (_jsx(VisuallyHiddenInput, { type: "hidden", control: formTrigger, name: name, value: value, disabled: disabled, readOnly: readOnly, required: required }))] }) }) }));
266
+ }
267
+ function RatingItem(props) {
268
+ const { index, asChild, onClick: onClickProp, onFocus: onFocusProp, onKeyDown: onKeyDownProp, onMouseDown: onMouseDownProp, onMouseEnter: onMouseEnterProp, onMouseMove: onMouseMoveProp, onMouseLeave: onMouseLeaveProp, disabled, className, children, ref, ...itemProps } = props;
269
+ const itemRef = React.useRef(null);
270
+ const composedRef = useComposedRefs(ref, itemRef);
271
+ const context = useRatingContext(ITEM_NAME);
272
+ const instanceId = React.useId();
273
+ const actualIndex = React.useMemo(() => {
274
+ if (index !== undefined) {
275
+ return index;
276
+ }
277
+ return context.getAutoIndex(instanceId);
278
+ }, [index, context, instanceId]);
279
+ const itemValue = actualIndex + 1;
280
+ const store = useStoreContext(ITEM_NAME);
281
+ const focusContext = useFocusContext(ITEM_NAME);
282
+ const value = useStore((state) => state.value);
283
+ const hoveredValue = useStore((state) => state.hoveredValue);
284
+ const clearable = context.clearable;
285
+ const step = context.step;
286
+ const activationMode = context.activationMode;
287
+ const itemId = getItemId(context.rootId, itemValue);
288
+ const isDisabled = context.disabled || disabled;
289
+ const isReadOnly = context.readOnly;
290
+ const isTabStop = focusContext.tabStopId === itemId;
291
+ const displayValue = hoveredValue ?? value;
292
+ const isFilled = displayValue >= itemValue;
293
+ const isPartiallyFilled = step < 1 && displayValue >= itemValue - step && displayValue < itemValue;
294
+ const isHovered = hoveredValue !== null && hoveredValue < itemValue;
295
+ const isMouseClickRef = React.useRef(false);
296
+ const propsRef = useAsRef({
297
+ onClick: onClickProp,
298
+ onFocus: onFocusProp,
299
+ onKeyDown: onKeyDownProp,
300
+ onMouseDown: onMouseDownProp,
301
+ onMouseEnter: onMouseEnterProp,
302
+ onMouseMove: onMouseMoveProp,
303
+ onMouseLeave: onMouseLeaveProp,
304
+ });
305
+ useIsomorphicLayoutEffect(() => {
306
+ focusContext.onItemRegister({
307
+ id: itemId,
308
+ ref: itemRef,
309
+ value: itemValue,
310
+ disabled: !!isDisabled,
311
+ });
312
+ if (!isDisabled) {
313
+ focusContext.onFocusableItemAdd();
314
+ }
315
+ return () => {
316
+ focusContext.onItemUnregister(itemId);
317
+ if (!isDisabled) {
318
+ focusContext.onFocusableItemRemove();
319
+ }
320
+ };
321
+ }, [focusContext, itemId, itemValue, isDisabled]);
322
+ const onClick = React.useCallback((event) => {
323
+ propsRef.current.onClick?.(event);
324
+ if (event.defaultPrevented)
325
+ return;
326
+ if (!isDisabled && !isReadOnly) {
327
+ let newValue = itemValue;
328
+ if (step < 1) {
329
+ const rect = event.currentTarget.getBoundingClientRect();
330
+ const clickX = event.clientX - rect.left;
331
+ const isLeftHalf = clickX < rect.width / 2;
332
+ if (context.dir === 'rtl') {
333
+ if (!isLeftHalf) {
334
+ newValue = itemValue - step;
335
+ }
336
+ }
337
+ else {
338
+ if (isLeftHalf) {
339
+ newValue = itemValue - step;
340
+ }
341
+ }
342
+ }
343
+ if (clearable && value === newValue) {
344
+ newValue = 0;
345
+ }
346
+ store.setState('value', newValue);
347
+ }
348
+ }, [isDisabled, isReadOnly, clearable, step, value, itemValue, store, context.dir, propsRef]);
349
+ const onFocus = React.useCallback((event) => {
350
+ propsRef.current.onFocus?.(event);
351
+ if (event.defaultPrevented)
352
+ return;
353
+ focusContext.onItemFocus(itemId);
354
+ const isKeyboardFocus = !isMouseClickRef.current;
355
+ if (!isDisabled && !isReadOnly && activationMode !== 'manual' && isKeyboardFocus) {
356
+ const isHalfStepValue = step < 1 && value === itemValue - step;
357
+ if (!isHalfStepValue) {
358
+ const newValue = clearable && value === itemValue ? 0 : itemValue;
359
+ store.setState('value', newValue);
360
+ }
361
+ }
362
+ isMouseClickRef.current = false;
363
+ }, [focusContext, itemId, activationMode, isDisabled, isReadOnly, clearable, value, itemValue, step, store, propsRef]);
364
+ const onKeyDown = React.useCallback((event) => {
365
+ propsRef.current.onKeyDown?.(event);
366
+ if (event.defaultPrevented)
367
+ return;
368
+ if ((event.key === 'Enter' || event.key === ' ') && activationMode === 'manual') {
369
+ event.preventDefault();
370
+ if (!isDisabled && !isReadOnly && itemRef.current) {
371
+ itemRef.current.click();
372
+ }
373
+ return;
374
+ }
375
+ if (event.key === 'Tab' && event.shiftKey) {
376
+ focusContext.onItemShiftTab();
377
+ return;
378
+ }
379
+ if (event.target !== event.currentTarget)
380
+ return;
381
+ const focusIntent = getFocusIntent(event, context.dir, context.orientation);
382
+ if (focusIntent !== undefined) {
383
+ if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey)
384
+ return;
385
+ event.preventDefault();
386
+ if (step < 1 && (focusIntent === 'prev' || focusIntent === 'next')) {
387
+ if (!isDisabled && !isReadOnly) {
388
+ let newValue = value;
389
+ if (focusIntent === 'next') {
390
+ newValue = Math.min(value + step, context.max);
391
+ }
392
+ else {
393
+ newValue = Math.max(value - step, 0);
394
+ }
395
+ store.setState('value', newValue);
396
+ const items = focusContext.getItems().filter((item) => !item.disabled);
397
+ const targetItem = items.find((item) => item.value === Math.ceil(newValue));
398
+ if (targetItem?.ref.current) {
399
+ queueMicrotask(() => targetItem.ref.current?.focus());
400
+ }
401
+ }
402
+ return;
403
+ }
404
+ const items = focusContext.getItems().filter((item) => !item.disabled);
405
+ let candidateRefs = items.map((item) => item.ref);
406
+ if (focusIntent === 'last') {
407
+ candidateRefs.reverse();
408
+ }
409
+ else if (focusIntent === 'prev' || focusIntent === 'next') {
410
+ if (focusIntent === 'prev')
411
+ candidateRefs.reverse();
412
+ const currentIndex = candidateRefs.findIndex((ref) => ref.current === event.currentTarget);
413
+ candidateRefs = candidateRefs.slice(currentIndex + 1);
414
+ }
415
+ queueMicrotask(() => focusFirst(candidateRefs));
416
+ }
417
+ }, [
418
+ focusContext,
419
+ context.dir,
420
+ context.orientation,
421
+ activationMode,
422
+ isDisabled,
423
+ isReadOnly,
424
+ step,
425
+ value,
426
+ context.max,
427
+ store,
428
+ propsRef,
429
+ ]);
430
+ const onMouseDown = React.useCallback((event) => {
431
+ propsRef.current.onMouseDown?.(event);
432
+ if (event.defaultPrevented)
433
+ return;
434
+ isMouseClickRef.current = true;
435
+ if (isDisabled) {
436
+ event.preventDefault();
437
+ }
438
+ else {
439
+ focusContext.onItemFocus(itemId);
440
+ }
441
+ }, [focusContext, itemId, isDisabled, propsRef]);
442
+ const onMouseEnter = React.useCallback((event) => {
443
+ propsRef.current.onMouseEnter?.(event);
444
+ if (event.defaultPrevented)
445
+ return;
446
+ if (!isDisabled && !isReadOnly) {
447
+ let hoverValue = itemValue;
448
+ if (step < 1) {
449
+ const rect = event.currentTarget.getBoundingClientRect();
450
+ const mouseX = event.clientX - rect.left;
451
+ const isLeftHalf = mouseX < rect.width / 2;
452
+ if (context.dir === 'rtl') {
453
+ if (!isLeftHalf) {
454
+ hoverValue = itemValue - step;
455
+ }
456
+ }
457
+ else {
458
+ if (isLeftHalf) {
459
+ hoverValue = itemValue - step;
460
+ }
461
+ }
462
+ }
463
+ store.setState('hoveredValue', hoverValue);
464
+ }
465
+ }, [isDisabled, isReadOnly, step, itemValue, store, context.dir, propsRef]);
466
+ const onMouseLeave = React.useCallback((event) => {
467
+ propsRef.current.onMouseLeave?.(event);
468
+ if (event.defaultPrevented)
469
+ return;
470
+ if (!isDisabled && !isReadOnly) {
471
+ store.setState('hoveredValue', null);
472
+ }
473
+ }, [isDisabled, isReadOnly, store, propsRef]);
474
+ const onMouseMove = React.useCallback((event) => {
475
+ propsRef.current.onMouseMove?.(event);
476
+ if (event.defaultPrevented)
477
+ return;
478
+ if (!isDisabled && !isReadOnly && step < 1) {
479
+ const rect = event.currentTarget.getBoundingClientRect();
480
+ const mouseX = event.clientX - rect.left;
481
+ const isLeftHalf = mouseX < rect.width / 2;
482
+ let hoverValue = itemValue;
483
+ if (context.dir === 'rtl') {
484
+ hoverValue = !isLeftHalf ? itemValue - step : itemValue;
485
+ }
486
+ else {
487
+ hoverValue = isLeftHalf ? itemValue - step : itemValue;
488
+ }
489
+ store.setState('hoveredValue', hoverValue);
490
+ }
491
+ }, [isDisabled, isReadOnly, step, itemValue, store, context.dir, propsRef]);
492
+ const dataState = isFilled ? 'full' : isPartiallyFilled ? 'partial' : 'empty';
493
+ const ItemPrimitive = asChild ? SlotPrimitive.Slot : 'button';
494
+ return (_jsx(ItemPrimitive, { role: "radio", type: "button", id: itemId, "aria-checked": isFilled, "aria-posinset": itemValue, "aria-setsize": context.max, "data-disabled": isDisabled ? '' : undefined, "data-readonly": isReadOnly ? '' : undefined, "data-state": isFilled ? 'full' : isPartiallyFilled ? 'partial' : 'empty', "data-hovered": isHovered ? '' : undefined, "data-slot": "rating-item", disabled: isDisabled, tabIndex: isTabStop ? 0 : -1, ...itemProps, ref: composedRef, style: {
495
+ ...itemProps.style,
496
+ ...(isPartiallyFilled && {
497
+ '--partial-fill': `url(#${getPartialFillGradientId(context.rootId, step)})`,
498
+ }),
499
+ }, className: cn('inline-flex items-center justify-center rounded transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50', "[&_svg:not([class*='size-'])]:size-full [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:transition-colors [&_svg]:duration-200 data-[state=empty]:[&_svg]:fill-transparent data-[state=full]:[&_svg]:fill-current data-[state=partial]:[&_svg]:fill-(--partial-fill)", context.size === 'sm' ? 'size-4' : context.size === 'lg' ? 'size-6' : 'size-5', className), onClick: onClick, onFocus: onFocus, onKeyDown: onKeyDown, onMouseDown: onMouseDown, onMouseEnter: onMouseEnter, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, children: typeof children === 'function' ? children(dataState) : (children ?? _jsx(Star, {})) }));
500
+ }
501
+ export { Rating, RatingItem, useStore as useRating };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
3
+ declare function ScrollArea({ className, children, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>): React.JSX.Element;
4
+ declare function ScrollBar({ className, orientation, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): React.JSX.Element;
5
+ export { ScrollArea, ScrollBar };
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
4
+ import { cn } from "../../lib/utils.js";
5
+ function ScrollArea({ className, children, ...props }) {
6
+ return (_jsxs(ScrollAreaPrimitive.Root, { "data-slot": "scroll-area", className: cn('relative', className), ...props, children: [_jsx(ScrollAreaPrimitive.Viewport, { "data-slot": "scroll-area-viewport", className: "size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1", children: children }), _jsx(ScrollBar, {}), _jsx(ScrollAreaPrimitive.Corner, {})] }));
7
+ }
8
+ function ScrollBar({ className, orientation = 'vertical', ...props }) {
9
+ return (_jsx(ScrollAreaPrimitive.ScrollAreaScrollbar, { "data-slot": "scroll-area-scrollbar", orientation: orientation, className: cn('flex touch-none p-px transition-colors select-none', orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent', orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent', className), ...props, children: _jsx(ScrollAreaPrimitive.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "relative flex-1 rounded-full bg-border" }) }));
10
+ }
11
+ export { ScrollArea, ScrollBar };
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import type { OptionIcon } from '@coffer-org/sdk/fields';
3
+ export interface ComboboxItem {
4
+ value: string;
5
+ title: string;
6
+ subtitle?: string;
7
+ icon?: OptionIcon;
8
+ node?: React.ReactNode;
9
+ }
10
+ export declare function Combobox({ value, onChange, items, placeholder, triggerClassName, }: {
11
+ value: string;
12
+ onChange: (v: string) => void;
13
+ items: ComboboxItem[];
14
+ placeholder?: string;
15
+ triggerClassName?: string;
16
+ }): React.JSX.Element;
17
+ export declare function ChipsCombobox({ selected, onChange, items, placeholder, labelOf, chipClassName, chipStyle, }: {
18
+ selected: string[];
19
+ onChange: (next: string[]) => void;
20
+ items: ComboboxItem[];
21
+ placeholder?: string;
22
+ labelOf?: (value: string) => string;
23
+ chipClassName?: (value: string) => string;
24
+ chipStyle?: (value: string) => React.CSSProperties;
25
+ }): React.JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
4
+ import { Button } from "./button.js";
5
+ import { ChevronDown } from 'lucide-react';
6
+ import { OptionIconView } from "./option-icon.js";
7
+ import { OptionList } from "../../render/option-list.js";
8
+ import { MultipleChips } from "../../render/multiple-chips.js";
9
+ function ItemRow({ it }) {
10
+ if (it.node)
11
+ return _jsx("span", { className: "min-w-0 flex-1 truncate", children: it.node });
12
+ return (_jsxs(_Fragment, { children: [it.icon && _jsx(OptionIconView, { icon: it.icon, size: "xs" }), _jsx("span", { className: "min-w-0 truncate", children: it.title }), it.subtitle && it.subtitle !== it.title && _jsx("span", { className: "text-muted text-xs shrink-0", children: it.subtitle })] }));
13
+ }
14
+ export function Combobox({ value, onChange, items, placeholder, triggerClassName = 'w-full justify-between gap-2 px-2 font-normal', }) {
15
+ const [open, setOpen] = React.useState(false);
16
+ const usable = React.useMemo(() => items.filter((it) => it?.value != null), [items]);
17
+ const selected = React.useMemo(() => usable.find((it) => it.value === value), [usable, value]);
18
+ return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, className: triggerClassName, onKeyDown: (e) => {
19
+ if (e.key === 'ArrowDown') {
20
+ e.preventDefault();
21
+ setOpen(true);
22
+ }
23
+ }, children: [selected ? (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: _jsx(ItemRow, { it: selected }) })) : (_jsx("span", { className: "truncate text-muted-foreground", children: placeholder })), _jsx(ChevronDown, { size: 16, className: "shrink-0 text-muted" })] }) }), _jsx(PopoverContent, { align: "start", className: "w-(--radix-popover-trigger-width) min-w-52 p-2", children: _jsx(OptionList, { literal: true, options: usable, value: value, multiple: false, onPick: (v) => {
24
+ onChange(String(v));
25
+ setOpen(false);
26
+ } }) })] }));
27
+ }
28
+ export function ChipsCombobox({ selected, onChange, items, placeholder, labelOf, chipClassName, chipStyle, }) {
29
+ const byValue = React.useMemo(() => new Map(items.map((it) => [it.value, it])), [items]);
30
+ const available = items.filter((it) => !selected.includes(it.value));
31
+ const label = (v) => labelOf?.(v) ?? byValue.get(v)?.title ?? v;
32
+ return (_jsx(MultipleChips, { items: selected, content: (v) => {
33
+ const it = byValue.get(String(v));
34
+ return (_jsxs(_Fragment, { children: [it?.icon && _jsx(OptionIconView, { icon: it.icon, size: "xs" }), label(String(v))] }));
35
+ }, chipClassName: chipClassName ? (v) => chipClassName(String(v)) : undefined, chipStyle: chipStyle ? (v) => chipStyle(String(v)) : undefined, onRemove: (idx) => onChange(selected.filter((_, i) => i !== idx)), editor: available.length > 0 ? (_jsx(Combobox, { value: "", onChange: (v) => v && onChange([...selected, v]), items: available, placeholder: placeholder })) : null }));
36
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import * as SelectPrimitive from '@radix-ui/react-select';
3
+ declare const Select: React.FC<SelectPrimitive.SelectProps>;
4
+ declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
5
+ declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
6
+ declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
10
+ declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
+ declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
12
+ declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import * as SelectPrimitive from '@radix-ui/react-select';
4
+ import { Check, ChevronDown, ChevronUp } from 'lucide-react';
5
+ import { cn } from "../../lib/utils.js";
6
+ const Select = SelectPrimitive.Root;
7
+ const SelectGroup = SelectPrimitive.Group;
8
+ const SelectValue = SelectPrimitive.Value;
9
+ const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex h-9 w-full items-center justify-between gap-2 rounded-lg border border-input bg-background px-3 py-1 text-sm text-foreground transition-colors', 'data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring', 'disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4 opacity-60" }) })] })));
10
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
11
+ const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn('flex cursor-default items-center justify-center py-1', className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
12
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
13
+ const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn('flex cursor-default items-center justify-center py-1', className), ...props, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
14
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
15
+ const SelectContent = React.forwardRef(({ className, children, position = 'popper', ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn('relative z-50 max-h-96 min-w-32 overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-md', 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', position === 'popper' && 'data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1', className), position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn('p-1', position === 'popper' &&
16
+ 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
17
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
18
+ const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn('px-2 py-1.5 text-xs font-semibold text-muted-foreground', className), ...props })));
19
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
20
+ const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn('relative flex w-full cursor-pointer select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none', 'focus:bg-elevated focus:text-text data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4 text-accent" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
21
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
22
+ const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn('-mx-1 my-1 h-px bg-border', className), ...props })));
23
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
24
+ export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
3
+ declare const Separator: React.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ export { Separator };
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
4
+ import { cn } from "../../lib/utils.js";
5
+ const Separator = React.forwardRef(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (_jsx(SeparatorPrimitive.Root, { ref: ref, decorative: decorative, orientation: orientation, className: cn('shrink-0 bg-border', orientation === 'horizontal' ? 'h-px w-full' : 'h-full w-px', className), ...props })));
6
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
7
+ export { Separator };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
3
+ declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitive.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Switch };
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
4
+ import { cn } from "../../lib/utils.js";
5
+ const Switch = React.forwardRef(({ className, ...props }, ref) => (_jsx(SwitchPrimitive.Root, { ref: ref, className: cn('peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background', 'disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-border', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { className: cn('pointer-events-none block h-5 w-5 rounded-full bg-white shadow-lg ring-0 transition-transform', 'data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0') }) })));
6
+ Switch.displayName = SwitchPrimitive.Root.displayName;
7
+ export { Switch };