@vibe/core 3.50.1-alpha-1be71.0 → 3.50.1
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 +4 -0
- 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/metadata.json +11649 -8784
- 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 +4 -0
- 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/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/Dialog/Dialog.js +1 -1
- package/dist/mocked_classnames/src/components/Dialog/Dialog.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/Table/TableContainer/TableContainer.module.scss.js +1 -1
- package/dist/mocked_classnames/src/components/Table/TableRowMenu/TableRowMenu.js +1 -1
- package/dist/mocked_classnames/src/components/Table/TableRowMenu/TableRowMenu.js.map +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/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/Dialog/Dialog.js +1 -1
- package/dist/src/components/Dialog/Dialog.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/Table/TableContainer/TableContainer.module.scss.js +1 -1
- package/dist/src/components/Table/TableRowMenu/TableRowMenu.js +1 -1
- package/dist/src/components/Table/TableRowMenu/TableRowMenu.js.map +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/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 +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"classnames";import t,{useRef as o}from"react";import{getTestId as s,ComponentDefaultTestId as n}from"../../../tests/testIds.js";import i from"../../Button/Button.js";import r from"../../Tooltip/Tooltip.js";import l from"../../../hooks/useMergeRef.js";import m from"../MenuItem/hooks/useMenuItemMouseEvents.js";import u from"../MenuItem/hooks/useMenuItemKeyboardEvents.js";import{
|
|
1
|
+
import e from"classnames";import t,{useRef as o}from"react";import{getTestId as s,ComponentDefaultTestId as n}from"../../../tests/testIds.js";import i from"../../Button/Button.js";import r from"../../Tooltip/Tooltip.js";import l from"../../../hooks/useMergeRef.js";import m from"../MenuItem/hooks/useMenuItemMouseEvents.js";import u from"../MenuItem/hooks/useMenuItemKeyboardEvents.js";import{withStaticPropsWithoutForwardRef as a}from"../../../types/withStaticProps.js";import"../../../utils/colors-vars-map.js";import d from"../../Text/Text.js";import c from"./MenuItemButton.module.scss.js";import{TooltipPositions as p}from"../../Tooltip/TooltipConstants.js";var I=function(a){var p=a.className,I=a.kind,v=void 0===I?"primary":I,f=a.leftIcon,M=void 0===f?null:f,h=a.rightIcon,b=void 0===h?null:h,x=a.disabled,j=void 0!==x&&x,k=a.disableReason,E=a.index,C=a.activeItemIndex,S=void 0===C?-1:C,y=a.onClick,T=a.tooltipPosition,B=void 0===T?"right":T,O=a.tooltipShowDelay,N=void 0===O?300:O,g=a.children,A=a.resetOpenSubMenuIndex,w=a.setSubMenuIsOpenByIndex,D=a.setActiveItemIndex,R=a.menuRef,P=a.closeMenu,U=a.useDocumentEventListeners,L=a.id,_=a["data-testid"],z=o(null),K=o(null),q=l(z,K),F=j&&k,G=k,H=S===E,J=m({ref:z,resetOpenSubMenuIndex:A,setSubMenuIsOpenByIndex:w,isActive:H,setActiveItemIndex:D,index:E,hasChildren:!1}),Q=u({onClick:y,disabled:j,isActive:H,index:E,setActiveItemIndex:D,hasChildren:!1,shouldShowSubMenu:!1,setSubMenuIsOpenByIndex:w,menuRef:R,isMouseEnter:J,closeMenu:P,useDocumentEventListeners:U}).onClickCallback;return t.createElement(r,{content:F?G:null,position:B,showDelay:N},t.createElement(d,{type:"text2",element:"li","data-testid":_||s(n.MENU_ITEM_BUTTON,L),id:L,className:e(c.itemButton,p),ref:q,role:"menuitem","aria-current":H},t.createElement(i,{className:c.buttonComponent,active:H,disabled:j,leftIcon:M,rightIcon:b,onClick:Q,kind:v,size:"small",blurOnMouseUp:!1},t.createElement("div",{className:c.content},g))))};Object.assign(I,{isSelectable:!0,isMenuChild:!0});var v=a(I,{kinds:i.kinds,tooltipPositions:p});export{v as default};
|
|
2
2
|
//# sourceMappingURL=MenuItemButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemButton.js","sources":["../../../../../src/components/Menu/MenuItemButton/MenuItemButton.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { useRef } from \"react\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport Button from \"../../Button/Button\";\nimport Tooltip from \"../../Tooltip/Tooltip\";\nimport { ButtonType } from \"../../Button\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport useMenuItemMouseEvents from \"../MenuItem/hooks/useMenuItemMouseEvents\";\nimport useMenuItemKeyboardEvents from \"../MenuItem/hooks/useMenuItemKeyboardEvents\";\nimport { SubIcon, VibeComponentProps,
|
|
1
|
+
{"version":3,"file":"MenuItemButton.js","sources":["../../../../../src/components/Menu/MenuItemButton/MenuItemButton.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { useRef } from \"react\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport Button from \"../../Button/Button\";\nimport Tooltip from \"../../Tooltip/Tooltip\";\nimport { ButtonType } from \"../../Button\";\nimport useMergeRef from \"../../../hooks/useMergeRef\";\nimport useMenuItemMouseEvents from \"../MenuItem/hooks/useMenuItemMouseEvents\";\nimport useMenuItemKeyboardEvents from \"../MenuItem/hooks/useMenuItemKeyboardEvents\";\nimport { SubIcon, VibeComponentProps, ElementContent, withStaticPropsWithoutForwardRef } from \"../../../types\";\nimport Text from \"../../Text/Text\";\nimport styles from \"./MenuItemButton.module.scss\";\nimport { TooltipPositions } from \"../../Tooltip\";\nimport { TooltipPositions as TooltipPositionsEnum } from \"../../Tooltip/TooltipConstants\";\n\nexport interface MenuItemButtonProps extends VibeComponentProps {\n /**\n * The style variant of the button.\n */\n kind?: ButtonType;\n /**\n * Icon displayed on the left side of the button.\n */\n leftIcon?: SubIcon;\n /**\n * Icon displayed on the right side of the button.\n */\n rightIcon?: SubIcon;\n /**\n * The index of the menu item in the menu.\n */\n index?: number;\n /**\n * The index of the currently active menu item.\n */\n activeItemIndex?: number;\n /**\n * If true, the button is disabled.\n */\n disabled?: boolean;\n /**\n * The reason why the button is disabled, displayed as a tooltip.\n */\n disableReason?: string;\n /**\n * Callback fired when the button is clicked.\n */\n onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;\n /**\n * The position of the tooltip.\n */\n tooltipPosition?: TooltipPositions;\n /**\n * The delay in milliseconds before the tooltip appears.\n */\n tooltipShowDelay?: number;\n /**\n * Callback to reset the open submenu index.\n */\n resetOpenSubMenuIndex?: () => void;\n /**\n * Callback to open or close a submenu by index.\n */\n setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void;\n /**\n * Callback to set the active item index.\n */\n setActiveItemIndex?: (index: number) => void;\n /**\n * Reference to the menu container.\n */\n menuRef?: React.RefObject<HTMLElement>;\n /**\n * Function to close the menu.\n */\n closeMenu?: () => void;\n /**\n * If true, event listeners are added at the document level.\n */\n useDocumentEventListeners?: boolean;\n /**\n * The content of the button.\n */\n children?: ElementContent | ElementContent[];\n}\n\nconst MenuItemButton = ({\n className,\n kind = \"primary\",\n leftIcon = null,\n rightIcon = null,\n disabled = false,\n disableReason,\n index,\n activeItemIndex = -1,\n onClick,\n tooltipPosition = \"right\",\n tooltipShowDelay = 300,\n children,\n resetOpenSubMenuIndex,\n setSubMenuIsOpenByIndex,\n setActiveItemIndex,\n menuRef,\n closeMenu,\n useDocumentEventListeners,\n id,\n \"data-testid\": dataTestId\n}: MenuItemButtonProps) => {\n const ref = useRef(null);\n const referenceElementRef = useRef(null);\n const mergedRef = useMergeRef(ref, referenceElementRef);\n\n const shouldShowTooltip = disabled && disableReason;\n const tooltipContent = disableReason;\n\n const isActive = activeItemIndex === index;\n\n const isMouseEnter = useMenuItemMouseEvents({\n ref,\n resetOpenSubMenuIndex,\n setSubMenuIsOpenByIndex,\n isActive,\n setActiveItemIndex,\n index,\n hasChildren: false\n });\n\n const { onClickCallback } = useMenuItemKeyboardEvents({\n onClick,\n disabled,\n isActive,\n index,\n setActiveItemIndex,\n hasChildren: false,\n shouldShowSubMenu: false,\n setSubMenuIsOpenByIndex,\n menuRef,\n isMouseEnter,\n closeMenu,\n useDocumentEventListeners\n });\n\n return (\n <Tooltip\n content={shouldShowTooltip ? tooltipContent : null}\n position={tooltipPosition}\n showDelay={tooltipShowDelay}\n >\n <Text\n type=\"text2\"\n element=\"li\"\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.MENU_ITEM_BUTTON, id)}\n id={id}\n className={cx(styles.itemButton, className)}\n ref={mergedRef}\n role=\"menuitem\"\n aria-current={isActive}\n >\n <Button\n className={styles.buttonComponent}\n active={isActive}\n disabled={disabled}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n onClick={onClickCallback}\n kind={kind}\n size=\"small\"\n blurOnMouseUp={false}\n >\n <div className={styles.content}>{children}</div>\n </Button>\n </Text>\n </Tooltip>\n );\n};\n\nObject.assign(MenuItemButton, {\n isSelectable: true,\n isMenuChild: true\n});\n\ninterface MenuItemButtonStaticProps {\n kinds: typeof Button.kinds;\n tooltipPositions: typeof TooltipPositionsEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<MenuItemButtonProps, MenuItemButtonStaticProps>(MenuItemButton, {\n kinds: Button.kinds,\n tooltipPositions: TooltipPositionsEnum\n});\n"],"names":["MenuItemButton","_ref","className","_ref$kind","kind","_ref$leftIcon","leftIcon","_ref$rightIcon","rightIcon","_ref$disabled","disabled","disableReason","index","_ref$activeItemIndex","activeItemIndex","onClick","_ref$tooltipPosition","tooltipPosition","_ref$tooltipShowDelay","tooltipShowDelay","children","resetOpenSubMenuIndex","setSubMenuIsOpenByIndex","setActiveItemIndex","menuRef","closeMenu","useDocumentEventListeners","id","dataTestId","ref","useRef","referenceElementRef","mergedRef","useMergeRef","shouldShowTooltip","tooltipContent","isActive","isMouseEnter","useMenuItemMouseEvents","hasChildren","onClickCallback","useMenuItemKeyboardEvents","shouldShowSubMenu","React","Tooltip","content","position","showDelay","createElement","Text","type","element","getTestId","ComponentDefaultTestId","MENU_ITEM_BUTTON","cx","styles","itemButton","role","Button","buttonComponent","active","size","blurOnMouseUp","Object","assign","isSelectable","isMenuChild","withStaticPropsWithoutForwardRef","kinds","tooltipPositions","TooltipPositionsEnum"],"mappings":"upBAsFA,IAAMA,EAAiB,SAAHC,GAqBM,IApBxBC,EAASD,EAATC,UAASC,EAAAF,EACTG,KAAAA,OAAO,IAAHD,EAAG,UAASA,EAAAE,EAAAJ,EAChBK,SAAAA,OAAW,IAAHD,EAAG,KAAIA,EAAAE,EAAAN,EACfO,UAAAA,OAAY,IAAHD,EAAG,KAAIA,EAAAE,EAAAR,EAChBS,SAAAA,OAAW,IAAHD,GAAQA,EAChBE,EAAaV,EAAbU,cACAC,EAAKX,EAALW,MAAKC,EAAAZ,EACLa,gBAAAA,OAAe,IAAAD,GAAI,EAACA,EACpBE,EAAOd,EAAPc,QAAOC,EAAAf,EACPgB,gBAAAA,OAAkB,I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AWsD,EAAOX,SAAUzB,KAK3C,EAEA4C,OAAOC,OAAOjE,EAAgB,CAC5BkE,cAAc,EACdC,aAAa,IAQf,IAAeC,EAAAA,EAAiFpE,EAAgB,CAC9GqE,MAAOV,EAAOU,MACdC,iBAAkBC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"react";import s from"classnames";import{camelCase as o}from"lodash-es";import{getStyle as e}from"../../../helpers/typesciptCssModulesHelper.js";import{getTestId as i,ComponentDefaultTestId as r}from"../../../tests/testIds.js";import a from"../../Text/Text.js";import{MenuTitleCaptionPosition as m}from"./MenuTitleConstants.js";import{
|
|
1
|
+
import t from"react";import s from"classnames";import{camelCase as o}from"lodash-es";import{getStyle as e}from"../../../helpers/typesciptCssModulesHelper.js";import{getTestId as i,ComponentDefaultTestId as r}from"../../../tests/testIds.js";import a from"../../Text/Text.js";import{MenuTitleCaptionPosition as m}from"./MenuTitleConstants.js";import{withStaticPropsWithoutForwardRef as p}from"../../../types/withStaticProps.js";import"../../../utils/colors-vars-map.js";import n from"./MenuTitle.module.scss.js";var l=function(m){var p=m.caption,l=void 0===p?"":p,c=m.captionPosition,d=void 0===c?"bottom":c,f=m.id,u=m["data-testid"];return t.createElement(a,{color:"secondary",type:"text2",className:s(n.title,m.className),"data-testid":u||i(r.MENU_TITLE,f)},function(){if(l)return t.createElement("label",{className:s(n.titleCaption,e(n,o("title__caption--"+d))),id:f,"data-testid":u||i(r.MENU_TITLE_CAPTION,f)},l)}())};Object.assign(l,{isMenuChild:!0});var c=p(l,{positions:m,captionPositions:m});export{c as default};
|
|
2
2
|
//# sourceMappingURL=MenuTitle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuTitle.js","sources":["../../../../../src/components/Menu/MenuTitle/MenuTitle.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport Text from \"../../Text/Text\";\nimport { MenuTitleCaptionPosition as MenuTitleCaptionPositionEnum } from \"./MenuTitleConstants\";\nimport { MenuTitleCaptionPosition } from \"./MenuTitle.type\";\nimport { VibeComponentProps,
|
|
1
|
+
{"version":3,"file":"MenuTitle.js","sources":["../../../../../src/components/Menu/MenuTitle/MenuTitle.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport Text from \"../../Text/Text\";\nimport { MenuTitleCaptionPosition as MenuTitleCaptionPositionEnum } from \"./MenuTitleConstants\";\nimport { MenuTitleCaptionPosition } from \"./MenuTitle.type\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../../types\";\nimport styles from \"./MenuTitle.module.scss\";\n\nexport interface MenuTitleProps extends VibeComponentProps {\n /**\n * The caption text displayed alongside the title.\n */\n caption?: string | React.ReactNode;\n /**\n * The position of the caption relative to the title.\n */\n captionPosition?: MenuTitleCaptionPosition;\n}\n\nconst MenuTitle = ({\n className,\n caption = \"\",\n captionPosition = \"bottom\",\n id,\n \"data-testid\": dataTestId\n}: MenuTitleProps) => {\n const renderCaptionIfNeeded = () => {\n if (caption) {\n return (\n <label\n className={cx(styles.titleCaption, getStyle(styles, camelCase(\"title__caption--\" + captionPosition)))}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.MENU_TITLE_CAPTION, id)}\n >\n {caption}\n </label>\n );\n }\n };\n return (\n <Text\n color=\"secondary\"\n type=\"text2\"\n className={cx(styles.title, className)}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.MENU_TITLE, id)}\n >\n {renderCaptionIfNeeded()}\n </Text>\n );\n};\n\nObject.assign(MenuTitle, {\n isMenuChild: true\n});\n\ninterface MenuTitleStaticProps {\n positions: typeof MenuTitleCaptionPositionEnum;\n captionPositions: typeof MenuTitleCaptionPositionEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<MenuTitleProps, MenuTitleStaticProps>(MenuTitle, {\n positions: MenuTitleCaptionPositionEnum,\n captionPositions: MenuTitleCaptionPositionEnum\n});\n"],"names":["MenuTitle","_ref","_ref$caption","caption","_ref$captionPosition","captionPosition","id","dataTestId","React","createElement","Text","color","type","className","cx","styles","title","getTestId","ComponentDefaultTestId","MENU_TITLE","titleCaption","getStyle","camelCase","MENU_TITLE_CAPTION","renderCaptionIfNeeded","Object","assign","isMenuChild","withStaticPropsWithoutForwardRef","positions","MenuTitleCaptionPositionEnum","captionPositions"],"mappings":"8fAsBA,IAAMA,EAAY,SAAHC,GAMM,IALVC,EAAAD,EACTE,QAAAA,OAAU,IAAHD,EAAG,GAAEA,EAAAE,EAAAH,EACZI,gBAAAA,OAAkB,IAAHD,EAAG,SAAQA,EAC1BE,EAAEL,EAAFK,GACeC,EAAUN,EAAzB,eAeA,OACEO,EAACC,cAAAC,EACC,CAAAC,MAAM,YACNC,KAAK,QACLC,UAAWC,EAAGC,EAAOC,MAvBhBf,EAATY,WAwBiB,cAAAN,GAAcU,EAAUC,EAAuBC,WAAYb,IAlB9C,WAC5B,GAAIH,EACF,OACEK,EACEC,cAAA,QAAA,CAAAI,UAAWC,EAAGC,EAAOK,aAAcC,EAASN,EAAQO,EAAU,mBAAqBjB,KACnFC,GAAIA,EACS,cAAAC,GAAcU,EAAUC,EAAuBK,mBAAoBjB,IAE/EH,GAYJqB,GAGP,EAEAC,OAAOC,OAAO1B,EAAW,CACvB2B,aAAa,IAQf,IAAeC,EAAAA,EAAuE5B,EAAW,CAC/F6B,UAAWC,EACXC,iBAAkBD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import t from"react";import{camelCase as s}from"lodash-es";import{getTestId as r,ComponentDefaultTestId as i}from"../../tests/testIds.js";import l from"classnames";import{SkeletonType as o,SKELETON_SIZES as a,TextSkeletonSize as m,SKELETON_CUSTOM_SIZE as p}from"./SkeletonConstants.js";import{getStyle as d}from"../../helpers/typesciptCssModulesHelper.js";import{
|
|
1
|
+
import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import t from"react";import{camelCase as s}from"lodash-es";import{getTestId as r,ComponentDefaultTestId as i}from"../../tests/testIds.js";import l from"classnames";import{SkeletonType as o,SKELETON_SIZES as a,TextSkeletonSize as m,SKELETON_CUSTOM_SIZE as p}from"./SkeletonConstants.js";import{getStyle as d}from"../../helpers/typesciptCssModulesHelper.js";import{withStaticPropsWithoutForwardRef as c}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import n from"./Skeleton.module.scss.js";var u=c((function(a){var c=a.type,u=void 0===c?"rectangle":c,f=a.size,h=void 0===f?"custom":f,v=a.className,j=a.wrapperClassName,y=a.width,g=a.height,N=a.fullWidth,w=void 0!==N&&N,E=a.id,S=a["data-testid"],b=Object.values(o).includes(u)?u:"rectangle",k=Object.values(m).includes(h)?h:p;return t.createElement("div",{id:E,className:l(n.skeleton,j,e({},n.fullWidth,w)),"data-testid":S||r(i.SKELETON,E)},t.createElement("div",{className:l(n[b],d(n,s(b+"-"+k)),v,e({},n.fullWidth,w)),style:{width:y,height:g}}))}),{types:o,sizes:a});export{u as default};
|
|
2
2
|
//# sourceMappingURL=Skeleton.js.map
|
|
@@ -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":"44CA0EA,IAAMA,EAAc,SAACC,GAAA,IACn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AC,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,EARjBuB,QACAC,GAOiBxB,EAPjBwB,S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rGiJ,mBAAoBL,EACpBM,yBAA0BN,EAC1BE,MAAOrC,EAAOqC,MACdK,OAAQ1C,EAAO0C,OACfC,MAAO3C,EAAO2C,MACdC,UAAW5C,EAAO4C,UAClBC,mBAAoBvD,EAAuB+C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={tableContainer:"tableContainer_8ef3d5be9b",menuContainer:"
|
|
1
|
+
var e={tableContainer:"tableContainer_8ef3d5be9b",menuContainer:"menuContainer_0a62e5f9a0"};!function(e){const n="s_id-c61f3446ce1a_3_50_0";if("undefined"!=typeof document){const t=document.head||document.getElementsByTagName("head")[0];if(t.querySelector("#"+n))return;const i=document.createElement("style");i.id=n,t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i),i.appendChild(document.createTextNode(e))}else globalThis.injectedStyles&&(globalThis.injectedStyles[n]=e)}(".tableContainer_8ef3d5be9b {\n width: 100%;\n height: 100%;\n position: relative;\n}\n.tableContainer_8ef3d5be9b .menuContainer_0a62e5f9a0 {\n --cell-width: 40px;\n position: absolute;\n overflow: hidden;\n left: calc(1px - var(--cell-width));\n width: var(--cell-width);\n height: 100%;\n}");export{e as default};
|
|
2
2
|
//# sourceMappingURL=TableContainer.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{forwardRef as t,useCallback as n}from"react";import o from"classnames";import{getTestId as r}from"../../../tests/testIds.js";import{ComponentDefaultTestId as u}from"../../../tests/constants.js";import s from"./TableRowMenu.module.scss.js";import m from"../../MenuButton/MenuButton.js";import i from"../../Menu/Menu/Menu.js";import"../../Menu/MenuItem/MenuItem.js";import"../../Menu/MenuItemButton/MenuItemButton.js";import"../../Menu/MenuDivider/MenuDivider.js";import"../../Menu/MenuTitle/MenuTitle.js";import"../../Menu/MenuGridItem/MenuGridItem.js";import{createPortal as a}from"react-dom";import{useTable as M}from"../context/TableContext/TableContext.js";import{getStyle as l}from"../../../helpers/typesciptCssModulesHelper.js";import{useTableRowMenu as d}from"../context/TableRowMenuContext/TableRowMenuContext.js";import{useTableContainer as p}from"../context/TableContainerContext/TableContainerContext.js";var c=t((function(t,c){var f=t.rowId,j=t.className,T=t.id,
|
|
1
|
+
import e,{forwardRef as t,useCallback as n}from"react";import o from"classnames";import{getTestId as r}from"../../../tests/testIds.js";import{ComponentDefaultTestId as u}from"../../../tests/constants.js";import s from"./TableRowMenu.module.scss.js";import m from"../../MenuButton/MenuButton.js";import i from"../../Menu/Menu/Menu.js";import"../../Menu/MenuItem/MenuItem.js";import"../../Menu/MenuItemButton/MenuItemButton.js";import"../../Menu/MenuDivider/MenuDivider.js";import"../../Menu/MenuTitle/MenuTitle.js";import"../../Menu/MenuGridItem/MenuGridItem.js";import{createPortal as a}from"react-dom";import{useTable as M}from"../context/TableContext/TableContext.js";import{getStyle as l}from"../../../helpers/typesciptCssModulesHelper.js";import{useTableRowMenu as d}from"../context/TableRowMenuContext/TableRowMenuContext.js";import{useTableContainer as p}from"../context/TableContainerContext/TableContainerContext.js";var c=t((function(t,c){var f=t.rowId,j=t.className,T=t.id,x=t["data-testid"],C=t.children,b=p().menuContainerRef,w=M().size,v=d(),I=v.hoveredRowId,R=v.setTableMenuHidden,E=v.setTableMenuShown,B=v.menuButtonPosition,h=v.onMouseOverRowMenu,N=v.onMouseLeaveRowMenu,H=n((function(){R()}),[R]),L=n((function(){E()}),[E]);return b.current&&I&&I===f?e.createElement(e.Fragment,null,a(e.createElement("div",{className:o(s.rowMenuContainer,l(s,w)),style:{top:B},onMouseEnter:h,onMouseLeave:N},e.createElement(m,{id:T,ref:c,className:o(s.tableMenu,j),size:"xs",onMenuHide:H,onMenuShow:L,"data-testid":x||r(u.TABLE_ROW_MENU,T)},e.createElement(i,null,C))),b.current)):null}));export{c as default};
|
|
2
2
|
//# sourceMappingURL=TableRowMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRowMenu.js","sources":["../../../../../src/components/Table/TableRowMenu/TableRowMenu.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from \"react\";\nimport cx from \"classnames\";\nimport { getTestId } from \"../../../tests/test-ids-utils\";\nimport { ComponentDefaultTestId } from \"../../../tests/constants\";\nimport styles from \"./TableRowMenu.module.scss\";\nimport MenuButton from \"../../MenuButton/MenuButton\";\nimport { Menu } from \"../../Menu\";\nimport { createPortal } from \"react-dom\";\nimport { useTable } from \"../context/TableContext/TableContext\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport { useTableRowMenu } from \"../context/TableRowMenuContext/TableRowMenuContext\";\nimport { useTableContainer } from \"../context/TableContainerContext/TableContainerContext\";\nimport { TableMenuProps } from \"./TableRowMenu.types\";\n\nconst TableRowMenu = forwardRef(\n (\n { rowId, className, id, \"data-testid\": dataTestId, children }: TableMenuProps,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const { menuContainerRef } = useTableContainer();\n const { size } = useTable();\n const {\n hoveredRowId,\n setTableMenuHidden,\n setTableMenuShown,\n menuButtonPosition,\n onMouseOverRowMenu,\n onMouseLeaveRowMenu\n } = useTableRowMenu();\n\n const onMenuHide = useCallback(() => {\n setTableMenuHidden();\n }, [setTableMenuHidden]);\n\n const onMenuShow = useCallback(() => {\n setTableMenuShown();\n }, [setTableMenuShown]);\n\n const shouldShowMenu = menuContainerRef.current && hoveredRowId && hoveredRowId === rowId;\n if (!shouldShowMenu) return null;\n\n return (\n <>\n {createPortal(\n <div\n className={cx(styles.rowMenuContainer, getStyle(styles, size))}\n style={{ top: menuButtonPosition }}\n onMouseEnter={onMouseOverRowMenu}\n onMouseLeave={onMouseLeaveRowMenu}\n
|
|
1
|
+
{"version":3,"file":"TableRowMenu.js","sources":["../../../../../src/components/Table/TableRowMenu/TableRowMenu.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from \"react\";\nimport cx from \"classnames\";\nimport { getTestId } from \"../../../tests/test-ids-utils\";\nimport { ComponentDefaultTestId } from \"../../../tests/constants\";\nimport styles from \"./TableRowMenu.module.scss\";\nimport MenuButton from \"../../MenuButton/MenuButton\";\nimport { Menu } from \"../../Menu\";\nimport { createPortal } from \"react-dom\";\nimport { useTable } from \"../context/TableContext/TableContext\";\nimport { getStyle } from \"../../../helpers/typesciptCssModulesHelper\";\nimport { useTableRowMenu } from \"../context/TableRowMenuContext/TableRowMenuContext\";\nimport { useTableContainer } from \"../context/TableContainerContext/TableContainerContext\";\nimport { TableMenuProps } from \"./TableRowMenu.types\";\n\nconst TableRowMenu = forwardRef(\n (\n { rowId, className, id, \"data-testid\": dataTestId, children }: TableMenuProps,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const { menuContainerRef } = useTableContainer();\n const { size } = useTable();\n const {\n hoveredRowId,\n setTableMenuHidden,\n setTableMenuShown,\n menuButtonPosition,\n onMouseOverRowMenu,\n onMouseLeaveRowMenu\n } = useTableRowMenu();\n\n const onMenuHide = useCallback(() => {\n setTableMenuHidden();\n }, [setTableMenuHidden]);\n\n const onMenuShow = useCallback(() => {\n setTableMenuShown();\n }, [setTableMenuShown]);\n\n const shouldShowMenu = menuContainerRef.current && hoveredRowId && hoveredRowId === rowId;\n if (!shouldShowMenu) return null;\n\n return (\n <>\n {createPortal(\n <div\n className={cx(styles.rowMenuContainer, getStyle(styles, size))}\n style={{ top: menuButtonPosition }}\n onMouseEnter={onMouseOverRowMenu}\n onMouseLeave={onMouseLeaveRowMenu}\n >\n <MenuButton\n id={id}\n ref={ref}\n className={cx(styles.tableMenu, className)}\n size=\"xs\"\n onMenuHide={onMenuHide}\n onMenuShow={onMenuShow}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TABLE_ROW_MENU, id)}\n >\n <Menu>{children}</Menu>\n </MenuButton>\n </div>,\n menuContainerRef.current\n )}\n </>\n );\n }\n);\n\nexport default TableRowMenu;\n"],"names":["TableRowMenu","forwardRef","_ref","ref","rowId","className","id","dataTestId","children","menuContainerRef","useTableContainer","size","useTable","_useTableRowMenu","useTableRowMenu","hoveredRowId","setTableMenuHidden","setTableMenuShown","menuButtonPosition","onMouseOverRowMenu","onMouseLeaveRowMenu","onMenuHide","useCallback","onMenuShow","current","React","createElement","Fragment","createPortal","cx","styles","rowMenuContainer","getStyle","style","top","onMouseEnter","onMouseLeave","MenuButton","tableMenu","getTestId","ComponentDefaultTestId","TABLE_ROW_MENU","Menu"],"mappings":"65BAcMA,IAAAA,EAAeC,GACnB,SAAAC,EAEEC,GACE,IAFAC,EAAKF,EAALE,MAAOC,EAASH,EAATG,UAAWC,EAAEJ,EAAFI,GAAmBC,EAAUL,EAAzB,eAA2BM,EAAQN,EAARM,SAG3CC,EAAqBC,IAArBD,iBACAE,EAASC,IAATD,KACRE,EAOIC,IANFC,EAAYF,EAAZE,aACAC,EAAkBH,EAAlBG,mBACAC,EAAiBJ,EAAjBI,kBACAC,EAAkBL,EAAlBK,mBACAC,EAAkBN,EAAlBM,mBACAC,EAAmBP,EAAnBO,oBAGIC,EAAaC,GAAY,WAC7BN,GACF,GAAG,CAACA,IAEEO,EAAaD,GAAY,WAC7BL,GACF,GAAG,CAACA,IAGJ,OADuBR,EAAiBe,SAAWT,GAAgBA,IAAiBX,EAIlFqB,EAAAC,cAAAD,EAAAE,SAAA,KACGC,EACCH,uBACEpB,UAAWwB,EAAGC,EAAOC,iBAAkBC,EAASF,EAAQnB,IACxDsB,MAAO,CAAEC,IAAKhB,GACdiB,aAAchB,EACdiB,aAAchB,GAEdK,EAAAC,cAACW,EACC,CAAA/B,GAAIA,EACJH,IAAKA,EACLE,UAAWwB,EAAGC,EAAOQ,UAAWjC,GAChCM,KAAK,KACLU,WAAYA,EACZE,WAAYA,gBACChB,GAAcgC,EAAUC,EAAuBC,eAAgBnC,IAE5EmB,EAAAC,cAACgB,EAAI,KAAElC,KAGXC,EAAiBe,UAvBK,IA2B9B"}
|
|
@@ -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,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,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, 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, unknown>(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,GA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
@@ -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
|