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