asma-ui-core 3.130.0 → 3.130.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.
@@ -9,7 +9,7 @@ import { useHelperRowBudget as _t } from "../../../helpers/useHelperRowBudget.js
9
9
  import { useHelperSlot as At } from "../../../helpers/useHelperSlot.js";
10
10
  import { fieldLabelAboveClass as Ht, fieldWidthStyle as Ct, floatingLabelClass as Rt, floatingLabelLayoutStyle as wt, notchedLegendClass as Ft, notchedOutlineClass as he, singleLineInputLayoutStyle as Bt, singleLineShellLayoutStyle as Mt } from "../field-styles.js";
11
11
  import L from "./StyledInputField.module.js";
12
- import { Children as Et, useCallback as pe, useId as Ot, useLayoutEffect as M, useRef as Y, useState as E } from "react";
12
+ import { Children as Et, useCallback as pe, useId as Ot, useLayoutEffect as M, useRef as J, useState as E } from "react";
13
13
  import { Fragment as Tt, jsx as t, jsxs as f } from "react/jsx-runtime";
14
14
  import { useMergeRefs as me } from "@floating-ui/react";
15
15
  var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_0_0_0_2px_var(--colors-focus-ring)]", Dt = "pointer-events-none absolute -inset-1 rounded peer-focus-visible:shadow-[inset_0_0_0_2px_var(--colors-focus-ring)]", kt = ({ reason: u, children: r }) => u === void 0 ? r : /* @__PURE__ */ t(vt, {
@@ -17,12 +17,12 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
17
17
  openOnTap: !0,
18
18
  persistentDescription: !0,
19
19
  children: r
