@pega/cosmos-react-core 3.0.0-dev.16.1 → 3.0.0-dev.18.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 (242) hide show
  1. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppHeader.js +4 -6
  3. package/lib/components/AppShell/AppHeader.js.map +1 -1
  4. package/lib/components/AppShell/AppHeader.styles.d.ts +16 -0
  5. package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -0
  6. package/lib/components/AppShell/AppHeader.styles.js +155 -0
  7. package/lib/components/AppShell/AppHeader.styles.js.map +1 -0
  8. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  9. package/lib/components/AppShell/AppShell.js +44 -157
  10. package/lib/components/AppShell/AppShell.js.map +1 -1
  11. package/lib/components/AppShell/AppShell.styles.d.ts +7 -51
  12. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  13. package/lib/components/AppShell/AppShell.styles.js +44 -535
  14. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  15. package/lib/components/AppShell/AppShell.types.d.ts +16 -5
  16. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  17. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  18. package/lib/components/AppShell/AppShellContext.d.ts +2 -0
  19. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
  20. package/lib/components/AppShell/AppShellContext.js +2 -0
  21. package/lib/components/AppShell/AppShellContext.js.map +1 -1
  22. package/lib/components/AppShell/AppShellList.js +3 -1
  23. package/lib/components/AppShell/AppShellList.js.map +1 -1
  24. package/lib/components/AppShell/AppShellList.styles.d.ts +19 -0
  25. package/lib/components/AppShell/AppShellList.styles.d.ts.map +1 -0
  26. package/lib/components/AppShell/AppShellList.styles.js +141 -0
  27. package/lib/components/AppShell/AppShellList.styles.js.map +1 -0
  28. package/lib/components/AppShell/AppShellSearch.d.ts +10 -0
  29. package/lib/components/AppShell/AppShellSearch.d.ts.map +1 -0
  30. package/lib/components/AppShell/AppShellSearch.js +32 -0
  31. package/lib/components/AppShell/AppShellSearch.js.map +1 -0
  32. package/lib/components/AppShell/AppShellSearch.styles.d.ts +8 -0
  33. package/lib/components/AppShell/AppShellSearch.styles.d.ts.map +1 -0
  34. package/lib/components/AppShell/AppShellSearch.styles.js +190 -0
  35. package/lib/components/AppShell/AppShellSearch.styles.js.map +1 -0
  36. package/lib/components/AppShell/Drawer.js +2 -2
  37. package/lib/components/AppShell/Drawer.js.map +1 -1
  38. package/lib/components/AppShell/Drawer.styles.d.ts +15 -0
  39. package/lib/components/AppShell/Drawer.styles.d.ts.map +1 -0
  40. package/lib/components/AppShell/Drawer.styles.js +153 -0
  41. package/lib/components/AppShell/Drawer.styles.js.map +1 -0
  42. package/lib/components/AppShell/NavigationList.d.ts +5 -0
  43. package/lib/components/AppShell/NavigationList.d.ts.map +1 -0
  44. package/lib/components/AppShell/NavigationList.js +123 -0
  45. package/lib/components/AppShell/NavigationList.js.map +1 -0
  46. package/lib/components/AppShell/NavigationListItemWrapper.d.ts +5 -0
  47. package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -0
  48. package/lib/components/AppShell/NavigationListItemWrapper.js +109 -0
  49. package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -0
  50. package/lib/components/AppShell/Operator.js +4 -4
  51. package/lib/components/AppShell/Operator.js.map +1 -1
  52. package/lib/components/Badges/Keyboard.d.ts.map +1 -1
  53. package/lib/components/Badges/Keyboard.js +2 -0
  54. package/lib/components/Badges/Keyboard.js.map +1 -1
  55. package/lib/components/Badges/Selection.d.ts +1 -1
  56. package/lib/components/Badges/Selection.d.ts.map +1 -1
  57. package/lib/components/Badges/Selection.js +4 -2
  58. package/lib/components/Badges/Selection.js.map +1 -1
  59. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
  60. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  61. package/lib/components/Breadcrumbs/Breadcrumbs.js +27 -7
  62. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  63. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  64. package/lib/components/ComboBox/ComboBox.js +56 -15
  65. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  66. package/lib/components/ComboBox/ComboBox.styles.d.ts +3 -1
  67. package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
  68. package/lib/components/ComboBox/ComboBox.types.d.ts +5 -1
  69. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  70. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  71. package/lib/components/ComboBox/ComboBoxInput.d.ts +7 -0
  72. package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
  73. package/lib/components/ComboBox/ComboBoxInput.js +5 -2
  74. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  75. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  76. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +113 -37
  77. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  78. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +10 -0
  79. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
  80. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
  81. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  82. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +2 -2
  83. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  84. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts +2 -0
  85. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts.map +1 -1
  86. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.js.map +1 -1
  87. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  88. package/lib/components/CompositeInput/CompositeInput.js +2 -2
  89. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  90. package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
  91. package/lib/components/CompositeInput/CompositeInput.styles.js +20 -17
  92. package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
  93. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  94. package/lib/components/Currency/CurrencyInput.js +12 -3
  95. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  96. package/lib/components/Currency/utils.d.ts.map +1 -1
  97. package/lib/components/Currency/utils.js +3 -2
  98. package/lib/components/Currency/utils.js.map +1 -1
  99. package/lib/components/DateTime/DateTime.types.d.ts +2 -0
  100. package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
  101. package/lib/components/DateTime/DateTime.types.js.map +1 -1
  102. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  103. package/lib/components/DateTime/Input/DateInput.js +12 -3
  104. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  105. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  106. package/lib/components/DateTime/Input/DateTimeInput.js +12 -3
  107. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  108. package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
  109. package/lib/components/DateTime/Picker/Calendar.js +6 -12
  110. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  111. package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -4
  112. package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
  113. package/lib/components/DateTime/Picker/Calendar.styles.js +12 -54
  114. package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
  115. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  116. package/lib/components/DateTime/Picker/DatePicker.js +2 -1
  117. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  118. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +3 -0
  119. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -0
  120. package/lib/components/DateTime/Picker/DatePicker.styles.js +39 -0
  121. package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -0
  122. package/lib/components/DateTime/Picker/DateRangePicker.js +1 -1
  123. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  124. package/lib/components/DateTime/Picker/TimePicker.d.ts.map +1 -1
  125. package/lib/components/DateTime/Picker/TimePicker.js +10 -5
  126. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  127. package/lib/components/DateTime/index.d.ts +2 -0
  128. package/lib/components/DateTime/index.d.ts.map +1 -1
  129. package/lib/components/DateTime/index.js +2 -0
  130. package/lib/components/DateTime/index.js.map +1 -1
  131. package/lib/components/Dialog/Dialog.d.ts.map +1 -1
  132. package/lib/components/Dialog/Dialog.js +3 -2
  133. package/lib/components/Dialog/Dialog.js.map +1 -1
  134. package/lib/components/ExpandCollapse/ExpandCollapse.d.ts.map +1 -1
  135. package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
  136. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  137. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  138. package/lib/components/FieldGroup/FieldGroup.js +27 -24
  139. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  140. package/lib/components/FormControl/FormControl.d.ts +6 -2
  141. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  142. package/lib/components/FormControl/FormControl.js +60 -35
  143. package/lib/components/FormControl/FormControl.js.map +1 -1
  144. package/lib/components/FormField/FormField.d.ts.map +1 -1
  145. package/lib/components/FormField/FormField.js +65 -5
  146. package/lib/components/FormField/FormField.js.map +1 -1
  147. package/lib/components/Input/Input.d.ts.map +1 -1
  148. package/lib/components/Input/Input.js +13 -2
  149. package/lib/components/Input/Input.js.map +1 -1
  150. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  151. package/lib/components/ListToolbar/ListToolbar.js +64 -9
  152. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  153. package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -0
  154. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  155. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  156. package/lib/components/ListToolbar/PresetMenuPopover.d.ts +12 -0
  157. package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -0
  158. package/lib/components/ListToolbar/PresetMenuPopover.js +36 -0
  159. package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -0
  160. package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -1
  161. package/lib/components/ListToolbar/QueryOptionPopover.js +14 -44
  162. package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -1
  163. package/lib/components/Menu/Menu.d.ts.map +1 -1
  164. package/lib/components/Menu/Menu.js +8 -5
  165. package/lib/components/Menu/Menu.js.map +1 -1
  166. package/lib/components/Menu/Menu.styles.js +1 -1
  167. package/lib/components/Menu/Menu.styles.js.map +1 -1
  168. package/lib/components/Menu/Menu.types.d.ts +13 -0
  169. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  170. package/lib/components/Menu/Menu.types.js.map +1 -1
  171. package/lib/components/Menu/MenuGroup.d.ts.map +1 -1
  172. package/lib/components/Menu/MenuGroup.js +3 -3
  173. package/lib/components/Menu/MenuGroup.js.map +1 -1
  174. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  175. package/lib/components/Menu/MenuItem.js +3 -5
  176. package/lib/components/Menu/MenuItem.js.map +1 -1
  177. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  178. package/lib/components/Menu/MenuList.js +14 -14
  179. package/lib/components/Menu/MenuList.js.map +1 -1
  180. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  181. package/lib/components/Number/NumberInput.js +13 -4
  182. package/lib/components/Number/NumberInput.js.map +1 -1
  183. package/lib/components/Number/NumberInput.styles.d.ts +6 -2
  184. package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
  185. package/lib/components/Number/NumberInput.styles.js +4 -2
  186. package/lib/components/Number/NumberInput.styles.js.map +1 -1
  187. package/lib/components/Number/NumberInput.types.d.ts +2 -0
  188. package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
  189. package/lib/components/Number/NumberInput.types.js.map +1 -1
  190. package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
  191. package/lib/components/PageTemplates/DashboardPage.js +1 -4
  192. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  193. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  194. package/lib/components/Phone/PhoneInput.js +12 -3
  195. package/lib/components/Phone/PhoneInput.js.map +1 -1
  196. package/lib/components/SearchInput/SearchInput.d.ts +5 -0
  197. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  198. package/lib/components/SearchInput/SearchInput.js +14 -4
  199. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  200. package/lib/components/SearchInput/SearchInput.styles.d.ts +3 -0
  201. package/lib/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  202. package/lib/components/SearchInput/SearchInput.styles.js +6 -0
  203. package/lib/components/SearchInput/SearchInput.styles.js.map +1 -1
  204. package/lib/components/Select/Select.d.ts +2 -0
  205. package/lib/components/Select/Select.d.ts.map +1 -1
  206. package/lib/components/Select/Select.js +4 -3
  207. package/lib/components/Select/Select.js.map +1 -1
  208. package/lib/components/Skeleton/ParagraphSkeleton.d.ts.map +1 -1
  209. package/lib/components/Skeleton/ParagraphSkeleton.js +2 -2
  210. package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
  211. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  212. package/lib/components/TextArea/TextArea.js +4 -2
  213. package/lib/components/TextArea/TextArea.js.map +1 -1
  214. package/lib/components/Tooltip/Tooltip.d.ts +5 -0
  215. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  216. package/lib/components/Tooltip/Tooltip.js +22 -5
  217. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  218. package/lib/hooks/useActiveDescendant.d.ts +5 -1
  219. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  220. package/lib/hooks/useActiveDescendant.js +162 -94
  221. package/lib/hooks/useActiveDescendant.js.map +1 -1
  222. package/lib/hooks/useI18n.d.ts +33 -0
  223. package/lib/hooks/useI18n.d.ts.map +1 -1
  224. package/lib/hooks/useI18n.js +2 -1
  225. package/lib/hooks/useI18n.js.map +1 -1
  226. package/lib/i18n/default.d.ts +33 -0
  227. package/lib/i18n/default.d.ts.map +1 -1
  228. package/lib/i18n/default.js +47 -13
  229. package/lib/i18n/default.js.map +1 -1
  230. package/lib/i18n/i18n.d.ts +66 -0
  231. package/lib/i18n/i18n.d.ts.map +1 -1
  232. package/lib/i18n/translate.d.ts +3 -0
  233. package/lib/i18n/translate.d.ts.map +1 -1
  234. package/lib/i18n/translate.js.map +1 -1
  235. package/lib/init.js +1 -1
  236. package/lib/init.js.map +1 -1
  237. package/lib/theme/theme.d.ts +12 -0
  238. package/lib/theme/theme.d.ts.map +1 -1
  239. package/lib/theme/themeDefinition.json +7 -1
  240. package/lib/theme/themeOverrides.schema.json +9 -0
  241. package/lib/theme/themes/darkTheme.json +3 -1
  242. package/package.json +1 -1
