@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.
@@ -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)
@@ -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 { shouldRenderErrorMessage, ErrorMessage } from '@rescui/form-field';
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 { useBackwardCompatibleId } from './use-backward-compatible-id.js';
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
- (_ref, ref) => {
26
- let {
27
- id,
28
- className,
29
- disabled,
30
- error,
31
- reserveErrorLine = false,
32
- busy,
33
- onChange,
34
- size = 'm',
35
- mode = 'classic',
36
- theme: themeFromProps,
37
- textareaRef,
38
- value,
39
- tabIndex,
40
- label,
41
- boldLabel = true,
42
- note,
43
- characterCounter,
44
- ...restProps
45
- } = _ref;
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-${useBackwardCompatibleId()}`;
142
+ const uniqueId = `textarea-${useSafeId()}`;
50
143
  const errorId = `${id ? id : uniqueId}-error`;
51
- const hasFooter = Boolean(note) || Boolean(characterCounter) || shouldRenderErrorMessage(error, reserveErrorLine);
52
- return /*#__PURE__*/React.createElement("label", {
53
- ref: ref,
54
- className: cn(styles.labelWrapper, SIZE_STYLES[size], MODE_STYLES[mode], THEME_STYLES[theme], !!error && styles.error, disabled ? styles.disabled : styles.enabled, focused && styles.focused, boldLabel && styles.boldLabel, isEmpty ? styles.empty : styles.filled, className),
55
- id: id,
56
- "data-test": 'textarea'
57
- }, label && /*#__PURE__*/React.createElement("div", {
58
- className: styles.label,
59
- "data-test": 'textarea__label',
60
- "data-rs-internal": boldLabel ? 'textarea__bold-label' : 'textarea__label'
61
- }, label), /*#__PURE__*/React.createElement("div", {
62
- className: styles.wrapper,
63
- onFocus: () => setFocused(true),
64
- onBlur: () => setFocused(false)
65
- }, /*#__PURE__*/React.createElement(TextareaAutosize, { ...restProps,
66
- className: styles.inner,
67
- disabled: disabled,
68
- value: value,
69
- onChange: onChange,
70
- ref: textareaRef,
71
- "aria-errormessage": error ? errorId : undefined,
72
- "aria-invalid": Boolean(error),
73
- tabIndex: disabled ? -1 : tabIndex,
74
- "data-test": 'textarea__input',
75
- "data-rs-internal": "textarea__inner"
76
- }), busy && /*#__PURE__*/React.createElement("span", {
77
- className: styles.busyIcon
78
- }, /*#__PURE__*/React.createElement(LoadingOutlineIcon, {
79
- "data-test": "textarea__busy-icon",
80
- "data-rs-internal": "textarea__busy-icon",
81
- "data-render-all-sizes": true
82
- }))), hasFooter && /*#__PURE__*/React.createElement("div", {
83
- className: styles.footer
84
- }, characterCounter && /*#__PURE__*/React.createElement("div", {
85
- className: styles.characterCounter
86
- }, characterCounter), /*#__PURE__*/React.createElement(ErrorMessage, {
87
- id: errorId,
88
- className: styles.errorMessage,
89
- "data-test": 'textarea__error',
90
- reserveLine: reserveErrorLine
91
- }, error), note && /*#__PURE__*/React.createElement("div", {
92
- className: styles.note,
93
- "data-test": 'textarea__note',
94
- "data-rs-internal": "textarea__note"
95
- }, note)));
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": "_themeLight_18horc_8",
3
- "themeDark": "_themeDark_18horc_11",
4
- "sizeS": "_sizeS_18horc_15",
5
- "sizeM": "_sizeM_18horc_18",
6
- "sizeL": "_sizeL_18horc_21",
7
- "classic": "_classic_18horc_25",
8
- "rock": "_rock_18horc_28",
9
- "labelWrapper": "_labelWrapper_18horc_32",
10
- "wrapper": "_wrapper_18horc_40",
11
- "error": "_error_18horc_57",
12
- "disabled": "_disabled_18horc_63",
13
- "enabled": "_enabled_18horc_69",
14
- "focused": "_focused_18horc_69",
15
- "filled": "_filled_18horc_75",
16
- "inner": "_inner_18horc_91",
17
- "busyIcon": "_busyIcon_18horc_177",
18
- "label": "_label_18horc_32",
19
- "footer": "_footer_18horc_208",
20
- "characterCounter": "_characterCounter_18horc_227",
21
- "errorMessage": "_errorMessage_18horc_236",
22
- "note": "_note_18horc_240"
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 };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare function useFallbackId(): number;
3
+ export declare const useSafeId: typeof React.useId | typeof useFallbackId;
4
+ export {};
@@ -0,0 +1,10 @@
1
+ import React, { useState } from 'react';
2
+ let nextFallbackId = 0;
3
+
4
+ function useFallbackId() {
5
+ const [id] = useState(() => nextFallbackId++);
6
+ return id;
7
+ }
8
+
9
+ const useSafeId = React.useId ?? useFallbackId;
10
+ export { useSafeId };
@@ -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