20
- }), mn = ({ dataTest: u, label: r, labelPlacement: fe = "above", value: x, defaultValue: S, onChange: xe, onBlur: ye, onFocus: be, error: y, helperText: J, reserveHelperText: ve, expandHelperText: Le = !0, maxLength: Se, counter: Ie, locale: Ne, disabled: h, readOnly: _e, lockedReason: O, readOnlyReason: T, required: _, allowClear: Ae, onClear: He, type: Ce = "text", placeholder: Re, name: we, id: Fe, autoComplete: Be, autoFocus: Me, multiline: i, rows: A, minRows: D, maxRows: k, size: Ee = "medium", width: Q = "full", fullWidth: Wt, className: Oe, style: Te, sx: De, inputRef: ke, slotProps: n, InputProps: X, onKeyDown: Z, onClick: We, variant: $t }) => {
21
- const $e = Ot(), W = Fe ?? $e, q = `${W}-helper-text`, $ = Y(null), z = Y(0), ee = Y(null), [ze, Ue] = E(void 0), [H, te] = E(!1), [je, ne] = E(S != null && S !== ""), [Pe, Ke] = E(String(S ?? "").length), c = !!O || O === 0, o = !c && (!!T || T === 0), l = !!_e || c || o, C = x !== void 0, oe = C ? x !== "" && x != null : je, Ge = !!h || !!l, U = n?.input?.startAdornment ?? X?.startAdornment, I = Et.count(U) > 0, m = I && Array.isArray(U), j = n?.input?.endAdornment ?? X?.endAdornment, b = c ? /* @__PURE__ */ f(Tt, { children: [j, /* @__PURE__ */ t(St, {
20
+ }), mn = ({ dataTest: u, label: r, labelPlacement: fe = "above", value: x, defaultValue: S, onChange: xe, onBlur: ye, onFocus: be, error: y, helperText: Q, reserveHelperText: ve, expandHelperText: Le = !0, maxLength: Se, counter: Ie, locale: Ne, disabled: h, readOnly: _e, lockedReason: O, readOnlyReason: T, required: _, allowClear: Ae, onClear: He, type: Ce = "text", placeholder: Re, name: we, id: Fe, autoComplete: Be, autoFocus: Me, multiline: i, rows: A, minRows: D, maxRows: k, size: Ee = "medium", width: X = "full", fullWidth: Wt, className: Oe, style: Te, sx: De, inputRef: ke, slotProps: n, InputProps: Z, onKeyDown: q, onClick: We, variant: $t }) => {
21
+ const $e = Ot(), W = Fe ?? $e, ee = `${W}-helper-text`, $ = J(null), z = J(0), te = J(null), [ze, Ue] = E(void 0), [H, ne] = E(!1), [je, oe] = E(S != null && S !== ""), [Pe, Ke] = E(String(S ?? "").length), c = !!O || O === 0, o = !c && (!!T || T === 0), l = !!_e || c || o, C = x !== void 0, le = C ? x !== "" && x != null : je, Ge = !!h || !!l, U = n?.input?.startAdornment ?? Z?.startAdornment, I = Et.count(U) > 0, m = I && Array.isArray(U), j = n?.input?.endAdornment ?? Z?.endAdornment, b = c ? /* @__PURE__ */ f(Tt, { children: [j, /* @__PURE__ */ t(St, {
22
22
  width: 24,
23
23
  height: 24,
24
24
  className: "text-delta-700"
25
- })] }) : j, N = !!(Ae && oe && !Ge), { ref: Ve, ...s } = n?.htmlInput ?? {}, Ye = ke ?? Ve, { className: Je, style: P, ref: Qe } = n?.input ?? {}, Xe = me([Qe]), Ze = n?.input?.onMouseDown, le = n?.input?.onClick, qe = le ? { onClick: le } : {}, et = Be ?? s.autoComplete, tt = we ?? s.name, K = s.id ?? W, R = Se ?? s.maxLength, ie = `${W}-counter`, ae = Ie !== !1 && !!R && !o, nt = C ? String(x ?? "").length : Pe, w = fe === "floating" && !!r && !o, F = H || oe || I, g = pe(() => {
25
+ })] }) : j, N = !!(Ae && le && !Ge), { ref: Ve, ...s } = n?.htmlInput ?? {}, Ye = ke ?? Ve, { className: Je, style: P, ref: Qe } = n?.input ?? {}, Xe = me([Qe]), Ze = n?.input?.onMouseDown, ie = n?.input?.onClick, qe = ie ? { onClick: ie } : {}, et = Be ?? s.autoComplete, tt = we ?? s.name, K = s.id ?? W, R = Se ?? s.maxLength, ae = `${W}-counter`, G = Ie !== !1 && !!R && !o, nt = C ? String(x ?? "").length : Pe, w = fe === "floating" && !!r && !o, F = H || le || I, g = pe(() => {
26
26
  const e = $.current;
27
27
  if (!(!i || !e) && (z.current = e.offsetWidth, z.current !== 0)) {
28
28
  if (e.removeAttribute("data-scrollable"), A != null && !l) e.style.height = "";
@@ -43,11 +43,11 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
43
43
  l,
44
44
  A
45
45
  ]), ot = (e) => {
46
- l || (C || (ne(e.target.value !== ""), Ke(e.target.value.length), g()), xe?.(e));
46
+ l || (C || (oe(e.target.value !== ""), Ke(e.target.value.length), g()), xe?.(e));
47
47
  }, lt = (e) => {
48
- !h && !l && te(!0), be?.(e);
48
+ !h && !l && ne(!0), be?.(e);
49
49
  }, it = (e) => {
50
- !h && !l && te(!1), ye?.(e);
50
+ !h && !l && ne(!1), ye?.(e);
51
51
  };
52
52
  M(() => {
53
53
  g();
@@ -72,23 +72,23 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
72
72
  }, [i, g]);
73
73
  const re = me([Ye, pe((e) => {
74
74
  $.current = e instanceof HTMLTextAreaElement ? e : null;
75
- }, [])]), { style: G, ...at } = s, v = !i && !m && !o, { height: zt, minHeight: Ut, maxHeight: jt, paddingTop: Pt, paddingBottom: Kt, ...rt } = P ?? {}, st = v ? {
75
+ }, [])]), { style: V, ...at } = s, v = !i && !m && !o, { height: zt, minHeight: Ut, maxHeight: jt, paddingTop: Pt, paddingBottom: Kt, ...rt } = P ?? {}, st = v ? {
76
76
  ...rt,
77
77
  ...Mt()
78
78
  } : m ? {
79
79
  boxSizing: "border-box",
80
80
  minHeight: 40,
81
81
  ...P
82
- } : P, { height: Gt, minHeight: Vt, maxHeight: Yt, paddingTop: Jt, paddingBottom: Qt, paddingLeft: Xt, paddingRight: dt, ...ct } = G ?? {}, ut = v ? {
82
+ } : P, { height: Gt, minHeight: Vt, maxHeight: Yt, paddingTop: Jt, paddingBottom: Qt, paddingLeft: Xt, paddingRight: dt, ...ct } = V ?? {}, ut = v ? {
83
83
  ...ct,
84
84
  ...Bt({
85
85
  paddingLeft: I ? 40 : 14,
86
86
  paddingRight: dt ?? ze ?? (N || b ? 40 : 14)
87
87
  })
88
- } : G;
88
+ } : V;
89
89
  M(() => {
90
90
  if (!v) return;
91
- const e = ee.current, d = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
91
+ const e = te.current, d = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
92
92
  Ue((p) => p === d ? p : d);
93
93
  }, [
94
94
  v,
@@ -96,9 +96,9 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
96
96
  j,
97
97
  c
98
98
  ]);
