@vibe/core 3.53.1-alpha-685df.0 → 3.53.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.
Files changed (40) hide show
  1. package/dist/components/Toast/Toast.d.ts +2 -2
  2. package/dist/icons/dist/react/DropdownChevronDown.js +1 -1
  3. package/dist/icons/dist/react/DropdownChevronDown.js.map +1 -1
  4. package/dist/icons/dist/react/DropdownChevronUp.js +1 -1
  5. package/dist/icons/dist/react/DropdownChevronUp.js.map +1 -1
  6. package/dist/metadata.json +30 -16
  7. package/dist/mocked_classnames/components/Toast/Toast.d.ts +2 -2
  8. package/dist/mocked_classnames/icons/dist/react/DropdownChevronDown.js +1 -1
  9. package/dist/mocked_classnames/icons/dist/react/DropdownChevronDown.js.map +1 -1
  10. package/dist/mocked_classnames/icons/dist/react/DropdownChevronUp.js +1 -1
  11. package/dist/mocked_classnames/icons/dist/react/DropdownChevronUp.js.map +1 -1
  12. package/dist/mocked_classnames/src/components/AlertBanner/AlertBannerButton/AlertBannerButton.js +1 -1
  13. package/dist/mocked_classnames/src/components/AlertBanner/AlertBannerButton/AlertBannerButton.js.map +1 -1
  14. package/dist/mocked_classnames/src/components/Button/Button.js +1 -1
  15. package/dist/mocked_classnames/src/components/Button/Button.js.map +1 -1
  16. package/dist/mocked_classnames/src/components/Counter/Counter.js +1 -1
  17. package/dist/mocked_classnames/src/components/Counter/Counter.js.map +1 -1
  18. package/dist/mocked_classnames/src/components/Dialog/DialogContent/DialogContent.js +1 -1
  19. package/dist/mocked_classnames/src/components/Dialog/DialogContent/DialogContent.js.map +1 -1
  20. package/dist/mocked_classnames/src/components/SplitButton/SplitButton.js +1 -1
  21. package/dist/mocked_classnames/src/components/SplitButton/SplitButton.js.map +1 -1
  22. package/dist/mocked_classnames/src/components/Toast/Toast.js +1 -1
  23. package/dist/mocked_classnames/src/components/Toast/Toast.js.map +1 -1
  24. package/dist/mocked_classnames/src/components/Toast/ToastButton/ToastButton.js +1 -1
  25. package/dist/mocked_classnames/src/components/Toast/ToastButton/ToastButton.js.map +1 -1
  26. package/dist/src/components/AlertBanner/AlertBannerButton/AlertBannerButton.js +1 -1
  27. package/dist/src/components/AlertBanner/AlertBannerButton/AlertBannerButton.js.map +1 -1
  28. package/dist/src/components/Button/Button.js +1 -1
  29. package/dist/src/components/Button/Button.js.map +1 -1
  30. package/dist/src/components/Counter/Counter.js +1 -1
  31. package/dist/src/components/Counter/Counter.js.map +1 -1
  32. package/dist/src/components/Dialog/DialogContent/DialogContent.js +1 -1
  33. package/dist/src/components/Dialog/DialogContent/DialogContent.js.map +1 -1
  34. package/dist/src/components/SplitButton/SplitButton.js +1 -1
  35. package/dist/src/components/SplitButton/SplitButton.js.map +1 -1
  36. package/dist/src/components/Toast/Toast.js +1 -1
  37. package/dist/src/components/Toast/Toast.js.map +1 -1
  38. package/dist/src/components/Toast/ToastButton/ToastButton.js +1 -1
  39. package/dist/src/components/Toast/ToastButton/ToastButton.js.map +1 -1
  40. package/package.json +3 -3
