@cloud-ru/ds-fields 1.0.8-preview-563d8ff6.0 → 1.0.8-preview-61ab169d.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.
@@ -77,10 +77,16 @@ type FieldTextAreaOwnProps = {
77
77
  */
78
78
  showClearButton?: boolean;
79
79
  /**
80
- * Кнопка копирования (видна при value && !disabled, независимо от readonly)
80
+ * Кнопка копирования (видна при непустом value в режиме readonly, как у остальных полей)
81
81
  * @default true
82
82
  */
83
83
  showCopyButton?: boolean;
84
+ /**
85
+ * Показывать кнопку копирования и в обычном (не readonly) режиме — рядом с кнопкой очистки.
86
+ * Опция только для textarea: в многострочном поле копирование значения осмысленно и при вводе.
87
+ * @default false
88
+ */
89
+ showCopyButtonInEditMode?: boolean;
84
90
  /** Колбек после копирования */
85
91
  onCopyButtonClick?(): void;
86
92
  /** Колбек фокуса */
@@ -18,7 +18,7 @@ const hooks_1 = require("../../hooks");
18
18
  const shared_1 = require("../shared");
19
19
  const styles_module_scss_1 = __importDefault(require('../shared/styles.module.css'));
20
20
  const styles_module_scss_2 = __importDefault(require('./styles.module.css'));
21
- exports.FieldTextArea = (0, react_1.forwardRef)(function FieldTextArea({ label = '', labelTooltip, caption, hint, error, validationState = field_decorator_1.VALIDATION_STATE.Default, showHintIcon, length, required, size = field_decorator_1.SIZE.M, className, fieldClassName, background = true, value: valueProp, defaultValue = '', onChange, placeholder, id, name, maxLength, disabled, readonly: readOnly, autoFocus, layoutPresets, inputMode, spellCheck, minRows = 3, maxRows = 1000, resizable = false, allowMoreThanMaxLength = true, header, footer, showClearButton: showClearButtonProp = true, showCopyButton: showCopyButtonProp = true, onCopyButtonClick, onFocus: onFocusProp, onBlur: onBlurProp, onKeyDown: onKeyDownProp, 'data-test-id': dataTestId, ...rest }, ref) {
21
+ exports.FieldTextArea = (0, react_1.forwardRef)(function FieldTextArea({ label = '', labelTooltip, caption, hint, error, validationState = field_decorator_1.VALIDATION_STATE.Default, showHintIcon, length, required, size = field_decorator_1.SIZE.M, className, fieldClassName, background = true, value: valueProp, defaultValue = '', onChange, placeholder, id, name, maxLength, disabled, readonly: readOnly, autoFocus, layoutPresets, inputMode, spellCheck, minRows = 3, maxRows = 1000, resizable = false, allowMoreThanMaxLength = true, header, footer, showClearButton: showClearButtonProp = true, showCopyButton: showCopyButtonProp = true, showCopyButtonInEditMode = false, onCopyButtonClick, onFocus: onFocusProp, onBlur: onBlurProp, onKeyDown: onKeyDownProp, 'data-test-id': dataTestId, ...rest }, ref) {
22
22
  const localRef = (0, react_1.useRef)(null);
23
23
  const clearButtonRef = (0, react_1.useRef)(null);
24
24
  const copyButtonRef = (0, react_1.useRef)(null);
@@ -37,9 +37,9 @@ exports.FieldTextArea = (0, react_1.forwardRef)(function FieldTextArea({ label =
37
37
  const stringValue = String(value ?? '');
38
38
  const isResizable = resizable && !disabled && !readOnly;
39
39
  const showClearUi = Boolean(showClearButtonProp && stringValue && !readOnly && !disabled);
40
- // Copy не завязан на readonly (паритет с snack-uikit master): виден при любом непустом значении.
41
- // В editable-режиме показываются обе кнопки (clear + copy), в readonly — только copy.
42
- const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled);
40
+ // По умолчанию copy только в readonly, как у остальных полей. В editable-режиме кнопка
41
+ // появляется лишь по явному `showCopyButtonInEditMode`; тогда видны обе (clear + copy).
42
+ const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && (readOnly || showCopyButtonInEditMode));
43
43
  const onClear = (0, react_1.useCallback)(() => {
44
44
  setValue('');
45
45
  onChange?.('');
@@ -77,10 +77,16 @@ type FieldTextAreaOwnProps = {
77
77
  */
78
78
  showClearButton?: boolean;
79
79
  /**
80
- * Кнопка копирования (видна при value && !disabled, независимо от readonly)
80
+ * Кнопка копирования (видна при непустом value в режиме readonly, как у остальных полей)
81
81
  * @default true
82
82
  */
83
83
  showCopyButton?: boolean;
84
+ /**
85
+ * Показывать кнопку копирования и в обычном (не readonly) режиме — рядом с кнопкой очистки.
86
+ * Опция только для textarea: в многострочном поле копирование значения осмысленно и при вводе.
87
+ * @default false
88
+ */
89
+ showCopyButtonInEditMode?: boolean;
84
90
  /** Колбек после копирования */
85
91
  onCopyButtonClick?(): void;
86
92
  /** Колбек фокуса */
@@ -12,7 +12,7 @@ import { useAdaptiveAutoFocus } from '../../hooks/index.js';
12
12
  import { copyTextToClipboard, FieldShell, toInputSize, useCopyButton } from '../shared/index.js';
13
13
  import fieldStyles from '../shared/styles.module.css';
14
14
  import styles from './styles.module.css';
15
- export const FieldTextArea = forwardRef(function FieldTextArea({ label = '', labelTooltip, caption, hint, error, validationState = VALIDATION_STATE.Default, showHintIcon, length, required, size = SIZE.M, className, fieldClassName, background = true, value: valueProp, defaultValue = '', onChange, placeholder, id, name, maxLength, disabled, readonly: readOnly, autoFocus, layoutPresets, inputMode, spellCheck, minRows = 3, maxRows = 1000, resizable = false, allowMoreThanMaxLength = true, header, footer, showClearButton: showClearButtonProp = true, showCopyButton: showCopyButtonProp = true, onCopyButtonClick, onFocus: onFocusProp, onBlur: onBlurProp, onKeyDown: onKeyDownProp, 'data-test-id': dataTestId, ...rest }, ref) {
15
+ export const FieldTextArea = forwardRef(function FieldTextArea({ label = '', labelTooltip, caption, hint, error, validationState = VALIDATION_STATE.Default, showHintIcon, length, required, size = SIZE.M, className, fieldClassName, background = true, value: valueProp, defaultValue = '', onChange, placeholder, id, name, maxLength, disabled, readonly: readOnly, autoFocus, layoutPresets, inputMode, spellCheck, minRows = 3, maxRows = 1000, resizable = false, allowMoreThanMaxLength = true, header, footer, showClearButton: showClearButtonProp = true, showCopyButton: showCopyButtonProp = true, showCopyButtonInEditMode = false, onCopyButtonClick, onFocus: onFocusProp, onBlur: onBlurProp, onKeyDown: onKeyDownProp, 'data-test-id': dataTestId, ...rest }, ref) {
16
16
  const localRef = useRef(null);
17
17
  const clearButtonRef = useRef(null);
18
18
  const copyButtonRef = useRef(null);
@@ -31,9 +31,9 @@ export const FieldTextArea = forwardRef(function FieldTextArea({ label = '', lab
31
31
  const stringValue = String(value ?? '');
32
32
  const isResizable = resizable && !disabled && !readOnly;
33
33
  const showClearUi = Boolean(showClearButtonProp && stringValue && !readOnly && !disabled);
34
- // Copy не завязан на readonly (паритет с snack-uikit master): виден при любом непустом значении.
35
- // В editable-режиме показываются обе кнопки (clear + copy), в readonly — только copy.
36
- const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled);
34
+ // По умолчанию copy только в readonly, как у остальных полей. В editable-режиме кнопка
35
+ // появляется лишь по явному `showCopyButtonInEditMode`; тогда видны обе (clear + copy).
36
+ const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && (readOnly || showCopyButtonInEditMode));
37
37
  const onClear = useCallback(() => {
38
38
  setValue('');
39
39
  onChange?.('');