@ringcentral/juno 2.23.0 → 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.
@@ -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: ({ item, index, ...itemRest }: import("./useDownshift.interface").RcDownshiftGetItemPropsOptions<T>) => {
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, getItemProps = _j.getItemProps, focusInput = _j.focusInput, resetSuggestionList = _j.reset, getSuggestionListInputProps = _j.getInputProps, getSuggestionListInputAriaProps = _j.getInputAriaProps, getSuggestionListClearButtonProps = _j.getClearButtonProps, getLabelProps = _j.getLabelProps, getMenuProps = _j.getMenuProps;
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 suggestionListItemProps = getSuggestionListInputProps(props);
286
- return foundation_1.combineProps(tslib_1.__assign(tslib_1.__assign({}, suggestionListItemProps), { onPaste: function (e) {
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
  };
@@ -11,10 +11,21 @@ var styles_1 = require("./styles");
11
11
  var utils_1 = require("./utils");
12
12
  var _RcSwitch = react_1.forwardRef(function (inProps, ref) {
13
13
  var props = foundation_1.useThemeProps({ props: inProps, name: 'RcSwitch' });
14
- var label = props.label, _a = props.formControlLabelProps, formControlLabelProps = _a === void 0 ? {} : _a, focusVisibleClassNameProp = props.focusVisibleClassName, classesProp = props.classes, color = props.color, trackColor = props.trackColor, rest = tslib_1.__rest(props, ["label", "formControlLabelProps", "focusVisibleClassName", "classes", "color", "trackColor"]);
14
+ var label = props.label, _a = props.formControlLabelProps, formControlLabelProps = _a === void 0 ? {} : _a, focusVisibleClassNameProp = props.focusVisibleClassName, classesProp = props.classes, color = props.color, trackColor = props.trackColor, _b = props.inputRef, inputRefProp = _b === void 0 ? null : _b, onFocus = props.onFocus, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["label", "formControlLabelProps", "focusVisibleClassName", "classes", "color", "trackColor", "inputRef", "onFocus", "onBlur"]);
15
15
  var classes = react_1.useMemo(function () { return foundation_1.combineClasses(foundation_1.omit(utils_1.RcSwitchClasses, ['focusVisible']), classesProp); }, [classesProp]);
16
16
  var focusVisibleClassName = react_1.useMemo(function () { return clsx_1.default(utils_1.RcSwitchClasses.focusVisible, focusVisibleClassNameProp); }, [focusVisibleClassNameProp]);
17
- var Switch = (react_1.default.createElement(Switch_1.default, tslib_1.__assign({ ref: ref, focusVisibleClassName: focusVisibleClassName, classes: classes }, rest, { color: "default", size: "medium", disableRipple: true, disableTouchRipple: true })));
17
+ var inputRef = react_1.useRef(null);
18
+ var handleInputRef = foundation_1.useForkRef(inputRef, inputRefProp);
19
+ var Switch = (react_1.default.createElement(Switch_1.default, tslib_1.__assign({ ref: ref, inputRef: handleInputRef, focusVisibleClassName: focusVisibleClassName, classes: classes }, rest, { color: "default", size: "medium", disableRipple: true, disableTouchRipple: true, onFocus: function (e) {
20
+ var _a;
21
+ if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.matches('[data-focus-visible-added]')) {
22
+ e.currentTarget.parentElement.setAttribute('data-focus-visible-within', '');
23
+ }
24
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
25
+ }, onBlur: function (e) {
26
+ e.currentTarget.parentElement.removeAttribute('data-focus-visible-within');
27
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
28
+ } })));
18
29
  if (label) {
19
30
  return (react_1.default.createElement(FormControlLabel_1.RcFormControlLabel, tslib_1.__assign({}, formControlLabelProps, { label: label, control: Switch })));
20
31
  }
@@ -14,6 +14,6 @@ exports.SwitchStyle = function (_a) {
14
14
  var colorProp = _a.color, trackColorProp = _a.trackColor;
15
15
  var checkedColor = foundation_1.getParsePaletteColor(colorProp);
16
16
  var trackColor = foundation_1.getParsePaletteColor(trackColorProp, defaultTrackColorArray);
17
- return foundation_1.css(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n &.", " {\n /* make sure focus ring can show correctly */\n overflow: visible;\n padding: 0px;\n ", ";\n ", ";\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n ", "\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "], ["\n &.", " {\n /* make sure focus ring can show correctly */\n overflow: visible;\n padding: 0px;\n ", ";\n ", ";\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n ", "\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "])), utils_1.RcSwitchClasses.root, widthCss, heightCss, utils_1.RcSwitchClasses.switchBase, widthCss, heightCss, foundation_1.spacing(-2), utils_1.RcSwitchClasses.checked, foundation_1.spacing(2), utils_1.RcSwitchClasses.thumb, thumbSize, thumbColor, utils_1.RcSwitchClasses.track, heightCss, foundation_1.radius('round'), trackColor, utils_1.RcSwitchClasses.checked, utils_1.RcSwitchClasses.track, checkedColor, utils_1.RcSwitchClasses.disabled, utils_1.RcSwitchClasses.track, disabledColor, utils_1.RcSwitchClasses.focusVisible, utils_1.RcSwitchClasses.track, foundation_1.focusRing('normal'), foundation_1.nonTouchHoverMedia, notDisabledSwitchBase('08', checkedColor, trackColor), notDisabledSwitchBase('24', checkedColor, trackColor));
17
+ return foundation_1.css(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n &.", " {\n padding: 0px;\n ", ";\n ", ";\n\n &[data-focus-visible-within] {\n border-radius: 100vw;\n ", "\n }\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "], ["\n &.", " {\n padding: 0px;\n ", ";\n ", ";\n\n &[data-focus-visible-within] {\n border-radius: 100vw;\n ", "\n }\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "])), utils_1.RcSwitchClasses.root, widthCss, heightCss, foundation_1.focusRing('normal'), utils_1.RcSwitchClasses.switchBase, widthCss, heightCss, foundation_1.spacing(-2), utils_1.RcSwitchClasses.checked, foundation_1.spacing(2), utils_1.RcSwitchClasses.thumb, thumbSize, thumbColor, utils_1.RcSwitchClasses.track, heightCss, foundation_1.radius('round'), trackColor, utils_1.RcSwitchClasses.checked, utils_1.RcSwitchClasses.track, checkedColor, utils_1.RcSwitchClasses.disabled, utils_1.RcSwitchClasses.track, disabledColor, foundation_1.nonTouchHoverMedia, notDisabledSwitchBase('08', checkedColor, trackColor), notDisabledSwitchBase('24', checkedColor, trackColor));
18
18
  };
19
19
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -1,12 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var foundation_1 = require("../../../../foundation");
4
- exports.RcSwitchClasses = foundation_1.RcClasses([
5
- 'root',
6
- 'switchBase',
7
- 'thumb',
8
- 'track',
9
- 'checked',
10
- 'disabled',
11
- 'focusVisible',
12
- ], 'RcSwitch');
4
+ exports.RcSwitchClasses = foundation_1.RcClasses(['root', 'switchBase', 'thumb', 'track', 'checked', 'disabled'], 'RcSwitch');
@@ -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, id = props.id,
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 = react_1.useMemo(function () {
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
- InputPropsProp,
94
- clearAriaLabel,
95
- clearBtn,
96
- clearButtonProps,
97
- clearLabel,
98
- handleClear,
99
- size,
100
- ]);
101
- var events = react_1.useMemo(function () {
102
- return foundation_1.combineProps({
103
- onBlur: function () {
104
- runValidate();
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 InputProps = react_1.useMemo(function () {
118
- var curr = {
119
- outline: combineOutlineClasses,
120
- borderLess: undefined,
121
- standard: undefined,
122
- }[variant];
123
- return foundation_1.combineProps({
124
- classes: curr || utils_1.RcTextFieldInputClasses,
125
- disableUnderline: ['outline', 'borderLess', 'inline'].includes(variant),
126
- }, tslib_1.__assign(tslib_1.__assign({}, InputPropsProp), { endAdornment: endAdornment }));
127
- }, [InputPropsProp, endAdornment, variant]);
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, getItemProps = _j.getItemProps, focusInput = _j.focusInput, resetSuggestionList = _j.reset, getSuggestionListInputProps = _j.getInputProps, getSuggestionListInputAriaProps = _j.getInputAriaProps, getSuggestionListClearButtonProps = _j.getClearButtonProps, getLabelProps = _j.getLabelProps, getMenuProps = _j.getMenuProps;
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 suggestionListItemProps = getSuggestionListInputProps(props);
284
- return combineProps(__assign(__assign({}, suggestionListItemProps), { onPaste: function (e) {
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
  };
@@ -1,18 +1,29 @@
1
1
  import { __assign, __makeTemplateObject, __rest } from "tslib";
2
- import React, { forwardRef, useMemo } from 'react';
2
+ import React, { forwardRef, useMemo, useRef } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import MuiSwitch from '@material-ui/core/Switch';
5
- import { combineClasses, omit, useThemeProps, } from '../../../foundation';
5
+ import { combineClasses, omit, useThemeProps, useForkRef, } from '../../../foundation';
6
6
  import styled from '../../../foundation/styled-components';
7
7
  import { RcFormControlLabel } from '../FormControlLabel';
8
8
  import { SwitchStyle } from './styles';
9
9
  import { RcSwitchClasses } from './utils';
10
10
  var _RcSwitch = forwardRef(function (inProps, ref) {
11
11
  var props = useThemeProps({ props: inProps, name: 'RcSwitch' });
12
- var label = props.label, _a = props.formControlLabelProps, formControlLabelProps = _a === void 0 ? {} : _a, focusVisibleClassNameProp = props.focusVisibleClassName, classesProp = props.classes, color = props.color, trackColor = props.trackColor, rest = __rest(props, ["label", "formControlLabelProps", "focusVisibleClassName", "classes", "color", "trackColor"]);
12
+ var label = props.label, _a = props.formControlLabelProps, formControlLabelProps = _a === void 0 ? {} : _a, focusVisibleClassNameProp = props.focusVisibleClassName, classesProp = props.classes, color = props.color, trackColor = props.trackColor, _b = props.inputRef, inputRefProp = _b === void 0 ? null : _b, onFocus = props.onFocus, onBlur = props.onBlur, rest = __rest(props, ["label", "formControlLabelProps", "focusVisibleClassName", "classes", "color", "trackColor", "inputRef", "onFocus", "onBlur"]);
13
13
  var classes = useMemo(function () { return combineClasses(omit(RcSwitchClasses, ['focusVisible']), classesProp); }, [classesProp]);
14
14
  var focusVisibleClassName = useMemo(function () { return clsx(RcSwitchClasses.focusVisible, focusVisibleClassNameProp); }, [focusVisibleClassNameProp]);
15
- var Switch = (React.createElement(MuiSwitch, __assign({ ref: ref, focusVisibleClassName: focusVisibleClassName, classes: classes }, rest, { color: "default", size: "medium", disableRipple: true, disableTouchRipple: true })));
15
+ var inputRef = useRef(null);
16
+ var handleInputRef = useForkRef(inputRef, inputRefProp);
17
+ var Switch = (React.createElement(MuiSwitch, __assign({ ref: ref, inputRef: handleInputRef, focusVisibleClassName: focusVisibleClassName, classes: classes }, rest, { color: "default", size: "medium", disableRipple: true, disableTouchRipple: true, onFocus: function (e) {
18
+ var _a;
19
+ if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.matches('[data-focus-visible-added]')) {
20
+ e.currentTarget.parentElement.setAttribute('data-focus-visible-within', '');
21
+ }
22
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
23
+ }, onBlur: function (e) {
24
+ e.currentTarget.parentElement.removeAttribute('data-focus-visible-within');
25
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
26
+ } })));
16
27
  if (label) {
17
28
  return (React.createElement(RcFormControlLabel, __assign({}, formControlLabelProps, { label: label, control: Switch })));
18
29
  }
@@ -12,6 +12,6 @@ export var SwitchStyle = function (_a) {
12
12
  var colorProp = _a.color, trackColorProp = _a.trackColor;
13
13
  var checkedColor = getParsePaletteColor(colorProp);
14
14
  var trackColor = getParsePaletteColor(trackColorProp, defaultTrackColorArray);
15
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n &.", " {\n /* make sure focus ring can show correctly */\n overflow: visible;\n padding: 0px;\n ", ";\n ", ";\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n ", "\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "], ["\n &.", " {\n /* make sure focus ring can show correctly */\n overflow: visible;\n padding: 0px;\n ", ";\n ", ";\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n ", "\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "])), RcSwitchClasses.root, widthCss, heightCss, RcSwitchClasses.switchBase, widthCss, heightCss, spacing(-2), RcSwitchClasses.checked, spacing(2), RcSwitchClasses.thumb, thumbSize, thumbColor, RcSwitchClasses.track, heightCss, radius('round'), trackColor, RcSwitchClasses.checked, RcSwitchClasses.track, checkedColor, RcSwitchClasses.disabled, RcSwitchClasses.track, disabledColor, RcSwitchClasses.focusVisible, RcSwitchClasses.track, focusRing('normal'), nonTouchHoverMedia, notDisabledSwitchBase('08', checkedColor, trackColor), notDisabledSwitchBase('24', checkedColor, trackColor));
15
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n &.", " {\n padding: 0px;\n ", ";\n ", ";\n\n &[data-focus-visible-within] {\n border-radius: 100vw;\n ", "\n }\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "], ["\n &.", " {\n padding: 0px;\n ", ";\n ", ";\n\n &[data-focus-visible-within] {\n border-radius: 100vw;\n ", "\n }\n\n .", " {\n ", ";\n ", ";\n padding: 0;\n background-color: transparent;\n transform: translateX(", ");\n\n &.", " {\n transform: translateX(", ");\n }\n }\n\n .", " {\n ", ";\n background-color: ", ";\n box-shadow: none;\n }\n\n .", " {\n ", ";\n opacity: 1;\n margin: 0;\n border-radius: ", ";\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n .", " + .", " {\n background-color: ", ";\n }\n\n ", " {\n &:hover {\n ", ";\n }\n }\n\n &:active {\n ", ";\n }\n }\n "])), RcSwitchClasses.root, widthCss, heightCss, focusRing('normal'), RcSwitchClasses.switchBase, widthCss, heightCss, spacing(-2), RcSwitchClasses.checked, spacing(2), RcSwitchClasses.thumb, thumbSize, thumbColor, RcSwitchClasses.track, heightCss, radius('round'), trackColor, RcSwitchClasses.checked, RcSwitchClasses.track, checkedColor, RcSwitchClasses.disabled, RcSwitchClasses.track, disabledColor, nonTouchHoverMedia, notDisabledSwitchBase('08', checkedColor, trackColor), notDisabledSwitchBase('24', checkedColor, trackColor));
16
16
  };
17
17
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -1,10 +1,2 @@
1
1
  import { RcClasses } from '../../../../foundation';
2
- export var RcSwitchClasses = RcClasses([
3
- 'root',
4
- 'switchBase',
5
- 'thumb',
6
- 'track',
7
- 'checked',
8
- 'disabled',
9
- 'focusVisible',
10
- ], 'RcSwitch');
2
+ export var RcSwitchClasses = RcClasses(['root', 'switchBase', 'thumb', 'track', 'checked', 'disabled'], 'RcSwitch');
@@ -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, id = props.id,
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 = useMemo(function () {
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
- InputPropsProp,
91
- clearAriaLabel,
92
- clearBtn,
93
- clearButtonProps,
94
- clearLabel,
95
- handleClear,
96
- size,
97
- ]);
98
- var events = useMemo(function () {
99
- return combineProps({
100
- onBlur: function () {
101
- runValidate();
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 InputProps = useMemo(function () {
115
- var curr = {
116
- outline: combineOutlineClasses,
117
- borderLess: undefined,
118
- standard: undefined,
119
- }[variant];
120
- return combineProps({
121
- classes: curr || RcTextFieldInputClasses,
122
- disableUnderline: ['outline', 'borderLess', 'inline'].includes(variant),
123
- }, __assign(__assign({}, InputPropsProp), { endAdornment: endAdornment }));
124
- }, [InputPropsProp, endAdornment, variant]);
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(); } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",