99
- const ht = F || !w, { show: V, role: pt } = At("StyledInputField", y, J, ve, l), { fieldRef: mt, rowRef: gt, rowStyle: ft } = _t(Le && V), se = {
99
+ const ht = F || !w, { show: Y, role: pt } = At("StyledInputField", y, Q, ve, l, G), { fieldRef: mt, rowRef: gt, rowStyle: ft } = _t(Le && Y), se = {
100
100
  ...at,
101
- style: v ? ut : G,
101
+ style: v ? ut : V,
102
102
  id: K,
103
103
  name: tt,
104
104
  maxLength: R,
@@ -112,12 +112,12 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
112
112
  defaultValue: S,
113
113
  "aria-invalid": y ? !0 : void 0,
114
114
  "aria-label": s["aria-label"] ?? (s["aria-labelledby"] ? void 0 : typeof r == "string" && r !== "" ? r : void 0),
115
- "aria-describedby": [V ? q : s["aria-describedby"], ae ? ie : void 0].filter(Boolean).join(" ") || void 0,
115
+ "aria-describedby": [Y ? ee : s["aria-describedby"], G ? ae : void 0].filter(Boolean).join(" ") || void 0,
116
116
  onChange: ot,
117
117
  onFocus: lt,
118
118
  onBlur: it,
119
- onKeyDown: s.onKeyDown || Z ? (e) => {
120
- Z?.(e), e.defaultPrevented || s.onKeyDown?.(e);
119
+ onKeyDown: s.onKeyDown || q ? (e) => {
120
+ q?.(e), e.defaultPrevented || s.onKeyDown?.(e);
121
121
  } : void 0
122
122
  }, de = a(L.Input, "peer border-0 bg-transparent text-base tracking-[0.00938em] outline-none placeholder:text-delta-500", o ? "text-delta-700" : "text-delta-800", m ? "box-border h-8 min-w-[60px] flex-1 py-0 pl-0 pr-0 leading-[23px]" : i ? a("w-full resize-none p-0 pl-0 pr-0", o ? "leading-6" : "leading-[23px]", L["Input--multiline"]) : o ? "m-0 w-full p-0 text-base leading-6" : a("w-full", L["Input--singleLine"], !N && !b && "max-xs:pr-1.5"), "disabled:text-delta-300", l && !o && "text-delta-800", (c || o) && "cursor-default", Je), xt = !i && !m ? {
123
123
  "data-start-adornment": I ? "true" : void 0,
@@ -127,10 +127,10 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
127
127
  ref: mt,
128
128
  className: a("group relative min-w-0 flex-col", Oe),
129
129
  onClick: We,
130
- "data-field-width": Q,
130
+ "data-field-width": X,
131
131
  style: {
132
132
  display: "flex",
133
- ...Ct(Q),
133
+ ...Ct(X),
134
134
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
135
135
  letterSpacing: "0.00938em",
136
136
  ...B(De),
@@ -191,14 +191,14 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
191
191
  "data-testid": `${u}-clear`,
192
192
  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",
193
193
  onClick: (e) => {
194
- e.stopPropagation(), e.preventDefault(), C || ne(!1), He?.();
194
+ e.stopPropagation(), e.preventDefault(), C || oe(!1), He?.();
195
195
  },
196
196
  children: /* @__PURE__ */ t(Lt, {
197
197
  width: 18,
198
198
  height: 18
199
199
  })
200
200
  }) : b && /* @__PURE__ */ t("span", {
201
- ref: ee,
201
+ ref: te,
202
202
  className: "absolute inset-y-0 right-[14px] flex max-w-[calc(100%-28px)] items-center gap-1",
203
203
  children: b
204
204
  }),
@@ -251,12 +251,12 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
251
251
  })]
