@charcoal-ui/react 6.0.0-rc.9 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/dist/_lib/compat.d.ts.map +1 -1
  2. package/dist/_lib/createDivComponent.cjs +0 -1
  3. package/dist/_lib/createDivComponent.cjs.map +1 -1
  4. package/dist/_lib/createDivComponent.d.ts +1 -1
  5. package/dist/_lib/createDivComponent.js.map +1 -1
  6. package/dist/_lib/index.cjs.map +1 -1
  7. package/dist/_lib/index.js.map +1 -1
  8. package/dist/_lib/useClassNames.cjs +0 -1
  9. package/dist/_lib/useClassNames.cjs.map +1 -1
  10. package/dist/_lib/useClassNames.js.map +1 -1
  11. package/dist/_lib/useForwardedRef.cjs +1 -1
  12. package/dist/_lib/useForwardedRef.cjs.map +1 -1
  13. package/dist/_lib/useForwardedRef.js.map +1 -1
  14. package/dist/_lib/useIsomorphicLayoutEffect.cjs +0 -1
  15. package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -1
  16. package/dist/_lib/useIsomorphicLayoutEffect.d.ts +2 -2
  17. package/dist/_lib/useIsomorphicLayoutEffect.d.ts.map +1 -1
  18. package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -1
  19. package/dist/components/Button/index.d.ts +1 -1
  20. package/dist/components/Button/index.d.ts.map +1 -1
  21. package/dist/components/Button/index2.cjs +1 -1
  22. package/dist/components/Button/index2.cjs.map +1 -1
  23. package/dist/components/Button/index2.js.map +1 -1
  24. package/dist/components/Carousel/CarouselItem.cjs +0 -1
  25. package/dist/components/Carousel/CarouselItem.cjs.map +1 -1
  26. package/dist/components/Carousel/CarouselItem.d.ts.map +1 -1
  27. package/dist/components/Carousel/CarouselItem.js.map +1 -1
  28. package/dist/components/Carousel/carouselStore.cjs.map +1 -1
  29. package/dist/components/Carousel/carouselStore.js.map +1 -1
  30. package/dist/components/Carousel/index.d.ts +1 -1
  31. package/dist/components/Carousel/index.d.ts.map +1 -1
  32. package/dist/components/Carousel/index2.cjs +0 -1
  33. package/dist/components/Carousel/index2.cjs.map +1 -1
  34. package/dist/components/Carousel/index2.js.map +1 -1
  35. package/dist/components/Carousel/intersectionObserver.cjs.map +1 -1
  36. package/dist/components/Carousel/intersectionObserver.js.map +1 -1
  37. package/dist/components/Carousel/resizeObserver.cjs.map +1 -1
  38. package/dist/components/Carousel/resizeObserver.js.map +1 -1
  39. package/dist/components/Carousel/store.cjs.map +1 -1
  40. package/dist/components/Carousel/store.js.map +1 -1
  41. package/dist/components/Carousel/useCarouselScroller.cjs +0 -1
  42. package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -1
  43. package/dist/components/Carousel/useCarouselScroller.js.map +1 -1
  44. package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -1
  45. package/dist/components/Checkbox/CheckboxInput/index2.cjs +0 -1
  46. package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -1
  47. package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -1
  48. package/dist/components/Checkbox/CheckboxWithLabel.cjs +1 -1
  49. package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -1
  50. package/dist/components/Checkbox/CheckboxWithLabel.d.ts +2 -2
  51. package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -1
  52. package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -1
  53. package/dist/components/Checkbox/index.d.ts.map +1 -1
  54. package/dist/components/Checkbox/index2.cjs +0 -1
  55. package/dist/components/Checkbox/index2.cjs.map +1 -1
  56. package/dist/components/Checkbox/index2.js.map +1 -1
  57. package/dist/components/Clickable/index.d.ts +1 -1
  58. package/dist/components/Clickable/index.d.ts.map +1 -1
  59. package/dist/components/Clickable/index2.cjs +1 -1
  60. package/dist/components/Clickable/index2.cjs.map +1 -1
  61. package/dist/components/Clickable/index2.js.map +1 -1
  62. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +0 -1
  63. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -1
  64. package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -1
  65. package/dist/components/DropdownSelector/DropdownPopover.cjs +0 -1
  66. package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -1
  67. package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -1
  68. package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
  69. package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
  70. package/dist/components/DropdownSelector/ListItem/index2.cjs +0 -1
  71. package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -1
  72. package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -1
  73. package/dist/components/DropdownSelector/MenuItem/index.cjs +29 -2
  74. package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -1
  75. package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
  76. package/dist/components/DropdownSelector/MenuItem/index.js +30 -2
  77. package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -1
  78. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -1
  79. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -1
  80. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +0 -1
  81. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -1
  82. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -1
  83. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +0 -1
  84. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -1
  85. package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -1
  86. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +0 -1
  87. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -1
  88. package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -1
  89. package/dist/components/DropdownSelector/MenuList/index2.cjs +0 -1
  90. package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -1
  91. package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -1
  92. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +1 -1
  93. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -1
  94. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -1
  95. package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
  96. package/dist/components/DropdownSelector/Popover/index2.cjs +18 -1
  97. package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -1
  98. package/dist/components/DropdownSelector/Popover/index2.js +19 -1
  99. package/dist/components/DropdownSelector/Popover/index2.js.map +1 -1
  100. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +0 -1
  101. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -1
  102. package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -1
  103. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  104. package/dist/components/DropdownSelector/index2.cjs +27 -10
  105. package/dist/components/DropdownSelector/index2.cjs.map +1 -1
  106. package/dist/components/DropdownSelector/index2.js +26 -9
  107. package/dist/components/DropdownSelector/index2.js.map +1 -1
  108. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +1 -1
  109. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -1
  110. package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -1
  111. package/dist/components/FieldLabel/index.d.ts.map +1 -1
  112. package/dist/components/FieldLabel/index2.cjs +1 -1
  113. package/dist/components/FieldLabel/index2.cjs.map +1 -1
  114. package/dist/components/FieldLabel/index2.js.map +1 -1
  115. package/dist/components/HintText/index2.cjs +0 -1
  116. package/dist/components/HintText/index2.cjs.map +1 -1
  117. package/dist/components/HintText/index2.js.map +1 -1
  118. package/dist/components/Icon/index.cjs +1 -1
  119. package/dist/components/Icon/index.cjs.map +1 -1
  120. package/dist/components/Icon/index.d.ts.map +1 -1
  121. package/dist/components/Icon/index.js.map +1 -1
  122. package/dist/components/IconButton/index.d.ts +1 -1
  123. package/dist/components/IconButton/index.d.ts.map +1 -1
  124. package/dist/components/IconButton/index2.cjs +1 -1
  125. package/dist/components/IconButton/index2.cjs.map +1 -1
  126. package/dist/components/IconButton/index2.js.map +1 -1
  127. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  128. package/dist/components/LoadingSpinner/index2.cjs +0 -1
  129. package/dist/components/LoadingSpinner/index2.cjs.map +1 -1
  130. package/dist/components/LoadingSpinner/index2.js.map +1 -1
  131. package/dist/components/Modal/Dialog/index2.cjs +1 -1
  132. package/dist/components/Modal/Dialog/index2.cjs.map +1 -1
  133. package/dist/components/Modal/Dialog/index2.js.map +1 -1
  134. package/dist/components/Modal/ModalBackgroundContext.cjs +1 -1
  135. package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -1
  136. package/dist/components/Modal/ModalBackgroundContext.js.map +1 -1
  137. package/dist/components/Modal/ModalPlumbing.d.ts +3 -3
  138. package/dist/components/Modal/ModalPlumbing2.cjs +0 -1
  139. package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -1
  140. package/dist/components/Modal/ModalPlumbing2.js.map +1 -1
  141. package/dist/components/Modal/index.d.ts.map +1 -1
  142. package/dist/components/Modal/index2.cjs +1 -1
  143. package/dist/components/Modal/index2.cjs.map +1 -1
  144. package/dist/components/Modal/index2.js.map +1 -1
  145. package/dist/components/Modal/useCustomModalOverlay.cjs +1 -1
  146. package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -1
  147. package/dist/components/Modal/useCustomModalOverlay.js.map +1 -1
  148. package/dist/components/Modal/useTransitionPresence.cjs +1 -3
  149. package/dist/components/Modal/useTransitionPresence.cjs.map +1 -1
  150. package/dist/components/Modal/useTransitionPresence.js +1 -2
  151. package/dist/components/Modal/useTransitionPresence.js.map +1 -1
  152. package/dist/components/MultiSelect/context.cjs +0 -1
  153. package/dist/components/MultiSelect/context.cjs.map +1 -1
  154. package/dist/components/MultiSelect/context.js.map +1 -1
  155. package/dist/components/MultiSelect/index.d.ts +1 -1
  156. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  157. package/dist/components/MultiSelect/index2.cjs +2 -2
  158. package/dist/components/MultiSelect/index2.cjs.map +1 -1
  159. package/dist/components/MultiSelect/index2.js.map +1 -1
  160. package/dist/components/Pagination/PaginationContext.cjs +0 -1
  161. package/dist/components/Pagination/PaginationContext.cjs.map +1 -1
  162. package/dist/components/Pagination/PaginationContext.js.map +1 -1
  163. package/dist/components/Pagination/helper.cjs.map +1 -1
  164. package/dist/components/Pagination/helper.js.map +1 -1
  165. package/dist/components/Pagination/index2.cjs +26 -135
  166. package/dist/components/Pagination/index2.cjs.map +1 -1
  167. package/dist/components/Pagination/index2.js +86 -182
  168. package/dist/components/Pagination/index2.js.map +1 -1
  169. package/dist/components/Radio/RadioGroup/index2.cjs +1 -1
  170. package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -1
  171. package/dist/components/Radio/RadioGroup/index2.js.map +1 -1
  172. package/dist/components/Radio/RadioGroupContext.cjs.map +1 -1
  173. package/dist/components/Radio/RadioGroupContext.js.map +1 -1
  174. package/dist/components/Radio/RadioInput/index.d.ts.map +1 -1
  175. package/dist/components/Radio/RadioInput/index2.cjs +0 -1
  176. package/dist/components/Radio/RadioInput/index2.cjs.map +1 -1
  177. package/dist/components/Radio/RadioInput/index2.js.map +1 -1
  178. package/dist/components/Radio/index.d.ts.map +1 -1
  179. package/dist/components/Radio/index2.cjs +2 -2
  180. package/dist/components/Radio/index2.cjs.map +1 -1
  181. package/dist/components/Radio/index2.js.map +1 -1
  182. package/dist/components/SegmentedControl/RadioGroupContext.cjs +1 -1
  183. package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -1
  184. package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -1
  185. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  186. package/dist/components/SegmentedControl/index2.cjs +1 -1
  187. package/dist/components/SegmentedControl/index2.cjs.map +1 -1
  188. package/dist/components/SegmentedControl/index2.js.map +1 -1
  189. package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -1
  190. package/dist/components/Switch/SwitchInput/index2.cjs +0 -1
  191. package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -1
  192. package/dist/components/Switch/SwitchInput/index2.js.map +1 -1
  193. package/dist/components/Switch/SwitchWithLabel.cjs +1 -1
  194. package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -1
  195. package/dist/components/Switch/SwitchWithLabel.d.ts +2 -2
  196. package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -1
  197. package/dist/components/Switch/SwitchWithLabel.js.map +1 -1
  198. package/dist/components/Switch/index.d.ts +1 -1
  199. package/dist/components/Switch/index.d.ts.map +1 -1
  200. package/dist/components/Switch/index2.cjs +0 -1
  201. package/dist/components/Switch/index2.cjs.map +1 -1
  202. package/dist/components/Switch/index2.js.map +1 -1
  203. package/dist/components/TagItem/index.d.ts +1 -1
  204. package/dist/components/TagItem/index.d.ts.map +1 -1
  205. package/dist/components/TagItem/index2.cjs +1 -1
  206. package/dist/components/TagItem/index2.cjs.map +1 -1
  207. package/dist/components/TagItem/index2.js.map +1 -1
  208. package/dist/components/TextArea/index.d.ts.map +1 -1
  209. package/dist/components/TextArea/index2.cjs +0 -1
  210. package/dist/components/TextArea/index2.cjs.map +1 -1
  211. package/dist/components/TextArea/index2.js.map +1 -1
  212. package/dist/components/TextEllipsis/helper.cjs +2 -1
  213. package/dist/components/TextEllipsis/helper.cjs.map +1 -1
  214. package/dist/components/TextEllipsis/helper.d.ts.map +1 -1
  215. package/dist/components/TextEllipsis/helper.js +1 -1
  216. package/dist/components/TextEllipsis/helper.js.map +1 -1
  217. package/dist/components/TextEllipsis/index2.cjs +14 -98
  218. package/dist/components/TextEllipsis/index2.cjs.map +1 -1
  219. package/dist/components/TextEllipsis/index2.js +14 -93
  220. package/dist/components/TextEllipsis/index2.js.map +1 -1
  221. package/dist/components/TextField/AssistiveText/index.d.ts +1 -1
  222. package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -1
  223. package/dist/components/TextField/AssistiveText/index2.js.map +1 -1
  224. package/dist/components/TextField/index.d.ts +1 -1
  225. package/dist/components/TextField/index.d.ts.map +1 -1
  226. package/dist/components/TextField/index2.cjs +1 -1
  227. package/dist/components/TextField/index2.cjs.map +1 -1
  228. package/dist/components/TextField/index2.js.map +1 -1
  229. package/dist/components/TextField/useFocusWithClick.cjs +0 -1
  230. package/dist/components/TextField/useFocusWithClick.cjs.map +1 -1
  231. package/dist/components/TextField/useFocusWithClick.js.map +1 -1
  232. package/dist/core/CharcoalProvider.cjs +1 -1
  233. package/dist/core/CharcoalProvider.cjs.map +1 -1
  234. package/dist/core/CharcoalProvider.js.map +1 -1
  235. package/dist/core/SSRProvider.cjs +1 -1
  236. package/dist/core/SSRProvider.cjs.map +1 -1
  237. package/dist/core/SSRProvider.js +1 -1
  238. package/dist/core/SSRProvider.js.map +1 -1
  239. package/dist/core/SetThemeScript.cjs +0 -1
  240. package/dist/core/SetThemeScript.cjs.map +1 -1
  241. package/dist/core/SetThemeScript.js.map +1 -1
  242. package/dist/core/themeHelper.cjs +0 -1
  243. package/dist/core/themeHelper.cjs.map +1 -1
  244. package/dist/core/themeHelper.d.ts +2 -2
  245. package/dist/core/themeHelper.d.ts.map +1 -1
  246. package/dist/core/themeHelper.js.map +1 -1
  247. package/dist/index.cjs +22 -23
  248. package/dist/index.css +1000 -1000
  249. package/dist/layered.css +1000 -1000
  250. package/dist/layered.css.map +1 -1
  251. package/package.json +10 -10
  252. package/src/_lib/compat.ts +1 -7
  253. package/src/components/Carousel/index.browser.test.tsx +1 -1
  254. package/src/components/Carousel/intersectionObserver.test.ts +12 -12
  255. package/src/components/Carousel/resizeObserver.test.ts +1 -1
  256. package/src/components/DropdownSelector/MenuItem/index.tsx +40 -2
  257. package/src/components/DropdownSelector/Popover/index.tsx +20 -1
  258. package/src/components/DropdownSelector/index.browser.test.tsx +94 -0
  259. package/src/components/DropdownSelector/index.test.tsx +57 -2
  260. package/src/components/DropdownSelector/index.tsx +37 -12
  261. package/src/components/FieldLabel/index.tsx +1 -2
  262. package/src/components/Icon/index.tsx +2 -1
  263. package/src/components/Modal/__snapshots__/index.css.snap +1 -0
  264. package/src/components/TextEllipsis/TextEllipsis.story.tsx +1 -1
  265. package/src/css.d.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index2.cjs","names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","FieldLabel","countCodePointsInString","mergeRefs","useFocusWithClick","AssistiveText","useClassNames","useVisuallyHidden","useId","TextAreaImperativeHandle","setValue","value","sync","TextAreaProps","onChange","imperativeRef","React","Ref","showCount","showLabel","assistiveText","invalid","label","requiredText","disabled","subLabel","ReactNode","autoHeight","maxRows","getCount","Omit","ComponentPropsWithoutRef","TextArea","HTMLTextAreaElement","TextAreaInner","className","required","maxLength","rows","initialRows","defaultValue","props","isUncontrolled","undefined","countValue","toString","setRows","count","setCount","textareaRef","containerRef","visuallyHiddenProps","isEnableAutoHeight","classNames","showAssistiveText","length","syncHeight","textarea","currentRows","match","hasValidMaxRows","nextRows","Math","min","syncTextAreaState","handleChange","e","ChangeEvent","currentTarget","current","textAreaId","id","describedbyId","labelledbyId"],"sources":["../../../src/components/TextArea/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from '../TextField/useFocusWithClick'\nimport { AssistiveText } from '../TextField/AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\n/**\n * `TextArea` を `imperativeRef` から操作するためのハンドル\n */\nexport type TextAreaImperativeHandle = {\n /**\n * textarea の値を更新し、文字数や高さなどの内部状態を同期する\n */\n setValue: (value: string) => void\n /**\n * textarea の現在の値をもとに、文字数や高さなどの内部状態を同期する\n */\n sync: () => void\n}\n\nexport type TextAreaProps = {\n value?: string\n onChange?: (value: string) => void\n imperativeRef?: React.Ref<TextAreaImperativeHandle>\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n autoHeight?: boolean\n\n maxRows?: number\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'textarea'>, 'onChange'>\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n function TextAreaInner(\n {\n onChange,\n className,\n value,\n showCount = false,\n showLabel = false,\n label = '',\n requiredText,\n subLabel,\n disabled = false,\n required,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n maxRows,\n invalid,\n getCount = countCodePointsInString,\n defaultValue,\n imperativeRef,\n ...props\n },\n forwardRef,\n ) {\n const isUncontrolled = value === undefined\n // `null` is invalid for TextAreaProps, but may arrive at runtime. Keep the\n // pre-f710d512 nullish fallback so getCount is never called with null.\n const countValue = value ?? defaultValue?.toString() ?? ''\n const [rows, setRows] = useState(initialRows)\n const [count, setCount] = useState(getCount(countValue))\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const containerRef = useRef(null)\n useFocusWithClick(containerRef, textareaRef)\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const isEnableAutoHeight = useMemo(\n () => autoHeight || (maxRows && maxRows >= 0),\n [autoHeight, maxRows],\n )\n const classNames = useClassNames('charcoal-text-area-root', className)\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const currentRows =\n (`${textarea.value}\\n`.match(/\\n/gu)?.length ?? 0) || 1\n const hasValidMaxRows = maxRows !== undefined && maxRows >= 1\n const nextRows = initialRows <= currentRows ? currentRows : initialRows\n\n if (!hasValidMaxRows) {\n setRows(nextRows)\n return\n }\n\n setRows(Math.min(nextRows, maxRows))\n },\n [initialRows, maxRows],\n )\n\n const syncTextAreaState = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const count = getCount(textarea.value)\n\n if (isUncontrolled) {\n setCount(count)\n }\n\n if (isEnableAutoHeight) {\n syncHeight(textarea)\n }\n\n return count\n },\n [getCount, isEnableAutoHeight, isUncontrolled, syncHeight],\n )\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const value = e.currentTarget.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n\n syncTextAreaState(e.currentTarget)\n onChange?.(value)\n },\n [getCount, maxLength, onChange, syncTextAreaState],\n )\n\n useImperativeHandle(\n imperativeRef,\n () => ({\n setValue: (value: string) => {\n if (textareaRef.current === null) {\n return\n }\n\n textareaRef.current.value = value\n syncTextAreaState(textareaRef.current)\n },\n sync: () => {\n if (textareaRef.current !== null) {\n syncTextAreaState(textareaRef.current)\n }\n },\n }),\n [syncTextAreaState],\n )\n\n const textAreaId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n useEffect(() => {\n // 制御コンポーネントの時の挙動\n if (!isUncontrolled) {\n setCount(getCount(countValue))\n }\n\n // autoHeight同期(valueが変更された時にsyncHeightしたい)\n if (isEnableAutoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [\n isUncontrolled,\n countValue,\n getCount,\n isEnableAutoHeight,\n textareaRef,\n syncHeight,\n ])\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={textAreaId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-area-container\"\n aria-disabled={disabled === true ? 'true' : undefined}\n aria-invalid={invalid === true}\n ref={containerRef}\n style={{\n '--charcoal-text-area-rows': rows,\n }}\n >\n <textarea\n className=\"charcoal-text-area-textarea\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={textAreaId}\n maxLength={maxLength}\n data-no-bottom-padding={showCount}\n onChange={handleChange}\n ref={mergeRefs(forwardRef, textareaRef)}\n rows={rows}\n value={value}\n disabled={disabled}\n defaultValue={defaultValue}\n {...props}\n />\n {showCount && (\n <span className=\"charcoal-text-area-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextArea\n"],"mappings":";;;;;;;;;;;;;;AAsDA,MAAMsC,iCACJ,SAASE,cACP,EACEpB,UACAqB,WACAxB,OACAO,YAAY,OACZC,YAAY,OACZG,QAAQ,IACRC,cACAE,UACAD,WAAW,OACXY,UACAhB,eACAiB,WACAV,aAAa,OACbW,MAAMC,cAAc,GACpBX,SACAP,SACAQ,WAAW3B,yCACXsC,cACAzB,eACA,GAAG0B,SAEL/C,YACA;CACA,MAAMgD,iBAAiB/B,UAAUgC;CAGjC,MAAMC,aAAajC,SAAS6B,cAAcK,UAAU,IAAI;CACxD,MAAM,CAACP,MAAMQ,+BAAoBP,YAAY;CAC7C,MAAM,CAACQ,OAAOC,gCAAqBnB,SAASe,WAAW,CAAC;CAExD,MAAMK,gCAA0C,KAAK;CACrD,MAAMC,iCAAsB,KAAK;CACjC9C,4CAAkB8C,cAAcD,YAAY;CAC5C,MAAM,EAAEE,0EAA2C;CAEnD,MAAMC,8CACEzB,cAAeC,WAAWA,WAAW,GAC3C,CAACD,YAAYC,QACf,CAAC;CACD,MAAMyB,aAAa/C,oCAAc,2BAA2B6B,UAAU;C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M,SAASnB,SAASe,WAAW,CAAC;EAIhC,IAAIQ,sBAAsBH,YAAYoB,YAAY,MAChDb,WAAWP,YAAYoB,QAAQ;IAEhC;EACD3B;EACAE;EACAf;EACAuB;EACAH;EACAO;EACD,CAAC;CAEF,OACE,4CAAC,OAAD;EAAK,WAAWH;EAAY,iBAAe7B;YAA3C;GACE,2CAAC,uBAAD;IACE,SAAS8C;IACT,IAAIG;IACGnD;IACGc;IACIb;IACJE;IACV,GAAK,CAACN,YAAYgC,sBAAsB,EAAG;IAAC;GAE9C,4CAAC,OAAD;IACE,WAAU;IACV,iBAAe3B,aAAa,OAAO,SAASmB;IAC5C,gBAActB,YAAY;IAC1B,KAAK6B;IACL,OAAO,EACL,6BAA6BZ,MAC9B;cAPH,CASE,2CAAC,YAAD;KACE,WAAU;KACV,oBAAkBgB,oBAAoBkB,gBAAgB7B;KACtD,gBAActB;KACd,mBAAiBoD;KACjB,IAAIH;KACOjC;KACX,0BAAwBnB;KACxB,UAAU+C;KACV,KAAK9D,0BAAUT,YAAYuD,YAAY;KACjCX;KACC3B;KACGa;KACIgB;KACd,GAAIC;KAAM,GAEXvB,aACC,2CAAC,QAAD;KAAM,WAAU;eACbmB,cAAcM,SAAY,GAAGI,MAAK,GAAIV,cAAcU;KAExD,EACE;;GACJO,qBACC,2CAAC,+BAAD;IAAe,gBAAcjC,YAAY;IAAM,IAAImD;cAChDpD;IAEJ;GACG;;EAGX"}
