@snack-uikit/fields 0.44.0 → 0.45.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/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
+ # 0.45.0 (2025-05-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * **PDS-2223:** add onKeyDown props to FieldTextArea ([818f74d](https://github.com/cloud-ru-tech/snack-uikit/commit/818f74d498068e5cd9ed13bc9d2f9bfcc1943d2f))
12
+
13
+
14
+
15
+
16
+
6
17
  # 0.44.0 (2025-05-23)
7
18
 
8
19
 
package/README.md CHANGED
@@ -519,6 +519,7 @@ FieldStepper в основном предназначен для работы с
519
519
  | onBlur | `FocusEventHandler<HTMLTextAreaElement>` | - | Колбек потери фокуса |
520
520
  | placeholder | `string` | - | Плейсхолдер |
521
521
  | maxLength | `number` | - | Максимальное кол-во символов |
522
+ | onKeyDown | `KeyboardEventHandler<HTMLTextAreaElement>` | - | Колбек нажатия клавиши клавиатуры |
522
523
  | className | `string` | - | CSS-класс |
523
524
  | label | `string` | - | Лейбл |
524
525
  | labelTooltip | `ReactNode` | - | Всплывающая подсказка лейбла |
@@ -2,7 +2,7 @@ import { ChangeEvent, ReactNode } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
3
  import { TextAreaProps } from '../../helperComponents';
4
4
  import { FieldDecoratorProps } from '../FieldDecorator';
5
- type InputProps = Pick<Partial<TextAreaProps>, 'value'> & Pick<TextAreaProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
5
+ type InputProps = Pick<Partial<TextAreaProps>, 'value'> & Pick<TextAreaProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'onKeyDown'>;
6
6
  type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'caption' | 'hint' | 'size' | 'validationState' | 'showHintIcon' | 'labelTooltipPlacement' | 'error'>;
7
7
  type FieldTextAreaOwnProps = {
8
8
  /** Минимальное кол-во строк, до которого размер поля может быть увеличен @default 3*/
@@ -30,5 +30,5 @@ type FieldTextAreaOwnProps = {
30
30
  export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
31
31
  export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
32
32
  'data-test-id'?: string;
33
- } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "onFocus" | "onBlur" | "id" | "disabled" | "name" | "readonly" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
33
+ } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "onKeyDown" | "onFocus" | "onBlur" | "id" | "disabled" | "name" | "readonly" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
34
34
  export {};
@@ -48,6 +48,7 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
48
48
  onChange: onChangeProp,
49
49
  onFocus,
50
50
  onBlur,
51
+ onKeyDown,
51
52
  className,
52
53
  label,
53
54
  labelTooltip,
@@ -61,7 +62,7 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
61
62
  onCopyButtonClick,
62
63
  footer
63
64
  } = _a,
64
- rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick", "footer"]);
65
+ rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "onKeyDown", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick", "footer"]);
65
66
  const localRef = (0, react_1.useRef)(null);
66
67
  const clearButtonRef = (0, react_1.useRef)(null);
67
68
  const copyButtonRef = (0, react_1.useRef)(null);
@@ -107,6 +108,10 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
107
108
  readonly,
108
109
  submitKeys: ['Enter', 'Space', 'Tab']
109
110
  });
