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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/inputs/input-field/StyledInputField.js +139 -136
- package/dist/src/table/helpers/defaultSortingFn.d.ts +48 -0
- package/dist/src/table/helpers/defaultSortingFn.test.d.ts +1 -0
- package/dist/src/table/types.d.ts +13 -0
- package/dist/table/helpers/defaultSortingFn.js +60 -0
- package/dist/table/hooks/useStyledTable.js +124 -112
- package/package.json +1 -1
|
@@ -1,279 +1,282 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { StyledTooltip as
|
|
4
|
-
import { CloseIcon as
|
|
5
|
-
import { LockIcon as
|
|
6
|
-
import { CharacterCounter as
|
|
7
|
-
import { HelperRow as
|
|
8
|
-
import { useHelperRowBudget as
|
|
9
|
-
import { useHelperSlot as
|
|
10
|
-
import { fieldLabelAboveClass as
|
|
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
|
|
13
|
-
import { Fragment as
|
|
14
|
-
import { useMergeRefs as
|
|
15
|
-
var
|
|
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:
|
|
20
|
-
}),
|
|
21
|
-
const
|
|
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
|
-
})] }) :
|
|
26
|
-
const e =
|
|
27
|
-
if (!(!i || !e) && (
|
|
28
|
-
if (e.removeAttribute("data-scrollable"),
|
|
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,
|
|
35
|
-
|
|
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
|
-
|
|
45
|
-
]),
|
|
46
|
-
l || (C || (
|
|
47
|
-
},
|
|
48
|
-
!h && !l &&
|
|
49
|
-
},
|
|
50
|
-
!h && !l &&
|
|
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
|
-
|
|
55
|
+
E(() => {
|
|
53
56
|
g();
|
|
54
57
|
}, [
|
|
55
58
|
g,
|
|
56
59
|
S,
|
|
57
60
|
x
|
|
58
|
-
]),
|
|
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]),
|
|
63
|
-
const e =
|
|
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 !==
|
|
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
|
|
74
|
-
|
|
75
|
-
}, [])]), { style:
|
|
76
|
-
...
|
|
77
|
-
...
|
|
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
|
-
...
|
|
82
|
-
} :
|
|
83
|
-
...
|
|
84
|
-
...
|
|
85
|
-
paddingLeft:
|
|
86
|
-
paddingRight:
|
|
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
|
-
} :
|
|
89
|
-
|
|
91
|
+
} : Y;
|
|
92
|
+
E(() => {
|
|
90
93
|
if (!v) return;
|
|
91
|
-
const e =
|
|
92
|
-
|
|
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
|
-
|
|
96
|
-
|
|
98
|
+
I,
|
|
99
|
+
P,
|
|
97
100
|
c
|
|
98
101
|
]);
|
|
99
|
-
const
|
|
100
|
-
...
|
|
101
|
-
style: v ?
|
|
102
|
-
id:
|
|
103
|
-
name:
|
|
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:
|
|
108
|
+
placeholder: gt ? Be : void 0,
|
|
106
109
|
disabled: h,
|
|
107
110
|
readOnly: l,
|
|
108
|
-
required:
|
|
109
|
-
autoComplete:
|
|
110
|
-
autoFocus:
|
|
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
|
|
115
|
-
"aria-describedby": [
|
|
116
|
-
onChange:
|
|
117
|
-
onFocus:
|
|
118
|
-
onBlur:
|
|
119
|
-
onKeyDown: s.onKeyDown ||
|
|
120
|
-
|
|
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
|
-
},
|
|
123
|
-
"data-start-adornment":
|
|
124
|
-
"data-end-adornment":
|
|
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:
|
|
128
|
-
className:
|
|
129
|
-
onClick:
|
|
130
|
-
"data-field-width":
|
|
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
|
-
...
|
|
136
|
+
...wt(q),
|
|
134
137
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
135
138
|
letterSpacing: "0.00938em",
|
|
136
|
-
...
|
|
137
|
-
|
|
139
|
+
...M(We),
|
|
140
|
+
...$e
|
|
138
141
|
},
|
|
139
142
|
children: [
|
|
140
|
-
|
|
141
|
-
className:
|
|
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
|
-
...
|
|
149
|
+
...M(n?.inputLabel?.sx),
|
|
147
150
|
...n?.inputLabel?.style
|
|
148
151
|
},
|
|
149
152
|
children: /* @__PURE__ */ f("label", {
|
|
150
|
-
htmlFor:
|
|
151
|
-
children: [
|
|
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(
|
|
158
|
-
reason: c ?
|
|
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:
|
|
163
|
-
ref:
|
|
164
|
-
onMouseDown:
|
|
165
|
-
...
|
|
166
|
-
style:
|
|
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
|
-
|
|
170
|
-
className:
|
|
171
|
-
children:
|
|
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
|
-
...
|
|
175
|
-
ref:
|
|
177
|
+
...ce,
|
|
178
|
+
ref: de,
|
|
176
179
|
"data-testid": u,
|
|
177
|
-
rows:
|
|
178
|
-
className:
|
|
180
|
+
rows: _ ?? k ?? 2,
|
|
181
|
+
className: ue
|
|
179
182
|
}) : /* @__PURE__ */ t("input", {
|
|
180
|
-
...
|
|
181
|
-
...
|
|
182
|
-
ref:
|
|
183
|
+
...ce,
|
|
184
|
+
...vt,
|
|
185
|
+
ref: de,
|
|
183
186
|
"data-testid": u,
|
|
184
|
-
type:
|
|
185
|
-
className:
|
|
187
|
+
type: Fe,
|
|
188
|
+
className: ue
|
|
186
189
|
}),
|
|
187
|
-
|
|
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 ||
|
|
197
|
+
e.stopPropagation(), e.preventDefault(), C || ie(!1), we?.();
|
|
195
198
|
},
|
|
196
|
-
children: /* @__PURE__ */ t(
|
|
199
|
+
children: /* @__PURE__ */ t(Ht, {
|
|
197
200
|
width: 18,
|
|
198
201
|
height: 18
|
|
199
202
|
})
|
|
200
203
|
}) : b && /* @__PURE__ */ t("span", {
|
|
201
|
-
ref:
|
|
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:
|
|
210
|
+
className: $t
|
|
208
211
|
}) : w ? /* @__PURE__ */ t("fieldset", {
|
|
209
212
|
"aria-hidden": !0,
|
|
210
|
-
className:
|
|
211
|
-
focused:
|
|
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 &&
|
|
219
|
+
}), c && ye),
|
|
217
220
|
children: /* @__PURE__ */ t("legend", {
|
|
218
|
-
className:
|
|
221
|
+
className: Mt(F),
|
|
219
222
|
children: /* @__PURE__ */ f("span", {
|
|
220
223
|
className: "inline-block px-[5px]",
|
|
221
|
-
children: [
|
|
224
|
+
children: [a, N && " *"]
|
|
222
225
|
})
|
|
223
226
|
})
|
|
224
227
|
}) : /* @__PURE__ */ t("div", {
|
|
225
228
|
"aria-hidden": !0,
|
|
226
|
-
className:
|
|
227
|
-
focused:
|
|
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 &&
|
|
235
|
+
}), c && ye)
|
|
233
236
|
})
|
|
234
237
|
]
|
|
235
238
|
}), w && /* @__PURE__ */ f("label", {
|
|
236
|
-
htmlFor:
|
|
237
|
-
className:
|
|
239
|
+
htmlFor: G,
|
|
240
|
+
className: r(Ft({
|
|
238
241
|
shrink: F,
|
|
239
|
-
focused:
|
|
242
|
+
focused: A,
|
|
240
243
|
error: y,
|
|
241
244
|
disabled: h,
|
|
242
245
|
readOnly: l,
|
|
243
|
-
size:
|
|
246
|
+
size: De
|
|
244
247
|
}), n?.inputLabel?.className),
|
|
245
248
|
style: {
|
|
246
|
-
...
|
|
249
|
+
...M(n?.inputLabel?.sx),
|
|
247
250
|
...n?.inputLabel?.style,
|
|
248
|
-
...
|
|
251
|
+
...Bt(F)
|
|
249
252
|
},
|
|
250
|
-
children: [
|
|
253
|
+
children: [a, N && " *"]
|
|
251
254
|
})]
|
|
252
255
|
})
|
|
253
256
|
}),
|
|
254
|
-
|
|
255
|
-
ref:
|
|
256
|
-
id:
|
|
257
|
-
role:
|
|
257
|
+
J && /* @__PURE__ */ t(_t, {
|
|
258
|
+
ref: yt,
|
|
259
|
+
id: ne,
|
|
260
|
+
role: ft,
|
|
258
261
|
error: y,
|
|
259
|
-
message:
|
|
262
|
+
message: Z,
|
|
260
263
|
hideErrorIcon: n?.formHelperText?.hideErrorIcon,
|
|
261
|
-
className:
|
|
264
|
+
className: r("mr-[14px] box-border items-start", n?.formHelperText?.className),
|
|
262
265
|
style: {
|
|
263
|
-
...
|
|
264
|
-
...
|
|
266
|
+
...bt,
|
|
267
|
+
...M(n?.formHelperText?.sx)
|
|
265
268
|
}
|
|
266
269
|
}),
|
|
267
|
-
|
|
268
|
-
id:
|
|
269
|
-
length:
|
|
270
|
+
V && R ? /* @__PURE__ */ t(Nt, {
|
|
271
|
+
id: se,
|
|
272
|
+
length: it,
|
|
270
273
|
limit: R,
|
|
271
|
-
locale:
|
|
274
|
+
locale: Ae,
|
|
272
275
|
className: "pt-1"
|
|
273
276
|
}) : null
|
|
274
277
|
]
|
|
275
278
|
});
|
|
276
279
|
};
|
|
277
280
|
export {
|
|
278
|
-
|
|
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
|
+
};
|