1
+ {"version":3,"file":"index2.cjs","names":[],"sources":["../../../src/components/TextArea/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from '../TextField/useFocusWithClick'\nimport { AssistiveText } from '../TextField/AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\n/**\n * `TextArea` を `imperativeRef` から操作するためのハンドル\n */\nexport type TextAreaImperativeHandle = {\n /**\n * textarea の値を更新し、文字数や高さなどの内部状態を同期する\n */\n setValue: (value: string) => void\n /**\n * textarea の現在の値をもとに、文字数や高さなどの内部状態を同期する\n */\n sync: () => void\n}\n\nexport type TextAreaProps = {\n value?: string\n onChange?: (value: string) => void\n imperativeRef?: React.Ref<TextAreaImperativeHandle>\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n autoHeight?: boolean\n\n maxRows?: number\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'textarea'>, 'onChange'>\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n function TextAreaInner(\n {\n onChange,\n className,\n value,\n showCount = false,\n showLabel = false,\n label = '',\n requiredText,\n subLabel,\n disabled = false,\n required,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n maxRows,\n invalid,\n getCount = countCodePointsInString,\n defaultValue,\n imperativeRef,\n ...props\n },\n forwardRef,\n ) {\n const isUncontrolled = value === undefined\n // `null` is invalid for TextAreaProps, but may arrive at runtime. Keep the\n // pre-f710d512 nullish fallback so getCount is never called with null.\n const countValue = value ?? defaultValue?.toString() ?? ''\n const [rows, setRows] = useState(initialRows)\n const [count, setCount] = useState(getCount(countValue))\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const containerRef = useRef(null)\n useFocusWithClick(containerRef, textareaRef)\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const isEnableAutoHeight = useMemo(\n () => autoHeight || (maxRows && maxRows >= 0),\n [autoHeight, maxRows],\n )\n const classNames = useClassNames('charcoal-text-area-root', className)\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const currentRows =\n (`${textarea.value}\\n`.match(/\\n/gu)?.length ?? 0) || 1\n const hasValidMaxRows = maxRows !== undefined && maxRows >= 1\n const nextRows = initialRows <= currentRows ? currentRows : initialRows\n\n if (!hasValidMaxRows) {\n setRows(nextRows)\n return\n }\n\n setRows(Math.min(nextRows, maxRows))\n },\n [initialRows, maxRows],\n )\n\n const syncTextAreaState = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const count = getCount(textarea.value)\n\n if (isUncontrolled) {\n setCount(count)\n }\n\n if (isEnableAutoHeight) {\n syncHeight(textarea)\n }\n\n return count\n },\n [getCount, isEnableAutoHeight, isUncontrolled, syncHeight],\n )\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const value = e.currentTarget.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n\n syncTextAreaState(e.currentTarget)\n onChange?.(value)\n },\n [getCount, maxLength, onChange, syncTextAreaState],\n )\n\n useImperativeHandle(\n imperativeRef,\n () => ({\n setValue: (value: string) => {\n if (textareaRef.current === null) {\n return\n }\n\n textareaRef.current.value = value\n syncTextAreaState(textareaRef.current)\n },\n sync: () => {\n if (textareaRef.current !== null) {\n syncTextAreaState(textareaRef.current)\n }\n },\n }),\n [syncTextAreaState],\n )\n\n const textAreaId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n useEffect(() => {\n // 制御コンポーネントの時の挙動\n if (!isUncontrolled) {\n setCount(getCount(countValue))\n }\n\n // autoHeight同期(valueが変更された時にsyncHeightしたい)\n if (isEnableAutoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [\n isUncontrolled,\n countValue,\n getCount,\n isEnableAutoHeight,\n textareaRef,\n syncHeight,\n ])\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={textAreaId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-area-container\"\n aria-disabled={disabled === true ? 'true' : undefined}\n aria-invalid={invalid === true}\n ref={containerRef}\n style={{\n '--charcoal-text-area-rows': rows,\n }}\n >\n <textarea\n className=\"charcoal-text-area-textarea\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={textAreaId}\n maxLength={maxLength}\n data-no-bottom-padding={showCount}\n onChange={handleChange}\n ref={mergeRefs(forwardRef, textareaRef)}\n rows={rows}\n value={value}\n disabled={disabled}\n defaultValue={defaultValue}\n {...props}\n />\n {showCount && (\n <span className=\"charcoal-text-area-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextArea\n"],"mappings":";;;;;;;;;;;;;AAsDA,MAAM,iCACJ,SAAS,cACP,EACE,UACA,WACA,OACA,YAAY,OACZ,YAAY,OACZ,QAAQ,IACR,cACA,UACA,WAAW,OACX,UACA,eACA,WACA,aAAa,OACb,MAAM,cAAc,GACpB,SACA,SACA,WAAW,yCACX,cACA,eACA,GAAG,SAEL,YACA;CACA,MAAM,iBAAiB,UAAU;CAGjC,MAAM,aAAa,SAAS,cAAc,SAAS,KAAK;CACxD,MAAM,CAAC,MAAM,+BAAoB,WAAW;CAC5C,MAAM,CAAC,OAAO,gCAAqB,SAAS,UAAU,CAAC;CAEvD,MAAM,gCAA0C,IAAI;CACpD,MAAM,iCAAsB,IAAI;CAChC,4CAAkB,cAAc,WAAW;CAC3C,MAAM,EAAE,yEAA0C;CAElD,MAAM,8CACE,cAAe,WAAW,WAAW,GAC3C,CAAC,YAAY,OAAO,CACtB;CACA,MAAM,aAAa,oCAAc,2BAA2B,SAAS;CACrE,MAAM,oBACJ,iBAAiB,QAAQ,cAAc,WAAW;CAEpD,M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,iBAAe;YAA3C;GACE,2CAAC,uBAAD;IACE,SAAS;IACT,IAAI;IACG;IACG;IACI;IACJ;IACV,GAAK,CAAC,YAAY,sBAAsB,CAAC;GAAG;GAE9C,4CAAC,OAAD;IACE,WAAU;IACV,iBAAe,aAAa,OAAO,SAAS;IAC5C,gBAAc,YAAY;IAC1B,KAAK;IACL,OAAO,EACL,6BAA6B,KAC/B;cAPF,CASE,2CAAC,YAAD;KACE,WAAU;KACV,oBAAkB,oBAAoB,gBAAgB;KACtD,gBAAc;KACd,mBAAiB;KACjB,IAAI;KACO;KACX,0BAAwB;KACxB,UAAU;KACV,KAAK,0BAAU,YAAY,WAAW;KAChC;KACC;KACG;KACI;KACd,GAAI;IAAM,IAEX,aACC,2CAAC,QAAD;KAAM,WAAU;eACb,cAAc,SAAY,GAAG,MAAK,GAAI,cAAc;IACjD,EAEL;;GACJ,qBACC,2CAAC,+BAAD;IAAe,gBAAc,YAAY;IAAM,IAAI;cAChD;GACY;EAEd;;AAET,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","FieldLabel","countCodePointsInString","mergeRefs","useFocusWithClick","AssistiveText","useClassNames","useVisuallyHidden","useId","TextAreaImperativeHandle","setValue","value","sync","TextAreaProps","onChange","imperativeRef","React","Ref","showCount","showLabel","assistiveText","invalid","label","requiredText","disabled","subLabel","ReactNode","autoHeight","maxRows","getCount","Omit","ComponentPropsWithoutRef","TextArea","HTMLTextAreaElement","TextAreaInner","className","required","maxLength","rows","initialRows","defaultValue","props","isUncontrolled","undefined","countValue","toString","setRows","count","setCount","textareaRef","containerRef","visuallyHiddenProps","isEnableAutoHeight","classNames","showAssistiveText","length","syncHeight","textarea","currentRows","match","hasValidMaxRows","nextRows","Math","min","syncTextAreaState","handleChange","e","ChangeEvent","currentTarget","current","textAreaId","id","describedbyId","labelledbyId"],"sources":["../../../src/components/TextArea/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from '../TextField/useFocusWithClick'\nimport { AssistiveText } from '../TextField/AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\n/**\n * `TextArea` を `imperativeRef` から操作するためのハンドル\n */\nexport type TextAreaImperativeHandle = {\n /**\n * textarea の値を更新し、文字数や高さなどの内部状態を同期する\n */\n setValue: (value: string) => void\n /**\n * textarea の現在の値をもとに、文字数や高さなどの内部状態を同期する\n */\n sync: () => void\n}\n\nexport type TextAreaProps = {\n value?: string\n onChange?: (value: string) => void\n imperativeRef?: React.Ref<TextAreaImperativeHandle>\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n autoHeight?: boolean\n\n maxRows?: number\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'textarea'>, 'onChange'>\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n function TextAreaInner(\n {\n onChange,\n className,\n value,\n showCount = false,\n showLabel = false,\n label = '',\n requiredText,\n subLabel,\n disabled = false,\n required,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n maxRows,\n invalid,\n getCount = countCodePointsInString,\n defaultValue,\n imperativeRef,\n ...props\n },\n forwardRef,\n ) {\n const isUncontrolled = value === undefined\n // `null` is invalid for TextAreaProps, but may arrive at runtime. Keep the\n // pre-f710d512 nullish fallback so getCount is never called with null.\n const countValue = value ?? defaultValue?.toString() ?? ''\n const [rows, setRows] = useState(initialRows)\n const [count, setCount] = useState(getCount(countValue))\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const containerRef = useRef(null)\n useFocusWithClick(containerRef, textareaRef)\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const isEnableAutoHeight = useMemo(\n () => autoHeight || (maxRows && maxRows >= 0),\n [autoHeight, maxRows],\n )\n const classNames = useClassNames('charcoal-text-area-root', className)\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const currentRows =\n (`${textarea.value}\\n`.match(/\\n/gu)?.length ?? 0) || 1\n const hasValidMaxRows = maxRows !== undefined && maxRows >= 1\n const nextRows = initialRows <= currentRows ? currentRows : initialRows\n\n if (!hasValidMaxRows) {\n setRows(nextRows)\n return\n }\n\n setRows(Math.min(nextRows, maxRows))\n },\n [initialRows, maxRows],\n )\n\n const syncTextAreaState = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const count = getCount(textarea.value)\n\n if (isUncontrolled) {\n setCount(count)\n }\n\n if (isEnableAutoHeight) {\n syncHeight(textarea)\n }\n\n return count\n },\n [getCount, isEnableAutoHeight, isUncontrolled, syncHeight],\n )\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const value = e.currentTarget.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n\n syncTextAreaState(e.currentTarget)\n onChange?.(value)\n },\n [getCount, maxLength, onChange, syncTextAreaState],\n )\n\n useImperativeHandle(\n imperativeRef,\n () => ({\n setValue: (value: string) => {\n if (textareaRef.current === null) {\n return\n }\n\n textareaRef.current.value = value\n syncTextAreaState(textareaRef.current)\n },\n sync: () => {\n if (textareaRef.current !== null) {\n syncTextAreaState(textareaRef.current)\n }\n },\n }),\n [syncTextAreaState],\n )\n\n const textAreaId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n useEffect(() => {\n // 制御コンポーネントの時の挙動\n if (!isUncontrolled) {\n setCount(getCount(countValue))\n }\n\n // autoHeight同期(valueが変更された時にsyncHeightしたい)\n if (isEnableAutoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [\n isUncontrolled,\n countValue,\n getCount,\n isEnableAutoHeight,\n textareaRef,\n syncHeight,\n ])\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={textAreaId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-area-container\"\n aria-disabled={disabled === true ? 'true' : undefined}\n aria-invalid={invalid === true}\n ref={containerRef}\n style={{\n '--charcoal-text-area-rows': rows,\n }}\n >\n <textarea\n className=\"charcoal-text-area-textarea\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={textAreaId}\n maxLength={maxLength}\n data-no-bottom-padding={showCount}\n onChange={handleChange}\n ref={mergeRefs(forwardRef, textareaRef)}\n rows={rows}\n value={value}\n disabled={disabled}\n defaultValue={defaultValue}\n {...props}\n />\n {showCount && (\n <span className=\"charcoal-text-area-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextArea\n"],"mappings":";;;;;;;;;;;;;AAsDA,MAAMsC,WAAWtC,WACf,SAASwC,cACP,EACEpB,UACAqB,WACAxB,OACAO,YAAY,OACZC,YAAY,OACZG,QAAQ,IACRC,cACAE,UACAD,WAAW,OACXY,UACAhB,eACAiB,WACAV,aAAa,OACbW,MAAMC,cAAc,GACpBX,SACAP,SACAQ,WAAW3B,yBACXsC,cACAzB,eACA,GAAG0B,SAEL/C,YACA;CACA,MAAMgD,iBAAiB/B,UAAUgC;CAGjC,MAAMC,aAAajC,SAAS6B,cAAcK,UAAU,IAAI;CACxD,MAAM,CAACP,MAAMQ,WAA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cjC,YAAY;IAAM,IAAImD;cAChDpD;IAEJ;GACG;;EAGX"}
1
+ {"version":3,"file":"index2.js","names":[],"sources":["../../../src/components/TextArea/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from '../TextField/useFocusWithClick'\nimport { AssistiveText } from '../TextField/AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\n/**\n * `TextArea` を `imperativeRef` から操作するためのハンドル\n */\nexport type TextAreaImperativeHandle = {\n /**\n * textarea の値を更新し、文字数や高さなどの内部状態を同期する\n */\n setValue: (value: string) => void\n /**\n * textarea の現在の値をもとに、文字数や高さなどの内部状態を同期する\n */\n sync: () => void\n}\n\nexport type TextAreaProps = {\n value?: string\n onChange?: (value: string) => void\n imperativeRef?: React.Ref<TextAreaImperativeHandle>\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n autoHeight?: boolean\n\n maxRows?: number\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'textarea'>, 'onChange'>\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n function TextAreaInner(\n {\n onChange,\n className,\n value,\n showCount = false,\n showLabel = false,\n label = '',\n requiredText,\n subLabel,\n disabled = false,\n required,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n maxRows,\n invalid,\n getCount = countCodePointsInString,\n defaultValue,\n imperativeRef,\n ...props\n },\n forwardRef,\n ) {\n const isUncontrolled = value === undefined\n // `null` is invalid for TextAreaProps, but may arrive at runtime. Keep the\n // pre-f710d512 nullish fallback so getCount is never called with null.\n const countValue = value ?? defaultValue?.toString() ?? ''\n const [rows, setRows] = useState(initialRows)\n const [count, setCount] = useState(getCount(countValue))\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const containerRef = useRef(null)\n useFocusWithClick(containerRef, textareaRef)\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const isEnableAutoHeight = useMemo(\n () => autoHeight || (maxRows && maxRows >= 0),\n [autoHeight, maxRows],\n )\n const classNames = useClassNames('charcoal-text-area-root', className)\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const currentRows =\n (`${textarea.value}\\n`.match(/\\n/gu)?.length ?? 0) || 1\n const hasValidMaxRows = maxRows !== undefined && maxRows >= 1\n const nextRows = initialRows <= currentRows ? currentRows : initialRows\n\n if (!hasValidMaxRows) {\n setRows(nextRows)\n return\n }\n\n setRows(Math.min(nextRows, maxRows))\n },\n [initialRows, maxRows],\n )\n\n const syncTextAreaState = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const count = getCount(textarea.value)\n\n if (isUncontrolled) {\n setCount(count)\n }\n\n if (isEnableAutoHeight) {\n syncHeight(textarea)\n }\n\n return count\n },\n [getCount, isEnableAutoHeight, isUncontrolled, syncHeight],\n )\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const value = e.currentTarget.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n\n syncTextAreaState(e.currentTarget)\n onChange?.(value)\n },\n [getCount, maxLength, onChange, syncTextAreaState],\n )\n\n useImperativeHandle(\n imperativeRef,\n () => ({\n setValue: (value: string) => {\n if (textareaRef.current === null) {\n return\n }\n\n textareaRef.current.value = value\n syncTextAreaState(textareaRef.current)\n },\n sync: () => {\n if (textareaRef.current !== null) {\n syncTextAreaState(textareaRef.current)\n }\n },\n }),\n [syncTextAreaState],\n )\n\n const textAreaId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n useEffect(() => {\n // 制御コンポーネントの時の挙動\n if (!isUncontrolled) {\n setCount(getCount(countValue))\n }\n\n // autoHeight同期(valueが変更された時にsyncHeightしたい)\n if (isEnableAutoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [\n isUncontrolled,\n countValue,\n getCount,\n isEnableAutoHeight,\n textareaRef,\n syncHeight,\n ])\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={textAreaId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-area-container\"\n aria-disabled={disabled === true ? 'true' : undefined}\n aria-invalid={invalid === true}\n ref={containerRef}\n style={{\n '--charcoal-text-area-rows': rows,\n }}\n >\n <textarea\n className=\"charcoal-text-area-textarea\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={textAreaId}\n maxLength={maxLength}\n data-no-bottom-padding={showCount}\n onChange={handleChange}\n ref={mergeRefs(forwardRef, textareaRef)}\n rows={rows}\n value={value}\n disabled={disabled}\n defaultValue={defaultValue}\n {...props}\n />\n {showCount && (\n <span className=\"charcoal-text-area-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextArea\n"],"mappings":";;;;;;;;;;;;;AAsDA,MAAM,WAAW,WACf,SAAS,cACP,EACE,UACA,WACA,OACA,YAAY,OACZ,YAAY,OACZ,QAAQ,IACR,cACA,UACA,WAAW,OACX,UACA,eACA,WACA,aAAa,OACb,MAAM,cAAc,GACpB,SACA,SACA,WAAW,yBACX,cACA,eACA,GAAG,SAEL,YACA;CACA,MAAM,iBAAiB,UAAU;CAG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C1B;GAGF,YAAY,QAAQ,QAAQ;GAC5B,kBAAkB,YAAY,OAAO;EACvC;EACA,YAAY;GACV,IAAI,YAAY,YAAY,MAC1B,kBAAkB,YAAY,OAAO;EAEzC;CACF,IACA,CAAC,iBAAiB,CACpB;CAEA,MAAM,aAAa,MAAM,MAAM,EAAE;CACjC,MAAM,gBAAgB,MAAM;CAC5B,MAAM,eAAe,MAAM;CAE3B,gBAAgB;EAEd,IAAI,CAAC,gBACH,SAAS,SAAS,UAAU,CAAC;EAI/B,IAAI,sBAAsB,YAAY,YAAY,MAChD,WAAW,YAAY,OAAO;CAElC,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CAED,OACE,qBAAC,OAAD;EAAK,WAAW;EAAY,iBAAe;YAA3C;GACE,oBAAC,YAAD;IACE,SAAS;IACT,IAAI;IACG;IACG;IACI;IACJ;IACV,GAAK,CAAC,YAAY,sBAAsB,CAAC;GAAG;GAE9C,qBAAC,OAAD;IACE,WAAU;IACV,iBAAe,aAAa,OAAO,SAAS;IAC5C,gBAAc,YAAY;IAC1B,KAAK;IACL,OAAO,EACL,6BAA6B,KAC/B;cAPF,CASE,oBAAC,YAAD;KACE,WAAU;KACV,oBAAkB,oBAAoB,gBAAgB;KACtD,gBAAc;KACd,mBAAiB;KACjB,IAAI;KACO;KACX,0BAAwB;KACxB,UAAU;KACV,KAAK,UAAU,YAAY,WAAW;KAChC;KACC;KACG;KACI;KACd,GAAI;IAAM,IAEX,aACC,oBAAC,QAAD;KAAM,WAAU;eACb,cAAc,SAAY,GAAG,MAAK,GAAI,cAAc;IACjD,EAEL;;GACJ,qBACC,oBAAC,eAAD;IAAe,gBAAc,YAAY;IAAM,IAAI;cAChD;GACY;EAEd;;AAET,CACF"}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  let react = require("react");
4
3
 
