@cloud-ru/ds-fields 3.0.8-preview-052d8f8a.0 → 3.0.8-preview-74274795.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/cjs/components/FieldSecure/FieldSecure.js +8 -8
- package/dist/cjs/components/FieldSelect/FieldSelect.js +1 -19
- package/dist/cjs/components/FieldSelect/hooks.d.ts +1 -1
- package/dist/cjs/components/FieldSelect/types.d.ts +0 -1
- package/dist/cjs/components/FieldStepper/FieldStepper.js +3 -2
- package/dist/esm/components/FieldSecure/FieldSecure.js +8 -8
- package/dist/esm/components/FieldSelect/FieldSelect.js +2 -20
- package/dist/esm/components/FieldSelect/hooks.d.ts +1 -1
- package/dist/esm/components/FieldSelect/types.d.ts +0 -1
- package/dist/esm/components/FieldStepper/FieldStepper.js +3 -2
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/components/FieldSecure/FieldSecure.tsx +9 -9
- package/src/components/FieldSelect/FieldSelect.tsx +0 -26
- package/src/components/FieldSelect/hooks.ts +1 -1
- package/src/components/FieldSelect/types.ts +0 -1
- package/src/components/FieldStepper/FieldStepper.tsx +4 -2
|
@@ -40,24 +40,24 @@ exports.FieldSecure = (0, react_1.forwardRef)(function FieldSecure({ label = '',
|
|
|
40
40
|
}, [onChange, setValue]);
|
|
41
41
|
const ensureAsyncValue = (0, react_1.useCallback)(async () => {
|
|
42
42
|
if (!asyncValueGetter || isAsyncLoaded) {
|
|
43
|
-
return
|
|
43
|
+
return true;
|
|
44
44
|
}
|
|
45
45
|
setIsLoading(true);
|
|
46
46
|
try {
|
|
47
47
|
const next = await asyncValueGetter();
|
|
48
48
|
setIsAsyncLoaded(true);
|
|
49
49
|
emitChange(next);
|
|
50
|
-
return
|
|
50
|
+
return true;
|
|
51
51
|
}
|
|
52
52
|
catch {
|
|
53
|
-
return
|
|
53
|
+
return false;
|
|
54
54
|
}
|
|
55
55
|
finally {
|
|
56
56
|
setIsLoading(false);
|
|
57
57
|
}
|
|
58
|
-
}, [asyncValueGetter, emitChange, isAsyncLoaded
|
|
58
|
+
}, [asyncValueGetter, emitChange, isAsyncLoaded]);
|
|
59
59
|
const toggleHidden = (0, react_1.useCallback)(() => {
|
|
60
|
-
ensureAsyncValue().then(
|
|
60
|
+
ensureAsyncValue().then(success => {
|
|
61
61
|
if (!success) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -83,13 +83,13 @@ exports.FieldSecure = (0, react_1.forwardRef)(function FieldSecure({ label = '',
|
|
|
83
83
|
const stringValue = String(value ?? '');
|
|
84
84
|
const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && readOnly);
|
|
85
85
|
const showHideUi = Boolean(showHideButtonProp && !(readOnly && !stringValue));
|
|
86
|
-
const onCopy = (0, react_1.useCallback)(() => ensureAsyncValue().then(async (
|
|
87
|
-
const copied =
|
|
86
|
+
const onCopy = (0, react_1.useCallback)(() => ensureAsyncValue().then(async (success) => {
|
|
87
|
+
const copied = success && (await (0, shared_1.copyTextToClipboard)(stringValue));
|
|
88
88
|
if (copied) {
|
|
89
89
|
onCopyButtonClick?.();
|
|
90
90
|
}
|
|
91
91
|
return copied;
|
|
92
|
-
}), [ensureAsyncValue, onCopyButtonClick]);
|
|
92
|
+
}), [ensureAsyncValue, onCopyButtonClick, stringValue]);
|
|
93
93
|
const copyButtonSettings = (0, shared_1.useCopyButton)({
|
|
94
94
|
copyButtonRef,
|
|
95
95
|
showCopyButton: showCopyUi,
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FieldSelect = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
9
8
|
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
10
9
|
const input_private_1 = require("@cloud-ru/ds-input-private");
|
|
11
10
|
const list_1 = require("@cloud-ru/ds-list");
|
|
@@ -35,7 +34,6 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
35
34
|
const onSingleChange = onChange;
|
|
36
35
|
const onMultipleChange = onChange;
|
|
37
36
|
const resolvedAutoFocus = (0, hooks_1.useAdaptiveAutoFocus)(autoFocus, layoutPresets);
|
|
38
|
-
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
39
37
|
const inputRef = (0, react_1.useRef)(null);
|
|
40
38
|
// Отдельный ref на реальный <input>: `inputRef.current` перезаписывается span-обёрткой PopoverPrivate.
|
|
41
39
|
const inputElementRef = (0, react_1.useRef)(null);
|
|
@@ -81,9 +79,6 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
81
79
|
}, [multiple, value, multipleLocal]);
|
|
82
80
|
const effectiveValidationState = (0, react_1.useMemo)(() => (error ? field_decorator_1.VALIDATION_STATE.Error : validationState), [error, validationState]);
|
|
83
81
|
const allItems = (0, react_1.useMemo)(() => [...(pinTop ?? []), ...items, ...(pinBottom ?? [])], [items, pinTop, pinBottom]);
|
|
84
|
-
const mobileSearchable = (0, react_1.useMemo)(() => searchable ||
|
|
85
|
-
autocomplete ||
|
|
86
|
-
(0, utils_2.resolveAddCustomOptionTriggers)({ allowCustomOption, addCustomOptionTriggers, multiple }).includes('enter'), [searchable, autocomplete, allowCustomOption, addCustomOptionTriggers, multiple]);
|
|
87
82
|
const selectedIds = (0, react_1.useMemo)(() => (0, utils_2.getSelectedIds)({ multiple, multipleValue, singleValue }), [multiple, multipleValue, singleValue]);
|
|
88
83
|
// Выбранное, которого нет в `items` (кастом по allowCustomOption, ленивая подгрузка) — в список, не только в чип.
|
|
89
84
|
const missingSelectedItems = (0, react_1.useMemo)(() => (0, utils_2.getMissingSelectedItems)(selectedIds, allItems), [selectedIds, allItems]);
|
|
@@ -453,18 +448,5 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
453
448
|
}), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.acrylicBg, "aria-hidden": true }) }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.borderStateLayer, "data-state": 'borderOnBackground' }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.focusLayer })] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.fieldContainer, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.contentWrapper, children: [iconBefore && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.iconSlot, children: iconBefore }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.inputLine, children: [prefix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.prefix, children: prefix }), hasChips ? ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_2.default.chipsRow, ref: contentRef, "data-test-id": constants_1.TEST_IDS.fieldSelectChips, children: [selectedPairs.map(pair => ((0, jsx_runtime_1.jsx)(tag_1.Tag, { label: formatPair(pair), size: utils_2.TAG_SIZE_MAP[size], appearance: pair.appearance ?? 'neutral', onDelete: disabled || readOnly || pair.disabled ? undefined : handleRemoveChip(pair.id) }, String(pair.id)))), searchInput, (0, jsx_runtime_1.jsx)("span", { ref: inputPlugRef, className: styles_module_scss_2.default.inputPlug, "aria-hidden": true, children: inputValue })] })) : (searchInput), postfixButtons && (
|
|
454
449
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
455
450
|
(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfixButtonsSlot, onMouseDown: shared_1.preventSlotMouseDown, onClick: shared_1.stopSlotClickPropagation, children: postfixButtons })), postfix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfix, children: postfix })] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.iconSlot, children: (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_2.default.chevron, "data-open": open || undefined, "aria-hidden": true, children: (0, jsx_runtime_1.jsx)(system_1.ChevronDownSVG, {}) }) })] }) })] }));
|
|
456
|
-
return ((0, jsx_runtime_1.jsx)(field_decorator_1.FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, size: size, validationState: validationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, children: (0, jsx_runtime_1.jsx)(list_1.Droplist, { items: filteredItems, label: label,
|
|
457
|
-
? {
|
|
458
|
-
value: inputValue,
|
|
459
|
-
onChange: handleInputChange,
|
|
460
|
-
onKeyDown: event => {
|
|
461
|
-
if (tryCommitFromKeyboard(event)) {
|
|
462
|
-
event.preventDefault();
|
|
463
|
-
event.stopPropagation();
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
placeholder,
|
|
467
|
-
loading,
|
|
468
|
-
}
|
|
469
|
-
: undefined, pinTop: filteredPinTop, pinBottom: filteredPinBottom, trigger: 'click', placement: placement, widthStrategy: widthStrategy, triggerElemRef: inputRef, listRef: listRef, size: size, open: open, onOpenChange: handleOpenChange, selection: droplistSelection, closeDroplistOnItemClick: closeDroplistOnItemClick, footer: footer, footerDivider: footerDivider, footerActiveElementsRefs: footerActiveElementsRefs, loading: loading, noDataState: noDataState, noResultsState: noResultsState, errorDataState: errorDataState, dataError: dataError, dataFiltered: dataFiltered ?? (searchable && typing && inputValue !== ''), virtualized: virtualized, scroll: true, scrollToSelectedItem: scrollToSelectedItem, limitedScrollHeight: limitedScrollHeight, untouchableScrollbars: untouchableScrollbars, closeOnPopstate: closeOnPopstate, "data-test-id": constants_1.TEST_IDS.fieldSelectList, children: trigger }) }));
|
|
451
|
+
return ((0, jsx_runtime_1.jsx)(field_decorator_1.FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, size: size, validationState: validationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, children: (0, jsx_runtime_1.jsx)(list_1.Droplist, { items: filteredItems, label: label, pinTop: filteredPinTop, pinBottom: filteredPinBottom, trigger: 'click', placement: placement, widthStrategy: widthStrategy, triggerElemRef: inputRef, listRef: listRef, size: size, open: open, onOpenChange: handleOpenChange, selection: droplistSelection, closeDroplistOnItemClick: closeDroplistOnItemClick, footer: footer, footerDivider: footerDivider, footerActiveElementsRefs: footerActiveElementsRefs, loading: loading, noDataState: noDataState, noResultsState: noResultsState, errorDataState: errorDataState, dataError: dataError, dataFiltered: dataFiltered ?? (searchable && typing && inputValue !== ''), virtualized: virtualized, scroll: true, scrollToSelectedItem: scrollToSelectedItem, limitedScrollHeight: limitedScrollHeight, untouchableScrollbars: untouchableScrollbars, closeOnPopstate: closeOnPopstate, "data-test-id": constants_1.TEST_IDS.fieldSelectList, children: trigger }) }));
|
|
470
452
|
});
|
|
@@ -25,7 +25,7 @@ export declare function useCustomOption({ allowCustomOption, addCustomOptionTrig
|
|
|
25
25
|
enableCloseCommit: () => void;
|
|
26
26
|
tryCommitOnClose: () => boolean;
|
|
27
27
|
tryCommitOnBlur: (event: FocusEvent<HTMLInputElement>) => CustomOptionBlurResult;
|
|
28
|
-
tryCommitFromKeyboard: (event:
|
|
28
|
+
tryCommitFromKeyboard: (event: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
29
29
|
handleListSingleChange: (next: ItemId | undefined) => void;
|
|
30
30
|
handleListMultipleChange: (next: ItemId[]) => void;
|
|
31
31
|
};
|
|
@@ -96,7 +96,6 @@ type CommonSelectProps = FieldSelectDecoratorProps & DroplistPassthrough & {
|
|
|
96
96
|
widthStrategy?: DroplistProps['widthStrategy'];
|
|
97
97
|
/**
|
|
98
98
|
* Включить поиск/ввод в поле — пользователь печатает, список фильтруется по подстроке лейбла.
|
|
99
|
-
* `autocomplete` и создание опции по Enter также включают мобильный поиск.
|
|
100
99
|
* @default true
|
|
101
100
|
*/
|
|
102
101
|
searchable?: boolean;
|
|
@@ -59,10 +59,10 @@ exports.FieldStepper = (0, react_1.forwardRef)(function FieldStepper({ label = '
|
|
|
59
59
|
emitValue((0, utils_2.applyStep)(value, step));
|
|
60
60
|
}, [emitValue, step, value]);
|
|
61
61
|
const handleInputChange = (0, react_1.useCallback)((raw, event) => {
|
|
62
|
-
if (raw === '
|
|
62
|
+
if (raw === '-') {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
const parsed = Number(raw);
|
|
65
|
+
const parsed = raw === '' ? 0 : Number(raw);
|
|
66
66
|
if (Number.isNaN(parsed)) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
@@ -79,6 +79,7 @@ exports.FieldStepper = (0, react_1.forwardRef)(function FieldStepper({ label = '
|
|
|
79
79
|
clampTimerRef.current = setTimeout(() => setClampTooltip(null), 2000);
|
|
80
80
|
}, []);
|
|
81
81
|
const handleBlur = (0, react_1.useCallback)((event) => {
|
|
82
|
+
setFocusVisible(false);
|
|
82
83
|
if (!allowMoreThanLimits) {
|
|
83
84
|
if (typeof max === 'number' && value > max) {
|
|
84
85
|
setValue(max);
|
|
@@ -34,24 +34,24 @@ export const FieldSecure = forwardRef(function FieldSecure({ label = '', labelTo
|
|
|
34
34
|
}, [onChange, setValue]);
|
|
35
35
|
const ensureAsyncValue = useCallback(async () => {
|
|
36
36
|
if (!asyncValueGetter || isAsyncLoaded) {
|
|
37
|
-
return
|
|
37
|
+
return true;
|
|
38
38
|
}
|
|
39
39
|
setIsLoading(true);
|
|
40
40
|
try {
|
|
41
41
|
const next = await asyncValueGetter();
|
|
42
42
|
setIsAsyncLoaded(true);
|
|
43
43
|
emitChange(next);
|
|
44
|
-
return
|
|
44
|
+
return true;
|
|
45
45
|
}
|
|
46
46
|
catch {
|
|
47
|
-
return
|
|
47
|
+
return false;
|
|
48
48
|
}
|
|
49
49
|
finally {
|
|
50
50
|
setIsLoading(false);
|
|
51
51
|
}
|
|
52
|
-
}, [asyncValueGetter, emitChange, isAsyncLoaded
|
|
52
|
+
}, [asyncValueGetter, emitChange, isAsyncLoaded]);
|
|
53
53
|
const toggleHidden = useCallback(() => {
|
|
54
|
-
ensureAsyncValue().then(
|
|
54
|
+
ensureAsyncValue().then(success => {
|
|
55
55
|
if (!success) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -77,13 +77,13 @@ export const FieldSecure = forwardRef(function FieldSecure({ label = '', labelTo
|
|
|
77
77
|
const stringValue = String(value ?? '');
|
|
78
78
|
const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && readOnly);
|
|
79
79
|
const showHideUi = Boolean(showHideButtonProp && !(readOnly && !stringValue));
|
|
80
|
-
const onCopy = useCallback(() => ensureAsyncValue().then(async (
|
|
81
|
-
const copied =
|
|
80
|
+
const onCopy = useCallback(() => ensureAsyncValue().then(async (success) => {
|
|
81
|
+
const copied = success && (await copyTextToClipboard(stringValue));
|
|
82
82
|
if (copied) {
|
|
83
83
|
onCopyButtonClick?.();
|
|
84
84
|
}
|
|
85
85
|
return copied;
|
|
86
|
-
}), [ensureAsyncValue, onCopyButtonClick]);
|
|
86
|
+
}), [ensureAsyncValue, onCopyButtonClick, stringValue]);
|
|
87
87
|
const copyButtonSettings = useCopyButton({
|
|
88
88
|
copyButtonRef,
|
|
89
89
|
showCopyButton: showCopyUi,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
3
2
|
import { ChevronDownSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
4
3
|
import { InputPrivate, useButtonNavigation, useClearButton } from '@cloud-ru/ds-input-private';
|
|
5
4
|
import { Droplist } from '@cloud-ru/ds-list';
|
|
@@ -17,7 +16,7 @@ import { copyTextToClipboard, getAcrylicProps, preventSlotMouseDown, stopSlotCli
|
|
|
17
16
|
import fieldStyles from '../shared/styles.module.css';
|
|
18
17
|
import { useCustomOption } from './hooks.js';
|
|
19
18
|
import styles from './styles.module.css';
|
|
20
|
-
import { extractAppearance, extractLabel, filterItems, findItem, flatten, getMissingSelectedItems, getSelectedIds, isMultiple,
|
|
19
|
+
import { extractAppearance, extractLabel, filterItems, findItem, flatten, getMissingSelectedItems, getSelectedIds, isMultiple, TAG_SIZE_MAP, } from './utils/index.js';
|
|
21
20
|
export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
22
21
|
const { label = '', labelTooltip, caption, hint, error, validationState = VALIDATION_STATE.Default, showHintIcon, length, required, size = SIZE.M, className, fieldClassName, items, pinTop, pinBottom, placeholder = '', iconBefore, prefix, postfix, disabled, readonly: readOnly, background = true, open: openProp, onOpenChange, placement, widthStrategy = 'eq', searchable = true, search, autocomplete = false, resetSearchOnOptionSelection = true, showClearButton = true, showCopyButton = true, onCopyButtonClick, id, name, autoFocus, layoutPresets, value, onChange, onFocus: onFocusProp, onBlur: onBlurProp, enableFuzzySearch = true, selectedOptionFormatter, footer, footerDivider, footerActiveElementsRefs, loading, noDataState, noResultsState, errorDataState, dataError, dataFiltered, virtualized, scrollToSelectedItem, limitedScrollHeight, untouchableScrollbars, closeOnPopstate, onKeyDown: onKeyDownProp, 'data-test-id': dataTestId = TEST_IDS.fieldSelect, } = props;
|
|
23
22
|
const multiple = isMultiple(props);
|
|
@@ -29,7 +28,6 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
29
28
|
const onSingleChange = onChange;
|
|
30
29
|
const onMultipleChange = onChange;
|
|
31
30
|
const resolvedAutoFocus = useAdaptiveAutoFocus(autoFocus, layoutPresets);
|
|
32
|
-
const { layoutType } = useAdaptiveLayout();
|
|
33
31
|
const inputRef = useRef(null);
|
|
34
32
|
// Отдельный ref на реальный <input>: `inputRef.current` перезаписывается span-обёрткой PopoverPrivate.
|
|
35
33
|
const inputElementRef = useRef(null);
|
|
@@ -75,9 +73,6 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
75
73
|
}, [multiple, value, multipleLocal]);
|
|
76
74
|
const effectiveValidationState = useMemo(() => (error ? VALIDATION_STATE.Error : validationState), [error, validationState]);
|
|
77
75
|
const allItems = useMemo(() => [...(pinTop ?? []), ...items, ...(pinBottom ?? [])], [items, pinTop, pinBottom]);
|
|
78
|
-
const mobileSearchable = useMemo(() => searchable ||
|
|
79
|
-
autocomplete ||
|
|
80
|
-
resolveAddCustomOptionTriggers({ allowCustomOption, addCustomOptionTriggers, multiple }).includes('enter'), [searchable, autocomplete, allowCustomOption, addCustomOptionTriggers, multiple]);
|
|
81
76
|
const selectedIds = useMemo(() => getSelectedIds({ multiple, multipleValue, singleValue }), [multiple, multipleValue, singleValue]);
|
|
82
77
|
// Выбранное, которого нет в `items` (кастом по allowCustomOption, ленивая подгрузка) — в список, не только в чип.
|
|
83
78
|
const missingSelectedItems = useMemo(() => getMissingSelectedItems(selectedIds, allItems), [selectedIds, allItems]);
|
|
@@ -447,18 +442,5 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
447
442
|
}), children: _jsx("div", { className: fieldStyles.acrylicBg, "aria-hidden": true }) }), _jsx("div", { className: fieldStyles.borderStateLayer, "data-state": 'borderOnBackground' }), _jsx("div", { className: fieldStyles.focusLayer })] }), _jsx("div", { className: fieldStyles.fieldContainer, children: _jsxs("div", { className: fieldStyles.contentWrapper, children: [iconBefore && _jsx("div", { className: fieldStyles.iconSlot, children: iconBefore }), _jsxs("div", { className: fieldStyles.inputLine, children: [prefix && _jsx("span", { className: fieldStyles.prefix, children: prefix }), hasChips ? (_jsxs("div", { className: styles.chipsRow, ref: contentRef, "data-test-id": TEST_IDS.fieldSelectChips, children: [selectedPairs.map(pair => (_jsx(Tag, { label: formatPair(pair), size: TAG_SIZE_MAP[size], appearance: pair.appearance ?? 'neutral', onDelete: disabled || readOnly || pair.disabled ? undefined : handleRemoveChip(pair.id) }, String(pair.id)))), searchInput, _jsx("span", { ref: inputPlugRef, className: styles.inputPlug, "aria-hidden": true, children: inputValue })] })) : (searchInput), postfixButtons && (
|
|
448
443
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
449
444
|
_jsx("span", { className: fieldStyles.postfixButtonsSlot, onMouseDown: preventSlotMouseDown, onClick: stopSlotClickPropagation, children: postfixButtons })), postfix && _jsx("span", { className: fieldStyles.postfix, children: postfix })] }), _jsx("div", { className: fieldStyles.iconSlot, children: _jsx("span", { className: styles.chevron, "data-open": open || undefined, "aria-hidden": true, children: _jsx(ChevronDownSVG, {}) }) })] }) })] }));
|
|
450
|
-
return (_jsx(FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, size: size, validationState: validationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, children: _jsx(Droplist, { items: filteredItems, label: label,
|
|
451
|
-
? {
|
|
452
|
-
value: inputValue,
|
|
453
|
-
onChange: handleInputChange,
|
|
454
|
-
onKeyDown: event => {
|
|
455
|
-
if (tryCommitFromKeyboard(event)) {
|
|
456
|
-
event.preventDefault();
|
|
457
|
-
event.stopPropagation();
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
placeholder,
|
|
461
|
-
loading,
|
|
462
|
-
}
|
|
463
|
-
: undefined, pinTop: filteredPinTop, pinBottom: filteredPinBottom, trigger: 'click', placement: placement, widthStrategy: widthStrategy, triggerElemRef: inputRef, listRef: listRef, size: size, open: open, onOpenChange: handleOpenChange, selection: droplistSelection, closeDroplistOnItemClick: closeDroplistOnItemClick, footer: footer, footerDivider: footerDivider, footerActiveElementsRefs: footerActiveElementsRefs, loading: loading, noDataState: noDataState, noResultsState: noResultsState, errorDataState: errorDataState, dataError: dataError, dataFiltered: dataFiltered ?? (searchable && typing && inputValue !== ''), virtualized: virtualized, scroll: true, scrollToSelectedItem: scrollToSelectedItem, limitedScrollHeight: limitedScrollHeight, untouchableScrollbars: untouchableScrollbars, closeOnPopstate: closeOnPopstate, "data-test-id": TEST_IDS.fieldSelectList, children: trigger }) }));
|
|
445
|
+
return (_jsx(FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, size: size, validationState: validationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, children: _jsx(Droplist, { items: filteredItems, label: label, pinTop: filteredPinTop, pinBottom: filteredPinBottom, trigger: 'click', placement: placement, widthStrategy: widthStrategy, triggerElemRef: inputRef, listRef: listRef, size: size, open: open, onOpenChange: handleOpenChange, selection: droplistSelection, closeDroplistOnItemClick: closeDroplistOnItemClick, footer: footer, footerDivider: footerDivider, footerActiveElementsRefs: footerActiveElementsRefs, loading: loading, noDataState: noDataState, noResultsState: noResultsState, errorDataState: errorDataState, dataError: dataError, dataFiltered: dataFiltered ?? (searchable && typing && inputValue !== ''), virtualized: virtualized, scroll: true, scrollToSelectedItem: scrollToSelectedItem, limitedScrollHeight: limitedScrollHeight, untouchableScrollbars: untouchableScrollbars, closeOnPopstate: closeOnPopstate, "data-test-id": TEST_IDS.fieldSelectList, children: trigger }) }));
|
|
464
446
|
});
|
|
@@ -25,7 +25,7 @@ export declare function useCustomOption({ allowCustomOption, addCustomOptionTrig
|
|
|
25
25
|
enableCloseCommit: () => void;
|
|
26
26
|
tryCommitOnClose: () => boolean;
|
|
27
27
|
tryCommitOnBlur: (event: FocusEvent<HTMLInputElement>) => CustomOptionBlurResult;
|
|
28
|
-
tryCommitFromKeyboard: (event:
|
|
28
|
+
tryCommitFromKeyboard: (event: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
29
29
|
handleListSingleChange: (next: ItemId | undefined) => void;
|
|
30
30
|
handleListMultipleChange: (next: ItemId[]) => void;
|
|
31
31
|
};
|
|
@@ -96,7 +96,6 @@ type CommonSelectProps = FieldSelectDecoratorProps & DroplistPassthrough & {
|
|
|
96
96
|
widthStrategy?: DroplistProps['widthStrategy'];
|
|
97
97
|
/**
|
|
98
98
|
* Включить поиск/ввод в поле — пользователь печатает, список фильтруется по подстроке лейбла.
|
|
99
|
-
* `autocomplete` и создание опции по Enter также включают мобильный поиск.
|
|
100
99
|
* @default true
|
|
101
100
|
*/
|
|
102
101
|
searchable?: boolean;
|
|
@@ -53,10 +53,10 @@ export const FieldStepper = forwardRef(function FieldStepper({ label = '', label
|
|
|
53
53
|
emitValue(applyStep(value, step));
|
|
54
54
|
}, [emitValue, step, value]);
|
|
55
55
|
const handleInputChange = useCallback((raw, event) => {
|
|
56
|
-
if (raw === '
|
|
56
|
+
if (raw === '-') {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
const parsed = Number(raw);
|
|
59
|
+
const parsed = raw === '' ? 0 : Number(raw);
|
|
60
60
|
if (Number.isNaN(parsed)) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
@@ -73,6 +73,7 @@ export const FieldStepper = forwardRef(function FieldStepper({ label = '', label
|
|
|
73
73
|
clampTimerRef.current = setTimeout(() => setClampTooltip(null), 2000);
|
|
74
74
|
}, []);
|
|
75
75
|
const handleBlur = useCallback((event) => {
|
|
76
|
+
setFocusVisible(false);
|
|
76
77
|
if (!allowMoreThanLimits) {
|
|
77
78
|
if (typeof max === 'number' && value > max) {
|
|
78
79
|
setValue(max);
|