@true-engineering/true-react-common-ui-kit 4.0.0-alpha75 → 4.0.0-alpha76
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/dist/components/Select/Select.d.ts +7 -4
- package/dist/components/Select/Select.styles.d.ts +4 -1
- package/dist/components/Select/types.d.ts +17 -0
- package/dist/components/WithPopup/WithPopup.d.ts +4 -2
- package/dist/helpers/misc.d.ts +0 -1
- package/dist/true-react-common-ui-kit.js +200 -234
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.ts +2 -1
- package/src/components/Select/CustomSelect.stories.tsx +0 -14
- package/src/components/Select/MultiSelect.stories.tsx +5 -16
- package/src/components/Select/Select.stories.tsx +5 -16
- package/src/components/Select/Select.styles.ts +8 -19
- package/src/components/Select/Select.tsx +203 -231
- package/src/components/Select/components/SelectList/SelectList.styles.ts +1 -0
- package/src/components/Select/types.ts +18 -0
- package/src/components/WithPopup/WithPopup.tsx +18 -5
- package/src/helpers/misc.ts +0 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo, useRef, useEffect, memo, useLayoutEffect, useCallback, useState, Fragment as Fragment$1, forwardRef, PureComponent, createRef, createElement } from "react";
|
|
2
2
|
import { createUseStyles } from "react-jss";
|
|
3
|
-
import { isObject, isString, isNotEmpty, isArrayNotEmpty, mergeStyles, isStringEmpty, isStringNotEmpty, mergeRefs, isFunction, isEmpty, addDataAttributes as addDataAttributes$1,
|
|
3
|
+
import { isObject, isString, isNotEmpty, isArrayNotEmpty, mergeStyles, isStringEmpty, isStringNotEmpty, mergeRefs, isFunction, isEmpty, addDataAttributes as addDataAttributes$1, applyAction, stopPropagation, isReactNodeNotEmpty, addClickHandler, getTestId, getSelectKeyHandler, addDataTestId, getArray, isArrayLikeNotEmpty, doNothing, createFilter, indexMap, merge, getTransition, isNumberInteger, isArrayEmpty } from "@true-engineering/true-react-platform-helpers";
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { CSSTransition } from "react-transition-group";
|
|
6
6
|
import clsx from "clsx";
|
|
@@ -12,11 +12,11 @@ import InputMask from "react-input-mask";
|
|
|
12
12
|
import "react-datepicker/dist/react-datepicker.css";
|
|
13
13
|
import { getYear, getMonth, format, parse, isSameDay, isValid, isAfter, isBefore, sub, endOfYear, startOfYear, endOfMonth, startOfMonth } from "date-fns";
|
|
14
14
|
import ReactDatePicker from "react-datepicker";
|
|
15
|
-
import { Portal } from "react-overlays";
|
|
16
15
|
import { debounce } from "ts-debounce";
|
|
17
16
|
import scrollIntoViewIfNeeded from "scroll-into-view-if-needed";
|
|
18
17
|
import { enUS, ru } from "date-fns/locale";
|
|
19
18
|
import { filesize } from "filesize";
|
|
19
|
+
import { Portal } from "react-overlays";
|
|
20
20
|
import { hasFlag } from "country-flag-icons";
|
|
21
21
|
import * as Flags from "country-flag-icons/react/3x2";
|
|
22
22
|
import { RemoveScroll } from "react-remove-scroll";
|
|
@@ -2522,16 +2522,6 @@ const transformToKebab = (string) => {
|
|
|
2522
2522
|
return result;
|
|
2523
2523
|
};
|
|
2524
2524
|
const getParentNode = (element) => element.nodeName === "HTML" || element === document ? element : element.parentNode ?? element.host;
|
|
2525
|
-
const hasExactParent = (element, parent) => {
|
|
2526
|
-
if (element === parent) {
|
|
2527
|
-
return true;
|
|
2528
|
-
}
|
|
2529
|
-
const parentNode = getParentNode(element);
|
|
2530
|
-
if (parentNode === element) {
|
|
2531
|
-
return false;
|
|
2532
|
-
}
|
|
2533
|
-
return hasExactParent(parentNode, parent);
|
|
2534
|
-
};
|
|
2535
2525
|
const getStyleComputedProperty = (element) => element.nodeType !== 1 ? {} : getComputedStyle(element, null);
|
|
2536
2526
|
const getScrollParent = (element) => {
|
|
2537
2527
|
if (!element) {
|
|
@@ -2999,6 +2989,7 @@ const useStyles$X = createThemedStyles("WithPopup", {
|
|
|
2999
2989
|
const WithPopup = ({
|
|
3000
2990
|
trigger,
|
|
3001
2991
|
children,
|
|
2992
|
+
state,
|
|
3002
2993
|
middlewares = [],
|
|
3003
2994
|
eventType = "click",
|
|
3004
2995
|
placement = eventType === "click" ? "bottom-end" : "top",
|
|
@@ -3014,6 +3005,7 @@ const WithPopup = ({
|
|
|
3014
3005
|
isDisabled = false,
|
|
3015
3006
|
shouldShowArrow = false,
|
|
3016
3007
|
isMinWidthSameAsTrigger = false,
|
|
3008
|
+
flipOptions,
|
|
3017
3009
|
hoverOptions,
|
|
3018
3010
|
clickOptions,
|
|
3019
3011
|
focusOptions,
|
|
@@ -3025,13 +3017,16 @@ const WithPopup = ({
|
|
|
3025
3017
|
onToggle
|
|
3026
3018
|
}) => {
|
|
3027
3019
|
const classes = useStyles$X({ theme: tweakStyles });
|
|
3028
|
-
const
|
|
3020
|
+
const innerState = useState(false);
|
|
3021
|
+
const [isOpen, setIsOpen] = state ?? innerState;
|
|
3029
3022
|
const isActive = isOpen && !isDisabled;
|
|
3030
3023
|
const arrowRef = useRef(null);
|
|
3031
3024
|
const handleToggle = (next, event) => {
|
|
3032
3025
|
event?.stopPropagation();
|
|
3033
|
-
|
|
3034
|
-
|
|
3026
|
+
if (isOpen !== next) {
|
|
3027
|
+
onToggle?.(next, event);
|
|
3028
|
+
setIsOpen(next);
|
|
3029
|
+
}
|
|
3035
3030
|
};
|
|
3036
3031
|
const handleClose = (event) => {
|
|
3037
3032
|
handleToggle(false, event);
|
|
@@ -3040,7 +3035,10 @@ const WithPopup = ({
|
|
|
3040
3035
|
open: isActive,
|
|
3041
3036
|
middleware: [
|
|
3042
3037
|
offset(popupOffset),
|
|
3043
|
-
canBeFlipped && flip(
|
|
3038
|
+
canBeFlipped && flip((middlewareState) => ({
|
|
3039
|
+
fallbackAxisSideDirection: "start",
|
|
3040
|
+
...applyAction(flipOptions, middlewareState)
|
|
3041
|
+
})),
|
|
3044
3042
|
isMinWidthSameAsTrigger && minWidthRelativeToTrigger,
|
|
3045
3043
|
...middlewares,
|
|
3046
3044
|
shouldShowArrow && arrow({ element: arrowRef })
|
|
@@ -3219,7 +3217,7 @@ const useStyles$V = createThemedStyles("List", {
|
|
|
3219
3217
|
paddingLeft: 4
|
|
3220
3218
|
}
|
|
3221
3219
|
});
|
|
3222
|
-
const withPopupStyles$
|
|
3220
|
+
const withPopupStyles$2 = {
|
|
3223
3221
|
trigger: {
|
|
3224
3222
|
width: "100%"
|
|
3225
3223
|
}
|
|
@@ -3251,7 +3249,7 @@ const List = ({ items, size: size2, testId, data, tweakStyles, onClick }) => {
|
|
|
3251
3249
|
WithPopup,
|
|
3252
3250
|
{
|
|
3253
3251
|
eventType: "hover",
|
|
3254
|
-
tweakStyles: withPopupStyles$
|
|
3252
|
+
tweakStyles: withPopupStyles$2,
|
|
3255
3253
|
placement: "right-start",
|
|
3256
3254
|
popupOffset: 0,
|
|
3257
3255
|
shouldRenderInBody: false,
|
|
@@ -4619,7 +4617,7 @@ class ScrollIntoViewIfNeeded extends PureComponent {
|
|
|
4619
4617
|
componentDidMount() {
|
|
4620
4618
|
const { active } = this.props;
|
|
4621
4619
|
if (active) {
|
|
4622
|
-
this.handleScrollIntoViewIfNeeded
|
|
4620
|
+
requestAnimationFrame(this.handleScrollIntoViewIfNeeded);
|
|
4623
4621
|
}
|
|
4624
4622
|
}
|
|
4625
4623
|
componentDidUpdate({ active }) {
|
|
@@ -4656,7 +4654,8 @@ const useStyles$H = createThemedStyles("SelectList", {
|
|
|
4656
4654
|
boxSizing: "border-box",
|
|
4657
4655
|
padding: [CONTAINER_PADDING, 0],
|
|
4658
4656
|
fontSize: 16,
|
|
4659
|
-
overflow: "hidden"
|
|
4657
|
+
overflow: "hidden",
|
|
4658
|
+
cursor: "default"
|
|
4660
4659
|
},
|
|
4661
4660
|
withListHeader: {
|
|
4662
4661
|
paddingTop: 0
|
|
@@ -4879,22 +4878,6 @@ const useStyles$G = createThemedStyles("Select", {
|
|
|
4879
4878
|
width: "100%",
|
|
4880
4879
|
cursor: "text"
|
|
4881
4880
|
},
|
|
4882
|
-
listWrapper: {
|
|
4883
|
-
left: -1,
|
|
4884
|
-
zIndex: 3,
|
|
4885
|
-
width: "fit-content",
|
|
4886
|
-
minWidth: "calc(100% + 1px)"
|
|
4887
|
-
},
|
|
4888
|
-
withoutPopper: {
|
|
4889
|
-
position: "absolute",
|
|
4890
|
-
top: "100%",
|
|
4891
|
-
paddingTop: 4
|
|
4892
|
-
},
|
|
4893
|
-
listWrapperInBody: {
|
|
4894
|
-
minWidth: "auto",
|
|
4895
|
-
width: "auto",
|
|
4896
|
-
maxWidth: "min-content"
|
|
4897
|
-
},
|
|
4898
4881
|
arrow: {
|
|
4899
4882
|
width: "var(--icon-inner-size, 20px)",
|
|
4900
4883
|
height: "var(--icon-inner-size, 20px)",
|
|
@@ -4939,6 +4922,11 @@ const getInputStyles = ({
|
|
|
4939
4922
|
}
|
|
4940
4923
|
return baseInputStyles;
|
|
4941
4924
|
};
|
|
4925
|
+
const withPopupStyles$1 = {
|
|
4926
|
+
popup: {
|
|
4927
|
+
maxWidth: "min-content"
|
|
4928
|
+
}
|
|
4929
|
+
};
|
|
4942
4930
|
function Select(props) {
|
|
4943
4931
|
const {
|
|
4944
4932
|
options,
|
|
@@ -4969,6 +4957,7 @@ function Select(props) {
|
|
|
4969
4957
|
onBlur,
|
|
4970
4958
|
onType,
|
|
4971
4959
|
onOpen,
|
|
4960
|
+
onClose,
|
|
4972
4961
|
isOptionDisabled = defaultIsOptionDisabled,
|
|
4973
4962
|
compareValuesOnChange = defaultCompareFunction,
|
|
4974
4963
|
convertValueToString = defaultConvertFunction$2,
|
|
@@ -5005,16 +4994,20 @@ function Select(props) {
|
|
|
5005
4994
|
className: "tweakSelectList",
|
|
5006
4995
|
currentComponentName: "Select"
|
|
5007
4996
|
});
|
|
4997
|
+
const tweakWithPopupStyles = useTweakStyles({
|
|
4998
|
+
innerStyles: withPopupStyles$1,
|
|
4999
|
+
tweakStyles,
|
|
5000
|
+
className: "tweakWithPopup",
|
|
5001
|
+
currentComponentName: "WithTooltip"
|
|
5002
|
+
});
|
|
5008
5003
|
const isMounted = useIsMounted();
|
|
5009
|
-
const
|
|
5004
|
+
const isDropdownOpenState = useState(false);
|
|
5005
|
+
const [isDropdownOpen, setIsDropdownOpen] = isDropdownOpenState;
|
|
5010
5006
|
const [areOptionsLoading, setAreOptionsLoading] = useState(false);
|
|
5011
5007
|
const hasDefaultOption = isReactNodeNotEmpty(defaultOptionLabel);
|
|
5012
5008
|
const [focusedListCellIndex, setFocusedListCellIndex] = useState(DEFAULT_OPTION_INDEX);
|
|
5013
5009
|
const [searchValue, setSearchValue] = useState("");
|
|
5014
5010
|
const [shouldShowDefaultOption, setShouldShowDefaultOption] = useState(true);
|
|
5015
|
-
const root = useRef(null);
|
|
5016
|
-
const inputWrapper = useRef(null);
|
|
5017
|
-
const list = useRef(null);
|
|
5018
5011
|
const input = useRef(null);
|
|
5019
5012
|
const strValue = isMultiSelect ? value?.[0] : value;
|
|
5020
5013
|
const shouldShowAllOption = isMultiSelect && isStringNotEmpty(allOptionsLabel) && searchValue === "";
|
|
@@ -5056,80 +5049,64 @@ function Select(props) {
|
|
|
5056
5049
|
]);
|
|
5057
5050
|
const stringValue = isNotEmpty(strValue) ? convertValueToString(strValue) : void 0;
|
|
5058
5051
|
const showedStringValue = areAllOptionsSelected && isNotEmpty(allOptionsLabel) ? allOptionsLabel : stringValue;
|
|
5052
|
+
const hasEnoughSymbolsToSearch = searchValue.trim().length >= minSymbolsCountToOpenList;
|
|
5053
|
+
const hasContentInDropdown = (
|
|
5054
|
+
// Есть опции
|
|
5055
|
+
(filteredOptions.length > 0 || // Дефолтная опция
|
|
5056
|
+
defaultOptionLabel !== void 0 && !hasEnoughSymbolsToSearch || // Текст "Загрузка..."
|
|
5057
|
+
inputProps.isLoading || // Текст "Совпадений не найдено"
|
|
5058
|
+
noMatchesLabel !== void 0 || // У нас есть инпут с поиском внутри листа
|
|
5059
|
+
hasSearchInputInList) && // Последняя проверка на случай, если мы че то ищем в опциях
|
|
5060
|
+
(optionsMode === "normal" || hasEnoughSymbolsToSearch)
|
|
5061
|
+
);
|
|
5062
|
+
const isDropdownDisabled = isDisabled || isReadonly || !hasContentInDropdown;
|
|
5063
|
+
const isDropdownActive = isDropdownOpen && !isDropdownDisabled;
|
|
5059
5064
|
const convertToId = useCallback(
|
|
5060
5065
|
(v) => (convertValueToId ?? getDefaultConvertToIdFunction(convertValueToString))(v),
|
|
5061
5066
|
[convertValueToId, convertValueToString]
|
|
5062
5067
|
);
|
|
5063
|
-
const
|
|
5064
|
-
setIsListOpen(false);
|
|
5068
|
+
const reset = () => {
|
|
5065
5069
|
setSearchValue("");
|
|
5066
5070
|
setShouldShowDefaultOption(true);
|
|
5067
|
-
}
|
|
5068
|
-
const
|
|
5069
|
-
(
|
|
5070
|
-
|
|
5071
|
-
return;
|
|
5072
|
-
}
|
|
5073
|
-
closeList();
|
|
5074
|
-
onBlur?.(event);
|
|
5075
|
-
},
|
|
5076
|
-
[isListOpen, closeList, onBlur]
|
|
5077
|
-
);
|
|
5078
|
-
const handleListOpen = () => {
|
|
5079
|
-
if (!isReadonly && !isListOpen) {
|
|
5080
|
-
setIsListOpen(true);
|
|
5071
|
+
};
|
|
5072
|
+
const handleChange = (newValue, event) => {
|
|
5073
|
+
if (!compareValuesOnChange(value, newValue)) {
|
|
5074
|
+
onChange(newValue, event);
|
|
5081
5075
|
}
|
|
5082
5076
|
};
|
|
5083
|
-
const
|
|
5084
|
-
|
|
5085
|
-
|
|
5077
|
+
const handleOptionSelect = (index, event) => {
|
|
5078
|
+
if (!isMultiSelect) {
|
|
5079
|
+
setIsDropdownOpen(false);
|
|
5080
|
+
event.stopPropagation();
|
|
5081
|
+
}
|
|
5082
|
+
handleChange(index === DEFAULT_OPTION_INDEX ? void 0 : filteredOptions[index], event);
|
|
5083
|
+
reset();
|
|
5084
|
+
input.current?.blur();
|
|
5086
5085
|
};
|
|
5087
|
-
const
|
|
5088
|
-
|
|
5086
|
+
const handleToggleOptionCheckbox = (index, isSelected, event) => {
|
|
5087
|
+
if (!isMultiSelect) {
|
|
5088
|
+
return;
|
|
5089
|
+
}
|
|
5090
|
+
if (index === DEFAULT_OPTION_INDEX || index === ALL_OPTION_INDEX && !isSelected) {
|
|
5091
|
+
handleChange(void 0, event);
|
|
5092
|
+
return;
|
|
5093
|
+
}
|
|
5094
|
+
if (index === ALL_OPTION_INDEX && isSelected) {
|
|
5095
|
+
handleChange(availableOptions, event);
|
|
5096
|
+
return;
|
|
5097
|
+
}
|
|
5098
|
+
const option = filteredOptions[index];
|
|
5099
|
+
handleChange(
|
|
5100
|
+
isSelected ? (
|
|
5101
|
+
// Добавляем
|
|
5102
|
+
[...value ?? [], option]
|
|
5103
|
+
) : (
|
|
5104
|
+
// Убираем
|
|
5105
|
+
value?.filter((o) => convertToId(o) !== convertToId(option))
|
|
5106
|
+
),
|
|
5107
|
+
event
|
|
5108
|
+
);
|
|
5089
5109
|
};
|
|
5090
|
-
const handleChange = useCallback(
|
|
5091
|
-
(newValue, event) => {
|
|
5092
|
-
if (!compareValuesOnChange(value, newValue)) {
|
|
5093
|
-
onChange(newValue, event);
|
|
5094
|
-
}
|
|
5095
|
-
},
|
|
5096
|
-
[value, compareValuesOnChange, onChange]
|
|
5097
|
-
);
|
|
5098
|
-
const handleOptionSelect = useCallback(
|
|
5099
|
-
(index, event) => {
|
|
5100
|
-
handleChange(index === DEFAULT_OPTION_INDEX ? void 0 : filteredOptions[index], event);
|
|
5101
|
-
handleListClose(event);
|
|
5102
|
-
input.current?.blur();
|
|
5103
|
-
},
|
|
5104
|
-
[handleChange, handleListClose, filteredOptions]
|
|
5105
|
-
);
|
|
5106
|
-
const handleToggleOptionCheckbox = useCallback(
|
|
5107
|
-
(index, isSelected, event) => {
|
|
5108
|
-
if (!isMultiSelect) {
|
|
5109
|
-
return;
|
|
5110
|
-
}
|
|
5111
|
-
if (index === DEFAULT_OPTION_INDEX || index === ALL_OPTION_INDEX && !isSelected) {
|
|
5112
|
-
handleChange(void 0, event);
|
|
5113
|
-
return;
|
|
5114
|
-
}
|
|
5115
|
-
if (index === ALL_OPTION_INDEX && isSelected) {
|
|
5116
|
-
handleChange(availableOptions, event);
|
|
5117
|
-
return;
|
|
5118
|
-
}
|
|
5119
|
-
const option = filteredOptions[index];
|
|
5120
|
-
handleChange(
|
|
5121
|
-
isSelected ? (
|
|
5122
|
-
// Добавляем
|
|
5123
|
-
[...value ?? [], option]
|
|
5124
|
-
) : (
|
|
5125
|
-
// Убираем
|
|
5126
|
-
value?.filter((o) => convertToId(o) !== convertToId(option))
|
|
5127
|
-
),
|
|
5128
|
-
event
|
|
5129
|
-
);
|
|
5130
|
-
},
|
|
5131
|
-
[isMultiSelect, filteredOptions, handleChange, value, availableOptions, convertToId]
|
|
5132
|
-
);
|
|
5133
5110
|
const handleOnType = useCallback(
|
|
5134
5111
|
async (v) => {
|
|
5135
5112
|
if (onType === void 0) {
|
|
@@ -5165,7 +5142,7 @@ function Select(props) {
|
|
|
5165
5142
|
setSearchValue(v);
|
|
5166
5143
|
};
|
|
5167
5144
|
const handleKeyDown = (event) => {
|
|
5168
|
-
if (!
|
|
5145
|
+
if (!isDropdownActive) {
|
|
5169
5146
|
return;
|
|
5170
5147
|
}
|
|
5171
5148
|
event.stopPropagation();
|
|
@@ -5173,6 +5150,10 @@ function Select(props) {
|
|
|
5173
5150
|
(index) => index === focusedListCellIndex
|
|
5174
5151
|
);
|
|
5175
5152
|
switch (event.code) {
|
|
5153
|
+
case "Escape":
|
|
5154
|
+
case "Tab":
|
|
5155
|
+
setIsDropdownOpen(false);
|
|
5156
|
+
break;
|
|
5176
5157
|
case "Enter":
|
|
5177
5158
|
case "NumpadEnter": {
|
|
5178
5159
|
let indexToSelect = focusedListCellIndex;
|
|
@@ -5208,53 +5189,25 @@ function Select(props) {
|
|
|
5208
5189
|
}
|
|
5209
5190
|
}
|
|
5210
5191
|
};
|
|
5211
|
-
const
|
|
5212
|
-
if (
|
|
5192
|
+
const handleArrowClick = (event) => {
|
|
5193
|
+
if (isDropdownActive) {
|
|
5213
5194
|
input.current?.blur();
|
|
5214
|
-
|
|
5195
|
+
setIsDropdownOpen(false);
|
|
5215
5196
|
} else {
|
|
5216
5197
|
input.current?.focus();
|
|
5217
|
-
|
|
5218
|
-
};
|
|
5219
|
-
useOnClickOutsideWithRef(list, handleListClose, inputWrapper);
|
|
5220
|
-
const hasEnoughSymbolsToSearch = searchValue.trim().length >= minSymbolsCountToOpenList;
|
|
5221
|
-
const isOpen = (
|
|
5222
|
-
// Пользователь пытается открыть лист
|
|
5223
|
-
isListOpen && // Нам есть что показать:
|
|
5224
|
-
// Есть опции
|
|
5225
|
-
(filteredOptions.length > 0 || // Дефолтная опция
|
|
5226
|
-
defaultOptionLabel !== void 0 && !hasEnoughSymbolsToSearch || // Текст "Загрузка..."
|
|
5227
|
-
inputProps.isLoading || // Текст "Совпадений не найдено"
|
|
5228
|
-
noMatchesLabel !== void 0 || // У нас есть инпут с поиском внутри листа
|
|
5229
|
-
hasSearchInputInList) && // Последняя проверка на случай, если мы че то ищем в опциях
|
|
5230
|
-
(optionsMode === "normal" || hasEnoughSymbolsToSearch)
|
|
5231
|
-
);
|
|
5232
|
-
const handleBlur = (event) => {
|
|
5233
|
-
if (isListOpen && !isOpen) {
|
|
5234
|
-
handleListClose(event);
|
|
5235
|
-
return;
|
|
5236
|
-
}
|
|
5237
|
-
if (!isNotEmpty(event.relatedTarget) || !isNotEmpty(list.current) || !isNotEmpty(inputWrapper.current)) {
|
|
5238
|
-
return;
|
|
5239
|
-
}
|
|
5240
|
-
const isActionInsideSelect = hasExactParent(event.relatedTarget, list.current) || hasExactParent(event.relatedTarget, inputWrapper.current);
|
|
5241
|
-
if (!isActionInsideSelect) {
|
|
5242
|
-
handleListClose(event);
|
|
5198
|
+
event.stopPropagation();
|
|
5243
5199
|
}
|
|
5244
5200
|
};
|
|
5245
5201
|
const {
|
|
5246
|
-
|
|
5202
|
+
placement = "bottom-start",
|
|
5203
|
+
popupOffset = 4,
|
|
5247
5204
|
shouldRenderInBody = false,
|
|
5248
|
-
shouldHideOnScroll = false
|
|
5205
|
+
shouldHideOnScroll = false,
|
|
5206
|
+
isMinWidthSameAsTrigger = true,
|
|
5207
|
+
canBeFlipped = false,
|
|
5208
|
+
flipOptions,
|
|
5209
|
+
middlewares
|
|
5249
5210
|
} = dropdownOptions ?? {};
|
|
5250
|
-
const popperData = useDropdown({
|
|
5251
|
-
isOpen,
|
|
5252
|
-
onDropdownClose: handleListClose,
|
|
5253
|
-
referenceElement: inputWrapper.current,
|
|
5254
|
-
dropdownElement: list.current,
|
|
5255
|
-
options: dropdownOptions,
|
|
5256
|
-
dependenciesForPositionUpdating: [inputProps.isLoading, filteredOptions.length]
|
|
5257
|
-
});
|
|
5258
5211
|
useEffect(() => {
|
|
5259
5212
|
const focusedCellIndex = isNotEmpty(strValue) ? optionsIndexesForNavigation.find((index) => {
|
|
5260
5213
|
const option = filteredOptions[index];
|
|
@@ -5262,11 +5215,13 @@ function Select(props) {
|
|
|
5262
5215
|
}) : void 0;
|
|
5263
5216
|
setFocusedListCellIndex(focusedCellIndex ?? optionsIndexesForNavigation[0]);
|
|
5264
5217
|
}, [strValue, filteredOptions, optionsIndexesForNavigation, convertToId]);
|
|
5265
|
-
|
|
5266
|
-
if (
|
|
5218
|
+
useDidMountEffect(() => {
|
|
5219
|
+
if (isDropdownActive) {
|
|
5267
5220
|
onOpen?.();
|
|
5221
|
+
} else {
|
|
5222
|
+
onClose?.();
|
|
5268
5223
|
}
|
|
5269
|
-
}, [
|
|
5224
|
+
}, [isDropdownActive, onClose, onOpen]);
|
|
5270
5225
|
const searchInputEl = hasSearchInputInList && /* @__PURE__ */ jsx(
|
|
5271
5226
|
SearchInput,
|
|
5272
5227
|
{
|
|
@@ -5282,47 +5237,59 @@ function Select(props) {
|
|
|
5282
5237
|
searchInputEl,
|
|
5283
5238
|
header
|
|
5284
5239
|
] });
|
|
5285
|
-
const
|
|
5286
|
-
|
|
5240
|
+
const handleFocus = (event) => {
|
|
5241
|
+
if (isDisabled) {
|
|
5242
|
+
return;
|
|
5243
|
+
}
|
|
5244
|
+
onFocus?.(event);
|
|
5245
|
+
if (isDropdownDisabled) {
|
|
5246
|
+
return;
|
|
5247
|
+
}
|
|
5248
|
+
setIsDropdownOpen(true);
|
|
5249
|
+
};
|
|
5250
|
+
const handleBlur = (event) => {
|
|
5251
|
+
if (isDropdownActive) {
|
|
5252
|
+
return;
|
|
5253
|
+
}
|
|
5254
|
+
reset();
|
|
5255
|
+
onBlur?.(event);
|
|
5256
|
+
};
|
|
5257
|
+
const renderTrigger = /* @__PURE__ */ jsx("div", { className: classes.root, onKeyDown: handleKeyDown, children: /* @__PURE__ */ jsx("div", { className: clsx(classes.inputWrapper, isDisabled && classes.disabled), children: /* @__PURE__ */ jsx(
|
|
5258
|
+
InputBase,
|
|
5287
5259
|
{
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5260
|
+
ref: input,
|
|
5261
|
+
value: searchValue !== "" && !shouldRenderSearchInputInList ? searchValue : showedStringValue,
|
|
5262
|
+
size: size2,
|
|
5263
|
+
isActive: isDropdownOpen || isActive,
|
|
5264
|
+
isReadonly: hasReadonlyInput,
|
|
5265
|
+
isDisabled,
|
|
5266
|
+
isLoading: areOptionsLoading,
|
|
5267
|
+
onChange: handleInputChange,
|
|
5268
|
+
onFocus: handleFocus,
|
|
5295
5269
|
onBlur: handleBlur,
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
{
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
convertValueToId: convertToId,
|
|
5320
|
-
onOptionSelect: handleOptionSelect,
|
|
5321
|
-
onToggleCheckbox: handleToggleOptionCheckbox
|
|
5322
|
-
}
|
|
5323
|
-
)
|
|
5324
|
-
}
|
|
5325
|
-
);
|
|
5270
|
+
tweakStyles: tweakInputStyles,
|
|
5271
|
+
testId,
|
|
5272
|
+
endIcon: [
|
|
5273
|
+
isMultiSelect && shouldShowMultiSelectCounter ? {
|
|
5274
|
+
key: "counter",
|
|
5275
|
+
iconComponent: /* @__PURE__ */ jsxs("div", { className: classes.counter, children: [
|
|
5276
|
+
"(+",
|
|
5277
|
+
value.length - 1,
|
|
5278
|
+
")"
|
|
5279
|
+
] }),
|
|
5280
|
+
shouldResetSize: true
|
|
5281
|
+
} : void 0,
|
|
5282
|
+
...getArray(endIcon),
|
|
5283
|
+
isNotEmpty(dropdownIcon) ? {
|
|
5284
|
+
key: "arrow",
|
|
5285
|
+
onClick: handleArrowClick,
|
|
5286
|
+
tabIndex: void 0,
|
|
5287
|
+
iconComponent: /* @__PURE__ */ jsx("div", { className: clsx(classes.arrow, { [classes.activeArrow]: isDropdownOpen }), children: renderIcon(dropdownIcon) })
|
|
5288
|
+
} : void 0
|
|
5289
|
+
].filter(isNotEmpty),
|
|
5290
|
+
...inputProps
|
|
5291
|
+
}
|
|
5292
|
+
) }) });
|
|
5326
5293
|
return /* @__PURE__ */ jsx(
|
|
5327
5294
|
WithMessages,
|
|
5328
5295
|
{
|
|
@@ -5330,53 +5297,53 @@ function Select(props) {
|
|
|
5330
5297
|
infoMessage,
|
|
5331
5298
|
tweakStyles: tweakWithMessagesStyles,
|
|
5332
5299
|
testId: getTestId(testId, "wrapper"),
|
|
5333
|
-
children: /* @__PURE__ */
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5300
|
+
children: /* @__PURE__ */ jsx(
|
|
5301
|
+
WithPopup,
|
|
5302
|
+
{
|
|
5303
|
+
state: isDropdownOpenState,
|
|
5304
|
+
isDisabled: isDropdownDisabled,
|
|
5305
|
+
placement,
|
|
5306
|
+
popupOffset,
|
|
5307
|
+
shouldRenderInBody,
|
|
5308
|
+
shouldHideOnScroll,
|
|
5309
|
+
isMinWidthSameAsTrigger,
|
|
5310
|
+
canBeFlipped,
|
|
5311
|
+
flipOptions,
|
|
5312
|
+
middlewares,
|
|
5313
|
+
isTriggerWrapped: true,
|
|
5314
|
+
clickOptions: { toggle: false },
|
|
5315
|
+
transitionOptions: { duration: 0 },
|
|
5316
|
+
trigger: renderTrigger,
|
|
5317
|
+
tweakStyles: tweakWithPopupStyles,
|
|
5318
|
+
children: /* @__PURE__ */ jsx(
|
|
5319
|
+
SelectList,
|
|
5320
|
+
{
|
|
5321
|
+
options: filteredOptions,
|
|
5322
|
+
size: size2,
|
|
5323
|
+
defaultOptionLabel: hasDefaultOption && shouldShowDefaultOption && defaultOptionLabel,
|
|
5324
|
+
allOptionsLabel: shouldShowAllOption && allOptionsLabel,
|
|
5325
|
+
areAllOptionsSelected,
|
|
5326
|
+
customListHeader: customHeader,
|
|
5327
|
+
customListFooter: applyAction(footer, { filteredOptions }),
|
|
5328
|
+
noMatchesLabel,
|
|
5329
|
+
focusedIndex: focusedListCellIndex,
|
|
5330
|
+
activeValue: value,
|
|
5331
|
+
isLoading: inputProps.isLoading,
|
|
5332
|
+
loadingLabel,
|
|
5333
|
+
isMultiSelect,
|
|
5334
|
+
shouldScrollToList: shouldScrollToList && !shouldHideOnScroll,
|
|
5335
|
+
isOptionDisabled,
|
|
5336
|
+
convertValueToString,
|
|
5337
|
+
convertValueToReactNode,
|
|
5338
|
+
convertValueToId: convertToId,
|
|
5339
|
+
onOptionSelect: handleOptionSelect,
|
|
5340
|
+
onToggleCheckbox: handleToggleOptionCheckbox,
|
|
5341
|
+
tweakStyles: tweakSelectListStyles,
|
|
5342
|
+
testId: getTestId(testId, "list")
|
|
5343
|
+
}
|
|
5344
|
+
)
|
|
5345
|
+
}
|
|
5346
|
+
)
|
|
5380
5347
|
}
|
|
5381
5348
|
);
|
|
5382
5349
|
}
|
|
@@ -12085,7 +12052,6 @@ export {
|
|
|
12085
12052
|
getPhoneObjFromString,
|
|
12086
12053
|
getScrollParent,
|
|
12087
12054
|
getStyleComputedProperty,
|
|
12088
|
-
hasExactParent,
|
|
12089
12055
|
helpers,
|
|
12090
12056
|
iconsMap,
|
|
12091
12057
|
isControlWrapperIcon,
|