5
4
  //#region src/components/TextEllipsis/helper.ts
@@ -27,5 +26,7 @@ const onlyText = (children) => {
27
26
  };
28
27
 
29
28
  //#endregion
29
+ exports.childToString = childToString;
30
30
  exports.getFinalTitle = getFinalTitle;
31
+ exports.onlyText = onlyText;
31
32
  //# sourceMappingURL=helper.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.cjs","names":["Children","isValidElement","ReactElement","ReactNode","getFinalTitle","showTooltip","title","children","undefined","resolvedTitle","onlyText","hasChildren","element","Boolean","props","childToString","child","JSON","stringify","toString","Array","isArray","toArray","reduce","text","newText","concat"],"sources":["../../../src/components/TextEllipsis/helper.ts"],"sourcesContent":["// https://github.com/fernandopasik/react-children-utilities/blob/971d8a0324e6183734d8d1af9a65dbad18ab3d00/src/lib/onlyText.ts\n\nimport { Children, isValidElement, ReactElement, ReactNode } from 'react'\n\nexport const getFinalTitle = (\n showTooltip: boolean,\n title?: string,\n children?: ReactNode,\n): string | undefined => {\n // 1. 表示フラグが false なら即終了\n if (!showTooltip) {\n return undefined\n }\n\n // 2. タイトルの候補を取得\n const resolvedTitle = title ?? onlyText(children)\n\n // 3. resolvedTitle が falsy (undefined, null, \"\") なら終了\n if (!resolvedTitle) {\n return undefined\n }\n\n // 4. 有効な文字列のみを返す\n return resolvedTitle\n}\n\nconst hasChildren = (\n element: ReactNode,\n): element is ReactElement<{ children: ReactNode[] }> =>\n isValidElement<{ children?: ReactNode[] }>(element) &&\n Boolean(element.props.children)\n\nexport const childToString = (\n child?: number | string | boolean | {} | null,\n): string => {\n if (\n typeof child === 'undefined' ||\n child === null ||\n typeof child === 'boolean'\n ) {\n return ''\n }\n\n if (JSON.stringify(child) === '{}') {\n return ''\n }\n\n return (child as string | number).toString()\n}\n\nexport const onlyText = (children: ReactNode): string => {\n if (!Array.isArray(children) && !isValidElement(children)) {\n return childToString(children)\n }\n\n return Children.toArray(children).reduce(\n (text: string, child: ReactNode): string => {\n let newText = ''\n\n if (isValidElement(child) && hasChildren(child)) {\n newText = onlyText(child.props.children)\n } else if (isValidElement(child) && !hasChildren(child)) {\n newText = ''\n } else {\n newText = childToString(child)\n }\n\n return text.concat(newText)\n },\n '',\n )\n}\n"],"mappings":";;;;;AAIA,MAAaI,iBACXC,aACAC,OACAC,aACuB;CAEvB,IAAI,CAACF,aACH;CAIF,MAAMI,gBAAgBH,SAASI,SAASH,SAAS;CAGjD,IAAI,CAACE,eACH;CAIF,OAAOA;;AAGT,MAAME,eACJC,sCAE2CA,QAAQ,IACnDC,QAAQD,QAAQE,MAAMP,SAAS;AAEjC,MAAaQ,iBACXC,UACW;CACX,IACE,OAAOA,UAAU,eACjBA,UAAU,QACV,OAAOA,UAAU,WAEjB,OAAO;CAGT,IAAIC,KAAKC,UAAUF,MAAM,KAAK,MAC5B,OAAO;CAGT,OAAQA,MAA0BG,UAAU;;AAG9C,MAAaT,YAAYH,aAAgC;CACvD,IAAI,CAACa,MAAMC,QAAQd,SAAS,IAAI,2BAAgBA,SAAS,EACvD,OAAOQ,cAAcR,SAAS;CAGhC,OAAOP,eAASsB,QAAQf,SAAS,CAACgB,QAC/BC,MAAcR,UAA6B;EAC1C,IAAIS,UAAU;EAEd,8BAAmBT,MAAM,IAAIL,YAAYK,MAAM,EAC7CS,UAAUf,SAASM,MAAMF,MAAMP,SAAS;OACnC,8BAAmBS,MAAM,IAAI,CAACL,YAAYK,MAAM,EACrDS,UAAU;OAEVA,UAAUV,cAAcC,MAAM;EAGhC,OAAOQ,KAAKE,OAAOD,QAAQ;IAE7B,GACD"}
