@ringcentral/juno 2.23.1 → 2.24.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.js +2 -2
- package/components/Downshift/SuggestionList/utils/useSuggestionList.js +0 -3
- package/components/Downshift/utils/useDownshift.d.ts +3 -1
- package/components/Downshift/utils/useDownshift.js +23 -3
- package/components/Forms/TextField/TextField.js +29 -43
- package/es6/components/Downshift/Downshift.js +2 -2
- package/es6/components/Downshift/SuggestionList/utils/useSuggestionList.js +0 -3
- package/es6/components/Downshift/utils/useDownshift.js +24 -4
- package/es6/components/Forms/TextField/TextField.js +30 -44
- package/package.json +1 -1
|
@@ -192,7 +192,7 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
192
192
|
onKeyDown: onKeyDownProp,
|
|
193
193
|
disabledItemsHighlightable: disabledItemsHighlightable,
|
|
194
194
|
onGroupExpanded: onGroupExpanded,
|
|
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;
|
|
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, popperElementRef = _10.popperElementRef;
|
|
196
196
|
var open = Boolean((isOpen || noOptionItem) && textFieldRef.current);
|
|
197
197
|
var _11 = getInputProps(), onBlur = _11.onBlur, InputProps = tslib_1.__rest(_11, ["onBlur"]);
|
|
198
198
|
var helperText = isNew
|
|
@@ -307,7 +307,7 @@ var _RcDownshift = react_1.memo(react_1.forwardRef(function (inProps, ref) {
|
|
|
307
307
|
maxLength: maxLength, containerRef: inputContainerRef }, getInputAriaProps(TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.inputProps)),
|
|
308
308
|
}, rest), { value: inputValue, clearBtn: false })),
|
|
309
309
|
!helperText && screenReaderText && (react_1.default.createElement(VisuallyHidden_1.RcVisuallyHidden, { id: describedbyId }, screenReaderText)),
|
|
310
|
-
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, modifiers: { fixOffsets: utils_1.fixOffsetsModifer },
|
|
310
|
+
react_1.default.createElement(styles_1.StyledPopper, tslib_1.__assign({ ref: popperElementRef, open: open, position: position, component: PopperComponent, placement: "bottom-start", anchorEl: anchorElRef.current, "data-test-automation-id": "suggestions-list", popperRef: popperRef, modifiers: { fixOffsets: utils_1.fixOffsetsModifer },
|
|
311
311
|
// * view type in popper.js
|
|
312
312
|
popperOptions: {
|
|
313
313
|
onUpdate: function (e) {
|
|
@@ -118,9 +118,6 @@ exports.useSuggestionList = function (_a) {
|
|
|
118
118
|
var groupOrder = (currGroup === null || currGroup === void 0 ? void 0 : currGroup.order) || 0;
|
|
119
119
|
return foundation_1.combineProps(tslib_1.__assign({ id: currUniqueId + "-option-" + index, onClick: function (e) {
|
|
120
120
|
selectItem(e, item);
|
|
121
|
-
}, onMouseDown: function (e) {
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
e.stopPropagation();
|
|
124
121
|
}, onMouseOver: function () {
|
|
125
122
|
if (highlightedIndexRef.current !== index &&
|
|
126
123
|
getIsItemCanSelected(item)) {
|
|
@@ -3,6 +3,7 @@ import { ChangeEvent, HTMLAttributes } from 'react';
|
|
|
3
3
|
import { RcIconButtonProps } from '../../Buttons/IconButton';
|
|
4
4
|
import { RcDownshiftProps } from '../Downshift';
|
|
5
5
|
import { RcDownshiftSelectedItem } from './SelectItem';
|
|
6
|
+
import { RcDownshiftGetItemPropsOptions } from './useDownshift.interface';
|
|
6
7
|
declare type UseDownshiftParams<T extends RcDownshiftSelectedItem = RcDownshiftSelectedItem> = {
|
|
7
8
|
/** that input ref you binding event */
|
|
8
9
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
@@ -292,7 +293,7 @@ export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownsh
|
|
|
292
293
|
'aria-required': boolean;
|
|
293
294
|
'aria-disabled': boolean;
|
|
294
295
|
};
|
|
295
|
-
getItemProps: (
|
|
296
|
+
getItemProps: (props: RcDownshiftGetItemPropsOptions<T>) => {
|
|
296
297
|
isSelected?: boolean | undefined;
|
|
297
298
|
disabled?: boolean | undefined;
|
|
298
299
|
ref?: import("react").RefObject<any> | undefined;
|
|
@@ -577,5 +578,6 @@ export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownsh
|
|
|
577
578
|
id: string;
|
|
578
579
|
inputChanged: boolean;
|
|
579
580
|
autoCompleteSelectedIndex: number;
|
|
581
|
+
popperElementRef: import("react").RefObject<HTMLDivElement>;
|
|
580
582
|
};
|
|
581
583
|
export {};
|
|
@@ -29,6 +29,7 @@ exports.useDownshift = function (_a) {
|
|
|
29
29
|
var stopAutoSelectRef = react_1.useRef(false);
|
|
30
30
|
var fromPasteString = react_1.useRef('');
|
|
31
31
|
var keepHighlightedIndexRef = react_1.useRef(false);
|
|
32
|
+
var popperElementRef = react_1.useRef(null);
|
|
32
33
|
var _g = foundation_1.useSleep(), sleep = _g.sleep, getSleeping = _g.getSleeping;
|
|
33
34
|
// * when that is autocomplete, that will never be multiple
|
|
34
35
|
var multiple = isAutocomplete ? false : multipleProp;
|
|
@@ -146,7 +147,20 @@ exports.useDownshift = function (_a) {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
},
|
|
149
|
-
}), inputValue = _j.inputValue, optionItems = _j.optionItems, optionsGroupList = _j.optionsGroupList, highlightedIndexRef = _j.highlightedIndexRef, changeHighlightedIndexReasonRef = _j.changeHighlightedIndexReasonRef, forceUpdate = _j.forceUpdate, selectItem = _j.selectItem, handleF10KeyDown = _j.handleF10KeyDown, onKeyFocusedIndexHandle = _j.onKeyFocusedIndexHandle, setHighlightedIndex = _j.setHighlightedIndex, updateInputValue = _j.updateInputValue, clearInput = _j.clearInput, getNextFocusableOption = _j.getNextFocusableOption,
|
|
150
|
+
}), inputValue = _j.inputValue, optionItems = _j.optionItems, optionsGroupList = _j.optionsGroupList, highlightedIndexRef = _j.highlightedIndexRef, changeHighlightedIndexReasonRef = _j.changeHighlightedIndexReasonRef, forceUpdate = _j.forceUpdate, selectItem = _j.selectItem, handleF10KeyDown = _j.handleF10KeyDown, onKeyFocusedIndexHandle = _j.onKeyFocusedIndexHandle, setHighlightedIndex = _j.setHighlightedIndex, updateInputValue = _j.updateInputValue, clearInput = _j.clearInput, getNextFocusableOption = _j.getNextFocusableOption, getSuggestionListItemProps = _j.getItemProps, focusInput = _j.focusInput, resetSuggestionList = _j.reset, getSuggestionListInputProps = _j.getInputProps, getSuggestionListInputAriaProps = _j.getInputAriaProps, getSuggestionListClearButtonProps = _j.getClearButtonProps, getLabelProps = _j.getLabelProps, getMenuProps = _j.getMenuProps;
|
|
151
|
+
var getItemProps = function (props) {
|
|
152
|
+
var onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, rest = tslib_1.__rest(props, ["onMouseDown", "onMouseUp"]);
|
|
153
|
+
return getSuggestionListItemProps(tslib_1.__assign(tslib_1.__assign({}, rest), { onMouseDown: function (e) {
|
|
154
|
+
// `getPopperProps` will prevent change focus when mouse down popper
|
|
155
|
+
// but suggestion item is an exception.
|
|
156
|
+
// so we need stop propagation to make sure focus can be changed
|
|
157
|
+
e.stopPropagation();
|
|
158
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e);
|
|
159
|
+
}, onMouseUp: function (e) {
|
|
160
|
+
focusInput();
|
|
161
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
|
|
162
|
+
} }));
|
|
163
|
+
};
|
|
150
164
|
var readOnly = !isAutocomplete && !multiple && tags.length >= 1 ? true : undefined;
|
|
151
165
|
var closeMenu = function (e, reason) {
|
|
152
166
|
keepHighlightedIndexRef.current = false;
|
|
@@ -282,8 +296,8 @@ exports.useDownshift = function (_a) {
|
|
|
282
296
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
283
297
|
}, []);
|
|
284
298
|
var getInputProps = function (props) {
|
|
285
|
-
var
|
|
286
|
-
return foundation_1.combineProps(tslib_1.__assign(tslib_1.__assign({},
|
|
299
|
+
var suggestionListInputProps = getSuggestionListInputProps(props);
|
|
300
|
+
return foundation_1.combineProps(tslib_1.__assign(tslib_1.__assign({}, suggestionListInputProps), { onPaste: function (e) {
|
|
287
301
|
var _a;
|
|
288
302
|
if (freeSolo) {
|
|
289
303
|
var clipboardData = e.clipboardData;
|
|
@@ -320,7 +334,12 @@ exports.useDownshift = function (_a) {
|
|
|
320
334
|
stopAutoSelectRef.current = false;
|
|
321
335
|
blurTags();
|
|
322
336
|
}, onBlur: function (e) {
|
|
337
|
+
var _a;
|
|
323
338
|
setInputFocused(false);
|
|
339
|
+
// mouse down suggestion item will change focus,
|
|
340
|
+
// but we don't want to close popper in this case
|
|
341
|
+
if ((_a = popperElementRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget))
|
|
342
|
+
return;
|
|
324
343
|
if (autoSelect && !stopAutoSelectRef.current) {
|
|
325
344
|
if (!freeSolo)
|
|
326
345
|
selectItem(e, optionItems[highlightedIndexRef.current]);
|
|
@@ -532,5 +551,6 @@ exports.useDownshift = function (_a) {
|
|
|
532
551
|
id: downshiftId,
|
|
533
552
|
inputChanged: isInputValueChangedRef.current,
|
|
534
553
|
autoCompleteSelectedIndex: autoCompleteSelectedIndexRef.current,
|
|
554
|
+
popperElementRef: popperElementRef,
|
|
535
555
|
};
|
|
536
556
|
};
|
|
@@ -44,7 +44,7 @@ var _RcTextField = react_1.forwardRef(function (inProps, ref) {
|
|
|
44
44
|
// TODO: remove when remove focusOnMount
|
|
45
45
|
autoFocusProp = _a === void 0 ? focusOnMount : _a, InputPropsProp = props.InputProps, error = props.error, helperText = props.helperText,
|
|
46
46
|
// no need assign to MuiTextField
|
|
47
|
-
defaultValue = props.defaultValue, inputRefProp = props.inputRef, _b = props.autoSelect, autoSelect = _b === void 0 ? selectOnMount : _b, autoFocusDelay = props.autoFocusDelay, clearLabel = props.clearLabel, clearButtonProps = props.clearButtonProps, clearBtn = props.clearBtn, validate = props.validate, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onClear = props.onClear,
|
|
47
|
+
defaultValue = props.defaultValue, inputRefProp = props.inputRef, _b = props.autoSelect, autoSelect = _b === void 0 ? selectOnMount : _b, autoFocusDelay = props.autoFocusDelay, clearLabel = props.clearLabel, clearButtonProps = props.clearButtonProps, clearBtn = props.clearBtn, validate = props.validate, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onClear = props.onClear, idProp = props.id,
|
|
48
48
|
// #region outline pick props
|
|
49
49
|
variant = props.variant, radius = props.radius, size = props.size, align = props.align, textVariant = props.textVariant, gutterBottom = props.gutterBottom, color = props.color,
|
|
50
50
|
// #endregion
|
|
@@ -68,7 +68,7 @@ var _RcTextField = react_1.forwardRef(function (inProps, ref) {
|
|
|
68
68
|
onChange === null || onChange === void 0 ? void 0 : onChange(fakeEvent);
|
|
69
69
|
setValidateMessage('');
|
|
70
70
|
});
|
|
71
|
-
var endAdornment =
|
|
71
|
+
var endAdornment = (function () {
|
|
72
72
|
var getCleanButton = function () {
|
|
73
73
|
var iconTitle = clearLabel || (clearButtonProps === null || clearButtonProps === void 0 ? void 0 : clearButtonProps.title);
|
|
74
74
|
var combineClearProps = foundation_1.combineProps({
|
|
@@ -89,48 +89,32 @@ var _RcTextField = react_1.forwardRef(function (inProps, ref) {
|
|
|
89
89
|
return InputPropsProp.endAdornment;
|
|
90
90
|
}
|
|
91
91
|
return clearBtn ? getCleanButton() : undefined;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onFocus: function () {
|
|
107
|
-
if (validateMessage !== '') {
|
|
108
|
-
setValidateMessage('');
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
}, {
|
|
112
|
-
onBlur: onBlur,
|
|
113
|
-
onFocus: onFocus,
|
|
114
|
-
});
|
|
115
|
-
}, [onBlur, onFocus, runValidate, validateMessage]);
|
|
92
|
+
})();
|
|
93
|
+
var events = foundation_1.combineProps({
|
|
94
|
+
onBlur: function () {
|
|
95
|
+
runValidate();
|
|
96
|
+
},
|
|
97
|
+
onFocus: function () {
|
|
98
|
+
if (validateMessage !== '') {
|
|
99
|
+
setValidateMessage('');
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
}, {
|
|
103
|
+
onBlur: onBlur,
|
|
104
|
+
onFocus: onFocus,
|
|
105
|
+
});
|
|
116
106
|
var classes = react_1.useMemo(function () { return foundation_1.combineClasses(utils_1.RcTextFieldClasses, classesProp); }, [classesProp]);
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var FormHelperTextProps = react_1.useMemo(function () {
|
|
129
|
-
return foundation_1.combineProps({ classes: utils_1.RcTextFieldFormHelperTextClasses }, FormHelperTextPropsProp);
|
|
130
|
-
}, [FormHelperTextPropsProp]);
|
|
131
|
-
var InputLabelProps = react_1.useMemo(function () {
|
|
132
|
-
return foundation_1.combineProps({ classes: utils_1.RcTextFieldInputLabelClasses, shrink: true }, InputLabelPropsProp);
|
|
133
|
-
}, [InputLabelPropsProp]);
|
|
107
|
+
var additionClasses = {
|
|
108
|
+
outline: combineOutlineClasses,
|
|
109
|
+
borderLess: undefined,
|
|
110
|
+
standard: undefined,
|
|
111
|
+
}[variant];
|
|
112
|
+
var InputProps = foundation_1.combineProps({
|
|
113
|
+
classes: additionClasses || utils_1.RcTextFieldInputClasses,
|
|
114
|
+
disableUnderline: ['outline', 'borderLess', 'inline'].includes(variant),
|
|
115
|
+
}, tslib_1.__assign(tslib_1.__assign({}, InputPropsProp), { endAdornment: endAdornment }));
|
|
116
|
+
var FormHelperTextProps = foundation_1.combineProps({ classes: utils_1.RcTextFieldFormHelperTextClasses }, FormHelperTextPropsProp);
|
|
117
|
+
var InputLabelProps = foundation_1.combineProps({ classes: utils_1.RcTextFieldInputLabelClasses, shrink: true }, InputLabelPropsProp);
|
|
134
118
|
react_1.useLayoutEffect(function () {
|
|
135
119
|
var inputElm = innerRef.current;
|
|
136
120
|
var autoFocus = autoFocusProp || (InputPropsProp === null || InputPropsProp === void 0 ? void 0 : InputPropsProp.autoFocus);
|
|
@@ -158,6 +142,8 @@ var _RcTextField = react_1.forwardRef(function (inProps, ref) {
|
|
|
158
142
|
};
|
|
159
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
144
|
}, []);
|
|
145
|
+
// TODO: remove this after upgrade to Mui5
|
|
146
|
+
var id = foundation_1.useId(idProp);
|
|
161
147
|
react_1.useEffect(function () {
|
|
162
148
|
if (id)
|
|
163
149
|
formContext.set(id, { validate: function () { return runValidate(); } });
|
|
@@ -188,7 +188,7 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
188
188
|
onKeyDown: onKeyDownProp,
|
|
189
189
|
disabledItemsHighlightable: disabledItemsHighlightable,
|
|
190
190
|
onGroupExpanded: onGroupExpanded,
|
|
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;
|
|
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, popperElementRef = _10.popperElementRef;
|
|
192
192
|
var open = Boolean((isOpen || noOptionItem) && textFieldRef.current);
|
|
193
193
|
var _11 = getInputProps(), onBlur = _11.onBlur, InputProps = __rest(_11, ["onBlur"]);
|
|
194
194
|
var helperText = isNew
|
|
@@ -303,7 +303,7 @@ var _RcDownshift = memo(forwardRef(function (inProps, ref) {
|
|
|
303
303
|
maxLength: maxLength, containerRef: inputContainerRef }, getInputAriaProps(TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.inputProps)),
|
|
304
304
|
}, rest), { value: inputValue, clearBtn: false })),
|
|
305
305
|
!helperText && screenReaderText && (React.createElement(RcVisuallyHidden, { id: describedbyId }, screenReaderText)),
|
|
306
|
-
React.createElement(StyledPopper, __assign({ open: open, position: position, component: PopperComponent, placement: "bottom-start", anchorEl: anchorElRef.current, "data-test-automation-id": "suggestions-list", popperRef: popperRef, modifiers: { fixOffsets: fixOffsetsModifer },
|
|
306
|
+
React.createElement(StyledPopper, __assign({ ref: popperElementRef, open: open, position: position, component: PopperComponent, placement: "bottom-start", anchorEl: anchorElRef.current, "data-test-automation-id": "suggestions-list", popperRef: popperRef, modifiers: { fixOffsets: fixOffsetsModifer },
|
|
307
307
|
// * view type in popper.js
|
|
308
308
|
popperOptions: {
|
|
309
309
|
onUpdate: function (e) {
|
|
@@ -116,9 +116,6 @@ export var useSuggestionList = function (_a) {
|
|
|
116
116
|
var groupOrder = (currGroup === null || currGroup === void 0 ? void 0 : currGroup.order) || 0;
|
|
117
117
|
return combineProps(__assign({ id: currUniqueId + "-option-" + index, onClick: function (e) {
|
|
118
118
|
selectItem(e, item);
|
|
119
|
-
}, onMouseDown: function (e) {
|
|
120
|
-
e.preventDefault();
|
|
121
|
-
e.stopPropagation();
|
|
122
119
|
}, onMouseOver: function () {
|
|
123
120
|
if (highlightedIndexRef.current !== index &&
|
|
124
121
|
getIsItemCanSelected(item)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator, __read, __spread } from "tslib";
|
|
1
|
+
import { __assign, __awaiter, __generator, __read, __rest, __spread } from "tslib";
|
|
2
2
|
import { useCallback, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
3
3
|
import { combineProps, getSelectionPosition, useChange, useControlled, useId, useSleep, } from '../../../foundation';
|
|
4
4
|
import { useSuggestionList } from '../SuggestionList/utils/useSuggestionList';
|
|
@@ -27,6 +27,7 @@ export var useDownshift = function (_a) {
|
|
|
27
27
|
var stopAutoSelectRef = useRef(false);
|
|
28
28
|
var fromPasteString = useRef('');
|
|
29
29
|
var keepHighlightedIndexRef = useRef(false);
|
|
30
|
+
var popperElementRef = useRef(null);
|
|
30
31
|
var _g = useSleep(), sleep = _g.sleep, getSleeping = _g.getSleeping;
|
|
31
32
|
// * when that is autocomplete, that will never be multiple
|
|
32
33
|
var multiple = isAutocomplete ? false : multipleProp;
|
|
@@ -144,7 +145,20 @@ export var useDownshift = function (_a) {
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
},
|
|
147
|
-
}), inputValue = _j.inputValue, optionItems = _j.optionItems, optionsGroupList = _j.optionsGroupList, highlightedIndexRef = _j.highlightedIndexRef, changeHighlightedIndexReasonRef = _j.changeHighlightedIndexReasonRef, forceUpdate = _j.forceUpdate, selectItem = _j.selectItem, handleF10KeyDown = _j.handleF10KeyDown, onKeyFocusedIndexHandle = _j.onKeyFocusedIndexHandle, setHighlightedIndex = _j.setHighlightedIndex, updateInputValue = _j.updateInputValue, clearInput = _j.clearInput, getNextFocusableOption = _j.getNextFocusableOption,
|
|
148
|
+
}), inputValue = _j.inputValue, optionItems = _j.optionItems, optionsGroupList = _j.optionsGroupList, highlightedIndexRef = _j.highlightedIndexRef, changeHighlightedIndexReasonRef = _j.changeHighlightedIndexReasonRef, forceUpdate = _j.forceUpdate, selectItem = _j.selectItem, handleF10KeyDown = _j.handleF10KeyDown, onKeyFocusedIndexHandle = _j.onKeyFocusedIndexHandle, setHighlightedIndex = _j.setHighlightedIndex, updateInputValue = _j.updateInputValue, clearInput = _j.clearInput, getNextFocusableOption = _j.getNextFocusableOption, getSuggestionListItemProps = _j.getItemProps, focusInput = _j.focusInput, resetSuggestionList = _j.reset, getSuggestionListInputProps = _j.getInputProps, getSuggestionListInputAriaProps = _j.getInputAriaProps, getSuggestionListClearButtonProps = _j.getClearButtonProps, getLabelProps = _j.getLabelProps, getMenuProps = _j.getMenuProps;
|
|
149
|
+
var getItemProps = function (props) {
|
|
150
|
+
var onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, rest = __rest(props, ["onMouseDown", "onMouseUp"]);
|
|
151
|
+
return getSuggestionListItemProps(__assign(__assign({}, rest), { onMouseDown: function (e) {
|
|
152
|
+
// `getPopperProps` will prevent change focus when mouse down popper
|
|
153
|
+
// but suggestion item is an exception.
|
|
154
|
+
// so we need stop propagation to make sure focus can be changed
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e);
|
|
157
|
+
}, onMouseUp: function (e) {
|
|
158
|
+
focusInput();
|
|
159
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
|
|
160
|
+
} }));
|
|
161
|
+
};
|
|
148
162
|
var readOnly = !isAutocomplete && !multiple && tags.length >= 1 ? true : undefined;
|
|
149
163
|
var closeMenu = function (e, reason) {
|
|
150
164
|
keepHighlightedIndexRef.current = false;
|
|
@@ -280,8 +294,8 @@ export var useDownshift = function (_a) {
|
|
|
280
294
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
281
295
|
}, []);
|
|
282
296
|
var getInputProps = function (props) {
|
|
283
|
-
var
|
|
284
|
-
return combineProps(__assign(__assign({},
|
|
297
|
+
var suggestionListInputProps = getSuggestionListInputProps(props);
|
|
298
|
+
return combineProps(__assign(__assign({}, suggestionListInputProps), { onPaste: function (e) {
|
|
285
299
|
var _a;
|
|
286
300
|
if (freeSolo) {
|
|
287
301
|
var clipboardData = e.clipboardData;
|
|
@@ -318,7 +332,12 @@ export var useDownshift = function (_a) {
|
|
|
318
332
|
stopAutoSelectRef.current = false;
|
|
319
333
|
blurTags();
|
|
320
334
|
}, onBlur: function (e) {
|
|
335
|
+
var _a;
|
|
321
336
|
setInputFocused(false);
|
|
337
|
+
// mouse down suggestion item will change focus,
|
|
338
|
+
// but we don't want to close popper in this case
|
|
339
|
+
if ((_a = popperElementRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget))
|
|
340
|
+
return;
|
|
322
341
|
if (autoSelect && !stopAutoSelectRef.current) {
|
|
323
342
|
if (!freeSolo)
|
|
324
343
|
selectItem(e, optionItems[highlightedIndexRef.current]);
|
|
@@ -530,5 +549,6 @@ export var useDownshift = function (_a) {
|
|
|
530
549
|
id: downshiftId,
|
|
531
550
|
inputChanged: isInputValueChangedRef.current,
|
|
532
551
|
autoCompleteSelectedIndex: autoCompleteSelectedIndexRef.current,
|
|
552
|
+
popperElementRef: popperElementRef,
|
|
533
553
|
};
|
|
534
554
|
};
|
|
@@ -2,7 +2,7 @@ import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
|
|
|
2
2
|
import React, { forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
3
3
|
import MuiTextField from '@material-ui/core/TextField';
|
|
4
4
|
import { DeleteCircle } from '@ringcentral/juno-icon';
|
|
5
|
-
import { clearReactReferencesInNode, combineClasses, combineProps, styled, useControlled, useDeprecatedCheck, useEventCallback, useForkRef, useThemeProps, } from '../../../foundation';
|
|
5
|
+
import { clearReactReferencesInNode, combineClasses, combineProps, styled, useControlled, useDeprecatedCheck, useEventCallback, useForkRef, useThemeProps, useId, } from '../../../foundation';
|
|
6
6
|
import { useRcFormContext } from '../Form/Form/FormContext';
|
|
7
7
|
import { ClearIconButton, TextFieldStyle } from './styles';
|
|
8
8
|
import { RcOutlineTextFieldIconSizes, RcOutlineTextFieldInputClasses, RcTextFieldClasses, RcTextFieldFormHelperTextClasses, RcTextFieldInputClasses, RcTextFieldInputLabelClasses, } from './utils';
|
|
@@ -41,7 +41,7 @@ var _RcTextField = forwardRef(function (inProps, ref) {
|
|
|
41
41
|
// TODO: remove when remove focusOnMount
|
|
42
42
|
autoFocusProp = _a === void 0 ? focusOnMount : _a, InputPropsProp = props.InputProps, error = props.error, helperText = props.helperText,
|
|
43
43
|
// no need assign to MuiTextField
|
|
44
|
-
defaultValue = props.defaultValue, inputRefProp = props.inputRef, _b = props.autoSelect, autoSelect = _b === void 0 ? selectOnMount : _b, autoFocusDelay = props.autoFocusDelay, clearLabel = props.clearLabel, clearButtonProps = props.clearButtonProps, clearBtn = props.clearBtn, validate = props.validate, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onClear = props.onClear,
|
|
44
|
+
defaultValue = props.defaultValue, inputRefProp = props.inputRef, _b = props.autoSelect, autoSelect = _b === void 0 ? selectOnMount : _b, autoFocusDelay = props.autoFocusDelay, clearLabel = props.clearLabel, clearButtonProps = props.clearButtonProps, clearBtn = props.clearBtn, validate = props.validate, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onClear = props.onClear, idProp = props.id,
|
|
45
45
|
// #region outline pick props
|
|
46
46
|
variant = props.variant, radius = props.radius, size = props.size, align = props.align, textVariant = props.textVariant, gutterBottom = props.gutterBottom, color = props.color,
|
|
47
47
|
// #endregion
|
|
@@ -65,7 +65,7 @@ var _RcTextField = forwardRef(function (inProps, ref) {
|
|
|
65
65
|
onChange === null || onChange === void 0 ? void 0 : onChange(fakeEvent);
|
|
66
66
|
setValidateMessage('');
|
|
67
67
|
});
|
|
68
|
-
var endAdornment =
|
|
68
|
+
var endAdornment = (function () {
|
|
69
69
|
var getCleanButton = function () {
|
|
70
70
|
var iconTitle = clearLabel || (clearButtonProps === null || clearButtonProps === void 0 ? void 0 : clearButtonProps.title);
|
|
71
71
|
var combineClearProps = combineProps({
|
|
@@ -86,48 +86,32 @@ var _RcTextField = forwardRef(function (inProps, ref) {
|
|
|
86
86
|
return InputPropsProp.endAdornment;
|
|
87
87
|
}
|
|
88
88
|
return clearBtn ? getCleanButton() : undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
onFocus: function () {
|
|
104
|
-
if (validateMessage !== '') {
|
|
105
|
-
setValidateMessage('');
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
}, {
|
|
109
|
-
onBlur: onBlur,
|
|
110
|
-
onFocus: onFocus,
|
|
111
|
-
});
|
|
112
|
-
}, [onBlur, onFocus, runValidate, validateMessage]);
|
|
89
|
+
})();
|
|
90
|
+
var events = combineProps({
|
|
91
|
+
onBlur: function () {
|
|
92
|
+
runValidate();
|
|
93
|
+
},
|
|
94
|
+
onFocus: function () {
|
|
95
|
+
if (validateMessage !== '') {
|
|
96
|
+
setValidateMessage('');
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
}, {
|
|
100
|
+
onBlur: onBlur,
|
|
101
|
+
onFocus: onFocus,
|
|
102
|
+
});
|
|
113
103
|
var classes = useMemo(function () { return combineClasses(RcTextFieldClasses, classesProp); }, [classesProp]);
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var FormHelperTextProps = useMemo(function () {
|
|
126
|
-
return combineProps({ classes: RcTextFieldFormHelperTextClasses }, FormHelperTextPropsProp);
|
|
127
|
-
}, [FormHelperTextPropsProp]);
|
|
128
|
-
var InputLabelProps = useMemo(function () {
|
|
129
|
-
return combineProps({ classes: RcTextFieldInputLabelClasses, shrink: true }, InputLabelPropsProp);
|
|
130
|
-
}, [InputLabelPropsProp]);
|
|
104
|
+
var additionClasses = {
|
|
105
|
+
outline: combineOutlineClasses,
|
|
106
|
+
borderLess: undefined,
|
|
107
|
+
standard: undefined,
|
|
108
|
+
}[variant];
|
|
109
|
+
var InputProps = combineProps({
|
|
110
|
+
classes: additionClasses || RcTextFieldInputClasses,
|
|
111
|
+
disableUnderline: ['outline', 'borderLess', 'inline'].includes(variant),
|
|
112
|
+
}, __assign(__assign({}, InputPropsProp), { endAdornment: endAdornment }));
|
|
113
|
+
var FormHelperTextProps = combineProps({ classes: RcTextFieldFormHelperTextClasses }, FormHelperTextPropsProp);
|
|
114
|
+
var InputLabelProps = combineProps({ classes: RcTextFieldInputLabelClasses, shrink: true }, InputLabelPropsProp);
|
|
131
115
|
useLayoutEffect(function () {
|
|
132
116
|
var inputElm = innerRef.current;
|
|
133
117
|
var autoFocus = autoFocusProp || (InputPropsProp === null || InputPropsProp === void 0 ? void 0 : InputPropsProp.autoFocus);
|
|
@@ -155,6 +139,8 @@ var _RcTextField = forwardRef(function (inProps, ref) {
|
|
|
155
139
|
};
|
|
156
140
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
141
|
}, []);
|
|
142
|
+
// TODO: remove this after upgrade to Mui5
|
|
143
|
+
var id = useId(idProp);
|
|
158
144
|
useEffect(function () {
|
|
159
145
|
if (id)
|
|
160
146
|
formContext.set(id, { validate: function () { return runValidate(); } });
|