@@ -0,0 +1,123 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { useCallback, useContext, useEffect, useRef, useState } from 'react';
4
+ import { useTheme, useArrows, useConsolidatedRef, useDirection, useUID, useI18n, useElement } from '../../hooks';
5
+ import ExpandCollapse from '../ExpandCollapse';
6
+ import BareButton from '../Button/BareButton';
7
+ import Flex from '../Flex';
8
+ import Icon from '../Icon';
9
+ import Text from '../Text';
10
+ import Button from '../Button';
11
+ import Link from '../Link';
12
+ import NavigationListItemWrapper from './NavigationListItemWrapper';
13
+ import { StyledNavList, StyledNestedNavList, StyledAppShellNavIcon, StyledNavListItem, StyledCaseClose } from './AppShell.styles';
14
+ import AppShellContext from './AppShellContext';
15
+ const NavigationMenu = props => {
16
+ const { navOpen } = useContext(AppShellContext);
17
+ const { visual, primary, secondary, href, onClick, items, onDismiss, active, actions, forwardedRef, ...restProps } = props;
18
+ const uid = useUID();
19
+ const [collapsed, setCollapsed] = useState(true);
20
+ const toggleCollapsed = useCallback((e) => {
21
+ e.stopPropagation();
22
+ setCollapsed(state => !state);
23
+ }, [setCollapsed]);
24
+ const itemRef = useConsolidatedRef(forwardedRef);
25
+ const onKeyDown = useCallback(({ key }) => {
26
+ if (key === 'Escape') {
27
+ setCollapsed(true);
28
+ itemRef.current?.focus();
29
+ }
30
+ }, []);
31
+ const menuRef = useRef(null);
32
+ useArrows(menuRef, { selector: '[role="menuitem"]', cycle: true });
33
+ const { end } = useDirection();
34
+ return (_createElement(StyledNavListItem, { ...restProps, key: primary, nestedListCollapsed: collapsed, onKeyDown: onKeyDown, ref: menuRef },
35
+ _jsxs(BareButton, { id: uid, ref: itemRef, tabIndex: collapsed ? 0 : -1, "aria-expanded": !collapsed, "aria-controls": `${uid}-menu`, "aria-label": primary, onClick: toggleCollapsed, children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), _jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon })] }),
36
+ _jsx(NavigationList, { id: `${uid}-menu`, nestedList: true, items: items, collapsed: !navOpen || collapsed })));
37
+ };
38
+ const NavigationListItem = props => {
39
+ const { navOpen } = useContext(AppShellContext);
40
+ const { visual, primary, secondary, href, onClick, items, collapseItems = false, dismissible = false, onDismiss, active, actions, forwardedRef, isMenuItem, ...restProps } = props;
41
+ const t = useI18n();
42
+ const [listItemChildren, setListItemChildren] = useElement(null);
43
+ const listItemRef = useConsolidatedRef(forwardedRef, setListItemChildren);
44
+ const hasItems = (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);
45
+ const compProps = {
46
+ onClick: (e) => {
47
+ e.stopPropagation();
48
+ onClick?.(e);
49
+ },
50
+ href,
51
+ 'aria-label': primary
52
+ };
53
+ let caseItems;
54
+ if (onDismiss) {
55
+ caseItems = [
56
+ {
57
+ primary: t('go_to_noun', [primary]),
58
+ onClick
59
+ },
60
+ {
61
+ primary: t('dismiss_case'),
62
+ onClick: onDismiss
63
+ }
64
+ ];
65
+ }
66
+ let Component;
67
+ if (href) {
68
+ Component = Link;
69
+ }
70
+ else {
71
+ Component = BareButton;
72
+ }
73
+ useEffect(() => {
74
+ if (!navOpen && actions) {
75
+ const node = document.getElementsByTagName('body')[0];
76
+ const clickEvent = document.createEvent('MouseEvent');
77
+ clickEvent.initEvent('mousedown', true, true);
78
+ node.dispatchEvent(clickEvent);
79
+ }
80
+ if (navOpen && isMenuItem && listItemRef.current?.parentElement?.matches(':first-child'))
81
+ listItemRef.current?.focus();
82
+ }, [navOpen]);
83
+ const { end } = useDirection();
84
+ return (_createElement(StyledNavListItem, { ...restProps, key: primary, nestedListCollapsed: true },
85
+ _jsx(NavigationListItemWrapper, { tooltipLabel: secondary ? `${primary} ${secondary}` : primary, label: primary, childrenElement: listItemChildren, items: actions || items || caseItems, navOpen: navOpen, children: _jsxs(Component, { ...compProps, ref: listItemRef, ...(navOpen && isMenuItem
86
+ ? { tabIndex: -1, role: 'menuitem', 'aria-label': primary }
87
+ : {}), children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), (hasItems || actions) && _jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon })] }) }),
88
+ dismissible && (_jsx(Button, { icon: true, variant: 'simple', as: StyledCaseClose, onClick: onDismiss, "aria-label": t('dismiss_case'), children: _jsx(Icon, { name: 'times' }) })),
89
+ hasItems && (
90
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
91
+ _jsx(NavigationList, { nestedList: true, items: actions || items, collapsed: !navOpen || collapseItems }))));
92
+ };
93
+ const NavigationList = props => {
94
+ const { items = [], nestedList, id, collapsed } = props;
95
+ let Component = StyledNavList;
96
+ let ItemComponent;
97
+ const { navOpen } = useContext(AppShellContext);
98
+ let fwdProps = {
99
+ collapsed: !!collapsed
100
+ };
101
+ const { base: { animation } } = useTheme();
102
+ if (nestedList) {
103
+ fwdProps = {
104
+ as: ExpandCollapse,
105
+ forwardedAs: 'ul',
106
+ nullWhenCollapsed: true,
107
+ transitionSpeed: items.length >= 10 ? `calc(2 * ${animation.speed})` : animation.speed,
108
+ ...fwdProps
109
+ };
110
+ Component = StyledNestedNavList;
111
+ }
112
+ return (_jsx(Component, { ...(nestedList ? { role: 'menu', id } : {}), ...fwdProps, children: items?.map(item => {
113
+ if (item.items && item.items.length > 0 && navOpen) {
114
+ ItemComponent = NavigationMenu;
115
+ }
116
+ else {
117
+ ItemComponent = NavigationListItem;
118
+ }
119
+ return _jsx(ItemComponent, { isMenuItem: nestedList, ...item }, item.id || item.primary);
120
+ }) }));
121
+ };
122
+ export default NavigationList;
123
+ //# sourceMappingURL=NavigationList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAKL,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,UAAU,EACX,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,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ACvB,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,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE;YACjB,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;YACD,OAAO,KAAC,aAAa,IAA+B,UAAU,EAAE,UAAU,KAAM,IAAI,IAAzD,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAAsC,CAAC;QAC3F,CAAC,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n ElementType,\n FC,\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 useElement\n} from '../../hooks';\nimport ExpandCollapse from '../ExpandCollapse';\nimport BareButton from '../Button/BareButton';\nimport Flex from '../Flex';\nimport Icon from '../Icon';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport Link from '../Link';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport {\n NavListItemProps,\n NavListItemWrapperProps,\n NavListProps,\n NavMenuProps\n} from './AppShell.types';\nimport {\n StyledNavList,\n StyledNestedNavList,\n StyledAppShellNavIcon,\n StyledNavListItem,\n StyledCaseClose\n} from './AppShell.styles';\nimport AppShellContext from './AppShellContext';\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 active,\n actions,\n forwardedRef,\n ...restProps\n } = props;\n\n const uid = useUID();\n\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 onKeyDown = useCallback(({ key }: KeyboardEvent) => {\n if (key === 'Escape') {\n setCollapsed(true);\n itemRef.current?.focus();\n }\n }, []);\n\n const menuRef = useRef<HTMLLIElement>(null);\n\n useArrows(menuRef, { selector: '[role=\"menuitem\"]', cycle: true });\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem\n {...restProps}\n key={primary}\n nestedListCollapsed={collapsed}\n onKeyDown={onKeyDown}\n ref={menuRef}\n >\n <BareButton\n id={uid}\n ref={itemRef}\n tabIndex={collapsed ? 0 : -1}\n aria-expanded={!collapsed}\n aria-controls={`${uid}-menu`}\n aria-label={primary}\n onClick={toggleCollapsed}\n >\n {visual}\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 <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />\n </BareButton>\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\nconst NavigationListItem: FC<NavListItemProps> = props => {\n const { navOpen } = useContext(AppShellContext);\n const {\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n collapseItems = false,\n dismissible = false,\n onDismiss,\n active,\n actions,\n forwardedRef,\n isMenuItem,\n ...restProps\n } = props;\n\n const t = useI18n();\n const [listItemChildren, setListItemChildren] = useElement<HTMLElement>(null);\n const listItemRef = useConsolidatedRef(forwardedRef, setListItemChildren);\n\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 'aria-label': primary\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\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed>\n {/* forwardedRef typed as 'any' due to ambiguity of Component element type */}\n <NavigationListItemWrapper\n tooltipLabel={secondary ? `${primary} ${secondary}` : primary}\n label={primary}\n childrenElement={listItemChildren}\n items={actions || items || caseItems}\n navOpen={navOpen}\n >\n <Component\n {...compProps}\n ref={listItemRef as any}\n {...(navOpen && isMenuItem\n ? { tabIndex: -1, role: 'menuitem', 'aria-label': primary }\n : {})}\n >\n {visual}\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 {(hasItems || actions) && <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />}\n </Component>\n </NavigationListItemWrapper>\n {dismissible && (\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 {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> = props => {\n const { items = [], nestedList, id, collapsed } = props;\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 (item.items && item.items.length > 0 && navOpen) {\n ItemComponent = NavigationMenu;\n } else {\n ItemComponent = NavigationListItem;\n }\n return <ItemComponent key={item.id || item.primary} isMenuItem={nestedList} {...item} />;\n })}\n </Component>\n );\n};\n\nexport default NavigationList;\n"]}
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { NavListItemWrapperProps } from './AppShell.types';
3
+ declare const ListItemWrapper: FC<NavListItemWrapperProps>;
4
+ export default ListItemWrapper;
5
+ //# sourceMappingURL=NavigationListItemWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationListItemWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2C,MAAM,OAAO,CAAC;AAWpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AA+B3D,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,uBAAuB,CAuIhD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext, useEffect, useRef, useState } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { useDirection, useEscape, useFocusWithin, useOuterEvent, usePrevious } from '../../hooks';
5
+ import Text from '../Text';
6
+ import Tooltip from '../Tooltip';
7
+ import Popover from '../Popover';
8
+ import Menu from '../Menu';
9
+ import { StyledMenuListContainer } from '../Menu/Menu.styles';
10
+ import { defaultThemeProp } from '../../theme';
11
+ import AppShellContext from './AppShellContext';
12
+ const StyledNavigationPopover = styled.div(({ theme }) => {
13
+ return css `
14
+ background-color: ${theme.components['app-shell'].nav['background-color']};
15
+ &,
16
+ ${StyledMenuListContainer} {
17
+ background-color: ${theme.components['app-shell'].nav['background-color']};
18
+
19
+ header {
20
+ color: ${theme.base.palette.light};
21
+ border-bottom: none;
22
+ }
23
+ }
24
+
25
+ ${StyledMenuListContainer} li {
26
+ color: rgba(255, 255, 255, 0.7);
27
+ background-color: transparent;
28
+
29
+ &:hover,
30
+ &[data-current='true'] {
31
+ color: #ffffff;
32
+ background-color: rgba(255, 255, 255, 0.05);
33
+ }
34
+ }
35
+ `;
36
+ });
37
+ StyledNavigationPopover.defaultProps = defaultThemeProp;
38
+ const ListItemWrapper = props => {
39
+ const { children, childrenElement, label, tooltipLabel, items = [], content, navOpen, onMenuToggle } = props;
40
+ const popoverRef = useRef(null);
41
+ const menuRef = useRef(null);
42
+ const [popoverOpen, setPopoverOpen] = useState(false);
43
+ const direction = useDirection();
44
+ const { menuOpen, setMenuOpen } = useContext(AppShellContext);
45
+ const focusWithin = useFocusWithin([popoverRef, childrenElement]);
46
+ const prevFocusWithin = usePrevious(focusWithin);
47
+ const closePopoverAndMenu = () => {
48
+ if (popoverOpen) {
49
+ setPopoverOpen(false);
50
+ setMenuOpen(false);
51
+ childrenElement?.focus();
52
+ }
53
+ };
54
+ useOuterEvent('click', [popoverRef?.current, menuRef?.current], () => {
55
+ closePopoverAndMenu();
56
+ });
57
+ const onClick = (e) => {
58
+ if ((items?.length || content) && !navOpen) {
59
+ e.stopPropagation();
60
+ e.preventDefault();
61
+ setPopoverOpen(true);
62
+ setMenuOpen(true);
63
+ }
64
+ };
65
+ const onKeyDown = (e) => {
66
+ if (e.key === 'Tab' && !content) {
67
+ setPopoverOpen(false);
68
+ }
69
+ if (e.key === 'Enter' && items.length) {
70
+ setPopoverOpen(true);
71
+ }
72
+ };
73
+ useEffect(() => {
74
+ childrenElement?.addEventListener('click', onClick);
75
+ childrenElement?.addEventListener('keydown', onKeyDown);
76
+ return () => {
77
+ childrenElement?.removeEventListener('click', onClick);
78
+ childrenElement?.removeEventListener('keydown', onKeyDown);
79
+ };
80
+ }, [childrenElement, navOpen, items]);
81
+ useEffect(() => {
82
+ onMenuToggle?.(popoverOpen ? 'open' : 'close');
83
+ }, [popoverOpen]);
84
+ useEffect(() => {
85
+ if (!focusWithin && prevFocusWithin) {
86
+ setPopoverOpen(false);
87
+ }
88
+ }, [focusWithin]);
89
+ useEscape(() => {
90
+ closePopoverAndMenu();
91
+ }, childrenElement, [childrenElement]);
92
+ useEscape(() => {
93
+ closePopoverAndMenu();
94
+ }, popoverRef, [popoverRef]);
95
+ return (_jsxs(_Fragment, { children: [children, !navOpen && (_jsxs(_Fragment, { children: [!popoverOpen && !menuOpen && (_jsx(Tooltip, { target: childrenElement, placement: direction.ltr ? 'right' : 'left', showDelay: 'none', hideDelay: 'none', children: tooltipLabel })), popoverOpen && (items.length || content) && (_jsx(Popover, { target: childrenElement, placement: direction.ltr ? 'right-start' : 'left-start', ref: popoverRef, as: StyledNavigationPopover, arrow: true, children: content || (_jsx(Menu, { mode: 'action', variant: 'flyout', focusControlEl: childrenElement, ref: menuRef, items: items.map(item => {
96
+ return {
97
+ id: (item.primary || item.text),
98
+ primary: (item.primary || item.text),
99
+ href: item.href,
100
+ onClick: (id, e) => {
101
+ e.stopPropagation();
102
+ item.onClick?.(e);
103
+ setPopoverOpen(false);
104
+ }
105
+ };
106
+ }), header: _jsx(Text, { variant: 'h2', children: label }) })) }))] }))] }));
107
+ };
108
+ export default ListItemWrapper;
109
+ //# sourceMappingURL=NavigationListItemWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationListItemWrapper.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,uBAAuB,GAAG,MAAM,CAA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AAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAW;oCACzC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAW;oCAC9C,IAAI,EAAE,IAAI,CAAC,IAAc;oCACzB,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;wCACjB,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;wCAClB,cAAc,CAAC,KAAK,CAAC,CAAC;oCACxB,CAAC;iCACF,CAAC;4BACJ,CAAC,CAAC,EACF,MAAM,EAAE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAQ,GACzC,CACH,GACO,CACX,IACA,CACJ,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, useContext, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useDirection, useEscape, useFocusWithin, useOuterEvent, usePrevious } from '../../hooks';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\nimport Popover from '../Popover';\nimport Menu from '../Menu';\nimport { StyledMenuListContainer } from '../Menu/Menu.styles';\nimport { defaultThemeProp } from '../../theme';\n\nimport { NavListItemWrapperProps } from './AppShell.types';\nimport AppShellContext from './AppShellContext';\n\nconst StyledNavigationPopover = styled.div(({ theme }) => {\n return css`\n background-color: ${theme.components['app-shell'].nav['background-color']};\n &,\n ${StyledMenuListContainer} {\n background-color: ${theme.components['app-shell'].nav['background-color']};\n\n header {\n color: ${theme.base.palette.light};\n border-bottom: none;\n }\n }\n\n ${StyledMenuListContainer} li {\n color: rgba(255, 255, 255, 0.7);\n background-color: transparent;\n\n &:hover,\n &[data-current='true'] {\n color: #ffffff;\n background-color: rgba(255, 255, 255, 0.05);\n }\n }\n `;\n});\n\nStyledNavigationPopover.defaultProps = defaultThemeProp;\n\nconst ListItemWrapper: FC<NavListItemWrapperProps> = props => {\n const {\n children,\n childrenElement,\n label,\n tooltipLabel,\n items = [],\n content,\n navOpen,\n onMenuToggle\n } = props;\n const popoverRef = useRef<HTMLDivElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const [popoverOpen, setPopoverOpen] = useState(false);\n const direction = useDirection();\n const { menuOpen, setMenuOpen } = useContext(AppShellContext);\n\n const focusWithin = useFocusWithin([popoverRef, childrenElement]);\n const prevFocusWithin = usePrevious(focusWithin);\n\n const closePopoverAndMenu = () => {\n if (popoverOpen) {\n setPopoverOpen(false);\n setMenuOpen(false);\n childrenElement?.focus();\n }\n };\n\n useOuterEvent('click', [popoverRef?.current, menuRef?.current], () => {\n closePopoverAndMenu();\n });\n\n const onClick = (e: Event) => {\n if ((items?.length || content) && !navOpen) {\n e.stopPropagation();\n e.preventDefault();\n setPopoverOpen(true);\n setMenuOpen(true);\n }\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Tab' && !content) {\n setPopoverOpen(false);\n }\n if (e.key === 'Enter' && items.length) {\n setPopoverOpen(true);\n }\n };\n\n useEffect(() => {\n childrenElement?.addEventListener('click', onClick);\n childrenElement?.addEventListener('keydown', onKeyDown);\n return () => {\n childrenElement?.removeEventListener('click', onClick);\n childrenElement?.removeEventListener('keydown', onKeyDown);\n };\n }, [childrenElement, navOpen, items]);\n\n useEffect(() => {\n onMenuToggle?.(popoverOpen ? 'open' : 'close');\n }, [popoverOpen]);\n\n useEffect(() => {\n if (!focusWithin && prevFocusWithin) {\n setPopoverOpen(false);\n }\n }, [focusWithin]);\n\n useEscape(\n () => {\n closePopoverAndMenu();\n },\n childrenElement,\n [childrenElement]\n );\n\n useEscape(\n () => {\n closePopoverAndMenu();\n },\n popoverRef,\n [popoverRef]\n );\n\n return (\n <>\n {children}\n {!navOpen && (\n <>\n {!popoverOpen && !menuOpen && (\n <Tooltip\n target={childrenElement}\n placement={direction.ltr ? 'right' : 'left'}\n showDelay='none'\n hideDelay='none'\n >\n {tooltipLabel}\n </Tooltip>\n )}\n {popoverOpen && (items.length || content) && (\n <Popover\n target={childrenElement}\n placement={direction.ltr ? 'right-start' : 'left-start'}\n ref={popoverRef}\n as={StyledNavigationPopover}\n arrow\n >\n {content || (\n <Menu\n mode='action'\n variant='flyout'\n focusControlEl={childrenElement as HTMLElement}\n ref={menuRef}\n items={items.map(item => {\n return {\n id: (item.primary || item.text) as string,\n primary: (item.primary || item.text) as string,\n href: item.href as string,\n onClick: (id, e) => {\n e.stopPropagation();\n item.onClick?.(e);\n setPopoverOpen(false);\n }\n };\n })}\n header={<Text variant='h2'>{label}</Text>}\n />\n )}\n </Popover>\n )}\n </>\n )}\n </>\n );\n};\n\nexport default ListItemWrapper;\n"]}
@@ -9,10 +9,10 @@ const Operator = forwardRef(({ children, actions, popover, as }, ref) => {
9
9
  const { navOpen } = useContext(AppShellContext);
10
10
  const buttonRef = useConsolidatedRef(ref);
11
11
  const operatorMenuItems = useMemo(() => {
12
- return actions.flat().map(({ id, text, onClick: click, ...rest }) => ({
13
- id,
14
- primary: text,
15
- onClick: click,
12
+ return actions.flat().map(({ id, primary, onClick: click, ...rest }) => ({
13
+ id: id || primary,
14
+ primary,
15
+ onClick: (menuId, e) => click?.(e),
16
16
  ...rest
17
17
  }));
18
18
  }, [actions]);
@@ -1 +1 @@
1
- {"version":3,"file":"Operator.js","sourceRoot":"","sources":["../../../src/components/AppShell/Operator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,QAAQ,GA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AAW,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC,YAEA,QAAQ,GACE,EACb,KAAC,OAAO,OAAK,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,YAC7D,KAAC,IAAI,IACH,cAAc,EAAE,SAAS,CAAC,OAAO,IAAI,SAAS,EAC9C,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,iBAAiB;oBACxB;;uBAEG;oBACH,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;wBACpB,IACG,CAAgF;6BAC9E,MAAM,GAAG,CAAC,EACb;4BACA,WAAW,CAAC,KAAK,CAAC,CAAC;yBACpB;oBACH,CAAC,GACD,GACM,IACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useContext, useMemo } from 'react';\nimport type { Ref, ReactNode, MouseEvent, UIEvent } from 'react';\n\nimport BareButton from '../Button/BareButton';\nimport Popover from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { AcceptedMouseEventElement } from '../Menu/Menu.types';\nimport { useConsolidatedRef } from '../../hooks';\nimport type { AsProp, OmitStrict } from '../../types';\n\nimport AppShellContext from './AppShellContext';\nimport { OperatorProps } from './AppShell.types';\n\nconst Operator = forwardRef(\n (\n {\n children,\n actions,\n popover,\n as\n }: {\n children: ReactNode;\n actions: OperatorProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n } & AsProp,\n ref: Ref<HTMLButtonElement> | undefined\n ) => {\n const { navOpen } = useContext(AppShellContext);\n const buttonRef = useConsolidatedRef(ref);\n\n const operatorMenuItems = useMemo(() => {\n return actions.flat().map(({ id, text, onClick: click, ...rest }) => ({\n id,\n primary: text,\n onClick: click,\n ...rest\n }));\n }, [actions]);\n\n const [showMenu, setShowMenu] = useState(false);\n\n useEffect(() => {\n if (!navOpen) setShowMenu(false);\n }, [navOpen]);\n\n return (\n <>\n <BareButton\n as={as}\n ref={buttonRef}\n aria-expanded={showMenu ? 'true' : 'false'}\n aria-haspopup='menu'\n onClick={() => {\n setShowMenu(cur => !cur);\n }}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === 'Escape') setShowMenu(false);\n }}\n onBlur={() => {\n setShowMenu(false);\n }}\n >\n {children}\n </BareButton>\n <Popover {...popover} show={showMenu} target={buttonRef.current}>\n <Menu\n focusControlEl={buttonRef.current ?? undefined}\n mode='action'\n items={operatorMenuItems}\n /**\n * @see {@link MenuButton} implementation for explanation of conditions. This is in essence duplicated.\n */\n onItemClick={(_, e) => {\n if (\n (e as MouseEvent<AcceptedMouseEventElement> & UIEvent<AcceptedMouseEventElement>)\n .detail > 0\n ) {\n setShowMenu(false);\n }\n }}\n />\n </Popover>\n </>\n );\n }\n);\n\nexport default Operator;\n"]}
1
+ {"version":3,"file":"Operator.js","sourceRoot":"","sources":["../../../src/components/AppShell/Operator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,IAAuB,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,QAAQ,GAAG,UAAU,CACzB,CACE,EACE,QAAQ,EACR,OAAO,EACP,OAAO,EACP,EAAE,EAKM,EACV,GAAuC,EACvC,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAE1C,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE;Q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AAS,CAAC,OAAO,IAAI,SAAS,EAC9C,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,iBAAiB;oBACxB;;uBAEG;oBACH,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;wBACpB,IACG,CAAgF;6BAC9E,MAAM,GAAG,CAAC,EACb;4BACA,WAAW,CAAC,KAAK,CAAC,CAAC;yBACpB;oBACH,CAAC,GACD,GACM,IACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useContext, useMemo } from 'react';\nimport type { Ref, ReactNode, MouseEvent, UIEvent } from 'react';\n\nimport BareButton from '../Button/BareButton';\nimport Popover from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu, { MenuItemProps } from '../Menu';\nimport type { AcceptedMouseEventElement } from '../Menu/Menu.types';\nimport { useConsolidatedRef } from '../../hooks';\nimport type { AsProp, OmitStrict } from '../../types';\n\nimport AppShellContext from './AppShellContext';\nimport { OperatorProps } from './AppShell.types';\n\nconst Operator = forwardRef(\n (\n {\n children,\n actions,\n popover,\n as\n }: {\n children: ReactNode;\n actions: OperatorProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n } & AsProp,\n ref: Ref<HTMLButtonElement> | undefined\n ) => {\n const { navOpen } = useContext(AppShellContext);\n const buttonRef = useConsolidatedRef(ref);\n\n const operatorMenuItems = useMemo(() => {\n return actions.flat().map<MenuItemProps>(({ id, primary, onClick: click, ...rest }) => ({\n id: id || primary,\n primary,\n onClick: (menuId, e) => click?.(e),\n ...rest\n }));\n }, [actions]);\n\n const [showMenu, setShowMenu] = useState(false);\n\n useEffect(() => {\n if (!navOpen) setShowMenu(false);\n }, [navOpen]);\n\n return (\n <>\n <BareButton\n as={as}\n ref={buttonRef}\n aria-expanded={showMenu ? 'true' : 'false'}\n aria-haspopup='menu'\n onClick={() => {\n setShowMenu(cur => !cur);\n }}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === 'Escape') setShowMenu(false);\n }}\n onBlur={() => {\n setShowMenu(false);\n }}\n >\n {children}\n </BareButton>\n <Popover {...popover} show={showMenu} target={buttonRef.current}>\n <Menu\n focusControlEl={buttonRef.current ?? undefined}\n mode='action'\n items={operatorMenuItems}\n /**\n * @see {@link MenuButton} implementation for explanation of conditions. This is in essence duplicated.\n */\n onItemClick={(_, e) => {\n if (\n (e as MouseEvent<AcceptedMouseEventElement> & UIEvent<AcceptedMouseEventElement>)\n .detail > 0\n ) {\n setShowMenu(false);\n }\n }}\n />\n </Popover>\n </>\n );\n }\n);\n\nexport default Operator;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsB3C,eAAO,MAAM,cAAc,yGA+B1B,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAU7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsB3C,eAAO,MAAM,cAAc,yGA+B1B,CAAC;AAGF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAU7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import styled, { css } from 'styled-components';
3
+ import { defaultThemeProp } from '../../theme';
3
4
  import useOS from '../../hooks/useOS';
4
5
  const osxKeyMapper = {
5
6
  Command: '⌘',
@@ -40,6 +41,7 @@ export const StyledKeyboard = styled.kbd(({ theme: { base, components: { text: {
40
41
  inset-block-start: calc(1.25rem / 4 - 0.125rem);
41
42
  `;
42
43
  });
44
+ StyledKeyboard.defaultProps = defaultThemeProp;
43
45
  const Keyboard = ({ keyName, ...restProps }) => {
44
46
  const { windows: isWindows } = useOS();
45
47
  return (_jsx(StyledKeyboard, { ...restProps, "aria-label": keyName, children: (isWindows && windowsKeyMapper[keyName]) ||
@@ -1 +1 @@
1
- {"version":3,"file":"Keyboard.js","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAGtC,MAAM,YAAY,GAA8B;IAC9C,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,SAAS,EAAE,OAAO;IAClB,WAAW,EAAE,OAAO;IACpB,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,IAAI,EAAE,EAAE,OAAO,EAAE,EACjB,MAAM,EAAE,EAAE,QAAQ,EAAE,EACrB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;0BACY,QAAQ,CAAC,kBAAkB,CAAC;eACvC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;qBAG1B,IAAI,CAAC,aAAa,CAAC;qBACnB,OAAO,CAAC,aAAa,CAAC;;;;gCAIX,QAAQ,CAAC,cAAc,CAAC;4BAC5B,IAAI,CAAC,eAAe,CAAC;;;;;;;;KAQ5C,CAAC;AACJ,CAAC,CACF,CAAC;AAMF,MAAM,QAAQ,GAAoD,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;IAC9F,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;IACvC,OAAO,CACL,KAAC,cAAc,OAAK,SAAS,gBAAc,OAAO,YAC/C,CAAC,SAAS,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC;YACrB,gBAAgB,CAAC,OAAO,CAAC;YACzB,OAAO,GACM,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport useOS from '../../hooks/useOS';\nimport { ForwardProps } from '../../types';\n\nconst osxKeyMapper: { [key: string]: string } = {\n Command: '⌘',\n Option: '⌥',\n Control: '⌃',\n Return: '↵',\n Delete: 'Del'\n};\n\nconst windowsKeyMapper: { [key: string]: string } = {\n Control: 'Ctrl',\n Windows: '⊞',\n Backspace: 'Backspace'\n};\n\nconst generalKeyMapper: { [key: string]: string } = {\n 'Page up': 'Pg up',\n 'Page down': 'Pg dn',\n Ins: 'Insert'\n};\n\nexport const StyledKeyboard = styled.kbd(\n ({\n theme: {\n base,\n components: {\n text: { primary },\n badges: { keyboard }\n }\n }\n }) => {\n return css`\n background-color: ${keyboard['background-color']};\n color: ${base.palette['foreground-color']};\n display: inline-block;\n position: relative;\n font-family: ${base['font-family']};\n font-weight: ${primary['font-weight']};\n overflow: hidden;\n white-space: nowrap;\n padding: 0.125rem;\n border: 0.0125rem solid ${keyboard['border-color']};\n border-radius: calc(${base['border-radius']} / 4);\n text-transform: capitalize;\n text-align: center;\n min-width: 1.25rem;\n height: 1.25rem;\n text-overflow: ellipsis;\n line-height: 1rem;\n inset-block-start: calc(1.25rem / 4 - 0.125rem);\n `;\n }\n);\n\nexport interface KeyboardProps {\n keyName: string;\n}\n\nconst Keyboard: FunctionComponent<KeyboardProps & ForwardProps> = ({ keyName, ...restProps }) => {\n const { windows: isWindows } = useOS();\n return (\n <StyledKeyboard {...restProps} aria-label={keyName}>\n {(isWindows && windowsKeyMapper[keyName]) ||\n osxKeyMapper[keyName] ||\n generalKeyMapper[keyName] ||\n keyName}\n </StyledKeyboard>\n );\n};\n\nexport default Keyboard;\n"]}
1
+ {"version":3,"file":"Keyboard.js","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAGtC,MAAM,YAAY,GAA8B;IAC9C,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,SAAS,EAAE,OAAO;IAClB,WAAW,EAAE,OAAO;IACpB,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,IAAI,EAAE,EAAE,OAAO,EAAE,EACjB,MAAM,EAAE,EAAE,QAAQ,EAAE,EACrB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;0BACY,QAAQ,CAAC,kBAAkB,CAAC;eACvC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;qBAG1B,IAAI,CAAC,aAAa,CAAC;qBACnB,OAAO,CAAC,aAAa,CAAC;;;;gCAIX,QAAQ,CAAC,cAAc,CAAC;4BAC5B,IAAI,CAAC,eAAe,CAAC;;;;;;;;KAQ5C,CAAC;AACJ,CAAC,CACF,CAAC;AACF,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAM/C,MAAM,QAAQ,GAAoD,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;IAC9F,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;IACvC,OAAO,CACL,KAAC,cAAc,OAAK,SAAS,gBAAc,OAAO,YAC/C,CAAC,SAAS,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC;YACrB,gBAAgB,CAAC,OAAO,CAAC;YACzB,OAAO,GACM,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport useOS from '../../hooks/useOS';\nimport { ForwardProps } from '../../types';\n\nconst osxKeyMapper: { [key: string]: string } = {\n Command: '⌘',\n Option: '⌥',\n Control: '⌃',\n Return: '↵',\n Delete: 'Del'\n};\n\nconst windowsKeyMapper: { [key: string]: string } = {\n Control: 'Ctrl',\n Windows: '⊞',\n Backspace: 'Backspace'\n};\n\nconst generalKeyMapper: { [key: string]: string } = {\n 'Page up': 'Pg up',\n 'Page down': 'Pg dn',\n Ins: 'Insert'\n};\n\nexport const StyledKeyboard = styled.kbd(\n ({\n theme: {\n base,\n components: {\n text: { primary },\n badges: { keyboard }\n }\n }\n }) => {\n return css`\n background-color: ${keyboard['background-color']};\n color: ${base.palette['foreground-color']};\n display: inline-block;\n position: relative;\n font-family: ${base['font-family']};\n font-weight: ${primary['font-weight']};\n overflow: hidden;\n white-space: nowrap;\n padding: 0.125rem;\n border: 0.0125rem solid ${keyboard['border-color']};\n border-radius: calc(${base['border-radius']} / 4);\n text-transform: capitalize;\n text-align: center;\n min-width: 1.25rem;\n height: 1.25rem;\n text-overflow: ellipsis;\n line-height: 1rem;\n inset-block-start: calc(1.25rem / 4 - 0.125rem);\n `;\n }\n);\nStyledKeyboard.defaultProps = defaultThemeProp;\n\nexport interface KeyboardProps {\n keyName: string;\n}\n\nconst Keyboard: FunctionComponent<KeyboardProps & ForwardProps> = ({ keyName, ...restProps }) => {\n const { windows: isWindows } = useOS();\n return (\n <StyledKeyboard {...restProps} aria-label={keyName}>\n {(isWindows && windowsKeyMapper[keyName]) ||\n osxKeyMapper[keyName] ||\n generalKeyMapper[keyName] ||\n keyName}\n </StyledKeyboard>\n );\n};\n\nexport default Keyboard;\n"]}
@@ -14,7 +14,7 @@ export interface SelectableProps {
14
14
  /** Event handler fired on every keyup event. */
15
15
  onKeyUp?: (event: KeyboardEvent) => void;
16
16
  }
17
- export declare const StyledSelectable: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
17
+ export declare const StyledSelectable: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
18
18
  declare const Selectable: FC<SelectableProps & ForwardProps>;
19
19
  export default Selectable;
20
20
  //# sourceMappingURL=Selection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Selection.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAoC,aAAa,EAAE,MAAM,OAAO,CAAC;AAIxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;A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CAC1C;AAED,eAAO,MAAM,gBAAgB,4GAsD3B,CAAC;AAGH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAsDlD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -7,8 +7,9 @@ import BareButton, { StyledBareButton } from '../Button/BareButton';
7
7
  import Icon, { registerIcon, StyledIcon } from '../Icon';
8
8
  import * as timesIcon from '../Icon/icons/times.icon';
9
9
  import { useConsolidatedRef, useI18n } from '../../hooks';
10
+ import { defaultThemeProp } from '../../theme';
10
11
  registerIcon(timesIcon);
11
- export const StyledSelectable = styled.div(props => {
12
+ export const StyledSelectable = styled.button(props => {
12
13
  const { foreground, background } = props.theme.components.badges.selectable.base;
13
14
  const { dark } = props.theme.base.palette;
14
15
  const borderRadius = props.theme.base['border-radius'];
@@ -61,6 +62,7 @@ export const StyledSelectable = styled.div(props => {
61
62
  }
62
63
  `;
63
64
  });
65
+ StyledSelectable.defaultProps = defaultThemeProp;
64
66
  const Selectable = forwardRef(({ id, children, onSelect, onRemove, onClick, onKeyUp, ...restProps }, ref) => {
65
67
  const consolidatedRef = useConsolidatedRef(ref);
66
68
  const t = useI18n();
@@ -82,7 +84,7 @@ const Selectable = forwardRef(({ id, children, onSelect, onRemove, onClick, onKe
82
84
  onRemove?.(id);
83
85
  }
84
86
  };
85
- return (_jsxs(BareButton, { role: 'button', tabIndex: '0', as: StyledSelectable, ref: consolidatedRef, onClick: handleClick, onKeyUp: handleKeyUp, ...restProps, children: [children, onRemove && (_jsx(BareButton, { tabIndex: '-1', onClick: handleCloseClick, "aria-label": `${t('remove')}`, children: _jsx(Icon, { name: 'times' }) }))] }));
87
+ return (_jsxs(StyledSelectable, { ref: consolidatedRef, onClick: handleClick, onKeyUp: handleKeyUp, ...restProps, children: [children, onRemove && (_jsx(BareButton, { tabIndex: '-1', onClick: handleCloseClick, "aria-label": `${t('remove')}`, children: _jsx(Icon, { name: 'times' }) }))] }));
86
88
  });
87
89
  export default Selectable;
88
90
  //# sourceMappingURL=Selection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Selection.js","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,UAAU,EAAuC,MAAM,OAAO,CAAC;AACxF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE1D,YAAY,CAAC,SAAS,CAAC,CAAC;AAiBxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACjD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;IAErC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,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CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,CAAgB,EAAE,EAAE;QACvC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;YACrB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;SAChB;QAED,IAAI,CAAC,CAAC,GAAG,KAAK,WAAW,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE;YAC/C,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;SAChB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,UAAU,IACT,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,GAAG,EACZ,EAAE,EAAE,gBAAgB,EACpB,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,KAChB,SAAS,aAEZ,QAAQ,EACR,QAAQ,IAAI,CACX,KAAC,UAAU,IAAC,QAAQ,EAAC,IAAI,EAAC,OAAO,EAAE,gBAAgB,gBAAc,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,YAC/E,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACV,CACd,IACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC, MouseEvent, forwardRef, PropsWithoutRef, Ref, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, transparentize } from 'polished';\n\nimport { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils/utils';\nimport BareButton, { StyledBareButton } from '../Button/BareButton';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { useConsolidatedRef, useI18n } from '../../hooks';\n\nregisterIcon(timesIcon);\n\nexport interface SelectableProps {\n /** An id that is used by the onSelect and onRemove functions if they are provided. */\n id: string;\n /** The content of the Badge. */\n children: string;\n /** Takes an ID that represents the Badge. This function is called when the Badge is clicked. */\n onSelect?: (id: string) => void;\n /** Takes an ID that represents the Badge. This function is called when the Badge is closed by clicking the X. */\n onRemove?: (id: string) => void;\n /** Event handler called when the Badge is clicked. */\n onClick?: (event: MouseEvent) => void;\n /** Event handler fired on every keyup event. */\n onKeyUp?: (event: KeyboardEvent) => void;\n}\n\nexport const StyledSelectable = styled.div(props => {\n const { foreground, background } = props.theme.components.badges.selectable.base;\n const { dark } = props.theme.base.palette;\n const borderRadius = props.theme.base['border-radius'];\n const { spacing } = props.theme.base;\n\n const displayBackground = tryCatch(() => mix(0.15, background, '#ffffff'));\n const hoverBorder = tryCatch(() => mix(0.3, background, '#ffffff'));\n const boxShadowColor = tryCatch(() => transparentize(0.45, dark));\n\n const height = 1.125;\n return css`\n background: ${displayBackground};\n border: 0 solid transparent;\n border-radius: calc(${height} * ${borderRadius});\n color: ${foreground};\n cursor: default;\n display: inline-flex;\n align-items: center;\n font-size: 0.75rem;\n height: ${height}rem;\n padding: 0 ${spacing};\n min-width: max-content;\n line-height: 1;\n\n &:hover {\n color: ${props.theme.base.palette.interactive};\n box-shadow: inset 0 0 0 0.0625rem ${hoverBorder};\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n &:active {\n box-shadow: inset 0 0 0 0.0625rem ${background};\n }\n\n &:focus {\n color: ${props.theme.base.palette.interactive};\n box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};\n outline: none;\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n ${StyledIcon} {\n margin-inline-start: ${spacing};\n height: 1em;\n width: 1em;\n }\n `;\n});\n\nconst Selectable: FC<SelectableProps & ForwardProps> = forwardRef(\n (\n {\n id,\n children,\n onSelect,\n onRemove,\n onClick,\n onKeyUp,\n ...restProps\n }: PropsWithoutRef<SelectableProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const consolidatedRef = useConsolidatedRef(ref);\n const t = useI18n();\n\n const handleClick = (e: MouseEvent<HTMLDivElement>) => {\n onClick?.(e);\n onSelect?.(id);\n };\n\n const handleCloseClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onRemove?.(id);\n };\n\n const handleKeyUp = (e: KeyboardEvent) => {\n onKeyUp?.(e);\n if (e.key === 'Enter') {\n onSelect?.(id);\n }\n\n if (e.key === 'Backspace' || e.key === 'Delete') {\n onRemove?.(id);\n }\n };\n\n return (\n <BareButton\n role='button'\n tabIndex='0'\n as={StyledSelectable}\n ref={consolidatedRef}\n onClick={handleClick}\n onKeyUp={handleKeyUp}\n {...restProps}\n >\n {children}\n {onRemove && (\n <BareButton tabIndex='-1' onClick={handleCloseClick} aria-label={`${t('remove')}`}>\n <Icon name='times' />\n </BareButton>\n )}\n </BareButton>\n );\n }\n);\n\nexport default Selectable;\n"]}
1
+ {"version":3,"file":"Selection.js","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,UAAU,EAAuC,MAAM,OAAO,CAAC;AACxF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,CAAC,SAAS,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IAAI,CACX,KAAC,UAAU,IAAC,QAAQ,EAAC,IAAI,EAAC,OAAO,EAAE,gBAAgB,gBAAc,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,YAC/E,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACV,CACd,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC, MouseEvent, forwardRef, PropsWithoutRef, Ref, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, transparentize } from 'polished';\n\nimport { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils/utils';\nimport BareButton, { StyledBareButton } from '../Button/BareButton';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { useConsolidatedRef, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nregisterIcon(timesIcon);\n\nexport interface SelectableProps {\n /** An id that is used by the onSelect and onRemove functions if they are provided. */\n id: string;\n /** The content of the Badge. */\n children: string;\n /** Takes an ID that represents the Badge. This function is called when the Badge is clicked. */\n onSelect?: (id: string) => void;\n /** Takes an ID that represents the Badge. This function is called when the Badge is closed by clicking the X. */\n onRemove?: (id: string) => void;\n /** Event handler called when the Badge is clicked. */\n onClick?: (event: MouseEvent) => void;\n /** Event handler fired on every keyup event. */\n onKeyUp?: (event: KeyboardEvent) => void;\n}\n\nexport const StyledSelectable = styled.button(props => {\n const { foreground, background } = props.theme.components.badges.selectable.base;\n const { dark } = props.theme.base.palette;\n const borderRadius = props.theme.base['border-radius'];\n const { spacing } = props.theme.base;\n\n const displayBackground = tryCatch(() => mix(0.15, background, '#ffffff'));\n const hoverBorder = tryCatch(() => mix(0.3, background, '#ffffff'));\n const boxShadowColor = tryCatch(() => transparentize(0.45, dark));\n\n const height = 1.125;\n return css`\n background: ${displayBackground};\n border: 0 solid transparent;\n border-radius: calc(${height} * ${borderRadius});\n color: ${foreground};\n cursor: default;\n display: inline-flex;\n align-items: center;\n font-size: 0.75rem;\n height: ${height}rem;\n padding: 0 ${spacing};\n min-width: max-content;\n line-height: 1;\n\n &:hover {\n color: ${props.theme.base.palette.interactive};\n box-shadow: inset 0 0 0 0.0625rem ${hoverBorder};\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n &:active {\n box-shadow: inset 0 0 0 0.0625rem ${background};\n }\n\n &:focus {\n color: ${props.theme.base.palette.interactive};\n box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};\n outline: none;\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n ${StyledIcon} {\n margin-inline-start: ${spacing};\n height: 1em;\n width: 1em;\n }\n `;\n});\nStyledSelectable.defaultProps = defaultThemeProp;\n\nconst Selectable: FC<SelectableProps & ForwardProps> = forwardRef(\n (\n {\n id,\n children,\n onSelect,\n onRemove,\n onClick,\n onKeyUp,\n ...restProps\n }: PropsWithoutRef<SelectableProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const consolidatedRef = useConsolidatedRef(ref);\n const t = useI18n();\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n onSelect?.(id);\n };\n\n const handleCloseClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onRemove?.(id);\n };\n\n const handleKeyUp = (e: KeyboardEvent) => {\n onKeyUp?.(e);\n if (e.key === 'Enter') {\n onSelect?.(id);\n }\n\n if (e.key === 'Backspace' || e.key === 'Delete') {\n onRemove?.(id);\n }\n };\n\n return (\n <StyledSelectable\n ref={consolidatedRef}\n onClick={handleClick}\n onKeyUp={handleKeyUp}\n {...restProps}\n >\n {children}\n {onRemove && (\n <BareButton tabIndex='-1' onClick={handleCloseClick} aria-label={`${t('remove')}`}>\n <Icon name='times' />\n </BareButton>\n )}\n </StyledSelectable>\n );\n }\n);\n\nexport default Selectable;\n"]}
@@ -1,4 +1,5 @@
1
1
  import { FunctionComponent, Ref } from 'react';
2
+ import { DefaultTheme } from 'styled-components';
2
3
  import { BaseProps, ForwardProps, NoChildrenProp } from '../../types';
3
4
  import { MenuItemProps } from '../Menu';
4
5
  export interface BreadcrumbsProps extends BaseProps, NoChildrenProp {
@@ -7,7 +8,7 @@ export interface BreadcrumbsProps extends BaseProps, NoChildrenProp {
7
8
  /** Ref forwarded to the wrapping element. */
8
9
  ref?: Ref<HTMLDivElement>;
9
10
  }
10
- export declare const StyledBreadcrumbs: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
11
+ export declare const StyledBreadcrumbs: import("styled-components").StyledComponent<"div", DefaultTheme, {
11
12
  oneItemRemaining: boolean;
12
13
  }, never>;
13
14
  declare const Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAKJ,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAUtE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,WAAW,gBAAiB,SAAQ,SAAS,EAAE,cAAc;IACjE,mHAAmH;IACnH,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAYD,eAAO,MAAM,iBAAiB;sBAAkC,OAAO;SAoBtE,CAAC;AAIF,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAkHnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAKJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAUtE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,WAAW,gBAAiB,SAAQ,SAAS,EAAE,cAAc;IACjE,mHAAmH;IACnH,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAYD,eAAO,MAAM,iBAAiB;sBAAkC,OAAO;SA0BtE,CAAC;AAyBF,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAwHnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -5,14 +5,14 @@ import { rgba } from 'polished';
5
5
  import { useElement, useConsolidatedRef, useDirection } from '../../hooks';
6
6
  import { defaultThemeProp } from '../../theme';
7
7
  import { debounce, tryCatch } from '../../utils';
8
- import Button from '../Button';
8
+ import Button, { StyledButton } from '../Button';
9
9
  import Flex from '../Flex';
10
- import Link from '../Link';
10
+ import Link, { StyledLink } from '../Link';
11
11
  import Icon, { StyledIcon, registerIcon } from '../Icon';
12
12
  import * as caretLeftIcon from '../Icon/icons/caret-left.icon';
13
13
  import * as caretRightIcon from '../Icon/icons/caret-right.icon';
14
14
  import MenuButton from '../MenuButton';
15
- import Text from '../Text';
15
+ import Text, { StyledText } from '../Text';
16
16
  registerIcon(caretLeftIcon, caretRightIcon);
17
17
  const StyledSeparator = styled(Icon)(({ theme }) => {
18
18
  const color = tryCatch(() => rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2']));
@@ -20,7 +20,7 @@ const StyledSeparator = styled(Icon)(({ theme }) => {
20
20
  color: ${color};
21
21
  `;
22
22
  });
23
- export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
23
+ export const StyledBreadcrumbs = styled.div(({ theme, oneItemRemaining }) => css `
24
24
  white-space: nowrap;
25
25
  overflow: visible;
26
26
  visibility: hidden;
@@ -31,6 +31,12 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
31
31
  flex-shrink: 0;
32
32
  }
33
33
 
34
+ ${StyledLink},
35
+ ${StyledButton},
36
+ ${StyledText} {
37
+ max-width: ${theme.base['content-width'].md};
38
+ }
39
+
34
40
  ${oneItemRemaining &&
35
41
  css `
36
42
  & > :last-child {
@@ -40,6 +46,20 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
40
46
  `}
41
47
  `);
42
48
  StyledBreadcrumbs.defaultProps = defaultThemeProp;
49
+ const getEllipsisStyles = ({ theme }) => {
50
+ return css `
51
+ min-width: ${theme.base['content-width'].xs};
52
+ white-space: nowrap;
53
+ overflow: hidden;
54
+ text-overflow: ellipsis;
55
+ `;
56
+ };
57
+ const StyledEllipsizedLink = styled(Link)(getEllipsisStyles);
58
+ StyledEllipsizedLink.defaultProps = defaultThemeProp;
59
+ const StyledEllipsizedButton = styled(Button)(getEllipsisStyles);
60
+ StyledEllipsizedButton.defaultProps = defaultThemeProp;
61
+ const StyledEllipsizedText = styled(Text)(getEllipsisStyles);
62
+ StyledEllipsizedText.defaultProps = defaultThemeProp;
43
63
  const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
44
64
  const [breadcrumbsEl, setBreadcrumbsEl] = useElement();
45
65
  const [numMenuItems, setNumMenuItems] = useState(0);
@@ -83,15 +103,15 @@ const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
83
103
  const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;
84
104
  let Comp;
85
105
  if (href)
86
- Comp = (_jsxs(Link, { href: href, onClick: (e) => {
106
+ Comp = (_jsxs(Link, { href: href, as: primary.length > 60 ? StyledEllipsizedLink : undefined, onClick: (e) => {
87
107
  onClick?.(id, e);
88
108
  }, ...restCrumbProps, children: [visual, " ", primary] }, id));
89
109
  else if (onClick)
90
- Comp = (_jsxs(Button, { variant: 'link', onClick: (e) => {
110
+ Comp = (_jsxs(Button, { variant: 'link', as: primary.length > 60 ? StyledEllipsizedButton : undefined, onClick: (e) => {
91
111
  onClick(id, e);
92
112
  }, ...restCrumbProps, children: [visual, " ", primary] }, id));
93
113
  else
94
- Comp = (_jsxs(Text, { ...restCrumbProps, children: [visual, " ", primary] }, id));
114
+ Comp = (_jsxs(Text, { as: primary.length > 60 ? StyledEllipsizedText : undefined, ...restCrumbProps, children: [visual, " ", primary] }, id));
95
115
  if (index === path.slice(numMenuItems).length - 1)
96
116
  return Comp;
97
117
  return (_jsxs(Fragment, { children: [Comp, _jsx(StyledSeparator, { name: `caret-${end}` })] }, id));