1
+ {"version":3,"file":"helper.cjs","names":[],"sources":["../../../src/components/TextEllipsis/helper.ts"],"sourcesContent":["// https://github.com/fernandopasik/react-children-utilities/blob/971d8a0324e6183734d8d1af9a65dbad18ab3d00/src/lib/onlyText.ts\n\nimport { Children, isValidElement, ReactElement, ReactNode } from 'react'\n\nexport const getFinalTitle = (\n showTooltip: boolean,\n title?: string,\n children?: ReactNode,\n): string | undefined => {\n // 1. 表示フラグが false なら即終了\n if (!showTooltip) {\n return undefined\n }\n\n // 2. タイトルの候補を取得\n const resolvedTitle = title ?? onlyText(children)\n\n // 3. resolvedTitle が falsy (undefined, null, \"\") なら終了\n if (!resolvedTitle) {\n return undefined\n }\n\n // 4. 有効な文字列のみを返す\n return resolvedTitle\n}\n\nconst hasChildren = (\n element: ReactNode,\n): element is ReactElement<{ children: ReactNode[] }> =>\n isValidElement<{ children?: ReactNode[] }>(element) &&\n Boolean(element.props.children)\n\nexport const childToString = (\n child?: number | string | boolean | {} | null,\n): string => {\n if (\n typeof child === 'undefined' ||\n child === null ||\n typeof child === 'boolean'\n ) {\n return ''\n }\n\n if (JSON.stringify(child) === '{}') {\n return ''\n }\n\n return (child as string | number).toString()\n}\n\nexport const onlyText = (children: ReactNode): string => {\n if (!Array.isArray(children) && !isValidElement(children)) {\n return childToString(children)\n }\n\n return Children.toArray(children).reduce(\n (text: string, child: ReactNode): string => {\n let newText = ''\n\n if (isValidElement(child) && hasChildren(child)) {\n newText = onlyText(child.props.children)\n } else if (isValidElement(child) && !hasChildren(child)) {\n newText = ''\n } else {\n newText = childToString(child)\n }\n\n return text.concat(newText)\n },\n '',\n )\n}\n"],"mappings":";;;;AAIA,MAAa,iBACX,aACA,OACA,aACuB;CAEvB,IAAI,CAAC,aACH;CAIF,MAAM,gBAAgB,SAAS,SAAS,QAAQ;CAGhD,IAAI,CAAC,eACH;CAIF,OAAO;AACT;AAEA,MAAM,eACJ,sCAE2C,OAAO,KAClD,QAAQ,QAAQ,MAAM,QAAQ;AAEhC,MAAa,iBACX,UACW;CACX,IACE,OAAO,UAAU,eACjB,UAAU,QACV,OAAO,UAAU,WAEjB,OAAO;CAGT,IAAI,KAAK,UAAU,KAAK,MAAM,MAC5B,OAAO;CAGT,OAAQ,MAA0B,SAAS;AAC7C;AAEA,MAAa,YAAY,aAAgC;CACvD,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,2BAAgB,QAAQ,GACtD,OAAO,cAAc,QAAQ;CAG/B,OAAO,eAAS,QAAQ,QAAQ,CAAC,CAAC,QAC/B,MAAc,UAA6B;EAC1C,IAAI,UAAU;EAEd,8BAAmB,KAAK,KAAK,YAAY,KAAK,GAC5C,UAAU,SAAS,MAAM,MAAM,QAAQ;OAClC,8BAAmB,KAAK,KAAK,CAAC,YAAY,KAAK,GACpD,UAAU;OAEV,UAAU,cAAc,KAAK;EAG/B,OAAO,KAAK,OAAO,OAAO;CAC5B,GACA,EACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/TextEllipsis/helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAA;AAEzE,eAAO,MAAM,aAAa,GACxB,aAAa,OAAO,EACpB,QAAQ,MAAM,EACd,WAAW,SAAS,KACnB,MAAM,GAAG,SAgBX,CAAA;AAQD,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,KAC5C,MAcF,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,UAAU,SAAS,KAAG,MAqB9C,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/TextEllipsis/helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAA;AAEzE,eAAO,MAAM,aAAa,gBACX,OAAO,UACZ,MAAM,aACH,SAAS,KACnB,MAAM,GAAG,SAgBX,CAAA;AAQD,eAAO,MAAM,aAAa,WAChB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,KAC5C,MAcF,CAAA;AAED,eAAO,MAAM,QAAQ,aAAc,SAAS,KAAG,MAqB9C,CAAA"}
@@ -26,5 +26,5 @@ const onlyText = (children) => {
26
26
  };
