@pega/cosmos-react-core 4.0.0-dev.19.1 → 4.0.0-dev.19.3

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 (65) hide show
  1. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppShell.js +18 -31
  3. package/lib/components/AppShell/AppShell.js.map +1 -1
  4. package/lib/components/AppShell/AppShell.styles.js +1 -1
  5. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  6. package/lib/components/AppShell/Drawer.d.ts.map +1 -1
  7. package/lib/components/AppShell/Drawer.js +25 -12
  8. package/lib/components/AppShell/Drawer.js.map +1 -1
  9. package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
  10. package/lib/components/AppShell/NavigationList.js +3 -3
  11. package/lib/components/AppShell/NavigationList.js.map +1 -1
  12. package/lib/components/AppShell/Operator.d.ts +2 -2
  13. package/lib/components/AppShell/Operator.d.ts.map +1 -1
  14. package/lib/components/Avatar/Avatar.d.ts +2 -2
  15. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  16. package/lib/components/Backdrop/Backdrop.d.ts +3 -3
  17. package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
  18. package/lib/components/Backdrop/Backdrop.js.map +1 -1
  19. package/lib/components/Card/CardContent.d.ts +2 -2
  20. package/lib/components/Card/CardContent.d.ts.map +1 -1
  21. package/lib/components/Card/CardContent.js.map +1 -1
  22. package/lib/components/ComboBox/ComboBox.styles.d.ts +1 -1
  23. package/lib/components/DateTime/utils.d.ts +9 -4
  24. package/lib/components/DateTime/utils.d.ts.map +1 -1
  25. package/lib/components/DateTime/utils.js +129 -67
  26. package/lib/components/DateTime/utils.js.map +1 -1
  27. package/lib/components/File/FileInput.d.ts +1 -1
  28. package/lib/components/File/FileInput.d.ts.map +1 -1
  29. package/lib/components/FormControl/FormControl.d.ts +1 -1
  30. package/lib/components/FormField/FormField.d.ts +2 -2
  31. package/lib/components/FormField/FormField.d.ts.map +1 -1
  32. package/lib/components/FormField/FormField.js.map +1 -1
  33. package/lib/components/Icon/iconNames.d.ts +1 -1
  34. package/lib/components/Icon/iconNames.d.ts.map +1 -1
  35. package/lib/components/Icon/iconNames.js +2 -0
  36. package/lib/components/Icon/iconNames.js.map +1 -1
  37. package/lib/components/Icon/icons/semitruck-solid.icon.d.ts +5 -0
  38. package/lib/components/Icon/icons/semitruck-solid.icon.d.ts.map +1 -0
  39. package/lib/components/Icon/icons/semitruck-solid.icon.js +7 -0
  40. package/lib/components/Icon/icons/semitruck-solid.icon.js.map +1 -0
  41. package/lib/components/Icon/icons/semitruck.icon.d.ts +5 -0
  42. package/lib/components/Icon/icons/semitruck.icon.d.ts.map +1 -0
  43. package/lib/components/Icon/icons/semitruck.icon.js +7 -0
  44. package/lib/components/Icon/icons/semitruck.icon.js.map +1 -0
  45. package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -2
  46. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  47. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  48. package/lib/components/Modal/Modal.styles.d.ts +1 -1
  49. package/lib/components/Modal/Modal.styles.d.ts.map +1 -1
  50. package/lib/components/Modal/ModalManager.js.map +1 -1
  51. package/lib/components/Number/NumberInput.styles.d.ts +2 -2
  52. package/lib/components/Text/Text.d.ts +1 -1
  53. package/lib/components/Text/Text.d.ts.map +1 -1
  54. package/lib/components/Tree/Tree.d.ts +2 -11
  55. package/lib/components/Tree/Tree.d.ts.map +1 -1
  56. package/lib/components/Tree/Tree.js.map +1 -1
  57. package/lib/theme/ThemeMachine.d.ts +1 -1
  58. package/lib/theme/ThemeMachine.d.ts.map +1 -1
  59. package/lib/theme/ThemeMachine.js.map +1 -1
  60. package/lib/theme/theme.d.ts +549 -549
  61. package/lib/theme/themes/aries2023DarkTheme.json +1 -0
  62. package/lib/types/types.d.ts +14 -6
  63. package/lib/types/types.d.ts.map +1 -1
  64. package/lib/types/types.js.map +1 -1
  65. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAGL,cAAc,EAGd,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,OAAO,EACP,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAEjE,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAOpE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B,EAC/B,eAAe,EACf,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAElE,MAAM,cAAc,GAAqB,KAAK,CAAC,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAChD,MAAM,EACJ,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E,IAAI;YACjB,iBAAiB,EAAE,IAAI;YACvB,eAAe,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;YACtF,GAAG,QAAQ;SACZ,CAAC;QAEF,SAAS,GAAG,mBAAmB,CAAC;KACjC;IAED,OAAO,CACL,KAAC,SAAS,OAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAM,QAAQ,YAClE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChB,IAAI,cAAc,CAAM,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YAE3C,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,EAAE;gBAClD,aAAa,GAAG,cAAc,CAAC;aAChC;iBAAM;gBACL,aAAa,GAAG,kBAAkB,CAAC;aACpC;YAED,OAAO,CACL,KAAC,aAAa,IAEZ,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,KACtB,IAAI,IAHH,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAI5B,CACH,CAAC;QACJ,CAAC,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n ElementType,\n FC,\n isValidElement,\n MouseEvent,\n MouseEventHandler,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n useTheme,\n useArrows,\n useConsolidatedRef,\n useDirection,\n useUID,\n useI18n,\n useEscape\n} from '../../hooks';\nimport ExpandCollapse from '../ExpandCollapse';\nimport BareButton from '../Button/BareButton';\nimport Flex from '../Flex';\nimport Icon, { registerIcon } from '../Icon';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport Link from '../Link';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport {\n NavListItemProps,\n NavListItemWrapperProps,\n NavListProps,\n NavMenuProps\n} from './AppShell.types';\nimport {\n StyledNavList,\n StyledNestedNavList,\n StyledNavItemIconBox,\n StyledNavListItem,\n StyledNavListItemExpandCollapse,\n StyledCaseClose,\n StyledSingleSelectIconBox\n} from './AppShell.styles';\nimport AppShellContext from './AppShellContext';\n\nregisterIcon(timesIcon, checkIcon, caretLeftIcon, caretRightIcon);\n\nconst NavigationMenu: FC<NavMenuProps> = props => {\n const { navOpen } = useContext(AppShellContext);\n const {\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n onDismiss,\n actions,\n forwardedRef,\n ...restProps\n } = props;\n\n const uid = useUID();\n\n const { navState } = useContext(AppShellContext);\n const [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation();\n setCollapsed(state => !state);\n },\n [setCollapsed]\n );\n\n const itemRef = useConsolidatedRef(forwardedRef);\n\n const menuRef = useRef<HTMLLIElement>(null);\n\n useArrows(menuRef, { selector: '[role=\"menuitem\"]', cycle: true });\n\n useEscape(() => {\n setCollapsed(true);\n itemRef.current?.focus();\n }, menuRef);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed={collapsed} ref={menuRef}>\n <BareButton\n id={uid}\n ref={itemRef}\n aria-expanded={!collapsed}\n aria-controls={`${uid}-menu`}\n aria-label={primary}\n onClick={toggleCollapsed}\n >\n {visual && <StyledNavItemIconBox>{visual}</StyledNavItemIconBox>}\n\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n\n {navState === 'open' && <Icon name={`caret-${end}`} as={StyledNavListItemExpandCollapse} />}\n </BareButton>\n\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <NavigationList\n id={`${uid}-menu`}\n nestedList\n items={items}\n collapsed={!navOpen || collapsed}\n />\n </StyledNavListItem>\n );\n};\n\nexport const NavigationListItem: FC<NavListItemProps> = ({\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n collapseItems = false,\n onDismiss,\n actions,\n forwardedRef,\n isMenuItem,\n count,\n singleSelect,\n selected,\n 'aria-labelledby': ariaLabelledBy,\n ...restProps\n}) => {\n const { navOpen, navState } = useContext(AppShellContext);\n const t = useI18n();\n const listItemRef = useConsolidatedRef(forwardedRef);\n const [menuState, setMenuState] = useState('');\n const hasItems =\n (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);\n const compProps: {\n href?: string;\n onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>;\n actions?: NavListItemProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n 'aria-label'?: string;\n } = {\n onClick: (e: MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>) => {\n e.stopPropagation();\n onClick?.(e);\n },\n href\n };\n\n let caseItems: NavListItemWrapperProps['items'] | undefined;\n if (onDismiss) {\n caseItems = [\n {\n primary: t('go_to_noun', [primary]),\n onClick\n },\n {\n primary: t('dismiss_case'),\n onClick: onDismiss\n }\n ];\n }\n\n let Component: ElementType;\n\n if (href) {\n Component = Link;\n } else {\n Component = BareButton;\n }\n\n useEffect(() => {\n if (!navOpen && actions) {\n const node = document.getElementsByTagName('body')[0];\n const clickEvent = document.createEvent('MouseEvent');\n clickEvent.initEvent('mousedown', true, true);\n node.dispatchEvent(clickEvent);\n }\n if (navOpen && isMenuItem && listItemRef.current?.parentElement?.matches(':first-child'))\n listItemRef.current?.focus();\n }, [navOpen]);\n\n const { end } = useDirection();\n const primaryId = useUID();\n\n return (\n <StyledNavListItem {...restProps} key={primary} singleSelect={singleSelect} nestedListCollapsed>\n <NavigationListItemWrapper\n tooltipLabel={secondary ? `${primary} ${secondary}` : primary}\n label={primary}\n childElementRef={listItemRef}\n items={actions || items || caseItems}\n onMenuToggle={setMenuState}\n >\n <Component\n {...compProps}\n ref={listItemRef}\n {...(navOpen && isMenuItem ? { tabIndex: -1, role: 'menuitem' } : {})}\n aria-labelledby={`${primaryId} ${count ? `${primary}-count` : ''} ${ariaLabelledBy}`}\n {...(hasItems && { 'aria-haspopup': 'menu', 'aria-expanded': menuState === 'open' })}\n >\n {singleSelect && (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledSingleSelectIconBox}\n >\n {selected && <Icon name='check' />}\n </Flex>\n )}\n\n {visual && <StyledNavItemIconBox>{visual}</StyledNavItemIconBox>}\n\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span id={primaryId}>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span id={primaryId}>{primary}</span>\n )}\n\n {(hasItems || actions) && navState === 'open' && (\n <Icon name={`caret-${end}`} as={StyledNavListItemExpandCollapse} />\n )}\n </Component>\n </NavigationListItemWrapper>\n\n {onDismiss && navOpen && (\n <Button\n icon\n variant='simple'\n as={StyledCaseClose}\n onClick={onDismiss}\n aria-label={t('dismiss_case')}\n >\n <Icon name='times' />\n </Button>\n )}\n\n {hasItems && (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n <NavigationList nestedList items={actions || items} collapsed={!navOpen || collapseItems} />\n )}\n </StyledNavListItem>\n );\n};\n\nconst NavigationList: FC<NavListProps> = ({\n items = [],\n nestedList,\n id,\n collapsed,\n singleSelect\n}) => {\n let Component: ElementType = StyledNavList;\n let ItemComponent: ElementType;\n const { navOpen } = useContext(AppShellContext);\n\n let fwdProps: {\n as?: ElementType;\n forwardedAs?: ElementType;\n nullWhenCollapsed?: boolean;\n transitionSpeed?: string;\n collapsed: boolean;\n } = {\n collapsed: !!collapsed\n };\n\n const {\n base: { animation }\n } = useTheme();\n\n if (nestedList) {\n fwdProps = {\n as: ExpandCollapse,\n forwardedAs: 'ul',\n nullWhenCollapsed: true,\n transitionSpeed: items.length >= 10 ? `calc(2 * ${animation.speed})` : animation.speed,\n ...fwdProps\n };\n\n Component = StyledNestedNavList;\n }\n\n return (\n <Component {...(nestedList ? { role: 'menu', id } : {})} {...fwdProps}>\n {items.map(item => {\n if (isValidElement<any>(item)) return item;\n\n if (item.items && item.items.length > 0 && navOpen) {\n ItemComponent = NavigationMenu;\n } else {\n ItemComponent = NavigationListItem;\n }\n\n return (\n <ItemComponent\n key={item.id || item.primary}\n isMenuItem={nestedList}\n singleSelect={singleSelect}\n {...item}\n />\n );\n })}\n </Component>\n );\n};\n\nexport default NavigationList;\n"]}