@@ -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 p}from"react";import{SplitButtonSecondaryContentPosition as g,ENTER_KEYS as f,DEFAULT_DIALOG_SHOW_TRIGGER as v,DEFAULT_DIALOG_HIDE_TRIGGER as D,DIALOG_MOVE_BY as y,SECONDARY_BUTTON_ARIA_LABEL as C,SECONDARY_BUTTON_WRAPPER_CLASSNAME as N}from"./SplitButtonConstants.js";import{withStaticPropsWithoutForwardRef as h}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{HideShowEvent as k,AnimationType as T}from"../Dialog/DialogConstants.js";import{NOOP as b}from"../../utils/function-utils.js";import{isInsideClass as S}from"../../utils/dom-utils.js";import j from"../../hooks/useKeyEvent/index.js";import P from"../../hooks/useEventListener/index.js";import I from"../Button/Button.js";import B from"../Dialog/Dialog.js";import E from"../DialogContentContainer/DialogContentContainer.js";import O from"./SplitButton.module.scss.js";import{ComponentVibeId as _}from"../../tests/constants.js";import z from"../../../icons/dist/react/DropdownChevronDown.js";var L=h((function(g){var h=g.secondaryDialogContent,L=g.onSecondaryDialogDidShow,w=void 0===L?b:L,A=g.onSecondaryDialogDidHide,x=void 0===A?b:A,R=g.shouldCloseOnClickInsideDialog,H=g.zIndex,U=void 0===H?null:H,F=g.secondaryDialogClassName,K=void 0===F?"":F,M=g.secondaryDialogPosition,W=void 0===M?"bottom-start":M,Y=g.dialogContainerSelector,V=g.dialogPaddingSize,X=void 0===V?"medium":V,q=g.disabled,G=g.loading,J=g.kind,Q=void 0===J?"primary":J,Z=g.color,$=void 0===Z?"primary":Z,oo=g.className,eo=g.leftIcon,to=g.rightIcon,io=g.onClick,no=g.children,ao=g.marginLeft,ro=g.marginRight,so=g.active,lo=g.id,co=g["data-testid"],mo=i(g,["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"]),uo=c(!1),po=o(uo,2),go=po[0],fo=po[1],vo=c(!1),Do=o(vo,2),yo=Do[0],Co=Do[1],No=c(!1),ho=o(No,2),ko=ho[0],To=ho[1],bo=m(null),So=m(null),jo=u((function(){return Co(!0)}),[Co]),Po=u((function(){return Co(!1)}),[Co]),Io=u((function(o){return!q&&!S(o.target,N)}),[q]),Bo=u((function(o){Io(o)&&To(!0)}),[To,Io]),Eo=u((function(){return To(!1)}),[To]),Oo=u((function(o){Io(o)&&To(!0)}),[To,Io]),_o=u((function(){fo(!0),w()}),[fo,w]),zo=u((function(o,e){fo(!1),x(),"esckey"===e&&So.current.focus()}),[fo,x]);P({eventName:"mouseenter",callback:jo,ref:bo}),P({eventName:"mouseleave",callback:Po,ref:bo}),P({eventName:"mousedown",callback:Bo,ref:bo}),P({eventName:"mouseup",callback:Eo,ref:bo}),P({eventName:"transitionend",callback:Eo,ref:bo}),j({keys:f,ref:bo,callback:Oo});var Lo=p((function(){return l(O.button,a(O,n("kind-"+Q)),a(O,n("color-"+$)),e(e(e(e(e({},O.mainActive,so),O.active,ko),O.splitContentOpen,go),O.hovered,yo),O.disabled,q),oo)}),[oo,Q,$,so,ko,go,yo,q]),wo=p((function(){return q?[]:v}),[q]),Ao=p((function(){return R?[].concat(t(D),[k.CONTENT_CLICK]):D}),[R]),xo=u((function(){var o="function"==typeof h?h():h;return d.createElement(E,{type:E.types.POPOVER,size:X},o)}),[h,X]),Ro=p((function(){return"bottom"===W?"":"bottom-start"===W?"bottom":"top"}),[W]);return d.createElement("div",{className:Lo,ref:bo,id:lo,"data-testid":co||r(s.SPLIT_BUTTON,lo),"data-vibe":_.SPLIT_BUTTON},d.createElement(I,Object.assign({},mo,{preventClickAnimation:!0,leftIcon:eo,rightIcon:to,rightFlat:!0,color:$,kind:Q,active:so,onClick:io,className:O.mainButton,marginLeft:ao,onFocus:jo,onBlur:Po,disabled:q,loading:G,"data-testid":r(s.SPLIT_BUTTON_PRIMARY_BUTTON,lo)}),no),d.createElement("div",{className:O.secondaryButtonWrapper},d.createElement(B,{wrapperClassName:K,zIndex:U,content:xo,position:W,containerSelector:Y,startingEdge:Ro,animationType:T.EXPAND,moveBy:y,onDialogDidShow:_o,onDialogDidHide:zo,showTrigger:wo,hideTrigger:Ao},d.createElement(I,Object.assign({},mo,{ref:So,preventClickAnimation:!0,leftFlat:!0,noSidePadding:!0,color:$,kind:Q,className:O.secondaryButton,active:go,marginRight:ro,onFocus:jo,onBlur:Po,disabled:q,ariaLabel:C,ariaHasPopup:!0,ariaExpanded:go,"data-testid":r(s.SPLIT_BUTTON_SECONDARY_BUTTON,lo)}),d.createElement("div",{className:O.secondaryButtonIconWrapper},d.createElement(z,{"aria-hidden":"true"}))))))}),{secondaryPositions:g,secondaryDialogPositions:g,sizes:I.sizes,colors:I.colors,kinds:I.kinds,inputTags:I.inputTags,dialogPaddingSizes:E.sizes});export{L as default};
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 { 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 = \"primary\",\n color = \"primary\",\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\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":["withStaticPropsWithoutForwardRef","_a","secondaryDialogContent","_a$onSecondaryDialogD","onSecondaryDialogDidShow","NOOP","_a$onSecondaryDialogD2","onSecondaryDialogDidHide","shouldCloseOnClickInsideDialog","_a$zIndex","zIndex","_a$secondaryDialogCla","secondaryDialogClassName","_a$secondaryDialogPos","secondaryDialogPosition","dialogContainerSelector","_a$dialogPaddingSize","dialogPaddingSize","disabled","loading","_a$kind","kind","_a$color","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","secondaryPositions","SplitButtonSecondaryContentPosition","secondaryDialogPositions","sizes","colors","kinds","inputTags","dialogPaddingSizes"],"mappings":"65CA0EA,IAkOeA,EAAAA,GAlOK,SAACC,GAAA,IACnBC,EAyByBD,EAzBzBC,uBAAsBC,EAyBGF,EAxBzBG,yBAAAA,OAA2BC,IAAHF,EAAGE,EAAIF,EAAAG,EAwBNL,EAvBzBM,yBAAAA,OAA2BF,IAAHC,EAAGD,EAAIC,EAC/BE,EAsByBP,EAtBzBO,+BAA8BC,EAsBLR,EArBzBS,OAAAA,OAAS,IAAHD,EAAG,KAAIA,EAAAE,EAqBYV,EApBzBW,yBAAAA,OAA2B,IAAHD,EAAG,GAAEA,EAAAE,EAoBJZ,EAnBzBa,wBAAAA,OAA0B,IAAHD,EAAG,eAAcA,EACxCE,EAkByBd,EAlBzBc,wBAAuBC,EAkBEf,EAjBzBgB,kBAAAA,OAAoB,IAAHD,EAAG,SAAQA,EAC5BE,EAgByBjB,EAhBzBiB,SAIAC,EAYyBl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/C,GAYuG,CACrGC,mBAAoBC,EACpBC,yBAA0BD,EAC1BE,MAAOrC,EAAOqC,MACdC,OAAQtC,EAAOsC,OACfC,MAAOvC,EAAOuC,MACdC,UAAWxC,EAAOwC,UAClBC,mBAAoBnD,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,OA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rBqB,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,EAA2EhJ,EAAa,CACrGiJ,mBAAoBL,EACpBM,yBAA0BN,EAC1BE,MAAOrC,EAAOqC,MACdK,OAAQ1C,EAAO0C,OACfC,MAAO3C,EAAO2C,MACdC,UAAW5C,EAAO4C,UAClBC,mBAAoBvD,EAAuB+C"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as e}from"../../../_virtual/_tslib.js";import{camelCase as o}from"lodash-es";import{getTestId as i,ComponentDefaultTestId as n}from"../../tests/testIds.js";import r 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,R=j.onClose,U=void 0===R?g:R,q=j.className,G=j.id,J=j.closeButtonAriaLabel,K=void 0===J?"Close":J,Q=j["data-testid"],V=a(null),W=a(null),X=b(null==z?void 0:z.length),Y=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]),Z=l((function(){return void 0!==X&&(null==z?void 0:z.length)!==X}),[z,X]),$=l((function(){return z?z.filter((function(t){return"button"===t.type})).map((function(o,i){var n=o.content,a=e(o,["type","content"]);return s.createElement(T,Object.assign({key:"alert-button-".concat(i),className:r(N.actionButton,t({},N.withTransition,Z))},a),n)})):null}),[z,Z]),tt=l((function(){return r(N.toast,x(N,o("type-"+S)),q)}),[S,q]),et=c((function(){U&&U()}),[U]),ot=a(void 0),it=c((function(t){U&&null!=t&&(clearTimeout(ot.current),ot.current=setTimeout((function(){et()}),t))}),[et,U]);m((function(){return E&&A>0&&it(A),function(){clearTimeout(ot.current)}}),[E,A,it]);var nt=!I&&h(S,_),rt=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&&rt(V.current)}),[F,rt]),s.createElement(u,{in:E,nodeRef:W,classNames:{enterActive:N.enterActive,exitActive:N.exitActive},timeout:400,unmountOnExit:!0},s.createElement(p,{ref:W,id:G,"data-testid":Q||i(n.TOAST,G),type:"text2",element:"div",color:"fixedLight",className:tt,role:"alert","aria-live":"polite"},nt&&s.createElement("div",{className:r(N.icon)},nt),s.createElement(f,{align:"center",gap:"large",className:N.content},s.createElement(f,{gap:"medium","data-testid":i(n.TOAST_CONTENT),className:N.textContent},s.createElement("span",null,F),Y),($||P)&&($||P),L&&s.createElement(d,{size:"xs"})),M&&s.createElement(C,{className:r(N.closeButton),onClick:et,size:"small",kind:"tertiary",color:"fixed-light",ariaLabel:K,"data-testid":i(n.TOAST_CLOSE_BUTTON),icon:k,hideTooltip:!0})))}),{types:j,actionTypes:y});export{B as default};
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
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","sources":["../../../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import { camelCase } from \"lodash-es\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport React, { ReactElement, useCallback, useEffect, useMemo, useRef, type JSX } from \"react\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { IconSubComponentProps } from \"../Icon/Icon\";\nimport Text from \"../Text/Text\";\nimport Loader from \"../Loader/Loader\";\nimport Flex from \"../Flex/Flex\";\nimport { CloseSmall } from \"@vibe/icons\";\nimport ToastLink from \"./ToastLink/ToastLink\";\nimport ToastButton from \"./ToastButton/ToastButton\";\nimport { ToastActionType as ToastActionTypeEnum, ToastType as ToastTypeEnum } from \"./ToastConstants\";\nimport { ToastType, ToastAction } from \"./Toast.types\";\nimport { getIcon } from \"./ToastHelpers\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./Toast.module.scss\";\nimport IconButton from \"../IconButton/IconButton\";\nimport usePrevious from \"../../hooks/usePrevious\";\n\nexport interface ToastProps extends VibeComponentProps {\n /**\n * The actions available in the toast.\n */\n actions?: ToastAction[];\n /**\n * If true, the toast is open (visible).\n */\n open?: boolean;\n /**\n * If true, displays a loading indicator inside the toast.\n */\n loading?: boolean;\n /**\n * The type of toast.\n */\n type?: ToastType;\n /**\n * The icon displayed in the toast.\n */\n icon?: string | React.FC<IconSubComponentProps> | null;\n /**\n * If true, hides the toast icon.\n */\n hideIcon?: boolean;\n /**\n * The action element displayed in the toast.\n */\n action?: JSX.Element;\n /**\n * If false, hides the close button.\n */\n closeable?: boolean;\n /**\n * Callback fired when the toast is closed.\n */\n onClose?: () => void;\n /**\n * The number of milliseconds before the toast automatically closes.\n * (0 or null disables auto-close behavior).\n */\n autoHideDuration?: number;\n /**\n * The content displayed inside the toast.\n */\n children?: ReactElement<any> | ReactElement<any>[] | string;\n /**\n * The aria-label for the close button.\n */\n closeButtonAriaLabel?: string;\n}\n\nconst Toast = ({\n open = false,\n loading = false,\n autoHideDuration = null,\n type = \"normal\",\n icon,\n hideIcon = false,\n action: deprecatedAction,\n actions,\n children,\n closeable = true,\n onClose = NOOP,\n className,\n id,\n closeButtonAriaLabel = \"Close\",\n \"data-testid\": dataTestId\n}: ToastProps) => {\n const ref = useRef(null);\n const nodeRef = useRef<HTMLDivElement>(null);\n const prevActions = usePrevious(actions?.length);\n const toastLinks = useMemo(() => {\n return actions\n ? actions\n .filter(action => action.type === \"link\")\n .map(({ type: _type, ...otherProps }) => (\n <ToastLink key={otherProps.href} className={styles.actionLink} {...otherProps} />\n ))\n : null;\n }, [actions]);\n\n const shouldShowButtonTransition = useMemo(() => {\n return prevActions !== undefined && actions?.length !== prevActions;\n }, [actions, prevActions]);\n\n const toastButtons: JSX.Element[] | null = useMemo(() => {\n return actions\n ? actions\n .filter(action => action.type === \"button\")\n .map(({ type: _type, content, ...otherProps }, index) => (\n <ToastButton\n key={`alert-button-${index}`}\n className={cx(styles.actionButton, { [styles.withTransition]: shouldShowButtonTransition })}\n {...otherProps}\n >\n {content}\n </ToastButton>\n ))\n : null;\n }, [actions, shouldShowButtonTransition]);\n\n const classNames = useMemo(\n () => cx(styles.toast, getStyle(styles, camelCase(\"type-\" + type)), className),\n [type, className]\n );\n\n const handleClose = useCallback(() => {\n if (onClose) {\n onClose();\n }\n }, [onClose]);\n\n /* Timer */\n const timerAutoHide = useRef<NodeJS.Timeout>(undefined);\n const setAutoHideTimer = useCallback(\n (duration: number) => {\n if (!onClose || duration == null) {\n return;\n }\n\n clearTimeout(timerAutoHide.current);\n timerAutoHide.current = setTimeout(() => {\n handleClose();\n }, duration);\n },\n [handleClose, onClose]\n );\n\n useEffect(() => {\n if (open && autoHideDuration > 0) {\n setAutoHideTimer(autoHideDuration);\n }\n\n return () => {\n clearTimeout(timerAutoHide.current);\n };\n }, [open, autoHideDuration, setAutoHideTimer]);\n\n const iconElement = !hideIcon && getIcon(type, icon);\n\n // https://n12v.com/css-transition-to-from-auto/\n const recalculateElementWidth = useCallback((element: HTMLElement) => {\n const prevWidth = element.style.width;\n element.style.width = \"auto\";\n const endWidth = getComputedStyle(element).width;\n element.style.width = prevWidth;\n element.offsetWidth; // force repaint\n element.style.width = endWidth;\n }, []);\n\n useEffect(() => {\n if (ref.current) {\n recalculateElementWidth(ref.current);\n }\n }, [children, recalculateElementWidth]);\n\n return (\n <CSSTransition\n in={open}\n nodeRef={nodeRef}\n classNames={{ enterActive: styles.enterActive, exitActive: styles.exitActive }}\n timeout={400}\n unmountOnExit\n >\n <Text\n ref={nodeRef}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TOAST, id)}\n type=\"text2\"\n element=\"div\"\n color=\"fixedLight\"\n className={classNames}\n role=\"alert\"\n aria-live=\"polite\"\n >\n {iconElement && <div className={cx(styles.icon)}>{iconElement}</div>}\n <Flex align=\"center\" gap=\"large\" className={styles.content}>\n <Flex\n gap=\"medium\"\n data-testid={getTestId(ComponentDefaultTestId.TOAST_CONTENT)}\n className={styles.textContent}\n >\n <span>{children}</span>\n {toastLinks}\n </Flex>\n {(toastButtons || deprecatedAction) && (toastButtons || deprecatedAction)}\n {loading && <Loader size=\"xs\" />}\n </Flex>\n {closeable && (\n <IconButton\n className={cx(styles.closeButton)}\n onClick={handleClose}\n size=\"small\"\n kind=\"tertiary\"\n color=\"fixed-light\"\n ariaLabel={closeButtonAriaLabel}\n data-testid={getTestId(ComponentDefaultTestId.TOAST_CLOSE_BUTTON)}\n icon={CloseSmall}\n hideTooltip\n />\n )}\n </Text>\n </CSSTransition>\n );\n};\n\ninterface ToastStaticProps {\n types: typeof ToastTypeEnum;\n actionTypes: typeof ToastActionTypeEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<ToastProps, ToastStaticProps>(Toast, {\n types: ToastTypeEnum,\n actionTypes: ToastActionTypeEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","_ref$open","open","_ref$loading","loading","_ref$autoHideDuration","autoHideDuration","_ref$type","type","icon","_ref$hideIcon","hideIcon","deprecatedAction","action","actions","children","_ref$closeable","closeable","_ref$onClose","onClose","NOOP","className","id","_ref$closeButtonAriaL","closeButtonAriaLabel","dataTestId","ref","useRef","nodeRef","prevActions","usePrevious","length","toastLinks","useMemo","filter","map","_a","otherProps","__rest","React","createElement","ToastLink","key","href","styles","actionLink","shouldShowButtonTransition","undefined","toastButtons","index","content","ToastButton","Object","assign","concat","cx","actionButton","_defineProperty","withTransition","classNames","toast","getStyle","camelCase","handleClose","useCallback","timerAutoHide","setAutoHideTimer","duration","clearTimeout","current","setTimeout","useEffect","iconElement","getIcon","recalculateElementWidth","element","prevWidth","style","width","endWidth","getComputedStyle","CSSTransition","in","enterActive","exitActive","timeout","unmountOnExit","Text","getTestId","ComponentDefaultTestId","TOAST","color","role","Flex","align","gap","TOAST_CONTENT","textContent","Loader","size","IconButton","closeButton","onClick","kind","ariaLabel","TOAST_CLOSE_BUTTON","CloseSmall","hideTooltip","types","ToastTypeEnum","actionTypes","ToastActionTypeEnum"],"mappings":"4mCA0EA,IAgKeA,EAAAA,GAhKD,SAAHC,GAgBM,IAAAC,EAAAD,EAffE,KAAAA,OAAO,IAAHD,GAAQA,EAAAE,EAAAH,EACZI,QAAAA,OAAU,IAAHD,GAAQA,EAAAE,EAAAL,EACfM,iBAAAA,OAAmB,IAAHD,EAAG,KAAIA,EAAAE,EAAAP,EACvBQ,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EACfE,EAAIT,EAAJS,KAAIC,EAAAV,EACJW,SAAAA,OAAW,IAAHD,GAAQA,EACRE,EAAgBZ,EAAxBa,OACAC,EAAOd,EAAPc,QACAC,EAAQf,EAARe,SAAQC,EAAAhB,EACRiB,UAAAA,OAAY,IAAHD,GAAOA,EAAAE,EAAAlB,EAChBmB,QAAAA,OAAUC,IAAHF,EAAGE,EAAIF,EACdG,EAASrB,EAATqB,UACAC,EAAEtB,EAAFsB,GAAEC,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C,cAAA4D,GACC/E,UAAWkC,EAAGX,EAAOyD,aACrBC,QAASvC,GACToC,KAAK,QACLI,KAAK,WACLZ,MAAM,cACNa,UAAWhF,EACE,cAAAgE,EAAUC,EAAuBgB,oBAC9ChG,KAAMiG,EACNC,kBAMZ,GAOqF,CACnFC,MAAOC,EACPC,YAAaC"}
1
+ {"version":3,"file":"Toast.js","sources":["../../../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import { camelCase } from \"lodash-es\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport React, { ReactElement, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { IconSubComponentProps } from \"../Icon/Icon\";\nimport Text from \"../Text/Text\";\nimport Loader from \"../Loader/Loader\";\nimport Flex from \"../Flex/Flex\";\nimport { CloseSmall } from \"@vibe/icons\";\nimport ToastLink from \"./ToastLink/ToastLink\";\nimport ToastButton from \"./ToastButton/ToastButton\";\nimport { ToastActionType as ToastActionTypeEnum, ToastType as ToastTypeEnum } from \"./ToastConstants\";\nimport { ToastType, ToastAction } from \"./Toast.types\";\nimport { getIcon } from \"./ToastHelpers\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./Toast.module.scss\";\nimport IconButton from \"../IconButton/IconButton\";\nimport usePrevious from \"../../hooks/usePrevious\";\n\nexport interface ToastProps extends VibeComponentProps {\n /**\n * The actions available in the toast.\n */\n actions?: ToastAction[];\n /**\n * If true, the toast is open (visible).\n */\n open?: boolean;\n /**\n * If true, displays a loading indicator inside the toast.\n */\n loading?: boolean;\n /**\n * The type of toast.\n */\n type?: ToastType;\n /**\n * The icon displayed in the toast.\n */\n icon?: string | React.FC<IconSubComponentProps> | null;\n /**\n * If true, hides the toast icon.\n */\n hideIcon?: boolean;\n /**\n * The action element displayed in the toast.\n */\n action?: JSX.Element;\n /**\n * If false, hides the close button.\n */\n closeable?: boolean;\n /**\n * Callback fired when the toast is closed.\n */\n onClose?: () => void;\n /**\n * The number of milliseconds before the toast automatically closes.\n * (0 or null disables auto-close behavior).\n */\n autoHideDuration?: number;\n /**\n * The content displayed inside the toast.\n */\n children?: ReactElement | ReactElement[] | string;\n /**\n * The aria-label for the close button.\n */\n closeButtonAriaLabel?: string;\n}\n\nconst Toast = ({\n open = false,\n loading = false,\n autoHideDuration = null,\n type = \"normal\",\n icon,\n hideIcon = false,\n action: deprecatedAction,\n actions,\n children,\n closeable = true,\n onClose = NOOP,\n className,\n id,\n closeButtonAriaLabel = \"Close\",\n \"data-testid\": dataTestId\n}: ToastProps) => {\n const ref = useRef(null);\n const prevActions = usePrevious(actions?.length);\n const toastLinks = useMemo(() => {\n return actions\n ? actions\n .filter(action => action.type === \"link\")\n .map(({ type: _type, ...otherProps }) => (\n <ToastLink key={otherProps.href} className={styles.actionLink} {...otherProps} />\n ))\n : null;\n }, [actions]);\n\n const shouldShowButtonTransition = useMemo(() => {\n return prevActions !== undefined && actions?.length !== prevActions;\n }, [actions, prevActions]);\n\n const toastButtons: JSX.Element[] | null = useMemo(() => {\n return actions\n ? actions\n .filter(action => action.type === \"button\")\n .map(({ type: _type, content, ...otherProps }, index) => (\n <ToastButton\n key={`alert-button-${index}`}\n className={cx(styles.actionButton, { [styles.withTransition]: shouldShowButtonTransition })}\n {...otherProps}\n >\n {content}\n </ToastButton>\n ))\n : null;\n }, [actions, shouldShowButtonTransition]);\n\n const classNames = useMemo(\n () => cx(styles.toast, getStyle(styles, camelCase(\"type-\" + type)), className),\n [type, className]\n );\n\n const handleClose = useCallback(() => {\n if (onClose) {\n onClose();\n }\n }, [onClose]);\n\n /* Timer */\n const timerAutoHide = useRef<NodeJS.Timeout>();\n const setAutoHideTimer = useCallback(\n (duration: number) => {\n if (!onClose || duration == null) {\n return;\n }\n\n clearTimeout(timerAutoHide.current);\n timerAutoHide.current = setTimeout(() => {\n handleClose();\n }, duration);\n },\n [handleClose, onClose]\n );\n\n useEffect(() => {\n if (open && autoHideDuration > 0) {\n setAutoHideTimer(autoHideDuration);\n }\n\n return () => {\n clearTimeout(timerAutoHide.current);\n };\n }, [open, autoHideDuration, setAutoHideTimer]);\n\n const iconElement = !hideIcon && getIcon(type, icon);\n\n // https://n12v.com/css-transition-to-from-auto/\n const recalculateElementWidth = useCallback((element: HTMLElement) => {\n const prevWidth = element.style.width;\n element.style.width = \"auto\";\n const endWidth = getComputedStyle(element).width;\n element.style.width = prevWidth;\n element.offsetWidth; // force repaint\n element.style.width = endWidth;\n }, []);\n\n useEffect(() => {\n if (ref.current) {\n recalculateElementWidth(ref.current);\n }\n }, [children, recalculateElementWidth]);\n\n return (\n <CSSTransition\n in={open}\n classNames={{ enterActive: styles.enterActive, exitActive: styles.exitActive }}\n timeout={400}\n unmountOnExit\n >\n <Text\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TOAST, id)}\n type=\"text2\"\n element=\"div\"\n color=\"fixedLight\"\n className={classNames}\n role=\"alert\"\n aria-live=\"polite\"\n ref={ref}\n >\n {iconElement && <div className={cx(styles.icon)}>{iconElement}</div>}\n <Flex align=\"center\" gap=\"large\" className={styles.content}>\n <Flex\n gap=\"medium\"\n data-testid={getTestId(ComponentDefaultTestId.TOAST_CONTENT)}\n className={styles.textContent}\n >\n <span>{children}</span>\n {toastLinks}\n </Flex>\n {(toastButtons || deprecatedAction) && (toastButtons || deprecatedAction)}\n {loading && <Loader size=\"xs\" />}\n </Flex>\n {closeable && (\n <IconButton\n className={cx(styles.closeButton)}\n onClick={handleClose}\n size=\"small\"\n kind=\"tertiary\"\n color=\"fixed-light\"\n ariaLabel={closeButtonAriaLabel}\n data-testid={getTestId(ComponentDefaultTestId.TOAST_CLOSE_BUTTON)}\n icon={CloseSmall}\n hideTooltip\n />\n )}\n </Text>\n </CSSTransition>\n );\n};\n\ninterface ToastStaticProps {\n types: typeof ToastTypeEnum;\n actionTypes: typeof ToastActionTypeEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<ToastProps, ToastStaticProps>(Toast, {\n types: ToastTypeEnum,\n actionTypes: ToastActionTypeEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","_ref$open","open","_ref$loading","loading","_ref$autoHideDuration","autoHideDuration","_ref$type","type","icon","_ref$hideIcon","hideIcon","deprecatedAction","action","actions","children","_ref$closeable","closeable","_ref$onClose","onClose","NOOP","className","id","_ref$closeButtonAriaL","closeButtonAriaLabel","dataTestId","ref","useRef","prevActions","usePrevious","length","toastLinks","useMemo","filter","map","_a","otherProps","__rest","React","createElement","ToastLink","key","href","styles","actionLink","shouldShowButtonTransition","undefined","toastButtons","index","content","ToastButton","Object","assign","concat","cx","actionButton","_defineProperty","withTransition","classNames","toast","getStyle","camelCase","handleClose","useCallback","timerAutoHide","setAutoHideTimer","duration","clearTimeout","current","setTimeout","useEffect","iconElement","getIcon","recalculateElementWidth","element","prevWidth","style","width","endWidth","getComputedStyle","CSSTransition","in","enterActive","exitActive","timeout","unmountOnExit","Text","getTestId","ComponentDefaultTestId","TOAST","color","role","Flex","align","gap","TOAST_CONTENT","textContent","Loader","size","IconButton","closeButton","onClick","kind","ariaLabel","TOAST_CLOSE_BUTTON","CloseSmall","hideTooltip","types","ToastTypeEnum","actionTypes","ToastActionTypeEnum"],"mappings":"4mCA0EA,IA8JeA,EAAAA,GA9JD,SAAHC,GAgBM,IAAAC,EAAAD,EAffE,KAAAA,OAAO,IAAHD,GAAQA,EAAAE,EAAAH,EACZI,QAAAA,OAAU,IAAHD,GAAQA,EAAAE,EAAAL,EACfM,iBAAAA,OAAmB,IAAHD,EAAG,KAAIA,EAAAE,EAAAP,EACvBQ,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EACfE,EAAIT,EAAJS,KAAIC,EAAAV,EACJW,SAAAA,OAAW,IAAHD,GAAQA,EACRE,EAAgBZ,EAAxBa,OACAC,EAAOd,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AOqD,aAElB1D,EAAAC,cAAA,OAAA,KAAOxB,GACNgB,IAEDgB,GAAgBnC,KAAsBmC,GAAgBnC,GACvDR,GAAWkC,gBAAC2D,EAAM,CAACC,KAAK,QAE1BjF,GACCqB,EAACC,cAAA4D,GACC9E,UAAWiC,EAAGX,EAAOyD,aACrBC,QAASvC,GACToC,KAAK,QACLI,KAAK,WACLZ,MAAM,cACNa,UAAW/E,EACE,cAAA+D,EAAUC,EAAuBgB,oBAC9C/F,KAAMgG,EACNC,kBAMZ,GAOqF,CACnFC,MAAOC,EACPC,YAAaC"}
@@ -1,2 +1,2 @@
1
- import{__rest as t}from"../../../../_virtual/_tslib.js";import s from"../../Button/Button.js";import a from"react";import{ComponentDefaultTestId as e}from"../../../tests/constants.js";import{getTestId as r}from"../../../tests/testIds.js";var i=function(i){var o=i.className,m=i.id,d=i["data-testid"],n=t(i,["className","id","data-testid"]);return a.createElement(s,Object.assign({},n,{id:m,kind:"secondary",marginLeft:!1,"data-testid":d||r(e.TOAST_BUTTON,m),className:o,size:"small",color:"fixed-light"}))};export{i as default};
1
+ import{__rest as t}from"../../../../_virtual/_tslib.js";import s from"../../Button/Button.js";import a from"react";import{ComponentDefaultTestId as e}from"../../../tests/constants.js";import{getTestId as i}from"../../../tests/testIds.js";var r=function(r){var o=r.className,m=r.id,d=r["data-testid"],n=t(r,["className","id","data-testid"]),c=Object.assign(Object.assign(Object.assign({},s.defaultProps),{kind:"secondary",marginLeft:!1}),n);return a.createElement(s,Object.assign({},c,{id:m,"data-testid":d||i(e.TOAST_BUTTON,m),className:o,size:"small",color:"fixed-light"}))};export{r as default};
2
2
  //# sourceMappingURL=ToastButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastButton.js","sources":["../../../../../../src/components/Toast/ToastButton/ToastButton.tsx"],"sourcesContent":["import Button, { ButtonProps } from \"../../Button/Button\";\nimport React, { FC } from \"react\";\nimport { ComponentDefaultTestId } from \"../../../tests/constants\";\nimport { getTestId } from \"../../../tests/test-ids-utils\";\n\nexport type ToastButtonProps = ButtonProps;\n\nconst ToastButton: FC<ToastButtonProps> = ({\n className,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}: ToastButtonProps) => {\n return (\n <Button\n {...buttonProps}\n id={id}\n kind=\"secondary\"\n marginLeft={false}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TOAST_BUTTON, id)}\n className={className}\n size=\"small\"\n color=\"fixed-light\"\n />\n );\n};\n\nexport default ToastButton;\n"],"names":["ToastButton","_a","className","id","dataTestId","buttonProps","__rest","React","createElement","Button","kind","marginLeft","getTestId","ComponentDefaultTestId","TOAST_BUTTON","size","color"],"mappings":"8OAOA,IAAMA,EAAoC,SAACC,GAAA,IACzCC,EAEyBD,EAFzBC,UACAC,EACyBF,EADzBE,GACeC,EAAUH,EAAzB,eACGI,EAJsCC,EAAAL,EAAA,CAAA,YAAA,KAAA,gBAMzC,OACEM,EAACC,cAAAC,mBACKJ,EAAW,CACfF,GAAIA,EACJO,KAAK,YACLC,YAAY,EAAK,cACJP,GAAcQ,EAAUC,EAAuBC,aAAcX,GAC1ED,UAAWA,EACXa,KAAK,QACLC,MAAM,gBAGZ"}