252
252
  })
253
253
  }),
254
- V && /* @__PURE__ */ t(Nt, {
254
+ Y && /* @__PURE__ */ t(Nt, {
255
255
  ref: gt,
256
- id: q,
256
+ id: ee,
257
257
  role: pt,
258
258
  error: y,
259
- message: J,
259
+ message: Q,
260
260
  hideErrorIcon: n?.formHelperText?.hideErrorIcon,
261
261
  className: a("mr-[14px] box-border items-start", n?.formHelperText?.className),
262
262
  style: {
@@ -264,8 +264,8 @@ var ge = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_
264
264
  ...B(n?.formHelperText?.sx)
265
265
  }
266
266
  }),
267
- ae && R ? /* @__PURE__ */ t(It, {
268
- id: ie,
267
+ G && R ? /* @__PURE__ */ t(It, {
268
+ id: ae,
269
269
  length: nt,
270
270
  limit: R,
271
271
  locale: Ne,
@@ -1,12 +1,13 @@
1
- import { useHelperAlertRole as u } from "./useHelperAlertRole.js";
2
- import { warnMissingErrorMessage as s } from "./warnMissingErrorMessage.js";
3
- function f(r, e, o, t, l) {
4
- const n = l !== !0 && (t === !0 || o != null || !!e);
5
- return s(r, e, o), {
6
- show: n,
7
- role: u(e)
1
+ import { useHelperAlertRole as p } from "./useHelperAlertRole.js";
2
+ import { warnMissingErrorMessage as f } from "./warnMissingErrorMessage.js";
3
+ var c = (r) => typeof r == "string" ? r.trim() !== "" : r != null && r !== !1;
4
+ function h(r, t, o, l, n, e) {
5
+ const u = e ? c(o) : l === !0 || o != null, i = n !== !0 && (u || !!t);
6
+ return f(r, t, o), {
7
+ show: i,
8
+ role: p(t)
8
9
  };
9
10
  }
10
11
  export {
11
- f as useHelperSlot
12
+ h as useHelperSlot
12
13
  };
@@ -7,5 +7,6 @@ export interface UseHelperSlotResult {
7
7
  * Shared logic for the helper-text row beneath input components.
8
8
  * Returns `show` (whether the slot should render) and `role` (ARIA live-region role).
9
9
  * Emits a dev-mode warning when `error` is set but `message` is empty.
10
+ * Under a character counter a blank slot is never reserved: the counter takes that line instead.
10
11
  */
11
- export declare function useHelperSlot(component: string, error: boolean | undefined, message: ReactNode, reserveHelperText?: boolean, readOnly?: boolean): UseHelperSlotResult;
12
+ export declare function useHelperSlot(component: string, error: boolean | undefined, message: ReactNode, reserveHelperText?: boolean, readOnly?: boolean, hasCounter?: boolean): UseHelperSlotResult;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.130.0",
6
+ "version": "3.130.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",