@cloud-ru/uikit-product-fields-predefined 2.4.8-preview-5e39e65e.0 → 3.0.1-preview-d01a0cca.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 +11 -0
- package/README.md +1 -37
- package/dist/cjs/components/FieldCode/FieldCode.d.ts +2 -0
- package/dist/cjs/components/FieldCode/FieldCode.js +3 -3
- package/dist/cjs/components/FieldCode/components/Cell/Cell.d.ts +2 -0
- package/dist/cjs/components/FieldCode/components/Cell/Cell.js +2 -2
- package/dist/cjs/components/FieldCode/components/Cell/styles.module.css +16 -0
- package/dist/cjs/components/FieldCode/styles.module.css +7 -0
- package/dist/cjs/components/index.d.ts +0 -1
- package/dist/cjs/components/index.js +0 -1
- package/dist/esm/components/FieldCode/FieldCode.d.ts +2 -0
- package/dist/esm/components/FieldCode/FieldCode.js +3 -3
- package/dist/esm/components/FieldCode/components/Cell/Cell.d.ts +2 -0
- package/dist/esm/components/FieldCode/components/Cell/Cell.js +2 -2
- package/dist/esm/components/FieldCode/components/Cell/styles.module.css +16 -0
- package/dist/esm/components/FieldCode/styles.module.css +7 -0
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/components/index.js +0 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -5
- package/src/components/FieldCode/FieldCode.tsx +11 -3
- package/src/components/FieldCode/components/Cell/Cell.tsx +4 -1
- package/src/components/FieldCode/components/Cell/styles.module.scss +19 -0
- package/src/components/FieldCode/styles.module.scss +8 -0
- package/src/components/index.ts +0 -1
- package/dist/cjs/components/FieldAi/FieldAi.d.ts +0 -24
- package/dist/cjs/components/FieldAi/FieldAi.js +0 -92
- package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.d.ts +0 -5
- package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.js +0 -12
- package/dist/cjs/components/FieldAi/components/AlertButton/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/AlertButton/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/AlertButton/styles.module.css +0 -17
- package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.d.ts +0 -9
- package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.js +0 -28
- package/dist/cjs/components/FieldAi/components/CheckItem/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/CheckItem/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/CheckItem/styles.module.css +0 -36
- package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +0 -5
- package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +0 -31
- package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/MobileFieldAi/styles.module.css +0 -78
- package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +0 -7
- package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.js +0 -23
- package/dist/cjs/components/FieldAi/components/PasswordValidation/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/PasswordValidation/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/PasswordValidation/styles.module.css +0 -36
- package/dist/cjs/components/FieldAi/components/TextArea/TextArea.d.ts +0 -39
- package/dist/cjs/components/FieldAi/components/TextArea/TextArea.js +0 -33
- package/dist/cjs/components/FieldAi/components/TextArea/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/TextArea/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/TextArea/styles.module.css +0 -32
- package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +0 -10
- package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +0 -23
- package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.js +0 -17
- package/dist/cjs/components/FieldAi/components/WithPasswordValidation/styles.module.css +0 -6
- package/dist/cjs/components/FieldAi/index.d.ts +0 -1
- package/dist/cjs/components/FieldAi/index.js +0 -17
- package/dist/cjs/components/FieldAi/styles.module.css +0 -61
- package/dist/cjs/components/FieldAi/utils.d.ts +0 -10
- package/dist/cjs/components/FieldAi/utils.js +0 -19
- package/dist/esm/components/FieldAi/FieldAi.d.ts +0 -24
- package/dist/esm/components/FieldAi/FieldAi.js +0 -86
- package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.d.ts +0 -5
- package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.js +0 -6
- package/dist/esm/components/FieldAi/components/AlertButton/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/AlertButton/index.js +0 -1
- package/dist/esm/components/FieldAi/components/AlertButton/styles.module.css +0 -17
- package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.d.ts +0 -9
- package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.js +0 -22
- package/dist/esm/components/FieldAi/components/CheckItem/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/CheckItem/index.js +0 -1
- package/dist/esm/components/FieldAi/components/CheckItem/styles.module.css +0 -36
- package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +0 -5
- package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +0 -25
- package/dist/esm/components/FieldAi/components/MobileFieldAi/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/MobileFieldAi/index.js +0 -1
- package/dist/esm/components/FieldAi/components/MobileFieldAi/styles.module.css +0 -78
- package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +0 -7
- package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.js +0 -17
- package/dist/esm/components/FieldAi/components/PasswordValidation/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/PasswordValidation/index.js +0 -1
- package/dist/esm/components/FieldAi/components/PasswordValidation/styles.module.css +0 -36
- package/dist/esm/components/FieldAi/components/TextArea/TextArea.d.ts +0 -39
- package/dist/esm/components/FieldAi/components/TextArea/TextArea.js +0 -27
- package/dist/esm/components/FieldAi/components/TextArea/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/TextArea/index.js +0 -1
- package/dist/esm/components/FieldAi/components/TextArea/styles.module.css +0 -32
- package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +0 -10
- package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +0 -17
- package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.js +0 -1
- package/dist/esm/components/FieldAi/components/WithPasswordValidation/styles.module.css +0 -6
- package/dist/esm/components/FieldAi/index.d.ts +0 -1
- package/dist/esm/components/FieldAi/index.js +0 -1
- package/dist/esm/components/FieldAi/styles.module.css +0 -61
- package/dist/esm/components/FieldAi/utils.d.ts +0 -10
- package/dist/esm/components/FieldAi/utils.js +0 -15
- package/src/components/FieldAi/FieldAi.tsx +0 -201
- package/src/components/FieldAi/components/AlertButton/AlertButton.tsx +0 -16
- package/src/components/FieldAi/components/AlertButton/index.ts +0 -1
- package/src/components/FieldAi/components/AlertButton/styles.module.scss +0 -20
- package/src/components/FieldAi/components/CheckItem/CheckItem.tsx +0 -45
- package/src/components/FieldAi/components/CheckItem/index.ts +0 -1
- package/src/components/FieldAi/components/CheckItem/styles.module.scss +0 -44
- package/src/components/FieldAi/components/MobileFieldAi/MobileFieldAi.tsx +0 -57
- package/src/components/FieldAi/components/MobileFieldAi/index.ts +0 -1
- package/src/components/FieldAi/components/MobileFieldAi/styles.module.scss +0 -90
- package/src/components/FieldAi/components/PasswordValidation/PasswordValidation.tsx +0 -85
- package/src/components/FieldAi/components/PasswordValidation/index.ts +0 -1
- package/src/components/FieldAi/components/PasswordValidation/styles.module.scss +0 -34
- package/src/components/FieldAi/components/TextArea/TextArea.tsx +0 -113
- package/src/components/FieldAi/components/TextArea/index.ts +0 -1
- package/src/components/FieldAi/components/TextArea/styles.module.scss +0 -35
- package/src/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.tsx +0 -63
- package/src/components/FieldAi/components/WithPasswordValidation/index.ts +0 -1
- package/src/components/FieldAi/components/WithPasswordValidation/styles.module.scss +0 -8
- package/src/components/FieldAi/index.ts +0 -1
- package/src/components/FieldAi/styles.module.scss +0 -85
- package/src/components/FieldAi/utils.ts +0 -27
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
|
+
# 3.0.0 (2026-05-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* **LK-7388:** remove FieldAi ([95b0317](https://github.com/cloud-ru-tech/uikit-product/commit/95b03178739bd283313142b5cc352681cdf68ba7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 2.4.7 (2026-04-30)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -72,43 +72,6 @@
|
|
|
72
72
|
| afterClose | `VoidFunction` | - | Коллбек после закрытия модального окна/дровера |
|
|
73
73
|
| entityIcon | `JSXElementConstructor<{ size?: number; className?: string; }>` | - | Иконка сервиса |
|
|
74
74
|
| permission | "none" \| "canRead" \| "canCreate" | - | Управление состоянием компонента в зависимости от прав пользователя (по дефолту permission = 'canCreate') |
|
|
75
|
-
## FieldAi
|
|
76
|
-
### Props
|
|
77
|
-
| name | type | default value | description |
|
|
78
|
-
|------|------|---------------|-------------|
|
|
79
|
-
| layoutType* | enum LayoutType: `"mobile"`, `"tablet"`, `"desktop"`, `"desktopSmall"` | - | |
|
|
80
|
-
| onSubmit* | `(value: string) => void` | - | Колбек действия при отправке |
|
|
81
|
-
| value | `string` | - | HTML-аттрибут value |
|
|
82
|
-
| onChange | `(value: string, e?: ChangeEvent<HTMLTextAreaElement>) => void` | - | Колбек смены значения |
|
|
83
|
-
| inputMode | enum InputMode: `"search"`, `"none"`, `"text"`, `"tel"`, `"email"`, `"decimal"`, `"numeric"`, `"url"` | - | Режим работы экранной клавиатуры |
|
|
84
|
-
| id | `string` | - | HTML-аттрибут id |
|
|
85
|
-
| name | `string` | - | HTML-аттрибут name |
|
|
86
|
-
| maxLength | `number` | - | Максимальное кол-во символов |
|
|
87
|
-
| disabled | `boolean` | - | Является ли поле деактивированным |
|
|
88
|
-
| readonly | `boolean` | - | Является ли поле доступным только на чтение |
|
|
89
|
-
| onFocus | `FocusEventHandler<HTMLTextAreaElement>` | - | Колбек получения фокуса |
|
|
90
|
-
| onBlur | `FocusEventHandler<HTMLTextAreaElement>` | - | Колбек потери фокуса |
|
|
91
|
-
| autoFocus | `boolean` | - | Включен ли авто-фокус |
|
|
92
|
-
| onKeyDown | `KeyboardEventHandler<HTMLTextAreaElement>` | - | Колбек нажатия клавиши клавиатуры |
|
|
93
|
-
| className | `string` | - | CSS-класс |
|
|
94
|
-
| caption | `string` | - | Подпись справа от лейбла |
|
|
95
|
-
| hint | `string` | - | Подсказка внизу |
|
|
96
|
-
| showHintIcon | `boolean` | - | Отображать иконку подсказки |
|
|
97
|
-
| validationState | enum ValidationState: `"error"`, `"default"`, `"warning"`, `"success"` | - | Состояние валидации |
|
|
98
|
-
| labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Расположение подсказки лейбла |
|
|
99
|
-
| error | `string` | - | |
|
|
100
|
-
| allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
|
|
101
|
-
| showCopyButton | `boolean` | - | Отображение кнопки Копировать для поля (актуально только для `readonly = true`) |
|
|
102
|
-
| onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
|
|
103
|
-
| showClearButton | `boolean` | true | Отображение кнопки очистки поля |
|
|
104
|
-
| minRows | `number` | 3 | Минимальное кол-во строк, до которого размер поля может быть увеличен |
|
|
105
|
-
| maxRows | `number` | 1000 | Максимальное кол-во строк, до которого размер поля может быть увеличен |
|
|
106
|
-
| resizable | `boolean` | - | Может ли ли пользователь изменять размеры поля (если св-во не включено, поле автоматически меняет свой размер) |
|
|
107
|
-
| secure | `boolean \| "password"` | - | Режим ввода sensitive данных (пароля, API ключей, токенов, etc) |
|
|
108
|
-
| onResetContextClick | `() => void` | - | Действие при клике по кнопке сброса контекста |
|
|
109
|
-
| onCancelSecure | `() => void` | - | Действие для отмены секьюрности поля |
|
|
110
|
-
| ref | `LegacyRef<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|
|
111
|
-
| key | `Key` | - | |
|
|
112
75
|
## FieldChat
|
|
113
76
|
### Props
|
|
114
77
|
| name | type | default value | description |
|
|
@@ -369,6 +332,7 @@
|
|
|
369
332
|
| resendCode | `ResendCodeProps` | - | Компонент отправки нового кода |
|
|
370
333
|
| focusEffects | `readonly FieldCodeFocusEffect[]` | - | Сценарии автофокуса; по умолчанию — первая ячейка при монтировании и после сброса (см. `FieldCodeFocusEffect`) |
|
|
371
334
|
| invalidCode | `string` | - | Сообщение при неверном коде, если не передан свой `error` |
|
|
335
|
+
| stretchCells | `boolean` | - | Растягивать ячейки на всю доступную ширину; иначе фиксированная ширина по `size` |
|
|
372
336
|
| value | `string` | - | Значение кода |
|
|
373
337
|
| onChange | `(code: string) => void` | - | Колбек изменения значения |
|
|
374
338
|
| onComplete | `(code: string) => void` | - | Колбек достижения ввода всех символов кода |
|
|
@@ -26,6 +26,8 @@ export type FieldCodeOwnProps = {
|
|
|
26
26
|
focusEffects?: readonly FieldCodeFocusEffect[];
|
|
27
27
|
/** Сообщение при неверном коде, если не передан свой `error` */
|
|
28
28
|
invalidCode?: string;
|
|
29
|
+
/** Растягивать ячейки на всю доступную ширину; иначе фиксированная ширина по `size` */
|
|
30
|
+
stretchCells?: boolean;
|
|
29
31
|
};
|
|
30
32
|
export type FieldCodeProps = FieldCodeOwnProps & Omit<UseCodeInputParams, 'moveFocus'> & Pick<FieldDecoratorProps, 'size' | 'disabled' | 'label' | 'error' | 'data-test-id'>;
|
|
31
33
|
export declare const FieldCode: import("react").ForwardRefExoticComponent<FieldCodeOwnProps & Omit<UseCodeInputParams, "moveFocus"> & Pick<FieldDecoratorProps, "size" | "label" | "error" | "disabled" | "data-test-id"> & import("react").RefAttributes<FieldCodeRef>>;
|
|
@@ -15,7 +15,7 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
|
15
15
|
const utils_1 = require("./utils");
|
|
16
16
|
exports.FieldCode = (0, react_1.forwardRef)(function FieldCode(props, ref) {
|
|
17
17
|
var _a;
|
|
18
|
-
const { codeLength, className, cellClassName, value, onChange, spacing, onComplete, size, disabled, label, error, invalidCode, showEmptyChars, resendCode, focusEffects = constants_1.FIELD_CODE_DEFAULT_FOCUS_EFFECTS, 'data-test-id': dataTestId, } = props;
|
|
18
|
+
const { codeLength, className, cellClassName, value, onChange, spacing, onComplete, size, disabled, label, error, invalidCode, showEmptyChars, resendCode, focusEffects = constants_1.FIELD_CODE_DEFAULT_FOCUS_EFFECTS, stretchCells = false, 'data-test-id': dataTestId, } = props;
|
|
19
19
|
const { inputsRef, moveFocus, blurFields } = (0, hooks_1.useFocusCell)(codeLength);
|
|
20
20
|
const { code, cellHandlers, onChangeCode } = (0, hooks_1.useCodeInput)({ value, onChange, codeLength, moveFocus, onComplete });
|
|
21
21
|
const { resetCode } = (0, hooks_1.useFieldHelpers)({
|
|
@@ -38,11 +38,11 @@ exports.FieldCode = (0, react_1.forwardRef)(function FieldCode(props, ref) {
|
|
|
38
38
|
size,
|
|
39
39
|
error: resolvedError,
|
|
40
40
|
};
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(styles_module_scss_1.default.fieldCode, className) }, (dataTestId ? { 'data-test-id': dataTestId } : undefined), { children: [(0, jsx_runtime_1.jsx)(fields_1.FieldDecorator, Object.assign({}, resolvedDecoratorProps, { children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.codeContainer, "data-size": size, children: code.map((char, index) => ((0, jsx_runtime_1.jsx)(components_1.Cell, { ref: inputRef => {
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(styles_module_scss_1.default.fieldCode, className), "data-stretch-cells": stretchCells || undefined }, (dataTestId ? { 'data-test-id': dataTestId } : undefined), { children: [(0, jsx_runtime_1.jsx)(fields_1.FieldDecorator, Object.assign({ className: styles_module_scss_1.default.fieldDecorator }, resolvedDecoratorProps, { children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.codeContainer, "data-size": size, "data-stretch-cells": stretchCells || undefined, children: code.map((char, index) => ((0, jsx_runtime_1.jsx)(components_1.Cell, { ref: inputRef => {
|
|
42
42
|
if (inputRef) {
|
|
43
43
|
inputsRef.current[index] = inputRef;
|
|
44
44
|
}
|
|
45
|
-
}, className: (0, classnames_1.default)((spacing === null || spacing === void 0 ? void 0 : spacing.includes(index)) && styles_module_scss_1.default.cellSpacing, cellClassName), size: size, value: char, disabled: disabled, autoComplete: index === 0 ? 'one-time-code' : undefined, onKeyDown: e => cellHandlers.onKeyDown(e, index), onPaste: cellHandlers.onPaste, onChange: e => cellHandlers.onChange(e, index), validationState: (0, utils_1.getCellValidationState)(char, showEmptyChars, Boolean(resolvedError)) }, index))) }) })), resendCode ? (0, jsx_runtime_1.jsx)(components_1.ResendCode, Object.assign({}, resendCode, { size: (_a = resendCode.size) !== null && _a !== void 0 ? _a : size })) : null] })));
|
|
45
|
+
}, className: (0, classnames_1.default)((spacing === null || spacing === void 0 ? void 0 : spacing.includes(index)) && styles_module_scss_1.default.cellSpacing, cellClassName), stretchCells: stretchCells, size: size, value: char, disabled: disabled, autoComplete: index === 0 ? 'one-time-code' : undefined, onKeyDown: e => cellHandlers.onKeyDown(e, index), onPaste: cellHandlers.onPaste, onChange: e => cellHandlers.onChange(e, index), validationState: (0, utils_1.getCellValidationState)(char, showEmptyChars, Boolean(resolvedError)) }, index))) }) })), resendCode ? (0, jsx_runtime_1.jsx)(components_1.ResendCode, Object.assign({}, resendCode, { size: (_a = resendCode.size) !== null && _a !== void 0 ? _a : size })) : null] })));
|
|
46
46
|
});
|
|
47
47
|
var constants_2 = require("./constants");
|
|
48
48
|
Object.defineProperty(exports, "FIELD_CODE_DEFAULT_FOCUS_EFFECTS", { enumerable: true, get: function () { return constants_2.FIELD_CODE_DEFAULT_FOCUS_EFFECTS; } });
|
|
@@ -2,4 +2,6 @@ import { FieldTextProps } from '@snack-uikit/fields';
|
|
|
2
2
|
export declare const Cell: import("react").ForwardRefExoticComponent<{
|
|
3
3
|
/** CSS-класс ячейки кода */
|
|
4
4
|
className?: string;
|
|
5
|
+
/** Растягивать ячейку на всю доступную ширину */
|
|
6
|
+
stretchCells?: boolean;
|
|
5
7
|
} & Pick<FieldTextProps, "size" | "onPaste" | "onChange" | "onKeyDown" | "value" | "disabled" | "autoComplete" | "validationState"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -22,6 +22,6 @@ const fields_1 = require("@snack-uikit/fields");
|
|
|
22
22
|
const constants_1 = require("../../constants");
|
|
23
23
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
24
24
|
exports.Cell = (0, react_1.forwardRef)((props, ref) => {
|
|
25
|
-
const { className, size, value } = props, fieldCellProps = __rest(props, ["className", "size", "value"]);
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(fields_1.FieldText, Object.assign({ inputMode: 'numeric', ref: ref, className: (0, classnames_1.default)(styles_module_scss_1.default.cell, className), "data-size": size, showClearButton: false, value: value === constants_1.ZERO_WIDTH_SPACE ? '' : value, size: size }, fieldCellProps)));
|
|
25
|
+
const { className, size, stretchCells, value } = props, fieldCellProps = __rest(props, ["className", "size", "stretchCells", "value"]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(fields_1.FieldText, Object.assign({ inputMode: 'numeric', ref: ref, className: (0, classnames_1.default)(styles_module_scss_1.default.cell, className), "data-size": size, "data-stretch-cells": stretchCells || undefined, showClearButton: false, value: value === constants_1.ZERO_WIDTH_SPACE ? '' : value, size: size }, fieldCellProps)));
|
|
27
27
|
});
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
.cell{
|
|
2
|
+
flex-shrink:0;
|
|
3
|
+
}
|
|
1
4
|
.cell input{
|
|
2
5
|
text-align:center;
|
|
6
|
+
}
|
|
7
|
+
.cell[data-size=s]:not([data-stretch-cells]){
|
|
8
|
+
width:32px;
|
|
9
|
+
}
|
|
10
|
+
.cell[data-size=m]:not([data-stretch-cells]){
|
|
11
|
+
width:40px;
|
|
12
|
+
}
|
|
13
|
+
.cell[data-size=l]:not([data-stretch-cells]){
|
|
14
|
+
width:48px;
|
|
15
|
+
}
|
|
16
|
+
.cell[data-stretch-cells]{
|
|
17
|
+
flex:1 1 0;
|
|
18
|
+
min-width:0;
|
|
3
19
|
}
|
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./FieldPhone"), exports);
|
|
18
18
|
__exportStar(require("./SelectCreate"), exports);
|
|
19
|
-
__exportStar(require("./FieldAi"), exports);
|
|
20
19
|
__exportStar(require("./FieldChat"), exports);
|
|
21
20
|
__exportStar(require("./AIDisclaimer"), exports);
|
|
22
21
|
__exportStar(require("./FieldName"), exports);
|
|
@@ -26,6 +26,8 @@ export type FieldCodeOwnProps = {
|
|
|
26
26
|
focusEffects?: readonly FieldCodeFocusEffect[];
|
|
27
27
|
/** Сообщение при неверном коде, если не передан свой `error` */
|
|
28
28
|
invalidCode?: string;
|
|
29
|
+
/** Растягивать ячейки на всю доступную ширину; иначе фиксированная ширина по `size` */
|
|
30
|
+
stretchCells?: boolean;
|
|
29
31
|
};
|
|
30
32
|
export type FieldCodeProps = FieldCodeOwnProps & Omit<UseCodeInputParams, 'moveFocus'> & Pick<FieldDecoratorProps, 'size' | 'disabled' | 'label' | 'error' | 'data-test-id'>;
|
|
31
33
|
export declare const FieldCode: import("react").ForwardRefExoticComponent<FieldCodeOwnProps & Omit<UseCodeInputParams, "moveFocus"> & Pick<FieldDecoratorProps, "size" | "label" | "error" | "disabled" | "data-test-id"> & import("react").RefAttributes<FieldCodeRef>>;
|
|
@@ -9,7 +9,7 @@ import styles from './styles.module.css';
|
|
|
9
9
|
import { getCellValidationState } from './utils';
|
|
10
10
|
export const FieldCode = forwardRef(function FieldCode(props, ref) {
|
|
11
11
|
var _a;
|
|
12
|
-
const { codeLength, className, cellClassName, value, onChange, spacing, onComplete, size, disabled, label, error, invalidCode, showEmptyChars, resendCode, focusEffects = FIELD_CODE_DEFAULT_FOCUS_EFFECTS, 'data-test-id': dataTestId, } = props;
|
|
12
|
+
const { codeLength, className, cellClassName, value, onChange, spacing, onComplete, size, disabled, label, error, invalidCode, showEmptyChars, resendCode, focusEffects = FIELD_CODE_DEFAULT_FOCUS_EFFECTS, stretchCells = false, 'data-test-id': dataTestId, } = props;
|
|
13
13
|
const { inputsRef, moveFocus, blurFields } = useFocusCell(codeLength);
|
|
14
14
|
const { code, cellHandlers, onChangeCode } = useCodeInput({ value, onChange, codeLength, moveFocus, onComplete });
|
|
15
15
|
const { resetCode } = useFieldHelpers({
|
|
@@ -32,10 +32,10 @@ export const FieldCode = forwardRef(function FieldCode(props, ref) {
|
|
|
32
32
|
size,
|
|
33
33
|
error: resolvedError,
|
|
34
34
|
};
|
|
35
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.fieldCode, className) }, (dataTestId ? { 'data-test-id': dataTestId } : undefined), { children: [_jsx(FieldDecorator, Object.assign({}, resolvedDecoratorProps, { children: _jsx("div", { className: styles.codeContainer, "data-size": size, children: code.map((char, index) => (_jsx(Cell, { ref: inputRef => {
|
|
35
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.fieldCode, className), "data-stretch-cells": stretchCells || undefined }, (dataTestId ? { 'data-test-id': dataTestId } : undefined), { children: [_jsx(FieldDecorator, Object.assign({ className: styles.fieldDecorator }, resolvedDecoratorProps, { children: _jsx("div", { className: styles.codeContainer, "data-size": size, "data-stretch-cells": stretchCells || undefined, children: code.map((char, index) => (_jsx(Cell, { ref: inputRef => {
|
|
36
36
|
if (inputRef) {
|
|
37
37
|
inputsRef.current[index] = inputRef;
|
|
38
38
|
}
|
|
39
|
-
}, className: cn((spacing === null || spacing === void 0 ? void 0 : spacing.includes(index)) && styles.cellSpacing, cellClassName), size: size, value: char, disabled: disabled, autoComplete: index === 0 ? 'one-time-code' : undefined, onKeyDown: e => cellHandlers.onKeyDown(e, index), onPaste: cellHandlers.onPaste, onChange: e => cellHandlers.onChange(e, index), validationState: getCellValidationState(char, showEmptyChars, Boolean(resolvedError)) }, index))) }) })), resendCode ? _jsx(ResendCode, Object.assign({}, resendCode, { size: (_a = resendCode.size) !== null && _a !== void 0 ? _a : size })) : null] })));
|
|
39
|
+
}, className: cn((spacing === null || spacing === void 0 ? void 0 : spacing.includes(index)) && styles.cellSpacing, cellClassName), stretchCells: stretchCells, size: size, value: char, disabled: disabled, autoComplete: index === 0 ? 'one-time-code' : undefined, onKeyDown: e => cellHandlers.onKeyDown(e, index), onPaste: cellHandlers.onPaste, onChange: e => cellHandlers.onChange(e, index), validationState: getCellValidationState(char, showEmptyChars, Boolean(resolvedError)) }, index))) }) })), resendCode ? _jsx(ResendCode, Object.assign({}, resendCode, { size: (_a = resendCode.size) !== null && _a !== void 0 ? _a : size })) : null] })));
|
|
40
40
|
});
|
|
41
41
|
export { FIELD_CODE_DEFAULT_FOCUS_EFFECTS } from './constants';
|
|
@@ -2,4 +2,6 @@ import { FieldTextProps } from '@snack-uikit/fields';
|
|
|
2
2
|
export declare const Cell: import("react").ForwardRefExoticComponent<{
|
|
3
3
|
/** CSS-класс ячейки кода */
|
|
4
4
|
className?: string;
|
|
5
|
+
/** Растягивать ячейку на всю доступную ширину */
|
|
6
|
+
stretchCells?: boolean;
|
|
5
7
|
} & Pick<FieldTextProps, "size" | "onPaste" | "onChange" | "onKeyDown" | "value" | "disabled" | "autoComplete" | "validationState"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -16,6 +16,6 @@ import { FieldText } from '@snack-uikit/fields';
|
|
|
16
16
|
import { ZERO_WIDTH_SPACE } from '../../constants';
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
export const Cell = forwardRef((props, ref) => {
|
|
19
|
-
const { className, size, value } = props, fieldCellProps = __rest(props, ["className", "size", "value"]);
|
|
20
|
-
return (_jsx(FieldText, Object.assign({ inputMode: 'numeric', ref: ref, className: cn(styles.cell, className), "data-size": size, showClearButton: false, value: value === ZERO_WIDTH_SPACE ? '' : value, size: size }, fieldCellProps)));
|
|
19
|
+
const { className, size, stretchCells, value } = props, fieldCellProps = __rest(props, ["className", "size", "stretchCells", "value"]);
|
|
20
|
+
return (_jsx(FieldText, Object.assign({ inputMode: 'numeric', ref: ref, className: cn(styles.cell, className), "data-size": size, "data-stretch-cells": stretchCells || undefined, showClearButton: false, value: value === ZERO_WIDTH_SPACE ? '' : value, size: size }, fieldCellProps)));
|
|
21
21
|
});
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
.cell{
|
|
2
|
+
flex-shrink:0;
|
|
3
|
+
}
|
|
1
4
|
.cell input{
|
|
2
5
|
text-align:center;
|
|
6
|
+
}
|
|
7
|
+
.cell[data-size=s]:not([data-stretch-cells]){
|
|
8
|
+
width:32px;
|
|
9
|
+
}
|
|
10
|
+
.cell[data-size=m]:not([data-stretch-cells]){
|
|
11
|
+
width:40px;
|
|
12
|
+
}
|
|
13
|
+
.cell[data-size=l]:not([data-stretch-cells]){
|
|
14
|
+
width:48px;
|
|
15
|
+
}
|
|
16
|
+
.cell[data-stretch-cells]{
|
|
17
|
+
flex:1 1 0;
|
|
18
|
+
min-width:0;
|
|
3
19
|
}
|