1
+ {"version":3,"file":"ToastButton.js","sources":["../../../../../../src/components/Toast/ToastButton/ToastButton.tsx"],"sourcesContent":["import Button, { ButtonProps } from \"../../Button/Button\";\nimport React, { FC } from \"react\";\nimport { ComponentDefaultTestId } from \"../../../tests/constants\";\nimport { getTestId } from \"../../../tests/test-ids-utils\";\nimport { ButtonType } from \"../../Button\";\n\nexport type ToastButtonProps = ButtonProps;\n\nconst ToastButton: FC<ToastButtonProps> = ({\n className,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}: ToastButtonProps) => {\n const overrideButtonProps = {\n ...Button.defaultProps,\n kind: \"secondary\" as ButtonType,\n marginLeft: false,\n ...buttonProps\n };\n\n return (\n <Button\n {...overrideButtonProps}\n id={id}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.TOAST_BUTTON, id)}\n className={className}\n size=\"small\"\n color=\"fixed-light\"\n />\n );\n};\n\nexport default ToastButton;\n"],"names":["ToastButton","_a","className","id","dataTestId","buttonProps","__rest","overrideButtonProps","Object","assign","Button","defaultProps","kind","marginLeft","React","createElement","getTestId","ComponentDefaultTestId","TOAST_BUTTON","size","color"],"mappings":"8OAQA,IAAMA,EAAoC,SAACC,GAAA,IACzCC,EAEyBD,EAFzBC,UACAC,EACyBF,EADzBE,GACeC,EAAUH,EAAzB,eACGI,EAJsCC,EAAAL,EAAA,CAAA,YAAA,KAAA,gBAMnCM,EACDC,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAC,EAAOC,eACVC,KAAM,YACNC,YAAY,IACTR,GAGL,OACES,EAAAC,cAACL,EAAMF,OAAAC,OAAA,CAAA,EACDF,EACJ,CAAAJ,GAAIA,gBACSC,GAAcY,EAAUC,EAAuBC,aAAcf,GAC1ED,UAAWA,EACXiB,KAAK,QACLC,MAAM,gBAGZ"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as r}from"../../../../_virtual/_tslib.js";import{getTestId as a,ComponentDefaultTestId as e}from"../../../tests/testIds.js";import s from"classnames";import o from"../../Button/Button.js";import i from"react";import n from"./AlertBannerButton.module.scss.js";var m=function(m){var l=m.marginLeft,d=void 0!==l&&l,c=m.isDarkBackground,u=void 0!==c&&c,f=m.id,p=m["data-testid"],B=r(m,["marginLeft","isDarkBackground","id","data-testid"]),g=s(t(t({},n.marginLeft,d),n.darkBackground,u));return i.createElement("div",{className:g,"data-testid":p||a(e.ALERT_BANNER_BUTTON,f),id:f},i.createElement(o,Object.assign({},B,{size:"small",className:s(n.bannerButton),color:"on-primary-color"})))};Object.assign(m,{isAlertBannerItem:!0});export{m as default};
1
+ import{defineProperty as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as r}from"../../../../_virtual/_tslib.js";import{getTestId as a,ComponentDefaultTestId as e}from"../../../tests/testIds.js";import s from"classnames";import i from"../../Button/Button.js";import o from"react";import n from"./AlertBannerButton.module.scss.js";var m=function(m){var l=m.marginLeft,d=void 0!==l&&l,c=m.isDarkBackground,u=void 0!==c&&c,f=m.id,p=m["data-testid"],B=r(m,["marginLeft","isDarkBackground","id","data-testid"]),g=Object.assign(Object.assign({},i.defaultProps),B),j=s(t(t({},n.marginLeft,d),n.darkBackground,u));return o.createElement("div",{className:j,"data-testid":p||a(e.ALERT_BANNER_BUTTON,f),id:f},o.createElement(i,Object.assign({},g,{size:"small",className:s(n.bannerButton),color:"on-primary-color"})))};Object.assign(m,{isAlertBannerItem:!0});export{m as default};
2
2
  //# sourceMappingURL=AlertBannerButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AlertBannerButton.js","sources":["../../../../../src/components/AlertBanner/AlertBannerButton/AlertBannerButton.tsx"],"sourcesContent":["import { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport Button, { ButtonProps } from \"../../Button/Button\";\nimport React, { FC } from \"react\";\nimport styles from \"./AlertBannerButton.module.scss\";\n\nexport interface AlertBannerButtonProps extends ButtonProps {\n /**\n * If true, the button is displayed on a dark background.\n */\n isDarkBackground?: boolean;\n}\n\nconst AlertBannerButton: FC<AlertBannerButtonProps> = ({\n marginLeft = false,\n isDarkBackground = false,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}) => {\n const classNames = cx({\n [styles.marginLeft]: marginLeft,\n [styles.darkBackground]: isDarkBackground\n });\n\n return (\n <div\n className={classNames}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.ALERT_BANNER_BUTTON, id)}\n id={id}\n >\n <Button {...buttonProps} size=\"small\" className={cx(styles.bannerButton)} color=\"on-primary-color\" />\n </div>\n );\n};\n\nObject.assign(AlertBannerButton, {\n isAlertBannerItem: true\n});\n\nexport default AlertBannerButton;\n"],"names":["AlertBannerButton","_a","_a$marginLeft","marginLeft","_a$isDarkBackground","isDarkBackground","id","dataTestId","buttonProps","__rest","classNames","cx","_defineProperty","styles","darkBackground","React","createElement","className","getTestId","ComponentDefaultTestId","ALERT_BANNER_BUTTON","Button","size","bannerButton","color","Object","assign","isAlertBannerItem"],"mappings":"oWAaA,IAAMA,EAAgD,SAACC,GAAA,IAAAC,EAI5BD,EAHzBE,WAAAA,OAAa,IAAHD,GAAQA,EAAAE,EAGOH,EAFzBI,iBAAAA,OAAmB,IAAHD,GAAQA,EACxBE,EACyBL,EADzBK,GACeC,EAAUN,EAAzB,eACGO,EAAWC,EAAAR,EALuC,sDAO/CS,EAAaC,EAAEC,EAAAA,KAClBC,EAAOV,WAAaA,GACpBU,EAAOC,eAAiBT,IAG3B,OACEU,EACEC,cAAA,MAAA,CAAAC,UAAWP,EAAU,cACRH,GAAcW,EAAUC,EAAuBC,oBAAqBd,GACjFA,GAAIA,GAEJS,EAACC,cAAAK,mBAAWb,EAAW,CAAEc,KAAK,QAAQL,UAAWN,EAAGE,EAAOU,cAAeC,MAAM,sBAGtF,EAEAC,OAAOC,OAAO1B,EAAmB,CAC/B2B,mBAAmB"}
