@true-engineering/true-react-common-ui-kit 1.10.0 → 1.11.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/dist/components/Select/Select.styles.d.ts +9 -10
- package/dist/components/Select/SelectList/SelectList.d.ts +2 -1
- package/dist/true-react-common-ui-kit.js +49 -24
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +49 -24
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Select/MultiSelect.stories.tsx +1 -0
- package/src/components/Select/Select.styles.ts +10 -12
- package/src/components/Select/Select.tsx +33 -14
- package/src/components/Select/SelectList/SelectList.tsx +4 -3
|
@@ -43,20 +43,19 @@ export declare const styles: {
|
|
|
43
43
|
cursor: string;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
counter: {
|
|
47
|
+
'&:not(:last-child)': {
|
|
48
48
|
paddingRight: number;
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
};
|
|
51
|
+
icon: {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
};
|
|
55
|
+
tweakInput: {
|
|
56
|
+
input: {
|
|
51
57
|
paddingRight: number;
|
|
52
58
|
};
|
|
53
|
-
unitsWrapper: {
|
|
54
|
-
position: string;
|
|
55
|
-
padding: number[];
|
|
56
|
-
};
|
|
57
|
-
fakeValue: {
|
|
58
|
-
display: string;
|
|
59
|
-
};
|
|
60
59
|
disabled: {
|
|
61
60
|
'& $input': {
|
|
62
61
|
cursor: string;
|
|
@@ -12,6 +12,7 @@ export interface ISelectListProps<Value> extends ICommonProps {
|
|
|
12
12
|
defaultOptionLabel?: string;
|
|
13
13
|
testId?: string;
|
|
14
14
|
allOptionsLabel?: string;
|
|
15
|
+
areAllOptionsSelected?: boolean;
|
|
15
16
|
shouldScrollToList?: boolean;
|
|
16
17
|
customListHeader?: ReactNode;
|
|
17
18
|
onOptionSelect(index: number, event: MouseEvent<HTMLElement>): void;
|
|
@@ -21,4 +22,4 @@ export interface ISelectListProps<Value> extends ICommonProps {
|
|
|
21
22
|
convertValueToReactNode?(value: Value, isDisabled: boolean): ReactNode;
|
|
22
23
|
convertValueToId(value: Value): string | undefined;
|
|
23
24
|
}
|
|
24
|
-
export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, customListHeader, isOptionDisabled, allOptionsLabel, onOptionSelect, onToggleCheckbox, convertValueToString, convertValueToReactNode, convertValueToId, }: ISelectListProps<Value>): JSX.Element;
|
|
25
|
+
export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, areAllOptionsSelected, customListHeader, isOptionDisabled, allOptionsLabel, onOptionSelect, onToggleCheckbox, convertValueToString, convertValueToReactNode, convertValueToId, }: ISelectListProps<Value>): JSX.Element;
|
|
@@ -7872,7 +7872,7 @@ function _define_property$x(obj, key, value) {
|
|
|
7872
7872
|
return obj;
|
|
7873
7873
|
}
|
|
7874
7874
|
function SelectList(param) {
|
|
7875
|
-
var options = param.options, focusedIndex = param.focusedIndex, activeValue = param.activeValue, defaultOptionLabel = param.defaultOptionLabel, _param_noMatchesLabel = param.noMatchesLabel, noMatchesLabel = _param_noMatchesLabel === void 0 ? "Совпадений не найдено" : _param_noMatchesLabel, isLoading = param.isLoading, _param_loadingLabel = param.loadingLabel, loadingLabel = _param_loadingLabel === void 0 ? "Загрузка..." : _param_loadingLabel, tweakStyles = param.tweakStyles, testId = param.testId, _param_shouldScrollToList = param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, customListHeader = param.customListHeader, isOptionDisabled = param.isOptionDisabled, allOptionsLabel = param.allOptionsLabel, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox, convertValueToString = param.convertValueToString, _param_convertValueToReactNode = param.convertValueToReactNode, convertValueToReactNode = _param_convertValueToReactNode === void 0 ? convertValueToString : _param_convertValueToReactNode, convertValueToId = param.convertValueToId;
|
|
7875
|
+
var options = param.options, focusedIndex = param.focusedIndex, activeValue = param.activeValue, defaultOptionLabel = param.defaultOptionLabel, _param_noMatchesLabel = param.noMatchesLabel, noMatchesLabel = _param_noMatchesLabel === void 0 ? "Совпадений не найдено" : _param_noMatchesLabel, isLoading = param.isLoading, _param_loadingLabel = param.loadingLabel, loadingLabel = _param_loadingLabel === void 0 ? "Загрузка..." : _param_loadingLabel, tweakStyles = param.tweakStyles, testId = param.testId, _param_shouldScrollToList = param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, areAllOptionsSelected = param.areAllOptionsSelected, customListHeader = param.customListHeader, isOptionDisabled = param.isOptionDisabled, allOptionsLabel = param.allOptionsLabel, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox, convertValueToString = param.convertValueToString, _param_convertValueToReactNode = param.convertValueToReactNode, convertValueToReactNode = _param_convertValueToReactNode === void 0 ? convertValueToString : _param_convertValueToReactNode, convertValueToId = param.convertValueToId;
|
|
7876
7876
|
var classes = useTheme("SelectList", styles$v, tweakStyles).classes;
|
|
7877
7877
|
var isMultiSelect = isNotEmpty(onToggleCheckbox);
|
|
7878
7878
|
var multiSelectValue = activeValue;
|
|
@@ -7936,8 +7936,8 @@ function SelectList(param) {
|
|
|
7936
7936
|
isNotEmpty(allOptionsLabel) && /* @__PURE__ */ jsx(SelectListItem, {
|
|
7937
7937
|
classes,
|
|
7938
7938
|
index: ALL_OPTION_INDEX,
|
|
7939
|
-
isSemiChecked: selectedOptionsCount > 0 &&
|
|
7940
|
-
isActive:
|
|
7939
|
+
isSemiChecked: selectedOptionsCount > 0 && !areAllOptionsSelected,
|
|
7940
|
+
isActive: areAllOptionsSelected,
|
|
7941
7941
|
isFocused: focusedIndex === ALL_OPTION_INDEX,
|
|
7942
7942
|
onOptionSelect,
|
|
7943
7943
|
onToggleCheckbox,
|
|
@@ -8031,25 +8031,19 @@ var styles$u = {
|
|
|
8031
8031
|
cursor: "default"
|
|
8032
8032
|
}
|
|
8033
8033
|
},
|
|
8034
|
+
counter: {
|
|
8035
|
+
"&:not(:last-child)": {
|
|
8036
|
+
paddingRight: 8
|
|
8037
|
+
}
|
|
8038
|
+
},
|
|
8039
|
+
icon: {
|
|
8040
|
+
width: 16,
|
|
8041
|
+
height: 16
|
|
8042
|
+
},
|
|
8034
8043
|
tweakInput: {
|
|
8035
8044
|
input: {
|
|
8036
8045
|
paddingRight: 32
|
|
8037
8046
|
},
|
|
8038
|
-
withUnits: {
|
|
8039
|
-
paddingRight: 8
|
|
8040
|
-
},
|
|
8041
|
-
unitsWrapper: {
|
|
8042
|
-
position: "unset",
|
|
8043
|
-
padding: [
|
|
8044
|
-
0,
|
|
8045
|
-
32,
|
|
8046
|
-
0,
|
|
8047
|
-
0
|
|
8048
|
-
]
|
|
8049
|
-
},
|
|
8050
|
-
fakeValue: {
|
|
8051
|
-
display: "none"
|
|
8052
|
-
},
|
|
8053
8047
|
disabled: {
|
|
8054
8048
|
"& $input": {
|
|
8055
8049
|
cursor: "default"
|
|
@@ -8511,7 +8505,7 @@ var __generator$4 = globalThis && globalThis.__generator || function(thisArg, bo
|
|
|
8511
8505
|
}
|
|
8512
8506
|
};
|
|
8513
8507
|
function Select(props) {
|
|
8514
|
-
var options = props.options, value = props.value, defaultOptionLabel = props.defaultOptionLabel, allOptionsLabel = props.allOptionsLabel, _props_debounceTime = props.debounceTime, debounceTime = _props_debounceTime === void 0 ? 400 : _props_debounceTime, _props_optionsMode = props.optionsMode, optionsMode = _props_optionsMode === void 0 ? "normal" : _props_optionsMode, noMatchesLabel = props.noMatchesLabel, loadingLabel = props.loadingLabel, tweakStyles = props.tweakStyles, testId = props.testId, isReadonly = props.isReadonly, isDisabled = props.isDisabled, dropdownOptions = props.dropdownOptions, _props_minSymbolsCountToOpenList = props.minSymbolsCountToOpenList, minSymbolsCountToOpenList = _props_minSymbolsCountToOpenList === void 0 ? 0 : _props_minSymbolsCountToOpenList, _props_dropdownIcon = props.dropdownIcon, dropdownIcon = _props_dropdownIcon === void 0 ? "chevron-down" : _props_dropdownIcon, _props_shouldScrollToList = props.shouldScrollToList, shouldScrollToList = _props_shouldScrollToList === void 0 ? true : _props_shouldScrollToList, searchInput = props.searchInput,
|
|
8508
|
+
var options = props.options, value = props.value, defaultOptionLabel = props.defaultOptionLabel, allOptionsLabel = props.allOptionsLabel, _props_debounceTime = props.debounceTime, debounceTime = _props_debounceTime === void 0 ? 400 : _props_debounceTime, _props_optionsMode = props.optionsMode, optionsMode = _props_optionsMode === void 0 ? "normal" : _props_optionsMode, noMatchesLabel = props.noMatchesLabel, loadingLabel = props.loadingLabel, tweakStyles = props.tweakStyles, testId = props.testId, isReadonly = props.isReadonly, isDisabled = props.isDisabled, dropdownOptions = props.dropdownOptions, _props_minSymbolsCountToOpenList = props.minSymbolsCountToOpenList, minSymbolsCountToOpenList = _props_minSymbolsCountToOpenList === void 0 ? 0 : _props_minSymbolsCountToOpenList, _props_dropdownIcon = props.dropdownIcon, dropdownIcon = _props_dropdownIcon === void 0 ? "chevron-down" : _props_dropdownIcon, _props_shouldScrollToList = props.shouldScrollToList, shouldScrollToList = _props_shouldScrollToList === void 0 ? true : _props_shouldScrollToList, searchInput = props.searchInput, iconType = props.iconType, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onType = props.onType, onOpen = props.onOpen, _props_isOptionDisabled = props.isOptionDisabled, isOptionDisabled = _props_isOptionDisabled === void 0 ? defaultIsOptionDisabled : _props_isOptionDisabled, _props_compareValuesOnChange = props.compareValuesOnChange, compareValuesOnChange = _props_compareValuesOnChange === void 0 ? defaultCompareFunction : _props_compareValuesOnChange, _props_convertValueToString = props.convertValueToString, convertValueToString = _props_convertValueToString === void 0 ? defaultConvertFunction$2 : _props_convertValueToString, convertValueToId = props.convertValueToId, convertValueToReactNode = props.convertValueToReactNode, optionsFilter = props.optionsFilter, inputProps = _object_without_properties$5(props, [
|
|
8515
8509
|
"options",
|
|
8516
8510
|
"value",
|
|
8517
8511
|
"defaultOptionLabel",
|
|
@@ -8529,7 +8523,7 @@ function Select(props) {
|
|
|
8529
8523
|
"dropdownIcon",
|
|
8530
8524
|
"shouldScrollToList",
|
|
8531
8525
|
"searchInput",
|
|
8532
|
-
"
|
|
8526
|
+
"iconType",
|
|
8533
8527
|
"onChange",
|
|
8534
8528
|
"onFocus",
|
|
8535
8529
|
"onBlur",
|
|
@@ -8576,6 +8570,16 @@ function Select(props) {
|
|
|
8576
8570
|
searchValue,
|
|
8577
8571
|
optionsMode
|
|
8578
8572
|
]);
|
|
8573
|
+
var availableOptions = useMemo(function() {
|
|
8574
|
+
return options.filter(function(o) {
|
|
8575
|
+
return !isOptionDisabled(o);
|
|
8576
|
+
});
|
|
8577
|
+
}, [
|
|
8578
|
+
options,
|
|
8579
|
+
isOptionDisabled
|
|
8580
|
+
]);
|
|
8581
|
+
var areAllOptionsSelected = isMultiSelect && (value === null || value === void 0 ? void 0 : value.length) === availableOptions.length;
|
|
8582
|
+
var shouldShowMultiSelectCounter = isMultiSelect && isNotEmpty(value) && value.length > 1 && !areAllOptionsSelected;
|
|
8579
8583
|
var optionsIndexesForNavigation = useMemo(function() {
|
|
8580
8584
|
var result = [];
|
|
8581
8585
|
if (shouldShowDefaultOption && hasDefaultOption) {
|
|
@@ -8594,7 +8598,7 @@ function Select(props) {
|
|
|
8594
8598
|
filteredOptions
|
|
8595
8599
|
]);
|
|
8596
8600
|
var stringValue = isNotEmpty(strValue) ? convertValueToString(strValue) : void 0;
|
|
8597
|
-
var showedStringValue =
|
|
8601
|
+
var showedStringValue = areAllOptionsSelected && isNotEmpty(allOptionsLabel) ? allOptionsLabel : stringValue;
|
|
8598
8602
|
var convertToId = useCallback(function(v) {
|
|
8599
8603
|
return (convertValueToId !== null && convertValueToId !== void 0 ? convertValueToId : getDefaultConvertToIdFunction(convertValueToString))(v);
|
|
8600
8604
|
}, [
|
|
@@ -8662,7 +8666,7 @@ function Select(props) {
|
|
|
8662
8666
|
return;
|
|
8663
8667
|
}
|
|
8664
8668
|
if (index === ALL_OPTION_INDEX && isSelected) {
|
|
8665
|
-
handleOnChange(
|
|
8669
|
+
handleOnChange(availableOptions);
|
|
8666
8670
|
return;
|
|
8667
8671
|
}
|
|
8668
8672
|
var option = filteredOptions[index];
|
|
@@ -8755,7 +8759,7 @@ function Select(props) {
|
|
|
8755
8759
|
if (isMultiSelect) {
|
|
8756
8760
|
var isThisValueAlreadySelected;
|
|
8757
8761
|
if (indexToSelect === ALL_OPTION_INDEX) {
|
|
8758
|
-
isThisValueAlreadySelected =
|
|
8762
|
+
isThisValueAlreadySelected = areAllOptionsSelected;
|
|
8759
8763
|
} else {
|
|
8760
8764
|
var valueIdToSelect = convertToId(filteredOptions[indexToSelect]);
|
|
8761
8765
|
var _value_some;
|
|
@@ -8811,6 +8815,10 @@ function Select(props) {
|
|
|
8811
8815
|
input: {
|
|
8812
8816
|
cursor: "pointer"
|
|
8813
8817
|
}
|
|
8818
|
+
}), _object_spread$u({}, isMultiSelect && {
|
|
8819
|
+
inputIcon: {
|
|
8820
|
+
width: "auto"
|
|
8821
|
+
}
|
|
8814
8822
|
}), tweakStyles === null || tweakStyles === void 0 ? void 0 : tweakStyles.tweakInput);
|
|
8815
8823
|
}, [
|
|
8816
8824
|
tweakStyles === null || tweakStyles === void 0 ? void 0 : tweakStyles.tweakInput,
|
|
@@ -8852,6 +8860,7 @@ function Select(props) {
|
|
|
8852
8860
|
options: filteredOptions,
|
|
8853
8861
|
defaultOptionLabel: hasDefaultOption && shouldShowDefaultOption ? defaultOptionLabel : void 0,
|
|
8854
8862
|
allOptionsLabel: shouldShowAllOption ? allOptionsLabel : void 0,
|
|
8863
|
+
areAllOptionsSelected,
|
|
8855
8864
|
customListHeader: hasSearchInputInList ? /* @__PURE__ */ jsx(SearchInput, _object_spread$u({
|
|
8856
8865
|
value: searchValue,
|
|
8857
8866
|
onChange: handleInputChange,
|
|
@@ -8874,6 +8883,22 @@ function Select(props) {
|
|
|
8874
8883
|
onToggleCheckbox: isMultiSelect ? handleToggleOptionCheckbox : void 0
|
|
8875
8884
|
})
|
|
8876
8885
|
}));
|
|
8886
|
+
var multiSelectCounterWithIcon = shouldShowMultiSelectCounter || isNotEmpty(iconType) ? /* @__PURE__ */ jsxs(Fragment, {
|
|
8887
|
+
children: [
|
|
8888
|
+
shouldShowMultiSelectCounter && /* @__PURE__ */ jsxs("div", {
|
|
8889
|
+
className: classes.counter,
|
|
8890
|
+
children: [
|
|
8891
|
+
"(+",
|
|
8892
|
+
value.length - 1,
|
|
8893
|
+
")"
|
|
8894
|
+
]
|
|
8895
|
+
}),
|
|
8896
|
+
isNotEmpty(iconType) && /* @__PURE__ */ jsx("div", {
|
|
8897
|
+
className: classes.icon,
|
|
8898
|
+
children: renderIcon(iconType)
|
|
8899
|
+
})
|
|
8900
|
+
]
|
|
8901
|
+
}) : void 0;
|
|
8877
8902
|
return /* @__PURE__ */ jsxs("div", {
|
|
8878
8903
|
className: classes.root,
|
|
8879
8904
|
onKeyDown: handleKeyDown,
|
|
@@ -8895,7 +8920,7 @@ function Select(props) {
|
|
|
8895
8920
|
isLoading: areOptionsLoading,
|
|
8896
8921
|
tweakStyles: tweakInputStyles,
|
|
8897
8922
|
testId,
|
|
8898
|
-
|
|
8923
|
+
iconType: isMultiSelect ? multiSelectCounterWithIcon : iconType
|
|
8899
8924
|
}, inputProps)),
|
|
8900
8925
|
/* @__PURE__ */ jsx("div", {
|
|
8901
8926
|
onMouseDown: function(event) {
|