@vibe/core 3.50.1-alpha-b401f.0 → 3.50.1-alpha-b92cc.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/components/AlertBanner/AlertBanner.d.ts +1 -1
- package/dist/components/AttentionBox/AttentionBox.d.ts +1 -1
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Avatar/AvatarBadge.d.ts +1 -1
- package/dist/components/Avatar/AvatarContent.d.ts +1 -1
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/Badge/Indicator/Indicator.d.ts +1 -1
- package/dist/components/Box/Box.d.ts +1 -1
- package/dist/components/BreadcrumbsBar/BreadcrumbsBar.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/components/Chips/Chips.d.ts +1 -1
- package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/components/ColorPicker/components/ColorPickerContent/ColorPickerContent.d.ts +1 -1
- package/dist/components/Combobox/Combobox.d.ts +1 -1
- package/dist/components/Combobox/components/ComboboxOption/ComboboxOption.d.ts +1 -1
- package/dist/components/Counter/Counter.d.ts +1 -1
- package/dist/components/DialogContentContainer/DialogContentContainer.d.ts +1 -1
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/DropdownNew/Dropdown.types.d.ts +42 -16
- package/dist/components/DropdownNew/hooks/useDropdownCombobox.d.ts +1 -1
- package/dist/components/DropdownNew/hooks/useDropdownFiltering.d.ts +1 -1
- package/dist/components/DropdownNew/hooks/useDropdownMultiCombobox.d.ts +1 -1
- package/dist/components/DropdownNew/utils/dropdownUtils.d.ts +1 -1
- package/dist/components/EditableHeading/EditableHeading.d.ts +1 -1
- package/dist/components/EditableText/EditableText.d.ts +1 -1
- package/dist/components/Flex/Flex.d.ts +1 -1
- package/dist/components/FormattedNumber/FormattedNumber.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/IconButton/IconButton.d.ts +1 -1
- package/dist/components/Label/Label.d.ts +1 -1
- package/dist/components/LegacyModal/LegacyModal.d.ts +1 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/ListItem/ListItem.d.ts +1 -1
- package/dist/components/ListItemAvatar/ListItemAvatar.d.ts +1 -1
- package/dist/components/ListItemIcon/ListItemIcon.d.ts +1 -1
- package/dist/components/Loader/Loader.d.ts +1 -1
- package/dist/components/Menu/Menu/Menu.d.ts +1 -1
- package/dist/components/Menu/MenuItem/MenuItem.d.ts +1 -1
- package/dist/components/Menu/MenuItemButton/MenuItemButton.d.ts +1 -1
- package/dist/components/Menu/MenuTitle/MenuTitle.d.ts +1 -1
- package/dist/components/MenuButton/MenuButton.d.ts +1 -1
- package/dist/components/MultiStepIndicator/MultiStepIndicator.d.ts +1 -1
- package/dist/components/ProgressBars/LinearProgressBar/LinearProgressBar.d.ts +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/components/Slider/Slider.d.ts +1 -1
- package/dist/components/Slider/SliderInfix.d.ts +1 -1
- package/dist/components/SplitButton/SplitButton.d.ts +1 -1
- package/dist/components/Steps/Steps.d.ts +1 -1
- package/dist/components/Table/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/TabPanels/TabPanels.d.ts +1 -1
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextField/TextField.d.ts +1 -1
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/dist/components/Tipseen/Tipseen.d.ts +1 -1
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.d.ts +1 -2
- package/dist/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.d.ts +1 -3
- package/dist/metadata.json +19677 -3193
- package/dist/mocked_classnames/components/AlertBanner/AlertBanner.d.ts +1 -1
- package/dist/mocked_classnames/components/AttentionBox/AttentionBox.d.ts +1 -1
- package/dist/mocked_classnames/components/Avatar/Avatar.d.ts +1 -1
- package/dist/mocked_classnames/components/Avatar/AvatarBadge.d.ts +1 -1
- package/dist/mocked_classnames/components/Avatar/AvatarContent.d.ts +1 -1
- package/dist/mocked_classnames/components/Badge/Badge.d.ts +1 -1
- package/dist/mocked_classnames/components/Badge/Indicator/Indicator.d.ts +1 -1
- package/dist/mocked_classnames/components/Box/Box.d.ts +1 -1
- package/dist/mocked_classnames/components/BreadcrumbsBar/BreadcrumbsBar.d.ts +1 -1
- package/dist/mocked_classnames/components/Button/Button.d.ts +1 -1
- package/dist/mocked_classnames/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/mocked_classnames/components/Chips/Chips.d.ts +1 -1
- package/dist/mocked_classnames/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/mocked_classnames/components/ColorPicker/components/ColorPickerContent/ColorPickerContent.d.ts +1 -1
- package/dist/mocked_classnames/components/Combobox/Combobox.d.ts +1 -1
- package/dist/mocked_classnames/components/Combobox/components/ComboboxOption/ComboboxOption.d.ts +1 -1
- package/dist/mocked_classnames/components/Counter/Counter.d.ts +1 -1
- package/dist/mocked_classnames/components/DialogContentContainer/DialogContentContainer.d.ts +1 -1
- package/dist/mocked_classnames/components/Divider/Divider.d.ts +1 -1
- package/dist/mocked_classnames/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/mocked_classnames/components/DropdownNew/Dropdown.types.d.ts +42 -16
- package/dist/mocked_classnames/components/DropdownNew/hooks/useDropdownCombobox.d.ts +1 -1
- package/dist/mocked_classnames/components/DropdownNew/hooks/useDropdownFiltering.d.ts +1 -1
- package/dist/mocked_classnames/components/DropdownNew/hooks/useDropdownMultiCombobox.d.ts +1 -1
- package/dist/mocked_classnames/components/DropdownNew/utils/dropdownUtils.d.ts +1 -1
- package/dist/mocked_classnames/components/EditableHeading/EditableHeading.d.ts +1 -1
- package/dist/mocked_classnames/components/EditableText/EditableText.d.ts +1 -1
- package/dist/mocked_classnames/components/Flex/Flex.d.ts +1 -1
- package/dist/mocked_classnames/components/FormattedNumber/FormattedNumber.d.ts +1 -1
- package/dist/mocked_classnames/components/Heading/Heading.d.ts +1 -1
- package/dist/mocked_classnames/components/Icon/Icon.d.ts +1 -1
- package/dist/mocked_classnames/components/IconButton/IconButton.d.ts +1 -1
- package/dist/mocked_classnames/components/Label/Label.d.ts +1 -1
- package/dist/mocked_classnames/components/LegacyModal/LegacyModal.d.ts +1 -1
- package/dist/mocked_classnames/components/Link/Link.d.ts +1 -1
- package/dist/mocked_classnames/components/List/List.d.ts +1 -1
- package/dist/mocked_classnames/components/ListItem/ListItem.d.ts +1 -1
- package/dist/mocked_classnames/components/ListItemAvatar/ListItemAvatar.d.ts +1 -1
- package/dist/mocked_classnames/components/ListItemIcon/ListItemIcon.d.ts +1 -1
- package/dist/mocked_classnames/components/Loader/Loader.d.ts +1 -1
- package/dist/mocked_classnames/components/Menu/Menu/Menu.d.ts +1 -1
- package/dist/mocked_classnames/components/Menu/MenuItem/MenuItem.d.ts +1 -1
- package/dist/mocked_classnames/components/Menu/MenuItemButton/MenuItemButton.d.ts +1 -1
- package/dist/mocked_classnames/components/Menu/MenuTitle/MenuTitle.d.ts +1 -1
- package/dist/mocked_classnames/components/MenuButton/MenuButton.d.ts +1 -1
- package/dist/mocked_classnames/components/MultiStepIndicator/MultiStepIndicator.d.ts +1 -1
- package/dist/mocked_classnames/components/ProgressBars/LinearProgressBar/LinearProgressBar.d.ts +1 -1
- package/dist/mocked_classnames/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/mocked_classnames/components/Slider/Slider.d.ts +1 -1
- package/dist/mocked_classnames/components/Slider/SliderInfix.d.ts +1 -1
- package/dist/mocked_classnames/components/SplitButton/SplitButton.d.ts +1 -1
- package/dist/mocked_classnames/components/Steps/Steps.d.ts +1 -1
- package/dist/mocked_classnames/components/Table/Table/Table.d.ts +1 -1
- package/dist/mocked_classnames/components/Tabs/TabPanels/TabPanels.d.ts +1 -1
- package/dist/mocked_classnames/components/Text/Text.d.ts +1 -1
- package/dist/mocked_classnames/components/TextField/TextField.d.ts +1 -1
- package/dist/mocked_classnames/components/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/dist/mocked_classnames/components/Tipseen/Tipseen.d.ts +1 -1
- package/dist/mocked_classnames/components/Toast/Toast.d.ts +1 -1
- package/dist/mocked_classnames/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.d.ts +1 -2
- package/dist/mocked_classnames/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.d.ts +1 -3
- package/dist/mocked_classnames/src/components/AttentionBox/AttentionBox.js +1 -1
- package/dist/mocked_classnames/src/components/AttentionBox/AttentionBox.js.map +1 -1
- package/dist/mocked_classnames/src/components/Avatar/Avatar.js +1 -1
- package/dist/mocked_classnames/src/components/Avatar/Avatar.js.map +1 -1
- package/dist/mocked_classnames/src/components/Avatar/AvatarBadge.js +1 -1
- package/dist/mocked_classnames/src/components/Avatar/AvatarBadge.js.map +1 -1
- package/dist/mocked_classnames/src/components/Avatar/AvatarContent.js +1 -1
- package/dist/mocked_classnames/src/components/Avatar/AvatarContent.js.map +1 -1
- package/dist/mocked_classnames/src/components/Badge/Indicator/Indicator.js +1 -1
- package/dist/mocked_classnames/src/components/Badge/Indicator/Indicator.js.map +1 -1
- package/dist/mocked_classnames/src/components/BreadcrumbsBar/BreadcrumbsBar.js +1 -1
- package/dist/mocked_classnames/src/components/BreadcrumbsBar/BreadcrumbsBar.js.map +1 -1
- package/dist/mocked_classnames/src/components/Combobox/components/ComboboxOption/ComboboxOption.js +1 -1
- package/dist/mocked_classnames/src/components/Combobox/components/ComboboxOption/ComboboxOption.js.map +1 -1
- package/dist/mocked_classnames/src/components/Counter/Counter.js +1 -1
- package/dist/mocked_classnames/src/components/Counter/Counter.js.map +1 -1
- package/dist/mocked_classnames/src/components/Divider/Divider.js +1 -1
- package/dist/mocked_classnames/src/components/Divider/Divider.js.map +1 -1
- package/dist/mocked_classnames/src/components/LegacyModal/LegacyModal.js +1 -1
- package/dist/mocked_classnames/src/components/LegacyModal/LegacyModal.js.map +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuItemButton/MenuItemButton.js +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuItemButton/MenuItemButton.js.map +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuTitle/MenuTitle.js +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuTitle/MenuTitle.js.map +1 -1
- package/dist/mocked_classnames/src/components/Skeleton/Skeleton.js +1 -1
- package/dist/mocked_classnames/src/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/mocked_classnames/src/components/Slider/SliderInfix.js +1 -1
- package/dist/mocked_classnames/src/components/Slider/SliderInfix.js.map +1 -1
- package/dist/mocked_classnames/src/components/SplitButton/SplitButton.js +1 -1
- package/dist/mocked_classnames/src/components/SplitButton/SplitButton.js.map +1 -1
- package/dist/mocked_classnames/src/components/Tabs/Tab/Tab.js +1 -1
- package/dist/mocked_classnames/src/components/Tabs/Tab/Tab.js.map +1 -1
- package/dist/mocked_classnames/src/components/Tabs/TabList/TabList.js +1 -1
- package/dist/mocked_classnames/src/components/Tabs/TabList/TabList.js.map +1 -1
- package/dist/mocked_classnames/src/components/TextField/TextField.js +1 -1
- package/dist/mocked_classnames/src/components/TextField/TextField.js.map +1 -1
- package/dist/mocked_classnames/src/components/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/mocked_classnames/src/components/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/mocked_classnames/src/components/Toast/Toast.js +1 -1
- package/dist/mocked_classnames/src/components/Toast/Toast.js.map +1 -1
- package/dist/mocked_classnames/src/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.js +1 -1
- package/dist/mocked_classnames/src/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.js.map +1 -1
- package/dist/mocked_classnames/src/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/dist/mocked_classnames/src/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.js.map +1 -1
- package/dist/mocked_classnames/src/index.js +1 -1
- package/dist/mocked_classnames/src/types/withStaticProps.js +1 -1
- package/dist/mocked_classnames/src/types/withStaticProps.js.map +1 -1
- package/dist/mocked_classnames/types/withStaticProps.d.ts +2 -2
- package/dist/src/components/AttentionBox/AttentionBox.js +1 -1
- package/dist/src/components/AttentionBox/AttentionBox.js.map +1 -1
- package/dist/src/components/Avatar/Avatar.js +1 -1
- package/dist/src/components/Avatar/Avatar.js.map +1 -1
- package/dist/src/components/Avatar/AvatarBadge.js +1 -1
- package/dist/src/components/Avatar/AvatarBadge.js.map +1 -1
- package/dist/src/components/Avatar/AvatarContent.js +1 -1
- package/dist/src/components/Avatar/AvatarContent.js.map +1 -1
- package/dist/src/components/Badge/Indicator/Indicator.js +1 -1
- package/dist/src/components/Badge/Indicator/Indicator.js.map +1 -1
- package/dist/src/components/BreadcrumbsBar/BreadcrumbsBar.js +1 -1
- package/dist/src/components/BreadcrumbsBar/BreadcrumbsBar.js.map +1 -1
- package/dist/src/components/Combobox/components/ComboboxOption/ComboboxOption.js +1 -1
- package/dist/src/components/Combobox/components/ComboboxOption/ComboboxOption.js.map +1 -1
- package/dist/src/components/Counter/Counter.js +1 -1
- package/dist/src/components/Counter/Counter.js.map +1 -1
- package/dist/src/components/Divider/Divider.js +1 -1
- package/dist/src/components/Divider/Divider.js.map +1 -1
- package/dist/src/components/LegacyModal/LegacyModal.js +1 -1
- package/dist/src/components/LegacyModal/LegacyModal.js.map +1 -1
- package/dist/src/components/Menu/MenuItemButton/MenuItemButton.js +1 -1
- package/dist/src/components/Menu/MenuItemButton/MenuItemButton.js.map +1 -1
- package/dist/src/components/Menu/MenuTitle/MenuTitle.js +1 -1
- package/dist/src/components/Menu/MenuTitle/MenuTitle.js.map +1 -1
- package/dist/src/components/Skeleton/Skeleton.js +1 -1
- package/dist/src/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/src/components/Slider/SliderInfix.js +1 -1
- package/dist/src/components/Slider/SliderInfix.js.map +1 -1
- package/dist/src/components/SplitButton/SplitButton.js +1 -1
- package/dist/src/components/SplitButton/SplitButton.js.map +1 -1
- package/dist/src/components/Tabs/Tab/Tab.js +1 -1
- package/dist/src/components/Tabs/Tab/Tab.js.map +1 -1
- package/dist/src/components/Tabs/TabList/TabList.js +1 -1
- package/dist/src/components/Tabs/TabList/TabList.js.map +1 -1
- package/dist/src/components/TextField/TextField.js +1 -1
- package/dist/src/components/TextField/TextField.js.map +1 -1
- package/dist/src/components/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/src/components/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/src/components/Toast/Toast.js +1 -1
- package/dist/src/components/Toast/Toast.js.map +1 -1
- package/dist/src/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.js +1 -1
- package/dist/src/hooks/useGridKeyboardNavigation/gridKeyboardNavigationHelper.js.map +1 -1
- package/dist/src/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/dist/src/hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/types/withStaticProps.js +1 -1
- package/dist/src/types/withStaticProps.js.map +1 -1
- package/dist/types/withStaticProps.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.js","sources":["../../../../src/components/Skeleton/Skeleton.tsx"],"sourcesContent":["import React from \"react\";\nimport { camelCase } from \"lodash-es\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport {\n SKELETON_SIZES,\n SkeletonType as SkeletonTypeEnum,\n SKELETON_CUSTOM_SIZE,\n TextSkeletonSize as TextSkeletonSizeEnum\n} from \"./SkeletonConstants\";\n\nimport { SkeletonType, SkeletonSizeType } from \"./Skelton.types\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport {
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sources":["../../../../src/components/Skeleton/Skeleton.tsx"],"sourcesContent":["import React from \"react\";\nimport { camelCase } from \"lodash-es\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport {\n SKELETON_SIZES,\n SkeletonType as SkeletonTypeEnum,\n SKELETON_CUSTOM_SIZE,\n TextSkeletonSize as TextSkeletonSizeEnum\n} from \"./SkeletonConstants\";\n\nimport { SkeletonType, SkeletonSizeType } from \"./Skelton.types\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./Skeleton.module.scss\";\n\nexport interface SkeletonProps extends VibeComponentProps {\n /**\n * The type of skeleton.\n */\n type?: SkeletonType;\n /**\n * The predefined size of the skeleton.\n */\n size?: SkeletonSizeType;\n /**\n * The width of the skeleton in pixels.\n */\n width?: number;\n /**\n * The height of the skeleton in pixels.\n */\n height?: number;\n /**\n * Class name applied to the wrapper element.\n */\n wrapperClassName?: string;\n /**\n * If true, the skeleton will take up the full width of its container.\n */\n fullWidth?: boolean;\n}\n\nconst Skeleton = ({\n type = \"rectangle\",\n size = \"custom\",\n className,\n wrapperClassName,\n width,\n height,\n fullWidth = false,\n id,\n \"data-testid\": dataTestId\n}: SkeletonProps) => {\n const skeletonType = (Object.values(SkeletonTypeEnum) as string[]).includes(type) ? type : \"rectangle\";\n\n // Skeleton has sizes only for text type, other types support only custom size\n const skeletonSize = (Object.values(TextSkeletonSizeEnum) as string[]).includes(size) ? size : SKELETON_CUSTOM_SIZE;\n\n return (\n <div\n id={id}\n className={cx(styles.skeleton, wrapperClassName, { [styles.fullWidth]: fullWidth })}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.SKELETON, id)}\n >\n <div\n className={cx(styles[skeletonType], getStyle(styles, camelCase(skeletonType + \"-\" + skeletonSize)), className, {\n [styles.fullWidth]: fullWidth\n })}\n style={{ width, height }}\n />\n </div>\n );\n};\n\ninterface SkeletonStaticProps {\n types: typeof SkeletonTypeEnum;\n sizes: typeof SKELETON_SIZES;\n}\n\nexport default withStaticPropsWithoutForwardRef<SkeletonProps, SkeletonStaticProps>(Skeleton, {\n types: SkeletonTypeEnum,\n sizes: SKELETON_SIZES\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","_ref$type","type","_ref$size","size","className","wrapperClassName","width","height","_ref$fullWidth","fullWidth","id","dataTestId","skeletonType","Object","values","SkeletonTypeEnum","includes","skeletonSize","TextSkeletonSizeEnum","SKELETON_CUSTOM_SIZE","React","createElement","cx","styles","skeleton","_defineProperty","getTestId","ComponentDefaultTestId","SKELETON","getStyle","camelCase","style","types","sizes","SKELETON_SIZES"],"mappings":"slBA2CA,IAqCeA,EAAAA,GArCE,SAAHC,GAUM,IAAAC,EAAAD,EATlBE,KAAAA,OAAO,IAAHD,EAAG,YAAWA,EAAAE,EAAAH,EAClBI,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EACfE,EAASL,EAATK,UACAC,EAAgBN,EAAhBM,iBACAC,EAAKP,EAALO,MACAC,EAAMR,EAANQ,OAAMC,EAAAT,EACNU,UAAAA,OAAY,IAAHD,GAAQA,EACjBE,EAAEX,EAAFW,GACeC,EAAUZ,EAAzB,eAEMa,EAAgBC,OAAOC,OAAOC,GAA+BC,SAASf,GAAQA,EAAO,YAGrFgB,EAAgBJ,OAAOC,OAAOI,GAAmCF,SAASb,GAAQA,EAAOgB,EAE/F,OACEC,EACEC,cAAA,MAAA,CAAAX,GAAIA,EACJN,UAAWkB,EAAGC,EAAOC,SAAUnB,EAAgBoB,KAAKF,EAAOd,UAAYA,IAC1D,cAAAE,GAAce,EAAUC,EAAuBC,SAAUlB,IAEtEU,EACEC,cAAA,MAAA,CAAAjB,UAAWkB,EAAGC,EAAOX,GAAeiB,EAASN,EAAQO,EAAUlB,EAAe,IAAMK,IAAgBb,EAASqB,EAC1GF,CAAAA,EAAAA,EAAOd,UAAYA,IAEtBsB,MAAO,CAAEzB,MAAAA,EAAOC,OAAAA,KAIxB,GAO8F,CAC5FyB,MAAOjB,EACPkB,MAAOC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"react";import{InfixKind as o}from"./SliderConstants.js";import{useSliderInfixComponent as i}from"./SliderInfixHooks.js";import t from"classnames";import{getStyle as e}from"../../helpers/typesciptCssModulesHelper.js";import{
|
|
1
|
+
import{slicedToArray as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"react";import{InfixKind as o}from"./SliderConstants.js";import{useSliderInfixComponent as i}from"./SliderInfixHooks.js";import t from"classnames";import{getStyle as e}from"../../helpers/typesciptCssModulesHelper.js";import{withStaticPropsWithoutForwardRef as m}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import l from"./SliderInfix.module.scss.js";var p=m((function o(m){var p=m.kind,a=void 0===p?o.kinds.PREFIX:p,n=i(a),f=r(n,4),d=f[1],c=f[2],u=f[3];return f[0]&&s.createElement("div",{className:t(l.infix,e(l,a),d.map((function(r){return e(l,r)}))),style:u},c)}),{kinds:o});export{p as default};
|
|
2
2
|
//# sourceMappingURL=SliderInfix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderInfix.js","sources":["../../../../src/components/Slider/SliderInfix.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { InfixKind as InfixKindEnum } from \"./SliderConstants\";\nimport { useSliderInfixComponent } from \"./SliderInfixHooks\";\nimport cx from \"classnames\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport {
|
|
1
|
+
{"version":3,"file":"SliderInfix.js","sources":["../../../../src/components/Slider/SliderInfix.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { InfixKind as InfixKindEnum } from \"./SliderConstants\";\nimport { useSliderInfixComponent } from \"./SliderInfixHooks\";\nimport cx from \"classnames\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./SliderInfix.module.scss\";\nimport { InfixKind } from \"./Slider.types\";\n\nexport interface SliderInfixProps extends VibeComponentProps {\n /**\n * Specifies the type of infix (prefix or postfix).\n */\n kind?: InfixKind;\n}\n\nconst SliderInfix: FC<SliderInfixProps> & { kinds?: typeof InfixKindEnum } = ({ kind = SliderInfix.kinds.PREFIX }) => {\n const [isShow, modificators, InfixComponent, inlineStyle] = useSliderInfixComponent(kind);\n return (\n isShow && (\n <div\n className={cx(\n styles.infix,\n getStyle(styles, kind),\n modificators.map(m => getStyle(styles, m))\n )}\n style={inlineStyle}\n >\n {InfixComponent}\n </div>\n )\n );\n};\n\nexport default withStaticPropsWithoutForwardRef<SliderInfixProps, { kinds: typeof InfixKindEnum }>(SliderInfix, {\n kinds: InfixKindEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","SliderInfix","_ref","_ref$kind","kind","kinds","PREFIX","_useSliderInfixCompon","useSliderInfixComponent","_useSliderInfixCompon2","_slicedToArray","modificators","InfixComponent","inlineStyle","React","className","cx","styles","infix","getStyle","map","m","style","InfixKindEnum"],"mappings":"0dAgBA,IAkBeA,EAAAA,GAlB8D,SAAvEC,EAAWC,GAAoG,IAAAC,EAAAD,EAArCE,KAAAA,OAAOH,IAAHE,EAAGF,EAAYI,MAAMC,OAAMH,EAC7GI,EAA4DC,EAAwBJ,GAAKK,EAAAC,EAAAH,EAAA,GAA1EI,EAAYF,EAAA,GAAEG,EAAcH,EAAA,GAAEI,EAAWJ,EAAA,GACxD,OADaA,EAAA,IAGTK,uBACEC,UAAWC,EACTC,EAAOC,MACPC,EAASF,EAAQb,GACjBO,EAAaS,KAAI,SAAAC,GAAC,OAAIF,EAASF,EAAQI,EAAE,KAE3CC,MAAOT,GAEND,EAIT,GAEgH,CAC9GP,MAAOkB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as o,defineProperty as e,toConsumableArray as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as i}from"../../../_virtual/_tslib.js";import{camelCase as n}from"lodash-es";import{getStyle as a}from"../../helpers/typesciptCssModulesHelper.js";import{getTestId as r,ComponentDefaultTestId as s}from"../../tests/testIds.js";import l from"classnames";import d,{useState as c,useRef as m,useCallback as u,useMemo as g}from"react";import{SplitButtonSecondaryContentPosition as p,ENTER_KEYS as f,DEFAULT_DIALOG_SHOW_TRIGGER as D,DEFAULT_DIALOG_HIDE_TRIGGER as v,DIALOG_MOVE_BY as y,SECONDARY_BUTTON_ARIA_LABEL as C,SECONDARY_BUTTON_WRAPPER_CLASSNAME as T}from"./SplitButtonConstants.js";import{
|
|
1
|
+
import{slicedToArray as o,defineProperty as e,toConsumableArray as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as i}from"../../../_virtual/_tslib.js";import{camelCase as n}from"lodash-es";import{getStyle as a}from"../../helpers/typesciptCssModulesHelper.js";import{getTestId as r,ComponentDefaultTestId as s}from"../../tests/testIds.js";import l from"classnames";import d,{useState as c,useRef as m,useCallback as u,useMemo as g}from"react";import{SplitButtonSecondaryContentPosition as p,ENTER_KEYS as f,DEFAULT_DIALOG_SHOW_TRIGGER as D,DEFAULT_DIALOG_HIDE_TRIGGER as v,DIALOG_MOVE_BY as y,SECONDARY_BUTTON_ARIA_LABEL as C,SECONDARY_BUTTON_WRAPPER_CLASSNAME as T}from"./SplitButtonConstants.js";import{withStaticPropsWithoutForwardRef as S}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{HideShowEvent as N,AnimationType as b}from"../Dialog/DialogConstants.js";import{NOOP as h}from"../../utils/function-utils.js";import{isInsideClass as k}from"../../utils/dom-utils.js";import P from"../../hooks/useKeyEvent/index.js";import j from"../../hooks/useEventListener/index.js";import I from"../Button/Button.js";import B from"../Dialog/Dialog.js";import O from"../DialogContentContainer/DialogContentContainer.js";import E from"./SplitButton.module.scss.js";import{ComponentVibeId as _}from"../../tests/constants.js";import z from"../../../icons/dist/react/DropdownChevronDown.js";var w=function(p){var S=p.secondaryDialogContent,w=p.onSecondaryDialogDidShow,L=void 0===w?h:w,A=p.onSecondaryDialogDidHide,x=void 0===A?h:A,R=p.shouldCloseOnClickInsideDialog,H=p.zIndex,U=void 0===H?null:H,M=p.secondaryDialogClassName,F=p.secondaryDialogPosition,K=void 0===F?"bottom-start":F,W=p.dialogContainerSelector,Y=p.dialogPaddingSize,V=void 0===Y?"medium":Y,X=p.disabled,q=p.loading,G=p.kind,J=p.color,Q=p.className,Z=p.leftIcon,$=p.rightIcon,oo=p.onClick,eo=p.children,to=p.marginLeft,io=p.marginRight,no=p.active,ao=p.id,ro=p["data-testid"],so=i(p,["secondaryDialogContent","onSecondaryDialogDidShow","onSecondaryDialogDidHide","shouldCloseOnClickInsideDialog","zIndex","secondaryDialogClassName","secondaryDialogPosition","dialogContainerSelector","dialogPaddingSize","disabled","success","loading","kind","color","className","leftIcon","rightIcon","onClick","children","marginLeft","marginRight","active","id","data-testid"]),lo=c(!1),co=o(lo,2),mo=co[0],uo=co[1],go=c(!1),po=o(go,2),fo=po[0],Do=po[1],vo=c(!1),yo=o(vo,2),Co=yo[0],To=yo[1],So=m(null),No=m(null),bo=u((function(){return Do(!0)}),[Do]),ho=u((function(){return Do(!1)}),[Do]),ko=u((function(o){return!X&&!k(o.target,T)}),[X]),Po=u((function(o){ko(o)&&To(!0)}),[To,ko]),jo=u((function(){return To(!1)}),[To]),Io=u((function(o){ko(o)&&To(!0)}),[To,ko]),Bo=u((function(){uo(!0),L()}),[uo,L]),Oo=u((function(o,e){uo(!1),x(),"esckey"===e&&No.current.focus()}),[uo,x]);j({eventName:"mouseenter",callback:bo,ref:So}),j({eventName:"mouseleave",callback:ho,ref:So}),j({eventName:"mousedown",callback:Po,ref:So}),j({eventName:"mouseup",callback:jo,ref:So}),j({eventName:"transitionend",callback:jo,ref:So}),P({keys:f,ref:So,callback:Io});var Eo=g((function(){return l(E.button,a(E,n("kind-"+G)),a(E,n("color-"+J)),e(e(e(e(e({},E.mainActive,no),E.active,Co),E.splitContentOpen,mo),E.hovered,fo),E.disabled,X),Q)}),[Q,G,J,no,Co,mo,fo,X]),_o=g((function(){return X?[]:D}),[X]),zo=g((function(){return R?[].concat(t(v),[N.CONTENT_CLICK]):v}),[R]),wo=u((function(){var o="function"==typeof S?S():S;return d.createElement(O,{type:O.types.POPOVER,size:V},o)}),[S,V]),Lo=g((function(){return"bottom"===K?"":"bottom-start"===K?"bottom":"top"}),[K]);return d.createElement("div",{className:Eo,ref:So,id:ao,"data-testid":ro||r(s.SPLIT_BUTTON,ao),"data-vibe":_.SPLIT_BUTTON},d.createElement(I,Object.assign({},so,{preventClickAnimation:!0,leftIcon:Z,rightIcon:$,rightFlat:!0,color:J,kind:G,active:no,onClick:oo,className:E.mainButton,marginLeft:to,onFocus:bo,onBlur:ho,disabled:X,loading:q,"data-testid":r(s.SPLIT_BUTTON_PRIMARY_BUTTON,ao)}),eo),d.createElement("div",{className:E.secondaryButtonWrapper},d.createElement(B,{wrapperClassName:M,zIndex:U,content:wo,position:K,containerSelector:W,startingEdge:Lo,animationType:b.EXPAND,moveBy:y,onDialogDidShow:Bo,onDialogDidHide:Oo,showTrigger:_o,hideTrigger:zo},d.createElement(I,Object.assign({},so,{ref:No,preventClickAnimation:!0,leftFlat:!0,noSidePadding:!0,color:J,kind:G,className:E.secondaryButton,active:mo,marginRight:io,onFocus:bo,onBlur:ho,disabled:X,ariaLabel:C,ariaHasPopup:!0,ariaExpanded:mo,"data-testid":r(s.SPLIT_BUTTON_SECONDARY_BUTTON,ao)}),d.createElement("div",{className:E.secondaryButtonIconWrapper},d.createElement(z,{"aria-hidden":"true"}))))))};w.defaultProps=Object.assign(Object.assign({},I.defaultProps),{onSecondaryDialogDidShow:h,onSecondaryDialogDidHide:h,zIndex:null,secondaryDialogClassName:"",secondaryDialogPosition:p.BOTTOM_START,dialogPaddingSize:O.sizes.MEDIUM});var L=S(w,{secondaryPositions:p,secondaryDialogPositions:p,sizes:I.sizes,colors:I.colors,kinds:I.kinds,inputTags:I.inputTags,dialogPaddingSizes:O.sizes});export{L as default};
|
|
2
2
|
//# sourceMappingURL=SplitButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitButton.js","sources":["../../../../src/components/SplitButton/SplitButton.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\n// Libraries import\nimport React, { ReactElement, useCallback, useMemo, useRef, useState } from \"react\";\n// Constants import\nimport {\n DEFAULT_DIALOG_HIDE_TRIGGER,\n DEFAULT_DIALOG_SHOW_TRIGGER,\n DIALOG_MOVE_BY,\n ENTER_KEYS,\n SECONDARY_BUTTON_ARIA_LABEL,\n SECONDARY_BUTTON_WRAPPER_CLASSNAME,\n SplitButtonSecondaryContentPosition,\n SplitButtonSecondaryContentPositionType\n} from \"./SplitButtonConstants\";\nimport { withStaticProps } from \"../../types\";\nimport { AnimationType, DialogPosition, HideShowEvent } from \"../Dialog/DialogConstants\";\n// Utils import\nimport { NOOP } from \"../../utils/function-utils\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\n// Hooks import\nimport useKeyEvent from \"../../hooks/useKeyEvent\";\nimport useEventListener from \"../../hooks/useEventListener\";\n// Components import\nimport Button, { ButtonProps } from \"../Button/Button\";\nimport Dialog, { DialogEvent } from \"../Dialog/Dialog\";\nimport { DropdownChevronDown } from \"@vibe/icons\";\nimport DialogContentContainer from \"../DialogContentContainer/DialogContentContainer\";\nimport styles from \"./SplitButton.module.scss\";\nimport { DialogSize, DialogTriggerEvent } from \"../Dialog\";\nimport { ComponentVibeId } from \"../../tests/constants\";\n\nexport interface SplitButtonProps extends ButtonProps {\n /**\n * The element or renderer that is displayed inside the dialog opened by clicking the secondary button.\n */\n secondaryDialogContent?: ReactElement | (() => string | ReactElement);\n /**\n * Callback fired when the secondary dialog is shown.\n */\n onSecondaryDialogDidShow?: () => void;\n /**\n * Callback fired when the secondary dialog is hidden.\n */\n onSecondaryDialogDidHide?: () => void;\n /**\n * The z-index applied to the secondary dialog.\n */\n zIndex?: number;\n /**\n * Class name applied to the wrapper of the secondary dialog.\n */\n secondaryDialogClassName?: string;\n /**\n * The position of the secondary dialog.\n */\n secondaryDialogPosition?: SplitButtonSecondaryContentPositionType;\n /**\n * The padding size inside the secondary dialog.\n */\n dialogPaddingSize?: DialogSize;\n /**\n * The CSS selector of the container where the dialog should be rendered.\n */\n dialogContainerSelector?: string;\n /**\n * If true, clicking inside the dialog will close it.\n */\n shouldCloseOnClickInsideDialog?: boolean;\n}\n\nconst SplitButton = ({\n secondaryDialogContent,\n onSecondaryDialogDidShow = NOOP,\n onSecondaryDialogDidHide = NOOP,\n shouldCloseOnClickInsideDialog,\n zIndex = null,\n secondaryDialogClassName,\n secondaryDialogPosition = \"bottom-start\",\n dialogContainerSelector,\n dialogPaddingSize = \"medium\",\n disabled,\n // success mode not working right now, need to fix it in different pr\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n success,\n loading,\n kind,\n color,\n className,\n leftIcon,\n rightIcon,\n onClick,\n children,\n marginLeft,\n marginRight,\n active,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}: SplitButtonProps) => {\n // State //\n const [isDialogOpen, setDialogOpen] = useState(false);\n const [isHovered, setIsHover] = useState(false);\n const [isActive, setIsActive] = useState(false);\n\n // Refs //\n const ref = useRef(null);\n const secondaryButtonRef = useRef(null);\n\n // Callbacks //\n const setHovered = useCallback(() => setIsHover(true), [setIsHover]);\n const setNotHovered = useCallback(() => setIsHover(false), [setIsHover]);\n\n const shouldSetActive = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (disabled) return false;\n return !isInsideClass(e.target as HTMLElement, SECONDARY_BUTTON_WRAPPER_CLASSNAME);\n },\n [disabled]\n );\n\n const setActive = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (!shouldSetActive(e)) return;\n setIsActive(true);\n },\n [setIsActive, shouldSetActive]\n );\n const setNotActive = useCallback(() => setIsActive(false), [setIsActive]);\n const setActiveOnEnter = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (!shouldSetActive(e)) return;\n setIsActive(true);\n },\n [setIsActive, shouldSetActive]\n );\n\n const showDialog = useCallback(() => {\n setDialogOpen(true);\n onSecondaryDialogDidShow();\n }, [setDialogOpen, onSecondaryDialogDidShow]);\n\n const hideDialog = useCallback(\n (_: DialogEvent, eventName: DialogTriggerEvent) => {\n setDialogOpen(false);\n onSecondaryDialogDidHide();\n if (eventName === \"esckey\") {\n secondaryButtonRef.current.focus();\n }\n },\n [setDialogOpen, onSecondaryDialogDidHide]\n );\n\n // Event listeners //\n\n // Used to set both buttons as hovered no matter what button was hovered\n useEventListener({ eventName: \"mouseenter\", callback: setHovered, ref });\n useEventListener({ eventName: \"mouseleave\", callback: setNotHovered, ref });\n\n useEventListener({ eventName: \"mousedown\", callback: setActive, ref });\n useEventListener({ eventName: \"mouseup\", callback: setNotActive, ref });\n\n // Used to finish active transition if clicked on enter\n useEventListener({ eventName: \"transitionend\", callback: setNotActive, ref });\n\n // Key events\n useKeyEvent({ keys: ENTER_KEYS, ref, callback: setActiveOnEnter });\n\n const classNames = useMemo(\n () =>\n cx(\n styles.button,\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + color)),\n {\n [styles.mainActive]: active,\n [styles.active]: isActive,\n [styles.splitContentOpen]: isDialogOpen,\n [styles.hovered]: isHovered,\n [styles.disabled]: disabled\n },\n className\n ),\n [className, kind, color, active, isActive, isDialogOpen, isHovered, disabled]\n );\n\n const dialogShowTrigger = useMemo(() => (disabled ? [] : DEFAULT_DIALOG_SHOW_TRIGGER), [disabled]);\n\n const dialogHideTrigger = useMemo(() => {\n if (shouldCloseOnClickInsideDialog) return [...DEFAULT_DIALOG_HIDE_TRIGGER, HideShowEvent.CONTENT_CLICK];\n return DEFAULT_DIALOG_HIDE_TRIGGER;\n }, [shouldCloseOnClickInsideDialog]);\n\n const actionsContent = useCallback(() => {\n const content = typeof secondaryDialogContent === \"function\" ? secondaryDialogContent() : secondaryDialogContent;\n return (\n <DialogContentContainer type={DialogContentContainer.types.POPOVER} size={dialogPaddingSize}>\n {content}\n </DialogContentContainer>\n );\n }, [secondaryDialogContent, dialogPaddingSize]);\n\n const animationEdgePosition = useMemo(() => {\n if (secondaryDialogPosition === \"bottom\") {\n return \"\";\n }\n if (secondaryDialogPosition === \"bottom-start\") {\n return \"bottom\";\n }\n\n return \"top\";\n }, [secondaryDialogPosition]);\n\n return (\n <div\n className={classNames}\n ref={ref}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.SPLIT_BUTTON, id)}\n data-vibe={ComponentVibeId.SPLIT_BUTTON}\n >\n <Button\n {\n ...buttonProps /* We are enriching button with other props so we must use spreading */\n }\n preventClickAnimation\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n rightFlat\n color={color}\n kind={kind}\n active={active}\n onClick={onClick}\n className={styles.mainButton}\n marginLeft={marginLeft}\n onFocus={setHovered}\n onBlur={setNotHovered}\n disabled={disabled}\n loading={loading}\n data-testid={getTestId(ComponentDefaultTestId.SPLIT_BUTTON_PRIMARY_BUTTON, id)}\n >\n {children}\n </Button>\n <div className={styles.secondaryButtonWrapper}>\n <Dialog\n wrapperClassName={secondaryDialogClassName}\n zIndex={zIndex}\n content={actionsContent}\n position={secondaryDialogPosition as DialogPosition}\n containerSelector={dialogContainerSelector}\n startingEdge={animationEdgePosition}\n animationType={AnimationType.EXPAND}\n moveBy={DIALOG_MOVE_BY}\n onDialogDidShow={showDialog}\n onDialogDidHide={hideDialog}\n showTrigger={dialogShowTrigger}\n hideTrigger={dialogHideTrigger}\n >\n <Button\n {...buttonProps}\n ref={secondaryButtonRef}\n preventClickAnimation\n leftFlat\n noSidePadding\n color={color}\n kind={kind}\n className={styles.secondaryButton}\n active={isDialogOpen}\n marginRight={marginRight}\n onFocus={setHovered}\n onBlur={setNotHovered}\n disabled={disabled}\n ariaLabel={SECONDARY_BUTTON_ARIA_LABEL}\n ariaHasPopup\n ariaExpanded={isDialogOpen}\n data-testid={getTestId(ComponentDefaultTestId.SPLIT_BUTTON_SECONDARY_BUTTON, id)}\n >\n <div className={styles.secondaryButtonIconWrapper}>\n <DropdownChevronDown aria-hidden=\"true\" />\n </div>\n </Button>\n </Dialog>\n </div>\n </div>\n );\n};\n\nSplitButton.defaultProps = {\n ...Button.defaultProps,\n onSecondaryDialogDidShow: NOOP,\n onSecondaryDialogDidHide: NOOP,\n zIndex: null,\n secondaryDialogClassName: \"\",\n secondaryDialogPosition: SplitButtonSecondaryContentPosition.BOTTOM_START,\n dialogPaddingSize: DialogContentContainer.sizes.MEDIUM\n};\n\ninterface SplitButtonStaticProps {\n secondaryPositions: typeof SplitButtonSecondaryContentPosition;\n secondaryDialogPositions: typeof SplitButtonSecondaryContentPosition;\n sizes: typeof Button.sizes;\n colors: typeof Button.colors;\n kinds: typeof Button.kinds;\n inputTags: typeof Button.inputTags;\n dialogPaddingSizes: typeof DialogContentContainer.sizes;\n}\n\nexport default withStaticProps<SplitButtonProps, SplitButtonStaticProps>(SplitButton, {\n secondaryPositions: SplitButtonSecondaryContentPosition,\n secondaryDialogPositions: SplitButtonSecondaryContentPosition,\n sizes: Button.sizes,\n colors: Button.colors,\n kinds: Button.kinds,\n inputTags: Button.inputTags,\n dialogPaddingSizes: DialogContentContainer.sizes\n});\n"],"names":["SplitButton","_a","secondaryDialogContent","_a$onSecondaryDialogD","onSecondaryDialogDidShow","NOOP","_a$onSecondaryDialogD2","onSecondaryDialogDidHide","shouldCloseOnClickInsideDialog","_a$zIndex","zIndex","secondaryDialogClassName","_a$secondaryDialogPos","secondaryDialogPosition","dialogContainerSelector","_a$dialogPaddingSize","dialogPaddingSize","disabled","loading","kind","color","className","leftIcon","rightIcon","onClick","children","marginLeft","marginRight","active","id","dataTestId","buttonProps","__rest","_useState","useState","_useState2","_slicedToArray","isDialogOpen","setDialogOpen","_useState3","_useState4","isHovered","setIsHover","_useState5","_useState6","isActive","setIsActive","ref","useRef","secondaryButtonRef","setHovered","useCallback","setNotHovered","shouldSetActive","e","isInsideClass","target","SECONDARY_BUTTON_WRAPPER_CLASSNAME","setActive","setNotActive","setActiveOnEnter","showDialog","hideDialog","_","eventName","current","focus","useEventListener","callback","useKeyEvent","keys","ENTER_KEYS","classNames","useMemo","cx","styles","button","getStyle","camelCase","_defineProperty","mainActive","splitContentOpen","hovered","dialogShowTrigger","DEFAULT_DIALOG_SHOW_TRIGGER","dialogHideTrigger","concat","_toConsumableArray","DEFAULT_DIALOG_HIDE_TRIGGER","HideShowEvent","CONTENT_CLICK","actionsContent","content","React","createElement","DialogContentContainer","type","types","POPOVER","size","animationEdgePosition","getTestId","ComponentDefaultTestId","SPLIT_BUTTON","ComponentVibeId","Button","Object","assign","preventClickAnimation","rightFlat","mainButton","onFocus","onBlur","SPLIT_BUTTON_PRIMARY_BUTTON","secondaryButtonWrapper","Dialog","wrapperClassName","position","containerSelector","startingEdge","animationType","AnimationType","EXPAND","moveBy","DIALOG_MOVE_BY","onDialogDidShow","onDialogDidHide","showTrigger","hideTrigger","leftFlat","noSidePadding","secondaryButton","ariaLabel","SECONDARY_BUTTON_ARIA_LABEL","ariaHasPopup","ariaExpanded","SPLIT_BUTTON_SECONDARY_BUTTON","secondaryButtonIconWrapper","DropdownChevronDown","defaultProps","SplitButtonSecondaryContentPosition","BOTTOM_START","sizes","MEDIUM","withStaticProps","secondaryPositions","secondaryDialogPositions","colors","kinds","inputTags","dialogPaddingSizes"],"mappings":"44CA0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IAEbQ,EAAAC,cAACW,EAAMC,OAAAC,OAAA,CAAA,EACD5E,GAAW,CACfgB,IAAKE,GACL2D,uBAAqB,EACrBqB,UAAQ,EACRC,eACA,EAAA9G,MAAOA,EACPD,KAAMA,EACNE,UAAWsD,EAAOwD,gBAClBvG,OAAQS,GACRV,YAAaA,GACboF,QAAS7D,GACT8D,OAAQ5D,GACRnC,SAAUA,EACVmH,UAAWC,EACXC,cACA,EAAAC,aAAclG,GAAY,cACbgE,EAAUC,EAAuBkC,8BAA+B3G,MAE7EgE,EAAAC,cAAA,MAAA,CAAKzE,UAAWsD,EAAO8D,4BACrB5C,EAACC,cAAA4C,EAAgC,CAAA,cAAA,aAO/C,EAEA1I,EAAY2I,aAAYjC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EACnBF,EAAOkC,cACV,CAAAvI,yBAA0BC,EAC1BE,yBAA0BF,EAC1BK,OAAQ,KACRC,yBAA0B,GAC1BE,wBAAyB+H,EAAoCC,aAC7D7H,kBAAmB+E,EAAuB+C,MAAMC,SAalD,IAAeC,EAAAA,EAA0DhJ,EAAa,CACpFiJ,mBAAoBL,EACpBM,yBAA0BN,EAC1BE,MAAOrC,EAAOqC,MACdK,OAAQ1C,EAAO0C,OACfC,MAAO3C,EAAO2C,MACdC,UAAW5C,EAAO4C,UAClBC,mBAAoBvD,EAAuB+C"}
|
|
1
|
+
{"version":3,"file":"SplitButton.js","sources":["../../../../src/components/SplitButton/SplitButton.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\n// Libraries import\nimport React, { ReactElement, useCallback, useMemo, useRef, useState } from \"react\";\n// Constants import\nimport {\n DEFAULT_DIALOG_HIDE_TRIGGER,\n DEFAULT_DIALOG_SHOW_TRIGGER,\n DIALOG_MOVE_BY,\n ENTER_KEYS,\n SECONDARY_BUTTON_ARIA_LABEL,\n SECONDARY_BUTTON_WRAPPER_CLASSNAME,\n SplitButtonSecondaryContentPosition,\n SplitButtonSecondaryContentPositionType\n} from \"./SplitButtonConstants\";\nimport { withStaticPropsWithoutForwardRef } from \"../../types\";\nimport { AnimationType, DialogPosition, HideShowEvent } from \"../Dialog/DialogConstants\";\n// Utils import\nimport { NOOP } from \"../../utils/function-utils\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\n// Hooks import\nimport useKeyEvent from \"../../hooks/useKeyEvent\";\nimport useEventListener from \"../../hooks/useEventListener\";\n// Components import\nimport Button, { ButtonProps } from \"../Button/Button\";\nimport Dialog, { DialogEvent } from \"../Dialog/Dialog\";\nimport { DropdownChevronDown } from \"@vibe/icons\";\nimport DialogContentContainer from \"../DialogContentContainer/DialogContentContainer\";\nimport styles from \"./SplitButton.module.scss\";\nimport { DialogSize, DialogTriggerEvent } from \"../Dialog\";\nimport { ComponentVibeId } from \"../../tests/constants\";\n\nexport interface SplitButtonProps extends ButtonProps {\n /**\n * The element or renderer that is displayed inside the dialog opened by clicking the secondary button.\n */\n secondaryDialogContent?: ReactElement | (() => string | ReactElement);\n /**\n * Callback fired when the secondary dialog is shown.\n */\n onSecondaryDialogDidShow?: () => void;\n /**\n * Callback fired when the secondary dialog is hidden.\n */\n onSecondaryDialogDidHide?: () => void;\n /**\n * The z-index applied to the secondary dialog.\n */\n zIndex?: number;\n /**\n * Class name applied to the wrapper of the secondary dialog.\n */\n secondaryDialogClassName?: string;\n /**\n * The position of the secondary dialog.\n */\n secondaryDialogPosition?: SplitButtonSecondaryContentPositionType;\n /**\n * The padding size inside the secondary dialog.\n */\n dialogPaddingSize?: DialogSize;\n /**\n * The CSS selector of the container where the dialog should be rendered.\n */\n dialogContainerSelector?: string;\n /**\n * If true, clicking inside the dialog will close it.\n */\n shouldCloseOnClickInsideDialog?: boolean;\n}\n\nconst SplitButton = ({\n secondaryDialogContent,\n onSecondaryDialogDidShow = NOOP,\n onSecondaryDialogDidHide = NOOP,\n shouldCloseOnClickInsideDialog,\n zIndex = null,\n secondaryDialogClassName,\n secondaryDialogPosition = \"bottom-start\",\n dialogContainerSelector,\n dialogPaddingSize = \"medium\",\n disabled,\n // success mode not working right now, need to fix it in different pr\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n success,\n loading,\n kind,\n color,\n className,\n leftIcon,\n rightIcon,\n onClick,\n children,\n marginLeft,\n marginRight,\n active,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}: SplitButtonProps) => {\n // State //\n const [isDialogOpen, setDialogOpen] = useState(false);\n const [isHovered, setIsHover] = useState(false);\n const [isActive, setIsActive] = useState(false);\n\n // Refs //\n const ref = useRef(null);\n const secondaryButtonRef = useRef(null);\n\n // Callbacks //\n const setHovered = useCallback(() => setIsHover(true), [setIsHover]);\n const setNotHovered = useCallback(() => setIsHover(false), [setIsHover]);\n\n const shouldSetActive = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (disabled) return false;\n return !isInsideClass(e.target as HTMLElement, SECONDARY_BUTTON_WRAPPER_CLASSNAME);\n },\n [disabled]\n );\n\n const setActive = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (!shouldSetActive(e)) return;\n setIsActive(true);\n },\n [setIsActive, shouldSetActive]\n );\n const setNotActive = useCallback(() => setIsActive(false), [setIsActive]);\n const setActiveOnEnter = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (!shouldSetActive(e)) return;\n setIsActive(true);\n },\n [setIsActive, shouldSetActive]\n );\n\n const showDialog = useCallback(() => {\n setDialogOpen(true);\n onSecondaryDialogDidShow();\n }, [setDialogOpen, onSecondaryDialogDidShow]);\n\n const hideDialog = useCallback(\n (_: DialogEvent, eventName: DialogTriggerEvent) => {\n setDialogOpen(false);\n onSecondaryDialogDidHide();\n if (eventName === \"esckey\") {\n secondaryButtonRef.current.focus();\n }\n },\n [setDialogOpen, onSecondaryDialogDidHide]\n );\n\n // Event listeners //\n\n // Used to set both buttons as hovered no matter what button was hovered\n useEventListener({ eventName: \"mouseenter\", callback: setHovered, ref });\n useEventListener({ eventName: \"mouseleave\", callback: setNotHovered, ref });\n\n useEventListener({ eventName: \"mousedown\", callback: setActive, ref });\n useEventListener({ eventName: \"mouseup\", callback: setNotActive, ref });\n\n // Used to finish active transition if clicked on enter\n useEventListener({ eventName: \"transitionend\", callback: setNotActive, ref });\n\n // Key events\n useKeyEvent({ keys: ENTER_KEYS, ref, callback: setActiveOnEnter });\n\n const classNames = useMemo(\n () =>\n cx(\n styles.button,\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + color)),\n {\n [styles.mainActive]: active,\n [styles.active]: isActive,\n [styles.splitContentOpen]: isDialogOpen,\n [styles.hovered]: isHovered,\n [styles.disabled]: disabled\n },\n className\n ),\n [className, kind, color, active, isActive, isDialogOpen, isHovered, disabled]\n );\n\n const dialogShowTrigger = useMemo(() => (disabled ? [] : DEFAULT_DIALOG_SHOW_TRIGGER), [disabled]);\n\n const dialogHideTrigger = useMemo(() => {\n if (shouldCloseOnClickInsideDialog) return [...DEFAULT_DIALOG_HIDE_TRIGGER, HideShowEvent.CONTENT_CLICK];\n return DEFAULT_DIALOG_HIDE_TRIGGER;\n }, [shouldCloseOnClickInsideDialog]);\n\n const actionsContent = useCallback(() => {\n const content = typeof secondaryDialogContent === \"function\" ? secondaryDialogContent() : secondaryDialogContent;\n return (\n <DialogContentContainer type={DialogContentContainer.types.POPOVER} size={dialogPaddingSize}>\n {content}\n </DialogContentContainer>\n );\n }, [secondaryDialogContent, dialogPaddingSize]);\n\n const animationEdgePosition = useMemo(() => {\n if (secondaryDialogPosition === \"bottom\") {\n return \"\";\n }\n if (secondaryDialogPosition === \"bottom-start\") {\n return \"bottom\";\n }\n\n return \"top\";\n }, [secondaryDialogPosition]);\n\n return (\n <div\n className={classNames}\n ref={ref}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.SPLIT_BUTTON, id)}\n data-vibe={ComponentVibeId.SPLIT_BUTTON}\n >\n <Button\n {\n ...buttonProps /* We are enriching button with other props so we must use spreading */\n }\n preventClickAnimation\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n rightFlat\n color={color}\n kind={kind}\n active={active}\n onClick={onClick}\n className={styles.mainButton}\n marginLeft={marginLeft}\n onFocus={setHovered}\n onBlur={setNotHovered}\n disabled={disabled}\n loading={loading}\n data-testid={getTestId(ComponentDefaultTestId.SPLIT_BUTTON_PRIMARY_BUTTON, id)}\n >\n {children}\n </Button>\n <div className={styles.secondaryButtonWrapper}>\n <Dialog\n wrapperClassName={secondaryDialogClassName}\n zIndex={zIndex}\n content={actionsContent}\n position={secondaryDialogPosition as DialogPosition}\n containerSelector={dialogContainerSelector}\n startingEdge={animationEdgePosition}\n animationType={AnimationType.EXPAND}\n moveBy={DIALOG_MOVE_BY}\n onDialogDidShow={showDialog}\n onDialogDidHide={hideDialog}\n showTrigger={dialogShowTrigger}\n hideTrigger={dialogHideTrigger}\n >\n <Button\n {...buttonProps}\n ref={secondaryButtonRef}\n preventClickAnimation\n leftFlat\n noSidePadding\n color={color}\n kind={kind}\n className={styles.secondaryButton}\n active={isDialogOpen}\n marginRight={marginRight}\n onFocus={setHovered}\n onBlur={setNotHovered}\n disabled={disabled}\n ariaLabel={SECONDARY_BUTTON_ARIA_LABEL}\n ariaHasPopup\n ariaExpanded={isDialogOpen}\n data-testid={getTestId(ComponentDefaultTestId.SPLIT_BUTTON_SECONDARY_BUTTON, id)}\n >\n <div className={styles.secondaryButtonIconWrapper}>\n <DropdownChevronDown aria-hidden=\"true\" />\n </div>\n </Button>\n </Dialog>\n </div>\n </div>\n );\n};\n\nSplitButton.defaultProps = {\n ...Button.defaultProps,\n onSecondaryDialogDidShow: NOOP,\n onSecondaryDialogDidHide: NOOP,\n zIndex: null,\n secondaryDialogClassName: \"\",\n secondaryDialogPosition: SplitButtonSecondaryContentPosition.BOTTOM_START,\n dialogPaddingSize: DialogContentContainer.sizes.MEDIUM\n};\n\ninterface SplitButtonStaticProps {\n secondaryPositions: typeof SplitButtonSecondaryContentPosition;\n secondaryDialogPositions: typeof SplitButtonSecondaryContentPosition;\n sizes: typeof Button.sizes;\n colors: typeof Button.colors;\n kinds: typeof Button.kinds;\n inputTags: typeof Button.inputTags;\n dialogPaddingSizes: typeof DialogContentContainer.sizes;\n}\n\nexport default withStaticPropsWithoutForwardRef<SplitButtonProps, SplitButtonStaticProps>(SplitButton, {\n secondaryPositions: SplitButtonSecondaryContentPosition,\n secondaryDialogPositions: SplitButtonSecondaryContentPosition,\n sizes: Button.sizes,\n colors: Button.colors,\n kinds: Button.kinds,\n inputTags: Button.inputTags,\n dialogPaddingSizes: DialogContentContainer.sizes\n});\n"],"names":["SplitButton","_a","secondaryDialogContent","_a$onSecondaryDialogD","onSecondaryDialogDidShow","NOOP","_a$onSecondaryDialogD2","onSecondaryDialogDidHide","shouldCloseOnClickInsideDialog","_a$zIndex","zIndex","secondaryDialogClassName","_a$secondaryDialogPos","secondaryDialogPosition","dialogContainerSelector","_a$dialogPaddingSize","dialogPaddingSize","disabled","loading","kind","color","className","leftIcon","rightIcon","onClick","children","marginLeft","marginRight","active","id","dataTestId","buttonProps","__rest","_useState","useState","_useState2","_slicedToArray","isDialogOpen","setDialogOpen","_useState3","_useState4","isHovered","setIsHover","_useState5","_useState6","isActive","setIsActive","ref","useRef","secondaryButtonRef","setHovered","useCallback","setNotHovered","shouldSetActive","e","isInsideClass","target","SECONDARY_BUTTON_WRAPPER_CLASSNAME","setActive","setNotActive","setActiveOnEnter","showDialog","hideDialog","_","eventName","current","focus","useEventListener","callback","useKeyEvent","keys","ENTER_KEYS","classNames","useMemo","cx","styles","button","getStyle","camelCase","_defineProperty","mainActive","splitContentOpen","hovered","dialogShowTrigger","DEFAULT_DIALOG_SHOW_TRIGGER","dialogHideTrigger","concat","_toConsumableArray","DEFAULT_DIALOG_HIDE_TRIGGER","HideShowEvent","CONTENT_CLICK","actionsContent","content","React","createElement","DialogContentContainer","type","types","POPOVER","size","animationEdgePosition","getTestId","ComponentDefaultTestId","SPLIT_BUTTON","ComponentVibeId","Button","Object","assign","preventClickAnimation","rightFlat","mainButton","onFocus","onBlur","SPLIT_BUTTON_PRIMARY_BUTTON","secondaryButtonWrapper","Dialog","wrapperClassName","position","containerSelector","startingEdge","animationType","AnimationType","EXPAND","moveBy","DIALOG_MOVE_BY","onDialogDidShow","onDialogDidHide","showTrigger","hideTrigger","leftFlat","noSidePadding","secondaryButton","ariaLabel","SECONDARY_BUTTON_ARIA_LABEL","ariaHasPopup","ariaExpanded","SPLIT_BUTTON_SECONDARY_BUTTON","secondaryButtonIconWrapper","DropdownChevronDown","defaultProps","SplitButtonSecondaryContentPosition","BOTTOM_START","sizes","MEDIUM","withStaticPropsWithoutForwardRef","secondaryPositions","secondaryDialogPositions","colors","kinds","inputTags","dialogPaddingSizes"],"mappings":"65CA0EA,IAAMA,EAAc,SAACC,GAAA,IACnBC,EA2BiBD,EA3BjBC,uBAAsBC,EA2BLF,EA1BjBG,yBAAAA,OAA2BC,IAAHF,EAAGE,EAAIF,EAAAG,EA0BdL,EAzBjBM,yBAAAA,OAA2BF,IAAHC,EAAGD,EAAIC,EAC/BE,EAwBiBP,EAxBjBO,+BAA8BC,EAwBbR,EAvBjBS,OAAAA,OAAS,IAAHD,EAAG,KAAIA,EACbE,EAsBiBV,EAtBjBU,yBAAwBC,EAsBPX,EArBjBY,wBAAAA,OAA0B,IAAHD,EAAG,eAAcA,EACxCE,EAoBiBb,EApBjBa,wBAAuBC,EAoBNd,EAnBjBe,kBAAAA,OAAoB,IAAHD,EAAG,SAAQA,EAC5BE,EAkBiBhB,EAlBjBgB,SAIAC,EAciBjB,EAdjBiB,QACAC,EAaiBlB,EAbjBkB,KACAC,EAYiBnB,EAZjBmB,MACAC,EAWiBpB,EAXjBoB,UACAC,EAUiBrB,EAVjBqB,SACAC,EASiBtB,EATjBsB,UACAC,GAQiBvB,EAR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AAeC,EAAAA,EAA2EhJ,EAAa,CACrGiJ,mBAAoBL,EACpBM,yBAA0BN,EAC1BE,MAAOrC,EAAOqC,MACdK,OAAQ1C,EAAO0C,OACfC,MAAO3C,EAAO2C,MACdC,UAAW5C,EAAO4C,UAClBC,mBAAoBvD,EAAuB+C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as e,toConsumableArray as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import o from"classnames";import
|
|
1
|
+
import{defineProperty as e,toConsumableArray as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import o from"classnames";import r,{forwardRef as a,useRef as i}from"react";import{noop as s}from"lodash-es";import n from"../../../hooks/useMergeRef.js";import{getStyle as l}from"../../../helpers/typesciptCssModulesHelper.js";import c from"../../Icon/Icon.js";import{getTestId as m,ComponentDefaultTestId as d}from"../../../tests/testIds.js";import p from"./Tab.module.scss.js";import f from"../../Tooltip/Tooltip.js";import{ComponentVibeId as u}from"../../../tests/constants.js";var b=a((function(a,b){var v=a.className,j=a.tabInnerClassName,y=a.id,I=a.value,T=void 0===I?0:I,C=a.disabled,h=void 0!==C&&C,N=a.active,g=void 0!==N&&N,k=a.focus,A=void 0!==k&&k,E=a.onClick,B=void 0===E?s:E,H=a.tooltipProps,P=void 0===H?{}:H,S=a.icon,F=a.iconType,M=a.iconSide,_=void 0===M?"left":M,x=a.children,z=a["data-testid"],O=i(null),R=n(b,O);return r.createElement(f,Object.assign({},P,{content:P.content}),r.createElement("li",{ref:R,key:y,className:o(p.tabWrapper,v,e(e(e({},p.active,g),p.disabled,h),p.tabFocusVisibleInset,A)),id:y,role:"tab","aria-selected":g,"aria-disabled":h,"data-testid":z||m(d.TAB,y),"data-vibe":u.TAB},r.createElement("a",{className:o(p.tabInner,j),onClick:function(){return!h&&B(T)}},function(){if(!S)return x;var e=r.createElement(c,{ariaHidden:!0,iconType:F,icon:S,className:o(p.tabIcon,l(p,_)),iconSize:18,ignoreFocusStyle:!0}),a=r.Children.toArray(x);return"left"===_?[e].concat(t(a)):[].concat(t(a),[e])}())))}));export{b as default};
|
|
2
2
|
//# sourceMappingURL=Tab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.js","sources":["../../../../../src/components/Tabs/Tab/Tab.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { FC, forwardRef, ReactElement, useRef } from \"react\";\nimport { noop as NOOP } from \"lodash-es\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport Icon from \"../../Icon/Icon\";\nimport VibeComponentProps from \"../../../types/VibeComponentProps\";\nimport { IconType } from \"../../Icon\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport styles from \"./Tab.module.scss\";\nimport { SubIcon } from \"../../../types/SubIcon\";\nimport Tooltip, { TooltipProps } from \"../../Tooltip/Tooltip\";\nimport { ComponentVibeId } from \"../../../tests/constants\";\
|
|
1
|
+
{"version":3,"file":"Tab.js","sources":["../../../../../src/components/Tabs/Tab/Tab.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { FC, forwardRef, ReactElement, useRef } from \"react\";\nimport { noop as NOOP } from \"lodash-es\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport Icon from \"../../Icon/Icon\";\nimport VibeComponentProps from \"../../../types/VibeComponentProps\";\nimport { IconType } from \"../../Icon\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport styles from \"./Tab.module.scss\";\nimport { SubIcon } from \"../../../types/SubIcon\";\nimport Tooltip, { TooltipProps } from \"../../Tooltip/Tooltip\";\nimport { ComponentVibeId } from \"../../../tests/constants\";\n\nexport interface TabProps extends VibeComponentProps {\n /**\n * Class name applied to the inner tab content.\n */\n tabInnerClassName?: string;\n /**\n * The index value of the tab.\n */\n value?: number;\n /**\n * If true, disables the tab.\n */\n disabled?: boolean;\n /**\n * If true, marks the tab as active.\n */\n active?: boolean;\n /**\n * If true, applies focus styles to the tab.\n */\n focus?: boolean;\n /**\n * The icon displayed in the tab.\n */\n icon?: SubIcon;\n /**\n * The type of icon.\n */\n iconType?: IconType;\n /**\n * The position of the icon relative to the text.\n */\n iconSide?: string;\n /**\n * Callback fired when the tab is clicked.\n */\n onClick?: (value: number) => void;\n /**\n * Props passed to the tab's tooltip.\n */\n tooltipProps?: Partial<TooltipProps>;\n /**\n * The content displayed inside the tab.\n */\n children?: string | ReactElement | ReactElement[];\n}\n\nconst Tab: FC<TabProps> = forwardRef(\n (\n {\n className,\n tabInnerClassName,\n id,\n value = 0,\n disabled = false,\n active = false,\n focus = false,\n onClick = NOOP,\n tooltipProps = {} as TooltipProps,\n icon,\n iconType,\n iconSide = \"left\",\n children,\n \"data-testid\": dataTestId\n }: TabProps,\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n function renderIconAndChildren() {\n if (!icon) return children;\n\n const iconElement = (\n <Icon\n ariaHidden={true}\n iconType={iconType}\n icon={icon}\n className={cx(styles.tabIcon, getStyle(styles, iconSide))}\n iconSize={18}\n ignoreFocusStyle\n />\n );\n\n const childrenArray = React.Children.toArray(children);\n\n if (iconSide === \"left\") {\n return [iconElement, ...childrenArray];\n }\n\n return [...childrenArray, iconElement];\n }\n return (\n <Tooltip {...tooltipProps} content={tooltipProps.content}>\n <li\n ref={mergedRef}\n key={id}\n className={cx(styles.tabWrapper, className, {\n [styles.active]: active,\n [styles.disabled]: disabled,\n [styles.tabFocusVisibleInset]: focus\n })}\n id={id}\n role=\"tab\"\n aria-selected={active}\n aria-disabled={disabled}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TAB, id)}\n data-vibe={ComponentVibeId.TAB}\n >\n {/* eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events */}\n <a className={cx(styles.tabInner, tabInnerClassName)} onClick={() => !disabled && onClick(value)}>\n {renderIconAndChildren()}\n </a>\n </li>\n </Tooltip>\n );\n }\n);\n\nexport default Tab;\n"],"names":["Tab","forwardRef","_ref","ref","className","tabInnerClassName","id","_ref$value","value","_ref$disabled","disabled","_ref$active","active","_ref$focus","focus","_ref$onClick","onClick","NOOP","_ref$tooltipProps","tooltipProps","icon","iconType","_ref$iconSide","iconSide","children","dataTestId","componentRef","useRef","mergedRef","useMergeRef","React","createElement","Tooltip","Object","assign","content","key","cx","styles","tabWrapper","_defineProperty","tabFocusVisibleInset","role","getTestId","ComponentDefaultTestId","TAB","ComponentVibeId","tabInner","iconElement","Icon","ariaHidden","tabIcon","getStyle","iconSize","ignoreFocusStyle","childrenArray","Children","toArray","concat","_toConsumableArray","renderIconAndChildren"],"mappings":"2kBA6DMA,IAAAA,EAAoBC,GACxB,SAAAC,EAiBEC,GACE,IAhBAC,EAASF,EAATE,UACAC,EAAiBH,EAAjBG,kBACAC,EAAEJ,EAAFI,GAAEC,EAAAL,EACFM,MAAAA,OAAQ,IAAHD,EAAG,EAACA,EAAAE,EAAAP,EACTQ,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAT,EAChBU,OAAAA,OAAS,IAAHD,GAAQA,EAAAE,EAAAX,EACdY,MAAAA,OAAQ,IAAHD,GAAQA,EAAAE,EAAAb,EACbc,QAAAA,OAAUC,IAAHF,EAAGE,EAAIF,EAAAG,EAAAhB,EACdiB,aAAAA,OAAY,IAAAD,EAAG,CAAkB,EAAAA,EACjCE,EAAIlB,EAAJkB,KACAC,EAAQnB,EAARmB,SAAQC,EAAApB,EACRqB,SAAAA,OAAW,IAAHD,EAAG,OAAMA,EACjBE,EAAQtB,EAARsB,SACeC,EAAUvB,EAAzB,eAIIwB,EAAeC,EAAO,MACtBC,EAAYC,EAAY1B,EAAKuB,GAwBnC,OACEI,EAACC,cAAAC,EAAYC,OAAAC,OAAA,CAAA,EAAAf,GAAcgB,QAAShB,EAAagB,UAC/CL,EAAAC,cAAA,KAAA,CACE5B,IAAKyB,EACLQ,IAAK9B,EACLF,UAAWiC,EAAGC,EAAOC,WAAYnC,EAASoC,EAAAA,EAAAA,EACvCF,GAAAA,EAAO1B,OAASA,GAChB0B,EAAO5B,SAAWA,GAClB4B,EAAOG,qBAAuB3B,IAEjCR,GAAIA,EACJoC,KAAK,MAAK,gBACK9B,EAAM,gBACNF,EAAQ,cACVe,GAAckB,EAAUC,EAAuBC,IAAKvC,GAAG,YACzDwC,EAAgBD,KAG3Bf,EAAAC,cAAA,IAAA,CAAG3B,UAAWiC,EAAGC,EAAOS,SAAU1C,GAAoBW,QAAS,WAAA,OAAON,GAAYM,EAAQR,EAAM,GAxCtG,WACE,IAAKY,EAAM,OAAOI,EAElB,IAAMwB,EACJlB,gBAACmB,EAAI,CACHC,YAAY,EACZ7B,SAAUA,EACVD,KAAMA,EACNhB,UAAWiC,EAAGC,EAAOa,QAASC,EAASd,EAAQf,IAC/C8B,SAAU,GACVC,kBAAgB,IAIdC,EAAgBzB,EAAM0B,SAASC,QAAQjC,GAE7C,MAAiB,SAAbD,EACF,CAAQyB,GAAWU,OAAAC,EAAKJ,IAG1B,GAAAG,OAAAC,EAAWJ,IAAeP,GAC5B,CAoBSY,KAKX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import t from"classnames";import{camelCase as r}from"lodash-es";import s,{forwardRef as
|
|
1
|
+
import{slicedToArray as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import t from"classnames";import{camelCase as r}from"lodash-es";import s,{forwardRef as o,useRef as a,useState as i,useEffect as n,useMemo as l,useCallback as m}from"react";import d from"../../../hooks/useGridKeyboardNavigation/useGridKeyboardNavigation.js";import u from"../../../hooks/useMergeRef.js";import c from"../../../hooks/usePrevious/index.js";import{NOOP as p}from"../../../utils/function-utils.js";import{getTestId as f,ComponentDefaultTestId as b}from"../../../tests/testIds.js";import{getStyle as v}from"../../../helpers/typesciptCssModulesHelper.js";import h from"./TabList.module.scss.js";var I=o((function(o,I){var C=o.className,T=o.id,g=o.onTabChange,j=void 0===g?p:g,N=o.activeTabId,y=void 0===N?0:N,L=o.tabType,k=void 0===L?"Compact":L,x=o.size,A=o.children,E=o["data-testid"],B=a(null),S=u(I,B),_=i(y),G=e(_,2),H=G[0],K=G[1],M=c(y);n((function(){y!==M&&y!==H&&K(y)}),[y,M,H,K]);var O=l((function(){var e=new Set;return s.Children.forEach(A,(function(t,r){t.props.disabled&&e.add(r)})),e}),[A]),P=m((function(e){O.has(e)||(K(e),j&&j(e))}),[j,O]),W=m((function(e,t){var r,s=null===(r=A[t].props)||void 0===r?void 0:r.onClick;O.has(t)||(s&&s(t),P(t))}),[A,O,P]),w=m((function(e){return A[e]}),[A]),z=l((function(){return Array.from(O)}),[O]),R=a(),q=d({ref:R,numberOfItemsInLine:null==A?void 0:A.length,itemsCount:null==A?void 0:A.length,getItemByIndex:w,onItemClicked:W,disabledIndexes:z}),D=q.activeIndex,F=q.onSelectionAction,J=l((function(){return s.Children.map(A,(function(e,r){return s.cloneElement(e,{value:r,active:H===r,focus:D===r,onClick:F,className:t(h.tabListTabWrapper,e.props.className),tabInnerClassName:t(h.tabListTabInner,e.props.tabInnerClassName)})}))}),[A,H,D,F]);return s.createElement("div",{ref:S,className:t(h.tabsWrapper,C,[v(h,r(k))]),id:T,"data-testid":E||f(b.TAB_LIST,T)},s.createElement("ul",{ref:R,tabIndex:0,className:t(h.tabsList,[v(h,x)]),role:"tablist"},J))}));Object.assign(I,{isTabList:!0});export{I as default};
|
|
2
2
|
//# sourceMappingURL=TabList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.js","sources":["../../../../../src/components/Tabs/TabList/TabList.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport { camelCase } from \"lodash-es\";\nimport React, { FC, forwardRef, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport useGridKeyboardNavigation from \"../../../hooks/useGridKeyboardNavigation/useGridKeyboardNavigation\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport usePrevious from \"../../../hooks/usePrevious\";\nimport VibeComponentProps from \"../../../types/VibeComponentProps\";\nimport { NOOP } from \"../../../utils/function-utils\";\nimport { TabProps } from \"../Tab/Tab\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport styles from \"./TabList.module.scss\";\n\nexport interface TabListProps extends VibeComponentProps {\n /**\n * Callback fired when the active tab changes.\n */\n onTabChange?: (tabId: number) => void;\n /**\n * The index of the currently active tab.\n */\n activeTabId?: number;\n /**\n * The type of tab style.\n */\n tabType?: string;\n /**\n * The size of the tab list.\n */\n size?: string;\n /**\n * The child elements representing tabs.\n */\n children?: ReactElement<TabProps>[];\n}\n\nconst TabList: FC<TabListProps> = forwardRef(\n (\n {\n className,\n id,\n onTabChange = NOOP,\n activeTabId = 0,\n tabType = \"Compact\",\n size,\n children,\n \"data-testid\": dataTestId\n },\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [activeTabState, setActiveTabState] = useState<number>(activeTabId);\n\n const prevActiveTabIdProp = usePrevious(activeTabId);\n\n useEffect(() => {\n // Update active tab if changed from props\n if (activeTabId !== prevActiveTabIdProp && activeTabId !== activeTabState) {\n setActiveTabState(activeTabId);\n }\n }, [activeTabId, prevActiveTabIdProp, activeTabState, setActiveTabState]);\n\n const disabledTabIds = useMemo(() => {\n const disabledIds = new Set<number>();\n React.Children.forEach(children, (child, index) => {\n if (child.props.disabled) {\n disabledIds.add(index);\n }\n });\n return disabledIds;\n }, [children]);\n\n const onTabSelect = useCallback(\n (tabId: number) => {\n if (disabledTabIds.has(tabId)) return;\n setActiveTabState(tabId);\n onTabChange && onTabChange(tabId);\n },\n [onTabChange, disabledTabIds]\n );\n\n const onTabClick = useCallback(\n (value: HTMLElement | void, tabId: number) => {\n const tabCallbackFunc = children[tabId].props?.onClick;\n if (disabledTabIds.has(tabId)) return;\n if (tabCallbackFunc) tabCallbackFunc(tabId);\n onTabSelect(tabId);\n },\n [children, disabledTabIds, onTabSelect]\n );\n\n const getItemByIndex = useCallback((index: number): ReactElement<TabProps> => children[index], [children]);\n const disabledIndexes = useMemo(() => Array.from(disabledTabIds), [disabledTabIds]);\n const ulRef = useRef();\n const { activeIndex: focusIndex, onSelectionAction } = useGridKeyboardNavigation({\n ref: ulRef,\n numberOfItemsInLine: children?.length,\n itemsCount: children?.length,\n getItemByIndex,\n onItemClicked: onTabClick,\n disabledIndexes
|
|
1
|
+
{"version":3,"file":"TabList.js","sources":["../../../../../src/components/Tabs/TabList/TabList.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport { camelCase } from \"lodash-es\";\nimport React, { FC, forwardRef, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport useGridKeyboardNavigation from \"../../../hooks/useGridKeyboardNavigation/useGridKeyboardNavigation\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport usePrevious from \"../../../hooks/usePrevious\";\nimport VibeComponentProps from \"../../../types/VibeComponentProps\";\nimport { NOOP } from \"../../../utils/function-utils\";\nimport { TabProps } from \"../Tab/Tab\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport styles from \"./TabList.module.scss\";\n\nexport interface TabListProps extends VibeComponentProps {\n /**\n * Callback fired when the active tab changes.\n */\n onTabChange?: (tabId: number) => void;\n /**\n * The index of the currently active tab.\n */\n activeTabId?: number;\n /**\n * The type of tab style.\n */\n tabType?: string;\n /**\n * The size of the tab list.\n */\n size?: string;\n /**\n * The child elements representing tabs.\n */\n children?: ReactElement<TabProps>[];\n}\n\nconst TabList: FC<TabListProps> = forwardRef(\n (\n {\n className,\n id,\n onTabChange = NOOP,\n activeTabId = 0,\n tabType = \"Compact\",\n size,\n children,\n \"data-testid\": dataTestId\n },\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [activeTabState, setActiveTabState] = useState<number>(activeTabId);\n\n const prevActiveTabIdProp = usePrevious(activeTabId);\n\n useEffect(() => {\n // Update active tab if changed from props\n if (activeTabId !== prevActiveTabIdProp && activeTabId !== activeTabState) {\n setActiveTabState(activeTabId);\n }\n }, [activeTabId, prevActiveTabIdProp, activeTabState, setActiveTabState]);\n\n const disabledTabIds = useMemo(() => {\n const disabledIds = new Set<number>();\n React.Children.forEach(children, (child, index) => {\n if (child.props.disabled) {\n disabledIds.add(index);\n }\n });\n return disabledIds;\n }, [children]);\n\n const onTabSelect = useCallback(\n (tabId: number) => {\n if (disabledTabIds.has(tabId)) return;\n setActiveTabState(tabId);\n onTabChange && onTabChange(tabId);\n },\n [onTabChange, disabledTabIds]\n );\n\n const onTabClick = useCallback(\n (value: HTMLElement | void, tabId: number) => {\n const tabCallbackFunc = children[tabId].props?.onClick;\n if (disabledTabIds.has(tabId)) return;\n if (tabCallbackFunc) tabCallbackFunc(tabId);\n onTabSelect(tabId);\n },\n [children, disabledTabIds, onTabSelect]\n );\n\n const getItemByIndex = useCallback((index: number): ReactElement<TabProps> => children[index], [children]);\n const disabledIndexes = useMemo(() => Array.from(disabledTabIds), [disabledTabIds]);\n const ulRef = useRef();\n const { activeIndex: focusIndex, onSelectionAction } = useGridKeyboardNavigation({\n ref: ulRef,\n numberOfItemsInLine: children?.length,\n itemsCount: children?.length,\n getItemByIndex,\n onItemClicked: onTabClick,\n disabledIndexes\n });\n\n const tabsToRender = useMemo(() => {\n const childrenToRender = React.Children.map(children, (child, index) => {\n return React.cloneElement(child, {\n value: index,\n active: activeTabState === index,\n focus: focusIndex === index,\n onClick: onSelectionAction,\n className: cx(styles.tabListTabWrapper, child.props.className),\n tabInnerClassName: cx(styles.tabListTabInner, child.props.tabInnerClassName)\n });\n });\n return childrenToRender;\n }, [children, activeTabState, focusIndex, onSelectionAction]);\n\n return (\n <div\n ref={mergedRef}\n className={cx(styles.tabsWrapper, className, [getStyle(styles, camelCase(tabType))])}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TAB_LIST, id)}\n >\n <ul ref={ulRef} tabIndex={0} className={cx(styles.tabsList, [getStyle(styles, size)])} role=\"tablist\">\n {tabsToRender}\n </ul>\n </div>\n );\n }\n);\n\nObject.assign(TabList, {\n isTabList: true\n});\n\nexport default TabList;\n"],"names":["TabList","forwardRef","_ref","ref","className","id","_ref$onTabChange","onTabChange","NOOP","_ref$activeTabId","activeTabId","_ref$tabType","tabType","size","children","dataTestId","componentRef","useRef","mergedRef","useMergeRef","_useState","useState","_useState2","_slicedToArray","activeTabState","setActiveTabState","prevActiveTabIdProp","usePrevious","useEffect","disabledTabIds","useMemo","disabledIds","Set","React","Children","forEach","child","index","props","disabled","add","onTabSelect","useCallback","tabId","has","onTabClick","value","tabCallbackFunc","_a","onClick","getItemByIndex","disabledIndexes","Array","from","ulRef","_useGridKeyboardNavig","useGridKeyboardNavigation","numberOfItemsInLine","length","itemsCount","onItemClicked","focusIndex","activeIndex","onSelectionAction","tabsToRender","map","cloneElement","active","focus","cx","styles","tabListTabWrapper","tabInnerClassName","tabListTabInner","createElement","tabsWrapper","getStyle","camelCase","getTestId","ComponentDefaultTestId","TAB_LIST","tabIndex","tabsList","role","Object","assign","isTabList"],"mappings":"+qBAoCMA,IAAAA,EAA4BC,GAChC,SAAAC,EAWEC,GACE,IAVAC,EAASF,EAATE,UACAC,EAAEH,EAAFG,GAAEC,EAAAJ,EACFK,YAAAA,OAAcC,IAAHF,EAAGE,EAAIF,EAAAG,EAAAP,EAClBQ,YAAAA,OAAc,IAAHD,EAAG,EAACA,EAAAE,EAAAT,EACfU,QAAAA,OAAU,IAAHD,EAAG,UAASA,EACnBE,EAAIX,EAAJW,KACAC,EAAQZ,EAARY,SACeC,EAAUb,EAAzB,eAIIc,EAAeC,EAAO,MACtBC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aAAa9B,EAAO,CAC/BU,MAAOT,EACP8B,OAAQ3C,IAAmBa,EAC3B+B,MAAOP,IAAexB,EACtBY,QAASc,EACT3D,UAAWiE,EAAGC,EAAOC,kBAAmBnC,EAAME,MAAMlC,WACpDoE,kBAAmBH,EAAGC,EAAOG,gBAAiBrC,EAAME,MAAMkC,oBAE9D,GAED,GAAE,CAAC1D,EAAUU,EAAgBqC,EAAYE,IAE1C,OACE9B,EACEyC,cAAA,MAAA,CAAAvE,IAAKe,EACLd,UAAWiE,EAAGC,EAAOK,YAAavE,EAAW,CAACwE,EAASN,EAAQO,EAAUjE,MACzEP,GAAIA,gBACSU,GAAc+D,EAAUC,EAAuBC,SAAU3E,IAEtE4B,EAAAyC,cAAA,KAAA,CAAIvE,IAAKmD,EAAO2B,SAAU,EAAG7E,UAAWiE,EAAGC,EAAOY,SAAU,CAACN,EAASN,EAAQzD,KAASsE,KAAK,WACzFnB,GAIT,IAGFoB,OAAOC,OAAOrF,EAAS,CACrBsF,WAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o from"classnames";import a,{forwardRef as n,useState as r,useRef as i,useCallback as l,useMemo as s,useEffect as c}from"react";import d from"../../hooks/useDebounceEvent/index.js";import m from"../Icon/Icon.js";import u from"../Loader/Loader.js";import p from"../Text/Text.js";import v from"../FieldLabel/FieldLabel.js";import{TextFieldFeedbackState as f,TextFieldTextType as C,FEEDBACK_CLASSES as b,SIZE_MAPPER as x,TextFieldAriaLabel as y}from"./TextFieldConstants.js";import{BASE_SIZES as E}from"../../constants/sizes.js";import T from"../../hooks/useMergeRef.js";import N from"../Clickable/Clickable.js";import{getTestId as h}from"../../tests/testIds.js";import{NOOP as g}from"../../utils/function-utils.js";import{ComponentDefaultTestId as I,ComponentVibeId as j}from"../../tests/constants.js";import{
|
|
1
|
+
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o from"classnames";import a,{forwardRef as n,useState as r,useRef as i,useCallback as l,useMemo as s,useEffect as c}from"react";import d from"../../hooks/useDebounceEvent/index.js";import m from"../Icon/Icon.js";import u from"../Loader/Loader.js";import p from"../Text/Text.js";import v from"../FieldLabel/FieldLabel.js";import{TextFieldFeedbackState as f,TextFieldTextType as C,FEEDBACK_CLASSES as b,SIZE_MAPPER as x,TextFieldAriaLabel as y}from"./TextFieldConstants.js";import{BASE_SIZES as E}from"../../constants/sizes.js";import T from"../../hooks/useMergeRef.js";import N from"../Clickable/Clickable.js";import{getTestId as h}from"../../tests/testIds.js";import{NOOP as g}from"../../utils/function-utils.js";import{ComponentDefaultTestId as I,ComponentVibeId as j}from"../../tests/constants.js";import{withStaticPropsWithoutForwardRef as F}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import L from"./TextField.module.scss.js";import k from"../Tooltip/Tooltip.js";import D from"../HiddenText/HiddenText.js";var w={primary:"",secondary:""},H=F(n((function(n,f){var C=n.className,E=void 0===C?"":C,F=n.placeholder,H=void 0===F?"":F,A=n.autoComplete,S=void 0===A?"off":A,_=n.value,q=n.onChange,R=void 0===q?g:q,W=n.onBlur,z=void 0===W?g:W,B=n.onFocus,O=void 0===B?g:B,K=n.onKeyDown,M=void 0===K?g:K,P=n.onWheel,V=void 0===P?g:P,X=n.debounceRate,U=void 0===X?0:X,Y=n.autoFocus,G=void 0!==Y&&Y,J=n.disabled,Q=void 0!==J&&J,Z=n.readonly,$=void 0!==Z&&Z,ee=n.setRef,te=void 0===ee?g:ee,oe=n.iconName,ae=n.secondaryIconName,ne=n.id,re=void 0===ne?"input":ne,ie=n.title,le=void 0===ie?"":ie,se=n.size,ce=void 0===se?"small":se,de=n.validation,me=void 0===de?null:de,ue=n.wrapperClassName,pe=void 0===ue?"":ue,ve=n.onIconClick,fe=void 0===ve?g:ve,Ce=n.clearOnIconClick,be=void 0!==Ce&&Ce,xe=n.labelIconName,ye=n.showCharCount,Ee=void 0!==ye&&ye,Te=n.inputAriaLabel,Ne=n.searchResultsContainerId,he=void 0===Ne?"":Ne,ge=n.activeDescendant,Ie=void 0===ge?"":ge,je=n.iconsNames,Fe=void 0===je?w:je,Le=n.type,ke=void 0===Le?"text":Le,De=n.maxLength,we=void 0===De?null:De,He=n.allowExceedingMaxLength,Ae=void 0!==He&&He,Se=n.trim,_e=void 0!==Se&&Se,qe=n.role,Re=void 0===qe?"":qe,We=n.required,ze=void 0!==We&&We,Be=n.requiredErrorText,Oe=void 0===Be?"":Be,Ke=n.loading,Me=void 0!==Ke&&Ke,Pe=n["data-testid"],Ve=n.secondaryDataTestId,Xe=n.tabIndex,Ue=n.underline,Ye=void 0!==Ue&&Ue,Ge=n.name,Je=n.controlled,Qe=void 0!==Je&&Je,Ze=n.iconTooltipContent,$e=n.secondaryTooltipContent,et=n.dir,tt=r(!1),ot=e(tt,2),at=ot[0],nt=ot[1],rt=i(null),it=T(f,rt,te),lt=l((function(e){ze&&!e.target.value&&nt(!0),z(e)}),[z,ze]),st=l((function(e,t){at&&e&&nt(!1),R(e,t||{target:rt.current})}),[R,at]),ct=d({delay:U,onChange:st,initialStateValue:_,trim:_e}),dt=ct.inputValue,mt=ct.onEventChanged,ut=ct.clearValue,pt=s((function(){return Qe?_:dt}),[Qe,_,dt]),vt=l((function(e){Qe?st(e.target.value,e):mt(e)}),[Qe,st,mt]),ft=s((function(){return ae&&pt?ae:oe}),[oe,ae,pt]),Ct=l((function(){Q||(be&&(rt.current&&rt.current.focus(),rt.current.value="",Qe?st(""):ut()),fe(ft))}),[Q,be,fe,ft,Qe,st,ut]),bt=s((function(){return"number"==typeof we&&pt&&pt.length>we?b.error:me&&me.status||at?b[at?"error":me.status]:""}),[we,me,at,pt]),xt=oe||ae,yt=Ee||me&&me.text||at&&Oe,Et=ae===ft,Tt=oe===ft,Nt=(fe!==g||Fe.primary||Ze)&&pt&&oe.length&&Tt,ht=(ae||$e)&&Et&&!!pt,gt=Ae?"".concat(re,"-allow-exceeding-max-length-text"):void 0;c((function(){if((null==rt?void 0:rt.current)&&G){var e=requestAnimationFrame((function(){return rt.current.focus()}));return function(){return cancelAnimationFrame(e)}}}),[rt,G]);var It=fe!==g||be,jt=Fe.primary||Ze,Ft=Fe.secondary||$e;return a.createElement("div",{className:o(L.textField,pe,t(t({},L.disabled,Q),L.onlyUnderline,Ye)),role:Re,"aria-busy":Me},a.createElement("div",{className:o(L.labelWrapper)},a.createElement(v,{labelText:le,icon:xe,labelFor:re,required:ze}),a.createElement("div",{className:o(L.inputWrapper,x[ce],bt)},a.createElement("input",{className:o(E,L.input,t(t({},L.inputHasIcon,!!xt),L.readOnly,$)),placeholder:H,autoComplete:S,value:pt,onChange:vt,disabled:Q,readOnly:$,ref:it,type:ke,id:re,"data-testid":Pe||h(I.TEXT_FIELD,re),"data-vibe":j.TEXT_FIELD,name:Ge,onBlur:lt,onFocus:O,onKeyDown:M,onWheel:V,maxLength:"number"!=typeof we||Ae?void 0:we,role:he&&"combobox","aria-label":Te||H,"aria-invalid":me&&"error"===me.status||at,"aria-owns":he,"aria-activedescendant":Ie,"aria-required":ze,"aria-describedby":gt,required:ze,tabIndex:Xe,dir:et}),Me&&a.createElement("div",{className:o(L.loaderContainer,t({},L.loaderContainerHasIcon,xt))},a.createElement("div",{className:o(L.loader)},a.createElement(u,{className:o(L.loaderSvg)}))),a.createElement(k,{content:Tt?Ze:void 0,referenceWrapperClassName:L.tooltipContainer},a.createElement(N,{className:o(L.iconContainer,t(t(t({},L.iconContainerHasIcon,xt),L.iconContainerActive,Tt),L.iconContainerClickable,It)),onClick:Ct,tabIndex:Nt?"0":"-1",ariaLabel:jt},a.createElement(m,{icon:oe,className:o(L.icon),iconType:"font",iconSize:"small"===ce?"16px":"18px"}))),a.createElement(k,{content:Et?$e:void 0,addKeyboardHideShowTriggersByDefault:!0,referenceWrapperClassName:L.tooltipContainer},a.createElement(N,{className:o(L.iconContainer,t(t(t({},L.iconContainerHasIcon,xt),L.iconContainerActive,Et),L.iconContainerClickable,It)),onClick:Ct,tabIndex:ht?"0":"-1","data-testid":Ve||h(I.TEXT_FIELD_SECONDARY_BUTTON,re),ariaLabel:Ft},a.createElement(m,{icon:ae,className:o(L.icon),iconType:"font",iconSize:"small"===ce?"16px":"18px"})))),yt&&a.createElement(p,{type:"text2",color:"secondary",className:o(L.subTextContainer)},me&&me.text&&a.createElement("span",{className:o(L.subTextContainerStatus)},at?Oe:me.text),Ee&&a.createElement("span",{className:o(L.counter),"aria-label":y.CHAR},pt&&pt.length||0,"number"==typeof we&&"/".concat(we),a.createElement(D,{id:gt,text:"Maximum of ".concat(we," characters")})))))})),{sizes:E,feedbacks:f,types:C});export{H as default};
|
|
2
2
|
//# sourceMappingURL=TextField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, {\n ChangeEvent,\n ChangeEventHandler,\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from \"react\";\nimport useDebounceEvent from \"../../hooks/useDebounceEvent\";\nimport Icon from \"../Icon/Icon\";\nimport Loader from \"../Loader/Loader\";\nimport Text from \"../Text/Text\";\nimport FieldLabel from \"../FieldLabel/FieldLabel\";\nimport {\n FEEDBACK_CLASSES,\n SIZE_MAPPER,\n TextFieldAriaLabel,\n TextFieldFeedbackState as TextFieldFeedbackStateEnum,\n TextFieldTextType as TextFieldTextTypeEnum\n} from \"./TextFieldConstants\";\nimport { TextFieldType, TextFieldSize } from \"./TextField.types\";\nimport { BASE_SIZES } from \"../../constants/sizes\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport Clickable from \"../../components/Clickable/Clickable\";\nimport { getTestId } from \"../../tests/test-ids-utils\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport { ComponentDefaultTestId, ComponentVibeId } from \"../../tests/constants\";\nimport { VibeComponentProps, withStaticProps } from \"../../types\";\nimport styles from \"./TextField.module.scss\";\nimport { Tooltip } from \"../Tooltip\";\nimport { HiddenText } from \"../HiddenText\";\n\nconst EMPTY_OBJECT = { primary: \"\", secondary: \"\" };\n\nexport interface TextFieldProps extends VibeComponentProps {\n /**\n * The placeholder text displayed when the input is empty.\n */\n placeholder?: string;\n /**\n * Configures the browser's autocomplete behavior.\n */\n autoComplete?: string;\n /**\n * The current value of the text field.\n */\n value?: string;\n /**\n * Callback fired when the text field value changes.\n */\n onChange?: (\n value: string,\n event: React.ChangeEvent<HTMLInputElement> | Pick<React.ChangeEvent<HTMLInputElement>, \"target\">\n ) => void;\n /**\n * Callback fired when the text field loses focus.\n */\n onBlur?: (event: React.FocusEvent) => void;\n /**\n * Callback fired when the text field gains focus.\n */\n onFocus?: (event: React.FocusEvent) => void;\n /**\n * Callback fired when a key is pressed inside the text field.\n */\n onKeyDown?: (event: React.KeyboardEvent) => void;\n /**\n * Callback fired when the mouse wheel is used inside the text field.\n */\n onWheel?: (event: React.WheelEvent) => void;\n /**\n * The debounce rate for input value changes.\n */\n debounceRate?: number;\n /**\n * If true, the input is automatically focused on mount.\n */\n autoFocus?: boolean;\n /**\n * If true, disables the text field.\n */\n disabled?: boolean;\n /**\n * If true, makes the text field read-only.\n */\n readonly?: boolean;\n /**\n * A function to set a reference to the input element.\n */\n setRef?: (node: HTMLElement) => void;\n /**\n * The primary icon displayed inside the text field.\n */\n iconName?: string | React.FunctionComponent | null;\n /**\n * The secondary icon displayed inside the text field.\n */\n secondaryIconName?: string | React.FunctionComponent | null;\n /**\n * The label displayed above the text field.\n */\n title?: string;\n /**\n * The size of the text field.\n */\n size?: TextFieldSize;\n /**\n * Validation state for the text field.\n */\n validation?: { status?: \"error\" | \"success\"; text?: string | React.ReactNode };\n /**\n * Class name applied to the text field wrapper.\n */\n wrapperClassName?: string;\n /**\n * Callback fired when the icon inside the text field is clicked.\n */\n onIconClick?: (icon: string | React.FunctionComponent | null) => void;\n /**\n * If true, clears the input when the icon is clicked.\n */\n clearOnIconClick?: boolean;\n /**\n * The icon displayed inside the label.\n */\n labelIconName?: string | React.FunctionComponent | null;\n /**\n * If true, displays the character count.\n */\n showCharCount?: boolean;\n /**\n * The ARIA label for the input field.\n */\n inputAriaLabel?: string;\n /**\n * The ID of the container where search results are displayed.\n */\n searchResultsContainerId?: string;\n /**\n * The ID of the currently active search result.\n */\n activeDescendant?: string;\n /**\n * Icon labels for accessibility.\n */\n iconsNames?: {\n primary: string;\n secondary: string;\n };\n /**\n * The type of the text field.\n */\n type?: TextFieldType;\n /**\n * The maximum number of characters allowed.\n */\n maxLength?: number;\n /**\n * If true, allows the user to exceed the character limit set by `maxLength`.\n */\n allowExceedingMaxLength?: boolean;\n /**\n * If true, trims whitespace from the input value.\n */\n trim?: boolean;\n /**\n * The ARIA role of the text field.\n */\n role?: string;\n /**\n * If true, marks the input as required.\n */\n required?: boolean;\n /**\n * The error message displayed when a required field is left empty.\n */\n requiredErrorText?: string;\n /**\n * If true, displays a loading indicator inside the text field.\n */\n loading?: boolean;\n /**\n * Test ID for the secondary icon.\n */\n secondaryDataTestId?: string;\n /**\n * The tab order of the input field.\n */\n tabIndex?: number;\n /**\n * The name attribute for the input field.\n */\n name?: string;\n /**\n * If true, renders only an underline style for the text field.\n */\n underline?: boolean;\n /**\n * If true, the component is controlled by an external state.\n */\n controlled?: boolean;\n /**\n * Tooltip content for the primary icon.\n */\n iconTooltipContent?: string;\n /**\n * Tooltip content for the secondary icon.\n */\n secondaryTooltipContent?: string;\n /**\n * The text direction of the input.\n */\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n}\n\nconst TextField = forwardRef(\n (\n {\n className = \"\",\n placeholder = \"\",\n autoComplete = \"off\",\n value,\n onChange = NOOP,\n onBlur = NOOP,\n onFocus = NOOP,\n onKeyDown = NOOP,\n onWheel = NOOP,\n debounceRate = 0,\n autoFocus = false,\n disabled = false,\n readonly = false,\n setRef = NOOP,\n iconName,\n secondaryIconName,\n id = \"input\",\n title = \"\",\n size = \"small\",\n validation = null,\n wrapperClassName = \"\",\n onIconClick = NOOP,\n clearOnIconClick = false,\n labelIconName,\n showCharCount = false,\n inputAriaLabel,\n searchResultsContainerId = \"\",\n activeDescendant = \"\",\n iconsNames = EMPTY_OBJECT,\n type = \"text\",\n maxLength = null,\n allowExceedingMaxLength = false,\n trim = false,\n role = \"\",\n required = false,\n requiredErrorText = \"\",\n loading = false,\n \"data-testid\": dataTestId,\n secondaryDataTestId,\n tabIndex,\n underline = false,\n name,\n controlled = false,\n iconTooltipContent,\n secondaryTooltipContent,\n dir\n }: TextFieldProps,\n ref: React.ForwardedRef<unknown>\n ) => {\n const [isRequiredAndEmpty, setIsRequiredAndEmpty] = useState(false);\n\n const inputRef = useRef(null);\n const mergedRef = useMergeRef(ref, inputRef, setRef);\n\n const onBlurCallback = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (required && !e.target.value) {\n setIsRequiredAndEmpty(true);\n }\n onBlur(e);\n },\n [onBlur, required]\n );\n\n const onChangeCallback = useCallback(\n (value: string, e?: React.ChangeEvent<HTMLInputElement>) => {\n if (isRequiredAndEmpty && value) {\n setIsRequiredAndEmpty(false);\n }\n const event = e || { target: inputRef.current };\n onChange(value, event);\n },\n [onChange, isRequiredAndEmpty]\n );\n\n const {\n inputValue: uncontrolledInput,\n onEventChanged,\n clearValue\n } = useDebounceEvent({\n delay: debounceRate,\n onChange: onChangeCallback,\n initialStateValue: value,\n trim\n });\n\n const inputValue = useMemo(() => {\n return controlled ? value : uncontrolledInput;\n }, [controlled, value, uncontrolledInput]);\n\n const handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(\n event => {\n controlled ? onChangeCallback(event.target.value, event) : onEventChanged(event);\n },\n [controlled, onChangeCallback, onEventChanged]\n );\n\n const currentStateIconName = useMemo(() => {\n if (secondaryIconName) {\n return inputValue ? secondaryIconName : iconName;\n }\n return iconName;\n }, [iconName, secondaryIconName, inputValue]);\n\n const onIconClickCallback = useCallback(() => {\n if (disabled) {\n return;\n }\n\n if (clearOnIconClick) {\n if (inputRef.current) {\n inputRef.current.focus();\n }\n // Do it cause otherwise the value is not cleared in target object\n inputRef.current.value = \"\";\n controlled ? onChangeCallback(\"\") : clearValue();\n }\n onIconClick(currentStateIconName);\n }, [disabled, clearOnIconClick, onIconClick, currentStateIconName, controlled, onChangeCallback, clearValue]);\n\n const validationClass = useMemo(() => {\n if (typeof maxLength === \"number\" && inputValue && inputValue.length > maxLength) {\n return FEEDBACK_CLASSES.error;\n }\n\n if ((!validation || !validation.status) && !isRequiredAndEmpty) {\n return \"\";\n }\n const status = isRequiredAndEmpty ? \"error\" : validation.status;\n return FEEDBACK_CLASSES[status];\n }, [maxLength, validation, isRequiredAndEmpty, inputValue]);\n\n const hasIcon = iconName || secondaryIconName;\n const shouldShowExtraText =\n showCharCount || (validation && validation.text) || (isRequiredAndEmpty && requiredErrorText);\n const isSecondary = secondaryIconName === currentStateIconName;\n const isPrimary = iconName === currentStateIconName;\n const shouldFocusOnPrimaryIcon =\n (onIconClick !== NOOP || iconsNames.primary || iconTooltipContent) && inputValue && iconName.length && isPrimary;\n const shouldFocusOnSecondaryIcon = (secondaryIconName || secondaryTooltipContent) && isSecondary && !!inputValue;\n const allowExceedingMaxLengthTextId = allowExceedingMaxLength ? `${id}-allow-exceeding-max-length-text` : undefined;\n\n useEffect(() => {\n if (!inputRef?.current || !autoFocus) {\n return;\n }\n\n const animationFrame = requestAnimationFrame(() => inputRef.current.focus());\n return () => cancelAnimationFrame(animationFrame);\n }, [inputRef, autoFocus]);\n\n const isIconContainerClickable = onIconClick !== NOOP || clearOnIconClick;\n\n const primaryIconLabel = iconsNames.primary || iconTooltipContent;\n const secondaryIconLabel = iconsNames.secondary || secondaryTooltipContent;\n\n return (\n <div\n className={cx(styles.textField, wrapperClassName, {\n [styles.disabled]: disabled,\n [styles.onlyUnderline]: underline\n })}\n role={role}\n aria-busy={loading}\n >\n <div className={cx(styles.labelWrapper)}>\n <FieldLabel labelText={title} icon={labelIconName} labelFor={id} required={required} />\n <div className={cx(styles.inputWrapper, SIZE_MAPPER[size], validationClass)}>\n {/*Programatical input (tabIndex={-1}) is working fine with aria-activedescendant attribute despite the rule*/}\n {/*eslint-disable-next-line jsx-a11y/aria-activedescendant-has-tabindex*/}\n <input\n className={cx(className, styles.input, {\n [styles.inputHasIcon]: !!hasIcon,\n [styles.readOnly]: readonly\n })}\n placeholder={placeholder}\n autoComplete={autoComplete}\n value={inputValue}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readonly}\n ref={mergedRef}\n type={type}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TEXT_FIELD, id)}\n data-vibe={ComponentVibeId.TEXT_FIELD}\n name={name}\n onBlur={onBlurCallback}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n onWheel={onWheel}\n maxLength={typeof maxLength === \"number\" && !allowExceedingMaxLength ? maxLength : undefined}\n role={searchResultsContainerId && \"combobox\"} // For voice reader\n aria-label={inputAriaLabel || placeholder}\n aria-invalid={(validation && validation.status === \"error\") || isRequiredAndEmpty}\n aria-owns={searchResultsContainerId}\n aria-activedescendant={activeDescendant}\n aria-required={required}\n aria-describedby={allowExceedingMaxLengthTextId}\n required={required}\n tabIndex={tabIndex}\n dir={dir}\n />\n {loading && (\n <div\n className={cx(styles.loaderContainer, {\n [styles.loaderContainerHasIcon]: hasIcon\n })}\n >\n <div className={cx(styles.loader)}>\n <Loader className={cx(styles.loaderSvg)} />\n </div>\n </div>\n )}\n <Tooltip\n content={isPrimary ? iconTooltipContent : undefined}\n referenceWrapperClassName={styles.tooltipContainer}\n >\n <Clickable\n className={cx(styles.iconContainer, {\n [styles.iconContainerHasIcon]: hasIcon,\n [styles.iconContainerActive]: isPrimary,\n [styles.iconContainerClickable]: isIconContainerClickable\n })}\n onClick={onIconClickCallback}\n tabIndex={shouldFocusOnPrimaryIcon ? \"0\" : \"-1\"}\n ariaLabel={primaryIconLabel}\n >\n <Icon\n icon={iconName}\n className={cx(styles.icon)}\n iconType=\"font\"\n iconSize={size === \"small\" ? \"16px\" : \"18px\"}\n />\n </Clickable>\n </Tooltip>\n <Tooltip\n content={isSecondary ? secondaryTooltipContent : undefined}\n addKeyboardHideShowTriggersByDefault\n referenceWrapperClassName={styles.tooltipContainer}\n >\n <Clickable\n className={cx(styles.iconContainer, {\n [styles.iconContainerHasIcon]: hasIcon,\n [styles.iconContainerActive]: isSecondary,\n [styles.iconContainerClickable]: isIconContainerClickable\n })}\n onClick={onIconClickCallback}\n tabIndex={shouldFocusOnSecondaryIcon ? \"0\" : \"-1\"}\n data-testid={secondaryDataTestId || getTestId(ComponentDefaultTestId.TEXT_FIELD_SECONDARY_BUTTON, id)}\n ariaLabel={secondaryIconLabel}\n >\n <Icon\n icon={secondaryIconName}\n className={cx(styles.icon)}\n iconType=\"font\"\n iconSize={size === \"small\" ? \"16px\" : \"18px\"}\n />\n </Clickable>\n </Tooltip>\n </div>\n {shouldShowExtraText && (\n <Text type=\"text2\" color=\"secondary\" className={cx(styles.subTextContainer)}>\n {validation && validation.text && (\n <span className={cx(styles.subTextContainerStatus)}>\n {isRequiredAndEmpty ? requiredErrorText : validation.text}\n </span>\n )}\n {showCharCount && (\n <span className={cx(styles.counter)} aria-label={TextFieldAriaLabel.CHAR}>\n {(inputValue && inputValue.length) || 0}\n {typeof maxLength === \"number\" && `/${maxLength}`}\n <HiddenText id={allowExceedingMaxLengthTextId} text={`Maximum of ${maxLength} characters`} />\n </span>\n )}\n </Text>\n )}\n </div>\n </div>\n );\n }\n);\n\ninterface TextFieldStaticProps {\n sizes: typeof BASE_SIZES;\n types: typeof TextFieldTextTypeEnum;\n feedbacks: typeof TextFieldFeedbackStateEnum;\n}\n\nexport default withStaticProps<TextFieldProps, TextFieldStaticProps>(TextField, {\n sizes: BASE_SIZES,\n feedbacks: TextFieldFeedbackStateEnum,\n types: TextFieldTextTypeEnum\n});\n"],"names":["EMPTY_OBJECT","primary","secondary","withStaticProps","forwardRef","_ref","ref","_ref$className","className","_ref$placeholder","placeholder","_ref$autoComplete","autoComplete","value","_ref$onChange","onChange","NOOP","_ref$onBlur","onBlur","_ref$onFocus","onFocus","_ref$onKeyDown","onKeyDown","_ref$onWheel","onWheel","_ref$debounceRate","debounceRate","_ref$autoFocus","autoFocus","_ref$disabled","disabled","_ref$readonly","readonly","_ref$setRef","setRef","iconName","secondaryIconName","_ref$id","id","_ref$title","title","_ref$size","size","_ref$validation","validation","_ref$wrapperClassName","wrapperClassName","_ref$onIconClick","onIconClick","_ref$clearOnIconClick","clearOnIconClick","labelIconName","_ref$showCharCount","showCharCount","inputAriaLabel","_ref$searchResultsCon","searchResultsContainerId","_ref$activeDescendant","activeDescendant","_ref$iconsNames","iconsNames","_ref$type","type","_ref$maxLength","maxLength","_ref$allowExceedingMa","allowExceedingMaxLength","_ref$trim","trim","_ref$role","role","_ref$required","required","_ref$requiredErrorTex","requiredErrorText","_ref$loading","loading","dataTestId","secondaryDataTestId","tabIndex","_ref$underline","underline","name","_ref$controlled","controlled","iconTooltipContent","secondaryTooltipContent","dir","_useState","useState","_useState2","_slicedToArray","isRequiredAndEmpty","setIsRequiredAndEmpty","inputRef","useRef","mergedRef","useMergeRef","onBlurCallback","useCallback","e","target","onChangeCallback","current","_useDebounceEvent","useDebounceEvent","delay","initialStateValue","uncontrolledInput","inputValue","onEventChanged","clearValue","useMemo","handleChange","event","currentStateIconName","onIconClickCallback","focus","validationClass","length","FEEDBACK_CLASSES","error","status","hasIcon","shouldShowExtraText","text","isSecondary","isPrimary","shouldFocusOnPrimaryIcon","shouldFocusOnSecondaryIcon","allowExceedingMaxLengthTextId","concat","undefined","useEffect","animationFrame","requestAnimationFrame","cancelAnimationFrame","isIconContainerClickable","primaryIconLabel","secondaryIconLabel","React","createElement","cx","styles","textField","_defineProperty","onlyUnderline","labelWrapper","FieldLabel","labelText","icon","labelFor","inputWrapper","SIZE_MAPPER","input","inputHasIcon","readOnly","getTestId","ComponentDefaultTestId","TEXT_FIELD","ComponentVibeId","loaderContainer","loaderContainerHasIcon","loader","Loader","loaderSvg","Tooltip","content","referenceWrapperClassName","tooltipContainer","Clickable","iconContainer","iconContainerHasIcon","iconContainerActive","iconContainerClickable","onClick","ariaLabel","Icon","iconType","iconSize","addKeyboardHideShowTriggersByDefault","TEXT_FIELD_SECONDARY_BUTTON","Text","color","subTextContainer","subTextContainerStatus","counter","TextFieldAriaLabel","CHAR","HiddenText","sizes","BASE_SIZES","feedbacks","TextFieldFeedbackStateEnum","types","TextFieldTextTypeEnum"],"mappings":"4mCAmCA,IAAMA,EAAe,CAAEC,QAAS,GAAIC,UAAW,IA2dhCC,EAAAA,EApSGC,GAChB,SAAAC,EAiDEC,GACE,IAAAC,EAAAF,EAhDAG,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EAAAE,EAAAJ,EACdK,YAAAA,OAAc,IAAHD,EAAG,GAAEA,EAAAE,EAAAN,EAChBO,aAAAA,OAAe,IAAHD,EAAG,MAAKA,EACpBE,EAAKR,EAALQ,MAAKC,EAAAT,EACLU,SAAAA,OAAWC,IAAHF,EAAGE,EAAIF,EAAAG,EAAAZ,EACfa,OAAAA,OAASF,IAAHC,EAAGD,EAAIC,EAAAE,EAAAd,EACbe,QAAAA,OAAUJ,IAAHG,EAAGH,EAAIG,EAAAE,EAAAhB,EACdiB,UAAAA,OAAYN,IAAHK,EAAGL,EAAIK,EAAAE,EAAAlB,EAChBmB,QAAAA,OAAUR,IAAHO,EAAGP,EAAIO,EAAAE,EAAApB,EACdqB,aAAAA,OAAe,IAAHD,EAAG,EAACA,EAAAE,EAAAtB,EAChBuB,UAAAA,OAAY,IAAHD,GAAQA,EAAAE,EAAAxB,EACjByB,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAA1B,EAChB2B,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,GAAA5B,EAChB6B,OAAAA,QAASlB,IAAHiB,GAAGjB,EAAIiB,GACbE,GAAQ9B,EAAR8B,SACAC,GAAiB/B,EAAjB+B,kBAAiBC,GAAAhC,EACjBiC,G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AEXE,EAAAC,cAACoC,EAAI,CACH3B,KAAMnH,GACN3B,UAAWsI,EAAGC,EAAOO,MACrB4B,SAAS,OACTC,SAAmB,UAATzI,GAAmB,OAAS,WAI5CkG,EAACC,cAAAyB,GACCC,QAASzC,GAAcxC,QAA0B8C,EACjDgD,sCAAoC,EACpCZ,0BAA2BzB,EAAO0B,kBAElC7B,EAACC,cAAA6B,GACClK,UAAWsI,EAAGC,EAAO4B,cAAa1B,EAAAA,EAAAA,KAC/BF,EAAO6B,qBAAuBjD,IAC9BoB,EAAO8B,oBAAsB/C,IAC7BiB,EAAO+B,uBAAyBrC,KAEnCsC,QAAS3D,GACTrC,SAAUkD,GAA6B,IAAM,KAAI,cACpCnD,IAAuB+E,EAAUC,EAAuBuB,4BAA6B/I,IAClG0I,UAAWrC,IAEXC,EAAAC,cAACoC,EAAI,CACH3B,KAAMlH,GACN5B,UAAWsI,EAAGC,EAAOO,MACrB4B,SAAS,OACTC,SAAmB,UAATzI,GAAmB,OAAS,YAK7CkF,IACCgB,EAACC,cAAAyC,GAAKxH,KAAK,QAAQyH,MAAM,YAAY/K,UAAWsI,EAAGC,EAAOyC,mBACvD5I,IAAcA,GAAWiF,MACxBe,EAAMC,cAAA,OAAA,CAAArI,UAAWsI,EAAGC,EAAO0C,yBACxB7F,GAAqBlB,GAAoB9B,GAAWiF,MAGxDxE,IACCuF,EAAMC,cAAA,OAAA,CAAArI,UAAWsI,EAAGC,EAAO2C,SAAsB,aAAAC,EAAmBC,MAChE/E,IAAcA,GAAWU,QAAW,EAChB,iBAAdvD,IAAsBmE,IAAAA,OAAQnE,IACtC4E,EAAAC,cAACgD,EAAW,CAAAvJ,GAAI4F,GAA+BL,KAAI,cAAAM,OAAgBnE,GAAS,oBAQ5F,IAS8E,CAC9E8H,MAAOC,EACPC,UAAWC,EACXC,MAAOC"}
|
|
1
|
+
{"version":3,"file":"TextField.js","sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, {\n ChangeEvent,\n ChangeEventHandler,\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from \"react\";\nimport useDebounceEvent from \"../../hooks/useDebounceEvent\";\nimport Icon from \"../Icon/Icon\";\nimport Loader from \"../Loader/Loader\";\nimport Text from \"../Text/Text\";\nimport FieldLabel from \"../FieldLabel/FieldLabel\";\nimport {\n FEEDBACK_CLASSES,\n SIZE_MAPPER,\n TextFieldAriaLabel,\n TextFieldFeedbackState as TextFieldFeedbackStateEnum,\n TextFieldTextType as TextFieldTextTypeEnum\n} from \"./TextFieldConstants\";\nimport { TextFieldType, TextFieldSize } from \"./TextField.types\";\nimport { BASE_SIZES } from \"../../constants/sizes\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport Clickable from \"../../components/Clickable/Clickable\";\nimport { getTestId } from \"../../tests/test-ids-utils\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport { ComponentDefaultTestId, ComponentVibeId } from \"../../tests/constants\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./TextField.module.scss\";\nimport { Tooltip } from \"../Tooltip\";\nimport { HiddenText } from \"../HiddenText\";\n\nconst EMPTY_OBJECT = { primary: \"\", secondary: \"\" };\n\nexport interface TextFieldProps extends VibeComponentProps {\n /**\n * The placeholder text displayed when the input is empty.\n */\n placeholder?: string;\n /**\n * Configures the browser's autocomplete behavior.\n */\n autoComplete?: string;\n /**\n * The current value of the text field.\n */\n value?: string;\n /**\n * Callback fired when the text field value changes.\n */\n onChange?: (\n value: string,\n event: React.ChangeEvent<HTMLInputElement> | Pick<React.ChangeEvent<HTMLInputElement>, \"target\">\n ) => void;\n /**\n * Callback fired when the text field loses focus.\n */\n onBlur?: (event: React.FocusEvent) => void;\n /**\n * Callback fired when the text field gains focus.\n */\n onFocus?: (event: React.FocusEvent) => void;\n /**\n * Callback fired when a key is pressed inside the text field.\n */\n onKeyDown?: (event: React.KeyboardEvent) => void;\n /**\n * Callback fired when the mouse wheel is used inside the text field.\n */\n onWheel?: (event: React.WheelEvent) => void;\n /**\n * The debounce rate for input value changes.\n */\n debounceRate?: number;\n /**\n * If true, the input is automatically focused on mount.\n */\n autoFocus?: boolean;\n /**\n * If true, disables the text field.\n */\n disabled?: boolean;\n /**\n * If true, makes the text field read-only.\n */\n readonly?: boolean;\n /**\n * A function to set a reference to the input element.\n */\n setRef?: (node: HTMLElement) => void;\n /**\n * The primary icon displayed inside the text field.\n */\n iconName?: string | React.FunctionComponent | null;\n /**\n * The secondary icon displayed inside the text field.\n */\n secondaryIconName?: string | React.FunctionComponent | null;\n /**\n * The label displayed above the text field.\n */\n title?: string;\n /**\n * The size of the text field.\n */\n size?: TextFieldSize;\n /**\n * Validation state for the text field.\n */\n validation?: { status?: \"error\" | \"success\"; text?: string | React.ReactNode };\n /**\n * Class name applied to the text field wrapper.\n */\n wrapperClassName?: string;\n /**\n * Callback fired when the icon inside the text field is clicked.\n */\n onIconClick?: (icon: string | React.FunctionComponent | null) => void;\n /**\n * If true, clears the input when the icon is clicked.\n */\n clearOnIconClick?: boolean;\n /**\n * The icon displayed inside the label.\n */\n labelIconName?: string | React.FunctionComponent | null;\n /**\n * If true, displays the character count.\n */\n showCharCount?: boolean;\n /**\n * The ARIA label for the input field.\n */\n inputAriaLabel?: string;\n /**\n * The ID of the container where search results are displayed.\n */\n searchResultsContainerId?: string;\n /**\n * The ID of the currently active search result.\n */\n activeDescendant?: string;\n /**\n * Icon labels for accessibility.\n */\n iconsNames?: {\n primary: string;\n secondary: string;\n };\n /**\n * The type of the text field.\n */\n type?: TextFieldType;\n /**\n * The maximum number of characters allowed.\n */\n maxLength?: number;\n /**\n * If true, allows the user to exceed the character limit set by `maxLength`.\n */\n allowExceedingMaxLength?: boolean;\n /**\n * If true, trims whitespace from the input value.\n */\n trim?: boolean;\n /**\n * The ARIA role of the text field.\n */\n role?: string;\n /**\n * If true, marks the input as required.\n */\n required?: boolean;\n /**\n * The error message displayed when a required field is left empty.\n */\n requiredErrorText?: string;\n /**\n * If true, displays a loading indicator inside the text field.\n */\n loading?: boolean;\n /**\n * Test ID for the secondary icon.\n */\n secondaryDataTestId?: string;\n /**\n * The tab order of the input field.\n */\n tabIndex?: number;\n /**\n * The name attribute for the input field.\n */\n name?: string;\n /**\n * If true, renders only an underline style for the text field.\n */\n underline?: boolean;\n /**\n * If true, the component is controlled by an external state.\n */\n controlled?: boolean;\n /**\n * Tooltip content for the primary icon.\n */\n iconTooltipContent?: string;\n /**\n * Tooltip content for the secondary icon.\n */\n secondaryTooltipContent?: string;\n /**\n * The text direction of the input.\n */\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n}\n\nconst TextField = forwardRef(\n (\n {\n className = \"\",\n placeholder = \"\",\n autoComplete = \"off\",\n value,\n onChange = NOOP,\n onBlur = NOOP,\n onFocus = NOOP,\n onKeyDown = NOOP,\n onWheel = NOOP,\n debounceRate = 0,\n autoFocus = false,\n disabled = false,\n readonly = false,\n setRef = NOOP,\n iconName,\n secondaryIconName,\n id = \"input\",\n title = \"\",\n size = \"small\",\n validation = null,\n wrapperClassName = \"\",\n onIconClick = NOOP,\n clearOnIconClick = false,\n labelIconName,\n showCharCount = false,\n inputAriaLabel,\n searchResultsContainerId = \"\",\n activeDescendant = \"\",\n iconsNames = EMPTY_OBJECT,\n type = \"text\",\n maxLength = null,\n allowExceedingMaxLength = false,\n trim = false,\n role = \"\",\n required = false,\n requiredErrorText = \"\",\n loading = false,\n \"data-testid\": dataTestId,\n secondaryDataTestId,\n tabIndex,\n underline = false,\n name,\n controlled = false,\n iconTooltipContent,\n secondaryTooltipContent,\n dir\n }: TextFieldProps,\n ref: React.ForwardedRef<unknown>\n ) => {\n const [isRequiredAndEmpty, setIsRequiredAndEmpty] = useState(false);\n\n const inputRef = useRef(null);\n const mergedRef = useMergeRef(ref, inputRef, setRef);\n\n const onBlurCallback = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (required && !e.target.value) {\n setIsRequiredAndEmpty(true);\n }\n onBlur(e);\n },\n [onBlur, required]\n );\n\n const onChangeCallback = useCallback(\n (value: string, e?: React.ChangeEvent<HTMLInputElement>) => {\n if (isRequiredAndEmpty && value) {\n setIsRequiredAndEmpty(false);\n }\n const event = e || { target: inputRef.current };\n onChange(value, event);\n },\n [onChange, isRequiredAndEmpty]\n );\n\n const {\n inputValue: uncontrolledInput,\n onEventChanged,\n clearValue\n } = useDebounceEvent({\n delay: debounceRate,\n onChange: onChangeCallback,\n initialStateValue: value,\n trim\n });\n\n const inputValue = useMemo(() => {\n return controlled ? value : uncontrolledInput;\n }, [controlled, value, uncontrolledInput]);\n\n const handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(\n event => {\n controlled ? onChangeCallback(event.target.value, event) : onEventChanged(event);\n },\n [controlled, onChangeCallback, onEventChanged]\n );\n\n const currentStateIconName = useMemo(() => {\n if (secondaryIconName) {\n return inputValue ? secondaryIconName : iconName;\n }\n return iconName;\n }, [iconName, secondaryIconName, inputValue]);\n\n const onIconClickCallback = useCallback(() => {\n if (disabled) {\n return;\n }\n\n if (clearOnIconClick) {\n if (inputRef.current) {\n inputRef.current.focus();\n }\n // Do it cause otherwise the value is not cleared in target object\n inputRef.current.value = \"\";\n controlled ? onChangeCallback(\"\") : clearValue();\n }\n onIconClick(currentStateIconName);\n }, [disabled, clearOnIconClick, onIconClick, currentStateIconName, controlled, onChangeCallback, clearValue]);\n\n const validationClass = useMemo(() => {\n if (typeof maxLength === \"number\" && inputValue && inputValue.length > maxLength) {\n return FEEDBACK_CLASSES.error;\n }\n\n if ((!validation || !validation.status) && !isRequiredAndEmpty) {\n return \"\";\n }\n const status = isRequiredAndEmpty ? \"error\" : validation.status;\n return FEEDBACK_CLASSES[status];\n }, [maxLength, validation, isRequiredAndEmpty, inputValue]);\n\n const hasIcon = iconName || secondaryIconName;\n const shouldShowExtraText =\n showCharCount || (validation && validation.text) || (isRequiredAndEmpty && requiredErrorText);\n const isSecondary = secondaryIconName === currentStateIconName;\n const isPrimary = iconName === currentStateIconName;\n const shouldFocusOnPrimaryIcon =\n (onIconClick !== NOOP || iconsNames.primary || iconTooltipContent) && inputValue && iconName.length && isPrimary;\n const shouldFocusOnSecondaryIcon = (secondaryIconName || secondaryTooltipContent) && isSecondary && !!inputValue;\n const allowExceedingMaxLengthTextId = allowExceedingMaxLength ? `${id}-allow-exceeding-max-length-text` : undefined;\n\n useEffect(() => {\n if (!inputRef?.current || !autoFocus) {\n return;\n }\n\n const animationFrame = requestAnimationFrame(() => inputRef.current.focus());\n return () => cancelAnimationFrame(animationFrame);\n }, [inputRef, autoFocus]);\n\n const isIconContainerClickable = onIconClick !== NOOP || clearOnIconClick;\n\n const primaryIconLabel = iconsNames.primary || iconTooltipContent;\n const secondaryIconLabel = iconsNames.secondary || secondaryTooltipContent;\n\n return (\n <div\n className={cx(styles.textField, wrapperClassName, {\n [styles.disabled]: disabled,\n [styles.onlyUnderline]: underline\n })}\n role={role}\n aria-busy={loading}\n >\n <div className={cx(styles.labelWrapper)}>\n <FieldLabel labelText={title} icon={labelIconName} labelFor={id} required={required} />\n <div className={cx(styles.inputWrapper, SIZE_MAPPER[size], validationClass)}>\n {/*Programatical input (tabIndex={-1}) is working fine with aria-activedescendant attribute despite the rule*/}\n {/*eslint-disable-next-line jsx-a11y/aria-activedescendant-has-tabindex*/}\n <input\n className={cx(className, styles.input, {\n [styles.inputHasIcon]: !!hasIcon,\n [styles.readOnly]: readonly\n })}\n placeholder={placeholder}\n autoComplete={autoComplete}\n value={inputValue}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readonly}\n ref={mergedRef}\n type={type}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TEXT_FIELD, id)}\n data-vibe={ComponentVibeId.TEXT_FIELD}\n name={name}\n onBlur={onBlurCallback}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n onWheel={onWheel}\n maxLength={typeof maxLength === \"number\" && !allowExceedingMaxLength ? maxLength : undefined}\n role={searchResultsContainerId && \"combobox\"} // For voice reader\n aria-label={inputAriaLabel || placeholder}\n aria-invalid={(validation && validation.status === \"error\") || isRequiredAndEmpty}\n aria-owns={searchResultsContainerId}\n aria-activedescendant={activeDescendant}\n aria-required={required}\n aria-describedby={allowExceedingMaxLengthTextId}\n required={required}\n tabIndex={tabIndex}\n dir={dir}\n />\n {loading && (\n <div\n className={cx(styles.loaderContainer, {\n [styles.loaderContainerHasIcon]: hasIcon\n })}\n >\n <div className={cx(styles.loader)}>\n <Loader className={cx(styles.loaderSvg)} />\n </div>\n </div>\n )}\n <Tooltip\n content={isPrimary ? iconTooltipContent : undefined}\n referenceWrapperClassName={styles.tooltipContainer}\n >\n <Clickable\n className={cx(styles.iconContainer, {\n [styles.iconContainerHasIcon]: hasIcon,\n [styles.iconContainerActive]: isPrimary,\n [styles.iconContainerClickable]: isIconContainerClickable\n })}\n onClick={onIconClickCallback}\n tabIndex={shouldFocusOnPrimaryIcon ? \"0\" : \"-1\"}\n ariaLabel={primaryIconLabel}\n >\n <Icon\n icon={iconName}\n className={cx(styles.icon)}\n iconType=\"font\"\n iconSize={size === \"small\" ? \"16px\" : \"18px\"}\n />\n </Clickable>\n </Tooltip>\n <Tooltip\n content={isSecondary ? secondaryTooltipContent : undefined}\n addKeyboardHideShowTriggersByDefault\n referenceWrapperClassName={styles.tooltipContainer}\n >\n <Clickable\n className={cx(styles.iconContainer, {\n [styles.iconContainerHasIcon]: hasIcon,\n [styles.iconContainerActive]: isSecondary,\n [styles.iconContainerClickable]: isIconContainerClickable\n })}\n onClick={onIconClickCallback}\n tabIndex={shouldFocusOnSecondaryIcon ? \"0\" : \"-1\"}\n data-testid={secondaryDataTestId || getTestId(ComponentDefaultTestId.TEXT_FIELD_SECONDARY_BUTTON, id)}\n ariaLabel={secondaryIconLabel}\n >\n <Icon\n icon={secondaryIconName}\n className={cx(styles.icon)}\n iconType=\"font\"\n iconSize={size === \"small\" ? \"16px\" : \"18px\"}\n />\n </Clickable>\n </Tooltip>\n </div>\n {shouldShowExtraText && (\n <Text type=\"text2\" color=\"secondary\" className={cx(styles.subTextContainer)}>\n {validation && validation.text && (\n <span className={cx(styles.subTextContainerStatus)}>\n {isRequiredAndEmpty ? requiredErrorText : validation.text}\n </span>\n )}\n {showCharCount && (\n <span className={cx(styles.counter)} aria-label={TextFieldAriaLabel.CHAR}>\n {(inputValue && inputValue.length) || 0}\n {typeof maxLength === \"number\" && `/${maxLength}`}\n <HiddenText id={allowExceedingMaxLengthTextId} text={`Maximum of ${maxLength} characters`} />\n </span>\n )}\n </Text>\n )}\n </div>\n </div>\n );\n }\n);\n\ninterface TextFieldStaticProps {\n sizes: typeof BASE_SIZES;\n types: typeof TextFieldTextTypeEnum;\n feedbacks: typeof TextFieldFeedbackStateEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<TextFieldProps, TextFieldStaticProps>(TextField, {\n sizes: BASE_SIZES,\n feedbacks: TextFieldFeedbackStateEnum,\n types: TextFieldTextTypeEnum\n});\n"],"names":["EMPTY_OBJECT","primary","secondary","withStaticPropsWithoutForwardRef","forwardRef","_ref","ref","_ref$className","className","_ref$placeholder","placeholder","_ref$autoComplete","autoComplete","value","_ref$onChange","onChange","NOOP","_ref$onBlur","onBlur","_ref$onFocus","onFocus","_ref$onKeyDown","onKeyDown","_ref$onWheel","onWheel","_ref$debounceRate","debounceRate","_ref$autoFocus","autoFocus","_ref$disabled","disabled","_ref$readonly","readonly","_ref$setRef","setRef","iconName","secondaryIconName","_ref$id","id","_ref$title","title","_ref$size","size","_ref$validation","validation","_ref$wrapperClassName","wrapperClassName","_ref$onIconClick","onIconClick","_ref$clearOnIconClick","clearOnIconClick","labelIconName","_ref$showCharCount","showCharCount","inputAriaLabel","_ref$searchResultsCon","searchResultsContainerId","_ref$activeDescendant","activeDescendant","_ref$iconsNames","iconsNames","_ref$type","type","_ref$maxLength","maxLength","_ref$allowExceedingMa","allowExceedingMaxLength","_ref$trim","trim","_ref$role","role","_ref$required","required","_ref$requiredErrorTex","requiredErrorText","_ref$loading","loading","dataTestId","secondaryDataTestId","tabIndex","_ref$underline","underline","name","_ref$controlled","controlled","iconTooltipContent","secondaryTooltipContent","dir","_useState","useState","_useState2","_slicedToArray","isRequiredAndEmpty","setIsRequiredAndEmpty","inputRef","useRef","mergedRef","useMergeRef","onBlurCallback","useCallback","e","target","onChangeCallback","current","_useDebounceEvent","useDebounceEvent","delay","initialStateValue","uncontrolledInput","inputValue","onEventChanged","clearValue","useMemo","handleChange","event","currentStateIconName","onIconClickCallback","focus","validationClass","length","FEEDBACK_CLASSES","error","status","hasIcon","shouldShowExtraText","text","isSecondary","isPrimary","shouldFocusOnPrimaryIcon","shouldFocusOnSecondaryIcon","allowExceedingMaxLengthTextId","concat","undefined","useEffect","animationFrame","requestAnimationFrame","cancelAnimationFrame","isIconContainerClickable","primaryIconLabel","secondaryIconLabel","React","createElement","cx","styles","textField","_defineProperty","onlyUnderline","labelWrapper","FieldLabel","labelText","icon","labelFor","inputWrapper","SIZE_MAPPER","input","inputHasIcon","readOnly","getTestId","ComponentDefaultTestId","TEXT_FIELD","ComponentVibeId","loaderContainer","loaderContainerHasIcon","loader","Loader","loaderSvg","Tooltip","content","referenceWrapperClassName","tooltipContainer","Clickable","iconContainer","iconContainerHasIcon","iconContainerActive","iconContainerClickable","onClick","ariaLabel","Icon","iconType","iconSize","addKeyboardHideShowTriggersByDefault","TEXT_FIELD_SECONDARY_BUTTON","Text","color","subTextContainer","subTextContainerStatus","counter","TextFieldAriaLabel","CHAR","HiddenText","sizes","BASE_SIZES","feedbacks","TextFieldFeedbackStateEnum","types","TextFieldTextTypeEnum"],"mappings":"6nCAmCA,IAAMA,EAAe,CAAEC,QAAS,GAAIC,UAAW,IA2dhCC,EAAAA,EApSGC,GAChB,SAAAC,EAiDEC,GACE,IAAAC,EAAAF,EAhDAG,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EAAAE,EAAAJ,EACdK,YAAAA,OAAc,IAAHD,EAAG,GAAEA,EAAAE,EAAAN,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B,KAAMlH,GACN5B,UAAWsI,EAAGC,EAAOO,MACrB4B,SAAS,OACTC,SAAmB,UAATzI,GAAmB,OAAS,YAK7CkF,IACCgB,EAACC,cAAAyC,GAAKxH,KAAK,QAAQyH,MAAM,YAAY/K,UAAWsI,EAAGC,EAAOyC,mBACvD5I,IAAcA,GAAWiF,MACxBe,EAAMC,cAAA,OAAA,CAAArI,UAAWsI,EAAGC,EAAO0C,yBACxB7F,GAAqBlB,GAAoB9B,GAAWiF,MAGxDxE,IACCuF,EAAMC,cAAA,OAAA,CAAArI,UAAWsI,EAAGC,EAAO2C,SAAsB,aAAAC,EAAmBC,MAChE/E,IAAcA,GAAWU,QAAW,EAChB,iBAAdvD,IAAsBmE,IAAAA,OAAQnE,IACtC4E,EAAAC,cAACgD,EAAW,CAAAvJ,GAAI4F,GAA+BL,KAAI,cAAAM,OAAgBnE,GAAS,oBAQ5F,IAS+F,CAC/F8H,MAAOC,EACPC,UAAWC,EACXC,MAAOC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r from"classnames";import t,{useState as o,useMemo as s,useEffect as m}from"react";import{SystemTheme as i,ThemeColor as n}from"./ThemeProviderConstants.js";import{generateRandomAlphaString as a,isAnySystemThemeClassNameOnBody as c,addSystemThemeClassNameToBody as l,removeSystemThemeClassNameFromBody as d,shouldGenerateTheme as u,generateThemeCssOverride as f}from"./ThemeProviderUtils.js";import p from"../../hooks/ssr/useIsomorphicLayoutEffect.js";import{
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r from"classnames";import t,{useState as o,useMemo as s,useEffect as m}from"react";import{SystemTheme as i,ThemeColor as n}from"./ThemeProviderConstants.js";import{generateRandomAlphaString as a,isAnySystemThemeClassNameOnBody as c,addSystemThemeClassNameToBody as l,removeSystemThemeClassNameFromBody as d,shouldGenerateTheme as u,generateThemeCssOverride as f}from"./ThemeProviderUtils.js";import p from"../../hooks/ssr/useIsomorphicLayoutEffect.js";import{withStaticPropsWithoutForwardRef as h}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";var v=h((function(i){var n=i.themeConfig,h=i.children,v=i.themeClassSpecifier,y=i.systemTheme,T=i.className,j=o(!1),C=e(j,2),g=C[0],P=C[1],E=s((function(){return v||a()}),[v]);return p((function(){if(y&&!c())return l(y),function(){d(y)}}),[y]),m((function(){if(u(n)){if(!document.getElementById(n.name)){var e=document.createElement("style");e.type="text/css",e.id=n.name;var r=f(n,E);try{e.appendChild(document.createTextNode(r)),document.head.appendChild(e),P(!0)}catch(e){console.error("vibe ThemeProvider: error inserting theme-generated css - ",e)}return function(){document.head.removeChild(e)}}P(!0)}}),[E,n]),!g&&u(n)?null:t.createElement("div",{className:r(null==n?void 0:n.name,E,T)},h)}),{systemThemes:i,colors:n});export{v as default};
|
|
2
2
|
//# sourceMappingURL=ThemeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../../../src/components/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { ReactElement, useEffect, useMemo, useState } from \"react\";\nimport { SystemTheme as SystemThemeEnum, Theme, ThemeColor as ThemeColorEnum } from \"./ThemeProviderConstants\";\nimport { SystemTheme } from \"./ThemeProvider.types\";\nimport {\n addSystemThemeClassNameToBody,\n generateRandomAlphaString,\n generateThemeCssOverride,\n isAnySystemThemeClassNameOnBody,\n removeSystemThemeClassNameFromBody,\n shouldGenerateTheme\n} from \"./ThemeProviderUtils\";\nimport useIsomorphicLayoutEffect from \"../../hooks/ssr/useIsomorphicLayoutEffect\";\nimport {
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../../../src/components/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { ReactElement, useEffect, useMemo, useState } from \"react\";\nimport { SystemTheme as SystemThemeEnum, Theme, ThemeColor as ThemeColorEnum } from \"./ThemeProviderConstants\";\nimport { SystemTheme } from \"./ThemeProvider.types\";\nimport {\n addSystemThemeClassNameToBody,\n generateRandomAlphaString,\n generateThemeCssOverride,\n isAnySystemThemeClassNameOnBody,\n removeSystemThemeClassNameFromBody,\n shouldGenerateTheme\n} from \"./ThemeProviderUtils\";\nimport useIsomorphicLayoutEffect from \"../../hooks/ssr/useIsomorphicLayoutEffect\";\nimport { withStaticPropsWithoutForwardRef } from \"../../types\";\n\nexport interface ThemeProviderProps {\n /**\n * The theme configuration to apply. It consists of a `name` (a unique CSS class name added to the children)\n * and an object of color overrides for each system theme.\n */\n themeConfig?: Theme;\n /**\n * The children to be rendered with the applied theme.\n */\n children: ReactElement;\n /**\n * A string added to the theme name selector to make it more specific, in case `themeConfig.name`\n * collides with another class name.\n */\n themeClassSpecifier?: string;\n /**\n * The system theme to apply to the `body` element on mount,\n * if there is no system theme class name on the body already.\n */\n systemTheme?: SystemTheme;\n /**\n * Class name applied to the wrapping `div`.\n */\n className?: string;\n}\n\nconst ThemeProvider = ({\n themeConfig,\n children,\n themeClassSpecifier: customThemeClassSpecifier,\n systemTheme,\n className\n}: ThemeProviderProps) => {\n const [stylesLoaded, setStylesLoaded] = useState(false);\n const themeClassSpecifier = useMemo(\n () => customThemeClassSpecifier || generateRandomAlphaString(),\n [customThemeClassSpecifier]\n );\n\n // Add the systemTheme class name to the body on mount\n useIsomorphicLayoutEffect(() => {\n if (!systemTheme) {\n return;\n }\n\n if (isAnySystemThemeClassNameOnBody()) {\n // If there is already a systemTheme class name on the body, we don't want to override it\n return;\n }\n\n addSystemThemeClassNameToBody(systemTheme);\n\n return () => {\n // Cleanup the systemTheme class name from the body on ThemeProvider unmount\n removeSystemThemeClassNameFromBody(systemTheme);\n };\n }, [systemTheme]);\n\n useEffect(() => {\n if (!shouldGenerateTheme(themeConfig)) {\n return;\n }\n if (document.getElementById(themeConfig.name)) {\n setStylesLoaded(true);\n return;\n }\n\n const styleElement = document.createElement(\"style\");\n styleElement.type = \"text/css\";\n styleElement.id = themeConfig.name;\n const themeCssOverride = generateThemeCssOverride(themeConfig, themeClassSpecifier);\n\n try {\n styleElement.appendChild(document.createTextNode(themeCssOverride));\n document.head.appendChild(styleElement);\n setStylesLoaded(true);\n } catch (error) {\n console.error(\"vibe ThemeProvider: error inserting theme-generated css - \", error);\n }\n\n return () => {\n document.head.removeChild(styleElement);\n };\n }, [themeClassSpecifier, themeConfig]);\n\n if (!stylesLoaded && shouldGenerateTheme(themeConfig)) {\n // Waiting for styles to load before children render\n return null;\n }\n\n // Pass the theme name as a class to the div wrapping children - to scope the effect of the theme\n return <div className={cx(themeConfig?.name, themeClassSpecifier, className)}>{children}</div>;\n};\n\ninterface ThemeProviderStaticProps {\n systemThemes: typeof SystemThemeEnum;\n colors: typeof ThemeColorEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<ThemeProviderProps, ThemeProviderStaticProps>(ThemeProvider, {\n systemThemes: SystemThemeEnum,\n colors: ThemeColorEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","themeConfig","children","customThemeClassSpecifier","themeClassSpecifier","systemTheme","className","_useState","useState","_useState2","_slicedToArray","stylesLoaded","setStylesLoaded","useMemo","generateRandomAlphaString","useIsomorphicLayoutEffect","isAnySystemThemeClassNameOnBody","addSystemThemeClassNameToBody","removeSystemThemeClassNameFromBody","useEffect","shouldGenerateTheme","document","getElementById","name","styleElement","createElement","type","id","themeCssOverride","generateThemeCssOverride","appendChild","createTextNode","head","error","console","removeChild","React","cx","systemThemes","SystemThemeEnum","colors","ThemeColorEnum"],"mappings":"mpBAyCA,IAyEeA,EAAAA,GAzEO,SAAHC,GAMM,IALvBC,EAAWD,EAAXC,YACAC,EAAQF,EAARE,SACqBC,EAAyBH,EAA9CI,oBACAC,EAAWL,EAAXK,YACAC,EAASN,EAATM,UAEAC,EAAwCC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAAhDI,EAAYF,EAAA,GAAEG,EAAeH,EAAA,GAC9BL,EAAsBS,GAC1B,WAAA,OAAMV,GAA6BW,MACnC,CAACX,IAiDH,OA7CAY,GAA0B,WACxB,GAAKV,IAIDW,IAOJ,OAFAC,EAA8BZ,GAEvB,WAELa,EAAmCb,GAEvC,GAAG,CAACA,IAEJc,GAAU,WACR,GAAKC,EAAoBnB,GAAzB,CAGA,IAAIoB,SAASC,eAAerB,EAAYsB,MAAxC,CAKA,IAAMC,EAAeH,SAASI,cAAc,SAC5CD,EAAaE,KAAO,WACpBF,EAAaG,GAAK1B,EAAYsB,KAC9B,IAAMK,EAAmBC,EAAyB5B,EAAaG,GAE/D,IACEoB,EAAaM,YAAYT,SAASU,eAAeH,IACjDP,SAASW,KAAKF,YAAYN,GAC1BZ,GAAgB,EACjB,CAAC,MAAOqB,GACPC,QAAQD,MAAM,6DAA8DA,EAC7E,CAED,OAAO,WACLZ,SAASW,KAAKG,YAAYX,GAhB3B,CAFCZ,GAAgB,EAFjB,CAsBH,GAAG,CAACR,EAAqBH,KAEpBU,GAAgBS,EAAoBnB,GAEhC,KAIFmC,EAAAX,cAAA,MAAA,CAAKnB,UAAW+B,EAAGpC,aAAA,EAAAA,EAAasB,KAAMnB,EAAqBE,IAAaJ,EACjF,GAO6G,CAC3GoC,aAAcC,EACdC,OAAQC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as e}from"../../../_virtual/_tslib.js";import{camelCase as o}from"lodash-es";import{getTestId as r,ComponentDefaultTestId as i}from"../../tests/testIds.js";import n from"classnames";import s,{useRef as a,useMemo as l,useCallback as c,useEffect as m}from"react";import{CSSTransition as u}from"react-transition-group";import p from"../Text/Text.js";import d from"../Loader/Loader.js";import f from"../Flex/Flex.js";import v from"./ToastLink/ToastLink.js";import T from"./ToastButton/ToastButton.js";import{ToastType as j,ToastActionType as y}from"./ToastConstants.js";import{getIcon as h}from"./ToastHelpers.js";import{NOOP as g}from"../../utils/function-utils.js";import{getStyle as x}from"../../helpers/typesciptCssModulesHelper.js";import{
|
|
1
|
+
import{defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as e}from"../../../_virtual/_tslib.js";import{camelCase as o}from"lodash-es";import{getTestId as r,ComponentDefaultTestId as i}from"../../tests/testIds.js";import n from"classnames";import s,{useRef as a,useMemo as l,useCallback as c,useEffect as m}from"react";import{CSSTransition as u}from"react-transition-group";import p from"../Text/Text.js";import d from"../Loader/Loader.js";import f from"../Flex/Flex.js";import v from"./ToastLink/ToastLink.js";import T from"./ToastButton/ToastButton.js";import{ToastType as j,ToastActionType as y}from"./ToastConstants.js";import{getIcon as h}from"./ToastHelpers.js";import{NOOP as g}from"../../utils/function-utils.js";import{getStyle as x}from"../../helpers/typesciptCssModulesHelper.js";import{withStaticPropsWithoutForwardRef as E}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import N from"./Toast.module.scss.js";import C from"../IconButton/IconButton.js";import b from"../../hooks/usePrevious/index.js";import k from"../../../icons/dist/react/CloseSmall.js";var B=E((function(j){var y=j.open,E=void 0!==y&&y,B=j.loading,L=void 0!==B&&B,O=j.autoHideDuration,A=void 0===O?null:O,w=j.type,S=void 0===w?"normal":w,_=j.icon,H=j.hideIcon,I=void 0!==H&&H,P=j.action,z=j.actions,F=j.children,D=j.closeable,M=void 0===D||D,U=j.onClose,q=void 0===U?g:U,G=j.className,J=j.id,K=j.closeButtonAriaLabel,Q=void 0===K?"Close":K,R=j["data-testid"],V=a(null),W=b(null==z?void 0:z.length),X=l((function(){return z?z.filter((function(t){return"link"===t.type})).map((function(t){var o=e(t,["type"]);return s.createElement(v,Object.assign({key:o.href,className:N.actionLink},o))})):null}),[z]),Y=l((function(){return void 0!==W&&(null==z?void 0:z.length)!==W}),[z,W]),Z=l((function(){return z?z.filter((function(t){return"button"===t.type})).map((function(o,r){var i=o.content,a=e(o,["type","content"]);return s.createElement(T,Object.assign({key:"alert-button-".concat(r),className:n(N.actionButton,t({},N.withTransition,Y))},a),i)})):null}),[z,Y]),$=l((function(){return n(N.toast,x(N,o("type-"+S)),G)}),[S,G]),tt=c((function(){q&&q()}),[q]),et=a(),ot=c((function(t){q&&null!=t&&(clearTimeout(et.current),et.current=setTimeout((function(){tt()}),t))}),[tt,q]);m((function(){return E&&A>0&&ot(A),function(){clearTimeout(et.current)}}),[E,A,ot]);var rt=!I&&h(S,_),it=c((function(t){var e=t.style.width;t.style.width="auto";var o=getComputedStyle(t).width;t.style.width=e,t.style.width=o}),[]);return m((function(){V.current&&it(V.current)}),[F,it]),s.createElement(u,{in:E,classNames:{enterActive:N.enterActive,exitActive:N.exitActive},timeout:400,unmountOnExit:!0},s.createElement(p,{id:J,"data-testid":R||r(i.TOAST,J),type:"text2",element:"div",color:"fixedLight",className:$,role:"alert","aria-live":"polite",ref:V},rt&&s.createElement("div",{className:n(N.icon)},rt),s.createElement(f,{align:"center",gap:"large",className:N.content},s.createElement(f,{gap:"medium","data-testid":r(i.TOAST_CONTENT),className:N.textContent},s.createElement("span",null,F),X),(Z||P)&&(Z||P),L&&s.createElement(d,{size:"xs"})),M&&s.createElement(C,{className:n(N.closeButton),onClick:tt,size:"small",kind:"tertiary",color:"fixed-light",ariaLabel:Q,"data-testid":r(i.TOAST_CLOSE_BUTTON),icon:k,hideTooltip:!0})))}),{types:j,actionTypes:y});export{B as default};
|
|
2
2
|
//# sourceMappingURL=Toast.js.map
|