1
+ {"version":3,"file":"AlertBannerButton.js","sources":["../../../../../src/components/AlertBanner/AlertBannerButton/AlertBannerButton.tsx"],"sourcesContent":["import { ComponentDefaultTestId, getTestId } from \"../../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport Button, { ButtonProps } from \"../../Button/Button\";\nimport React, { FC } from \"react\";\nimport styles from \"./AlertBannerButton.module.scss\";\n\nexport interface AlertBannerButtonProps extends ButtonProps {\n /**\n * If true, the button is displayed on a dark background.\n */\n isDarkBackground?: boolean;\n}\n\nconst AlertBannerButton: FC<AlertBannerButtonProps> = ({\n marginLeft = false,\n isDarkBackground = false,\n id,\n \"data-testid\": dataTestId,\n ...buttonProps\n}) => {\n const overrideButtonProps = { ...Button.defaultProps, ...buttonProps };\n\n const classNames = cx({\n [styles.marginLeft]: marginLeft,\n [styles.darkBackground]: isDarkBackground\n });\n\n return (\n <div\n className={classNames}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.ALERT_BANNER_BUTTON, id)}\n id={id}\n >\n <Button {...overrideButtonProps} size=\"small\" className={cx(styles.bannerButton)} color=\"on-primary-color\" />\n </div>\n );\n};\n\nObject.assign(AlertBannerButton, {\n isAlertBannerItem: true\n});\n\nexport default AlertBannerButton;\n"],"names":["AlertBannerButton","_a","_a$marginLeft","marginLeft","_a$isDarkBackground","isDarkBackground","id","dataTestId","buttonProps","__rest","overrideButtonProps","Button","defaultProps","classNames","cx","_defineProperty","styles","darkBackground","React","createElement","className","getTestId","ComponentDefaultTestId","ALERT_BANNER_BUTTON","size","bannerButton","color","Object","assign","isAlertBannerItem"],"mappings":"oWAaA,IAAMA,EAAgD,SAACC,GAAA,IAAAC,EAI5BD,EAHzBE,WAAAA,OAAa,IAAHD,GAAQA,EAAAE,EAGOH,EAFzBI,iBAAAA,OAAmB,IAAHD,GAAQA,EACxBE,EACyBL,EADzBK,GACeC,EAAUN,EAAzB,eACGO,EAAWC,EAAAR,EALuC,sDAO/CS,iCAA2BC,EAAOC,cAAiBJ,GAEnDK,EAAaC,EAAEC,EAAAA,KAClBC,EAAOb,WAAaA,GACpBa,EAAOC,eAAiBZ,IAG3B,OACEa,EACEC,cAAA,MAAA,CAAAC,UAAWP,EAAU,cACRN,GAAcc,EAAUC,EAAuBC,oBAAqBjB,GACjFA,GAAIA,GAEJY,EAACC,cAAAR,mBAAWD,EAAmB,CAAEc,KAAK,QAAQJ,UAAWN,EAAGE,EAAOS,cAAeC,MAAM,sBAG9F,EAEAC,OAAOC,OAAO5B,EAAmB,CAC/B6B,mBAAmB"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o,{forwardRef as t,useRef as i,useEffect as a,useCallback as r,useMemo as n}from"react";import{camelCase as s}from"lodash-es";import l from"classnames";import{SIZES as c}from"../../constants/sizes.js";import d from"../../hooks/useMergeRef.js";import{NOOP as u}from"../../utils/function-utils.js";import m from"../Icon/Icon.js";import p from"../Loader/Loader.js";import{ButtonColor as f,ButtonType as v,ButtonInputType as y,BUTTON_ICON_SIZE as g,SMALL_BUTTON_ICON_SIZE as b}from"./ButtonConstants.js";import{getParentBackgroundColorNotTransparent as h,TRANSPARENT_COLOR as j}from"./helper/dom-helpers.js";import{getTestId as N}from"../../tests/testIds.js";import{withStaticProps as x}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{getStyle as C}from"../../helpers/typesciptCssModulesHelper.js";import{ComponentDefaultTestId as E,ComponentVibeId as F}from"../../tests/constants.js";import k from"./Button.module.scss.js";import{useButtonLoading as B}from"./helper/useButtonLoading.js";var I=x(t((function(t,c){var f=t.className,v=t.children,y=t.kind,x=void 0===y?"primary":y,I=t.onClick,S=void 0===I?u:I,T=t.name,P=t.size,L=void 0===P?"medium":P,z=t.color,O=void 0===z?"primary":z,M=t.disabled,w=void 0!==M&&M,D=t.rightIcon,U=void 0===D?null:D,A=t.leftIcon,H=void 0===A?null:A,R=t.success,_=void 0!==R&&R,q=t.successText,G=void 0===q?"":q,J=t.successIcon,K=void 0===J?null:J,Q=t.style,V=t.loading,W=void 0!==V&&V,X=t.loaderClassName,Y=t.active,Z=void 0!==Y&&Y,$=t.activeButtonClassName,ee=t.id,oe=t.marginRight,te=void 0!==oe&&oe,ie=t.marginLeft,ae=void 0!==ie&&ie,re=t.type,ne=void 0===re?"button":re,se=t.onMouseDown,le=void 0===se?u:se,ce=t.ariaLabel,de=t.rightFlat,ue=void 0!==de&&de,me=t.leftFlat,pe=void 0!==me&&me,fe=t.preventClickAnimation,ve=void 0!==fe&&fe,ye=t.noSidePadding,ge=void 0!==ye&&ye,be=t.onFocus,he=void 0===be?u:be,je=t.onBlur,Ne=void 0===je?u:je,xe=t.ariaLabeledBy,Ce=t.defaultTextColorOnPrimaryColor,Ee=void 0===Ce?j:Ce,Fe=t.ariaHasPopup,ke=t.ariaExpanded,Be=t.ariaControls,Ie=t["aria-describedby"],Se=t["aria-hidden"],Te=t["aria-pressed"],Pe=t.blurOnMouseUp,Le=void 0===Pe||Pe,ze=t["data-testid"],Oe=t.insetFocus,Me=void 0!==Oe&&Oe,we=t.tabIndex,De=i(null),Ue=d(c,De),Ae=B({isLoading:W}).loading;a((function(){if(("on-primary-color"===O||"fixed-light"===O)&&"primary"===x&&De.current){var e=De.current;e.style.color=h(e,Ee)}}),[x,De,O,Ee]);var He=r((function(){var e=De.current;!w&&e&&Le&&e.blur()}),[w,De,Le]),Re=r((function(e){w||Ae||_?e.preventDefault():S&&S(e)}),[S,w,Ae,_]),_e=r((function(e){w||Ae||_?e.preventDefault():le&&le(e)}),[le,w,Ae,_]),qe=n((function(){var o,t=_?"positive":O;return l(f,k.button,C(k,s("size-"+L)),C(k,s("kind-"+x)),C(k,s("color-"+t)),(e(e(e(e(e(e(e(e(e(e(o={},k.success,_),C(k,s("color-"+t+"-active")),Z),$,Z),k.marginRight,te),k.marginLeft,ae),k.rightFlat,ue),k.leftFlat,pe),k.preventClickAnimation,ve),k.noSidePadding,ge),k.disabled,w),e(o,k.insetFocusStyle,Me)))}),[_,O,f,L,x,Z,$,te,ae,ue,pe,ve,ge,w,Me]),Ge=n((function(){return{ref:Ue,type:ne,className:qe,name:T,onMouseUp:He,style:Q,onClick:Re,id:ee,onFocus:he,onBlur:Ne,tabIndex:w||Se?-1:we,"data-testid":ze||N(E.BUTTON,ee),"data-vibe":F.BUTTON,onMouseDown:_e,"aria-disabled":w,"aria-busy":Ae,"aria-labelledby":xe,"aria-label":ce,"aria-haspopup":Fe,"aria-expanded":ke,"aria-controls":Be,"aria-describedby":Ie,"aria-hidden":Se,"aria-pressed":Te}}),[Ue,ne,qe,T,He,Q,Re,ee,he,Ne,we,ze,_e,w,Ae,xe,ce,Fe,ke,Be,Ie,Se,Te]),Je=r((function(e){if("function"==typeof e)switch(L){case"xxs":case"xs":return b;default:return g}}),[L]),Ke=n((function(){return o.Children.toArray(v).some(Boolean)}),[v]),Qe=n((function(){return o.createElement(o.Fragment,null,H?o.createElement(m,{iconType:"font",icon:H,iconSize:Je(H),className:l(e({},k.leftIcon,Ke)),ignoreFocusStyle:!0}):null,v,U?o.createElement(m,{iconType:"font",icon:U,iconSize:Je(U),className:l(e({},k.rightIcon,Ke)),ignoreFocusStyle:!0}):null)}),[v,Ke,Je,H,U]);return Ae?o.createElement("button",Object.assign({},Ge,{key:"".concat(ee,"-loading")}),o.createElement("span",{className:l(k.loader,X)},o.createElement(p,{className:k.loaderSvg}),o.createElement("span",{"aria-hidden":!0,className:k.textPlaceholder},Qe))):_?o.createElement("button",Object.assign({},Ge,{key:"".concat(ee,"-success")}),o.createElement("span",{className:k.successContent},K?o.createElement(m,{iconType:"font",icon:K,iconSize:Je(K),className:l(e({},k.leftIcon,!!G)),ignoreFocusStyle:!0}):null,G),o.createElement("span",{"aria-hidden":"true",className:k.textPlaceholder},Qe)):o.createElement("button",Object.assign({},Ge,{key:"".concat(ee,"-button")}),Qe)})),{sizes:c,colors:f,kinds:v,types:y,inputTags:y});export{I as default};
1
+ import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import t,{forwardRef as a,useRef as o,useEffect as n,useCallback as r,useMemo as i}from"react";import{camelCase as s}from"lodash-es";import l from"classnames";import{SIZES as c}from"../../constants/sizes.js";import u from"../../hooks/useMergeRef.js";import{NOOP as d}from"../../utils/function-utils.js";import m from"../Icon/Icon.js";import p from"../Loader/Loader.js";import{BUTTON_ICON_SIZE as f,SMALL_BUTTON_ICON_SIZE as g,ButtonColor as y,ButtonType as b,ButtonInputType as v}from"./ButtonConstants.js";import{TRANSPARENT_COLOR as h,getParentBackgroundColorNotTransparent as C}from"./helper/dom-helpers.js";import{getTestId as j}from"../../tests/testIds.js";import{withStaticProps as x}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{getStyle as F}from"../../helpers/typesciptCssModulesHelper.js";import{ComponentDefaultTestId as N,ComponentVibeId as k}from"../../tests/constants.js";import E from"./Button.module.scss.js";import{useButtonLoading as I}from"./helper/useButtonLoading.js";var B=a((function(a,c){var d=a.className,y=a.children,b=a.kind,v=a.onClick,h=a.name,x=a.size,B=a.color,P=a.disabled,S=a.rightIcon,T=a.leftIcon,L=a.success,O=a.successText,z=a.successIcon,M=a.style,w=a.loading,D=a.loaderClassName,U=a.active,A=a.activeButtonClassName,H=a.id,R=a.marginRight,_=a.marginLeft,q=a.type,G=a.onMouseDown,J=a.ariaLabel,K=a.rightFlat,Q=a.leftFlat,V=a.preventClickAnimation,W=a.noSidePadding,X=a.onFocus,Y=a.onBlur,Z=a.ariaLabeledBy,$=a.defaultTextColorOnPrimaryColor,ee=a.ariaHasPopup,te=a.ariaExpanded,ae=a.ariaControls,oe=a["aria-describedby"],ne=a["aria-hidden"],re=a["aria-pressed"],ie=a.blurOnMouseUp,se=a["data-testid"],le=a.insetFocus,ce=a.tabIndex,ue=o(null),de=u(c,ue),me=I({isLoading:w}).loading;n((function(){if(("on-primary-color"===B||"fixed-light"===B)&&"primary"===b&&ue.current){var e=ue.current;e.style.color=C(e,$)}}),[b,ue,B,$]);var pe=r((function(){var e=ue.current;!P&&e&&ie&&e.blur()}),[P,ue,ie]),fe=r((function(e){P||me||L?e.preventDefault():v&&v(e)}),[v,P,me,L]),ge=r((function(e){P||me||L?e.preventDefault():G&&G(e)}),[G,P,me,L]),ye=i((function(){var t,a=L?"positive":B;return l(d,E.button,F(E,s("size-"+x)),F(E,s("kind-"+b)),F(E,s("color-"+a)),(e(e(e(e(e(e(e(e(e(e(t={},E.success,L),F(E,s("color-"+a+"-active")),U),A,U),E.marginRight,R),E.marginLeft,_),E.rightFlat,K),E.leftFlat,Q),E.preventClickAnimation,V),E.noSidePadding,W),E.disabled,P),e(t,E.insetFocusStyle,le)))}),[L,B,d,x,b,U,A,R,_,K,Q,V,W,P,le]),be=i((function(){return{ref:de,type:q,className:ye,name:h,onMouseUp:pe,style:M,onClick:fe,id:H,onFocus:X,onBlur:Y,tabIndex:P||ne?-1:ce,"data-testid":se||j(N.BUTTON,H),"data-vibe":k.BUTTON,onMouseDown:ge,"aria-disabled":P,"aria-busy":me,"aria-labelledby":Z,"aria-label":J,"aria-haspopup":ee,"aria-expanded":te,"aria-controls":ae,"aria-describedby":oe,"aria-hidden":ne,"aria-pressed":re}}),[de,q,ye,h,pe,M,fe,H,X,Y,ce,se,ge,P,me,Z,J,ee,te,ae,oe,ne,re]),ve=r((function(e){if("function"==typeof e)switch(x){case"xxs":case"xs":return g;default:return f}}),[x]),he=i((function(){return t.Children.toArray(y).some(Boolean)}),[y]),Ce=i((function(){return t.createElement(t.Fragment,null,T?t.createElement(m,{iconType:"font",icon:T,iconSize:ve(T),className:l(e({},E.leftIcon,he)),ignoreFocusStyle:!0}):null,y,S?t.createElement(m,{iconType:"font",icon:S,iconSize:ve(S),className:l(e({},E.rightIcon,he)),ignoreFocusStyle:!0}):null)}),[y,he,ve,T,S]);return me?t.createElement("button",Object.assign({},be,{key:"".concat(H,"-loading")}),t.createElement("span",{className:l(E.loader,D)},t.createElement(p,{className:E.loaderSvg}),t.createElement("span",{"aria-hidden":!0,className:E.textPlaceholder},Ce))):L?t.createElement("button",Object.assign({},be,{key:"".concat(H,"-success")}),t.createElement("span",{className:E.successContent},z?t.createElement(m,{iconType:"font",icon:z,iconSize:ve(z),className:l(e({},E.leftIcon,!!O)),ignoreFocusStyle:!0}):null,O),t.createElement("span",{"aria-hidden":"true",className:E.textPlaceholder},Ce)):t.createElement("button",Object.assign({},be,{key:"".concat(H,"-button")}),Ce)}));B.defaultProps={name:void 0,style:void 0,kind:"primary",onClick:d,size:"medium",color:"primary",disabled:!1,rightIcon:null,leftIcon:null,success:!1,successText:"",successIcon:null,loading:!1,loaderClassName:void 0,active:!1,marginRight:!1,marginLeft:!1,type:"button",onMouseDown:d,rightFlat:!1,leftFlat:!1,preventClickAnimation:!1,noSidePadding:!1,onFocus:d,onBlur:d,defaultTextColorOnPrimaryColor:h,ariaHasPopup:void 0,blurOnMouseUp:!0,ariaExpanded:void 0,ariaControls:void 0,ariaLabel:void 0,ariaLabeledBy:void 0,insetFocus:!1};var P=x(B,{sizes:c,colors:y,kinds:b,types:v,inputTags:v});export{P as default};
2
2
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable react/button-has-type */\nimport React, { AriaAttributes, forwardRef, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { camelCase } from \"lodash-es\";\nimport cx from \"classnames\";\nimport { SIZES } from \"../../constants\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport Icon from \"../../components/Icon/Icon\";\nimport Loader from \"../../components/Loader/Loader\";\nimport {\n BUTTON_ICON_SIZE,\n ButtonColor as ButtonColorEnum,\n ButtonInputType as ButtonInputTypeEnum,\n ButtonType as ButtonTypeEnum,\n SMALL_BUTTON_ICON_SIZE\n} from \"./ButtonConstants\";\nimport { ButtonColor, ButtonInputType, ButtonType, ButtonSize } from \"./Button.types\";\nimport { getParentBackgroundColorNotTransparent, TRANSPARENT_COLOR } from \"./helper/dom-helpers\";\nimport { getTestId } from \"../../tests/test-ids-utils\";\nimport { SubIcon, VibeComponentProps, withStaticProps } from \"../../types\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, ComponentVibeId } from \"../../tests/constants\";\nimport styles from \"./Button.module.scss\";\nimport { useButtonLoading } from \"./helper/useButtonLoading\";\n\nexport interface ButtonProps extends VibeComponentProps {\n children: React.ReactNode;\n /** Custom class names to pass to the component */\n className?: string;\n activeButtonClassName?: string;\n /** The button's kind */\n kind?: ButtonType;\n /** Callback function to run when the button is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Blur on button click */\n blurOnMouseUp?: boolean;\n /** Name of the button - for form submit usages */\n name?: string;\n /** The button's size */\n size?: ButtonSize;\n /** The button's color */\n color?: ButtonColor;\n /** The button's type */\n type?: ButtonInputType;\n /** Whether the button should be disabled or not */\n disabled?: boolean;\n /** Icon to place on the right */\n rightIcon?: SubIcon;\n /** Icon to place on the left */\n leftIcon?: SubIcon;\n /** the success props are used when you have async action and wants to display a success message */\n success?: boolean;\n /** Success icon name */\n successIcon?: SubIcon;\n /** Success text */\n successText?: string;\n /** loading boolean which switches the text to a loader */\n loading?: boolean;\n /** className which is applied to loader container **/\n loaderClassName?: string;\n style?: React.CSSProperties;\n /** displays the active state */\n active?: boolean;\n /** id to pass to the button */\n id?: string;\n /** adds 8px margin to the right */\n marginRight?: boolean;\n /** adds 8px margin to the left */\n marginLeft?: boolean;\n /** element id to describe the button accordingly */\n ariaLabeledBy?: string;\n /** aria label to provide important when providing only Icon */\n ariaLabel?: string;\n /** aria for a button popup */\n ariaHasPopup?: React.HTMLProps<HTMLButtonElement>[\"aria-haspopup\"];\n /** aria to be set if the popup is open */\n ariaExpanded?: boolean;\n /** aria controls - receives id for the controlled region */\n ariaControls?: string;\n \"aria-describedby\"?: AriaAttributes[\"aria-describedby\"];\n /**\n * aria to be used for screen reader to know if the button is hidden\n */\n \"aria-hidden\"?: AriaAttributes[\"aria-hidden\"];\n /**\n * Indicates the current \"pressed\" state of toggle buttons\n */\n \"aria-pressed\"?: AriaAttributes[\"aria-pressed\"];\n /** On Button Focus callback */\n onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;\n /** On Button Blur callback */\n onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;\n rightFlat?: boolean;\n leftFlat?: boolean;\n preventClickAnimation?: boolean;\n noSidePadding?: boolean;\n /** default color for text color in ON_PRIMARY_COLOR kind (should be any type of css color (rbg, var, hex...) */\n defaultTextColorOnPrimaryColor?: string;\n \"data-testid\"?: string;\n /** Change the focus indicator from around the button to within it */\n insetFocus?: boolean;\n /** Specifies the tab order of an element */\n tabIndex?: number;\n}\n\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n children,\n kind = \"primary\",\n onClick = NOOP,\n name,\n size = \"medium\",\n color = \"primary\",\n disabled = false,\n rightIcon = null,\n leftIcon = null,\n success = false,\n successText = \"\",\n successIcon = null,\n style,\n loading: isLoading = false,\n loaderClassName,\n active = false,\n activeButtonClassName,\n id,\n marginRight = false,\n marginLeft = false,\n type = \"button\",\n onMouseDown = NOOP,\n ariaLabel,\n rightFlat = false,\n leftFlat = false,\n preventClickAnimation = false,\n noSidePadding = false,\n onFocus = NOOP,\n onBlur = NOOP,\n ariaLabeledBy,\n defaultTextColorOnPrimaryColor = TRANSPARENT_COLOR,\n ariaHasPopup,\n ariaExpanded,\n ariaControls,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-hidden\": ariaHidden,\n \"aria-pressed\": ariaPressed,\n blurOnMouseUp = true,\n \"data-testid\": dataTestId,\n insetFocus = false,\n tabIndex\n }: ButtonProps,\n ref\n ) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const mergedRef = useMergeRef(ref, buttonRef);\n\n const { loading } = useButtonLoading({ isLoading });\n\n useEffect(() => {\n if (color !== \"on-primary-color\" && color !== \"fixed-light\") return;\n if (kind !== \"primary\") return;\n if (!buttonRef.current) return;\n\n const buttonElement = buttonRef.current;\n buttonElement.style.color = getParentBackgroundColorNotTransparent(buttonElement, defaultTextColorOnPrimaryColor);\n }, [kind, buttonRef, color, defaultTextColorOnPrimaryColor]);\n\n const onMouseUp = useCallback(() => {\n const button = buttonRef.current;\n if (disabled || !button) {\n return;\n }\n if (blurOnMouseUp) {\n button.blur();\n }\n }, [disabled, buttonRef, blurOnMouseUp]);\n\n const onButtonClicked = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || loading || success) {\n event.preventDefault();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [onClick, disabled, loading, success]\n );\n\n const onMouseDownClicked = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || loading || success) {\n event.preventDefault();\n return;\n }\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [onMouseDown, disabled, loading, success]\n );\n\n const classNames = useMemo(() => {\n const calculatedColor = success ? \"positive\" : color;\n return cx(\n className,\n styles.button,\n getStyle(styles, camelCase(\"size-\" + size)),\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + calculatedColor)),\n {\n [styles.success]: success,\n [getStyle(styles, camelCase(\"color-\" + calculatedColor + \"-active\"))]: active,\n [activeButtonClassName]: active,\n [styles.marginRight]: marginRight,\n [styles.marginLeft]: marginLeft,\n [styles.rightFlat]: rightFlat,\n [styles.leftFlat]: leftFlat,\n [styles.preventClickAnimation]: preventClickAnimation,\n [styles.noSidePadding]: noSidePadding,\n [styles.disabled]: disabled,\n [styles.insetFocusStyle]: insetFocus\n }\n );\n }, [\n success,\n color,\n className,\n size,\n kind,\n active,\n activeButtonClassName,\n marginRight,\n marginLeft,\n rightFlat,\n leftFlat,\n preventClickAnimation,\n noSidePadding,\n disabled,\n insetFocus\n ]);\n\n const buttonProps = useMemo(() => {\n const props: Record<string, unknown> = {\n ref: mergedRef,\n type,\n className: classNames,\n name,\n onMouseUp,\n style,\n onClick: onButtonClicked,\n id,\n onFocus,\n onBlur,\n tabIndex: disabled || ariaHidden ? -1 : tabIndex,\n \"data-testid\": dataTestId || getTestId(ComponentDefaultTestId.BUTTON, id),\n \"data-vibe\": ComponentVibeId.BUTTON,\n onMouseDown: onMouseDownClicked,\n \"aria-disabled\": disabled,\n \"aria-busy\": loading,\n \"aria-labelledby\": ariaLabeledBy,\n \"aria-label\": ariaLabel,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-expanded\": ariaExpanded,\n \"aria-controls\": ariaControls,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-hidden\": ariaHidden,\n \"aria-pressed\": ariaPressed\n };\n return props;\n }, [\n mergedRef,\n type,\n classNames,\n name,\n onMouseUp,\n style,\n onButtonClicked,\n id,\n onFocus,\n onBlur,\n tabIndex,\n dataTestId,\n onMouseDownClicked,\n disabled,\n loading,\n ariaLabeledBy,\n ariaLabel,\n ariaHasPopup,\n ariaExpanded,\n ariaControls,\n ariaDescribedBy,\n ariaHidden,\n ariaPressed\n ]);\n\n const iconSize = useCallback(\n (icon: SubIcon) => {\n if (typeof icon !== \"function\") return;\n switch (size) {\n case \"xxs\":\n case \"xs\":\n return SMALL_BUTTON_ICON_SIZE;\n default:\n return BUTTON_ICON_SIZE;\n }\n },\n [size]\n );\n\n const hasRenderableChildren = useMemo(() => React.Children.toArray(children).some(Boolean), [children]);\n\n const buttonContent = useMemo(\n () => (\n <>\n {leftIcon ? (\n <Icon\n iconType=\"font\"\n icon={leftIcon}\n iconSize={iconSize(leftIcon)}\n className={cx({\n [styles.leftIcon]: hasRenderableChildren\n })}\n ignoreFocusStyle\n />\n ) : null}\n {children}\n {rightIcon ? (\n <Icon\n iconType=\"font\"\n icon={rightIcon}\n iconSize={iconSize(rightIcon)}\n className={cx({\n [styles.rightIcon]: hasRenderableChildren\n })}\n ignoreFocusStyle\n />\n ) : null}\n </>\n ),\n [children, hasRenderableChildren, iconSize, leftIcon, rightIcon]\n );\n\n if (loading) {\n return (\n <button {...buttonProps} key={`${id}-loading`}>\n <span className={cx(styles.loader, loaderClassName)}>\n <Loader className={styles.loaderSvg} />\n <span aria-hidden className={styles.textPlaceholder}>\n {buttonContent}\n </span>\n </span>\n </button>\n );\n }\n\n if (success) {\n return (\n <button {...buttonProps} key={`${id}-success`}>\n <span className={styles.successContent}>\n {successIcon ? (\n <Icon\n iconType=\"font\"\n icon={successIcon}\n iconSize={iconSize(successIcon)}\n className={cx({\n [styles.leftIcon]: !!successText\n })}\n ignoreFocusStyle\n />\n ) : null}\n {successText}\n </span>\n <span aria-hidden=\"true\" className={styles.textPlaceholder}>\n {buttonContent}\n </span>\n </button>\n );\n }\n\n return (\n <button {...buttonProps} key={`${id}-button`}>\n {buttonContent}\n </button>\n );\n }\n);\n\ninterface ButtonStaticProps {\n sizes: typeof SIZES;\n colors: typeof ButtonColorEnum;\n kinds: typeof ButtonTypeEnum;\n types: typeof ButtonInputTypeEnum;\n inputTags: typeof ButtonInputTypeEnum;\n}\n\nexport default withStaticProps<ButtonProps, ButtonStaticProps>(Button, {\n sizes: SIZES,\n colors: ButtonColorEnum,\n kinds: ButtonTypeEnum,\n types: ButtonInputTypeEnum,\n inputTags: ButtonInputTypeEnum\n});\n"],"names":["withStaticProps","forwardRef","_ref","ref","className","children","_ref$kind","kind","_ref$onClick","onClick","NOOP","name","_ref$size","size","_ref$color","color","_ref$disabled","disabled","_ref$rightIcon","rightIcon","_ref$leftIcon","leftIcon","_ref$success","success","_ref$successText","successText","_ref$successIcon","successIcon","style","_ref$loading","loading","isLoading","loaderClassName","_ref$active","active","activeButtonClassName","id","_ref$marginRight","marginRight","_ref$marginLeft","marginLeft","_ref$type","type","_ref$onMouseDown","onMouseDown","ariaLabel","_ref$rightFlat","rightFlat","_ref$leftFlat","leftFlat","_ref$preventClickAnim","preventClickAnimation","_ref$noSidePadding","noSidePadding","_ref$onFocus","onFocus","_ref$onBlur","onBlur","ariaLabeledBy","_ref$defaultTextColor","defaultTextColorOnPrimaryColor","TRANSPARENT_COLOR","ariaHasPopup","ariaExpanded","ariaControls","ariaDescribedBy","ariaHidden","ariaPressed","_ref$blurOnMouseUp","blurOnMouseUp","dataTestId","_ref$insetFocus","insetFocus","tabIndex","buttonRef","useRef","mergedRef","useMergeRef","useButtonLoading","useEffect","current","buttonElement","getParentBackgroundColorNotTransparent","onMouseUp","useCallback","button","blur","onButtonClicked","event","preventDefault","onMouseDownClicked","classNames","useMemo","_cx","calculatedColor","cx","styles","getStyle","camelCase","_defineProperty","insetFocusStyle","buttonProps","getTestId","ComponentDefaultTestId","BUTTON","ComponentVibeId","iconSize","icon","SMALL_BUTTON_ICON_SIZE","BUTTON_ICON_SIZE","hasRenderableChildren","React","Children","toArray","some","Boolean","buttonContent","createElement","Fragment","Icon","iconType","ignoreFocusStyle","key","concat","loader","Loader","loaderSvg","textPlaceholder","successContent","Object","assign","sizes","SIZES","colors","ButtonColorEnum","kinds","ButtonTypeEnum","types","ButtonInputTypeEnum","inputTags"],"mappings":"klCA0GA,IAsSeA,EAAAA,EAtSAC,GACb,SAAAC,EA6CEC,GACE,IA5CAC,EAASF,EAATE,UACAC,EAAQH,EAARG,SAAQC,EAAAJ,EACRK,KAAAA,OAAO,IAAHD,EAAG,UAASA,EAAAE,EAAAN,EAChBO,QAAAA,OAAUC,IAAHF,EAAGE,EAAIF,EACdG,EAAIT,EAAJS,KAAIC,EAAAV,EACJW,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EAAAE,EAAAZ,EACfa,MAAAA,OAAQ,IAAHD,EAAG,UAASA,EAAAE,EAAAd,EACjBe,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAhB,EAChBiB,UAAAA,OAAY,IAAHD,EAAG,KAAIA,EAAAE,EAAAlB,EAChBmB,SAAAA,OAAW,IAAHD,EAAG,KAAIA,EAAAE,EAAApB,EACfqB,QAAAA,OAAU,IAAHD,GAAQA,EAAAE,EAAAtB,EACfuB,YAAAA,OAAc,IAAHD,EAAG,GAAEA,EAAAE,EAAAxB,EAChByB,YAAAA,OAAc,IAAHD,EAAG,KAAIA,EAClBE,EAAK1B,EAAL0B,MAAKC,EAAA3B,EACL4B,QAASC,OAAY,IAAHF,GAAQA,EAC1BG,EAAe9B,EAAf8B,gBAAeC,EAAA/B,EACfgC,OAAAA,OAAS,IAAHD,GAAQA,EACdE,EAAqBjC,EAArBiC,sBACAC,GAAElC,EAAFkC,GAAEC,GAAAnC,EACFoC,YAAAA,QAAc,IAAHD,IAAQA,GAAAE,GAAArC,EACnBsC,WAAAA,QAAa,IAAHD,IAAQA,GAAAE,GAAAvC,EAClBwC,KAAAA,QAAO,IAAHD,GAAG,SAAQA,GAAAE,GAAAzC,EACf0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8B,YAC1Bf,EAAkBM,cAAA,OAAA,CAAA,eAAA,EAAAjH,UAAW4F,EAAO+B,iBACjCX,MAOP7F,EAEAwF,0CAAYV,GAAW,CAAEqB,IAAG,GAAAC,OAAKvF,GAAE,cACjC2E,EAAAM,cAAA,OAAA,CAAMjH,UAAW4F,EAAOgC,gBACrBrG,EACCoF,EAAAM,cAACE,EACC,CAAAC,SAAS,OACTb,KAAMhF,EACN+E,SAAUA,GAAS/E,GACnBvB,UAAW2F,EAAEI,EACVH,CAAAA,EAAAA,EAAO3E,WAAaI,IAEvBgG,kBAAgB,IAEhB,KACHhG,GAEHsF,EAAAM,cAAA,OAAA,CAAA,cAAkB,OAAOjH,UAAW4F,EAAO+B,iBACxCX,KAOPL,EAAAM,cAAA,SAAAY,OAAAC,OAAA,CAAA,EAAY7B,GAAW,CAAEqB,IAAG,GAAAC,OAAKvF,GAAE,aAChCgF,GAGP,IAWqE,CACrEe,MAAOC,EACPC,OAAQC,EACRC,MAAOC,EACPC,MAAOC,EACPC,UAAWD"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable react/button-has-type */\nimport React, { AriaAttributes, forwardRef, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { camelCase } from \"lodash-es\";\nimport cx from \"classnames\";\nimport { SIZES } from \"../../constants\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport Icon from \"../../components/Icon/Icon\";\nimport Loader from \"../../components/Loader/Loader\";\nimport {\n BUTTON_ICON_SIZE,\n ButtonColor as ButtonColorEnum,\n ButtonInputType as ButtonInputTypeEnum,\n ButtonType as ButtonTypeEnum,\n SMALL_BUTTON_ICON_SIZE\n} from \"./ButtonConstants\";\nimport { ButtonColor, ButtonInputType, ButtonType, ButtonSize } from \"./Button.types\";\nimport { getParentBackgroundColorNotTransparent, TRANSPARENT_COLOR } from \"./helper/dom-helpers\";\nimport { getTestId } from \"../../tests/test-ids-utils\";\nimport { SubIcon, VibeComponentProps, withStaticProps } from \"../../types\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, ComponentVibeId } from \"../../tests/constants\";\nimport styles from \"./Button.module.scss\";\nimport { useButtonLoading } from \"./helper/useButtonLoading\";\n\nexport interface ButtonProps extends VibeComponentProps {\n children: React.ReactNode;\n /** Custom class names to pass to the component */\n className?: string;\n activeButtonClassName?: string;\n /** The button's kind */\n kind?: ButtonType;\n /** Callback function to run when the button is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Blur on button click */\n blurOnMouseUp?: boolean;\n /** Name of the button - for form submit usages */\n name?: string;\n /** The button's size */\n size?: ButtonSize;\n /** The button's color */\n color?: ButtonColor;\n /** The button's type */\n type?: ButtonInputType;\n /** Whether the button should be disabled or not */\n disabled?: boolean;\n /** Icon to place on the right */\n rightIcon?: SubIcon;\n /** Icon to place on the left */\n leftIcon?: SubIcon;\n /** the success props are used when you have async action and wants to display a success message */\n success?: boolean;\n /** Success icon name */\n successIcon?: SubIcon;\n /** Success text */\n successText?: string;\n /** loading boolean which switches the text to a loader */\n loading?: boolean;\n /** className which is applied to loader container **/\n loaderClassName?: string;\n style?: React.CSSProperties;\n /** displays the active state */\n active?: boolean;\n /** id to pass to the button */\n id?: string;\n /** adds 8px margin to the right */\n marginRight?: boolean;\n /** adds 8px margin to the left */\n marginLeft?: boolean;\n /** element id to describe the button accordingly */\n ariaLabeledBy?: string;\n /** aria label to provide important when providing only Icon */\n ariaLabel?: string;\n /** aria for a button popup */\n ariaHasPopup?: React.HTMLProps<HTMLButtonElement>[\"aria-haspopup\"];\n /** aria to be set if the popup is open */\n ariaExpanded?: boolean;\n /** aria controls - receives id for the controlled region */\n ariaControls?: string;\n \"aria-describedby\"?: AriaAttributes[\"aria-describedby\"];\n /**\n * aria to be used for screen reader to know if the button is hidden\n */\n \"aria-hidden\"?: AriaAttributes[\"aria-hidden\"];\n /**\n * Indicates the current \"pressed\" state of toggle buttons\n */\n \"aria-pressed\"?: AriaAttributes[\"aria-pressed\"];\n /** On Button Focus callback */\n onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;\n /** On Button Blur callback */\n onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;\n rightFlat?: boolean;\n leftFlat?: boolean;\n preventClickAnimation?: boolean;\n noSidePadding?: boolean;\n /** default color for text color in ON_PRIMARY_COLOR kind (should be any type of css color (rbg, var, hex...) */\n defaultTextColorOnPrimaryColor?: string;\n \"data-testid\"?: string;\n /** Change the focus indicator from around the button to within it */\n insetFocus?: boolean;\n /** Specifies the tab order of an element */\n tabIndex?: number;\n}\n\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n children,\n kind,\n onClick,\n name,\n size,\n color,\n disabled,\n rightIcon,\n leftIcon,\n success,\n successText,\n successIcon,\n style,\n loading: isLoading,\n loaderClassName,\n active,\n activeButtonClassName,\n id,\n marginRight,\n marginLeft,\n type,\n onMouseDown,\n ariaLabel,\n rightFlat,\n leftFlat,\n preventClickAnimation,\n noSidePadding,\n onFocus,\n onBlur,\n ariaLabeledBy,\n defaultTextColorOnPrimaryColor,\n ariaHasPopup,\n ariaExpanded,\n ariaControls,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-hidden\": ariaHidden,\n \"aria-pressed\": ariaPressed,\n blurOnMouseUp,\n \"data-testid\": dataTestId,\n insetFocus,\n tabIndex\n }: ButtonProps,\n ref\n ) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const mergedRef = useMergeRef(ref, buttonRef);\n\n const { loading } = useButtonLoading({ isLoading });\n\n useEffect(() => {\n if (color !== \"on-primary-color\" && color !== \"fixed-light\") return;\n if (kind !== \"primary\") return;\n if (!buttonRef.current) return;\n\n const buttonElement = buttonRef.current;\n buttonElement.style.color = getParentBackgroundColorNotTransparent(buttonElement, defaultTextColorOnPrimaryColor);\n }, [kind, buttonRef, color, defaultTextColorOnPrimaryColor]);\n\n const onMouseUp = useCallback(() => {\n const button = buttonRef.current;\n if (disabled || !button) {\n return;\n }\n if (blurOnMouseUp) {\n button.blur();\n }\n }, [disabled, buttonRef, blurOnMouseUp]);\n\n const onButtonClicked = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || loading || success) {\n event.preventDefault();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [onClick, disabled, loading, success]\n );\n\n const onMouseDownClicked = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || loading || success) {\n event.preventDefault();\n return;\n }\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [onMouseDown, disabled, loading, success]\n );\n\n const classNames = useMemo(() => {\n const calculatedColor = success ? \"positive\" : color;\n return cx(\n className,\n styles.button,\n getStyle(styles, camelCase(\"size-\" + size)),\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + calculatedColor)),\n {\n [styles.success]: success,\n [getStyle(styles, camelCase(\"color-\" + calculatedColor + \"-active\"))]: active,\n [activeButtonClassName]: active,\n [styles.marginRight]: marginRight,\n [styles.marginLeft]: marginLeft,\n [styles.rightFlat]: rightFlat,\n [styles.leftFlat]: leftFlat,\n [styles.preventClickAnimation]: preventClickAnimation,\n [styles.noSidePadding]: noSidePadding,\n [styles.disabled]: disabled,\n [styles.insetFocusStyle]: insetFocus\n }\n );\n }, [\n success,\n color,\n className,\n size,\n kind,\n active,\n activeButtonClassName,\n marginRight,\n marginLeft,\n rightFlat,\n leftFlat,\n preventClickAnimation,\n noSidePadding,\n disabled,\n insetFocus\n ]);\n\n const buttonProps = useMemo(() => {\n const props: Record<string, unknown> = {\n ref: mergedRef,\n type,\n className: classNames,\n name,\n onMouseUp,\n style,\n onClick: onButtonClicked,\n id,\n onFocus,\n onBlur,\n tabIndex: disabled || ariaHidden ? -1 : tabIndex,\n \"data-testid\": dataTestId || getTestId(ComponentDefaultTestId.BUTTON, id),\n \"data-vibe\": ComponentVibeId.BUTTON,\n onMouseDown: onMouseDownClicked,\n \"aria-disabled\": disabled,\n \"aria-busy\": loading,\n \"aria-labelledby\": ariaLabeledBy,\n \"aria-label\": ariaLabel,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-expanded\": ariaExpanded,\n \"aria-controls\": ariaControls,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-hidden\": ariaHidden,\n \"aria-pressed\": ariaPressed\n };\n return props;\n }, [\n mergedRef,\n type,\n classNames,\n name,\n onMouseUp,\n style,\n onButtonClicked,\n id,\n onFocus,\n onBlur,\n tabIndex,\n dataTestId,\n onMouseDownClicked,\n disabled,\n loading,\n ariaLabeledBy,\n ariaLabel,\n ariaHasPopup,\n ariaExpanded,\n ariaControls,\n ariaDescribedBy,\n ariaHidden,\n ariaPressed\n ]);\n\n const iconSize = useCallback(\n (icon: SubIcon) => {\n if (typeof icon !== \"function\") return;\n switch (size) {\n case \"xxs\":\n case \"xs\":\n return SMALL_BUTTON_ICON_SIZE;\n default:\n return BUTTON_ICON_SIZE;\n }\n },\n [size]\n );\n\n const hasRenderableChildren = useMemo(() => React.Children.toArray(children).some(Boolean), [children]);\n\n const buttonContent = useMemo(\n () => (\n <>\n {leftIcon ? (\n <Icon\n iconType=\"font\"\n icon={leftIcon}\n iconSize={iconSize(leftIcon)}\n className={cx({\n [styles.leftIcon]: hasRenderableChildren\n })}\n ignoreFocusStyle\n />\n ) : null}\n {children}\n {rightIcon ? (\n <Icon\n iconType=\"font\"\n icon={rightIcon}\n iconSize={iconSize(rightIcon)}\n className={cx({\n [styles.rightIcon]: hasRenderableChildren\n })}\n ignoreFocusStyle\n />\n ) : null}\n </>\n ),\n [children, hasRenderableChildren, iconSize, leftIcon, rightIcon]\n );\n\n if (loading) {\n return (\n <button {...buttonProps} key={`${id}-loading`}>\n <span className={cx(styles.loader, loaderClassName)}>\n <Loader className={styles.loaderSvg} />\n <span aria-hidden className={styles.textPlaceholder}>\n {buttonContent}\n </span>\n </span>\n </button>\n );\n }\n\n if (success) {\n return (\n <button {...buttonProps} key={`${id}-success`}>\n <span className={styles.successContent}>\n {successIcon ? (\n <Icon\n iconType=\"font\"\n icon={successIcon}\n iconSize={iconSize(successIcon)}\n className={cx({\n [styles.leftIcon]: !!successText\n })}\n ignoreFocusStyle\n />\n ) : null}\n {successText}\n </span>\n <span aria-hidden=\"true\" className={styles.textPlaceholder}>\n {buttonContent}\n </span>\n </button>\n );\n }\n\n return (\n <button {...buttonProps} key={`${id}-button`}>\n {buttonContent}\n </button>\n );\n }\n);\n\nButton.defaultProps = {\n name: undefined,\n style: undefined,\n kind: \"primary\",\n onClick: NOOP,\n size: \"medium\",\n color: \"primary\",\n disabled: false,\n rightIcon: null,\n leftIcon: null,\n success: false,\n successText: \"\",\n successIcon: null,\n loading: false,\n loaderClassName: undefined,\n active: false,\n marginRight: false,\n marginLeft: false,\n type: \"button\",\n onMouseDown: NOOP,\n rightFlat: false,\n leftFlat: false,\n preventClickAnimation: false,\n noSidePadding: false,\n onFocus: NOOP,\n onBlur: NOOP,\n defaultTextColorOnPrimaryColor: TRANSPARENT_COLOR,\n ariaHasPopup: undefined,\n blurOnMouseUp: true,\n ariaExpanded: undefined,\n ariaControls: undefined,\n ariaLabel: undefined,\n ariaLabeledBy: undefined,\n insetFocus: false\n};\n\ninterface ButtonStaticProps {\n sizes: typeof SIZES;\n colors: typeof ButtonColorEnum;\n kinds: typeof ButtonTypeEnum;\n types: typeof ButtonInputTypeEnum;\n inputTags: typeof ButtonInputTypeEnum;\n}\n\nexport default withStaticProps<ButtonProps, ButtonStaticProps>(Button, {\n sizes: SIZES,\n colors: ButtonColorEnum,\n kinds: ButtonTypeEnum,\n types: ButtonInputTypeEnum,\n inputTags: ButtonInputTypeEnum\n});\n"],"names":["Button","forwardRef","_ref","ref","className","children","kind","onClick","name","size","color","disabled","rightIcon","leftIcon","success","successText","successIcon","style","isLoading","loading","loaderClassName","active","activeButtonClassName","id","marginRight","marginLeft","type","onMouseDown","ariaLabel","rightFlat","leftFlat","preventClickAnimation","noSidePadding","onFocus","onBlur","ariaLabeledBy","defaultTextColorOnPrimaryColor","ariaHasPopup","ariaExpanded","ariaControls","ariaDescribedBy","ariaHidden","ariaPressed","blurOnMouseUp","dataTestId","insetFocus","tabIndex","buttonRef","useRef","mergedRef","useMergeRef","useButtonLoading","useEffect","current","buttonElement","getParentBackgroundColorNotTransparent","onMouseUp","useCallback","button","blur","onButtonClicked","event","preventDefault","onMouseDownClicked","classNames","useMemo","_cx","calculatedColor","cx","styles","getStyle","camelCase","_defineProperty","insetFocusStyle","buttonProps","getTestId","ComponentDefaultTestId","BUTTON","ComponentVibeId","iconSize","icon","SMALL_BUTTON_ICON_SIZE","BUTTON_ICON_SIZE","hasRenderableChildren","React","Children","toArray","some","Boolean","buttonContent","createElement","Fragment","Icon","iconType","ignoreFocusStyle","key","concat","loader","Loader","loaderSvg","textPlaceholder","successContent","Object","assign","defaultProps","undefined","NOOP","TRANSPARENT_COLOR","withStaticProps","sizes","SIZES","colors","ButtonColorEnum","kinds","ButtonTypeEnum","types","ButtonInputTypeEnum","inputTags"],"mappings":"klCA0GA,IAAMA,EAASC,GACb,SAAAC,EA6CEC,GACE,IA5CAC,EAASF,EAATE,UACAC,EAAQH,EAARG,SACAC,EAAIJ,EAAJI,KACAC,EAAOL,EAAPK,QACAC,EAAIN,EAAJM,KACAC,EAAIP,EAAJO,KACAC,EAAKR,EAALQ,MACAC,EAAQT,EAARS,SACAC,EAASV,EAATU,UACAC,EAAQX,EAARW,SACAC,EAAOZ,EAAPY,QACAC,EAAWb,EAAXa,YACAC,EAAWd,EAAXc,YACAC,EAAKf,EAALe,MACSC,EAAShB,EAAlBiB,QACAC,EAAelB,EAAfkB,gBACAC,EAAMnB,EAANmB,OACAC,EAAqBpB,EAArBoB,sBACAC,EAAErB,EAAFqB,GACAC,EAAWtB,EAAXsB,Y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/D,GACnBZ,UAAWgE,EAAEI,EACVH,CAAAA,EAAAA,EAAOxD,WAAaE,IAEvB+E,kBAAgB,IAEhB,KACH/E,GAEHqE,EAAAM,cAAA,OAAA,CAAA,cAAkB,OAAOtF,UAAWiE,EAAO+B,iBACxCX,KAOPL,EAAAM,cAAA,SAAAY,OAAAC,OAAA,CAAA,EAAY7B,GAAW,CAAEqB,IAAG,GAAAC,OAAKzE,EAAE,aAChCkE,GAGP,IAGFzF,EAAOwG,aAAe,CACpBhG,UAAMiG,EACNxF,WAAOwF,EACPnG,KAAM,UACNC,QAASmG,EACTjG,KAAM,SACNC,MAAO,UACPC,UAAU,EACVC,UAAW,KACXC,SAAU,KACVC,SAAS,EACTC,YAAa,GACbC,YAAa,KACbG,SAAS,EACTC,qBAAiBqF,EACjBpF,QAAQ,EACRG,aAAa,EACbC,YAAY,EACZC,KAAM,SACNC,YAAa+E,EACb7E,WAAW,EACXC,UAAU,EACVC,uBAAuB,EACvBC,eAAe,EACfC,QAASyE,EACTxE,OAAQwE,EACRtE,+BAAgCuE,EAChCtE,kBAAcoE,EACd9D,eAAe,EACfL,kBAAcmE,EACdlE,kBAAckE,EACd7E,eAAW6E,EACXtE,mBAAesE,EACf5D,YAAY,GAWd,IAAe+D,EAAAA,EAAgD5G,EAAQ,CACrE6G,MAAOC,EACPC,OAAQC,EACRC,MAAOC,EACPC,MAAOC,EACPC,UAAWD"}
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{camelCase as o}from"lodash-es";import{getStyle as i}from"../../helpers/typesciptCssModulesHelper.js";import{getTestId as r,ComponentDefaultTestId as a}from"../../tests/testIds.js";import n from"classnames";import s,{useState as l,useRef as d,useCallback as m,useEffect as c,useMemo as u}from"react";import{SwitchTransition as f,CSSTransition as p}from"react-transition-group";import v from"../../hooks/useEventListener/index.js";import E from"../../hooks/useAfterFirstRender/index.js";import{NOOP as b}from"../../utils/function-utils.js";import{CounterSize as j,CounterColor as x,CounterType as h}from"./CounterConstants.js";import{withStaticPropsWithoutForwardRef as y}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import A from"./Counter.module.scss.js";var N=y((function(j){var x=j.className,h=j.counterClassName,y=j.count,N=void 0===y?0:y,k=j.size,C=void 0===k?"large":k,g=j.kind,w=void 0===g?"fill":g,L=j.color,M=void 0===L?"primary":L,R=j.maxDigits,z=void 0===R?3:R,D=j.ariaLabeledBy,P=void 0===D?"":D,T=j.ariaLabel,B=void 0===T?"":T,H=j.id,O=void 0===H?"":H,U=j.prefix,_=void 0===U?"":U,F=j.onMouseDown,I=void 0===F?b:F,S=j.noAnimation,q=void 0!==S&&S,G=j["data-testid"],J=l(!1),K=e(J,2),Q=K[0],V=K[1],W=d(null),X=d(null),Y=m((function(){V(!0)}),[V]),Z=m((function(){V(!1)}),[V]);v({eventName:"animationend",callback:Z,ref:W});var $=E();c((function(){$.current&&Y()}),[N,$,Y]),c((function(){z>0||console.error("Max digits must be a positive number")}),[z]);var ee=u((function(){return n(A.counter,i(A,o("size-"+C)),i(A,o("kind-"+w)),i(A,o("color-"+M)),t({},A.withAnimation,Q),h)}),[C,w,M,Q,h]),te="counter"+(O?"-".concat(O):""),oe=(null==N?void 0:(""+N).length)>z?"".concat(Math.pow(10,z)-1,"+"):N+"",ie=s.createElement("span",{id:te,"data-testid":G||r(a.COUNTER,O)},_+oe);return s.createElement("span",{className:x,"aria-label":"".concat(B," ").concat(oe),"aria-labelledby":P,onMouseDown:I},s.createElement("div",{className:ee,"aria-label":oe,ref:W},q?ie:s.createElement(f,{mode:"out-in"},s.createElement(p,{key:oe,nodeRef:X,classNames:{enter:A.fadeEnter,enterActive:A.fadeEnterActive,exit:A.fadeExit,exitActive:A.fadeExitActive},addEndListener:function(e,t){e.addEventListener("transitionend",t,!1)}},s.createElement("span",{ref:X,id:te,"data-testid":G||r(a.COUNTER,O)},_+oe)))))}),{sizes:j,colors:x,kinds:h});export{N as default};
1
+ import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{camelCase as o}from"lodash-es";import{getStyle as i}from"../../helpers/typesciptCssModulesHelper.js";import{getTestId as r,ComponentDefaultTestId as a}from"../../tests/testIds.js";import n from"classnames";import s,{useState as l,useRef as d,useCallback as m,useEffect as c,useMemo as u}from"react";import{SwitchTransition as p,CSSTransition as f}from"react-transition-group";import v from"../../hooks/useEventListener/index.js";import E from"../../hooks/useAfterFirstRender/index.js";import{NOOP as b}from"../../utils/function-utils.js";import{CounterSize as j,CounterColor as x,CounterType as h}from"./CounterConstants.js";import{withStaticPropsWithoutForwardRef as y}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import A from"./Counter.module.scss.js";var N=y((function(j){var x=j.className,h=j.counterClassName,y=j.count,N=void 0===y?0:y,k=j.size,C=void 0===k?"large":k,g=j.kind,w=void 0===g?"fill":g,L=j.color,M=void 0===L?"primary":L,z=j.maxDigits,D=void 0===z?3:z,P=j.ariaLabeledBy,R=void 0===P?"":P,T=j.ariaLabel,B=void 0===T?"":T,H=j.id,O=void 0===H?"":H,U=j.prefix,_=void 0===U?"":U,F=j.onMouseDown,I=void 0===F?b:F,S=j.noAnimation,q=void 0!==S&&S,G=j["data-testid"],J=l(!1),K=e(J,2),Q=K[0],V=K[1],W=d(null),X=m((function(){V(!0)}),[V]),Y=m((function(){V(!1)}),[V]);v({eventName:"animationend",callback:Y,ref:W});var Z=E();c((function(){Z.current&&X()}),[N,Z,X]),c((function(){D>0||console.error("Max digits must be a positive number")}),[D]);var $=u((function(){return n(A.counter,i(A,o("size-"+C)),i(A,o("kind-"+w)),i(A,o("color-"+M)),t({},A.withAnimation,Q),h)}),[C,w,M,Q,h]),ee="counter"+(O?"-".concat(O):""),te=(null==N?void 0:(""+N).length)>D?"".concat(Math.pow(10,D)-1,"+"):N+"",oe=s.createElement("span",{id:ee,"data-testid":G||r(a.COUNTER,O)},_+te);return s.createElement("span",{className:x,"aria-label":"".concat(B," ").concat(te),"aria-labelledby":R,onMouseDown:I},s.createElement("div",{className:$,"aria-label":te,ref:W},q?oe:s.createElement(p,{mode:"out-in"},s.createElement(f,{key:te,classNames:{enter:A.fadeEnter,enterActive:A.fadeEnterActive,exit:A.fadeExit,exitActive:A.fadeExitActive},addEndListener:function(e,t){e.addEventListener("transitionend",t,!1)}},s.createElement("span",{id:ee,"data-testid":G||r(a.COUNTER,O)},_+te)))))}),{sizes:j,colors:x,kinds:h});export{N as default};
2
2
  //# sourceMappingURL=Counter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Counter.js","sources":["../../../../src/components/Counter/Counter.tsx"],"sourcesContent":["import { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { CSSTransition, SwitchTransition } from \"react-transition-group\";\nimport useEventListener from \"../../hooks/useEventListener\";\nimport useAfterFirstRender from \"../../hooks/useAfterFirstRender\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport {\n CounterColor as CounterColorEnum,\n CounterSize as CounterSizeEnum,\n CounterType as CounterTypeEnum\n} from \"./CounterConstants\";\nimport { CounterColor, CounterSize, CounterType } from \"./Counter.types\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./Counter.module.scss\";\n\nexport interface CounterProps extends VibeComponentProps {\n /**\n * The ID of the element describing the counter.\n */\n ariaLabeledBy?: string;\n /**\n * Class name applied to the counter element.\n */\n counterClassName?: string;\n /**\n * The numeric value displayed in the counter.\n */\n count?: number;\n /**\n * The label of the counter for accessibility.\n */\n ariaLabel?: string;\n /**\n * The size of the counter.\n */\n size?: CounterSize;\n /**\n * The visual style of the counter.\n */\n kind?: CounterType;\n /**\n * The color of the counter.\n */\n color?: CounterColor;\n /**\n * The maximum number of digits displayed before truncation.\n */\n maxDigits?: number;\n /**\n * Text prepended to the counter value.\n */\n prefix?: string;\n /**\n * Callback fired when the counter is clicked.\n */\n onMouseDown?: (event: React.MouseEvent<HTMLSpanElement>) => void;\n /**\n * If true, disables counter animations.\n */\n noAnimation?: boolean;\n}\n\nconst Counter = ({\n className,\n counterClassName,\n count = 0,\n size = \"large\",\n kind = \"fill\",\n color = \"primary\",\n maxDigits = 3,\n ariaLabeledBy = \"\",\n ariaLabel = \"\",\n id = \"\",\n prefix = \"\",\n onMouseDown = NOOP,\n noAnimation = false,\n \"data-testid\": dataTestId\n}: CounterProps) => {\n const [countChangeAnimationState, setCountChangeAnimationState] = useState(false);\n\n const ref = useRef<HTMLDivElement>(null);\n const nodeRef = useRef<HTMLSpanElement>(null);\n\n const setCountChangedAnimationActive = useCallback(() => {\n setCountChangeAnimationState(true);\n }, [setCountChangeAnimationState]);\n\n const setCountChangedAnimationNotActive = useCallback(() => {\n setCountChangeAnimationState(false);\n }, [setCountChangeAnimationState]);\n\n useEventListener({\n eventName: \"animationend\",\n callback: setCountChangedAnimationNotActive,\n ref\n });\n\n const isAfterFirstRender = useAfterFirstRender();\n\n useEffect(() => {\n if (isAfterFirstRender.current) {\n setCountChangedAnimationActive();\n }\n }, [count, isAfterFirstRender, setCountChangedAnimationActive]);\n\n useEffect(() => {\n if (maxDigits <= 0) {\n console.error(\"Max digits must be a positive number\");\n }\n }, [maxDigits]);\n\n const classNames = useMemo(() => {\n return cx(\n styles.counter,\n getStyle(styles, camelCase(\"size-\" + size)),\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + color)),\n {\n [styles.withAnimation]: countChangeAnimationState\n },\n counterClassName\n );\n }, [size, kind, color, countChangeAnimationState, counterClassName]);\n\n const counterId = \"counter\" + (id ? `-${id}` : \"\");\n const countText = count?.toString().length > maxDigits ? `${10 ** maxDigits - 1}+` : String(count);\n const counter = (\n <span id={counterId} data-testid={dataTestId || getTestId(ComponentDefaultTestId.COUNTER, id)}>\n {prefix + countText}\n </span>\n );\n\n return (\n <span\n className={className}\n aria-label={`${ariaLabel} ${countText}`}\n aria-labelledby={ariaLabeledBy}\n onMouseDown={onMouseDown}\n >\n <div className={classNames} aria-label={countText} ref={ref}>\n {noAnimation ? (\n counter\n ) : (\n <SwitchTransition mode=\"out-in\">\n <CSSTransition\n key={countText}\n nodeRef={nodeRef}\n classNames={{\n enter: styles.fadeEnter,\n enterActive: styles.fadeEnterActive,\n exit: styles.fadeExit,\n exitActive: styles.fadeExitActive\n }}\n // @ts-expect-error @definitelyTyped typings expecting a single parameter for some reason when the function passed here is called with two parameters\n // See https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L522-L534\n addEndListener={(node: HTMLElement, done: () => void) => {\n node.addEventListener(\"transitionend\", done, false);\n }}\n >\n <span\n ref={nodeRef}\n id={counterId}\n data-testid={dataTestId || getTestId(ComponentDefaultTestId.COUNTER, id)}\n >\n {prefix + countText}\n </span>\n </CSSTransition>\n </SwitchTransition>\n )}\n </div>\n </span>\n );\n};\n\ninterface CounterStaticProps {\n sizes: typeof CounterSizeEnum;\n colors: typeof CounterColorEnum;\n kinds: typeof CounterTypeEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<CounterProps, CounterStaticProps>(Counter, {\n sizes: CounterSizeEnum,\n colors: CounterColorEnum,\n kinds: CounterTypeEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","className","counterClassName","_ref$count","count","_ref$size","size","_ref$kind","kind","_ref$color","color","_ref$maxDigits","maxDigits","_ref$ariaLabeledBy","ariaLabeledBy","_ref$ariaLabel","ariaLabel","_ref$id","id","_ref$prefix","prefix","_ref$onMouseDown","onMouseDown","NOOP","_ref$noAnimation","noAnimation","dataTestId","_useState","useState","_useState2","_slicedToArray","countChangeAnimationState","setCountChangeAnimationState","ref","useRef","nodeRef","setCountChangedAnimationActive","useCallback","setCountChangedAnimationNotActive","useEventListener","eventName","callback","isAfterFirstRender","useAfterFirstRender","useEffect","current","console","error","classNames","useMemo","cx","styles","counter","getStyle","camelCase","_defineProperty","withAnimation","counterId","concat","countText","length","Math","pow","String","React","createElement","getTestId","ComponentDefaultTestId","COUNTER","SwitchTransition","mode","CSSTransition","key","enter","fadeEnter","enterActive","fadeEnterActive","exit","fadeExit","exitActive","fadeExitActive","addEndListener","node","done","addEventListener","sizes","CounterSizeEnum","colors","CounterColorEnum","kinds","CounterTypeEnum"],"mappings":"43BAiEA,IAsHeA,EAAAA,GAtHC,SAAHC,GAeM,IAdjBC,EAASD,EAATC,UACAC,EAAgBF,EAAhBE,iBAAgBC,EAAAH,EAChBI,MAAAA,OAAQ,IAAHD,EAAG,EAACA,EAAAE,EAAAL,EACTM,KAAAA,OAAO,IAAHD,EAAG,QAAOA,EAAAE,EAAAP,EACdQ,KAAAA,OAAO,IAAHD,EAAG,OAAMA,EAAAE,EAAAT,EACbU,MAAAA,OAAQ,IAAHD,EAAG,UAASA,EAAAE,EAAAX,EACjBY,UAAAA,OAAY,IAAHD,EAAG,EAACA,EAAAE,EAAAb,EACbc,cAAAA,OAAgB,IAAHD,EAAG,GAAEA,EAAAE,EAAAf,EAClBgB,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EAAAE,EAAAjB,EACdkB,GAAAA,OAAK,IAAHD,EAAG,GAAEA,EAAAE,EAAAnB,EACPoB,OAAAA,OAAS,IAAHD,EAAG,GAAEA,EAAAE,EAAArB,EACXsB,YAAAA,OAAcC,IAAHF,EAAGE,EAAIF,EAAAG,EAAAxB,EAClByB,YAAAA,OAAc,IAAHD,GAAQA,EACJE,EAAU1B,EAAzB,eAEA2B,EAAkEC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1EI,EAAyBF,EAAA,GAAEG,EAA4BH,EAAA,GAExDI,EAAMC,EAAuB,MAC7BC,EAAUD,EAAwB,MAElCE,EAAiCC,GAAY,WACjDL,GAA6B,EAC/B,GAAG,CAACA,IAEEM,EAAoCD,GAAY,WAC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BAAiBD,GAAM,EAC/C,GAEAnB,EAAAC,cAAA,OAAA,CACEhC,IAAKE,EACLjB,GAAIuC,GAAS,cACA/B,GAAcwC,EAAUC,EAAuBC,QAASlD,IAEpEE,EAASuC,OAQ1B,GAQ2F,CACzF0B,MAAOC,EACPC,OAAQC,EACRC,MAAOC"}
