{"version":3,"file":"DesktopActions.cjs","names":["_react","_interopRequireDefault","require","_styledComponents","_Button","_ProfileButton","_icons","_styles","_InputFields","_types","_jsxRuntime","_excluded","_excluded2","_excluded3","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","Wrapper","styled","div","BREAKPOINTS","MEDIUM","IconButtonStyled","CustomActionWrapper","ProfileWrapper","DesktopActions","React","forwardRef","_ref","ref","buttons","user","profileComponent","onShowUserMenu","elRefs","setElRefs","useState","searchTermNormalSmall","setSearchTermNormalSmall","useEffect","Array","fill","map","createRef","useImperativeHandle","index","type","renderItem","item","placement","action","rest","_objectWithoutProperties2","jsx","children","ProfileButton","onClick","target","icon","SystemIcons","User","initials","firstName","charAt","lastName","IconButton","variant","shape","id","SwitchApp","size","SearchBar","placeholder","enterSearch","setSearchTerm","searchTerm","removeSearch","Size","Medium","role","propTypes","_propTypes","array","node","func","isRequired","_default","exports"],"sources":["../../../src/GlobalNavigationBar/desktop/DesktopActions.tsx"],"sourcesContent":["import React from 'react';\r\nimport styled from 'styled-components';\r\nimport {MenuAccountInfo, MobileMenuButtonTypes, DesktopMenuButtonTypes} from '../types';\r\nimport {IconButton, IconButtonStyled, IconButtonStyledSecondary} from '../../Button';\r\nimport {ProfileButton} from '../../ProfileButton';\r\nimport {SystemIcons} from '../../icons';\r\nimport {BREAKPOINTS} from '../../styles';\r\nimport { SearchBar } from '../../InputFields';\r\nimport { Size } from '../../types';\r\n\r\nconst Wrapper = styled.div`\r\n  align-items: center;\r\n\r\n  display: none;\r\n\r\n  ${BREAKPOINTS.MEDIUM} {\r\n    display: flex;\r\n  }\r\n\r\n  ${IconButtonStyled}{\r\n    display: 'none';\r\n    ${BREAKPOINTS.MEDIUM} {\r\n      display: block;\r\n    }\r\n  }\r\n`;\r\n\r\nconst CustomActionWrapper = styled.div`\r\n\r\n`;\r\n\r\nconst ProfileWrapper = styled.div`\r\n  margin: 0 8px;\r\n`;\r\n\r\n\r\ninterface DesktopActionsProps {\r\n  buttons?: DesktopMenuButtonTypes[];\r\n  user?: MenuAccountInfo;\r\n  profileComponent?: React.ReactNode\r\n  onShowUserMenu: () => void;\r\n}\r\n\r\nexport interface DesktopActionsRef {\r\n  buttons?: { ref: React.MutableRefObject<HTMLButtonElement | null>, type: 'profile' | 'action' | 'switcher' | undefined }[]\r\n}\r\n\r\nconst  DesktopActions = React.forwardRef(({\r\n                                           buttons,\r\n                                           user,\r\n                                            profileComponent,\r\n                                           onShowUserMenu\r\n                                         }: DesktopActionsProps, ref: React.Ref<DesktopActionsRef>) => {\r\n\r\n  const [elRefs, setElRefs] = React.useState<React.RefObject<HTMLButtonElement | null>[]>([]);\r\n  const [searchTermNormalSmall, setSearchTermNormalSmall] = React.useState('');\r\n\r\n  const length = buttons?.length || 0;\r\n\r\n  React.useEffect(() => {\r\n    setElRefs(Array(length || 0).fill(null).map(() => React.createRef<HTMLButtonElement>()));\r\n  }, [length]);\r\n\r\n  React.useImperativeHandle(ref, () => ({\r\n    buttons: elRefs.map((r, index) => ({\r\n      ref: r,\r\n      type: buttons?.[index]?.type,\r\n    }))\r\n  }), [elRefs, buttons]);\r\n\r\n  const renderItem = (item: MobileMenuButtonTypes, index: number) => {\r\n    switch (item.type) {\r\n      case 'profile': {\r\n        const {placement, type, action, ...rest} = item;\r\n        if(!!profileComponent)\r\n          return <ProfileWrapper>{profileComponent}</ProfileWrapper>;\r\n        else\r\n          return <ProfileWrapper>\r\n            <ProfileButton key={index}\r\n                           ref={elRefs[index]}\r\n                           onClick={e => {\r\n                             item.action ? item.action(e?.target) : onShowUserMenu()\r\n                           }}\r\n                           icon={!user && <SystemIcons.User/>}\r\n                           initials={(user?.firstName?.charAt(0) ?? '') + (user?.lastName?.charAt(0) ?? '')}\r\n                           {...rest}/>\r\n          </ProfileWrapper>\r\n      }\r\n      case 'action': {\r\n        const {placement, type, icon, action, ...rest} = item;\r\n        return <IconButton key={index}\r\n                           ref={elRefs[index]}\r\n                           variant={'secondary'}\r\n                           shape={'circular'}\r\n                           action={e => item.action && item.action(e?.target)}\r\n                           {...rest}>\r\n          {item.icon}\r\n        </IconButton>\r\n      }\r\n      case 'switcher': {\r\n        const {placement, type, action, ...rest} = item;\r\n        return <IconButton key={index}\r\n                           ref={elRefs[index]}\r\n                           variant={'secondary'}\r\n                           shape={'circular'}\r\n                           id=\"globalNavAppsButton\"\r\n                           action={e => item.action && item.action(e?.target)}\r\n                           {...rest}>\r\n          <SystemIcons.SwitchApp size=\"24px\"/>\r\n        </IconButton>\r\n      }\r\n      case 'search': {\r\n        return <CustomActionWrapper key={index}>\r\n           <SearchBar\r\n                id=\"unifiedSearchInputField\"\r\n                placeholder=\"Enter your search term\"\r\n                enterSearch={() => {}}\r\n                setSearchTerm={setSearchTermNormalSmall}\r\n                searchTerm={searchTermNormalSmall}\r\n                removeSearch={() => {\r\n                  setSearchTermNormalSmall('');\r\n                }}\r\n                size={Size.Medium}\r\n              />\r\n        </CustomActionWrapper>;\r\n      }\r\n    }\r\n  }\r\n\r\n  return (\r\n    <Wrapper role=\"toolbar\" aria-label=\"Toolbar\">\r\n      {buttons?.map((item, index) => renderItem(item, index))}\r\n    </Wrapper>\r\n  )\r\n});\r\n\r\n\r\nexport default DesktopActions;\r\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmC,IAAAQ,WAAA,GAAAR,OAAA;AAAA,MAAAS,SAAA;EAAAC,UAAA;EAAAC,UAA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