asma-ui-core 3.133.1 → 3.134.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,279 +1,282 @@
1
- import { cn as a } from "../../../helpers/cn.js";
2
- import { resolveSx as B } from "../../../helpers/sx.js";
3
- import { StyledTooltip as vt } from "../../data-display/tooltip/StyledTooltip.js";
4
- import { CloseIcon as Lt } from "../../icons/close-icon/CloseIcon.js";
5
- import { LockIcon as St } from "../../icons/lock-icon/LockIcon.js";
6
- import { CharacterCounter as It } from "../../../helpers/CharacterCounter.js";
7
- import { HelperRow as Nt } from "../../../helpers/HelperRow.js";
8
- import { useHelperRowBudget as _t } from "../../../helpers/useHelperRowBudget.js";
9
- import { useHelperSlot as At } from "../../../helpers/useHelperSlot.js";
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";
1
+ import { cn as r } from "../../../helpers/cn.js";
2
+ import { resolveSx as M } from "../../../helpers/sx.js";
3
+ import { StyledTooltip as St } from "../../data-display/tooltip/StyledTooltip.js";
4
+ import { CloseIcon as Ht } from "../../icons/close-icon/CloseIcon.js";
5
+ import { LockIcon as It } from "../../icons/lock-icon/LockIcon.js";
6
+ import { CharacterCounter as Nt } from "../../../helpers/CharacterCounter.js";
7
+ import { HelperRow as _t } from "../../../helpers/HelperRow.js";
8
+ import { useHelperRowBudget as At } from "../../../helpers/useHelperRowBudget.js";
9
+ import { useHelperSlot as Ct } from "../../../helpers/useHelperSlot.js";
10
+ import { fieldLabelAboveClass as Rt, fieldWidthStyle as wt, floatingLabelClass as Ft, floatingLabelLayoutStyle as Bt, notchedLegendClass as Mt, notchedOutlineClass as ge, singleLineInputLayoutStyle as Et, singleLineShellLayoutStyle as Ot } 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 J, useState as E } from "react";
13
- import { Fragment as Tt, jsx as t, jsxs as f } from "react/jsx-runtime";
14
- import { useMergeRefs as me } from "@floating-ui/react";
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, {
12
+ import { Children as Tt, useCallback as fe, useId as Dt, useLayoutEffect as E, useRef as X, useState as O } from "react";
13
+ import { Fragment as kt, jsx as t, jsxs as f } from "react/jsx-runtime";
14
+ import { useMergeRefs as xe } from "@floating-ui/react";
15
+ var ye = "peer-focus-visible:border-focus-ring peer-focus-visible:shadow-[inset_0_0_0_2px_var(--colors-focus-ring)]", $t = "pointer-events-none absolute -inset-1 rounded peer-focus-visible:shadow-[inset_0_0_0_2px_var(--colors-focus-ring)]", Wt = ({ reason: u, children: a }) => u === void 0 ? a : /* @__PURE__ */ t(St, {
16
16
  title: u,
17
17
  openOnTap: !0,
18
18
  persistentDescription: !0,
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: 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, {
19
+ children: a
20
+ }), fn = ({ dataTest: u, label: a, labelPlacement: be = "above", value: x, defaultValue: S, onChange: ve, onBlur: Le, onFocus: Se, error: y, helperText: Z, reserveHelperText: He, expandHelperText: Ie = !0, maxLength: Ne, counter: _e, locale: Ae, disabled: h, readOnly: Ce, lockedReason: T, readOnlyReason: D, required: N, allowClear: Re, onClear: we, type: Fe = "text", placeholder: Be, name: Me, id: Ee, autoComplete: Oe, autoFocus: Te, multiline: i, rows: _, minRows: k, maxRows: $, size: De = "medium", width: q = "full", fullWidth: zt, className: ke, style: $e, sx: We, inputRef: ze, slotProps: n, InputProps: ee, onKeyDown: te, onClick: Ue, variant: Ut }) => {
21
+ const je = Dt(), W = Ee ?? je, ne = `${W}-helper-text`, z = X(null), U = X(0), oe = X(null), [Pe, Ke] = O(void 0), [A, le] = O(!1), [Ge, ie] = O(S != null && S !== ""), [Ve, Ye] = O(String(S ?? "").length), c = !!T || T === 0, o = !c && (!!D || D === 0), l = !!Ce || c || o, C = x !== void 0, re = C ? x !== "" && x != null : Ge, Je = !!h || !!l, j = n?.input?.startAdornment ?? ee?.startAdornment, H = Tt.count(j) > 0, m = H && Array.isArray(j), P = n?.input?.endAdornment ?? ee?.endAdornment, b = c ? /* @__PURE__ */ f(kt, { children: [P, /* @__PURE__ */ t(It, {
22
22
  width: 24,
23
23
  height: 24,
24
24
  className: "text-delta-700"
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
- const e = $.current;
27
- if (!(!i || !e) && (z.current = e.offsetWidth, z.current !== 0)) {
28
- if (e.removeAttribute("data-scrollable"), A != null && !l) e.style.height = "";
25
+ })] }) : P, I = !!(Re && re && !Je), { ref: Qe, ...s } = n?.htmlInput ?? {}, Xe = ze ?? Qe, { className: Ze, style: K, ref: qe } = n?.input ?? {}, et = xe([qe]), tt = n?.input?.onMouseDown, ae = n?.input?.onClick, nt = ae ? { onClick: ae } : {}, ot = Oe ?? s.autoComplete, lt = Me ?? s.name, G = s.id ?? W, R = Ne ?? s.maxLength, se = `${W}-counter`, V = _e !== !1 && !!R && !o, it = C ? String(x ?? "").length : Ve, w = be === "floating" && !!a && !o, F = A || re || H, g = fe(() => {
26
+ const e = z.current;
27
+ if (!(!i || !e) && (U.current = e.offsetWidth, U.current !== 0)) {
28
+ if (e.removeAttribute("data-scrollable"), _ != null && !l) e.style.height = "";
29
29
  else {
30
30
  if (e.style.height = "auto", e.scrollHeight === 0) {
31
31
  e.style.height = "";
32
32
  return;
33
33
  }
34
- const d = getComputedStyle(e), p = Number.parseFloat(d.lineHeight) || 24, ce = Number.parseFloat(d.paddingTop) + Number.parseFloat(d.paddingBottom), ue = A ?? D, yt = ue ? ue * p + ce : 0, bt = l || !k ? Number.POSITIVE_INFINITY : k * p + ce;
35
- e.style.height = `${Math.min(bt, Math.max(yt, e.scrollHeight))}px`;
34
+ const d = getComputedStyle(e), p = Number.parseFloat(d.lineHeight) || 24, he = Number.parseFloat(d.paddingTop) + Number.parseFloat(d.paddingBottom), pe = _ ?? k, Lt = pe ? pe * p + he : 0, Q = l || !$ ? Number.POSITIVE_INFINITY : $ * p + he;
35
+ let B = Math.min(Q, Math.max(Lt, e.scrollHeight));
36
+ e.style.height = `${B}px`;
37
+ for (let me = 0; me < 2 && B < Q && e.scrollHeight > e.clientHeight + 1; me++)
38
+ B = Math.min(Q, e.scrollHeight), e.style.height = `${B}px`;
36
39
  }
37
40
  e.scrollHeight > e.clientHeight + 1 && e.setAttribute("data-scrollable", "true");
38
41
  }
39
42
  }, [
43
+ $,
40
44
  k,
41
- D,
42
45
  i,
43
46
  l,
44
- A
45
- ]), ot = (e) => {
46
- l || (C || (oe(e.target.value !== ""), Ke(e.target.value.length), g()), xe?.(e));
47
- }, lt = (e) => {
48
- !h && !l && ne(!0), be?.(e);
49
- }, it = (e) => {
50
- !h && !l && ne(!1), ye?.(e);
47
+ _
48
+ ]), rt = (e) => {
49
+ l || (C || (ie(e.target.value !== ""), Ye(e.target.value.length), g()), ve?.(e));
50
+ }, at = (e) => {
51
+ !h && !l && le(!0), Se?.(e);
52
+ }, st = (e) => {
53
+ !h && !l && le(!1), Le?.(e);
51
54
  };
52
- M(() => {
55
+ E(() => {
53
56
  g();
54
57
  }, [
55
58
  g,
56
59
  S,
57
60
  x
58
- ]), M(() => {
61
+ ]), E(() => {
59
62
  if (!i || !document.fonts) return;
60
63
  const e = () => g();
61
64
  return document.fonts.addEventListener("loadingdone", e), () => document.fonts.removeEventListener("loadingdone", e);
62
- }, [i, g]), M(() => {
63
- const e = $.current;
65
+ }, [i, g]), E(() => {
66
+ const e = z.current;
64
67
  if (!i || !e || typeof ResizeObserver > "u") return;
65
68
  let d = 0;
66
69
  const p = new ResizeObserver(() => {
67
- e.offsetWidth !== z.current && (cancelAnimationFrame(d), d = requestAnimationFrame(g));
70
+ e.offsetWidth !== U.current && (cancelAnimationFrame(d), d = requestAnimationFrame(g));
68
71
  });
69
72
  return p.observe(e), () => {
70
73
  cancelAnimationFrame(d), p.disconnect();
71
74
  };
72
75
  }, [i, g]);
73
- const re = me([Ye, pe((e) => {
74
- $.current = e instanceof HTMLTextAreaElement ? e : null;
75
- }, [])]), { style: V, ...at } = s, v = !i && !m && !o, { height: zt, minHeight: Ut, maxHeight: jt, paddingTop: Pt, paddingBottom: Kt, ...rt } = P ?? {}, st = v ? {
76
- ...rt,
77
- ...Mt()
76
+ const de = xe([Xe, fe((e) => {
77
+ z.current = e instanceof HTMLTextAreaElement ? e : null;
78
+ }, [])]), { style: Y, ...dt } = s, v = !i && !m && !o, { height: jt, minHeight: Pt, maxHeight: Kt, paddingTop: Gt, paddingBottom: Vt, ...ct } = K ?? {}, ut = v ? {
79
+ ...ct,
80
+ ...Ot()
78
81
  } : m ? {
79
82
  boxSizing: "border-box",
80
83
  minHeight: 40,
81
- ...P
82
- } : P, { height: Gt, minHeight: Vt, maxHeight: Yt, paddingTop: Jt, paddingBottom: Qt, paddingLeft: Xt, paddingRight: dt, ...ct } = V ?? {}, ut = v ? {
83
- ...ct,
84
- ...Bt({
85
- paddingLeft: I ? 40 : 14,
86
- paddingRight: dt ?? ze ?? (N || b ? 40 : 14)
84
+ ...K
85
+ } : K, { height: Yt, minHeight: Jt, maxHeight: Qt, paddingTop: Xt, paddingBottom: Zt, paddingLeft: qt, paddingRight: ht, ...pt } = Y ?? {}, mt = v ? {
86
+ ...pt,
87
+ ...Et({
88
+ paddingLeft: H ? 40 : 14,
89
+ paddingRight: ht ?? Pe ?? (I || b ? 40 : 14)
87
90
  })
88
- } : V;
89
- M(() => {
91
+ } : Y;
92
+ E(() => {
90
93
  if (!v) return;
91
- const e = te.current, d = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
92
- Ue((p) => p === d ? p : d);
94
+ const e = oe.current, d = e ? Math.ceil(e.getBoundingClientRect().width) + 20 : void 0;
95
+ Ke((p) => p === d ? p : d);
93
96
  }, [
94
97
  v,
95
- N,
96
- j,
98
+ I,
99
+ P,
97
100
  c
98
101
  ]);
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
- ...at,
101
- style: v ? ut : V,
102
- id: K,
103
- name: tt,
102
+ const gt = F || !w, { show: J, role: ft } = Ct("StyledInputField", y, Z, He, l, V), { fieldRef: xt, rowRef: yt, rowStyle: bt } = At(Ie && J), ce = {
103
+ ...dt,
104
+ style: v ? mt : Y,
105
+ id: G,
106
+ name: lt,
104
107
  maxLength: R,
105
- placeholder: ht ? Re : void 0,
108
+ placeholder: gt ? Be : void 0,
106
109
  disabled: h,
107
110
  readOnly: l,
108
- required: _,
109
- autoComplete: et,
110
- autoFocus: Me,
111
+ required: N,
112
+ autoComplete: ot,
113
+ autoFocus: Te,
111
114
  value: x,
112
115
  defaultValue: S,
113
116
  "aria-invalid": y ? !0 : void 0,
114
- "aria-label": s["aria-label"] ?? (s["aria-labelledby"] ? void 0 : typeof r == "string" && r !== "" ? r : void 0),
115
- "aria-describedby": [Y ? ee : s["aria-describedby"], G ? ae : void 0].filter(Boolean).join(" ") || void 0,
116
- onChange: ot,
117
- onFocus: lt,
118
- onBlur: it,
119
- onKeyDown: s.onKeyDown || q ? (e) => {
120
- q?.(e), e.defaultPrevented || s.onKeyDown?.(e);
117
+ "aria-label": s["aria-label"] ?? (s["aria-labelledby"] ? void 0 : typeof a == "string" && a !== "" ? a : void 0),
118
+ "aria-describedby": [J ? ne : s["aria-describedby"], V ? se : void 0].filter(Boolean).join(" ") || void 0,
119
+ onChange: rt,
120
+ onFocus: at,
121
+ onBlur: st,
122
+ onKeyDown: s.onKeyDown || te ? (e) => {
123
+ te?.(e), e.defaultPrevented || s.onKeyDown?.(e);
121
124
  } : void 0
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
- "data-start-adornment": I ? "true" : void 0,
124
- "data-end-adornment": N || b ? "true" : void 0
125
+ }, ue = r(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 ? r("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" : r("w-full", L["Input--singleLine"], !I && !b && "max-xs:pr-1.5"), "disabled:text-delta-300", l && !o && "text-delta-800", (c || o) && "cursor-default", Ze), vt = !i && !m ? {
126
+ "data-start-adornment": H ? "true" : void 0,
127
+ "data-end-adornment": I || b ? "true" : void 0
125
128
  } : {};
126
129
  return /* @__PURE__ */ f("div", {
127
- ref: mt,
128
- className: a("group relative min-w-0 flex-col", Oe),
129
- onClick: We,
130
- "data-field-width": X,
130
+ ref: xt,
131
+ className: r("group relative min-w-0 flex-col", ke),
132
+ onClick: Ue,
133
+ "data-field-width": q,
131
134
  style: {
132
135
  display: "flex",
133
- ...Ct(X),
136
+ ...wt(q),
134
137
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
135
138
  letterSpacing: "0.00938em",
136
- ...B(De),
137
- ...Te
139
+ ...M(We),
140
+ ...$e
138
141
  },
139
142
  children: [
140
- r && !w && /* @__PURE__ */ t("div", {
141
- className: a(Ht({
143
+ a && !w && /* @__PURE__ */ t("div", {
144
+ className: r(Rt({
142
145
  disabled: h,
143
146
  flush: o
144
147
  }), n?.inputLabel?.className),
145
148
  style: {
146
- ...B(n?.inputLabel?.sx),
149
+ ...M(n?.inputLabel?.sx),
147
150
  ...n?.inputLabel?.style
148
151
  },
149
152
  children: /* @__PURE__ */ f("label", {
150
- htmlFor: K,
151
- children: [r, _ && /* @__PURE__ */ t("span", {
153
+ htmlFor: G,
154
+ children: [a, N && /* @__PURE__ */ t("span", {
152
155
  "aria-hidden": "true",
153
156
  children: " *"
154
157
  })]
155
158
  })
156
159
  }),
157
- /* @__PURE__ */ t(kt, {
158
- reason: c ? O : o ? T : void 0,
160
+ /* @__PURE__ */ t(Wt, {
161
+ reason: c ? T : o ? D : void 0,
159
162
  children: /* @__PURE__ */ f("div", {
160
163
  className: "relative overflow-visible",
161
164
  children: [/* @__PURE__ */ f("div", {
162
- className: a("relative flex", v && L.InputShell, i && !o && "box-border items-center px-[14px] py-[16.5px]", m && a(L.AdornmentList, b && L["AdornmentList--endAdornment"]), l && !o && "rounded bg-delta-50", c && i && "pr-[44px]"),
163
- ref: Xe,
164
- onMouseDown: Ze,
165
- ...qe,
166
- style: st,
165
+ className: r("relative flex", v && L.InputShell, i && !o && "box-border items-center px-[14px] py-[16.5px]", m && r(L.AdornmentList, b && L["AdornmentList--endAdornment"]), l && !o && "rounded bg-delta-50", c && i && "pr-[44px]"),
166
+ ref: et,
167
+ onMouseDown: tt,
168
+ ...nt,
169
+ style: ut,
167
170
  "data-testid": m ? `${u}-adornment-list` : `${u}-shell`,
168
171
  children: [
169
- I && /* @__PURE__ */ t("span", {
170
- className: a("items-center text-delta-500", m ? "contents" : "absolute left-3 flex"),
171
- children: U
172
+ H && /* @__PURE__ */ t("span", {
173
+ className: r("items-center text-delta-500", m ? "contents" : "absolute left-3 flex"),
174
+ children: j
172
175
  }),
173
176
  i ? /* @__PURE__ */ t("textarea", {
174
- ...se,
175
- ref: re,
177
+ ...ce,
178
+ ref: de,
176
179
  "data-testid": u,
177
- rows: A ?? D ?? 2,
178
- className: de
180
+ rows: _ ?? k ?? 2,
181
+ className: ue
179
182
  }) : /* @__PURE__ */ t("input", {
180
- ...se,
181
- ...xt,
182
- ref: re,
183
+ ...ce,
184
+ ...vt,
185
+ ref: de,
183
186
  "data-testid": u,
184
- type: Ce,
185
- className: de
187
+ type: Fe,
188
+ className: ue
186
189
  }),
187
- N ? /* @__PURE__ */ t("button", {
190
+ I ? /* @__PURE__ */ t("button", {
188
191
  type: "button",
189
192
  tabIndex: -1,
190
193
  "aria-label": "Clear",
191
194
  "data-testid": `${u}-clear`,
192
195
  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
196
  onClick: (e) => {
194
- e.stopPropagation(), e.preventDefault(), C || oe(!1), He?.();
197
+ e.stopPropagation(), e.preventDefault(), C || ie(!1), we?.();
195
198
  },
196
- children: /* @__PURE__ */ t(Lt, {
199
+ children: /* @__PURE__ */ t(Ht, {
197
200
  width: 18,
198
201
  height: 18
199
202
  })
200
203
  }) : b && /* @__PURE__ */ t("span", {
201
- ref: te,
204
+ ref: oe,
202
205
  className: "absolute inset-y-0 right-[14px] flex max-w-[calc(100%-28px)] items-center gap-1",
203
206
  children: b
204
207
  }),
205
208
  o ? /* @__PURE__ */ t("div", {
206
209
  "aria-hidden": !0,
207
- className: Dt
210
+ className: $t
208
211
  }) : w ? /* @__PURE__ */ t("fieldset", {
209
212
  "aria-hidden": !0,
210
- className: a(he({
211
- focused: H,
213
+ className: r(ge({
214
+ focused: A,
212
215
  error: y,
213
216
  disabled: h,
214
217
  readOnly: l,
215
218
  notched: !0
216
- }), c && ge),
219
+ }), c && ye),
217
220
  children: /* @__PURE__ */ t("legend", {
218
- className: Ft(F),
221
+ className: Mt(F),
219
222
  children: /* @__PURE__ */ f("span", {
220
223
  className: "inline-block px-[5px]",
221
- children: [r, _ && " *"]
224
+ children: [a, N && " *"]
222
225
  })
223
226
  })
224
227
  }) : /* @__PURE__ */ t("div", {
225
228
  "aria-hidden": !0,
226
- className: a(he({
227
- focused: H,
229
+ className: r(ge({
230
+ focused: A,
228
231
  error: y,
229
232
  disabled: h,
230
233
  readOnly: l,
231
234
  notched: !1
232
- }), c && ge)
235
+ }), c && ye)
233
236
  })
234
237
  ]
235
238
  }), w && /* @__PURE__ */ f("label", {
236
- htmlFor: K,
237
- className: a(Rt({
239
+ htmlFor: G,
240
+ className: r(Ft({
238
241
  shrink: F,
239
- focused: H,
242
+ focused: A,
240
243
  error: y,
241
244
  disabled: h,
242
245
  readOnly: l,
243
- size: Ee
246
+ size: De
244
247
  }), n?.inputLabel?.className),
245
248
  style: {
246
- ...B(n?.inputLabel?.sx),
249
+ ...M(n?.inputLabel?.sx),
247
250
  ...n?.inputLabel?.style,
248
- ...wt(F)
251
+ ...Bt(F)
249
252
  },
250
- children: [r, _ && " *"]
253
+ children: [a, N && " *"]
251
254
  })]
252
255
  })
253
256
  }),
254
- Y && /* @__PURE__ */ t(Nt, {
255
- ref: gt,
256
- id: ee,
257
- role: pt,
257
+ J && /* @__PURE__ */ t(_t, {
258
+ ref: yt,
259
+ id: ne,
260
+ role: ft,
258
261
  error: y,
259
- message: Q,
262
+ message: Z,
260
263
  hideErrorIcon: n?.formHelperText?.hideErrorIcon,
261
- className: a("mr-[14px] box-border items-start", n?.formHelperText?.className),
264
+ className: r("mr-[14px] box-border items-start", n?.formHelperText?.className),
262
265
  style: {
263
- ...ft,
264
- ...B(n?.formHelperText?.sx)
266
+ ...bt,
267
+ ...M(n?.formHelperText?.sx)
265
268
  }
266
269
  }),
267
- G && R ? /* @__PURE__ */ t(It, {
268
- id: ae,
269
- length: nt,
270
+ V && R ? /* @__PURE__ */ t(Nt, {
271
+ id: se,
272
+ length: it,
270
273
  limit: R,
271
- locale: Ne,
274
+ locale: Ae,
272
275
  className: "pt-1"
273
276
  }) : null
274
277
  ]
275
278
  });
276
279
  };
277
280
  export {
278
- mn as StyledInputField
281
+ fn as StyledInputField
279
282
  };
@@ -0,0 +1,48 @@
1
+ import { BuiltInSortingFn, SortingFn, Table } from '@tanstack/react-table';
2
+ /**
3
+ * The comparison every `StyledTable` column uses unless the column, or the app's `defaultColumn`, names its own `sortingFn`
4
+ * (ASMA-8597, P2f, DEC-SORTFN). It is registered as `sortingFns.styledDefault`.
5
+ *
6
+ * - Empty cells (`undefined`, `null`, `''`, whitespace only, `NaN`, an invalid `Date`) go last in both directions. Two empty
7
+ * cells tie.
8
+ * - Numbers, `Date`s and booleans compare by value; two ISO 8601 date strings compare by time.
9
+ * - Any other two strings, and two values of different types, compare as text in the table locale: case and accents are
10
+ * ignored and digit runs compare as numbers (`svc-9` before `svc-10`).
11
+ * - Ties return 0, so TanStack keeps the data order.
12
+ */
13
+ /**
14
+ * The name the comparison is registered under in the table's `sortingFns`. It is typed as a built-in name because TanStack's
15
+ * `SortingFns` interface, which would let `'styledDefault'` type-check, turns `sortingFns` into a required prop of every
16
+ * `StyledTable` once it is augmented; the table registers the function itself, so no app needs to.
17
+ */
18
+ export declare const STYLED_DEFAULT_SORTING_FN: BuiltInSortingFn;
19
+ /** One collator per locale: building one is the expensive part of a text comparison. */
20
+ export declare const getSortCollator: (locale?: string) => Intl.Collator;
21
+ /** Whether a cell has no value to sort on: such cells always go last. */
22
+ export declare const isEmptySortValue: (value: unknown) => boolean;
23
+ /** Compares two cells that are not empty, ascending. A tie is exactly 0. */
24
+ export declare const compareSortValues: (a: unknown, b: unknown, collator: Intl.Collator) => number;
25
+ /**
26
+ * Builds the comparison. TanStack hands a sorting function only `(rowA, rowB, columnId)` and flips its result afterwards
27
+ * for a descending sort and for `invertSorting`, so an empty cell would swap ends with the direction. To keep it last the
28
+ * comparison reads the column's direction and `invertSorting` live from the table (`getTable` returns the table of the
29
+ * render that sorts) and returns the sign that comes out "after" once TanStack has applied both flips.
30
+ */
31
+ export declare const createStyledDefaultSortingFn: <TData>(getTable: () => Table<TData> | undefined) => SortingFn<TData>;
32
+ /** The parts of a column definition that decide whether the default comparison applies to it. */
33
+ interface SortUndefinedColumnDef {
34
+ sortingFn?: unknown;
35
+ sortUndefined?: unknown;
36
+ columns?: readonly SortUndefinedColumnDef[];
37
+ }
38
+ /**
39
+ * Gives `sortUndefined: false` to the leaf columns that sort with `styledDefault`, and to no other (DeepSeek's audit of
40
+ * #340, round 1). The setting lets `undefined` reach the comparison so that it can put it last. A column with its own
41
+ * `sortingFn` would then receive `undefined` in its own comparator, which was written for TanStack's handling and may not
42
+ * expect it, so it keeps TanStack's default.
43
+ *
44
+ * A leaf gets it only when it sorts with `styledDefault` (neither it nor the app's `defaultColumn` names another
45
+ * `sortingFn`) and neither it nor the app's `defaultColumn` sets `sortUndefined`. Group columns are walked into.
46
+ */
47
+ export declare const resolveSortUndefinedDefaults: <TColumn extends SortUndefinedColumnDef>(columns: readonly TColumn[], defaultColumn?: SortUndefinedColumnDef) => TColumn[];
48
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -73,6 +73,19 @@ export type RowActionsState = {
73
73
  state: 'enabled';
74
74
  };
75
75
  export type StyledTableProps<TData, TCustomData> = {
76
+ /**
77
+ * The table's language. It sets the labels, and also the text order of the default sort: names compare in this locale,
78
+ * ignoring case and accents, with digit runs as numbers (`'no'` puts æ, ø and å after z).
79
+ *
80
+ * **Default sort.** Unless a column sets its own `sortingFn` (or the table's `defaultColumn` does), the column sorts with
81
+ * `sortingFns.styledDefault` (ASMA-8597, P2f): numbers, dates and booleans by value, ISO date strings by time, other
82
+ * text in the table locale, ties in the data order. Empty cells (`undefined`, `null`, `''`, whitespace, `NaN`, an invalid
83
+ * `Date`) always go last, in both directions. A column with its own `sortingFn`, or one that `defaultColumn: { sortingFn }`
84
+ * covers, is not touched: its comparator, and TanStack's handling of `undefined` before it, stay as they were. A column's own
85
+ * `sortUndefined` only decides where `undefined` goes (TanStack handles it before the comparison); `null`, `''`,
86
+ * whitespace, `NaN` and an invalid `Date` still go last through `styledDefault`. The table's own `sortingFns` are kept
87
+ * beside `styledDefault`.
88
+ */
76
89
  locale?: 'no' | 'en';
77
90
  height?: string | number;
78
91
  actions?: (row: Row<TData>) => (IAction<TData> | ICustomAction<TData>)[];
@@ -0,0 +1,60 @@
1
+ var E = "styledDefault", v = (e) => e === "no" ? "nb" : e ?? "en", p = /* @__PURE__ */ new Map(), S = (e) => {
2
+ const t = v(e);
3
+ let r = p.get(t);
4
+ return r || (r = new Intl.Collator(t, {
5
+ numeric: !0,
6
+ sensitivity: "base"
7
+ }), p.set(t, r)), r;
8
+ }, D = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?)?$/, y = [
9
+ 31,
10
+ 28,
11
+ 31,
12
+ 30,
13
+ 31,
14
+ 30,
15
+ 31,
16
+ 31,
17
+ 30,
18
+ 31,
19
+ 30,
20
+ 31
21
+ ], T = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, b = (e, t, r) => t >= 1 && t <= 12 && r >= 1 && r <= (t === 2 && T(e) ? 29 : y[t - 1]), l = (e) => {
22
+ if (!D.test(e) || !b(Number(e.slice(0, 4)), Number(e.slice(5, 7)), Number(e.slice(8, 10)))) return;
23
+ const t = Date.parse(e.replace(" ", "T").replace(",", "."));
24
+ return Number.isNaN(t) ? void 0 : t;
25
+ }, u = (e) => e == null || typeof e == "string" && e.trim() === "" || typeof e == "number" && Number.isNaN(e) || e instanceof Date && Number.isNaN(e.getTime()), f = (e, t) => e < t ? -1 : e > t ? 1 : 0, F = (e, t, r) => {
26
+ if (typeof e == "number" && typeof t == "number") return f(e, t);
27
+ if (e instanceof Date && t instanceof Date) return f(e.getTime(), t.getTime());
28
+ if (typeof e == "boolean" && typeof t == "boolean") return f(Number(e), Number(t));
29
+ if (typeof e == "string" && typeof t == "string") {
30
+ const i = l(e), o = l(t);
31
+ return i !== void 0 && o !== void 0 ? f(i, o) : r.compare(e, t) || 0;
32
+ }
33
+ return r.compare(String(e), String(t)) || 0;
34
+ }, U = (e) => (t, r, i) => {
35
+ const o = t.getValue(i), n = r.getValue(i), s = u(o), a = u(n), d = e();
36
+ if (s || a) {
37
+ if (s && a) return 0;
38
+ const m = d?.getState().sorting.find((N) => N.id === i)?.desc ?? !1, g = d?.getColumn(i)?.columnDef.invertSorting ?? !1, c = (m ? -1 : 1) * (g ? -1 : 1);
39
+ return s ? c : -c;
40
+ }
41
+ return F(o, n, S(d?.options.meta?.locale));
42
+ }, _ = (e, t) => {
43
+ const r = t?.sortingFn, i = t?.sortUndefined !== void 0, o = (n) => {
44
+ if (n.columns?.length) return {
45
+ ...n,
46
+ columns: n.columns.map((a) => o(a))
47
+ };
48
+ const s = n.sortingFn ?? r;
49
+ return !(s == null || s === "styledDefault") || n.sortUndefined !== void 0 || i ? n : {
50
+ ...n,
51
+ sortUndefined: !1
52
+ };
53
+ };
54
+ return e.map(o);
55
+ };
56
+ export {
57
+ E as STYLED_DEFAULT_SORTING_FN,
58
+ U as createStyledDefaultSortingFn,
59
+ _ as resolveSortUndefinedDefaults
60
+ };