1
+ {"version":3,"file":"Counter.js","sources":["../../../../src/components/Counter/Counter.tsx"],"sourcesContent":["import { camelCase } from \"lodash-es\";\nimport { getStyle } from \"../../helpers/typesciptCssModulesHelper\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport cx from \"classnames\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { CSSTransition, SwitchTransition } from \"react-transition-group\";\nimport useEventListener from \"../../hooks/useEventListener\";\nimport useAfterFirstRender from \"../../hooks/useAfterFirstRender\";\nimport { NOOP } from \"../../utils/function-utils\";\nimport {\n CounterColor as CounterColorEnum,\n CounterSize as CounterSizeEnum,\n CounterType as CounterTypeEnum\n} from \"./CounterConstants\";\nimport { CounterColor, CounterSize, CounterType } from \"./Counter.types\";\nimport { VibeComponentProps, withStaticPropsWithoutForwardRef } from \"../../types\";\nimport styles from \"./Counter.module.scss\";\n\nexport interface CounterProps extends VibeComponentProps {\n /**\n * The ID of the element describing the counter.\n */\n ariaLabeledBy?: string;\n /**\n * Class name applied to the counter element.\n */\n counterClassName?: string;\n /**\n * The numeric value displayed in the counter.\n */\n count?: number;\n /**\n * The label of the counter for accessibility.\n */\n ariaLabel?: string;\n /**\n * The size of the counter.\n */\n size?: CounterSize;\n /**\n * The visual style of the counter.\n */\n kind?: CounterType;\n /**\n * The color of the counter.\n */\n color?: CounterColor;\n /**\n * The maximum number of digits displayed before truncation.\n */\n maxDigits?: number;\n /**\n * Text prepended to the counter value.\n */\n prefix?: string;\n /**\n * Callback fired when the counter is clicked.\n */\n onMouseDown?: (event: React.MouseEvent<HTMLSpanElement>) => void;\n /**\n * If true, disables counter animations.\n */\n noAnimation?: boolean;\n}\n\nconst Counter = ({\n className,\n counterClassName,\n count = 0,\n size = \"large\",\n kind = \"fill\",\n color = \"primary\",\n maxDigits = 3,\n ariaLabeledBy = \"\",\n ariaLabel = \"\",\n id = \"\",\n prefix = \"\",\n onMouseDown = NOOP,\n noAnimation = false,\n \"data-testid\": dataTestId\n}: CounterProps) => {\n const [countChangeAnimationState, setCountChangeAnimationState] = useState(false);\n\n const ref = useRef<HTMLDivElement>(null);\n\n const setCountChangedAnimationActive = useCallback(() => {\n setCountChangeAnimationState(true);\n }, [setCountChangeAnimationState]);\n\n const setCountChangedAnimationNotActive = useCallback(() => {\n setCountChangeAnimationState(false);\n }, [setCountChangeAnimationState]);\n\n useEventListener({\n eventName: \"animationend\",\n callback: setCountChangedAnimationNotActive,\n ref\n });\n\n const isAfterFirstRender = useAfterFirstRender();\n\n useEffect(() => {\n if (isAfterFirstRender.current) {\n setCountChangedAnimationActive();\n }\n }, [count, isAfterFirstRender, setCountChangedAnimationActive]);\n\n useEffect(() => {\n if (maxDigits <= 0) {\n console.error(\"Max digits must be a positive number\");\n }\n }, [maxDigits]);\n\n const classNames = useMemo(() => {\n return cx(\n styles.counter,\n getStyle(styles, camelCase(\"size-\" + size)),\n getStyle(styles, camelCase(\"kind-\" + kind)),\n getStyle(styles, camelCase(\"color-\" + color)),\n {\n [styles.withAnimation]: countChangeAnimationState\n },\n counterClassName\n );\n }, [size, kind, color, countChangeAnimationState, counterClassName]);\n\n const counterId = \"counter\" + (id ? `-${id}` : \"\");\n const countText = count?.toString().length > maxDigits ? `${10 ** maxDigits - 1}+` : String(count);\n const counter = (\n <span id={counterId} data-testid={dataTestId || getTestId(ComponentDefaultTestId.COUNTER, id)}>\n {prefix + countText}\n </span>\n );\n\n return (\n <span\n className={className}\n aria-label={`${ariaLabel} ${countText}`}\n aria-labelledby={ariaLabeledBy}\n onMouseDown={onMouseDown}\n >\n <div className={classNames} aria-label={countText} ref={ref}>\n {noAnimation ? (\n counter\n ) : (\n <SwitchTransition mode=\"out-in\">\n <CSSTransition\n key={countText}\n classNames={{\n enter: styles.fadeEnter,\n enterActive: styles.fadeEnterActive,\n exit: styles.fadeExit,\n exitActive: styles.fadeExitActive\n }}\n // @ts-expect-error @definitelyTyped typings expecting a single parameter for some reason when the function passed here is called with two parameters\n // See https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L522-L534\n addEndListener={(node: HTMLElement, done: () => void) => {\n node.addEventListener(\"transitionend\", done, false);\n }}\n >\n <span id={counterId} data-testid={dataTestId || getTestId(ComponentDefaultTestId.COUNTER, id)}>\n {prefix + countText}\n </span>\n </CSSTransition>\n </SwitchTransition>\n )}\n </div>\n </span>\n );\n};\n\ninterface CounterStaticProps {\n sizes: typeof CounterSizeEnum;\n colors: typeof CounterColorEnum;\n kinds: typeof CounterTypeEnum;\n}\n\nexport default withStaticPropsWithoutForwardRef<CounterProps, CounterStaticProps>(Counter, {\n sizes: CounterSizeEnum,\n colors: CounterColorEnum,\n kinds: CounterTypeEnum\n});\n"],"names":["withStaticPropsWithoutForwardRef","_ref","className","counterClassName","_ref$count","count","_ref$size","size","_ref$kind","kind","_ref$color","color","_ref$maxDigits","maxDigits","_ref$ariaLabeledBy","ariaLabeledBy","_ref$ariaLabel","ariaLabel","_ref$id","id","_ref$prefix","prefix","_ref$onMouseDown","onMouseDown","NOOP","_ref$noAnimation","noAnimation","dataTestId","_useState","useState","_useState2","_slicedToArray","countChangeAnimationState","setCountChangeAnimationState","ref","useRef","setCountChangedAnimationActive","useCallback","setCountChangedAnimationNotActive","useEventListener","eventName","callback","isAfterFirstRender","useAfterFirstRender","useEffect","current","console","error","classNames","useMemo","cx","styles","counter","getStyle","camelCase","_defineProperty","withAnimation","counterId","concat","countText","length","Math","pow","String","React","createElement","getTestId","ComponentDefaultTestId","COUNTER","SwitchTransition","mode","CSSTransition","key","enter","fadeEnter","enterActive","fadeEnterActive","exit","fadeExit","exitActive","fadeExitActive","addEndListener","node","done","addEventListener","sizes","CounterSizeEnum","colors","CounterColorEnum","kinds","CounterTypeEnum"],"mappings":"43BAiEA,IAgHeA,EAAAA,GAhHC,SAAHC,GAeM,IAdjBC,EAASD,EAATC,UACAC,EAAgBF,EAAhBE,iBAAgBC,EAAAH,EAChBI,MAAAA,OAAQ,IAAHD,EAAG,EAACA,EAAAE,EAAAL,EACTM,KAAAA,OAAO,IAAHD,EAAG,QAAOA,EAAAE,EAAAP,EACdQ,KAAAA,OAAO,IAAHD,EAAG,OAAMA,EAAAE,EAAAT,EACbU,MAAAA,OAAQ,IAAHD,EAAG,UAASA,EAAAE,EAAAX,EACjBY,UAAAA,OAAY,IAAHD,EAAG,EAACA,EAAAE,EAAAb,EACbc,cAAAA,OAAgB,IAAHD,EAAG,GAAEA,EAAAE,EAAAf,EAClBgB,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EAAAE,EAAAjB,EACdkB,GAAAA,OAAK,IAAHD,EAAG,GAAEA,EAAAE,EAAAnB,EACPoB,OAAAA,OAAS,IAAHD,EAAG,GAAEA,EAAAE,EAAArB,EACXsB,YAAAA,OAAcC,IAAHF,EAAGE,EAAIF,EAAAG,EAAAxB,EAClByB,YAAAA,OAAc,IAAHD,GAAQA,EACJE,EAAU1B,EAAzB,eAEA2B,EAAkEC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1EI,EAAyBF,EAAA,GAAEG,EAA4BH,EAAA,GAExDI,EAAMC,EAAuB,MAE7BC,EAAiCC,GAAY,WACjDJ,GAA6B,EAC/B,GAAG,CAACA,IAEEK,EAAoCD,GAAY,WACpDJ,GAA6B,EAC/B,GAAG,CAACA,IAEJM,EAAiB,CACfC,UAAW,eACXC,SAAUH,EACVJ,IAAAA,IAGF,IAAMQ,EAAqBC,IAE3BC,GAAU,WACJF,EAAmBG,SACrBT,GAEH,GAAE,CAAC/B,EAAOqC,EAAoBN,IAE/BQ,GAAU,WACJ/B,EAAa,GACfiC,QAAQC,MAAM,uCA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ginBabelHelpers.js";import o,{forwardRef as t,useRef as a,useCallback as s,useEffect as r,cloneElement as i}from"react";import n from"classnames";import{camelCase as p}from"lodash-es";import{CSSTransition as l}from"react-transition-group";import c from"../../../hooks/useClickOutside/index.js";import{chainFunctions as d,NOOP as m}from"../../../utils/function-utils.js";import u from"../../../hooks/useKeyEvent/index.js";import{keyCodes as f}from"../../../constants/keyCodes.js";import"../../../constants/sizes.js";import{getStyle as v}from"../../../helpers/typesciptCssModulesHelper.js";import y from"./DialogContent.module.scss.js";import k from"../../../hooks/useDisableScroll/index.js";var C={},x=[f.ESCAPE],h=t((function(t,f){var h=t.onEsc,E=void 0===h?m:h,b=t.children,j=t.position,A=t.wrapperClassName,N=t.isOpen,g=void 0!==N&&N,M=t.startingEdge,S=t.animationType,w=void 0===S?"expand":S,O=t.onMouseEnter,D=void 0===O?m:O,H=t.onMouseLeave,L=void 0===H?m:H,P=t.onClickOutside,T=void 0===P?m:P,R=t.onClick,_=void 0===R?m:R,z=t.onContextMenu,B=void 0===z?m:z,K=t.showDelay,W=t.styleObject,q=void 0===W?C:W,F=t.isReferenceHidden,G=t.hasTooltip,I=void 0!==G&&G,J=t.containerSelector,Q=t.disableContainerScroll,U=void 0!==Q&&Q,V=t["data-testid"],X=a(null),Y=s((function(e){if(g)return T(e,"clickoutside")}),[g,T]),Z=s((function(e){g&&B(e)}),[g,B]);u({keys:x,callback:E}),c({callback:Y,ref:X}),c({eventName:"contextmenu",callback:Z,ref:X});var $=k("string"==typeof U?U:J),ee=$.disableScroll,oe=$.enableScroll;r((function(){U&&(g?ee():oe())}),[U,ee,oe,g]);var te={classNames:void 0};switch(w){case"expand":te.classNames={appear:y.expandAppear,appearActive:y.expandAppearActive,exit:y.expandExit};break;case"opacity-and-slide":te.classNames={appear:y.opacitySlideAppear,appearActive:y.opacitySlideAppearActive}}return o.createElement("span",{className:n("monday-style-dialog-content-wrapper",y.contentWrapper,A),ref:f,"data-testid":V,style:q,onClickCapture:_,"data-popper-reference-hidden":F},o.createElement(l,{classNames:te.classNames,nodeRef:X,in:g,appear:!!w,timeout:K},o.createElement("div",{className:n(y.contentComponent,v(y,p(j)),e(e({},v(y,p("edge-"+M)),M),y.hasTooltip,I)),ref:X},o.Children.toArray(b).map((function(e){return i(e,{onMouseEnter:d([e.props.onMouseEnter,D]),onMouseLeave:d([e.props.onMouseLeave,L])})})))))}));export{h as default};
1
+ import{defineProperty as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import o,{forwardRef as t,useRef as a,useCallback as r,useEffect as i,cloneElement as s}from"react";import n from"classnames";import{camelCase as p}from"lodash-es";import{CSSTransition as l}from"react-transition-group";import c from"../../../hooks/useClickOutside/index.js";import{chainFunctions as d,NOOP as m}from"../../../utils/function-utils.js";import u from"../../../hooks/useKeyEvent/index.js";import{keyCodes as f}from"../../../constants/keyCodes.js";import"../../../constants/sizes.js";import{getStyle as v}from"../../../helpers/typesciptCssModulesHelper.js";import y from"./DialogContent.module.scss.js";import k from"../../../hooks/useDisableScroll/index.js";var C={},x=[f.ESCAPE],h=t((function(t,f){var h=t.onEsc,E=void 0===h?m:h,b=t.children,j=t.position,A=t.wrapperClassName,g=t.isOpen,M=void 0!==g&&g,S=t.startingEdge,N=t.animationType,O=void 0===N?"expand":N,w=t.onMouseEnter,D=void 0===w?m:w,H=t.onMouseLeave,L=void 0===H?m:H,P=t.onClickOutside,T=void 0===P?m:P,_=t.onClick,z=void 0===_?m:_,B=t.onContextMenu,K=void 0===B?m:B,R=t.showDelay,W=t.styleObject,q=void 0===W?C:W,F=t.isReferenceHidden,G=t.hasTooltip,I=void 0!==G&&G,J=t.containerSelector,Q=t.disableContainerScroll,U=void 0!==Q&&Q,V=t["data-testid"],X=a(null),Y=r((function(e){if(M)return T(e,"clickoutside")}),[M,T]),Z=r((function(e){M&&K(e)}),[M,K]);u({keys:x,callback:E}),c({callback:Y,ref:X}),c({eventName:"contextmenu",callback:Z,ref:X});var $=k("string"==typeof U?U:J),ee=$.disableScroll,oe=$.enableScroll;i((function(){U&&(M?ee():oe())}),[U,ee,oe,M]);var te={classNames:void 0};switch(O){case"expand":te.classNames={appear:y.expandAppear,appearActive:y.expandAppearActive,exit:y.expandExit};break;case"opacity-and-slide":te.classNames={appear:y.opacitySlideAppear,appearActive:y.opacitySlideAppearActive}}return o.createElement("span",{className:n("monday-style-dialog-content-wrapper",y.contentWrapper,A),ref:f,"data-testid":V,style:q,onClickCapture:z,"data-popper-reference-hidden":F},o.createElement(l,Object.assign({},te,{in:M,appear:!!O,timeout:R}),o.createElement("div",{className:n(y.contentComponent,v(y,p(j)),e(e({},v(y,p("edge-"+S)),S),y.hasTooltip,I)),ref:X},o.Children.toArray(b).map((function(e){return s(e,{onMouseEnter:d([e.props.onMouseEnter,D]),onMouseLeave:d([e.props.onMouseLeave,L])})})))))}));export{h as default};
2
2
  //# sourceMappingURL=DialogContent.js.map