@central-ui/react 0.0.0-stage → 0.1.1

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 (292) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -2
  3. package/dist/components/accordion/index.d.ts +73 -0
  4. package/dist/components/accordion/index.d.ts.map +1 -0
  5. package/dist/components/accordion/index.js +92 -0
  6. package/dist/components/accordion/index.js.map +1 -0
  7. package/dist/components/autocomplete/index.d.ts +365 -0
  8. package/dist/components/autocomplete/index.d.ts.map +1 -0
  9. package/dist/components/autocomplete/index.js +369 -0
  10. package/dist/components/autocomplete/index.js.map +1 -0
  11. package/dist/components/avatar/index.d.ts +48 -0
  12. package/dist/components/avatar/index.d.ts.map +1 -0
  13. package/dist/components/avatar/index.js +60 -0
  14. package/dist/components/avatar/index.js.map +1 -0
  15. package/dist/components/badge/index.d.ts +29 -0
  16. package/dist/components/badge/index.d.ts.map +1 -0
  17. package/dist/components/badge/index.js +36 -0
  18. package/dist/components/badge/index.js.map +1 -0
  19. package/dist/components/banner/index.d.ts +71 -0
  20. package/dist/components/banner/index.d.ts.map +1 -0
  21. package/dist/components/banner/index.js +119 -0
  22. package/dist/components/banner/index.js.map +1 -0
  23. package/dist/components/breadcrumb/index.d.ts +31 -0
  24. package/dist/components/breadcrumb/index.d.ts.map +1 -0
  25. package/dist/components/breadcrumb/index.js +42 -0
  26. package/dist/components/breadcrumb/index.js.map +1 -0
  27. package/dist/components/button/index.d.ts +48 -0
  28. package/dist/components/button/index.d.ts.map +1 -0
  29. package/dist/components/button/index.js +60 -0
  30. package/dist/components/button/index.js.map +1 -0
  31. package/dist/components/card/index.d.ts +34 -0
  32. package/dist/components/card/index.d.ts.map +1 -0
  33. package/dist/components/card/index.js +45 -0
  34. package/dist/components/card/index.js.map +1 -0
  35. package/dist/components/checkbox/index.d.ts +66 -0
  36. package/dist/components/checkbox/index.d.ts.map +1 -0
  37. package/dist/components/checkbox/index.js +146 -0
  38. package/dist/components/checkbox/index.js.map +1 -0
  39. package/dist/components/chip/index.d.ts +26 -0
  40. package/dist/components/chip/index.d.ts.map +1 -0
  41. package/dist/components/chip/index.js +40 -0
  42. package/dist/components/chip/index.js.map +1 -0
  43. package/dist/components/combobox/index.d.ts +427 -0
  44. package/dist/components/combobox/index.d.ts.map +1 -0
  45. package/dist/components/combobox/index.js +416 -0
  46. package/dist/components/combobox/index.js.map +1 -0
  47. package/dist/components/datepicker/index.d.ts +297 -0
  48. package/dist/components/datepicker/index.d.ts.map +1 -0
  49. package/dist/components/datepicker/index.js +507 -0
  50. package/dist/components/datepicker/index.js.map +1 -0
  51. package/dist/components/dialog/index.d.ts +88 -0
  52. package/dist/components/dialog/index.d.ts.map +1 -0
  53. package/dist/components/dialog/index.js +102 -0
  54. package/dist/components/dialog/index.js.map +1 -0
  55. package/dist/components/divider/index.d.ts +21 -0
  56. package/dist/components/divider/index.d.ts.map +1 -0
  57. package/dist/components/divider/index.js +24 -0
  58. package/dist/components/divider/index.js.map +1 -0
  59. package/dist/components/drawer/index.d.ts +99 -0
  60. package/dist/components/drawer/index.d.ts.map +1 -0
  61. package/dist/components/drawer/index.js +137 -0
  62. package/dist/components/drawer/index.js.map +1 -0
  63. package/dist/components/empty/index.d.ts +40 -0
  64. package/dist/components/empty/index.d.ts.map +1 -0
  65. package/dist/components/empty/index.js +61 -0
  66. package/dist/components/empty/index.js.map +1 -0
  67. package/dist/components/fileupload/index.d.ts +107 -0
  68. package/dist/components/fileupload/index.d.ts.map +1 -0
  69. package/dist/components/fileupload/index.js +185 -0
  70. package/dist/components/fileupload/index.js.map +1 -0
  71. package/dist/components/form/index.d.ts +34 -0
  72. package/dist/components/form/index.d.ts.map +1 -0
  73. package/dist/components/form/index.js +35 -0
  74. package/dist/components/form/index.js.map +1 -0
  75. package/dist/components/input/index.d.ts +85 -0
  76. package/dist/components/input/index.d.ts.map +1 -0
  77. package/dist/components/input/index.js +249 -0
  78. package/dist/components/input/index.js.map +1 -0
  79. package/dist/components/menu/index.d.ts +115 -0
  80. package/dist/components/menu/index.d.ts.map +1 -0
  81. package/dist/components/menu/index.js +188 -0
  82. package/dist/components/menu/index.js.map +1 -0
  83. package/dist/components/metric/index.d.ts +24 -0
  84. package/dist/components/metric/index.d.ts.map +1 -0
  85. package/dist/components/metric/index.js +26 -0
  86. package/dist/components/metric/index.js.map +1 -0
  87. package/dist/components/numberinput/index.d.ts +105 -0
  88. package/dist/components/numberinput/index.d.ts.map +1 -0
  89. package/dist/components/numberinput/index.js +240 -0
  90. package/dist/components/numberinput/index.js.map +1 -0
  91. package/dist/components/otpinput/index.d.ts +63 -0
  92. package/dist/components/otpinput/index.d.ts.map +1 -0
  93. package/dist/components/otpinput/index.js +133 -0
  94. package/dist/components/otpinput/index.js.map +1 -0
  95. package/dist/components/page/index.d.ts +54 -0
  96. package/dist/components/page/index.d.ts.map +1 -0
  97. package/dist/components/page/index.js +100 -0
  98. package/dist/components/page/index.js.map +1 -0
  99. package/dist/components/passwordinput/index.d.ts +88 -0
  100. package/dist/components/passwordinput/index.d.ts.map +1 -0
  101. package/dist/components/passwordinput/index.js +251 -0
  102. package/dist/components/passwordinput/index.js.map +1 -0
  103. package/dist/components/popover/index.d.ts +67 -0
  104. package/dist/components/popover/index.d.ts.map +1 -0
  105. package/dist/components/popover/index.js +76 -0
  106. package/dist/components/popover/index.js.map +1 -0
  107. package/dist/components/radio/index.d.ts +90 -0
  108. package/dist/components/radio/index.d.ts.map +1 -0
  109. package/dist/components/radio/index.js +232 -0
  110. package/dist/components/radio/index.js.map +1 -0
  111. package/dist/components/ratinginput/index.d.ts +59 -0
  112. package/dist/components/ratinginput/index.d.ts.map +1 -0
  113. package/dist/components/ratinginput/index.js +88 -0
  114. package/dist/components/ratinginput/index.js.map +1 -0
  115. package/dist/components/select/index.d.ts +205 -0
  116. package/dist/components/select/index.d.ts.map +1 -0
  117. package/dist/components/select/index.js +234 -0
  118. package/dist/components/select/index.js.map +1 -0
  119. package/dist/components/skeleton/index.d.ts +19 -0
  120. package/dist/components/skeleton/index.d.ts.map +1 -0
  121. package/dist/components/skeleton/index.js +20 -0
  122. package/dist/components/skeleton/index.js.map +1 -0
  123. package/dist/components/slider/index.d.ts +72 -0
  124. package/dist/components/slider/index.d.ts.map +1 -0
  125. package/dist/components/slider/index.js +159 -0
  126. package/dist/components/slider/index.js.map +1 -0
  127. package/dist/components/spinner/index.d.ts +14 -0
  128. package/dist/components/spinner/index.d.ts.map +1 -0
  129. package/dist/components/spinner/index.js +15 -0
  130. package/dist/components/spinner/index.js.map +1 -0
  131. package/dist/components/splitter/index.d.ts +49 -0
  132. package/dist/components/splitter/index.d.ts.map +1 -0
  133. package/dist/components/splitter/index.js +67 -0
  134. package/dist/components/splitter/index.js.map +1 -0
  135. package/dist/components/stepper/index.d.ts +82 -0
  136. package/dist/components/stepper/index.d.ts.map +1 -0
  137. package/dist/components/stepper/index.js +100 -0
  138. package/dist/components/stepper/index.js.map +1 -0
  139. package/dist/components/switch/index.d.ts +57 -0
  140. package/dist/components/switch/index.d.ts.map +1 -0
  141. package/dist/components/switch/index.js +101 -0
  142. package/dist/components/switch/index.js.map +1 -0
  143. package/dist/components/table/index.d.ts +110 -0
  144. package/dist/components/table/index.d.ts.map +1 -0
  145. package/dist/components/table/index.js +211 -0
  146. package/dist/components/table/index.js.map +1 -0
  147. package/dist/components/tabs/index.d.ts +67 -0
  148. package/dist/components/tabs/index.d.ts.map +1 -0
  149. package/dist/components/tabs/index.js +78 -0
  150. package/dist/components/tabs/index.js.map +1 -0
  151. package/dist/components/textarea/index.d.ts +72 -0
  152. package/dist/components/textarea/index.d.ts.map +1 -0
  153. package/dist/components/textarea/index.js +205 -0
  154. package/dist/components/textarea/index.js.map +1 -0
  155. package/dist/components/textlink/index.d.ts +39 -0
  156. package/dist/components/textlink/index.d.ts.map +1 -0
  157. package/dist/components/textlink/index.js +42 -0
  158. package/dist/components/textlink/index.js.map +1 -0
  159. package/dist/components/toast/index.d.ts +111 -0
  160. package/dist/components/toast/index.d.ts.map +1 -0
  161. package/dist/components/toast/index.js +205 -0
  162. package/dist/components/toast/index.js.map +1 -0
  163. package/dist/components/toggle/index.d.ts +41 -0
  164. package/dist/components/toggle/index.d.ts.map +1 -0
  165. package/dist/components/toggle/index.js +78 -0
  166. package/dist/components/toggle/index.js.map +1 -0
  167. package/dist/components/tooltip/index.d.ts +44 -0
  168. package/dist/components/tooltip/index.d.ts.map +1 -0
  169. package/dist/components/tooltip/index.js +51 -0
  170. package/dist/components/tooltip/index.js.map +1 -0
  171. package/dist/index.d.ts +50 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +46 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/types/Style.d.ts +14 -0
  176. package/dist/types/Style.d.ts.map +1 -0
  177. package/dist/types/Style.js +2 -0
  178. package/dist/types/Style.js.map +1 -0
  179. package/dist/types/Tone.d.ts +4 -0
  180. package/dist/types/Tone.d.ts.map +1 -0
  181. package/dist/types/Tone.js +2 -0
  182. package/dist/types/Tone.js.map +1 -0
  183. package/dist/utils/ArkStateToDataAttributes.d.ts +4 -0
  184. package/dist/utils/ArkStateToDataAttributes.d.ts.map +1 -0
  185. package/dist/utils/ArkStateToDataAttributes.js +9 -0
  186. package/dist/utils/ArkStateToDataAttributes.js.map +1 -0
  187. package/dist/utils/Tone.d.ts +3 -0
  188. package/dist/utils/Tone.d.ts.map +1 -0
  189. package/dist/utils/Tone.js +7 -0
  190. package/dist/utils/Tone.js.map +1 -0
  191. package/dist/utils/useForwardClickToInput.d.ts +4 -0
  192. package/dist/utils/useForwardClickToInput.d.ts.map +1 -0
  193. package/dist/utils/useForwardClickToInput.js +27 -0
  194. package/dist/utils/useForwardClickToInput.js.map +1 -0
  195. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +198 -0
  196. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +1 -0
  197. package/dist/utils/virtualization/useVirtualizedAutocomplete.js +180 -0
  198. package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +1 -0
  199. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +200 -0
  200. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +1 -0
  201. package/dist/utils/virtualization/useVirtualizedCombobox.js +174 -0
  202. package/dist/utils/virtualization/useVirtualizedCombobox.js.map +1 -0
  203. package/dist/utils/virtualization/useVirtualizedTable.d.ts +169 -0
  204. package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +1 -0
  205. package/dist/utils/virtualization/useVirtualizedTable.js +127 -0
  206. package/dist/utils/virtualization/useVirtualizedTable.js.map +1 -0
  207. package/package.json +64 -4
  208. package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -0
  209. package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +155 -0
  210. package/src/presets/shopify-polaris/shopify-polaris-avatar.css +47 -0
  211. package/src/presets/shopify-polaris/shopify-polaris-badge.css +27 -0
  212. package/src/presets/shopify-polaris/shopify-polaris-banner.css +111 -0
  213. package/src/presets/shopify-polaris/shopify-polaris-breadcrumb.css +16 -0
  214. package/src/presets/shopify-polaris/shopify-polaris-button.css +79 -0
  215. package/src/presets/shopify-polaris/shopify-polaris-card.css +28 -0
  216. package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +52 -0
  217. package/src/presets/shopify-polaris/shopify-polaris-chip.css +16 -0
  218. package/src/presets/shopify-polaris/shopify-polaris-combobox.css +179 -0
  219. package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +183 -0
  220. package/src/presets/shopify-polaris/shopify-polaris-dialog.css +40 -0
  221. package/src/presets/shopify-polaris/shopify-polaris-divider.css +12 -0
  222. package/src/presets/shopify-polaris/shopify-polaris-drawer.css +40 -0
  223. package/src/presets/shopify-polaris/shopify-polaris-empty.css +32 -0
  224. package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +78 -0
  225. package/src/presets/shopify-polaris/shopify-polaris-form.css +8 -0
  226. package/src/presets/shopify-polaris/shopify-polaris-input.css +72 -0
  227. package/src/presets/shopify-polaris/shopify-polaris-menu.css +112 -0
  228. package/src/presets/shopify-polaris/shopify-polaris-metric.css +16 -0
  229. package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +88 -0
  230. package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +42 -0
  231. package/src/presets/shopify-polaris/shopify-polaris-page.css +69 -0
  232. package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +76 -0
  233. package/src/presets/shopify-polaris/shopify-polaris-popover.css +47 -0
  234. package/src/presets/shopify-polaris/shopify-polaris-radio.css +54 -0
  235. package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +42 -0
  236. package/src/presets/shopify-polaris/shopify-polaris-select.css +119 -0
  237. package/src/presets/shopify-polaris/shopify-polaris-skeleton.css +8 -0
  238. package/src/presets/shopify-polaris/shopify-polaris-slider.css +86 -0
  239. package/src/presets/shopify-polaris/shopify-polaris-spinner.css +16 -0
  240. package/src/presets/shopify-polaris/shopify-polaris-splitter.css +34 -0
  241. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +55 -0
  242. package/src/presets/shopify-polaris/shopify-polaris-switch.css +38 -0
  243. package/src/presets/shopify-polaris/shopify-polaris-table.css +72 -0
  244. package/src/presets/shopify-polaris/shopify-polaris-tabs.css +33 -0
  245. package/src/presets/shopify-polaris/shopify-polaris-textarea.css +61 -0
  246. package/src/presets/shopify-polaris/shopify-polaris-textlink.css +8 -0
  247. package/src/presets/shopify-polaris/shopify-polaris-toggle.css +52 -0
  248. package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +31 -0
  249. package/src/presets/shopify-polaris/shopify-polaris.css +380 -0
  250. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-accordion.css +28 -0
  251. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +155 -0
  252. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-avatar.css +47 -0
  253. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-badge.css +27 -0
  254. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-banner.css +96 -0
  255. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-breadcrumb.css +16 -0
  256. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-button.css +68 -0
  257. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-card.css +28 -0
  258. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +52 -0
  259. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-chip.css +16 -0
  260. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +184 -0
  261. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +187 -0
  262. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +40 -0
  263. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-divider.css +12 -0
  264. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +40 -0
  265. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-empty.css +32 -0
  266. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +72 -0
  267. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-form.css +8 -0
  268. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +72 -0
  269. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +112 -0
  270. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-metric.css +16 -0
  271. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +88 -0
  272. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +42 -0
  273. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-page.css +69 -0
  274. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +76 -0
  275. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +47 -0
  276. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +54 -0
  277. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +42 -0
  278. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-select.css +118 -0
  279. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-skeleton.css +8 -0
  280. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +86 -0
  281. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-spinner.css +16 -0
  282. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-splitter.css +34 -0
  283. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +55 -0
  284. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +38 -0
  285. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-table.css +72 -0
  286. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tabs.css +33 -0
  287. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +61 -0
  288. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textlink.css +8 -0
  289. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-toast.css +43 -0
  290. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-toggle.css +52 -0
  291. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +31 -0
  292. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +381 -0
