@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,111 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ import Icon from "../Icon/index.js";
4
+ import FieldLabel from "../FieldLabel/index2.js";
5
+ import { AssistiveText } from "../TextField/AssistiveText/index2.js";
6
+ /* empty css */
7
+ import { DropdownPopover } from "./DropdownPopover.js";
8
+ import { findPreviewRecursive } from "./utils/findPreviewRecursive.js";
9
+ import { getValuesRecursive } from "./MenuList/internals/getValuesRecursive.js";
10
+ import MenuList from "./MenuList/index2.js";
11
+ import React, { useCallback, useMemo, useRef, useState } from "react";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ import { useId } from "react-aria/useId";
14
+ import { useVisuallyHidden } from "react-aria/VisuallyHidden";
15
+
16
+ //#region src/components/DropdownSelector/index.tsx
17
+ function DropdownSelector({ onChange, showLabel = false, selectRef, ...props }) {
18
+ const triggerRef = useRef(null);
19
+ const [isOpen, setIsOpen] = useState(false);
20
+ const preview = findPreviewRecursive(props.children, props.value);
21
+ const isPlaceholder = useMemo(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
22
+ const propsArray = getValuesRecursive(props.children);
23
+ const hasMatchedValue = useMemo(() => propsArray.some((itemProps) => itemProps.value === props.value), [propsArray, props.value]);
24
+ const { visuallyHiddenProps } = useVisuallyHidden();
25
+ const handleChange = useCallback((e) => {
26
+ onChange(e.target.value);
27
+ }, [onChange]);
28
+ const labelId = useId();
29
+ const describedbyId = useId();
30
+ return /* @__PURE__ */ jsxs("div", {
31
+ className: useClassNames("charcoal-dropdown-selector-root", props.className),
32
+ "aria-disabled": props.disabled,
33
+ children: [
34
+ /* @__PURE__ */ jsx(FieldLabel, {
35
+ id: labelId,
36
+ label: props.label,
37
+ required: props.required,
38
+ requiredText: props.requiredText,
39
+ subLabel: props.subLabel,
40
+ ...!showLabel ? visuallyHiddenProps : {}
41
+ }),
42
+ /* @__PURE__ */ jsx("div", {
43
+ ...visuallyHiddenProps,
44
+ "aria-hidden": "true",
45
+ children: /* @__PURE__ */ jsxs("select", {
46
+ name: props.name,
47
+ value: props.value,
48
+ onChange: handleChange,
49
+ tabIndex: -1,
50
+ ref: selectRef,
51
+ children: [!hasMatchedValue && /* @__PURE__ */ jsx("option", {
52
+ value: props.value,
53
+ children: props.value
54
+ }), propsArray.map((itemProps) => {
55
+ return /* @__PURE__ */ jsx("option", {
56
+ value: itemProps.value,
57
+ disabled: itemProps.disabled,
58
+ children: itemProps.value
59
+ }, itemProps.value);
60
+ })]
61
+ })
62
+ }),
63
+ /* @__PURE__ */ jsxs("button", {
64
+ className: "charcoal-dropdown-selector-button",
65
+ "aria-labelledby": labelId,
66
+ "aria-invalid": props.invalid,
67
+ "aria-describedby": props.assistiveText !== void 0 ? describedbyId : void 0,
68
+ disabled: props.disabled,
69
+ onClick: () => {
70
+ if (props.disabled === true) return;
71
+ setIsOpen(true);
72
+ },
73
+ ref: triggerRef,
74
+ type: "button",
75
+ "data-active": isOpen,
76
+ children: [/* @__PURE__ */ jsx("span", {
77
+ className: "charcoal-ui-dropdown-selector-text",
78
+ "data-placeholder": isPlaceholder,
79
+ children: isPlaceholder ? props.placeholder : preview
80
+ }), /* @__PURE__ */ jsx(Icon, {
81
+ className: "charcoal-ui-dropdown-selector-icon",
82
+ name: "16/Menu"
83
+ })]
84
+ }),
85
+ isOpen && /* @__PURE__ */ jsx(DropdownPopover, {
86
+ isOpen,
87
+ onClose: () => setIsOpen(false),
88
+ triggerRef,
89
+ value: props.value,
90
+ inertWorkaround: props.inertWorkaround,
91
+ children: /* @__PURE__ */ jsx(MenuList, {
92
+ value: props.value,
93
+ onChange: (v) => {
94
+ onChange(v);
95
+ setIsOpen(false);
96
+ },
97
+ children: props.children
98
+ })
99
+ }),
100
+ props.assistiveText !== void 0 && /* @__PURE__ */ jsx(AssistiveText, {
101
+ "data-invalid": props.invalid === true,
102
+ id: describedbyId,
103
+ children: props.assistiveText
104
+ })
105
+ ]
106
+ });
107
+ }
108
+
109
+ //#endregion
110
+ export { DropdownSelector as default };
111
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["React","ReactNode","useState","useRef","useMemo","useCallback","Icon","FieldLabel","DropdownPopover","findPreviewRecursive","MenuList","MenuListChildren","getValuesRecursive","AssistiveText","useClassNames","PopoverProps","useVisuallyHidden","useId","DropdownSelectorProps","label","value","disabled","placeholder","showLabel","invalid","assistiveText","required","requiredText","subLabel","name","children","onChange","className","selectRef","Ref","HTMLSelectElement","Pick","DropdownSelector","props","triggerRef","HTMLButtonElement","isOpen","setIsOpen","preview","isPlaceholder","undefined","propsArray","hasMatchedValue","some","itemProps","visuallyHiddenProps","handleChange","e","ChangeEvent","target","labelId","describedbyId","classNames","map","inertWorkaround","v"],"sources":["../../../src/components/DropdownSelector/index.tsx"],"sourcesContent":["import './index.css'\n\nimport React, { ReactNode, useState, useRef, useMemo, useCallback } from 'react'\nimport Icon from '../Icon'\nimport FieldLabel from '../FieldLabel'\nimport { DropdownPopover } from './DropdownPopover'\nimport { findPreviewRecursive } from './utils/findPreviewRecursive'\nimport MenuList, { MenuListChildren } from './MenuList'\nimport { getValuesRecursive } from './MenuList/internals/getValuesRecursive'\nimport { AssistiveText } from '../TextField/AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { PopoverProps } from './Popover'\n\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\nexport type DropdownSelectorProps = {\n label: string\n value: string\n disabled?: boolean\n placeholder?: string\n showLabel?: boolean\n invalid?: boolean\n assistiveText?: string\n required?: boolean\n requiredText?: string\n subLabel?: ReactNode\n /**\n * the name of hidden `<select />`\n */\n name?: string\n children: MenuListChildren\n onChange: (value: string) => void\n className?: string\n selectRef?: React.Ref<HTMLSelectElement>\n} & Pick<PopoverProps, 'inertWorkaround'>\n\nexport default function DropdownSelector({\n onChange,\n showLabel = false,\n selectRef,\n ...props\n}: DropdownSelectorProps) {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const [isOpen, setIsOpen] = useState(false)\n const preview = findPreviewRecursive(props.children, props.value)\n\n const isPlaceholder = useMemo(\n () => props.placeholder !== undefined && preview === undefined,\n [preview, props.placeholder],\n )\n\n const propsArray = getValuesRecursive(props.children)\n const hasMatchedValue = useMemo(\n () => propsArray.some((itemProps) => itemProps.value === props.value),\n [propsArray, props.value],\n )\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLSelectElement>) => {\n onChange(e.target.value)\n },\n [onChange],\n )\n\n const labelId = useId()\n const describedbyId = useId()\n\n const classNames = useClassNames(\n 'charcoal-dropdown-selector-root',\n props.className,\n )\n\n return (\n <div className={classNames} aria-disabled={props.disabled}>\n <FieldLabel\n id={labelId}\n label={props.label}\n required={props.required}\n requiredText={props.requiredText}\n subLabel={props.subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div {...visuallyHiddenProps} aria-hidden=\"true\">\n <select\n name={props.name}\n value={props.value}\n onChange={handleChange}\n tabIndex={-1}\n ref={selectRef}\n >\n {!hasMatchedValue && (\n <option value={props.value}>{props.value}</option>\n )}\n {propsArray.map((itemProps) => {\n return (\n <option\n key={itemProps.value}\n value={itemProps.value}\n disabled={itemProps.disabled}\n >\n {itemProps.value}\n </option>\n )\n })}\n </select>\n </div>\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props */}\n <button\n className=\"charcoal-dropdown-selector-button\"\n aria-labelledby={labelId}\n aria-invalid={props.invalid}\n aria-describedby={\n props.assistiveText !== undefined ? describedbyId : undefined\n }\n disabled={props.disabled}\n onClick={() => {\n if (props.disabled === true) return\n setIsOpen(true)\n }}\n ref={triggerRef}\n type=\"button\"\n data-active={isOpen}\n >\n <span\n className=\"charcoal-ui-dropdown-selector-text\"\n data-placeholder={isPlaceholder}\n >\n {isPlaceholder ? props.placeholder : preview}\n </span>\n <Icon className=\"charcoal-ui-dropdown-selector-icon\" name=\"16/Menu\" />\n </button>\n {isOpen && (\n <DropdownPopover\n isOpen={isOpen}\n onClose={() => setIsOpen(false)}\n triggerRef={triggerRef}\n value={props.value}\n inertWorkaround={props.inertWorkaround}\n >\n <MenuList\n value={props.value}\n onChange={(v) => {\n onChange(v)\n setIsOpen(false)\n }}\n >\n {props.children}\n </MenuList>\n </DropdownPopover>\n )}\n {props.assistiveText !== undefined && (\n <AssistiveText data-invalid={props.invalid === true} id={describedbyId}>\n {props.assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAwBqC,iBAAiB,EACvCN,UACAR,YAAY,OACZU,WACA,GAAGK,SACqB;CACxB,MAAMC,aAAapC,OAA0B,KAAK;CAClD,MAAM,CAACsC,QAAQC,aAAaxC,SAAS,MAAM;CAC3C,MAAMyC,UAAUlC,qBAAqB6B,MAAMR,UAAUQ,MAAMlB,MAAM;CAEjE,MAAMwB,gBAAgBxC,cACdkC,MAAMhB,gBAAgBuB,UAAaF,YAAYE,QACrD,CAACF,SAASL,MAAMhB,YAClB,CAAC;CAED,MAAMwB,aAAalC,mBAAmB0B,MAAMR,SAAS;CACrD,MAAMiB,kBAAkB3C,cAChB0C,WAAWE,MAAMC,cAAcA,UAAU7B,UAAUkB,MAAMlB,MAAM,EACrE,CAAC0B,YAAYR,MAAMlB,MACrB,CAAC;CAED,MAAM,EAAE8B,wBAAwBlC,mBAAmB;CAEnD,MAAMmC,eAAe9C,aAClB+C,MAA4C;EAC3CrB,SAASqB,EAAEE,OAAOlC,MAAM;IAE1B,CAACW,SACH,CAAC;CAED,MAAMwB,UAAUtC,OAAO;CACvB,MAAMuC,gBAAgBvC,OAAO;CAO7B,OACE,qBAAC,OAAD;EAAK,WANYH,cACjB,mCACAwB,MAAMN,UAIoB;EAAE,iBAAeM,MAAMjB;YAAjD;GACE,oBAAC,YAAD;IACE,IAAIkC;IACJ,OAAOjB,MAAMnB;IACb,UAAUmB,MAAMZ;IAChB,cAAcY,MAAMX;IACpB,UAAUW,MAAMV;IAChB,GAAK,CAACL,YAAY2B,sBAAsB,EAAG;IAAC;GAE9C,oBAAC,OAAD;IAAK,GAAIA;IAAqB,eAAY;cACxC,qBAAC,UAAD;KACE,MAAMZ,MAAMT;KACZ,OAAOS,MAAMlB;KACb,UAAU+B;KACV,UAAU;KACV,KAAKlB;eALP,CAOG,CAACc,mBACA,oBAAC,UAAD;MAAQ,OAAOT,MAAMlB;gBAAQkB,MAAMlB;MACpC,GACA0B,WAAWY,KAAKT,cAAc;MAC7B,OACE,oBAAC,UAAD;OAEE,OAAOA,UAAU7B;OACjB,UAAU6B,UAAU5B;iBAEnB4B,UAAU7B;OACJ,EALF6B,UAAU7B,MAKR;OAEX,CACI;;IACL;GAEL,qBAAC,UAAD;IACE,WAAU;IACV,mBAAiBmC;IACjB,gBAAcjB,MAAMd;IACpB,oBACEc,MAAMb,kBAAkBoB,SAAYW,gBAAgBX;IAEtD,UAAUP,MAAMjB;IAChB,eAAe;KACb,IAAIiB,MAAMjB,aAAa,MAAM;KAC7BqB,UAAU,KAAK;;IAEjB,KAAKH;IACL,MAAK;IACL,eAAaE;cAdf,CAgBE,oBAAC,QAAD;KACE,WAAU;KACV,oBAAkBG;eAEjBA,gBAAgBN,MAAMhB,cAAcqB;KACjC,GACN,oBAAC,MAAD;KAAM,WAAU;KAAqC,MAAK;KAAS,EAC7D;;GACPF,UACC,oBAAC,iBAAD;IACUA;IACR,eAAeC,UAAU,MAAM;IACnBH;IACZ,OAAOD,MAAMlB;IACb,iBAAiBkB,MAAMqB;cAEvB,oBAAC,UAAD;KACE,OAAOrB,MAAMlB;KACb,WAAWwC,MAAM;MACf7B,SAAS6B,EAAE;MACXlB,UAAU,MAAM;;eAGjBJ,MAAMR;KACC;IAEb;GACAQ,MAAMb,kBAAkBoB,UACvB,oBAAC,eAAD;IAAe,gBAAcP,MAAMd,YAAY;IAAM,IAAIgC;cACtDlB,MAAMb;IAEV;GACG"}
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+ react = require_runtime.__toESM(react);
5
+
6
+ //#region src/components/DropdownSelector/utils/findPreviewRecursive.tsx
7
+ /**
8
+ * DropdownSelectorの選択中の要素をレンダリングするため、
9
+ * 選択中のMenuItemを再帰的に探索しReactNodeを返す。
10
+ *
11
+ * @param children
12
+ * @param value
13
+ * @param values
14
+ * @returns
15
+ */
16
+ function findPreviewRecursive(children, value) {
17
+ const childArray = react.Children.toArray(children);
18
+ for (let i = 0; i < childArray.length; i++) {
19
+ const child = childArray[i];
20
+ if (react.isValidElement(child)) {
21
+ if ("value" in child.props) {
22
+ if (child.props.value === value && "children" in child.props) return child.props.children;
23
+ }
24
+ if ("children" in child.props) {
25
+ const children = findPreviewRecursive(child.props.children, value);
26
+ if (children !== void 0) return children;
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ //#endregion
33
+ exports.findPreviewRecursive = findPreviewRecursive;
34
+ //# sourceMappingURL=findPreviewRecursive.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findPreviewRecursive.cjs","names":["ReactNode","React","findPreviewRecursive","children","value","childArray","Children","toArray","i","length","child","isValidElement","props","childValue","undefined"],"sources":["../../../../src/components/DropdownSelector/utils/findPreviewRecursive.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport * as React from 'react'\n\n/**\n * DropdownSelectorの選択中の要素をレンダリングするため、\n * 選択中のMenuItemを再帰的に探索しReactNodeを返す。\n *\n * @param children\n * @param value\n * @param values\n * @returns\n */\nexport function findPreviewRecursive(\n children: ReactNode,\n value: string,\n): ReactNode | undefined {\n const childArray = React.Children.toArray(children)\n for (let i = 0; i < childArray.length; i++) {\n const child = childArray[i]\n if (React.isValidElement(child)) {\n if ('value' in child.props) {\n const childValue = (child.props as { value: string }).value\n if (childValue === value && 'children' in child.props) {\n const children = (child.props as { children: ReactNode }).children\n return children\n }\n }\n if ('children' in child.props) {\n const children = findPreviewRecursive(\n (child.props as { children: ReactNode }).children,\n value,\n )\n if (children !== undefined) {\n return children\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgBE,qBACdC,UACAC,OACuB;CACvB,MAAMC,aAAaJ,MAAMK,SAASC,QAAQJ,SAAS;CACnD,KAAK,IAAIK,IAAI,GAAGA,IAAIH,WAAWI,QAAQD,KAAK;EAC1C,MAAME,QAAQL,WAAWG;EACzB,IAAIP,MAAMU,eAAeD,MAAM,EAAE;GAC/B,IAAI,WAAWA,MAAME,OAEnB;QADoBF,MAAME,MAA4BR,UACnCA,SAAS,cAAcM,MAAME,OAE9C,OADkBF,MAAME,MAAkCT;;GAI9D,IAAI,cAAcO,MAAME,OAAO;IAC7B,MAAMT,WAAWD,qBACdQ,MAAME,MAAkCT,UACzCC,MACD;IACD,IAAID,aAAaW,QACf,OAAOX"}
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/components/DropdownSelector/utils/findPreviewRecursive.tsx
5
+ /**
6
+ * DropdownSelectorの選択中の要素をレンダリングするため、
7
+ * 選択中のMenuItemを再帰的に探索しReactNodeを返す。
8
+ *
9
+ * @param children
10
+ * @param value
11
+ * @param values
12
+ * @returns
13
+ */
14
+ function findPreviewRecursive(children, value) {
15
+ const childArray = React$1.Children.toArray(children);
16
+ for (let i = 0; i < childArray.length; i++) {
17
+ const child = childArray[i];
18
+ if (React$1.isValidElement(child)) {
19
+ if ("value" in child.props) {
20
+ if (child.props.value === value && "children" in child.props) return child.props.children;
21
+ }
22
+ if ("children" in child.props) {
23
+ const children = findPreviewRecursive(child.props.children, value);
24
+ if (children !== void 0) return children;
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ //#endregion
31
+ export { findPreviewRecursive };
32
+ //# sourceMappingURL=findPreviewRecursive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findPreviewRecursive.js","names":["ReactNode","React","findPreviewRecursive","children","value","childArray","Children","toArray","i","length","child","isValidElement","props","childValue","undefined"],"sources":["../../../../src/components/DropdownSelector/utils/findPreviewRecursive.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport * as React from 'react'\n\n/**\n * DropdownSelectorの選択中の要素をレンダリングするため、\n * 選択中のMenuItemを再帰的に探索しReactNodeを返す。\n *\n * @param children\n * @param value\n * @param values\n * @returns\n */\nexport function findPreviewRecursive(\n children: ReactNode,\n value: string,\n): ReactNode | undefined {\n const childArray = React.Children.toArray(children)\n for (let i = 0; i < childArray.length; i++) {\n const child = childArray[i]\n if (React.isValidElement(child)) {\n if ('value' in child.props) {\n const childValue = (child.props as { value: string }).value\n if (childValue === value && 'children' in child.props) {\n const children = (child.props as { children: ReactNode }).children\n return children\n }\n }\n if ('children' in child.props) {\n const children = findPreviewRecursive(\n (child.props as { children: ReactNode }).children,\n value,\n )\n if (children !== undefined) {\n return children\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgBE,qBACdC,UACAC,OACuB;CACvB,MAAMC,aAAaJ,QAAMK,SAASC,QAAQJ,SAAS;CACnD,KAAK,IAAIK,IAAI,GAAGA,IAAIH,WAAWI,QAAQD,KAAK;EAC1C,MAAME,QAAQL,WAAWG;EACzB,IAAIP,QAAMU,eAAeD,MAAM,EAAE;GAC/B,IAAI,WAAWA,MAAME,OAEnB;QADoBF,MAAME,MAA4BR,UACnCA,SAAS,cAAcM,MAAME,OAE9C,OADkBF,MAAME,MAAkCT;;GAI9D,IAAI,cAAcO,MAAME,OAAO;IAC7B,MAAMT,WAAWD,qBACdQ,MAAME,MAAkCT,UACzCC,MACD;IACD,IAAID,aAAaW,QACf,OAAOX"}
@@ -0,0 +1,35 @@
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
+ react = require_runtime.__toESM(react);
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ //#region src/components/FieldLabel/index.tsx
10
+ const FieldLabel = react.forwardRef(function FieldLabel({ style, className, label, required = false, requiredText, subLabel, ...labelProps }, ref) {
11
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12
+ style,
13
+ className: require_useClassNames.useClassNames("charcoal-field-label-root", className),
14
+ children: [
15
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
16
+ ref,
17
+ className: "charcoal-field-label",
18
+ ...labelProps,
19
+ children: label
20
+ }),
21
+ required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
22
+ className: "charcoal-field-label-required-text",
23
+ children: requiredText
24
+ }),
25
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
26
+ className: "charcoal-field-label-sub-label",
27
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: subLabel })
28
+ })
29
+ ]
30
+ });
31
+ });
32
+
33
+ //#endregion
34
+ exports.default = FieldLabel;
35
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["React","useClassNames","FieldLabelProps","LabelHTMLAttributes","HTMLLabelElement","className","label","subLabel","ReactNode","required","requiredText","FieldLabel","forwardRef","style","labelProps","ref","classNames"],"sources":["../../../src/components/FieldLabel/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nimport './index.css'\n\nexport interface FieldLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n readonly className?: string\n readonly label: string\n readonly subLabel?: React.ReactNode\n readonly required?: boolean\n // TODO: 翻訳用のContextで注入する\n readonly requiredText?: string\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n function FieldLabel(\n {\n style,\n className,\n label,\n required = false,\n requiredText,\n subLabel,\n ...labelProps\n },\n ref,\n ) {\n const classNames = useClassNames('charcoal-field-label-root', className)\n return (\n <div style={style} className={classNames}>\n <label ref={ref} className=\"charcoal-field-label\" {...labelProps}>\n {label}\n </label>\n {required && (\n <div className=\"charcoal-field-label-required-text\">\n {requiredText}\n </div>\n )}\n <div className=\"charcoal-field-label-sub-label\">\n <span>{subLabel}</span>\n </div>\n </div>\n )\n },\n)\n\nexport default FieldLabel\n"],"mappings":";;;;;;;;;AAeA,MAAMW,aAAaX,MAAMY,WACvB,SAASD,WACP,EACEE,OACAR,WACAC,OACAG,WAAW,OACXC,cACAH,UACA,GAAGO,cAELC,KACA;CAEA,OACE,4CAAC,OAAD;EAAYF;EAAO,WAFFZ,oCAAc,6BAA6BI,UAEpB;YAAxC;GACE,2CAAC,SAAD;IAAYU;IAAK,WAAU;IAAuB,GAAID;cACnDR;IACI;GACNG,YACC,2CAAC,OAAD;IAAK,WAAU;cACZC;IAEJ;GACD,2CAAC,OAAD;IAAK,WAAU;cACb,2CAAC,QAAD,YAAOH,UAAe;IACnB;GACD;;EAGX"}
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import * as React$1 from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+
7
+ //#region src/components/FieldLabel/index.tsx
8
+ const FieldLabel = React$1.forwardRef(function FieldLabel({ style, className, label, required = false, requiredText, subLabel, ...labelProps }, ref) {
9
+ return /* @__PURE__ */ jsxs("div", {
10
+ style,
11
+ className: useClassNames("charcoal-field-label-root", className),
12
+ children: [
13
+ /* @__PURE__ */ jsx("label", {
14
+ ref,
15
+ className: "charcoal-field-label",
16
+ ...labelProps,
17
+ children: label
18
+ }),
19
+ required && /* @__PURE__ */ jsx("div", {
20
+ className: "charcoal-field-label-required-text",
21
+ children: requiredText
22
+ }),
23
+ /* @__PURE__ */ jsx("div", {
24
+ className: "charcoal-field-label-sub-label",
25
+ children: /* @__PURE__ */ jsx("span", { children: subLabel })
26
+ })
27
+ ]
28
+ });
29
+ });
30
+
31
+ //#endregion
32
+ export { FieldLabel as default };
33
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["React","useClassNames","FieldLabelProps","LabelHTMLAttributes","HTMLLabelElement","className","label","subLabel","ReactNode","required","requiredText","FieldLabel","forwardRef","style","labelProps","ref","classNames"],"sources":["../../../src/components/FieldLabel/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nimport './index.css'\n\nexport interface FieldLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n readonly className?: string\n readonly label: string\n readonly subLabel?: React.ReactNode\n readonly required?: boolean\n // TODO: 翻訳用のContextで注入する\n readonly requiredText?: string\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n function FieldLabel(\n {\n style,\n className,\n label,\n required = false,\n requiredText,\n subLabel,\n ...labelProps\n },\n ref,\n ) {\n const classNames = useClassNames('charcoal-field-label-root', className)\n return (\n <div style={style} className={classNames}>\n <label ref={ref} className=\"charcoal-field-label\" {...labelProps}>\n {label}\n </label>\n {required && (\n <div className=\"charcoal-field-label-required-text\">\n {requiredText}\n </div>\n )}\n <div className=\"charcoal-field-label-sub-label\">\n <span>{subLabel}</span>\n </div>\n </div>\n )\n },\n)\n\nexport default FieldLabel\n"],"mappings":";;;;;;;AAeA,MAAMW,aAAaX,QAAMY,WACvB,SAASD,WACP,EACEE,OACAR,WACAC,OACAG,WAAW,OACXC,cACAH,UACA,GAAGO,cAELC,KACA;CAEA,OACE,qBAAC,OAAD;EAAYF;EAAO,WAFFZ,cAAc,6BAA6BI,UAEpB;YAAxC;GACE,oBAAC,SAAD;IAAYU;IAAK,WAAU;IAAuB,GAAID;cACnDR;IACI;GACNG,YACC,oBAAC,OAAD;IAAK,WAAU;cACZC;IAEJ;GACD,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,QAAD,YAAOH,UAAe;IACnB;GACD;;EAGX"}
@@ -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
+ const require_index = require('../Icon/index.cjs');
5
+ require('./index.cjs');
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/components/HintText/index.tsx
9
+ function HintText({ children, context = "section", className }) {
10
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11
+ className: require_useClassNames.useClassNames("charcoal-hint-text", className),
12
+ "data-context": context,
13
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14
+ className: "charcoal-hint-text-icon",
15
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, { name: "16/Info" })
16
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
17
+ className: "charcoal-hint-text-message",
18
+ children
19
+ })]
20
+ });
21
+ }
22
+
23
+ //#endregion
24
+ exports.default = HintText;
25
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["ReactNode","Icon","useClassNames","HintTextContext","HintTextProps","children","context","className","HintText","classNames"],"sources":["../../../src/components/HintText/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport Icon from '../Icon'\n\nimport './index.css'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nexport type HintTextContext = 'page' | 'section'\nexport interface HintTextProps {\n children: ReactNode\n context?: HintTextContext\n className?: string\n}\n\nexport default function HintText({\n children,\n context = 'section',\n className,\n}: HintTextProps) {\n const classNames = useClassNames('charcoal-hint-text', className)\n\n return (\n <div className={classNames} data-context={context}>\n <div className=\"charcoal-hint-text-icon\">\n <Icon name=\"16/Info\" />\n </div>\n <p className=\"charcoal-hint-text-message\">{children}</p>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAaA,SAAwBQ,SAAS,EAC/BH,UACAC,UAAU,WACVC,aACgB;CAGhB,OACE,4CAAC,OAAD;EAAK,WAHYL,oCAAc,sBAAsBK,UAG3B;EAAE,gBAAcD;YAA1C,CACE,2CAAC,OAAD;GAAK,WAAU;aACb,2CAAC,uBAAD,EAAM,MAAK,WAAS;GACjB,GACL,2CAAC,KAAD;GAAG,WAAU;GAA8BD;GAAY,EACnD"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ import Icon from "../Icon/index.js";
4
+ /* empty css */
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+
7
+ //#region src/components/HintText/index.tsx
8
+ function HintText({ children, context = "section", className }) {
9
+ return /* @__PURE__ */ jsxs("div", {
10
+ className: useClassNames("charcoal-hint-text", className),
11
+ "data-context": context,
12
+ children: [/* @__PURE__ */ jsx("div", {
13
+ className: "charcoal-hint-text-icon",
14
+ children: /* @__PURE__ */ jsx(Icon, { name: "16/Info" })
15
+ }), /* @__PURE__ */ jsx("p", {
16
+ className: "charcoal-hint-text-message",
17
+ children
18
+ })]
19
+ });
20
+ }
21
+
22
+ //#endregion
23
+ export { HintText as default };
24
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["ReactNode","Icon","useClassNames","HintTextContext","HintTextProps","children","context","className","HintText","classNames"],"sources":["../../../src/components/HintText/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport Icon from '../Icon'\n\nimport './index.css'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nexport type HintTextContext = 'page' | 'section'\nexport interface HintTextProps {\n children: ReactNode\n context?: HintTextContext\n className?: string\n}\n\nexport default function HintText({\n children,\n context = 'section',\n className,\n}: HintTextProps) {\n const classNames = useClassNames('charcoal-hint-text', className)\n\n return (\n <div className={classNames} data-context={context}>\n <div className=\"charcoal-hint-text-icon\">\n <Icon name=\"16/Info\" />\n </div>\n <p className=\"charcoal-hint-text-message\">{children}</p>\n </div>\n )\n}\n"],"mappings":";;;;;;;AAaA,SAAwBQ,SAAS,EAC/BH,UACAC,UAAU,WACVC,aACgB;CAGhB,OACE,qBAAC,OAAD;EAAK,WAHYL,cAAc,sBAAsBK,UAG3B;EAAE,gBAAcD;YAA1C,CACE,oBAAC,OAAD;GAAK,WAAU;aACb,oBAAC,MAAD,EAAM,MAAK,WAAS;GACjB,GACL,oBAAC,KAAD;GAAG,WAAU;GAA8BD;GAAY,EACnD"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ require('../../icons/css/icon.cjs');
4
+ let react = require("react");
5
+ react = require_runtime.__toESM(react);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let _charcoal_ui_icons = require("@charcoal-ui/icons");
8
+
9
+ //#region src/components/Icon/index.tsx
10
+ const Icon = react.forwardRef(function IconInner({ name, scale, unsafeNonGuidelineScale, fixedSize, className, style: userStyle, ...rest }, ref) {
11
+ const actualSize = react.useMemo(() => (0, _charcoal_ui_icons.calcActualSize)({
12
+ name,
13
+ scale,
14
+ unsafeNonGuidelineScale,
15
+ fixedSize
16
+ }), [
17
+ name,
18
+ scale,
19
+ unsafeNonGuidelineScale,
20
+ fixedSize
21
+ ]);
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pixiv-icon", {
23
+ ref,
24
+ name,
25
+ scale,
26
+ "unsafe-non-guideline-scale": unsafeNonGuidelineScale,
27
+ "fixed-size": fixedSize,
28
+ style: react.useMemo(() => ({
29
+ ...userStyle,
30
+ "--charcoal-icon-size": `${actualSize}px`
31
+ }), [actualSize, userStyle]),
32
+ class: `charcoal-icon ${className || ""}`.trim(),
33
+ ...rest
34
+ });
35
+ });
36
+
37
+ //#endregion
38
+ exports.default = Icon;
39
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["React","calcActualSize","IconSizing","PixivIcon","Props","OwnProps","unsafeNonGuidelineScale","fixedSize","className","IconProps","PropsWithoutRef","Omit","Icon","forwardRef","IconInner","name","scale","style","userStyle","rest","ref","actualSize","useMemo","CSSProperties","trim"],"sources":["../../../src/components/Icon/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport '@charcoal-ui/icons'\n// tmp fix for https://github.com/rolldown/tsdown/pull/981\nimport '../../../../icons/css/icon.css'\nimport { calcActualSize } from '@charcoal-ui/icons'\nimport type { IconSizing, PixivIcon, Props } from '@charcoal-ui/icons'\n\nexport interface OwnProps {\n /**\n * @deprecated `fixedSize` を利用してください。\n * `attr()` の数値解釈サポートが限定的なため、リセット CSS だけではレイアウトシフトが防げません。\n */\n unsafeNonGuidelineScale?: number\n /**\n * 固定 px サイズで描画します。ガイドライン外のサイズを利用する場合に推奨される指定方法で、\n * 他のサイズ指定 (`scale` / `unsafeNonGuidelineScale`) よりも常に優先されます。\n *\n * `<Icon>` は同じ値を `--charcoal-icon-size` インライン CSS 変数として自動付与するため、\n * Web Component の hydrate 前後でレイアウトシフトは発生しません。\n */\n fixedSize?: number\n className?: string\n}\n\nexport interface IconProps\n extends OwnProps,\n React.PropsWithoutRef<\n Omit<Props, 'class' | 'unsafe-non-guideline-scale' | 'fixed-size' | 'css'>\n > {}\n\nconst Icon = React.forwardRef<PixivIcon, IconProps>(function IconInner(\n {\n name,\n scale,\n unsafeNonGuidelineScale,\n fixedSize,\n className,\n style: userStyle,\n ...rest\n },\n ref,\n) {\n const actualSize = React.useMemo(\n // IconSizing の排他制約は IconProps の型レベルで保証されるため、内部では緩和する\n () =>\n calcActualSize({\n name,\n scale,\n unsafeNonGuidelineScale,\n fixedSize,\n } as { name: string } & IconSizing),\n [name, scale, unsafeNonGuidelineScale, fixedSize],\n )\n\n const style = React.useMemo(\n () =>\n ({\n ...userStyle,\n '--charcoal-icon-size': `${actualSize}px`,\n }) as React.CSSProperties,\n [actualSize, userStyle],\n )\n\n return (\n <pixiv-icon\n ref={ref}\n name={name}\n scale={scale}\n unsafe-non-guideline-scale={unsafeNonGuidelineScale}\n fixed-size={fixedSize}\n style={style}\n class={`charcoal-icon ${className || ''}`.trim()}\n {...rest}\n />\n )\n})\n\nexport default Icon\n"],"mappings":";;;;;;;;;AA+BA,MAAMY,OAAOZ,MAAMa,WAAiC,SAASC,UAC3D,EACEC,MACAC,OACAV,yBACAC,WACAC,WACAS,OAAOC,WACP,GAAGC,QAELC,KACA;CACA,MAAMC,aAAarB,MAAMsB,qDAGN;EACbP;EACAC;EACAV;EACAC;EACD,CAAkC,EACrC;EAACQ;EAAMC;EAAOV;EAAyBC;EACzC,CAAC;CAWD,OACE,2CAAC,cAAD;EACOa;EACCL;EACCC;EACP,8BAA4BV;EAC5B,cAAYC;EACZ,OAhBUP,MAAMsB,eAEf;GACC,GAAGJ;GACH,wBAAwB,GAAGG,WAAU;GACtC,GACH,CAACA,YAAYH,UACf,CASgB;EACZ,OAAO,iBAAiBV,aAAa,KAAKgB,MAAM;EAChD,GAAIL;EACJ;EAEJ"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ /* empty css */
3
+ import * as React$1 from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { calcActualSize } from "@charcoal-ui/icons";
6
+
7
+ //#region src/components/Icon/index.tsx
8
+ const Icon = React$1.forwardRef(function IconInner({ name, scale, unsafeNonGuidelineScale, fixedSize, className, style: userStyle, ...rest }, ref) {
9
+ const actualSize = React$1.useMemo(() => calcActualSize({
10
+ name,
11
+ scale,
12
+ unsafeNonGuidelineScale,
13
+ fixedSize
14
+ }), [
15
+ name,
16
+ scale,
17
+ unsafeNonGuidelineScale,
18
+ fixedSize
19
+ ]);
20
+ return /* @__PURE__ */ jsx("pixiv-icon", {
21
+ ref,
22
+ name,
23
+ scale,
24
+ "unsafe-non-guideline-scale": unsafeNonGuidelineScale,
25
+ "fixed-size": fixedSize,
26
+ style: React$1.useMemo(() => ({
27
+ ...userStyle,
28
+ "--charcoal-icon-size": `${actualSize}px`
29
+ }), [actualSize, userStyle]),
30
+ class: `charcoal-icon ${className || ""}`.trim(),
31
+ ...rest
32
+ });
33
+ });
34
+
35
+ //#endregion
36
+ export { Icon as default };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["React","calcActualSize","IconSizing","PixivIcon","Props","OwnProps","unsafeNonGuidelineScale","fixedSize","className","IconProps","PropsWithoutRef","Omit","Icon","forwardRef","IconInner","name","scale","style","userStyle","rest","ref","actualSize","useMemo","CSSProperties","trim"],"sources":["../../../src/components/Icon/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport '@charcoal-ui/icons'\n// tmp fix for https://github.com/rolldown/tsdown/pull/981\nimport '../../../../icons/css/icon.css'\nimport { calcActualSize } from '@charcoal-ui/icons'\nimport type { IconSizing, PixivIcon, Props } from '@charcoal-ui/icons'\n\nexport interface OwnProps {\n /**\n * @deprecated `fixedSize` を利用してください。\n * `attr()` の数値解釈サポートが限定的なため、リセット CSS だけではレイアウトシフトが防げません。\n */\n unsafeNonGuidelineScale?: number\n /**\n * 固定 px サイズで描画します。ガイドライン外のサイズを利用する場合に推奨される指定方法で、\n * 他のサイズ指定 (`scale` / `unsafeNonGuidelineScale`) よりも常に優先されます。\n *\n * `<Icon>` は同じ値を `--charcoal-icon-size` インライン CSS 変数として自動付与するため、\n * Web Component の hydrate 前後でレイアウトシフトは発生しません。\n */\n fixedSize?: number\n className?: string\n}\n\nexport interface IconProps\n extends OwnProps,\n React.PropsWithoutRef<\n Omit<Props, 'class' | 'unsafe-non-guideline-scale' | 'fixed-size' | 'css'>\n > {}\n\nconst Icon = React.forwardRef<PixivIcon, IconProps>(function IconInner(\n {\n name,\n scale,\n unsafeNonGuidelineScale,\n fixedSize,\n className,\n style: userStyle,\n ...rest\n },\n ref,\n) {\n const actualSize = React.useMemo(\n // IconSizing の排他制約は IconProps の型レベルで保証されるため、内部では緩和する\n () =>\n calcActualSize({\n name,\n scale,\n unsafeNonGuidelineScale,\n fixedSize,\n } as { name: string } & IconSizing),\n [name, scale, unsafeNonGuidelineScale, fixedSize],\n )\n\n const style = React.useMemo(\n () =>\n ({\n ...userStyle,\n '--charcoal-icon-size': `${actualSize}px`,\n }) as React.CSSProperties,\n [actualSize, userStyle],\n )\n\n return (\n <pixiv-icon\n ref={ref}\n name={name}\n scale={scale}\n unsafe-non-guideline-scale={unsafeNonGuidelineScale}\n fixed-size={fixedSize}\n style={style}\n class={`charcoal-icon ${className || ''}`.trim()}\n {...rest}\n />\n )\n})\n\nexport default Icon\n"],"mappings":";;;;;;;AA+BA,MAAMY,OAAOZ,QAAMa,WAAiC,SAASC,UAC3D,EACEC,MACAC,OACAV,yBACAC,WACAC,WACAS,OAAOC,WACP,GAAGC,QAELC,KACA;CACA,MAAMC,aAAarB,QAAMsB,cAGrBrB,eAAe;EACbc;EACAC;EACAV;EACAC;EACD,CAAkC,EACrC;EAACQ;EAAMC;EAAOV;EAAyBC;EACzC,CAAC;CAWD,OACE,oBAAC,cAAD;EACOa;EACCL;EACCC;EACP,8BAA4BV;EAC5B,cAAYC;EACZ,OAhBUP,QAAMsB,eAEf;GACC,GAAGJ;GACH,wBAAwB,GAAGG,WAAU;GACtC,GACH,CAACA,YAAYH,UACf,CASgB;EACZ,OAAO,iBAAiBV,aAAa,KAAKgB,MAAM;EAChD,GAAIL;EACJ;EAEJ"}
@@ -0,0 +1,46 @@
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
+ react = require_runtime.__toESM(react);
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ //#region src/components/IconButton/index.tsx
10
+ const IconButton = (0, react.forwardRef)(function IconButtonInner({ variant = "Default", size = "M", icon, isActive = false, component, ...rest }, ref) {
11
+ validateIconSize(size, icon);
12
+ const Component = (0, react.useMemo)(() => component ?? "button", [component]);
13
+ const classNames = require_useClassNames.useClassNames("charcoal-icon-button", rest.className);
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
15
+ ...rest,
16
+ ref,
17
+ className: classNames,
18
+ "data-size": size,
19
+ "data-active": isActive,
20
+ "data-variant": variant,
21
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pixiv-icon", { name: icon })
22
+ });
23
+ });
24
+ /**
25
+ * validates matches of size and icon
26
+ */
27
+ function validateIconSize(size, icon) {
28
+ let requiredIconSize;
29
+ switch (size) {
30
+ case "XS":
31
+ requiredIconSize = "16";
32
+ break;
33
+ case "S":
34
+ case "M":
35
+ requiredIconSize = "24";
36
+ break;
37
+ }
38
+ const result = /^\d*/u.exec(icon);
39
+ if (result == null) throw new Error("Invalid icon name");
40
+ const [iconSize] = result;
41
+ if (iconSize !== requiredIconSize) console.warn(`IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"`);
42
+ }
43
+
44
+ //#endregion
45
+ exports.default = IconButton;
46
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["React","ForwardedRef","forwardRef","useMemo","JSX","useClassNames","KnownIconType","Variant","Size","IconButtonProps","ElementType","variant","size","icon","isActive","component","T","Omit","ComponentPropsWithRef","IconButton","HTMLButtonElement","IconButtonInner","rest","ref","validateIconSize","Component","classNames","className","p","Element","requiredIconSize","result","exec","Error","iconSize","console","warn"],"sources":["../../../src/components/IconButton/index.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, useMemo, type JSX } from 'react'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport type { KnownIconType } from '@charcoal-ui/icons'\n\nimport './index.css'\n\ntype Variant = 'Default' | 'Overlay'\ntype Size = 'XS' | 'S' | 'M'\n\nexport type IconButtonProps<T extends React.ElementType = 'button'> = {\n readonly variant?: Variant\n readonly size?: Size\n readonly icon: keyof KnownIconType\n readonly isActive?: boolean\n component?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>\n\nconst IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n function IconButtonInner<T extends React.ElementType>(\n {\n variant = 'Default',\n size = 'M',\n icon,\n isActive = false,\n component,\n ...rest\n }: IconButtonProps<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n ) {\n validateIconSize(size, icon)\n const Component = useMemo(() => component ?? 'button', [component])\n const classNames = useClassNames('charcoal-icon-button', rest.className)\n\n return (\n <Component\n {...rest}\n ref={ref}\n className={classNames}\n data-size={size}\n data-active={isActive}\n data-variant={variant}\n >\n <pixiv-icon name={icon} />\n </Component>\n )\n },\n) as <T extends React.ElementType = 'button'>(\n p: IconButtonProps<T>,\n) => JSX.Element\n\nexport default IconButton\n\n/**\n * validates matches of size and icon\n */\nfunction validateIconSize(size: Size, icon: keyof KnownIconType) {\n let requiredIconSize: string\n switch (size) {\n case 'XS':\n requiredIconSize = '16'\n break\n case 'S':\n case 'M':\n requiredIconSize = '24'\n break\n }\n // アイコン名は サイズ/名前\n const result = /^\\d*/u.exec(icon)\n if (result == null) {\n throw new Error('Invalid icon name')\n }\n const [iconSize] = result\n if (iconSize !== requiredIconSize) {\n // eslint-disable-next-line no-console\n console.warn(\n `IconButton with size \"${size}\" expect icon size \"${requiredIconSize}, but got \"${iconSize}\"`,\n )\n }\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAMmB,mCACJ,SAASE,gBACP,EACEV,UAAU,WACVC,OAAO,KACPC,MACAC,WAAW,OACXC,WACA,GAAGO,QAELC,KACA;CACAC,iBAAiBZ,MAAMC,KAAK;CAC5B,MAAMY,qCAA0BV,aAAa,UAAU,CAACA,UAAU,CAAC;CACnE,MAAMW,aAAarB,oCAAc,wBAAwBiB,KAAKK,UAAU;CAExE,OACE,2CAAC,WAAD;EACE,GAAIL;EACCC;EACL,WAAWG;EACX,aAAWd;EACX,eAAaE;EACb,gBAAcH;YAEd,2CAAC,cAAD,EAAY,MAAME,MAAK;EACb;EAGjB;;;;AASD,SAASW,iBAAiBZ,MAAYC,MAA2B;CAC/D,IAAIiB;CACJ,QAAQlB,MAAR;EACE,KAAK;GACHkB,mBAAmB;GACnB;EACF,KAAK;EACL,KAAK;GACHA,mBAAmB;GACnB;;CAGJ,MAAMC,SAAS,QAAQC,KAAKnB,KAAK;CACjC,IAAIkB,UAAU,MACZ,MAAM,IAAIE,MAAM,oBAAoB;CAEtC,MAAM,CAACC,YAAYH;CACnB,IAAIG,aAAaJ,kBAEfK,QAAQC,KACN,yBAAyBxB,KAAI,sBAAuBkB,iBAAgB,aAAcI,SAAQ,GAC3F"}
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { useClassNames } from "../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import React, { forwardRef, useMemo } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/IconButton/index.tsx
8
+ const IconButton = forwardRef(function IconButtonInner({ variant = "Default", size = "M", icon, isActive = false, component, ...rest }, ref) {
9
+ validateIconSize(size, icon);
10
+ const Component = useMemo(() => component ?? "button", [component]);
11
+ const classNames = useClassNames("charcoal-icon-button", rest.className);
12
+ return /* @__PURE__ */ jsx(Component, {
13
+ ...rest,
14
+ ref,
15
+ className: classNames,
16
+ "data-size": size,
17
+ "data-active": isActive,
18
+ "data-variant": variant,
19
+ children: /* @__PURE__ */ jsx("pixiv-icon", { name: icon })
20
+ });
21
+ });
22
+ /**
23
+ * validates matches of size and icon
24
+ */
25
+ function validateIconSize(size, icon) {
26
+ let requiredIconSize;
27
+ switch (size) {
28
+ case "XS":
29
+ requiredIconSize = "16";
30
+ break;
31
+ case "S":
32
+ case "M":
33
+ requiredIconSize = "24";
34
+ break;
35
+ }
36
+ const result = /^\d*/u.exec(icon);
37
+ if (result == null) throw new Error("Invalid icon name");
38
+ const [iconSize] = result;
39
+ if (iconSize !== requiredIconSize) console.warn(`IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"`);
40
+ }
41
+
42
+ //#endregion
43
+ export { IconButton as default };
44
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["React","ForwardedRef","forwardRef","useMemo","JSX","useClassNames","KnownIconType","Variant","Size","IconButtonProps","ElementType","variant","size","icon","isActive","component","T","Omit","ComponentPropsWithRef","IconButton","HTMLButtonElement","IconButtonInner","rest","ref","validateIconSize","Component","classNames","className","p","Element","requiredIconSize","result","exec","Error","iconSize","console","warn"],"sources":["../../../src/components/IconButton/index.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, useMemo, type JSX } from 'react'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport type { KnownIconType } from '@charcoal-ui/icons'\n\nimport './index.css'\n\ntype Variant = 'Default' | 'Overlay'\ntype Size = 'XS' | 'S' | 'M'\n\nexport type IconButtonProps<T extends React.ElementType = 'button'> = {\n readonly variant?: Variant\n readonly size?: Size\n readonly icon: keyof KnownIconType\n readonly isActive?: boolean\n component?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>\n\nconst IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n function IconButtonInner<T extends React.ElementType>(\n {\n variant = 'Default',\n size = 'M',\n icon,\n isActive = false,\n component,\n ...rest\n }: IconButtonProps<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n ) {\n validateIconSize(size, icon)\n const Component = useMemo(() => component ?? 'button', [component])\n const classNames = useClassNames('charcoal-icon-button', rest.className)\n\n return (\n <Component\n {...rest}\n ref={ref}\n className={classNames}\n data-size={size}\n data-active={isActive}\n data-variant={variant}\n >\n <pixiv-icon name={icon} />\n </Component>\n )\n },\n) as <T extends React.ElementType = 'button'>(\n p: IconButtonProps<T>,\n) => JSX.Element\n\nexport default IconButton\n\n/**\n * validates matches of size and icon\n */\nfunction validateIconSize(size: Size, icon: keyof KnownIconType) {\n let requiredIconSize: string\n switch (size) {\n case 'XS':\n requiredIconSize = '16'\n break\n case 'S':\n case 'M':\n requiredIconSize = '24'\n break\n }\n // アイコン名は サイズ/名前\n const result = /^\\d*/u.exec(icon)\n if (result == null) {\n throw new Error('Invalid icon name')\n }\n const [iconSize] = result\n if (iconSize !== requiredIconSize) {\n // eslint-disable-next-line no-console\n console.warn(\n `IconButton with size \"${size}\" expect icon size \"${requiredIconSize}, but got \"${iconSize}\"`,\n )\n }\n}\n"],"mappings":";;;;;;;AAiBA,MAAMmB,aAAajB,WACjB,SAASmB,gBACP,EACEV,UAAU,WACVC,OAAO,KACPC,MACAC,WAAW,OACXC,WACA,GAAGO,QAELC,KACA;CACAC,iBAAiBZ,MAAMC,KAAK;CAC5B,MAAMY,YAAYtB,cAAcY,aAAa,UAAU,CAACA,UAAU,CAAC;CACnE,MAAMW,aAAarB,cAAc,wBAAwBiB,KAAKK,UAAU;CAExE,OACE,oBAAC,WAAD;EACE,GAAIL;EACCC;EACL,WAAWG;EACX,aAAWd;EACX,eAAaE;EACb,gBAAcH;YAEd,oBAAC,cAAD,EAAY,MAAME,MAAK;EACb;EAGjB;;;;AASD,SAASW,iBAAiBZ,MAAYC,MAA2B;CAC/D,IAAIiB;CACJ,QAAQlB,MAAR;EACE,KAAK;GACHkB,mBAAmB;GACnB;EACF,KAAK;EACL,KAAK;GACHA,mBAAmB;GACnB;;CAGJ,MAAMC,SAAS,QAAQC,KAAKnB,KAAK;CACjC,IAAIkB,UAAU,MACZ,MAAM,IAAIE,MAAM,oBAAoB;CAEtC,MAAM,CAACC,YAAYH;CACnB,IAAIG,aAAaJ,kBAEfK,QAAQC,KACN,yBAAyBxB,KAAI,sBAAuBkB,iBAAgB,aAAcI,SAAQ,GAC3F"}
@@ -0,0 +1,43 @@
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/LoadingSpinner/index.tsx
9
+ const LoadingSpinner = (0, react.forwardRef)(function LoadingSpinnerInner({ size = 48, padding = 16, transparent = false, ...props }, ref) {
10
+ const classNames = require_useClassNames.useClassNames("charcoal-loading-spinner", props.className);
11
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12
+ role: "progressbar",
13
+ style: {
14
+ "--charcoal-loading-spinner-size": `${size}px`,
15
+ "--charcoal-loading-spinner-padding": `${padding}px`
16
+ },
17
+ "data-transparent": transparent,
18
+ className: classNames,
19
+ ref,
20
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LoadingSpinnerIcon, {})
21
+ });
22
+ });
23
+ var LoadingSpinner_default = (0, react.memo)(LoadingSpinner);
24
+ const LoadingSpinnerIcon = (0, react.forwardRef)(function LoadingSpinnerIcon({ once = false }, ref) {
25
+ const iconRef = (0, react.useRef)(null);
26
+ (0, react.useImperativeHandle)(ref, () => ({ restart: () => {
27
+ if (!iconRef.current) return;
28
+ iconRef.current.dataset.resetAnimation = "true";
29
+ iconRef.current.offsetWidth;
30
+ delete iconRef.current.dataset.resetAnimation;
31
+ } }));
32
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
33
+ role: "presentation",
34
+ ref: iconRef,
35
+ "data-once": once,
36
+ className: "charcoal-loading-spinner-icon"
37
+ });
38
+ });
39
+
40
+ //#endregion
41
+ exports.LoadingSpinnerIcon = LoadingSpinnerIcon;
42
+ exports.default = LoadingSpinner_default;
43
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["forwardRef","useImperativeHandle","useRef","memo","useClassNames","LoadingSpinnerProps","size","padding","transparent","className","LoadingSpinner","HTMLDivElement","LoadingSpinnerInner","props","ref","classNames","Props","once","LoadingSpinnerIconHandler","restart","LoadingSpinnerIcon","iconRef","current","dataset","resetAnimation","offsetWidth"],"sources":["../../../src/components/LoadingSpinner/index.tsx"],"sourcesContent":["import { forwardRef, useImperativeHandle, useRef, memo } from 'react'\nimport { useClassNames } from '../../_lib/useClassNames'\n\nimport './index.css'\n\nexport type LoadingSpinnerProps = {\n readonly size?: number\n readonly padding?: number\n readonly transparent?: boolean\n readonly className?: string\n}\n\nconst LoadingSpinner = forwardRef<HTMLDivElement, LoadingSpinnerProps>(\n function LoadingSpinnerInner(\n { size = 48, padding = 16, transparent = false, ...props },\n ref,\n ) {\n const classNames = useClassNames(\n 'charcoal-loading-spinner',\n props.className,\n )\n\n return (\n <div\n role=\"progressbar\"\n style={{\n '--charcoal-loading-spinner-size': `${size}px`,\n '--charcoal-loading-spinner-padding': `${padding}px`,\n }}\n data-transparent={transparent}\n className={classNames}\n ref={ref}\n >\n <LoadingSpinnerIcon />\n </div>\n )\n },\n)\n\nexport default memo(LoadingSpinner)\n\ntype Props = {\n once?: boolean\n}\n\nexport interface LoadingSpinnerIconHandler {\n restart(): void\n}\n\nexport const LoadingSpinnerIcon = forwardRef<LoadingSpinnerIconHandler, Props>(\n function LoadingSpinnerIcon({ once = false }, ref) {\n const iconRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(ref, () => ({\n restart: () => {\n if (!iconRef.current) {\n return\n }\n iconRef.current.dataset.resetAnimation = 'true'\n // Force reflow hack!\n void iconRef.current.offsetWidth\n delete iconRef.current.dataset.resetAnimation\n },\n }))\n\n return (\n <div\n role=\"presentation\"\n ref={iconRef}\n data-once={once}\n className=\"charcoal-loading-spinner-icon\"\n />\n )\n },\n)\n"],"mappings":";;;;;;;;AAYA,MAAMU,uCACJ,SAASE,oBACP,EAAEN,OAAO,IAAIC,UAAU,IAAIC,cAAc,OAAO,GAAGK,SACnDC,KACA;CACA,MAAMC,aAAaX,oCACjB,4BACAS,MAAMJ,UACP;CAED,OACE,2CAAC,OAAD;EACE,MAAK;EACL,OAAO;GACL,mCAAmC,GAAGH,KAAI;GAC1C,sCAAsC,GAAGC,QAAO;GACjD;EACD,oBAAkBC;EAClB,WAAWO;EACND;YAEL,2CAAC,oBAAD,EAAmB;EACf;EAGX;AAED,6CAAoBJ,eAAe;AAUnC,MAAaU,2CACX,SAASA,mBAAmB,EAAEH,OAAO,SAASH,KAAK;CACjD,MAAMO,4BAAiC,KAAK;CAE5CpB,+BAAoBa,YAAY,EAC9BK,eAAe;EACb,IAAI,CAACE,QAAQC,SACX;EAEFD,QAAQC,QAAQC,QAAQC,iBAAiB;EAEzC,AAAKH,QAAQC,QAAQG;EACrB,OAAOJ,QAAQC,QAAQC,QAAQC;IAElC,EAAE;CAEH,OACE,2CAAC,OAAD;EACE,MAAK;EACL,KAAKH;EACL,aAAWJ;EACX,WAAU;EACV;EAGP"}