@rescui/textarea 0.11.6-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.14 → 0.11.6-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43
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/lib/_virtual/close-outline.js +337 -0
- package/lib/_virtual/index.css.js +12 -12
- package/lib/_virtual/loading-outline.js +310 -79
- package/lib/index.css +177 -98
- package/lib/index.d.ts +2 -0
- package/lib/public-api.p.css +25 -0
- package/lib/public-api.pcss +25 -0
- package/lib/textarea.d.ts +7 -0
- package/lib/textarea.js +336 -69
- package/lib/textarea.p.module.css.js +24 -21
- package/lib/use-safe-id.d.ts +4 -0
- package/lib/use-safe-id.js +10 -0
- package/llm/components/textarea.md +24 -0
- package/package.json +6 -5
- package/lib/use-backward-compatible-id.d.ts +0 -4
- package/lib/use-backward-compatible-id.js +0 -14
package/lib/public-api.p.css
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
@property --_rs-theme-dark-coefficient{
|
|
2
|
+
syntax:'<number>';
|
|
3
|
+
inherits:true;
|
|
4
|
+
initial-value:0;
|
|
5
|
+
}
|
|
1
6
|
@define-mixin rs-textarea-size-s{
|
|
2
7
|
&:not(html){
|
|
3
8
|
--_rs-textarea-vertical-padding:6px;
|
|
4
9
|
--_rs-textarea-horizontal-padding:8px;
|
|
10
|
+
--_rs-textarea-icon-size:20px;
|
|
11
|
+
--_rs-textarea-icon-offset:8px;
|
|
5
12
|
}
|
|
6
13
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
7
14
|
--_rs-icons-height:20px;
|
|
@@ -116,6 +123,8 @@
|
|
|
116
123
|
&:not(html){
|
|
117
124
|
--_rs-textarea-vertical-padding:8px;
|
|
118
125
|
--_rs-textarea-horizontal-padding:8px;
|
|
126
|
+
--_rs-textarea-icon-size:24px;
|
|
127
|
+
--_rs-textarea-icon-offset:8px;
|
|
119
128
|
}
|
|
120
129
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
121
130
|
--_rs-icons-height:24px;
|
|
@@ -249,6 +258,8 @@
|
|
|
249
258
|
&:not(html){
|
|
250
259
|
--_rs-textarea-vertical-padding:12px;
|
|
251
260
|
--_rs-textarea-horizontal-padding:16px;
|
|
261
|
+
--_rs-textarea-icon-size:28px;
|
|
262
|
+
--_rs-textarea-icon-offset:16px;
|
|
252
263
|
}
|
|
253
264
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
254
265
|
--_rs-icons-height:28px;
|
|
@@ -392,6 +403,13 @@
|
|
|
392
403
|
--_rs-textarea-focused-busy-icon-color:rgba(
|
|
393
404
|
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
|
|
394
405
|
0.7
|
|
406
|
+
);
|
|
407
|
+
--_rs-textarea-focused-clear-icon-color:rgba(
|
|
408
|
+
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
|
|
409
|
+
0.7
|
|
410
|
+
);
|
|
411
|
+
--_rs-textarea-focused-clear-icon-accent-color:rgb(
|
|
412
|
+
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227)
|
|
395
413
|
);
|
|
396
414
|
--_rs-textarea-focused-scrollbar-track-color:rgb(
|
|
397
415
|
calc(232 - var(--_rs-theme-dark-coefficient, 0)*184), calc(232 - var(--_rs-theme-dark-coefficient, 0)*184), calc(232 - var(--_rs-theme-dark-coefficient, 0)*181)
|
|
@@ -412,6 +430,13 @@
|
|
|
412
430
|
--_rs-textarea-focused-busy-icon-color:rgba(
|
|
413
431
|
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227),
|
|
414
432
|
0.7
|
|
433
|
+
);
|
|
434
|
+
--_rs-textarea-focused-clear-icon-color:rgba(
|
|
435
|
+
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227),
|
|
436
|
+
0.7
|
|
437
|
+
);
|
|
438
|
+
--_rs-textarea-focused-clear-icon-accent-color:rgb(
|
|
439
|
+
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227)
|
|
415
440
|
);
|
|
416
441
|
--_rs-textarea-focused-scrollbar-track-color:rgb(
|
|
417
442
|
calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(51 + var(--_rs-theme-dark-coefficient, 0)*181)
|
package/lib/public-api.pcss
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
@property --_rs-theme-dark-coefficient{
|
|
2
|
+
syntax:'<number>';
|
|
3
|
+
inherits:true;
|
|
4
|
+
initial-value:0;
|
|
5
|
+
}
|
|
1
6
|
@define-mixin rs-textarea-size-s{
|
|
2
7
|
&:not(html){
|
|
3
8
|
--_rs-textarea-vertical-padding:6px;
|
|
4
9
|
--_rs-textarea-horizontal-padding:8px;
|
|
10
|
+
--_rs-textarea-icon-size:20px;
|
|
11
|
+
--_rs-textarea-icon-offset:8px;
|
|
5
12
|
}
|
|
6
13
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
7
14
|
--_rs-icons-height:20px;
|
|
@@ -116,6 +123,8 @@
|
|
|
116
123
|
&:not(html){
|
|
117
124
|
--_rs-textarea-vertical-padding:8px;
|
|
118
125
|
--_rs-textarea-horizontal-padding:8px;
|
|
126
|
+
--_rs-textarea-icon-size:24px;
|
|
127
|
+
--_rs-textarea-icon-offset:8px;
|
|
119
128
|
}
|
|
120
129
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
121
130
|
--_rs-icons-height:24px;
|
|
@@ -249,6 +258,8 @@
|
|
|
249
258
|
&:not(html){
|
|
250
259
|
--_rs-textarea-vertical-padding:12px;
|
|
251
260
|
--_rs-textarea-horizontal-padding:16px;
|
|
261
|
+
--_rs-textarea-icon-size:28px;
|
|
262
|
+
--_rs-textarea-icon-offset:16px;
|
|
252
263
|
}
|
|
253
264
|
&:not(html) [data-rs-internal='textarea__busy-icon']:not(html){
|
|
254
265
|
--_rs-icons-height:28px;
|
|
@@ -392,6 +403,13 @@
|
|
|
392
403
|
--_rs-textarea-focused-busy-icon-color:rgba(
|
|
393
404
|
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
|
|
394
405
|
0.7
|
|
406
|
+
);
|
|
407
|
+
--_rs-textarea-focused-clear-icon-color:rgba(
|
|
408
|
+
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
|
|
409
|
+
0.7
|
|
410
|
+
);
|
|
411
|
+
--_rs-textarea-focused-clear-icon-accent-color:rgb(
|
|
412
|
+
calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227)
|
|
395
413
|
);
|
|
396
414
|
--_rs-textarea-focused-scrollbar-track-color:rgb(
|
|
397
415
|
calc(232 - var(--_rs-theme-dark-coefficient, 0)*184), calc(232 - var(--_rs-theme-dark-coefficient, 0)*184), calc(232 - var(--_rs-theme-dark-coefficient, 0)*181)
|
|
@@ -412,6 +430,13 @@
|
|
|
412
430
|
--_rs-textarea-focused-busy-icon-color:rgba(
|
|
413
431
|
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227),
|
|
414
432
|
0.7
|
|
433
|
+
);
|
|
434
|
+
--_rs-textarea-focused-clear-icon-color:rgba(
|
|
435
|
+
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227),
|
|
436
|
+
0.7
|
|
437
|
+
);
|
|
438
|
+
--_rs-textarea-focused-clear-icon-accent-color:rgb(
|
|
439
|
+
calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227)
|
|
415
440
|
);
|
|
416
441
|
--_rs-textarea-focused-scrollbar-track-color:rgb(
|
|
417
442
|
calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(51 + var(--_rs-theme-dark-coefficient, 0)*181)
|
package/lib/textarea.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ type TextareaExclusiveProps = {
|
|
|
48
48
|
* `Blur` textarea callback
|
|
49
49
|
*/
|
|
50
50
|
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear textarea callback. The clear button appears when this callback is provided and textarea is not empty.
|
|
53
|
+
*/
|
|
54
|
+
onClear?: React.MouseEventHandler<HTMLButtonElement>;
|
|
51
55
|
/**
|
|
52
56
|
* `mouseEnter` textarea callback
|
|
53
57
|
*/
|
|
@@ -91,6 +95,9 @@ type TextareaExclusiveProps = {
|
|
|
91
95
|
label?: React.ReactNode;
|
|
92
96
|
note?: React.ReactNode;
|
|
93
97
|
textareaRef?: React.Ref<HTMLTextAreaElement>;
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use `onClear` instead.
|
|
100
|
+
*/
|
|
94
101
|
enableClear?: boolean;
|
|
95
102
|
boldLabel?: boolean;
|
|
96
103
|
/**
|
package/lib/textarea.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
3
|
+
import { c } from 'react-compiler-runtime';
|
|
2
4
|
import React, { useState } from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
import TextareaAutosize from 'react-textarea-autosize';
|
|
5
7
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
|
-
import {
|
|
8
|
+
import { ErrorMessage, shouldRenderErrorMessage } from '@rescui/form-field';
|
|
7
9
|
import cn from 'classnames';
|
|
10
|
+
import CloseOutlineIcon from './_virtual/close-outline.js';
|
|
8
11
|
import LoadingOutlineIcon from './_virtual/loading-outline.js';
|
|
9
|
-
import {
|
|
12
|
+
import { useSafeId } from './use-safe-id.js';
|
|
10
13
|
import styles from './textarea.p.module.css.js';
|
|
11
14
|
const SIZE_STYLES = {
|
|
12
15
|
s: styles.sizeS,
|
|
@@ -22,77 +25,340 @@ const MODE_STYLES = {
|
|
|
22
25
|
rock: styles.rock
|
|
23
26
|
};
|
|
24
27
|
const Textarea = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
(t0, ref) => {
|
|
29
|
+
const $ = c(76);
|
|
30
|
+
let busy;
|
|
31
|
+
let characterCounter;
|
|
32
|
+
let className;
|
|
33
|
+
let disabled;
|
|
34
|
+
let error;
|
|
35
|
+
let id;
|
|
36
|
+
let label;
|
|
37
|
+
let note;
|
|
38
|
+
let onChange;
|
|
39
|
+
let onClear;
|
|
40
|
+
let restProps;
|
|
41
|
+
let t1;
|
|
42
|
+
let t2;
|
|
43
|
+
let t3;
|
|
44
|
+
let t4;
|
|
45
|
+
let tabIndex;
|
|
46
|
+
let textareaRef;
|
|
47
|
+
let themeFromProps;
|
|
48
|
+
let value;
|
|
49
|
+
|
|
50
|
+
if ($[0] !== t0) {
|
|
51
|
+
const {
|
|
52
|
+
id: t5,
|
|
53
|
+
className: t6,
|
|
54
|
+
disabled: t7,
|
|
55
|
+
error: t8,
|
|
56
|
+
reserveErrorLine: t9,
|
|
57
|
+
busy: t10,
|
|
58
|
+
onChange: t11,
|
|
59
|
+
onClear: t12,
|
|
60
|
+
enableClear: _enableClear,
|
|
61
|
+
size: t13,
|
|
62
|
+
mode: t14,
|
|
63
|
+
theme: t15,
|
|
64
|
+
textareaRef: t16,
|
|
65
|
+
value: t17,
|
|
66
|
+
tabIndex: t18,
|
|
67
|
+
label: t19,
|
|
68
|
+
boldLabel: t20,
|
|
69
|
+
note: t21,
|
|
70
|
+
characterCounter: t22,
|
|
71
|
+
...t23
|
|
72
|
+
} = t0;
|
|
73
|
+
id = t5;
|
|
74
|
+
className = t6;
|
|
75
|
+
disabled = t7;
|
|
76
|
+
error = t8;
|
|
77
|
+
t1 = t9;
|
|
78
|
+
busy = t10;
|
|
79
|
+
onChange = t11;
|
|
80
|
+
onClear = t12;
|
|
81
|
+
t2 = t13;
|
|
82
|
+
t3 = t14;
|
|
83
|
+
themeFromProps = t15;
|
|
84
|
+
textareaRef = t16;
|
|
85
|
+
value = t17;
|
|
86
|
+
tabIndex = t18;
|
|
87
|
+
label = t19;
|
|
88
|
+
t4 = t20;
|
|
89
|
+
note = t21;
|
|
90
|
+
characterCounter = t22;
|
|
91
|
+
restProps = t23;
|
|
92
|
+
$[0] = t0;
|
|
93
|
+
$[1] = busy;
|
|
94
|
+
$[2] = characterCounter;
|
|
95
|
+
$[3] = className;
|
|
96
|
+
$[4] = disabled;
|
|
97
|
+
$[5] = error;
|
|
98
|
+
$[6] = id;
|
|
99
|
+
$[7] = label;
|
|
100
|
+
$[8] = note;
|
|
101
|
+
$[9] = onChange;
|
|
102
|
+
$[10] = onClear;
|
|
103
|
+
$[11] = restProps;
|
|
104
|
+
$[12] = t1;
|
|
105
|
+
$[13] = t2;
|
|
106
|
+
$[14] = t3;
|
|
107
|
+
$[15] = t4;
|
|
108
|
+
$[16] = tabIndex;
|
|
109
|
+
$[17] = textareaRef;
|
|
110
|
+
$[18] = themeFromProps;
|
|
111
|
+
$[19] = value;
|
|
112
|
+
} else {
|
|
113
|
+
busy = $[1];
|
|
114
|
+
characterCounter = $[2];
|
|
115
|
+
className = $[3];
|
|
116
|
+
disabled = $[4];
|
|
117
|
+
error = $[5];
|
|
118
|
+
id = $[6];
|
|
119
|
+
label = $[7];
|
|
120
|
+
note = $[8];
|
|
121
|
+
onChange = $[9];
|
|
122
|
+
onClear = $[10];
|
|
123
|
+
restProps = $[11];
|
|
124
|
+
t1 = $[12];
|
|
125
|
+
t2 = $[13];
|
|
126
|
+
t3 = $[14];
|
|
127
|
+
t4 = $[15];
|
|
128
|
+
tabIndex = $[16];
|
|
129
|
+
textareaRef = $[17];
|
|
130
|
+
themeFromProps = $[18];
|
|
131
|
+
value = $[19];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const reserveErrorLine = t1 === undefined ? false : t1;
|
|
135
|
+
const size = t2 === undefined ? "m" : t2;
|
|
136
|
+
const mode = t3 === undefined ? "classic" : t3;
|
|
137
|
+
const boldLabel = t4 === undefined ? true : t4;
|
|
46
138
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
47
139
|
const isEmpty = !value;
|
|
140
|
+
const showClearIcon = Boolean(onClear && !isEmpty);
|
|
48
141
|
const [focused, setFocused] = useState(false);
|
|
49
|
-
const uniqueId = `textarea-${
|
|
142
|
+
const uniqueId = `textarea-${useSafeId()}`;
|
|
50
143
|
const errorId = `${id ? id : uniqueId}-error`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
144
|
+
let t5;
|
|
145
|
+
|
|
146
|
+
if ($[20] !== characterCounter || $[21] !== error || $[22] !== note || $[23] !== reserveErrorLine) {
|
|
147
|
+
t5 = Boolean(note) || Boolean(characterCounter) || shouldRenderErrorMessage(error, reserveErrorLine);
|
|
148
|
+
$[20] = characterCounter;
|
|
149
|
+
$[21] = error;
|
|
150
|
+
$[22] = note;
|
|
151
|
+
$[23] = reserveErrorLine;
|
|
152
|
+
$[24] = t5;
|
|
153
|
+
} else {
|
|
154
|
+
t5 = $[24];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const hasFooter = t5;
|
|
158
|
+
const t6 = SIZE_STYLES[size];
|
|
159
|
+
const t7 = MODE_STYLES[mode];
|
|
160
|
+
const t8 = THEME_STYLES[theme];
|
|
161
|
+
const t9 = !!error && styles.error;
|
|
162
|
+
const t10 = disabled ? styles.disabled : styles.enabled;
|
|
163
|
+
const t11 = focused && styles.focused;
|
|
164
|
+
const t12 = boldLabel && styles.boldLabel;
|
|
165
|
+
const t13 = isEmpty ? styles.empty : styles.filled;
|
|
166
|
+
let t14;
|
|
167
|
+
|
|
168
|
+
if ($[25] !== className || $[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t13 || $[30] !== t6 || $[31] !== t7 || $[32] !== t8 || $[33] !== t9) {
|
|
169
|
+
t14 = cn(styles.labelWrapper, t6, t7, t8, t9, t10, t11, t12, t13, className);
|
|
170
|
+
$[25] = className;
|
|
171
|
+
$[26] = t10;
|
|
172
|
+
$[27] = t11;
|
|
173
|
+
$[28] = t12;
|
|
174
|
+
$[29] = t13;
|
|
175
|
+
$[30] = t6;
|
|
176
|
+
$[31] = t7;
|
|
177
|
+
$[32] = t8;
|
|
178
|
+
$[33] = t9;
|
|
179
|
+
$[34] = t14;
|
|
180
|
+
} else {
|
|
181
|
+
t14 = $[34];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let t15;
|
|
185
|
+
|
|
186
|
+
if ($[35] !== boldLabel || $[36] !== label) {
|
|
187
|
+
t15 = label && /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
className: styles.label,
|
|
189
|
+
"data-test": "textarea__label",
|
|
190
|
+
"data-rs-internal": boldLabel ? "textarea__bold-label" : "textarea__label"
|
|
191
|
+
}, label);
|
|
192
|
+
$[35] = boldLabel;
|
|
193
|
+
$[36] = label;
|
|
194
|
+
$[37] = t15;
|
|
195
|
+
} else {
|
|
196
|
+
t15 = $[37];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const t16 = showClearIcon && styles.clearable;
|
|
200
|
+
let t17;
|
|
201
|
+
|
|
202
|
+
if ($[38] !== t16) {
|
|
203
|
+
t17 = cn(styles.wrapper, t16);
|
|
204
|
+
$[38] = t16;
|
|
205
|
+
$[39] = t17;
|
|
206
|
+
} else {
|
|
207
|
+
t17 = $[39];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let t18;
|
|
211
|
+
let t19;
|
|
212
|
+
|
|
213
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
214
|
+
t18 = () => setFocused(true);
|
|
215
|
+
|
|
216
|
+
t19 = () => setFocused(false);
|
|
217
|
+
|
|
218
|
+
$[40] = t18;
|
|
219
|
+
$[41] = t19;
|
|
220
|
+
} else {
|
|
221
|
+
t18 = $[40];
|
|
222
|
+
t19 = $[41];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const t20 = error ? errorId : undefined;
|
|
226
|
+
const t21 = Boolean(error);
|
|
227
|
+
const t22 = disabled ? -1 : tabIndex;
|
|
228
|
+
let t23;
|
|
229
|
+
|
|
230
|
+
if ($[42] !== disabled || $[43] !== focused || $[44] !== onChange || $[45] !== restProps || $[46] !== t20 || $[47] !== t21 || $[48] !== t22 || $[49] !== textareaRef || $[50] !== value) {
|
|
231
|
+
t23 = /*#__PURE__*/React.createElement(TextareaAutosize, _extends({}, restProps, {
|
|
232
|
+
className: styles.inner,
|
|
233
|
+
disabled: disabled,
|
|
234
|
+
value: value,
|
|
235
|
+
onChange: onChange,
|
|
236
|
+
ref: textareaRef,
|
|
237
|
+
"aria-errormessage": t20,
|
|
238
|
+
"aria-invalid": t21,
|
|
239
|
+
tabIndex: t22,
|
|
240
|
+
"data-test": "textarea__input",
|
|
241
|
+
"data-rs-internal": "textarea__inner",
|
|
242
|
+
"data-focused": focused
|
|
243
|
+
}));
|
|
244
|
+
$[42] = disabled;
|
|
245
|
+
$[43] = focused;
|
|
246
|
+
$[44] = onChange;
|
|
247
|
+
$[45] = restProps;
|
|
248
|
+
$[46] = t20;
|
|
249
|
+
$[47] = t21;
|
|
250
|
+
$[48] = t22;
|
|
251
|
+
$[49] = textareaRef;
|
|
252
|
+
$[50] = value;
|
|
253
|
+
$[51] = t23;
|
|
254
|
+
} else {
|
|
255
|
+
t23 = $[51];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let t24;
|
|
259
|
+
|
|
260
|
+
if ($[52] !== onClear || $[53] !== showClearIcon) {
|
|
261
|
+
t24 = showClearIcon && /*#__PURE__*/React.createElement("button", {
|
|
262
|
+
type: "button",
|
|
263
|
+
className: styles.clearIcon,
|
|
264
|
+
onClick: onClear,
|
|
265
|
+
"aria-label": "Clear textarea",
|
|
266
|
+
"data-test": "textarea__clear-icon",
|
|
267
|
+
"data-rs-internal": "textarea__clear-icon",
|
|
268
|
+
tabIndex: -1
|
|
269
|
+
}, /*#__PURE__*/React.createElement(CloseOutlineIcon, {
|
|
270
|
+
className: styles.icon,
|
|
271
|
+
"data-render-all-sizes": true
|
|
272
|
+
}));
|
|
273
|
+
$[52] = onClear;
|
|
274
|
+
$[53] = showClearIcon;
|
|
275
|
+
$[54] = t24;
|
|
276
|
+
} else {
|
|
277
|
+
t24 = $[54];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
let t25;
|
|
281
|
+
|
|
282
|
+
if ($[55] !== busy) {
|
|
283
|
+
t25 = busy && /*#__PURE__*/React.createElement("span", {
|
|
284
|
+
className: styles.busyIcon
|
|
285
|
+
}, /*#__PURE__*/React.createElement(LoadingOutlineIcon, {
|
|
286
|
+
"data-test": "textarea__busy-icon",
|
|
287
|
+
"data-rs-internal": "textarea__busy-icon",
|
|
288
|
+
"data-render-all-sizes": true
|
|
289
|
+
}));
|
|
290
|
+
$[55] = busy;
|
|
291
|
+
$[56] = t25;
|
|
292
|
+
} else {
|
|
293
|
+
t25 = $[56];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let t26;
|
|
297
|
+
|
|
298
|
+
if ($[57] !== t17 || $[58] !== t23 || $[59] !== t24 || $[60] !== t25) {
|
|
299
|
+
t26 = /*#__PURE__*/React.createElement("div", {
|
|
300
|
+
className: t17,
|
|
301
|
+
onFocus: t18,
|
|
302
|
+
onBlur: t19
|
|
303
|
+
}, t23, t24, t25);
|
|
304
|
+
$[57] = t17;
|
|
305
|
+
$[58] = t23;
|
|
306
|
+
$[59] = t24;
|
|
307
|
+
$[60] = t25;
|
|
308
|
+
$[61] = t26;
|
|
309
|
+
} else {
|
|
310
|
+
t26 = $[61];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let t27;
|
|
314
|
+
|
|
315
|
+
if ($[62] !== characterCounter || $[63] !== error || $[64] !== errorId || $[65] !== hasFooter || $[66] !== note || $[67] !== reserveErrorLine) {
|
|
316
|
+
t27 = hasFooter && /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
className: styles.footer
|
|
318
|
+
}, characterCounter && /*#__PURE__*/React.createElement("div", {
|
|
319
|
+
className: styles.characterCounter
|
|
320
|
+
}, characterCounter), /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
321
|
+
id: errorId,
|
|
322
|
+
className: styles.errorMessage,
|
|
323
|
+
"data-test": "textarea__error",
|
|
324
|
+
reserveLine: reserveErrorLine
|
|
325
|
+
}, error), note && /*#__PURE__*/React.createElement("div", {
|
|
326
|
+
className: styles.note,
|
|
327
|
+
"data-test": "textarea__note",
|
|
328
|
+
"data-rs-internal": "textarea__note"
|
|
329
|
+
}, note));
|
|
330
|
+
$[62] = characterCounter;
|
|
331
|
+
$[63] = error;
|
|
332
|
+
$[64] = errorId;
|
|
333
|
+
$[65] = hasFooter;
|
|
334
|
+
$[66] = note;
|
|
335
|
+
$[67] = reserveErrorLine;
|
|
336
|
+
$[68] = t27;
|
|
337
|
+
} else {
|
|
338
|
+
t27 = $[68];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let t28;
|
|
342
|
+
|
|
343
|
+
if ($[69] !== id || $[70] !== ref || $[71] !== t14 || $[72] !== t15 || $[73] !== t26 || $[74] !== t27) {
|
|
344
|
+
t28 = /*#__PURE__*/React.createElement("label", {
|
|
345
|
+
ref: ref,
|
|
346
|
+
className: t14,
|
|
347
|
+
id: id,
|
|
348
|
+
"data-test": "textarea"
|
|
349
|
+
}, t15, t26, t27);
|
|
350
|
+
$[69] = id;
|
|
351
|
+
$[70] = ref;
|
|
352
|
+
$[71] = t14;
|
|
353
|
+
$[72] = t15;
|
|
354
|
+
$[73] = t26;
|
|
355
|
+
$[74] = t27;
|
|
356
|
+
$[75] = t28;
|
|
357
|
+
} else {
|
|
358
|
+
t28 = $[75];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return t28;
|
|
96
362
|
});
|
|
97
363
|
Textarea.displayName = 'Textarea';
|
|
98
364
|
Textarea.propTypes = {
|
|
@@ -105,6 +371,7 @@ Textarea.propTypes = {
|
|
|
105
371
|
onChange: PropTypes.func,
|
|
106
372
|
onFocus: PropTypes.func,
|
|
107
373
|
onBlur: PropTypes.func,
|
|
374
|
+
onClear: PropTypes.func,
|
|
108
375
|
size: PropTypes.oneOf(['s', 'm', 'l']),
|
|
109
376
|
mode: PropTypes.oneOf(['classic', 'rock']),
|
|
110
377
|
theme: PropTypes.oneOf(['light', 'dark']),
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"classic": "
|
|
8
|
-
"rock": "
|
|
9
|
-
"labelWrapper": "
|
|
10
|
-
"wrapper": "
|
|
11
|
-
"error": "
|
|
12
|
-
"disabled": "
|
|
13
|
-
"enabled": "
|
|
14
|
-
"focused": "
|
|
15
|
-
"filled": "
|
|
16
|
-
"inner": "
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
2
|
+
"themeLight": "_themeLight_1hf7mcw_8",
|
|
3
|
+
"themeDark": "_themeDark_1hf7mcw_11",
|
|
4
|
+
"sizeS": "_sizeS_1hf7mcw_15",
|
|
5
|
+
"sizeM": "_sizeM_1hf7mcw_18",
|
|
6
|
+
"sizeL": "_sizeL_1hf7mcw_21",
|
|
7
|
+
"classic": "_classic_1hf7mcw_25",
|
|
8
|
+
"rock": "_rock_1hf7mcw_28",
|
|
9
|
+
"labelWrapper": "_labelWrapper_1hf7mcw_32",
|
|
10
|
+
"wrapper": "_wrapper_1hf7mcw_40",
|
|
11
|
+
"error": "_error_1hf7mcw_57",
|
|
12
|
+
"disabled": "_disabled_1hf7mcw_63",
|
|
13
|
+
"enabled": "_enabled_1hf7mcw_69",
|
|
14
|
+
"focused": "_focused_1hf7mcw_69",
|
|
15
|
+
"filled": "_filled_1hf7mcw_75",
|
|
16
|
+
"inner": "_inner_1hf7mcw_91",
|
|
17
|
+
"clearable": "_clearable_1hf7mcw_119",
|
|
18
|
+
"clearIcon": "_clearIcon_1hf7mcw_184",
|
|
19
|
+
"icon": "_icon_1hf7mcw_226",
|
|
20
|
+
"busyIcon": "_busyIcon_1hf7mcw_234",
|
|
21
|
+
"label": "_label_1hf7mcw_32",
|
|
22
|
+
"footer": "_footer_1hf7mcw_265",
|
|
23
|
+
"characterCounter": "_characterCounter_1hf7mcw_284",
|
|
24
|
+
"errorMessage": "_errorMessage_1hf7mcw_293",
|
|
25
|
+
"note": "_note_1hf7mcw_297"
|
|
23
26
|
};
|
|
24
27
|
export { styles as default };
|
|
@@ -18,6 +18,30 @@ import { Textarea } from '@rescui/textarea';
|
|
|
18
18
|
</div>;
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
### With clear button
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { useState } from 'react';
|
|
25
|
+
import { Textarea } from '@rescui/textarea';
|
|
26
|
+
|
|
27
|
+
const Demo = () => {
|
|
28
|
+
const [value, setValue] = useState('Text that can be cleared and have a decent length');
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div style={{ maxWidth: 400 }}>
|
|
32
|
+
<Textarea
|
|
33
|
+
value={value}
|
|
34
|
+
onChange={e => setValue(e.target.value)}
|
|
35
|
+
onClear={() => setValue('')}
|
|
36
|
+
minRows={3}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
render(<Demo />);
|
|
43
|
+
```
|
|
44
|
+
|
|
21
45
|
### With character counter
|
|
22
46
|
|
|
23
47
|
```tsx
|