27
27
 
28
28
  //#endregion
29
- export { getFinalTitle };
29
+ export { childToString, getFinalTitle, onlyText };
30
30
  //# sourceMappingURL=helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","names":["Children","isValidElement","ReactElement","ReactNode","getFinalTitle","showTooltip","title","children","undefined","resolvedTitle","onlyText","hasChildren","element","Boolean","props","childToString","child","JSON","stringify","toString","Array","isArray","toArray","reduce","text","newText","concat"],"sources":["../../../src/components/TextEllipsis/helper.ts"],"sourcesContent":["// https://github.com/fernandopasik/react-children-utilities/blob/971d8a0324e6183734d8d1af9a65dbad18ab3d00/src/lib/onlyText.ts\n\nimport { Children, isValidElement, ReactElement, ReactNode } from 'react'\n\nexport const getFinalTitle = (\n showTooltip: boolean,\n title?: string,\n children?: ReactNode,\n): string | undefined => {\n // 1. 表示フラグが false なら即終了\n if (!showTooltip) {\n return undefined\n }\n\n // 2. タイトルの候補を取得\n const resolvedTitle = title ?? onlyText(children)\n\n // 3. resolvedTitle が falsy (undefined, null, \"\") なら終了\n if (!resolvedTitle) {\n return undefined\n }\n\n // 4. 有効な文字列のみを返す\n return resolvedTitle\n}\n\nconst hasChildren = (\n element: ReactNode,\n): element is ReactElement<{ children: ReactNode[] }> =>\n isValidElement<{ children?: ReactNode[] }>(element) &&\n Boolean(element.props.children)\n\nexport const childToString = (\n child?: number | string | boolean | {} | null,\n): string => {\n if (\n typeof child === 'undefined' ||\n child === null ||\n typeof child === 'boolean'\n ) {\n return ''\n }\n\n if (JSON.stringify(child) === '{}') {\n return ''\n }\n\n return (child as string | number).toString()\n}\n\nexport const onlyText = (children: ReactNode): string => {\n if (!Array.isArray(children) && !isValidElement(children)) {\n return childToString(children)\n }\n\n return Children.toArray(children).reduce(\n (text: string, child: ReactNode): string => {\n let newText = ''\n\n if (isValidElement(child) && hasChildren(child)) {\n newText = onlyText(child.props.children)\n } else if (isValidElement(child) && !hasChildren(child)) {\n newText = ''\n } else {\n newText = childToString(child)\n }\n\n return text.concat(newText)\n },\n '',\n )\n}\n"],"mappings":";;;;AAIA,MAAaI,iBACXC,aACAC,OACAC,aACuB;CAEvB,IAAI,CAACF,aACH;CAIF,MAAMI,gBAAgBH,SAASI,SAASH,SAAS;CAGjD,IAAI,CAACE,eACH;CAIF,OAAOA;;AAGT,MAAME,eACJC,YAEAX,eAA2CW,QAAQ,IACnDC,QAAQD,QAAQE,MAAMP,SAAS;AAEjC,MAAaQ,iBACXC,UACW;CACX,IACE,OAAOA,UAAU,eACjBA,UAAU,QACV,OAAOA,UAAU,WAEjB,OAAO;CAGT,IAAIC,KAAKC,UAAUF,MAAM,KAAK,MAC5B,OAAO;CAGT,OAAQA,MAA0BG,UAAU;;AAG9C,MAAaT,YAAYH,aAAgC;CACvD,IAAI,CAACa,MAAMC,QAAQd,SAAS,IAAI,CAACN,eAAeM,SAAS,EACvD,OAAOQ,cAAcR,SAAS;CAGhC,OAAOP,SAASsB,QAAQf,SAAS,CAACgB,QAC/BC,MAAcR,UAA6B;EAC1C,IAAIS,UAAU;EAEd,IAAIxB,eAAee,MAAM,IAAIL,YAAYK,MAAM,EAC7CS,UAAUf,SAASM,MAAMF,MAAMP,SAAS;OACnC,IAAIN,eAAee,MAAM,IAAI,CAACL,YAAYK,MAAM,EACrDS,UAAU;OAEVA,UAAUV,cAAcC,MAAM;EAGhC,OAAOQ,KAAKE,OAAOD,QAAQ;IAE7B,GACD"}
1
+ {"version":3,"file":"helper.js","names":[],"sources":["../../../src/components/TextEllipsis/helper.ts"],"sourcesContent":["// https://github.com/fernandopasik/react-children-utilities/blob/971d8a0324e6183734d8d1af9a65dbad18ab3d00/src/lib/onlyText.ts\n\nimport { Children, isValidElement, ReactElement, ReactNode } from 'react'\n\nexport const getFinalTitle = (\n showTooltip: boolean,\n title?: string,\n children?: ReactNode,\n): string | undefined => {\n // 1. 表示フラグが false なら即終了\n if (!showTooltip) {\n return undefined\n }\n\n // 2. タイトルの候補を取得\n const resolvedTitle = title ?? onlyText(children)\n\n // 3. resolvedTitle が falsy (undefined, null, \"\") なら終了\n if (!resolvedTitle) {\n return undefined\n }\n\n // 4. 有効な文字列のみを返す\n return resolvedTitle\n}\n\nconst hasChildren = (\n element: ReactNode,\n): element is ReactElement<{ children: ReactNode[] }> =>\n isValidElement<{ children?: ReactNode[] }>(element) &&\n Boolean(element.props.children)\n\nexport const childToString = (\n child?: number | string | boolean | {} | null,\n): string => {\n if (\n typeof child === 'undefined' ||\n child === null ||\n typeof child === 'boolean'\n ) {\n return ''\n }\n\n if (JSON.stringify(child) === '{}') {\n return ''\n }\n\n return (child as string | number).toString()\n}\n\nexport const onlyText = (children: ReactNode): string => {\n if (!Array.isArray(children) && !isValidElement(children)) {\n return childToString(children)\n }\n\n return Children.toArray(children).reduce(\n (text: string, child: ReactNode): string => {\n let newText = ''\n\n if (isValidElement(child) && hasChildren(child)) {\n newText = onlyText(child.props.children)\n } else if (isValidElement(child) && !hasChildren(child)) {\n newText = ''\n } else {\n newText = childToString(child)\n }\n\n return text.concat(newText)\n },\n '',\n )\n}\n"],"mappings":";;;;AAIA,MAAa,iBACX,aACA,OACA,aACuB;CAEvB,IAAI,CAAC,aACH;CAIF,MAAM,gBAAgB,SAAS,SAAS,QAAQ;CAGhD,IAAI,CAAC,eACH;CAIF,OAAO;AACT;AAEA,MAAM,eACJ,YAEA,eAA2C,OAAO,KAClD,QAAQ,QAAQ,MAAM,QAAQ;AAEhC,MAAa,iBACX,UACW;CACX,IACE,OAAO,UAAU,eACjB,UAAU,QACV,OAAO,UAAU,WAEjB,OAAO;CAGT,IAAI,KAAK,UAAU,KAAK,MAAM,MAC5B,OAAO;CAGT,OAAQ,MAA0B,SAAS;AAC7C;AAEA,MAAa,YAAY,aAAgC;CACvD,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,CAAC,eAAe,QAAQ,GACtD,OAAO,cAAc,QAAQ;CAG/B,OAAO,SAAS,QAAQ,QAAQ,CAAC,CAAC,QAC/B,MAAc,UAA6B;EAC1C,IAAI,UAAU;EAEd,IAAI,eAAe,KAAK,KAAK,YAAY,KAAK,GAC5C,UAAU,SAAS,MAAM,MAAM,QAAQ;OAClC,IAAI,eAAe,KAAK,KAAK,CAAC,YAAY,KAAK,GACpD,UAAU;OAEV,UAAU,cAAc,KAAK;EAG/B,OAAO,KAAK,OAAO,OAAO;CAC5B,GACA,EACF;AACF"}
@@ -1,117 +1,33 @@
1
1
  "use client";
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  const require_useClassNames = require('../../_lib/useClassNames.cjs');
4
3
  require('./index.cjs');
