@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.
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.cjs +0 -1
- package/dist/_lib/createDivComponent.cjs.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +1 -1
- package/dist/_lib/createDivComponent.js.map +1 -1
- package/dist/_lib/index.cjs.map +1 -1
- package/dist/_lib/index.js.map +1 -1
- package/dist/_lib/useClassNames.cjs +0 -1
- package/dist/_lib/useClassNames.cjs.map +1 -1
- package/dist/_lib/useClassNames.js.map +1 -1
- package/dist/_lib/useForwardedRef.cjs +1 -1
- package/dist/_lib/useForwardedRef.cjs.map +1 -1
- package/dist/_lib/useForwardedRef.js.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs +0 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index2.cjs +1 -1
- package/dist/components/Button/index2.cjs.map +1 -1
- package/dist/components/Button/index2.js.map +1 -1
- package/dist/components/Carousel/CarouselItem.cjs +0 -1
- package/dist/components/Carousel/CarouselItem.cjs.map +1 -1
- package/dist/components/Carousel/CarouselItem.d.ts.map +1 -1
- package/dist/components/Carousel/CarouselItem.js.map +1 -1
- package/dist/components/Carousel/carouselStore.cjs.map +1 -1
- package/dist/components/Carousel/carouselStore.js.map +1 -1
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Carousel/index.d.ts.map +1 -1
- package/dist/components/Carousel/index2.cjs +0 -1
- package/dist/components/Carousel/index2.cjs.map +1 -1
- package/dist/components/Carousel/index2.js.map +1 -1
- package/dist/components/Carousel/intersectionObserver.cjs.map +1 -1
- package/dist/components/Carousel/intersectionObserver.js.map +1 -1
- package/dist/components/Carousel/resizeObserver.cjs.map +1 -1
- package/dist/components/Carousel/resizeObserver.js.map +1 -1
- package/dist/components/Carousel/store.cjs.map +1 -1
- package/dist/components/Carousel/store.js.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.cjs +0 -1
- package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.js.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs +0 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +2 -2
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index2.cjs +0 -1
- package/dist/components/Checkbox/index2.cjs.map +1 -1
- package/dist/components/Checkbox/index2.js.map +1 -1
- package/dist/components/Clickable/index.d.ts +1 -1
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/Clickable/index2.cjs +1 -1
- package/dist/components/Clickable/index2.cjs.map +1 -1
- package/dist/components/Clickable/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.cjs +29 -2
- package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.js +30 -2
- package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs +18 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.js +19 -1
- package/dist/components/DropdownSelector/Popover/index2.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +0 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index2.cjs +27 -10
- package/dist/components/DropdownSelector/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/index2.js +26 -9
- package/dist/components/DropdownSelector/index2.js.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -1
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/FieldLabel/index2.cjs +1 -1
- package/dist/components/FieldLabel/index2.cjs.map +1 -1
- package/dist/components/FieldLabel/index2.js.map +1 -1
- package/dist/components/HintText/index2.cjs +0 -1
- package/dist/components/HintText/index2.cjs.map +1 -1
- package/dist/components/HintText/index2.js.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index2.cjs +1 -1
- package/dist/components/IconButton/index2.cjs.map +1 -1
- package/dist/components/IconButton/index2.js.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index2.cjs +0 -1
- package/dist/components/LoadingSpinner/index2.cjs.map +1 -1
- package/dist/components/LoadingSpinner/index2.js.map +1 -1
- package/dist/components/Modal/Dialog/index2.cjs +1 -1
- package/dist/components/Modal/Dialog/index2.cjs.map +1 -1
- package/dist/components/Modal/Dialog/index2.js.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.js.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +3 -3
- package/dist/components/Modal/ModalPlumbing2.cjs +0 -1
- package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -1
- package/dist/components/Modal/ModalPlumbing2.js.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index2.cjs +1 -1
- package/dist/components/Modal/index2.cjs.map +1 -1
- package/dist/components/Modal/index2.js.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.js.map +1 -1
- package/dist/components/Modal/useTransitionPresence.cjs +1 -3
- package/dist/components/Modal/useTransitionPresence.cjs.map +1 -1
- package/dist/components/Modal/useTransitionPresence.js +1 -2
- package/dist/components/Modal/useTransitionPresence.js.map +1 -1
- package/dist/components/MultiSelect/context.cjs +0 -1
- package/dist/components/MultiSelect/context.cjs.map +1 -1
- package/dist/components/MultiSelect/context.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index2.cjs +2 -2
- package/dist/components/MultiSelect/index2.cjs.map +1 -1
- package/dist/components/MultiSelect/index2.js.map +1 -1
- package/dist/components/Pagination/PaginationContext.cjs +0 -1
- package/dist/components/Pagination/PaginationContext.cjs.map +1 -1
- package/dist/components/Pagination/PaginationContext.js.map +1 -1
- package/dist/components/Pagination/helper.cjs.map +1 -1
- package/dist/components/Pagination/helper.js.map +1 -1
- package/dist/components/Pagination/index2.cjs +26 -135
- package/dist/components/Pagination/index2.cjs.map +1 -1
- package/dist/components/Pagination/index2.js +86 -182
- package/dist/components/Pagination/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroupContext.cjs.map +1 -1
- package/dist/components/Radio/RadioGroupContext.js.map +1 -1
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioInput/index2.cjs +0 -1
- package/dist/components/Radio/RadioInput/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioInput/index2.js.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index2.cjs +2 -2
- package/dist/components/Radio/index2.cjs.map +1 -1
- package/dist/components/Radio/index2.js.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index2.cjs +1 -1
- package/dist/components/SegmentedControl/index2.cjs.map +1 -1
- package/dist/components/SegmentedControl/index2.js.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.cjs +0 -1
- package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.js.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.d.ts +2 -2
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.js.map +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index2.cjs +0 -1
- package/dist/components/Switch/index2.cjs.map +1 -1
- package/dist/components/Switch/index2.js.map +1 -1
- package/dist/components/TagItem/index.d.ts +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TagItem/index2.cjs +1 -1
- package/dist/components/TagItem/index2.cjs.map +1 -1
- package/dist/components/TagItem/index2.js.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextArea/index2.cjs +0 -1
- package/dist/components/TextArea/index2.cjs.map +1 -1
- package/dist/components/TextArea/index2.js.map +1 -1
- package/dist/components/TextEllipsis/helper.cjs +2 -1
- package/dist/components/TextEllipsis/helper.cjs.map +1 -1
- package/dist/components/TextEllipsis/helper.d.ts.map +1 -1
- package/dist/components/TextEllipsis/helper.js +1 -1
- package/dist/components/TextEllipsis/helper.js.map +1 -1
- package/dist/components/TextEllipsis/index2.cjs +14 -98
- package/dist/components/TextEllipsis/index2.cjs.map +1 -1
- package/dist/components/TextEllipsis/index2.js +14 -93
- package/dist/components/TextEllipsis/index2.js.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +1 -1
- package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -1
- package/dist/components/TextField/AssistiveText/index2.js.map +1 -1
- package/dist/components/TextField/index.d.ts +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index2.cjs +1 -1
- package/dist/components/TextField/index2.cjs.map +1 -1
- package/dist/components/TextField/index2.js.map +1 -1
- package/dist/components/TextField/useFocusWithClick.cjs +0 -1
- package/dist/components/TextField/useFocusWithClick.cjs.map +1 -1
- package/dist/components/TextField/useFocusWithClick.js.map +1 -1
- package/dist/core/CharcoalProvider.cjs +1 -1
- package/dist/core/CharcoalProvider.cjs.map +1 -1
- package/dist/core/CharcoalProvider.js.map +1 -1
- package/dist/core/SSRProvider.cjs +1 -1
- package/dist/core/SSRProvider.cjs.map +1 -1
- package/dist/core/SSRProvider.js +1 -1
- package/dist/core/SSRProvider.js.map +1 -1
- package/dist/core/SetThemeScript.cjs +0 -1
- package/dist/core/SetThemeScript.cjs.map +1 -1
- package/dist/core/SetThemeScript.js.map +1 -1
- package/dist/core/themeHelper.cjs +0 -1
- package/dist/core/themeHelper.cjs.map +1 -1
- package/dist/core/themeHelper.d.ts +2 -2
- package/dist/core/themeHelper.d.ts.map +1 -1
- package/dist/core/themeHelper.js.map +1 -1
- package/dist/index.cjs +22 -23
- package/dist/index.css +1000 -1000
- package/dist/layered.css +1000 -1000
- package/dist/layered.css.map +1 -1
- package/package.json +10 -10
- package/src/_lib/compat.ts +1 -7
- package/src/components/Carousel/index.browser.test.tsx +1 -1
- package/src/components/Carousel/intersectionObserver.test.ts +12 -12
- package/src/components/Carousel/resizeObserver.test.ts +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +40 -2
- package/src/components/DropdownSelector/Popover/index.tsx +20 -1
- package/src/components/DropdownSelector/index.browser.test.tsx +94 -0
- package/src/components/DropdownSelector/index.test.tsx +57 -2
- package/src/components/DropdownSelector/index.tsx +37 -12
- package/src/components/FieldLabel/index.tsx +1 -2
- package/src/components/Icon/index.tsx +2 -1
- package/src/components/Modal/__snapshots__/index.css.snap +1 -0
- package/src/components/TextEllipsis/TextEllipsis.story.tsx +1 -1
- 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,YA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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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@@ -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,WAAW9C,SAASuC,YAAY;CAC7C,MAAM,CAACQ,OAAOC,YAAYhD,SAAS6B,SAASe,WAAW,CAAC;CAExD,MAAMK,cAAclD,OAA4B,KAAK;CACrD,MAAMmD,eAAenD,OAAO,KAAK;CACjCK,kBAAkB8C,cAAcD,YAAY;CAC5C,MAAM,EAAEE,wBAAwB5C,mBAAmB;CAEnD,MAAM6C,qBAAqBtD,cACnB6B,cAAeC,WAAWA,WAAW,GAC3C,CAACD,YAAYC,QACf,CAAC;CACD,MAAMyB,aAAa/C,cAAc,2BAA2B6B,UAAU;CACtE,MAAMmB,oBACJlC,iBAAiB,QAAQA,cAAcmC,WAAW;CAEpD,MAAMC,aAAa7D,aAChB8D,aAAkC;EACjC,MAAMC,eACH,GAAGD,SAAS9C,MAAK,IAAKgD,MAAM,OAAO,EAAEJ,UAAU,MAAM;EACxD,MAAMK,kBAAkBhC,YAAYe,UAAaf,WAAW;EAC5D,MAAMiC,WAAWtB,eAAemB,cAAcA,cAAcnB;E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;GACE,oBAAC,YAAD;IACE,SAAS8C;IACT,IAAIG;IACGnD;IACGc;IACIb;IACJE;IACV,GAAK,CAACN,YAAYgC,sBAAsB,EAAG;IAAC;GAE9C,qBAAC,OAAD;IACE,WAAU;IACV,iBAAe3B,aAAa,OAAO,SAASmB;IAC5C,gBAActB,YAAY;IAC1B,KAAK6B;IACL,OAAO,EACL,6BAA6BZ,MAC9B;cAPH,CASE,oBAAC,YAAD;KACE,WAAU;KACV,oBAAkBgB,oBAAoBkB,gBAAgB7B;KACtD,gBAActB;KACd,mBAAiBoD;KACjB,IAAIH;KACOjC;KACX,0BAAwBnB;KACxB,UAAU+C;KACV,KAAK9D,UAAUT,YAAYuD,YAAY;KACjCX;KACC3B;KACGa;KACIgB;KACd,GAAIC;KAAM,GAEXvB,aACC,oBAAC,QAAD;KAAM,WAAU;eACbmB,cAAcM,SAAY,GAAGI,MAAK,GAAIV,cAAcU;KAExD,EACE;;GACJO,qBACC,oBAAC,eAAD;IAAe,gBAAcjC,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;CAGjC,MAAM,aAAa,SAAS,cAAc,SAAS,KAAK;CACxD,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAS,SAAS,UAAU,CAAC;CAEvD,MAAM,cAAc,OAA4B,IAAI;CACpD,MAAM,eAAe,OAAO,IAAI;CAChC,kBAAkB,cAAc,WAAW;CAC3C,MAAM,EAAE,wBAAwB,kBAAkB;CAElD,MAAM,qBAAqB,cACnB,cAAe,WAAW,WAAW,GAC3C,CAAC,YAAY,OAAO,CACtB;CACA,MAAM,aAAa,cAAc,2BAA2B,SAAS;CACrE,MAAM,oBACJ,iBAAiB,QAAQ,cAAc,WAAW;CAEpD,MAAM,aAAa,aAChB,aAAkC;EACjC,MAAM,eACH,GAAG,SAAS,MAAK,IAAK,MAAM,MAAM,CAAC,EAAE,UAAU,MAAM;EACxD,MAAM,kBAAkB,YAAY,UAAa,WAAW;EAC5D,MAAM,WAAW,eAAe,cAAc,cAAc;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,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":[
|
|
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,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","names":[
|
|
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(
|
|
11
|
+
function TextEllipsis({ lineHeight, lineLimit = 1, children, title, hyphens = "auto", showTooltip = true, useNowrap = false, ...props }) {
|
|
14
12
|
"use memo";
|
|
15
|
-
const
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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":[
|
|
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(
|
|
11
|
+
function TextEllipsis({ lineHeight, lineLimit = 1, children, title, hyphens = "auto", showTooltip = true, useNowrap = false, ...props }) {
|
|
13
12
|
"use memo";
|
|
14
|
-
const
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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":[
|
|
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]) |
|
|
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":[
|
|
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":[
|
|
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">, "
|
|
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,KAA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,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,MAAM,CAAA;IACrB,QAAQ,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":[
|
|
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,UACA,SAAS,MACT,OAAO,QACP,SACA,OACA,WAAW,yCACX,GAAG,SAEL,YACA;CACA,MAAM,6BAAoC,IAAI;CAE9C,MAAM,EAAE,yEAA0C;CAElD,MAAM,CAAC,OAAO,gCAAqB,SAAS,SAAS,EAAE,CAAC;CAExD,MAAM,uCACH,MAA2C;EAC1C,MAAM,QAAQ,EAAE,OAA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