@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
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, Fragment, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
+
import { rgba } from 'polished';
|
|
4
5
|
import { useElement, useConsolidatedRef, useDirection } from '../../hooks';
|
|
5
6
|
import { defaultThemeProp } from '../../theme';
|
|
6
|
-
import { debounce } from '../../utils';
|
|
7
|
-
import Button from '../Button';
|
|
7
|
+
import { debounce, tryCatch } from '../../utils';
|
|
8
|
+
import Button, { StyledButton } from '../Button';
|
|
8
9
|
import Flex from '../Flex';
|
|
9
|
-
import Link from '../Link';
|
|
10
|
+
import Link, { StyledLink } from '../Link';
|
|
10
11
|
import Icon, { StyledIcon, registerIcon } from '../Icon';
|
|
11
12
|
import * as caretLeftIcon from '../Icon/icons/caret-left.icon';
|
|
12
13
|
import * as caretRightIcon from '../Icon/icons/caret-right.icon';
|
|
13
14
|
import MenuButton from '../MenuButton';
|
|
14
|
-
import Text from '../Text';
|
|
15
|
+
import Text, { StyledText } from '../Text';
|
|
15
16
|
registerIcon(caretLeftIcon, caretRightIcon);
|
|
16
|
-
|
|
17
|
+
const StyledSeparator = styled(Icon)(({ theme }) => {
|
|
18
|
+
const color = tryCatch(() => rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2']));
|
|
19
|
+
return css `
|
|
20
|
+
color: ${color};
|
|
21
|
+
`;
|
|
22
|
+
});
|
|
23
|
+
export const StyledBreadcrumbs = styled.div(({ theme, oneItemRemaining }) => css `
|
|
17
24
|
white-space: nowrap;
|
|
18
25
|
overflow: visible;
|
|
19
26
|
visibility: hidden;
|
|
@@ -24,6 +31,12 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
|
|
|
24
31
|
flex-shrink: 0;
|
|
25
32
|
}
|
|
26
33
|
|
|
34
|
+
${StyledLink},
|
|
35
|
+
${StyledButton},
|
|
36
|
+
${StyledText} {
|
|
37
|
+
max-width: ${theme.base['content-width'].md};
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
${oneItemRemaining &&
|
|
28
41
|
css `
|
|
29
42
|
& > :last-child {
|
|
@@ -33,6 +46,20 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
|
|
|
33
46
|
`}
|
|
34
47
|
`);
|
|
35
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;
|
|
36
63
|
const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
|
|
37
64
|
const [breadcrumbsEl, setBreadcrumbsEl] = useElement();
|
|
38
65
|
const [numMenuItems, setNumMenuItems] = useState(0);
|
|
@@ -72,22 +99,22 @@ const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
|
|
|
72
99
|
}
|
|
73
100
|
}, [breadcrumbsEl, numMenuItems]);
|
|
74
101
|
const { end } = useDirection();
|
|
75
|
-
return (_jsxs(Flex, { ...restProps, container: { gap:
|
|
102
|
+
return (_jsxs(Flex, { ...restProps, container: { gap: 0.5, alignItems: 'center' }, as: StyledBreadcrumbs, oneItemRemaining: numMenuItems === path.length - 1, ref: breadcrumbRef, children: [numMenuItems > 0 && (_jsxs(_Fragment, { children: [_jsx(MenuButton, { text: 'Links', iconOnly: true, variant: 'link', icon: 'folder-hierarchy-solid', menu: { items: path.slice(0, numMenuItems).reverse() } }), _jsx(StyledSeparator, { name: `caret-${end}` })] })), path.slice(numMenuItems).map((crumb, index) => {
|
|
76
103
|
const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;
|
|
77
104
|
let Comp;
|
|
78
105
|
if (href)
|
|
79
|
-
Comp = (_jsxs(Link, { href: href, onClick: (e) => {
|
|
106
|
+
Comp = (_jsxs(Link, { href: href, as: primary.length > 60 ? StyledEllipsizedLink : undefined, onClick: (e) => {
|
|
80
107
|
onClick?.(id, e);
|
|
81
108
|
}, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
82
109
|
else if (onClick)
|
|
83
|
-
Comp = (_jsxs(Button, { variant: 'link', onClick: (e) => {
|
|
110
|
+
Comp = (_jsxs(Button, { variant: 'link', as: primary.length > 60 ? StyledEllipsizedButton : undefined, onClick: (e) => {
|
|
84
111
|
onClick(id, e);
|
|
85
112
|
}, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
86
113
|
else
|
|
87
|
-
Comp = (_jsxs(Text, { ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
114
|
+
Comp = (_jsxs(Text, { as: primary.length > 60 ? StyledEllipsizedText : undefined, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
88
115
|
if (index === path.slice(numMenuItems).length - 1)
|
|
89
116
|
return Comp;
|
|
90
|
-
return (_jsxs(Fragment, { children: [Comp, _jsx(
|
|
117
|
+
return (_jsxs(Fragment, { children: [Comp, _jsx(StyledSeparator, { name: `caret-${end}` })] }, id));
|
|
91
118
|
})] }));
|
|
92
119
|
});
|
|
93
120
|
export default Breadcrumbs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.js","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EAIR,SAAS,EACT,MAAM,EACN,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAG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AE/D,OAAO,CACL,MAAC,QAAQ,eACN,IAAI,EACL,KAAC,IAAI,IAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAI,KAFjB,EAAE,CAGN,CACZ,CAAC;YACJ,CAAC,CAAC,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n Fragment,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useRef,\n useState,\n MouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useElement, useConsolidatedRef, useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { debounce } from '../../utils';\nimport Button from '../Button';\nimport Flex from '../Flex';\nimport Link from '../Link';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport MenuButton from '../MenuButton';\nimport Text from '../Text';\nimport { MenuItemProps } from '../Menu';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport interface BreadcrumbsProps extends BaseProps, NoChildrenProp {\n /** A set of actions representing the chronological hierarchy of pages or locations leading to the current view. */\n path: MenuItemProps[];\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledBreadcrumbs = styled.div<{ oneItemRemaining: boolean }>(\n ({ oneItemRemaining }) => css`\n white-space: nowrap;\n overflow: visible;\n visibility: hidden;\n\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n }\n\n ${oneItemRemaining &&\n css`\n & > :last-child {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `}\n `\n);\n\nStyledBreadcrumbs.defaultProps = defaultThemeProp;\n\nconst Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps> = forwardRef(\n ({ path, ...restProps }: PropsWithoutRef<BreadcrumbsProps>, ref: BreadcrumbsProps['ref']) => {\n const [breadcrumbsEl, setBreadcrumbsEl] = useElement<HTMLDivElement>();\n const [numMenuItems, setNumMenuItems] = useState(0);\n const minInlineWidth = useRef(0);\n\n const breadcrumbRef = useConsolidatedRef(setBreadcrumbsEl, ref);\n\n const debouncedResize = debounce((entries: ResizeObserverEntry[]) => {\n if (entries[0].contentRect.width > minInlineWidth.current) {\n setNumMenuItems(curr => {\n if (curr === 0) return curr;\n return curr - 1;\n });\n }\n }, 100);\n\n const resizeObserver = new ResizeObserver(debouncedResize);\n\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1 && numMenuItems < path.length - 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n setNumMenuItems(curr => {\n if (curr === path.length - 1) return curr;\n return curr + 1;\n });\n } else if (breadcrumbsEl) breadcrumbsEl.style.visibility = 'visible';\n },\n { root: breadcrumbsEl, threshold: 1 }\n );\n\n useEffect(() => {\n if (breadcrumbsEl && breadcrumbsEl.lastChild) {\n intersectionObserver.observe(breadcrumbsEl.lastChild as Element);\n resizeObserver.observe(breadcrumbsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [breadcrumbsEl, numMenuItems]);\n\n const { end } = useDirection();\n\n return (\n <Flex\n {...restProps}\n container={{ gap: 1, alignItems: 'center' }}\n as={StyledBreadcrumbs}\n oneItemRemaining={numMenuItems === path.length - 1}\n ref={breadcrumbRef}\n >\n {numMenuItems > 0 && (\n <>\n <MenuButton\n text='Links'\n iconOnly\n variant='link'\n icon='folder-hierarchy-solid'\n menu={{ items: path.slice(0, numMenuItems).reverse() }}\n />\n <Icon name={`caret-${end}`} />\n </>\n )}\n {path.slice(numMenuItems).map((crumb, index) => {\n const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;\n let Comp;\n if (href)\n Comp = (\n <Link\n key={id}\n href={href}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n onClick?.(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Link>\n );\n else if (onClick)\n Comp = (\n <Button\n key={id}\n variant='link'\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onClick(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Button>\n );\n else\n Comp = (\n <Text key={id} {...restCrumbProps}>\n {visual} {primary}\n </Text>\n );\n\n if (index === path.slice(numMenuItems).length - 1) return Comp;\n\n return (\n <Fragment key={id}>\n {Comp}\n <Icon name={`caret-${end}`} />\n </Fragment>\n );\n })}\n </Flex>\n );\n }\n);\n\nexport default Breadcrumbs;\n"]}
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EAIR,SAAS,EACT,MAAM,EACN,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAA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D,cAAc,aAEjB,MAAM,OAAG,OAAO,KAJZ,EAAE,CAKF,CACR,CAAC;gBAEJ,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAE/D,OAAO,CACL,MAAC,QAAQ,eACN,IAAI,EACL,KAAC,eAAe,IAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAI,KAF5B,EAAE,CAGN,CACZ,CAAC;YACJ,CAAC,CAAC,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n Fragment,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useRef,\n useState,\n MouseEvent\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { useElement, useConsolidatedRef, useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { debounce, tryCatch } from '../../utils';\nimport Button, { StyledButton } from '../Button';\nimport Flex from '../Flex';\nimport Link, { StyledLink } from '../Link';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport MenuButton from '../MenuButton';\nimport Text, { StyledText } from '../Text';\nimport { MenuItemProps } from '../Menu';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport interface BreadcrumbsProps extends BaseProps, NoChildrenProp {\n /** A set of actions representing the chronological hierarchy of pages or locations leading to the current view. */\n path: MenuItemProps[];\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledSeparator: typeof Icon = styled(Icon)(({ theme }) => {\n const color = tryCatch(() =>\n rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2'])\n );\n\n return css`\n color: ${color};\n `;\n});\n\nexport const StyledBreadcrumbs = styled.div<{ oneItemRemaining: boolean }>(\n ({ theme, oneItemRemaining }) => css`\n white-space: nowrap;\n overflow: visible;\n visibility: hidden;\n\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n }\n\n ${StyledLink},\n ${StyledButton},\n ${StyledText} {\n max-width: ${theme.base['content-width'].md};\n }\n\n ${oneItemRemaining &&\n css`\n & > :last-child {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `}\n `\n);\n\nStyledBreadcrumbs.defaultProps = defaultThemeProp;\n\nconst getEllipsisStyles = ({ theme }: { theme: DefaultTheme }) => {\n return css`\n min-width: ${theme.base['content-width'].xs};\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n `;\n};\n\nconst StyledEllipsizedLink = styled(Link)(getEllipsisStyles);\n\nStyledEllipsizedLink.defaultProps = defaultThemeProp;\n\nconst StyledEllipsizedButton = styled(Button)(getEllipsisStyles);\n\nStyledEllipsizedButton.defaultProps = defaultThemeProp;\n\nconst StyledEllipsizedText = styled(Text)(getEllipsisStyles);\n\nStyledEllipsizedText.defaultProps = defaultThemeProp;\n\nconst Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps> = forwardRef(\n ({ path, ...restProps }: PropsWithoutRef<BreadcrumbsProps>, ref: BreadcrumbsProps['ref']) => {\n const [breadcrumbsEl, setBreadcrumbsEl] = useElement<HTMLDivElement>();\n const [numMenuItems, setNumMenuItems] = useState(0);\n const minInlineWidth = useRef(0);\n\n const breadcrumbRef = useConsolidatedRef(setBreadcrumbsEl, ref);\n\n const debouncedResize = debounce((entries: ResizeObserverEntry[]) => {\n if (entries[0].contentRect.width > minInlineWidth.current) {\n setNumMenuItems(curr => {\n if (curr === 0) return curr;\n return curr - 1;\n });\n }\n }, 100);\n\n const resizeObserver = new ResizeObserver(debouncedResize);\n\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1 && numMenuItems < path.length - 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n setNumMenuItems(curr => {\n if (curr === path.length - 1) return curr;\n return curr + 1;\n });\n } else if (breadcrumbsEl) breadcrumbsEl.style.visibility = 'visible';\n },\n { root: breadcrumbsEl, threshold: 1 }\n );\n\n useEffect(() => {\n if (breadcrumbsEl && breadcrumbsEl.lastChild) {\n intersectionObserver.observe(breadcrumbsEl.lastChild as Element);\n resizeObserver.observe(breadcrumbsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [breadcrumbsEl, numMenuItems]);\n\n const { end } = useDirection();\n\n return (\n <Flex\n {...restProps}\n container={{ gap: 0.5, alignItems: 'center' }}\n as={StyledBreadcrumbs}\n oneItemRemaining={numMenuItems === path.length - 1}\n ref={breadcrumbRef}\n >\n {numMenuItems > 0 && (\n <>\n <MenuButton\n text='Links'\n iconOnly\n variant='link'\n icon='folder-hierarchy-solid'\n menu={{ items: path.slice(0, numMenuItems).reverse() }}\n />\n <StyledSeparator name={`caret-${end}`} />\n </>\n )}\n {path.slice(numMenuItems).map((crumb, index) => {\n const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;\n let Comp;\n if (href)\n Comp = (\n <Link\n key={id}\n href={href}\n as={primary.length > 60 ? StyledEllipsizedLink : undefined}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n onClick?.(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Link>\n );\n else if (onClick)\n Comp = (\n <Button\n key={id}\n variant='link'\n as={primary.length > 60 ? StyledEllipsizedButton : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onClick(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Button>\n );\n else\n Comp = (\n <Text\n key={id}\n as={primary.length > 60 ? StyledEllipsizedText : undefined}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Text>\n );\n\n if (index === path.slice(numMenuItems).length - 1) return Comp;\n\n return (\n <Fragment key={id}>\n {Comp}\n <StyledSeparator name={`caret-${end}`} />\n </Fragment>\n );\n })}\n </Flex>\n );\n }\n);\n\nexport default Breadcrumbs;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA6R7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'r
|
|
|
3
3
|
import Icon, { registerIcon } from '../Icon';
|
|
4
4
|
import * as caretDownIcon from '../Icon/icons/caret-down.icon';
|
|
5
5
|
import * as caretUpIcon from '../Icon/icons/caret-up.icon';
|
|
6
|
-
import { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement } from '../../hooks';
|
|
6
|
+
import { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement, useDirection } from '../../hooks';
|
|
7
7
|
import Popover from '../Popover';
|
|
8
8
|
import FormField from '../FormField';
|
|
9
9
|
import { StyledFormControl } from '../FormControl';
|
|
@@ -12,24 +12,38 @@ import Button from '../Button';
|
|
|
12
12
|
import { navigatorIsAvailable } from '../../utils';
|
|
13
13
|
import menuHelpers from '../Menu/helpers';
|
|
14
14
|
import { sameWidth } from '../Popover/modifiers';
|
|
15
|
+
import VisuallyHiddenText from '../VisuallyHiddenText';
|
|
15
16
|
import ComboBoxInput from './ComboBoxInput';
|
|
16
17
|
import { StyledComboBox } from './ComboBox.styles';
|
|
17
18
|
registerIcon(caretDownIcon, caretUpIcon);
|
|
18
19
|
const isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');
|
|
19
20
|
const ComboBox = forwardRef((props, ref) => {
|
|
20
21
|
const uid = useUID();
|
|
21
|
-
const { value, required, id = uid, label, labelHidden, info, status, readOnly, disabled, mode = 'single-select', selected, onChange, actions, onFocus, onBlur, onDropdownButtonClick: onDropdownButtonClickProp, onClick, menu, ...restProps } = props;
|
|
22
|
+
const { value, required, id = uid, label, labelHidden, info, status, readOnly, disabled, mode = 'single-select', selected, onChange, actions, onFocus, onBlur, onResolveSuggestion, onDropdownButtonClick: onDropdownButtonClickProp, onClick, menu, ...restProps } = props;
|
|
23
|
+
const [pauseMenuDescendantEvaluation, setPauseMenuDescendantEvaluation] = useState(true);
|
|
24
|
+
const [pauseSelectedDescendantEvaluation, setPauseSelectedDescendantEvaluation] = useState(false);
|
|
22
25
|
const t = useI18n();
|
|
26
|
+
const listId = `${id}-list`;
|
|
23
27
|
const inputRef = useRef(null);
|
|
24
28
|
const [open, setOpen] = useState(false);
|
|
25
29
|
const menuRef = useRef(null);
|
|
26
30
|
const menuComponentId = `${id}-listbox`;
|
|
31
|
+
const { start } = useDirection();
|
|
27
32
|
// Force a re-render to make sure useFocusWithin has valid elements to set listeners on.
|
|
28
33
|
const [, setContainerEl] = useElement();
|
|
29
34
|
const containerRef = useConsolidatedRef(ref, setContainerEl);
|
|
35
|
+
const toggleMenuDescendantsActive = useCallback((bool) => {
|
|
36
|
+
setPauseMenuDescendantEvaluation(!bool);
|
|
37
|
+
setPauseSelectedDescendantEvaluation(bool);
|
|
38
|
+
}, []);
|
|
39
|
+
const toggleSelectedDescendantsActive = useCallback((bool) => {
|
|
40
|
+
setPauseSelectedDescendantEvaluation(!bool);
|
|
41
|
+
setPauseMenuDescendantEvaluation(bool);
|
|
42
|
+
}, []);
|
|
30
43
|
const focus = useFocusWithin([containerRef], focused => {
|
|
31
44
|
if (!focused) {
|
|
32
45
|
setOpen(false);
|
|
46
|
+
toggleMenuDescendantsActive(false);
|
|
33
47
|
onBlur?.(selected?.items);
|
|
34
48
|
}
|
|
35
49
|
else {
|
|
@@ -48,20 +62,28 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
48
62
|
case 'ArrowUp':
|
|
49
63
|
if (e.altKey) {
|
|
50
64
|
e.preventDefault();
|
|
51
|
-
if (open)
|
|
65
|
+
if (open) {
|
|
52
66
|
setOpen(false);
|
|
67
|
+
toggleMenuDescendantsActive(false);
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
break;
|
|
55
71
|
case 'ArrowDown':
|
|
56
72
|
e.preventDefault();
|
|
57
|
-
if (!open)
|
|
73
|
+
if (!open) {
|
|
58
74
|
setOpen(true);
|
|
75
|
+
toggleMenuDescendantsActive(true);
|
|
76
|
+
}
|
|
59
77
|
break;
|
|
60
78
|
case 'Escape':
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
e.
|
|
79
|
+
case 'Tab':
|
|
80
|
+
if (e.key === 'Escape') {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
if (open)
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}
|
|
64
85
|
setOpen(false);
|
|
86
|
+
toggleMenuDescendantsActive(false);
|
|
65
87
|
break;
|
|
66
88
|
default:
|
|
67
89
|
}
|
|
@@ -71,27 +93,41 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
71
93
|
setOpen(!open);
|
|
72
94
|
}, [open, onDropdownButtonClickProp]);
|
|
73
95
|
const dropdownButton = useMemo(() => {
|
|
74
|
-
return (menu?.items?.length || onDropdownButtonClickProp || !onChange
|
|
75
|
-
!readOnly ? (_jsx(Button, { "aria-label": t(open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'), icon: true, variant: 'simple', onClick: onDropdownButtonClick, onMouseDown: (e) => {
|
|
96
|
+
return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (_jsx(Button, { "aria-label": t(open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'), icon: true, variant: 'simple', onClick: onDropdownButtonClick, onMouseDown: (e) => {
|
|
76
97
|
e.preventDefault();
|
|
77
98
|
inputRef.current?.focus();
|
|
78
99
|
}, disabled: disabled, tabIndex: '-1', children: _jsx(Icon, { name: open ? 'caret-up' : 'caret-down' }) })) : null;
|
|
79
|
-
}, [onDropdownButtonClick, onChange, readOnly, open, disabled
|
|
100
|
+
}, [onDropdownButtonClick, onChange, readOnly, open, disabled]);
|
|
101
|
+
const ariaDescribedBy = useMemo(() => {
|
|
102
|
+
let idString = `${id}-inputDescription`;
|
|
103
|
+
if (info) {
|
|
104
|
+
idString = idString.concat(` ${id}-info`);
|
|
105
|
+
}
|
|
106
|
+
if (onChange) {
|
|
107
|
+
idString = idString.concat(` ${id}-searchDescription`);
|
|
108
|
+
}
|
|
109
|
+
if (mode === 'multi-select') {
|
|
110
|
+
idString = idString.concat(` ${id}-multiselectDescription`);
|
|
111
|
+
}
|
|
112
|
+
return idString;
|
|
113
|
+
}, [info, id, mode, onChange]);
|
|
80
114
|
const onInputClick = useCallback((e) => {
|
|
81
115
|
if (readOnly)
|
|
82
116
|
return;
|
|
83
117
|
setOpen(true);
|
|
118
|
+
toggleMenuDescendantsActive(true);
|
|
84
119
|
onClick?.(e);
|
|
85
120
|
}, [readOnly, onClick]);
|
|
86
121
|
useEffect(() => {
|
|
87
122
|
if (focus && menu && value && value.length > 0) {
|
|
88
123
|
setOpen(true);
|
|
124
|
+
toggleMenuDescendantsActive(true);
|
|
89
125
|
}
|
|
90
126
|
}, [menu, value, focus]);
|
|
91
127
|
// Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.
|
|
92
128
|
// The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.
|
|
93
129
|
const inputActions = (_jsxs(_Fragment, { children: [dropdownButton, actions] }));
|
|
94
|
-
const Comp = (_jsxs(StyledComboBox, { ref: containerRef, as: StyledFormControl, id: `${id}-combobox`,
|
|
130
|
+
const Comp = (_jsxs(StyledComboBox, { ref: containerRef, as: StyledFormControl, id: `${id}-combobox`, role: 'combobox', "aria-haspopup": 'listbox', "aria-expanded": !readOnly && !disabled && open, "aria-owns": open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined, children: [_jsx(ComboBoxInput, { ref: inputRef, role: 'searchbox', "aria-autocomplete": 'list', "aria-controls": open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined, "aria-describedby": ariaDescribedBy, selected: selected?.items, spellCheck: false, ...{
|
|
95
131
|
id,
|
|
96
132
|
readOnly,
|
|
97
133
|
disabled,
|
|
@@ -99,7 +135,11 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
99
135
|
value,
|
|
100
136
|
mode,
|
|
101
137
|
status
|
|
102
|
-
}, actions: inputActions, onRemove: selected?.onRemove, onClick: onInputClick, onKeyDown: onInputKeyDown, required: required,
|
|
138
|
+
}, actions: inputActions, onRemove: selected?.onRemove, onClick: onInputClick, onKeyDown: onInputKeyDown, required: required, pauseDescendantEvaluation: pauseSelectedDescendantEvaluation, onSelectedFocus: () => {
|
|
139
|
+
toggleSelectedDescendantsActive(true);
|
|
140
|
+
}, onSelectedBlur: () => {
|
|
141
|
+
toggleSelectedDescendantsActive(false);
|
|
142
|
+
}, ...restProps }), _jsx(Popover, { show: open && menu !== undefined, target: containerRef.current, placement: 'bottom-start', modifiers: [
|
|
103
143
|
{
|
|
104
144
|
name: 'flip',
|
|
105
145
|
options: {
|
|
@@ -107,17 +147,18 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
107
147
|
}
|
|
108
148
|
},
|
|
109
149
|
sameWidth
|
|
110
|
-
], strategy: isMobile ? 'absolute' : 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
|
|
150
|
+
], strategy: isMobile ? 'absolute' : 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, listId: listId, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
|
|
111
151
|
if (mode === 'single-select') {
|
|
112
152
|
setOpen(false);
|
|
153
|
+
toggleMenuDescendantsActive(true);
|
|
113
154
|
}
|
|
114
155
|
menu.onItemClick?.(itemId, e);
|
|
115
156
|
const clickedItem = menuHelpers.getItem(menu.items, itemId);
|
|
116
157
|
if (clickedItem?.primary && !clickedItem?.selected) {
|
|
117
158
|
selected?.onNew?.(clickedItem?.primary);
|
|
118
159
|
}
|
|
119
|
-
}, arrowNavigationUnsupported: true })) })] }));
|
|
120
|
-
return label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled }, children: Comp })) : (Comp);
|
|
160
|
+
}, "aria-label": t('menu_option_list'), pauseDescendantEvaluation: pauseMenuDescendantEvaluation, arrowNavigationUnsupported: true })) })] }));
|
|
161
|
+
return (_jsxs(_Fragment, { children: [label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled, onResolveSuggestion }, children: Comp })) : (Comp), _jsx(VisuallyHiddenText, { id: `${id}-inputDescription`, "aria-hidden": true, children: `${t('combobox_open_close')} ` }), _jsx(VisuallyHiddenText, { id: `${id}-searchDescription`, "aria-hidden": true, children: t('combobox_search_instructions') }), _jsx(VisuallyHiddenText, { id: `${id}-multiselectDescription`, "aria-hidden": true, children: t('multiselect_instructions', [start]) })] }));
|
|
121
162
|
});
|
|
122
163
|
export default ComboBox;
|
|
123
164
|
//# sourceMappingURL=ComboBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.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,IAAI,SAAS,EAC7C,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACzB,IAAI,IAAI,KAAK,eAAe,EAAE;4BAC5B,OAAO,CAAC,KAAK,CAAC,CAAC;yBAChB;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;wBAE9B,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;wBAE5D,IAAI,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE;4BAClD,QAAQ,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;yBACzC;oBACH,CAAC,EACD,0BAA0B,SAC1B,CACH,GACO,IACK,CAClB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,OAAK,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YACxE,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent as ReactKeyboardEvent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport * as caretUpIcon from '../Icon/icons/caret-up.icon';\nimport { ForwardProps } from '../../types';\nimport { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement } from '../../hooks';\nimport Popover from '../Popover';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport Menu, { MenuProps } from '../Menu';\nimport Button from '../Button';\nimport { navigatorIsAvailable } from '../../utils';\nimport menuHelpers from '../Menu/helpers';\nimport { sameWidth } from '../Popover/modifiers';\n\nimport ComboBoxInput from './ComboBoxInput';\nimport ComboBoxProps from './ComboBox.types';\nimport { StyledComboBox } from './ComboBox.styles';\n\nregisterIcon(caretDownIcon, caretUpIcon);\n\nconst isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');\n\nconst ComboBox: FunctionComponent<ComboBoxProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ComboBoxProps>, ref: Ref<HTMLDivElement>) => {\n const uid = useUID();\n const {\n value,\n required,\n id = uid,\n label,\n labelHidden,\n info,\n status,\n readOnly,\n disabled,\n mode = 'single-select',\n selected,\n onChange,\n actions,\n onFocus,\n onBlur,\n onDropdownButtonClick: onDropdownButtonClickProp,\n onClick,\n menu,\n ...restProps\n } = props;\n\n const t = useI18n();\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const menuRef: MenuProps['ref'] = useRef(null);\n const menuComponentId = `${id}-listbox`;\n\n // Force a re-render to make sure useFocusWithin has valid elements to set listeners on.\n const [, setContainerEl] = useElement();\n const containerRef = useConsolidatedRef<HTMLDivElement>(ref, setContainerEl);\n\n const focus = useFocusWithin([containerRef], focused => {\n if (!focused) {\n setOpen(false);\n onBlur?.(selected?.items);\n } else {\n onFocus?.(selected?.items);\n if (isMobile) {\n setTimeout(() => {\n containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }, 150); // delay it to let keyboard expand first\n }\n }\n });\n\n const onInputKeyDown = useCallback(\n (e: ReactKeyboardEvent<HTMLInputElement>) => {\n if (!menu || readOnly) return;\n switch (e.key) {\n case 'ArrowUp':\n if (e.altKey) {\n e.preventDefault();\n if (open) setOpen(false);\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!open) setOpen(true);\n break;\n case 'Escape':\n e.preventDefault();\n if (open) e.stopPropagation();\n setOpen(false);\n break;\n default:\n }\n },\n [open, readOnly, menu, value]\n );\n\n const onDropdownButtonClick = useCallback(() => {\n onDropdownButtonClickProp?.(!open);\n setOpen(!open);\n }, [open, onDropdownButtonClickProp]);\n\n const dropdownButton = useMemo(() => {\n return (menu?.items?.length || onDropdownButtonClickProp || !onChange || menu?.loading) &&\n !readOnly ? (\n <Button\n aria-label={t(\n open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'\n )}\n icon\n variant='simple'\n onClick={onDropdownButtonClick}\n onMouseDown={(e: MouseEvent) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n disabled={disabled}\n tabIndex='-1'\n >\n <Icon name={open ? 'caret-up' : 'caret-down'} />\n </Button>\n ) : null;\n }, [onDropdownButtonClick, onChange, readOnly, open, disabled, menu?.loading]);\n\n const onInputClick = useCallback(\n (e: MouseEvent) => {\n if (readOnly) return;\n setOpen(true);\n onClick?.(e);\n },\n [readOnly, onClick]\n );\n\n useEffect(() => {\n if (focus && menu && value && value.length > 0) {\n setOpen(true);\n }\n }, [menu, value, focus]);\n\n // Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.\n // The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.\n const inputActions = (\n <>\n {dropdownButton}\n {actions}\n </>\n );\n\n const Comp = (\n <StyledComboBox ref={containerRef} as={StyledFormControl} id={`${id}-combobox`}>\n <ComboBoxInput\n ref={inputRef}\n role='combobox'\n aria-haspopup='listbox'\n aria-expanded={!readOnly && !disabled && open}\n aria-autocomplete='list'\n aria-describedby={info ? `${id}-inputDescription ${id}-info` : `${id}-inputDescription`}\n selected={selected?.items}\n spellCheck={false}\n {...{\n id,\n readOnly,\n disabled,\n onChange,\n value,\n mode,\n status\n }}\n actions={inputActions}\n onRemove={selected?.onRemove}\n onClick={onInputClick}\n onKeyDown={onInputKeyDown}\n required={required}\n {...restProps}\n />\n\n <span id={`${id}-inputDescription`} hidden>\n {`${t('combobox_open_close')} ` && onChange ? t('combobox_search_instructions') : ''}\n </span>\n\n <Popover\n show={open && menu !== undefined}\n target={containerRef.current}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start']\n }\n },\n sameWidth\n ]}\n strategy={isMobile ? 'absolute' : 'fixed'}\n onMouseDown={(e: MouseEvent) => e.preventDefault()}\n >\n {menu && (\n <Menu\n ref={menuRef}\n id={menuComponentId}\n role='listbox'\n mode={mode}\n {...menu}\n items={menu.items}\n focusControlEl={inputRef.current || undefined}\n onItemClick={(itemId, e) => {\n if (mode === 'single-select') {\n setOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n\n const clickedItem = menuHelpers.getItem(menu.items, itemId);\n\n if (clickedItem?.primary && !clickedItem?.selected) {\n selected?.onNew?.(clickedItem?.primary);\n }\n }}\n arrowNavigationUnsupported\n />\n )}\n </Popover>\n </StyledComboBox>\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, required, disabled }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default ComboBox;\n"]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,MAAM,EACN,UAAU,EACV,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,MAAM,MAAM,WAA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4BACf,2BAA2B,CAAC,IAAI,CAAC,CAAC;yBACnC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;wBAE9B,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;wBAE5D,IAAI,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE;4BAClD,QAAQ,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;yBACzC;oBACH,CAAC,gBACW,CAAC,CAAC,kBAAkB,CAAC,EACjC,yBAAyB,EAAE,6BAA6B,EACxD,0BAA0B,SAC1B,CACH,GACO,IACK,CAClB,CAAC;IAEF,OAAO,CACL,8BACG,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,SAAS,OACJ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAEpF,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,EACD,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,mBAAmB,iCAC7C,GAAG,CAAC,CAAC,qBAAqB,CAAC,GAAG,GACZ,EACrB,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,oBAAoB,iCAC9C,CAAC,CAAC,8BAA8B,CAAC,GACf,EACrB,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,yBAAyB,iCACnD,CAAC,CAAC,0BAA0B,EAAE,CAAC,KAAK,CAAC,CAAC,GACpB,IACpB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent as ReactKeyboardEvent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport * as caretUpIcon from '../Icon/icons/caret-up.icon';\nimport { ForwardProps } from '../../types';\nimport {\n useConsolidatedRef,\n useFocusWithin,\n useI18n,\n useUID,\n useElement,\n useDirection\n} from '../../hooks';\nimport Popover from '../Popover';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport Menu, { MenuProps } from '../Menu';\nimport Button from '../Button';\nimport { navigatorIsAvailable } from '../../utils';\nimport menuHelpers from '../Menu/helpers';\nimport { sameWidth } from '../Popover/modifiers';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport ComboBoxInput from './ComboBoxInput';\nimport ComboBoxProps from './ComboBox.types';\nimport { StyledComboBox } from './ComboBox.styles';\n\nregisterIcon(caretDownIcon, caretUpIcon);\n\nconst isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');\n\nconst ComboBox: FunctionComponent<ComboBoxProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ComboBoxProps>, ref: Ref<HTMLDivElement>) => {\n const uid = useUID();\n const {\n value,\n required,\n id = uid,\n label,\n labelHidden,\n info,\n status,\n readOnly,\n disabled,\n mode = 'single-select',\n selected,\n onChange,\n actions,\n onFocus,\n onBlur,\n onResolveSuggestion,\n onDropdownButtonClick: onDropdownButtonClickProp,\n onClick,\n menu,\n ...restProps\n } = props;\n const [pauseMenuDescendantEvaluation, setPauseMenuDescendantEvaluation] = useState(true);\n const [pauseSelectedDescendantEvaluation, setPauseSelectedDescendantEvaluation] =\n useState(false);\n const t = useI18n();\n const listId = `${id}-list`;\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const menuRef: MenuProps['ref'] = useRef(null);\n const menuComponentId = `${id}-listbox`;\n const { start } = useDirection();\n\n // Force a re-render to make sure useFocusWithin has valid elements to set listeners on.\n const [, setContainerEl] = useElement();\n const containerRef = useConsolidatedRef<HTMLDivElement>(ref, setContainerEl);\n\n const toggleMenuDescendantsActive = useCallback((bool: boolean) => {\n setPauseMenuDescendantEvaluation(!bool);\n setPauseSelectedDescendantEvaluation(bool);\n }, []);\n\n const toggleSelectedDescendantsActive = useCallback((bool: boolean) => {\n setPauseSelectedDescendantEvaluation(!bool);\n setPauseMenuDescendantEvaluation(bool);\n }, []);\n\n const focus = useFocusWithin([containerRef], focused => {\n if (!focused) {\n setOpen(false);\n toggleMenuDescendantsActive(false);\n onBlur?.(selected?.items);\n } else {\n onFocus?.(selected?.items);\n if (isMobile) {\n setTimeout(() => {\n containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }, 150); // delay it to let keyboard expand first\n }\n }\n });\n\n const onInputKeyDown = useCallback(\n (e: ReactKeyboardEvent<HTMLInputElement>) => {\n if (!menu || readOnly) return;\n switch (e.key) {\n case 'ArrowUp':\n if (e.altKey) {\n e.preventDefault();\n if (open) {\n setOpen(false);\n toggleMenuDescendantsActive(false);\n }\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n toggleMenuDescendantsActive(true);\n }\n break;\n case 'Escape':\n case 'Tab':\n if (e.key === 'Escape') {\n e.preventDefault();\n if (open) e.stopPropagation();\n }\n setOpen(false);\n toggleMenuDescendantsActive(false);\n break;\n default:\n }\n },\n [open, readOnly, menu, value]\n );\n\n const onDropdownButtonClick = useCallback(() => {\n onDropdownButtonClickProp?.(!open);\n setOpen(!open);\n }, [open, onDropdownButtonClickProp]);\n\n const dropdownButton = useMemo(() => {\n return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (\n <Button\n aria-label={t(\n open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'\n )}\n icon\n variant='simple'\n onClick={onDropdownButtonClick}\n onMouseDown={(e: MouseEvent) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n disabled={disabled}\n tabIndex='-1'\n >\n <Icon name={open ? 'caret-up' : 'caret-down'} />\n </Button>\n ) : null;\n }, [onDropdownButtonClick, onChange, readOnly, open, disabled]);\n\n const ariaDescribedBy = useMemo(() => {\n let idString = `${id}-inputDescription`;\n\n if (info) {\n idString = idString.concat(` ${id}-info`);\n }\n if (onChange) {\n idString = idString.concat(` ${id}-searchDescription`);\n }\n if (mode === 'multi-select') {\n idString = idString.concat(` ${id}-multiselectDescription`);\n }\n\n return idString;\n }, [info, id, mode, onChange]);\n\n const onInputClick = useCallback(\n (e: MouseEvent) => {\n if (readOnly) return;\n setOpen(true);\n toggleMenuDescendantsActive(true);\n onClick?.(e);\n },\n [readOnly, onClick]\n );\n\n useEffect(() => {\n if (focus && menu && value && value.length > 0) {\n setOpen(true);\n toggleMenuDescendantsActive(true);\n }\n }, [menu, value, focus]);\n\n // Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.\n // The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.\n const inputActions = (\n <>\n {dropdownButton}\n {actions}\n </>\n );\n\n const Comp = (\n <StyledComboBox\n ref={containerRef}\n as={StyledFormControl}\n id={`${id}-combobox`}\n role='combobox'\n aria-haspopup='listbox'\n aria-expanded={!readOnly && !disabled && open}\n aria-owns={\n open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined\n }\n >\n <ComboBoxInput\n ref={inputRef}\n role='searchbox'\n aria-autocomplete='list'\n aria-controls={\n open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined\n }\n aria-describedby={ariaDescribedBy}\n selected={selected?.items}\n spellCheck={false}\n {...{\n id,\n readOnly,\n disabled,\n onChange,\n value,\n mode,\n status\n }}\n actions={inputActions}\n onRemove={selected?.onRemove}\n onClick={onInputClick}\n onKeyDown={onInputKeyDown}\n required={required}\n pauseDescendantEvaluation={pauseSelectedDescendantEvaluation}\n onSelectedFocus={() => {\n toggleSelectedDescendantsActive(true);\n }}\n onSelectedBlur={() => {\n toggleSelectedDescendantsActive(false);\n }}\n {...restProps}\n />\n\n <Popover\n show={open && menu !== undefined}\n target={containerRef.current}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start']\n }\n },\n sameWidth\n ]}\n strategy={isMobile ? 'absolute' : 'fixed'}\n onMouseDown={(e: MouseEvent) => e.preventDefault()}\n >\n {menu && (\n <Menu\n ref={menuRef}\n listId={listId}\n id={menuComponentId}\n role='listbox'\n mode={mode}\n {...menu}\n items={menu.items}\n focusControlEl={inputRef.current || undefined}\n onItemClick={(itemId, e) => {\n if (mode === 'single-select') {\n setOpen(false);\n toggleMenuDescendantsActive(true);\n }\n menu.onItemClick?.(itemId, e);\n\n const clickedItem = menuHelpers.getItem(menu.items, itemId);\n\n if (clickedItem?.primary && !clickedItem?.selected) {\n selected?.onNew?.(clickedItem?.primary);\n }\n }}\n aria-label={t('menu_option_list')}\n pauseDescendantEvaluation={pauseMenuDescendantEvaluation}\n arrowNavigationUnsupported\n />\n )}\n </Popover>\n </StyledComboBox>\n );\n\n return (\n <>\n {label ? (\n <FormField\n {...{ label, labelHidden, id, info, status, required, disabled, onResolveSuggestion }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n )}\n <VisuallyHiddenText id={`${id}-inputDescription`} aria-hidden>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`} aria-hidden>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-multiselectDescription`} aria-hidden>\n {t('multiselect_instructions', [start])}\n </VisuallyHiddenText>\n </>\n );\n }\n);\n\nexport default ComboBox;\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const StyledSelectInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
-
export declare const StyledComboBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../..").OmitStrict<import("../FormControl").FormControlProps, never> & Required<Pick<import("../FormControl").FormControlProps, never
|
|
2
|
+
export declare const StyledComboBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../..").OmitStrict<import("../FormControl").FormControlProps, never> & Required<Pick<import("../FormControl").FormControlProps, never>> & {
|
|
3
|
+
hasSuggestion?: boolean | undefined;
|
|
4
|
+
}, never>;
|
|
3
5
|
//# sourceMappingURL=ComboBox.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,yGAmD5B,CAAC;AAIH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,yGAmD5B,CAAC;AAIH,eAAO,MAAM,cAAc;;SASzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, ReactNode } from 'react';
|
|
1
|
+
import { ChangeEvent, ReactNode, Ref } from 'react';
|
|
2
2
|
import type { NoChildrenProp } from '../../types';
|
|
3
3
|
import { FormControlProps } from '../FormControl';
|
|
4
4
|
import { MenuItemProps, MenuProps } from '../Menu/Menu.types';
|
|
@@ -53,6 +53,8 @@ export default interface ComboBoxProps extends NoChildrenProp {
|
|
|
53
53
|
* Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.
|
|
54
54
|
*/
|
|
55
55
|
onBlur?: (selected?: Selected | Selected[]) => void;
|
|
56
|
+
/** Callback fired when AI suggestion is accepted/rejected */
|
|
57
|
+
onResolveSuggestion?: FormControlProps['onResolveSuggestion'];
|
|
56
58
|
/** Automatically focuses the input on render. */
|
|
57
59
|
autoFocus?: boolean;
|
|
58
60
|
/**
|
|
@@ -72,5 +74,7 @@ export default interface ComboBoxProps extends NoChildrenProp {
|
|
|
72
74
|
menu?: MenuProps;
|
|
73
75
|
/** A visual which represents the selected item. */
|
|
74
76
|
visual?: ReactNode;
|
|
77
|
+
/** Reference to the element. */
|
|
78
|
+
ref?: Ref<HTMLDivElement>;
|
|
75
79
|
}
|
|
76
80
|
//# sourceMappingURL=ComboBox.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.types.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBox.types.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,CAAC,OAAO,WAAW,aAAc,SAAQ,cAAc;IAC3D;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,uCAAuC;IACvC,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,wEAAwE;IACxE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,gBAAg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,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,wDAAwD;IACxD,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yCAAyC;IACzC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,mDAAmD;IACnD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gCAAgC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.types.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, ReactNode } from 'react';\n\nimport type { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\nimport { MenuItemProps, MenuProps } from '../Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport default interface ComboBoxProps extends NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the component non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Placeholder text */\n placeholder?: FormControlProps['placeholder'];\n /**\n * Whether it is single selection or multi selection combobox.\n * @default 'single-select'\n */\n mode?: 'single-select' | 'multi-select';\n /** Currently selected option, single for single-select, an array for multi-select. */\n selected?: {\n items?: Selected | Selected[];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n onNew?: (text: string) => void;\n };\n /** Value of the combobox filtering input. */\n value?: FormControlProps['value'];\n /** Callback fired when the filtering input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired when the ComboBox input gains focus. */\n onFocus?: (selected?: Selected | Selected[]) => void;\n /**\n * Callback fired when the ComboBox looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: (selected?: Selected | Selected[]) => void;\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Combobox input. */\n onClick?: (e: MouseEvent) => void;\n /** Action Buttons that will render within the input. */\n actions?: ReactNode;\n /** Menu related props. @see MenuProps */\n menu?: MenuProps;\n /** A visual which represents the selected item. */\n visual?: ReactNode;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ComboBox.types.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, ReactNode, Ref } from 'react';\n\nimport type { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\nimport { MenuItemProps, MenuProps } from '../Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport default interface ComboBoxProps extends NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the component non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Placeholder text */\n placeholder?: FormControlProps['placeholder'];\n /**\n * Whether it is single selection or multi selection combobox.\n * @default 'single-select'\n */\n mode?: 'single-select' | 'multi-select';\n /** Currently selected option, single for single-select, an array for multi-select. */\n selected?: {\n items?: Selected | Selected[];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n onNew?: (text: string) => void;\n };\n /** Value of the combobox filtering input. */\n value?: FormControlProps['value'];\n /** Callback fired when the filtering input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired when the ComboBox input gains focus. */\n onFocus?: (selected?: Selected | Selected[]) => void;\n /**\n * Callback fired when the ComboBox looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: (selected?: Selected | Selected[]) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Combobox input. */\n onClick?: (e: MouseEvent) => void;\n /** Action Buttons that will render within the input. */\n actions?: ReactNode;\n /** Menu related props. @see MenuProps */\n menu?: MenuProps;\n /** A visual which represents the selected item. */\n visual?: ReactNode;\n /** Reference to the element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { BaseProps, ForwardProps } from '../../types';
|
|
3
3
|
import { MenuItemProps } from '../Menu/Menu.types';
|
|
4
|
+
import type { MultiSelectInputProps } from './MultiSelectInput/MultiSelectInput.types';
|
|
4
5
|
import ComboBoxProps, { Selected } from './ComboBox.types';
|
|
5
6
|
interface ComboBoxInputProps extends BaseProps {
|
|
6
7
|
mode?: 'multi-select' | 'single-select';
|
|
@@ -8,6 +9,12 @@ interface ComboBoxInputProps extends BaseProps {
|
|
|
8
9
|
value?: ComboBoxProps['value'];
|
|
9
10
|
visual?: ComboBoxProps['visual'];
|
|
10
11
|
onRemove?: (id: MenuItemProps['id'], index: number) => void;
|
|
12
|
+
/** Callback on selected item pseudo focus */
|
|
13
|
+
onSelectedFocus?: MultiSelectInputProps['onSelectedFocus'];
|
|
14
|
+
/** Callback on selected item pseudo blur */
|
|
15
|
+
onSelectedBlur?: MultiSelectInputProps['onSelectedBlur'];
|
|
16
|
+
/** Pause evaluation of selected item descendants */
|
|
17
|
+
pauseDescendantEvaluation?: MultiSelectInputProps['pauseDescendantEvaluation'];
|
|
11
18
|
}
|
|
12
19
|
declare const ComboBoxInput: FunctionComponent<ComboBoxInputProps & ForwardProps>;
|
|
13
20
|
export default ComboBoxInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxInput.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oB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BAAqB,CAAC,iBAAiB,CAAC,CAAC;IAC3D,4CAA4C;IAC5C,cAAc,CAAC,EAAE,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACzD,oDAAoD;IACpD,yBAAyB,CAAC,EAAE,qBAAqB,CAAC,2BAA2B,CAAC,CAAC;CAChF;AAED,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAqCvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -3,10 +3,13 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import SingleSelectInput from './SingleSelectInput/SingleSelectInput';
|
|
4
4
|
import MultiSelectInput from './MultiSelectInput/MultiSelectInput';
|
|
5
5
|
const ComboBoxInput = forwardRef((props, ref) => {
|
|
6
|
-
const { value, mode, selected, visual, onRemove, ...restProps } = props;
|
|
6
|
+
const { value, mode, selected, visual, onRemove, onSelectedFocus, onSelectedBlur, pauseDescendantEvaluation, ...restProps } = props;
|
|
7
7
|
return mode === 'multi-select' ? (_jsx(MultiSelectInput, { selected: selected, value: value, ...{
|
|
8
8
|
ref,
|
|
9
|
-
onRemove
|
|
9
|
+
onRemove,
|
|
10
|
+
onSelectedBlur,
|
|
11
|
+
onSelectedFocus,
|
|
12
|
+
pauseDescendantEvaluation
|
|
10
13
|
}, ...restProps })) : (_jsx(SingleSelectInput, { ref: ref, selected: selected, value: value, visual: visual, ...restProps }));
|
|
11
14
|
});
|
|
12
15
|
export default ComboBoxInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxInput.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAK5E,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBoxInput.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAK5E,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AAkBnE,MAAM,aAAa,GAAyD,UAAU,CACpF,CAAC,KAA0C,EAAE,GAA0B,EAAE,EAAE;IACzE,MAAM,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,OAAO,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAC/B,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAsB,EAChC,KAAK,EAAE,KAAK,KACR;YACF,GAAG;YACH,QAAQ;YACR,cAAc;YACd,eAAe;YACf,yBAAyB;SAC1B,KACG,SAAS,GACb,CACH,CAAC,CAAC,CAAC,CACF,KAAC,iBAAiB,IAChB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAoB,EAC9B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,KACV,SAAS,GACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef } from 'react';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { MenuItemProps } from '../Menu/Menu.types';\n\nimport SingleSelectInput from './SingleSelectInput/SingleSelectInput';\nimport MultiSelectInput from './MultiSelectInput/MultiSelectInput';\nimport type { MultiSelectInputProps } from './MultiSelectInput/MultiSelectInput.types';\nimport ComboBoxProps, { Selected } from './ComboBox.types';\n\ninterface ComboBoxInputProps extends BaseProps {\n mode?: 'multi-select' | 'single-select';\n selected?: Selected | Selected[];\n value?: ComboBoxProps['value'];\n visual?: ComboBoxProps['visual'];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n /** Callback on selected item pseudo focus */\n onSelectedFocus?: MultiSelectInputProps['onSelectedFocus'];\n /** Callback on selected item pseudo blur */\n onSelectedBlur?: MultiSelectInputProps['onSelectedBlur'];\n /** Pause evaluation of selected item descendants */\n pauseDescendantEvaluation?: MultiSelectInputProps['pauseDescendantEvaluation'];\n}\n\nconst ComboBoxInput: FunctionComponent<ComboBoxInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ComboBoxInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n value,\n mode,\n selected,\n visual,\n onRemove,\n onSelectedFocus,\n onSelectedBlur,\n pauseDescendantEvaluation,\n ...restProps\n } = props;\n\n return mode === 'multi-select' ? (\n <MultiSelectInput\n selected={selected as Selected[]}\n value={value}\n {...{\n ref,\n onRemove,\n onSelectedBlur,\n onSelectedFocus,\n pauseDescendantEvaluation\n }}\n {...restProps}\n />\n ) : (\n <SingleSelectInput\n ref={ref}\n selected={selected as Selected}\n value={value}\n visual={visual}\n {...restProps}\n />\n );\n }\n);\n\nexport default ComboBoxInput;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiB9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,sBAAsB,yGAwBjC,CAAC;AAGH,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CA8M7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|