@@ -0,0 +1,232 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
3
+ import { Radio as BaseRadio } from '@base-ui/react/radio';
4
+ import { createContext, useCallback, forwardRef, useContext, useEffect, useId, useState, } from 'react';
5
+ import { ToneProvider, useToneContext } from "../../utils/Tone.js";
6
+ /**
7
+ * Root owns the chosen value. For each choice keep Item, ItemButton, ItemIndicator, and ItemLabel together. The indicator follows selection automatically; do not manage a separate checked state for each item.
8
+ *
9
+ * @example Complete composition
10
+ * import { Radio } from '@central-ui/react'
11
+ *
12
+ * const plans = [
13
+ * {
14
+ * value: 'basic',
15
+ * label: 'Basic',
16
+ * description: 'For personal use.',
17
+ * disabled: false,
18
+ * },
19
+ * {
20
+ * value: 'team',
21
+ * label: 'Team',
22
+ * description: 'For shared work.',
23
+ * disabled: false,
24
+ * },
25
+ * {
26
+ * value: 'enterprise',
27
+ * label: 'Enterprise',
28
+ * description: 'Unavailable right now.',
29
+ * disabled: true,
30
+ * },
31
+ * ]
32
+ * function Example() {
33
+ * return (
34
+ * <Radio.Root name="plan" defaultValue="basic">
35
+ * <Radio.Container>
36
+ * <Radio.Label>Plan</Radio.Label>
37
+ * <Radio.List>
38
+ * {plans.map((plan) => (
39
+ * <Radio.Item key={plan.value} value={plan.value} disabled={plan.disabled}>
40
+ * <Radio.ItemButton>
41
+ * <Radio.ItemIndicator />
42
+ * </Radio.ItemButton>
43
+ * <Radio.ItemLabel>{plan.label}</Radio.ItemLabel>
44
+ * <Radio.ItemDescription>{plan.description}</Radio.ItemDescription>
45
+ * </Radio.Item>
46
+ * ))}
47
+ * </Radio.List>
48
+ * <Radio.Description>Choose one plan.</Radio.Description>
49
+ * </Radio.Container>
50
+ * </Radio.Root>
51
+ * )
52
+ * }
53
+ *
54
+ * @example Choose the initial plan
55
+ * // Keep the same Item compositions; each Item still supplies its own value.
56
+ * ;<Radio.Root defaultValue="pro" name="plan">
57
+ * {
58
+ * // Rest of components here
59
+ * }
60
+ * </Radio.Root>
61
+ */
62
+ export function Root({ children, tone = 'neutral', ...props }) {
63
+ const [labelIds, setLabelIds] = useState([]);
64
+ const [messageIds, setMessageIds] = useState([]);
65
+ return (_jsx(ToneProvider, { value: tone, children: _jsx(BaseRadioGroup, { ...props, "aria-labelledby": [props['aria-labelledby'], ...labelIds].filter(Boolean).join(' ') ||
66
+ undefined, "aria-describedby": [props['aria-describedby'], ...messageIds]
67
+ .filter(Boolean)
68
+ .join(' ') || undefined, "aria-invalid": tone === 'invalid' || props['aria-invalid'] || undefined, render: (groupProps, state) => {
69
+ const { children, ...elementProps } = groupProps;
70
+ return (_jsx(RadioContext.Provider, { value: {
71
+ elementProps,
72
+ state,
73
+ messageIds,
74
+ setMessageIds,
75
+ setLabelIds,
76
+ }, children: _jsx(_Fragment, { children: children }) }));
77
+ }, children: children }) }));
78
+ }
79
+ export const Container = forwardRef(function Container({ disableStyle, className, ...props }, ref) {
80
+ return (_jsx("div", { ...props, ref: ref, "data-component": "radio-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
81
+ });
82
+ export const List = forwardRef(function List({ disableStyle, ...props }, ref) {
83
+ const { elementProps } = useRadioContext();
84
+ const { ref: nativeRef, ...nativeProps } = elementProps;
85
+ return (_jsx("div", { ...nativeProps, ...props, ref: useRootRef(nativeRef, ref), "data-component": "radio-list", "data-style-disabled": disableStyle ? '' : undefined, className: props.className }));
86
+ });
87
+ /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
88
+ export const Label = forwardRef(function Label({ disableStyle, className, id, ...props }, ref) {
89
+ const generatedId = useId();
90
+ const labelId = id ?? generatedId;
91
+ const context = useRadioContext();
92
+ useEffect(() => {
93
+ context.setLabelIds((current) => [...current, labelId]);
94
+ return () => context.setLabelIds((current) => current.filter((value) => value !== labelId));
95
+ }, [labelId, context.setLabelIds]);
96
+ return (_jsx("div", { ...props, id: labelId, ref: ref, "data-disabled": context.state.disabled ? '' : undefined, "data-component": "radio-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
97
+ });
98
+ export function Item({ disableStyle, children, value, disabled, readOnly, required, inputRef, id, className, ...props }) {
99
+ const generatedId = useId();
100
+ const group = useRadioContext();
101
+ const [messageIds, setMessageIds] = useState([]);
102
+ const [state, setState] = useState({
103
+ checked: false,
104
+ disabled: disabled ?? group.state.disabled,
105
+ readOnly: readOnly ?? group.state.readOnly,
106
+ required: required ?? group.state.required,
107
+ });
108
+ return (_jsx(ItemContext.Provider, { value: {
109
+ coreProps: {
110
+ value,
111
+ disabled,
112
+ readOnly,
113
+ required,
114
+ inputRef,
115
+ id: id ?? generatedId,
116
+ },
117
+ state,
118
+ setState,
119
+ messageIds,
120
+ setMessageIds,
121
+ }, children: _jsx("div", { ...props, "data-component": "radio-item", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children }) }));
122
+ }
123
+ export const ItemButton = forwardRef(function ItemButton({ disableStyle, className, ...props }, ref) {
124
+ const item = useItemContext();
125
+ const group = useRadioContext();
126
+ const tone = useToneContext();
127
+ return (_jsx(BaseRadio.Root, { ...props, ...item.coreProps, ref: ref, "aria-describedby": [props['aria-describedby'], ...group.messageIds, ...item.messageIds]
128
+ .filter(Boolean)
129
+ .join(' ') || undefined, "aria-invalid": tone === 'invalid' || props['aria-invalid'] || undefined, "data-tone": tone, "data-component": "radio-itembutton", "data-style-disabled": disableStyle ? '' : undefined, className: className, render: (buttonProps, state) => (_jsx(RadioButtonSurface, { ...buttonProps, state: state })) }));
130
+ });
131
+ /** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
132
+ export const ItemIndicator = forwardRef(function ItemIndicator({ disableStyle, children, className, ...props }, ref) {
133
+ return (_jsx(BaseRadio.Indicator, { ...props, ref: ref, "data-component": "radio-itemindicator", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children }));
134
+ });
135
+ export const ItemLabel = forwardRef(function ItemLabel({ disableStyle, className, ...props }, ref) {
136
+ const item = useItemContext();
137
+ return (_jsx("label", { ...props, ref: ref, htmlFor: item.coreProps.id, "data-disabled": item.state.disabled ? '' : undefined, "data-component": "radio-itemlabel", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
138
+ });
139
+ export const ItemDescription = forwardRef(function ItemDescription({ disableStyle, className, id, ...props }, ref) {
140
+ const generatedId = useId();
141
+ const messageId = id ?? generatedId;
142
+ const item = useItemContext();
143
+ useEffect(() => {
144
+ item.setMessageIds((current) => [...current, messageId]);
145
+ return () => item.setMessageIds((current) => current.filter((value) => value !== messageId));
146
+ }, [messageId, item.setMessageIds]);
147
+ return (_jsx("span", { ...props, ref: ref, id: messageId, "data-disabled": item.state.disabled ? '' : undefined, "data-checked": item.state.checked ? '' : undefined, "data-component": "radio-itemdescription", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
148
+ });
149
+ export const Description = forwardRef(function Description({ disableStyle, className, id, ...props }, ref) {
150
+ const messageId = useMessageId(id);
151
+ const context = useRadioContext();
152
+ return (_jsx("div", { ...props, id: messageId, ref: ref, "data-disabled": context.state.disabled ? '' : undefined, "data-component": "radio-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
153
+ });
154
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
155
+ export const Error = forwardRef(function Error({ disableStyle, className, id, ...props }, ref) {
156
+ const messageId = useMessageId(id);
157
+ const context = useRadioContext();
158
+ return (_jsx("div", { role: "alert", "aria-atomic": "true", ...props, id: messageId, ref: ref, "data-disabled": context.state.disabled ? '' : undefined, "data-component": "radio-error", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
159
+ });
160
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
161
+ export const Success = forwardRef(function Success({ disableStyle, className, id, ...props }, ref) {
162
+ const messageId = useMessageId(id);
163
+ const context = useRadioContext();
164
+ return (_jsx("div", { role: "status", "aria-atomic": "true", ...props, id: messageId, ref: ref, "data-disabled": context.state.disabled ? '' : undefined, "data-component": "radio-success", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
165
+ });
166
+ const RadioContext = createContext(null);
167
+ function useRadioContext() {
168
+ const context = useContext(RadioContext);
169
+ if (!context)
170
+ throw new globalThis.Error('Radio parts must be inside Radio.Root');
171
+ return context;
172
+ }
173
+ const ItemContext = createContext(null);
174
+ function useItemContext() {
175
+ const context = useContext(ItemContext);
176
+ if (!context)
177
+ throw new globalThis.Error('Radio item parts must be inside Radio.Item');
178
+ return context;
179
+ }
180
+ const RadioButtonSurface = forwardRef(function RadioButtonSurface({ state, ...props }, ref) {
181
+ const { setState } = useItemContext();
182
+ useEffect(() => {
183
+ setState({
184
+ checked: state.checked,
185
+ disabled: state.disabled,
186
+ readOnly: state.readOnly,
187
+ required: state.required,
188
+ });
189
+ }, [state.checked, state.disabled, state.readOnly, state.required, setState]);
190
+ return _jsx("span", { ...props, ref: ref });
191
+ });
192
+ function useMessageId(id) {
193
+ const generatedId = useId();
194
+ const messageId = id ?? generatedId;
195
+ const { setMessageIds } = useRadioContext();
196
+ useEffect(() => {
197
+ setMessageIds((current) => [...current, messageId]);
198
+ return () => setMessageIds((current) => current.filter((value) => value !== messageId));
199
+ }, [messageId, setMessageIds]);
200
+ return messageId;
201
+ }
202
+ function useRootRef(nativeRef, forwardedRef) {
203
+ return useCallback((element) => {
204
+ const nativeCleanup = typeof nativeRef === 'function'
205
+ ? nativeRef(element)
206
+ : nativeRef
207
+ ? ((nativeRef.current = element), undefined)
208
+ : undefined;
209
+ const forwardedCleanup = typeof forwardedRef === 'function'
210
+ ? forwardedRef(element)
211
+ : forwardedRef
212
+ ? ((forwardedRef.current = element), undefined)
213
+ : undefined;
214
+ if (typeof nativeCleanup === 'function' ||
215
+ typeof forwardedCleanup === 'function')
216
+ return () => {
217
+ if (typeof nativeCleanup === 'function')
218
+ nativeCleanup();
219
+ else if (typeof nativeRef === 'function')
220
+ nativeRef(null);
221
+ else if (nativeRef)
222
+ nativeRef.current = null;
223
+ if (typeof forwardedCleanup === 'function')
224
+ forwardedCleanup();
225
+ else if (typeof forwardedRef === 'function')
226
+ forwardedRef(null);
227
+ else if (forwardedRef)
228
+ forwardedRef.current = null;
229
+ };
230
+ }, [nativeRef, forwardedRef]);
231
+ }
232
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/radio/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAE,KAAK,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BACpD,IAAI,SAAS;oBAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;gBAC5C,IAAI,OAAO,gBAAgB,KAAK,UAAU;oBAAE,gBAAgB,EAAE,CAAA;qBACzD,IAAI,OAAO,YAAY,KAAK,UAAU;oBAAE,YAAY,CAAC,IAAI,CAAC,CAAA;qBAC1D,IAAI,YAAY;oBAAE,YAAY,CAAC,OAAO,GAAG,IAAI,CAAA;YACpD,CAAC,CAAA;IACL,CAAC,EACD,CAAC,SAAS,EAAE,YAAY,CAAC,CAC1B,CAAA;AACH,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import { type RatingGroupControlProps, type RatingGroupItemProps, type RatingGroupLabelProps, type RatingGroupRootProps } from '@ark-ui/react/rating-group';
3
+ import type { LucideProps } from 'lucide-react';
4
+ import type { ComponentProps, ReactElement, ReactNode } from 'react';
5
+ /**
6
+ * Root configures the scale and selection. StarsList supplies indices; use StarButton with StarIcon for each rating. Highlight, checked, and half-star appearance are built in; do not recreate hover state.
7
+ *
8
+ * @example Complete composition
9
+ * import { RatingInput } from '@central-ui/react'
10
+ *
11
+ * function Example() {
12
+ * return (
13
+ * <RatingInput.Root count={5}>
14
+ * <RatingInput.Container>
15
+ * <RatingInput.Label>How was your delivery?</RatingInput.Label>
16
+ * <RatingInput.StarsList>
17
+ * {(index) => (
18
+ * <RatingInput.StarButton key={index} index={index}>
19
+ * <RatingInput.StarIcon />
20
+ * </RatingInput.StarButton>
21
+ * )}
22
+ * </RatingInput.StarsList>
23
+ * <RatingInput.Description>Choose up to five stars.</RatingInput.Description>
24
+ * </RatingInput.Container>
25
+ * </RatingInput.Root>
26
+ * )
27
+ * }
28
+ *
29
+ * @example Allow half-star ratings
30
+ * // Keep the same StarsList and StarIcon; half-star rendering is built in.
31
+ * ;<RatingInput.Root count={5} allowHalf defaultValue={2.5}>
32
+ * {
33
+ * // Rest of components here
34
+ * }
35
+ * </RatingInput.Root>
36
+ */
37
+ export declare function Root({ children, tone, ...props }: Omit<RatingGroupRootProps, 'asChild'> & {
38
+ /** Visual feedback only; defaults to neutral. */
39
+ tone?: 'neutral' | 'valid' | 'invalid';
40
+ }): import("react").JSX.Element;
41
+ export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
42
+ export declare function Label({ disableStyle, className, ...props }: Omit<RatingGroupLabelProps, 'asChild'> & StyleProps): import("react").JSX.Element;
43
+ /** Calls children for each rating index. Pass the supplied index to StarButton; do not create a second hover or selection state. */
44
+ export declare function StarsList({ disableStyle, className, children, ...props }: (Omit<RatingGroupControlProps, 'asChild' | 'children'> & {
45
+ /** Render StarButton with the supplied index and put StarIcon inside it. */
46
+ children: (index: number) => ReactNode;
47
+ }) & StyleProps): import("react").JSX.Element;
48
+ export declare function StarButton({ disableStyle, children, className, ...props }: (Omit<RatingGroupItemProps, 'asChild' | 'children'> & {
49
+ /** Use StarIcon for built-in highlight and half-star visuals, or a custom icon that accepts the forwarded state attributes. */
50
+ children: ReactElement;
51
+ }) & StyleProps): import("react").JSX.Element;
52
+ /** Built-in icon; no children needed. Use it inside its matching control. */
53
+ export declare function StarIcon({ disableStyle, className, strokeWidth, style, ...props }: Omit<LucideProps, 'children'> & StyleProps): import("react").JSX.Element;
54
+ export declare function Description({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
55
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
56
+ export declare function Error({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
57
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
58
+ export declare function Success({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceR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A+H;IAC/H,QAAQ,EAAE,YAAY,CAAA;CACvB,CAAC,GACA,UAAU,+BAuCX;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,EACvB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,UAAU,+BA8B5C;AAED,wBAAgB,WAAW,CAAC,EAC1B,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,UAAU,+BASpC;AAED,iHAAiH;AACjH,wBAAgB,KAAK,CAAC,EACpB,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,UAAU,+BASpC;AAED,iHAAiH;AACjH,wBAAgB,OAAO,CAAC,EACtB,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,UAAU,+BASpC"}
@@ -0,0 +1,88 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { RatingGroup, useRatingGroup, useRatingGroupContext, } from '@ark-ui/react/rating-group';
3
+ import { Star as DefaultStarIcon } from 'lucide-react';
4
+ import { cloneElement, forwardRef, useId, Fragment } from 'react';
5
+ import { ToneProvider, useToneContext } from "../../utils/Tone.js";
6
+ /**
7
+ * Root configures the scale and selection. StarsList supplies indices; use StarButton with StarIcon for each rating. Highlight, checked, and half-star appearance are built in; do not recreate hover state.
8
+ *
9
+ * @example Complete composition
10
+ * import { RatingInput } from '@central-ui/react'
11
+ *
12
+ * function Example() {
13
+ * return (
14
+ * <RatingInput.Root count={5}>
15
+ * <RatingInput.Container>
16
+ * <RatingInput.Label>How was your delivery?</RatingInput.Label>
17
+ * <RatingInput.StarsList>
18
+ * {(index) => (
19
+ * <RatingInput.StarButton key={index} index={index}>
20
+ * <RatingInput.StarIcon />
21
+ * </RatingInput.StarButton>
22
+ * )}
23
+ * </RatingInput.StarsList>
24
+ * <RatingInput.Description>Choose up to five stars.</RatingInput.Description>
25
+ * </RatingInput.Container>
26
+ * </RatingInput.Root>
27
+ * )
28
+ * }
29
+ *
30
+ * @example Allow half-star ratings
31
+ * // Keep the same StarsList and StarIcon; half-star rendering is built in.
32
+ * ;<RatingInput.Root count={5} allowHalf defaultValue={2.5}>
33
+ * {
34
+ * // Rest of components here
35
+ * }
36
+ * </RatingInput.Root>
37
+ */
38
+ export function Root({ children, tone = 'neutral', ...props }) {
39
+ const rating = useRatingGroup(props);
40
+ return (_jsx(ToneProvider, { value: tone, children: _jsx(RatingGroup.RootProvider, { value: rating, asChild: true, children: _jsx(_Fragment, { children: children }) }) }));
41
+ }
42
+ export const Container = forwardRef(({ disableStyle, children, className, ...props }, ref) => {
43
+ const tone = useToneContext();
44
+ return (_jsxs("div", { ...props, ref: ref, "data-tone": tone, "data-component": "ratinginput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [children, _jsx(RatingGroup.HiddenInput, { style: { display: 'none' } })] }));
45
+ });
46
+ export function Label({ disableStyle, className, ...props }) {
47
+ return (_jsx(RatingGroup.Label, { ...props, "data-component": "ratinginput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
48
+ }
49
+ /** Calls children for each rating index. Pass the supplied index to StarButton; do not create a second hover or selection state. */
50
+ export function StarsList({ disableStyle, className, children, ...props }) {
51
+ const context = useRatingGroupContext();
52
+ return (_jsx(RatingGroup.Control, { ...props, "data-component": "ratinginput-starslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: context.items.map((index) => (_jsx(Fragment, { children: children(index) }, index))) }));
53
+ }
54
+ export function StarButton({ disableStyle, children, className, ...props }) {
55
+ const tone = useToneContext();
56
+ const rating = useRatingGroupContext();
57
+ const input = rating.getHiddenInputProps();
58
+ return (_jsx(RatingGroup.Item, { ...props, "data-tone": tone, "data-component": "ratinginput-starbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsx(RatingGroup.ItemContext, { children: ({ highlighted, half, checked }) => cloneElement(children, {
59
+ 'data-highlighted': highlighted ? '' : undefined,
60
+ 'data-half': half ? '' : undefined,
61
+ 'data-checked': checked ? '' : undefined,
62
+ 'data-disabled': input.disabled ? '' : undefined,
63
+ 'data-readonly': input.readOnly ? '' : undefined,
64
+ 'data-tone': tone,
65
+ 'aria-hidden': true,
66
+ }) }) }));
67
+ }
68
+ /** Built-in icon; no children needed. Use it inside its matching control. */
69
+ export function StarIcon({ disableStyle, className, strokeWidth, style, ...props }) {
70
+ const gradient_id = useId();
71
+ return (_jsx(DefaultStarIcon, { ...props, strokeWidth: strokeWidth ?? 1.5, style: {
72
+ '--star-half-fill': `url("#${gradient_id}-ltr")`,
73
+ '--star-half-fill-rtl': `url("#${gradient_id}-rtl")`,
74
+ ...style,
75
+ }, "data-component": "ratinginput-staricon", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsxs("defs", { children: [_jsxs("linearGradient", { id: `${gradient_id}-ltr`, children: [_jsx("stop", { offset: "50%", stopColor: "currentColor" }), _jsx("stop", { offset: "50%", stopColor: "currentColor", stopOpacity: 0 })] }), _jsxs("linearGradient", { id: `${gradient_id}-rtl`, children: [_jsx("stop", { offset: "50%", stopColor: "currentColor", stopOpacity: 0 }), _jsx("stop", { offset: "50%", stopColor: "currentColor" })] })] }) }));
76
+ }
77
+ export function Description({ disableStyle, className, ...props }) {
78
+ return (_jsx("div", { ...props, "data-component": "ratinginput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
79
+ }
80
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
81
+ export function Error({ disableStyle, className, ...props }) {
82
+ return (_jsx("div", { ...props, "data-component": "ratinginput-error", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
83
+ }
84
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
85
+ export function Success({ disableStyle, className, ...props }) {
86
+ return (_jsx("div", { ...props, "data-component": "ratinginput-success", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
87
+ }
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ratinginput/index.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,WAAW,EACX,cAAc,EACd,qBAAqB,GAKtB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAQtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,QAAQ,EACR,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EAIT;IACC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;IAEpC,OAAO,CACL,KAAC,YAAY,IAAC,KAAK,EAAE,IAAI,YACvB,KAAC,WAAW,CAAC,YAAY,IAAC,KAAK,EAAE,MAAM,EAAE,OAAO,kBAC9C,4BAAG,QAAQ,GAAI,GACU,GACd,CAChB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAGjC,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAE7B,OAAO,CACL,kBACM,KAAK,EACT,GAAG,EAAE,GAAG,eACG,IAAI,oBACA,uBAAuB,yBACjB,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAClD,SAAS,EAAE,SAAS,aAEnB,QAAQ,EACT,KAAC,WAAW,CAAC,WAAW,IAA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EAAC,WAAW,EAAE,CAAC,GAAI,IAC/C,EACjB,0BAAgB,EAAE,EAAE,GAAG,WAAW,MAAM,aACtC,eAAM,MAAM,EAAC,KAAK,EAAC,SAAS,EAAC,cAAc,EAAC,WAAW,EAAE,CAAC,GAAI,EAC9D,eAAM,MAAM,EAAC,KAAK,EAAC,SAAS,EAAC,cAAc,GAAG,IAC/B,IACZ,GACS,CACnB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAC1B,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EAC2B;IACnC,OAAO,CACL,iBACM,KAAK,oBACM,yBAAyB,yBACnB,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAClD,SAAS,EAAE,SAAS,GACpB,CACH,CAAA;AACH,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,KAAK,CAAC,EACpB,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EAC2B;IACnC,OAAO,CACL,iBACM,KAAK,oBACM,mBAAmB,yBACb,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAClD,SAAS,EAAE,SAAS,GACpB,CACH,CAAA;AACH,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,OAAO,CAAC,EACtB,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EAC2B;IACnC,OAAO,CACL,iBACM,KAAK,oBACM,qBAAqB,yBACf,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAClD,SAAS,EAAE,SAAS,GACpB,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,205 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import { Select as BaseSelect } from '@base-ui/react/select';
3
+ import type { LucideProps } from 'lucide-react';
4
+ import type { ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
5
+ export type ItemShape = {
6
+ /** Used automatically for the displayed selection. No label accessor needed. */
7
+ label: string;
8
+ /** Keep identifiers stable so recreated items still match the current selection. */
9
+ value: string;
10
+ };
11
+ export type GroupShape = {
12
+ /** Use an empty label and omit GroupLabel when the list should look flat. */
13
+ label: string;
14
+ /** Keep this group wrapper even without a visible heading. */
15
+ items: readonly ItemShape[];
16
+ };
17
+ /** Use GroupType<typeof rootItems> for the GroupsList callback, with the exact items passed to Root. */
18
+ export type GroupType<T extends readonly GroupShape[]> = T[number];
19
+ /** Use SelectionsType<typeof rootItems> for a custom multiple-value callback, with the exact items passed to Root. */
20
+ export type SelectionsType<T extends readonly GroupShape[]> = ItemType<T>[];
21
+ /** Use ItemType<typeof rootItems> for an ItemsList or custom single-value callback, with the exact items passed to Root. */
22
+ export type ItemType<T extends readonly GroupShape[]> = GroupType<T>['items'][number];
23
+ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean | undefined = false> = Omit<BaseSelect.Root.Props<ItemType<T>, Multiple>, 'items' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue'> & {
24
+ /** Prepare groups before passing items. For a flat-looking list, use one group with label: empty string and omit GroupLabel; keep Group and ItemsList. */
25
+ items: T;
26
+ /** Choose the visual tone. This does not validate data or show/hide feedback messages. */
27
+ tone?: 'neutral' | 'valid' | 'invalid';
28
+ };
29
+ /**
30
+ * Prepare groups in items. A flat-looking list is one group with an empty label and no GroupLabel; keep Group around ItemsList. OpenButtonValue already formats the selection: omit children unless a custom display is needed. Keep ScrollArea → GroupsList → Group → ItemsList → Item in Popup.
31
+ *
32
+ * @example Complete composition
33
+ * import { Select } from '@central-ui/react'
34
+ *
35
+ * const cities = [
36
+ * { value: 'rabat', label: 'Rabat', country: 'Morocco', population: 580000 },
37
+ * {
38
+ * value: 'casablanca',
39
+ * label: 'Casablanca',
40
+ * country: 'Morocco',
41
+ * population: 3359818,
42
+ * },
43
+ * {
44
+ * value: 'marrakesh',
45
+ * label: 'Marrakesh',
46
+ * country: 'Morocco',
47
+ * population: 928850,
48
+ * },
49
+ * ]
50
+ * const allCities = [{ label: '', items: cities }]
51
+ * type City = Select.ItemType<typeof allCities>
52
+ * type Country = Select.GroupType<typeof allCities>
53
+ * function Example() {
54
+ * return (
55
+ * <Select.Root items={allCities} name="city">
56
+ * <Select.Container>
57
+ * <Select.Label>City</Select.Label>
58
+ * <Select.OpenButton>
59
+ * <Select.OpenButtonValue placeholder="Choose a city" />
60
+ * <Select.OpenButtonIcon />
61
+ * </Select.OpenButton>
62
+ * <Select.Description>Choose a city.</Select.Description>
63
+ *
64
+ * <Select.Popup>
65
+ * <Select.ScrollArea // Required listbox and scrolling viewport.
66
+ * >
67
+ * <Select.GroupsList // Required groups container.
68
+ * >
69
+ * {(group: Country) => (
70
+ * <Select.Group
71
+ * key={group.label}
72
+ * items={group.items}
73
+ * aria-label={group.label}
74
+ * >
75
+ * <Select.ItemsList>
76
+ * {(city: City) => (
77
+ * <Select.Item
78
+ * key={city.value}
79
+ * value={city}
80
+ * disabled={city.value === 'marseille'}
81
+ * >
82
+ * <Select.ItemText>{city.label}</Select.ItemText>
83
+ * <Select.ItemIndicator />
84
+ * </Select.Item>
85
+ * )}
86
+ * </Select.ItemsList>
87
+ * </Select.Group>
88
+ * )}
89
+ * </Select.GroupsList>
90
+ * </Select.ScrollArea>
91
+ * </Select.Popup>
92
+ * </Select.Container>
93
+ * </Select.Root>
94
+ * )
95
+ * }
96
+ *
97
+ * @example Custom selection display only when needed
98
+ * // Default usage is <Select.OpenButtonValue /> with no children.
99
+ * // For this custom single-selection display, items={allCities} is passed to Root.
100
+ * ;<Select.OpenButtonValue>
101
+ * {(city: Select.ItemType<typeof allCities> | null) =>
102
+ * city ? city.label + ' — ' + city.country : 'Choose a city'
103
+ * }
104
+ * </Select.OpenButtonValue>
105
+ *
106
+ * @example Select more than one city
107
+ * // Keep the same popup items and OpenButtonValue; both already support multiple selection.
108
+ * ;<Select.Root items={allCities} multiple>
109
+ * {
110
+ * // Rest of components here
111
+ * }
112
+ * </Select.Root>
113
+ */
114
+ export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, items, id, tone, open, defaultOpen, onOpenChange, ...props }: RootProps<T, Multiple>): import("react").JSX.Element;
115
+ export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
116
+ export declare const Label: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectLabelProps, "className"> & {
117
+ className?: string;
118
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
119
+ export declare const Value: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectValueProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
120
+ export type OpenButtonValueProps<Value extends ItemShape | ItemShape[] | null = ItemShape | ItemShape[] | null> = Omit<ComponentPropsWithRef<typeof BaseSelect.Value>, 'className' | 'children'> & {
121
+ className?: string;
122
+ /** Omit to keep the automatic formatted selection. Only for a custom display, annotate the callback with ItemType<typeof rootItems> or SelectionsType<typeof rootItems> for multiple selection, using the same items as Root. */
123
+ children?: ReactNode | ((value: Value) => ReactNode);
124
+ } & StyleProps;
125
+ /** Omit children to keep the built-in formatted value. Supply children only for a special display; do not format the selection yourself for the usual case. */
126
+ export declare function OpenButtonValue<Value extends ItemShape | ItemShape[] | null = ItemShape | ItemShape[] | null>({ disableStyle, className, ...props }: OpenButtonValueProps<Value> & StyleProps): import("react").JSX.Element;
127
+ export type ScrollAreaProps = Omit<ComponentPropsWithRef<typeof BaseSelect.List>, 'children' | 'className'> & {
128
+ className?: string;
129
+ children?: ReactNode;
130
+ } & StyleProps;
131
+ export declare const ScrollArea: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react").SelectListProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "children" | "className"> & {
132
+ className?: string;
133
+ children?: ReactNode;
134
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
135
+ export type GroupsListProps<Group extends GroupShape = GroupShape> = Omit<ComponentPropsWithRef<'div'>, 'children'> & {
136
+ /** Return Group with ItemsList. Manually annotate group with Select.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
137
+ children: ReactNode | ((group: Group, index: number) => ReactNode);
138
+ } & StyleProps;
139
+ /** Let this list render the groups. Manually annotate its children callback with Select.GroupType<typeof rootItems>, using the SAME items variable passed to Root. */
140
+ export declare function GroupsList<Group extends GroupShape = GroupShape>({ disableStyle, children, className, style, ...props }: GroupsListProps<Group> & StyleProps): import("react").JSX.Element;
141
+ export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<'div'>, 'children' | 'className'> & {
142
+ className?: string;
143
+ /** Return Item with ItemText and ItemIndicator. Manually annotate item with Select.ItemType<typeof rootItems>, using the exact items variable passed to Root. */
144
+ children: (item: Item, index: number) => ReactNode;
145
+ } & StyleProps;
146
+ /** Let this list render the surrounding group. Manually annotate its callback with Select.ItemType<typeof rootItems>, using the SAME items variable passed to Root. */
147
+ export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className, ...props }: ItemsListProps<Item> & StyleProps): import("react").JSX.Element;
148
+ export type GroupProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Group>, 'className'> & {
149
+ className?: string;
150
+ /** Prepare groups before passing items. For a flat-looking list, use one group with label: empty string and omit GroupLabel; keep Group and ItemsList. */
151
+ /** Prepare groups before passing items. For a flat-looking list, use one group with label: empty string and omit GroupLabel; keep Group and ItemsList. */
152
+ items: readonly Item[];
153
+ } & StyleProps;
154
+ export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, items, children, className, ...props }: GroupProps<Item> & StyleProps): import("react").JSX.Element;
155
+ export type ItemProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Item>, 'value' | 'className'> & {
156
+ className?: string;
157
+ /** Pass the item from ItemsList; matching uses its value identifier, so recreated item objects still select correctly. */
158
+ /** Pass the item from ItemsList; matching uses its value identifier, so recreated item objects still select correctly. */
159
+ value: Item;
160
+ } & StyleProps;
161
+ export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: ItemProps<Item> & StyleProps): import("react").JSX.Element;
162
+ export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseSelect.Popup>, 'className'> & {
163
+ className?: string;
164
+ } & Pick<BaseSelect.Portal.Props, 'container'> & Pick<BaseSelect.Positioner.Props, 'anchor' | 'positionMethod' | 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance' | 'alignItemWithTrigger'> & StyleProps;
165
+ /** Already includes the portal and positioner. Keep it in the matching Root and let the native open state control visibility. */
166
+ export declare function Popup({ disableStyle, container, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, alignItemWithTrigger, className, style, ...props }: PopupProps & StyleProps): import("react").JSX.Element;
167
+ export declare const Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").SVGProps<SVGSVGElement>, "children" | "dangerouslySetInnerHTML"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
168
+ /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
169
+ export declare const PopupOpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectTriggerProps, "children" | "className" | "render"> & {
170
+ className?: string;
171
+ /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
172
+ children: ReactElement;
173
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
174
+ export declare const OpenButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectTriggerProps, "className"> & {
175
+ className?: string;
176
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
177
+ /** Omit for an unlabeled/flat-looking group; keep the Group wrapper. Supply the heading only when grouping should be visible. */
178
+ export declare const GroupLabel: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectGroupLabelProps, "className"> & {
179
+ className?: string;
180
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
181
+ export declare const Separator: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectSeparatorProps, "className"> & {
182
+ className?: string;
183
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
184
+ export declare const ItemText: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectItemTextProps, "className"> & {
185
+ className?: string;
186
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
187
+ export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
188
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
189
+ export declare const Error: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
190
+ /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
191
+ export declare const Success: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
192
+ /** Built-in icon; no children needed. Use it inside its matching control. */
193
+ export declare const OpenButtonIcon: import("react").ForwardRefExoticComponent<Omit<LucideProps & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
194
+ /** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
195
+ export declare const ItemIndicator: import("react").ForwardRefExoticComponent<Omit<Omit<LucideProps, "children"> & Pick<import("@base-ui/react").SelectItemIndicatorProps, "keepMounted"> & {
196
+ /** Optional replacement SVG icon. It receives this indicator's props and ref. */
197
+ children?: ReactElement<LucideProps>;
198
+ } & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
199
+ export declare const ScrollUpArrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectScrollUpArrowProps, "className"> & {
200
+ className?: string;
201
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
202
+ export declare const ScrollDownArrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SelectScrollDownArrowProps, "className"> & {
203
+ className?: string;
204
+ } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
205
+ //# sourceMappingURL=index.d.ts.map