@charcoal-ui/react 6.0.0-rc.7 → 6.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_lib/createDivComponent.cjs +20 -0
- package/dist/_lib/createDivComponent.cjs.map +1 -0
- package/dist/_lib/createDivComponent.js +19 -0
- package/dist/_lib/createDivComponent.js.map +1 -0
- package/dist/_lib/index.cjs +22 -0
- package/dist/_lib/index.cjs.map +1 -0
- package/dist/_lib/index.js +20 -0
- package/dist/_lib/index.js.map +1 -0
- package/dist/_lib/useClassNames.cjs +15 -0
- package/dist/_lib/useClassNames.cjs.map +1 -0
- package/dist/_lib/useClassNames.js +14 -0
- package/dist/_lib/useClassNames.js.map +1 -0
- package/dist/_lib/useForwardedRef.cjs +19 -0
- package/dist/_lib/useForwardedRef.cjs.map +1 -0
- package/dist/_lib/useForwardedRef.js +17 -0
- package/dist/_lib/useForwardedRef.js.map +1 -0
- package/dist/_lib/useIsomorphicLayoutEffect.cjs +13 -0
- package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -0
- package/dist/_lib/useIsomorphicLayoutEffect.js +12 -0
- package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +30 -0
- package/dist/components/Button/index2.cjs +26 -0
- package/dist/components/Button/index2.cjs.map +1 -0
- package/dist/components/Button/index2.js +24 -0
- package/dist/components/Button/index2.js.map +1 -0
- package/dist/components/Carousel/CarouselItem.cjs +46 -0
- package/dist/components/Carousel/CarouselItem.cjs.map +1 -0
- package/dist/components/Carousel/CarouselItem.js +45 -0
- package/dist/components/Carousel/CarouselItem.js.map +1 -0
- package/dist/components/Carousel/carouselStore.cjs +38 -0
- package/dist/components/Carousel/carouselStore.cjs.map +1 -0
- package/dist/components/Carousel/carouselStore.js +37 -0
- package/dist/components/Carousel/carouselStore.js.map +1 -0
- package/dist/components/Carousel/index2.cjs +145 -0
- package/dist/components/Carousel/index2.cjs.map +1 -0
- package/dist/components/Carousel/index2.js +144 -0
- package/dist/components/Carousel/index2.js.map +1 -0
- package/dist/components/Carousel/intersectionObserver.cjs +46 -0
- package/dist/components/Carousel/intersectionObserver.cjs.map +1 -0
- package/dist/components/Carousel/intersectionObserver.js +45 -0
- package/dist/components/Carousel/intersectionObserver.js.map +1 -0
- package/dist/components/Carousel/resizeObserver.cjs +34 -0
- package/dist/components/Carousel/resizeObserver.cjs.map +1 -0
- package/dist/components/Carousel/resizeObserver.js +33 -0
- package/dist/components/Carousel/resizeObserver.js.map +1 -0
- package/dist/components/Carousel/store.cjs +24 -0
- package/dist/components/Carousel/store.cjs.map +1 -0
- package/dist/components/Carousel/store.js +23 -0
- package/dist/components/Carousel/store.js.map +1 -0
- package/dist/components/Carousel/useCarouselScroller.cjs +149 -0
- package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -0
- package/dist/components/Carousel/useCarouselScroller.js +148 -0
- package/dist/components/Carousel/useCarouselScroller.js.map +1 -0
- package/dist/components/Checkbox/CheckboxInput/index2.cjs +29 -0
- package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -0
- package/dist/components/Checkbox/CheckboxInput/index2.js +28 -0
- package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -0
- package/dist/components/Checkbox/CheckboxWithLabel.cjs +23 -0
- package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -0
- package/dist/components/Checkbox/CheckboxWithLabel.js +21 -0
- package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -0
- package/dist/components/Checkbox/index2.cjs +34 -0
- package/dist/components/Checkbox/index2.cjs.map +1 -0
- package/dist/components/Checkbox/index2.js +33 -0
- package/dist/components/Checkbox/index2.js.map +1 -0
- package/dist/components/Clickable/index2.cjs +21 -0
- package/dist/components/Clickable/index2.cjs.map +1 -0
- package/dist/components/Clickable/index2.js +19 -0
- package/dist/components/Clickable/index2.js.map +1 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +44 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.js +43 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.cjs +41 -0
- package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.js +40 -0
- package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -0
- package/dist/components/DropdownSelector/ListItem/index2.cjs +19 -0
- package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/ListItem/index2.js +18 -0
- package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/index.cjs +30 -0
- package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/index.js +29 -0
- package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs +30 -0
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js +29 -0
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +53 -0
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js +52 -0
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -0
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +20 -0
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuItemGroup/index2.js +19 -0
- package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -0
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +15 -0
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuList/MenuListContext.js +14 -0
- package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -0
- package/dist/components/DropdownSelector/MenuList/index2.cjs +32 -0
- package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuList/index2.js +31 -0
- package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -0
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +34 -0
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -0
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js +32 -0
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -0
- package/dist/components/DropdownSelector/Popover/index2.cjs +71 -0
- package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/Popover/index2.js +70 -0
- package/dist/components/DropdownSelector/Popover/index2.js.map +1 -0
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +27 -0
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -0
- package/dist/components/DropdownSelector/Popover/usePreventScroll.js +26 -0
- package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -0
- package/dist/components/DropdownSelector/index2.cjs +113 -0
- package/dist/components/DropdownSelector/index2.cjs.map +1 -0
- package/dist/components/DropdownSelector/index2.js +111 -0
- package/dist/components/DropdownSelector/index2.js.map +1 -0
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +34 -0
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -0
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.js +32 -0
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -0
- package/dist/components/FieldLabel/index2.cjs +35 -0
- package/dist/components/FieldLabel/index2.cjs.map +1 -0
- package/dist/components/FieldLabel/index2.js +33 -0
- package/dist/components/FieldLabel/index2.js.map +1 -0
- package/dist/components/HintText/index2.cjs +25 -0
- package/dist/components/HintText/index2.cjs.map +1 -0
- package/dist/components/HintText/index2.js +24 -0
- package/dist/components/HintText/index2.js.map +1 -0
- package/dist/components/Icon/index.cjs +39 -0
- package/dist/components/Icon/index.cjs.map +1 -0
- package/dist/components/Icon/index.js +37 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/IconButton/index2.cjs +46 -0
- package/dist/components/IconButton/index2.cjs.map +1 -0
- package/dist/components/IconButton/index2.js +44 -0
- package/dist/components/IconButton/index2.js.map +1 -0
- package/dist/components/LoadingSpinner/index2.cjs +43 -0
- package/dist/components/LoadingSpinner/index2.cjs.map +1 -0
- package/dist/components/LoadingSpinner/index2.js +41 -0
- package/dist/components/LoadingSpinner/index2.js.map +1 -0
- package/dist/components/Modal/Dialog/index2.cjs +30 -0
- package/dist/components/Modal/Dialog/index2.cjs.map +1 -0
- package/dist/components/Modal/Dialog/index2.js +28 -0
- package/dist/components/Modal/Dialog/index2.js.map +1 -0
- package/dist/components/Modal/ModalBackgroundContext.cjs +14 -0
- package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -0
- package/dist/components/Modal/ModalBackgroundContext.js +12 -0
- package/dist/components/Modal/ModalBackgroundContext.js.map +1 -0
- package/dist/components/Modal/ModalPlumbing2.cjs +30 -0
- package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -0
- package/dist/components/Modal/ModalPlumbing2.js +26 -0
- package/dist/components/Modal/ModalPlumbing2.js.map +1 -0
- package/dist/components/Modal/index2.cjs +121 -0
- package/dist/components/Modal/index2.cjs.map +1 -0
- package/dist/components/Modal/index2.js +118 -0
- package/dist/components/Modal/index2.js.map +1 -0
- package/dist/components/Modal/useCustomModalOverlay.cjs +48 -0
- package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -0
- package/dist/components/Modal/useCustomModalOverlay.js +45 -0
- package/dist/components/Modal/useCustomModalOverlay.js.map +1 -0
- package/dist/components/Modal/useTransitionPresence.cjs +57 -0
- package/dist/components/Modal/useTransitionPresence.cjs.map +1 -0
- package/dist/components/Modal/useTransitionPresence.js +56 -0
- package/dist/components/Modal/useTransitionPresence.js.map +1 -0
- package/dist/components/MultiSelect/context.cjs +19 -0
- package/dist/components/MultiSelect/context.cjs.map +1 -0
- package/dist/components/MultiSelect/context.js +18 -0
- package/dist/components/MultiSelect/context.js.map +1 -0
- package/dist/components/MultiSelect/index2.cjs +97 -0
- package/dist/components/MultiSelect/index2.cjs.map +1 -0
- package/dist/components/MultiSelect/index2.js +93 -0
- package/dist/components/MultiSelect/index2.js.map +1 -0
- package/dist/components/Pagination/PaginationContext.cjs +16 -0
- package/dist/components/Pagination/PaginationContext.cjs.map +1 -0
- package/dist/components/Pagination/PaginationContext.js +14 -0
- package/dist/components/Pagination/PaginationContext.js.map +1 -0
- package/dist/components/Pagination/helper.cjs +63 -0
- package/dist/components/Pagination/helper.cjs.map +1 -0
- package/dist/components/Pagination/helper.js +61 -0
- package/dist/components/Pagination/helper.js.map +1 -0
- package/dist/components/Pagination/index2.cjs +301 -0
- package/dist/components/Pagination/index2.cjs.map +1 -0
- package/dist/components/Pagination/index2.js +288 -0
- package/dist/components/Pagination/index2.js.map +1 -0
- package/dist/components/Radio/RadioGroup/index2.cjs +49 -0
- package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -0
- package/dist/components/Radio/RadioGroup/index2.js +47 -0
- package/dist/components/Radio/RadioGroup/index2.js.map +1 -0
- package/dist/components/Radio/RadioGroupContext.cjs +20 -0
- package/dist/components/Radio/RadioGroupContext.cjs.map +1 -0
- package/dist/components/Radio/RadioGroupContext.js +18 -0
- package/dist/components/Radio/RadioGroupContext.js.map +1 -0
- package/dist/components/Radio/RadioInput/index2.cjs +27 -0
- package/dist/components/Radio/RadioInput/index2.cjs.map +1 -0
- package/dist/components/Radio/RadioInput/index2.js +26 -0
- package/dist/components/Radio/RadioInput/index2.js.map +1 -0
- package/dist/components/Radio/index2.cjs +42 -0
- package/dist/components/Radio/index2.cjs.map +1 -0
- package/dist/components/Radio/index2.js +39 -0
- package/dist/components/Radio/index2.js.map +1 -0
- package/dist/components/SegmentedControl/RadioGroupContext.cjs +24 -0
- package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -0
- package/dist/components/SegmentedControl/RadioGroupContext.js +21 -0
- package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -0
- package/dist/components/SegmentedControl/index2.cjs +72 -0
- package/dist/components/SegmentedControl/index2.cjs.map +1 -0
- package/dist/components/SegmentedControl/index2.js +70 -0
- package/dist/components/SegmentedControl/index2.js.map +1 -0
- package/dist/components/Switch/SwitchInput/index2.cjs +25 -0
- package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -0
- package/dist/components/Switch/SwitchInput/index2.js +24 -0
- package/dist/components/Switch/SwitchInput/index2.js.map +1 -0
- package/dist/components/Switch/SwitchWithLabel.cjs +23 -0
- package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -0
- package/dist/components/Switch/SwitchWithLabel.js +21 -0
- package/dist/components/Switch/SwitchWithLabel.js.map +1 -0
- package/dist/components/Switch/index2.cjs +37 -0
- package/dist/components/Switch/index2.cjs.map +1 -0
- package/dist/components/Switch/index2.js +36 -0
- package/dist/components/Switch/index2.js.map +1 -0
- package/dist/components/TagItem/index2.cjs +57 -0
- package/dist/components/TagItem/index2.cjs.map +1 -0
- package/dist/components/TagItem/index2.js +55 -0
- package/dist/components/TagItem/index2.js.map +1 -0
- package/dist/components/TextArea/index2.cjs +134 -0
- package/dist/components/TextArea/index2.cjs.map +1 -0
- package/dist/components/TextArea/index2.js +133 -0
- package/dist/components/TextArea/index2.js.map +1 -0
- package/dist/components/TextEllipsis/helper.cjs +31 -0
- package/dist/components/TextEllipsis/helper.cjs.map +1 -0
- package/dist/components/TextEllipsis/helper.js +30 -0
- package/dist/components/TextEllipsis/helper.js.map +1 -0
- package/dist/components/TextEllipsis/index2.cjs +119 -0
- package/dist/components/TextEllipsis/index2.cjs.map +1 -0
- package/dist/components/TextEllipsis/index2.js +114 -0
- package/dist/components/TextEllipsis/index2.js.map +1 -0
- package/dist/components/TextField/AssistiveText/index2.cjs +10 -0
- package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -0
- package/dist/components/TextField/AssistiveText/index2.js +10 -0
- package/dist/components/TextField/AssistiveText/index2.js.map +1 -0
- package/dist/components/TextField/index2.cjs +101 -0
- package/dist/components/TextField/index2.cjs.map +1 -0
- package/dist/components/TextField/index2.js +100 -0
- package/dist/components/TextField/index2.js.map +1 -0
- package/dist/components/TextField/useFocusWithClick.cjs +23 -0
- package/dist/components/TextField/useFocusWithClick.cjs.map +1 -0
- package/dist/components/TextField/useFocusWithClick.js +22 -0
- package/dist/components/TextField/useFocusWithClick.js.map +1 -0
- package/dist/core/CharcoalProvider.cjs +16 -0
- package/dist/core/CharcoalProvider.cjs.map +1 -0
- package/dist/core/CharcoalProvider.js +14 -0
- package/dist/core/CharcoalProvider.js.map +1 -0
- package/dist/core/OverlayProvider.js +4 -0
- package/dist/core/SSRProvider.cjs +15 -0
- package/dist/core/SSRProvider.cjs.map +1 -0
- package/dist/core/SSRProvider.js +14 -0
- package/dist/core/SSRProvider.js.map +1 -0
- package/dist/core/SetThemeScript.cjs +45 -0
- package/dist/core/SetThemeScript.cjs.map +1 -0
- package/dist/core/SetThemeScript.js +43 -0
- package/dist/core/SetThemeScript.js.map +1 -0
- package/dist/core/themeHelper.cjs +154 -0
- package/dist/core/themeHelper.cjs.map +1 -0
- package/dist/core/themeHelper.js +143 -0
- package/dist/core/themeHelper.js.map +1 -0
- package/dist/index.cjs +81 -12
- package/dist/index.css +799 -799
- package/dist/index.js +31 -12
- package/dist/layered.css +802 -802
- package/dist/layered.css.map +1 -1
- package/package.json +5 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
|
|
5
|
+
//#region src/components/TextEllipsis/helper.ts
|
|
6
|
+
const getFinalTitle = (showTooltip, title, children) => {
|
|
7
|
+
if (!showTooltip) return;
|
|
8
|
+
const resolvedTitle = title ?? onlyText(children);
|
|
9
|
+
if (!resolvedTitle) return;
|
|
10
|
+
return resolvedTitle;
|
|
11
|
+
};
|
|
12
|
+
const hasChildren = (element) => (0, react.isValidElement)(element) && Boolean(element.props.children);
|
|
13
|
+
const childToString = (child) => {
|
|
14
|
+
if (typeof child === "undefined" || child === null || typeof child === "boolean") return "";
|
|
15
|
+
if (JSON.stringify(child) === "{}") return "";
|
|
16
|
+
return child.toString();
|
|
17
|
+
};
|
|
18
|
+
const onlyText = (children) => {
|
|
19
|
+
if (!Array.isArray(children) && !(0, react.isValidElement)(children)) return childToString(children);
|
|
20
|
+
return react.Children.toArray(children).reduce((text, child) => {
|
|
21
|
+
let newText = "";
|
|
22
|
+
if ((0, react.isValidElement)(child) && hasChildren(child)) newText = onlyText(child.props.children);
|
|
23
|
+
else if ((0, react.isValidElement)(child) && !hasChildren(child)) newText = "";
|
|
24
|
+
else newText = childToString(child);
|
|
25
|
+
return text.concat(newText);
|
|
26
|
+
}, "");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.getFinalTitle = getFinalTitle;
|
|
31
|
+
//# sourceMappingURL=helper.cjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Children, isValidElement } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/TextEllipsis/helper.ts
|
|
5
|
+
const getFinalTitle = (showTooltip, title, children) => {
|
|
6
|
+
if (!showTooltip) return;
|
|
7
|
+
const resolvedTitle = title ?? onlyText(children);
|
|
8
|
+
if (!resolvedTitle) return;
|
|
9
|
+
return resolvedTitle;
|
|
10
|
+
};
|
|
11
|
+
const hasChildren = (element) => isValidElement(element) && Boolean(element.props.children);
|
|
12
|
+
const childToString = (child) => {
|
|
13
|
+
if (typeof child === "undefined" || child === null || typeof child === "boolean") return "";
|
|
14
|
+
if (JSON.stringify(child) === "{}") return "";
|
|
15
|
+
return child.toString();
|
|
16
|
+
};
|
|
17
|
+
const onlyText = (children) => {
|
|
18
|
+
if (!Array.isArray(children) && !isValidElement(children)) return childToString(children);
|
|
19
|
+
return Children.toArray(children).reduce((text, child) => {
|
|
20
|
+
let newText = "";
|
|
21
|
+
if (isValidElement(child) && hasChildren(child)) newText = onlyText(child.props.children);
|
|
22
|
+
else if (isValidElement(child) && !hasChildren(child)) newText = "";
|
|
23
|
+
else newText = childToString(child);
|
|
24
|
+
return text.concat(newText);
|
|
25
|
+
}, "");
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getFinalTitle };
|
|
30
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_useClassNames = require('../../_lib/useClassNames.cjs');
|
|
4
|
+
require('./index.cjs');
|
|
5
|
+
const require_helper = require('./helper.cjs');
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let react_compiler_runtime = require("react-compiler-runtime");
|
|
8
|
+
|
|
9
|
+
//#region src/components/TextEllipsis/index.tsx
|
|
10
|
+
/**
|
|
11
|
+
* 複数行のテキストに表示行数制限を設けて`...`で省略する
|
|
12
|
+
*/
|
|
13
|
+
function TextEllipsis(t0) {
|
|
14
|
+
"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;
|
|
62
|
+
const classNames = require_useClassNames.useClassNames("charcoal-text-ellipsis", props.className);
|
|
63
|
+
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,
|
|
81
|
+
"--charcoal-text-ellipsis-line-limit": lineLimit,
|
|
82
|
+
hyphens,
|
|
83
|
+
...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;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
exports.default = TextEllipsis;
|
|
119
|
+
//# sourceMappingURL=index2.cjs.map
|
|
@@ -0,0 +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;E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A,IAAApB,EAAA,QAAAP,WAAAO,EAAA,QAAAR,aAAAQ,EAAA,QAAAM,MAAAe,SAAArB,EAAA,QAAAmB,IAAA;EAHHC,KAAA;GAAA,GACMD;GAEH,uCACsC3B;GAASC;GAAA,GAE7Ca,MAAKe;GACT;EAAArB,EAAA,MAAAP;EAAAO,EAAA,MAAAR;EAAAQ,EAAA,MAAAM,MAAAe;EAAArB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAoB;QAAAA,KAAApB,EAAA;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"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useClassNames } from "../../_lib/useClassNames.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { getFinalTitle } from "./helper.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { c } from "react-compiler-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/TextEllipsis/index.tsx
|
|
9
|
+
/**
|
|
10
|
+
* 複数行のテキストに表示行数制限を設けて`...`で省略する
|
|
11
|
+
*/
|
|
12
|
+
function TextEllipsis(t0) {
|
|
13
|
+
"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;
|
|
57
|
+
const classNames = useClassNames("charcoal-text-ellipsis", props.className);
|
|
58
|
+
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,
|
|
76
|
+
"--charcoal-text-ellipsis-line-limit": lineLimit,
|
|
77
|
+
hyphens,
|
|
78
|
+
...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;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { TextEllipsis as default };
|
|
114
|
+
//# sourceMappingURL=index2.js.map
|
|
@@ -0,0 +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,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;QAAA;EAAAN,WAAAF,EAAA;EAAAT,aAAAS,EAAA;EAAAG,QAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;EAAAO,KAAAP,EAAA;EAAAQ,QAAAR,EAAA;;CAPlB,MAAAR,YAAAY,OAAAK,SAAA,IAAAL;CAGA,MAAAX,UAAAY,OAAAI,SAAA,SAAAJ;CACA,MAAAX,cAAAY,OAAAG,SAAA,OAAAH;CACA,MAAAX,YAAAY,OAAAE,SAAA,QAAAF;CAAiB,IAAAG;CAAA,IAAAV,EAAA,OAAAE,YAAAF,EAAA,QAAAN,eAAAM,EAAA,QAAAQ,OAAA;EAIEE,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ACMpB,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_createDivComponent = require('../../../_lib/createDivComponent.cjs');
|
|
3
|
+
require('./index.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/components/TextField/AssistiveText/index.tsx
|
|
6
|
+
const AssistiveText = require_createDivComponent.createDivComponent("charcoal-text-field-assistive-text");
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.AssistiveText = AssistiveText;
|
|
10
|
+
//# sourceMappingURL=index2.cjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createDivComponent } from "../../../_lib/createDivComponent.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
|
|
5
|
+
//#region src/components/TextField/AssistiveText/index.tsx
|
|
6
|
+
const AssistiveText = createDivComponent("charcoal-text-field-assistive-text");
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { AssistiveText };
|
|
10
|
+
//# sourceMappingURL=index2.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_useClassNames = require('../../_lib/useClassNames.cjs');
|
|
4
|
+
require('./index.cjs');
|
|
5
|
+
const require_index$1 = require('../FieldLabel/index2.cjs');
|
|
6
|
+
const require_index$2 = require('../../_lib/index.cjs');
|
|
7
|
+
const require_useFocusWithClick = require('./useFocusWithClick.cjs');
|
|
8
|
+
const require_index$3 = require('./AssistiveText/index2.cjs');
|
|
9
|
+
let react = require("react");
|
|
10
|
+
react = require_runtime.__toESM(react);
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let react_aria_useId = require("react-aria/useId");
|
|
13
|
+
let react_aria_VisuallyHidden = require("react-aria/VisuallyHidden");
|
|
14
|
+
|
|
15
|
+
//#region src/components/TextField/index.tsx
|
|
16
|
+
const TextField = react.forwardRef(function SingleLineTextFieldInner({ assistiveText, className, disabled = false, label = "", maxLength, onChange, prefix = null, required, requiredText, showCount = false, showLabel = false, subLabel, suffix = null, type = "text", invalid, value, getCount = require_index$2.countCodePointsInString, ...props }, forwardRef) {
|
|
17
|
+
const inputRef = (0, react.useRef)(null);
|
|
18
|
+
const { visuallyHiddenProps } = (0, react_aria_VisuallyHidden.useVisuallyHidden)();
|
|
19
|
+
const [count, setCount] = (0, react.useState)(getCount(value ?? ""));
|
|
20
|
+
const handleChange = (0, react.useCallback)((e) => {
|
|
21
|
+
const value = e.target.value;
|
|
22
|
+
const count = getCount(value);
|
|
23
|
+
if (maxLength !== void 0 && count > maxLength) return;
|
|
24
|
+
setCount(count);
|
|
25
|
+
onChange?.(value);
|
|
26
|
+
}, [
|
|
27
|
+
getCount,
|
|
28
|
+
maxLength,
|
|
29
|
+
onChange
|
|
30
|
+
]);
|
|
31
|
+
(0, react.useEffect)(() => {
|
|
32
|
+
setCount(getCount(value ?? ""));
|
|
33
|
+
}, [getCount, value]);
|
|
34
|
+
const containerRef = (0, react.useRef)(null);
|
|
35
|
+
require_useFocusWithClick.useFocusWithClick(containerRef, inputRef);
|
|
36
|
+
const inputId = (0, react_aria_useId.useId)(props.id);
|
|
37
|
+
const describedbyId = (0, react_aria_useId.useId)();
|
|
38
|
+
const labelledbyId = (0, react_aria_useId.useId)();
|
|
39
|
+
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
40
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
41
|
+
className: require_useClassNames.useClassNames("charcoal-text-field-root", className),
|
|
42
|
+
"aria-disabled": disabled,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, {
|
|
45
|
+
htmlFor: inputId,
|
|
46
|
+
id: labelledbyId,
|
|
47
|
+
label,
|
|
48
|
+
required,
|
|
49
|
+
requiredText,
|
|
50
|
+
subLabel,
|
|
51
|
+
...!showLabel ? visuallyHiddenProps : {}
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
54
|
+
className: "charcoal-text-field-container",
|
|
55
|
+
"aria-disabled": disabled === true ? true : void 0,
|
|
56
|
+
"data-invalid": invalid === true,
|
|
57
|
+
ref: containerRef,
|
|
58
|
+
children: [
|
|
59
|
+
prefix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
60
|
+
className: "charcoal-text-field-prefix",
|
|
61
|
+
children: prefix
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
64
|
+
className: "charcoal-text-field-input-root",
|
|
65
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
66
|
+
className: "charcoal-text-field-input",
|
|
67
|
+
"aria-describedby": showAssistiveText ? describedbyId : void 0,
|
|
68
|
+
"aria-invalid": invalid,
|
|
69
|
+
"aria-labelledby": labelledbyId,
|
|
70
|
+
id: inputId,
|
|
71
|
+
"data-invalid": invalid === true,
|
|
72
|
+
maxLength,
|
|
73
|
+
onChange: handleChange,
|
|
74
|
+
disabled,
|
|
75
|
+
ref: require_index$2.mergeRefs(forwardRef, inputRef),
|
|
76
|
+
type,
|
|
77
|
+
value,
|
|
78
|
+
...props
|
|
79
|
+
})
|
|
80
|
+
}),
|
|
81
|
+
(suffix || showCount) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
82
|
+
className: "charcoal-text-field-suffix",
|
|
83
|
+
children: [suffix, showCount && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
84
|
+
className: "charcoal-text-field-line-counter",
|
|
85
|
+
children: maxLength !== void 0 ? `${count}/${maxLength}` : count
|
|
86
|
+
})]
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}),
|
|
90
|
+
showAssistiveText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$3.AssistiveText, {
|
|
91
|
+
"data-invalid": invalid === true,
|
|
92
|
+
id: describedbyId,
|
|
93
|
+
children: assistiveText
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
exports.default = TextField;
|
|
101
|
+
//# sourceMappingURL=index2.cjs.map
|
|
@@ -0,0 +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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,gBAAc1B;OACd,mBAAiB+B;OACjB,IAAIH;OACJ,gBAAc5B,YAAY;OACfc;OACX,UAAUQ;OACAnB;OACV,KAAKjB,0BAAUwB,YAAYQ,SAAS;OAC9BF;OACCrB;OACP,GAAIsB;OAAM;MAET;MACHvB,UAAUG,cACV,4CAAC,OAAD;MAAK,WAAU;gBAAf,CACGH,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"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useClassNames } from "../../_lib/useClassNames.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import FieldLabel from "../FieldLabel/index2.js";
|
|
5
|
+
import { countCodePointsInString, mergeRefs } from "../../_lib/index.js";
|
|
6
|
+
import { useFocusWithClick } from "./useFocusWithClick.js";
|
|
7
|
+
import { AssistiveText } from "./AssistiveText/index2.js";
|
|
8
|
+
import * as React$1 from "react";
|
|
9
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useId } from "react-aria/useId";
|
|
12
|
+
import { useVisuallyHidden } from "react-aria/VisuallyHidden";
|
|
13
|
+
|
|
14
|
+
//#region src/components/TextField/index.tsx
|
|
15
|
+
const TextField = React$1.forwardRef(function SingleLineTextFieldInner({ assistiveText, className, disabled = false, label = "", maxLength, onChange, prefix = null, required, requiredText, showCount = false, showLabel = false, subLabel, suffix = null, type = "text", invalid, value, getCount = countCodePointsInString, ...props }, forwardRef) {
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const { visuallyHiddenProps } = useVisuallyHidden();
|
|
18
|
+
const [count, setCount] = useState(getCount(value ?? ""));
|
|
19
|
+
const handleChange = useCallback((e) => {
|
|
20
|
+
const value = e.target.value;
|
|
21
|
+
const count = getCount(value);
|
|
22
|
+
if (maxLength !== void 0 && count > maxLength) return;
|
|
23
|
+
setCount(count);
|
|
24
|
+
onChange?.(value);
|
|
25
|
+
}, [
|
|
26
|
+
getCount,
|
|
27
|
+
maxLength,
|
|
28
|
+
onChange
|
|
29
|
+
]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setCount(getCount(value ?? ""));
|
|
32
|
+
}, [getCount, value]);
|
|
33
|
+
const containerRef = useRef(null);
|
|
34
|
+
useFocusWithClick(containerRef, inputRef);
|
|
35
|
+
const inputId = useId(props.id);
|
|
36
|
+
const describedbyId = useId();
|
|
37
|
+
const labelledbyId = useId();
|
|
38
|
+
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: useClassNames("charcoal-text-field-root", className),
|
|
41
|
+
"aria-disabled": disabled,
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
44
|
+
htmlFor: inputId,
|
|
45
|
+
id: labelledbyId,
|
|
46
|
+
label,
|
|
47
|
+
required,
|
|
48
|
+
requiredText,
|
|
49
|
+
subLabel,
|
|
50
|
+
...!showLabel ? visuallyHiddenProps : {}
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: "charcoal-text-field-container",
|
|
54
|
+
"aria-disabled": disabled === true ? true : void 0,
|
|
55
|
+
"data-invalid": invalid === true,
|
|
56
|
+
ref: containerRef,
|
|
57
|
+
children: [
|
|
58
|
+
prefix && /* @__PURE__ */ jsx("div", {
|
|
59
|
+
className: "charcoal-text-field-prefix",
|
|
60
|
+
children: prefix
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "charcoal-text-field-input-root",
|
|
64
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
65
|
+
className: "charcoal-text-field-input",
|
|
66
|
+
"aria-describedby": showAssistiveText ? describedbyId : void 0,
|
|
67
|
+
"aria-invalid": invalid,
|
|
68
|
+
"aria-labelledby": labelledbyId,
|
|
69
|
+
id: inputId,
|
|
70
|
+
"data-invalid": invalid === true,
|
|
71
|
+
maxLength,
|
|
72
|
+
onChange: handleChange,
|
|
73
|
+
disabled,
|
|
74
|
+
ref: mergeRefs(forwardRef, inputRef),
|
|
75
|
+
type,
|
|
76
|
+
value,
|
|
77
|
+
...props
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
(suffix || showCount) && /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: "charcoal-text-field-suffix",
|
|
82
|
+
children: [suffix, showCount && /* @__PURE__ */ jsx("span", {
|
|
83
|
+
className: "charcoal-text-field-line-counter",
|
|
84
|
+
children: maxLength !== void 0 ? `${count}/${maxLength}` : count
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
showAssistiveText && /* @__PURE__ */ jsx(AssistiveText, {
|
|
90
|
+
"data-invalid": invalid === true,
|
|
91
|
+
id: describedbyId,
|
|
92
|
+
children: assistiveText
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { TextField as default };
|
|
100
|
+
//# sourceMappingURL=index2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index2.js","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,QAAM2B,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,yBACX,GAAGgC,SAELP,YACA;CACA,MAAMQ,WAAWrC,OAAyB,KAAK;CAE/C,MAAM,EAAEsC,wB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;OACCrB;OACP,GAAIsB;OAAM;MAET;MACHvB,UAAUG,cACV,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACGH,QACAG,aACC,oBAAC,QAAD;OAAM,WAAU;iBACbiB,cAAcY,SAAY,GAAGN,MAAK,GAAIN,cAAcM;OAExD,EAEJ;;KACE;;GACJY,qBACC,oBAAC,eAAD;IAAe,gBAAchC,YAAY;IAAM,IAAI8B;cAChD/B;IAEJ;GACG;;EAGX"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
|
|
5
|
+
//#region src/components/TextField/useFocusWithClick.tsx
|
|
6
|
+
function useFocusWithClick(containerRef, inputRef) {
|
|
7
|
+
(0, react.useEffect)(() => {
|
|
8
|
+
const el = containerRef.current;
|
|
9
|
+
if (el) {
|
|
10
|
+
const handleDown = (e) => {
|
|
11
|
+
if (e.target !== inputRef.current) inputRef.current?.focus();
|
|
12
|
+
};
|
|
13
|
+
el.addEventListener("click", handleDown);
|
|
14
|
+
return () => {
|
|
15
|
+
el.removeEventListener("click", handleDown);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.useFocusWithClick = useFocusWithClick;
|
|
23
|
+
//# sourceMappingURL=useFocusWithClick.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFocusWithClick.cjs","names":["useEffect","React","useFocusWithClick","containerRef","RefObject","HTMLDivElement","inputRef","HTMLInputElement","HTMLTextAreaElement","el","current","handleDown","e","MouseEvent","target","focus","addEventListener","removeEventListener"],"sources":["../../../src/components/TextField/useFocusWithClick.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport * as React from 'react'\n\nexport function useFocusWithClick(\n containerRef: React.RefObject<HTMLDivElement | null>,\n inputRef: React.RefObject<HTMLInputElement | HTMLTextAreaElement | null>,\n) {\n useEffect(() => {\n const el = containerRef.current\n if (el) {\n const handleDown = (e: MouseEvent) => {\n if (e.target !== inputRef.current) {\n inputRef.current?.focus()\n }\n }\n el.addEventListener('click', handleDown)\n return () => {\n el.removeEventListener('click', handleDown)\n }\n }\n })\n}\n"],"mappings":";;;;;AAGA,SAAgBE,kBACdC,cACAG,UACA;CACAN,2BAAgB;EACd,MAAMS,KAAKN,aAAaO;EACxB,IAAID,IAAI;GACN,MAAME,cAAcC,MAAkB;IACpC,IAAIA,EAAEE,WAAWR,SAASI,SACxBJ,SAASI,SAASK,OAAO;;GAG7BN,GAAGO,iBAAiB,SAASL,WAAW;GACxC,aAAa;IACXF,GAAGQ,oBAAoB,SAASN,WAAW;;;GAG/C"}
|