@ringcentral/juno 2.13.1 → 2.16.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/components/Downshift/Downshift.d.ts +47 -3
- package/components/Downshift/Downshift.js +50 -13
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +19 -1
- package/components/Downshift/SuggestionList/SuggestionList.js +44 -29
- package/components/Downshift/styles/StyledPopper.d.ts +12 -7
- package/components/Downshift/styles/StyledPopper.js +6 -6
- package/components/Downshift/utils/useDownshift.d.ts +1 -0
- package/components/Downshift/utils/useDownshift.js +3 -0
- package/components/Forms/Select/Select.js +2 -2
- package/components/List/ListItem/ListItem.d.ts +3 -1
- package/components/List/ListItem/ListItem.js +3 -2
- package/components/List/ListItem/styles/ListItemStyle.d.ts +5 -0
- package/components/List/ListItem/styles/ListItemStyle.js +17 -5
- package/components/List/ListItem/utils/ListItemUtils.d.ts +2 -0
- package/components/List/ListItem/utils/ListItemUtils.js +5 -4
- package/components/Menu/MenuItem/MenuItem.d.ts +7 -6
- package/components/Menu/MenuItem/MenuItem.js +14 -4
- package/components/Menu/MenuItem/styles/MenuItemStyle.js +6 -3
- package/components/Menu/MenuItem/utils/MenuItemUtils.d.ts +4 -1
- package/components/Menu/MenuItem/utils/MenuItemUtils.js +4 -1
- package/components/Menu/MenuOption/styles/StyledMenuOption.d.ts +1 -1
- package/components/Menu/SubMenu/SubMenu.d.ts +1 -1
- package/components/Menu/SubMenu/utils/SubMenuUtils.d.ts +1 -1
- package/components/TablePagination/styles/TablePaginationStyle.d.ts +4 -4
- package/es6/components/Downshift/Downshift.js +51 -14
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +44 -29
- package/es6/components/Downshift/styles/StyledPopper.js +6 -6
- package/es6/components/Downshift/utils/useDownshift.js +3 -0
- package/es6/components/Forms/Select/Select.js +2 -2
- package/es6/components/List/ListItem/ListItem.js +3 -2
- package/es6/components/List/ListItem/styles/ListItemStyle.js +19 -7
- package/es6/components/List/ListItem/utils/ListItemUtils.js +4 -3
- package/es6/components/Menu/MenuItem/MenuItem.js +16 -6
- package/es6/components/Menu/MenuItem/styles/MenuItemStyle.js +10 -7
- package/es6/components/Menu/MenuItem/utils/MenuItemUtils.js +4 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, ComponentType } from 'react';
|
|
2
2
|
import { CustomStyledComponentResult, RcBaseProps, RcClassesProps } from '../../foundation';
|
|
3
3
|
import { RcIconButtonProps } from '../Buttons/IconButton';
|
|
4
4
|
import { RcTextFieldProps } from '../Forms/TextField';
|
|
@@ -7,11 +7,14 @@ import { WithTooltipProps } from '../Tooltip';
|
|
|
7
7
|
import { RcDownshiftInput } from './styles';
|
|
8
8
|
import { RcSuggestionListProps } from './SuggestionList';
|
|
9
9
|
import { RcDownshiftDefaultFilterOptions, RcDownshiftFilterOptions, RcDownshiftGroupedOption, RcDownshiftSelectedItem, RcDownshiftSelectedItemAdditionProps } from './utils';
|
|
10
|
+
import { TransitionProps as MuiTransitionProps } from '@material-ui/core/transitions';
|
|
10
11
|
export interface RcDownshiftRenderOptionState {
|
|
11
12
|
/** current input value */
|
|
12
13
|
inputValue?: string;
|
|
13
14
|
/** is that item selected */
|
|
14
15
|
selected: boolean;
|
|
16
|
+
/** is that item be show highlighted style */
|
|
17
|
+
highlighted?: boolean;
|
|
15
18
|
/** that item index */
|
|
16
19
|
index: number;
|
|
17
20
|
/** sort index in option own group */
|
|
@@ -177,12 +180,53 @@ declare type RcDownshiftProps<T extends RcDownshiftSelectedItem = RcDownshiftSel
|
|
|
177
180
|
* a different option or changes the character string in the input.
|
|
178
181
|
*/
|
|
179
182
|
autoSelect?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* custom PopperComponent for render
|
|
185
|
+
*
|
|
186
|
+
* @default RcPopper
|
|
187
|
+
*/
|
|
188
|
+
PopperComponent?: ComponentType<RcPopperProps>;
|
|
180
189
|
/** props for apply on `RcPopper` */
|
|
181
|
-
PopperProps?: RcBaseProps<RcPopperProps
|
|
190
|
+
PopperProps?: RcBaseProps<Partial<RcPopperProps>, 'open' | 'keepMounted' | 'anchorEl' | 'style'> & {
|
|
191
|
+
/**
|
|
192
|
+
* typeof that popper `anchorEl` binding when menu open
|
|
193
|
+
*
|
|
194
|
+
* - `root`: on that whole TextField
|
|
195
|
+
* - `input`: on that inside input
|
|
196
|
+
* @default 'root'
|
|
197
|
+
*/
|
|
198
|
+
anchorElType?: 'root' | 'input';
|
|
199
|
+
/**
|
|
200
|
+
* The component used for the transition.
|
|
201
|
+
*
|
|
202
|
+
* default will base on `SuggestionListProps.virtualize`
|
|
203
|
+
* @default virtualize ? `RcFade` : `RcGrow`
|
|
204
|
+
*/
|
|
205
|
+
TransitionComponent?: React.JSXElementConstructor<MuiTransitionProps & {
|
|
206
|
+
children: React.ReactElement<any, any>;
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Set to 'auto' to automatically calculate transition time based on height.
|
|
210
|
+
* @default 'auto'
|
|
211
|
+
*/
|
|
212
|
+
transitionDuration?: MuiTransitionProps['timeout'] | 'auto';
|
|
213
|
+
/**
|
|
214
|
+
* Props applied to the transition element.
|
|
215
|
+
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
|
|
216
|
+
* @default {}
|
|
217
|
+
*/
|
|
218
|
+
TransitionProps?: MuiTransitionProps;
|
|
219
|
+
};
|
|
182
220
|
/** is have ToggleButton */
|
|
183
221
|
toggleButton?: boolean;
|
|
184
222
|
/** Props for apply on ToggleButton */
|
|
185
|
-
ToggleButtonProps?:
|
|
223
|
+
ToggleButtonProps?: RcIconButtonProps & WithTooltipProps;
|
|
224
|
+
/**
|
|
225
|
+
* get custom `ToggleButtonProps` with menu open state.
|
|
226
|
+
*
|
|
227
|
+
* that can be use when you need custom toggle button icon, that will override props you pass inside `ToggleButtonProps`
|
|
228
|
+
*/
|
|
229
|
+
getToggleButtonProps?: (isOpen: boolean) => RcDownshiftProps<T>['ToggleButtonProps'];
|
|
186
230
|
/**
|
|
187
231
|
* A ref for imperative actions.
|
|
188
232
|
*
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
var juno_icon_1 = require("@ringcentral/juno-icon");
|
|
6
|
+
var Fade_1 = require("../Transitions/Fade");
|
|
7
|
+
var Grow_1 = require("../Transitions/Grow");
|
|
6
8
|
var foundation_1 = require("../../foundation");
|
|
7
9
|
var Chip_1 = require("../Chip");
|
|
8
10
|
var ClearIconButton_1 = require("../Forms/TextField/styles/ClearIconButton");
|
|
@@ -12,6 +14,10 @@ exports.RcDownshiftInput = styles_1.RcDownshiftInput;
|
|
|
12
14
|
var SuggestionList_1 = require("./SuggestionList");
|
|
13
15
|
var utils_1 = require("./utils");
|
|
14
16
|
exports.RcDownshiftDefaultFilterOptions = utils_1.RcDownshiftDefaultFilterOptions;
|
|
17
|
+
/**
|
|
18
|
+
* default transition style for grow when not virtualize
|
|
19
|
+
*/
|
|
20
|
+
var DEFAULT_GROW_STYLE = { style: { transformOrigin: '0 0 0' } };
|
|
15
21
|
var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
16
22
|
var props = foundation_1.useThemeProps({ props: inProps, name: 'RcDownshift' });
|
|
17
23
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -125,21 +131,27 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
125
131
|
]);
|
|
126
132
|
}
|
|
127
133
|
var theme = foundation_1.useTheme();
|
|
128
|
-
var _a = props.itemToString, itemToString = _a === void 0 ? utils_1.DEFAULT_GET_OPTION_LABEL : _a, _b = props.keyToChips, keyToChips = _b === void 0 ? utils_1.DEFAULT_KEY_TO_CHIPS : _b, _c = props.limitOfFreeChips, limitOfFreeChips = _c === void 0 ? utils_1.DEFAULT_LIMIT_CHIPS : _c, minRowHeight = props.minRowHeight, suggestionItems = props.suggestionItems, messageRef = props.messageRef, MenuItem = props.MenuItem, inputLabel = props.inputLabel, nameError = props.nameError, maxLength = props.maxLength, InputItem = props.InputItem, emailError = props.emailError, autoSwitchEmail = props.autoSwitchEmail, enableFreeChips = props.enableFreeChips, inputPlaceholder = props.inputPlaceholder, errorSelectedItems = props.errorSelectedItems, enableAutoTransform = props.enableAutoTransform, allowPlainHelperText = props.allowPlainHelperText, TextFieldProps = props.TextFieldProps, selectedItemsProp = props.selectedItems, automationId = props.automationId, screenReader = props.screenReader, onSelectChange = props.onSelectChange, variant = props.variant, groupExpanded = props.groupExpanded, groupDefaultExpanded = props.groupDefaultExpanded, _d = props.groupVariant, groupVariant = _d === void 0 ? 'normal' : _d, getExpandIconProps = props.getExpandIconProps, groupBy = props.groupBy, _e = props.value, valueProp = _e === void 0 ? selectedItemsProp : _e, _f = props.autoHighlight, autoHighlight = _f === void 0 ? true : _f, _g = props.fullWidth, fullWidth = _g === void 0 ? true : _g, _h = props.clearBtn, clearBtn = _h === void 0 ? false : _h, _j = props.toggleButton, toggleButton = _j === void 0 ? false : _j, _k = props.multiple, multiple = _k === void 0 ? false : _k, clearButtonProps = props.clearButtonProps, onClear = props.onClear, ToggleButtonProps = props.ToggleButtonProps,
|
|
129
|
-
|
|
134
|
+
var _a = props.itemToString, itemToString = _a === void 0 ? utils_1.DEFAULT_GET_OPTION_LABEL : _a, _b = props.keyToChips, keyToChips = _b === void 0 ? utils_1.DEFAULT_KEY_TO_CHIPS : _b, _c = props.limitOfFreeChips, limitOfFreeChips = _c === void 0 ? utils_1.DEFAULT_LIMIT_CHIPS : _c, minRowHeight = props.minRowHeight, suggestionItems = props.suggestionItems, messageRef = props.messageRef, MenuItem = props.MenuItem, inputLabel = props.inputLabel, nameError = props.nameError, maxLength = props.maxLength, InputItem = props.InputItem, emailError = props.emailError, autoSwitchEmail = props.autoSwitchEmail, enableFreeChips = props.enableFreeChips, inputPlaceholder = props.inputPlaceholder, errorSelectedItems = props.errorSelectedItems, enableAutoTransform = props.enableAutoTransform, allowPlainHelperText = props.allowPlainHelperText, TextFieldProps = props.TextFieldProps, selectedItemsProp = props.selectedItems, automationId = props.automationId, screenReader = props.screenReader, onSelectChange = props.onSelectChange, variant = props.variant, groupExpanded = props.groupExpanded, groupDefaultExpanded = props.groupDefaultExpanded, _d = props.groupVariant, groupVariant = _d === void 0 ? 'normal' : _d, getExpandIconProps = props.getExpandIconProps, groupBy = props.groupBy, _e = props.value, valueProp = _e === void 0 ? selectedItemsProp : _e, _f = props.autoHighlight, autoHighlight = _f === void 0 ? true : _f, _g = props.fullWidth, fullWidth = _g === void 0 ? true : _g, _h = props.clearBtn, clearBtn = _h === void 0 ? false : _h, _j = props.toggleButton, toggleButton = _j === void 0 ? false : _j, _k = props.multiple, multiple = _k === void 0 ? false : _k, clearButtonProps = props.clearButtonProps, onClear = props.onClear, ToggleButtonProps = props.ToggleButtonProps, _l = props.getToggleButtonProps, getToggleButtonPropsProp = _l === void 0 ? function (isOpen) {
|
|
135
|
+
return {
|
|
136
|
+
symbol: isOpen ? juno_icon_1.ArrowUp : juno_icon_1.ArrowDown,
|
|
137
|
+
};
|
|
138
|
+
} : _l, inputValueProp = props.inputValue, onKeyDownProp = props.onKeyDown, helperTextProp = props.helperText, options = props.options, openOnFocus = props.openOnFocus, _m = props.getOptionLabel, getOptionLabel = _m === void 0 ? itemToString : _m, renderInput = props.renderInput, _o = props.label, label = _o === void 0 ? inputLabel : _o, _p = props.inputRef, inputRefProp = _p === void 0 ? messageRef : _p, _q = props.error, error = _q === void 0 ? nameError : _q, _r = props.placeholder, placeholder = _r === void 0 ? inputPlaceholder : _r, _s = props.freeSolo, freeSolo = _s === void 0 ? enableFreeChips : _s, _t = props.keyToTags, keyToTags = _t === void 0 ? keyToChips : _t, _u = props.maxFreeSolo, maxFreeSolo = _u === void 0 ? limitOfFreeChips : _u, _v = props.SuggestionListProps, _w = _v === void 0 ? {} : _v, _x = _w.virtualize, virtualize = _x === void 0 ? true : _x, SuggestionListProps = tslib_1.__rest(_w, ["virtualize"]), _y = props.autoSelect, autoSelect = _y === void 0 ? enableAutoTransform : _y, PopperComponent = props.PopperComponent, _z = props.PopperProps, _0 = _z === void 0 ? {} : _z, _1 = _0.anchorElType, anchorElType = _1 === void 0 ? 'root' : _1, popperTransition = _0.transition, _2 = _0.TransitionComponent, TransitionComponent = _2 === void 0 ? virtualize ? Fade_1.RcFade : Grow_1.RcGrow : _2, _3 = _0.transitionDuration, transitionDurationProp = _3 === void 0 ? 'auto' : _3, _4 = _0.TransitionProps, TransitionPropsProp = _4 === void 0 ? {} : _4, PopperProps = tslib_1.__rest(_0, ["anchorElType", "transition", "TransitionComponent", "transitionDuration", "TransitionProps"]), initialIsOpen = props.initialIsOpen, disabled = props.disabled, requiredProp = props.required, _5 = props.defaultIsOpen, defaultIsOpen = _5 === void 0 ? openOnFocus : _5, _6 = props.disableCloseOnSelect, disableCloseOnSelect = _6 === void 0 ? defaultIsOpen : _6, _7 = props.onChange, onChangeProp = _7 === void 0 ? onSelectChange : _7, onInputChangeProp = props.onInputChange, onMaxFreeSolo = props.onMaxFreeSolo, FormHelperTextPropsProp = props.FormHelperTextProps, action = props.action, filterOptions = props.filterOptions, renderOption = props.renderOption, renderTags = props.renderTags, getOptionDisabled = props.getOptionDisabled, renderGroup = props.renderGroup, onGroupExpanded = props.onGroupExpanded, renderNoOptions = props.renderNoOptions, InputPropsProp = props.InputProps, debug = props.debug, disabledItemsHighlightable = props.disabledItemsHighlightable, openProp = props.open, onOpen = props.onOpen, onClose = props.onClose, focused = props.focused, color = props.color, rest = tslib_1.__rest(props, ["itemToString", "keyToChips", "limitOfFreeChips", "minRowHeight", "suggestionItems", "messageRef", "MenuItem", "inputLabel", "nameError", "maxLength", "InputItem", "emailError", "autoSwitchEmail", "enableFreeChips", "inputPlaceholder", "errorSelectedItems", "enableAutoTransform", "allowPlainHelperText", "TextFieldProps", "selectedItems", "automationId", "screenReader", "onSelectChange", "variant", "groupExpanded", "groupDefaultExpanded", "groupVariant", "getExpandIconProps", "groupBy", "value", "autoHighlight", "fullWidth", "clearBtn", "toggleButton", "multiple", "clearButtonProps", "onClear", "ToggleButtonProps", "getToggleButtonProps", "inputValue", "onKeyDown", "helperText", "options", "openOnFocus", "getOptionLabel", "renderInput", "label", "inputRef", "error", "placeholder", "freeSolo", "keyToTags", "maxFreeSolo", "SuggestionListProps", "autoSelect", "PopperComponent", "PopperProps", "initialIsOpen", "disabled", "required", "defaultIsOpen", "disableCloseOnSelect", "onChange", "onInputChange", "onMaxFreeSolo", "FormHelperTextProps", "action", "filterOptions", "renderOption", "renderTags", "getOptionDisabled", "renderGroup", "onGroupExpanded", "renderNoOptions", "InputProps", "debug", "disabledItemsHighlightable", "open", "onOpen", "onClose", "focused", "color"]);
|
|
139
|
+
var _8 = tslib_1.__read(react_1.useState('bottom-start'), 2), position = _8[0], setPosition = _8[1];
|
|
130
140
|
var innerInputRef = react_1.useRef(null);
|
|
131
141
|
var textFieldRef = react_1.useRef(null);
|
|
132
142
|
var inputRef = foundation_1.useForkRef(inputRefProp, innerInputRef);
|
|
133
143
|
var inputContainerRef = react_1.useRef(null);
|
|
134
144
|
// * if that have pass old suggestionItems mean that use old logic
|
|
135
145
|
var isNew = !suggestionItems;
|
|
146
|
+
var transitionDuration = transitionDurationProp === 'auto' ? undefined : transitionDurationProp;
|
|
147
|
+
var anchorElRef = anchorElType === 'input' ? inputContainerRef : textFieldRef;
|
|
136
148
|
var oneOfTagError = false;
|
|
137
149
|
if (process.env.NODE_ENV !== 'production') {
|
|
138
150
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
139
151
|
utils_1.useDownshiftError({ isNew: isNew, MenuItem: MenuItem, InputItem: InputItem });
|
|
140
152
|
}
|
|
141
153
|
var required = requiredProp || (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.required);
|
|
142
|
-
var
|
|
154
|
+
var _9 = utils_1.useDownshift({
|
|
143
155
|
focused: focused,
|
|
144
156
|
open: openProp,
|
|
145
157
|
variant: variant,
|
|
@@ -178,9 +190,9 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
178
190
|
onKeyDown: onKeyDownProp,
|
|
179
191
|
disabledItemsHighlightable: disabledItemsHighlightable,
|
|
180
192
|
onGroupExpanded: onGroupExpanded,
|
|
181
|
-
}), focusInput =
|
|
193
|
+
}), focusInput = _9.focusInput, optionItems = _9.optionItems, optionsGroupList = _9.optionsGroupList, selectedItems = _9.tags, highlightedIndex = _9.highlightedIndex, getToggleButtonProps = _9.getToggleButtonProps, getTagProps = _9.getTagProps, getTagListBoxProps = _9.getTagListBoxProps, getMenuProps = _9.getMenuProps, getPopperProps = _9.getPopperProps, getInputProps = _9.getInputProps, getInputAriaProps = _9.getInputAriaProps, getLabelProps = _9.getLabelProps, getItemProps = _9.getItemProps, isOpen = _9.isOpen, inputValue = _9.inputValue, activeIndex = _9.activeIndex, setActiveIndex = _9.setActiveIndex, setHighlightedIndex = _9.setHighlightedIndex, onInputChange = _9.onInputChange, keepHighlightedIndex = _9.keepHighlightedIndex, changeHighlightedIndexReason = _9.changeHighlightedIndexReason, closeMenu = _9.closeMenu, openMenu = _9.openMenu, reset = _9.reset, getClearButtonProps = _9.getClearButtonProps, noOptionItem = _9.noOptionItem, getNoOptionsProps = _9.getNoOptionsProps, isKeepHighlightedIndex = _9.isKeepHighlightedIndex, isDownshiftFocused = _9.focused, autoCompleteSelectedIndex = _9.autoCompleteSelectedIndex;
|
|
182
194
|
var open = Boolean((isOpen || noOptionItem) && textFieldRef.current);
|
|
183
|
-
var
|
|
195
|
+
var _10 = getInputProps(), onBlur = _10.onBlur, InputProps = tslib_1.__rest(_10, ["onBlur"]);
|
|
184
196
|
var helperText = isNew
|
|
185
197
|
? helperTextProp
|
|
186
198
|
: nameError || allowPlainHelperText
|
|
@@ -205,8 +217,9 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
205
217
|
}
|
|
206
218
|
var toTextFieldRef = foundation_1.useForkRef(textFieldRef, ref);
|
|
207
219
|
var colorHex = react_1.useMemo(function () { return (color ? foundation_1.getParsePaletteColor(color)({ theme: theme }) : undefined); }, [color, theme]);
|
|
220
|
+
var isAutocomplete = variant === 'autocomplete';
|
|
208
221
|
var startAdornment = (function () {
|
|
209
|
-
if (
|
|
222
|
+
if (isAutocomplete) {
|
|
210
223
|
return undefined;
|
|
211
224
|
}
|
|
212
225
|
var getCustomizedTagProps = function (selectedItem, index) {
|
|
@@ -246,15 +259,15 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
246
259
|
? color || 'interactive.f01'
|
|
247
260
|
: error
|
|
248
261
|
? 'danger.f02'
|
|
249
|
-
: 'neutral.f04', size: "large",
|
|
250
|
-
var
|
|
262
|
+
: 'neutral.f04', size: "large" }, getToggleButtonProps(tslib_1.__assign(tslib_1.__assign({}, ToggleButtonProps), getToggleButtonPropsProp(isOpen))))))));
|
|
263
|
+
var _11 = (function () {
|
|
251
264
|
var _a = InputPropsProp || {}, classes = _a.classes, restInputPropsProp = tslib_1.__rest(_a, ["classes"]);
|
|
252
265
|
var toClasses = foundation_1.combineClasses(classes, utils_1.RcDownshiftInputClasses);
|
|
253
266
|
return {
|
|
254
267
|
containerClassName: toClasses.container,
|
|
255
268
|
TextFieldInputProps: foundation_1.combineProps(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ classes: foundation_1.omit(toClasses, ['container']), endAdornment: endAdornment, inputComponent: styles_1.RcDownshiftInput }, getTagListBoxProps()), InputProps), { onBlur: debug ? undefined : onBlur }), restInputPropsProp),
|
|
256
269
|
};
|
|
257
|
-
})(), containerClassName =
|
|
270
|
+
})(), containerClassName = _11.containerClassName, TextFieldInputProps = _11.TextFieldInputProps;
|
|
258
271
|
react_1.useImperativeHandle(action, function () { return ({
|
|
259
272
|
getActiveIndex: function () { return activeIndex; },
|
|
260
273
|
setActiveIndex: setActiveIndex,
|
|
@@ -277,6 +290,12 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
277
290
|
var _a;
|
|
278
291
|
(_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
|
279
292
|
});
|
|
293
|
+
var menuChildren = (
|
|
294
|
+
// * that root element for animation host
|
|
295
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
296
|
+
isOpen && (react_1.default.createElement(SuggestionList_1.RcSuggestionList, tslib_1.__assign({ selectedIndex: isAutocomplete ? autoCompleteSelectedIndex : undefined, highlightedIndex: highlightedIndex, optionsGroupList: optionsGroupList, options: optionItems, groupVariant: groupVariant, groupExpanded: groupExpanded, renderGroup: renderGroup, MenuItem: MenuItem, renderOption: renderOption, inputValue: inputValue, getItemProps: getItemProps, getMenuProps: getMenuProps, changeHighlightedIndexReason: changeHighlightedIndexReason, getOptionDisabled: getOptionDisabled, isKeepHighlightedIndex: isKeepHighlightedIndex, onUpdatePopper: handleUpdatePopper, maxContainerHeight: 180, getOptionLabel: getOptionLabel, position: "unset", virtualize: virtualize }, SuggestionListProps))),
|
|
297
|
+
isRenderNoOptions && (renderNoOptions === null || renderNoOptions === void 0 ? void 0 : renderNoOptions(getNoOptionsProps, noOptionItem))));
|
|
298
|
+
var prevMenuChildren = foundation_1.usePrevious(function () { return menuChildren; });
|
|
280
299
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
281
300
|
react_1.default.createElement(styles_1.StyledTextField, tslib_1.__assign({ renderInput: renderInput, hasTags: hasTags, ref: toTextFieldRef, inputRef: inputRef, "data-test-automation-id": automationId, fullWidth: fullWidth, placeholder: !hasTags ? placeholder : undefined, label: label, focused: isDownshiftFocused, disabled: disabled, required: required, color: color,
|
|
282
301
|
// * if below one of tag is error, that main downshift default will be error
|
|
@@ -287,7 +306,7 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
287
306
|
maxLength: maxLength, containerRef: inputContainerRef }, getInputAriaProps(TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.inputProps)),
|
|
288
307
|
}, rest), { value: inputValue, clearBtn: false })),
|
|
289
308
|
!helperText && screenReaderText && (react_1.default.createElement(VisuallyHidden_1.RcVisuallyHidden, { id: describedbyId }, screenReaderText)),
|
|
290
|
-
react_1.default.createElement(styles_1.StyledPopper, tslib_1.__assign({ open: open, position: position, anchorEl:
|
|
309
|
+
react_1.default.createElement(styles_1.StyledPopper, tslib_1.__assign({ open: open, position: position, component: PopperComponent, placement: "bottom-start", anchorEl: anchorElRef.current, "data-test-automation-id": "suggestions-list", popperRef: popperRef,
|
|
291
310
|
// * view type in popper.js
|
|
292
311
|
popperOptions: {
|
|
293
312
|
onUpdate: function (e) {
|
|
@@ -296,9 +315,27 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
296
315
|
setPosition(currPosition);
|
|
297
316
|
}
|
|
298
317
|
},
|
|
299
|
-
} }, getPopperProps(PopperProps)),
|
|
300
|
-
|
|
301
|
-
|
|
318
|
+
} }, getPopperProps(PopperProps), { transition: popperTransition }), popperTransition
|
|
319
|
+
? function (_a) {
|
|
320
|
+
if (_a === void 0) { _a = {}; }
|
|
321
|
+
var _b = _a.TransitionProps, _c = _b === void 0 ? {} : _b, onEnterProp = _c.onEnter, onExitProp = _c.onExited, inProp = _c.in, restTransitionProp = tslib_1.__rest(_a, ["TransitionProps"]);
|
|
322
|
+
var onEnter = function (node, isAppearing) {
|
|
323
|
+
var _a;
|
|
324
|
+
onEnterProp();
|
|
325
|
+
(_a = TransitionPropsProp.onEnter) === null || _a === void 0 ? void 0 : _a.call(TransitionPropsProp, node, isAppearing);
|
|
326
|
+
};
|
|
327
|
+
var onExited = function (node) {
|
|
328
|
+
var _a;
|
|
329
|
+
onExitProp();
|
|
330
|
+
(_a = TransitionPropsProp.onExited) === null || _a === void 0 ? void 0 : _a.call(TransitionPropsProp, node);
|
|
331
|
+
};
|
|
332
|
+
return (react_1.default.createElement(TransitionComponent, tslib_1.__assign({ in: inProp, onEnter: onEnter, onExited: onExited }, restTransitionProp, { timeout: transitionDuration }, (virtualize ? {} : DEFAULT_GROW_STYLE), TransitionPropsProp),
|
|
333
|
+
react_1.default.createElement("div", null,
|
|
334
|
+
// when menu be close use previous option menu,
|
|
335
|
+
// keep menu item before animation done
|
|
336
|
+
inProp ? menuChildren : prevMenuChildren)));
|
|
337
|
+
}
|
|
338
|
+
: menuChildren)));
|
|
302
339
|
}));
|
|
303
340
|
var RcDownshift = foundation_1.styled(_RcDownshift)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.DownshiftStyle);
|
|
304
341
|
RcDownshift.defaultProps = {};
|
|
@@ -16,6 +16,8 @@ export declare type RcSuggestionListProps<T> = RcBaseProps<Partial<VirtuosoProps
|
|
|
16
16
|
* @default false
|
|
17
17
|
*/
|
|
18
18
|
padding?: boolean | number;
|
|
19
|
+
/** is that menu virtualize */
|
|
20
|
+
virtualize?: boolean;
|
|
19
21
|
} & RcClassesProps<'root' | 'toggle' | 'expanded' | 'groupTitle'>;
|
|
20
22
|
export declare type InnerSuggestionListProps = {
|
|
21
23
|
/** current highlightedIndex */
|
|
@@ -40,6 +42,10 @@ export declare type InnerSuggestionListProps = {
|
|
|
40
42
|
* set that as `unset`, let outside `absolute` container to calculate that.
|
|
41
43
|
*/
|
|
42
44
|
position?: 'absolute' | 'unset';
|
|
45
|
+
/**
|
|
46
|
+
* in autocomplete mode, that will have selected index, show selected when focused
|
|
47
|
+
*/
|
|
48
|
+
selectedIndex?: number;
|
|
43
49
|
} & Pick<RcDownshiftProps, 'inputValue' | 'MenuItem' | 'renderOption' | 'getOptionDisabled' | 'renderGroup' | 'groupExpanded' | 'groupVariant' | 'getOptionLabel'> & RcSuggestionListProps<any>;
|
|
44
50
|
export declare const RcSuggestionList: import("styled-components").StyledComponentClass<{
|
|
45
51
|
/** current highlightedIndex */
|
|
@@ -64,6 +70,10 @@ export declare const RcSuggestionList: import("styled-components").StyledCompone
|
|
|
64
70
|
* set that as `unset`, let outside `absolute` container to calculate that.
|
|
65
71
|
*/
|
|
66
72
|
position?: "absolute" | "unset" | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* in autocomplete mode, that will have selected index, show selected when focused
|
|
75
|
+
*/
|
|
76
|
+
selectedIndex?: number | undefined;
|
|
67
77
|
} & Pick<RcDownshiftProps<RcDownshiftSelectedItem>, "getOptionDisabled" | "getOptionLabel" | "renderOption" | "groupVariant" | "groupExpanded" | "renderGroup" | "MenuItem" | "inputValue"> & Pick<Partial<VirtuosoProps<any, undefined>>, "key" | "form" | "list" | "className" | "color" | "height" | "id" | "lang" | "max" | "media" | "method" | "min" | "name" | "style" | "target" | "type" | "width" | "role" | "tabIndex" | "crossOrigin" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "step" | "cite" | "label" | "slot" | "span" | "summary" | "title" | "pattern" | "download" | "start" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "value" | "shape" | "disabled" | "hrefLang" | "rel" | "default" | "action" | "content" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "open" | "selected" | "src" | "checked" | "readOnly" | "required" | "autoComplete" | "rows" | "accept" | "acceptCharset" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "dateTime" | "defer" | "encType" | "frameBorder" | "headers" | "high" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "maxLength" | "mediaGroup" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "optimum" | "playsInline" | "poster" | "preload" | "reversed" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "useMap" | "wmode" | "wrap" | "context" | "overscan" | "increaseViewportBy" | "topItemCount" | "initialTopMostItemIndex" | "initialScrollTop" | "initialItemCount" | "components" | "computeItemKey" | "defaultItemHeight" | "itemSize" | "fixedItemHeight" | "scrollSeekConfiguration" | "followOutput" | "headerFooterTag" | "firstItemIndex" | "isScrolling" | "endReached" | "startReached" | "rangeChanged" | "atBottomStateChange" | "atTopStateChange" | "totalListHeightChanged" | "itemsRendered" | "alignToBottom" | "useWindowScroll" | "customScrollParent" | "scrollerRef" | "atBottomThreshold" | "react18ConcurrentRendering"> & {
|
|
68
78
|
/**
|
|
69
79
|
* that virtual list container height,
|
|
@@ -77,6 +87,8 @@ export declare const RcSuggestionList: import("styled-components").StyledCompone
|
|
|
77
87
|
* @default false
|
|
78
88
|
*/
|
|
79
89
|
padding?: number | boolean | undefined;
|
|
90
|
+
/** is that menu virtualize */
|
|
91
|
+
virtualize?: boolean | undefined;
|
|
80
92
|
} & RcClassesProps<"root" | "expanded" | "toggle" | "groupTitle"> & React.RefAttributes<any>, import("../../../foundation").RcTheme, Pick<{
|
|
81
93
|
/** current highlightedIndex */
|
|
82
94
|
highlightedIndex: number;
|
|
@@ -100,6 +112,10 @@ export declare const RcSuggestionList: import("styled-components").StyledCompone
|
|
|
100
112
|
* set that as `unset`, let outside `absolute` container to calculate that.
|
|
101
113
|
*/
|
|
102
114
|
position?: "absolute" | "unset" | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* in autocomplete mode, that will have selected index, show selected when focused
|
|
117
|
+
*/
|
|
118
|
+
selectedIndex?: number | undefined;
|
|
103
119
|
} & Pick<RcDownshiftProps<RcDownshiftSelectedItem>, "getOptionDisabled" | "getOptionLabel" | "renderOption" | "groupVariant" | "groupExpanded" | "renderGroup" | "MenuItem" | "inputValue"> & Pick<Partial<VirtuosoProps<any, undefined>>, "key" | "form" | "list" | "className" | "color" | "height" | "id" | "lang" | "max" | "media" | "method" | "min" | "name" | "style" | "target" | "type" | "width" | "role" | "tabIndex" | "crossOrigin" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "step" | "cite" | "label" | "slot" | "span" | "summary" | "title" | "pattern" | "download" | "start" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "value" | "shape" | "disabled" | "hrefLang" | "rel" | "default" | "action" | "content" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "open" | "selected" | "src" | "checked" | "readOnly" | "required" | "autoComplete" | "rows" | "accept" | "acceptCharset" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "dateTime" | "defer" | "encType" | "frameBorder" | "headers" | "high" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "maxLength" | "mediaGroup" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "optimum" | "playsInline" | "poster" | "preload" | "reversed" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "useMap" | "wmode" | "wrap" | "context" | "overscan" | "increaseViewportBy" | "topItemCount" | "initialTopMostItemIndex" | "initialScrollTop" | "initialItemCount" | "components" | "computeItemKey" | "defaultItemHeight" | "itemSize" | "fixedItemHeight" | "scrollSeekConfiguration" | "followOutput" | "headerFooterTag" | "firstItemIndex" | "isScrolling" | "endReached" | "startReached" | "rangeChanged" | "atBottomStateChange" | "atTopStateChange" | "totalListHeightChanged" | "itemsRendered" | "alignToBottom" | "useWindowScroll" | "customScrollParent" | "scrollerRef" | "atBottomThreshold" | "react18ConcurrentRendering"> & {
|
|
104
120
|
/**
|
|
105
121
|
* that virtual list container height,
|
|
@@ -113,6 +129,8 @@ export declare const RcSuggestionList: import("styled-components").StyledCompone
|
|
|
113
129
|
* @default false
|
|
114
130
|
*/
|
|
115
131
|
padding?: number | boolean | undefined;
|
|
116
|
-
|
|
132
|
+
/** is that menu virtualize */
|
|
133
|
+
virtualize?: boolean | undefined;
|
|
134
|
+
} & RcClassesProps<"root" | "expanded" | "toggle" | "groupTitle"> & React.RefAttributes<any>, "ref" | "key" | "form" | "list" | "className" | "color" | "height" | "id" | "lang" | "max" | "media" | "method" | "min" | "name" | "style" | "target" | "type" | "width" | "role" | "tabIndex" | "crossOrigin" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "step" | "cite" | "label" | "slot" | "span" | "summary" | "title" | "pattern" | "download" | "start" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "value" | "shape" | "disabled" | "hrefLang" | "rel" | "default" | "action" | "content" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "position" | "open" | "padding" | "selected" | "src" | "checked" | "readOnly" | "required" | "autoComplete" | "rows" | "accept" | "acceptCharset" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "dateTime" | "defer" | "encType" | "frameBorder" | "headers" | "high" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "maxLength" | "mediaGroup" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "optimum" | "playsInline" | "poster" | "preload" | "reversed" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "useMap" | "wmode" | "wrap" | "context" | "overscan" | "increaseViewportBy" | "topItemCount" | "initialTopMostItemIndex" | "initialScrollTop" | "initialItemCount" | "components" | "computeItemKey" | "defaultItemHeight" | "itemSize" | "fixedItemHeight" | "scrollSeekConfiguration" | "followOutput" | "headerFooterTag" | "firstItemIndex" | "isScrolling" | "endReached" | "startReached" | "rangeChanged" | "atBottomStateChange" | "atTopStateChange" | "totalListHeightChanged" | "itemsRendered" | "alignToBottom" | "useWindowScroll" | "customScrollParent" | "scrollerRef" | "atBottomThreshold" | "react18ConcurrentRendering" | "options" | "getItemProps" | "getOptionDisabled" | "getOptionLabel" | "renderOption" | "groupVariant" | "groupExpanded" | "renderGroup" | "MenuItem" | "inputValue" | "maxContainerHeight" | "virtualize" | "optionsGroupList" | "highlightedIndex" | "getMenuProps" | "changeHighlightedIndexReason" | "isKeepHighlightedIndex" | "onUpdatePopper" | "selectedIndex"> & {
|
|
117
135
|
theme?: import("../../../foundation").RcTheme | undefined;
|
|
118
136
|
}>;
|
|
@@ -21,7 +21,7 @@ var List = react_1.forwardRef(function (props, ref) {
|
|
|
21
21
|
var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
22
22
|
var _a;
|
|
23
23
|
var props = foundation_1.useThemeProps({ props: inProps, name: 'RcSuggestionList' });
|
|
24
|
-
var highlightedIndex = props.highlightedIndex, options = props.options, getItemProps = props.getItemProps, getMenuProps = props.getMenuProps, renderOption = props.renderOption, inputValue = props.inputValue, groupVariant = props.groupVariant, groupExpanded = props.groupExpanded, renderGroup = props.renderGroup, optionsGroupList = props.optionsGroupList, getOptionDisabled = props.getOptionDisabled, MenuItem = props.MenuItem, changeHighlightedIndexReason = props.changeHighlightedIndexReason, isKeepHighlightedIndex = props.isKeepHighlightedIndex, componentsProp = props.components, onUpdatePopper = props.onUpdatePopper, getOptionLabel = props.getOptionLabel, padding = props.padding,
|
|
24
|
+
var highlightedIndex = props.highlightedIndex, options = props.options, getItemProps = props.getItemProps, _b = props.virtualize, virtualize = _b === void 0 ? true : _b, getMenuProps = props.getMenuProps, renderOption = props.renderOption, selectedOptions = props.value, inputValue = props.inputValue, groupVariant = props.groupVariant, groupExpanded = props.groupExpanded, renderGroup = props.renderGroup, optionsGroupList = props.optionsGroupList, getOptionDisabled = props.getOptionDisabled, MenuItem = props.MenuItem, changeHighlightedIndexReason = props.changeHighlightedIndexReason, isKeepHighlightedIndex = props.isKeepHighlightedIndex, componentsProp = props.components, onUpdatePopper = props.onUpdatePopper, getOptionLabel = props.getOptionLabel, padding = props.padding, _c = props.maxContainerHeight, maxContainerHeight = _c === void 0 ? '100%' : _c, classNameProp = props.className, classesProp = props.classes, _d = props.position, position = _d === void 0 ? 'absolute' : _d, selectedIndex = props.selectedIndex, rest = tslib_1.__rest(props, ["highlightedIndex", "options", "getItemProps", "virtualize", "getMenuProps", "renderOption", "value", "inputValue", "groupVariant", "groupExpanded", "renderGroup", "optionsGroupList", "getOptionDisabled", "MenuItem", "changeHighlightedIndexReason", "isKeepHighlightedIndex", "components", "onUpdatePopper", "getOptionLabel", "padding", "maxContainerHeight", "className", "classes", "position", "selectedIndex"]);
|
|
25
25
|
var vlRef = react_1.useRef(null);
|
|
26
26
|
var forkVlRef = foundation_1.useForkRef(ref, vlRef);
|
|
27
27
|
var isTitleMode = groupVariant === 'normal';
|
|
@@ -30,7 +30,7 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
30
30
|
var itemCount = options.length;
|
|
31
31
|
var classes = foundation_1.combineClasses(utils_1.RcSuggestionListClasses, classesProp);
|
|
32
32
|
var className = clsx_1.default(classNameProp, classes === null || classes === void 0 ? void 0 : classes.root);
|
|
33
|
-
var
|
|
33
|
+
var _e = Virtuoso_1.useDynamicHeight({
|
|
34
34
|
itemCount: itemCount,
|
|
35
35
|
maxContainerHeight: maxContainerHeight,
|
|
36
36
|
onContainerHeightChange: function (changeHeight) {
|
|
@@ -40,25 +40,30 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
40
40
|
onUpdatePopper === null || onUpdatePopper === void 0 ? void 0 : onUpdatePopper();
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
}), totalListHeightChanged =
|
|
43
|
+
}), totalListHeightChanged = _e.totalListHeightChanged, style = _e.style, containerHeighRef = _e.containerHeighRef;
|
|
44
44
|
var sleep = foundation_1.useSleep().sleep;
|
|
45
45
|
var scrollToIndexWithRetry = foundation_1.useRetry(function (location) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var toIndex, toElm;
|
|
47
|
-
var _a, _b;
|
|
48
|
-
return tslib_1.__generator(this, function (
|
|
49
|
-
switch (
|
|
46
|
+
var toIndex, toElm_1, toElm;
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
return tslib_1.__generator(this, function (_d) {
|
|
49
|
+
switch (_d.label) {
|
|
50
50
|
case 0:
|
|
51
|
+
toIndex = location.index;
|
|
52
|
+
if (!virtualize) {
|
|
53
|
+
toElm_1 = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-item-index=\"" + toIndex + "\"]");
|
|
54
|
+
toElm_1 === null || toElm_1 === void 0 ? void 0 : toElm_1.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
55
|
+
return [2 /*return*/, true];
|
|
56
|
+
}
|
|
51
57
|
if (location.index === 0 && padding !== undefined) {
|
|
52
58
|
location = tslib_1.__assign(tslib_1.__assign({}, location), { offset: -(typeof padding === 'number'
|
|
53
59
|
? padding
|
|
54
60
|
: styles_1.menuListBoundaryPadding) });
|
|
55
61
|
}
|
|
56
|
-
(
|
|
57
|
-
toIndex = location.index;
|
|
62
|
+
(_b = vlRef.current) === null || _b === void 0 ? void 0 : _b.scrollToIndex(location);
|
|
58
63
|
return [4 /*yield*/, sleep(0)];
|
|
59
64
|
case 1:
|
|
60
|
-
|
|
61
|
-
toElm = (
|
|
65
|
+
_d.sent();
|
|
66
|
+
toElm = (_c = listRef.current) === null || _c === void 0 ? void 0 : _c.querySelector("[data-item-index=\"" + toIndex + "\"]");
|
|
62
67
|
if (toElm) {
|
|
63
68
|
return [2 /*return*/, true];
|
|
64
69
|
}
|
|
@@ -69,10 +74,10 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
69
74
|
retryTimes: 10,
|
|
70
75
|
intervalTime: 20,
|
|
71
76
|
}).retry;
|
|
72
|
-
var
|
|
77
|
+
var _f = Virtuoso_1.useHighlightScroll({
|
|
73
78
|
containerHeighRef: containerHeighRef,
|
|
74
79
|
scrollToIndex: scrollToIndexWithRetry,
|
|
75
|
-
}), scrollerRef =
|
|
80
|
+
}), scrollerRef = _f.scrollerRef, scrollerRefFn = _f.scrollerRefFn, itemsRendered = _f.itemsRendered, scrollToHighlightedIndex = _f.scrollToHighlightedIndex;
|
|
76
81
|
// for safari, prevent popover
|
|
77
82
|
var virtuosoViewPort = (_a = scrollerRef.current) === null || _a === void 0 ? void 0 : _a.firstElementChild;
|
|
78
83
|
react_1.useLayoutEffect(function () {
|
|
@@ -82,7 +87,7 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
82
87
|
}, [virtuosoViewPort, position]);
|
|
83
88
|
var prevHighlightedIndex = foundation_1.usePrevious(function () { return highlightedIndex; }, true);
|
|
84
89
|
react_1.useLayoutEffect(function () {
|
|
85
|
-
if (vlRef.current &&
|
|
90
|
+
if ((!virtualize || vlRef.current) &&
|
|
86
91
|
!isKeepHighlightedIndex &&
|
|
87
92
|
// * only scroll when reason is 'keyboard'
|
|
88
93
|
changeHighlightedIndexReason &&
|
|
@@ -120,8 +125,9 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
120
125
|
index: index,
|
|
121
126
|
className: isGroupTitle ? classes.groupTitle : undefined,
|
|
122
127
|
});
|
|
123
|
-
var
|
|
124
|
-
var
|
|
128
|
+
var highlighted = highlightedIndex === index;
|
|
129
|
+
var selected = selectedIndex === index;
|
|
130
|
+
var resultProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ 'data-item-index': !virtualize ? index : undefined }, option), itemProps), { key: itemProps.id });
|
|
125
131
|
var indexInOwnGroup = resultProps.indexInOwnGroup;
|
|
126
132
|
delete resultProps.indexInOwnGroup;
|
|
127
133
|
// * when item is not disabled, that should check outside is that disabled
|
|
@@ -131,6 +137,7 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
131
137
|
var state = {
|
|
132
138
|
inputValue: inputValue,
|
|
133
139
|
selected: selected,
|
|
140
|
+
highlighted: highlighted,
|
|
134
141
|
index: index,
|
|
135
142
|
indexInOwnGroup: indexInOwnGroup,
|
|
136
143
|
};
|
|
@@ -143,9 +150,11 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
143
150
|
}
|
|
144
151
|
// TODO: that MenuItem will be remove
|
|
145
152
|
if (MenuItem) {
|
|
146
|
-
return (react_1.default.createElement(MenuItem
|
|
153
|
+
return (react_1.default.createElement(MenuItem
|
|
154
|
+
// when not virtualize, use index as key
|
|
155
|
+
, tslib_1.__assign({}, resultProps, { itemId: option.id, "data-suggestion-item-id": option.id, isHighlighted: selected || highlighted, isMember: option.isMember })));
|
|
147
156
|
}
|
|
148
|
-
return (react_1.default.createElement(MenuItem_1.RcMenuItem, tslib_1.__assign({ component: "div", selected: selected }, foundation_1.omit(resultProps, [
|
|
157
|
+
return (react_1.default.createElement(MenuItem_1.RcMenuItem, tslib_1.__assign({ component: "div", selected: selected, focused: highlighted }, foundation_1.omit(resultProps, [
|
|
149
158
|
'isSuggestion',
|
|
150
159
|
'freeSolo',
|
|
151
160
|
'label',
|
|
@@ -166,17 +175,23 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
166
175
|
var components = react_1.useMemo(function () {
|
|
167
176
|
return tslib_1.__assign({ List: List, Header: PaddingComponent, Footer: PaddingComponent }, componentsProp);
|
|
168
177
|
}, [componentsProp, PaddingComponent]);
|
|
169
|
-
return (react_1.default.createElement(SuggestionListContext.Provider, { value: listRef },
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
return (react_1.default.createElement(SuggestionListContext.Provider, { value: listRef }, virtualize ? (react_1.default.createElement(Virtuoso_1.Virtuoso, tslib_1.__assign({ ref: forkVlRef, totalCount: itemCount, data: itemData, className: className, components: components, itemContent: itemContent }, getMenuProps(), foundation_1.combineProps({
|
|
179
|
+
scrollerRef: function (scrollElm) {
|
|
180
|
+
scrollerRefFn(scrollElm);
|
|
181
|
+
Virtuoso_1.modifyVlScrollerStyle(scrollElm, position);
|
|
182
|
+
},
|
|
183
|
+
itemsRendered: itemsRendered,
|
|
184
|
+
totalListHeightChanged: totalListHeightChanged,
|
|
185
|
+
style: style,
|
|
186
|
+
isScrolling: handleScrolling,
|
|
187
|
+
}, rest)))) : (react_1.default.createElement(List, { style: { maxHeight: style.height, overflow: 'auto' }, ref: function (scrollElm) {
|
|
188
|
+
scrollerRefFn(scrollElm);
|
|
189
|
+
} },
|
|
190
|
+
react_1.default.createElement(PaddingComponent, null),
|
|
191
|
+
options.map(function (x, i) {
|
|
192
|
+
return itemContent(i, x);
|
|
193
|
+
}),
|
|
194
|
+
react_1.default.createElement(PaddingComponent, null)))));
|
|
180
195
|
});
|
|
181
196
|
exports.RcSuggestionList = foundation_1.styled(SuggestionList)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), styles_2.SuggestionListStyle);
|
|
182
197
|
exports.RcSuggestionList.displayName = 'RcSuggestionList';
|