@pega/cosmos-react-core 3.0.0-dev.16.0 → 3.0.0-dev.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +4 -6
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.d.ts +16 -0
- package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -0
- package/lib/components/AppShell/AppHeader.styles.js +155 -0
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -0
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +44 -157
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +7 -51
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +44 -535
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +16 -5
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +2 -0
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +2 -0
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/AppShellList.js +3 -1
- package/lib/components/AppShell/AppShellList.js.map +1 -1
- package/lib/components/AppShell/AppShellList.styles.d.ts +19 -0
- package/lib/components/AppShell/AppShellList.styles.d.ts.map +1 -0
- package/lib/components/AppShell/AppShellList.styles.js +141 -0
- package/lib/components/AppShell/AppShellList.styles.js.map +1 -0
- package/lib/components/AppShell/AppShellSearch.d.ts +10 -0
- package/lib/components/AppShell/AppShellSearch.d.ts.map +1 -0
- package/lib/components/AppShell/AppShellSearch.js +32 -0
- package/lib/components/AppShell/AppShellSearch.js.map +1 -0
- package/lib/components/AppShell/AppShellSearch.styles.d.ts +8 -0
- package/lib/components/AppShell/AppShellSearch.styles.d.ts.map +1 -0
- package/lib/components/AppShell/AppShellSearch.styles.js +190 -0
- package/lib/components/AppShell/AppShellSearch.styles.js.map +1 -0
- package/lib/components/AppShell/Drawer.js +2 -2
- package/lib/components/AppShell/Drawer.js.map +1 -1
- package/lib/components/AppShell/Drawer.styles.d.ts +15 -0
- package/lib/components/AppShell/Drawer.styles.d.ts.map +1 -0
- package/lib/components/AppShell/Drawer.styles.js +153 -0
- package/lib/components/AppShell/Drawer.styles.js.map +1 -0
- package/lib/components/AppShell/NavigationList.d.ts +5 -0
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -0
- package/lib/components/AppShell/NavigationList.js +123 -0
- package/lib/components/AppShell/NavigationList.js.map +1 -0
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts +5 -0
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -0
- package/lib/components/AppShell/NavigationListItemWrapper.js +109 -0
- package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -0
- package/lib/components/AppShell/Operator.js +4 -4
- package/lib/components/AppShell/Operator.js.map +1 -1
- package/lib/components/Badges/Keyboard.d.ts.map +1 -1
- package/lib/components/Badges/Keyboard.js +2 -0
- package/lib/components/Badges/Keyboard.js.map +1 -1
- package/lib/components/Badges/Selection.d.ts +1 -1
- package/lib/components/Badges/Selection.d.ts.map +1 -1
- package/lib/components/Badges/Selection.js +4 -2
- package/lib/components/Badges/Selection.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +2 -0
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +37 -10
- package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +56 -15
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts +3 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts +5 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.d.ts +7 -0
- package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.js +5 -2
- package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +113 -37
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +10 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +2 -2
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts +2 -0
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.js +2 -2
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.js +19 -17
- package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.js +17 -4
- package/lib/components/Currency/CurrencyInput.js.map +1 -1
- package/lib/components/Currency/utils.d.ts.map +1 -1
- package/lib/components/Currency/utils.js +3 -2
- package/lib/components/Currency/utils.js.map +1 -1
- package/lib/components/DateTime/DateTime.types.d.ts +2 -0
- package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
- package/lib/components/DateTime/DateTime.types.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +12 -3
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +12 -3
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +6 -12
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -4
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.js +13 -55
- package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +2 -1
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +3 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js +39 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -0
- package/lib/components/DateTime/Picker/DateRangePicker.js +1 -1
- package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/TimePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/TimePicker.js +10 -5
- package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
- package/lib/components/DateTime/index.d.ts +2 -0
- package/lib/components/DateTime/index.d.ts.map +1 -1
- package/lib/components/DateTime/index.js +2 -0
- package/lib/components/DateTime/index.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +3 -2
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapse.d.ts.map +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +28 -26
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FormControl/FormControl.d.ts +6 -2
- package/lib/components/FormControl/FormControl.d.ts.map +1 -1
- package/lib/components/FormControl/FormControl.js +60 -35
- package/lib/components/FormControl/FormControl.js.map +1 -1
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +65 -5
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Input/Input.d.ts.map +1 -1
- package/lib/components/Input/Input.js +13 -2
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +64 -9
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts +12 -0
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js +36 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -1
- package/lib/components/ListToolbar/QueryOptionPopover.js +14 -44
- package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +8 -5
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.styles.js +1 -1
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +13 -0
- package/lib/components/Menu/Menu.types.d.ts.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/MenuGroup.d.ts.map +1 -1
- package/lib/components/Menu/MenuGroup.js +3 -3
- package/lib/components/Menu/MenuGroup.js.map +1 -1
- package/lib/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/components/Menu/MenuItem.js +3 -5
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuList.d.ts.map +1 -1
- package/lib/components/Menu/MenuList.js +14 -14
- package/lib/components/Menu/MenuList.js.map +1 -1
- package/lib/components/MetaList/MetaList.d.ts.map +1 -1
- package/lib/components/MetaList/MetaList.js +13 -10
- package/lib/components/MetaList/MetaList.js.map +1 -1
- package/lib/components/Number/NumberInput.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.js +18 -5
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/Number/NumberInput.styles.d.ts +6 -2
- package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.styles.js +4 -2
- package/lib/components/Number/NumberInput.styles.js.map +1 -1
- package/lib/components/Number/NumberInput.types.d.ts +2 -0
- package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.types.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.js +1 -4
- package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
- package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.js +12 -3
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.d.ts +5 -0
- package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.js +14 -4
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.styles.d.ts +3 -0
- package/lib/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.styles.js +6 -0
- package/lib/components/SearchInput/SearchInput.styles.js.map +1 -1
- package/lib/components/Select/Select.d.ts +2 -0
- package/lib/components/Select/Select.d.ts.map +1 -1
- package/lib/components/Select/Select.js +4 -3
- package/lib/components/Select/Select.js.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.d.ts.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.js +2 -2
- package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
- package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
- package/lib/components/Tabs/TabPanel.js +1 -7
- package/lib/components/Tabs/TabPanel.js.map +1 -1
- package/lib/components/Text/Text.js +2 -2
- package/lib/components/Text/Text.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +4 -2
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts +5 -0
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +22 -5
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/hooks/useActiveDescendant.d.ts +5 -1
- package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
- package/lib/hooks/useActiveDescendant.js +166 -95
- package/lib/hooks/useActiveDescendant.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +36 -1
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useI18n.js +2 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/i18n/default.d.ts +36 -1
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +50 -14
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +72 -2
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/i18n/translate.d.ts +3 -0
- package/lib/i18n/translate.d.ts.map +1 -1
- package/lib/i18n/translate.js.map +1 -1
- package/lib/theme/theme.d.ts +12 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +7 -1
- package/lib/theme/themeOverrides.schema.json +9 -0
- package/lib/theme/themes/darkTheme.json +3 -1
- 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,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAOpE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,cAAc,GAAqB,KAAK,CAAC,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAChD,MAAM,EACJ,MAAM,EACN,OAAO,EACP,SAAS,EACT,IAAI,EACJ,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,GAAG,GAAG,MA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,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 @@
|
|
|
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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CACtB,OAAO;oCACL,EAAE,EAAE,CAAC,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,
|
|
13
|
-
id,
|
|
14
|
-
primary
|
|
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,
|
|
1
|
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AAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,8BACE,KAAC,UAAU,IACT,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,SAAS,mBACC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,mBAC5B,MAAM,EACpB,OAAO,EAAE,GAAG,EAAE;oBACZ,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC3B,CAAC,EACD,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE;oBAC9B,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ;wBAAE,WAAW,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;oBACX,WAAW,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, { 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;
|
|
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,GA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AM,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<"
|
|
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;
|
|
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;AAU3C,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,iHAAiH;IACjH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,sDAAsD;IACtD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;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.
|
|
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(
|
|
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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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAIvF,OAAO,EAAE,S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U,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,gEAAgE;IAChE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAC;IACX,iIAAiI;IACjI,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,oBAAoB;YAAuB,OAAO;SAS7D,CAAC;AAIH,eAAO,MAAM,mBAAmB;gBAA4B,OAAO;SAmBjE,CAAC;AAIH,eAAO,MAAM,mBAAmB;YAAuB,OAAO;SAW5D,CAAC;AAIH,eAAO,MAAM,yBAAyB,yGAQpC,CAAC;AAIH,eAAO,MAAM,yBAAyB,qKAAmB,CAAC;AAE1D,eAAO,MAAM,kBAAkB,mIAkB7B,CAAC;AAIH,eAAO,MAAM,YAAY,yGAKvB,CAAC;AAIH,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CAqGzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -48,6 +48,8 @@ StyledBannerContent.defaultProps = defaultThemeProp;
|
|
|
48
48
|
export const StyledBannerMessage = styled.li(({ inline, theme }) => {
|
|
49
49
|
return css `
|
|
50
50
|
color: ${theme.base.palette['foreground-color']};
|
|
51
|
+
word-break: break-word;
|
|
52
|
+
|
|
51
53
|
${inline &&
|
|
52
54
|
css `
|
|
53
55
|
display: inline-block;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,UAAU,EAAwB,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,E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ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { getContrast, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Icon, { registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as bulbIcon from '../Icon/icons/bulb.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport Button from '../Button';\nimport { tryCatch } from '../../utils';\nimport { useDirection, useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport Text from '../Text';\n\nregisterIcon(timesIcon, checkIcon, bulbIcon, warnSolidIcon, flagWaveSolidIcon);\n\nexport interface BannerProps extends BaseProps, NoChildrenProp {\n /** Controls the styling of the Banner. */\n variant: 'urgent' | 'success' | 'warning' | 'info';\n /** Heading text for the Banner. */\n heading?: string;\n /**\n * The heading tag to render the provided heading as. This is agnostic to the styling of the heading.\n * @default \"h2\"\n */\n headingTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n /** Pass one or more descriptive messages to inform the user. */\n messages: string[];\n /** ID for the Banner. Used both as onDismiss callback arg and DOM id. */\n id: string;\n /** Link or Button provided to the user for next steps. Link should use regular href and Button should use an onClick handler. */\n action?: ReactNode;\n /** Callback when user explicitly dismisses the Banner. */\n onDismiss?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledBannerMessages = styled.ul<{ inline: boolean }>(({ theme, inline }) => {\n return css`\n list-style-position: inside;\n ${inline &&\n css`\n display: inline-block;\n margin-inline-end: ${theme.base.spacing};\n `}\n `;\n});\n\nStyledBannerMessages.defaultProps = defaultThemeProp;\n\nexport const StyledBannerContent = styled.div<{ hasDismiss: boolean }>(({ theme, hasDismiss }) => {\n const { end } = useDirection();\n return css`\n position: relative;\n padding: calc(1.5 * ${theme.base.spacing});\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n border-top-${end}-radius: ${theme.components.card['border-radius']};\n border-bottom-${end}-radius: ${theme.components.card['border-radius']};\n\n ${\n hasDismiss &&\n css`\n border-inline-end: none;\n padding-inline-end: calc(0.75 * ${theme.base.spacing});\n border-radius: 0;\n `\n }\n `;\n});\n\nStyledBannerContent.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessage = styled.li<{ inline: boolean }>(({ inline, theme }) => {\n return css`\n color: ${theme.base.palette['foreground-color']};\n ${inline &&\n css`\n display: inline-block;\n margin-inline-end: ${theme.base.spacing};\n `}\n `;\n});\n\nStyledBannerMessage.defaultProps = defaultThemeProp;\n\nexport const StyledBannerDismissColumn = styled.div(({ theme }) => {\n const { end } = useDirection();\n return css`\n border-top-${end}-radius: ${theme.components.card['border-radius']};\n border-bottom-${end}-radius: ${theme.components.card['border-radius']};\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n `;\n});\n\nStyledBannerDismissColumn.defaultProps = defaultThemeProp;\n\nexport const StyledBannerDismissButton = styled(Button)``;\n\nexport const StyledBannerStatus = styled.div<Pick<BannerProps, 'variant'>>(({ variant, theme }) => {\n const { background: bg } = theme.components.banner[variant];\n const color = tryCatch(() =>\n getContrast(bg, theme.base.palette['primary-background']) >= 3\n ? theme.base.palette['primary-background']\n : readableColor(bg)\n );\n\n const { start } = useDirection();\n\n return css`\n background-color: ${bg};\n width: 3.125rem;\n color: ${color};\n border-top-${start}-radius: ${theme.components.card['border-radius']};\n border-bottom-${start}-radius: ${theme.components.card['border-radius']};\n font-size: 1.25rem;\n `;\n});\n\nStyledBannerStatus.defaultProps = defaultThemeProp;\n\nexport const StyledBanner = styled.div(({ theme }) => {\n return css`\n background: ${theme.components.card.background};\n border-radius: ${theme.components.card['border-radius']};\n `;\n});\n\nStyledBanner.defaultProps = defaultThemeProp;\n\nconst Banner: FunctionComponent<BannerProps & ForwardProps> = forwardRef(\n (\n {\n variant,\n heading,\n headingTag = 'h2',\n messages,\n onDismiss,\n action,\n id,\n ...restProps\n }: PropsWithoutRef<BannerProps>,\n ref: BannerProps['ref']\n ) => {\n const inline = messages.length === 1;\n const singleLine = inline && !heading;\n const hasDismiss = !!onDismiss;\n\n let bannerIcon = 'warn-solid';\n let role: string | undefined = 'alert';\n let ariaLive = 'assertive';\n\n if (variant === 'info') {\n bannerIcon = 'bulb-solid';\n ariaLive = 'polite';\n role = undefined;\n } else if (variant === 'success') {\n bannerIcon = 'check';\n ariaLive = 'polite';\n role = undefined;\n } else if (variant === 'warning') {\n bannerIcon = 'flag-wave-solid';\n }\n\n const t = useI18n();\n\n return (\n <Flex\n {...restProps}\n container\n as={StyledBanner}\n role={role}\n aria-live={ariaLive}\n id={id}\n ref={ref}\n >\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n item={{ shrink: 0 }}\n as={StyledBannerStatus}\n variant={variant}\n >\n <Icon name={bannerIcon} />\n </Flex>\n\n <Flex\n container={singleLine ? { alignItems: 'center' } : { direction: 'column', gap: 1 }}\n item={{ grow: 1 }}\n as={StyledBannerContent}\n hasDismiss={hasDismiss}\n >\n {heading && (\n <Text variant='h4' as={headingTag}>\n {heading}\n </Text>\n )}\n\n <StyledBannerMessages inline={inline}>\n {messages.map((msg, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <StyledBannerMessage key={`${msg}+${index}`} inline={inline}>\n {msg}\n </StyledBannerMessage>\n ))}\n </StyledBannerMessages>\n\n {action}\n </Flex>\n\n {onDismiss && (\n <Flex\n container={{\n direction: 'column',\n justify: singleLine ? 'center' : undefined,\n pad: [singleLine ? 0.5 : 1, 0.5, 0.5, 0]\n }}\n as={StyledBannerDismissColumn}\n >\n <StyledBannerDismissButton\n variant='simple'\n icon\n onClick={() => onDismiss(id)}\n aria-label={t('banner_dismiss_button_label_a11y')}\n >\n <Icon name='times' />\n </StyledBannerDismissButton>\n </Flex>\n )}\n </Flex>\n );\n }\n);\n\nexport default Banner;\n"]}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AAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACK,GACvB,CACR,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { FunctionComponent, ReactNode, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { getContrast, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Icon, { registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as bulbIcon from '../Icon/icons/bulb.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport Button from '../Button';\nimport { tryCatch } from '../../utils';\nimport { useDirection, useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport Text from '../Text';\n\nregisterIcon(timesIcon, checkIcon, bulbIcon, warnSolidIcon, flagWaveSolidIcon);\n\nexport interface BannerProps extends BaseProps, NoChildrenProp {\n /** Controls the styling of the Banner. */\n variant: 'urgent' | 'success' | 'warning' | 'info';\n /** Heading text for the Banner. */\n heading?: string;\n /**\n * The heading tag to render the provided heading as. This is agnostic to the styling of the heading.\n * @default \"h2\"\n */\n headingTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n /** Pass one or more descriptive messages to inform the user. */\n messages: string[];\n /** ID for the Banner. Used both as onDismiss callback arg and DOM id. */\n id: string;\n /** Link or Button provided to the user for next steps. Link should use regular href and Button should use an onClick handler. */\n action?: ReactNode;\n /** Callback when user explicitly dismisses the Banner. */\n onDismiss?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledBannerMessages = styled.ul<{ inline: boolean }>(({ theme, inline }) => {\n return css`\n list-style-position: inside;\n ${inline &&\n css`\n display: inline-block;\n margin-inline-end: ${theme.base.spacing};\n `}\n `;\n});\n\nStyledBannerMessages.defaultProps = defaultThemeProp;\n\nexport const StyledBannerContent = styled.div<{ hasDismiss: boolean }>(({ theme, hasDismiss }) => {\n const { end } = useDirection();\n return css`\n position: relative;\n padding: calc(1.5 * ${theme.base.spacing});\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n border-top-${end}-radius: ${theme.components.card['border-radius']};\n border-bottom-${end}-radius: ${theme.components.card['border-radius']};\n\n ${\n hasDismiss &&\n css`\n border-inline-end: none;\n padding-inline-end: calc(0.75 * ${theme.base.spacing});\n border-radius: 0;\n `\n }\n `;\n});\n\nStyledBannerContent.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessage = styled.li<{ inline: boolean }>(({ inline, theme }) => {\n return css`\n color: ${theme.base.palette['foreground-color']};\n word-break: break-word;\n\n ${inline &&\n css`\n display: inline-block;\n margin-inline-end: ${theme.base.spacing};\n `}\n `;\n});\n\nStyledBannerMessage.defaultProps = defaultThemeProp;\n\nexport const StyledBannerDismissColumn = styled.div(({ theme }) => {\n const { end } = useDirection();\n return css`\n border-top-${end}-radius: ${theme.components.card['border-radius']};\n border-bottom-${end}-radius: ${theme.components.card['border-radius']};\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n `;\n});\n\nStyledBannerDismissColumn.defaultProps = defaultThemeProp;\n\nexport const StyledBannerDismissButton = styled(Button)``;\n\nexport const StyledBannerStatus = styled.div<Pick<BannerProps, 'variant'>>(({ variant, theme }) => {\n const { background: bg } = theme.components.banner[variant];\n const color = tryCatch(() =>\n getContrast(bg, theme.base.palette['primary-background']) >= 3\n ? theme.base.palette['primary-background']\n : readableColor(bg)\n );\n\n const { start } = useDirection();\n\n return css`\n background-color: ${bg};\n width: 3.125rem;\n color: ${color};\n border-top-${start}-radius: ${theme.components.card['border-radius']};\n border-bottom-${start}-radius: ${theme.components.card['border-radius']};\n font-size: 1.25rem;\n `;\n});\n\nStyledBannerStatus.defaultProps = defaultThemeProp;\n\nexport const StyledBanner = styled.div(({ theme }) => {\n return css`\n background: ${theme.components.card.background};\n border-radius: ${theme.components.card['border-radius']};\n `;\n});\n\nStyledBanner.defaultProps = defaultThemeProp;\n\nconst Banner: FunctionComponent<BannerProps & ForwardProps> = forwardRef(\n (\n {\n variant,\n heading,\n headingTag = 'h2',\n messages,\n onDismiss,\n action,\n id,\n ...restProps\n }: PropsWithoutRef<BannerProps>,\n ref: BannerProps['ref']\n ) => {\n const inline = messages.length === 1;\n const singleLine = inline && !heading;\n const hasDismiss = !!onDismiss;\n\n let bannerIcon = 'warn-solid';\n let role: string | undefined = 'alert';\n let ariaLive = 'assertive';\n\n if (variant === 'info') {\n bannerIcon = 'bulb-solid';\n ariaLive = 'polite';\n role = undefined;\n } else if (variant === 'success') {\n bannerIcon = 'check';\n ariaLive = 'polite';\n role = undefined;\n } else if (variant === 'warning') {\n bannerIcon = 'flag-wave-solid';\n }\n\n const t = useI18n();\n\n return (\n <Flex\n {...restProps}\n container\n as={StyledBanner}\n role={role}\n aria-live={ariaLive}\n id={id}\n ref={ref}\n >\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n item={{ shrink: 0 }}\n as={StyledBannerStatus}\n variant={variant}\n >\n <Icon name={bannerIcon} />\n </Flex>\n\n <Flex\n container={singleLine ? { alignItems: 'center' } : { direction: 'column', gap: 1 }}\n item={{ grow: 1 }}\n as={StyledBannerContent}\n hasDismiss={hasDismiss}\n >\n {heading && (\n <Text variant='h4' as={headingTag}>\n {heading}\n </Text>\n )}\n\n <StyledBannerMessages inline={inline}>\n {messages.map((msg, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <StyledBannerMessage key={`${msg}+${index}`} inline={inline}>\n {msg}\n </StyledBannerMessage>\n ))}\n </StyledBannerMessages>\n\n {action}\n </Flex>\n\n {onDismiss && (\n <Flex\n container={{\n direction: 'column',\n justify: singleLine ? 'center' : undefined,\n pad: [singleLine ? 0.5 : 1, 0.5, 0.5, 0]\n }}\n as={StyledBannerDismissColumn}\n >\n <StyledBannerDismissButton\n variant='simple'\n icon\n onClick={() => onDismiss(id)}\n aria-label={t('banner_dismiss_button_label_a11y')}\n >\n <Icon name='times' />\n </StyledBannerDismissButton>\n </Flex>\n )}\n </Flex>\n );\n }\n);\n\nexport default Banner;\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",
|
|
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;
|
|
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"}
|