1
+ {"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAGL,cAAc,EAGd,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,OAAO,EACP,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,SAAS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AAC;aAChC;iBAAM;gBACL,aAAa,GAAG,kBAAkB,CAAC;aACpC;YAED,OAAO,CACL,KAAC,aAAa,IAEZ,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,kBACZ,IAAI,CAAC,cAAc,CAAC,KAC9B,IAAI,IAJH,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAK5B,CACH,CAAC;QACJ,CAAC,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n ElementType,\n FC,\n isValidElement,\n MouseEvent,\n MouseEventHandler,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n useTheme,\n useArrows,\n useConsolidatedRef,\n useDirection,\n useUID,\n useI18n,\n useEscape\n} from '../../hooks';\nimport ExpandCollapse from '../ExpandCollapse';\nimport BareButton from '../Button/BareButton';\nimport Flex from '../Flex';\nimport Icon, { registerIcon } from '../Icon';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport Link from '../Link';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport {\n NavListItemProps,\n NavListItemWrapperProps,\n NavListProps,\n NavMenuProps\n} from './AppShell.types';\nimport {\n StyledNavList,\n StyledNestedNavList,\n StyledNavItemIconBox,\n StyledNavListItem,\n StyledNavListItemExpandCollapse,\n StyledCaseClose,\n StyledSingleSelectIconBox\n} from './AppShell.styles';\nimport AppShellContext from './AppShellContext';\n\nregisterIcon(timesIcon, checkIcon, caretLeftIcon, caretRightIcon);\n\nconst NavigationMenu: FC<NavMenuProps> = props => {\n const { navOpen } = useContext(AppShellContext);\n const {\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n onDismiss,\n actions,\n forwardedRef,\n ...restProps\n } = props;\n\n const uid = useUID();\n\n const { navState } = useContext(AppShellContext);\n const [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation();\n setCollapsed(state => !state);\n },\n [setCollapsed]\n );\n\n const itemRef = useConsolidatedRef(forwardedRef);\n\n const menuRef = useRef<HTMLLIElement>(null);\n\n useArrows(menuRef, { selector: '[role=\"menuitem\"]', cycle: true });\n\n useEscape(() => {\n setCollapsed(true);\n itemRef.current?.focus();\n }, menuRef);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed={collapsed} ref={menuRef}>\n <BareButton\n id={uid}\n ref={itemRef}\n aria-expanded={!collapsed}\n aria-controls={`${uid}-menu`}\n aria-label={primary}\n onClick={toggleCollapsed}\n >\n {visual && <StyledNavItemIconBox>{visual}</StyledNavItemIconBox>}\n\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n\n {navState === 'open' && <Icon name={`caret-${end}`} as={StyledNavListItemExpandCollapse} />}\n </BareButton>\n\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <NavigationList\n id={`${uid}-menu`}\n nestedList\n items={items}\n collapsed={!navOpen || collapsed}\n />\n </StyledNavListItem>\n );\n};\n\nexport const NavigationListItem: FC<NavListItemProps> = ({\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n collapseItems = false,\n onDismiss,\n actions,\n forwardedRef,\n isMenuItem,\n count,\n singleSelect,\n selected,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-current': ariaCurrent,\n ...restProps\n}) => {\n const { navOpen, navState } = useContext(AppShellContext);\n const t = useI18n();\n const listItemRef = useConsolidatedRef(forwardedRef);\n const [menuState, setMenuState] = useState('');\n const hasItems =\n (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);\n const compProps: {\n href?: string;\n onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>;\n actions?: NavListItemProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n 'aria-label'?: string;\n } = {\n onClick: (e: MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>) => {\n e.stopPropagation();\n onClick?.(e);\n },\n href\n };\n\n let caseItems: NavListItemWrapperProps['items'] | undefined;\n if (onDismiss) {\n caseItems = [\n {\n primary: t('go_to_noun', [primary]),\n onClick\n },\n {\n primary: t('dismiss_case'),\n onClick: onDismiss\n }\n ];\n }\n\n let Component: ElementType;\n\n if (href) {\n Component = Link;\n } else {\n Component = BareButton;\n }\n\n useEffect(() => {\n if (!navOpen && actions) {\n const node = document.getElementsByTagName('body')[0];\n const clickEvent = document.createEvent('MouseEvent');\n clickEvent.initEvent('mousedown', true, true);\n node.dispatchEvent(clickEvent);\n }\n if (navOpen && isMenuItem && listItemRef.current?.parentElement?.matches(':first-child'))\n listItemRef.current?.focus();\n }, [navOpen]);\n\n const { end } = useDirection();\n const primaryId = useUID();\n\n return (\n <StyledNavListItem {...restProps} key={primary} singleSelect={singleSelect} nestedListCollapsed>\n <NavigationListItemWrapper\n tooltipLabel={secondary ? `${primary} ${secondary}` : primary}\n label={primary}\n childElementRef={listItemRef}\n items={actions || items || caseItems}\n onMenuToggle={setMenuState}\n >\n <Component\n {...compProps}\n ref={listItemRef}\n {...(navOpen && isMenuItem ? { tabIndex: -1, role: 'menuitem' } : {})}\n aria-labelledby={`${primaryId} ${count ? `${primary}-count` : ''} ${ariaLabelledBy}`}\n {...(hasItems && { 'aria-haspopup': 'menu', 'aria-expanded': menuState === 'open' })}\n aria-current={ariaCurrent}\n >\n {singleSelect && (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledSingleSelectIconBox}\n >\n {selected && <Icon name='check' />}\n </Flex>\n )}\n\n {visual && <StyledNavItemIconBox>{visual}</StyledNavItemIconBox>}\n\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span id={primaryId}>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span id={primaryId}>{primary}</span>\n )}\n\n {(hasItems || actions) && navState === 'open' && (\n <Icon name={`caret-${end}`} as={StyledNavListItemExpandCollapse} />\n )}\n </Component>\n </NavigationListItemWrapper>\n\n {onDismiss && navOpen && (\n <Button\n icon\n variant='simple'\n as={StyledCaseClose}\n onClick={onDismiss}\n aria-label={t('dismiss_case')}\n >\n <Icon name='times' />\n </Button>\n )}\n\n {hasItems && (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n <NavigationList nestedList items={actions || items} collapsed={!navOpen || collapseItems} />\n )}\n </StyledNavListItem>\n );\n};\n\nconst NavigationList: FC<NavListProps> = ({\n items = [],\n nestedList,\n id,\n collapsed,\n singleSelect\n}) => {\n let Component: ElementType = StyledNavList;\n let ItemComponent: ElementType;\n const { navOpen } = useContext(AppShellContext);\n\n let fwdProps: {\n as?: ElementType;\n forwardedAs?: ElementType;\n nullWhenCollapsed?: boolean;\n transitionSpeed?: string;\n collapsed: boolean;\n } = {\n collapsed: !!collapsed\n };\n\n const {\n base: { animation }\n } = useTheme();\n\n if (nestedList) {\n fwdProps = {\n as: ExpandCollapse,\n forwardedAs: 'ul',\n nullWhenCollapsed: true,\n transitionSpeed: items.length >= 10 ? `calc(2 * ${animation.speed})` : animation.speed,\n ...fwdProps\n };\n\n Component = StyledNestedNavList;\n }\n\n return (\n <Component {...(nestedList ? { role: 'menu', id } : {})} {...fwdProps}>\n {items.map(item => {\n if (isValidElement<any>(item)) return item;\n\n if (item.items && item.items.length > 0 && navOpen) {\n ItemComponent = NavigationMenu;\n } else {\n ItemComponent = NavigationListItem;\n }\n\n return (\n <ItemComponent\n key={item.id || item.primary}\n isMenuItem={nestedList}\n singleSelect={singleSelect}\n aria-current={item['aria-current']}\n {...item}\n />\n );\n })}\n </Component>\n );\n};\n\nexport default NavigationList;\n"]}
@@ -1,11 +1,11 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { PopoverProps } from '../Popover';
3
- import type { AsProp, OmitStrict } from '../../types';
3
+ import type { AsProp } from '../../types';
4
4
  import { OperatorProps } from './AppShell.types';
