@snack-uikit/fields 0.35.7-preview-c6f5cbae.0 → 0.36.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 +12 -0
- package/README.md +1 -1
- package/dist/cjs/components/FieldText/FieldText.d.ts +2 -2
- package/dist/cjs/components/FieldText/FieldText.js +8 -5
- package/dist/esm/components/FieldText/FieldText.d.ts +2 -2
- package/dist/esm/components/FieldText/FieldText.js +7 -3
- package/package.json +6 -6
- package/src/components/FieldText/FieldText.tsx +18 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.36.0 (2024-12-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FCB-40:** add onKeyDown prop ([fdbda5b](https://github.com/cloud-ru-tech/snack-uikit/commit/fdbda5b5b861527d0dfa54b13fb5a353128a5984))
|
|
12
|
+
* **FCB-40:** add onPaste prop ([a31d8f3](https://github.com/cloud-ru-tech/snack-uikit/commit/a31d8f3d985b9dc1a8f53fc7740505d74eefd961))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## 0.35.6 (2024-12-17)
|
|
7
19
|
|
|
8
20
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -460,7 +460,7 @@ FieldStepper в основном предназначен для работы с
|
|
|
460
460
|
| placeholder | `string` | - | Значение плейсхолдера |
|
|
461
461
|
| maxLength | `number` | - | Максимальная длина вводимого значения |
|
|
462
462
|
| autoComplete | `string \| boolean` | false | Включен ли автокомплит для поля |
|
|
463
|
-
|
|
|
463
|
+
| onKeyDown | `KeyboardEventHandler<HTMLInputElement>` | - | Колбек обработки начала нажатия клавиши клавиатуры |
|
|
464
464
|
| onPaste | `ClipboardEventHandler<HTMLInputElement>` | - | Колбек обработки вставки значения |
|
|
465
465
|
| className | `string` | - | CSS-класс |
|
|
466
466
|
| label | `string` | - | Лейбл |
|
|
@@ -3,7 +3,7 @@ import { InputPrivateProps } from '@snack-uikit/input-private';
|
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
import { Button } from '../../types';
|
|
5
5
|
import { FieldDecoratorProps } from '../FieldDecorator';
|
|
6
|
-
type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete' | 'onPaste' | '
|
|
6
|
+
type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete' | 'onPaste' | 'onKeyDown'>;
|
|
7
7
|
type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'caption' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement' | 'error'>;
|
|
8
8
|
type FieldTextOwnProps = {
|
|
9
9
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
@@ -29,5 +29,5 @@ type FieldTextOwnProps = {
|
|
|
29
29
|
export type FieldTextProps = WithSupportProps<FieldTextOwnProps & InputProps & WrapperProps>;
|
|
30
30
|
export declare const FieldText: import("react").ForwardRefExoticComponent<{
|
|
31
31
|
'data-test-id'?: string;
|
|
32
|
-
} & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "onFocus" | "onBlur" | "id" | "disabled" | "name" | "onPaste" | "
|
|
32
|
+
} & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "onKeyDown" | "onFocus" | "onBlur" | "id" | "disabled" | "name" | "onPaste" | "readonly" | "placeholder" | "autoComplete" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
33
33
|
export {};
|
|
@@ -60,10 +60,10 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
60
60
|
prefix,
|
|
61
61
|
postfix,
|
|
62
62
|
button: buttonProp,
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
onPaste,
|
|
64
|
+
onKeyDown
|
|
65
65
|
} = _a,
|
|
66
|
-
rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "prefixIcon", "prefix", "postfix", "button", "
|
|
66
|
+
rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown"]);
|
|
67
67
|
const [value = '', onChange] = (0, hooks_1.useValueControl)({
|
|
68
68
|
value: valueProp,
|
|
69
69
|
defaultValue: '',
|
|
@@ -156,6 +156,10 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
156
156
|
readonly,
|
|
157
157
|
submitKeys: ['Enter', 'Space', 'Tab']
|
|
158
158
|
});
|
|
159
|
+
const handleKeyDown = event => {
|
|
160
|
+
onInputKeyDown(event);
|
|
161
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
162
|
+
};
|
|
159
163
|
return (0, jsx_runtime_1.jsx)(FieldDecorator_1.FieldDecorator, Object.assign({
|
|
160
164
|
className: className,
|
|
161
165
|
label: label,
|
|
@@ -194,8 +198,7 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
194
198
|
onFocus: onFocus,
|
|
195
199
|
onBlur: onBlur,
|
|
196
200
|
tabIndex: inputTabIndex,
|
|
197
|
-
onKeyDown:
|
|
198
|
-
onKeyUp: onKeyUp,
|
|
201
|
+
onKeyDown: handleKeyDown,
|
|
199
202
|
onPaste: onPaste,
|
|
200
203
|
placeholder: placeholder,
|
|
201
204
|
disabled: disabled,
|
|
@@ -3,7 +3,7 @@ import { InputPrivateProps } from '@snack-uikit/input-private';
|
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
import { Button } from '../../types';
|
|
5
5
|
import { FieldDecoratorProps } from '../FieldDecorator';
|
|
6
|
-
type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete' | 'onPaste' | '
|
|
6
|
+
type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> & Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'maxLength' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'autoComplete' | 'onPaste' | 'onKeyDown'>;
|
|
7
7
|
type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'caption' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement' | 'error'>;
|
|
8
8
|
type FieldTextOwnProps = {
|
|
9
9
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
@@ -29,5 +29,5 @@ type FieldTextOwnProps = {
|
|
|
29
29
|
export type FieldTextProps = WithSupportProps<FieldTextOwnProps & InputProps & WrapperProps>;
|
|
30
30
|
export declare const FieldText: import("react").ForwardRefExoticComponent<{
|
|
31
31
|
'data-test-id'?: string;
|
|
32
|
-
} & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "onFocus" | "onBlur" | "id" | "disabled" | "name" | "onPaste" | "
|
|
32
|
+
} & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "value" | "onChange"> & Pick<InputPrivateProps, "onKeyDown" | "onFocus" | "onBlur" | "id" | "disabled" | "name" | "onPaste" | "readonly" | "placeholder" | "autoComplete" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
33
33
|
export {};
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import mergeRefs from 'merge-refs';
|
|
14
|
-
import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import { forwardRef, useCallback, useMemo, useRef, useState, } from 'react';
|
|
15
15
|
import { InputPrivate, SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
|
|
16
16
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
17
|
import { VALIDATION_STATE } from '../../constants';
|
|
@@ -21,7 +21,7 @@ import { getValidationState } from '../../utils/getValidationState';
|
|
|
21
21
|
import { FieldDecorator } from '../FieldDecorator';
|
|
22
22
|
import { getContainerVariant } from './helpers';
|
|
23
23
|
export const FieldText = forwardRef((_a, ref) => {
|
|
24
|
-
var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, onCopyButtonClick, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, error, autoComplete, prefixIcon, prefix, postfix, button: buttonProp,
|
|
24
|
+
var { id, name, value: valueProp, placeholder, maxLength, disabled = false, readonly = false, showCopyButton: showCopyButtonProp = true, showClearButton: showClearButtonProp = true, allowMoreThanMaxLength = false, onChange: onChangeProp, onFocus, onBlur, onCopyButtonClick, className, label, labelTooltip, labelTooltipPlacement, required = false, caption, hint, showHintIcon, size = SIZE.S, validationState = VALIDATION_STATE.Default, error, autoComplete, prefixIcon, prefix, postfix, button: buttonProp, onPaste, onKeyDown } = _a, rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown"]);
|
|
25
25
|
const [value = '', onChange] = useValueControl({
|
|
26
26
|
value: valueProp,
|
|
27
27
|
defaultValue: '',
|
|
@@ -87,5 +87,9 @@ export const FieldText = forwardRef((_a, ref) => {
|
|
|
87
87
|
readonly,
|
|
88
88
|
submitKeys: ['Enter', 'Space', 'Tab'],
|
|
89
89
|
});
|
|
90
|
-
|
|
90
|
+
const handleKeyDown = event => {
|
|
91
|
+
onInputKeyDown(event);
|
|
92
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
93
|
+
};
|
|
94
|
+
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, validationState: fieldValidationState, error: error }, extractSupportProps(rest), { children: _jsx(FieldContainerPrivate, { size: size, validationState: fieldValidationState, disabled: disabled, readonly: readonly, variant: containerVariant, inputRef: localRef, prefix: prefixButtons, postfix: postfixButtons, disableFocus: isButtonFocused, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: value, onChange: onChange, onFocus: onFocus, onBlur: onBlur, tabIndex: inputTabIndex, onKeyDown: handleKeyDown, onPaste: onPaste, placeholder: placeholder, disabled: disabled, readonly: readonly, type: 'text', maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined, id: id, name: name, autoComplete: autoComplete, "data-test-id": 'field-text__input' }) }) })));
|
|
91
95
|
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.36.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/button": "0.19.5",
|
|
40
|
-
"@snack-uikit/calendar": "0.11.12
|
|
41
|
-
"@snack-uikit/color-picker": "0.3.8
|
|
40
|
+
"@snack-uikit/calendar": "0.11.12",
|
|
41
|
+
"@snack-uikit/color-picker": "0.3.8",
|
|
42
42
|
"@snack-uikit/divider": "3.2.2",
|
|
43
43
|
"@snack-uikit/dropdown": "0.4.2",
|
|
44
44
|
"@snack-uikit/icons": "0.24.1",
|
|
45
|
-
"@snack-uikit/input-private": "4.
|
|
46
|
-
"@snack-uikit/list": "0.
|
|
45
|
+
"@snack-uikit/input-private": "4.5.0",
|
|
46
|
+
"@snack-uikit/list": "0.22.0",
|
|
47
47
|
"@snack-uikit/scroll": "0.9.2",
|
|
48
48
|
"@snack-uikit/skeleton": "0.6.1",
|
|
49
49
|
"@snack-uikit/slider": "0.3.3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d328fa0c928a7dfaa6396374a3f639c9f61ae878"
|
|
69
69
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import mergeRefs from 'merge-refs';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
KeyboardEventHandler,
|
|
5
|
+
ReactElement,
|
|
6
|
+
ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
3
12
|
|
|
4
13
|
import { InputPrivate, InputPrivateProps, SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
|
|
5
14
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
@@ -25,7 +34,7 @@ type InputProps = Pick<Partial<InputPrivateProps>, 'value' | 'onChange'> &
|
|
|
25
34
|
| 'onBlur'
|
|
26
35
|
| 'autoComplete'
|
|
27
36
|
| 'onPaste'
|
|
28
|
-
| '
|
|
37
|
+
| 'onKeyDown'
|
|
29
38
|
>;
|
|
30
39
|
|
|
31
40
|
type WrapperProps = Pick<
|
|
@@ -100,8 +109,8 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
|
|
|
100
109
|
prefix,
|
|
101
110
|
postfix,
|
|
102
111
|
button: buttonProp,
|
|
103
|
-
onKeyUp,
|
|
104
112
|
onPaste,
|
|
113
|
+
onKeyDown,
|
|
105
114
|
...rest
|
|
106
115
|
},
|
|
107
116
|
ref,
|
|
@@ -193,6 +202,11 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
|
|
|
193
202
|
submitKeys: ['Enter', 'Space', 'Tab'],
|
|
194
203
|
});
|
|
195
204
|
|
|
205
|
+
const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = event => {
|
|
206
|
+
onInputKeyDown(event);
|
|
207
|
+
onKeyDown?.(event);
|
|
208
|
+
};
|
|
209
|
+
|
|
196
210
|
return (
|
|
197
211
|
<FieldDecorator
|
|
198
212
|
className={className}
|
|
@@ -231,8 +245,7 @@ export const FieldText = forwardRef<HTMLInputElement, FieldTextProps>(
|
|
|
231
245
|
onFocus={onFocus}
|
|
232
246
|
onBlur={onBlur}
|
|
233
247
|
tabIndex={inputTabIndex}
|
|
234
|
-
onKeyDown={
|
|
235
|
-
onKeyUp={onKeyUp}
|
|
248
|
+
onKeyDown={handleKeyDown}
|
|
236
249
|
onPaste={onPaste}
|
|
237
250
|
placeholder={placeholder}
|
|
238
251
|
disabled={disabled}
|