@true-engineering/true-react-common-ui-kit 1.1.0 → 1.2.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.d.ts +7 -6
- package/dist/components/Select/SelectList/SelectList.d.ts +8 -8
- package/dist/components/Select/helpers.d.ts +1 -0
- package/dist/true-react-common-ui-kit.js +24 -22
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +24 -22
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Select/Select.stories.tsx +16 -12
- package/src/components/Select/Select.tsx +31 -29
- package/src/components/Select/SelectList/SelectList.tsx +12 -19
- package/src/components/Select/helpers.ts +5 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { IInputProps } from '../Input';
|
|
3
3
|
import { IIconType } from '../Icon';
|
|
4
4
|
import { IDropdownWithPopperOptions } from '../../types';
|
|
@@ -7,22 +7,23 @@ export interface ISelectProps<Value> extends Omit<IInputProps, 'value' | 'onChan
|
|
|
7
7
|
tweakStyles?: SelectStyles;
|
|
8
8
|
defaultOptionLabel?: string;
|
|
9
9
|
noMatchesLabel?: string;
|
|
10
|
-
loadingLabel?:
|
|
10
|
+
loadingLabel?: ReactNode;
|
|
11
11
|
optionsMode?: 'search' | 'dynamic' | 'normal';
|
|
12
|
-
onType?: (value: string) => Promise<void>;
|
|
13
12
|
debounceTime?: number;
|
|
14
13
|
minSymbolsCountToOpenList?: number;
|
|
15
14
|
dropdownOptions?: IDropdownWithPopperOptions;
|
|
16
15
|
dropdownIcon?: IIconType;
|
|
17
|
-
onOpen?: () => void;
|
|
18
|
-
optionsFilter?: (options: Value[], query: string) => Value[];
|
|
19
16
|
options: Value[];
|
|
20
17
|
value: Value | undefined;
|
|
21
18
|
shouldScrollToList?: boolean;
|
|
19
|
+
isOptionDisabled?(option: Value): boolean;
|
|
22
20
|
onChange(value: Value | undefined): void;
|
|
21
|
+
onType?(value: string): Promise<void>;
|
|
22
|
+
optionsFilter?(options: Value[], query: string): Value[];
|
|
23
|
+
onOpen?(): void;
|
|
23
24
|
compareValuesOnChange?(v1: Value | undefined, v2: Value | undefined): boolean;
|
|
24
25
|
convertValueToString?(value: Value): string | undefined;
|
|
25
26
|
convertValueToReactNode?(value: Value): ReactNode;
|
|
26
27
|
convertValueToId?(value: Value): string | undefined;
|
|
27
28
|
}
|
|
28
|
-
export declare function Select<Value>({ options, value,
|
|
29
|
+
export declare function Select<Value>({ options, value, defaultOptionLabel, debounceTime, optionsMode, noMatchesLabel, loadingLabel, tweakStyles, testId, isDisabled, dropdownOptions, minSymbolsCountToOpenList, dropdownIcon, shouldScrollToList, onChange, onFocus, onBlur, onType, onOpen, isOptionDisabled, compareValuesOnChange, convertValueToString, convertValueToId, convertValueToReactNode, optionsFilter, ...inputProps }: ISelectProps<Value>): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { ICommonProps } from '../../../types';
|
|
3
3
|
import { SelectListStyles } from './SelectList.styles';
|
|
4
4
|
export interface ISelectListProps<Value> extends ICommonProps {
|
|
@@ -8,14 +8,14 @@ export interface ISelectListProps<Value> extends ICommonProps {
|
|
|
8
8
|
activeValue?: Value;
|
|
9
9
|
noMatchesLabel?: string;
|
|
10
10
|
isLoading?: boolean;
|
|
11
|
-
loadingLabel?:
|
|
11
|
+
loadingLabel?: ReactNode;
|
|
12
12
|
defaultOptionLabel?: string;
|
|
13
|
-
onOptionClick: (index: number) => void;
|
|
14
13
|
testId?: string;
|
|
15
14
|
shouldScrollToList?: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
onOptionClick(index: number): void;
|
|
16
|
+
isOptionDisabled(value: Value): boolean;
|
|
17
|
+
convertValueToString(value: Value): string | undefined;
|
|
18
|
+
convertValueToReactNode?(value: Value): ReactNode;
|
|
19
|
+
convertValueToId?(value: Value): string | undefined;
|
|
19
20
|
}
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function SelectList<Value>({ options, onOptionClick, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, convertValueToString, convertValueToReactNode, convertValueToId, tweakStyles, testId, shouldScrollToList, }: ISelectListProps<Value>): JSX.Element;
|
|
21
|
+
export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, isOptionDisabled, onOptionClick, convertValueToString, convertValueToReactNode, convertValueToId, }: ISelectListProps<Value>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const defaultIsOptionDisabled: <Value>(option: Value) => boolean;
|
|
1
2
|
export declare const defaultConvertFunction: (v: unknown) => string | undefined;
|
|
2
3
|
export declare const defaultCompareFunction: <Value>(v1: Value, v2: Value) => boolean;
|
|
3
4
|
export declare const getActiveValueIndex: <Value>(options: Value[], value: Value | undefined, convertFunc: (v: Value) => string | undefined) => number;
|
|
@@ -6963,13 +6963,9 @@ function _define_property$x(obj, key, value) {
|
|
|
6963
6963
|
}
|
|
6964
6964
|
return obj;
|
|
6965
6965
|
}
|
|
6966
|
-
function isOptionDisabled(option) {
|
|
6967
|
-
var _option_isDisabled;
|
|
6968
|
-
return typeof option === "object" && option !== null && ((_option_isDisabled = option === null || option === void 0 ? void 0 : option.isDisabled) !== null && _option_isDisabled !== void 0 ? _option_isDisabled : false);
|
|
6969
|
-
}
|
|
6970
6966
|
var DEFAULT_OPTION_INDEX = -1;
|
|
6971
6967
|
function SelectList(param) {
|
|
6972
|
-
var options = param.options,
|
|
6968
|
+
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, isOptionDisabled = param.isOptionDisabled, onOptionClick = param.onOptionClick, convertValueToString = param.convertValueToString, convertValueToReactNode = param.convertValueToReactNode, _param_convertValueToId = param.convertValueToId, convertValueToId = _param_convertValueToId === void 0 ? convertValueToString : _param_convertValueToId;
|
|
6973
6969
|
var classes = useTheme("SelectList", styles$v, tweakStyles).classes;
|
|
6974
6970
|
var activeValueId = isNotEmpty(activeValue) ? convertValueToId(activeValue) : void 0;
|
|
6975
6971
|
var convertedToStringOptions = useMemo(function() {
|
|
@@ -7036,6 +7032,10 @@ function SelectList(param) {
|
|
|
7036
7032
|
})
|
|
7037
7033
|
});
|
|
7038
7034
|
}
|
|
7035
|
+
var _option_isDisabled;
|
|
7036
|
+
var defaultIsOptionDisabled = function(option) {
|
|
7037
|
+
return typeof option === "object" && option !== null && ((_option_isDisabled = option === null || option === void 0 ? void 0 : option.isDisabled) !== null && _option_isDisabled !== void 0 ? _option_isDisabled : false);
|
|
7038
|
+
};
|
|
7039
7039
|
var defaultConvertFunction$2 = function(v) {
|
|
7040
7040
|
return v === void 0 ? void 0 : String(v);
|
|
7041
7041
|
};
|
|
@@ -7380,22 +7380,12 @@ var __generator$4 = globalThis && globalThis.__generator || function(thisArg, bo
|
|
|
7380
7380
|
}
|
|
7381
7381
|
};
|
|
7382
7382
|
function Select(_param) {
|
|
7383
|
-
var options = _param.options, value = _param.value,
|
|
7383
|
+
var options = _param.options, value = _param.value, defaultOptionLabel = _param.defaultOptionLabel, _param_debounceTime = _param.debounceTime, debounceTime = _param_debounceTime === void 0 ? 400 : _param_debounceTime, _param_optionsMode = _param.optionsMode, optionsMode = _param_optionsMode === void 0 ? "normal" : _param_optionsMode, noMatchesLabel = _param.noMatchesLabel, loadingLabel = _param.loadingLabel, tweakStyles = _param.tweakStyles, testId = _param.testId, isDisabled = _param.isDisabled, dropdownOptions = _param.dropdownOptions, _param_minSymbolsCountToOpenList = _param.minSymbolsCountToOpenList, minSymbolsCountToOpenList = _param_minSymbolsCountToOpenList === void 0 ? 0 : _param_minSymbolsCountToOpenList, _param_dropdownIcon = _param.dropdownIcon, dropdownIcon = _param_dropdownIcon === void 0 ? "chevron-down" : _param_dropdownIcon, _param_shouldScrollToList = _param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, onChange = _param.onChange, onFocus = _param.onFocus, onBlur = _param.onBlur, onType = _param.onType, onOpen = _param.onOpen, _param_isOptionDisabled = _param.isOptionDisabled, isOptionDisabled = _param_isOptionDisabled === void 0 ? defaultIsOptionDisabled : _param_isOptionDisabled, _param_compareValuesOnChange = _param.compareValuesOnChange, compareValuesOnChange = _param_compareValuesOnChange === void 0 ? defaultCompareFunction : _param_compareValuesOnChange, _param_convertValueToString = _param.convertValueToString, convertValueToString = _param_convertValueToString === void 0 ? defaultConvertFunction$2 : _param_convertValueToString, convertValueToId = _param.convertValueToId, convertValueToReactNode = _param.convertValueToReactNode, optionsFilter = _param.optionsFilter, inputProps = _object_without_properties$6(_param, [
|
|
7384
7384
|
"options",
|
|
7385
7385
|
"value",
|
|
7386
|
-
"onChange",
|
|
7387
|
-
"compareValuesOnChange",
|
|
7388
|
-
"convertValueToString",
|
|
7389
|
-
"convertValueToId",
|
|
7390
|
-
"convertValueToReactNode",
|
|
7391
7386
|
"defaultOptionLabel",
|
|
7392
|
-
"onFocus",
|
|
7393
|
-
"onBlur",
|
|
7394
|
-
"onType",
|
|
7395
|
-
"onOpen",
|
|
7396
7387
|
"debounceTime",
|
|
7397
7388
|
"optionsMode",
|
|
7398
|
-
"optionsFilter",
|
|
7399
7389
|
"noMatchesLabel",
|
|
7400
7390
|
"loadingLabel",
|
|
7401
7391
|
"tweakStyles",
|
|
@@ -7404,7 +7394,18 @@ function Select(_param) {
|
|
|
7404
7394
|
"dropdownOptions",
|
|
7405
7395
|
"minSymbolsCountToOpenList",
|
|
7406
7396
|
"dropdownIcon",
|
|
7407
|
-
"shouldScrollToList"
|
|
7397
|
+
"shouldScrollToList",
|
|
7398
|
+
"onChange",
|
|
7399
|
+
"onFocus",
|
|
7400
|
+
"onBlur",
|
|
7401
|
+
"onType",
|
|
7402
|
+
"onOpen",
|
|
7403
|
+
"isOptionDisabled",
|
|
7404
|
+
"compareValuesOnChange",
|
|
7405
|
+
"convertValueToString",
|
|
7406
|
+
"convertValueToId",
|
|
7407
|
+
"convertValueToReactNode",
|
|
7408
|
+
"optionsFilter"
|
|
7408
7409
|
]);
|
|
7409
7410
|
var _useTheme = useTheme("Select", styles$u, tweakStyles), classes = _useTheme.classes, componentStyles = _useTheme.componentStyles;
|
|
7410
7411
|
var isMounted = useIsMounted();
|
|
@@ -7698,10 +7699,6 @@ function Select(_param) {
|
|
|
7698
7699
|
}, popperData === null || popperData === void 0 ? void 0 : popperData.attributes.popper), {
|
|
7699
7700
|
children: isOpen && /* @__PURE__ */ jsx(SelectList, {
|
|
7700
7701
|
options: filteredOptions,
|
|
7701
|
-
convertValueToString,
|
|
7702
|
-
convertValueToReactNode,
|
|
7703
|
-
convertValueToId,
|
|
7704
|
-
onOptionClick: handleOptionClick,
|
|
7705
7702
|
defaultOptionLabel: hasDefaultOption && shouldShowDefaultOption ? defaultOptionLabel : void 0,
|
|
7706
7703
|
noMatchesLabel,
|
|
7707
7704
|
focusedIndex: focusedListCellIndex,
|
|
@@ -7710,7 +7707,12 @@ function Select(_param) {
|
|
|
7710
7707
|
loadingLabel,
|
|
7711
7708
|
tweakStyles: tweakStyles === null || tweakStyles === void 0 ? void 0 : tweakStyles.tweakSelectList,
|
|
7712
7709
|
testId: testId !== void 0 ? "".concat(testId, "-list") : void 0,
|
|
7713
|
-
shouldScrollToList: shouldScrollToList && !shouldUsePopper && !shouldHideOnScroll
|
|
7710
|
+
shouldScrollToList: shouldScrollToList && !shouldUsePopper && !shouldHideOnScroll,
|
|
7711
|
+
isOptionDisabled,
|
|
7712
|
+
convertValueToString,
|
|
7713
|
+
convertValueToReactNode,
|
|
7714
|
+
convertValueToId,
|
|
7715
|
+
onOptionClick: handleOptionClick
|
|
7714
7716
|
})
|
|
7715
7717
|
}))
|
|
7716
7718
|
})
|