@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,17 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useCallback } from 'react';
|
|
2
|
+
import { forwardRef, useRef, useCallback, useMemo, useState, useEffect } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
+
import { transparentize } from 'polished';
|
|
4
5
|
import { defaultThemeProp } from '../../../theme';
|
|
5
6
|
import Selectable, { StyledSelectable } from '../../Badges/Selection';
|
|
6
7
|
import { StyledFormControl } from '../../FormControl';
|
|
7
8
|
import Flex from '../../Flex';
|
|
8
|
-
import {
|
|
9
|
-
import { cap } from '../../../utils';
|
|
9
|
+
import { useConsolidatedRef, useActiveDescendant, useDirection, useI18n, useUID } from '../../../hooks';
|
|
10
|
+
import { cap, tryCatch } from '../../../utils';
|
|
11
|
+
import { StyledBareButton } from '../../Button/BareButton';
|
|
12
|
+
import VisuallyHiddenText from '../../VisuallyHiddenText';
|
|
10
13
|
import { StyledSelectInput } from '../ComboBox.styles';
|
|
11
14
|
export const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {
|
|
15
|
+
const { background } = theme.components.badges.selectable.base;
|
|
16
|
+
const { 'foreground-color': foreground } = theme.base.palette;
|
|
17
|
+
const boxShadowColor = tryCatch(() => transparentize(0.45, foreground));
|
|
12
18
|
return css `
|
|
13
19
|
ul {
|
|
14
20
|
list-style: none;
|
|
21
|
+
|
|
22
|
+
&[data-active-scope='true'] ${StyledSelectable}[data-current='true'] {
|
|
23
|
+
color: ${theme.base.palette.interactive};
|
|
24
|
+
box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};
|
|
25
|
+
outline: none;
|
|
26
|
+
|
|
27
|
+
${StyledBareButton} {
|
|
28
|
+
color: ${theme.base.palette.interactive};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
15
31
|
}
|
|
16
32
|
|
|
17
33
|
${StyledSelectable} {
|
|
@@ -21,48 +37,108 @@ export const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {
|
|
|
21
37
|
});
|
|
22
38
|
StyledMultiSelectInput.defaultProps = defaultThemeProp;
|
|
23
39
|
const MultiSelectInput = forwardRef((props, ref) => {
|
|
24
|
-
const { selected = [], value, onRemove, onChange, onKeyDown, actions, readOnly, disabled, status, placeholder, autoFocus, ...restProps } = props;
|
|
40
|
+
const { selected = [], value, onRemove, onChange, onKeyDown, onResolveSuggestion, actions, readOnly, disabled, status, placeholder, autoFocus, pauseDescendantEvaluation, onSelectedFocus, onSelectedBlur, 'aria-controls': ariaControls, ...restProps } = props;
|
|
41
|
+
const t = useI18n();
|
|
42
|
+
const id = useUID();
|
|
25
43
|
const inputRef = useConsolidatedRef(ref);
|
|
26
44
|
const listRef = useRef(null);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
const [focusDescendant, setFocusDescendant] = useState(null);
|
|
46
|
+
const [activeItemId, setActiveItemId] = useState(null);
|
|
47
|
+
const { start, end } = useDirection();
|
|
48
|
+
const uadConfig = useMemo(() => ({
|
|
49
|
+
focusEl: inputRef.current,
|
|
50
|
+
scope: listRef.current,
|
|
51
|
+
selector: 'li[role="option"]',
|
|
52
|
+
orientation: 'horizontal',
|
|
53
|
+
focusDescendantEl: focusDescendant,
|
|
54
|
+
clearFocusDescendant: () => {
|
|
55
|
+
setFocusDescendant(null);
|
|
56
|
+
},
|
|
57
|
+
pauseDescendantEvaluation,
|
|
58
|
+
onClick: (el) => {
|
|
59
|
+
el.click();
|
|
60
|
+
}
|
|
61
|
+
}), [pauseDescendantEvaluation, selected, focusDescendant]);
|
|
62
|
+
const { activeDescendant } = useActiveDescendant(uadConfig, [
|
|
63
|
+
pauseDescendantEvaluation,
|
|
64
|
+
selected
|
|
65
|
+
]);
|
|
66
|
+
const handleSelectedRemoval = useCallback((selectionId, idx) => {
|
|
67
|
+
if (!pauseDescendantEvaluation && idx === selected.length - 1) {
|
|
68
|
+
if (selected.length > 1) {
|
|
69
|
+
setFocusDescendant(listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] ||
|
|
70
|
+
null);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
onSelectedBlur?.();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
onRemove?.(selectionId, idx);
|
|
77
|
+
}, [selected, onRemove, onSelectedBlur, uadConfig]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
// Maintain active item & prev. val only as it changes.
|
|
80
|
+
if (activeDescendant?.id && activeDescendant.id !== activeItemId) {
|
|
81
|
+
setActiveItemId(activeDescendant.id);
|
|
82
|
+
}
|
|
83
|
+
}, [activeDescendant]);
|
|
33
84
|
const onInputKeyDown = useCallback((e) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
85
|
+
if (selected.length && inputRef.current?.selectionStart === 0) {
|
|
86
|
+
const lastIndex = selected.length - 1;
|
|
87
|
+
if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {
|
|
88
|
+
setFocusDescendant(listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] ||
|
|
89
|
+
null);
|
|
90
|
+
onSelectedFocus?.();
|
|
91
|
+
}
|
|
92
|
+
const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]
|
|
93
|
+
?.id;
|
|
94
|
+
const onLastItem = activeItemId === lastSelectableId;
|
|
95
|
+
if (!pauseDescendantEvaluation &&
|
|
96
|
+
((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')) {
|
|
97
|
+
onSelectedBlur?.();
|
|
98
|
+
}
|
|
99
|
+
if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {
|
|
100
|
+
handleSelectedRemoval(selected[lastIndex].id, lastIndex);
|
|
101
|
+
}
|
|
37
102
|
}
|
|
38
103
|
onKeyDown?.(e);
|
|
39
|
-
}, [
|
|
40
|
-
|
|
41
|
-
|
|
104
|
+
}, [
|
|
105
|
+
pauseDescendantEvaluation,
|
|
106
|
+
activeItemId,
|
|
107
|
+
onKeyDown,
|
|
108
|
+
handleSelectedRemoval,
|
|
109
|
+
selected,
|
|
110
|
+
readOnly,
|
|
111
|
+
disabled
|
|
112
|
+
]);
|
|
113
|
+
const ariaDescribedBy = useMemo(() => {
|
|
114
|
+
return onChange
|
|
115
|
+
? `${id}-inputDescription ${id}-searchDescription`
|
|
116
|
+
: `${id}-inputDescription`;
|
|
117
|
+
}, [id]);
|
|
118
|
+
return (_jsxs(Flex, { as: StyledMultiSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, container: { alignItems: 'center' }, ...{
|
|
42
119
|
readOnly,
|
|
43
120
|
disabled,
|
|
44
121
|
status
|
|
45
|
-
}, children: [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
autoFocus: autoFocus, ...restProps }) })] }), actions] }));
|
|
122
|
+
}, children: [selected.length > 0 && (_jsx(Flex, { ref: listRef, id: id, as: 'ul', role: 'listbox', container: { alignItems: 'center', wrap: 'wrap' }, "aria-label": t('selected_items'), children: selected.map((element, idx) => {
|
|
123
|
+
return (_jsx(Selectable, { as: 'li', role: 'option', id: element.id.toString(), status: status, onClick: e => {
|
|
124
|
+
const mouseClick = e.detail !== 0;
|
|
125
|
+
if (!readOnly && !disabled && !mouseClick) {
|
|
126
|
+
handleSelectedRemoval(element.id, idx);
|
|
127
|
+
}
|
|
128
|
+
}, onRemove: () => {
|
|
129
|
+
if (!readOnly && !disabled) {
|
|
130
|
+
handleSelectedRemoval(element.id, idx);
|
|
131
|
+
}
|
|
132
|
+
}, onKeyDown: (e) => {
|
|
133
|
+
// prevent browser's Back on FF
|
|
134
|
+
if (e.key === 'Backspace')
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
}, tabIndex: '-1', "aria-label": `${t('remove')} ${element.text}`, "aria-describedby": ariaDescribedBy, children: element.text }, element.id));
|
|
137
|
+
}) })), _jsx(Flex, { item: { grow: 1 }, container: true, children: _jsx("input", { size: 5, ref: inputRef, value: value,
|
|
138
|
+
// no-op avoids react uncontrolled warning
|
|
139
|
+
onChange: onChange || (() => { }), onKeyDown: onInputKeyDown, readOnly: readOnly || !onChange, disabled: disabled, placeholder: selected?.length ? undefined : placeholder, autoComplete: 'off',
|
|
140
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
141
|
+
autoFocus: autoFocus, "aria-controls": !pauseDescendantEvaluation ? id : ariaControls, ...restProps }) }), actions, _jsx(VisuallyHiddenText, { id: `${id}-inputDescription`, children: `${t('combobox_open_close')} ` }), _jsx(VisuallyHiddenText, { id: `${id}-searchDescription`, children: t('combobox_search_instructions') })] }));
|
|
66
142
|
});
|
|
67
143
|
export default MultiSelectInput;
|
|
68
144
|
//# sourceMappingURL=MultiSelectInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,MAAM,EACN,WAAW,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5E,OAAO,GAAG,CAAA;;;;;MAKN,gBAAgB;4BACM,KAAK,CAAC,IAAI,CAAC,OAAO;;GAE3C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,gBAAgB,GAA4D,UAAU,CAC1F,CAAC,KAA6C,EAAE,GAA0B,EAAE,EAAE;IAC5E,MAAM,EACJ,QAAQ,GAAG,EAAE,EACb,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SA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SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAC/B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EACvD,YAAY,EAAC,KAAK;4BAClB,iDAAiD;4BACjD,SAAS,EAAE,SAAS,KAChB,SAAS,GACb,GACG,IACF,EACN,OAAO,IACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n FunctionComponent,\n forwardRef,\n Ref,\n PropsWithoutRef,\n KeyboardEvent,\n useRef,\n useCallback\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport Selectable, { StyledSelectable } from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport { useArrows, useConsolidatedRef, useDirection } from '../../../hooks';\nimport { cap } from '../../../utils';\nimport { StyledSelectInput } from '../ComboBox.styles';\n\nimport { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {\n return css`\n ul {\n list-style: none;\n }\n\n ${StyledSelectable} {\n margin: calc(0.25 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledMultiSelectInput.defaultProps = defaultThemeProp;\n\nconst MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MultiSelectInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n selected = [],\n value,\n onRemove,\n onChange,\n onKeyDown,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n ...restProps\n } = props;\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n useArrows(listRef, {\n selector: 'div[role=\"button\"], input',\n cycle: false,\n dir: 'left-right',\n allowTabFocus: false\n });\n\n const onInputKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n const lastIndex = selected.length - 1;\n if (e.key === 'Backspace' && !(readOnly || disabled) && !value && selected.length > 0) {\n onRemove?.(selected[lastIndex].id, lastIndex);\n }\n onKeyDown?.(e);\n },\n [onKeyDown, value, selected, readOnly, disabled]\n );\n\n const { end } = useDirection();\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n container={{ alignItems: 'center' }}\n {...{\n readOnly,\n disabled,\n status\n }}\n >\n <Flex\n ref={listRef}\n as='ul'\n item={{ grow: 1 }}\n container={{ alignItems: 'center', wrap: 'wrap' }}\n onBlur={() => {\n if (inputRef.current) inputRef.current.tabIndex = 0;\n }}\n >\n {selected.map((element, idx) => {\n return (\n <li key={element.id}>\n <Selectable\n id={element.id}\n status={status}\n onRemove={\n readOnly || disabled\n ? undefined\n : id => {\n onRemove?.(id, idx);\n inputRef.current?.focus();\n }\n }\n onKeyDown={(e: KeyboardEvent<Element>) => {\n // prevent browser's Back on FF\n if (e.key === 'Backspace') e.preventDefault();\n if (idx === selected.length - 1 && e.key === `Arrow${cap(end)}`)\n inputRef.current?.focus();\n }}\n >\n {element.text}\n </Selectable>\n </li>\n );\n })}\n <Flex as='li' role='presentation' item={{ grow: 1 }} container>\n <input\n size={5}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onInputKeyDown}\n readOnly={readOnly || !onChange}\n disabled={disabled}\n placeholder={selected?.length ? undefined : placeholder}\n autoComplete='off'\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n {...restProps}\n />\n </Flex>\n </Flex>\n {actions}\n </Flex>\n );\n }\n);\n\nexport default MultiSelectInput;\n"]}
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],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,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n FunctionComponent,\n forwardRef,\n Ref,\n PropsWithoutRef,\n KeyboardEvent,\n useRef,\n useCallback,\n useMemo,\n useState,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport { ForwardProps } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport Selectable, { StyledSelectable } from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport {\n useConsolidatedRef,\n useActiveDescendant,\n useDirection,\n useI18n,\n useUID\n} from '../../../hooks';\nimport { cap, tryCatch } from '../../../utils';\nimport { StyledBareButton } from '../../Button/BareButton';\nimport VisuallyHiddenText from '../../VisuallyHiddenText';\nimport { StyledSelectInput } from '../ComboBox.styles';\n\nimport { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {\n const { background } = theme.components.badges.selectable.base;\n const { 'foreground-color': foreground } = theme.base.palette;\n const boxShadowColor = tryCatch(() => transparentize(0.45, foreground));\n\n return css`\n ul {\n list-style: none;\n\n &[data-active-scope='true'] ${StyledSelectable}[data-current='true'] {\n color: ${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: ${theme.base.palette.interactive};\n }\n }\n }\n\n ${StyledSelectable} {\n margin: calc(0.25 * ${theme.base.spacing});\n }\n `;\n});\nStyledMultiSelectInput.defaultProps = defaultThemeProp;\n\nconst MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MultiSelectInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n selected = [],\n value,\n onRemove,\n onChange,\n onKeyDown,\n onResolveSuggestion,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n pauseDescendantEvaluation,\n onSelectedFocus,\n onSelectedBlur,\n 'aria-controls': ariaControls,\n ...restProps\n } = props;\n const t = useI18n();\n const id = useUID();\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [activeItemId, setActiveItemId] = useState<string | null>(null);\n const { start, end } = useDirection();\n\n const uadConfig = useMemo(\n () => ({\n focusEl: inputRef.current,\n scope: listRef.current,\n selector: 'li[role=\"option\"]',\n orientation: 'horizontal' as const,\n focusDescendantEl: focusDescendant,\n clearFocusDescendant: () => {\n setFocusDescendant(null);\n },\n pauseDescendantEvaluation,\n onClick: (el: HTMLElement) => {\n el.click();\n }\n }),\n [pauseDescendantEvaluation, selected, focusDescendant]\n );\n\n const { activeDescendant } = useActiveDescendant(uadConfig, [\n pauseDescendantEvaluation,\n selected\n ]);\n\n const handleSelectedRemoval = useCallback(\n (selectionId, idx) => {\n if (!pauseDescendantEvaluation && idx === selected.length - 1) {\n if (selected.length > 1) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] as HTMLElement) ||\n null\n );\n } else {\n onSelectedBlur?.();\n }\n }\n onRemove?.(selectionId, idx);\n },\n [selected, onRemove, onSelectedBlur, uadConfig]\n );\n\n useEffect(() => {\n // Maintain active item & prev. val only as it changes.\n if (activeDescendant?.id && activeDescendant.id !== activeItemId) {\n setActiveItemId(activeDescendant.id);\n }\n }, [activeDescendant]);\n\n const onInputKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (selected.length && inputRef.current?.selectionStart === 0) {\n const lastIndex = selected.length - 1;\n if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] as HTMLElement) ||\n null\n );\n onSelectedFocus?.();\n }\n\n const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]\n ?.id;\n const onLastItem = activeItemId === lastSelectableId;\n\n if (\n !pauseDescendantEvaluation &&\n ((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')\n ) {\n onSelectedBlur?.();\n }\n\n if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {\n handleSelectedRemoval(selected[lastIndex].id, lastIndex);\n }\n }\n onKeyDown?.(e);\n },\n [\n pauseDescendantEvaluation,\n activeItemId,\n onKeyDown,\n handleSelectedRemoval,\n selected,\n readOnly,\n disabled\n ]\n );\n\n const ariaDescribedBy = useMemo(() => {\n return onChange\n ? `${id}-inputDescription ${id}-searchDescription`\n : `${id}-inputDescription`;\n }, [id]);\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center' }}\n {...{\n readOnly,\n disabled,\n status\n }}\n >\n {selected.length > 0 && (\n <Flex\n ref={listRef}\n id={id}\n as='ul'\n role='listbox'\n container={{ alignItems: 'center', wrap: 'wrap' }}\n aria-label={t('selected_items')}\n >\n {selected.map((element, idx) => {\n return (\n <Selectable\n as='li'\n key={element.id}\n role='option'\n id={element.id.toString()}\n status={status}\n onClick={e => {\n const mouseClick = e.detail !== 0;\n\n if (!readOnly && !disabled && !mouseClick) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onRemove={() => {\n if (!readOnly && !disabled) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onKeyDown={(e: KeyboardEvent<Element>) => {\n // prevent browser's Back on FF\n if (e.key === 'Backspace') e.preventDefault();\n }}\n tabIndex='-1'\n aria-label={`${t('remove')} ${element.text}`}\n aria-describedby={ariaDescribedBy}\n >\n {element.text}\n </Selectable>\n );\n })}\n </Flex>\n )}\n <Flex item={{ grow: 1 }} container>\n <input\n size={5}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onInputKeyDown}\n readOnly={readOnly || !onChange}\n disabled={disabled}\n placeholder={selected?.length ? undefined : placeholder}\n autoComplete='off'\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n aria-controls={!pauseDescendantEvaluation ? id : ariaControls}\n {...restProps}\n />\n </Flex>\n {actions}\n\n <VisuallyHiddenText id={`${id}-inputDescription`}>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`}>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n </Flex>\n );\n }\n);\n\nexport default MultiSelectInput;\n"]}
|
|
@@ -15,6 +15,8 @@ export interface MultiSelectInputProps extends BaseProps {
|
|
|
15
15
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
16
16
|
/** Callback fired on every key stroke on input field. */
|
|
17
17
|
onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
18
|
+
/** Callback fired when AI suggestion is accepted/rejected */
|
|
19
|
+
onResolveSuggestion?: FormControlProps['onResolveSuggestion'];
|
|
18
20
|
/** Makes the input non editable and non clickable. The browser defaults to false. */
|
|
19
21
|
readOnly?: FormControlProps['readOnly'];
|
|
20
22
|
/** Disable the control. The browser defaults to false. */
|
|
@@ -27,5 +29,13 @@ export interface MultiSelectInputProps extends BaseProps {
|
|
|
27
29
|
actions?: ReactNode;
|
|
28
30
|
/** Automatically focuses the input on render. */
|
|
29
31
|
autoFocus?: boolean;
|
|
32
|
+
/** Pause evaluation of selected item descendants */
|
|
33
|
+
pauseDescendantEvaluation?: boolean;
|
|
34
|
+
/** Callback on selected item pseudo focus */
|
|
35
|
+
onSelectedFocus?: () => void;
|
|
36
|
+
/** Callback on selected item pseudo blur */
|
|
37
|
+
onSelectedBlur?: () => void;
|
|
38
|
+
/** ID of pseudo-focus container controlled by input (ex: list, menu) */
|
|
39
|
+
'aria-controls'?: string;
|
|
30
40
|
}
|
|
31
41
|
//# sourceMappingURL=MultiSelectInput.types.d.ts.map
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,CAAC;IACpC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.types.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, KeyboardEvent, ReactNode } from 'react';\n\nimport { BaseProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\nimport { Selected } from '../ComboBox.types';\n\nexport interface MultiSelectInputProps extends BaseProps {\n /** List of items to be represented as pills. */\n selected?: Selected[];\n /** Input value */\n value?: string;\n /** Callback fired when the list value is selected irrespective of the input value changes. */\n onRemove?: (id: string, index: number) => void;\n /** Callback invoked when user accepts custom value by pressing enter. */\n onNew?: (text: string) => void;\n /** Callback fired when internal input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired on every key stroke on input field. */\n onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Placeholder visible on empty input. */\n placeholder?: string;\n /** Additional actions related to the input. */\n actions?: ReactNode;\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.types.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, KeyboardEvent, ReactNode } from 'react';\n\nimport { BaseProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\nimport { Selected } from '../ComboBox.types';\n\nexport interface MultiSelectInputProps extends BaseProps {\n /** List of items to be represented as pills. */\n selected?: Selected[];\n /** Input value */\n value?: string;\n /** Callback fired when the list value is selected irrespective of the input value changes. */\n onRemove?: (id: string, index: number) => void;\n /** Callback invoked when user accepts custom value by pressing enter. */\n onNew?: (text: string) => void;\n /** Callback fired when internal input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired on every key stroke on input field. */\n onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Placeholder visible on empty input. */\n placeholder?: string;\n /** Additional actions related to the input. */\n actions?: ReactNode;\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n /** Pause evaluation of selected item descendants */\n pauseDescendantEvaluation?: boolean;\n /** Callback on selected item pseudo focus */\n onSelectedFocus?: () => void;\n /** Callback on selected item pseudo blur */\n onSelectedBlur?: () => void;\n /** ID of pseudo-focus container controlled by input (ex: list, menu) */\n 'aria-controls'?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAM5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,uBAAuB,yGAA8B,CAAC;AAuBnE,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"SingleSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAM5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,uBAAuB,yGAA8B,CAAC;AAuBnE,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAkD/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -17,8 +17,8 @@ const StyledVisualContainer = styled.span(props => {
|
|
|
17
17
|
});
|
|
18
18
|
StyledVisualContainer.defaultProps = defaultThemeProp;
|
|
19
19
|
const SingleSelectInput = forwardRef((props, ref) => {
|
|
20
|
-
const { value, readOnly, disabled, status, actions, onChange, selected, visual, ...restProps } = props;
|
|
21
|
-
return (_jsxs(Flex, { as: StyledSingleSelectInput, forwardedAs: StyledFormControl, container: { alignItems: 'center', wrap: 'nowrap' }, ...{
|
|
20
|
+
const { value, readOnly, disabled, status, actions, onChange, onResolveSuggestion, selected, visual, ...restProps } = props;
|
|
21
|
+
return (_jsxs(Flex, { as: StyledSingleSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, container: { alignItems: 'center', wrap: 'nowrap' }, ...{
|
|
22
22
|
disabled,
|
|
23
23
|
status,
|
|
24
24
|
readOnly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA,EAAE,CAAC;AAEnE,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;IAChD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,cAAc,EAAE,WAAW,EAC3B,KAAK,EAAE,EAAE,MAAM,EAAE,EAClB,EACF,EACF,GAAG,KAAK,CAAC;IAEV,OAAO,GAAG,CAAA;yBACa,WAAW,CAAC,cAAc,CAAC,UAAU,WAAW,CAAC,cAAc,CAAC;sBACnE,MAAM,MAAM,WAAW,CAAC,cAAc,CAAC;4BACjC,IAAI,CAAC,OAAO;mBACrB,MAAM,UAAU,WAAW,CAAC,cAAc,CAAC;GAC3D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,iBAAiB,GAA6D,UAAU,CAC5F,CAAC,KAA8C,EAAE,GAA0B,EAAE,EAAE;IAC7E,MAAM,
|
|
1
|
+
{"version":3,"file":"SingleSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC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AC5D,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAC/C;YACF,QAAQ;YACR,MAAM;YACN,QAAQ;SACT,aAEA,MAAM,IAAI,CACT,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,qBAAqB,YACpF,MAAM,GACF,CACR,EACD,mBACM;oBACF,GAAG;oBACH,QAAQ;oBACR,MAAM;oBACN,QAAQ;iBACT,EACD,KAAK,EAAE,KAAK,IAAI,QAAQ,EAAE,IAAI,IAAI,EAAE;gBACpC,0CAA0C;gBAC1C,QAAQ,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAChC,QAAQ,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAC/B,YAAY,EAAC,KAAK,KACd,SAAS,GACb,EACD,OAAO,IACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport { ForwardProps } from '../../../types';\nimport { StyledSelectInput } from '../ComboBox.styles';\n\nimport SingleSelectInputProps from './SingleSelectInput.types';\n\nexport const StyledSingleSelectInput = styled(StyledSelectInput)``;\n\nconst StyledVisualContainer = styled.span(props => {\n const {\n theme: {\n base,\n components: {\n 'form-control': formControl,\n input: { height }\n }\n }\n } = props;\n\n return css`\n border-inline-end: ${formControl['border-width']} solid ${formControl['border-color']};\n min-width: calc(${height} - ${formControl['border-width']});\n padding: 0 calc(0.5 * ${base.spacing});\n height: calc(${height} - 2 * ${formControl['border-width']});\n `;\n});\n\nStyledVisualContainer.defaultProps = defaultThemeProp;\n\nconst SingleSelectInput: FunctionComponent<SingleSelectInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<SingleSelectInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n value,\n readOnly,\n disabled,\n status,\n actions,\n onChange,\n onResolveSuggestion,\n selected,\n visual,\n ...restProps\n } = props;\n\n return (\n <Flex\n as={StyledSingleSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n {...{\n disabled,\n status,\n readOnly\n }}\n >\n {visual && (\n <Flex container={{ justify: 'center', alignItems: 'center' }} as={StyledVisualContainer}>\n {visual}\n </Flex>\n )}\n <input\n {...{\n ref,\n disabled,\n status,\n readOnly\n }}\n value={value || selected?.text || ''}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n readOnly={readOnly || !onChange}\n autoComplete='off'\n {...restProps}\n />\n {actions}\n </Flex>\n );\n }\n);\n\nexport default SingleSelectInput;\n"]}
|
|
@@ -12,6 +12,8 @@ export default interface SingleSelectInputProps {
|
|
|
12
12
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
13
13
|
/** Callback fired on every key stroke on input field. */
|
|
14
14
|
onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
15
|
+
/** Callback fired when AI suggestion is accepted/rejected */
|
|
16
|
+
onResolveSuggestion?: FormControlProps['onResolveSuggestion'];
|
|
15
17
|
/** Makes the input non editable and non clickable. The browser defaults to false. */
|
|
16
18
|
readOnly?: FormControlProps['readOnly'];
|
|
17
19
|
/** Disable the control. The browser defaults to false. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleSelectInput.types.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAC,OAAO,WAAW,sBAAsB;IAC7C,gDAAgD;IAChD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD,yDAAyD;IACzD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzD,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yDAAyD;IACzD,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC"}
|
|
1
|
+
{"version":3,"file":"SingleSelectInput.types.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAC,OAAO,WAAW,sBAAsB;IAC7C,gDAAgD;IAChD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD,yDAAyD;IACzD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzD,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAC9D,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yDAAyD;IACzD,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleSelectInput.types.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, KeyboardEvent, ReactNode } from 'react';\n\nimport { FormControlProps } from '../../FormControl';\nimport ComboBoxProps, { Selected } from '../ComboBox.types';\n\nexport default interface SingleSelectInputProps {\n /** List of items to be represented as pills. */\n selected?: Selected;\n /** Input value */\n value?: string;\n /** Callback invoked when user accepts custom value by pressing enter. */\n onNew?: (text: string) => void;\n /** Callback fired when internal input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired on every key stroke on input field. */\n onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Placeholder visible on empty input. */\n placeholder?: string;\n /** Additional actions related to the input. */\n actions?: ReactNode;\n /** A visual to render a preview for the selected item */\n visual?: ComboBoxProps['visual'];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SingleSelectInput.types.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/SingleSelectInput/SingleSelectInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, KeyboardEvent, ReactNode } from 'react';\n\nimport { FormControlProps } from '../../FormControl';\nimport ComboBoxProps, { Selected } from '../ComboBox.types';\n\nexport default interface SingleSelectInputProps {\n /** List of items to be represented as pills. */\n selected?: Selected;\n /** Input value */\n value?: string;\n /** Callback invoked when user accepts custom value by pressing enter. */\n onNew?: (text: string) => void;\n /** Callback fired when internal input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired on every key stroke on input field. */\n onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Placeholder visible on empty input. */\n placeholder?: string;\n /** Additional actions related to the input. */\n actions?: ReactNode;\n /** A visual to render a preview for the selected item */\n visual?: ComboBoxProps['visual'];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeInput.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqB3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,QAAA,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"CompositeInput.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqB3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,QAAA,MAAM,cAAc,sEA0IqD,WAAW,GAAG,IAAI,CAAC;AAE5F,eAAe,cAAc,CAAC"}
|
|
@@ -39,7 +39,7 @@ const CompositeInput = forwardRef((props, ref) => {
|
|
|
39
39
|
closePopover();
|
|
40
40
|
}, document, [closePopover]);
|
|
41
41
|
const labelId = `${id}-label`;
|
|
42
|
-
const Comp = (_jsxs(Flex, { as: StyledCompositeInput, forwardedAs: StyledFormControl, container: { alignItems: 'center' }, status: status, disabled: disabled, ref: containerRef, children: [_jsxs(
|
|
42
|
+
const Comp = (_jsxs(Flex, { as: StyledCompositeInput, forwardedAs: StyledFormControl, container: { alignItems: 'center' }, status: status, disabled: disabled, ref: containerRef, children: [_jsxs(Flex, { container: { alignItems: 'center' }, as: StyledInputContainer, children: [_jsx(StyledInputButton, { ...restProps, id: id, disabled: disabled, "aria-haspopup": 'dialog', "aria-expanded": !disabled && open, "aria-describedby": info ? `${id}-info` : undefined, readOnly: true, required: required, onClick: () => {
|
|
43
43
|
if (!disabled) {
|
|
44
44
|
setOpen(true);
|
|
45
45
|
}
|
|
@@ -48,7 +48,7 @@ const CompositeInput = forwardRef((props, ref) => {
|
|
|
48
48
|
e.preventDefault();
|
|
49
49
|
setOpen(true);
|
|
50
50
|
}
|
|
51
|
-
}, value: value ?? '', ref: buttonRef }), (
|
|
51
|
+
}, value: value ?? '', ref: buttonRef }), _jsx(Flex, { container: { justify: 'center', alignItems: 'center' }, style: { pointerEvents: value ? '' : 'none' }, children: value && !open ? (_jsx(Button, { icon: true, compact: true, variant: 'simple', label: t('clear'), onClick: onClear, children: _jsx(Icon, { name: 'times' }) })) : (_jsx(Icon, { name: 'caret-down' })) })] }), open && (_jsx(Popover, { ref: setPopoverEl, role: 'dialog', target: containerRef.current, placement: 'bottom-start', strategy: 'fixed', modifiers: [
|
|
52
52
|
{
|
|
53
53
|
name: 'flip',
|
|
54
54
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeInput.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAmB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC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cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAEnC,SAAS,CACP,CAAC,CAAC,EAAE;QACF,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,YAAY,EAAE,CAAC;IACjB,CAAC,EACD,QAAQ,EACR,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE,QAAQ,CAAC;IAE9B,MAAM,IAAI,GAAG,CACX,MAAC,IAAI,IACH,EAAE,EAAE,oBAAoB,EACxB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,YAAY,aAEjB,MAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"CompositeInput.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAmB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM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,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,YACtE,CAAC,CAAC,OAAO,CAAC,GACJ,IACJ,IACF,GACC,CACX,IACI,CACR,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,OAAO,EAAE,YACjF,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACwF,CAAC;AAE5F,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, useEffect, useRef, useState } from 'react';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { ForwardProps } from '../../types';\nimport {\n useConsolidatedRef,\n useElement,\n useEscape,\n useI18n,\n useOuterEvent,\n useUID\n} from '../../hooks';\nimport { StyledFormControl } from '../FormControl';\nimport { getFocusables } from '../../utils';\nimport Flex from '../Flex';\nimport Button from '../Button';\nimport Popover from '../Popover';\nimport FormField from '../FormField';\n\nimport {\n StyledCompositeInput,\n StyledInputButton,\n StyledInputContainer\n} from './CompositeInput.styles';\nimport { CompositeInputProps } from './CompositeInput.types';\n\nregisterIcon(caretDownIcon, timesIcon);\n\nconst CompositeInput = forwardRef(\n (props: PropsWithoutRef<CompositeInputProps>, ref: CompositeInputProps['ref']) => {\n const uid = useUID();\n const {\n id = uid,\n disabled,\n value,\n onClear,\n required,\n status,\n info,\n label,\n labelHidden,\n dialog: { renderer: Renderer, rendererProps, onApply, onCancel },\n ...restProps\n } = props;\n const t = useI18n();\n\n const [open, setOpen] = useState(false);\n\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const containerRef = useConsolidatedRef<HTMLDivElement>(ref);\n const buttonRef = useRef<HTMLInputElement>(null);\n const formContentRef = useRef<HTMLElement>(null);\n\n const closePopover = () => {\n setOpen(false);\n buttonRef.current?.focus();\n };\n\n useOuterEvent('mousedown', [popoverEl, buttonRef], () => {\n if (open) onCancel({ close: closePopover });\n });\n\n useEffect(() => {\n if (open) {\n getFocusables(formContentRef)[0]?.focus();\n }\n }, [open, formContentRef.current]);\n\n useEscape(\n e => {\n e.preventDefault();\n closePopover();\n },\n document,\n [closePopover]\n );\n\n const labelId = `${id}-label`;\n\n const Comp = (\n <Flex\n as={StyledCompositeInput}\n forwardedAs={StyledFormControl}\n container={{ alignItems: 'center' }}\n status={status}\n disabled={disabled}\n ref={containerRef}\n >\n <Flex container={{ alignItems: 'center' }} as={StyledInputContainer}>\n <StyledInputButton\n {...restProps}\n id={id}\n disabled={disabled}\n aria-haspopup='dialog'\n aria-expanded={!disabled && open}\n aria-describedby={info ? `${id}-info` : undefined}\n readOnly\n required={required}\n onClick={() => {\n if (!disabled) {\n setOpen(true);\n }\n }}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n e.preventDefault();\n setOpen(true);\n }\n }}\n value={value ?? ''}\n ref={buttonRef}\n />\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n style={{ pointerEvents: value ? '' : 'none' }}\n >\n {value && !open ? (\n <Button icon compact variant='simple' label={t('clear')} onClick={onClear}>\n <Icon name='times' />\n </Button>\n ) : (\n <Icon name='caret-down' />\n )}\n </Flex>\n </Flex>\n\n {open && (\n <Popover\n ref={setPopoverEl}\n role='dialog'\n target={containerRef.current}\n placement='bottom-start'\n strategy='fixed'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start']\n }\n }\n ]}\n >\n <Flex container={{ direction: 'column', gap: 1.5, pad: 2 }} ref={formContentRef}>\n <Renderer {...rendererProps} />\n <Flex container={{ justify: 'between' }}>\n <Button variant='secondary' onClick={() => onCancel({ close: closePopover })}>\n {t('cancel')}\n </Button>\n <Button variant='primary' onClick={() => onApply({ close: closePopover })}>\n {t('apply')}\n </Button>\n </Flex>\n </Flex>\n </Popover>\n )}\n </Flex>\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, required, disabled, labelId }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n) as <P extends object>(props: CompositeInputProps<P> & ForwardProps) => JSX.Element | null;\n\nexport default CompositeInput;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"CompositeInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,2GAkB7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,yGAEhC,CAAC;AAEF,eAAO,MAAM,oBAAoB,yGAgChC,CAAC;AAIF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { StyledButton } from '../Button';
|
|
3
3
|
import { defaultThemeProp } from '../../theme';
|
|
4
|
-
import { StyledIcon } from '../Icon';
|
|
5
4
|
import StyledInput from '../Input/Input.styles';
|
|
5
|
+
import { StyledIcon } from '../Icon';
|
|
6
6
|
export const StyledInputButton = styled(StyledInput) `
|
|
7
|
+
padding-inline-end: 2rem;
|
|
7
8
|
background-color: inherit;
|
|
8
9
|
color: currentColor;
|
|
9
10
|
outline: none;
|
|
10
11
|
border: 0;
|
|
11
12
|
caret-color: transparent;
|
|
12
13
|
cursor: pointer;
|
|
13
|
-
|
|
14
|
-
StyledInputButton.defaultProps = defaultThemeProp;
|
|
15
|
-
export const StyledInputContainer = styled.div(({ theme: { base: { spacing } } }) => {
|
|
16
|
-
return css `
|
|
17
|
-
width: 100%;
|
|
18
|
-
position: relative;
|
|
14
|
+
width: 100%;
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
StyledInputContainer
|
|
16
|
+
& + div {
|
|
17
|
+
position: absolute;
|
|
18
|
+
inset: 0.0625rem 0 0.0625rem calc(100% - 2rem);
|
|
19
|
+
${StyledButton} ${StyledIcon} {
|
|
20
|
+
width: 1rem;
|
|
21
|
+
height: 1rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export const StyledInputContainer = styled.div `
|
|
26
|
+
position: relative;
|
|
27
|
+
`;
|
|
30
28
|
export const StyledCompositeInput = styled.div(({ theme: { base: { 'border-radius': borderRadius, 'hit-area': hitArea }, components: { 'form-control': formControl, input } } }) => {
|
|
31
29
|
return css `
|
|
32
30
|
height: ${input.height};
|
|
33
31
|
min-height: ${hitArea['mouse-min']};
|
|
34
32
|
|
|
33
|
+
@media (pointer: coarse) {
|
|
34
|
+
min-height: ${hitArea['finger-min']};
|
|
35
|
+
}
|
|
36
|
+
|
|
35
37
|
&:focus-within {
|
|
36
38
|
border-color: ${formControl[':focus']['border-color']};
|
|
37
39
|
box-shadow: ${formControl[':focus']['box-shadow']};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeInput.styles.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"CompositeInput.styles.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;;;;;;;;;;;;;MAa9C,YAAY,IAAI,UAAU;;;;;CAK/B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE7C,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAC5C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,EAC5D,UAAU,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,EACnD,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;gBACE,KAAK,CAAC,MAAM;oBACR,OAAO,CAAC,WAAW,CAAC;;;sBAGlB,OAAO,CAAC,YAAY,CAAC;;;;wBAInB,WAAW,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC;sBACvC,WAAW,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;;;;;;;YAO7C,YAAY;;wCAEgB,YAAY,MAAM,WAAW,CAAC,eAAe,CAAC;;sCAEhD,YAAY,MAAM,WAAW,CAAC,eAAe,CAAC;;KAE/E,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,eAAe,oBAAoB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { StyledButton } from '../Button';\nimport { defaultThemeProp } from '../../theme';\nimport StyledInput from '../Input/Input.styles';\nimport { StyledIcon } from '../Icon';\n\nexport const StyledInputButton = styled(StyledInput)`\n padding-inline-end: 2rem;\n background-color: inherit;\n color: currentColor;\n outline: none;\n border: 0;\n caret-color: transparent;\n cursor: pointer;\n width: 100%;\n\n & + div {\n position: absolute;\n inset: 0.0625rem 0 0.0625rem calc(100% - 2rem);\n ${StyledButton} ${StyledIcon} {\n width: 1rem;\n height: 1rem;\n }\n }\n`;\n\nexport const StyledInputContainer = styled.div`\n position: relative;\n`;\n\nexport const StyledCompositeInput = styled.div(\n ({\n theme: {\n base: { 'border-radius': borderRadius, 'hit-area': hitArea },\n components: { 'form-control': formControl, input }\n }\n }) => {\n return css`\n height: ${input.height};\n min-height: ${hitArea['mouse-min']};\n\n @media (pointer: coarse) {\n min-height: ${hitArea['finger-min']};\n }\n\n &:focus-within {\n border-color: ${formControl[':focus']['border-color']};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n\n &:hover:not([readonly]):not([disabled]):focus-within {\n border-color: transparent;\n }\n\n & > ${StyledButton} {\n border-start-start-radius: 0;\n border-start-end-radius: calc(${borderRadius} * ${formControl['border-radius']});\n border-end-start-radius: 0;\n border-end-end-radius: calc(${borderRadius} * ${formControl['border-radius']});\n }\n `;\n }\n);\n\nStyledCompositeInput.defaultProps = defaultThemeProp;\n\nexport default StyledCompositeInput;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiB3C,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAGvD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiB3C,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAGvD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAkKvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -7,7 +7,7 @@ import Input from '../Input';
|
|
|
7
7
|
import { getCurrencyMaximumFractionDigits, getFormattedValue, isValidCurrency } from './utils';
|
|
8
8
|
const CurrencyInput = forwardRef((props, ref) => {
|
|
9
9
|
const uid = useUID();
|
|
10
|
-
const { id = uid, status, label, labelHidden, info, required, disabled, readOnly, value: valueProp = '', onChange, onBlur, onFocus, currencyISOCode, showDecimal = true, showGroupSeparators = true, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, step = 1, alwaysShowISOCode = false, ...restProps } = props;
|
|
10
|
+
const { id = uid, status, label, labelHidden, info, required, disabled, readOnly, value: valueProp = '', onChange, onBlur, onFocus, onResolveSuggestion, currencyISOCode, showDecimal = true, showGroupSeparators = true, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, step = 1, alwaysShowISOCode = false, ...restProps } = props;
|
|
11
11
|
const { locale } = useConfiguration();
|
|
12
12
|
const t = useI18n();
|
|
13
13
|
const inputRef = useConsolidatedRef(ref);
|
|
@@ -79,12 +79,25 @@ const CurrencyInput = forwardRef((props, ref) => {
|
|
|
79
79
|
}
|
|
80
80
|
if (e.type === 'focus')
|
|
81
81
|
onFocus?.(parsableValue);
|
|
82
|
-
else
|
|
82
|
+
else {
|
|
83
|
+
if (parsableValue !== value) {
|
|
84
|
+
onChange(parsableValue);
|
|
85
|
+
}
|
|
83
86
|
onBlur?.(parsableValue);
|
|
87
|
+
}
|
|
84
88
|
};
|
|
85
89
|
const formattedValue = useInputFormatter(inputRef, value, formatValue, `\\p{N}${decimalSign}-`);
|
|
86
|
-
const Comp = (_jsx(Input, { ...{ onChange: onInputChange, id, readOnly, required, disabled, status, ...restProps }, inputMode: 'numeric', ref: inputRef, value: formattedValue, onKeyDown: onKeyDown, onFocus: onInputFocusEvent, onBlur: onInputFocusEvent, "aria-label": `${label}. ${validCurrencyISOCode ? t('measured_in', [validCurrencyISOCode]) : ''}`, maxLength: 16 }));
|
|
87
|
-
return label ? (_jsx(FormField, { ...{
|
|
90
|
+
const Comp = (_jsx(Input, { ...{ onChange: onInputChange, id, readOnly, required, disabled, status, ...restProps }, hasSuggestion: status === 'pending' && !!onResolveSuggestion, inputMode: 'numeric', ref: inputRef, value: formattedValue, onKeyDown: onKeyDown, onFocus: onInputFocusEvent, onBlur: onInputFocusEvent, "aria-label": `${label}. ${validCurrencyISOCode ? t('measured_in', [validCurrencyISOCode]) : ''}`, maxLength: 16 }));
|
|
91
|
+
return label ? (_jsx(FormField, { ...{
|
|
92
|
+
label,
|
|
93
|
+
labelHidden,
|
|
94
|
+
id,
|
|
95
|
+
info,
|
|
96
|
+
status,
|
|
97
|
+
required,
|
|
98
|
+
disabled,
|
|
99
|
+
onResolveSuggestion
|
|
100
|
+
}, children: Comp })) : (Comp);
|
|
88
101
|
});
|
|
89
102
|
export default CurrencyInput;
|
|
90
103
|
//# sourceMappingURL=CurrencyInput.js.map
|