asma-ui-core 3.101.7 → 3.102.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.
|
@@ -1,204 +1,231 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import { HelperRow as
|
|
5
|
-
import { useHelperRowBudget as
|
|
6
|
-
import { useHelperSlot as
|
|
7
|
-
import { floatingLabelClass as
|
|
8
|
-
import
|
|
9
|
-
import { Children as
|
|
10
|
-
import { jsx as
|
|
11
|
-
import { useMergeRefs as
|
|
12
|
-
var
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { cn as r } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as P } from "../../../helpers/sx.js";
|
|
3
|
+
import { CloseIcon as tt } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { HelperRow as nt } from "../../../helpers/HelperRow.js";
|
|
5
|
+
import { useHelperRowBudget as ot } from "../../../helpers/useHelperRowBudget.js";
|
|
6
|
+
import { useHelperSlot as it } from "../../../helpers/useHelperSlot.js";
|
|
7
|
+
import { floatingLabelClass as st, floatingLabelLayoutStyle as lt, notchedLegendClass as rt, notchedOutlineClass as ne, singleLineInputLayoutStyle as at, singleLineShellLayoutStyle as dt } from "../field-styles.js";
|
|
8
|
+
import g from "./StyledInputField.module.js";
|
|
9
|
+
import { Children as ct, useCallback as oe, useId as ut, useLayoutEffect as A, useRef as z, useState as $ } from "react";
|
|
10
|
+
import { jsx as s, jsxs as S } from "react/jsx-runtime";
|
|
11
|
+
import { useMergeRefs as ie } from "@floating-ui/react";
|
|
12
|
+
var Tt = ({ dataTest: x, label: a, value: b, defaultValue: v, onChange: se, onBlur: le, onFocus: re, error: m, helperText: j, reserveHelperText: ae, expandHelperText: de = !0, disabled: c, readOnly: t, required: N, allowClear: ce, onClear: ue, type: pe = "text", placeholder: me, name: he, id: fe, autoComplete: ge, autoFocus: xe, multiline: o, rows: L, minRows: C, maxRows: w, size: be = "medium", fullWidth: W, className: ye, style: Se, sx: ve, inputRef: Le, slotProps: n, InputProps: K, onKeyDown: U, onClick: He, variant: pt }) => {
|
|
13
|
+
const Ie = ut(), F = fe ?? Ie, V = `${F}-helper-text`, _ = z(null), M = z(0), Y = z(null), [Re, Ae] = $(void 0), [H, G] = $(!1), [Ne, J] = $(v != null && v !== ""), B = b !== void 0, Q = B ? b !== "" && b != null : Ne, Ce = !!c || !!t, k = n?.input?.startAdornment ?? K?.startAdornment, y = ct.count(k) > 0, u = y && Array.isArray(k), h = n?.input?.endAdornment ?? K?.endAdornment, I = !!(ce && Q && !Ce), { ref: we, ...l } = n?.htmlInput ?? {}, Fe = Le ?? we, { className: _e, style: E, ref: Me } = n?.input ?? {}, Be = ie([Me]), ke = n?.input?.onMouseDown, X = n?.input?.onClick, Ee = X ? { onClick: X } : {}, Te = ge ?? l.autoComplete, De = he ?? l.name, R = H || Q || y, p = oe(() => {
|
|
14
|
+
const e = _.current;
|
|
15
|
+
if (!(!o || !e) && (M.current = e.offsetWidth, M.current !== 0)) {
|
|
16
|
+
if (e.removeAttribute("data-scrollable"), L != null && !t) e.style.height = "";
|
|
17
|
+
else {
|
|
18
|
+
if (e.style.height = "auto", e.scrollHeight === 0) {
|
|
19
|
+
e.style.height = "";
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const i = getComputedStyle(e), d = Number.parseFloat(i.lineHeight) || 24, ee = Number.parseFloat(i.paddingTop) + Number.parseFloat(i.paddingBottom), te = L ?? C, Oe = te ? te * d + ee : 0, et = t || !w ? Number.POSITIVE_INFINITY : w * d + ee;
|
|
23
|
+
e.style.height = `${Math.min(et, Math.max(Oe, e.scrollHeight))}px`;
|
|
24
|
+
}
|
|
25
|
+
e.scrollHeight > e.clientHeight + 1 && e.setAttribute("data-scrollable", "true");
|
|
26
|
+
}
|
|
26
27
|
}, [
|
|
27
|
-
|
|
28
|
-
R,
|
|
29
|
-
H,
|
|
30
|
-
r,
|
|
28
|
+
w,
|
|
31
29
|
C,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
30
|
+
o,
|
|
31
|
+
t,
|
|
32
|
+
L
|
|
33
|
+
]), Pe = (e) => {
|
|
34
|
+
t || (B || (J(e.target.value !== ""), p()), se?.(e));
|
|
35
|
+
}, ze = (e) => {
|
|
36
|
+
!c && !t && G(!0), re?.(e);
|
|
37
|
+
}, $e = (e) => {
|
|
38
|
+
!c && !t && G(!1), le?.(e);
|
|
39
|
+
};
|
|
40
|
+
A(() => {
|
|
41
|
+
p();
|
|
42
|
+
}, [
|
|
43
|
+
p,
|
|
44
|
+
v,
|
|
45
|
+
b
|
|
46
|
+
]), A(() => {
|
|
47
|
+
if (!o || !document.fonts) return;
|
|
48
|
+
const e = () => p();
|
|
49
|
+
return document.fonts.addEventListener("loadingdone", e), () => document.fonts.removeEventListener("loadingdone", e);
|
|
50
|
+
}, [o, p]), A(() => {
|
|
51
|
+
const e = _.current;
|
|
52
|
+
if (!o || !e || typeof ResizeObserver > "u") return;
|
|
53
|
+
let i = 0;
|
|
54
|
+
const d = new ResizeObserver(() => {
|
|
55
|
+
e.offsetWidth !== M.current && (cancelAnimationFrame(i), i = requestAnimationFrame(p));
|
|
56
|
+
});
|
|
57
|
+
return d.observe(e), () => {
|
|
58
|
+
cancelAnimationFrame(i), d.disconnect();
|
|
59
|
+
};
|
|
60
|
+
}, [o, p]);
|
|
61
|
+
const Z = ie([Fe, oe((e) => {
|
|
62
|
+
_.current = e instanceof HTMLTextAreaElement ? e : null;
|
|
63
|
+
}, [])]), { style: T, ...je } = l, f = !o && !u, { height: mt, minHeight: ht, maxHeight: ft, paddingTop: gt, paddingBottom: xt, ...We } = E ?? {}, Ke = f ? {
|
|
64
|
+
...We,
|
|
65
|
+
...dt()
|
|
66
|
+
} : u ? {
|
|
40
67
|
boxSizing: "border-box",
|
|
41
68
|
minHeight: 40,
|
|
42
|
-
...
|
|
43
|
-
} :
|
|
44
|
-
...
|
|
45
|
-
...
|
|
46
|
-
paddingLeft:
|
|
47
|
-
paddingRight:
|
|
69
|
+
...E
|
|
70
|
+
} : E, { height: bt, minHeight: yt, maxHeight: St, paddingTop: vt, paddingBottom: Lt, paddingLeft: Ht, paddingRight: Ue, ...Ve } = T ?? {}, Ye = f ? {
|
|
71
|
+
...Ve,
|
|
72
|
+
...at({
|
|
73
|
+
paddingLeft: y ? 40 : 14,
|
|
74
|
+
paddingRight: Ue ?? Re ?? (I || h ? 40 : 14)
|
|
48
75
|
})
|
|
49
|
-
} :
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
const e =
|
|
53
|
-
|
|
76
|
+
} : T;
|
|
77
|
+
A(() => {
|
|
78
|
+
if (!f) return;
|
|
79
|
+
const e = Y.current, i = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
|
|
80
|
+
Ae((d) => d === i ? d : i);
|
|
54
81
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
82
|
+
f,
|
|
83
|
+
I,
|
|
84
|
+
h
|
|
58
85
|
]);
|
|
59
|
-
const
|
|
60
|
-
...
|
|
61
|
-
style:
|
|
62
|
-
id:
|
|
63
|
-
name:
|
|
64
|
-
placeholder:
|
|
65
|
-
disabled:
|
|
66
|
-
readOnly:
|
|
86
|
+
const Ge = R || !a, { show: D, role: Je } = it("StyledInputField", m, j, ae, t), { fieldRef: Qe, rowRef: Xe, rowStyle: Ze } = ot(de && D), q = {
|
|
87
|
+
...je,
|
|
88
|
+
style: f ? Ye : T,
|
|
89
|
+
id: l.id ?? F,
|
|
90
|
+
name: De,
|
|
91
|
+
placeholder: Ge ? me : void 0,
|
|
92
|
+
disabled: c,
|
|
93
|
+
readOnly: t,
|
|
67
94
|
required: N,
|
|
68
|
-
autoComplete:
|
|
69
|
-
autoFocus:
|
|
70
|
-
value:
|
|
71
|
-
defaultValue:
|
|
72
|
-
"aria-invalid":
|
|
73
|
-
"aria-label":
|
|
74
|
-
"aria-describedby":
|
|
75
|
-
onChange:
|
|
76
|
-
onFocus:
|
|
77
|
-
onBlur:
|
|
78
|
-
onKeyDown:
|
|
79
|
-
|
|
95
|
+
autoComplete: Te,
|
|
96
|
+
autoFocus: xe,
|
|
97
|
+
value: b,
|
|
98
|
+
defaultValue: v,
|
|
99
|
+
"aria-invalid": m ? !0 : void 0,
|
|
100
|
+
"aria-label": l["aria-label"] ?? (l["aria-labelledby"] ? void 0 : typeof a == "string" && a !== "" ? a : void 0),
|
|
101
|
+
"aria-describedby": D ? V : l["aria-describedby"],
|
|
102
|
+
onChange: Pe,
|
|
103
|
+
onFocus: ze,
|
|
104
|
+
onBlur: $e,
|
|
105
|
+
onKeyDown: l.onKeyDown || U ? (e) => {
|
|
106
|
+
U?.(e), e.defaultPrevented || l.onKeyDown?.(e);
|
|
80
107
|
} : void 0
|
|
81
|
-
},
|
|
82
|
-
"data-start-adornment":
|
|
83
|
-
"data-end-adornment":
|
|
108
|
+
}, O = r(g.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]" : o ? r("w-full resize-none p-0 pl-0 pr-0 leading-[23px]", g["Input--multiline"]) : r("w-full", g["Input--singleLine"]), "disabled:text-delta-300", t && "text-delta-800", _e), qe = !o && !u ? {
|
|
109
|
+
"data-start-adornment": y ? "true" : void 0,
|
|
110
|
+
"data-end-adornment": I || h ? "true" : void 0
|
|
84
111
|
} : {};
|
|
85
112
|
return /* @__PURE__ */ S("div", {
|
|
86
|
-
ref:
|
|
87
|
-
className:
|
|
88
|
-
onClick:
|
|
113
|
+
ref: Qe,
|
|
114
|
+
className: r("group relative min-w-0 flex-col", ye),
|
|
115
|
+
onClick: He,
|
|
89
116
|
style: {
|
|
90
|
-
display:
|
|
91
|
-
width:
|
|
117
|
+
display: W ? "flex" : "inline-flex",
|
|
118
|
+
width: W ? "100%" : 235,
|
|
92
119
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
93
120
|
letterSpacing: "0.00938em",
|
|
94
|
-
...
|
|
95
|
-
...
|
|
121
|
+
...P(ve),
|
|
122
|
+
...Se
|
|
96
123
|
},
|
|
97
124
|
children: [/* @__PURE__ */ S("div", {
|
|
98
125
|
className: "relative overflow-visible",
|
|
99
126
|
children: [/* @__PURE__ */ S("div", {
|
|
100
|
-
className:
|
|
101
|
-
ref:
|
|
102
|
-
onMouseDown:
|
|
103
|
-
...
|
|
104
|
-
style:
|
|
105
|
-
"data-testid":
|
|
127
|
+
className: r("relative flex", f && g.InputShell, o && "box-border items-center px-[14px] py-[16.5px]", u && r(g.AdornmentList, h && g["AdornmentList--endAdornment"]), t && "rounded bg-delta-50"),
|
|
128
|
+
ref: Be,
|
|
129
|
+
onMouseDown: ke,
|
|
130
|
+
...Ee,
|
|
131
|
+
style: Ke,
|
|
132
|
+
"data-testid": u ? `${x}-adornment-list` : `${x}-shell`,
|
|
106
133
|
children: [
|
|
107
|
-
|
|
108
|
-
className:
|
|
109
|
-
children:
|
|
134
|
+
y && /* @__PURE__ */ s("span", {
|
|
135
|
+
className: r("items-center text-delta-500", u ? "contents" : "absolute left-3 flex"),
|
|
136
|
+
children: k
|
|
110
137
|
}),
|
|
111
|
-
|
|
112
|
-
...
|
|
113
|
-
ref:
|
|
114
|
-
"data-testid":
|
|
115
|
-
rows:
|
|
116
|
-
className:
|
|
117
|
-
}) : /* @__PURE__ */
|
|
118
|
-
...
|
|
119
|
-
...
|
|
120
|
-
ref:
|
|
121
|
-
"data-testid":
|
|
122
|
-
type:
|
|
123
|
-
className:
|
|
138
|
+
o ? /* @__PURE__ */ s("textarea", {
|
|
139
|
+
...q,
|
|
140
|
+
ref: Z,
|
|
141
|
+
"data-testid": x,
|
|
142
|
+
rows: L ?? C ?? 2,
|
|
143
|
+
className: O
|
|
144
|
+
}) : /* @__PURE__ */ s("input", {
|
|
145
|
+
...q,
|
|
146
|
+
...qe,
|
|
147
|
+
ref: Z,
|
|
148
|
+
"data-testid": x,
|
|
149
|
+
type: pe,
|
|
150
|
+
className: O
|
|
124
151
|
}),
|
|
125
|
-
|
|
152
|
+
I ? /* @__PURE__ */ s("button", {
|
|
126
153
|
type: "button",
|
|
127
154
|
tabIndex: -1,
|
|
128
155
|
"aria-label": "Clear",
|
|
129
|
-
"data-testid": `${
|
|
156
|
+
"data-testid": `${x}-clear`,
|
|
130
157
|
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",
|
|
131
158
|
onClick: (e) => {
|
|
132
|
-
e.stopPropagation(), e.preventDefault(),
|
|
159
|
+
e.stopPropagation(), e.preventDefault(), B || J(!1), ue?.();
|
|
133
160
|
},
|
|
134
|
-
children: /* @__PURE__ */
|
|
161
|
+
children: /* @__PURE__ */ s(tt, {
|
|
135
162
|
width: 18,
|
|
136
163
|
height: 18
|
|
137
164
|
})
|
|
138
|
-
}) :
|
|
139
|
-
ref:
|
|
165
|
+
}) : h && /* @__PURE__ */ s("span", {
|
|
166
|
+
ref: Y,
|
|
140
167
|
className: "absolute inset-y-0 right-[14px] flex max-w-[calc(100%-28px)] items-center gap-1",
|
|
141
|
-
children:
|
|
168
|
+
children: h
|
|
142
169
|
}),
|
|
143
|
-
|
|
170
|
+
a ? /* @__PURE__ */ s("fieldset", {
|
|
144
171
|
"aria-hidden": !0,
|
|
145
|
-
className:
|
|
146
|
-
focused:
|
|
147
|
-
error:
|
|
148
|
-
disabled:
|
|
149
|
-
readOnly:
|
|
172
|
+
className: ne({
|
|
173
|
+
focused: H,
|
|
174
|
+
error: m,
|
|
175
|
+
disabled: c,
|
|
176
|
+
readOnly: t,
|
|
150
177
|
notched: !0
|
|
151
178
|
}),
|
|
152
|
-
children: /* @__PURE__ */
|
|
153
|
-
className:
|
|
179
|
+
children: /* @__PURE__ */ s("legend", {
|
|
180
|
+
className: rt(R),
|
|
154
181
|
children: /* @__PURE__ */ S("span", {
|
|
155
182
|
className: "inline-block px-[5px]",
|
|
156
|
-
children: [
|
|
183
|
+
children: [a, N && " *"]
|
|
157
184
|
})
|
|
158
185
|
})
|
|
159
|
-
}) : /* @__PURE__ */
|
|
186
|
+
}) : /* @__PURE__ */ s("div", {
|
|
160
187
|
"aria-hidden": !0,
|
|
161
|
-
className:
|
|
162
|
-
focused:
|
|
163
|
-
error:
|
|
164
|
-
disabled:
|
|
165
|
-
readOnly:
|
|
188
|
+
className: ne({
|
|
189
|
+
focused: H,
|
|
190
|
+
error: m,
|
|
191
|
+
disabled: c,
|
|
192
|
+
readOnly: t,
|
|
166
193
|
notched: !1
|
|
167
194
|
})
|
|
168
195
|
})
|
|
169
196
|
]
|
|
170
|
-
}),
|
|
171
|
-
htmlFor:
|
|
172
|
-
className:
|
|
173
|
-
shrink:
|
|
174
|
-
focused:
|
|
175
|
-
error:
|
|
176
|
-
disabled:
|
|
177
|
-
readOnly:
|
|
178
|
-
size:
|
|
179
|
-
}),
|
|
197
|
+
}), a && /* @__PURE__ */ S("label", {
|
|
198
|
+
htmlFor: F,
|
|
199
|
+
className: r(st({
|
|
200
|
+
shrink: R,
|
|
201
|
+
focused: H,
|
|
202
|
+
error: m,
|
|
203
|
+
disabled: c,
|
|
204
|
+
readOnly: t,
|
|
205
|
+
size: be
|
|
206
|
+
}), n?.inputLabel?.className),
|
|
180
207
|
style: {
|
|
181
|
-
...
|
|
182
|
-
...
|
|
183
|
-
...
|
|
208
|
+
...P(n?.inputLabel?.sx),
|
|
209
|
+
...n?.inputLabel?.style,
|
|
210
|
+
...lt(R)
|
|
184
211
|
},
|
|
185
|
-
children: [
|
|
212
|
+
children: [a, N && " *"]
|
|
186
213
|
})]
|
|
187
|
-
}),
|
|
188
|
-
ref:
|
|
189
|
-
id:
|
|
190
|
-
role:
|
|
191
|
-
error:
|
|
192
|
-
message:
|
|
193
|
-
hideErrorIcon:
|
|
194
|
-
className:
|
|
214
|
+
}), D && /* @__PURE__ */ s(nt, {
|
|
215
|
+
ref: Xe,
|
|
216
|
+
id: V,
|
|
217
|
+
role: Je,
|
|
218
|
+
error: m,
|
|
219
|
+
message: j,
|
|
220
|
+
hideErrorIcon: n?.formHelperText?.hideErrorIcon,
|
|
221
|
+
className: r("mr-[14px] box-border items-start", n?.formHelperText?.className),
|
|
195
222
|
style: {
|
|
196
|
-
...
|
|
197
|
-
...
|
|
223
|
+
...Ze,
|
|
224
|
+
...P(n?.formHelperText?.sx)
|
|
198
225
|
}
|
|
199
226
|
})]
|
|
200
227
|
});
|
|
201
228
|
};
|
|
202
229
|
export {
|
|
203
|
-
|
|
230
|
+
Tt as StyledInputField
|
|
204
231
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
Input:
|
|
3
|
-
InputShell:
|
|
4
|
-
"Input--singleLine": "_Input--
|
|
1
|
+
var t = "_Input_17evt_1", n = "_InputShell_17evt_8", e = "_AdornmentList_17evt_64", _ = {
|
|
2
|
+
Input: t,
|
|
3
|
+
InputShell: n,
|
|
4
|
+
"Input--singleLine": "_Input--singleLine_17evt_17",
|
|
5
|
+
"Input--multiline": "_Input--multiline_17evt_36",
|
|
5
6
|
AdornmentList: e,
|
|
6
|
-
"AdornmentList--endAdornment": "_AdornmentList--
|
|
7
|
+
"AdornmentList--endAdornment": "_AdornmentList--endAdornment_17evt_74"
|
|
7
8
|
};
|
|
8
9
|
export {
|
|
9
10
|
_ as default
|
|
@@ -87,8 +87,9 @@ export interface StyledInputFieldProps {
|
|
|
87
87
|
* own focus/value state to drive the shared field styling ([[field-styles]]); supports multiline,
|
|
88
88
|
* start/end adornments, an optional clear button, and error/helper text. Public props preserved
|
|
89
89
|
*
|
|
90
|
-
* ponytail: `variant` is accepted but always renders outlined
|
|
91
|
-
*
|
|
90
|
+
* ponytail: `variant` is accepted but always renders outlined — a known ceiling; Chromatic in CI is
|
|
91
|
+
* the visual gate. Multiline auto-grows between `minRows` and `maxRows` (a fixed `rows` pins the height)
|
|
92
|
+
* and scrolls once the content exceeds the cap; `readOnly` ignores the cap and shows the whole value.
|
|
92
93
|
*/
|
|
93
94
|
export declare const StyledInputField: ({ dataTest, label, value, defaultValue, onChange, onBlur, onFocus, error, helperText, reserveHelperText, expandHelperText, disabled, readOnly, required, allowClear, onClear, type, placeholder, name, id, autoComplete, autoFocus, multiline, rows, minRows, maxRows, size, fullWidth, className, style, sx, inputRef, slotProps, InputProps, onKeyDown, onClick, variant: _variant, }: StyledInputFieldProps) => JSX.Element;
|
|
94
95
|
export {};
|