asma-ui-core 3.53.1 → 3.54.1
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,15 +1,15 @@
|
|
|
1
1
|
import { cn as l } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import { ErrorOutlineIcon as
|
|
5
|
-
import { floatingLabelClass as
|
|
2
|
+
import { resolveSx as E } from "../../../helpers/sx.js";
|
|
3
|
+
import { CloseIcon as je } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { ErrorOutlineIcon as ze } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
|
|
5
|
+
import { floatingLabelClass as Ke, floatingLabelLayoutStyle as Ue, notchedLegendClass as Ve, notchedOutlineClass as J, singleLineInputLayoutStyle as We, singleLineShellLayoutStyle as Ye } from "../field-styles.js";
|
|
6
6
|
import y from "./StyledInputField.module.js";
|
|
7
|
-
import { Children as
|
|
7
|
+
import { Children as Ge, useCallback as Je, useId as Qe, useLayoutEffect as Q, useRef as X, useState as k } from "react";
|
|
8
8
|
import { jsx as i, jsxs as m } from "react/jsx-runtime";
|
|
9
9
|
import { useMergeRefs as Z } from "@floating-ui/react";
|
|
10
|
-
var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlur: O, onFocus: ee, error: o, helperText: L, disabled: s, readOnly: n, required: v, allowClear: te, onClear: ne, type: ie = "text", placeholder: oe, name: ae, id: le, autoComplete: se, autoFocus: de, multiline: d, rows: A, minRows: I, maxRows: C, size: re = "medium", fullWidth: ce, className: he, style: me, sx: pe, inputRef: ue, slotProps: t, InputProps:
|
|
11
|
-
const fe =
|
|
12
|
-
n || (
|
|
10
|
+
var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlur: O, onFocus: ee, error: o, helperText: L, disabled: s, readOnly: n, required: v, allowClear: te, onClear: ne, type: ie = "text", placeholder: oe, name: ae, id: le, autoComplete: se, autoFocus: de, multiline: d, rows: A, minRows: I, maxRows: C, size: re = "medium", fullWidth: ce, className: he, style: me, sx: pe, inputRef: ue, slotProps: t, InputProps: D, onKeyDown: T, onClick: ge, variant: Xe }) => {
|
|
11
|
+
const fe = Qe(), _ = le ?? fe, P = `${_}-helper-text`, $ = X(null), j = X(null), [xe, be] = k(void 0), [H, z] = k(!1), [ye, K] = k(S != null && S !== ""), R = u !== void 0, U = R ? u !== "" && u != null : ye, Se = !!s || !!n, w = t?.input?.startAdornment ?? D?.startAdornment, g = Ge.count(w) > 0, r = g && Array.isArray(w), f = t?.input?.endAdornment ?? D?.endAdornment, M = !!(te && U && !Se), { ref: Le, ...c } = t?.htmlInput ?? {}, Ie = ue ?? Le, { className: He, style: B, ref: Ne } = t?.input ?? {}, ve = Z([Ne]), Ae = t?.input?.onMouseDown, N = H || U || g, Ce = (e) => {
|
|
12
|
+
n || (R || K(e.target.value !== ""), q?.(e));
|
|
13
13
|
}, _e = (e) => {
|
|
14
14
|
!s && !n && z(!0), ee?.(e);
|
|
15
15
|
}, Re = (e) => {
|
|
@@ -19,8 +19,8 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
19
19
|
const e = $.current;
|
|
20
20
|
if (!d || A != null || !e) return;
|
|
21
21
|
e.style.height = "auto";
|
|
22
|
-
const h = getComputedStyle(e), b = Number.parseFloat(h.lineHeight) || 24, G = Number.parseFloat(h.paddingTop) + Number.parseFloat(h.paddingBottom),
|
|
23
|
-
e.style.height = `${Math.min(
|
|
22
|
+
const h = getComputedStyle(e), b = Number.parseFloat(h.lineHeight) || 24, G = Number.parseFloat(h.paddingTop) + Number.parseFloat(h.paddingBottom), Pe = I ? I * b + G : 0, $e = C ? C * b + G : Number.POSITIVE_INFINITY;
|
|
23
|
+
e.style.height = `${Math.min($e, Math.max(Pe, e.scrollHeight))}px`;
|
|
24
24
|
}, [
|
|
25
25
|
S,
|
|
26
26
|
C,
|
|
@@ -29,32 +29,33 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
29
29
|
A,
|
|
30
30
|
u
|
|
31
31
|
]);
|
|
32
|
-
const V = Z([Ie,
|
|
32
|
+
const V = Z([Ie, Je((e) => {
|
|
33
33
|
$.current = e instanceof HTMLTextAreaElement ? e : null;
|
|
34
|
-
}, [])]), { style:
|
|
34
|
+
}, [])]), { style: F, ...we } = c, x = !d && !r, { height: Ze, minHeight: qe, maxHeight: Oe, paddingTop: et, paddingBottom: tt, ...Me } = B ?? {}, Be = x ? {
|
|
35
35
|
...Me,
|
|
36
|
-
...
|
|
36
|
+
...Ye()
|
|
37
37
|
} : r ? {
|
|
38
38
|
boxSizing: "border-box",
|
|
39
39
|
minHeight: 40,
|
|
40
|
-
...
|
|
41
|
-
} :
|
|
40
|
+
...B
|
|
41
|
+
} : B, { height: nt, minHeight: it, maxHeight: ot, paddingTop: at, paddingBottom: lt, paddingLeft: st, paddingRight: Fe, ...Ee } = F ?? {}, ke = x ? {
|
|
42
42
|
...Ee,
|
|
43
|
-
...
|
|
43
|
+
...We({
|
|
44
44
|
paddingLeft: g ? 40 : 14,
|
|
45
|
-
paddingRight: Fe ?? xe ?? (
|
|
45
|
+
paddingRight: Fe ?? xe ?? (M || f ? 40 : 14)
|
|
46
46
|
})
|
|
47
|
-
} :
|
|
47
|
+
} : F;
|
|
48
48
|
Q(() => {
|
|
49
49
|
if (!x) return;
|
|
50
50
|
const e = j.current, h = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
|
|
51
51
|
be((b) => b === h ? b : h);
|
|
52
52
|
});
|
|
53
|
-
const W = {
|
|
53
|
+
const De = N || !a, W = {
|
|
54
54
|
...we,
|
|
55
|
-
style: x ? ke :
|
|
55
|
+
style: x ? ke : F,
|
|
56
|
+
id: c.id ?? _,
|
|
56
57
|
name: ae,
|
|
57
|
-
placeholder:
|
|
58
|
+
placeholder: De ? oe : void 0,
|
|
58
59
|
disabled: s,
|
|
59
60
|
readOnly: n,
|
|
60
61
|
required: v,
|
|
@@ -68,12 +69,12 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
68
69
|
onChange: Ce,
|
|
69
70
|
onFocus: _e,
|
|
70
71
|
onBlur: Re,
|
|
71
|
-
onKeyDown: c.onKeyDown ||
|
|
72
|
-
|
|
72
|
+
onKeyDown: c.onKeyDown || T ? (e) => {
|
|
73
|
+
T?.(e), e.defaultPrevented || c.onKeyDown?.(e);
|
|
73
74
|
} : void 0
|
|
74
|
-
}, Y = l(y.Input, "peer border-0 bg-transparent text-base tracking-[0.00938em] text-delta-800 outline-none placeholder:text-delta-500", r ? "box-border h-8 min-w-[60px] flex-1 py-0 pl-0 pr-0 leading-[23px]" : d ? "w-full resize-none overflow-hidden p-0 pl-0 pr-0 leading-[23px]" : l("w-full", y["Input--singleLine"]), "disabled:text-delta-300", n && "text-delta-800", He),
|
|
75
|
+
}, Y = l(y.Input, "peer border-0 bg-transparent text-base tracking-[0.00938em] text-delta-800 outline-none placeholder:text-delta-500", r ? "box-border h-8 min-w-[60px] flex-1 py-0 pl-0 pr-0 leading-[23px]" : d ? "w-full resize-none overflow-hidden p-0 pl-0 pr-0 leading-[23px]" : l("w-full", y["Input--singleLine"]), "disabled:text-delta-300", n && "text-delta-800", He), Te = !d && !r ? {
|
|
75
76
|
"data-start-adornment": g ? "true" : void 0,
|
|
76
|
-
"data-end-adornment":
|
|
77
|
+
"data-end-adornment": M || f ? "true" : void 0
|
|
77
78
|
} : {};
|
|
78
79
|
return /* @__PURE__ */ m("div", {
|
|
79
80
|
className: l("group relative inline-flex flex-col", he),
|
|
@@ -82,7 +83,7 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
82
83
|
width: ce ? "100%" : 235,
|
|
83
84
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
84
85
|
letterSpacing: "0.00938em",
|
|
85
|
-
...
|
|
86
|
+
...E(pe),
|
|
86
87
|
...me
|
|
87
88
|
},
|
|
88
89
|
children: [/* @__PURE__ */ m("div", {
|
|
@@ -96,7 +97,7 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
96
97
|
children: [
|
|
97
98
|
g && /* @__PURE__ */ i("span", {
|
|
98
99
|
className: l("items-center text-delta-500", r ? "contents" : "absolute left-3 flex"),
|
|
99
|
-
children:
|
|
100
|
+
children: w
|
|
100
101
|
}),
|
|
101
102
|
d ? /* @__PURE__ */ i("textarea", {
|
|
102
103
|
...W,
|
|
@@ -106,21 +107,21 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
106
107
|
className: Y
|
|
107
108
|
}) : /* @__PURE__ */ i("input", {
|
|
108
109
|
...W,
|
|
109
|
-
...
|
|
110
|
+
...Te,
|
|
110
111
|
ref: V,
|
|
111
112
|
"data-testid": p,
|
|
112
113
|
type: ie,
|
|
113
114
|
className: Y
|
|
114
115
|
}),
|
|
115
|
-
|
|
116
|
+
M ? /* @__PURE__ */ i("button", {
|
|
116
117
|
type: "button",
|
|
117
118
|
"aria-label": "Clear",
|
|
118
119
|
"data-testid": `${p}-clear`,
|
|
119
120
|
className: "absolute right-4 z-40 flex items-center justify-center rounded-full border-0 bg-transparent p-[2px] duration-300 hover:bg-gama-100",
|
|
120
121
|
onClick: (e) => {
|
|
121
|
-
e.stopPropagation(), e.preventDefault(),
|
|
122
|
+
e.stopPropagation(), e.preventDefault(), R || K(!1), ne?.();
|
|
122
123
|
},
|
|
123
|
-
children: /* @__PURE__ */ i(
|
|
124
|
+
children: /* @__PURE__ */ i(je, {
|
|
124
125
|
width: 18,
|
|
125
126
|
height: 18
|
|
126
127
|
})
|
|
@@ -139,7 +140,7 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
139
140
|
notched: !0
|
|
140
141
|
}),
|
|
141
142
|
children: /* @__PURE__ */ i("legend", {
|
|
142
|
-
className:
|
|
143
|
+
className: Ve(N),
|
|
143
144
|
children: /* @__PURE__ */ m("span", {
|
|
144
145
|
className: "inline-block px-[5px]",
|
|
145
146
|
children: [a, v && " *"]
|
|
@@ -157,8 +158,8 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
157
158
|
})
|
|
158
159
|
]
|
|
159
160
|
}), a && /* @__PURE__ */ m("label", {
|
|
160
|
-
htmlFor:
|
|
161
|
-
className: l(
|
|
161
|
+
htmlFor: _,
|
|
162
|
+
className: l(Ke({
|
|
162
163
|
shrink: N,
|
|
163
164
|
focused: H,
|
|
164
165
|
error: o,
|
|
@@ -167,17 +168,17 @@ var bt = ({ dataTest: p, label: a, value: u, defaultValue: S, onChange: q, onBlu
|
|
|
167
168
|
size: re
|
|
168
169
|
}), t?.inputLabel?.className),
|
|
169
170
|
style: {
|
|
170
|
-
...
|
|
171
|
+
...E(t?.inputLabel?.sx),
|
|
171
172
|
...t?.inputLabel?.style,
|
|
172
|
-
...
|
|
173
|
+
...Ue(N)
|
|
173
174
|
},
|
|
174
175
|
children: [a, v && " *"]
|
|
175
176
|
})]
|
|
176
177
|
}), !n && (L != null || o) && /* @__PURE__ */ m("div", {
|
|
177
178
|
id: P,
|
|
178
179
|
className: l(!t?.formHelperText && "mr-[14px] box-border min-h-[24px] pt-1", o && !t?.formHelperText?.hideErrorIcon && "flex items-start gap-1 text-error-500", !o && "text-delta-600", t?.formHelperText?.className),
|
|
179
|
-
style:
|
|
180
|
-
children: [o && !t?.formHelperText?.hideErrorIcon && /* @__PURE__ */ i(
|
|
180
|
+
style: E(t?.formHelperText?.sx),
|
|
181
|
+
children: [o && !t?.formHelperText?.hideErrorIcon && /* @__PURE__ */ i(ze, {
|
|
181
182
|
width: 20,
|
|
182
183
|
height: 20,
|
|
183
184
|
className: "min-w-5 shrink-0"
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { TOP_LAYER_PROPS as
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { FloatingPortal as
|
|
7
|
-
var
|
|
1
|
+
import { cn as O } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as c } from "../../../helpers/sx.js";
|
|
3
|
+
import { TOP_LAYER_PROPS as L, TOP_LAYER_RESET_STYLE as M, getOpenModalDialogAncestor as z, useTopLayerRef as D } from "../../../hooks/useTopLayer.hook.js";
|
|
4
|
+
import { useEffect as N, useMemo as k, useState as d } from "react";
|
|
5
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
6
|
+
import { FloatingPortal as C, autoUpdate as U, flip as Y, offset as H, shift as K, useDismiss as $, useFloating as j, useInteractions as I, useMergeRefs as q } from "@floating-ui/react";
|
|
7
|
+
var B = {
|
|
8
8
|
vertical: "bottom",
|
|
9
9
|
horizontal: "left"
|
|
10
|
-
},
|
|
10
|
+
}, G = {
|
|
11
11
|
vertical: "top",
|
|
12
12
|
horizontal: "left"
|
|
13
|
-
},
|
|
14
|
-
const
|
|
15
|
-
e && !
|
|
16
|
-
const
|
|
13
|
+
}, J = (e, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, te = ({ open: e, anchorEl: o, onClose: m, anchorOrigin: l = B, transformOrigin: n = G, id: v, className: g, sx: h, slotProps: r, onClick: y, children: R, keepMounted: P = !1 }) => {
|
|
14
|
+
const _ = k(() => J(l, n), [l, n]), [p, x] = d(e);
|
|
15
|
+
e && !p && x(!0);
|
|
16
|
+
const a = e || P && p, s = z(o), [f, w] = d(s);
|
|
17
|
+
o && f !== s && w(s);
|
|
18
|
+
const { refs: i, floatingStyles: S, context: T } = j({
|
|
17
19
|
open: e,
|
|
18
|
-
placement:
|
|
20
|
+
placement: _,
|
|
19
21
|
strategy: "fixed",
|
|
20
|
-
whileElementsMounted:
|
|
22
|
+
whileElementsMounted: U,
|
|
21
23
|
elements: { reference: o ?? void 0 },
|
|
22
24
|
middleware: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
H(4),
|
|
26
|
+
Y({ padding: 8 }),
|
|
27
|
+
K({ padding: 8 })
|
|
26
28
|
],
|
|
27
|
-
onOpenChange: (t,
|
|
28
|
-
t ||
|
|
29
|
+
onOpenChange: (t, E, F) => {
|
|
30
|
+
t || m?.(E ?? {}, F === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
29
31
|
}
|
|
30
|
-
}), { getFloatingProps:
|
|
32
|
+
}), { getFloatingProps: b } = I([$(T, {
|
|
31
33
|
outsidePress: !0,
|
|
32
34
|
escapeKey: !0
|
|
33
|
-
})]),
|
|
34
|
-
return
|
|
35
|
-
if (!
|
|
36
|
-
const t =
|
|
35
|
+
})]), A = q([D(i.setFloating)]);
|
|
36
|
+
return N(() => {
|
|
37
|
+
if (!a) return;
|
|
38
|
+
const t = i.floating.current;
|
|
37
39
|
if (!(!t || typeof t.showPopover != "function"))
|
|
38
40
|
try {
|
|
39
41
|
e && !t.matches(":popover-open") && t.showPopover(), !e && t.matches(":popover-open") && t.hidePopover();
|
|
@@ -41,28 +43,28 @@ var I = {
|
|
|
41
43
|
}
|
|
42
44
|
}, [
|
|
43
45
|
e,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
]),
|
|
47
|
-
root:
|
|
48
|
-
children: /* @__PURE__ */
|
|
49
|
-
ref:
|
|
50
|
-
id:
|
|
51
|
-
...
|
|
46
|
+
a,
|
|
47
|
+
i.floating
|
|
48
|
+
]), a ? /* @__PURE__ */ u(C, {
|
|
49
|
+
root: f,
|
|
50
|
+
children: /* @__PURE__ */ u("div", {
|
|
51
|
+
ref: A,
|
|
52
|
+
id: v,
|
|
53
|
+
...L,
|
|
52
54
|
style: {
|
|
53
|
-
...
|
|
54
|
-
...e ?
|
|
55
|
-
...
|
|
56
|
-
...
|
|
57
|
-
...
|
|
55
|
+
...M,
|
|
56
|
+
...e ? S : {},
|
|
57
|
+
...c(h),
|
|
58
|
+
...c(r?.paper?.sx),
|
|
59
|
+
...r?.paper?.style,
|
|
58
60
|
...e ? null : { display: "none" }
|
|
59
61
|
},
|
|
60
|
-
...e ?
|
|
61
|
-
className:
|
|
62
|
-
children:
|
|
62
|
+
...e ? b({ onClick: y }) : {},
|
|
63
|
+
className: O("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", g ?? "my-1", r?.paper?.className),
|
|
64
|
+
children: R
|
|
63
65
|
})
|
|
64
66
|
}) : null;
|
|
65
67
|
};
|
|
66
68
|
export {
|
|
67
|
-
|
|
69
|
+
te as StyledPopover
|
|
68
70
|
};
|