5
5
  declare const Operator: import("react").ForwardRefExoticComponent<{
6
6
  children: ReactNode;
7
7
  actions: OperatorProps['actions'];
8
- popover?: OmitStrict<PopoverProps<string>, "show" | "children" | "target"> | undefined;
8
+ popover?: Pick<PopoverProps<string>, "ref" | "className" | "placement" | "arrow" | "modifiers" | "strategy" | "portal" | "showDelay" | "hideDelay" | "groupId" | "hideOnTargetHidden" | "onHide"> | undefined;
9
9
  } & AsProp & import("react").RefAttributes<HTMLButtonElement>>;
10
10
  export default Operator;
11
11
  //# sourceMappingURL=Operator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Operator.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/Operator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,SAAS,EAAuB,MAAM,OAAO,CAAC;AAIjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,QAAA,MAAM,QAAQ;cAQE,SAAS;aACV,aAAa,CAAC,SAAS,CAAC;;8DA6DtC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Operator.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/Operator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,SAAS,EAAuB,MAAM,OAAO,CAAC;AAIjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,QAAA,MAAM,QAAQ;cAQE,SAAS;aACV,aAAa,CAAC,SAAS,CAAC;;8DA6DtC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { FunctionComponent, Ref, SyntheticEvent } from 'react';
