@versini/ui-textarea 4.0.1 → 4.0.3
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/dist/components/TextArea/TextArea.js +524 -4
- package/dist/index.js +10 -527
- package/package.json +5 -5
|
@@ -1,6 +1,526 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
1
|
+
import { jsx as g, jsxs as pe } from "react/jsx-runtime";
|
|
2
|
+
import ye, { useRef as f, useCallback as me, useEffect as S, useMemo as J, useState as _, useId as xe, useReducer as he, useLayoutEffect as L } from "react";
|
|
3
|
+
import c from "clsx";
|
|
4
|
+
const K = "av-text-area", Ae = "av-text-area-wrapper", P = "av-text-area-helper-text", ge = "av-text-area__control--right", Te = "av-text-area__control--left";
|
|
5
|
+
function ke() {
|
|
6
|
+
const e = f(!1);
|
|
7
|
+
return S(() => (e.current = !0, () => {
|
|
8
|
+
e.current = !1;
|
|
9
|
+
}), []), me(() => e.current, []);
|
|
10
|
+
}
|
|
11
|
+
function be(e) {
|
|
12
|
+
return J(() => e.every((r) => r == null) ? () => {
|
|
13
|
+
} : (r) => {
|
|
14
|
+
e.forEach((t) => {
|
|
15
|
+
typeof t == "function" ? t(r) : t != null && (t.current = r);
|
|
16
|
+
});
|
|
17
|
+
}, e);
|
|
18
|
+
}
|
|
19
|
+
const ve = {
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
width: 0,
|
|
23
|
+
height: 0,
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
bottom: 0,
|
|
27
|
+
right: 0
|
|
28
|
+
};
|
|
29
|
+
function W(e) {
|
|
30
|
+
const r = ke(), t = f(0), n = f(null), [a, o] = _(ve), s = J(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((l) => {
|
|
31
|
+
const u = l[0];
|
|
32
|
+
u && (cancelAnimationFrame(t.current), t.current = requestAnimationFrame(() => {
|
|
33
|
+
n.current && r() && o(u.contentRect);
|
|
34
|
+
}));
|
|
35
|
+
}), [r]);
|
|
36
|
+
return S(() => (n.current && (s == null || s.observe(n.current, e)), () => {
|
|
37
|
+
s == null || s.disconnect(), t.current && cancelAnimationFrame(t.current);
|
|
38
|
+
}), [s, e]), [n, a];
|
|
39
|
+
}
|
|
40
|
+
function Re({
|
|
41
|
+
value: e,
|
|
42
|
+
defaultValue: r,
|
|
43
|
+
finalValue: t,
|
|
44
|
+
onChange: n = () => {
|
|
45
|
+
},
|
|
46
|
+
initialControlledDelay: a = 0
|
|
47
|
+
}) {
|
|
48
|
+
const [o, s] = _(!1), [l, u] = _(
|
|
49
|
+
r !== void 0 ? r : t
|
|
50
|
+
), p = (y) => {
|
|
51
|
+
u(y), n == null || n(y);
|
|
52
|
+
};
|
|
53
|
+
return S(() => {
|
|
54
|
+
(async () => e !== void 0 && !o && a > 0 && (await new Promise(
|
|
55
|
+
(y) => setTimeout(y, a)
|
|
56
|
+
), s(!0)))();
|
|
57
|
+
}, [e, a, o]), e !== void 0 ? !o && a > 0 ? ["", n, !0] : [e, n, !0] : [l, p, !1];
|
|
58
|
+
}
|
|
59
|
+
function _e(e) {
|
|
60
|
+
const r = xe();
|
|
61
|
+
if (!e)
|
|
62
|
+
return r;
|
|
63
|
+
if (typeof e == "number" || typeof e == "string")
|
|
64
|
+
return `${e}${r}`;
|
|
65
|
+
if (typeof e == "object") {
|
|
66
|
+
const { id: t, prefix: n = "" } = e;
|
|
67
|
+
return typeof t == "number" || typeof t == "string" ? `${n}${t}` : `${n}${r}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const Q = "SET_ANNOUNCEMENT", Y = "CLEAR_ANNOUNCEMENT", Ne = {
|
|
71
|
+
alert: null,
|
|
72
|
+
alertdialog: null,
|
|
73
|
+
log: "polite",
|
|
74
|
+
marquee: null,
|
|
75
|
+
progressbar: null,
|
|
76
|
+
status: "polite",
|
|
77
|
+
timer: "assertive"
|
|
78
|
+
}, Ce = (e, r) => {
|
|
79
|
+
switch (r == null ? void 0 : r.type) {
|
|
80
|
+
case Q:
|
|
81
|
+
return {
|
|
82
|
+
...e,
|
|
83
|
+
announcement: r.payload
|
|
84
|
+
};
|
|
85
|
+
case Y:
|
|
86
|
+
return {
|
|
87
|
+
...e,
|
|
88
|
+
announcement: null
|
|
89
|
+
};
|
|
90
|
+
default:
|
|
91
|
+
return e;
|
|
92
|
+
}
|
|
93
|
+
}, Ee = ({
|
|
94
|
+
onAnnouncementClear: e,
|
|
95
|
+
dispatch: r
|
|
96
|
+
}) => {
|
|
97
|
+
r({
|
|
98
|
+
type: Y
|
|
99
|
+
}), typeof e == "function" && e();
|
|
100
|
+
}, q = ({
|
|
101
|
+
children: e,
|
|
102
|
+
clearAnnouncementDelay: r,
|
|
103
|
+
clearAnnouncementTimeoutRef: t,
|
|
104
|
+
onAnnouncementClear: n,
|
|
105
|
+
dispatch: a
|
|
106
|
+
}) => {
|
|
107
|
+
clearTimeout(t.current), e !== null && a({
|
|
108
|
+
type: Q,
|
|
109
|
+
payload: e
|
|
110
|
+
}), r && (t.current = setTimeout(
|
|
111
|
+
() => Ee({
|
|
112
|
+
onAnnouncementClear: n,
|
|
113
|
+
dispatch: a
|
|
114
|
+
}),
|
|
115
|
+
r
|
|
116
|
+
));
|
|
117
|
+
}, Le = ({
|
|
118
|
+
children: e,
|
|
119
|
+
announcementTimeoutRef: r,
|
|
120
|
+
announcementDelay: t,
|
|
121
|
+
clearAnnouncementDelay: n,
|
|
122
|
+
clearAnnouncementTimeoutRef: a,
|
|
123
|
+
onAnnouncementClear: o,
|
|
124
|
+
dispatch: s
|
|
125
|
+
}) => {
|
|
126
|
+
clearTimeout(r.current), t ? r.current = setTimeout(q, t, {
|
|
127
|
+
children: e,
|
|
128
|
+
clearAnnouncementDelay: n,
|
|
129
|
+
clearAnnouncementTimeoutRef: a,
|
|
130
|
+
onAnnouncementClear: o,
|
|
131
|
+
dispatch: s
|
|
132
|
+
}) : q({
|
|
133
|
+
children: e,
|
|
134
|
+
clearAnnouncementDelay: n,
|
|
135
|
+
clearAnnouncementTimeoutRef: a,
|
|
136
|
+
onAnnouncementClear: o,
|
|
137
|
+
dispatch: s
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
function Oe({
|
|
141
|
+
children: e,
|
|
142
|
+
className: r,
|
|
143
|
+
politeness: t,
|
|
144
|
+
role: n = null,
|
|
145
|
+
announcementDelay: a,
|
|
146
|
+
clearAnnouncementDelay: o,
|
|
147
|
+
onAnnouncementClear: s,
|
|
148
|
+
visible: l,
|
|
149
|
+
...u
|
|
150
|
+
}) {
|
|
151
|
+
const p = f(null), y = f(null), [b, N] = he(Ce, {
|
|
152
|
+
announcement: null
|
|
153
|
+
});
|
|
154
|
+
let T = t;
|
|
155
|
+
typeof T > "u" && (T = n ? Ne[n] : "assertive"), S(() => {
|
|
156
|
+
Le({
|
|
157
|
+
announcementTimeoutRef: p,
|
|
158
|
+
announcementDelay: a,
|
|
159
|
+
children: e,
|
|
160
|
+
clearAnnouncementDelay: o,
|
|
161
|
+
clearAnnouncementTimeoutRef: y,
|
|
162
|
+
onAnnouncementClear: s,
|
|
163
|
+
dispatch: N
|
|
164
|
+
});
|
|
165
|
+
}, [
|
|
166
|
+
e,
|
|
167
|
+
a,
|
|
168
|
+
o,
|
|
169
|
+
s
|
|
170
|
+
]);
|
|
171
|
+
const d = c(r, {
|
|
172
|
+
"sr-only": !l
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ g(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
"aria-live": T,
|
|
178
|
+
...n && { role: n },
|
|
179
|
+
className: d,
|
|
180
|
+
...u,
|
|
181
|
+
children: b.announcement
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
/*!
|
|
186
|
+
@versini/ui-liveregion v2.0.3
|
|
187
|
+
© 2025 gizmette.com
|
|
188
|
+
*/
|
|
189
|
+
try {
|
|
190
|
+
window.__VERSINI_UI_LIVEREGION__ || (window.__VERSINI_UI_LIVEREGION__ = {
|
|
191
|
+
version: "2.0.3",
|
|
192
|
+
buildTime: "05/26/2025 03:48 PM EDT",
|
|
193
|
+
homepage: "https://github.com/aversini/ui-components",
|
|
194
|
+
license: "MIT"
|
|
195
|
+
});
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
const Ie = () => "rounded-md text-base h-20 min-h-[80px] resize-none overflow-hidden px-4 py-7", Se = ({ mode: e }) => c({
|
|
199
|
+
"bg-surface-darker text-copy-lighter caret-copy-light": e === "dark",
|
|
200
|
+
"bg-surface-lighter text-copy-dark caret-copy-dark": e === "light",
|
|
201
|
+
"bg-surface-lighter text-copy-dark caret-copy-dark dark:bg-surface-darker dark:text-copy-lighter dark:caret-copy-light": e === "system",
|
|
202
|
+
"bg-surface-darker text-copy-lighter caret-copy-light dark:bg-surface-lighter dark:text-copy-dark dark:caret-copy-dark": e === "alt-system"
|
|
203
|
+
}), $e = ({
|
|
204
|
+
focusMode: e
|
|
205
|
+
}) => c("focus:outline focus:outline-2 focus:outline-offset-2", {
|
|
206
|
+
"focus:outline-focus-dark": e === "dark",
|
|
207
|
+
"focus:outline-focus-light": e === "light",
|
|
208
|
+
"focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
|
|
209
|
+
"focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
|
|
210
|
+
}), we = ({
|
|
211
|
+
noBorder: e,
|
|
212
|
+
error: r
|
|
213
|
+
}) => c("border-2", {
|
|
214
|
+
"border-border-dark": !e && !r,
|
|
215
|
+
"focus:border-border-dark": !e && r,
|
|
216
|
+
"border-border-error-dark": !e && r,
|
|
217
|
+
"border-transparent": e
|
|
218
|
+
}), De = ({
|
|
219
|
+
disabled: e,
|
|
220
|
+
raw: r,
|
|
221
|
+
error: t,
|
|
222
|
+
mode: n,
|
|
223
|
+
leftElement: a,
|
|
224
|
+
rightElement: o
|
|
225
|
+
}) => {
|
|
226
|
+
if (r)
|
|
227
|
+
return "";
|
|
228
|
+
if (e)
|
|
229
|
+
return c(
|
|
230
|
+
"transform translate-y-0 scale-100 absolute px-2 cursor-not-allowed opacity-50 font-medium",
|
|
231
|
+
{
|
|
232
|
+
"translate-x-[12px]": o === !0 && !a || !o && !a
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
if (!t)
|
|
236
|
+
return c(
|
|
237
|
+
"absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
|
|
238
|
+
{
|
|
239
|
+
"translate-x-[12px]": o === !0 && !a || !o && !a,
|
|
240
|
+
"text-copy-medium": n === "dark",
|
|
241
|
+
"text-copy-dark": n === "light",
|
|
242
|
+
"text-copy-dark dark:text-copy-medium": n === "system",
|
|
243
|
+
"text-copy-medium dark:text-copy-dark": n === "alt-system"
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
if (t)
|
|
247
|
+
return c(
|
|
248
|
+
"absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
|
|
249
|
+
{
|
|
250
|
+
"translate-x-[12px]": o === !0 && !a || !o && !a,
|
|
251
|
+
"text-copy-medium": n === "dark",
|
|
252
|
+
"text-copy-error-dark": n === "light",
|
|
253
|
+
"text-copy-error-dark dark:text-copy-error-light": n === "system",
|
|
254
|
+
"text-copy-medium dark:text-copy-error-dark": n === "alt-system"
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}, He = ({
|
|
258
|
+
error: e,
|
|
259
|
+
raw: r,
|
|
260
|
+
mode: t,
|
|
261
|
+
disabled: n
|
|
262
|
+
}) => {
|
|
263
|
+
if (r)
|
|
264
|
+
return "";
|
|
265
|
+
if (n)
|
|
266
|
+
return c(
|
|
267
|
+
P,
|
|
268
|
+
"absolute px-2 cursor-not-allowed opacity-50 font-medium"
|
|
269
|
+
);
|
|
270
|
+
if (!e)
|
|
271
|
+
return c(P, "absolute px-2 font-medium", {
|
|
272
|
+
"text-copy-medium": t === "dark",
|
|
273
|
+
"text-copy-dark": t === "light",
|
|
274
|
+
"text-copy-dark dark:text-copy-medium": t === "system",
|
|
275
|
+
"text-copy-medium dark:text-copy-dark": t === "alt-system"
|
|
276
|
+
});
|
|
277
|
+
if (e)
|
|
278
|
+
return c(P, "absolute px-2 font-medium", {
|
|
279
|
+
"text-copy-error-light": t === "dark",
|
|
280
|
+
"text-copy-error-dark": t === "light",
|
|
281
|
+
"text-copy-error-dark dark:text-copy-error-light": t === "system",
|
|
282
|
+
"dark:text-copy-error-dark text-copy-error-light": t === "alt-system"
|
|
283
|
+
});
|
|
284
|
+
}, Pe = ({
|
|
285
|
+
className: e,
|
|
286
|
+
textAreaClassName: r,
|
|
287
|
+
raw: t,
|
|
288
|
+
focusMode: n,
|
|
289
|
+
disabled: a,
|
|
290
|
+
noBorder: o,
|
|
291
|
+
error: s,
|
|
292
|
+
mode: l,
|
|
293
|
+
leftElement: u,
|
|
294
|
+
rightElement: p
|
|
295
|
+
}) => {
|
|
296
|
+
const y = t ? e : c(
|
|
297
|
+
"relative flex w-full flex-col justify-center",
|
|
298
|
+
Ae,
|
|
299
|
+
e
|
|
300
|
+
), b = t ? c(r) : c(
|
|
301
|
+
K,
|
|
302
|
+
r,
|
|
303
|
+
Ie(),
|
|
304
|
+
Se({ mode: l }),
|
|
305
|
+
$e({ focusMode: n }),
|
|
306
|
+
we({
|
|
307
|
+
noBorder: o,
|
|
308
|
+
error: s
|
|
309
|
+
}),
|
|
310
|
+
{
|
|
311
|
+
"disabled:cursor-not-allowed disabled:opacity-50": a
|
|
312
|
+
}
|
|
313
|
+
), N = t ? void 0 : "sr-only", T = De({
|
|
314
|
+
disabled: a,
|
|
315
|
+
raw: t,
|
|
316
|
+
error: s,
|
|
317
|
+
mode: l,
|
|
318
|
+
rightElement: p,
|
|
319
|
+
leftElement: u
|
|
320
|
+
}), d = He({
|
|
321
|
+
error: s,
|
|
322
|
+
raw: t,
|
|
323
|
+
mode: l,
|
|
324
|
+
disabled: a
|
|
325
|
+
}), C = t ? void 0 : c(ge, "absolute"), h = t ? void 0 : c(Te, "absolute");
|
|
326
|
+
return {
|
|
327
|
+
wrapper: y,
|
|
328
|
+
textArea: b,
|
|
329
|
+
accessibleLabel: N,
|
|
330
|
+
visibleLabel: T,
|
|
331
|
+
helperText: d,
|
|
332
|
+
rightElement: C,
|
|
333
|
+
leftElement: h
|
|
334
|
+
};
|
|
335
|
+
}, Fe = ({
|
|
336
|
+
scrollHeight: e,
|
|
337
|
+
currentHeight: r,
|
|
338
|
+
currentLabelOffset: t = 0,
|
|
339
|
+
currentHelperTextOffset: n = 0
|
|
340
|
+
}) => {
|
|
341
|
+
let s, l;
|
|
342
|
+
if (e > 0 && e !== r) {
|
|
343
|
+
const u = e - r, p = Math.abs(u / 24);
|
|
344
|
+
s = t + -1 * Math.sign(u) * (12 * p), l = n + Math.sign(u) * (12 * p);
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
labelOffset: s,
|
|
348
|
+
helperTextOffset: l,
|
|
349
|
+
scrollHeight: e
|
|
350
|
+
};
|
|
351
|
+
}, Me = ye.forwardRef(
|
|
352
|
+
({
|
|
353
|
+
id: e,
|
|
354
|
+
name: r,
|
|
355
|
+
label: t,
|
|
356
|
+
error: n = !1,
|
|
357
|
+
raw: a = !1,
|
|
358
|
+
className: o,
|
|
359
|
+
textAreaClassName: s,
|
|
360
|
+
mode: l = "system",
|
|
361
|
+
focusMode: u = "system",
|
|
362
|
+
value: p,
|
|
363
|
+
defaultValue: y,
|
|
364
|
+
disabled: b = !1,
|
|
365
|
+
noBorder: N = !1,
|
|
366
|
+
labelId: T,
|
|
367
|
+
helperText: d = "",
|
|
368
|
+
helperTextOnFocus: C = !1,
|
|
369
|
+
rightElement: h,
|
|
370
|
+
leftElement: v,
|
|
371
|
+
onChange: F,
|
|
372
|
+
onFocus: M,
|
|
373
|
+
onBlur: U,
|
|
374
|
+
...Z
|
|
375
|
+
}, ee) => {
|
|
376
|
+
var B;
|
|
377
|
+
const x = f(null), te = be([ee, x]), [re, O] = W(), [ne, R] = W(), $ = f(80), V = f(-25), m = f(null), X = f(30), I = f(null), E = _e({ id: e, prefix: `${K}-` }), [j, ae] = _(0), [G, oe] = _(0), [se, z] = _(
|
|
378
|
+
!!(!C && d)
|
|
379
|
+
), ce = `${r} error, ${d}`, k = Pe({
|
|
380
|
+
className: o,
|
|
381
|
+
textAreaClassName: s,
|
|
382
|
+
error: n,
|
|
383
|
+
raw: a,
|
|
384
|
+
focusMode: u,
|
|
385
|
+
disabled: b,
|
|
386
|
+
noBorder: N,
|
|
387
|
+
mode: l,
|
|
388
|
+
rightElement: !!h,
|
|
389
|
+
leftElement: !!v
|
|
390
|
+
}), [A, le] = Re({
|
|
391
|
+
value: p,
|
|
392
|
+
initialControlledDelay: 20,
|
|
393
|
+
defaultValue: y,
|
|
394
|
+
onChange: (i) => {
|
|
395
|
+
F && F({
|
|
396
|
+
target: {
|
|
397
|
+
value: i
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}), ue = (i) => {
|
|
402
|
+
le(i.target.value);
|
|
403
|
+
}, ie = (i) => {
|
|
404
|
+
C && d && z(!0), M && M(i);
|
|
405
|
+
}, de = (i) => {
|
|
406
|
+
C && d && !A && z(!1), U && U(i);
|
|
407
|
+
};
|
|
408
|
+
return L(() => {
|
|
409
|
+
O && O.width && ae(O.width + 18 + 10);
|
|
410
|
+
}, [O]), L(() => {
|
|
411
|
+
R && R.width && oe(R.width + 18 + 10);
|
|
412
|
+
}, [R]), L(() => {
|
|
413
|
+
a || x && x.current && A !== void 0 && (x.current.style.height = "inherit", x.current.style.height = x.current.scrollHeight + "px");
|
|
414
|
+
}, [A, a]), L(() => {
|
|
415
|
+
a || setTimeout(() => {
|
|
416
|
+
var i;
|
|
417
|
+
(i = m == null ? void 0 : m.current) == null || i.style.setProperty(
|
|
418
|
+
"--av-text-area-wrapper-transition",
|
|
419
|
+
A ? "none" : "all 0.2s ease-out"
|
|
420
|
+
);
|
|
421
|
+
}, 0);
|
|
422
|
+
}, [A, a]), L(() => {
|
|
423
|
+
var i, w;
|
|
424
|
+
if (!a && x && x.current && A !== void 0) {
|
|
425
|
+
const { labelOffset: D, helperTextOffset: H, scrollHeight: fe } = Fe({
|
|
426
|
+
scrollHeight: x.current.scrollHeight,
|
|
427
|
+
currentHeight: $.current,
|
|
428
|
+
currentLabelOffset: V.current,
|
|
429
|
+
currentHelperTextOffset: X.current
|
|
430
|
+
});
|
|
431
|
+
D && (V.current = D, (i = m == null ? void 0 : m.current) == null || i.style.setProperty(
|
|
432
|
+
"--av-text-area-label",
|
|
433
|
+
`${D}px`
|
|
434
|
+
)), H && (X.current = H, (w = I == null ? void 0 : I.current) == null || w.style.setProperty(
|
|
435
|
+
"--av-text-area-helper-text",
|
|
436
|
+
`${H}px`
|
|
437
|
+
)), $.current = fe || $.current;
|
|
438
|
+
}
|
|
439
|
+
}, [A, a]), R.width > 0 && ((B = m == null ? void 0 : m.current) == null || B.style.setProperty(
|
|
440
|
+
"--tw-translate-x",
|
|
441
|
+
`${12 + R.width + 5}px`
|
|
442
|
+
)), /* @__PURE__ */ pe("div", { className: k.wrapper, children: [
|
|
443
|
+
/* @__PURE__ */ g(
|
|
444
|
+
"label",
|
|
445
|
+
{
|
|
446
|
+
htmlFor: E,
|
|
447
|
+
id: T,
|
|
448
|
+
className: k.accessibleLabel,
|
|
449
|
+
children: t
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
v && /* @__PURE__ */ g(
|
|
453
|
+
"div",
|
|
454
|
+
{
|
|
455
|
+
ref: ne,
|
|
456
|
+
className: k.leftElement,
|
|
457
|
+
children: v
|
|
458
|
+
}
|
|
459
|
+
),
|
|
460
|
+
/* @__PURE__ */ g(
|
|
461
|
+
"textarea",
|
|
462
|
+
{
|
|
463
|
+
ref: te,
|
|
464
|
+
id: E,
|
|
465
|
+
name: r,
|
|
466
|
+
disabled: b,
|
|
467
|
+
placeholder: a ? void 0 : " ",
|
|
468
|
+
className: k.textArea,
|
|
469
|
+
rows: 1,
|
|
470
|
+
...d && { "aria-describedby": `${E}-helper` },
|
|
471
|
+
...n && { "aria-invalid": "true" },
|
|
472
|
+
...h && !v && !a && { style: { paddingRight: j } },
|
|
473
|
+
...v && !h && !a && { style: { paddingLeft: G } },
|
|
474
|
+
...h && v && !a && {
|
|
475
|
+
style: {
|
|
476
|
+
paddingRight: j,
|
|
477
|
+
paddingLeft: G
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
value: A,
|
|
481
|
+
onChange: ue,
|
|
482
|
+
onFocus: ie,
|
|
483
|
+
onBlur: de,
|
|
484
|
+
...Z
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
!a && /* @__PURE__ */ g(
|
|
488
|
+
"label",
|
|
489
|
+
{
|
|
490
|
+
ref: m,
|
|
491
|
+
"aria-hidden": !0,
|
|
492
|
+
htmlFor: E,
|
|
493
|
+
className: `${k.visibleLabel}`,
|
|
494
|
+
children: t
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
se && /* @__PURE__ */ g(
|
|
498
|
+
"div",
|
|
499
|
+
{
|
|
500
|
+
ref: I,
|
|
501
|
+
id: `${E}-helper`,
|
|
502
|
+
className: k.helperText,
|
|
503
|
+
children: d
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
h && /* @__PURE__ */ g(
|
|
507
|
+
"div",
|
|
508
|
+
{
|
|
509
|
+
ref: re,
|
|
510
|
+
className: k.rightElement,
|
|
511
|
+
children: h
|
|
512
|
+
}
|
|
513
|
+
),
|
|
514
|
+
n && d && /* @__PURE__ */ g(Oe, { politeness: "polite", clearAnnouncementDelay: 500, children: ce })
|
|
515
|
+
] });
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
Me.displayName = "TextArea";
|
|
4
519
|
export {
|
|
5
|
-
|
|
520
|
+
K as TEXT_AREA_CLASSNAME,
|
|
521
|
+
Te as TEXT_AREA_CONTROL_LEFT_CLASSNAME,
|
|
522
|
+
ge as TEXT_AREA_CONTROL_RIGHT_CLASSNAME,
|
|
523
|
+
P as TEXT_AREA_HELPER_TEXT_CLASSNAME,
|
|
524
|
+
Ae as TEXT_AREA_WRAPPER_CLASSNAME,
|
|
525
|
+
Me as TextArea
|
|
6
526
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,539 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import ye, { useRef as f, useEffect as S, useCallback as me, useMemo as J, useState as E, useId as xe, useReducer as he, useLayoutEffect as I } from "react";
|
|
3
|
-
import c from "clsx";
|
|
1
|
+
import { TEXT_AREA_CLASSNAME as T, TEXT_AREA_CONTROL_LEFT_CLASSNAME as R, TEXT_AREA_CONTROL_RIGHT_CLASSNAME as e, TEXT_AREA_HELPER_TEXT_CLASSNAME as S, TEXT_AREA_WRAPPER_CLASSNAME as i, TextArea as o } from "./components/TextArea/TextArea.js";
|
|
4
2
|
/*!
|
|
5
|
-
@versini/ui-textarea v4.0.
|
|
3
|
+
@versini/ui-textarea v4.0.3
|
|
6
4
|
© 2025 gizmette.com
|
|
7
5
|
*/
|
|
8
6
|
try {
|
|
9
7
|
window.__VERSINI_UI_TEXTAREA__ || (window.__VERSINI_UI_TEXTAREA__ = {
|
|
10
|
-
version: "4.0.
|
|
11
|
-
buildTime: "
|
|
8
|
+
version: "4.0.3",
|
|
9
|
+
buildTime: "05/26/2025 03:48 PM EDT",
|
|
12
10
|
homepage: "https://github.com/aversini/ui-components",
|
|
13
11
|
license: "MIT"
|
|
14
12
|
});
|
|
15
13
|
} catch {
|
|
16
14
|
}
|
|
17
|
-
const K = "av-text-area", Ae = "av-text-area-wrapper", H = "av-text-area-helper-text", Te = "av-text-area__control--right", ge = "av-text-area__control--left";
|
|
18
|
-
function _e() {
|
|
19
|
-
const e = f(!1);
|
|
20
|
-
return S(() => (e.current = !0, () => {
|
|
21
|
-
e.current = !1;
|
|
22
|
-
}), []), me(() => e.current, []);
|
|
23
|
-
}
|
|
24
|
-
function be(e) {
|
|
25
|
-
return J(() => e.every((n) => n == null) ? () => {
|
|
26
|
-
} : (n) => {
|
|
27
|
-
e.forEach((t) => {
|
|
28
|
-
typeof t == "function" ? t(n) : t != null && (t.current = n);
|
|
29
|
-
});
|
|
30
|
-
}, e);
|
|
31
|
-
}
|
|
32
|
-
const ke = {
|
|
33
|
-
x: 0,
|
|
34
|
-
y: 0,
|
|
35
|
-
width: 0,
|
|
36
|
-
height: 0,
|
|
37
|
-
top: 0,
|
|
38
|
-
left: 0,
|
|
39
|
-
bottom: 0,
|
|
40
|
-
right: 0
|
|
41
|
-
};
|
|
42
|
-
function W(e) {
|
|
43
|
-
const n = _e(), t = f(0), r = f(null), [a, s] = E(ke), o = J(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((l) => {
|
|
44
|
-
const u = l[0];
|
|
45
|
-
u && (cancelAnimationFrame(t.current), t.current = requestAnimationFrame(() => {
|
|
46
|
-
r.current && n() && s(u.contentRect);
|
|
47
|
-
}));
|
|
48
|
-
}), [n]);
|
|
49
|
-
return S(() => (r.current && (o == null || o.observe(r.current, e)), () => {
|
|
50
|
-
o == null || o.disconnect(), t.current && cancelAnimationFrame(t.current);
|
|
51
|
-
}), [o, e]), [r, a];
|
|
52
|
-
}
|
|
53
|
-
function Re({
|
|
54
|
-
value: e,
|
|
55
|
-
defaultValue: n,
|
|
56
|
-
finalValue: t,
|
|
57
|
-
onChange: r = () => {
|
|
58
|
-
},
|
|
59
|
-
initialControlledDelay: a = 0
|
|
60
|
-
}) {
|
|
61
|
-
const [s, o] = E(!1), [l, u] = E(
|
|
62
|
-
n !== void 0 ? n : t
|
|
63
|
-
), p = (y) => {
|
|
64
|
-
u(y), r == null || r(y);
|
|
65
|
-
};
|
|
66
|
-
return S(() => {
|
|
67
|
-
(async () => e !== void 0 && !s && a > 0 && (await new Promise(
|
|
68
|
-
(y) => setTimeout(y, a)
|
|
69
|
-
), o(!0)))();
|
|
70
|
-
}, [e, a, s]), e !== void 0 ? !s && a > 0 ? ["", r, !0] : [e, r, !0] : [l, p, !1];
|
|
71
|
-
}
|
|
72
|
-
function Ee(e) {
|
|
73
|
-
const n = xe();
|
|
74
|
-
if (!e)
|
|
75
|
-
return n;
|
|
76
|
-
if (typeof e == "number" || typeof e == "string")
|
|
77
|
-
return `${e}${n}`;
|
|
78
|
-
if (typeof e == "object") {
|
|
79
|
-
const { id: t, prefix: r = "" } = e;
|
|
80
|
-
return typeof t == "number" || typeof t == "string" ? `${r}${t}` : `${r}${n}`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const Q = "SET_ANNOUNCEMENT", Y = "CLEAR_ANNOUNCEMENT", Ne = {
|
|
84
|
-
alert: null,
|
|
85
|
-
alertdialog: null,
|
|
86
|
-
log: "polite",
|
|
87
|
-
marquee: null,
|
|
88
|
-
progressbar: null,
|
|
89
|
-
status: "polite",
|
|
90
|
-
timer: "assertive"
|
|
91
|
-
}, ve = (e, n) => {
|
|
92
|
-
switch (n == null ? void 0 : n.type) {
|
|
93
|
-
case Q:
|
|
94
|
-
return {
|
|
95
|
-
...e,
|
|
96
|
-
announcement: n.payload
|
|
97
|
-
};
|
|
98
|
-
case Y:
|
|
99
|
-
return {
|
|
100
|
-
...e,
|
|
101
|
-
announcement: null
|
|
102
|
-
};
|
|
103
|
-
default:
|
|
104
|
-
return e;
|
|
105
|
-
}
|
|
106
|
-
}, Ce = ({
|
|
107
|
-
onAnnouncementClear: e,
|
|
108
|
-
dispatch: n
|
|
109
|
-
}) => {
|
|
110
|
-
n({
|
|
111
|
-
type: Y
|
|
112
|
-
}), typeof e == "function" && e();
|
|
113
|
-
}, q = ({
|
|
114
|
-
children: e,
|
|
115
|
-
clearAnnouncementDelay: n,
|
|
116
|
-
clearAnnouncementTimeoutRef: t,
|
|
117
|
-
onAnnouncementClear: r,
|
|
118
|
-
dispatch: a
|
|
119
|
-
}) => {
|
|
120
|
-
clearTimeout(t.current), e !== null && a({
|
|
121
|
-
type: Q,
|
|
122
|
-
payload: e
|
|
123
|
-
}), n && (t.current = setTimeout(
|
|
124
|
-
() => Ce({
|
|
125
|
-
onAnnouncementClear: r,
|
|
126
|
-
dispatch: a
|
|
127
|
-
}),
|
|
128
|
-
n
|
|
129
|
-
));
|
|
130
|
-
}, Ie = ({
|
|
131
|
-
children: e,
|
|
132
|
-
announcementTimeoutRef: n,
|
|
133
|
-
announcementDelay: t,
|
|
134
|
-
clearAnnouncementDelay: r,
|
|
135
|
-
clearAnnouncementTimeoutRef: a,
|
|
136
|
-
onAnnouncementClear: s,
|
|
137
|
-
dispatch: o
|
|
138
|
-
}) => {
|
|
139
|
-
clearTimeout(n.current), t ? n.current = setTimeout(q, t, {
|
|
140
|
-
children: e,
|
|
141
|
-
clearAnnouncementDelay: r,
|
|
142
|
-
clearAnnouncementTimeoutRef: a,
|
|
143
|
-
onAnnouncementClear: s,
|
|
144
|
-
dispatch: o
|
|
145
|
-
}) : q({
|
|
146
|
-
children: e,
|
|
147
|
-
clearAnnouncementDelay: r,
|
|
148
|
-
clearAnnouncementTimeoutRef: a,
|
|
149
|
-
onAnnouncementClear: s,
|
|
150
|
-
dispatch: o
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
function Le({
|
|
154
|
-
children: e,
|
|
155
|
-
className: n,
|
|
156
|
-
politeness: t,
|
|
157
|
-
role: r = null,
|
|
158
|
-
announcementDelay: a,
|
|
159
|
-
clearAnnouncementDelay: s,
|
|
160
|
-
onAnnouncementClear: o,
|
|
161
|
-
visible: l,
|
|
162
|
-
...u
|
|
163
|
-
}) {
|
|
164
|
-
const p = f(null), y = f(null), [b, N] = he(ve, {
|
|
165
|
-
announcement: null
|
|
166
|
-
});
|
|
167
|
-
let g = t;
|
|
168
|
-
typeof g > "u" && (g = r ? Ne[r] : "assertive"), S(() => {
|
|
169
|
-
Ie({
|
|
170
|
-
announcementTimeoutRef: p,
|
|
171
|
-
announcementDelay: a,
|
|
172
|
-
children: e,
|
|
173
|
-
clearAnnouncementDelay: s,
|
|
174
|
-
clearAnnouncementTimeoutRef: y,
|
|
175
|
-
onAnnouncementClear: o,
|
|
176
|
-
dispatch: N
|
|
177
|
-
});
|
|
178
|
-
}, [
|
|
179
|
-
e,
|
|
180
|
-
a,
|
|
181
|
-
s,
|
|
182
|
-
o
|
|
183
|
-
]);
|
|
184
|
-
const d = c(n, {
|
|
185
|
-
"sr-only": !l
|
|
186
|
-
});
|
|
187
|
-
return /* @__PURE__ */ T(
|
|
188
|
-
"div",
|
|
189
|
-
{
|
|
190
|
-
"aria-live": g,
|
|
191
|
-
...r && { role: r },
|
|
192
|
-
className: d,
|
|
193
|
-
...u,
|
|
194
|
-
children: b.announcement
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
/*!
|
|
199
|
-
@versini/ui-liveregion v2.0.1
|
|
200
|
-
© 2025 gizmette.com
|
|
201
|
-
*/
|
|
202
|
-
try {
|
|
203
|
-
window.__VERSINI_UI_LIVEREGION__ || (window.__VERSINI_UI_LIVEREGION__ = {
|
|
204
|
-
version: "2.0.1",
|
|
205
|
-
buildTime: "04/02/2025 04:18 PM EDT",
|
|
206
|
-
homepage: "https://github.com/aversini/ui-components",
|
|
207
|
-
license: "MIT"
|
|
208
|
-
});
|
|
209
|
-
} catch {
|
|
210
|
-
}
|
|
211
|
-
const Oe = () => "rounded-md text-base h-20 min-h-[80px] resize-none overflow-hidden px-4 py-7", Se = ({ mode: e }) => c({
|
|
212
|
-
"bg-surface-darker text-copy-lighter caret-copy-light": e === "dark",
|
|
213
|
-
"bg-surface-lighter text-copy-dark caret-copy-dark": e === "light",
|
|
214
|
-
"bg-surface-lighter text-copy-dark caret-copy-dark dark:bg-surface-darker dark:text-copy-lighter dark:caret-copy-light": e === "system",
|
|
215
|
-
"bg-surface-darker text-copy-lighter caret-copy-light dark:bg-surface-lighter dark:text-copy-dark dark:caret-copy-dark": e === "alt-system"
|
|
216
|
-
}), we = ({
|
|
217
|
-
focusMode: e
|
|
218
|
-
}) => c("focus:outline focus:outline-2 focus:outline-offset-2", {
|
|
219
|
-
"focus:outline-focus-dark": e === "dark",
|
|
220
|
-
"focus:outline-focus-light": e === "light",
|
|
221
|
-
"focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
|
|
222
|
-
"focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
|
|
223
|
-
}), $e = ({
|
|
224
|
-
noBorder: e,
|
|
225
|
-
error: n
|
|
226
|
-
}) => c("border-2", {
|
|
227
|
-
"border-border-dark": !e && !n,
|
|
228
|
-
"focus:border-border-dark": !e && n,
|
|
229
|
-
"border-border-error-dark": !e && n,
|
|
230
|
-
"border-transparent": e
|
|
231
|
-
}), De = ({
|
|
232
|
-
disabled: e,
|
|
233
|
-
raw: n,
|
|
234
|
-
error: t,
|
|
235
|
-
mode: r,
|
|
236
|
-
leftElement: a,
|
|
237
|
-
rightElement: s
|
|
238
|
-
}) => {
|
|
239
|
-
if (n)
|
|
240
|
-
return "";
|
|
241
|
-
if (e)
|
|
242
|
-
return c(
|
|
243
|
-
"transform translate-y-0 scale-100 absolute px-2 cursor-not-allowed opacity-50 font-medium",
|
|
244
|
-
{
|
|
245
|
-
"translate-x-[12px]": s === !0 && !a || !s && !a
|
|
246
|
-
}
|
|
247
|
-
);
|
|
248
|
-
if (!t)
|
|
249
|
-
return c(
|
|
250
|
-
"absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
|
|
251
|
-
{
|
|
252
|
-
"translate-x-[12px]": s === !0 && !a || !s && !a,
|
|
253
|
-
"text-copy-medium": r === "dark",
|
|
254
|
-
"text-copy-dark": r === "light",
|
|
255
|
-
"text-copy-dark dark:text-copy-medium": r === "system",
|
|
256
|
-
"text-copy-medium dark:text-copy-dark": r === "alt-system"
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
if (t)
|
|
260
|
-
return c(
|
|
261
|
-
"absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
|
|
262
|
-
{
|
|
263
|
-
"translate-x-[12px]": s === !0 && !a || !s && !a,
|
|
264
|
-
"text-copy-medium": r === "dark",
|
|
265
|
-
"text-copy-error-dark": r === "light",
|
|
266
|
-
"text-copy-error-dark dark:text-copy-error-light": r === "system",
|
|
267
|
-
"text-copy-medium dark:text-copy-error-dark": r === "alt-system"
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
}, Pe = ({
|
|
271
|
-
error: e,
|
|
272
|
-
raw: n,
|
|
273
|
-
mode: t,
|
|
274
|
-
disabled: r
|
|
275
|
-
}) => {
|
|
276
|
-
if (n)
|
|
277
|
-
return "";
|
|
278
|
-
if (r)
|
|
279
|
-
return c(
|
|
280
|
-
H,
|
|
281
|
-
"absolute px-2 cursor-not-allowed opacity-50 font-medium"
|
|
282
|
-
);
|
|
283
|
-
if (!e)
|
|
284
|
-
return c(H, "absolute px-2 font-medium", {
|
|
285
|
-
"text-copy-medium": t === "dark",
|
|
286
|
-
"text-copy-dark": t === "light",
|
|
287
|
-
"text-copy-dark dark:text-copy-medium": t === "system",
|
|
288
|
-
"text-copy-medium dark:text-copy-dark": t === "alt-system"
|
|
289
|
-
});
|
|
290
|
-
if (e)
|
|
291
|
-
return c(H, "absolute px-2 font-medium", {
|
|
292
|
-
"text-copy-error-light": t === "dark",
|
|
293
|
-
"text-copy-error-dark": t === "light",
|
|
294
|
-
"text-copy-error-dark dark:text-copy-error-light": t === "system",
|
|
295
|
-
"dark:text-copy-error-dark text-copy-error-light": t === "alt-system"
|
|
296
|
-
});
|
|
297
|
-
}, He = ({
|
|
298
|
-
className: e,
|
|
299
|
-
textAreaClassName: n,
|
|
300
|
-
raw: t,
|
|
301
|
-
focusMode: r,
|
|
302
|
-
disabled: a,
|
|
303
|
-
noBorder: s,
|
|
304
|
-
error: o,
|
|
305
|
-
mode: l,
|
|
306
|
-
leftElement: u,
|
|
307
|
-
rightElement: p
|
|
308
|
-
}) => {
|
|
309
|
-
const y = t ? e : c(
|
|
310
|
-
"relative flex w-full flex-col justify-center",
|
|
311
|
-
Ae,
|
|
312
|
-
e
|
|
313
|
-
), b = t ? c(n) : c(
|
|
314
|
-
K,
|
|
315
|
-
n,
|
|
316
|
-
Oe(),
|
|
317
|
-
Se({ mode: l }),
|
|
318
|
-
we({ focusMode: r }),
|
|
319
|
-
$e({
|
|
320
|
-
noBorder: s,
|
|
321
|
-
error: o
|
|
322
|
-
}),
|
|
323
|
-
{
|
|
324
|
-
"disabled:cursor-not-allowed disabled:opacity-50": a
|
|
325
|
-
}
|
|
326
|
-
), N = t ? void 0 : "sr-only", g = De({
|
|
327
|
-
disabled: a,
|
|
328
|
-
raw: t,
|
|
329
|
-
error: o,
|
|
330
|
-
mode: l,
|
|
331
|
-
rightElement: p,
|
|
332
|
-
leftElement: u
|
|
333
|
-
}), d = Pe({
|
|
334
|
-
error: o,
|
|
335
|
-
raw: t,
|
|
336
|
-
mode: l,
|
|
337
|
-
disabled: a
|
|
338
|
-
}), v = t ? void 0 : c(Te, "absolute"), h = t ? void 0 : c(ge, "absolute");
|
|
339
|
-
return {
|
|
340
|
-
wrapper: y,
|
|
341
|
-
textArea: b,
|
|
342
|
-
accessibleLabel: N,
|
|
343
|
-
visibleLabel: g,
|
|
344
|
-
helperText: d,
|
|
345
|
-
rightElement: v,
|
|
346
|
-
leftElement: h
|
|
347
|
-
};
|
|
348
|
-
}, Me = ({
|
|
349
|
-
scrollHeight: e,
|
|
350
|
-
currentHeight: n,
|
|
351
|
-
currentLabelOffset: t = 0,
|
|
352
|
-
currentHelperTextOffset: r = 0
|
|
353
|
-
}) => {
|
|
354
|
-
let o, l;
|
|
355
|
-
if (e > 0 && e !== n) {
|
|
356
|
-
const u = e - n, p = Math.abs(u / 24);
|
|
357
|
-
o = t + -1 * Math.sign(u) * (12 * p), l = r + Math.sign(u) * (12 * p);
|
|
358
|
-
}
|
|
359
|
-
return {
|
|
360
|
-
labelOffset: o,
|
|
361
|
-
helperTextOffset: l,
|
|
362
|
-
scrollHeight: e
|
|
363
|
-
};
|
|
364
|
-
}, Fe = ye.forwardRef(
|
|
365
|
-
({
|
|
366
|
-
id: e,
|
|
367
|
-
name: n,
|
|
368
|
-
label: t,
|
|
369
|
-
error: r = !1,
|
|
370
|
-
raw: a = !1,
|
|
371
|
-
className: s,
|
|
372
|
-
textAreaClassName: o,
|
|
373
|
-
mode: l = "system",
|
|
374
|
-
focusMode: u = "system",
|
|
375
|
-
value: p,
|
|
376
|
-
defaultValue: y,
|
|
377
|
-
disabled: b = !1,
|
|
378
|
-
noBorder: N = !1,
|
|
379
|
-
labelId: g,
|
|
380
|
-
helperText: d = "",
|
|
381
|
-
helperTextOnFocus: v = !1,
|
|
382
|
-
rightElement: h,
|
|
383
|
-
leftElement: k,
|
|
384
|
-
onChange: M,
|
|
385
|
-
onFocus: F,
|
|
386
|
-
onBlur: U,
|
|
387
|
-
...Z
|
|
388
|
-
}, ee) => {
|
|
389
|
-
var B;
|
|
390
|
-
const x = f(null), te = be([ee, x]), [ne, L] = W(), [re, R] = W(), w = f(80), V = f(-25), m = f(null), X = f(30), O = f(null), C = Ee({ id: e, prefix: `${K}-` }), [j, ae] = E(0), [G, se] = E(0), [oe, z] = E(
|
|
391
|
-
!!(!v && d)
|
|
392
|
-
), ce = `${n} error, ${d}`, _ = He({
|
|
393
|
-
className: s,
|
|
394
|
-
textAreaClassName: o,
|
|
395
|
-
error: r,
|
|
396
|
-
raw: a,
|
|
397
|
-
focusMode: u,
|
|
398
|
-
disabled: b,
|
|
399
|
-
noBorder: N,
|
|
400
|
-
mode: l,
|
|
401
|
-
rightElement: !!h,
|
|
402
|
-
leftElement: !!k
|
|
403
|
-
}), [A, le] = Re({
|
|
404
|
-
value: p,
|
|
405
|
-
initialControlledDelay: 20,
|
|
406
|
-
defaultValue: y,
|
|
407
|
-
onChange: (i) => {
|
|
408
|
-
M && M({
|
|
409
|
-
target: {
|
|
410
|
-
value: i
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}), ue = (i) => {
|
|
415
|
-
le(i.target.value);
|
|
416
|
-
}, ie = (i) => {
|
|
417
|
-
v && d && z(!0), F && F(i);
|
|
418
|
-
}, de = (i) => {
|
|
419
|
-
v && d && !A && z(!1), U && U(i);
|
|
420
|
-
};
|
|
421
|
-
return I(() => {
|
|
422
|
-
L && L.width && ae(L.width + 18 + 10);
|
|
423
|
-
}, [L]), I(() => {
|
|
424
|
-
R && R.width && se(R.width + 18 + 10);
|
|
425
|
-
}, [R]), I(() => {
|
|
426
|
-
a || x && x.current && A !== void 0 && (x.current.style.height = "inherit", x.current.style.height = x.current.scrollHeight + "px");
|
|
427
|
-
}, [A, a]), I(() => {
|
|
428
|
-
a || setTimeout(() => {
|
|
429
|
-
var i;
|
|
430
|
-
(i = m == null ? void 0 : m.current) == null || i.style.setProperty(
|
|
431
|
-
"--av-text-area-wrapper-transition",
|
|
432
|
-
A ? "none" : "all 0.2s ease-out"
|
|
433
|
-
);
|
|
434
|
-
}, 0);
|
|
435
|
-
}, [A, a]), I(() => {
|
|
436
|
-
var i, $;
|
|
437
|
-
if (!a && x && x.current && A !== void 0) {
|
|
438
|
-
const { labelOffset: D, helperTextOffset: P, scrollHeight: fe } = Me({
|
|
439
|
-
scrollHeight: x.current.scrollHeight,
|
|
440
|
-
currentHeight: w.current,
|
|
441
|
-
currentLabelOffset: V.current,
|
|
442
|
-
currentHelperTextOffset: X.current
|
|
443
|
-
});
|
|
444
|
-
D && (V.current = D, (i = m == null ? void 0 : m.current) == null || i.style.setProperty(
|
|
445
|
-
"--av-text-area-label",
|
|
446
|
-
`${D}px`
|
|
447
|
-
)), P && (X.current = P, ($ = O == null ? void 0 : O.current) == null || $.style.setProperty(
|
|
448
|
-
"--av-text-area-helper-text",
|
|
449
|
-
`${P}px`
|
|
450
|
-
)), w.current = fe || w.current;
|
|
451
|
-
}
|
|
452
|
-
}, [A, a]), R.width > 0 && ((B = m == null ? void 0 : m.current) == null || B.style.setProperty(
|
|
453
|
-
"--tw-translate-x",
|
|
454
|
-
`${12 + R.width + 5}px`
|
|
455
|
-
)), /* @__PURE__ */ pe("div", { className: _.wrapper, children: [
|
|
456
|
-
/* @__PURE__ */ T(
|
|
457
|
-
"label",
|
|
458
|
-
{
|
|
459
|
-
htmlFor: C,
|
|
460
|
-
id: g,
|
|
461
|
-
className: _.accessibleLabel,
|
|
462
|
-
children: t
|
|
463
|
-
}
|
|
464
|
-
),
|
|
465
|
-
k && /* @__PURE__ */ T(
|
|
466
|
-
"div",
|
|
467
|
-
{
|
|
468
|
-
ref: re,
|
|
469
|
-
className: _.leftElement,
|
|
470
|
-
children: k
|
|
471
|
-
}
|
|
472
|
-
),
|
|
473
|
-
/* @__PURE__ */ T(
|
|
474
|
-
"textarea",
|
|
475
|
-
{
|
|
476
|
-
ref: te,
|
|
477
|
-
id: C,
|
|
478
|
-
name: n,
|
|
479
|
-
disabled: b,
|
|
480
|
-
placeholder: a ? void 0 : " ",
|
|
481
|
-
className: _.textArea,
|
|
482
|
-
rows: 1,
|
|
483
|
-
...d && { "aria-describedby": `${C}-helper` },
|
|
484
|
-
...r && { "aria-invalid": "true" },
|
|
485
|
-
...h && !k && !a && { style: { paddingRight: j } },
|
|
486
|
-
...k && !h && !a && { style: { paddingLeft: G } },
|
|
487
|
-
...h && k && !a && {
|
|
488
|
-
style: {
|
|
489
|
-
paddingRight: j,
|
|
490
|
-
paddingLeft: G
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
value: A,
|
|
494
|
-
onChange: ue,
|
|
495
|
-
onFocus: ie,
|
|
496
|
-
onBlur: de,
|
|
497
|
-
...Z
|
|
498
|
-
}
|
|
499
|
-
),
|
|
500
|
-
!a && /* @__PURE__ */ T(
|
|
501
|
-
"label",
|
|
502
|
-
{
|
|
503
|
-
ref: m,
|
|
504
|
-
"aria-hidden": !0,
|
|
505
|
-
htmlFor: C,
|
|
506
|
-
className: `${_.visibleLabel}`,
|
|
507
|
-
children: t
|
|
508
|
-
}
|
|
509
|
-
),
|
|
510
|
-
oe && /* @__PURE__ */ T(
|
|
511
|
-
"div",
|
|
512
|
-
{
|
|
513
|
-
ref: O,
|
|
514
|
-
id: `${C}-helper`,
|
|
515
|
-
className: _.helperText,
|
|
516
|
-
children: d
|
|
517
|
-
}
|
|
518
|
-
),
|
|
519
|
-
h && /* @__PURE__ */ T(
|
|
520
|
-
"div",
|
|
521
|
-
{
|
|
522
|
-
ref: ne,
|
|
523
|
-
className: _.rightElement,
|
|
524
|
-
children: h
|
|
525
|
-
}
|
|
526
|
-
),
|
|
527
|
-
r && d && /* @__PURE__ */ T(Le, { politeness: "polite", clearAnnouncementDelay: 500, children: ce })
|
|
528
|
-
] });
|
|
529
|
-
}
|
|
530
|
-
);
|
|
531
|
-
Fe.displayName = "TextArea";
|
|
532
15
|
export {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
16
|
+
T as TEXT_AREA_CLASSNAME,
|
|
17
|
+
R as TEXT_AREA_CONTROL_LEFT_CLASSNAME,
|
|
18
|
+
e as TEXT_AREA_CONTROL_RIGHT_CLASSNAME,
|
|
19
|
+
S as TEXT_AREA_HELPER_TEXT_CLASSNAME,
|
|
20
|
+
i as TEXT_AREA_WRAPPER_CLASSNAME,
|
|
21
|
+
o as TextArea
|
|
539
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-textarea",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@versini/ui-types": "5.0.
|
|
42
|
+
"@versini/ui-types": "5.0.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@tailwindcss/typography": "0.5.16",
|
|
46
46
|
"@versini/ui-hooks": "4.7.3",
|
|
47
|
-
"@versini/ui-liveregion": "2.0.
|
|
47
|
+
"@versini/ui-liveregion": "2.0.3",
|
|
48
48
|
"clsx": "2.1.1",
|
|
49
|
-
"tailwindcss": "4.1.
|
|
49
|
+
"tailwindcss": "4.1.7"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": [
|
|
52
52
|
"**/*.css"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "863a399128080a19f2668e458d495110aa0f68f8"
|
|
55
55
|
}
|