@cloud-ru/ds-fields 3.0.16-preview-9dd14541.0 → 3.0.16-preview-348e9881.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.
|
@@ -36,7 +36,6 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
36
36
|
const onMultipleChange = onChange;
|
|
37
37
|
const resolvedAutoFocus = (0, hooks_1.useAdaptiveAutoFocus)(autoFocus, layoutPresets);
|
|
38
38
|
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
39
|
-
const isMobile = (0, adaptive_1.isMobileLayout)(layoutType);
|
|
40
39
|
const inputRef = (0, react_1.useRef)(null);
|
|
41
40
|
// Отдельный ref на реальный <input>: `inputRef.current` перезаписывается span-обёрткой PopoverPrivate.
|
|
42
41
|
const inputElementRef = (0, react_1.useRef)(null);
|
|
@@ -340,7 +339,7 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
340
339
|
const { postfixButtons, inputTabIndex, onInputKeyDown } = (0, input_private_1.useButtonNavigation)({
|
|
341
340
|
inputRef: inputElementRef,
|
|
342
341
|
postfixButtons: (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
|
|
343
|
-
readonly:
|
|
342
|
+
readonly: !searchable || Boolean(readOnly),
|
|
344
343
|
submitKeys: ['Enter', ' ', 'Tab'],
|
|
345
344
|
});
|
|
346
345
|
const handleTriggerKeyDown = (event) => {
|
|
@@ -398,17 +397,15 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
398
397
|
if (!open) {
|
|
399
398
|
handleOpenChange(true);
|
|
400
399
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
}, [disabled, readOnly, open, handleOpenChange, isMobile]);
|
|
400
|
+
inputElementRef.current?.focus();
|
|
401
|
+
}, [disabled, readOnly, open, handleOpenChange]);
|
|
405
402
|
const handleInputFocus = (0, react_1.useCallback)((event) => {
|
|
406
403
|
setFocusVisible(event.target.matches(':focus-visible'));
|
|
407
|
-
if (searchable
|
|
404
|
+
if (searchable) {
|
|
408
405
|
event.target.select();
|
|
409
406
|
}
|
|
410
407
|
onFocusProp?.(event);
|
|
411
|
-
}, [searchable, onFocusProp
|
|
408
|
+
}, [searchable, onFocusProp]);
|
|
412
409
|
const handleInputBlur = (event) => {
|
|
413
410
|
setFocusVisible(false);
|
|
414
411
|
const blurResult = tryCommitOnBlur(event);
|
|
@@ -442,7 +439,7 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
442
439
|
const plug = inputPlugRef.current?.clientWidth ?? SEARCH_INPUT_PLUG_MIN_WIDTH;
|
|
443
440
|
setChipInputMinWidth(Math.min(content, Math.max(plug, SEARCH_INPUT_PLUG_MIN_WIDTH)));
|
|
444
441
|
}, [hasChips, inputValue, selectedPairs.length]);
|
|
445
|
-
const searchInputField = ((0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, { ref: (0, merge_refs_1.default)(ref, inputRef, inputElementRef), className: (0, classnames_1.default)(styles_module_scss_1.default.fieldInput, !searchable && styles_module_scss_2.default.readonlyCursor), value:
|
|
442
|
+
const searchInputField = ((0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, { ref: (0, merge_refs_1.default)(ref, inputRef, inputElementRef), className: (0, classnames_1.default)(styles_module_scss_1.default.fieldInput, !searchable && styles_module_scss_2.default.readonlyCursor), value: inputValue, onChange: searchable ? handleInputChange : undefined, placeholder: selectedLabel || hasChips ? '' : placeholder, disabled: disabled, readonly: !searchable || readOnly, id: id, name: name, autoFocus: resolvedAutoFocus, tabIndex: inputTabIndex, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleTriggerKeyDown, "data-test-id": constants_1.TEST_IDS.fieldSelectInput }));
|
|
446
443
|
const searchInput = hasChips ? ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_2.default.inputWrapper, style: { minWidth: chipInputMinWidth }, children: searchInputField }, 'search-input')) : ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.inputArea, children: searchInputField }));
|
|
447
444
|
const trigger = (
|
|
448
445
|
// Focusable-элемент — InputPrivate внутри, обёртка только собирает combobox.
|
|
@@ -458,7 +455,7 @@ exports.FieldSelect = (0, react_1.forwardRef)(function FieldSelect(props, ref) {
|
|
|
458
455
|
(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, {}) }) })] }) })] }));
|
|
459
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, search: (0, adaptive_1.isMobileLayout)(layoutType) && mobileSearchable && !readOnly && !disabled
|
|
460
457
|
? {
|
|
461
|
-
value:
|
|
458
|
+
value: inputValue,
|
|
462
459
|
onChange: handleInputChange,
|
|
463
460
|
onKeyDown: event => {
|
|
464
461
|
if (tryCommitFromKeyboard(event)) {
|
|
@@ -30,7 +30,6 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
30
30
|
const onMultipleChange = onChange;
|
|
31
31
|
const resolvedAutoFocus = useAdaptiveAutoFocus(autoFocus, layoutPresets);
|
|
32
32
|
const { layoutType } = useAdaptiveLayout();
|
|
33
|
-
const isMobile = isMobileLayout(layoutType);
|
|
34
33
|
const inputRef = useRef(null);
|
|
35
34
|
// Отдельный ref на реальный <input>: `inputRef.current` перезаписывается span-обёрткой PopoverPrivate.
|
|
36
35
|
const inputElementRef = useRef(null);
|
|
@@ -334,7 +333,7 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
334
333
|
const { postfixButtons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
|
|
335
334
|
inputRef: inputElementRef,
|
|
336
335
|
postfixButtons: useMemo(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
|
|
337
|
-
readonly:
|
|
336
|
+
readonly: !searchable || Boolean(readOnly),
|
|
338
337
|
submitKeys: ['Enter', ' ', 'Tab'],
|
|
339
338
|
});
|
|
340
339
|
const handleTriggerKeyDown = (event) => {
|
|
@@ -392,17 +391,15 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
392
391
|
if (!open) {
|
|
393
392
|
handleOpenChange(true);
|
|
394
393
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
}, [disabled, readOnly, open, handleOpenChange, isMobile]);
|
|
394
|
+
inputElementRef.current?.focus();
|
|
395
|
+
}, [disabled, readOnly, open, handleOpenChange]);
|
|
399
396
|
const handleInputFocus = useCallback((event) => {
|
|
400
397
|
setFocusVisible(event.target.matches(':focus-visible'));
|
|
401
|
-
if (searchable
|
|
398
|
+
if (searchable) {
|
|
402
399
|
event.target.select();
|
|
403
400
|
}
|
|
404
401
|
onFocusProp?.(event);
|
|
405
|
-
}, [searchable, onFocusProp
|
|
402
|
+
}, [searchable, onFocusProp]);
|
|
406
403
|
const handleInputBlur = (event) => {
|
|
407
404
|
setFocusVisible(false);
|
|
408
405
|
const blurResult = tryCommitOnBlur(event);
|
|
@@ -436,7 +433,7 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
436
433
|
const plug = inputPlugRef.current?.clientWidth ?? SEARCH_INPUT_PLUG_MIN_WIDTH;
|
|
437
434
|
setChipInputMinWidth(Math.min(content, Math.max(plug, SEARCH_INPUT_PLUG_MIN_WIDTH)));
|
|
438
435
|
}, [hasChips, inputValue, selectedPairs.length]);
|
|
439
|
-
const searchInputField = (_jsx(InputPrivate, { ref: mergeRefs(ref, inputRef, inputElementRef), className: cn(fieldStyles.fieldInput, !searchable && styles.readonlyCursor), value:
|
|
436
|
+
const searchInputField = (_jsx(InputPrivate, { ref: mergeRefs(ref, inputRef, inputElementRef), className: cn(fieldStyles.fieldInput, !searchable && styles.readonlyCursor), value: inputValue, onChange: searchable ? handleInputChange : undefined, placeholder: selectedLabel || hasChips ? '' : placeholder, disabled: disabled, readonly: !searchable || readOnly, id: id, name: name, autoFocus: resolvedAutoFocus, tabIndex: inputTabIndex, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleTriggerKeyDown, "data-test-id": TEST_IDS.fieldSelectInput }));
|
|
440
437
|
const searchInput = hasChips ? (_jsx("div", { className: styles.inputWrapper, style: { minWidth: chipInputMinWidth }, children: searchInputField }, 'search-input')) : (_jsx("div", { className: fieldStyles.inputArea, children: searchInputField }));
|
|
441
438
|
const trigger = (
|
|
442
439
|
// Focusable-элемент — InputPrivate внутри, обёртка только собирает combobox.
|
|
@@ -452,7 +449,7 @@ export const FieldSelect = forwardRef(function FieldSelect(props, ref) {
|
|
|
452
449
|
_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, {}) }) })] }) })] }));
|
|
453
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, search: isMobileLayout(layoutType) && mobileSearchable && !readOnly && !disabled
|
|
454
451
|
? {
|
|
455
|
-
value:
|
|
452
|
+
value: inputValue,
|
|
456
453
|
onChange: handleInputChange,
|
|
457
454
|
onKeyDown: event => {
|
|
458
455
|
if (tryCommitFromKeyboard(event)) {
|