111
+ const handleKeyDown = event => {
112
+ onInputKeyDown(event);
113
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
114
+ };
110
115
  return (0, jsx_runtime_1.jsx)(FieldDecorator_1.FieldDecorator, Object.assign({
111
116
  className: className,
112
117
  label: label,
@@ -165,7 +170,7 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
165
170
  ref: (0, merge_refs_1.default)(ref, localRef),
166
171
  onFocus: onFocus,
167
172
  onBlur: onBlur,
168
- onKeyDown: onInputKeyDown,
173
+ onKeyDown: handleKeyDown,
169
174
  tabIndex: inputTabIndex,
170
175
  maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined,
171
176
  "data-test-id": 'field-textarea__input'
@@ -2,7 +2,7 @@ import { ChangeEvent, ReactNode } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
3
  import { TextAreaProps } from '../../helperComponents';
4
4
  import { FieldDecoratorProps } from '../FieldDecorator';
5
- type InputProps = Pick<Partial<TextAreaProps>, 'value'> & Pick<TextAreaProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
5
+ type InputProps = Pick<Partial<TextAreaProps>, 'value'> & Pick<TextAreaProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'onKeyDown'>;
6
6
  type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'caption' | 'hint' | 'size' | 'validationState' | 'showHintIcon' | 'labelTooltipPlacement' | 'error'>;
7
7
  type FieldTextAreaOwnProps = {
8
8
  /** Минимальное кол-во строк, до которого размер поля может быть увеличен @default 3*/
@@ -30,5 +30,5 @@ type FieldTextAreaOwnProps = {
30
30
  export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
31
31
  export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
32
32
  'data-test-id'?: string;
33
- } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "onFocus" | "onBlur" | "id" | "disabled" | "name" | "readonly" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
33
+ } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "onKeyDown" | "onFocus" | "onBlur" | "id" | "disabled" | "name" | "readonly" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
34
34
  export {};
@@ -22,7 +22,7 @@ import { getValidationState } from '../../utils/getValidationState';
22
22
  import { FieldDecorator } from '../FieldDecorator';
23
23
  import styles from './styles.module.css';
24
24
  export const FieldTextArea = forwardRef((_a, ref) => {
25
- var { id, name, value: valueProp, placeholder, maxLength, minRows = 3, maxRows = 1000, disabled = false, resizable = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = true, showHintIcon, onChange: onChangeProp, onFocus, onBlur, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, error, size = SIZE.S, validationState = VALIDATION_STATE.Default, onCopyButtonClick, footer } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick", "footer"]);
25
+ var { id, name, value: valueProp, placeholder, maxLength, minRows = 3, maxRows = 1000, disabled = false, resizable = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = true, showHintIcon, onChange: onChangeProp, onFocus, onBlur, onKeyDown, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, error, size = SIZE.S, validationState = VALIDATION_STATE.Default, onCopyButtonClick, footer } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "onKeyDown", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick", "footer"]);
26
26
  const localRef = useRef(null);
27
27
  const clearButtonRef = useRef(null);
28
28
  const copyButtonRef = useRef(null);
@@ -56,5 +56,9 @@ export const FieldTextArea = forwardRef((_a, ref) => {
56
56
  readonly,
57
57
  submitKeys: ['Enter', 'Space', 'Tab'],
58
58
  });
59
- return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, caption: caption, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, error: error, validationState: fieldValidationState }, extractSupportProps(rest), { children: _jsxs(FieldContainerPrivate, { className: styles.container, size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, "data-resizable": isResizable || undefined, "data-actions": Boolean(footer) || undefined, variant: CONTAINER_VARIANT.MultiLine, style: { '--max-rows': maxRows, '--min-rows': minRows }, inputRef: localRef, postfix: _jsx("span", { className: styles.postfix, children: postfixButtons }), children: [_jsx(Scroll, { className: styles.scrollContainer, size: 's', barHideStrategy: 'never', resize: isResizable ? 'vertical' : 'none', "data-test-id": 'field-textarea__scroll-area', children: _jsx(TextArea, { className: styles.textarea, "data-size": size, value: value, onChange: onChange, placeholder: placeholder, disabled: disabled, readonly: readonly, minRows: minRows, id: id, name: name, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, onKeyDown: onInputKeyDown, tabIndex: inputTabIndex, maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, "data-test-id": 'field-textarea__input' }) }), footer] }) })));
59
+ const handleKeyDown = event => {
60
+ onInputKeyDown(event);
61
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
62
+ };
63
+ return (_jsx(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, required: required, caption: caption, length: maxLength ? { max: maxLength, current: value.length } : undefined, hint: hint, disabled: disabled, readonly: readonly, showHintIcon: showHintIcon, size: size, error: error, validationState: fieldValidationState }, extractSupportProps(rest), { children: _jsxs(FieldContainerPrivate, { className: styles.container, size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, "data-resizable": isResizable || undefined, "data-actions": Boolean(footer) || undefined, variant: CONTAINER_VARIANT.MultiLine, style: { '--max-rows': maxRows, '--min-rows': minRows }, inputRef: localRef, postfix: _jsx("span", { className: styles.postfix, children: postfixButtons }), children: [_jsx(Scroll, { className: styles.scrollContainer, size: 's', barHideStrategy: 'never', resize: isResizable ? 'vertical' : 'none', "data-test-id": 'field-textarea__scroll-area', children: _jsx(TextArea, { className: styles.textarea, "data-size": size, value: value, onChange: onChange, placeholder: placeholder, disabled: disabled, readonly: readonly, minRows: minRows, id: id, name: name, ref: mergeRefs(ref, localRef), onFocus: onFocus, onBlur: onBlur, onKeyDown: handleKeyDown, tabIndex: inputTabIndex, maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, "data-test-id": 'field-textarea__input' }) }), footer] }) })));
60
64
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.44.0",
7
+ "version": "0.45.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -65,5 +65,5 @@
65
65
  "peerDependencies": {
66
66
  "@snack-uikit/locale": "*"
67
67
  },
68
- "gitHead": "98d8215a4c461746557441b6a31b109ebe43ce5c"
68
+ "gitHead": "f1744e34626d50f18e26f9e472b6b89c57b48df2"
69
69
  }
@@ -1,5 +1,5 @@
1
1
  import mergeRefs from 'merge-refs';
2
- import { ChangeEvent, forwardRef, ReactNode, useMemo, useRef } from 'react';
2
+ import { ChangeEvent, forwardRef, KeyboardEventHandler, ReactNode, useMemo, useRef } from 'react';
3
3
 
4
4
  import { SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
5
5
  import { Scroll } from '@snack-uikit/scroll';
@@ -13,7 +13,10 @@ import { FieldDecorator, FieldDecoratorProps } from '../FieldDecorator';
13
13
  import styles from './styles.module.scss';
14
14
 
15
15
  type InputProps = Pick<Partial<TextAreaProps>, 'value'> &
16
- Pick<TextAreaProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
16
+ Pick<
17
+ TextAreaProps,
18
+ 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'onKeyDown'
19
+ >;
17
20
 
18
21
  type WrapperProps = Pick<
19
22
  FieldDecoratorProps,
@@ -76,6 +79,7 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
76
79
  onChange: onChangeProp,
77
80
  onFocus,
78
81
  onBlur,
82
+ onKeyDown,
79
83
  className,
80
84
  label,
81
85
  labelTooltip,
@@ -133,6 +137,11 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
133
137
  submitKeys: ['Enter', 'Space', 'Tab'],
134
138
  });
135
139
 
140
+ const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = event => {
141
+ onInputKeyDown(event);
142
+ onKeyDown?.(event);
143
+ };
144
+
136
145
  return (
137
146
  <FieldDecorator
138
147
  className={className}
@@ -186,7 +195,7 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
186
195
  ref={mergeRefs(ref, localRef)}
187
196
  onFocus={onFocus}
188
197
  onBlur={onBlur}
189
- onKeyDown={onInputKeyDown}
198
+ onKeyDown={handleKeyDown}
190
199
  tabIndex={inputTabIndex}
191
200
  maxLength={allowMoreThanMaxLength ? undefined : maxLength || undefined}
192
201
  data-test-id='field-textarea__input'