@redsift/pickers 11.6.0-muiv5-alpha.3 → 11.6.0-muiv5-alpha.5
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/{components/combobox/Combobox.d.ts → _internal/Combobox2.js} +7 -7
- package/_internal/Combobox2.js.map +1 -0
- package/{components/combobox-content/ComboboxContent.d.ts → _internal/ComboboxContent.js} +5 -5
- package/_internal/ComboboxContent.js.map +1 -0
- package/{components/combobox-content-footer/ComboboxContentFooter.d.ts → _internal/ComboboxContentFooter.js} +2 -2
- package/_internal/ComboboxContentFooter.js.map +1 -0
- package/{components/combobox-content-header/ComboboxContentHeader.d.ts → _internal/ComboboxContentHeader.js} +2 -2
- package/_internal/ComboboxContentHeader.js.map +1 -0
- package/{components/combobox-content-listbox/ComboboxContentListbox.d.ts → _internal/ComboboxContentListbox.js} +2 -2
- package/_internal/ComboboxContentListbox.js.map +1 -0
- package/{components/combobox-trigger/ComboboxTrigger.d.ts → _internal/ComboboxTrigger.js} +2 -2
- package/_internal/ComboboxTrigger.js.map +1 -0
- package/{components/item/Item.d.ts → _internal/Item2.js} +1 -1
- package/_internal/Item2.js.map +1 -0
- package/{components/menu-button/types.d.ts → _internal/MenuButton.js} +27 -2
- package/_internal/MenuButton.js.map +1 -0
- package/{components/menu-button-content/MenuButtonContent.d.ts → _internal/MenuButtonContent.js} +5 -5
- package/_internal/MenuButtonContent.js.map +1 -0
- package/{components/menu-button-content-footer/MenuButtonContentFooter.d.ts → _internal/MenuButtonContentFooter.js} +2 -2
- package/_internal/MenuButtonContentFooter.js.map +1 -0
- package/{components/menu-button-content-header/MenuButtonContentHeader.d.ts → _internal/MenuButtonContentHeader.js} +2 -2
- package/_internal/MenuButtonContentHeader.js.map +1 -0
- package/{components/menu-button-content-menu/MenuButtonContentMenu.d.ts → _internal/MenuButtonContentMenu.js} +2 -2
- package/_internal/MenuButtonContentMenu.js.map +1 -0
- package/{components/menu-button-trigger/MenuButtonTrigger.d.ts → _internal/MenuButtonTrigger.js} +2 -2
- package/_internal/MenuButtonTrigger.js.map +1 -0
- package/{components/select/types.d.ts → _internal/Select2.js} +20 -2
- package/_internal/Select2.js.map +1 -0
- package/{components/select-content/SelectContent.d.ts → _internal/SelectContent.js} +2 -2
- package/_internal/SelectContent.js.map +1 -0
- package/{components/select-trigger/SelectTrigger.d.ts → _internal/SelectTrigger.js} +2 -2
- package/_internal/SelectTrigger.js.map +1 -0
- package/{_virtual → _internal}/_rollupPluginBabelHelpers.js +1 -1
- package/_internal/combobox-content-footer.js +4 -0
- package/_internal/combobox-content-footer.js.map +1 -0
- package/_internal/combobox-content-header.js +4 -0
- package/_internal/combobox-content-header.js.map +1 -0
- package/_internal/combobox-content-listbox.js +6 -0
- package/_internal/combobox-content-listbox.js.map +1 -0
- package/_internal/combobox-content.js +9 -0
- package/_internal/combobox-content.js.map +1 -0
- package/_internal/combobox-trigger.js +6 -0
- package/_internal/combobox-trigger.js.map +1 -0
- package/_internal/combobox.js +10 -0
- package/_internal/combobox.js.map +1 -0
- package/_internal/item.js +2 -0
- package/_internal/item.js.map +1 -0
- package/_internal/menu-button-content-footer.js +4 -0
- package/_internal/menu-button-content-footer.js.map +1 -0
- package/_internal/menu-button-content-header.js +4 -0
- package/_internal/menu-button-content-header.js.map +1 -0
- package/_internal/menu-button-content-menu.js +3 -0
- package/_internal/menu-button-content-menu.js.map +1 -0
- package/_internal/menu-button-content.js +8 -0
- package/_internal/menu-button-content.js.map +1 -0
- package/_internal/menu-button-trigger.js +5 -0
- package/_internal/menu-button-trigger.js.map +1 -0
- package/_internal/menu-button.js +9 -0
- package/_internal/menu-button.js.map +1 -0
- package/_internal/select-content.js +4 -0
- package/_internal/select-content.js.map +1 -0
- package/_internal/select-trigger.js +5 -0
- package/_internal/select-trigger.js.map +1 -0
- package/_internal/select.js +6 -0
- package/_internal/select.js.map +1 -0
- package/{components/combobox-content-footer/types.d.ts → _internal/types.js} +1 -1
- package/_internal/types.js.map +1 -0
- package/{components/menu-button-content/types.d.ts → _internal/types10.js} +1 -1
- package/{components/menu-button-trigger/types.d.ts → _internal/types11.js} +1 -1
- package/{components/select-content/types.d.ts → _internal/types12.js} +1 -1
- package/{components/select-trigger/types.d.ts → _internal/types13.js} +1 -1
- package/{components/combobox-content-header/types.d.ts → _internal/types2.js} +1 -1
- package/{components/combobox-content-listbox/types.d.ts → _internal/types3.js} +2 -2
- package/{components/combobox-content/types.d.ts → _internal/types4.js} +1 -1
- package/{components/combobox-trigger/types.d.ts → _internal/types5.js} +2 -2
- package/{components/combobox/types.d.ts → _internal/types6.js} +1 -1
- package/{components/menu-button-content-footer/types.d.ts → _internal/types7.js} +1 -1
- package/{components/menu-button-content-header/types.d.ts → _internal/types8.js} +1 -1
- package/{components/menu-button-content-menu/types.d.ts → _internal/types9.js} +1 -1
- package/index.js +32 -18
- package/package.json +5 -5
- package/components/combobox/Combobox.js +0 -151
- package/components/combobox/Combobox.js.map +0 -1
- package/components/combobox/context.js +0 -6
- package/components/combobox/context.js.map +0 -1
- package/components/combobox/intl/en-US.json.js +0 -13
- package/components/combobox/intl/en-US.json.js.map +0 -1
- package/components/combobox/intl/fr-FR.json.js +0 -13
- package/components/combobox/intl/fr-FR.json.js.map +0 -1
- package/components/combobox/intl/index.js +0 -10
- package/components/combobox/intl/index.js.map +0 -1
- package/components/combobox/types.js +0 -22
- package/components/combobox/types.js.map +0 -1
- package/components/combobox-content/ComboboxContent.js +0 -70
- package/components/combobox-content/ComboboxContent.js.map +0 -1
- package/components/combobox-content-footer/ComboboxContentFooter.js +0 -28
- package/components/combobox-content-footer/ComboboxContentFooter.js.map +0 -1
- package/components/combobox-content-footer/styles.js +0 -12
- package/components/combobox-content-footer/styles.js.map +0 -1
- package/components/combobox-content-header/ComboboxContentHeader.js +0 -28
- package/components/combobox-content-header/ComboboxContentHeader.js.map +0 -1
- package/components/combobox-content-header/styles.js +0 -12
- package/components/combobox-content-header/styles.js.map +0 -1
- package/components/combobox-content-listbox/ComboboxContentListbox.js +0 -124
- package/components/combobox-content-listbox/ComboboxContentListbox.js.map +0 -1
- package/components/combobox-trigger/ComboboxTrigger.js +0 -352
- package/components/combobox-trigger/ComboboxTrigger.js.map +0 -1
- package/components/item/Item.js +0 -137
- package/components/item/Item.js.map +0 -1
- package/components/item/useMenuItem.js +0 -69
- package/components/item/useMenuItem.js.map +0 -1
- package/components/menu-button/MenuButton.d.ts +0 -29
- package/components/menu-button/MenuButton.js +0 -76
- package/components/menu-button/MenuButton.js.map +0 -1
- package/components/menu-button/context.js +0 -6
- package/components/menu-button/context.js.map +0 -1
- package/components/menu-button-content/MenuButtonContent.js +0 -68
- package/components/menu-button-content/MenuButtonContent.js.map +0 -1
- package/components/menu-button-content-footer/MenuButtonContentFooter.js +0 -28
- package/components/menu-button-content-footer/MenuButtonContentFooter.js.map +0 -1
- package/components/menu-button-content-footer/styles.js +0 -12
- package/components/menu-button-content-footer/styles.js.map +0 -1
- package/components/menu-button-content-header/MenuButtonContentHeader.js +0 -28
- package/components/menu-button-content-header/MenuButtonContentHeader.js.map +0 -1
- package/components/menu-button-content-header/styles.js +0 -12
- package/components/menu-button-content-header/styles.js.map +0 -1
- package/components/menu-button-content-menu/MenuButtonContentMenu.js +0 -41
- package/components/menu-button-content-menu/MenuButtonContentMenu.js.map +0 -1
- package/components/menu-button-trigger/MenuButtonTrigger.js +0 -167
- package/components/menu-button-trigger/MenuButtonTrigger.js.map +0 -1
- package/components/select/Select.d.ts +0 -22
- package/components/select/Select.js +0 -116
- package/components/select/Select.js.map +0 -1
- package/components/select/context.js +0 -6
- package/components/select/context.js.map +0 -1
- package/components/select-content/SelectContent.js +0 -62
- package/components/select-content/SelectContent.js.map +0 -1
- package/components/select-trigger/SelectTrigger.js +0 -249
- package/components/select-trigger/SelectTrigger.js.map +0 -1
- package/index.d.ts +0 -32
- /package/{_virtual → _internal}/_rollupPluginBabelHelpers.js.map +0 -0
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { useState, useEffect, useReducer, useMemo, useRef } from 'react';
|
|
3
|
-
import { ComboboxSelectionMode, ComboboxVariant } from './types.js';
|
|
4
|
-
import { Popover } from '@redsift/popovers';
|
|
5
|
-
import { ComboboxContext } from './context.js';
|
|
6
|
-
import { useTheme, ListboxReducer, ListboxActionType, useId, ThemeProvider, FocusWithinGroup, ListboxContext, Flexbox, Text, Theme } from '@redsift/design-system';
|
|
7
|
-
import { ComboboxTrigger } from '../combobox-trigger/ComboboxTrigger.js';
|
|
8
|
-
import { ComboboxContent } from '../combobox-content/ComboboxContent.js';
|
|
9
|
-
|
|
10
|
-
const COMPONENT_NAME = 'Combobox';
|
|
11
|
-
const CLASSNAME = 'redsift-combobox';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The Combobox component.
|
|
15
|
-
*/
|
|
16
|
-
const BaseCombobox = props => {
|
|
17
|
-
const {
|
|
18
|
-
defaultValue,
|
|
19
|
-
description,
|
|
20
|
-
descriptionProps,
|
|
21
|
-
filter = {
|
|
22
|
-
type: 'startsWith',
|
|
23
|
-
caseSensitive: false
|
|
24
|
-
},
|
|
25
|
-
formRef,
|
|
26
|
-
submitRef,
|
|
27
|
-
inputValue: propsInputValue,
|
|
28
|
-
isDisabled,
|
|
29
|
-
isInvalid,
|
|
30
|
-
maxOptionsLength,
|
|
31
|
-
minWidth = 'trigger-width',
|
|
32
|
-
onChange,
|
|
33
|
-
onInputChange,
|
|
34
|
-
selectionMode = ComboboxSelectionMode.single,
|
|
35
|
-
theme: propsTheme,
|
|
36
|
-
triggerClassName,
|
|
37
|
-
value,
|
|
38
|
-
variant = ComboboxVariant.options,
|
|
39
|
-
wrapperProps
|
|
40
|
-
} = props;
|
|
41
|
-
const theme = useTheme(propsTheme);
|
|
42
|
-
const [selectedValue, setValue] = useState(value || defaultValue || (selectionMode === 'multiple' ? [] : ''));
|
|
43
|
-
const [inputValue, setInputValue] = useState(propsInputValue || '');
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (value) {
|
|
46
|
-
state.setValue(value);
|
|
47
|
-
}
|
|
48
|
-
}, [value]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (propsInputValue) {
|
|
51
|
-
state.setInputValue(propsInputValue);
|
|
52
|
-
}
|
|
53
|
-
}, [propsInputValue]);
|
|
54
|
-
|
|
55
|
-
/** Listbox context */
|
|
56
|
-
const [listboxState, listboxDispatch] = useReducer(ListboxReducer, {
|
|
57
|
-
isDisabled,
|
|
58
|
-
selectedValues: selectionMode === ComboboxSelectionMode.multiple ? selectedValue : [selectedValue],
|
|
59
|
-
selectionMode
|
|
60
|
-
});
|
|
61
|
-
const listboxContext = useMemo(() => ({
|
|
62
|
-
state: listboxState,
|
|
63
|
-
dispatch: listboxDispatch
|
|
64
|
-
}), [listboxState]);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
listboxDispatch({
|
|
67
|
-
type: ListboxActionType.UPDATE_OPTIONS,
|
|
68
|
-
payload: {
|
|
69
|
-
isDisabled: isDisabled || false
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}, [isDisabled]);
|
|
73
|
-
const freeTextItemRef = useRef();
|
|
74
|
-
const [freeTextItemId] = useId();
|
|
75
|
-
|
|
76
|
-
/** Combobox context. */
|
|
77
|
-
const state = {
|
|
78
|
-
filter,
|
|
79
|
-
formRef,
|
|
80
|
-
submitRef,
|
|
81
|
-
value: selectedValue,
|
|
82
|
-
inputValue,
|
|
83
|
-
isDisabled: isDisabled || false,
|
|
84
|
-
isInvalid: isInvalid || false,
|
|
85
|
-
selectionMode,
|
|
86
|
-
variant,
|
|
87
|
-
freeTextItemRef: freeTextItemRef,
|
|
88
|
-
freeTextItemId,
|
|
89
|
-
triggerClassName,
|
|
90
|
-
setValue(value) {
|
|
91
|
-
if (isDisabled) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const previousValue = selectedValue;
|
|
95
|
-
setValue(value);
|
|
96
|
-
if (value !== previousValue && onChange) {
|
|
97
|
-
onChange(value);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
setInputValue(value) {
|
|
101
|
-
if (isDisabled) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const previousValue = inputValue;
|
|
105
|
-
setInputValue(value);
|
|
106
|
-
if (value !== previousValue && onInputChange) {
|
|
107
|
-
onInputChange(value);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
112
|
-
value: {
|
|
113
|
-
theme
|
|
114
|
-
}
|
|
115
|
-
}, /*#__PURE__*/React.createElement(FocusWithinGroup, {
|
|
116
|
-
focusType: "virtual-focus",
|
|
117
|
-
focusOnInit: false,
|
|
118
|
-
maxOptionsLength: maxOptionsLength
|
|
119
|
-
}, /*#__PURE__*/React.createElement(ComboboxContext.Provider, {
|
|
120
|
-
value: state
|
|
121
|
-
}, /*#__PURE__*/React.createElement(ListboxContext.Provider, {
|
|
122
|
-
value: listboxContext
|
|
123
|
-
}, /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
124
|
-
flexDirection: "column",
|
|
125
|
-
alignItems: "flex-start",
|
|
126
|
-
gap: "0px"
|
|
127
|
-
}, wrapperProps), /*#__PURE__*/React.createElement(Popover, _extends({
|
|
128
|
-
theme: theme,
|
|
129
|
-
overrideDisplayName: {
|
|
130
|
-
content: 'ComboboxContent',
|
|
131
|
-
trigger: 'ComboboxTrigger'
|
|
132
|
-
},
|
|
133
|
-
placement: "bottom-start",
|
|
134
|
-
role: "listbox",
|
|
135
|
-
minWidth: minWidth
|
|
136
|
-
}, props)), description && typeof description === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
137
|
-
theme: theme,
|
|
138
|
-
marginTop: "8px",
|
|
139
|
-
variant: "caption",
|
|
140
|
-
color: isInvalid ? 'error' : theme === Theme.light ? 'dark-grey' : 'white'
|
|
141
|
-
}, descriptionProps), description) : /*#__PURE__*/React.isValidElement(description) ? description : null)))));
|
|
142
|
-
};
|
|
143
|
-
BaseCombobox.className = CLASSNAME;
|
|
144
|
-
BaseCombobox.displayName = COMPONENT_NAME;
|
|
145
|
-
const Combobox = Object.assign(BaseCombobox, {
|
|
146
|
-
Trigger: ComboboxTrigger,
|
|
147
|
-
Content: ComboboxContent
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
export { BaseCombobox, Combobox };
|
|
151
|
-
//# sourceMappingURL=Combobox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import React, { RefObject, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport { ComboboxContent } from '../combobox-content';\nimport { ComboboxTrigger } from '../combobox-trigger';\n\nimport { ComboboxProps, ComboboxSelectionMode, ComboboxValue, ComboboxVariant } from './types';\nimport { Popover } from '@redsift/popovers';\nimport { ComboboxContext } from './context';\nimport {\n ListboxReducer,\n ListboxState,\n ListboxContextProps,\n FocusWithinGroup,\n ListboxContext,\n Flexbox,\n Text,\n ListboxActionType,\n Theme,\n useTheme,\n ThemeProvider,\n useId,\n} from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'Combobox';\nconst CLASSNAME = 'redsift-combobox';\n\n/**\n * The Combobox component.\n */\nexport const BaseCombobox: React.FC<ComboboxProps> & {\n displayName?: string;\n className?: string;\n} = (props) => {\n const {\n defaultValue,\n description,\n descriptionProps,\n filter = {\n type: 'startsWith',\n caseSensitive: false,\n },\n formRef,\n submitRef,\n inputValue: propsInputValue,\n isDisabled,\n isInvalid,\n maxOptionsLength,\n minWidth = 'trigger-width',\n onChange,\n onInputChange,\n selectionMode = ComboboxSelectionMode.single,\n theme: propsTheme,\n triggerClassName,\n value,\n variant = ComboboxVariant.options,\n wrapperProps,\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const [selectedValue, setValue] = useState<ComboboxValue>(\n value || defaultValue || (selectionMode === 'multiple' ? [] : '')\n );\n const [inputValue, setInputValue] = useState<string>(propsInputValue || '');\n useEffect(() => {\n if (value) {\n state.setValue(value);\n }\n }, [value]);\n useEffect(() => {\n if (propsInputValue) {\n state.setInputValue(propsInputValue);\n }\n }, [propsInputValue]);\n\n /** Listbox context */\n const [listboxState, listboxDispatch] = useReducer(ListboxReducer, {\n isDisabled,\n selectedValues: selectionMode === ComboboxSelectionMode.multiple ? selectedValue : [selectedValue],\n selectionMode,\n } as ListboxState);\n const listboxContext = useMemo<ListboxContextProps>(\n () => ({\n state: listboxState,\n dispatch: listboxDispatch,\n }),\n [listboxState]\n );\n useEffect(() => {\n listboxDispatch({\n type: ListboxActionType.UPDATE_OPTIONS,\n payload: {\n isDisabled: isDisabled || false,\n },\n });\n }, [isDisabled]);\n\n const freeTextItemRef = useRef<HTMLDivElement>();\n const [freeTextItemId] = useId();\n\n /** Combobox context. */\n const state = {\n filter,\n formRef,\n submitRef,\n value: selectedValue,\n inputValue,\n isDisabled: isDisabled || false,\n isInvalid: isInvalid || false,\n selectionMode,\n variant,\n freeTextItemRef: freeTextItemRef as RefObject<HTMLDivElement>,\n freeTextItemId,\n triggerClassName,\n setValue(value: ComboboxValue) {\n if (isDisabled) {\n return;\n }\n\n const previousValue = selectedValue;\n setValue(value);\n if (value !== previousValue && onChange) {\n onChange(value);\n }\n },\n setInputValue(value: string) {\n if (isDisabled) {\n return;\n }\n\n const previousValue = inputValue;\n setInputValue(value);\n if (value !== previousValue && onInputChange) {\n onInputChange(value);\n }\n },\n };\n\n return (\n <ThemeProvider value={{ theme }}>\n <FocusWithinGroup focusType=\"virtual-focus\" focusOnInit={false} maxOptionsLength={maxOptionsLength}>\n <ComboboxContext.Provider value={state}>\n <ListboxContext.Provider value={listboxContext}>\n <Flexbox flexDirection=\"column\" alignItems=\"flex-start\" gap=\"0px\" {...wrapperProps}>\n <Popover\n theme={theme}\n overrideDisplayName={{ content: 'ComboboxContent', trigger: 'ComboboxTrigger' }}\n placement=\"bottom-start\"\n role=\"listbox\"\n minWidth={minWidth}\n {...props}\n />\n {description && typeof description === 'string' ? (\n <Text\n theme={theme}\n marginTop=\"8px\"\n variant=\"caption\"\n color={isInvalid ? 'error' : theme === Theme.light ? 'dark-grey' : 'white'}\n {...descriptionProps}\n >\n {description}\n </Text>\n ) : React.isValidElement(description) ? (\n description\n ) : null}\n </Flexbox>\n </ListboxContext.Provider>\n </ComboboxContext.Provider>\n </FocusWithinGroup>\n </ThemeProvider>\n );\n};\nBaseCombobox.className = CLASSNAME;\nBaseCombobox.displayName = COMPONENT_NAME;\n\nexport const Combobox = Object.assign(BaseCombobox, {\n Trigger: ComboboxTrigger,\n Content: ComboboxContent,\n});\n"],"names":["COMPONENT_NAME","CLASSNAME","BaseCombobox","props","defaultValue","description","descriptionProps","filter","type","caseSensitive","formRef","submitRef","inputValue","propsInputValue","isDisabled","isInvalid","maxOptionsLength","minWidth","onChange","onInputChange","selectionMode","ComboboxSelectionMode","single","theme","propsTheme","triggerClassName","value","variant","ComboboxVariant","options","wrapperProps","useTheme","selectedValue","setValue","useState","setInputValue","useEffect","state","listboxState","listboxDispatch","useReducer","ListboxReducer","selectedValues","multiple","listboxContext","useMemo","dispatch","ListboxActionType","UPDATE_OPTIONS","payload","freeTextItemRef","useRef","freeTextItemId","useId","previousValue","React","createElement","ThemeProvider","FocusWithinGroup","focusType","focusOnInit","ComboboxContext","Provider","ListboxContext","Flexbox","_extends","flexDirection","alignItems","gap","Popover","overrideDisplayName","content","trigger","placement","role","Text","marginTop","color","Theme","light","isValidElement","className","displayName","Combobox","Object","assign","Trigger","ComboboxTrigger","Content","ComboboxContent"],"mappings":";;;;;;;;;AAsBA,MAAMA,cAAc,GAAG,UAAU,CAAA;AACjC,MAAMC,SAAS,GAAG,kBAAkB,CAAA;;AAEpC;AACA;AACA;AACaC,MAAAA,YAGZ,GAAIC,KAAK,IAAK;EACb,MAAM;IACJC,YAAY;IACZC,WAAW;I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IAAAA,SAAS,EAAC,cAAc;AACxBC,IAAAA,IAAI,EAAC,SAAS;AACdzD,IAAAA,QAAQ,EAAEA,QAAAA;AAAS,GAAA,EACfd,KAAK,CACV,CAAC,EACDE,WAAW,IAAI,OAAOA,WAAW,KAAK,QAAQ,gBAC7CkD,KAAA,CAAAC,aAAA,CAACmB,IAAI,EAAAV,QAAA,CAAA;AACH1C,IAAAA,KAAK,EAAEA,KAAM;AACbqD,IAAAA,SAAS,EAAC,KAAK;AACfjD,IAAAA,OAAO,EAAC,SAAS;AACjBkD,IAAAA,KAAK,EAAE9D,SAAS,GAAG,OAAO,GAAGQ,KAAK,KAAKuD,KAAK,CAACC,KAAK,GAAG,WAAW,GAAG,OAAA;GAC/DzE,EAAAA,gBAAgB,GAEnBD,WACG,CAAC,gBACLkD,KAAK,CAACyB,cAAc,CAAC3E,WAAW,CAAC,GACnCA,WAAW,GACT,IACG,CACc,CACD,CACV,CACL,CAAC,CAAA;AAEpB,EAAC;AACDH,YAAY,CAAC+E,SAAS,GAAGhF,SAAS,CAAA;AAClCC,YAAY,CAACgF,WAAW,GAAGlF,cAAc,CAAA;AAElC,MAAMmF,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACnF,YAAY,EAAE;AAClDoF,EAAAA,OAAO,EAAEC,eAAe;AACxBC,EAAAA,OAAO,EAAEC,eAAAA;AACX,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../src/components/combobox/context.ts"],"sourcesContent":["import React from 'react';\nimport { ComboboxState } from './types';\n\nexport const ComboboxContext = React.createContext<ComboboxState | null>(null);\n"],"names":["ComboboxContext","React","createContext"],"mappings":";;AAGO,MAAMA,eAAe,gBAAGC,KAAK,CAACC,aAAa,CAAuB,IAAI;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var collapse = "Collapse";
|
|
2
|
-
var expand = "Expand";
|
|
3
|
-
var selected = "{count, plural, =0 {None selected} other {# selected}}";
|
|
4
|
-
var unselect = "Unselect {label}";
|
|
5
|
-
var enUS = {
|
|
6
|
-
collapse: collapse,
|
|
7
|
-
expand: expand,
|
|
8
|
-
selected: selected,
|
|
9
|
-
unselect: unselect
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { collapse, enUS as default, expand, selected, unselect };
|
|
13
|
-
//# sourceMappingURL=en-US.json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"en-US.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var collapse = "Réduire";
|
|
2
|
-
var expand = "Développer";
|
|
3
|
-
var selected = "{count, plural, =0 {Aucun sélectionné} =1 {1 sélectionné} other {# sélectionnés}}";
|
|
4
|
-
var unselect = "Déselectionner {label}";
|
|
5
|
-
var frFR = {
|
|
6
|
-
collapse: collapse,
|
|
7
|
-
expand: expand,
|
|
8
|
-
selected: selected,
|
|
9
|
-
unselect: unselect
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { collapse, frFR as default, expand, selected, unselect };
|
|
13
|
-
//# sourceMappingURL=fr-FR.json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fr-FR.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/combobox/intl/index.ts"],"sourcesContent":["import enUS from './en-US.json';\nimport frFR from './fr-FR.json';\n\nexport default {\n 'en-US': enUS,\n 'fr-FR': frFR,\n};\n"],"names":["enUS","frFR"],"mappings":";;;AAGA,mBAAe;AACb,EAAA,OAAO,EAAEA,IAAI;AACb,EAAA,OAAO,EAAEC,IAAAA;AACX,CAAC;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component variant.
|
|
3
|
-
*/
|
|
4
|
-
const ComboboxSelectionMode = {
|
|
5
|
-
single: 'single',
|
|
6
|
-
multiple: 'multiple'
|
|
7
|
-
};
|
|
8
|
-
const ComboboxVariant = {
|
|
9
|
-
options: 'options',
|
|
10
|
-
suggestions: 'suggestions'
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Context props.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Component props.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export { ComboboxSelectionMode, ComboboxVariant };
|
|
22
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/components/combobox/types.ts"],"sourcesContent":["import { FlexboxProps, TextProps, Theme, ValueOf } from '@redsift/design-system';\nimport { PopoverProps } from '@redsift/popovers';\nimport { ReactElement, RefObject } from 'react';\n\n/**\n * Component variant.\n */\nexport const ComboboxSelectionMode = {\n single: 'single',\n multiple: 'multiple',\n} as const;\nexport type ComboboxSelectionMode = ValueOf<typeof ComboboxSelectionMode>;\n\nexport const ComboboxVariant = {\n options: 'options',\n suggestions: 'suggestions',\n} as const;\nexport type ComboboxVariant = ValueOf<typeof ComboboxVariant>;\n\nexport type ComboboxValue = string | string[];\n\n/**\n * Context props.\n */\nexport type ComboboxState = {\n /** Filtering parameters. */\n readonly filter?: {\n type: 'startsWith' | 'contains' | 'endsWith';\n caseSensitive?: boolean;\n };\n /** Whether the combobox is disabled or not. */\n readonly isDisabled: boolean;\n /** Whether the combobox is invalid or not. */\n readonly isInvalid: boolean;\n /** Sets the selected value. */\n setValue(value: ComboboxValue): void;\n /** Current selected value. */\n readonly value: ComboboxValue;\n /** Sets the input value. */\n setInputValue(inputValue: string): void;\n /** Current input value. */\n readonly inputValue: string;\n /** Whether the Combobox allow multiple selection or not. */\n selectionMode?: ComboboxSelectionMode;\n /** If 'options', the input field cannot have free text, the selection has to be made within the options. If 'suggestions', then choosing from the list isn't mandatory and the user can write free text within the input. */\n variant?: ComboboxVariant;\n /** Ref to the first item used to create values. */\n freeTextItemRef?: RefObject<HTMLDivElement>;\n /** Id of the first item used to create values. */\n freeTextItemId?: string;\n /** Class name to append to the trigger. */\n readonly triggerClassName?: string;\n /** Ref to the form, if any. */\n formRef?: RefObject<HTMLFormElement>;\n /** Ref to the submit button, if any. */\n submitRef?: RefObject<HTMLButtonElement>;\n};\n\n/**\n * Component props.\n */\nexport interface ComboboxProps extends PopoverProps {\n /** If 'options', the input field cannot have free text, the selection has to be made within the options. If 'suggestions', then choosing from the list isn't mandatory and the user can write free text within the input. */\n variant?: ComboboxVariant;\n /**\n * Default selected value.\n * Used for uncontrolled version.\n */\n defaultValue?: ComboboxValue;\n /** Description of the combobox. */\n description?: string | ReactElement;\n /** Additional description properties. */\n descriptionProps?: Omit<TextProps, 'ref'>;\n /** Filtering parameters. */\n filter?: {\n type: 'startsWith' | 'contains' | 'endsWith';\n caseSensitive?: boolean;\n };\n /** Ref to the form, if any. */\n formRef?: RefObject<HTMLFormElement>;\n /** Ref to the submit button, if any. */\n submitRef?: RefObject<HTMLButtonElement>;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is invalid or not. */\n isInvalid?: boolean;\n /** Maximum number of options displayed. Useful when too many options are displayed. */\n maxOptionsLength?: number;\n /** Method to handle selection change. */\n onChange?(value: ComboboxValue): void;\n /** Method to handle input change. */\n onInputChange?(value: string): void;\n /**\n * Currently selected value.\n * Used for controlled version.\n */\n value?: ComboboxValue;\n /** Input value. */\n inputValue?: string;\n /** Whether the Combobox allow multiple selection or not. */\n selectionMode?: ComboboxSelectionMode;\n /** Theme. */\n theme?: Theme;\n /** Class name to append to the trigger. */\n triggerClassName?: string;\n /** Props to forward to the wrapper. */\n wrapperProps?: Omit<FlexboxProps, 'ref'>;\n}\n\nexport type StyledComboboxProps = ComboboxProps;\n"],"names":["ComboboxSelectionMode","single","multiple","ComboboxVariant","options","suggestions"],"mappings":"AAIA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAG;AACnCC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,QAAQ,EAAE,UAAA;AACZ,EAAU;AAGH,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,WAAW,EAAE,aAAA;AACf,EAAU;;AAKV;AACA;AACA;;AAmCA;AACA;AACA;;;;"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { forwardRef, useContext } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { getContainerProps, AppContainerContext, FocusWithinGroupContext, ListboxContext, useTheme, partitionComponents, isComponent, Flexbox } from '@redsift/design-system';
|
|
5
|
-
import { usePopoverContext, useMergeRefs, FloatingPortal, StyledPopoverContent, PopoverContent } from '@redsift/popovers';
|
|
6
|
-
import { ComboboxContentListbox } from '../combobox-content-listbox/ComboboxContentListbox.js';
|
|
7
|
-
import { ComboboxContext } from '../combobox/context.js';
|
|
8
|
-
import { ComboboxContentHeader } from '../combobox-content-header/ComboboxContentHeader.js';
|
|
9
|
-
import { ComboboxContentFooter } from '../combobox-content-footer/ComboboxContentFooter.js';
|
|
10
|
-
|
|
11
|
-
const COMPONENT_NAME = 'ComboboxContent';
|
|
12
|
-
const CLASSNAME = 'redsift-combobox-content';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The ComboboxContent component.
|
|
16
|
-
*/
|
|
17
|
-
const BaseComboboxContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
18
|
-
var _comboboxState$inputV;
|
|
19
|
-
const {
|
|
20
|
-
children,
|
|
21
|
-
className,
|
|
22
|
-
style
|
|
23
|
-
} = props;
|
|
24
|
-
const containerProps = getContainerProps(props);
|
|
25
|
-
const {
|
|
26
|
-
getFloatingProps,
|
|
27
|
-
isOpen,
|
|
28
|
-
refs,
|
|
29
|
-
strategy,
|
|
30
|
-
x,
|
|
31
|
-
y
|
|
32
|
-
} = usePopoverContext();
|
|
33
|
-
const popoverRef = useMergeRefs([refs.setFloating, ref]);
|
|
34
|
-
const appContainerState = useContext(AppContainerContext);
|
|
35
|
-
const comboboxState = useContext(ComboboxContext);
|
|
36
|
-
const focusContext = useContext(FocusWithinGroupContext);
|
|
37
|
-
const listboxState = useContext(ListboxContext);
|
|
38
|
-
const theme = useTheme();
|
|
39
|
-
const [[header], [listbox], [footer]] = partitionComponents(React.Children.toArray(children), [isComponent('ComboboxContentHeader'), isComponent('ComboboxContentListbox'), isComponent('ComboboxContentFooter')]);
|
|
40
|
-
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
41
|
-
root: appContainerState === null || appContainerState === void 0 ? void 0 : appContainerState.appContainerRef.current
|
|
42
|
-
}, isOpen && /*#__PURE__*/React.createElement(StyledPopoverContent, _extends({
|
|
43
|
-
$theme: theme,
|
|
44
|
-
ref: popoverRef
|
|
45
|
-
}, getFloatingProps(props), {
|
|
46
|
-
style: _objectSpread2(_objectSpread2({
|
|
47
|
-
position: strategy,
|
|
48
|
-
top: y !== null && y !== void 0 ? y : 0,
|
|
49
|
-
left: x !== null && x !== void 0 ? x : 0
|
|
50
|
-
}, style), comboboxState !== null && comboboxState !== void 0 && (_comboboxState$inputV = comboboxState.inputValue) !== null && _comboboxState$inputV !== void 0 && _comboboxState$inputV.length && focusContext.state.tabStops.length === 0 ? {
|
|
51
|
-
display: 'none'
|
|
52
|
-
} : {}),
|
|
53
|
-
className: classNames(PopoverContent.className, BaseComboboxContent.className, className),
|
|
54
|
-
"aria-disabled": listboxState.state.isDisabled
|
|
55
|
-
}), /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
56
|
-
flexDirection: "column",
|
|
57
|
-
gap: "0px",
|
|
58
|
-
width: "100%"
|
|
59
|
-
}, containerProps), header, listbox, footer)));
|
|
60
|
-
});
|
|
61
|
-
BaseComboboxContent.className = CLASSNAME;
|
|
62
|
-
BaseComboboxContent.displayName = COMPONENT_NAME;
|
|
63
|
-
const ComboboxContent = Object.assign(BaseComboboxContent, {
|
|
64
|
-
Header: ComboboxContentHeader,
|
|
65
|
-
Listbox: ComboboxContentListbox,
|
|
66
|
-
Footer: ComboboxContentFooter
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export { BaseComboboxContent, ComboboxContent };
|
|
70
|
-
//# sourceMappingURL=ComboboxContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxContent.js","sources":["../../../src/components/combobox-content/ComboboxContent.tsx"],"sourcesContent":["import React, { forwardRef, useContext } from 'react';\nimport classNames from 'classnames';\n\nimport {\n AppContainerContext,\n Comp,\n Flexbox,\n FocusWithinGroupContext,\n ListboxContext,\n getContainerProps,\n isComponent,\n partitionComponents,\n useTheme,\n} from '@redsift/design-system';\nimport { ComboboxContentProps } from './types';\nimport {\n FloatingPortal,\n PopoverContent,\n usePopoverContext,\n StyledPopoverContent,\n useMergeRefs,\n} from '@redsift/popovers';\nimport { ComboboxContentHeader } from '../combobox-content-header';\nimport { ComboboxContentFooter } from '../combobox-content-footer';\nimport { ComboboxContentListbox } from '../combobox-content-listbox/ComboboxContentListbox';\nimport { ComboboxContext } from '../combobox/context';\n\nconst COMPONENT_NAME = 'ComboboxContent';\nconst CLASSNAME = 'redsift-combobox-content';\n\n/**\n * The ComboboxContent component.\n */\nexport const BaseComboboxContent: Comp<ComboboxContentProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, style } = props;\n const containerProps = getContainerProps(props);\n\n const { getFloatingProps, isOpen, refs, strategy, x, y } = usePopoverContext();\n const popoverRef = useMergeRefs([refs.setFloating, ref]);\n\n const appContainerState = useContext(AppContainerContext);\n const comboboxState = useContext(ComboboxContext);\n const focusContext = useContext(FocusWithinGroupContext);\n const listboxState = useContext(ListboxContext);\n const theme = useTheme();\n\n const [[header], [listbox], [footer]] = partitionComponents(React.Children.toArray(children), [\n isComponent('ComboboxContentHeader'),\n isComponent('ComboboxContentListbox'),\n isComponent('ComboboxContentFooter'),\n ]);\n\n return (\n <FloatingPortal root={appContainerState?.appContainerRef.current}>\n {isOpen && (\n <StyledPopoverContent\n $theme={theme!}\n ref={popoverRef}\n {...getFloatingProps(props)}\n style={{\n position: strategy,\n top: y ?? 0,\n left: x ?? 0,\n ...style,\n ...(comboboxState?.inputValue?.length && focusContext.state.tabStops.length === 0\n ? { display: 'none' }\n : {}),\n }}\n className={classNames(PopoverContent.className, BaseComboboxContent.className, className)}\n aria-disabled={listboxState.state.isDisabled}\n >\n <Flexbox flexDirection=\"column\" gap=\"0px\" width=\"100%\" {...containerProps}>\n {header}\n {listbox}\n {footer}\n </Flexbox>\n </StyledPopoverContent>\n )}\n </FloatingPortal>\n );\n});\nBaseComboboxContent.className = CLASSNAME;\nBaseComboboxContent.displayName = COMPONENT_NAME;\n\nexport const ComboboxContent = Object.assign(BaseComboboxContent, {\n Header: ComboboxContentHeader,\n Listbox: ComboboxContentListbox,\n Footer: ComboboxContentFooter,\n});\n"],"names":["COMPONENT_NAME","CLASSNAME","BaseComboboxContent","forwardRef","props","ref","_comboboxState$inputV","children","className","style","containerProps","getContainerProps","getFloatingProps","isOpen","refs","strategy","x","y","usePopoverContext","popoverRef","useMergeRefs","setFloating","appContainerState","useContext","AppContainerContext","comboboxState","ComboboxContext","focusContext","FocusWithinGroupContext","listboxState","ListboxContext","theme","useTheme","header","listbox","footer","partitionComponents","React","Children","toArray","isComponent","createElement","FloatingPortal","root","appContainerRef","current","StyledPopoverContent","_extends","$theme","_objectSpread","position","top","left","inputValue","length","state","tabStops","display","classNames","PopoverContent","isDisabled","Flexbox","flexDirection","gap","width","displayName","ComboboxContent","Object","assign","Header","ComboboxContentHeader","Listbox","ComboboxContentListbox","Footer","ComboboxContentFooter"],"mappings":";;;;;;;;;;AA2BA,MAAMA,cAAc,GAAG,iBAAiB,CAAA;AACxC,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,KAAK;AAACC,IAAAA,KAAK,EAAC,MAAA;GAAWtD,EAAAA,cAAc,GACtEuB,MAAM,EACNC,OAAO,EACPC,MACM,CACW,CAEV,CAAC,CAAA;AAErB,CAAC,EAAC;AACFjC,mBAAmB,CAACM,SAAS,GAAGP,SAAS,CAAA;AACzCC,mBAAmB,CAAC+D,WAAW,GAAGjE,cAAc,CAAA;AAEzC,MAAMkE,eAAe,GAAGC,MAAM,CAACC,MAAM,CAAClE,mBAAmB,EAAE;AAChEmE,EAAAA,MAAM,EAAEC,qBAAqB;AAC7BC,EAAAA,OAAO,EAAEC,sBAAsB;AAC/BC,EAAAA,MAAM,EAAEC,qBAAAA;AACV,CAAC;;;;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { StyledComboboxContentFooter } from './styles.js';
|
|
5
|
-
|
|
6
|
-
const _excluded = ["children", "className"];
|
|
7
|
-
const COMPONENT_NAME = 'ComboboxContentFooter';
|
|
8
|
-
const CLASSNAME = 'redsift-combobox-content-footer';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The ComboboxContentFooter component.
|
|
12
|
-
*/
|
|
13
|
-
const ComboboxContentFooter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
-
const {
|
|
15
|
-
children,
|
|
16
|
-
className
|
|
17
|
-
} = props,
|
|
18
|
-
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
-
return /*#__PURE__*/React.createElement(StyledComboboxContentFooter, _extends({}, forwardedProps, {
|
|
20
|
-
className: classNames(ComboboxContentFooter.className, className),
|
|
21
|
-
ref: ref
|
|
22
|
-
}), children);
|
|
23
|
-
});
|
|
24
|
-
ComboboxContentFooter.className = CLASSNAME;
|
|
25
|
-
ComboboxContentFooter.displayName = COMPONENT_NAME;
|
|
26
|
-
|
|
27
|
-
export { ComboboxContentFooter };
|
|
28
|
-
//# sourceMappingURL=ComboboxContentFooter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxContentFooter.js","sources":["../../../src/components/combobox-content-footer/ComboboxContentFooter.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { StyledComboboxContentFooter } from './styles';\nimport { ComboboxContentFooterProps } from './types';\nimport { Comp } from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'ComboboxContentFooter';\nconst CLASSNAME = 'redsift-combobox-content-footer';\n\n/**\n * The ComboboxContentFooter component.\n */\nexport const ComboboxContentFooter: Comp<ComboboxContentFooterProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <StyledComboboxContentFooter\n {...forwardedProps}\n className={classNames(ComboboxContentFooter.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {children}\n </StyledComboboxContentFooter>\n );\n});\nComboboxContentFooter.className = CLASSNAME;\nComboboxContentFooter.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentFooter","forwardRef","props","ref","children","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledComboboxContentFooter","_extends","classNames","displayName"],"mappings":";;;;;;AAOA,MAAMA,cAAc,GAAG,uBAAuB,CAAA;AAC9C,MAAMC,SAAS,GAAG,iCAAiC,CAAA;;AAEnD;AACA;AACA;AACO,MAAMC,qBAAuE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChH,MAAM;MAAEC,QAAQ;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGH,KAAK;AAAxBI,IAAAA,cAAc,GAAAC,wBAAA,CAAKL,KAAK,EAAAM,SAAA,CAAA,CAAA;EAExD,oBACEC,KAAA,CAAAC,aAAA,CAACC,2BAA2B,EAAAC,QAAA,KACtBN,cAAc,EAAA;IAClBD,SAAS,EAAEQ,UAAU,CAACb,qBAAqB,CAACK,SAAS,EAAEA,SAAS,CAAE;AAClEF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErCC,QAC0B,CAAC,CAAA;AAElC,CAAC,EAAC;AACFJ,qBAAqB,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC3CC,qBAAqB,CAACc,WAAW,GAAGhB,cAAc;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { baseContainer } from '@redsift/design-system';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component style.
|
|
6
|
-
*/
|
|
7
|
-
const StyledComboboxContentFooter = styled.div`
|
|
8
|
-
${baseContainer}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export { StyledComboboxContentFooter };
|
|
12
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../src/components/combobox-content-footer/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledComboboxContentFooterProps } from './types';\nimport { baseContainer } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledComboboxContentFooter = styled.div<StyledComboboxContentFooterProps>`\n ${baseContainer}\n`;\n"],"names":["StyledComboboxContentFooter","styled","div","baseContainer"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,2BAA2B,GAAGC,MAAM,CAACC,GAAsC,CAAA;AACxF,EAAA,EAAIC,aAAc,CAAA;AAClB;;;;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { StyledComboboxContentHeader } from './styles.js';
|
|
5
|
-
|
|
6
|
-
const _excluded = ["children", "className"];
|
|
7
|
-
const COMPONENT_NAME = 'ComboboxContentHeader';
|
|
8
|
-
const CLASSNAME = 'redsift-combobox-content-header';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The ComboboxContentHeader component.
|
|
12
|
-
*/
|
|
13
|
-
const ComboboxContentHeader = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
-
const {
|
|
15
|
-
children,
|
|
16
|
-
className
|
|
17
|
-
} = props,
|
|
18
|
-
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
-
return /*#__PURE__*/React.createElement(StyledComboboxContentHeader, _extends({}, forwardedProps, {
|
|
20
|
-
className: classNames(ComboboxContentHeader.className, className),
|
|
21
|
-
ref: ref
|
|
22
|
-
}), children);
|
|
23
|
-
});
|
|
24
|
-
ComboboxContentHeader.className = CLASSNAME;
|
|
25
|
-
ComboboxContentHeader.displayName = COMPONENT_NAME;
|
|
26
|
-
|
|
27
|
-
export { ComboboxContentHeader };
|
|
28
|
-
//# sourceMappingURL=ComboboxContentHeader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxContentHeader.js","sources":["../../../src/components/combobox-content-header/ComboboxContentHeader.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { StyledComboboxContentHeader } from './styles';\nimport { ComboboxContentHeaderProps } from './types';\nimport { Comp } from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'ComboboxContentHeader';\nconst CLASSNAME = 'redsift-combobox-content-header';\n\n/**\n * The ComboboxContentHeader component.\n */\nexport const ComboboxContentHeader: Comp<ComboboxContentHeaderProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <StyledComboboxContentHeader\n {...forwardedProps}\n className={classNames(ComboboxContentHeader.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {children}\n </StyledComboboxContentHeader>\n );\n});\nComboboxContentHeader.className = CLASSNAME;\nComboboxContentHeader.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentHeader","forwardRef","props","ref","children","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledComboboxContentHeader","_extends","classNames","displayName"],"mappings":";;;;;;AAOA,MAAMA,cAAc,GAAG,uBAAuB,CAAA;AAC9C,MAAMC,SAAS,GAAG,iCAAiC,CAAA;;AAEnD;AACA;AACA;AACO,MAAMC,qBAAuE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChH,MAAM;MAAEC,QAAQ;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGH,KAAK;AAAxBI,IAAAA,cAAc,GAAAC,wBAAA,CAAKL,KAAK,EAAAM,SAAA,CAAA,CAAA;EAExD,oBACEC,KAAA,CAAAC,aAAA,CAACC,2BAA2B,EAAAC,QAAA,KACtBN,cAAc,EAAA;IAClBD,SAAS,EAAEQ,UAAU,CAACb,qBAAqB,CAACK,SAAS,EAAEA,SAAS,CAAE;AAClEF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErCC,QAC0B,CAAC,CAAA;AAElC,CAAC,EAAC;AACFJ,qBAAqB,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC3CC,qBAAqB,CAACc,WAAW,GAAGhB,cAAc;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { baseContainer } from '@redsift/design-system';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component style.
|
|
6
|
-
*/
|
|
7
|
-
const StyledComboboxContentHeader = styled.div`
|
|
8
|
-
${baseContainer}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export { StyledComboboxContentHeader };
|
|
12
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../src/components/combobox-content-header/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledComboboxContentHeaderProps } from './types';\nimport { baseContainer } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledComboboxContentHeader = styled.div<StyledComboboxContentHeaderProps>`\n ${baseContainer}\n`;\n"],"names":["StyledComboboxContentHeader","styled","div","baseContainer"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,2BAA2B,GAAGC,MAAM,CAACC,GAAsC,CAAA;AACxF,EAAA,EAAIC,aAAc,CAAA;AAClB;;;;"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { forwardRef, useContext, useEffect } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { FocusWithinGroupContext, ListboxContext, isComponent, Item, useListboxItem, useTheme, Flexbox, StyledItem } from '@redsift/design-system';
|
|
5
|
-
import { ComboboxContext } from '../combobox/context.js';
|
|
6
|
-
import { ComboboxSelectionMode, ComboboxVariant } from '../combobox/types.js';
|
|
7
|
-
|
|
8
|
-
const _excluded = ["children", "className", "renderFreeTextItem"];
|
|
9
|
-
const COMPONENT_NAME = 'ComboboxContentListbox';
|
|
10
|
-
const CLASSNAME = 'redsift-combobox-content-listbox';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The ComboboxContentListbox component.
|
|
14
|
-
*/
|
|
15
|
-
const ComboboxContentListbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
16
|
-
const {
|
|
17
|
-
children,
|
|
18
|
-
className,
|
|
19
|
-
renderFreeTextItem
|
|
20
|
-
} = props,
|
|
21
|
-
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
22
|
-
const focusContext = useContext(FocusWithinGroupContext);
|
|
23
|
-
const listboxState = useContext(ListboxContext);
|
|
24
|
-
const comboboxState = useContext(ComboboxContext);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {
|
|
27
|
-
focusContext.dispatch(focusContext.state.delayedAction);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const canHaveMultipleSelections = (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.selectionMode) === ComboboxSelectionMode.multiple;
|
|
31
|
-
const canHaveFreeText = (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.variant) === ComboboxVariant.suggestions;
|
|
32
|
-
const cloneChildAndPush = (child, array) => {
|
|
33
|
-
if (!canHaveMultipleSelections || !canHaveFreeText || canHaveMultipleSelections && canHaveFreeText && !comboboxState.value.includes(child.props.value)) {
|
|
34
|
-
array.push( /*#__PURE__*/React.cloneElement(child, {
|
|
35
|
-
key: child.props.value,
|
|
36
|
-
hasCheckbox: canHaveMultipleSelections && !canHaveFreeText
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const renderedChildren = [];
|
|
41
|
-
if (Array.isArray(children)) {
|
|
42
|
-
for (const child of children) {
|
|
43
|
-
if (isComponent(Item)(child)) {
|
|
44
|
-
if (focusContext.state.maxOptionsLength) {
|
|
45
|
-
if (renderedChildren.length < focusContext.state.maxOptionsLength) {
|
|
46
|
-
if (!focusContext.state.filter) {
|
|
47
|
-
cloneChildAndPush(child, renderedChildren);
|
|
48
|
-
} else {
|
|
49
|
-
const {
|
|
50
|
-
value: filterValue,
|
|
51
|
-
type,
|
|
52
|
-
caseSensitive
|
|
53
|
-
} = focusContext.state.filter;
|
|
54
|
-
if (!filterValue) {
|
|
55
|
-
cloneChildAndPush(child, renderedChildren);
|
|
56
|
-
} else if (caseSensitive && (type === 'startsWith' && child.props.value.startsWith(filterValue) || type === 'contains' && child.props.value.includes(filterValue) || type === 'endsWith' && child.props.value.endsWith(filterValue))) {
|
|
57
|
-
cloneChildAndPush(child, renderedChildren);
|
|
58
|
-
} else if (!caseSensitive && (type === 'startsWith' && child.props.value.toLowerCase().startsWith(filterValue.toLowerCase()) || type === 'contains' && child.props.value.toLowerCase().includes(filterValue.toLowerCase()) || type === 'endsWith' && child.props.value.toLowerCase().endsWith(filterValue.toLowerCase()))) {
|
|
59
|
-
cloneChildAndPush(child, renderedChildren);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
cloneChildAndPush(child, renderedChildren);
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
renderedChildren.push(child);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const {
|
|
72
|
-
tabIndex,
|
|
73
|
-
isFocused,
|
|
74
|
-
isSelected,
|
|
75
|
-
isDisabled,
|
|
76
|
-
handleKeyDown,
|
|
77
|
-
handleClick
|
|
78
|
-
} = useListboxItem({
|
|
79
|
-
domElementRef: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.freeTextItemRef,
|
|
80
|
-
value: (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue) || '',
|
|
81
|
-
id: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.freeTextItemId
|
|
82
|
-
});
|
|
83
|
-
const theme = useTheme();
|
|
84
|
-
const renderedFreeTextItem = comboboxState !== null && comboboxState !== void 0 && comboboxState.inputValue ? renderFreeTextItem && typeof renderFreeTextItem === 'function' ? renderFreeTextItem(comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue, comboboxState, listboxState) : comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue : null;
|
|
85
|
-
return /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
86
|
-
className: classNames(ComboboxContentListbox.className, className)
|
|
87
|
-
}, forwardedProps, {
|
|
88
|
-
ref: ref,
|
|
89
|
-
flexDirection: "column",
|
|
90
|
-
gap: "0px",
|
|
91
|
-
margin: "8px 0px",
|
|
92
|
-
style: {
|
|
93
|
-
outline: 'none'
|
|
94
|
-
},
|
|
95
|
-
width: "100%"
|
|
96
|
-
}), canHaveMultipleSelections && canHaveFreeText ? /*#__PURE__*/React.createElement(StyledItem, {
|
|
97
|
-
role: "option",
|
|
98
|
-
id: comboboxState.freeTextItemId,
|
|
99
|
-
$color: "primary",
|
|
100
|
-
$isActive: isSelected,
|
|
101
|
-
$isDisabled: isDisabled,
|
|
102
|
-
$isGradient: false,
|
|
103
|
-
$isHovered: isFocused,
|
|
104
|
-
$hasBorder: false,
|
|
105
|
-
$hasCheckbox: false,
|
|
106
|
-
$theme: theme,
|
|
107
|
-
"aria-selected": isSelected,
|
|
108
|
-
className: classNames(Item.className, className),
|
|
109
|
-
onClick: handleClick,
|
|
110
|
-
ref: comboboxState.freeTextItemRef,
|
|
111
|
-
onKeyDown: handleKeyDown,
|
|
112
|
-
tabIndex: tabIndex,
|
|
113
|
-
style: !comboboxState.inputValue ? {
|
|
114
|
-
height: '0',
|
|
115
|
-
visibility: 'hidden',
|
|
116
|
-
padding: '0'
|
|
117
|
-
} : undefined
|
|
118
|
-
}, renderedFreeTextItem) : null, Array.isArray(children) ? renderedChildren : children);
|
|
119
|
-
});
|
|
120
|
-
ComboboxContentListbox.className = CLASSNAME;
|
|
121
|
-
ComboboxContentListbox.displayName = COMPONENT_NAME;
|
|
122
|
-
|
|
123
|
-
export { ComboboxContentListbox };
|
|
124
|
-
//# sourceMappingURL=ComboboxContentListbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxContentListbox.js","sources":["../../../src/components/combobox-content-listbox/ComboboxContentListbox.tsx"],"sourcesContent":["import React, { ReactNode, forwardRef, useContext, useEffect, RefObject, ReactElement } from 'react';\nimport classNames from 'classnames';\n\nimport {\n Comp,\n Flexbox,\n FocusWithinGroupContext,\n Item,\n ListboxContext,\n StyledItem,\n isComponent,\n useListboxItem,\n useTheme,\n} from '@redsift/design-system';\nimport { ComboboxContentListboxProps } from './types';\nimport { ComboboxContext } from '../combobox/context';\nimport { ComboboxSelectionMode, ComboboxVariant } from '../combobox/types';\n\nconst COMPONENT_NAME = 'ComboboxContentListbox';\nconst CLASSNAME = 'redsift-combobox-content-listbox';\n\n/**\n * The ComboboxContentListbox component.\n */\nexport const ComboboxContentListbox: Comp<ComboboxContentListboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, renderFreeTextItem, ...forwardedProps } = props;\n\n const focusContext = useContext(FocusWithinGroupContext);\n const listboxState = useContext(ListboxContext);\n const comboboxState = useContext(ComboboxContext);\n\n useEffect(() => {\n if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {\n focusContext.dispatch(focusContext.state.delayedAction);\n }\n });\n\n const canHaveMultipleSelections = comboboxState?.selectionMode === ComboboxSelectionMode.multiple;\n const canHaveFreeText = comboboxState?.variant === ComboboxVariant.suggestions;\n\n const cloneChildAndPush = (child: ReactElement, array: Array<ReactNode>) => {\n if (\n !canHaveMultipleSelections ||\n !canHaveFreeText ||\n (canHaveMultipleSelections && canHaveFreeText && !(comboboxState.value as string[]).includes(child.props.value))\n ) {\n array.push(\n React.cloneElement(child, {\n key: child.props.value,\n hasCheckbox: canHaveMultipleSelections && !canHaveFreeText,\n })\n );\n }\n };\n const renderedChildren: Array<ReactNode> = [];\n if (Array.isArray(children)) {\n for (const child of children) {\n if (isComponent(Item)(child)) {\n if (focusContext.state.maxOptionsLength) {\n if (renderedChildren.length < focusContext.state.maxOptionsLength) {\n if (!focusContext.state.filter) {\n cloneChildAndPush(child, renderedChildren);\n } else {\n const { value: filterValue, type, caseSensitive } = focusContext.state.filter;\n\n if (!filterValue) {\n cloneChildAndPush(child, renderedChildren);\n } else if (\n caseSensitive &&\n ((type === 'startsWith' && child.props.value!.startsWith(filterValue)) ||\n (type === 'contains' && child.props.value!.includes(filterValue)) ||\n (type === 'endsWith' && child.props.value!.endsWith(filterValue)))\n ) {\n cloneChildAndPush(child, renderedChildren);\n } else if (\n !caseSensitive &&\n ((type === 'startsWith' && child.props.value!.toLowerCase().startsWith(filterValue.toLowerCase())) ||\n (type === 'contains' && child.props.value!.toLowerCase().includes(filterValue.toLowerCase())) ||\n (type === 'endsWith' && child.props.value!.toLowerCase().endsWith(filterValue.toLowerCase())))\n ) {\n cloneChildAndPush(child, renderedChildren);\n }\n }\n }\n } else {\n cloneChildAndPush(child, renderedChildren);\n }\n } else {\n renderedChildren.push(child);\n }\n }\n }\n\n const { tabIndex, isFocused, isSelected, isDisabled, handleKeyDown, handleClick } = useListboxItem({\n domElementRef: comboboxState?.freeTextItemRef as RefObject<Element>,\n value: comboboxState?.inputValue || '',\n id: comboboxState?.freeTextItemId,\n });\n const theme = useTheme();\n\n const renderedFreeTextItem = comboboxState?.inputValue\n ? renderFreeTextItem && typeof renderFreeTextItem === 'function'\n ? renderFreeTextItem(comboboxState?.inputValue, comboboxState, listboxState)\n : comboboxState?.inputValue\n : null;\n\n return (\n <Flexbox\n className={classNames(ComboboxContentListbox.className, className)}\n {...forwardedProps}\n ref={ref}\n flexDirection=\"column\"\n gap=\"0px\"\n margin=\"8px 0px\"\n style={{ outline: 'none' }}\n width=\"100%\"\n >\n {canHaveMultipleSelections && canHaveFreeText ? (\n <StyledItem\n role=\"option\"\n id={comboboxState.freeTextItemId}\n $color=\"primary\"\n $isActive={isSelected}\n $isDisabled={isDisabled}\n $isGradient={false}\n $isHovered={isFocused}\n $hasBorder={false}\n $hasCheckbox={false}\n $theme={theme}\n aria-selected={isSelected}\n className={classNames(Item.className, className)}\n onClick={handleClick}\n ref={comboboxState.freeTextItemRef as RefObject<HTMLDivElement>}\n onKeyDown={handleKeyDown}\n tabIndex={tabIndex}\n style={\n !comboboxState.inputValue\n ? {\n height: '0',\n visibility: 'hidden',\n padding: '0',\n }\n : undefined\n }\n >\n {renderedFreeTextItem}\n </StyledItem>\n ) : null}\n {Array.isArray(children) ? renderedChildren : children}\n </Flexbox>\n );\n});\nComboboxContentListbox.className = CLASSNAME;\nComboboxContentListbox.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentListbox","forwardRef","props","ref","children","className","renderFreeTextItem","forwardedProps","_objectWithoutProperties","_excluded","focusContext","useContext","FocusWithinGroupContext","listboxState","ListboxContext","comboboxState","ComboboxContext","useEffect","state","delayedAction","tabStops","length","dispatch","canHaveMultipleSelections","selectionMode","ComboboxSelectionMode","multiple","canHaveFreeText","variant","ComboboxVariant","suggestions","cloneChildAndPush","child","array","value","includes","push","React","cloneElement","key","hasCheckbox","renderedChildren","Array","isArray","isComponent","Item","maxOptionsLength","filter","filterValue","type","caseSensitive","startsWith","endsWith","toLowerCase","tabIndex","isFocused","isSelected","isDisabled","handleKeyDown","handleClick","useListboxItem","domElementRef","freeTextItemRef","inputValue","id","freeTextItemId","theme","useTheme","renderedFreeTextItem","createElement","Flexbox","_extends","classNames","flexDirection","gap","margin","style","outline","width","StyledItem","role","$color","$isActive","$isDisabled","$isGradient","$isHovered","$hasBorder","$hasCheckbox","$theme","onClick","onKeyDown","height","visibility","padding","undefined","displayName"],"mappings":";;;;;;;;AAkBA,MAAMA,cAAc,GAAG,wBAAwB,CAAA;AAC/C,MAAMC,SAAS,GAAG,kCAAkC,CAAA;;AAEpD;AACA;AACA;AACO,MAAMC,sBAAyE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAClH,MAAM;MAAEC,QAAQ;MAAEC,SAAS;AAAEC,MAAAA,kBAAAA;AAAsC,KAAC,GAAGJ,KAAK;AAAxBK,IAAAA,cAAc,GAAAC,wBAAA,CAAKN,KAAK,EAAAO,SAAA,CAAA,CAAA;AAE5E,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACC,uBAAuB,CAAC,CAAA;AACxD,EAAA,MAAMC,YAAY,GAAGF,UAAU,CAACG,cAAc,CAAC,CAAA;AAC/C,EAAA,MAAMC,aAAa,GAAGJ,UAAU,CAACK,eAAe,CAAC,CAAA;AAEjDC,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIP,YAA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