2
- import { BaseProps, ForwardProps, PropsWithDefaults, NoChildrenProp, OmitStrict } from '../../types';
2
+ import { BaseProps, ForwardProps, PropsWithDefaults, NoChildrenProp } from '../../types';
3
3
  export interface AvatarProps extends BaseProps, NoChildrenProp {
4
4
  /** The name of the identity the Avatar represents. */
5
5
  name: string;
@@ -30,7 +30,7 @@ export interface AvatarProps extends BaseProps, NoChildrenProp {
30
30
  }
31
31
  type AvatarPropsWithDefaults = PropsWithDefaults<AvatarProps, 'shape' | 'size'>;
32
32
  export declare const StyledAvatarImage: import("styled-components").StyledComponent<FunctionComponent<import("../Image").ImageProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
33
- export declare const StyledAvatar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, OmitStrict<AvatarPropsWithDefaults, "children" | "name"> & {
33
+ export declare const StyledAvatar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<AvatarPropsWithDefaults, "color" | "size" | "icon" | "backgroundColor" | "ref" | "status" | "className" | "shape" | "imageSrc" | "onImageError"> & {
34
34
  hasSrc?: boolean | undefined;
35
35
  hasBrokenImage?: boolean | undefined;
36
36
  }, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,GAAG,EAEH,cAAc,EAIf,MAAM,OAAO,CAAC;AAKf,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACX,M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iBAAiB,EACjB,cAAc,EAEf,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,cAAc;IAC5D,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IAC9B,yDAAyD;IACzD,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,kEAAkE;IAClE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC/D,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,gBAAgB,CAAC,CAAC;CAC9C;AAED,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;AAuBhF,eAAO,MAAM,iBAAiB,mKAQ7B,CAAC;AAEF,eAAO,MAAM,YAAY;;;SAuExB,CAAC;AAIF,eAAO,MAAM,YAAY,4IA0BvB,CAAC;AAiBH;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CAyDzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { FunctionComponent, ReactNode, Ref, MouseEvent } from 'react';
2
- import { BaseProps, ForwardProps } from '../../types';
2
+ import { BaseProps, ForwardProps, ExcludeStrict } from '../../types';
3
3
  import { FlexProps } from '../Flex';
4
4
  export interface BackdropProps extends BaseProps {
5
5
  /**
@@ -10,7 +10,7 @@ export interface BackdropProps extends BaseProps {
10
10
  /** Any React Node to be rendered on top of the Backdrop component. */
11
11
  children?: ReactNode;
12
12
  /** Props passed to Flex container. */
13
- container?: Exclude<FlexProps['container'], boolean>;
13
+ container?: ExcludeStrict<FlexProps['container'], true>;
14
14
  /**
15
15
  * Toggles visibility of Backdrop.
16
16
  * @default false
@@ -44,7 +44,7 @@ export interface BackdropProps extends BaseProps {
44
44
  /** Ref for a Backdrop's root div element. */
45
45
  ref?: Ref<HTMLDivElement>;
46
46
  }
47
- export declare const StyledBackdrop: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../types").OmitStrict<BackdropProps, "alpha" | "open" | "position" | "transitionSpeed"> & Required<Pick<BackdropProps, "alpha" | "open" | "position" | "transitionSpeed">> & {
47
+ export declare const StyledBackdrop: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<BackdropProps, "children" | "ref" | "className" | "onClick" | "variant" | "container" | "onBeforeTransitionIn" | "onAfterTransitionIn" | "onBeforeTransitionOut" | "onAfterTransitionOut"> & Required<Pick<BackdropProps, "alpha" | "open" | "position" | "transitionSpeed">> & {
48
48
  opacity: 0 | 1;
49
49
  }, never>;
50
50
  declare const Backdrop: FunctionComponent<BackdropProps & ForwardProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,EAKT,GAAG,EACH,UAAU,EAEX,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,SAAS,EAAqB,YAAY,EAAE,MAAM,aAAa,CAAC;AACzE,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,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AChC,GAAG,EAAE,IAAI,KACL,SAAS,YAEZ,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n useEffect,\n useState,\n useCallback,\n forwardRef,\n Ref,\n MouseEvent,\n PropsWithoutRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow } from '../../utils';\nimport { BaseProps, PropsWithDefaults, ForwardProps } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { useConsolidatedRef } from '../../hooks';\n\nexport interface BackdropProps extends BaseProps {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\n /** Any React Node to be rendered on top of the Backdrop component. */\n children?: ReactNode;\n /** Props passed to Flex container. */\n container?: Exclude<FlexProps['container'], boolean>;\n /**\n * Toggles visibility of Backdrop.\n * @default false\n */\n open?: boolean;\n /**\n * Determines the color of the Backdrop.\n * @default 'dark'\n */\n variant?: 'dark' | 'light';\n /**\n * Transition speed of Backdrop animation.\n * @default 'medium'\n */\n transitionSpeed?: 'slow' | 'medium' | 'fast' | 'none';\n /**\n * The position of the Backdrop.\n * @default 'fixed'\n */\n position?: 'absolute' | 'fixed';\n /** Accepts a callback function for click event on Backdrop. */\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n /** Accepts a callback that gets invoked before opening Backdrop. */\n onBeforeTransitionIn?: () => void;\n /** Accepts a callback that gets invoked after opening Backdrop. */\n onAfterTransitionIn?: () => void;\n /** Accepts a callback that gets invoked before closing Backdrop. */\n onBeforeTransitionOut?: () => void;\n /** Accepts a callback that gets invoked after closing Backdrop */\n onAfterTransitionOut?: () => void;\n /** Ref for a Backdrop's root div element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype BackdropPropsWithDefaults = PropsWithDefaults<\n BackdropProps,\n 'open' | 'transitionSpeed' | 'alpha' | 'position'\n>;\n\nconst transitionSpeedToTheme = {\n slow: 2,\n medium: 1,\n fast: 0.5,\n none: 0\n} as const;\n\nexport const StyledBackdrop = styled.div<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(props => {\n const {\n theme: { base }\n } = props;\n const { opacity, alpha, variant, position } = props;\n const transitionDuration = `max(calc(${transitionSpeedToTheme[props.transitionSpeed]} * ${\n base.animation.speed\n }), 1ms)`;\n\n return css`\n position: ${position};\n z-index: ${position === 'fixed' ? base['z-index'].backdrop : base['z-index'].popover + 1};\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n opacity: ${opacity};\n transition-property: opacity;\n transition-timing-function: ${props.theme.base.animation.timing.ease};\n /* stylelint-disable declaration-block-no-duplicate-properties */\n transition-duration: 1ms;\n transition-duration: ${transitionDuration};\n /* stylelint-enable declaration-block-no-duplicate-properties */\n\n ${variant === 'dark' &&\n css`\n background: rgba(0, 0, 0, ${alpha});\n `}\n\n ${variant === 'light' &&\n css`\n background: rgba(255, 255, 255, ${alpha});\n `}\n `;\n});\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nconst Backdrop: FunctionComponent<BackdropProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<BackdropProps>, ref: BackdropProps['ref']) => {\n const {\n children,\n container,\n open = false,\n variant = 'dark',\n transitionSpeed = 'medium',\n alpha = 0.6,\n position = 'fixed',\n onBeforeTransitionIn,\n onAfterTransitionIn,\n onBeforeTransitionOut,\n onAfterTransitionOut,\n ...restProps\n } = props;\n\n const cRef = useConsolidatedRef(ref);\n\n const [state, setState] = useState<State>('closed');\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.propertyName !== 'opacity' || e.target !== e.currentTarget) return;\n let nextState: State;\n\n if (state === 'closing') {\n nextState = 'closed';\n onAfterTransitionOut?.();\n } else {\n nextState = 'open';\n onAfterTransitionIn?.();\n }\n\n setState(nextState);\n },\n [state, onAfterTransitionOut, onAfterTransitionIn]\n );\n\n useEffect(() => {\n if (open) {\n if (state === 'closed' || state === 'closing') {\n onBeforeTransitionIn?.();\n reflow();\n setState('opening');\n }\n } else if (state === 'open' || state === 'opening') {\n onBeforeTransitionOut?.();\n setState('closing');\n }\n }, [open]);\n\n // Using a separate effect instead of combined logic above as it seems more intuitive to mentally manage.\n useEffect(() => {\n if (!cRef.current) return;\n const opacity = window.getComputedStyle(cRef.current).opacity;\n // If the opacity is already at the destination value, sync the state value.\n if (state === 'closing' && opacity === '0') {\n // Since the transition never ran, we have to pretend it did and call the callback.\n // TODO: This maybe can be fixed with the animation api\n onAfterTransitionOut?.();\n setState('closed');\n }\n if (state === 'opening' && opacity === '1') {\n // ditto, see above...\n onAfterTransitionIn?.();\n setState('open');\n }\n }, [state]);\n\n return !open && state === 'closed' ? null : (\n <Flex\n container={{ justify: 'center', alignItems: 'center', ...container }}\n as={StyledBackdrop}\n transitionSpeed={transitionSpeed}\n opacity={state === 'opening' || state === 'open' ? 1 : 0}\n alpha={alpha}\n variant={variant}\n position={position}\n onTransitionEnd={onTransitionEnd}\n ref={cRef}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nexport default Backdrop;\n"]}
1
+ {"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EAIX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmDjD,MAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,CAAC;IACP,MAAM,EAA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AO,CAAC;QAC9D,4EAA4E;QAC5E,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,GAAG,EAAE;YAC1C,mFAAmF;YACnF,uDAAuD;YACvD,oBAAoB,EAAE,EAAE,CAAC;YACzB,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACpB;QACD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,GAAG,EAAE;YAC1C,sBAAsB;YACtB,mBAAmB,EAAE,EAAE,CAAC;YACxB,QAAQ,CAAC,MAAM,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAAC,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1C,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EACpE,EAAE,EAAE,cAAc,EAClB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,GAAG,EAAE,IAAI,KACL,SAAS,YAEZ,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n useEffect,\n useState,\n useCallback,\n forwardRef,\n Ref,\n MouseEvent,\n PropsWithoutRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow } from '../../utils';\nimport { BaseProps, PropsWithDefaults, ForwardProps, ExcludeStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { useConsolidatedRef } from '../../hooks';\n\nexport interface BackdropProps extends BaseProps {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\n /** Any React Node to be rendered on top of the Backdrop component. */\n children?: ReactNode;\n /** Props passed to Flex container. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /**\n * Toggles visibility of Backdrop.\n * @default false\n */\n open?: boolean;\n /**\n * Determines the color of the Backdrop.\n * @default 'dark'\n */\n variant?: 'dark' | 'light';\n /**\n * Transition speed of Backdrop animation.\n * @default 'medium'\n */\n transitionSpeed?: 'slow' | 'medium' | 'fast' | 'none';\n /**\n * The position of the Backdrop.\n * @default 'fixed'\n */\n position?: 'absolute' | 'fixed';\n /** Accepts a callback function for click event on Backdrop. */\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n /** Accepts a callback that gets invoked before opening Backdrop. */\n onBeforeTransitionIn?: () => void;\n /** Accepts a callback that gets invoked after opening Backdrop. */\n onAfterTransitionIn?: () => void;\n /** Accepts a callback that gets invoked before closing Backdrop. */\n onBeforeTransitionOut?: () => void;\n /** Accepts a callback that gets invoked after closing Backdrop */\n onAfterTransitionOut?: () => void;\n /** Ref for a Backdrop's root div element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype BackdropPropsWithDefaults = PropsWithDefaults<\n BackdropProps,\n 'open' | 'transitionSpeed' | 'alpha' | 'position'\n>;\n\nconst transitionSpeedToTheme = {\n slow: 2,\n medium: 1,\n fast: 0.5,\n none: 0\n} as const;\n\nexport const StyledBackdrop = styled.div<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(props => {\n const {\n theme: { base }\n } = props;\n const { opacity, alpha, variant, position } = props;\n const transitionDuration = `max(calc(${transitionSpeedToTheme[props.transitionSpeed]} * ${\n base.animation.speed\n }), 1ms)`;\n\n return css`\n position: ${position};\n z-index: ${position === 'fixed' ? base['z-index'].backdrop : base['z-index'].popover + 1};\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n opacity: ${opacity};\n transition-property: opacity;\n transition-timing-function: ${props.theme.base.animation.timing.ease};\n /* stylelint-disable declaration-block-no-duplicate-properties */\n transition-duration: 1ms;\n transition-duration: ${transitionDuration};\n /* stylelint-enable declaration-block-no-duplicate-properties */\n\n ${variant === 'dark' &&\n css`\n background: rgba(0, 0, 0, ${alpha});\n `}\n\n ${variant === 'light' &&\n css`\n background: rgba(255, 255, 255, ${alpha});\n `}\n `;\n});\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nconst Backdrop: FunctionComponent<BackdropProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<BackdropProps>, ref: BackdropProps['ref']) => {\n const {\n children,\n container,\n open = false,\n variant = 'dark',\n transitionSpeed = 'medium',\n alpha = 0.6,\n position = 'fixed',\n onBeforeTransitionIn,\n onAfterTransitionIn,\n onBeforeTransitionOut,\n onAfterTransitionOut,\n ...restProps\n } = props;\n\n const cRef = useConsolidatedRef(ref);\n\n const [state, setState] = useState<State>('closed');\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.propertyName !== 'opacity' || e.target !== e.currentTarget) return;\n let nextState: State;\n\n if (state === 'closing') {\n nextState = 'closed';\n onAfterTransitionOut?.();\n } else {\n nextState = 'open';\n onAfterTransitionIn?.();\n }\n\n setState(nextState);\n },\n [state, onAfterTransitionOut, onAfterTransitionIn]\n );\n\n useEffect(() => {\n if (open) {\n if (state === 'closed' || state === 'closing') {\n onBeforeTransitionIn?.();\n reflow();\n setState('opening');\n }\n } else if (state === 'open' || state === 'opening') {\n onBeforeTransitionOut?.();\n setState('closing');\n }\n }, [open]);\n\n // Using a separate effect instead of combined logic above as it seems more intuitive to mentally manage.\n useEffect(() => {\n if (!cRef.current) return;\n const opacity = window.getComputedStyle(cRef.current).opacity;\n // If the opacity is already at the destination value, sync the state value.\n if (state === 'closing' && opacity === '0') {\n // Since the transition never ran, we have to pretend it did and call the callback.\n // TODO: This maybe can be fixed with the animation api\n onAfterTransitionOut?.();\n setState('closed');\n }\n if (state === 'opening' && opacity === '1') {\n // ditto, see above...\n onAfterTransitionIn?.();\n setState('open');\n }\n }, [state]);\n\n return !open && state === 'closed' ? null : (\n <Flex\n container={{ justify: 'center', alignItems: 'center', ...container }}\n as={StyledBackdrop}\n transitionSpeed={transitionSpeed}\n opacity={state === 'opening' || state === 'open' ? 1 : 0}\n alpha={alpha}\n variant={variant}\n position={position}\n onTransitionEnd={onTransitionEnd}\n ref={cRef}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nexport default Backdrop;\n"]}
@@ -1,10 +1,10 @@
1
1
  import { FunctionComponent, ReactNode } from 'react';
2
- import { BaseProps, ForwardProps } from '../../types';
2
+ import { BaseProps, ExcludeStrict, ForwardProps } from '../../types';
3
3
  import { FlexProps } from '../Flex';
4
4
  export interface CardContentProps extends BaseProps {
5
5
  /** The content of the Card. */
6
6
  children: ReactNode;
7
- container?: Exclude<FlexProps['container'], boolean>;
7
+ container?: ExcludeStrict<FlexProps['container'], true>;
8
8
  }
9
9
  export declare const StyledCardContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
10
10
  declare const CardContent: FunctionComponent<CardContentProps & ForwardProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"CardContent.d.ts","sourceRoot":"","sources":["../../../src/components/Card/CardContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAM1C,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,+BAA+B;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;CACtD;AAED,eAAO,MAAM,iBAAiB,yGAY5B,CAAC;AAIH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAUnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"CardContent.d.ts","sourceRoot":"","sources":["../../../src/components/Card/CardContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAM1C,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,+BAA+B;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,iBAAiB,yGAY5B,CAAC;AAIH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAUnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardContent.js","sourceRoot":"","sources":["../../../src/components/Card/CardContent.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACxD,OAAO,GAAG,CAAA;MACN,aAAa,aAAa,UAAU,IAAI,UAAU;;4BAE5B,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO;;;YAGzE,gBAAgB;;;;GAIzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,WAAW,GAAuD,CAAC,EACvE,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACuC,EAAE,EAAE;IACvD,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE,EAAE,iBAAiB,YACzF,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FunctionComponent, PropsWithChildren, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCard } from './Card';\nimport { StyledCardFooter } from './CardFooter';\n\nexport interface CardContentProps extends BaseProps {\n /** The content of the Card. */\n children: ReactNode;\n container?: Exclude<FlexProps['container'], boolean>;\n}\n\nexport const StyledCardContent = styled.div(({ theme }) => {\n return css`\n ${StyledPopover} &, &:not(${StyledCard} ${StyledCard} > &) {\n position: relative;\n padding: calc(1.5 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n\n & + &,\n & + ${StyledCardFooter} {\n padding-block-start: 0;\n }\n }\n `;\n});\n\nStyledCardContent.defaultProps = defaultThemeProp;\n\nconst CardContent: FunctionComponent<CardContentProps & ForwardProps> = ({\n children,\n container,\n ...restProps\n}: PropsWithChildren<CardContentProps & ForwardProps>) => {\n return (\n <Flex {...restProps} container={{ direction: 'column', ...container }} as={StyledCardContent}>\n {children}\n </Flex>\n );\n};\n\nexport default CardContent;\n"]}
1
+ {"version":3,"file":"CardContent.js","sourceRoot":"","sources":["../../../src/components/Card/CardContent.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACxD,OAAO,GAAG,CAAA;MACN,aAAa,aAAa,UAAU,IAAI,UAAU;;4BAE5B,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO;;;YAGzE,gBAAgB;;;;GAIzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,WAAW,GAAuD,CAAC,EACvE,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACuC,EAAE,EAAE;IACvD,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE,EAAE,iBAAiB,YACzF,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FunctionComponent, PropsWithChildren, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ExcludeStrict, ForwardProps } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCard } from './Card';\nimport { StyledCardFooter } from './CardFooter';\n\nexport interface CardContentProps extends BaseProps {\n /** The content of the Card. */\n children: ReactNode;\n container?: ExcludeStrict<FlexProps['container'], true>;\n}\n\nexport const StyledCardContent = styled.div(({ theme }) => {\n return css`\n ${StyledPopover} &, &:not(${StyledCard} ${StyledCard} > &) {\n position: relative;\n padding: calc(1.5 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n\n & + &,\n & + ${StyledCardFooter} {\n padding-block-start: 0;\n }\n }\n `;\n});\n\nStyledCardContent.defaultProps = defaultThemeProp;\n\nconst CardContent: FunctionComponent<CardContentProps & ForwardProps> = ({\n children,\n container,\n ...restProps\n}: PropsWithChildren<CardContentProps & ForwardProps>) => {\n return (\n <Flex {...restProps} container={{ direction: 'column', ...container }} as={StyledCardContent}>\n {children}\n </Flex>\n );\n};\n\nexport default CardContent;\n"]}
@@ -1,5 +1,5 @@
1
1
  export declare const StyledSelectInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
- export declare const StyledComboBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../..").OmitStrict<import("../FormControl").FormControlProps, never> & Required<Pick<import("../FormControl").FormControlProps, never>> & {
2
+ export declare const StyledComboBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<import("../FormControl").FormControlProps, keyof import("../FormControl").FormControlProps> & Required<Pick<import("../FormControl").FormControlProps, never>> & {
3
3
  hasSuggestion?: boolean | undefined;
4
4
  }, never>;
5
5
  //# sourceMappingURL=ComboBox.styles.d.ts.map
@@ -1,14 +1,19 @@
1
1
  import { TranslationFunction, TranslationPack } from '../../i18n';
2
+ import { ExcludeStrict } from '../../types';
2
3
  import { DateTimeFormat, DateTimeVariant } from './DateTime.types';
3
4
  import { ClockFormat } from './Input/utils';
4
- interface DateTimeFormatOptions {
5
- t: TranslationFunction<TranslationPack>;
5
+ type DateTimeFormatOptions = {
6
6
  locale: string;
7
7
  format: DateTimeFormat;
8
- variant: DateTimeVariant;
9
8
  timeZone?: string;
10
9
  clockFormat?: ClockFormat;
11
- }
10
+ } & ({
11
+ variant: ExcludeStrict<DateTimeVariant, 'quarteryear'>;
12
+ t?: TranslationFunction<TranslationPack>;
13
+ } | {
14
+ variant: 'quarteryear';
15
+ t: TranslationFunction<TranslationPack>;
16
+ });
12
17
  export declare function formatDateTime(value: Date, { t, locale, format, variant, clockFormat, timeZone }: DateTimeFormatOptions): string;
13
18
  interface DurationFormatOptions {
14
19
  locale: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAmB,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EAMZ,MAAM,eAAe,CAAC;AAsBvB,UAAU,qBAAqB;IAC7B,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,EACX,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,qBAAqB,UA4K7E;AAOD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,WAAW,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;CACvD;AAED,wBAAgB,cAA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BAAgB,EAAE,WAAsB,EAAE,EAAE,qBAAqB,UAyC5E"}
@@ -8,66 +8,121 @@ const unitsInMs = {
8
8
  minute: 60 * 1000,
9
9
  second: 1000
10
10
  };
11
+ const timeShort = {
12
+ hour: 'numeric',
13
+ minute: 'numeric'
14
+ };
15
+ const timeShort12 = {
16
+ ...timeShort,
17
+ hour12: true
18
+ };
19
+ const timeShort24 = {
20
+ ...timeShort,
21
+ hour12: false
22
+ };
23
+ const timeLong = {
24
+ ...timeShort,
25
+ second: 'numeric'
26
+ };
27
+ const timeLong12 = {
28
+ ...timeShort12,
29
+ second: 'numeric'
30
+ };
31
+ const timeLong24 = {
32
+ ...timeShort24,
33
+ second: 'numeric'
34
+ };
35
+ const formatMapping = {
36
+ date: {
37
+ short: { year: 'numeric', month: 'short', day: 'numeric' },
38
+ long: { year: 'numeric', month: 'long', day: 'numeric' },
39
+ numeric: { year: 'numeric', month: 'numeric', day: 'numeric' }
40
+ },
41
+ datetime: {
42
+ short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort },
43
+ long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong },
44
+ numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort }
45
+ },
46
+ datetime12: {
47
+ short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort12 },
48
+ long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong12 },
49
+ numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort12 }
50
+ },
51
+ datetime24: {
52
+ short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort24 },
53
+ long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong24 },
54
+ numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort24 }
55
+ },
56
+ time: {
57
+ short: timeShort,
58
+ long: timeLong,
59
+ numeric: timeShort
60
+ },
61
+ time12: {
62
+ short: timeShort12,
63
+ long: timeLong12,
64
+ numeric: timeShort12
65
+ },
66
+ time24: {
67
+ short: timeShort24,
68
+ long: timeLong24,
69
+ numeric: timeShort24
70
+ },
71
+ month: {
72
+ short: { month: 'short' },
73
+ long: { month: 'long' },
74
+ numeric: { month: 'numeric' }
75
+ },
76
+ monthyear: {
77
+ short: { year: 'numeric', month: 'short' },
78
+ long: { year: 'numeric', month: 'long' },
79
+ numeric: { year: 'numeric', month: 'numeric' }
80
+ },
81
+ week: {
82
+ short: { month: 'short', day: 'numeric' },
83
+ long: { month: 'long', day: 'numeric' },
84
+ numeric: { month: 'numeric', day: 'numeric' }
85
+ },
86
+ year: {
87
+ short: { year: 'numeric' },
88
+ long: { year: 'numeric' },
89
+ numeric: { year: '2-digit' }
90
+ },
91
+ relative: {
92
+ short: { style: 'long', numeric: 'auto' },
93
+ long: { style: 'long', numeric: 'auto' },
94
+ numeric: { style: 'short', numeric: 'auto' }
95
+ }
96
+ };
97
+ const dateTimeFormatCache = {};
98
+ const relativeTimeFormatCache = {};
99
+ const displayNamesCache = {};
11
100
  export function formatDateTime(value, { t, locale, format, variant, clockFormat, timeZone }) {
12
- const timeShort = {
13
- hour: 'numeric',
14
- minute: 'numeric',
15
- hour12: clockFormat ? clockFormat === 12 : undefined
16
- };
17
- const timeLong = {
18
- ...timeShort,
19
- second: 'numeric'
20
- };
21
- const formatMapping = {
22
- date: {
23
- short: { year: 'numeric', month: 'short', day: 'numeric' },
24
- long: { year: 'numeric', month: 'long', day: 'numeric' },
25
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric' }
26
- },
27
- datetime: {
28
- short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort },
29
- long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong },
30
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort }
31
- },
32
- time: {
33
- short: timeShort,
34
- long: timeLong,
35
- numeric: timeShort
36
- },
37
- month: {
38
- short: { month: 'short' },
39
- long: { month: 'long' },
40
- numeric: { month: 'numeric' }
41
- },
42
- year: {
43
- short: { year: 'numeric' },
44
- long: { year: 'numeric' },
45
- numeric: { year: '2-digit' }
46
- },
47
- monthyear: {
48
- short: { year: 'numeric', month: 'short' },
49
- long: { year: 'numeric', month: 'long' },
50
- numeric: { year: 'numeric', month: 'numeric' }
51
- },
52
- week: {
53
- short: { month: 'short', day: 'numeric' },
54
- long: { month: 'long', day: 'numeric' },
55
- numeric: { month: 'numeric', day: 'numeric' }
56
- },
57
- relative: {
58
- short: { style: 'long', numeric: 'auto' },
59
- long: { style: 'long', numeric: 'auto' },
60
- numeric: { style: 'short', numeric: 'auto' }
61
- }
62
- };
63
101
  const getFormattedDate = (date, dateVariant, overrideTimeZone) => {
64
- return new Intl.DateTimeFormat(locale, {
65
- ...formatMapping[dateVariant][format],
66
- timeZone: overrideTimeZone ?? timeZone
67
- }).format(date);
102
+ const resolvedVariant = dateVariant === 'time' || dateVariant === 'datetime'
103
+ ? `${dateVariant}${clockFormat ?? ''}`
104
+ : dateVariant;
105
+ const resolvedTimeZone = overrideTimeZone ?? timeZone;
106
+ const resolvedOptions = formatMapping[resolvedVariant][format];
107
+ dateTimeFormatCache[locale] ??= {};
108
+ dateTimeFormatCache[locale][`${resolvedTimeZone}`] ??= new Map();
109
+ const map = dateTimeFormatCache[locale][`${resolvedTimeZone}`];
110
+ if (!map.has(resolvedOptions)) {
111
+ map.set(resolvedOptions, new Intl.DateTimeFormat(locale, {
112
+ ...resolvedOptions,
113
+ timeZone: resolvedTimeZone
114
+ }));
115
+ }
116
+ return map.get(resolvedOptions).format(date);
68
117
  };
69
118
  const relativeTimeFormatter = (relativeValue, unit) => {
70
- return new Intl.RelativeTimeFormat(locale, formatMapping.relative[format]).format(relativeValue, unit);
119
+ const resolvedOptions = formatMapping.relative[format];
120
+ relativeTimeFormatCache[locale] ??= new Map();
121
+ const map = relativeTimeFormatCache[locale];
122
+ if (!map.has(resolvedOptions)) {
123
+ map.set(resolvedOptions, new Intl.RelativeTimeFormat(locale, resolvedOptions));
124
+ }
125
+ return map.get(resolvedOptions).format(relativeValue, unit);
71
126
  };
72
127
  const getUnitsElapsed = (date, unit) => {
73
128
  let amount;
@@ -139,10 +194,11 @@ export function formatDateTime(value, { t, locale, format, variant, clockFormat,
139
194
  return relativeTimeFormatter(amount, unit);
140
195
  };
141
196
  const getFormattedWeek = (date) => {
142
- const displayNames = new Intl.DisplayNames(locale, {
197
+ displayNamesCache[locale] ??= new Intl.DisplayNames(locale, {
143
198
  style: 'long',
144
199
  type: 'dateTimeField'
145
200
  });
201
+ const displayNames = displayNamesCache[locale];
146
202
  const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
147
203
  const startDate = getFormattedDate(getStartOfWeek(adjustedUTCDate), 'week', 'UTC');
148
204
  const endDate = getFormattedDate(getEndOfWeek(adjustedUTCDate), 'week', 'UTC');
@@ -169,16 +225,19 @@ const dayInMs = 24 * 60 * 60 * 1000;
169
225
  const hourInMs = 60 * 60 * 1000;
170
226
  const minuteInMs = 60 * 1000;
171
227
  const secondInMs = 1000;
228
+ const numberFormatCache = {};
172
229
  export function formatDuration(valueInMs, { locale, significantUnits, unitDisplay = 'narrow' }) {
173
- const numberFormatterSeconds = new Intl.NumberFormat(locale, {
174
- style: 'unit',
175
- unit: 'second',
176
- unitDisplay
177
- });
230
+ numberFormatCache[locale] ??= {};
178
231
  const sign = valueInMs < 0 ? '-' : '';
179
232
  const absMs = Math.abs(valueInMs);
180
233
  if (absMs < secondInMs) {
181
- return numberFormatterSeconds.format(0);
234
+ numberFormatCache[locale].seconds ??= {};
235
+ numberFormatCache[locale].seconds.narrow ??= new Intl.NumberFormat(locale, {
236
+ style: 'unit',
237
+ unit: 'second',
238
+ unitDisplay: 'narrow'
239
+ });
240
+ return numberFormatCache[locale].seconds.narrow.format(0);
182
241
  }
183
242
  const durationParts = [
184
243
  { unit: 'day', value: Math.floor(absMs / dayInMs) },
@@ -188,12 +247,15 @@ export function formatDuration(valueInMs, { locale, significantUnits, unitDispla
188
247
  ];
189
248
  const result = [];
190
249
  for (let i = 0; result.length < significantUnits && i < durationParts.length; i += 1) {
191
- if (durationParts[i].value > 0) {
192
- result.push(new Intl.NumberFormat(locale, {
250
+ const { value, unit } = durationParts[i];
251
+ if (value > 0) {
252
+ numberFormatCache[locale][unit] ??= {};
253
+ numberFormatCache[locale][unit][unitDisplay] ??= new Intl.NumberFormat(locale, {
193
254
  style: 'unit',
194
- unit: durationParts[i].unit,
255
+ unit,
195
256
  unitDisplay
196
- }).format(durationParts[i].value));
257
+ });
258
+ result.push(numberFormatCache[locale][unit][unitDisplay].format(value));
197
259
  }
198
260
  }
199
261
  return `${sign}${result.join(' ')}`;