@koslibs/components 1.5.0 → 1.7.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 +31 -0
- package/README.md +85 -0
- package/dist/components/Button/button.js +20 -4
- package/dist/components/Button/index_module.css +1 -27
- package/dist/components/Collapse/collapse.js +3 -1
- package/dist/components/Collapse/index_module.css +2 -4
- package/dist/components/Input/index_module.css +9 -20
- package/dist/components/Input/input.d.ts +1 -1
- package/dist/components/Input/vars.css +7 -7
- package/dist/components/Modal/components/footer/index_module.css +1 -1
- package/dist/components/Modal/components/header/index.d.ts +1 -1
- package/dist/components/Modal/components/header/index_module.css +3 -3
- package/dist/components/Modal/index_module.css +2 -2
- package/dist/components/Popover/components/popover-surface/index.js +1 -1
- package/dist/components/Popover/{use-popover-position.d.ts → hooks/use-popover-position.d.ts} +1 -1
- package/dist/components/Spinner/preset_module.css +3 -1
- package/dist/components/Tabs/context.d.ts +10 -0
- package/dist/components/Tabs/context.js +3 -0
- package/dist/components/Tabs/hooks/use-tab-indicator.d.ts +11 -0
- package/dist/components/Tabs/hooks/use-tab-indicator.js +43 -0
- package/dist/components/Tabs/index.d.ts +3 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tabs/index.module.js +12 -0
- package/dist/components/Tabs/index_module.css +92 -0
- package/dist/components/Tabs/tab.d.ts +9 -0
- package/dist/components/Tabs/tab.js +38 -0
- package/dist/components/Tabs/tabs.d.ts +13 -0
- package/dist/components/Tabs/tabs.js +116 -0
- package/dist/components/Tabs/types.d.ts +61 -0
- package/dist/components/Tabs/types.js +0 -0
- package/dist/components/Tabs/vars.css +20 -0
- package/dist/components/Textarea/hooks/use-autosize.d.ts +2 -0
- package/dist/components/Textarea/hooks/use-autosize.js +106 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Textarea/index.js +1 -0
- package/dist/components/Textarea/index.module.js +14 -0
- package/dist/components/Textarea/index_module.css +269 -0
- package/dist/components/Textarea/textarea.d.ts +27 -0
- package/dist/components/Textarea/textarea.js +173 -0
- package/dist/components/Textarea/types.d.ts +108 -0
- package/dist/components/Textarea/types.js +0 -0
- package/dist/components/Textarea/vars.css +9 -0
- package/dist/components/Typography/index.d.ts +1 -1
- package/dist/components/Typography/index_module.css +2 -2
- package/dist/components/Typography/preset.module.js +2 -0
- package/dist/components/Typography/preset_module.css +4 -0
- package/dist/components/Typography/shared.d.ts +1 -1
- package/dist/components/Typography/text.d.ts +1 -1
- package/dist/components/Typography/vars.css +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/styles/theme.css +1 -0
- package/dist/styles/variables.css +63 -0
- package/package.json +2 -1
- /package/dist/components/Popover/{use-popover-position.js → hooks/use-popover-position.js} +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
@import "../../styles/theme.css";
|
|
2
|
+
@import "./vars.css";
|
|
3
|
+
|
|
4
|
+
.component-K9LhZN {
|
|
5
|
+
--field-background: var(--input-primary-background-color);
|
|
6
|
+
--field-border: var(--input-border-color);
|
|
7
|
+
--field-color: var(--input-color);
|
|
8
|
+
--field-label-color: var(--input-label-color);
|
|
9
|
+
--field-placeholder-color: var(--input-placeholder-color);
|
|
10
|
+
--field-icon-color: var(--input-icon-color);
|
|
11
|
+
gap: var(--input-gap);
|
|
12
|
+
width: var(--textarea-width);
|
|
13
|
+
vertical-align: top;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
max-width: 100%;
|
|
16
|
+
font-family: var(--font-primary);
|
|
17
|
+
color: var(--field-color);
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
|
|
21
|
+
&[data-block] {
|
|
22
|
+
width: 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&[data-view="secondary"] {
|
|
27
|
+
--field-background: var(--input-secondary-background-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[data-read-only] {
|
|
31
|
+
--field-border: var(--input-read-only-border-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&[data-error] {
|
|
35
|
+
--field-border: var(--input-error-border-color);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&[data-disabled] {
|
|
39
|
+
--field-background: var(--input-disabled-background-color);
|
|
40
|
+
--field-border: transparent;
|
|
41
|
+
--field-color: var(--input-disabled-color);
|
|
42
|
+
--field-label-color: var(--input-disabled-color);
|
|
43
|
+
--field-placeholder-color: var(--input-disabled-color);
|
|
44
|
+
--field-icon-color: var(--input-disabled-color);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.field-GADSqb {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
align-items: flex-start;
|
|
51
|
+
gap: var(--input-gap);
|
|
52
|
+
width: 100%;
|
|
53
|
+
padding: var(--textarea-padding);
|
|
54
|
+
border-radius: var(--input-border-radius);
|
|
55
|
+
background: var(--field-background);
|
|
56
|
+
box-shadow: inset 0 0 0 1px var(--field-border);
|
|
57
|
+
cursor: text;
|
|
58
|
+
display: flex;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@media (hover: hover) {
|
|
62
|
+
.component-K9LhZN:not([data-disabled], [data-read-only], [data-error]) .field-GADSqb:hover {
|
|
63
|
+
box-shadow: inset 0 0 0 1px var(--input-hover-border-color);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.component-K9LhZN:not([data-disabled]) .field-GADSqb:focus-within {
|
|
68
|
+
box-shadow: none;
|
|
69
|
+
outline: 2px solid var(--input-focus-border-color);
|
|
70
|
+
outline-offset: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.component-K9LhZN[data-error]:not([data-disabled]) .field-GADSqb:focus-within {
|
|
74
|
+
outline-color: var(--input-error-border-color);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.component-K9LhZN[data-disabled] .field-GADSqb, .textarea-vCe_J9:disabled {
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.value-pi9twE {
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
flex: 1;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
display: flex;
|
|
86
|
+
position: relative;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.header-AqxZRm {
|
|
90
|
+
align-items: baseline;
|
|
91
|
+
gap: var(--input-gap);
|
|
92
|
+
min-width: 0;
|
|
93
|
+
display: flex;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.innerHeader-N47qW7 {
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: 15px;
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.component-K9LhZN .counter-XxZoUu {
|
|
105
|
+
color: var(--field-label-color);
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
text-align: right;
|
|
108
|
+
font-variant-numeric: tabular-nums;
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
margin-left: auto;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.label-fhdpHS {
|
|
114
|
+
min-width: 0;
|
|
115
|
+
color: var(--field-label-color);
|
|
116
|
+
overflow-wrap: anywhere;
|
|
117
|
+
cursor: inherit;
|
|
118
|
+
flex: 1;
|
|
119
|
+
font-size: 13px;
|
|
120
|
+
display: block;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.component-K9LhZN[data-inner-label] .label-fhdpHS {
|
|
124
|
+
white-space: nowrap;
|
|
125
|
+
text-overflow: ellipsis;
|
|
126
|
+
font-size: var(--textarea-font-size);
|
|
127
|
+
transition: transform .18s, font-size .18s;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
transform: translateY(7.5px);
|
|
130
|
+
|
|
131
|
+
& > span {
|
|
132
|
+
font-size: inherit;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.component-K9LhZN[data-inner-label][data-filled] .label-fhdpHS, .component-K9LhZN[data-inner-label]:not([data-disabled], [data-read-only]) .value-pi9twE:focus-within .label-fhdpHS {
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
transform: translateY(0);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.component-K9LhZN[data-inner-label] .value-pi9twE:has(.textarea-vCe_J9:autofill) .label-fhdpHS {
|
|
142
|
+
font-size: 12px;
|
|
143
|
+
transform: translateY(0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.component-K9LhZN[data-inner-header] .textarea-vCe_J9 {
|
|
147
|
+
margin-top: calc(var(--size-30) / 2);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.component-K9LhZN[data-inner-label] .textarea-vCe_J9::placeholder {
|
|
151
|
+
opacity: 0;
|
|
152
|
+
transition: opacity .18s;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.component-K9LhZN[data-inner-label]:not([data-disabled], [data-read-only]) .textarea-vCe_J9:focus::placeholder {
|
|
156
|
+
opacity: 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.textarea-vCe_J9 {
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
width: 100%;
|
|
162
|
+
min-width: 0;
|
|
163
|
+
height: calc(var(--textarea-rows) * var(--textarea-line-height));
|
|
164
|
+
min-height: calc(var(--textarea-rows) * var(--textarea-line-height));
|
|
165
|
+
margin: var(--size-0);
|
|
166
|
+
padding: var(--size-0);
|
|
167
|
+
border-radius: var(--border-radius-0);
|
|
168
|
+
color: var(--field-color);
|
|
169
|
+
font-family: var(--font-primary);
|
|
170
|
+
font-size: var(--textarea-font-size);
|
|
171
|
+
font-weight: 400;
|
|
172
|
+
line-height: var(--textarea-line-height);
|
|
173
|
+
overflow-wrap: break-word;
|
|
174
|
+
resize: none;
|
|
175
|
+
appearance: none;
|
|
176
|
+
scrollbar-color: auto;
|
|
177
|
+
scrollbar-width: auto;
|
|
178
|
+
background: none;
|
|
179
|
+
border: 0;
|
|
180
|
+
outline: none;
|
|
181
|
+
display: block;
|
|
182
|
+
overflow: auto;
|
|
183
|
+
|
|
184
|
+
&::-webkit-scrollbar {
|
|
185
|
+
background: none;
|
|
186
|
+
width: 6px;
|
|
187
|
+
height: 6px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&::-webkit-scrollbar-button {
|
|
191
|
+
width: 0;
|
|
192
|
+
height: 0;
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&::-webkit-scrollbar-track {
|
|
197
|
+
background: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&::-webkit-scrollbar-track-piece {
|
|
201
|
+
background: none;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&::-webkit-scrollbar-corner {
|
|
205
|
+
background: none;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
&::-webkit-scrollbar-thumb {
|
|
209
|
+
border-radius: var(--border-radius-pill);
|
|
210
|
+
background: var(--field-icon-color);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&::placeholder {
|
|
214
|
+
color: var(--field-placeholder-color);
|
|
215
|
+
opacity: 1;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&:disabled {
|
|
219
|
+
opacity: 1;
|
|
220
|
+
-webkit-text-fill-color: var(--field-color);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
225
|
+
.textarea-vCe_J9 {
|
|
226
|
+
scrollbar-width: thin;
|
|
227
|
+
scrollbar-color: var(--field-icon-color) transparent;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.component-K9LhZN[data-resize] .textarea-vCe_J9 {
|
|
232
|
+
resize: vertical;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.component-K9LhZN .clear-BZMCFP {
|
|
236
|
+
width: 24px;
|
|
237
|
+
min-width: 0;
|
|
238
|
+
height: 24px;
|
|
239
|
+
min-height: 0;
|
|
240
|
+
margin: var(--size-0) var(--size-4-neg);
|
|
241
|
+
padding: var(--size-0);
|
|
242
|
+
color: var(--field-icon-color);
|
|
243
|
+
background: none;
|
|
244
|
+
flex: 0 0 24px;
|
|
245
|
+
|
|
246
|
+
&:hover, &:active {
|
|
247
|
+
color: var(--field-icon-color);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
& svg {
|
|
251
|
+
width: var(--input-icon-size);
|
|
252
|
+
height: var(--input-icon-size);
|
|
253
|
+
display: block;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.component-K9LhZN .message-_mT8Ov {
|
|
258
|
+
color: var(--input-hint-color);
|
|
259
|
+
overflow-wrap: anywhere;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.component-K9LhZN[data-error] .message-_mT8Ov {
|
|
263
|
+
color: var(--input-error-message-color);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.component-K9LhZN[data-disabled] .message-_mT8Ov {
|
|
267
|
+
color: var(--input-disabled-color);
|
|
268
|
+
}
|
|
269
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ChangeEvent, type MouseEvent } from 'react';
|
|
2
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, "children" | "defaultValue" | "onChange" | "value" | "maxLength" | "rows"> & {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
maxLength?: number;
|
|
6
|
+
showValueLength?: boolean;
|
|
7
|
+
view?: "primary" | "secondary";
|
|
8
|
+
block?: boolean;
|
|
9
|
+
label?: import("react").ReactNode;
|
|
10
|
+
labelView?: "outer" | "inner";
|
|
11
|
+
hint?: import("react").ReactNode;
|
|
12
|
+
error?: import("react").ReactNode | boolean;
|
|
13
|
+
minRows?: number;
|
|
14
|
+
maxRows?: number;
|
|
15
|
+
autosize?: boolean;
|
|
16
|
+
resize?: boolean;
|
|
17
|
+
clear?: boolean;
|
|
18
|
+
onChange?: (event: ChangeEvent<HTMLTextAreaElement>, payload: {
|
|
19
|
+
value: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
onClear?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
22
|
+
fieldClassName?: string;
|
|
23
|
+
textareaClassName?: string;
|
|
24
|
+
labelClassName?: string;
|
|
25
|
+
messageClassName?: string;
|
|
26
|
+
dataTestId?: string;
|
|
27
|
+
} & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CrossHeavyMIcon } from "@koslibs/icons/CrossHeavyMIcon";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
|
|
5
|
+
import { useDataTestId } from "../../hooks/use-data-test-id.js";
|
|
6
|
+
import { Button } from "../Button/index.js";
|
|
7
|
+
import { TypographyText } from "../Typography/text.js";
|
|
8
|
+
import { useAutosize } from "./hooks/use-autosize.js";
|
|
9
|
+
import index_module from "./index.module.js";
|
|
10
|
+
const Textarea = /*#__PURE__*/ forwardRef(({ view = 'primary', block = false, label, labelView = 'outer', hint, error, minRows = 3, maxRows, autosize = false, resize = false, clear = false, value, defaultValue, maxLength, showValueLength = false, onChange, onClear, disabled = false, readOnly = false, id, className, style, fieldClassName, textareaClassName, labelClassName, messageClassName, dataTestId, ...restProps }, ref)=>{
|
|
11
|
+
const generatedId = useId();
|
|
12
|
+
const textareaId = id ?? generatedId;
|
|
13
|
+
const textareaRef = useRef(null);
|
|
14
|
+
const [uncontrolledLength, setUncontrolledLength] = useState(defaultValue?.length ?? 0);
|
|
15
|
+
const controlled = void 0 !== value;
|
|
16
|
+
const valueLength = controlled ? value.length : uncontrolledLength;
|
|
17
|
+
const hasValue = valueLength > 0;
|
|
18
|
+
const showCounter = showValueLength && void 0 !== maxLength && Number.isInteger(maxLength) && maxLength >= 0;
|
|
19
|
+
const hasLabel = null != label && false !== label && '' !== label;
|
|
20
|
+
const errorMessage = hint && 'boolean' != typeof error ? error : void 0;
|
|
21
|
+
const message = errorMessage || hint;
|
|
22
|
+
const showClear = clear && hasValue && !disabled && !readOnly;
|
|
23
|
+
const rows = Number.isFinite(minRows) ? Math.max(1, Math.floor(minRows)) : 3;
|
|
24
|
+
const limit = void 0 !== maxRows && Number.isFinite(maxRows) ? Math.max(rows, Math.floor(maxRows)) : void 0;
|
|
25
|
+
const getDataTestId = useDataTestId(dataTestId);
|
|
26
|
+
useImperativeHandle(ref, ()=>textareaRef.current, []);
|
|
27
|
+
useAutosize(textareaRef, autosize, rows, limit, restProps.form);
|
|
28
|
+
useEffect(()=>{
|
|
29
|
+
const textarea = textareaRef.current;
|
|
30
|
+
const form = textarea?.form;
|
|
31
|
+
let active = true;
|
|
32
|
+
const handleReset = (event)=>{
|
|
33
|
+
setTimeout(()=>{
|
|
34
|
+
if (active && !event.defaultPrevented) setUncontrolledLength(textarea?.value.length ?? 0);
|
|
35
|
+
}, 0);
|
|
36
|
+
};
|
|
37
|
+
form?.addEventListener('reset', handleReset);
|
|
38
|
+
return ()=>{
|
|
39
|
+
active = false;
|
|
40
|
+
form?.removeEventListener('reset', handleReset);
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
restProps.form
|
|
44
|
+
]);
|
|
45
|
+
const handleChange = (event)=>{
|
|
46
|
+
const nextValue = event.target.value;
|
|
47
|
+
if (!controlled) setUncontrolledLength(nextValue.length);
|
|
48
|
+
onChange?.(event, {
|
|
49
|
+
value: nextValue
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const handleClear = (event)=>{
|
|
53
|
+
const textarea = textareaRef.current;
|
|
54
|
+
if (!textarea || !showClear) return;
|
|
55
|
+
if (!controlled) {
|
|
56
|
+
textarea.value = '';
|
|
57
|
+
setUncontrolledLength(0);
|
|
58
|
+
}
|
|
59
|
+
onClear?.(event);
|
|
60
|
+
textarea.focus();
|
|
61
|
+
};
|
|
62
|
+
const handleFieldClick = (event)=>{
|
|
63
|
+
if (disabled || event.defaultPrevented || !(event.target instanceof Element)) return;
|
|
64
|
+
const target = event.target.closest('textarea, button, a, label, input, select, [contenteditable], [tabindex]');
|
|
65
|
+
if (target && event.currentTarget.contains(target)) return;
|
|
66
|
+
textareaRef.current?.focus();
|
|
67
|
+
};
|
|
68
|
+
const labelElement = hasLabel && /*#__PURE__*/ jsx("label", {
|
|
69
|
+
htmlFor: textareaId,
|
|
70
|
+
className: classnames(index_module.label, labelClassName),
|
|
71
|
+
"data-test-id": getDataTestId('label'),
|
|
72
|
+
children: /*#__PURE__*/ jsx(TypographyText, {
|
|
73
|
+
size: 'inner' === labelView ? 12 : 13,
|
|
74
|
+
weight: 'inner' === labelView ? 'regular' : 'medium',
|
|
75
|
+
children: label
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
const counterElement = showCounter && /*#__PURE__*/ jsxs(TypographyText, {
|
|
79
|
+
size: 11,
|
|
80
|
+
className: index_module.counter,
|
|
81
|
+
style: {
|
|
82
|
+
minWidth: `${2 * String(maxLength).length + 1}ch`
|
|
83
|
+
},
|
|
84
|
+
dataTestId: getDataTestId('counter'),
|
|
85
|
+
children: [
|
|
86
|
+
valueLength,
|
|
87
|
+
"/",
|
|
88
|
+
maxLength
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
92
|
+
className: classnames(index_module.component, className),
|
|
93
|
+
style: {
|
|
94
|
+
'--textarea-rows': rows,
|
|
95
|
+
...style
|
|
96
|
+
},
|
|
97
|
+
"data-view": view,
|
|
98
|
+
"data-block": block || void 0,
|
|
99
|
+
"data-disabled": disabled || void 0,
|
|
100
|
+
"data-read-only": readOnly || void 0,
|
|
101
|
+
"data-error": Boolean(error) || void 0,
|
|
102
|
+
"data-label-view": labelView,
|
|
103
|
+
"data-inner-label": 'inner' === labelView && hasLabel || void 0,
|
|
104
|
+
"data-inner-header": 'inner' === labelView && (hasLabel || showCounter) || void 0,
|
|
105
|
+
"data-filled": hasValue || void 0,
|
|
106
|
+
"data-resize": resize && !autosize && !disabled && !readOnly || void 0,
|
|
107
|
+
"data-test-id": getDataTestId('form-control'),
|
|
108
|
+
children: [
|
|
109
|
+
'outer' === labelView && (hasLabel || showCounter) && /*#__PURE__*/ jsxs("div", {
|
|
110
|
+
className: index_module.header,
|
|
111
|
+
children: [
|
|
112
|
+
labelElement,
|
|
113
|
+
counterElement
|
|
114
|
+
]
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsxs("div", {
|
|
117
|
+
className: classnames(index_module.field, fieldClassName),
|
|
118
|
+
onClick: handleFieldClick,
|
|
119
|
+
"data-test-id": getDataTestId('field'),
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ jsxs("div", {
|
|
122
|
+
className: index_module.value,
|
|
123
|
+
children: [
|
|
124
|
+
'inner' === labelView && (hasLabel || showCounter) && /*#__PURE__*/ jsxs("div", {
|
|
125
|
+
className: classnames(index_module.header, index_module.innerHeader),
|
|
126
|
+
children: [
|
|
127
|
+
labelElement,
|
|
128
|
+
counterElement
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
/*#__PURE__*/ jsx("textarea", {
|
|
132
|
+
...restProps,
|
|
133
|
+
ref: textareaRef,
|
|
134
|
+
id: textareaId,
|
|
135
|
+
value: value,
|
|
136
|
+
defaultValue: defaultValue,
|
|
137
|
+
rows: rows,
|
|
138
|
+
maxLength: maxLength,
|
|
139
|
+
disabled: disabled,
|
|
140
|
+
readOnly: readOnly,
|
|
141
|
+
onChange: handleChange,
|
|
142
|
+
className: classnames(index_module.textarea, textareaClassName),
|
|
143
|
+
"data-test-id": dataTestId
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}),
|
|
147
|
+
showClear && /*#__PURE__*/ jsx(Button, {
|
|
148
|
+
view: "text",
|
|
149
|
+
size: 32,
|
|
150
|
+
className: index_module.clear,
|
|
151
|
+
title: "Очистить поле",
|
|
152
|
+
onMouseDown: (event)=>event.preventDefault(),
|
|
153
|
+
onClick: handleClear,
|
|
154
|
+
dataTestId: getDataTestId('clear'),
|
|
155
|
+
children: /*#__PURE__*/ jsx(CrossHeavyMIcon, {
|
|
156
|
+
width: 16,
|
|
157
|
+
height: 16
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
Boolean(message) && /*#__PURE__*/ jsx(TypographyText, {
|
|
163
|
+
tag: "div",
|
|
164
|
+
size: 12,
|
|
165
|
+
className: classnames(index_module.message, messageClassName),
|
|
166
|
+
dataTestId: getDataTestId(errorMessage ? 'error' : 'hint'),
|
|
167
|
+
children: message
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
Textarea.displayName = 'Textarea';
|
|
173
|
+
export { Textarea };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ChangeEvent, MouseEvent, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'maxLength' | 'onChange' | 'children' | 'rows'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Значение управляемого поля.
|
|
5
|
+
*/
|
|
6
|
+
value?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Начальное значение неуправляемого поля.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Максимальная длина нативного ввода в кодовых единицах UTF-16.
|
|
13
|
+
*/
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Показывает текущую длину и maxLength рядом с label.
|
|
17
|
+
* Работает только при заданном неотрицательном целом maxLength.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
showValueLength?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Вид поля: белый primary или светлый secondary.
|
|
23
|
+
* @default 'primary'
|
|
24
|
+
*/
|
|
25
|
+
view?: 'primary' | 'secondary';
|
|
26
|
+
/**
|
|
27
|
+
* Растягивает компонент на ширину контейнера.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
block?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Название поля. Клик переводит фокус в textarea.
|
|
33
|
+
*/
|
|
34
|
+
label?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Положение label. Внутренний label поднимается при фокусе или заполнении.
|
|
37
|
+
* @default 'outer'
|
|
38
|
+
*/
|
|
39
|
+
labelView?: 'outer' | 'inner';
|
|
40
|
+
/**
|
|
41
|
+
* Подсказка под полем. Сообщение об ошибке заменяет её.
|
|
42
|
+
*/
|
|
43
|
+
hint?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Сообщение об ошибке или true для состояния ошибки без сообщения.
|
|
46
|
+
* Без непустого hint отображается только рамка. true сохраняет hint.
|
|
47
|
+
*/
|
|
48
|
+
error?: ReactNode | boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Начальное число видимых строк; при autosize — минимальное число строк.
|
|
51
|
+
* Должно быть положительным целым числом.
|
|
52
|
+
* @default 3
|
|
53
|
+
*/
|
|
54
|
+
minRows?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Максимальное число видимых строк при autosize. Затем текст прокручивается.
|
|
57
|
+
* Значение меньше minRows ограничивается minRows.
|
|
58
|
+
*/
|
|
59
|
+
maxRows?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Подстраивает высоту под содержимое, включая переносы по ширине.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
autosize?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Разрешает менять высоту вручную за нижний правый угол.
|
|
67
|
+
* Не работает вместе с autosize, в disabled и readOnly. Ширина сохраняется.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
resize?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Показывает кнопку очистки заполненного редактируемого поля.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
clear?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Обработчик ввода с нативным событием React и текущим значением.
|
|
78
|
+
*/
|
|
79
|
+
onChange?: (event: ChangeEvent<HTMLTextAreaElement>, payload: {
|
|
80
|
+
value: string;
|
|
81
|
+
}) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Обработчик очистки. Не вызывает onChange.
|
|
84
|
+
* В управляемом режиме обновите value в этом обработчике.
|
|
85
|
+
*/
|
|
86
|
+
onClear?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Класс визуального поля.
|
|
89
|
+
*/
|
|
90
|
+
fieldClassName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Класс нативного textarea. className и style относятся к обёртке.
|
|
93
|
+
*/
|
|
94
|
+
textareaClassName?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Класс label.
|
|
97
|
+
*/
|
|
98
|
+
labelClassName?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Класс подсказки или сообщения об ошибке.
|
|
101
|
+
*/
|
|
102
|
+
messageClassName?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Идентификатор нативного textarea. Части получают суффиксы -form-control,
|
|
105
|
+
* -field, -label, -hint, -error, -clear и -counter.
|
|
106
|
+
*/
|
|
107
|
+
dataTestId?: string;
|
|
108
|
+
};
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ export declare const Typography: {
|
|
|
14
14
|
rowLimit?: 1 | 2 | 3;
|
|
15
15
|
dataTestId?: string;
|
|
16
16
|
} & {
|
|
17
|
-
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
17
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 20;
|
|
18
18
|
tag?: "span" | "p" | "div" | "li";
|
|
19
19
|
} & import("react").RefAttributes<import("./shared.js").TextElement>>;
|
|
20
20
|
Title: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "className" | "style" | "color" | "children"> & {
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
margin: var(--size-0, 0px);
|
|
6
6
|
padding: var(--size-0, 0px);
|
|
7
7
|
font-family: var(--font-primary);
|
|
8
|
-
font-style: normal;
|
|
9
|
-
line-height: var(--typography-line-height);
|
|
10
8
|
letter-spacing: var(--typography-letter-spacing);
|
|
9
|
+
font-style: normal;
|
|
10
|
+
line-height: normal;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.weight-regular-cOlAcy {
|
|
@@ -18,6 +18,8 @@ const preset_module = {
|
|
|
18
18
|
size15: "size-15-DxWyW2",
|
|
19
19
|
"size-16": "size-16-OgafBi",
|
|
20
20
|
size16: "size-16-OgafBi",
|
|
21
|
+
"size-18": "size-18-MSiKUJ",
|
|
22
|
+
size18: "size-18-MSiKUJ",
|
|
21
23
|
"size-20": "size-20-eTO0D7",
|
|
22
24
|
size20: "size-20-eTO0D7",
|
|
23
25
|
"size-24": "size-24-lZpjdx",
|
|
@@ -44,7 +44,7 @@ export type TextProps = BaseProps & {
|
|
|
44
44
|
* Размер шрифта в пикселях.
|
|
45
45
|
* @default 13
|
|
46
46
|
*/
|
|
47
|
-
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
47
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 20;
|
|
48
48
|
/**
|
|
49
49
|
* HTML-тег, определяющий семантику текста.
|
|
50
50
|
* @default span
|
|
@@ -10,6 +10,6 @@ export declare const TypographyText: import("react").ForwardRefExoticComponent<O
|
|
|
10
10
|
rowLimit?: 1 | 2 | 3;
|
|
11
11
|
dataTestId?: string;
|
|
12
12
|
} & {
|
|
13
|
-
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
13
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 20;
|
|
14
14
|
tag?: "span" | "p" | "div" | "li";
|
|
15
15
|
} & import("react").RefAttributes<TextElement>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
:root {
|
|
2
|
-
--typography-line-height: normal;
|
|
3
2
|
--typography-letter-spacing: 0;
|
|
4
3
|
--typography-regular-font-weight: 400;
|
|
5
4
|
--typography-medium-font-weight: 500;
|
|
@@ -19,6 +18,7 @@
|
|
|
19
18
|
--typography-font-size-14: 14px;
|
|
20
19
|
--typography-font-size-15: 15px;
|
|
21
20
|
--typography-font-size-16: 16px;
|
|
21
|
+
--typography-font-size-18: 18px;
|
|
22
22
|
--typography-font-size-20: 20px;
|
|
23
23
|
--typography-font-size-24: 24px;
|
|
24
24
|
--typography-font-size-28: 28px;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { Button } from './components/Button/index.js';
|
|
|
2
2
|
export type { ButtonProps } from './components/Button/index.js';
|
|
3
3
|
export { Input } from './components/Input/index.js';
|
|
4
4
|
export type { InputProps } from './components/Input/index.js';
|
|
5
|
+
export { Textarea } from './components/Textarea/index.js';
|
|
6
|
+
export type { TextareaProps } from './components/Textarea/index.js';
|
|
7
|
+
export { Tab, Tabs } from './components/Tabs/index.js';
|
|
8
|
+
export type { TabProps, TabsProps } from './components/Tabs/index.js';
|
|
5
9
|
export { Spinner } from './components/Spinner/index.js';
|
|
6
10
|
export type { SpinnerProps } from './components/Spinner/index.js';
|
|
7
11
|
export { Typography, TypographyText, TypographyTitle, Text, Title } from './components/Typography/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Button } from "./components/Button/index.js";
|
|
2
2
|
export { Input } from "./components/Input/index.js";
|
|
3
|
+
export { Textarea } from "./components/Textarea/index.js";
|
|
4
|
+
export { Tab, Tabs } from "./components/Tabs/index.js";
|
|
3
5
|
export { Spinner } from "./components/Spinner/index.js";
|
|
4
6
|
export { Text, Title, Typography, TypographyText, TypographyTitle } from "./components/Typography/index.js";
|
|
5
7
|
export { Popover } from "./components/Popover/index.js";
|