@charcoal-ui/react 6.0.0-rc.6 → 6.0.0-rc.8

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/dist/_lib/createDivComponent.cjs +20 -0
  2. package/dist/_lib/createDivComponent.cjs.map +1 -0
  3. package/dist/_lib/createDivComponent.js +19 -0
  4. package/dist/_lib/createDivComponent.js.map +1 -0
  5. package/dist/_lib/index.cjs +22 -0
  6. package/dist/_lib/index.cjs.map +1 -0
  7. package/dist/_lib/index.js +20 -0
  8. package/dist/_lib/index.js.map +1 -0
  9. package/dist/_lib/useClassNames.cjs +15 -0
  10. package/dist/_lib/useClassNames.cjs.map +1 -0
  11. package/dist/_lib/useClassNames.js +14 -0
  12. package/dist/_lib/useClassNames.js.map +1 -0
  13. package/dist/_lib/useForwardedRef.cjs +19 -0
  14. package/dist/_lib/useForwardedRef.cjs.map +1 -0
  15. package/dist/_lib/useForwardedRef.js +17 -0
  16. package/dist/_lib/useForwardedRef.js.map +1 -0
  17. package/dist/_lib/useIsomorphicLayoutEffect.cjs +13 -0
  18. package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -0
  19. package/dist/_lib/useIsomorphicLayoutEffect.js +12 -0
  20. package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -0
  21. package/dist/_virtual/_rolldown/runtime.cjs +30 -0
  22. package/dist/components/Button/index2.cjs +26 -0
  23. package/dist/components/Button/index2.cjs.map +1 -0
  24. package/dist/components/Button/index2.js +24 -0
  25. package/dist/components/Button/index2.js.map +1 -0
  26. package/dist/components/Carousel/CarouselItem.cjs +46 -0
  27. package/dist/components/Carousel/CarouselItem.cjs.map +1 -0
  28. package/dist/components/Carousel/CarouselItem.js +45 -0
  29. package/dist/components/Carousel/CarouselItem.js.map +1 -0
  30. package/dist/components/Carousel/carouselStore.cjs +38 -0
  31. package/dist/components/Carousel/carouselStore.cjs.map +1 -0
  32. package/dist/components/Carousel/carouselStore.js +37 -0
  33. package/dist/components/Carousel/carouselStore.js.map +1 -0
  34. package/dist/components/Carousel/index.d.ts +2 -0
  35. package/dist/components/Carousel/index.d.ts.map +1 -1
  36. package/dist/components/Carousel/index2.cjs +145 -0
  37. package/dist/components/Carousel/index2.cjs.map +1 -0
  38. package/dist/components/Carousel/index2.js +144 -0
  39. package/dist/components/Carousel/index2.js.map +1 -0
  40. package/dist/components/Carousel/intersectionObserver.cjs +46 -0
  41. package/dist/components/Carousel/intersectionObserver.cjs.map +1 -0
  42. package/dist/components/Carousel/intersectionObserver.js +45 -0
  43. package/dist/components/Carousel/intersectionObserver.js.map +1 -0
  44. package/dist/components/Carousel/resizeObserver.cjs +34 -0
  45. package/dist/components/Carousel/resizeObserver.cjs.map +1 -0
  46. package/dist/components/Carousel/resizeObserver.js +33 -0
  47. package/dist/components/Carousel/resizeObserver.js.map +1 -0
  48. package/dist/components/Carousel/store.cjs +24 -0
  49. package/dist/components/Carousel/store.cjs.map +1 -0
  50. package/dist/components/Carousel/store.js +23 -0
  51. package/dist/components/Carousel/store.js.map +1 -0
  52. package/dist/components/Carousel/useCarouselScroller.cjs +149 -0
  53. package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -0
  54. package/dist/components/Carousel/useCarouselScroller.js +148 -0
  55. package/dist/components/Carousel/useCarouselScroller.js.map +1 -0
  56. package/dist/components/Checkbox/CheckboxInput/index2.cjs +29 -0
  57. package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -0
  58. package/dist/components/Checkbox/CheckboxInput/index2.js +28 -0
  59. package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -0
  60. package/dist/components/Checkbox/CheckboxWithLabel.cjs +23 -0
  61. package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -0
  62. package/dist/components/Checkbox/CheckboxWithLabel.js +21 -0
  63. package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -0
  64. package/dist/components/Checkbox/index2.cjs +34 -0
  65. package/dist/components/Checkbox/index2.cjs.map +1 -0
  66. package/dist/components/Checkbox/index2.js +33 -0
  67. package/dist/components/Checkbox/index2.js.map +1 -0
  68. package/dist/components/Clickable/index2.cjs +21 -0
  69. package/dist/components/Clickable/index2.cjs.map +1 -0
  70. package/dist/components/Clickable/index2.js +19 -0
  71. package/dist/components/Clickable/index2.js.map +1 -0
  72. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +44 -0
  73. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -0
  74. package/dist/components/DropdownSelector/DropdownMenuItem/index2.js +43 -0
  75. package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -0
  76. package/dist/components/DropdownSelector/DropdownPopover.cjs +41 -0
  77. package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -0
  78. package/dist/components/DropdownSelector/DropdownPopover.js +40 -0
  79. package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -0
  80. package/dist/components/DropdownSelector/ListItem/index2.cjs +19 -0
  81. package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -0
  82. package/dist/components/DropdownSelector/ListItem/index2.js +18 -0
  83. package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -0
  84. package/dist/components/DropdownSelector/MenuItem/index.cjs +30 -0
  85. package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -0
  86. package/dist/components/DropdownSelector/MenuItem/index.js +29 -0
  87. package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -0
  88. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs +30 -0
  89. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -0
  90. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js +29 -0
  91. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -0
  92. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +53 -0
  93. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -0
  94. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js +52 -0
  95. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -0
  96. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +20 -0
  97. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -0
  98. package/dist/components/DropdownSelector/MenuItemGroup/index2.js +19 -0
  99. package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -0
  100. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +15 -0
  101. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -0
  102. package/dist/components/DropdownSelector/MenuList/MenuListContext.js +14 -0
  103. package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -0
  104. package/dist/components/DropdownSelector/MenuList/index2.cjs +32 -0
  105. package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -0
  106. package/dist/components/DropdownSelector/MenuList/index2.js +31 -0
  107. package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -0
  108. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +34 -0
  109. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -0
  110. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js +32 -0
  111. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -0
  112. package/dist/components/DropdownSelector/Popover/index2.cjs +71 -0
  113. package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -0
  114. package/dist/components/DropdownSelector/Popover/index2.js +70 -0
  115. package/dist/components/DropdownSelector/Popover/index2.js.map +1 -0
  116. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +27 -0
  117. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -0
  118. package/dist/components/DropdownSelector/Popover/usePreventScroll.js +26 -0
  119. package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -0
  120. package/dist/components/DropdownSelector/index2.cjs +113 -0
  121. package/dist/components/DropdownSelector/index2.cjs.map +1 -0
  122. package/dist/components/DropdownSelector/index2.js +111 -0
  123. package/dist/components/DropdownSelector/index2.js.map +1 -0
  124. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +34 -0
  125. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -0
  126. package/dist/components/DropdownSelector/utils/findPreviewRecursive.js +32 -0
  127. package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -0
  128. package/dist/components/FieldLabel/index2.cjs +35 -0
  129. package/dist/components/FieldLabel/index2.cjs.map +1 -0
  130. package/dist/components/FieldLabel/index2.js +33 -0
  131. package/dist/components/FieldLabel/index2.js.map +1 -0
  132. package/dist/components/HintText/index2.cjs +25 -0
  133. package/dist/components/HintText/index2.cjs.map +1 -0
  134. package/dist/components/HintText/index2.js +24 -0
  135. package/dist/components/HintText/index2.js.map +1 -0
  136. package/dist/components/Icon/index.cjs +39 -0
  137. package/dist/components/Icon/index.cjs.map +1 -0
  138. package/dist/components/Icon/index.js +37 -0
  139. package/dist/components/Icon/index.js.map +1 -0
  140. package/dist/components/IconButton/index2.cjs +46 -0
  141. package/dist/components/IconButton/index2.cjs.map +1 -0
  142. package/dist/components/IconButton/index2.js +44 -0
  143. package/dist/components/IconButton/index2.js.map +1 -0
  144. package/dist/components/LoadingSpinner/index2.cjs +43 -0
  145. package/dist/components/LoadingSpinner/index2.cjs.map +1 -0
  146. package/dist/components/LoadingSpinner/index2.js +41 -0
  147. package/dist/components/LoadingSpinner/index2.js.map +1 -0
  148. package/dist/components/Modal/Dialog/index2.cjs +30 -0
  149. package/dist/components/Modal/Dialog/index2.cjs.map +1 -0
  150. package/dist/components/Modal/Dialog/index2.js +28 -0
  151. package/dist/components/Modal/Dialog/index2.js.map +1 -0
  152. package/dist/components/Modal/ModalBackgroundContext.cjs +14 -0
  153. package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -0
  154. package/dist/components/Modal/ModalBackgroundContext.js +12 -0
  155. package/dist/components/Modal/ModalBackgroundContext.js.map +1 -0
  156. package/dist/components/Modal/ModalPlumbing2.cjs +30 -0
  157. package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -0
  158. package/dist/components/Modal/ModalPlumbing2.js +26 -0
  159. package/dist/components/Modal/ModalPlumbing2.js.map +1 -0
  160. package/dist/components/Modal/index2.cjs +121 -0
  161. package/dist/components/Modal/index2.cjs.map +1 -0
  162. package/dist/components/Modal/index2.js +118 -0
  163. package/dist/components/Modal/index2.js.map +1 -0
  164. package/dist/components/Modal/useCustomModalOverlay.cjs +48 -0
  165. package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -0
  166. package/dist/components/Modal/useCustomModalOverlay.js +45 -0
  167. package/dist/components/Modal/useCustomModalOverlay.js.map +1 -0
  168. package/dist/components/Modal/useTransitionPresence.cjs +57 -0
  169. package/dist/components/Modal/useTransitionPresence.cjs.map +1 -0
  170. package/dist/components/Modal/useTransitionPresence.js +56 -0
  171. package/dist/components/Modal/useTransitionPresence.js.map +1 -0
  172. package/dist/components/MultiSelect/context.cjs +19 -0
  173. package/dist/components/MultiSelect/context.cjs.map +1 -0
  174. package/dist/components/MultiSelect/context.js +18 -0
  175. package/dist/components/MultiSelect/context.js.map +1 -0
  176. package/dist/components/MultiSelect/index2.cjs +97 -0
  177. package/dist/components/MultiSelect/index2.cjs.map +1 -0
  178. package/dist/components/MultiSelect/index2.js +93 -0
  179. package/dist/components/MultiSelect/index2.js.map +1 -0
  180. package/dist/components/Pagination/PaginationContext.cjs +16 -0
  181. package/dist/components/Pagination/PaginationContext.cjs.map +1 -0
  182. package/dist/components/Pagination/PaginationContext.js +14 -0
  183. package/dist/components/Pagination/PaginationContext.js.map +1 -0
  184. package/dist/components/Pagination/helper.cjs +63 -0
  185. package/dist/components/Pagination/helper.cjs.map +1 -0
  186. package/dist/components/Pagination/helper.js +61 -0
  187. package/dist/components/Pagination/helper.js.map +1 -0
  188. package/dist/components/Pagination/index2.cjs +301 -0
  189. package/dist/components/Pagination/index2.cjs.map +1 -0
  190. package/dist/components/Pagination/index2.js +288 -0
  191. package/dist/components/Pagination/index2.js.map +1 -0
  192. package/dist/components/Radio/RadioGroup/index2.cjs +49 -0
  193. package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -0
  194. package/dist/components/Radio/RadioGroup/index2.js +47 -0
  195. package/dist/components/Radio/RadioGroup/index2.js.map +1 -0
  196. package/dist/components/Radio/RadioGroupContext.cjs +20 -0
  197. package/dist/components/Radio/RadioGroupContext.cjs.map +1 -0
  198. package/dist/components/Radio/RadioGroupContext.js +18 -0
  199. package/dist/components/Radio/RadioGroupContext.js.map +1 -0
  200. package/dist/components/Radio/RadioInput/index2.cjs +27 -0
  201. package/dist/components/Radio/RadioInput/index2.cjs.map +1 -0
  202. package/dist/components/Radio/RadioInput/index2.js +26 -0
  203. package/dist/components/Radio/RadioInput/index2.js.map +1 -0
  204. package/dist/components/Radio/index2.cjs +42 -0
  205. package/dist/components/Radio/index2.cjs.map +1 -0
  206. package/dist/components/Radio/index2.js +39 -0
  207. package/dist/components/Radio/index2.js.map +1 -0
  208. package/dist/components/SegmentedControl/RadioGroupContext.cjs +24 -0
  209. package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -0
  210. package/dist/components/SegmentedControl/RadioGroupContext.js +21 -0
  211. package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -0
  212. package/dist/components/SegmentedControl/index2.cjs +72 -0
  213. package/dist/components/SegmentedControl/index2.cjs.map +1 -0
  214. package/dist/components/SegmentedControl/index2.js +70 -0
  215. package/dist/components/SegmentedControl/index2.js.map +1 -0
  216. package/dist/components/Switch/SwitchInput/index2.cjs +25 -0
  217. package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -0
  218. package/dist/components/Switch/SwitchInput/index2.js +24 -0
  219. package/dist/components/Switch/SwitchInput/index2.js.map +1 -0
  220. package/dist/components/Switch/SwitchWithLabel.cjs +23 -0
  221. package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -0
  222. package/dist/components/Switch/SwitchWithLabel.js +21 -0
  223. package/dist/components/Switch/SwitchWithLabel.js.map +1 -0
  224. package/dist/components/Switch/index2.cjs +37 -0
  225. package/dist/components/Switch/index2.cjs.map +1 -0
  226. package/dist/components/Switch/index2.js +36 -0
  227. package/dist/components/Switch/index2.js.map +1 -0
  228. package/dist/components/TagItem/index.d.ts.map +1 -1
  229. package/dist/components/TagItem/index2.cjs +57 -0
  230. package/dist/components/TagItem/index2.cjs.map +1 -0
  231. package/dist/components/TagItem/index2.js +55 -0
  232. package/dist/components/TagItem/index2.js.map +1 -0
  233. package/dist/components/TextArea/index2.cjs +134 -0
  234. package/dist/components/TextArea/index2.cjs.map +1 -0
  235. package/dist/components/TextArea/index2.js +133 -0
  236. package/dist/components/TextArea/index2.js.map +1 -0
  237. package/dist/components/TextEllipsis/helper.cjs +31 -0
  238. package/dist/components/TextEllipsis/helper.cjs.map +1 -0
  239. package/dist/components/TextEllipsis/helper.js +30 -0
  240. package/dist/components/TextEllipsis/helper.js.map +1 -0
  241. package/dist/components/TextEllipsis/index2.cjs +119 -0
  242. package/dist/components/TextEllipsis/index2.cjs.map +1 -0
  243. package/dist/components/TextEllipsis/index2.js +114 -0
  244. package/dist/components/TextEllipsis/index2.js.map +1 -0
  245. package/dist/components/TextField/AssistiveText/index2.cjs +10 -0
  246. package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -0
  247. package/dist/components/TextField/AssistiveText/index2.js +10 -0
  248. package/dist/components/TextField/AssistiveText/index2.js.map +1 -0
  249. package/dist/components/TextField/index2.cjs +101 -0
  250. package/dist/components/TextField/index2.cjs.map +1 -0
  251. package/dist/components/TextField/index2.js +100 -0
  252. package/dist/components/TextField/index2.js.map +1 -0
  253. package/dist/components/TextField/useFocusWithClick.cjs +23 -0
  254. package/dist/components/TextField/useFocusWithClick.cjs.map +1 -0
  255. package/dist/components/TextField/useFocusWithClick.js +22 -0
  256. package/dist/components/TextField/useFocusWithClick.js.map +1 -0
  257. package/dist/core/CharcoalProvider.cjs +16 -0
  258. package/dist/core/CharcoalProvider.cjs.map +1 -0
  259. package/dist/core/CharcoalProvider.js +14 -0
  260. package/dist/core/CharcoalProvider.js.map +1 -0
  261. package/dist/core/OverlayProvider.js +4 -0
  262. package/dist/core/SSRProvider.cjs +15 -0
  263. package/dist/core/SSRProvider.cjs.map +1 -0
  264. package/dist/core/SSRProvider.js +14 -0
  265. package/dist/core/SSRProvider.js.map +1 -0
  266. package/dist/core/SetThemeScript.cjs +45 -0
  267. package/dist/core/SetThemeScript.cjs.map +1 -0
  268. package/dist/core/SetThemeScript.js +43 -0
  269. package/dist/core/SetThemeScript.js.map +1 -0
  270. package/dist/core/themeHelper.cjs +154 -0
  271. package/dist/core/themeHelper.cjs.map +1 -0
  272. package/dist/core/themeHelper.js +143 -0
  273. package/dist/core/themeHelper.js.map +1 -0
  274. package/dist/index.cjs +81 -12
  275. package/dist/index.css +1380 -1355
  276. package/dist/index.js +31 -12
  277. package/dist/layered.css +1376 -1351
  278. package/dist/layered.css.map +1 -1
  279. package/package.json +5 -5
  280. package/src/components/Carousel/MIGRATION.md +8 -8
  281. package/src/components/Carousel/__snapshots__/index.css.snap +4 -2
  282. package/src/components/Carousel/index.css +5 -2
  283. package/src/components/Carousel/index.story.tsx +14 -12
  284. package/src/components/Carousel/index.test.tsx +24 -0
  285. package/src/components/Carousel/index.tsx +17 -0
  286. package/src/components/TagItem/index.test.tsx +38 -0
  287. package/src/components/TagItem/index.tsx +1 -0
  288. package/src/components/TextArea/__snapshots__/index.css.snap +29 -8
  289. package/src/components/TextArea/index.css +30 -8
  290. package/src/components/TextArea/index.tsx +1 -1
  291. package/dist/index.cjs.map +0 -1
  292. package/dist/index.js.map +0 -1
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../../_lib/useClassNames.cjs');
4
+ const require_RadioGroupContext = require('../RadioGroupContext.cjs');
5
+ require('./index.cjs');
6
+ let react = require("react");
7
+ react = require_runtime.__toESM(react);
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+
10
+ //#region src/components/Radio/RadioGroup/index.tsx
11
+ const RadioGroup = (0, react.forwardRef)(function RadioGroupInner({ value, label, name, onChange, disabled, readonly, invalid, children, "aria-orientation": ariaOrientation = "vertical", ...props }, ref) {
12
+ const classNames = require_useClassNames.useClassNames("charcoal-radio-group", props.className);
13
+ const handleChange = (0, react.useCallback)((next) => {
14
+ onChange(next);
15
+ }, [onChange]);
16
+ const contextValue = (0, react.useMemo)(() => ({
17
+ name,
18
+ selected: value,
19
+ disabled: disabled ?? false,
20
+ readonly: readonly ?? false,
21
+ invalid: invalid ?? false,
22
+ onChange: handleChange
23
+ }), [
24
+ disabled,
25
+ handleChange,
26
+ invalid,
27
+ name,
28
+ readonly,
29
+ value
30
+ ]);
31
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RadioGroupContext.RadioGroupContext.Provider, {
32
+ value: contextValue,
33
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
34
+ role: "radiogroup",
35
+ "aria-disabled": disabled,
36
+ "aria-invalid": invalid,
37
+ "aria-label": label,
38
+ "aria-labelledby": props["aria-labelledby"],
39
+ "aria-orientation": ariaOrientation,
40
+ className: classNames,
41
+ ref,
42
+ children
43
+ })
44
+ });
45
+ });
46
+
47
+ //#endregion
48
+ exports.RadioGroup = RadioGroup;
49
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["forwardRef","useCallback","useMemo","JSX","React","useClassNames","RadioGroupContext","RadioGroupProps","PropsWithChildren","className","value","Value","label","name","onChange","next","disabled","readonly","invalid","ref","Ref","HTMLDivElement","ComponentProps","RadioGroup","RadioGroupInner","children","ariaOrientation","props","classNames","handleChange","contextValue","selected","Element"],"sources":["../../../../src/components/Radio/RadioGroup/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { forwardRef, useCallback, useMemo, type JSX } from 'react'\nimport * as React from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\nimport { RadioGroupContext } from '../RadioGroupContext'\n\nexport type RadioGroupProps<Value extends string = string> =\n React.PropsWithChildren<{\n className?: string\n value?: Value\n /**\n * aria-label of RadioGroup\n */\n label?: string\n name: string\n onChange(next: Value): void\n disabled?: boolean\n readonly?: boolean\n invalid?: boolean\n ref?: React.Ref<HTMLDivElement>\n 'aria-labelledby'?: React.ComponentProps<'div'>['aria-labelledby']\n 'aria-orientation'?: React.ComponentProps<'div'>['aria-orientation']\n }>\n\nexport const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(\n function RadioGroupInner(\n {\n value,\n label,\n name,\n onChange,\n disabled,\n readonly,\n invalid,\n children,\n 'aria-orientation': ariaOrientation = 'vertical',\n ...props\n },\n ref,\n ) {\n const classNames = useClassNames('charcoal-radio-group', props.className)\n\n const handleChange = useCallback(\n (next: string) => {\n onChange(next)\n },\n [onChange],\n )\n\n const contextValue = useMemo(\n () => ({\n name,\n selected: value,\n disabled: disabled ?? false,\n readonly: readonly ?? false,\n invalid: invalid ?? false,\n onChange: handleChange,\n }),\n [disabled, handleChange, invalid, name, readonly, value],\n )\n\n return (\n <RadioGroupContext.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n aria-disabled={disabled}\n aria-invalid={invalid}\n aria-label={label}\n aria-labelledby={props['aria-labelledby']}\n aria-orientation={ariaOrientation}\n className={classNames}\n ref={ref}\n >\n {children}\n </div>\n </RadioGroupContext.Provider>\n )\n },\n) as <Value extends string>(props: RadioGroupProps<Value>) => JSX.Element\n"],"mappings":";;;;;;;;;;AAyBA,MAAauB,mCACX,SAASC,gBACP,EACEd,OACAE,OACAC,MACAC,UACAE,UACAC,UACAC,SACAO,UACA,oBAAoBC,kBAAkB,YACtC,GAAGC,SAELR,KACA;CACA,MAAMS,aAAavB,oCAAc,wBAAwBsB,MAAMlB,UAAU;CAEzE,MAAMoB,uCACHd,SAAiB;EAChBD,SAASC,KAAK;IAEhB,CAACD,SACH,CAAC;CAED,MAAMgB,yCACG;EACLjB;EACAkB,UAAUrB;EACVM,UAAUA,YAAY;EACtBC,UAAUA,YAAY;EACtBC,SAASA,WAAW;EACpBJ,UAAUe;EACX,GACD;EAACb;EAAUa;EAAcX;EAASL;EAAMI;EAAUP;EACpD,CAAC;CAED,OACE,2CAAC,4CAAkB,UAAnB;EAA4B,OAAOoB;YACjC,2CAAC,OAAD;GACE,MAAK;GACL,iBAAed;GACf,gBAAcE;GACd,cAAYN;GACZ,mBAAiBe,MAAM;GACvB,oBAAkBD;GAClB,WAAWE;GACNT;GAEJM;GACE;EACsB;EAGlC"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { useClassNames } from "../../../_lib/useClassNames.js";
3
+ import { RadioGroupContext } from "../RadioGroupContext.js";
4
+ /* empty css */
5
+ import { forwardRef, useCallback, useMemo } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+
8
+ //#region src/components/Radio/RadioGroup/index.tsx
9
+ const RadioGroup = forwardRef(function RadioGroupInner({ value, label, name, onChange, disabled, readonly, invalid, children, "aria-orientation": ariaOrientation = "vertical", ...props }, ref) {
10
+ const classNames = useClassNames("charcoal-radio-group", props.className);
11
+ const handleChange = useCallback((next) => {
12
+ onChange(next);
13
+ }, [onChange]);
14
+ const contextValue = useMemo(() => ({
15
+ name,
16
+ selected: value,
17
+ disabled: disabled ?? false,
18
+ readonly: readonly ?? false,
19
+ invalid: invalid ?? false,
20
+ onChange: handleChange
21
+ }), [
22
+ disabled,
23
+ handleChange,
24
+ invalid,
25
+ name,
26
+ readonly,
27
+ value
28
+ ]);
29
+ return /* @__PURE__ */ jsx(RadioGroupContext.Provider, {
30
+ value: contextValue,
31
+ children: /* @__PURE__ */ jsx("div", {
32
+ role: "radiogroup",
33
+ "aria-disabled": disabled,
34
+ "aria-invalid": invalid,
35
+ "aria-label": label,
36
+ "aria-labelledby": props["aria-labelledby"],
37
+ "aria-orientation": ariaOrientation,
38
+ className: classNames,
39
+ ref,
40
+ children
41
+ })
42
+ });
43
+ });
44
+
45
+ //#endregion
46
+ export { RadioGroup };
47
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["forwardRef","useCallback","useMemo","JSX","React","useClassNames","RadioGroupContext","RadioGroupProps","PropsWithChildren","className","value","Value","label","name","onChange","next","disabled","readonly","invalid","ref","Ref","HTMLDivElement","ComponentProps","RadioGroup","RadioGroupInner","children","ariaOrientation","props","classNames","handleChange","contextValue","selected","Element"],"sources":["../../../../src/components/Radio/RadioGroup/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { forwardRef, useCallback, useMemo, type JSX } from 'react'\nimport * as React from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\nimport { RadioGroupContext } from '../RadioGroupContext'\n\nexport type RadioGroupProps<Value extends string = string> =\n React.PropsWithChildren<{\n className?: string\n value?: Value\n /**\n * aria-label of RadioGroup\n */\n label?: string\n name: string\n onChange(next: Value): void\n disabled?: boolean\n readonly?: boolean\n invalid?: boolean\n ref?: React.Ref<HTMLDivElement>\n 'aria-labelledby'?: React.ComponentProps<'div'>['aria-labelledby']\n 'aria-orientation'?: React.ComponentProps<'div'>['aria-orientation']\n }>\n\nexport const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(\n function RadioGroupInner(\n {\n value,\n label,\n name,\n onChange,\n disabled,\n readonly,\n invalid,\n children,\n 'aria-orientation': ariaOrientation = 'vertical',\n ...props\n },\n ref,\n ) {\n const classNames = useClassNames('charcoal-radio-group', props.className)\n\n const handleChange = useCallback(\n (next: string) => {\n onChange(next)\n },\n [onChange],\n )\n\n const contextValue = useMemo(\n () => ({\n name,\n selected: value,\n disabled: disabled ?? false,\n readonly: readonly ?? false,\n invalid: invalid ?? false,\n onChange: handleChange,\n }),\n [disabled, handleChange, invalid, name, readonly, value],\n )\n\n return (\n <RadioGroupContext.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n aria-disabled={disabled}\n aria-invalid={invalid}\n aria-label={label}\n aria-labelledby={props['aria-labelledby']}\n aria-orientation={ariaOrientation}\n className={classNames}\n ref={ref}\n >\n {children}\n </div>\n </RadioGroupContext.Provider>\n )\n },\n) as <Value extends string>(props: RadioGroupProps<Value>) => JSX.Element\n"],"mappings":";;;;;;;;AAyBA,MAAauB,aAAavB,WACxB,SAASwB,gBACP,EACEd,OACAE,OACAC,MACAC,UACAE,UACAC,UACAC,SACAO,UACA,oBAAoBC,kBAAkB,YACtC,GAAGC,SAELR,KACA;CACA,MAAMS,aAAavB,cAAc,wBAAwBsB,MAAMlB,UAAU;CAEzE,MAAMoB,eAAe5B,aAClBc,SAAiB;EAChBD,SAASC,KAAK;IAEhB,CAACD,SACH,CAAC;CAED,MAAMgB,eAAe5B,eACZ;EACLW;EACAkB,UAAUrB;EACVM,UAAUA,YAAY;EACtBC,UAAUA,YAAY;EACtBC,SAASA,WAAW;EACpBJ,UAAUe;EACX,GACD;EAACb;EAAUa;EAAcX;EAASL;EAAMI;EAAUP;EACpD,CAAC;CAED,OACE,oBAAC,kBAAkB,UAAnB;EAA4B,OAAOoB;YACjC,oBAAC,OAAD;GACE,MAAK;GACL,iBAAed;GACf,gBAAcE;GACd,cAAYN;GACZ,mBAAiBe,MAAM;GACvB,oBAAkBD;GAClB,WAAWE;GACNT;GAEJM;GACE;EACsB;EAGlC"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+ react = require_runtime.__toESM(react, 1);
5
+
6
+ //#region src/components/Radio/RadioGroupContext.ts
7
+ const RadioGroupContext = react.createContext({
8
+ name: void 0,
9
+ selected: void 0,
10
+ disabled: false,
11
+ readonly: false,
12
+ invalid: false,
13
+ onChange() {
14
+ throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
15
+ }
16
+ });
17
+
18
+ //#endregion
19
+ exports.RadioGroupContext = RadioGroupContext;
20
+ //# sourceMappingURL=RadioGroupContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupContext.cjs","names":["React","RadioGroupContext","name","selected","disabled","readonly","invalid","onChange","next","createContext","undefined","Error"],"sources":["../../../src/components/Radio/RadioGroupContext.ts"],"sourcesContent":["import * as React from 'react'\n\nexport interface RadioGroupContext {\n name: string\n selected?: string\n disabled: boolean\n readonly: boolean\n invalid: boolean\n onChange: (next: string) => void\n}\n\nexport const RadioGroupContext = React.createContext<RadioGroupContext>({\n name: undefined as never,\n selected: undefined,\n disabled: false,\n readonly: false,\n invalid: false,\n onChange() {\n throw new Error(\n 'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?',\n )\n },\n})\n"],"mappings":";;;;;;AAWA,MAAaC,oBAAoBD,MAAMS,cAAiC;CACtEP,MAAMQ;CACNP,UAAUO;CACVN,UAAU;CACVC,UAAU;CACVC,SAAS;CACTC,WAAW;EACT,MAAM,IAAII,MACR,iFACD;;CAEJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/components/Radio/RadioGroupContext.ts
5
+ const RadioGroupContext = React$1.createContext({
6
+ name: void 0,
7
+ selected: void 0,
8
+ disabled: false,
9
+ readonly: false,
10
+ invalid: false,
11
+ onChange() {
12
+ throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
13
+ }
14
+ });
15
+
16
+ //#endregion
17
+ export { RadioGroupContext };
18
+ //# sourceMappingURL=RadioGroupContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupContext.js","names":["React","RadioGroupContext","name","selected","disabled","readonly","invalid","onChange","next","createContext","undefined","Error"],"sources":["../../../src/components/Radio/RadioGroupContext.ts"],"sourcesContent":["import * as React from 'react'\n\nexport interface RadioGroupContext {\n name: string\n selected?: string\n disabled: boolean\n readonly: boolean\n invalid: boolean\n onChange: (next: string) => void\n}\n\nexport const RadioGroupContext = React.createContext<RadioGroupContext>({\n name: undefined as never,\n selected: undefined,\n disabled: false,\n readonly: false,\n invalid: false,\n onChange() {\n throw new Error(\n 'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?',\n )\n },\n})\n"],"mappings":";;;;AAWA,MAAaC,oBAAoBD,QAAMS,cAAiC;CACtEP,MAAMQ;CACNP,UAAUO;CACVN,UAAU;CACVC,UAAU;CACVC,SAAS;CACTC,WAAW;EACT,MAAM,IAAII,MACR,iFACD;;CAEJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../../_lib/useClassNames.cjs');
4
+ require('./index.cjs');
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/components/Radio/RadioInput/index.tsx
9
+ const RadioInput = (0, react.forwardRef)(function RadioInput({ onChange, invalid, className, ...props }, ref) {
10
+ const handleChange = (0, react.useCallback)((e) => {
11
+ const el = e.currentTarget;
12
+ onChange?.(el.value);
13
+ }, [onChange]);
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
15
+ className: require_useClassNames.useClassNames("charcoal-radio-input", className),
16
+ ref,
17
+ type: "radio",
18
+ onChange: handleChange,
19
+ "aria-invalid": invalid,
20
+ ...props
21
+ });
22
+ });
23
+ var RadioInput_default = (0, react.memo)(RadioInput);
24
+
25
+ //#endregion
26
+ exports.default = RadioInput_default;
27
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["forwardRef","memo","useCallback","useClassNames","CharcoalRadioInputProps","invalid","onChange","value","InputProps","React","HTMLProps","HTMLInputElement","RadioInputProps","Omit","RadioInput","className","props","ref","handleChange","e","ChangeEvent","el","currentTarget","classNames"],"sources":["../../../../src/components/Radio/RadioInput/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { forwardRef, memo, useCallback } from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\n\ntype CharcoalRadioInputProps = {\n invalid?: boolean\n onChange?: (value: string) => void\n}\n\ntype InputProps = React.HTMLProps<HTMLInputElement>\n\nexport type RadioInputProps = CharcoalRadioInputProps &\n Omit<InputProps, keyof CharcoalRadioInputProps | 'ref'>\n\nconst RadioInput = forwardRef<HTMLInputElement, RadioInputProps>(\n function RadioInput({ onChange, invalid, className, ...props }, ref) {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const el = e.currentTarget\n onChange?.(el.value)\n },\n [onChange],\n )\n\n const classNames = useClassNames('charcoal-radio-input', className)\n\n return (\n // eslint-disable-next-line jsx-a11y/role-supports-aria-props\n <input\n className={classNames}\n ref={ref}\n type=\"radio\"\n onChange={handleChange}\n aria-invalid={invalid}\n {...props}\n />\n )\n },\n)\n\nexport default memo(RadioInput)\n"],"mappings":";;;;;;;;AAeA,MAAMc,mCACJ,SAASA,WAAW,EAAER,UAAUD,SAASU,WAAW,GAAGC,SAASC,KAAK;CACnE,MAAMC,uCACHC,MAA2C;EAC1C,MAAME,KAAKF,EAAEG;EACbhB,WAAWe,GAAGd,MAAM;IAEtB,CAACD,SACH,CAAC;CAID,OAEE,2CAAC,SAAD;EACE,WALeH,oCAAc,wBAAwBY,UAKhC;EAChBE;EACL,MAAK;EACL,UAAUC;EACV,gBAAcb;EACd,GAAIW;EAAM;EAIjB;AAED,yCAAoBF,WAAW"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { useClassNames } from "../../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import { forwardRef, memo, useCallback } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/Radio/RadioInput/index.tsx
8
+ const RadioInput = forwardRef(function RadioInput({ onChange, invalid, className, ...props }, ref) {
9
+ const handleChange = useCallback((e) => {
10
+ const el = e.currentTarget;
11
+ onChange?.(el.value);
12
+ }, [onChange]);
13
+ return /* @__PURE__ */ jsx("input", {
14
+ className: useClassNames("charcoal-radio-input", className),
15
+ ref,
16
+ type: "radio",
17
+ onChange: handleChange,
18
+ "aria-invalid": invalid,
19
+ ...props
20
+ });
21
+ });
22
+ var RadioInput_default = memo(RadioInput);
23
+
24
+ //#endregion
25
+ export { RadioInput_default as default };
26
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["forwardRef","memo","useCallback","useClassNames","CharcoalRadioInputProps","invalid","onChange","value","InputProps","React","HTMLProps","HTMLInputElement","RadioInputProps","Omit","RadioInput","className","props","ref","handleChange","e","ChangeEvent","el","currentTarget","classNames"],"sources":["../../../../src/components/Radio/RadioInput/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { forwardRef, memo, useCallback } from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\n\ntype CharcoalRadioInputProps = {\n invalid?: boolean\n onChange?: (value: string) => void\n}\n\ntype InputProps = React.HTMLProps<HTMLInputElement>\n\nexport type RadioInputProps = CharcoalRadioInputProps &\n Omit<InputProps, keyof CharcoalRadioInputProps | 'ref'>\n\nconst RadioInput = forwardRef<HTMLInputElement, RadioInputProps>(\n function RadioInput({ onChange, invalid, className, ...props }, ref) {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const el = e.currentTarget\n onChange?.(el.value)\n },\n [onChange],\n )\n\n const classNames = useClassNames('charcoal-radio-input', className)\n\n return (\n // eslint-disable-next-line jsx-a11y/role-supports-aria-props\n <input\n className={classNames}\n ref={ref}\n type=\"radio\"\n onChange={handleChange}\n aria-invalid={invalid}\n {...props}\n />\n )\n },\n)\n\nexport default memo(RadioInput)\n"],"mappings":";;;;;;;AAeA,MAAMc,aAAad,WACjB,SAASc,WAAW,EAAER,UAAUD,SAASU,WAAW,GAAGC,SAASC,KAAK;CACnE,MAAMC,eAAehB,aAClBiB,MAA2C;EAC1C,MAAME,KAAKF,EAAEG;EACbhB,WAAWe,GAAGd,MAAM;IAEtB,CAACD,SACH,CAAC;CAID,OAEE,oBAAC,SAAD;EACE,WALeH,cAAc,wBAAwBY,UAKhC;EAChBE;EACL,MAAK;EACL,UAAUC;EACV,gBAAcb;EACd,GAAIW;EAAM;EAIjB;AAED,yBAAef,KAAKa,WAAW"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../_lib/useClassNames.cjs');
4
+ require('./index.cjs');
5
+ const require_RadioGroupContext = require('./RadioGroupContext.cjs');
6
+ const require_index$1 = require('./RadioInput/index2.cjs');
7
+ let react = require("react");
8
+ react = require_runtime.__toESM(react);
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ let warning = require("warning");
11
+ warning = require_runtime.__toESM(warning);
12
+
13
+ //#region src/components/Radio/index.tsx
14
+ const Radio = (0, react.forwardRef)(function RadioInner({ value, disabled = false, children, ...props }, ref) {
15
+ const { name, selected, disabled: isParentDisabled, readonly, invalid, onChange } = (0, react.useContext)(require_RadioGroupContext.RadioGroupContext);
16
+ const classNames = require_useClassNames.useClassNames("charcoal-radio__label", props.className);
17
+ (0, warning.default)(name !== void 0, `"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`);
18
+ const isSelected = value === selected;
19
+ const isDisabled = disabled || isParentDisabled;
20
+ const isReadonly = readonly && !isSelected;
21
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
22
+ "aria-disabled": isDisabled || isReadonly,
23
+ className: classNames,
24
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, {
25
+ name,
26
+ value,
27
+ checked: isSelected,
28
+ "aria-invalid": invalid,
29
+ onChange,
30
+ disabled: isDisabled || isReadonly,
31
+ ref
32
+ }), children != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
33
+ className: "charcoal-radio__label_div",
34
+ children
35
+ })]
36
+ });
37
+ });
38
+ var Radio_default = (0, react.memo)(Radio);
39
+
40
+ //#endregion
41
+ exports.default = Radio_default;
42
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["memo","forwardRef","useContext","React","warning","useClassNames","RadioGroupContext","RadioInput","RadioProps","PropsWithChildren","value","disabled","className","Radio","HTMLInputElement","RadioInner","children","props","ref","name","selected","isParentDisabled","readonly","invalid","onChange","classNames","undefined","isSelected","isDisabled","isReadonly"],"sources":["../../../src/components/Radio/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { memo, forwardRef, useContext } from 'react'\nimport * as React from 'react'\nimport warning from 'warning'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nimport { RadioGroupContext } from './RadioGroupContext'\nimport RadioInput from './RadioInput'\n\nexport type RadioProps = React.PropsWithChildren<{\n value: string\n disabled?: boolean\n className?: string\n}>\n\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(function RadioInner(\n { value, disabled = false, children, ...props },\n ref,\n) {\n const {\n name,\n selected,\n disabled: isParentDisabled,\n readonly,\n invalid,\n onChange,\n } = useContext(RadioGroupContext)\n\n const classNames = useClassNames('charcoal-radio__label', props.className)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`,\n )\n\n const isSelected = value === selected\n const isDisabled = disabled || isParentDisabled\n const isReadonly = readonly && !isSelected\n\n return (\n <label aria-disabled={isDisabled || isReadonly} className={classNames}>\n <RadioInput\n name={name}\n value={value}\n checked={isSelected}\n aria-invalid={invalid}\n onChange={onChange}\n disabled={isDisabled || isReadonly}\n ref={ref}\n />\n {children != null && (\n <div className=\"charcoal-radio__label_div\">{children}</div>\n )}\n </label>\n )\n})\n\nexport default memo(Radio)\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMa,8BAAiD,SAASE,WAC9D,EAAEL,OAAOC,WAAW,OAAOK,UAAU,GAAGC,SACxCC,KACA;CACA,MAAM,EACJC,MACAC,UACAT,UAAUU,kBACVC,UACAC,SACAC,mCACalB,4CAAkB;CAEjC,MAAMmB,aAAapB,oCAAc,yBAAyBY,MAAML,UAAU;CAE1ER,qBAEEe,SAASO,QACT,qFACD;CAED,MAAMC,aAAajB,UAAUU;CAC7B,MAAMQ,aAAajB,YAAYU;CAC/B,MAAMQ,aAAaP,YAAY,CAACK;CAEhC,OACE,4CAAC,SAAD;EAAO,iBAAeC,cAAcC;EAAY,WAAWJ;YAA3D,CACE,2CAAC,yBAAD;GACQN;GACCT;GACP,SAASiB;GACT,gBAAcJ;GACJC;GACV,UAAUI,cAAcC;GACnBX;GAAI,GAEVF,YAAY,QACX,2CAAC,OAAD;GAAK,WAAU;GAA6BA;GAC7C,EACK;;EAEV;AAEF,oCAAoBH,MAAM"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import { RadioGroupContext } from "./RadioGroupContext.js";
5
+ import RadioInput_default from "./RadioInput/index2.js";
6
+ import { forwardRef, memo, useContext } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import warning from "warning";
9
+
10
+ //#region src/components/Radio/index.tsx
11
+ const Radio = forwardRef(function RadioInner({ value, disabled = false, children, ...props }, ref) {
12
+ const { name, selected, disabled: isParentDisabled, readonly, invalid, onChange } = useContext(RadioGroupContext);
13
+ const classNames = useClassNames("charcoal-radio__label", props.className);
14
+ warning(name !== void 0, `"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`);
15
+ const isSelected = value === selected;
16
+ const isDisabled = disabled || isParentDisabled;
17
+ const isReadonly = readonly && !isSelected;
18
+ return /* @__PURE__ */ jsxs("label", {
19
+ "aria-disabled": isDisabled || isReadonly,
20
+ className: classNames,
21
+ children: [/* @__PURE__ */ jsx(RadioInput_default, {
22
+ name,
23
+ value,
24
+ checked: isSelected,
25
+ "aria-invalid": invalid,
26
+ onChange,
27
+ disabled: isDisabled || isReadonly,
28
+ ref
29
+ }), children != null && /* @__PURE__ */ jsx("div", {
30
+ className: "charcoal-radio__label_div",
31
+ children
32
+ })]
33
+ });
34
+ });
35
+ var Radio_default = memo(Radio);
36
+
37
+ //#endregion
38
+ export { Radio_default as default };
39
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["memo","forwardRef","useContext","React","warning","useClassNames","RadioGroupContext","RadioInput","RadioProps","PropsWithChildren","value","disabled","className","Radio","HTMLInputElement","RadioInner","children","props","ref","name","selected","isParentDisabled","readonly","invalid","onChange","classNames","undefined","isSelected","isDisabled","isReadonly"],"sources":["../../../src/components/Radio/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { memo, forwardRef, useContext } from 'react'\nimport * as React from 'react'\nimport warning from 'warning'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nimport { RadioGroupContext } from './RadioGroupContext'\nimport RadioInput from './RadioInput'\n\nexport type RadioProps = React.PropsWithChildren<{\n value: string\n disabled?: boolean\n className?: string\n}>\n\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(function RadioInner(\n { value, disabled = false, children, ...props },\n ref,\n) {\n const {\n name,\n selected,\n disabled: isParentDisabled,\n readonly,\n invalid,\n onChange,\n } = useContext(RadioGroupContext)\n\n const classNames = useClassNames('charcoal-radio__label', props.className)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`,\n )\n\n const isSelected = value === selected\n const isDisabled = disabled || isParentDisabled\n const isReadonly = readonly && !isSelected\n\n return (\n <label aria-disabled={isDisabled || isReadonly} className={classNames}>\n <RadioInput\n name={name}\n value={value}\n checked={isSelected}\n aria-invalid={invalid}\n onChange={onChange}\n disabled={isDisabled || isReadonly}\n ref={ref}\n />\n {children != null && (\n <div className=\"charcoal-radio__label_div\">{children}</div>\n )}\n </label>\n )\n})\n\nexport default memo(Radio)\n"],"mappings":";;;;;;;;;;AAgBA,MAAMa,QAAQZ,WAAyC,SAASc,WAC9D,EAAEL,OAAOC,WAAW,OAAOK,UAAU,GAAGC,SACxCC,KACA;CACA,MAAM,EACJC,MACAC,UACAT,UAAUU,kBACVC,UACAC,SACAC,aACEtB,WAAWI,kBAAkB;CAEjC,MAAMmB,aAAapB,cAAc,yBAAyBY,MAAML,UAAU;CAE1ER,QAEEe,SAASO,QACT,qFACD;CAED,MAAMC,aAAajB,UAAUU;CAC7B,MAAMQ,aAAajB,YAAYU;CAC/B,MAAMQ,aAAaP,YAAY,CAACK;CAEhC,OACE,qBAAC,SAAD;EAAO,iBAAeC,cAAcC;EAAY,WAAWJ;YAA3D,CACE,oBAAC,oBAAD;GACQN;GACCT;GACP,SAASiB;GACT,gBAAcJ;GACJC;GACV,UAAUI,cAAcC;GACnBX;GAAI,GAEVF,YAAY,QACX,oBAAC,OAAD;GAAK,WAAU;GAA6BA;GAC7C,EACK;;EAEV;AAEF,oBAAehB,KAAKa,MAAM"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+ react = require_runtime.__toESM(react);
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+
7
+ //#region src/components/SegmentedControl/RadioGroupContext.tsx
8
+ const RadioContext = (0, react.createContext)(null);
9
+ const RadioProvider = ({ value, children }) => {
10
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RadioContext.Provider, {
11
+ value,
12
+ children
13
+ });
14
+ };
15
+ const useRadioContext = () => {
16
+ const state = (0, react.useContext)(RadioContext);
17
+ if (state === null) throw new Error("`<RadioProvider>` is not likely mounted.");
18
+ return state;
19
+ };
20
+
21
+ //#endregion
22
+ exports.RadioProvider = RadioProvider;
23
+ exports.useRadioContext = useRadioContext;
24
+ //# sourceMappingURL=RadioGroupContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupContext.cjs","names":["createContext","useContext","React","RadioGroupState","RadioContext","RadioProviderProps","PropsWithChildren","value","RadioProvider","FC","children","useRadioContext","state","Error"],"sources":["../../../src/components/SegmentedControl/RadioGroupContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport * as React from 'react'\nimport { RadioGroupState } from 'react-stately/useRadioGroupState'\n\nconst RadioContext = createContext<RadioGroupState | null>(null)\n\ntype RadioProviderProps = React.PropsWithChildren<{\n value: RadioGroupState\n}>\nexport const RadioProvider: React.FC<RadioProviderProps> = ({\n value,\n children,\n}) => {\n return <RadioContext.Provider value={value}>{children}</RadioContext.Provider>\n}\nexport const useRadioContext = () => {\n const state = useContext(RadioContext)\n\n if (state === null)\n throw new Error('`<RadioProvider>` is not likely mounted.')\n\n return state\n}\n"],"mappings":";;;;;;;AAIA,MAAMI,wCAAqD,KAAK;AAKhE,MAAaI,iBAA+C,EAC1DD,OACAG,eACI;CACJ,OAAO,2CAAC,aAAa,UAAd;EAA8BH;EAAQG;EAAiC;;AAEhF,MAAaC,wBAAwB;CACnC,MAAMC,8BAAmBR,aAAa;CAEtC,IAAIQ,UAAU,MACZ,MAAM,IAAIC,MAAM,2CAA2C;CAE7D,OAAOD"}
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/components/SegmentedControl/RadioGroupContext.tsx
6
+ const RadioContext = createContext(null);
7
+ const RadioProvider = ({ value, children }) => {
8
+ return /* @__PURE__ */ jsx(RadioContext.Provider, {
9
+ value,
10
+ children
11
+ });
12
+ };
13
+ const useRadioContext = () => {
14
+ const state = useContext(RadioContext);
15
+ if (state === null) throw new Error("`<RadioProvider>` is not likely mounted.");
16
+ return state;
17
+ };
18
+
19
+ //#endregion
20
+ export { RadioProvider, useRadioContext };
21
+ //# sourceMappingURL=RadioGroupContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupContext.js","names":["createContext","useContext","React","RadioGroupState","RadioContext","RadioProviderProps","PropsWithChildren","value","RadioProvider","FC","children","useRadioContext","state","Error"],"sources":["../../../src/components/SegmentedControl/RadioGroupContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport * as React from 'react'\nimport { RadioGroupState } from 'react-stately/useRadioGroupState'\n\nconst RadioContext = createContext<RadioGroupState | null>(null)\n\ntype RadioProviderProps = React.PropsWithChildren<{\n value: RadioGroupState\n}>\nexport const RadioProvider: React.FC<RadioProviderProps> = ({\n value,\n children,\n}) => {\n return <RadioContext.Provider value={value}>{children}</RadioContext.Provider>\n}\nexport const useRadioContext = () => {\n const state = useContext(RadioContext)\n\n if (state === null)\n throw new Error('`<RadioProvider>` is not likely mounted.')\n\n return state\n}\n"],"mappings":";;;;;AAIA,MAAMI,eAAeJ,cAAsC,KAAK;AAKhE,MAAaQ,iBAA+C,EAC1DD,OACAG,eACI;CACJ,OAAO,oBAAC,aAAa,UAAd;EAA8BH;EAAQG;EAAiC;;AAEhF,MAAaC,wBAAwB;CACnC,MAAMC,QAAQX,WAAWG,aAAa;CAEtC,IAAIQ,UAAU,MACZ,MAAM,IAAIC,MAAM,2CAA2C;CAE7D,OAAOD"}
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../_lib/useClassNames.cjs');
4
+ const require_RadioGroupContext = require('./RadioGroupContext.cjs');
5
+ require('./index.cjs');
6
+ let react = require("react");
7
+ react = require_runtime.__toESM(react);
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let react_aria_useRadioGroup = require("react-aria/useRadioGroup");
10
+ let react_stately_useRadioGroupState = require("react-stately/useRadioGroupState");
11
+
12
+ //#region src/components/SegmentedControl/index.tsx
13
+ const SegmentedControl = (0, react.forwardRef)(function SegmentedControlInner(props, ref) {
14
+ const className = require_useClassNames.useClassNames("charcoal-segmented-control", props.className);
15
+ const ariaRadioGroupProps = (0, react.useMemo)(() => ({
16
+ ...props,
17
+ isDisabled: props.disabled,
18
+ isReadOnly: props.readonly,
19
+ isRequired: props.required,
20
+ "aria-label": props.name
21
+ }), [props]);
22
+ const state = (0, react_stately_useRadioGroupState.useRadioGroupState)(ariaRadioGroupProps);
23
+ const { radioGroupProps } = (0, react_aria_useRadioGroup.useRadioGroup)(ariaRadioGroupProps, state);
24
+ const segmentedControlItems = (0, react.useMemo)(() => {
25
+ return props.data.map((d) => typeof d === "string" ? {
26
+ value: d,
27
+ label: d
28
+ } : d);
29
+ }, [props.data]);
30
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
31
+ ref,
32
+ ...radioGroupProps,
33
+ className,
34
+ "data-uniform-segment-width": props.uniformSegmentWidth,
35
+ "data-full-width": props.fullWidth,
36
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RadioGroupContext.RadioProvider, {
37
+ value: state,
38
+ children: segmentedControlItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
39
+ value: item.value,
40
+ disabled: item.disabled,
41
+ uniformSegmentWidth: props.uniformSegmentWidth,
42
+ children: item.label
43
+ }, item.value))
44
+ })
45
+ });
46
+ });
47
+ var SegmentedControl_default = (0, react.memo)(SegmentedControl);
48
+ const Segmented = (props) => {
49
+ const state = require_RadioGroupContext.useRadioContext();
50
+ const ref = (0, react.useRef)(null);
51
+ const { inputProps, isDisabled, isSelected } = (0, react_aria_useRadioGroup.useRadio)((0, react.useMemo)(() => ({
52
+ value: props.value,
53
+ isDisabled: props.disabled,
54
+ children: props.children
55
+ }), [props]), state, ref);
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
57
+ className: "charcoal-segmented-control-radio__label",
58
+ "aria-disabled": isDisabled || state.isReadOnly,
59
+ "data-checked": isSelected,
60
+ "data-uniform-segment-width": props.uniformSegmentWidth,
61
+ "data-full-width": props.fullWidth,
62
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
63
+ className: "charcoal-segmented-control-radio__input",
64
+ ...inputProps,
65
+ ref
66
+ }), props.children]
67
+ });
68
+ };
69
+
70
+ //#endregion
71
+ exports.default = SegmentedControl_default;
72
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["ReactNode","forwardRef","memo","useMemo","useRef","React","RadioProvider","useRadioContext","useClassNames","AriaRadioGroupProps","AriaRadioProps","useRadio","useRadioGroup","useRadioGroupState","SegmentedControlItem","label","value","disabled","SegmentedControlProps","id","name","readonly","required","className","uniformSegmentWidth","fullWidth","defaultValue","data","onChange","SegmentedControl","HTMLDivElement","SegmentedControlInner","props","ref","ariaRadioGroupProps","isDisabled","isReadOnly","isRequired","state","radioGroupProps","segmentedControlItems","map","d","item","RadioProps","children","Segmented","HTMLInputElement","ariaRadioProps","inputProps","isSelected"],"sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["import { ReactNode, forwardRef, memo, useMemo, useRef } from 'react'\nimport * as React from 'react'\nimport { RadioProvider, useRadioContext } from './RadioGroupContext'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport './index.css'\nimport {\n AriaRadioGroupProps,\n AriaRadioProps,\n useRadio,\n useRadioGroup,\n} from 'react-aria/useRadioGroup'\n\nimport { useRadioGroupState } from 'react-stately/useRadioGroupState'\n\ntype SegmentedControlItem = {\n label: React.ReactNode\n value: string\n disabled?: boolean\n}\n\nexport type SegmentedControlProps = {\n readonly id?: string\n readonly name?: string\n readonly disabled?: boolean\n readonly readonly?: boolean\n readonly required?: boolean\n readonly className?: string\n readonly uniformSegmentWidth?: boolean\n readonly fullWidth?: boolean\n\n readonly value?: string\n readonly defaultValue?: string\n\n readonly data: string[] | SegmentedControlItem[]\n\n readonly onChange?: (value: string) => void\n}\n\nconst SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControlInner(props, ref) {\n const className = useClassNames(\n 'charcoal-segmented-control',\n props.className,\n )\n\n const ariaRadioGroupProps = useMemo<AriaRadioGroupProps>(\n () => ({\n ...props,\n isDisabled: props.disabled,\n isReadOnly: props.readonly,\n isRequired: props.required,\n 'aria-label': props.name,\n }),\n [props],\n )\n const state = useRadioGroupState(ariaRadioGroupProps)\n const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state)\n const segmentedControlItems = useMemo<SegmentedControlItem[]>(() => {\n return props.data.map((d) =>\n typeof d === 'string' ? { value: d, label: d } : d,\n )\n }, [props.data])\n\n return (\n <div\n ref={ref}\n {...radioGroupProps}\n className={className}\n data-uniform-segment-width={props.uniformSegmentWidth}\n data-full-width={props.fullWidth}\n >\n <RadioProvider value={state}>\n {segmentedControlItems.map((item) => (\n <Segmented\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n uniformSegmentWidth={props.uniformSegmentWidth}\n >\n {item.label}\n </Segmented>\n ))}\n </RadioProvider>\n </div>\n )\n },\n)\n\nexport default memo(SegmentedControl)\n\ntype RadioProps = {\n value: string\n disabled?: boolean\n children?: ReactNode\n uniformSegmentWidth?: boolean\n fullWidth?: boolean\n}\n\nconst Segmented = (props: RadioProps) => {\n const state = useRadioContext()\n const ref = useRef<HTMLInputElement>(null)\n const ariaRadioProps = useMemo<AriaRadioProps>(\n () => ({\n value: props.value,\n isDisabled: props.disabled,\n children: props.children,\n }),\n [props],\n )\n\n const { inputProps, isDisabled, isSelected } = useRadio(\n ariaRadioProps,\n state,\n ref,\n )\n\n return (\n <label\n className=\"charcoal-segmented-control-radio__label\"\n aria-disabled={isDisabled || state.isReadOnly}\n data-checked={isSelected}\n data-uniform-segment-width={props.uniformSegmentWidth}\n data-full-width={props.fullWidth}\n >\n <input\n className=\"charcoal-segmented-control-radio__input\"\n {...inputProps}\n ref={ref}\n />\n {props.children}\n </label>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,MAAM6B,yCACJ,SAASE,sBAAsBC,OAAOC,KAAK;CACzC,MAAMV,YAAYf,oCAChB,8BACAwB,MAAMT,UACP;CAED,MAAMW,gDACG;EACL,GAAGF;EACHG,YAAYH,MAAMf;EAClBmB,YAAYJ,MAAMX;EAClBgB,YAAYL,MAAMV;EAClB,cAAcU,MAAMZ;EACrB,GACD,CAACY,MACH,CAAC;CACD,MAAMM,iEAA2BJ,oBAAoB;CACrD,MAAM,EAAEK,gEAAkCL,qBAAqBI,MAAM;CACrE,MAAME,iDAA8D;EAClE,OAAOR,MAAML,KAAKc,KAAKC,MACrB,OAAOA,MAAM,WAAW;GAAE1B,OAAO0B;GAAG3B,OAAO2B;GAAG,GAAGA,EAClD;IACA,CAACV,MAAML,KAAK,CAAC;CAEhB,OACE,2CAAC,OAAD;EACOM;EACL,GAAIM;EACOhB;EACX,8BAA4BS,MAAMR;EAClC,mBAAiBQ,MAAMP;YAEvB,2CAAC,yCAAD;GAAe,OAAOa;aACnBE,sBAAsBC,KAAKE,SAC1B,2CAAC,WAAD;IAEE,OAAOA,KAAK3B;IACZ,UAAU2B,KAAK1B;IACf,qBAAqBe,MAAMR;cAE1BmB,KAAK5B;IAET,EAPQ4B,KAAK3B,MAOb,CAAC;GACW;EACX;EAGX;AAED,+CAAoBa,iBAAiB;AAUrC,MAAMiB,aAAad,UAAsB;CACvC,MAAMM,QAAQ/B,2CAAiB;CAC/B,MAAM0B,wBAA+B,KAAK;CAU1C,MAAM,EAAEgB,YAAYd,YAAYe,gFARvB;EACLlC,OAAOgB,MAAMhB;EACbmB,YAAYH,MAAMf;EAClB4B,UAAUb,MAAMa;EACjB,GACD,CAACb,MACH,CAGgB,EACdM,OACAL,IACD;CAED,OACE,4CAAC,SAAD;EACE,WAAU;EACV,iBAAeE,cAAcG,MAAMF;EACnC,gBAAcc;EACd,8BAA4BlB,MAAMR;EAClC,mBAAiBQ,MAAMP;YALzB,CAOE,2CAAC,SAAD;GACE,WAAU;GACV,GAAIwB;GACChB;GAAI,GAEVD,MAAMa,SACD"}
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ import { RadioProvider, useRadioContext } from "./RadioGroupContext.js";
4
+ /* empty css */
5
+ import { forwardRef, memo, useMemo, useRef } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useRadio, useRadioGroup } from "react-aria/useRadioGroup";
8
+ import { useRadioGroupState } from "react-stately/useRadioGroupState";
9
+
10
+ //#region src/components/SegmentedControl/index.tsx
11
+ const SegmentedControl = forwardRef(function SegmentedControlInner(props, ref) {
12
+ const className = useClassNames("charcoal-segmented-control", props.className);
13
+ const ariaRadioGroupProps = useMemo(() => ({
14
+ ...props,
15
+ isDisabled: props.disabled,
16
+ isReadOnly: props.readonly,
17
+ isRequired: props.required,
18
+ "aria-label": props.name
19
+ }), [props]);
20
+ const state = useRadioGroupState(ariaRadioGroupProps);
21
+ const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state);
22
+ const segmentedControlItems = useMemo(() => {
23
+ return props.data.map((d) => typeof d === "string" ? {
24
+ value: d,
25
+ label: d
26
+ } : d);
27
+ }, [props.data]);
28
+ return /* @__PURE__ */ jsx("div", {
29
+ ref,
30
+ ...radioGroupProps,
31
+ className,
32
+ "data-uniform-segment-width": props.uniformSegmentWidth,
33
+ "data-full-width": props.fullWidth,
34
+ children: /* @__PURE__ */ jsx(RadioProvider, {
35
+ value: state,
36
+ children: segmentedControlItems.map((item) => /* @__PURE__ */ jsx(Segmented, {
37
+ value: item.value,
38
+ disabled: item.disabled,
39
+ uniformSegmentWidth: props.uniformSegmentWidth,
40
+ children: item.label
41
+ }, item.value))
42
+ })
43
+ });
44
+ });
45
+ var SegmentedControl_default = memo(SegmentedControl);
46
+ const Segmented = (props) => {
47
+ const state = useRadioContext();
48
+ const ref = useRef(null);
49
+ const { inputProps, isDisabled, isSelected } = useRadio(useMemo(() => ({
50
+ value: props.value,
51
+ isDisabled: props.disabled,
52
+ children: props.children
53
+ }), [props]), state, ref);
54
+ return /* @__PURE__ */ jsxs("label", {
55
+ className: "charcoal-segmented-control-radio__label",
56
+ "aria-disabled": isDisabled || state.isReadOnly,
57
+ "data-checked": isSelected,
58
+ "data-uniform-segment-width": props.uniformSegmentWidth,
59
+ "data-full-width": props.fullWidth,
60
+ children: [/* @__PURE__ */ jsx("input", {
61
+ className: "charcoal-segmented-control-radio__input",
62
+ ...inputProps,
63
+ ref
64
+ }), props.children]
65
+ });
66
+ };
67
+
68
+ //#endregion
69
+ export { SegmentedControl_default as default };
70
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["ReactNode","forwardRef","memo","useMemo","useRef","React","RadioProvider","useRadioContext","useClassNames","AriaRadioGroupProps","AriaRadioProps","useRadio","useRadioGroup","useRadioGroupState","SegmentedControlItem","label","value","disabled","SegmentedControlProps","id","name","readonly","required","className","uniformSegmentWidth","fullWidth","defaultValue","data","onChange","SegmentedControl","HTMLDivElement","SegmentedControlInner","props","ref","ariaRadioGroupProps","isDisabled","isReadOnly","isRequired","state","radioGroupProps","segmentedControlItems","map","d","item","RadioProps","children","Segmented","HTMLInputElement","ariaRadioProps","inputProps","isSelected"],"sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["import { ReactNode, forwardRef, memo, useMemo, useRef } from 'react'\nimport * as React from 'react'\nimport { RadioProvider, useRadioContext } from './RadioGroupContext'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport './index.css'\nimport {\n AriaRadioGroupProps,\n AriaRadioProps,\n useRadio,\n useRadioGroup,\n} from 'react-aria/useRadioGroup'\n\nimport { useRadioGroupState } from 'react-stately/useRadioGroupState'\n\ntype SegmentedControlItem = {\n label: React.ReactNode\n value: string\n disabled?: boolean\n}\n\nexport type SegmentedControlProps = {\n readonly id?: string\n readonly name?: string\n readonly disabled?: boolean\n readonly readonly?: boolean\n readonly required?: boolean\n readonly className?: string\n readonly uniformSegmentWidth?: boolean\n readonly fullWidth?: boolean\n\n readonly value?: string\n readonly defaultValue?: string\n\n readonly data: string[] | SegmentedControlItem[]\n\n readonly onChange?: (value: string) => void\n}\n\nconst SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControlInner(props, ref) {\n const className = useClassNames(\n 'charcoal-segmented-control',\n props.className,\n )\n\n const ariaRadioGroupProps = useMemo<AriaRadioGroupProps>(\n () => ({\n ...props,\n isDisabled: props.disabled,\n isReadOnly: props.readonly,\n isRequired: props.required,\n 'aria-label': props.name,\n }),\n [props],\n )\n const state = useRadioGroupState(ariaRadioGroupProps)\n const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state)\n const segmentedControlItems = useMemo<SegmentedControlItem[]>(() => {\n return props.data.map((d) =>\n typeof d === 'string' ? { value: d, label: d } : d,\n )\n }, [props.data])\n\n return (\n <div\n ref={ref}\n {...radioGroupProps}\n className={className}\n data-uniform-segment-width={props.uniformSegmentWidth}\n data-full-width={props.fullWidth}\n >\n <RadioProvider value={state}>\n {segmentedControlItems.map((item) => (\n <Segmented\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n uniformSegmentWidth={props.uniformSegmentWidth}\n >\n {item.label}\n </Segmented>\n ))}\n </RadioProvider>\n </div>\n )\n },\n)\n\nexport default memo(SegmentedControl)\n\ntype RadioProps = {\n value: string\n disabled?: boolean\n children?: ReactNode\n uniformSegmentWidth?: boolean\n fullWidth?: boolean\n}\n\nconst Segmented = (props: RadioProps) => {\n const state = useRadioContext()\n const ref = useRef<HTMLInputElement>(null)\n const ariaRadioProps = useMemo<AriaRadioProps>(\n () => ({\n value: props.value,\n isDisabled: props.disabled,\n children: props.children,\n }),\n [props],\n )\n\n const { inputProps, isDisabled, isSelected } = useRadio(\n ariaRadioProps,\n state,\n ref,\n )\n\n return (\n <label\n className=\"charcoal-segmented-control-radio__label\"\n aria-disabled={isDisabled || state.isReadOnly}\n data-checked={isSelected}\n data-uniform-segment-width={props.uniformSegmentWidth}\n data-full-width={props.fullWidth}\n >\n <input\n className=\"charcoal-segmented-control-radio__input\"\n {...inputProps}\n ref={ref}\n />\n {props.children}\n </label>\n )\n}\n"],"mappings":";;;;;;;;;;AAsCA,MAAM6B,mBAAmB5B,WACvB,SAAS8B,sBAAsBC,OAAOC,KAAK;CACzC,MAAMV,YAAYf,cAChB,8BACAwB,MAAMT,UACP;CAED,MAAMW,sBAAsB/B,eACnB;EACL,GAAG6B;EACHG,YAAYH,MAAMf;EAClBmB,YAAYJ,MAAMX;EAClBgB,YAAYL,MAAMV;EAClB,cAAcU,MAAMZ;EACrB,GACD,CAACY,MACH,CAAC;CACD,MAAMM,QAAQzB,mBAAmBqB,oBAAoB;CACrD,MAAM,EAAEK,oBAAoB3B,cAAcsB,qBAAqBI,MAAM;CACrE,MAAME,wBAAwBrC,cAAsC;EAClE,OAAO6B,MAAML,KAAKc,KAAKC,MACrB,OAAOA,MAAM,WAAW;GAAE1B,OAAO0B;GAAG3B,OAAO2B;GAAG,GAAGA,EAClD;IACA,CAACV,MAAML,KAAK,CAAC;CAEhB,OACE,oBAAC,OAAD;EACOM;EACL,GAAIM;EACOhB;EACX,8BAA4BS,MAAMR;EAClC,mBAAiBQ,MAAMP;YAEvB,oBAAC,eAAD;GAAe,OAAOa;aACnBE,sBAAsBC,KAAKE,SAC1B,oBAAC,WAAD;IAEE,OAAOA,KAAK3B;IACZ,UAAU2B,KAAK1B;IACf,qBAAqBe,MAAMR;cAE1BmB,KAAK5B;IAET,EAPQ4B,KAAK3B,MAOb,CAAC;GACW;EACX;EAGX;AAED,+BAAed,KAAK2B,iBAAiB;AAUrC,MAAMiB,aAAad,UAAsB;CACvC,MAAMM,QAAQ/B,iBAAiB;CAC/B,MAAM0B,MAAM7B,OAAyB,KAAK;CAU1C,MAAM,EAAE6C,YAAYd,YAAYe,eAAevC,SATxBR,eACd;EACLa,OAAOgB,MAAMhB;EACbmB,YAAYH,MAAMf;EAClB4B,UAAUb,MAAMa;EACjB,GACD,CAACb,MACH,CAGgB,EACdM,OACAL,IACD;CAED,OACE,qBAAC,SAAD;EACE,WAAU;EACV,iBAAeE,cAAcG,MAAMF;EACnC,gBAAcc;EACd,8BAA4BlB,MAAMR;EAClC,mBAAiBQ,MAAMP;YALzB,CAOE,oBAAC,SAAD;GACE,WAAU;GACV,GAAIwB;GACChB;GAAI,GAEVD,MAAMa,SACD"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../../_lib/useClassNames.cjs');
4
+ require('./index.cjs');
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/components/Switch/SwitchInput/index.tsx
9
+ const SwitchInput = (0, react.forwardRef)(function SwitchInput({ onChange, className, ...props }, ref) {
10
+ const handleChange = (0, react.useCallback)((e) => {
11
+ const el = e.currentTarget;
12
+ onChange?.(el.checked);
13
+ }, [onChange]);
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
15
+ ref,
16
+ className: require_useClassNames.useClassNames("charcoal-switch-input", className),
17
+ type: "checkbox",
18
+ onChange: handleChange,
19
+ ...props
20
+ });
21
+ });
22
+
23
+ //#endregion
24
+ exports.default = SwitchInput;
25
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["forwardRef","useCallback","useClassNames","CharcoalSwitchProps","onChange","checked","InputProps","React","HTMLProps","HTMLInputElement","SwitchInputProps","Omit","SwitchInput","className","props","ref","handleChange","e","ChangeEvent","el","currentTarget","classNames"],"sources":["../../../../src/components/Switch/SwitchInput/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { forwardRef, useCallback } from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\n\nexport type CharcoalSwitchProps = {\n onChange?: (checked: boolean) => void\n}\n\ntype InputProps = React.HTMLProps<HTMLInputElement>\n\nexport type SwitchInputProps = CharcoalSwitchProps &\n Omit<InputProps, keyof CharcoalSwitchProps | 'ref'>\n\nconst SwitchInput = forwardRef<\n HTMLInputElement,\n Omit<SwitchInputProps, 'children'>\n>(function SwitchInput({ onChange, className, ...props }, ref) {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const el = e.currentTarget\n onChange?.(el.checked)\n },\n [onChange],\n )\n\n const classNames = useClassNames('charcoal-switch-input', className)\n return (\n <input\n ref={ref}\n className={classNames}\n type=\"checkbox\"\n onChange={handleChange}\n {...props}\n />\n )\n})\n\nexport default SwitchInput\n"],"mappings":";;;;;;;;AAcA,MAAMY,oCAGJ,SAASA,YAAY,EAAER,UAAUS,WAAW,GAAGC,SAASC,KAAK;CAC7D,MAAMC,uCACHC,MAA2C;EAC1C,MAAME,KAAKF,EAAEG;EACbhB,WAAWe,GAAGd,QAAQ;IAExB,CAACD,SACH,CAAC;CAGD,OACE,2CAAC,SAAD;EACOW;EACL,WAJeb,oCAAc,yBAAyBW,UAIjC;EACrB,MAAK;EACL,UAAUG;EACV,GAAIF;EACJ;EAEJ"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useClassNames } from "../../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import { forwardRef, useCallback } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/Switch/SwitchInput/index.tsx
8
+ const SwitchInput = forwardRef(function SwitchInput({ onChange, className, ...props }, ref) {
9
+ const handleChange = useCallback((e) => {
10
+ const el = e.currentTarget;
11
+ onChange?.(el.checked);
12
+ }, [onChange]);
13
+ return /* @__PURE__ */ jsx("input", {
14
+ ref,
15
+ className: useClassNames("charcoal-switch-input", className),
16
+ type: "checkbox",
17
+ onChange: handleChange,
18
+ ...props
19
+ });
20
+ });
21
+
22
+ //#endregion
23
+ export { SwitchInput as default };
24
+ //# sourceMappingURL=index2.js.map