@cloud-ru/uikit-product-mobile-fields 2.2.5-preview-0d3148a1.0 → 2.2.5
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/CHANGELOG.md +11 -0
- package/dist/cjs/components/MobileFieldSelect/MobileFieldSelectMultiple.js +2 -3
- package/dist/cjs/components/MobileFieldSelect/MobileFieldSelectSingle.js +4 -8
- package/dist/cjs/components/MobileFieldSelect/hooks.d.ts +5 -8
- package/dist/cjs/components/MobileFieldSelect/hooks.js +9 -16
- package/dist/cjs/components/MobileFieldSelect/index.d.ts +0 -2
- package/dist/cjs/components/MobileFieldSelect/index.js +1 -6
- package/dist/cjs/components/MobileFieldSelect/types.d.ts +2 -8
- package/dist/cjs/components/MobileFieldSelect/utils/extractListProps.d.ts +1 -1
- package/dist/cjs/components/MobileFieldSelect/utils/extractListProps.js +1 -6
- package/dist/esm/components/MobileFieldSelect/MobileFieldSelectMultiple.js +2 -3
- package/dist/esm/components/MobileFieldSelect/MobileFieldSelectSingle.js +4 -8
- package/dist/esm/components/MobileFieldSelect/hooks.d.ts +5 -8
- package/dist/esm/components/MobileFieldSelect/hooks.js +9 -16
- package/dist/esm/components/MobileFieldSelect/index.d.ts +0 -2
- package/dist/esm/components/MobileFieldSelect/index.js +0 -1
- package/dist/esm/components/MobileFieldSelect/types.d.ts +2 -8
- package/dist/esm/components/MobileFieldSelect/utils/extractListProps.d.ts +1 -1
- package/dist/esm/components/MobileFieldSelect/utils/extractListProps.js +1 -6
- package/package.json +5 -5
- package/src/components/MobileFieldSelect/MobileFieldSelectMultiple.tsx +0 -2
- package/src/components/MobileFieldSelect/MobileFieldSelectSingle.tsx +2 -9
- package/src/components/MobileFieldSelect/hooks.tsx +6 -25
- package/src/components/MobileFieldSelect/index.ts +0 -12
- package/src/components/MobileFieldSelect/types.ts +2 -21
- package/src/components/MobileFieldSelect/utils/extractListProps.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 2.2.5 (2026-07-25)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@cloud-ru/uikit-product-icons@17.8.0]($PUBLIC_PROJECT_URL/blob/master/packages/icons/CHANGELOG.md)
|
|
10
|
+
* [@cloud-ru/uikit-product-mobile-dropdown@2.1.20]($PUBLIC_PROJECT_URL/blob/master/packages/mobile-dropdown/CHANGELOG.md)
|
|
11
|
+
* [@cloud-ru/uikit-product-mobile-modal@2.2.3]($PUBLIC_PROJECT_URL/blob/master/packages/mobile-modal/CHANGELOG.md)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 2.2.4 (2026-07-21)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
|
@@ -39,7 +39,7 @@ const defaultSelectedOptionFormatter = item =>
|
|
|
39
39
|
// @ts-ignore
|
|
40
40
|
(item === null || item === void 0 ? void 0 : item.content.option) || '';
|
|
41
41
|
exports.MobileFieldSelectMultiple = (0, react_1.forwardRef)((_a, ref) => {
|
|
42
|
-
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showClearButton = true, onKeyDown: onInputKeyDownProp, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, removeByBackspace = false, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter
|
|
42
|
+
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showClearButton = true, onKeyDown: onInputKeyDownProp, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, removeByBackspace = false, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter } = _a, rest = __rest(_a, ["id", "name", "placeholder", "size", "options", "virtualized", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showClearButton", "onKeyDown", "validationState", "search", "enableFuzzySearch", "autocomplete", "autoFocus", "prefixIcon", "prefix", "postfix", "removeByBackspace", "addOptionByEnter", "addCustomOptionTriggers", "open", "onOpenChange", "selectedOptionFormatter"]);
|
|
43
43
|
const { t } = (0, uikit_product_locale_1.useLocale)('MobileFields');
|
|
44
44
|
const localRef = (0, react_1.useRef)(null);
|
|
45
45
|
const contentRef = (0, react_1.useRef)(null);
|
|
@@ -51,8 +51,7 @@ exports.MobileFieldSelectMultiple = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
51
51
|
});
|
|
52
52
|
const [{ selectedItems, items = [] }, setItems] = (0, react_1.useState)(() => (0, utils_2.updateMultipleItems)({ options, value, currentItems: [], selectedItems: undefined }));
|
|
53
53
|
const { flattenItems } = (0, react_1.useMemo)(() => (0, list_1.kindFlattenItems)({ items }), [items]);
|
|
54
|
-
const { inputValue, setInputValue, prevInputValue, updateInputValue } = (0, hooks_2.useSearchInput)(Object.assign(Object.assign({}, search), { defaultValue: '', selectedOptionFormatter
|
|
55
|
-
resetSearchOnOptionSelection }));
|
|
54
|
+
const { inputValue, setInputValue, prevInputValue, updateInputValue } = (0, hooks_2.useSearchInput)(Object.assign(Object.assign({}, search), { defaultValue: '', selectedOptionFormatter }));
|
|
56
55
|
const { resolvedAddCustomOptionTriggers, tryCommitCustomOptionFromInput } = (0, fields_1.useFieldSelectMultipleCustomOption)({
|
|
57
56
|
addCustomOptionTriggers,
|
|
58
57
|
addOptionByEnter,
|
|
@@ -35,7 +35,7 @@ const defaultSelectedOptionFormatter = item =>
|
|
|
35
35
|
// @ts-expect-error
|
|
36
36
|
(item === null || item === void 0 ? void 0 : item.content.option) || '';
|
|
37
37
|
exports.MobileFieldSelectSingle = (0, react_1.forwardRef)((_a, ref) => {
|
|
38
|
-
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showCopyButton = true, showClearButton = true, onKeyDown: onInputKeyDownProp, required = false, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter
|
|
38
|
+
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showCopyButton = true, showClearButton = true, onKeyDown: onInputKeyDownProp, required = false, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter } = _a, rest = __rest(_a, ["id", "name", "placeholder", "size", "options", "virtualized", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showCopyButton", "showClearButton", "onKeyDown", "required", "validationState", "search", "enableFuzzySearch", "autocomplete", "autoFocus", "prefixIcon", "prefix", "postfix", "addOptionByEnter", "addCustomOptionTriggers", "open", "onOpenChange", "selectedOptionFormatter"]);
|
|
39
39
|
const localRef = (0, react_1.useRef)(null);
|
|
40
40
|
const [open = false, setOpen] = (0, utils_1.useValueControl)({ value: openProp, onChange: onOpenChange });
|
|
41
41
|
const [value, setValue] = (0, utils_1.useValueControl)({
|
|
@@ -44,8 +44,7 @@ exports.MobileFieldSelectSingle = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
44
44
|
onChange: onChangeProp,
|
|
45
45
|
});
|
|
46
46
|
const [{ selectedItem, items = [] }, setItems] = (0, react_1.useState)(() => (0, utils_2.updateItems)({ options, value, currentItems: [], selectedItem: undefined }));
|
|
47
|
-
const { inputValue, setInputValue, prevInputValue } = (0, hooks_2.useSearchInput)(Object.assign(Object.assign({}, search), { selectedOptionFormatter
|
|
48
|
-
resetSearchOnOptionSelection }));
|
|
47
|
+
const { inputValue, setInputValue, prevInputValue } = (0, hooks_2.useSearchInput)(Object.assign(Object.assign({}, search), { selectedOptionFormatter }));
|
|
49
48
|
const prevSelectedItem = (0, react_1.useRef)(selectedItem);
|
|
50
49
|
const prefixSettings = (0, hooks_1.usePrefix)({ prefix, disabled });
|
|
51
50
|
const postfixSettings = (0, hooks_1.usePostfix)({ postfix, disabled });
|
|
@@ -63,11 +62,9 @@ exports.MobileFieldSelectSingle = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
prevSelectedItem.current = selectedItem;
|
|
66
|
-
|
|
67
|
-
setInputValue('');
|
|
68
|
-
}
|
|
65
|
+
setInputValue('');
|
|
69
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
-
}, [selectedItem, prevSelectedItem
|
|
67
|
+
}, [selectedItem, prevSelectedItem]);
|
|
71
68
|
const onClear = (0, react_1.useCallback)(() => {
|
|
72
69
|
var _a;
|
|
73
70
|
setValue(undefined);
|
|
@@ -84,7 +81,6 @@ exports.MobileFieldSelectSingle = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
84
81
|
showCopyButton,
|
|
85
82
|
inputRef: localRef,
|
|
86
83
|
onClear,
|
|
87
|
-
onCopyButtonClick,
|
|
88
84
|
valueToCopy: selectedOptionFormatter(selectedItem),
|
|
89
85
|
});
|
|
90
86
|
const handleSelectionChange = (0, react_1.useCallback)((newValue) => {
|
|
@@ -15,35 +15,32 @@ type UseCopyButtonProps = {
|
|
|
15
15
|
valueToCopy: string;
|
|
16
16
|
size: Size;
|
|
17
17
|
onValueRequest?(): AsyncValueRequest;
|
|
18
|
-
onCopyButtonClick?(): void;
|
|
19
18
|
disabled?: boolean;
|
|
20
19
|
prefix?: string;
|
|
21
20
|
postfix?: string;
|
|
22
21
|
};
|
|
23
|
-
export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest,
|
|
22
|
+
export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix, postfix, }: UseCopyButtonProps): ButtonProps;
|
|
24
23
|
type UseButtonsProps = {
|
|
25
24
|
readonly: boolean;
|
|
26
25
|
showClearButton: boolean;
|
|
27
26
|
showCopyButton: boolean;
|
|
28
27
|
size: 's' | 'm' | 'l';
|
|
29
28
|
onClear(): void;
|
|
30
|
-
onCopyButtonClick?(): void;
|
|
31
29
|
inputRef: RefObject<HTMLInputElement>;
|
|
32
30
|
valueToCopy?: string;
|
|
33
31
|
};
|
|
34
|
-
export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
32
|
+
export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, inputRef, valueToCopy, }: UseButtonsProps): {
|
|
35
33
|
postfixButtons: import("react/jsx-runtime").JSX.Element | undefined;
|
|
36
34
|
inputKeyDownNavigationHandler: KeyboardEventHandler<HTMLInputElement>;
|
|
37
35
|
buttonsRefs: (Element | null)[];
|
|
38
36
|
};
|
|
39
|
-
export declare function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter,
|
|
37
|
+
export declare function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter, }: SearchState & {
|
|
40
38
|
selectedOptionFormatter: SelectedOptionFormatter;
|
|
41
|
-
resetSearchOnOptionSelection?: boolean;
|
|
42
39
|
}): {
|
|
43
40
|
inputValue: string;
|
|
44
|
-
setInputValue: (value:
|
|
41
|
+
setInputValue: (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void;
|
|
45
42
|
prevInputValue: import("react").MutableRefObject<string>;
|
|
46
|
-
onInputValueChange: (value:
|
|
43
|
+
onInputValueChange: (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void;
|
|
47
44
|
updateInputValue: (selectedItem?: ItemWithId) => void;
|
|
48
45
|
};
|
|
49
46
|
export declare function useHandleDeleteItem(setValue: Handler): (item?: ItemWithId) => (e?: MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -34,16 +34,16 @@ function useHandleOnKeyDown({ setOpen, inputKeyDownNavigationHandler, onInputKey
|
|
|
34
34
|
onInputKeyDownProp === null || onInputKeyDownProp === void 0 ? void 0 : onInputKeyDownProp(e);
|
|
35
35
|
}, [inputKeyDownNavigationHandler, onInputKeyDownProp, setOpen]);
|
|
36
36
|
}
|
|
37
|
-
function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest,
|
|
37
|
+
function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix = '', postfix = '', }) {
|
|
38
38
|
return (0, react_1.useMemo)(() => ({
|
|
39
39
|
id: 'copy',
|
|
40
40
|
active: true,
|
|
41
41
|
ref: copyButtonRef,
|
|
42
42
|
show: showCopyButton,
|
|
43
|
-
render: props => ((0, jsx_runtime_1.jsx)(helperComponents_1.ButtonCopyValue, Object.assign({}, props, { size: input_private_1.BUTTON_SIZE_MAP[size], valueToCopy: (prefix !== null && prefix !== void 0 ? prefix : '') + valueToCopy + (postfix !== null && postfix !== void 0 ? postfix : ''), onValueRequest: onValueRequest,
|
|
44
|
-
}), [copyButtonRef, disabled,
|
|
43
|
+
render: props => ((0, jsx_runtime_1.jsx)(helperComponents_1.ButtonCopyValue, Object.assign({}, props, { size: input_private_1.BUTTON_SIZE_MAP[size], valueToCopy: (prefix !== null && prefix !== void 0 ? prefix : '') + valueToCopy + (postfix !== null && postfix !== void 0 ? postfix : ''), onValueRequest: onValueRequest, disabled: disabled }))),
|
|
44
|
+
}), [copyButtonRef, disabled, onValueRequest, showCopyButton, size, valueToCopy, prefix, postfix]);
|
|
45
45
|
}
|
|
46
|
-
function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
46
|
+
function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, inputRef, valueToCopy = '', }) {
|
|
47
47
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
48
48
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
49
49
|
const buttonsRefs = [copyButtonRef.current, clearButtonRef.current];
|
|
@@ -58,7 +58,6 @@ function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
|
58
58
|
showCopyButton: readonly && showCopyButton,
|
|
59
59
|
size,
|
|
60
60
|
valueToCopy,
|
|
61
|
-
onCopyButtonClick,
|
|
62
61
|
});
|
|
63
62
|
const { onInputKeyDown: inputKeyDownNavigationHandler, postfixButtons } = (0, input_private_1.useButtonNavigation)({
|
|
64
63
|
inputRef,
|
|
@@ -69,22 +68,16 @@ function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
|
69
68
|
});
|
|
70
69
|
return { postfixButtons, inputKeyDownNavigationHandler, buttonsRefs };
|
|
71
70
|
}
|
|
72
|
-
function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter,
|
|
73
|
-
const [inputValue = '',
|
|
71
|
+
function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter, }) {
|
|
72
|
+
const [inputValue = '', setInputValue] = (0, utils_1.useValueControl)({ value, onChange, defaultValue });
|
|
74
73
|
const prevInputValue = (0, react_1.useRef)(inputValue);
|
|
75
74
|
const updateInputValue = (0, react_1.useCallback)((selectedItem) => {
|
|
76
75
|
const newInputValue = selectedOptionFormatter(selectedItem);
|
|
77
|
-
if (
|
|
78
|
-
|
|
76
|
+
if (inputValue !== newInputValue || prevInputValue.current !== newInputValue) {
|
|
77
|
+
setInputValue(newInputValue);
|
|
79
78
|
prevInputValue.current = newInputValue;
|
|
80
79
|
}
|
|
81
|
-
}, [inputValue,
|
|
82
|
-
const setInputValue = (0, react_1.useCallback)((value) => {
|
|
83
|
-
const updatedValue = prevInputValue.current && value.includes(prevInputValue.current)
|
|
84
|
-
? value.replace(prevInputValue.current, '')
|
|
85
|
-
: value;
|
|
86
|
-
setInputValueState(updatedValue);
|
|
87
|
-
}, [setInputValueState]);
|
|
80
|
+
}, [inputValue, selectedOptionFormatter, setInputValue]);
|
|
88
81
|
return { inputValue, setInputValue, prevInputValue, onInputValueChange: setInputValue, updateInputValue };
|
|
89
82
|
}
|
|
90
83
|
function useHandleDeleteItem(setValue) {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export { MobileFieldSelect } from './MobileFieldSelect';
|
|
2
2
|
export type { MobileFieldSelectSingleProps, MobileFieldSelectMultipleProps, MobileFieldSelectProps, OptionProps, BaseOptionProps, AccordionOptionProps, NestListOptionProps, GroupOptionProps, SelectedOptionFormatter, } from './types';
|
|
3
|
-
export type { FieldSelectMultipleAddCustomOptionTrigger, FieldSelectSingleAddCustomOptionTrigger, } from '@snack-uikit/fields';
|
|
4
|
-
export { getCustomOptionTriggerByCode, shouldHandleCustomOptionTrigger, useFieldSelectMultipleCustomOption, useFieldSelectSingleCustomOption, } from '@snack-uikit/fields';
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MobileFieldSelect = void 0;
|
|
4
4
|
var MobileFieldSelect_1 = require("./MobileFieldSelect");
|
|
5
5
|
Object.defineProperty(exports, "MobileFieldSelect", { enumerable: true, get: function () { return MobileFieldSelect_1.MobileFieldSelect; } });
|
|
6
|
-
var fields_1 = require("@snack-uikit/fields");
|
|
7
|
-
Object.defineProperty(exports, "getCustomOptionTriggerByCode", { enumerable: true, get: function () { return fields_1.getCustomOptionTriggerByCode; } });
|
|
8
|
-
Object.defineProperty(exports, "shouldHandleCustomOptionTrigger", { enumerable: true, get: function () { return fields_1.shouldHandleCustomOptionTrigger; } });
|
|
9
|
-
Object.defineProperty(exports, "useFieldSelectMultipleCustomOption", { enumerable: true, get: function () { return fields_1.useFieldSelectMultipleCustomOption; } });
|
|
10
|
-
Object.defineProperty(exports, "useFieldSelectSingleCustomOption", { enumerable: true, get: function () { return fields_1.useFieldSelectSingleCustomOption; } });
|
|
@@ -46,8 +46,6 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
46
46
|
searchable?: boolean;
|
|
47
47
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
48
48
|
showCopyButton?: boolean;
|
|
49
|
-
/** Колбек клика по кнопке Копировать для поля */
|
|
50
|
-
onCopyButtonClick?(): void;
|
|
51
49
|
/**
|
|
52
50
|
* Отображение кнопки очистки поля
|
|
53
51
|
* @default true
|
|
@@ -74,17 +72,13 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
74
72
|
enableFuzzySearch?: boolean;
|
|
75
73
|
autocomplete?: boolean;
|
|
76
74
|
open?: boolean;
|
|
77
|
-
/** Поведение строки поиска при выборе опции из списка, false необходимо при асинхронной подгрузке значений с бэка, в случае если надо поиск оставить как значение при отсутствии данных
|
|
78
|
-
* @default true
|
|
79
|
-
*/
|
|
80
|
-
resetSearchOnOptionSelection?: boolean;
|
|
81
75
|
onOpenChange?(open: boolean): void;
|
|
82
76
|
selectedOptionFormatter?: SelectedOptionFormatter;
|
|
83
|
-
}> & Pick<FieldSelectProps, 'addOptionByEnter'> & Pick<DroplistProps, 'dataError' | 'noDataState' | 'noResultsState' | 'errorDataState' | 'dataFiltered'
|
|
77
|
+
}> & Pick<FieldSelectProps, 'addOptionByEnter'> & Pick<DroplistProps, 'dataError' | 'noDataState' | 'noResultsState' | 'errorDataState' | 'dataFiltered'>;
|
|
84
78
|
export type MobileFieldSelectSingleProps = FieldSelectPrivateProps & Omit<SelectionSingleState, 'mode'> & WrapperProps & FiledSelectCommonProps & Pick<FieldSelectSingleProps, 'addCustomOptionTriggers'>;
|
|
85
79
|
export type MobileFieldSelectMultipleProps = FieldSelectPrivateProps & {
|
|
86
80
|
removeByBackspace?: boolean;
|
|
87
|
-
} & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton'
|
|
81
|
+
} & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton'> & Pick<FieldSelectMultipleProps, 'addCustomOptionTriggers'>;
|
|
88
82
|
export type MobileFieldSelectProps = (MobileFieldSelectSingleProps & {
|
|
89
83
|
selection?: 'single';
|
|
90
84
|
}) | (MobileFieldSelectMultipleProps & {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DroplistProps } from '@snack-uikit/list';
|
|
2
2
|
import { MobileFieldSelectProps } from '../types';
|
|
3
|
-
export declare function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy,
|
|
3
|
+
export declare function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy, }: Partial<MobileFieldSelectProps>): Partial<DroplistProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractListProps = extractListProps;
|
|
4
|
-
function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy,
|
|
4
|
+
function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy, }) {
|
|
5
5
|
return {
|
|
6
6
|
dataError,
|
|
7
7
|
noDataState,
|
|
@@ -11,11 +11,6 @@ function extractListProps({ dataError, noDataState, noResultsState, errorDataSta
|
|
|
11
11
|
loading,
|
|
12
12
|
footer,
|
|
13
13
|
widthStrategy,
|
|
14
|
-
scrollToSelectedItem,
|
|
15
|
-
scrollRef,
|
|
16
|
-
scrollContainerRef,
|
|
17
|
-
onScroll,
|
|
18
|
-
untouchableScrollbars,
|
|
19
14
|
trigger: 'clickAndFocusVisible',
|
|
20
15
|
placement: 'bottom',
|
|
21
16
|
'data-test-id': 'field-select__list',
|
|
@@ -33,7 +33,7 @@ const defaultSelectedOptionFormatter = item =>
|
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
(item === null || item === void 0 ? void 0 : item.content.option) || '';
|
|
35
35
|
export const MobileFieldSelectMultiple = forwardRef((_a, ref) => {
|
|
36
|
-
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showClearButton = true, onKeyDown: onInputKeyDownProp, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, removeByBackspace = false, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter
|
|
36
|
+
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showClearButton = true, onKeyDown: onInputKeyDownProp, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, removeByBackspace = false, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter } = _a, rest = __rest(_a, ["id", "name", "placeholder", "size", "options", "virtualized", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showClearButton", "onKeyDown", "validationState", "search", "enableFuzzySearch", "autocomplete", "autoFocus", "prefixIcon", "prefix", "postfix", "removeByBackspace", "addOptionByEnter", "addCustomOptionTriggers", "open", "onOpenChange", "selectedOptionFormatter"]);
|
|
37
37
|
const { t } = useLocale('MobileFields');
|
|
38
38
|
const localRef = useRef(null);
|
|
39
39
|
const contentRef = useRef(null);
|
|
@@ -45,8 +45,7 @@ export const MobileFieldSelectMultiple = forwardRef((_a, ref) => {
|
|
|
45
45
|
});
|
|
46
46
|
const [{ selectedItems, items = [] }, setItems] = useState(() => updateMultipleItems({ options, value, currentItems: [], selectedItems: undefined }));
|
|
47
47
|
const { flattenItems } = useMemo(() => kindFlattenItems({ items }), [items]);
|
|
48
|
-
const { inputValue, setInputValue, prevInputValue, updateInputValue } = useSearchInput(Object.assign(Object.assign({}, search), { defaultValue: '', selectedOptionFormatter
|
|
49
|
-
resetSearchOnOptionSelection }));
|
|
48
|
+
const { inputValue, setInputValue, prevInputValue, updateInputValue } = useSearchInput(Object.assign(Object.assign({}, search), { defaultValue: '', selectedOptionFormatter }));
|
|
50
49
|
const { resolvedAddCustomOptionTriggers, tryCommitCustomOptionFromInput } = useFieldSelectMultipleCustomOption({
|
|
51
50
|
addCustomOptionTriggers,
|
|
52
51
|
addOptionByEnter,
|
|
@@ -29,7 +29,7 @@ const defaultSelectedOptionFormatter = item =>
|
|
|
29
29
|
// @ts-expect-error
|
|
30
30
|
(item === null || item === void 0 ? void 0 : item.content.option) || '';
|
|
31
31
|
export const MobileFieldSelectSingle = forwardRef((_a, ref) => {
|
|
32
|
-
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showCopyButton = true, showClearButton = true, onKeyDown: onInputKeyDownProp, required = false, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter
|
|
32
|
+
var { id, name, placeholder, size = 's', options, virtualized, value: valueProp, defaultValue, onChange: onChangeProp, disabled = false, readonly = false, searchable: searchableProp = true, showCopyButton = true, showClearButton = true, onKeyDown: onInputKeyDownProp, required = false, validationState = 'default', search, enableFuzzySearch = true, autocomplete = false, autoFocus, prefixIcon, prefix, postfix, addOptionByEnter = false, addCustomOptionTriggers, open: openProp, onOpenChange, selectedOptionFormatter = defaultSelectedOptionFormatter } = _a, rest = __rest(_a, ["id", "name", "placeholder", "size", "options", "virtualized", "value", "defaultValue", "onChange", "disabled", "readonly", "searchable", "showCopyButton", "showClearButton", "onKeyDown", "required", "validationState", "search", "enableFuzzySearch", "autocomplete", "autoFocus", "prefixIcon", "prefix", "postfix", "addOptionByEnter", "addCustomOptionTriggers", "open", "onOpenChange", "selectedOptionFormatter"]);
|
|
33
33
|
const localRef = useRef(null);
|
|
34
34
|
const [open = false, setOpen] = useValueControl({ value: openProp, onChange: onOpenChange });
|
|
35
35
|
const [value, setValue] = useValueControl({
|
|
@@ -38,8 +38,7 @@ export const MobileFieldSelectSingle = forwardRef((_a, ref) => {
|
|
|
38
38
|
onChange: onChangeProp,
|
|
39
39
|
});
|
|
40
40
|
const [{ selectedItem, items = [] }, setItems] = useState(() => updateItems({ options, value, currentItems: [], selectedItem: undefined }));
|
|
41
|
-
const { inputValue, setInputValue, prevInputValue } = useSearchInput(Object.assign(Object.assign({}, search), { selectedOptionFormatter
|
|
42
|
-
resetSearchOnOptionSelection }));
|
|
41
|
+
const { inputValue, setInputValue, prevInputValue } = useSearchInput(Object.assign(Object.assign({}, search), { selectedOptionFormatter }));
|
|
43
42
|
const prevSelectedItem = useRef(selectedItem);
|
|
44
43
|
const prefixSettings = usePrefix({ prefix, disabled });
|
|
45
44
|
const postfixSettings = usePostfix({ postfix, disabled });
|
|
@@ -57,11 +56,9 @@ export const MobileFieldSelectSingle = forwardRef((_a, ref) => {
|
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
prevSelectedItem.current = selectedItem;
|
|
60
|
-
|
|
61
|
-
setInputValue('');
|
|
62
|
-
}
|
|
59
|
+
setInputValue('');
|
|
63
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, [selectedItem, prevSelectedItem
|
|
61
|
+
}, [selectedItem, prevSelectedItem]);
|
|
65
62
|
const onClear = useCallback(() => {
|
|
66
63
|
var _a;
|
|
67
64
|
setValue(undefined);
|
|
@@ -78,7 +75,6 @@ export const MobileFieldSelectSingle = forwardRef((_a, ref) => {
|
|
|
78
75
|
showCopyButton,
|
|
79
76
|
inputRef: localRef,
|
|
80
77
|
onClear,
|
|
81
|
-
onCopyButtonClick,
|
|
82
78
|
valueToCopy: selectedOptionFormatter(selectedItem),
|
|
83
79
|
});
|
|
84
80
|
const handleSelectionChange = useCallback((newValue) => {
|
|
@@ -15,35 +15,32 @@ type UseCopyButtonProps = {
|
|
|
15
15
|
valueToCopy: string;
|
|
16
16
|
size: Size;
|
|
17
17
|
onValueRequest?(): AsyncValueRequest;
|
|
18
|
-
onCopyButtonClick?(): void;
|
|
19
18
|
disabled?: boolean;
|
|
20
19
|
prefix?: string;
|
|
21
20
|
postfix?: string;
|
|
22
21
|
};
|
|
23
|
-
export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest,
|
|
22
|
+
export declare function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix, postfix, }: UseCopyButtonProps): ButtonProps;
|
|
24
23
|
type UseButtonsProps = {
|
|
25
24
|
readonly: boolean;
|
|
26
25
|
showClearButton: boolean;
|
|
27
26
|
showCopyButton: boolean;
|
|
28
27
|
size: 's' | 'm' | 'l';
|
|
29
28
|
onClear(): void;
|
|
30
|
-
onCopyButtonClick?(): void;
|
|
31
29
|
inputRef: RefObject<HTMLInputElement>;
|
|
32
30
|
valueToCopy?: string;
|
|
33
31
|
};
|
|
34
|
-
export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
32
|
+
export declare function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, inputRef, valueToCopy, }: UseButtonsProps): {
|
|
35
33
|
postfixButtons: import("react/jsx-runtime").JSX.Element | undefined;
|
|
36
34
|
inputKeyDownNavigationHandler: KeyboardEventHandler<HTMLInputElement>;
|
|
37
35
|
buttonsRefs: (Element | null)[];
|
|
38
36
|
};
|
|
39
|
-
export declare function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter,
|
|
37
|
+
export declare function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter, }: SearchState & {
|
|
40
38
|
selectedOptionFormatter: SelectedOptionFormatter;
|
|
41
|
-
resetSearchOnOptionSelection?: boolean;
|
|
42
39
|
}): {
|
|
43
40
|
inputValue: string;
|
|
44
|
-
setInputValue: (value:
|
|
41
|
+
setInputValue: (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void;
|
|
45
42
|
prevInputValue: import("react").MutableRefObject<string>;
|
|
46
|
-
onInputValueChange: (value:
|
|
43
|
+
onInputValueChange: (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void;
|
|
47
44
|
updateInputValue: (selectedItem?: ItemWithId) => void;
|
|
48
45
|
};
|
|
49
46
|
export declare function useHandleDeleteItem(setValue: Handler): (item?: ItemWithId) => (e?: MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -27,16 +27,16 @@ export function useHandleOnKeyDown({ setOpen, inputKeyDownNavigationHandler, onI
|
|
|
27
27
|
onInputKeyDownProp === null || onInputKeyDownProp === void 0 ? void 0 : onInputKeyDownProp(e);
|
|
28
28
|
}, [inputKeyDownNavigationHandler, onInputKeyDownProp, setOpen]);
|
|
29
29
|
}
|
|
30
|
-
export function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest,
|
|
30
|
+
export function useCopyButton({ copyButtonRef, showCopyButton, size, valueToCopy, onValueRequest, disabled, prefix = '', postfix = '', }) {
|
|
31
31
|
return useMemo(() => ({
|
|
32
32
|
id: 'copy',
|
|
33
33
|
active: true,
|
|
34
34
|
ref: copyButtonRef,
|
|
35
35
|
show: showCopyButton,
|
|
36
|
-
render: props => (_jsx(ButtonCopyValue, Object.assign({}, props, { size: BUTTON_SIZE_MAP[size], valueToCopy: (prefix !== null && prefix !== void 0 ? prefix : '') + valueToCopy + (postfix !== null && postfix !== void 0 ? postfix : ''), onValueRequest: onValueRequest,
|
|
37
|
-
}), [copyButtonRef, disabled,
|
|
36
|
+
render: props => (_jsx(ButtonCopyValue, Object.assign({}, props, { size: BUTTON_SIZE_MAP[size], valueToCopy: (prefix !== null && prefix !== void 0 ? prefix : '') + valueToCopy + (postfix !== null && postfix !== void 0 ? postfix : ''), onValueRequest: onValueRequest, disabled: disabled }))),
|
|
37
|
+
}), [copyButtonRef, disabled, onValueRequest, showCopyButton, size, valueToCopy, prefix, postfix]);
|
|
38
38
|
}
|
|
39
|
-
export function useButtons({ readonly, showClearButton, showCopyButton, size, onClear,
|
|
39
|
+
export function useButtons({ readonly, showClearButton, showCopyButton, size, onClear, inputRef, valueToCopy = '', }) {
|
|
40
40
|
const clearButtonRef = useRef(null);
|
|
41
41
|
const copyButtonRef = useRef(null);
|
|
42
42
|
const buttonsRefs = [copyButtonRef.current, clearButtonRef.current];
|
|
@@ -51,7 +51,6 @@ export function useButtons({ readonly, showClearButton, showCopyButton, size, on
|
|
|
51
51
|
showCopyButton: readonly && showCopyButton,
|
|
52
52
|
size,
|
|
53
53
|
valueToCopy,
|
|
54
|
-
onCopyButtonClick,
|
|
55
54
|
});
|
|
56
55
|
const { onInputKeyDown: inputKeyDownNavigationHandler, postfixButtons } = useButtonNavigation({
|
|
57
56
|
inputRef,
|
|
@@ -62,22 +61,16 @@ export function useButtons({ readonly, showClearButton, showCopyButton, size, on
|
|
|
62
61
|
});
|
|
63
62
|
return { postfixButtons, inputKeyDownNavigationHandler, buttonsRefs };
|
|
64
63
|
}
|
|
65
|
-
export function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter,
|
|
66
|
-
const [inputValue = '',
|
|
64
|
+
export function useSearchInput({ value, onChange, defaultValue, selectedOptionFormatter, }) {
|
|
65
|
+
const [inputValue = '', setInputValue] = useValueControl({ value, onChange, defaultValue });
|
|
67
66
|
const prevInputValue = useRef(inputValue);
|
|
68
67
|
const updateInputValue = useCallback((selectedItem) => {
|
|
69
68
|
const newInputValue = selectedOptionFormatter(selectedItem);
|
|
70
|
-
if (
|
|
71
|
-
|
|
69
|
+
if (inputValue !== newInputValue || prevInputValue.current !== newInputValue) {
|
|
70
|
+
setInputValue(newInputValue);
|
|
72
71
|
prevInputValue.current = newInputValue;
|
|
73
72
|
}
|
|
74
|
-
}, [inputValue,
|
|
75
|
-
const setInputValue = useCallback((value) => {
|
|
76
|
-
const updatedValue = prevInputValue.current && value.includes(prevInputValue.current)
|
|
77
|
-
? value.replace(prevInputValue.current, '')
|
|
78
|
-
: value;
|
|
79
|
-
setInputValueState(updatedValue);
|
|
80
|
-
}, [setInputValueState]);
|
|
73
|
+
}, [inputValue, selectedOptionFormatter, setInputValue]);
|
|
81
74
|
return { inputValue, setInputValue, prevInputValue, onInputValueChange: setInputValue, updateInputValue };
|
|
82
75
|
}
|
|
83
76
|
export function useHandleDeleteItem(setValue) {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export { MobileFieldSelect } from './MobileFieldSelect';
|
|
2
2
|
export type { MobileFieldSelectSingleProps, MobileFieldSelectMultipleProps, MobileFieldSelectProps, OptionProps, BaseOptionProps, AccordionOptionProps, NestListOptionProps, GroupOptionProps, SelectedOptionFormatter, } from './types';
|
|
3
|
-
export type { FieldSelectMultipleAddCustomOptionTrigger, FieldSelectSingleAddCustomOptionTrigger, } from '@snack-uikit/fields';
|
|
4
|
-
export { getCustomOptionTriggerByCode, shouldHandleCustomOptionTrigger, useFieldSelectMultipleCustomOption, useFieldSelectSingleCustomOption, } from '@snack-uikit/fields';
|
|
@@ -46,8 +46,6 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
46
46
|
searchable?: boolean;
|
|
47
47
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
48
48
|
showCopyButton?: boolean;
|
|
49
|
-
/** Колбек клика по кнопке Копировать для поля */
|
|
50
|
-
onCopyButtonClick?(): void;
|
|
51
49
|
/**
|
|
52
50
|
* Отображение кнопки очистки поля
|
|
53
51
|
* @default true
|
|
@@ -74,17 +72,13 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
74
72
|
enableFuzzySearch?: boolean;
|
|
75
73
|
autocomplete?: boolean;
|
|
76
74
|
open?: boolean;
|
|
77
|
-
/** Поведение строки поиска при выборе опции из списка, false необходимо при асинхронной подгрузке значений с бэка, в случае если надо поиск оставить как значение при отсутствии данных
|
|
78
|
-
* @default true
|
|
79
|
-
*/
|
|
80
|
-
resetSearchOnOptionSelection?: boolean;
|
|
81
75
|
onOpenChange?(open: boolean): void;
|
|
82
76
|
selectedOptionFormatter?: SelectedOptionFormatter;
|
|
83
|
-
}> & Pick<FieldSelectProps, 'addOptionByEnter'> & Pick<DroplistProps, 'dataError' | 'noDataState' | 'noResultsState' | 'errorDataState' | 'dataFiltered'
|
|
77
|
+
}> & Pick<FieldSelectProps, 'addOptionByEnter'> & Pick<DroplistProps, 'dataError' | 'noDataState' | 'noResultsState' | 'errorDataState' | 'dataFiltered'>;
|
|
84
78
|
export type MobileFieldSelectSingleProps = FieldSelectPrivateProps & Omit<SelectionSingleState, 'mode'> & WrapperProps & FiledSelectCommonProps & Pick<FieldSelectSingleProps, 'addCustomOptionTriggers'>;
|
|
85
79
|
export type MobileFieldSelectMultipleProps = FieldSelectPrivateProps & {
|
|
86
80
|
removeByBackspace?: boolean;
|
|
87
|
-
} & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton'
|
|
81
|
+
} & Omit<SelectionMultipleState, 'mode'> & Omit<FiledSelectCommonProps, 'showCopyButton'> & Pick<FieldSelectMultipleProps, 'addCustomOptionTriggers'>;
|
|
88
82
|
export type MobileFieldSelectProps = (MobileFieldSelectSingleProps & {
|
|
89
83
|
selection?: 'single';
|
|
90
84
|
}) | (MobileFieldSelectMultipleProps & {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DroplistProps } from '@snack-uikit/list';
|
|
2
2
|
import { MobileFieldSelectProps } from '../types';
|
|
3
|
-
export declare function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy,
|
|
3
|
+
export declare function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy, }: Partial<MobileFieldSelectProps>): Partial<DroplistProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy,
|
|
1
|
+
export function extractListProps({ dataError, noDataState, noResultsState, errorDataState, dataFiltered, loading, footer, widthStrategy, }) {
|
|
2
2
|
return {
|
|
3
3
|
dataError,
|
|
4
4
|
noDataState,
|
|
@@ -8,11 +8,6 @@ export function extractListProps({ dataError, noDataState, noResultsState, error
|
|
|
8
8
|
loading,
|
|
9
9
|
footer,
|
|
10
10
|
widthStrategy,
|
|
11
|
-
scrollToSelectedItem,
|
|
12
|
-
scrollRef,
|
|
13
|
-
scrollContainerRef,
|
|
14
|
-
onScroll,
|
|
15
|
-
untouchableScrollbars,
|
|
16
11
|
trigger: 'clickAndFocusVisible',
|
|
17
12
|
placement: 'bottom',
|
|
18
13
|
'data-test-id': 'field-select__list',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-mobile-fields",
|
|
3
3
|
"title": "Mobile Fields",
|
|
4
|
-
"version": "2.2.5
|
|
4
|
+
"version": "2.2.5",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cloud-ru/uikit-product-icons": "17.
|
|
40
|
-
"@cloud-ru/uikit-product-mobile-dropdown": "2.1.
|
|
41
|
-
"@cloud-ru/uikit-product-mobile-modal": "2.2.
|
|
39
|
+
"@cloud-ru/uikit-product-icons": "17.8.0",
|
|
40
|
+
"@cloud-ru/uikit-product-mobile-dropdown": "2.1.20",
|
|
41
|
+
"@cloud-ru/uikit-product-mobile-modal": "2.2.3",
|
|
42
42
|
"@cloud-ru/uikit-product-utils": "9.1.0",
|
|
43
43
|
"@snack-uikit/button": "0.19.15",
|
|
44
44
|
"@snack-uikit/calendar": "0.14.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@cloud-ru/uikit-product-locale": "*"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "afdf1a34c4380b444d8d85aae085a5731887b418"
|
|
66
66
|
}
|
|
@@ -74,7 +74,6 @@ export const MobileFieldSelectMultiple: ForwardRefExoticComponent<
|
|
|
74
74
|
open: openProp,
|
|
75
75
|
onOpenChange,
|
|
76
76
|
selectedOptionFormatter = defaultSelectedOptionFormatter,
|
|
77
|
-
resetSearchOnOptionSelection = true,
|
|
78
77
|
...rest
|
|
79
78
|
},
|
|
80
79
|
ref,
|
|
@@ -103,7 +102,6 @@ export const MobileFieldSelectMultiple: ForwardRefExoticComponent<
|
|
|
103
102
|
...search,
|
|
104
103
|
defaultValue: '',
|
|
105
104
|
selectedOptionFormatter,
|
|
106
|
-
resetSearchOnOptionSelection,
|
|
107
105
|
});
|
|
108
106
|
|
|
109
107
|
const { resolvedAddCustomOptionTriggers, tryCommitCustomOptionFromInput } = useFieldSelectMultipleCustomOption({
|
|
@@ -68,8 +68,6 @@ export const MobileFieldSelectSingle: ForwardRefExoticComponent<
|
|
|
68
68
|
open: openProp,
|
|
69
69
|
onOpenChange,
|
|
70
70
|
selectedOptionFormatter = defaultSelectedOptionFormatter,
|
|
71
|
-
resetSearchOnOptionSelection = true,
|
|
72
|
-
onCopyButtonClick,
|
|
73
71
|
...rest
|
|
74
72
|
},
|
|
75
73
|
ref,
|
|
@@ -91,7 +89,6 @@ export const MobileFieldSelectSingle: ForwardRefExoticComponent<
|
|
|
91
89
|
const { inputValue, setInputValue, prevInputValue } = useSearchInput({
|
|
92
90
|
...search,
|
|
93
91
|
selectedOptionFormatter,
|
|
94
|
-
resetSearchOnOptionSelection,
|
|
95
92
|
});
|
|
96
93
|
|
|
97
94
|
const prevSelectedItem = useRef<ItemWithId | undefined>(selectedItem);
|
|
@@ -120,13 +117,10 @@ export const MobileFieldSelectSingle: ForwardRefExoticComponent<
|
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
prevSelectedItem.current = selectedItem;
|
|
123
|
-
|
|
124
|
-
if (resetSearchOnOptionSelection) {
|
|
125
|
-
setInputValue('');
|
|
126
|
-
}
|
|
120
|
+
setInputValue('');
|
|
127
121
|
|
|
128
122
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
}, [selectedItem, prevSelectedItem
|
|
123
|
+
}, [selectedItem, prevSelectedItem]);
|
|
130
124
|
|
|
131
125
|
const onClear = useCallback(() => {
|
|
132
126
|
setValue(undefined);
|
|
@@ -145,7 +139,6 @@ export const MobileFieldSelectSingle: ForwardRefExoticComponent<
|
|
|
145
139
|
showCopyButton,
|
|
146
140
|
inputRef: localRef,
|
|
147
141
|
onClear,
|
|
148
|
-
onCopyButtonClick,
|
|
149
142
|
valueToCopy: selectedOptionFormatter(selectedItem),
|
|
150
143
|
});
|
|
151
144
|
|
|
@@ -55,7 +55,6 @@ type UseCopyButtonProps = {
|
|
|
55
55
|
valueToCopy: string;
|
|
56
56
|
size: Size;
|
|
57
57
|
onValueRequest?(): AsyncValueRequest;
|
|
58
|
-
onCopyButtonClick?(): void;
|
|
59
58
|
disabled?: boolean;
|
|
60
59
|
prefix?: string;
|
|
61
60
|
postfix?: string;
|
|
@@ -67,7 +66,6 @@ export function useCopyButton({
|
|
|
67
66
|
size,
|
|
68
67
|
valueToCopy,
|
|
69
68
|
onValueRequest,
|
|
70
|
-
onCopyButtonClick,
|
|
71
69
|
disabled,
|
|
72
70
|
prefix = '',
|
|
73
71
|
postfix = '',
|
|
@@ -84,12 +82,11 @@ export function useCopyButton({
|
|
|
84
82
|
size={BUTTON_SIZE_MAP[size]}
|
|
85
83
|
valueToCopy={(prefix ?? '') + valueToCopy + (postfix ?? '')}
|
|
86
84
|
onValueRequest={onValueRequest}
|
|
87
|
-
onClick={onCopyButtonClick}
|
|
88
85
|
disabled={disabled}
|
|
89
86
|
/>
|
|
90
87
|
),
|
|
91
88
|
}),
|
|
92
|
-
[copyButtonRef, disabled,
|
|
89
|
+
[copyButtonRef, disabled, onValueRequest, showCopyButton, size, valueToCopy, prefix, postfix],
|
|
93
90
|
);
|
|
94
91
|
}
|
|
95
92
|
|
|
@@ -99,7 +96,6 @@ type UseButtonsProps = {
|
|
|
99
96
|
showCopyButton: boolean;
|
|
100
97
|
size: 's' | 'm' | 'l';
|
|
101
98
|
onClear(): void;
|
|
102
|
-
onCopyButtonClick?(): void;
|
|
103
99
|
inputRef: RefObject<HTMLInputElement>;
|
|
104
100
|
valueToCopy?: string;
|
|
105
101
|
};
|
|
@@ -110,7 +106,6 @@ export function useButtons({
|
|
|
110
106
|
showCopyButton,
|
|
111
107
|
size,
|
|
112
108
|
onClear,
|
|
113
|
-
onCopyButtonClick,
|
|
114
109
|
inputRef,
|
|
115
110
|
valueToCopy = '',
|
|
116
111
|
}: UseButtonsProps) {
|
|
@@ -130,7 +125,6 @@ export function useButtons({
|
|
|
130
125
|
showCopyButton: readonly && showCopyButton,
|
|
131
126
|
size,
|
|
132
127
|
valueToCopy,
|
|
133
|
-
onCopyButtonClick,
|
|
134
128
|
});
|
|
135
129
|
const { onInputKeyDown: inputKeyDownNavigationHandler, postfixButtons } = useButtonNavigation({
|
|
136
130
|
inputRef,
|
|
@@ -148,9 +142,8 @@ export function useSearchInput({
|
|
|
148
142
|
onChange,
|
|
149
143
|
defaultValue,
|
|
150
144
|
selectedOptionFormatter,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const [inputValue = '', setInputValueState] = useValueControl<string>({ value, onChange, defaultValue });
|
|
145
|
+
}: SearchState & { selectedOptionFormatter: SelectedOptionFormatter }) {
|
|
146
|
+
const [inputValue = '', setInputValue] = useValueControl<string>({ value, onChange, defaultValue });
|
|
154
147
|
|
|
155
148
|
const prevInputValue = useRef<string>(inputValue);
|
|
156
149
|
|
|
@@ -158,25 +151,13 @@ export function useSearchInput({
|
|
|
158
151
|
(selectedItem?: ItemWithId) => {
|
|
159
152
|
const newInputValue = selectedOptionFormatter(selectedItem);
|
|
160
153
|
|
|
161
|
-
if (
|
|
162
|
-
|
|
154
|
+
if (inputValue !== newInputValue || prevInputValue.current !== newInputValue) {
|
|
155
|
+
setInputValue(newInputValue);
|
|
163
156
|
|
|
164
157
|
prevInputValue.current = newInputValue;
|
|
165
158
|
}
|
|
166
159
|
},
|
|
167
|
-
[inputValue,
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
const setInputValue = useCallback(
|
|
171
|
-
(value: string) => {
|
|
172
|
-
const updatedValue =
|
|
173
|
-
prevInputValue.current && value.includes(prevInputValue.current)
|
|
174
|
-
? value.replace(prevInputValue.current, '')
|
|
175
|
-
: value;
|
|
176
|
-
|
|
177
|
-
setInputValueState(updatedValue);
|
|
178
|
-
},
|
|
179
|
-
[setInputValueState],
|
|
160
|
+
[inputValue, selectedOptionFormatter, setInputValue],
|
|
180
161
|
);
|
|
181
162
|
|
|
182
163
|
return { inputValue, setInputValue, prevInputValue, onInputValueChange: setInputValue, updateInputValue };
|
|
@@ -11,15 +11,3 @@ export type {
|
|
|
11
11
|
GroupOptionProps,
|
|
12
12
|
SelectedOptionFormatter,
|
|
13
13
|
} from './types';
|
|
14
|
-
|
|
15
|
-
export type {
|
|
16
|
-
FieldSelectMultipleAddCustomOptionTrigger,
|
|
17
|
-
FieldSelectSingleAddCustomOptionTrigger,
|
|
18
|
-
} from '@snack-uikit/fields';
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
getCustomOptionTriggerByCode,
|
|
22
|
-
shouldHandleCustomOptionTrigger,
|
|
23
|
-
useFieldSelectMultipleCustomOption,
|
|
24
|
-
useFieldSelectSingleCustomOption,
|
|
25
|
-
} from '@snack-uikit/fields';
|
|
@@ -94,8 +94,6 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
94
94
|
searchable?: boolean;
|
|
95
95
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
96
96
|
showCopyButton?: boolean;
|
|
97
|
-
/** Колбек клика по кнопке Копировать для поля */
|
|
98
|
-
onCopyButtonClick?(): void;
|
|
99
97
|
/**
|
|
100
98
|
* Отображение кнопки очистки поля
|
|
101
99
|
* @default true
|
|
@@ -131,29 +129,12 @@ type FiledSelectCommonProps = WithSupportProps<{
|
|
|
131
129
|
|
|
132
130
|
open?: boolean;
|
|
133
131
|
|
|
134
|
-
/** Поведение строки поиска при выборе опции из списка, false необходимо при асинхронной подгрузке значений с бэка, в случае если надо поиск оставить как значение при отсутствии данных
|
|
135
|
-
* @default true
|
|
136
|
-
*/
|
|
137
|
-
resetSearchOnOptionSelection?: boolean;
|
|
138
|
-
|
|
139
132
|
onOpenChange?(open: boolean): void;
|
|
140
133
|
|
|
141
134
|
selectedOptionFormatter?: SelectedOptionFormatter;
|
|
142
135
|
}> &
|
|
143
136
|
Pick<FieldSelectProps, 'addOptionByEnter'> &
|
|
144
|
-
Pick<
|
|
145
|
-
DroplistProps,
|
|
146
|
-
| 'dataError'
|
|
147
|
-
| 'noDataState'
|
|
148
|
-
| 'noResultsState'
|
|
149
|
-
| 'errorDataState'
|
|
150
|
-
| 'dataFiltered'
|
|
151
|
-
| 'untouchableScrollbars'
|
|
152
|
-
| 'scrollToSelectedItem'
|
|
153
|
-
| 'scrollRef'
|
|
154
|
-
| 'scrollContainerRef'
|
|
155
|
-
| 'onScroll'
|
|
156
|
-
>;
|
|
137
|
+
Pick<DroplistProps, 'dataError' | 'noDataState' | 'noResultsState' | 'errorDataState' | 'dataFiltered'>;
|
|
157
138
|
|
|
158
139
|
export type MobileFieldSelectSingleProps = FieldSelectPrivateProps &
|
|
159
140
|
Omit<SelectionSingleState, 'mode'> &
|
|
@@ -164,7 +145,7 @@ export type MobileFieldSelectSingleProps = FieldSelectPrivateProps &
|
|
|
164
145
|
export type MobileFieldSelectMultipleProps = FieldSelectPrivateProps & {
|
|
165
146
|
removeByBackspace?: boolean;
|
|
166
147
|
} & Omit<SelectionMultipleState, 'mode'> &
|
|
167
|
-
Omit<FiledSelectCommonProps, 'showCopyButton'
|
|
148
|
+
Omit<FiledSelectCommonProps, 'showCopyButton'> &
|
|
168
149
|
Pick<FieldSelectMultipleProps, 'addCustomOptionTriggers'>;
|
|
169
150
|
|
|
170
151
|
export type MobileFieldSelectProps =
|
|
@@ -11,11 +11,6 @@ export function extractListProps({
|
|
|
11
11
|
loading,
|
|
12
12
|
footer,
|
|
13
13
|
widthStrategy,
|
|
14
|
-
scrollToSelectedItem,
|
|
15
|
-
scrollRef,
|
|
16
|
-
scrollContainerRef,
|
|
17
|
-
onScroll,
|
|
18
|
-
untouchableScrollbars,
|
|
19
14
|
}: Partial<MobileFieldSelectProps>): Partial<DroplistProps> {
|
|
20
15
|
return {
|
|
21
16
|
dataError,
|
|
@@ -26,11 +21,6 @@ export function extractListProps({
|
|
|
26
21
|
loading,
|
|
27
22
|
footer,
|
|
28
23
|
widthStrategy,
|
|
29
|
-
scrollToSelectedItem,
|
|
30
|
-
scrollRef,
|
|
31
|
-
scrollContainerRef,
|
|
32
|
-
onScroll,
|
|
33
|
-
untouchableScrollbars,
|
|
34
24
|
trigger: 'clickAndFocusVisible',
|
|
35
25
|
placement: 'bottom',
|
|
36
26
|
'data-test-id': 'field-select__list',
|