@ringcentral/juno 2.19.2 → 2.20.1
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/Badge/Badge.d.ts +2 -2
- package/components/Badge/Badge.js +2 -2
- package/components/Downshift/Downshift.d.ts +6 -0
- package/components/Downshift/Downshift.js +9 -8
- package/components/Downshift/utils/useDownshift.d.ts +2 -2
- package/components/Downshift/utils/useDownshift.js +20 -11
- package/es6/components/Badge/Badge.js +2 -2
- package/es6/components/Downshift/Downshift.js +9 -8
- package/es6/components/Downshift/utils/useDownshift.js +20 -11
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ import MuiBadge from '@material-ui/core/Badge';
|
|
|
3
3
|
import { RcBaseProps, RcPaletteKeys, UnionPick } from '../../foundation';
|
|
4
4
|
import { RcPresenceProps } from '../Presence';
|
|
5
5
|
declare type RcBadgeProps = {
|
|
6
|
-
/** tag color, default is `
|
|
6
|
+
/** tag color, default is `umi.mentioned` */
|
|
7
7
|
color?: RcPaletteKeys;
|
|
8
|
-
/** text color, default is `
|
|
8
|
+
/** text color, default is `umi.text` */
|
|
9
9
|
textColor?: RcPaletteKeys;
|
|
10
10
|
/** tag border color */
|
|
11
11
|
borderColor?: RcPaletteKeys;
|
|
@@ -59,8 +59,8 @@ var _RcBadge = react_1.forwardRef(function (inProps, ref) {
|
|
|
59
59
|
var RcBadge = foundation_1.styled(_RcBadge)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.BadgeStyle);
|
|
60
60
|
exports.RcBadge = RcBadge;
|
|
61
61
|
RcBadge.defaultProps = {
|
|
62
|
-
color: '
|
|
63
|
-
textColor: '
|
|
62
|
+
color: 'umi.mentioned',
|
|
63
|
+
textColor: 'umi.text',
|
|
64
64
|
overlap: 'rectangular',
|
|
65
65
|
anchorOrigin: {
|
|
66
66
|
horizontal: 'right',
|
|
@@ -248,6 +248,12 @@ declare type RcDownshiftProps<T extends RcDownshiftSelectedItem = RcDownshiftSel
|
|
|
248
248
|
* and that also set `disableCloseOnSelect` to `true`
|
|
249
249
|
*/
|
|
250
250
|
openOnFocus?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* If `true`, the input element can be click to toggle that selection list
|
|
253
|
+
*
|
|
254
|
+
* When be `autocomplete`, that `toggleWithInput` default will be `true`
|
|
255
|
+
*/
|
|
256
|
+
toggleWithInput?: boolean;
|
|
251
257
|
/** get expand addition props */
|
|
252
258
|
getExpandIconProps?: (group: RcDownshiftGroupedOption) => Partial<RcIconButtonProps>;
|
|
253
259
|
/**
|
|
@@ -131,12 +131,13 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
131
131
|
]);
|
|
132
132
|
}
|
|
133
133
|
var theme = foundation_1.useTheme();
|
|
134
|
+
var isAutocomplete = props.variant === 'autocomplete';
|
|
134
135
|
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
136
|
return {
|
|
136
137
|
symbol: isOpen ? juno_icon_1.ArrowUp : juno_icon_1.ArrowDown,
|
|
137
138
|
};
|
|
138
|
-
} : _l, inputValueProp = props.inputValue, onKeyDownProp = props.onKeyDown, helperTextProp = props.helperText, options = props.options, openOnFocus = props.openOnFocus, _m = props.getOptionLabel, getOptionLabel =
|
|
139
|
-
var
|
|
139
|
+
} : _l, inputValueProp = props.inputValue, onKeyDownProp = props.onKeyDown, helperTextProp = props.helperText, options = props.options, openOnFocus = props.openOnFocus, _m = props.toggleWithInput, toggleWithInput = _m === void 0 ? isAutocomplete : _m, _o = props.getOptionLabel, getOptionLabel = _o === void 0 ? itemToString : _o, renderInput = props.renderInput, _p = props.label, label = _p === void 0 ? inputLabel : _p, _q = props.inputRef, inputRefProp = _q === void 0 ? messageRef : _q, _r = props.error, error = _r === void 0 ? nameError : _r, _s = props.placeholder, placeholder = _s === void 0 ? inputPlaceholder : _s, _t = props.freeSolo, freeSolo = _t === void 0 ? enableFreeChips : _t, _u = props.keyToTags, keyToTags = _u === void 0 ? keyToChips : _u, _v = props.maxFreeSolo, maxFreeSolo = _v === void 0 ? limitOfFreeChips : _v, _w = props.SuggestionListProps, _x = _w === void 0 ? {} : _w, _y = _x.virtualize, virtualize = _y === void 0 ? true : _y, SuggestionListProps = tslib_1.__rest(_x, ["virtualize"]), _z = props.autoSelect, autoSelect = _z === void 0 ? enableAutoTransform : _z, PopperComponent = props.PopperComponent, _0 = props.PopperProps, _1 = _0 === void 0 ? {} : _0, _2 = _1.anchorElType, anchorElType = _2 === void 0 ? 'root' : _2, popperTransition = _1.transition, _3 = _1.TransitionComponent, TransitionComponent = _3 === void 0 ? virtualize ? Fade_1.RcFade : Grow_1.RcGrow : _3, _4 = _1.transitionDuration, transitionDurationProp = _4 === void 0 ? 'auto' : _4, _5 = _1.TransitionProps, TransitionPropsProp = _5 === void 0 ? {} : _5, PopperProps = tslib_1.__rest(_1, ["anchorElType", "transition", "TransitionComponent", "transitionDuration", "TransitionProps"]), initialIsOpen = props.initialIsOpen, disabled = props.disabled, requiredProp = props.required, _6 = props.defaultIsOpen, defaultIsOpen = _6 === void 0 ? openOnFocus : _6, _7 = props.disableCloseOnSelect, disableCloseOnSelect = _7 === void 0 ? defaultIsOpen : _7, _8 = props.onChange, onChangeProp = _8 === void 0 ? onSelectChange : _8, 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", "toggleWithInput", "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"]);
|
|
140
|
+
var _9 = tslib_1.__read(react_1.useState('bottom-start'), 2), position = _9[0], setPosition = _9[1];
|
|
140
141
|
var innerInputRef = react_1.useRef(null);
|
|
141
142
|
var textFieldRef = react_1.useRef(null);
|
|
142
143
|
var inputRef = foundation_1.useForkRef(inputRefProp, innerInputRef);
|
|
@@ -151,7 +152,7 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
151
152
|
utils_1.useDownshiftError({ isNew: isNew, MenuItem: MenuItem, InputItem: InputItem });
|
|
152
153
|
}
|
|
153
154
|
var required = requiredProp || (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.required);
|
|
154
|
-
var
|
|
155
|
+
var _10 = utils_1.useDownshift({
|
|
155
156
|
focused: focused,
|
|
156
157
|
open: openProp,
|
|
157
158
|
variant: variant,
|
|
@@ -178,6 +179,7 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
178
179
|
disabled: disabled,
|
|
179
180
|
required: required,
|
|
180
181
|
openOnFocus: openOnFocus,
|
|
182
|
+
toggleWithInput: toggleWithInput,
|
|
181
183
|
autoHighlight: autoHighlight,
|
|
182
184
|
groupBy: groupBy,
|
|
183
185
|
groupVariant: groupVariant,
|
|
@@ -190,9 +192,9 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
190
192
|
onKeyDown: onKeyDownProp,
|
|
191
193
|
disabledItemsHighlightable: disabledItemsHighlightable,
|
|
192
194
|
onGroupExpanded: onGroupExpanded,
|
|
193
|
-
}), focusInput =
|
|
195
|
+
}), focusInput = _10.focusInput, optionItems = _10.optionItems, optionsGroupList = _10.optionsGroupList, selectedItems = _10.tags, highlightedIndex = _10.highlightedIndex, getToggleButtonProps = _10.getToggleButtonProps, getTagProps = _10.getTagProps, getTagListBoxProps = _10.getTagListBoxProps, getMenuProps = _10.getMenuProps, getPopperProps = _10.getPopperProps, getInputProps = _10.getInputProps, getInputAriaProps = _10.getInputAriaProps, getLabelProps = _10.getLabelProps, getItemProps = _10.getItemProps, isOpen = _10.isOpen, inputValue = _10.inputValue, activeIndex = _10.activeIndex, setActiveIndex = _10.setActiveIndex, setHighlightedIndex = _10.setHighlightedIndex, onInputChange = _10.onInputChange, keepHighlightedIndex = _10.keepHighlightedIndex, changeHighlightedIndexReason = _10.changeHighlightedIndexReason, closeMenu = _10.closeMenu, openMenu = _10.openMenu, reset = _10.reset, getClearButtonProps = _10.getClearButtonProps, noOptionItem = _10.noOptionItem, getNoOptionsProps = _10.getNoOptionsProps, isKeepHighlightedIndex = _10.isKeepHighlightedIndex, isDownshiftFocused = _10.focused, autoCompleteSelectedIndex = _10.autoCompleteSelectedIndex;
|
|
194
196
|
var open = Boolean((isOpen || noOptionItem) && textFieldRef.current);
|
|
195
|
-
var
|
|
197
|
+
var _11 = getInputProps(), onBlur = _11.onBlur, InputProps = tslib_1.__rest(_11, ["onBlur"]);
|
|
196
198
|
var helperText = isNew
|
|
197
199
|
? helperTextProp
|
|
198
200
|
: nameError || allowPlainHelperText
|
|
@@ -217,7 +219,6 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
217
219
|
}
|
|
218
220
|
var toTextFieldRef = foundation_1.useForkRef(textFieldRef, ref);
|
|
219
221
|
var colorHex = react_1.useMemo(function () { return (color ? foundation_1.getParsePaletteColor(color)({ theme: theme }) : undefined); }, [color, theme]);
|
|
220
|
-
var isAutocomplete = variant === 'autocomplete';
|
|
221
222
|
var startAdornment = (function () {
|
|
222
223
|
if (isAutocomplete) {
|
|
223
224
|
return undefined;
|
|
@@ -260,14 +261,14 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
260
261
|
: error
|
|
261
262
|
? 'danger.f02'
|
|
262
263
|
: 'neutral.f04', size: "large" }, getToggleButtonProps(tslib_1.__assign(tslib_1.__assign({}, ToggleButtonProps), getToggleButtonPropsProp(isOpen))))))));
|
|
263
|
-
var
|
|
264
|
+
var _12 = (function () {
|
|
264
265
|
var _a = InputPropsProp || {}, classes = _a.classes, restInputPropsProp = tslib_1.__rest(_a, ["classes"]);
|
|
265
266
|
var toClasses = foundation_1.combineClasses(classes, utils_1.RcDownshiftInputClasses);
|
|
266
267
|
return {
|
|
267
268
|
containerClassName: toClasses.container,
|
|
268
269
|
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),
|
|
269
270
|
};
|
|
270
|
-
})(), containerClassName =
|
|
271
|
+
})(), containerClassName = _12.containerClassName, TextFieldInputProps = _12.TextFieldInputProps;
|
|
271
272
|
react_1.useImperativeHandle(action, function () { return ({
|
|
272
273
|
getActiveIndex: function () { return activeIndex; },
|
|
273
274
|
setActiveIndex: setActiveIndex,
|
|
@@ -15,8 +15,8 @@ declare type UseDownshiftParams<T extends RcDownshiftSelectedItem = RcDownshiftS
|
|
|
15
15
|
* set that will auto add item into options
|
|
16
16
|
*/
|
|
17
17
|
addNoOptionItem?: 'first' | 'last';
|
|
18
|
-
} & Pick<RcDownshiftProps<T>, 'open' | 'onOpen' | 'onClose' | 'multiple' | 'onChange' | 'value' | 'getOptionLabel' | 'filterOptions' | 'options' | 'freeSolo' | 'maxFreeSolo' | 'onMaxFreeSolo' | 'disableCloseOnSelect' | 'initialIsOpen' | 'keyToTags' | 'inputValue' | 'autoSelect' | 'onInputChange' | 'onKeyDown' | 'disabled' | 'openOnFocus' | 'onClear' | 'renderNoOptions' | 'autoHighlight' | 'getOptionDisabled' | 'required' | 'label' | 'disabledItemsHighlightable' | 'variant' | 'groupBy' | 'getExpandIconProps' | 'groupExpanded' | 'groupDefaultExpanded' | 'onGroupExpanded' | 'groupVariant' | 'focused'>;
|
|
19
|
-
export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownshiftSelectedItem>({ multiple: multipleProp, variant, label: labelProp, inputValue: inputValueProp, getOptionLabel, keyToTags, filterOptions: filterOptionsProp, disabledItemsHighlightable, options, freeSolo, onInputChange: onInputChangeProp, maxFreeSolo, onMaxFreeSolo, openOnFocus, disableCloseOnSelect, initialIsOpen, autoSelect, inputContainerRef, inputRef, wrapperRef, onKeyDown: onKeyDownProp, onChange: onSelectChange, value: selectedItemsProp, disabled, renderNoOptions, onClear, autoHighlight, getOptionDisabled, addNoOptionItem, groupBy, onGroupExpanded, groupVariant, groupExpanded, groupDefaultExpanded, getExpandIconProps, required, open: openProp, onOpen, onClose, focused, }: UseDownshiftParams<T>) => {
|
|
18
|
+
} & Pick<RcDownshiftProps<T>, 'open' | 'onOpen' | 'onClose' | 'multiple' | 'onChange' | 'value' | 'getOptionLabel' | 'filterOptions' | 'options' | 'freeSolo' | 'maxFreeSolo' | 'onMaxFreeSolo' | 'disableCloseOnSelect' | 'initialIsOpen' | 'keyToTags' | 'inputValue' | 'autoSelect' | 'onInputChange' | 'onKeyDown' | 'disabled' | 'openOnFocus' | 'toggleWithInput' | 'onClear' | 'renderNoOptions' | 'autoHighlight' | 'getOptionDisabled' | 'required' | 'label' | 'disabledItemsHighlightable' | 'variant' | 'groupBy' | 'getExpandIconProps' | 'groupExpanded' | 'groupDefaultExpanded' | 'onGroupExpanded' | 'groupVariant' | 'focused'>;
|
|
19
|
+
export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownshiftSelectedItem>({ multiple: multipleProp, variant, label: labelProp, inputValue: inputValueProp, getOptionLabel, keyToTags, filterOptions: filterOptionsProp, disabledItemsHighlightable, options, freeSolo, onInputChange: onInputChangeProp, maxFreeSolo, onMaxFreeSolo, openOnFocus, toggleWithInput, disableCloseOnSelect, initialIsOpen, autoSelect, inputContainerRef, inputRef, wrapperRef, onKeyDown: onKeyDownProp, onChange: onSelectChange, value: selectedItemsProp, disabled, renderNoOptions, onClear, autoHighlight, getOptionDisabled, addNoOptionItem, groupBy, onGroupExpanded, groupVariant, groupExpanded, groupDefaultExpanded, getExpandIconProps, required, open: openProp, onOpen, onClose, focused, }: UseDownshiftParams<T>) => {
|
|
20
20
|
focusInput: () => void | undefined;
|
|
21
21
|
readOnly: boolean | undefined;
|
|
22
22
|
getTagProps: ({ index, selectedItem, ...restTagProps }: import("./useDownshift.interface").RcDownshiftGetSelectedItemProps<T>) => {
|
|
@@ -9,7 +9,7 @@ var useDownshiftTag_1 = require("./useDownshiftTag");
|
|
|
9
9
|
var DOWNSHIFT_ID_NO_RESULT_TOKEN = 'rc-chip-empty';
|
|
10
10
|
var DEFAULT_HIGHLIGHTED_INDEX = -1;
|
|
11
11
|
exports.useDownshift = function (_a) {
|
|
12
|
-
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DownshiftUtils_1.DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DownshiftUtils_1.DEFAULT_KEY_TO_CHIPS : _c, filterOptionsProp = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose, focused = _a.focused;
|
|
12
|
+
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DownshiftUtils_1.DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DownshiftUtils_1.DEFAULT_KEY_TO_CHIPS : _c, filterOptionsProp = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, toggleWithInput = _a.toggleWithInput, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose, focused = _a.focused;
|
|
13
13
|
var isAutocomplete = variant === 'autocomplete';
|
|
14
14
|
var autoCompleteSelectedIndexRef = react_1.useRef(DEFAULT_HIGHLIGHTED_INDEX);
|
|
15
15
|
var downshiftId = foundation_1.useId('downshift', true);
|
|
@@ -167,6 +167,17 @@ exports.useDownshift = function (_a) {
|
|
|
167
167
|
setIsOpen(true);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
+
var toggleMenu = function (e, focus) {
|
|
171
|
+
if (focus === void 0) { focus = true; }
|
|
172
|
+
if (isOpen) {
|
|
173
|
+
closeMenu(e, 'toggleInput');
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
openMenu(e);
|
|
177
|
+
if (focus)
|
|
178
|
+
focusInput();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
170
181
|
var handleInputChange = function (newValue, open, e) {
|
|
171
182
|
if (open === void 0) { open = true; }
|
|
172
183
|
if (inputValue !== newValue) {
|
|
@@ -433,7 +444,13 @@ exports.useDownshift = function (_a) {
|
|
|
433
444
|
break;
|
|
434
445
|
}
|
|
435
446
|
}
|
|
436
|
-
}
|
|
447
|
+
}, onMouseDown: toggleWithInput
|
|
448
|
+
? function (e) {
|
|
449
|
+
if (inputValue === '' || !isOpen) {
|
|
450
|
+
toggleMenu(e, false);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
: undefined }), props);
|
|
437
454
|
};
|
|
438
455
|
var getInputAriaProps = function (props) {
|
|
439
456
|
var suggestionListInputAriaProps = getSuggestionListInputAriaProps(props);
|
|
@@ -459,15 +476,7 @@ exports.useDownshift = function (_a) {
|
|
|
459
476
|
e.preventDefault();
|
|
460
477
|
e.stopPropagation();
|
|
461
478
|
},
|
|
462
|
-
onClick:
|
|
463
|
-
if (isOpen) {
|
|
464
|
-
closeMenu(e, 'toggleInput');
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
openMenu(e);
|
|
468
|
-
focusInput();
|
|
469
|
-
}
|
|
470
|
-
},
|
|
479
|
+
onClick: toggleMenu,
|
|
471
480
|
tabIndex: -1,
|
|
472
481
|
}, props);
|
|
473
482
|
};
|
|
@@ -56,8 +56,8 @@ var _RcBadge = forwardRef(function (inProps, ref) {
|
|
|
56
56
|
});
|
|
57
57
|
var RcBadge = styled(_RcBadge)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), BadgeStyle);
|
|
58
58
|
RcBadge.defaultProps = {
|
|
59
|
-
color: '
|
|
60
|
-
textColor: '
|
|
59
|
+
color: 'umi.mentioned',
|
|
60
|
+
textColor: 'umi.text',
|
|
61
61
|
overlap: 'rectangular',
|
|
62
62
|
anchorOrigin: {
|
|
63
63
|
horizontal: 'right',
|
|
@@ -127,12 +127,13 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
127
127
|
]);
|
|
128
128
|
}
|
|
129
129
|
var theme = useTheme();
|
|
130
|
+
var isAutocomplete = props.variant === 'autocomplete';
|
|
130
131
|
var _a = props.itemToString, itemToString = _a === void 0 ? DEFAULT_GET_OPTION_LABEL : _a, _b = props.keyToChips, keyToChips = _b === void 0 ? DEFAULT_KEY_TO_CHIPS : _b, _c = props.limitOfFreeChips, limitOfFreeChips = _c === void 0 ? 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) {
|
|
131
132
|
return {
|
|
132
133
|
symbol: isOpen ? ArrowUp : ArrowDown,
|
|
133
134
|
};
|
|
134
|
-
} : _l, inputValueProp = props.inputValue, onKeyDownProp = props.onKeyDown, helperTextProp = props.helperText, options = props.options, openOnFocus = props.openOnFocus, _m = props.getOptionLabel, getOptionLabel =
|
|
135
|
-
var
|
|
135
|
+
} : _l, inputValueProp = props.inputValue, onKeyDownProp = props.onKeyDown, helperTextProp = props.helperText, options = props.options, openOnFocus = props.openOnFocus, _m = props.toggleWithInput, toggleWithInput = _m === void 0 ? isAutocomplete : _m, _o = props.getOptionLabel, getOptionLabel = _o === void 0 ? itemToString : _o, renderInput = props.renderInput, _p = props.label, label = _p === void 0 ? inputLabel : _p, _q = props.inputRef, inputRefProp = _q === void 0 ? messageRef : _q, _r = props.error, error = _r === void 0 ? nameError : _r, _s = props.placeholder, placeholder = _s === void 0 ? inputPlaceholder : _s, _t = props.freeSolo, freeSolo = _t === void 0 ? enableFreeChips : _t, _u = props.keyToTags, keyToTags = _u === void 0 ? keyToChips : _u, _v = props.maxFreeSolo, maxFreeSolo = _v === void 0 ? limitOfFreeChips : _v, _w = props.SuggestionListProps, _x = _w === void 0 ? {} : _w, _y = _x.virtualize, virtualize = _y === void 0 ? true : _y, SuggestionListProps = __rest(_x, ["virtualize"]), _z = props.autoSelect, autoSelect = _z === void 0 ? enableAutoTransform : _z, PopperComponent = props.PopperComponent, _0 = props.PopperProps, _1 = _0 === void 0 ? {} : _0, _2 = _1.anchorElType, anchorElType = _2 === void 0 ? 'root' : _2, popperTransition = _1.transition, _3 = _1.TransitionComponent, TransitionComponent = _3 === void 0 ? virtualize ? RcFade : RcGrow : _3, _4 = _1.transitionDuration, transitionDurationProp = _4 === void 0 ? 'auto' : _4, _5 = _1.TransitionProps, TransitionPropsProp = _5 === void 0 ? {} : _5, PopperProps = __rest(_1, ["anchorElType", "transition", "TransitionComponent", "transitionDuration", "TransitionProps"]), initialIsOpen = props.initialIsOpen, disabled = props.disabled, requiredProp = props.required, _6 = props.defaultIsOpen, defaultIsOpen = _6 === void 0 ? openOnFocus : _6, _7 = props.disableCloseOnSelect, disableCloseOnSelect = _7 === void 0 ? defaultIsOpen : _7, _8 = props.onChange, onChangeProp = _8 === void 0 ? onSelectChange : _8, 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 = __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", "toggleWithInput", "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"]);
|
|
136
|
+
var _9 = __read(useState('bottom-start'), 2), position = _9[0], setPosition = _9[1];
|
|
136
137
|
var innerInputRef = useRef(null);
|
|
137
138
|
var textFieldRef = useRef(null);
|
|
138
139
|
var inputRef = useForkRef(inputRefProp, innerInputRef);
|
|
@@ -147,7 +148,7 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
147
148
|
useDownshiftError({ isNew: isNew, MenuItem: MenuItem, InputItem: InputItem });
|
|
148
149
|
}
|
|
149
150
|
var required = requiredProp || (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.required);
|
|
150
|
-
var
|
|
151
|
+
var _10 = useDownshift({
|
|
151
152
|
focused: focused,
|
|
152
153
|
open: openProp,
|
|
153
154
|
variant: variant,
|
|
@@ -174,6 +175,7 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
174
175
|
disabled: disabled,
|
|
175
176
|
required: required,
|
|
176
177
|
openOnFocus: openOnFocus,
|
|
178
|
+
toggleWithInput: toggleWithInput,
|
|
177
179
|
autoHighlight: autoHighlight,
|
|
178
180
|
groupBy: groupBy,
|
|
179
181
|
groupVariant: groupVariant,
|
|
@@ -186,9 +188,9 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
186
188
|
onKeyDown: onKeyDownProp,
|
|
187
189
|
disabledItemsHighlightable: disabledItemsHighlightable,
|
|
188
190
|
onGroupExpanded: onGroupExpanded,
|
|
189
|
-
}), focusInput =
|
|
191
|
+
}), focusInput = _10.focusInput, optionItems = _10.optionItems, optionsGroupList = _10.optionsGroupList, selectedItems = _10.tags, highlightedIndex = _10.highlightedIndex, getToggleButtonProps = _10.getToggleButtonProps, getTagProps = _10.getTagProps, getTagListBoxProps = _10.getTagListBoxProps, getMenuProps = _10.getMenuProps, getPopperProps = _10.getPopperProps, getInputProps = _10.getInputProps, getInputAriaProps = _10.getInputAriaProps, getLabelProps = _10.getLabelProps, getItemProps = _10.getItemProps, isOpen = _10.isOpen, inputValue = _10.inputValue, activeIndex = _10.activeIndex, setActiveIndex = _10.setActiveIndex, setHighlightedIndex = _10.setHighlightedIndex, onInputChange = _10.onInputChange, keepHighlightedIndex = _10.keepHighlightedIndex, changeHighlightedIndexReason = _10.changeHighlightedIndexReason, closeMenu = _10.closeMenu, openMenu = _10.openMenu, reset = _10.reset, getClearButtonProps = _10.getClearButtonProps, noOptionItem = _10.noOptionItem, getNoOptionsProps = _10.getNoOptionsProps, isKeepHighlightedIndex = _10.isKeepHighlightedIndex, isDownshiftFocused = _10.focused, autoCompleteSelectedIndex = _10.autoCompleteSelectedIndex;
|
|
190
192
|
var open = Boolean((isOpen || noOptionItem) && textFieldRef.current);
|
|
191
|
-
var
|
|
193
|
+
var _11 = getInputProps(), onBlur = _11.onBlur, InputProps = __rest(_11, ["onBlur"]);
|
|
192
194
|
var helperText = isNew
|
|
193
195
|
? helperTextProp
|
|
194
196
|
: nameError || allowPlainHelperText
|
|
@@ -213,7 +215,6 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
213
215
|
}
|
|
214
216
|
var toTextFieldRef = useForkRef(textFieldRef, ref);
|
|
215
217
|
var colorHex = useMemo(function () { return (color ? getParsePaletteColor(color)({ theme: theme }) : undefined); }, [color, theme]);
|
|
216
|
-
var isAutocomplete = variant === 'autocomplete';
|
|
217
218
|
var startAdornment = (function () {
|
|
218
219
|
if (isAutocomplete) {
|
|
219
220
|
return undefined;
|
|
@@ -256,14 +257,14 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
256
257
|
: error
|
|
257
258
|
? 'danger.f02'
|
|
258
259
|
: 'neutral.f04', size: "large" }, getToggleButtonProps(__assign(__assign({}, ToggleButtonProps), getToggleButtonPropsProp(isOpen))))))));
|
|
259
|
-
var
|
|
260
|
+
var _12 = (function () {
|
|
260
261
|
var _a = InputPropsProp || {}, classes = _a.classes, restInputPropsProp = __rest(_a, ["classes"]);
|
|
261
262
|
var toClasses = combineClasses(classes, RcDownshiftInputClasses);
|
|
262
263
|
return {
|
|
263
264
|
containerClassName: toClasses.container,
|
|
264
265
|
TextFieldInputProps: combineProps(__assign(__assign(__assign({ classes: omit(toClasses, ['container']), endAdornment: endAdornment, inputComponent: RcDownshiftInput }, getTagListBoxProps()), InputProps), { onBlur: debug ? undefined : onBlur }), restInputPropsProp),
|
|
265
266
|
};
|
|
266
|
-
})(), containerClassName =
|
|
267
|
+
})(), containerClassName = _12.containerClassName, TextFieldInputProps = _12.TextFieldInputProps;
|
|
267
268
|
useImperativeHandle(action, function () { return ({
|
|
268
269
|
getActiveIndex: function () { return activeIndex; },
|
|
269
270
|
setActiveIndex: setActiveIndex,
|
|
@@ -7,7 +7,7 @@ import { useDownshiftTag } from './useDownshiftTag';
|
|
|
7
7
|
var DOWNSHIFT_ID_NO_RESULT_TOKEN = 'rc-chip-empty';
|
|
8
8
|
var DEFAULT_HIGHLIGHTED_INDEX = -1;
|
|
9
9
|
export var useDownshift = function (_a) {
|
|
10
|
-
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DEFAULT_KEY_TO_CHIPS : _c, filterOptionsProp = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose, focused = _a.focused;
|
|
10
|
+
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DEFAULT_KEY_TO_CHIPS : _c, filterOptionsProp = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, toggleWithInput = _a.toggleWithInput, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose, focused = _a.focused;
|
|
11
11
|
var isAutocomplete = variant === 'autocomplete';
|
|
12
12
|
var autoCompleteSelectedIndexRef = useRef(DEFAULT_HIGHLIGHTED_INDEX);
|
|
13
13
|
var downshiftId = useId('downshift', true);
|
|
@@ -165,6 +165,17 @@ export var useDownshift = function (_a) {
|
|
|
165
165
|
setIsOpen(true);
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
+
var toggleMenu = function (e, focus) {
|
|
169
|
+
if (focus === void 0) { focus = true; }
|
|
170
|
+
if (isOpen) {
|
|
171
|
+
closeMenu(e, 'toggleInput');
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
openMenu(e);
|
|
175
|
+
if (focus)
|
|
176
|
+
focusInput();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
168
179
|
var handleInputChange = function (newValue, open, e) {
|
|
169
180
|
if (open === void 0) { open = true; }
|
|
170
181
|
if (inputValue !== newValue) {
|
|
@@ -431,7 +442,13 @@ export var useDownshift = function (_a) {
|
|
|
431
442
|
break;
|
|
432
443
|
}
|
|
433
444
|
}
|
|
434
|
-
}
|
|
445
|
+
}, onMouseDown: toggleWithInput
|
|
446
|
+
? function (e) {
|
|
447
|
+
if (inputValue === '' || !isOpen) {
|
|
448
|
+
toggleMenu(e, false);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
: undefined }), props);
|
|
435
452
|
};
|
|
436
453
|
var getInputAriaProps = function (props) {
|
|
437
454
|
var suggestionListInputAriaProps = getSuggestionListInputAriaProps(props);
|
|
@@ -457,15 +474,7 @@ export var useDownshift = function (_a) {
|
|
|
457
474
|
e.preventDefault();
|
|
458
475
|
e.stopPropagation();
|
|
459
476
|
},
|
|
460
|
-
onClick:
|
|
461
|
-
if (isOpen) {
|
|
462
|
-
closeMenu(e, 'toggleInput');
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
openMenu(e);
|
|
466
|
-
focusInput();
|
|
467
|
-
}
|
|
468
|
-
},
|
|
477
|
+
onClick: toggleMenu,
|
|
469
478
|
tabIndex: -1,
|
|
470
479
|
}, props);
|
|
471
480
|
};
|