5
4
  const require_helper = require('./helper.cjs');
6
5
  let react_jsx_runtime = require("react/jsx-runtime");
7
- let react_compiler_runtime = require("react-compiler-runtime");
8
6
 
9
7
  //#region src/components/TextEllipsis/index.tsx
10
8
  /**
11
9
  * 複数行のテキストに表示行数制限を設けて`...`で省略する
12
10
  */
13
- function TextEllipsis(t0) {
11
+ function TextEllipsis({ lineHeight, lineLimit = 1, children, title, hyphens = "auto", showTooltip = true, useNowrap = false, ...props }) {
14
12
  "use memo";
15
- const $ = (0, react_compiler_runtime.c)(33);
16
- if ($[0] !== "036f4b6fed1710575a7949f10872bec1708da86dc7f9ef6c9320b0b274640dca") {
17
- for (let $i = 0; $i < 33; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
18
- $[0] = "036f4b6fed1710575a7949f10872bec1708da86dc7f9ef6c9320b0b274640dca";
19
- }
20
- let children;
21
- let lineHeight;
22
- let props;
23
- let t1;
24
- let t2;
25
- let t3;
26
- let t4;
27
- let title;
28
- if ($[1] !== t0) {
29
- ({lineHeight, lineLimit: t1, children, title, hyphens: t2, showTooltip: t3, useNowrap: t4, ...props} = t0);
30
- $[1] = t0;
31
- $[2] = children;
32
- $[3] = lineHeight;
33
- $[4] = props;
34
- $[5] = t1;
35
- $[6] = t2;
36
- $[7] = t3;
37
- $[8] = t4;
38
- $[9] = title;
39
- } else {
40
- children = $[2];
41
- lineHeight = $[3];
42
- props = $[4];
43
- t1 = $[5];
44
- t2 = $[6];
45
- t3 = $[7];
46
- t4 = $[8];
47
- title = $[9];
48
- }
49
- const lineLimit = t1 === void 0 ? 1 : t1;
50
- const hyphens = t2 === void 0 ? "auto" : t2;
51
- const showTooltip = t3 === void 0 ? true : t3;
52
- const useNowrap = t4 === void 0 ? false : t4;
53
- let t5;
54
- if ($[10] !== children || $[11] !== showTooltip || $[12] !== title) {
55
- t5 = require_helper.getFinalTitle(showTooltip, title, children);
56
- $[10] = children;
57
- $[11] = showTooltip;
58
- $[12] = title;
59
- $[13] = t5;
60
- } else t5 = $[13];
61
- const finalTitle = t5;
13
+ const finalTitle = require_helper.getFinalTitle(showTooltip, title, children);
62
14
  const classNames = require_useClassNames.useClassNames("charcoal-text-ellipsis", props.className);
63
15
  const hasLineHeight = lineHeight !== void 0;
64
- let t6;
65
- if ($[14] !== useNowrap) {
66
- t6 = useNowrap ? { "data-use-nowrap": useNowrap } : {};
67
- $[14] = useNowrap;
68
- $[15] = t6;
69
- } else t6 = $[15];
70
- let t7;
71
- if ($[16] !== hasLineHeight || $[17] !== lineHeight) {
72
- t7 = hasLineHeight && { "--charcoal-text-ellipsis-line-height": `${lineHeight}px` };
73
- $[16] = hasLineHeight;
74
- $[17] = lineHeight;
75
- $[18] = t7;
76
- } else t7 = $[18];
77
- let t8;
78
- if ($[19] !== hyphens || $[20] !== lineLimit || $[21] !== props.style || $[22] !== t7) {
79
- t8 = {
80
- ...t7,
16
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
17
+ ...props,
18
+ className: classNames,
19
+ "data-line-limit": lineLimit,
20
+ "data-has-line-height": hasLineHeight,
21
+ ...useNowrap ? { "data-use-nowrap": useNowrap } : {},
22
+ style: {
23
+ ...hasLineHeight && { "--charcoal-text-ellipsis-line-height": `${lineHeight}px` },
81
24
  "--charcoal-text-ellipsis-line-limit": lineLimit,
82
25
  hyphens,
83
26
  ...props.style
84
- };
85
- $[19] = hyphens;
86
- $[20] = lineLimit;
87
- $[21] = props.style;
88
- $[22] = t7;
89
- $[23] = t8;
90
- } else t8 = $[23];
91
- const t9 = t8;
92
- let t10;
93
- if ($[24] !== children || $[25] !== classNames || $[26] !== finalTitle || $[27] !== hasLineHeight || $[28] !== lineLimit || $[29] !== props || $[30] !== t6 || $[31] !== t9) {
94
- t10 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
95
- ...props,
96
- className: classNames,
97
- "data-line-limit": lineLimit,
98
- "data-has-line-height": hasLineHeight,
99
- ...t6,
100
- style: t9,
101
- title: finalTitle,
102
- children
103
- });
104
- $[24] = children;
105
- $[25] = classNames;
106
- $[26] = finalTitle;
107
- $[27] = hasLineHeight;
108
- $[28] = lineLimit;
109
- $[29] = props;
110
- $[30] = t6;
111
- $[31] = t9;
112
- $[32] = t10;
113
- } else t10 = $[32];
114
- return t10;
27
+ },
28
+ title: finalTitle,
29
+ children
30
+ });
115
31
  }
116
32
 
