@snack-uikit/fields 0.43.0 → 0.43.1-preview-ff425617.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/README.md +1 -0
- package/dist/cjs/components/FieldTextArea/FieldTextArea.d.ts +3 -1
- package/dist/cjs/components/FieldTextArea/FieldTextArea.js +7 -5
- package/dist/cjs/components/FieldTextArea/styles.module.css +4 -0
- package/dist/esm/components/FieldTextArea/FieldTextArea.d.ts +3 -1
- package/dist/esm/components/FieldTextArea/FieldTextArea.js +3 -3
- package/dist/esm/components/FieldTextArea/styles.module.css +4 -0
- package/package.json +2 -2
- package/src/components/FieldTextArea/FieldTextArea.tsx +6 -1
- package/src/components/FieldTextArea/styles.module.scss +7 -3
package/README.md
CHANGED
|
@@ -509,6 +509,7 @@ FieldStepper в основном предназначен для работы с
|
|
|
509
509
|
| onCopyButtonClick | `() => void` | - | Колбек клика по кнопке Копировать для поля |
|
|
510
510
|
| showClearButton | `boolean` | true | Отображение кнопки очистки поля |
|
|
511
511
|
| allowMoreThanMaxLength | `boolean` | true | Можно ли вводить больше разрешённого кол-ва символов |
|
|
512
|
+
| footer | `ReactNode` | - | Нода под футер |
|
|
512
513
|
| value | `string` | - | HTML-аттрибут value |
|
|
513
514
|
| id | `string` | - | HTML-аттрибут id |
|
|
514
515
|
| name | `string` | - | HTML-аттрибут name |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
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';
|
|
@@ -24,6 +24,8 @@ type FieldTextAreaOwnProps = {
|
|
|
24
24
|
showClearButton?: boolean;
|
|
25
25
|
/** Можно ли вводить больше разрешённого кол-ва символов */
|
|
26
26
|
allowMoreThanMaxLength?: boolean;
|
|
27
|
+
/** Нода под футер */
|
|
28
|
+
footer?: ReactNode;
|
|
27
29
|
};
|
|
28
30
|
export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
|
|
29
31
|
export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
|
|
@@ -58,9 +58,10 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
58
58
|
error,
|
|
59
59
|
size = input_private_1.SIZE.S,
|
|
60
60
|
validationState = constants_1.VALIDATION_STATE.Default,
|
|
61
|
-
onCopyButtonClick
|
|
61
|
+
onCopyButtonClick,
|
|
62
|
+
footer
|
|
62
63
|
} = _a,
|
|
63
|
-
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"]);
|
|
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"]);
|
|
64
65
|
const localRef = (0, react_1.useRef)(null);
|
|
65
66
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
66
67
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
@@ -126,13 +127,14 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
126
127
|
error: error,
|
|
127
128
|
validationState: fieldValidationState
|
|
128
129
|
}, (0, utils_1.extractSupportProps)(rest), {
|
|
129
|
-
children: (0, jsx_runtime_1.
|
|
130
|
+
children: (0, jsx_runtime_1.jsxs)(helperComponents_1.FieldContainerPrivate, {
|
|
130
131
|
className: styles_module_scss_1.default.container,
|
|
131
132
|
size: size,
|
|
132
133
|
validationState: fieldValidationState,
|
|
133
134
|
disabled: disabled,
|
|
134
135
|
readonly: readonly,
|
|
135
136
|
"data-resizable": isResizable || undefined,
|
|
137
|
+
"data-actions": Boolean(footer) || undefined,
|
|
136
138
|
variant: constants_1.CONTAINER_VARIANT.MultiLine,
|
|
137
139
|
style: {
|
|
138
140
|
'--max-rows': maxRows,
|
|
@@ -143,7 +145,7 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
143
145
|
className: styles_module_scss_1.default.postfix,
|
|
144
146
|
children: postfixButtons
|
|
145
147
|
}),
|
|
146
|
-
children: (0, jsx_runtime_1.jsx)(scroll_1.Scroll, {
|
|
148
|
+
children: [(0, jsx_runtime_1.jsx)(scroll_1.Scroll, {
|
|
147
149
|
className: styles_module_scss_1.default.scrollContainer,
|
|
148
150
|
size: 's',
|
|
149
151
|
barHideStrategy: 'never',
|
|
@@ -168,7 +170,7 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
168
170
|
maxLength: allowMoreThanMaxLength ? undefined : maxLength || undefined,
|
|
169
171
|
"data-test-id": 'field-textarea__input'
|
|
170
172
|
})
|
|
171
|
-
})
|
|
173
|
+
}), footer]
|
|
172
174
|
})
|
|
173
175
|
}));
|
|
174
176
|
});
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
--max-rows:1000;
|
|
3
3
|
--min-rows:3;
|
|
4
4
|
}
|
|
5
|
+
.container[data-actions]{
|
|
6
|
+
display:flex;
|
|
7
|
+
flex-direction:column;
|
|
8
|
+
}
|
|
5
9
|
.container .scrollContainer{
|
|
6
10
|
min-height:calc(var(--min-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
|
7
11
|
max-height:calc(var(--max-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
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';
|
|
@@ -24,6 +24,8 @@ type FieldTextAreaOwnProps = {
|
|
|
24
24
|
showClearButton?: boolean;
|
|
25
25
|
/** Можно ли вводить больше разрешённого кол-ва символов */
|
|
26
26
|
allowMoreThanMaxLength?: boolean;
|
|
27
|
+
/** Нода под футер */
|
|
28
|
+
footer?: ReactNode;
|
|
27
29
|
};
|
|
28
30
|
export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
|
|
29
31
|
export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import mergeRefs from 'merge-refs';
|
|
14
14
|
import { forwardRef, useMemo, useRef } from 'react';
|
|
15
15
|
import { SIZE, useButtonNavigation, useClearButton } from '@snack-uikit/input-private';
|
|
@@ -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 } = _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"]);
|
|
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"]);
|
|
26
26
|
const localRef = useRef(null);
|
|
27
27
|
const clearButtonRef = useRef(null);
|
|
28
28
|
const copyButtonRef = useRef(null);
|
|
@@ -56,5 +56,5 @@ 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:
|
|
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] }) })));
|
|
60
60
|
});
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
--max-rows:1000;
|
|
3
3
|
--min-rows:3;
|
|
4
4
|
}
|
|
5
|
+
.container[data-actions]{
|
|
6
|
+
display:flex;
|
|
7
|
+
flex-direction:column;
|
|
8
|
+
}
|
|
5
9
|
.container .scrollContainer{
|
|
6
10
|
min-height:calc(var(--min-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
|
7
11
|
max-height:calc(var(--max-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.43.0",
|
|
7
|
+
"version": "0.43.1-preview-ff425617.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": "
|
|
68
|
+
"gitHead": "626b2eb4a6cd83c5576c7c21de21ec1b5ab8bcca"
|
|
69
69
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mergeRefs from 'merge-refs';
|
|
2
|
-
import { ChangeEvent, forwardRef, useMemo, useRef } from 'react';
|
|
2
|
+
import { ChangeEvent, forwardRef, 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';
|
|
@@ -50,6 +50,8 @@ type FieldTextAreaOwnProps = {
|
|
|
50
50
|
showClearButton?: boolean;
|
|
51
51
|
/** Можно ли вводить больше разрешённого кол-ва символов */
|
|
52
52
|
allowMoreThanMaxLength?: boolean;
|
|
53
|
+
/** Нода под футер */
|
|
54
|
+
footer?: ReactNode;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
|
|
@@ -85,6 +87,7 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
|
|
|
85
87
|
size = SIZE.S,
|
|
86
88
|
validationState = VALIDATION_STATE.Default,
|
|
87
89
|
onCopyButtonClick,
|
|
90
|
+
footer,
|
|
88
91
|
...rest
|
|
89
92
|
},
|
|
90
93
|
ref,
|
|
@@ -156,6 +159,7 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
|
|
|
156
159
|
disabled={disabled}
|
|
157
160
|
readonly={readonly}
|
|
158
161
|
data-resizable={isResizable || undefined}
|
|
162
|
+
data-actions={Boolean(footer) || undefined}
|
|
159
163
|
variant={CONTAINER_VARIANT.MultiLine}
|
|
160
164
|
style={{ '--max-rows': maxRows, '--min-rows': minRows }}
|
|
161
165
|
inputRef={localRef}
|
|
@@ -188,6 +192,7 @@ export const FieldTextArea = forwardRef<HTMLTextAreaElement, FieldTextAreaProps>
|
|
|
188
192
|
data-test-id='field-textarea__input'
|
|
189
193
|
/>
|
|
190
194
|
</Scroll>
|
|
195
|
+
{footer}
|
|
191
196
|
</FieldContainerPrivate>
|
|
192
197
|
</FieldDecorator>
|
|
193
198
|
);
|
|
@@ -8,7 +8,7 @@ $padding-right: (
|
|
|
8
8
|
);
|
|
9
9
|
$scroll-bar-heights: (
|
|
10
10
|
's': styles-tokens-fields.$dimension-050m,
|
|
11
|
-
'm': calc(styles-tokens-fields.$dimension-025m + styles-tokens-fields.$dimension-050m),
|
|
11
|
+
'm': calc(#{styles-tokens-fields.$dimension-025m} + #{styles-tokens-fields.$dimension-050m}),
|
|
12
12
|
'l': styles-tokens-fields.$dimension-1m,
|
|
13
13
|
);
|
|
14
14
|
$padding-right: (
|
|
@@ -18,7 +18,7 @@ $padding-right: (
|
|
|
18
18
|
);
|
|
19
19
|
$scroll-bar-heights: (
|
|
20
20
|
's': styles-tokens-fields.$dimension-050m,
|
|
21
|
-
'm': calc(styles-tokens-fields.$dimension-025m + styles-tokens-fields.$dimension-050m),
|
|
21
|
+
'm': calc(#{styles-tokens-fields.$dimension-025m} + #{styles-tokens-fields.$dimension-050m}),
|
|
22
22
|
'l': styles-tokens-fields.$dimension-1m,
|
|
23
23
|
);
|
|
24
24
|
|
|
@@ -26,6 +26,11 @@ $scroll-bar-heights: (
|
|
|
26
26
|
--max-rows: 1000;
|
|
27
27
|
--min-rows: 3;
|
|
28
28
|
|
|
29
|
+
&[data-actions] {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
.scrollContainer {
|
|
30
35
|
min-height: calc(var(--min-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
|
31
36
|
max-height: calc(var(--max-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
|
|
@@ -53,4 +58,3 @@ $scroll-bar-heights: (
|
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
|
-
|