asma-ui-core 3.110.0 → 3.112.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/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +41 -41
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +57 -57
- package/dist/components/inputs/input-field/StyledInputField.js +147 -157
- package/dist/components/inputs/textarea/StyledTextarea.js +46 -47
- package/dist/hooks/useBackCloses.hook.js +67 -38
- package/dist/hooks/useTopLayer.hook.js +30 -26
- package/dist/index.js +252 -249
- package/dist/src/components/inputs/input-field/StyledInputField.d.ts +4 -1
- package/dist/src/helpers/CharacterCounter.d.ts +2 -1
- package/dist/src/hooks/useBackCloses.hook.d.ts +47 -2
- package/dist/src/hooks/useTopLayer.hook.d.ts +6 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import { CharacterCounter as
|
|
5
|
-
import { HelperRow as
|
|
1
|
+
import { cn as s } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as F } from "../../../helpers/sx.js";
|
|
3
|
+
import { CloseIcon as mt } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { CharacterCounter as pt } from "../../../helpers/CharacterCounter.js";
|
|
5
|
+
import { HelperRow as gt } from "../../../helpers/HelperRow.js";
|
|
6
6
|
import { useHelperRowBudget as ft } from "../../../helpers/useHelperRowBudget.js";
|
|
7
7
|
import { useHelperSlot as xt } from "../../../helpers/useHelperSlot.js";
|
|
8
|
-
import { fieldLabelAboveClass as bt, fieldWidthStyle as yt, floatingLabelClass as Lt, floatingLabelLayoutStyle as St, notchedLegendClass as vt, notchedOutlineClass as
|
|
9
|
-
import
|
|
10
|
-
import { Children as
|
|
11
|
-
import { jsx as o, jsxs as
|
|
12
|
-
import { useMergeRefs as
|
|
13
|
-
var Ot = ({ dataTest: y, label: r, labelPlacement:
|
|
14
|
-
const
|
|
15
|
-
const e =
|
|
16
|
-
if (!(!i || !e) && (
|
|
17
|
-
if (e.removeAttribute("data-scrollable"),
|
|
8
|
+
import { fieldLabelAboveClass as bt, fieldWidthStyle as yt, floatingLabelClass as Lt, floatingLabelLayoutStyle as St, notchedLegendClass as vt, notchedOutlineClass as se, singleLineInputLayoutStyle as Ht, singleLineShellLayoutStyle as It } from "../field-styles.js";
|
|
9
|
+
import x from "./StyledInputField.module.js";
|
|
10
|
+
import { Children as At, useCallback as re, useId as Ct, useLayoutEffect as _, useRef as U, useState as B } from "react";
|
|
11
|
+
import { jsx as o, jsxs as b } from "react/jsx-runtime";
|
|
12
|
+
import { useMergeRefs as de } from "@floating-ui/react";
|
|
13
|
+
var Ot = ({ dataTest: y, label: r, labelPlacement: ce = "above", value: m, defaultValue: L, onChange: ue, onBlur: he, onFocus: me, error: p, helperText: K, reserveHelperText: pe, expandHelperText: ge = !0, maxLength: fe, counter: xe, locale: be, disabled: d, readOnly: n, required: v, allowClear: ye, onClear: Le, type: Se = "text", placeholder: ve, name: He, id: Ie, autoComplete: Ae, autoFocus: Ce, multiline: i, rows: H, minRows: M, maxRows: k, size: Ne = "medium", width: Y = "full", fullWidth: Nt, className: Re, style: we, sx: Fe, inputRef: _e, slotProps: t, InputProps: G, onKeyDown: J, onClick: Be, variant: Rt }) => {
|
|
14
|
+
const Me = Ct(), E = Ie ?? Me, Q = `${E}-helper-text`, T = U(null), D = U(0), V = U(null), [ke, Ee] = B(void 0), [I, X] = B(!1), [Te, Z] = B(L != null && L !== ""), [De, We] = B(String(L ?? "").length), A = m !== void 0, q = A ? m !== "" && m != null : Te, $e = !!d || !!n, W = t?.input?.startAdornment ?? G?.startAdornment, S = At.count(W) > 0, u = S && Array.isArray(W), g = t?.input?.endAdornment ?? G?.endAdornment, C = !!(ye && q && !$e), { ref: ze, ...l } = t?.htmlInput ?? {}, je = _e ?? ze, { className: Pe, style: $, ref: Ue } = t?.input ?? {}, Ke = de([Ue]), Ye = t?.input?.onMouseDown, O = t?.input?.onClick, Ge = O ? { onClick: O } : {}, Je = Ae ?? l.autoComplete, Qe = He ?? l.name, z = l.id ?? E, N = fe ?? l.maxLength, ee = `${E}-counter`, te = xe !== !1 && !!N, Ve = A ? String(m ?? "").length : De, R = ce === "floating" && !!r, w = I || q || S, h = re(() => {
|
|
15
|
+
const e = T.current;
|
|
16
|
+
if (!(!i || !e) && (D.current = e.offsetWidth, D.current !== 0)) {
|
|
17
|
+
if (e.removeAttribute("data-scrollable"), H != null && !n) e.style.height = "";
|
|
18
18
|
else {
|
|
19
19
|
if (e.style.height = "auto", e.scrollHeight === 0) {
|
|
20
20
|
e.style.height = "";
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
e.style.height = `${Math.min(
|
|
23
|
+
const a = getComputedStyle(e), c = Number.parseFloat(a.lineHeight) || 24, le = Number.parseFloat(a.paddingTop) + Number.parseFloat(a.paddingBottom), ae = H ?? M, ut = ae ? ae * c + le : 0, ht = n || !k ? Number.POSITIVE_INFINITY : k * c + le;
|
|
24
|
+
e.style.height = `${Math.min(ht, Math.max(ut, e.scrollHeight))}px`;
|
|
25
25
|
}
|
|
26
26
|
e.scrollHeight > e.clientHeight + 1 && e.setAttribute("data-scrollable", "true");
|
|
27
27
|
}
|
|
28
28
|
}, [
|
|
29
|
-
T,
|
|
30
29
|
k,
|
|
30
|
+
M,
|
|
31
31
|
i,
|
|
32
32
|
n,
|
|
33
|
-
|
|
34
|
-
]),
|
|
35
|
-
n || (A || (
|
|
36
|
-
},
|
|
37
|
-
!d && !n &&
|
|
38
|
-
},
|
|
39
|
-
!d && !n &&
|
|
33
|
+
H
|
|
34
|
+
]), Xe = (e) => {
|
|
35
|
+
n || (A || (Z(e.target.value !== ""), We(e.target.value.length), h()), ue?.(e));
|
|
36
|
+
}, Ze = (e) => {
|
|
37
|
+
!d && !n && X(!0), me?.(e);
|
|
38
|
+
}, qe = (e) => {
|
|
39
|
+
!d && !n && X(!1), he?.(e);
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
_(() => {
|
|
42
|
+
h();
|
|
43
43
|
}, [
|
|
44
|
-
|
|
44
|
+
h,
|
|
45
45
|
L,
|
|
46
|
-
|
|
47
|
-
]),
|
|
46
|
+
m
|
|
47
|
+
]), _(() => {
|
|
48
48
|
if (!i || !document.fonts) return;
|
|
49
|
-
const e = () =>
|
|
49
|
+
const e = () => h();
|
|
50
50
|
return document.fonts.addEventListener("loadingdone", e), () => document.fonts.removeEventListener("loadingdone", e);
|
|
51
|
-
}, [i,
|
|
52
|
-
const e =
|
|
51
|
+
}, [i, h]), _(() => {
|
|
52
|
+
const e = T.current;
|
|
53
53
|
if (!i || !e || typeof ResizeObserver > "u") return;
|
|
54
|
-
let
|
|
54
|
+
let a = 0;
|
|
55
55
|
const c = new ResizeObserver(() => {
|
|
56
|
-
e.offsetWidth !==
|
|
56
|
+
e.offsetWidth !== D.current && (cancelAnimationFrame(a), a = requestAnimationFrame(h));
|
|
57
57
|
});
|
|
58
58
|
return c.observe(e), () => {
|
|
59
|
-
cancelAnimationFrame(
|
|
59
|
+
cancelAnimationFrame(a), c.disconnect();
|
|
60
60
|
};
|
|
61
|
-
}, [i,
|
|
62
|
-
const ne =
|
|
63
|
-
|
|
64
|
-
}, [])]), { style:
|
|
65
|
-
...
|
|
61
|
+
}, [i, h]);
|
|
62
|
+
const ne = de([je, re((e) => {
|
|
63
|
+
T.current = e instanceof HTMLTextAreaElement ? e : null;
|
|
64
|
+
}, [])]), { style: j, ...Oe } = l, f = !i && !u, { height: wt, minHeight: Ft, maxHeight: _t, paddingTop: Bt, paddingBottom: Mt, ...et } = $ ?? {}, tt = f ? {
|
|
65
|
+
...et,
|
|
66
66
|
...It()
|
|
67
|
-
} :
|
|
67
|
+
} : u ? {
|
|
68
68
|
boxSizing: "border-box",
|
|
69
69
|
minHeight: 40,
|
|
70
|
-
|
|
71
|
-
} :
|
|
72
|
-
...
|
|
70
|
+
...$
|
|
71
|
+
} : $, { height: kt, minHeight: Et, maxHeight: Tt, paddingTop: Dt, paddingBottom: Wt, paddingLeft: $t, paddingRight: nt, ...ot } = j ?? {}, it = f ? {
|
|
72
|
+
...ot,
|
|
73
73
|
...Ht({
|
|
74
74
|
paddingLeft: S ? 40 : 14,
|
|
75
|
-
paddingRight:
|
|
75
|
+
paddingRight: nt ?? ke ?? (C || g ? 40 : 14)
|
|
76
76
|
})
|
|
77
|
-
} :
|
|
78
|
-
|
|
79
|
-
if (!
|
|
80
|
-
const e =
|
|
81
|
-
|
|
77
|
+
} : j;
|
|
78
|
+
_(() => {
|
|
79
|
+
if (!f) return;
|
|
80
|
+
const e = V.current, a = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
|
|
81
|
+
Ee((c) => c === a ? c : a);
|
|
82
82
|
}, [
|
|
83
|
-
|
|
83
|
+
f,
|
|
84
84
|
C,
|
|
85
|
-
|
|
85
|
+
g
|
|
86
86
|
]);
|
|
87
|
-
const
|
|
88
|
-
...
|
|
89
|
-
style:
|
|
90
|
-
id:
|
|
91
|
-
name:
|
|
92
|
-
maxLength:
|
|
93
|
-
placeholder:
|
|
87
|
+
const lt = w || !R, { show: P, role: at } = xt("StyledInputField", p, K, pe, n), { fieldRef: st, rowRef: rt, rowStyle: dt } = ft(ge && P), oe = {
|
|
88
|
+
...Oe,
|
|
89
|
+
style: f ? it : j,
|
|
90
|
+
id: z,
|
|
91
|
+
name: Qe,
|
|
92
|
+
maxLength: N,
|
|
93
|
+
placeholder: lt ? ve : void 0,
|
|
94
94
|
disabled: d,
|
|
95
95
|
readOnly: n,
|
|
96
|
-
required:
|
|
97
|
-
autoComplete:
|
|
98
|
-
autoFocus:
|
|
99
|
-
value:
|
|
96
|
+
required: v,
|
|
97
|
+
autoComplete: Je,
|
|
98
|
+
autoFocus: Ce,
|
|
99
|
+
value: m,
|
|
100
100
|
defaultValue: L,
|
|
101
|
-
"aria-invalid":
|
|
102
|
-
"aria-label":
|
|
103
|
-
"aria-describedby": [
|
|
104
|
-
onChange:
|
|
105
|
-
onFocus:
|
|
106
|
-
onBlur:
|
|
107
|
-
onKeyDown:
|
|
108
|
-
|
|
101
|
+
"aria-invalid": p ? !0 : void 0,
|
|
102
|
+
"aria-label": l["aria-label"] ?? (l["aria-labelledby"] ? void 0 : typeof r == "string" && r !== "" ? r : void 0),
|
|
103
|
+
"aria-describedby": [P ? Q : l["aria-describedby"], te ? ee : void 0].filter(Boolean).join(" ") || void 0,
|
|
104
|
+
onChange: Xe,
|
|
105
|
+
onFocus: Ze,
|
|
106
|
+
onBlur: qe,
|
|
107
|
+
onKeyDown: l.onKeyDown || J ? (e) => {
|
|
108
|
+
J?.(e), e.defaultPrevented || l.onKeyDown?.(e);
|
|
109
109
|
} : void 0
|
|
110
|
-
},
|
|
110
|
+
}, ie = s(x.Input, "peer border-0 bg-transparent text-base tracking-[0.00938em] text-delta-800 outline-none placeholder:text-delta-500", u ? "box-border h-8 min-w-[60px] flex-1 py-0 pl-0 pr-0 leading-[23px]" : i ? s("w-full resize-none p-0 pl-0 pr-0 leading-[23px]", x["Input--multiline"]) : s("w-full", x["Input--singleLine"]), "disabled:text-delta-300", n && "text-delta-800", Pe), ct = !i && !u ? {
|
|
111
111
|
"data-start-adornment": S ? "true" : void 0,
|
|
112
|
-
"data-end-adornment": C ||
|
|
112
|
+
"data-end-adornment": C || g ? "true" : void 0
|
|
113
113
|
} : {};
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
ref:
|
|
116
|
-
className:
|
|
117
|
-
onClick:
|
|
118
|
-
"data-field-width":
|
|
114
|
+
return /* @__PURE__ */ b("div", {
|
|
115
|
+
ref: st,
|
|
116
|
+
className: s("group relative min-w-0 flex-col", Re),
|
|
117
|
+
onClick: Be,
|
|
118
|
+
"data-field-width": Y,
|
|
119
119
|
style: {
|
|
120
120
|
display: "flex",
|
|
121
|
-
...yt(
|
|
121
|
+
...yt(Y),
|
|
122
122
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
123
123
|
letterSpacing: "0.00938em",
|
|
124
|
-
...
|
|
125
|
-
...
|
|
124
|
+
...F(Fe),
|
|
125
|
+
...we
|
|
126
126
|
},
|
|
127
127
|
children: [
|
|
128
|
-
r && !
|
|
129
|
-
className:
|
|
128
|
+
r && !R && /* @__PURE__ */ o("div", {
|
|
129
|
+
className: s(bt({ disabled: d }), t?.inputLabel?.className),
|
|
130
130
|
style: {
|
|
131
|
-
...
|
|
131
|
+
...F(t?.inputLabel?.sx),
|
|
132
132
|
...t?.inputLabel?.style
|
|
133
133
|
},
|
|
134
|
-
children: /* @__PURE__ */
|
|
135
|
-
htmlFor:
|
|
136
|
-
children: [r,
|
|
134
|
+
children: /* @__PURE__ */ b("label", {
|
|
135
|
+
htmlFor: z,
|
|
136
|
+
children: [r, v && /* @__PURE__ */ o("span", {
|
|
137
137
|
"aria-hidden": "true",
|
|
138
138
|
children: " *"
|
|
139
139
|
})]
|
|
140
140
|
})
|
|
141
141
|
}),
|
|
142
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ b("div", {
|
|
143
143
|
className: "relative overflow-visible",
|
|
144
|
-
children: [/* @__PURE__ */
|
|
145
|
-
className:
|
|
146
|
-
ref:
|
|
147
|
-
onMouseDown:
|
|
148
|
-
...
|
|
149
|
-
style:
|
|
150
|
-
"data-testid":
|
|
144
|
+
children: [/* @__PURE__ */ b("div", {
|
|
145
|
+
className: s("relative flex", f && x.InputShell, i && "box-border items-center px-[14px] py-[16.5px]", u && s(x.AdornmentList, g && x["AdornmentList--endAdornment"]), n && "rounded bg-delta-50"),
|
|
146
|
+
ref: Ke,
|
|
147
|
+
onMouseDown: Ye,
|
|
148
|
+
...Ge,
|
|
149
|
+
style: tt,
|
|
150
|
+
"data-testid": u ? `${y}-adornment-list` : `${y}-shell`,
|
|
151
151
|
children: [
|
|
152
152
|
S && /* @__PURE__ */ o("span", {
|
|
153
|
-
className:
|
|
154
|
-
children:
|
|
153
|
+
className: s("items-center text-delta-500", u ? "contents" : "absolute left-3 flex"),
|
|
154
|
+
children: W
|
|
155
155
|
}),
|
|
156
156
|
i ? /* @__PURE__ */ o("textarea", {
|
|
157
|
-
...
|
|
157
|
+
...oe,
|
|
158
158
|
ref: ne,
|
|
159
159
|
"data-testid": y,
|
|
160
|
-
rows:
|
|
161
|
-
className:
|
|
160
|
+
rows: H ?? M ?? 2,
|
|
161
|
+
className: ie
|
|
162
162
|
}) : /* @__PURE__ */ o("input", {
|
|
163
|
-
...
|
|
164
|
-
...
|
|
163
|
+
...oe,
|
|
164
|
+
...ct,
|
|
165
165
|
ref: ne,
|
|
166
166
|
"data-testid": y,
|
|
167
|
-
type:
|
|
168
|
-
className:
|
|
167
|
+
type: Se,
|
|
168
|
+
className: ie
|
|
169
169
|
}),
|
|
170
170
|
C ? /* @__PURE__ */ o("button", {
|
|
171
171
|
type: "button",
|
|
@@ -174,92 +174,82 @@ var Ot = ({ dataTest: y, label: r, labelPlacement: me = "above", value: g, defau
|
|
|
174
174
|
"data-testid": `${y}-clear`,
|
|
175
175
|
className: "asma-pressable absolute right-4 z-40 flex items-center justify-center rounded-full border-0 bg-transparent p-[2px] duration-300 hover:bg-gama-100",
|
|
176
176
|
onClick: (e) => {
|
|
177
|
-
e.stopPropagation(), e.preventDefault(), A ||
|
|
177
|
+
e.stopPropagation(), e.preventDefault(), A || Z(!1), Le?.();
|
|
178
178
|
},
|
|
179
|
-
children: /* @__PURE__ */ o(
|
|
179
|
+
children: /* @__PURE__ */ o(mt, {
|
|
180
180
|
width: 18,
|
|
181
181
|
height: 18
|
|
182
182
|
})
|
|
183
|
-
}) :
|
|
184
|
-
ref:
|
|
183
|
+
}) : g && /* @__PURE__ */ o("span", {
|
|
184
|
+
ref: V,
|
|
185
185
|
className: "absolute inset-y-0 right-[14px] flex max-w-[calc(100%-28px)] items-center gap-1",
|
|
186
|
-
children:
|
|
186
|
+
children: g
|
|
187
187
|
}),
|
|
188
|
-
|
|
188
|
+
R ? /* @__PURE__ */ o("fieldset", {
|
|
189
189
|
"aria-hidden": !0,
|
|
190
|
-
className:
|
|
191
|
-
focused:
|
|
192
|
-
error:
|
|
190
|
+
className: se({
|
|
191
|
+
focused: I,
|
|
192
|
+
error: p,
|
|
193
193
|
disabled: d,
|
|
194
194
|
readOnly: n,
|
|
195
195
|
notched: !0
|
|
196
196
|
}),
|
|
197
197
|
children: /* @__PURE__ */ o("legend", {
|
|
198
|
-
className: vt(
|
|
199
|
-
children: /* @__PURE__ */
|
|
198
|
+
className: vt(w),
|
|
199
|
+
children: /* @__PURE__ */ b("span", {
|
|
200
200
|
className: "inline-block px-[5px]",
|
|
201
|
-
children: [r,
|
|
201
|
+
children: [r, v && " *"]
|
|
202
202
|
})
|
|
203
203
|
})
|
|
204
204
|
}) : /* @__PURE__ */ o("div", {
|
|
205
205
|
"aria-hidden": !0,
|
|
206
|
-
className:
|
|
207
|
-
focused:
|
|
208
|
-
error:
|
|
206
|
+
className: se({
|
|
207
|
+
focused: I,
|
|
208
|
+
error: p,
|
|
209
209
|
disabled: d,
|
|
210
210
|
readOnly: n,
|
|
211
211
|
notched: !1
|
|
212
212
|
})
|
|
213
213
|
})
|
|
214
214
|
]
|
|
215
|
-
}),
|
|
216
|
-
htmlFor:
|
|
217
|
-
className:
|
|
218
|
-
shrink:
|
|
219
|
-
focused:
|
|
220
|
-
error:
|
|
215
|
+
}), R && /* @__PURE__ */ b("label", {
|
|
216
|
+
htmlFor: z,
|
|
217
|
+
className: s(Lt({
|
|
218
|
+
shrink: w,
|
|
219
|
+
focused: I,
|
|
220
|
+
error: p,
|
|
221
221
|
disabled: d,
|
|
222
222
|
readOnly: n,
|
|
223
|
-
size:
|
|
223
|
+
size: Ne
|
|
224
224
|
}), t?.inputLabel?.className),
|
|
225
225
|
style: {
|
|
226
|
-
...
|
|
226
|
+
...F(t?.inputLabel?.sx),
|
|
227
227
|
...t?.inputLabel?.style,
|
|
228
|
-
...St(
|
|
228
|
+
...St(w)
|
|
229
229
|
},
|
|
230
|
-
children: [r,
|
|
230
|
+
children: [r, v && " *"]
|
|
231
231
|
})]
|
|
232
232
|
}),
|
|
233
|
-
P &&
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
message: E,
|
|
240
|
-
hideErrorIcon: t?.formHelperText?.hideErrorIcon,
|
|
241
|
-
className: l("box-border min-w-0 flex-1 items-start", t?.formHelperText?.className),
|
|
242
|
-
style: v(t?.formHelperText?.sx)
|
|
243
|
-
}), /* @__PURE__ */ o(gt, {
|
|
244
|
-
id: te,
|
|
245
|
-
length: Ze,
|
|
246
|
-
limit: R,
|
|
247
|
-
locale: Le,
|
|
248
|
-
className: "ml-auto shrink-0 whitespace-nowrap pt-1"
|
|
249
|
-
})]
|
|
250
|
-
}) : _ && /* @__PURE__ */ o(re, {
|
|
251
|
-
ref: dt,
|
|
252
|
-
id: W,
|
|
253
|
-
role: oe,
|
|
254
|
-
error: h,
|
|
255
|
-
message: E,
|
|
233
|
+
P && /* @__PURE__ */ o(gt, {
|
|
234
|
+
ref: rt,
|
|
235
|
+
id: Q,
|
|
236
|
+
role: at,
|
|
237
|
+
error: p,
|
|
238
|
+
message: K,
|
|
256
239
|
hideErrorIcon: t?.formHelperText?.hideErrorIcon,
|
|
257
|
-
className:
|
|
240
|
+
className: s("mr-[14px] box-border items-start", t?.formHelperText?.className),
|
|
258
241
|
style: {
|
|
259
|
-
...
|
|
260
|
-
...
|
|
242
|
+
...dt,
|
|
243
|
+
...F(t?.formHelperText?.sx)
|
|
261
244
|
}
|
|
262
|
-
})
|
|
245
|
+
}),
|
|
246
|
+
te && N ? /* @__PURE__ */ o(pt, {
|
|
247
|
+
id: ee,
|
|
248
|
+
length: Ve,
|
|
249
|
+
limit: N,
|
|
250
|
+
locale: be,
|
|
251
|
+
className: "pt-1"
|
|
252
|
+
}) : null
|
|
263
253
|
]
|
|
264
254
|
});
|
|
265
255
|
};
|
|
@@ -1,72 +1,71 @@
|
|
|
1
|
-
import { CharacterCounter as
|
|
2
|
-
import { useHelperSlot as
|
|
3
|
-
import { fieldWidthStyle as
|
|
1
|
+
import { CharacterCounter as U } from "../../../helpers/CharacterCounter.js";
|
|
2
|
+
import { useHelperSlot as V } from "../../../helpers/useHelperSlot.js";
|
|
3
|
+
import { fieldWidthStyle as X } from "../field-styles.js";
|
|
4
4
|
import t from "./StyledTextarea.module.js";
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { jsx as e, jsxs as
|
|
7
|
-
var
|
|
8
|
-
const q =
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const K =
|
|
15
|
-
|
|
5
|
+
import { useEffect as Y, useId as x, useRef as Z } from "react";
|
|
6
|
+
import { jsx as e, jsxs as L } from "react/jsx-runtime";
|
|
7
|
+
var it = ({ id: F, variant: s = "active", label: d = "", labelClassName: M = "", description: n = "", reserveHelperText: B, value: o = "", minRows: i = 3, maxRows: r = 1 / 0, disabled: y, error: a, errorMessage: _, containerClassName: j = "", className: w = "", maxLength: c = 1 / 0, counter: C, refLink: E, dataTest: k, counterLimit: R, width: g = "full", locale: W, ...f }) => {
|
|
8
|
+
const q = Z(null), p = E ?? q, m = R ?? (Number.isFinite(c) ? c : void 0), h = C !== !1 && !!m, b = x(), $ = x(), z = x(), v = F ?? z, I = a ? _ : n, { show: N, role: D } = V("StyledTextarea", a, I, B);
|
|
9
|
+
Y(() => {
|
|
10
|
+
const l = p.current;
|
|
11
|
+
if (!l) return;
|
|
12
|
+
const u = window.getComputedStyle(l), T = parseFloat(u.lineHeight) || 24, H = parseFloat(u.paddingTop), A = parseFloat(u.paddingBottom);
|
|
13
|
+
l.style.height = "auto";
|
|
14
|
+
const K = l.scrollHeight - H - A, O = Math.max(1, Math.ceil(K / T)), Q = Math.min(Math.max(O, i), r);
|
|
15
|
+
l.style.height = `${Q * T + H + A}px`;
|
|
16
16
|
}, [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
r,
|
|
17
|
+
p,
|
|
18
|
+
o,
|
|
20
19
|
i,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
r,
|
|
21
|
+
h
|
|
22
|
+
]), r < i && (i = r);
|
|
23
|
+
const G = a ? "error" : "active", S = a ? "error" : y ? "disabled" : "active", J = typeof d != "string" || d.trim() !== "" ? void 0 : typeof n == "string" && n.trim() !== "" ? n : f.placeholder;
|
|
24
|
+
return /* @__PURE__ */ L("div", {
|
|
25
25
|
className: `relative flex flex-col gap-1 ${j}`,
|
|
26
26
|
"data-testid": k,
|
|
27
|
-
"data-field-width":
|
|
28
|
-
style:
|
|
27
|
+
"data-field-width": g,
|
|
28
|
+
style: X(g),
|
|
29
29
|
children: [
|
|
30
30
|
/* @__PURE__ */ e("label", {
|
|
31
|
-
htmlFor:
|
|
31
|
+
htmlFor: v,
|
|
32
32
|
className: `${t.label} ${t[S]} ${M}`,
|
|
33
|
-
children:
|
|
33
|
+
children: d
|
|
34
34
|
}),
|
|
35
35
|
N && /* @__PURE__ */ e("span", {
|
|
36
|
-
id:
|
|
36
|
+
id: b,
|
|
37
37
|
role: D,
|
|
38
38
|
className: `${t.description} ${t[S]} min-h-[24px]`,
|
|
39
39
|
children: I
|
|
40
40
|
}),
|
|
41
|
-
|
|
41
|
+
s === "view_only" ? /* @__PURE__ */ e("div", {
|
|
42
42
|
className: "pt-3 font-roboto text-base font-normal text-delta-700",
|
|
43
|
-
children:
|
|
44
|
-
}) :
|
|
43
|
+
children: o
|
|
44
|
+
}) : s === "not_editable" ? /* @__PURE__ */ e("div", {
|
|
45
45
|
className: "rounded bg-delta-50 p-3 font-roboto text-base font-normal text-delta-700",
|
|
46
|
-
children:
|
|
46
|
+
children: o
|
|
47
47
|
}) : /* @__PURE__ */ e("textarea", {
|
|
48
|
-
...
|
|
49
|
-
"aria-describedby": [N ?
|
|
50
|
-
"aria-invalid":
|
|
51
|
-
"aria-label":
|
|
52
|
-
id:
|
|
53
|
-
ref:
|
|
48
|
+
...f,
|
|
49
|
+
"aria-describedby": [N ? b : null, h ? $ : null].filter(Boolean).join(" ") || void 0,
|
|
50
|
+
"aria-invalid": a,
|
|
51
|
+
"aria-label": f["aria-label"] ?? J,
|
|
52
|
+
id: v,
|
|
53
|
+
ref: p,
|
|
54
54
|
className: `${t.textarea} ${t[G]} ${w}`,
|
|
55
55
|
wrap: "soft",
|
|
56
|
-
value:
|
|
57
|
-
disabled:
|
|
58
|
-
maxLength:
|
|
56
|
+
value: o,
|
|
57
|
+
disabled: y,
|
|
58
|
+
maxLength: c
|
|
59
59
|
}),
|
|
60
|
-
|
|
61
|
-
id:
|
|
62
|
-
length:
|
|
63
|
-
limit:
|
|
64
|
-
locale: W
|
|
65
|
-
|
|
66
|
-
})
|
|
60
|
+
h && m && s === "active" ? /* @__PURE__ */ e(U, {
|
|
61
|
+
id: $,
|
|
62
|
+
length: o.length,
|
|
63
|
+
limit: m,
|
|
64
|
+
locale: W
|
|
65
|
+
}) : null
|
|
67
66
|
]
|
|
68
67
|
});
|
|
69
68
|
};
|
|
70
69
|
export {
|
|
71
|
-
|
|
70
|
+
it as StyledTextarea
|
|
72
71
|
};
|