117
33
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index2.cjs","names":["getFinalTitle","useClassNames","CSSProperties","TextEllipsisProps","lineHeight","lineLimit","hyphens","showTooltip","useNowrap","React","ComponentPropsWithoutRef","TextEllipsis","t0","$","_c","$i","Symbol","for","children","props","t1","t2","t3","t4","title","undefined","t5","finalTitle","classNames","className","hasLineHeight","t6","t7","t8","style","t9","t10"],"sources":["../../../src/components/TextEllipsis/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { getFinalTitle } from './helper'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { CSSProperties } from 'react'\n\nexport type TextEllipsisProps = {\n lineHeight?: number\n lineLimit?: number\n /**\n * @default 'auto'\n */\n hyphens?: CSSProperties['hyphens']\n /**\n * html title属性を付与。false のときは付与せず、空文字のときは表示しない\n * @default true\n */\n showTooltip?: boolean\n /**\n *\n * @default false\n * true: use white-space: nowrap if lineLimit is 1\n * false: use -webkit-line-clamp if lineLimit is 1\n */\n useNowrap?: boolean\n} & React.ComponentPropsWithoutRef<'div'>\n\n/**\n * 複数行のテキストに表示行数制限を設けて`...`で省略する\n */\nexport default function TextEllipsis({\n lineHeight,\n lineLimit = 1,\n children,\n title,\n hyphens = 'auto',\n showTooltip = true,\n useNowrap = false,\n ...props\n}: TextEllipsisProps) {\n 'use memo'\n const finalTitle = getFinalTitle(showTooltip, title, children)\n\n const classNames = useClassNames('charcoal-text-ellipsis', props.className)\n const hasLineHeight = lineHeight !== undefined\n\n return (\n <div\n {...props}\n className={classNames}\n data-line-limit={lineLimit}\n data-has-line-height={hasLineHeight}\n {...(useNowrap ? { 'data-use-nowrap': useNowrap } : {})}\n style={\n {\n ...(hasLineHeight && {\n '--charcoal-text-ellipsis-line-height': `${lineHeight}px`,\n }),\n '--charcoal-text-ellipsis-line-limit': lineLimit,\n hyphens,\n ...props.style,\n } satisfies React.CSSProperties\n }\n title={finalTitle}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAeW,aAAAC,IAAA;AAAA;CAAA,MAAAC,kCAAA,GAAA;CAAA,IAAAA,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAAE,KAAA,GAAAA,KAAA,IAAAA,MAAA,GAAAF,EAAAE,MAAAC,OAAAC,IAAA,4BAAA;EAAAJ,EAAA,KAAA;;CAAA,IAAAK;CAAA,IAAAd;CAAA,IAAAe;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAX,EAAA,OAAAD,IAAA;EAAsB,CAAA,CAAAR,YAAAC,WAAAe,IAAAF,UAAAM,OAAAlB,SAAAe,IAAAd,aAAAe,IAAAd,WAAAe,OAAAJ,SAAAP;EASjBC,EAAA,KAAAD;EAAAC,EAAA,KAAAK;EAAAL,EAAA,KAAAT;EAAAS,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,KAAAU;EAAAV,EAAA,KAAAW;QAAA;EAAAN,WAAAL,EAAA;EAAAT,aAAAS,EAAA;EAAAM,QAAAN,EAAA;EAAAO,KAAAP,EAAA;EAAAQ,KAAAR,EAAA;EAAAS,KAAAT,EAAA;EAAAU,KAAAV,EAAA;EAAAW,QAAAX,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;CAPD,MAAAsB,KAAAF;CAO+B,IAAAG;CAAA,IAAAvB,EAAA,QAAAK,YAAAL,EAAA,QAAAe,cAAAf,EAAA,QAAAc,cAAAd,EAAA,QAAAiB,iBAAAjB,EAAA,QAAAR,aAAAQ,EAAA,QAAAM,SAAAN,EAAA,QAAAkB,MAAAlB,EAAA,QAAAsB,IAAA;EAdnCC,MAAA,2CAAA,OAAA;GAmBM,GAlBAjB;GACOS,WAAAA;GACMvB,mBAAAA;GACKyB,wBAAAA;GAAa,GAC9BC;GAEH,OAAAI;GASKR,OAAAA;GAENT;GACG;EAAAL,EAAA,MAAAK;EAAAL,EAAA,MAAAe;EAAAf,EAAA,MAAAc;EAAAd,EAAA,MAAAiB;EAAAjB,EAAA,MAAAR;EAAAQ,EAAA,MAAAM;EAAAN,EAAA,MAAAkB;EAAAlB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;QAAAA,MAAAvB,EAAA;CAAA,OAnBNuB"}
1
+ {"version":3,"file":"index2.cjs","names":[],"sources":["../../../src/components/TextEllipsis/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { getFinalTitle } from './helper'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { CSSProperties } from 'react'\n\nexport type TextEllipsisProps = {\n lineHeight?: number\n lineLimit?: number\n /**\n * @default 'auto'\n */\n hyphens?: CSSProperties['hyphens']\n /**\n * html title属性を付与。false のときは付与せず、空文字のときは表示しない\n * @default true\n */\n showTooltip?: boolean\n /**\n *\n * @default false\n * true: use white-space: nowrap if lineLimit is 1\n * false: use -webkit-line-clamp if lineLimit is 1\n */\n useNowrap?: boolean\n} & React.ComponentPropsWithoutRef<'div'>\n\n/**\n * 複数行のテキストに表示行数制限を設けて`...`で省略する\n */\nexport default function TextEllipsis({\n lineHeight,\n lineLimit = 1,\n children,\n title,\n hyphens = 'auto',\n showTooltip = true,\n useNowrap = false,\n ...props\n}: TextEllipsisProps) {\n 'use memo'\n const finalTitle = getFinalTitle(showTooltip, title, children)\n\n const classNames = useClassNames('charcoal-text-ellipsis', props.className)\n const hasLineHeight = lineHeight !== undefined\n\n return (\n <div\n {...props}\n className={classNames}\n data-line-limit={lineLimit}\n data-has-line-height={hasLineHeight}\n {...(useNowrap ? { 'data-use-nowrap': useNowrap } : {})}\n style={\n {\n ...(hasLineHeight && {\n '--charcoal-text-ellipsis-line-height': `${lineHeight}px`,\n }),\n '--charcoal-text-ellipsis-line-limit': lineLimit,\n hyphens,\n ...props.style,\n } satisfies React.CSSProperties\n }\n title={finalTitle}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAwB,aAAa,EACnC,YACA,YAAY,GACZ,UACA,OACA,UAAU,QACV,cAAc,MACd,YAAY,OACZ,GAAG,SACiB;CACpB;CACA,MAAM,aAAa,6BAAc,aAAa,OAAO,QAAQ;CAE7D,MAAM,aAAa,oCAAc,0BAA0B,MAAM,SAAS;CAC1E,MAAM,gBAAgB,eAAe;CAErC,OACE,2CAAC,OAAD;EACE,GAAI;EACJ,WAAW;EACX,mBAAiB;EACjB,wBAAsB;EACtB,GAAK,YAAY,EAAE,mBAAmB,UAAU,IAAI,CAAC;EACrD,OACE;GACE,GAAI,iBAAiB,EACnB,wCAAwC,GAAG,WAAU,IACvD;GACA,uCAAuC;GACvC;GACA,GAAG,MAAM;EACX;EAEF,OAAO;EAEN;CACE;AAET"}
@@ -3,110 +3,31 @@ import { useClassNames } from "../../_lib/useClassNames.js";
3
3
  /* empty css */
4
4
  import { getFinalTitle } from "./helper.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { c } from "react-compiler-runtime";
7
6
 
8
7
  //#region src/components/TextEllipsis/index.tsx
9
8
  /**
10
9
  * 複数行のテキストに表示行数制限を設けて`...`で省略する
11
10
  */
12
- function TextEllipsis(t0) {
11
+ function TextEllipsis({ lineHeight, lineLimit = 1, children, title, hyphens = "auto", showTooltip = true, useNowrap = false, ...props }) {
13
12
  "use memo";
14
- const $ = c(32);
15
- let children;
16
- let lineHeight;
17
- let props;
18
- let t1;
19
- let t2;
20
- let t3;
21
- let t4;
22
- let title;
23
- if ($[0] !== t0) {
24
- ({lineHeight, lineLimit: t1, children, title, hyphens: t2, showTooltip: t3, useNowrap: t4, ...props} = t0);
25
- $[0] = t0;
26
- $[1] = children;
27
- $[2] = lineHeight;
28
- $[3] = props;
29
- $[4] = t1;
30
- $[5] = t2;
31
- $[6] = t3;
32
- $[7] = t4;
33
- $[8] = title;
34
- } else {
35
- children = $[1];
36
- lineHeight = $[2];
37
- props = $[3];
38
- t1 = $[4];
39
- t2 = $[5];
40
- t3 = $[6];
41
- t4 = $[7];
42
- title = $[8];
43
- }
44
- const lineLimit = t1 === void 0 ? 1 : t1;
45
- const hyphens = t2 === void 0 ? "auto" : t2;
46
- const showTooltip = t3 === void 0 ? true : t3;
47
- const useNowrap = t4 === void 0 ? false : t4;
48
- let t5;
49
- if ($[9] !== children || $[10] !== showTooltip || $[11] !== title) {
50
- t5 = getFinalTitle(showTooltip, title, children);
51
- $[9] = children;
52
- $[10] = showTooltip;
53
- $[11] = title;
54
- $[12] = t5;
55
- } else t5 = $[12];
56
- const finalTitle = t5;
13
+ const finalTitle = getFinalTitle(showTooltip, title, children);
57
14
  const classNames = useClassNames("charcoal-text-ellipsis", props.className);
58
15
  const hasLineHeight = lineHeight !== void 0;
59
- let t6;
60
- if ($[13] !== useNowrap) {
61
- t6 = useNowrap ? { "data-use-nowrap": useNowrap } : {};
62
- $[13] = useNowrap;
63
- $[14] = t6;
64
- } else t6 = $[14];
65
- let t7;
66
- if ($[15] !== hasLineHeight || $[16] !== lineHeight) {
67
- t7 = hasLineHeight && { "--charcoal-text-ellipsis-line-height": `${lineHeight}px` };
68
- $[15] = hasLineHeight;
69
- $[16] = lineHeight;
70
- $[17] = t7;
71
- } else t7 = $[17];
72
- let t8;
73
- if ($[18] !== hyphens || $[19] !== lineLimit || $[20] !== props.style || $[21] !== t7) {
74
- t8 = {
75
- ...t7,
16
+ return /* @__PURE__ */ jsx("div", {
17
+ ...props,
18
+ className: classNames,
19
+ "data-line-limit": lineLimit,
20
+ "data-has-line-height": hasLineHeight,
21
+ ...useNowrap ? { "data-use-nowrap": useNowrap } : {},
22
+ style: {
23
+ ...hasLineHeight && { "--charcoal-text-ellipsis-line-height": `${lineHeight}px` },
76
24
  "--charcoal-text-ellipsis-line-limit": lineLimit,
77
25
  hyphens,
78
26
  ...props.style
79
- };
80
- $[18] = hyphens;
81
- $[19] = lineLimit;
82
- $[20] = props.style;
83
- $[21] = t7;
84
- $[22] = t8;
85
- } else t8 = $[22];
86
- const t9 = t8;
87
- let t10;
88
- if ($[23] !== children || $[24] !== classNames || $[25] !== finalTitle || $[26] !== hasLineHeight || $[27] !== lineLimit || $[28] !== props || $[29] !== t6 || $[30] !== t9) {
89
- t10 = /* @__PURE__ */ jsx("div", {
90
- ...props,
91
- className: classNames,
92
- "data-line-limit": lineLimit,
93
- "data-has-line-height": hasLineHeight,
94
- ...t6,
95
- style: t9,
96
- title: finalTitle,
97
- children
98
- });
99
- $[23] = children;
100
- $[24] = classNames;
101
- $[25] = finalTitle;
102
- $[26] = hasLineHeight;
103
- $[27] = lineLimit;
104
- $[28] = props;
105
- $[29] = t6;
106
- $[30] = t9;
107
- $[31] = t10;
108
- } else t10 = $[31];
109
- return t10;
27
+ },
28
+ title: finalTitle,
29
+ children
30
+ });
110
31
  }
111
32
 
112
33
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","names":["getFinalTitle","useClassNames","CSSProperties","TextEllipsisProps","lineHeight","lineLimit","hyphens","showTooltip","useNowrap","React","ComponentPropsWithoutRef","TextEllipsis","t0","$","_c","children","props","t1","t2","t3","t4","title","undefined","t5","finalTitle","classNames","className","hasLineHeight","t6","t7","t8","style","t9","t10"],"sources":["../../../src/components/TextEllipsis/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { getFinalTitle } from './helper'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { CSSProperties } from 'react'\n\nexport type TextEllipsisProps = {\n lineHeight?: number\n lineLimit?: number\n /**\n * @default 'auto'\n */\n hyphens?: CSSProperties['hyphens']\n /**\n * html title属性を付与。false のときは付与せず、空文字のときは表示しない\n * @default true\n */\n showTooltip?: boolean\n /**\n *\n * @default false\n * true: use white-space: nowrap if lineLimit is 1\n * false: use -webkit-line-clamp if lineLimit is 1\n */\n useNowrap?: boolean\n} & React.ComponentPropsWithoutRef<'div'>\n\n/**\n * 複数行のテキストに表示行数制限を設けて`...`で省略する\n */\nexport default function TextEllipsis({\n lineHeight,\n lineLimit = 1,\n children,\n title,\n hyphens = 'auto',\n showTooltip = true,\n useNowrap = false,\n ...props\n}: TextEllipsisProps) {\n 'use memo'\n const finalTitle = getFinalTitle(showTooltip, title, children)\n\n const classNames = useClassNames('charcoal-text-ellipsis', props.className)\n const hasLineHeight = lineHeight !== undefined\n\n return (\n <div\n {...props}\n className={classNames}\n data-line-limit={lineLimit}\n data-has-line-height={hasLineHeight}\n {...(useNowrap ? { 'data-use-nowrap': useNowrap } : {})}\n style={\n {\n ...(hasLineHeight && {\n '--charcoal-text-ellipsis-line-height': `${lineHeight}px`,\n }),\n '--charcoal-text-ellipsis-line-limit': lineLimit,\n hyphens,\n ...props.style,\n } satisfies React.CSSProperties\n }\n title={finalTitle}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAeW,aAAAC,IAAA;AAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAX;CAAA,IAAAY;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAR,EAAA,OAAAD,IAAA;EAAsB,CAAA,CAAAR,YAAAC,WAAAY,IAAAF,UAAAM,OAAAf,SAAAY,IAAAX,aAAAY,IAAAX,WAAAY,OAAAJ,SAAAJ;EASjBC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAT;EAAAS,EAAA,KA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AAQ,EAAA,QAAAG,MAAAe,SAAAlB,EAAA,QAAAgB,IAAA;EAHHC,KAAA;GAAA,GACMD;GAEH,uCACsCxB;GAASC;GAAA,GAE7CU,MAAKe;GACT;EAAAlB,EAAA,MAAAP;EAAAO,EAAA,MAAAR;EAAAQ,EAAA,MAAAG,MAAAe;EAAAlB,EAAA,MAAAgB;EAAAhB,EAAA,MAAAiB;QAAAA,KAAAjB,EAAA;CAPD,MAAAmB,KAAAF;CAO+B,IAAAG;CAAA,IAAApB,EAAA,QAAAE,YAAAF,EAAA,QAAAY,cAAAZ,EAAA,QAAAW,cAAAX,EAAA,QAAAc,iBAAAd,EAAA,QAAAR,aAAAQ,EAAA,QAAAG,SAAAH,EAAA,QAAAe,MAAAf,EAAA,QAAAmB,IAAA;EAdnCC,MAAA,oBAAA,OAAA;GAmBM,GAlBAjB;GACOS,WAAAA;GACMpB,mBAAAA;GACKsB,wBAAAA;GAAa,GAC9BC;GAEH,OAAAI;GASKR,OAAAA;GAENT;GACG;EAAAF,EAAA,MAAAE;EAAAF,EAAA,MAAAY;EAAAZ,EAAA,MAAAW;EAAAX,EAAA,MAAAc;EAAAd,EAAA,MAAAR;EAAAQ,EAAA,MAAAG;EAAAH,EAAA,MAAAe;EAAAf,EAAA,MAAAmB;EAAAnB,EAAA,MAAAoB;QAAAA,MAAApB,EAAA;CAAA,OAnBNoB"}
1
+ {"version":3,"file":"index2.js","names":[],"sources":["../../../src/components/TextEllipsis/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { getFinalTitle } from './helper'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { CSSProperties } from 'react'\n\nexport type TextEllipsisProps = {\n lineHeight?: number\n lineLimit?: number\n /**\n * @default 'auto'\n */\n hyphens?: CSSProperties['hyphens']\n /**\n * html title属性を付与。false のときは付与せず、空文字のときは表示しない\n * @default true\n */\n showTooltip?: boolean\n /**\n *\n * @default false\n * true: use white-space: nowrap if lineLimit is 1\n * false: use -webkit-line-clamp if lineLimit is 1\n */\n useNowrap?: boolean\n} & React.ComponentPropsWithoutRef<'div'>\n\n/**\n * 複数行のテキストに表示行数制限を設けて`...`で省略する\n */\nexport default function TextEllipsis({\n lineHeight,\n lineLimit = 1,\n children,\n title,\n hyphens = 'auto',\n showTooltip = true,\n useNowrap = false,\n ...props\n}: TextEllipsisProps) {\n 'use memo'\n const finalTitle = getFinalTitle(showTooltip, title, children)\n\n const classNames = useClassNames('charcoal-text-ellipsis', props.className)\n const hasLineHeight = lineHeight !== undefined\n\n return (\n <div\n {...props}\n className={classNames}\n data-line-limit={lineLimit}\n data-has-line-height={hasLineHeight}\n {...(useNowrap ? { 'data-use-nowrap': useNowrap } : {})}\n style={\n {\n ...(hasLineHeight && {\n '--charcoal-text-ellipsis-line-height': `${lineHeight}px`,\n }),\n '--charcoal-text-ellipsis-line-limit': lineLimit,\n hyphens,\n ...props.style,\n } satisfies React.CSSProperties\n }\n title={finalTitle}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAwB,aAAa,EACnC,YACA,YAAY,GACZ,UACA,OACA,UAAU,QACV,cAAc,MACd,YAAY,OACZ,GAAG,SACiB;CACpB;CACA,MAAM,aAAa,cAAc,aAAa,OAAO,QAAQ;CAE7D,MAAM,aAAa,cAAc,0BAA0B,MAAM,SAAS;CAC1E,MAAM,gBAAgB,eAAe;CAErC,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,WAAW;EACX,mBAAiB;EACjB,wBAAsB;EACtB,GAAK,YAAY,EAAE,mBAAmB,UAAU,IAAI,CAAC;EACrD,OACE;GACE,GAAI,iBAAiB,EACnB,wCAAwC,GAAG,WAAU,IACvD;GACA,uCAAuC;GACvC;GACA,GAAG,MAAM;EACX;EAEF,OAAO;EAEN;CACE;AAET"}
@@ -1,5 +1,5 @@
1
1
  import './index.css';
2
2
  export declare const AssistiveText: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
- ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
3
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
4
4
  }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.cjs","names":["createDivComponent","AssistiveText"],"sources":["../../../../src/components/TextField/AssistiveText/index.tsx"],"sourcesContent":["import { createDivComponent } from '../../../_lib/createDivComponent'\nimport './index.css'\n\nexport const AssistiveText = createDivComponent(\n 'charcoal-text-field-assistive-text',\n)\n"],"mappings":";;;;;AAGA,MAAaC,gBAAgBD,8CAC3B,qCACD"}
1
+ {"version":3,"file":"index2.cjs","names":[],"sources":["../../../../src/components/TextField/AssistiveText/index.tsx"],"sourcesContent":["import { createDivComponent } from '../../../_lib/createDivComponent'\nimport './index.css'\n\nexport const AssistiveText = createDivComponent(\n 'charcoal-text-field-assistive-text',\n)\n"],"mappings":";;;;;AAGA,MAAa,gBAAgB,8CAC3B,oCACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","names":["createDivComponent","AssistiveText"],"sources":["../../../../src/components/TextField/AssistiveText/index.tsx"],"sourcesContent":["import { createDivComponent } from '../../../_lib/createDivComponent'\nimport './index.css'\n\nexport const AssistiveText = createDivComponent(\n 'charcoal-text-field-assistive-text',\n)\n"],"mappings":";;;;;AAGA,MAAaC,gBAAgBD,mBAC3B,qCACD"}
1
+ {"version":3,"file":"index2.js","names":[],"sources":["../../../../src/components/TextField/AssistiveText/index.tsx"],"sourcesContent":["import { createDivComponent } from '../../../_lib/createDivComponent'\nimport './index.css'\n\nexport const AssistiveText = createDivComponent(\n 'charcoal-text-field-assistive-text',\n)\n"],"mappings":";;;;;AAGA,MAAa,gBAAgB,mBAC3B,oCACF"}
@@ -32,6 +32,6 @@ declare const TextField: React.ForwardRefExoticComponent<{
32
32
  subLabel?: React.ReactNode;
33
33
  rdfaPrefix?: string;
34
34
  getCount?: (value: string) => number;
35
- } & Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "prefix" | "onChange"> & React.RefAttributes<HTMLInputElement>>;
35
+ } & Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "onChange" | "prefix"> & React.RefAttributes<HTMLInputElement>>;
36
36
  export default TextField;
37
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAA;AAC3E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAElB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAElC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,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AQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CACrC,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAA;AAExE,QAAA,MAAM,SAAS;aApBJ,SAAS;aACT,SAAS;YAEV,MAAM;eACH,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;gBAEtB,OAAO;gBACP,OAAO;oBACH,MAAM;cACZ,OAAO;YAET,MAAM;mBACC,MAAM;eACV,OAAO;eACP,KAAK,CAAC,SAAS;iBACb,MAAM;eAER,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM;6KAqHrC,CAAA;eAEc,SAAS"}
@@ -7,7 +7,7 @@ const require_index$2 = require('../../_lib/index.cjs');
7
7
  const require_useFocusWithClick = require('./useFocusWithClick.cjs');
8
8
  const require_index$3 = require('./AssistiveText/index2.cjs');
9
9
  let react = require("react");
10
- react = require_runtime.__toESM(react);
10
+ react = require_runtime.__toESM(react, 1);
11
11
  let react_jsx_runtime = require("react/jsx-runtime");
12
12
  let react_aria_useId = require("react-aria/useId");
13
13
  let react_aria_VisuallyHidden = require("react-aria/VisuallyHidden");
@@ -1 +1 @@
1
- {"version":3,"file":"index2.cjs","names":["ReactNode","useCallback","useEffect","useRef","useState","React","FieldLabel","countCodePointsInString","mergeRefs","useFocusWithClick","AssistiveText","useClassNames","useVisuallyHidden","useId","TextFieldProps","prefix","suffix","value","onChange","showCount","showLabel","assistiveText","invalid","label","requiredText","disabled","subLabel","rdfaPrefix","getCount","Omit","ComponentPropsWithoutRef","TextField","forwardRef","HTMLInputElement","SingleLineTextFieldInner","className","maxLength","required","type","props","inputRef","visuallyHiddenProps","count","setCount","handleChange","e","ChangeEvent","target","undefined","containerRef","inputId","id","describedbyId","labelledbyId","showAssistiveText","length","classNames"],"sources":["../../../src/components/TextField/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from './useFocusWithClick'\nimport { AssistiveText } from './AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\nexport type TextFieldProps = {\n prefix?: ReactNode\n suffix?: ReactNode\n\n value?: string\n onChange?: (value: string) => void\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n rdfaPrefix?: string\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'input'>, 'prefix' | 'onChange'>\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n function SingleLineTextFieldInner(\n {\n assistiveText,\n className,\n disabled = false,\n label = '',\n maxLength,\n onChange,\n prefix = null,\n required,\n requiredText,\n showCount = false,\n showLabel = false,\n subLabel,\n suffix = null,\n type = 'text',\n invalid,\n value,\n getCount = countCodePointsInString,\n ...props\n },\n forwardRef,\n ) {\n const inputRef = useRef<HTMLInputElement>(null)\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const [count, setCount] = useState(getCount(value ?? ''))\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n setCount(count)\n onChange?.(value)\n },\n [getCount, maxLength, onChange],\n )\n\n useEffect(() => {\n setCount(getCount(value ?? ''))\n }, [getCount, value])\n\n const containerRef = useRef(null)\n\n useFocusWithClick(containerRef, inputRef)\n\n const inputId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const classNames = useClassNames('charcoal-text-field-root', className)\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={inputId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-field-container\"\n aria-disabled={disabled === true ? true : undefined}\n data-invalid={invalid === true}\n ref={containerRef}\n >\n {prefix && <div className=\"charcoal-text-field-prefix\">{prefix}</div>}\n <div className=\"charcoal-text-field-input-root\">\n <input\n className=\"charcoal-text-field-input\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={inputId}\n data-invalid={invalid === true}\n maxLength={maxLength}\n onChange={handleChange}\n disabled={disabled}\n ref={mergeRefs(forwardRef, inputRef)}\n type={type}\n value={value}\n {...props}\n />\n </div>\n {(suffix || showCount) && (\n <div className=\"charcoal-text-field-suffix\">\n {suffix}\n {showCount && (\n <span className=\"charcoal-text-field-line-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextField\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAM+B,YAAY1B,MAAM2B,WACtB,SAASE,yBACP,EACEb,eACAc,WACAV,WAAW,OACXF,QAAQ,IACRa,WACAlB,UACAH,SAAS,MACTsB,UACAb,cACAL,YAAY,OACZC,YAAY,OACZM,UACAV,SAAS,MACTsB,OAAO,QACPhB,SACAL,OACAW,WAAWrB,yCACX,GAAGgC,SAELP,YACA;CACA,MAAMQ,6BAAoC,KAAK;CAE/C,MAAM,EAAEC,0EAA2C;CAEnD,MAAM,CAACC,OAAOC,gCA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,QACAG,aACC,2CAAC,QAAD;OAAM,WAAU;iBACbiB,cAAcY,SAAY,GAAGN,MAAK,GAAIN,cAAcM;OAExD,EAEJ;;KACE;;GACJY,qBACC,2CAAC,+BAAD;IAAe,gBAAchC,YAAY;IAAM,IAAI8B;cAChD/B;IAEJ;GACG;;EAGX"}
1
+ {"version":3,"file":"index2.cjs","names":[],"sources":["../../../src/components/TextField/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport FieldLabel from '../FieldLabel'\nimport { countCodePointsInString, mergeRefs } from '../../_lib'\nimport { useFocusWithClick } from './useFocusWithClick'\nimport { AssistiveText } from './AssistiveText'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport { useVisuallyHidden } from 'react-aria/VisuallyHidden'\nimport { useId } from 'react-aria/useId'\n\nexport type TextFieldProps = {\n prefix?: ReactNode\n suffix?: ReactNode\n\n value?: string\n onChange?: (value: string) => void\n\n showCount?: boolean\n showLabel?: boolean\n assistiveText?: string\n invalid?: boolean\n\n label?: string\n requiredText?: string\n disabled?: boolean\n subLabel?: React.ReactNode\n rdfaPrefix?: string\n\n getCount?: (value: string) => number\n} & Omit<React.ComponentPropsWithoutRef<'input'>, 'prefix' | 'onChange'>\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n function SingleLineTextFieldInner(\n {\n assistiveText,\n className,\n disabled = false,\n label = '',\n maxLength,\n onChange,\n prefix = null,\n required,\n requiredText,\n showCount = false,\n showLabel = false,\n subLabel,\n suffix = null,\n type = 'text',\n invalid,\n value,\n getCount = countCodePointsInString,\n ...props\n },\n forwardRef,\n ) {\n const inputRef = useRef<HTMLInputElement>(null)\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n\n const [count, setCount] = useState(getCount(value ?? ''))\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n const count = getCount(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n setCount(count)\n onChange?.(value)\n },\n [getCount, maxLength, onChange],\n )\n\n useEffect(() => {\n setCount(getCount(value ?? ''))\n }, [getCount, value])\n\n const containerRef = useRef(null)\n\n useFocusWithClick(containerRef, inputRef)\n\n const inputId = useId(props.id)\n const describedbyId = useId()\n const labelledbyId = useId()\n\n const showAssistiveText =\n assistiveText != null && assistiveText.length !== 0\n\n const classNames = useClassNames('charcoal-text-field-root', className)\n\n return (\n <div className={classNames} aria-disabled={disabled}>\n <FieldLabel\n htmlFor={inputId}\n id={labelledbyId}\n label={label}\n required={required}\n requiredText={requiredText}\n subLabel={subLabel}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <div\n className=\"charcoal-text-field-container\"\n aria-disabled={disabled === true ? true : undefined}\n data-invalid={invalid === true}\n ref={containerRef}\n >\n {prefix && <div className=\"charcoal-text-field-prefix\">{prefix}</div>}\n <div className=\"charcoal-text-field-input-root\">\n <input\n className=\"charcoal-text-field-input\"\n aria-describedby={showAssistiveText ? describedbyId : undefined}\n aria-invalid={invalid}\n aria-labelledby={labelledbyId}\n id={inputId}\n data-invalid={invalid === true}\n maxLength={maxLength}\n onChange={handleChange}\n disabled={disabled}\n ref={mergeRefs(forwardRef, inputRef)}\n type={type}\n value={value}\n {...props}\n />\n </div>\n {(suffix || showCount) && (\n <div className=\"charcoal-text-field-suffix\">\n {suffix}\n {showCount && (\n <span className=\"charcoal-text-field-line-counter\">\n {maxLength !== undefined ? `${count}/${maxLength}` : count}\n </span>\n )}\n </div>\n )}\n </div>\n {showAssistiveText && (\n <AssistiveText data-invalid={invalid === true} id={describedbyId}>\n {assistiveText}\n </AssistiveText>\n )}\n </div>\n )\n },\n)\n\nexport default TextField\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAM,YAAY,MAAM,WACtB,SAAS,yBACP,EACE,eACA,WACA,WAAW,OACX,QAAQ,IACR,WACA,UACA,SAAS,MACT,UACA,cACA,YAAY,OACZ,YAAY,OACZ,UAC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