asma-ui-core 3.133.0 → 3.134.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,227 +1,244 @@
1
- import { cn as Le } from "../../../helpers/cn.js";
2
- import { firstTabbable as ne } from "../../../helpers/focusable.js";
3
- import { TOP_LAYER_PROPS as Me, TOP_LAYER_RESET_STYLE as Se, getOpenModalDialogAncestor as Ce, shouldUsePopoverTopLayer as Ie, useTopLayerRef as _e } from "../../../hooks/useTopLayer.hook.js";
1
+ import { cn as Me } from "../../../helpers/cn.js";
2
+ import { firstTabbable as re } from "../../../helpers/focusable.js";
3
+ import { TOP_LAYER_PROPS as Se, TOP_LAYER_RESET_STYLE as Ce, getOpenModalDialogAncestor as Ie, shouldUsePopoverTopLayer as _e, useTopLayerRef as We } from "../../../hooks/useTopLayer.hook.js";
4
4
  import { StyledButton as ke } from "../../inputs/button/StyledButton.js";
5
- import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as We, useBackCloses as Be } from "../../../hooks/useBackCloses.hook.js";
6
- import { isKeyboardModality as De, trackInputModality as qe } from "../../inputs/full-screen-picker/inputModality.js";
7
- import { useDebouncedValue as Xe } from "../../../hooks/useDebouncedValue.hook.js";
8
- import { useFocusTrap as $e } from "../../../hooks/useFocusTrap.hook.js";
9
- import { useMobileMediaQuery as Ke } from "../../../hooks/useMediaQuery.hook.js";
10
- import { SHEET_TEXT as Ne } from "../bottom-sheet/sheetCopy.js";
11
- import { formatResultsLabel as je } from "../bottom-sheet/formatResultsLabel.js";
12
- import { StyledBottomSheet as Ue } from "../bottom-sheet/StyledBottomSheet.js";
13
- import { PopoverAnatomy as Ve } from "./PopoverAnatomy.js";
14
- import { useCallback as d, useEffect as v, useId as Ye, useRef as f, useState as l } from "react";
15
- import { Fragment as re, jsx as m, jsxs as ie } from "react/jsx-runtime";
16
- import { FloatingPortal as ze, autoUpdate as Ge, flip as Qe, offset as Je, shift as Ze, size as et, useDismiss as tt, useFloating as ot, useInteractions as nt, useMergeRefs as rt } from "@floating-ui/react";
17
- var S = 240, it = {
5
+ import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as Be, useBackCloses as De } from "../../../hooks/useBackCloses.hook.js";
6
+ import { isKeyboardModality as qe, trackInputModality as Xe } from "../../inputs/full-screen-picker/inputModality.js";
7
+ import { useDebouncedValue as $e } from "../../../hooks/useDebouncedValue.hook.js";
8
+ import { useFocusTrap as Ke } from "../../../hooks/useFocusTrap.hook.js";
9
+ import { useMobileMediaQuery as Ne } from "../../../hooks/useMediaQuery.hook.js";
10
+ import { SHEET_TEXT as je } from "../bottom-sheet/sheetCopy.js";
11
+ import { formatResultsLabel as Ue } from "../bottom-sheet/formatResultsLabel.js";
12
+ import { StyledBottomSheet as Ve } from "../bottom-sheet/StyledBottomSheet.js";
13
+ import { PopoverAnatomy as Ye } from "./PopoverAnatomy.js";
14
+ import { useCallback as p, useEffect as b, useId as ze, useRef as g, useState as l } from "react";
15
+ import { Fragment as ie, jsx as h, jsxs as se } from "react/jsx-runtime";
16
+ import { FloatingPortal as Ge, autoUpdate as Qe, flip as Je, offset as Ze, shift as et, size as tt, useDismiss as ot, useFloating as nt, useInteractions as rt, useMergeRefs as it } from "@floating-ui/react";
17
+ var H = 240, st = {
18
18
  info: 472,
19
19
  action: 472
20
- }, se = 0.6, ae = "calc(100vw - 32px)", Rt = ({ dataTest: p, renderTrigger: C, variant: I = "info", title: y, children: _, viewResultsAction: k, resetAction: H, footerActions: W, resultCount: b, locale: R = "en", closeLabel: B = Ne[R].close, ariaLabel: D, onOpenChange: q, className: X, align: $ = "auto", ignoreOutside: K }) => {
21
- const g = Ye(), N = `${g}-title`, [o, ce] = l(!1), [j, le] = l(), [ue, U] = l(), [de, fe] = l("start"), [T, V] = l(), [me, Y] = l(S), u = Ke(), n = I === "action", pe = u && !n, E = u && n, w = d((e) => {
22
- ce(e), q?.(e);
23
- }, [q]), { refs: F, floatingStyles: ge, context: he, placement: z, isPositioned: ve } = ot({
24
- open: o,
25
- onOpenChange: w,
26
- placement: `${T ?? "bottom"}-${de}`,
20
+ }, ae = 0.6, ce = "calc(100vw - 32px)", at = () => {
21
+ let o;
22
+ return {
23
+ name: "holdAlignedEdge",
24
+ fn: ({ x: v, rects: w, placement: f }) => {
25
+ const u = f.endsWith("-end"), E = w.floating.width, { x, width: R } = w.reference;
26
+ return !(o !== void 0 && o.x >= x - 1 && o.x <= x + R + 1) || o?.atEnd !== u || o.viewportWidth !== window.innerWidth ? (o = {
27
+ x: u ? v + E : v,
28
+ atEnd: u,
29
+ viewportWidth: window.innerWidth
30
+ }, {}) : { x: u ? o.x - E : o.x };
31
+ },
32
+ release: () => {
33
+ o = void 0;
34
+ }
35
+ };
36
+ }, Tt = ({ dataTest: o, renderTrigger: v, variant: w = "info", title: f, children: u, viewResultsAction: E, resetAction: x, footerActions: R, resultCount: O, locale: M = "en", closeLabel: B = je[M].close, ariaLabel: D, onOpenChange: q, className: X, align: $ = "auto", ignoreOutside: K }) => {
37
+ const y = ze(), N = `${y}-title`, [n, le] = l(!1), [j, de] = l(), [ue, U] = l(), [fe, me] = l("start"), [S, V] = l(), [pe, Y] = l(H), [z] = l(at), m = Ne(), r = w === "action", ge = m && !r, A = m && r, T = p((e) => {
38
+ le(e), q?.(e);
39
+ }, [q]), { refs: C, floatingStyles: he, context: ve, placement: G, isPositioned: we } = nt({
40
+ open: n,
41
+ onOpenChange: T,
42
+ placement: `${S ?? "bottom"}-${fe}`,
27
43
  strategy: "fixed",
28
- whileElementsMounted: Ge,
44
+ whileElementsMounted: Qe,
29
45
  middleware: [
30
- Je(8),
31
- ...pe || T ? [] : [Qe({
46
+ Ze(8),
47
+ ...ge || S ? [] : [Je({
32
48
  padding: 8,
33
49
  crossAxis: !1,
34
50
  flipAlignment: !1
35
51
  })],
36
- Ze({ padding: 8 }),
37
- et({
52
+ z,
53
+ et({ padding: 8 }),
54
+ tt({
38
55
  padding: 8,
39
56
  apply({ availableHeight: e, rects: t }) {
40
- U(Math.min(e, Math.round(window.innerHeight * se))), u || Y((a) => Math.max(a, t.floating.width));
57
+ U(Math.min(e, Math.round(window.innerHeight * ae))), m || Y((c) => Math.max(c, t.floating.width));
41
58
  }
42
59
  })
43
60
  ]
44
61
  });
45
- o && ve && !T && V(z.startsWith("top") ? "top" : "bottom");
46
- const A = Ie(j), c = f(null), [r, ye] = l(null), Ee = d((e) => {
47
- c.current = e, ye(e);
48
- }, []), we = rt([_e(F.setFloating, A), Ee]), P = f(null), Pe = d((e) => {
49
- P.current = e, F.setReference(e);
50
- }, [F]), G = f(null), O = K?.length ? K.join(",") : void 0, Q = f(O);
51
- v(() => {
52
- Q.current = O;
53
- }, [O]);
54
- const h = d((e) => {
62
+ n && we && !S && V(G.startsWith("top") ? "top" : "bottom");
63
+ const I = _e(j), d = g(null), [i, Ee] = l(null), xe = p((e) => {
64
+ d.current = e, Ee(e);
65
+ }, []), ye = it([We(C.setFloating, I), xe]), F = g(null), Pe = p((e) => {
66
+ F.current = e, C.setReference(e);
67
+ }, [C]), Q = g(null), _ = K?.length ? K.join(",") : void 0, J = g(_);
68
+ b(() => {
69
+ J.current = _;
70
+ }, [_]);
71
+ const P = p((e) => {
55
72
  if (!(e instanceof Element)) return !1;
56
- if (c.current?.contains(e) || P.current?.contains(e) || G.current === e) return !0;
57
- const t = Q.current;
73
+ if (d.current?.contains(e) || F.current?.contains(e) || Q.current === e) return !0;
74
+ const t = J.current;
58
75
  return t !== void 0 && e.closest(t) !== null;
59
- }, []), J = f(null), xe = d((e) => {
60
- G.current = e.target, e.target instanceof HTMLElement && c.current?.contains(e.target) && (J.current = e.target);
61
- }, []), { getFloatingProps: be } = nt([tt(he, {
62
- enabled: !E,
76
+ }, []), Z = g(null), be = p((e) => {
77
+ Q.current = e.target, e.target instanceof HTMLElement && d.current?.contains(e.target) && (Z.current = e.target);
78
+ }, []), { getFloatingProps: Re } = rt([ot(ve, {
79
+ enabled: !A,
63
80
  escapeKey: !1,
64
81
  outsidePress: (e) => {
65
82
  const t = e.target;
66
83
  if (!(t instanceof Element)) return !0;
67
- if (h(t) || t.closest("[data-floating-ui-portal]")) return !1;
68
- const a = t.closest('dialog[open], [role="dialog"]');
69
- return !a || a.contains(c.current);
84
+ if (P(t) || t.closest("[data-floating-ui-portal]")) return !1;
85
+ const c = t.closest('dialog[open], [role="dialog"]');
86
+ return !c || c.contains(d.current);
70
87
  }
71
- })]), s = d(() => {
72
- w(!1);
73
- }, [w]);
74
- Be({
75
- active: o,
76
- requestClose: s,
77
- ownerRef: c
78
- }), v(() => {
79
- if (!o || E) return;
88
+ })]), a = p(() => {
89
+ T(!1);
90
+ }, [T]);
91
+ De({
92
+ active: n,
93
+ requestClose: a,
94
+ ownerRef: d
95
+ }), b(() => {
96
+ if (!n || A) return;
80
97
  const e = (t) => {
81
- t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(), We(t));
98
+ t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(), Be(t));
82
99
  };
83
100
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
84
- }, [o, E]), $e(o && n && r !== null, c);
85
- const [Z, Re] = l(!1);
86
- v(() => {
87
- if (!r || n && !Z) return;
101
+ }, [n, A]), Ke(n && r && i !== null, d);
102
+ const [ee, Ae] = l(!1);
103
+ b(() => {
104
+ if (!i || r && !ee) return;
88
105
  const e = requestAnimationFrame(() => {
89
- (n ? ne(r) : r)?.focus({ preventScroll: !0 });
106
+ (r ? re(i) : i)?.focus({ preventScroll: !0 });
90
107
  });
91
108
  return () => {
92
109
  cancelAnimationFrame(e);
93
110
  };
94
111
  }, [
112
+ i,
95
113
  r,
96
- n,
97
- Z
98
- ]), v(() => {
99
- if (!r) return;
114
+ ee
115
+ ]), b(() => {
116
+ if (!i) return;
100
117
  let e = 0;
101
118
  const t = () => {
102
119
  cancelAnimationFrame(e), e = requestAnimationFrame(() => {
103
- const i = document.activeElement;
104
- if (!r.isConnected || i && i !== document.body && h(i)) return;
105
- const M = J.current;
106
- (M?.isConnected && r.contains(M) ? M : ne(r) ?? r).focus({ preventScroll: !0 });
120
+ const s = document.activeElement;
121
+ if (!i.isConnected || s && s !== document.body && P(s)) return;
122
+ const k = Z.current;
123
+ (k?.isConnected && i.contains(k) ? k : re(i) ?? i).focus({ preventScroll: !0 });
107
124
  });
108
- }, a = (i) => {
109
- i.relatedTarget === null && s();
110
- }, te = (i) => {
111
- i.relatedTarget === null && h(i.target) && t();
112
- }, oe = (i) => {
113
- !r.isConnected || h(i.target) || (n ? t() : s());
125
+ }, c = (s) => {
126
+ s.relatedTarget === null && a();
127
+ }, oe = (s) => {
128
+ s.relatedTarget === null && P(s.target) && t();
129
+ }, ne = (s) => {
130
+ !i.isConnected || P(s.target) || (r ? t() : a());
114
131
  };
115
- return n ? document.addEventListener("focusout", te) : r.addEventListener("focusout", a), document.addEventListener("focusin", oe), () => {
116
- cancelAnimationFrame(e), document.removeEventListener("focusout", te), r.removeEventListener("focusout", a), document.removeEventListener("focusin", oe);
132
+ return r ? document.addEventListener("focusout", oe) : i.addEventListener("focusout", c), document.addEventListener("focusin", ne), () => {
133
+ cancelAnimationFrame(e), document.removeEventListener("focusout", oe), i.removeEventListener("focusout", c), document.removeEventListener("focusin", ne);
117
134
  };
118
135
  }, [
136
+ i,
119
137
  r,
120
- n,
121
- s,
122
- h
138
+ a,
139
+ P
123
140
  ]);
124
- const L = f(!1);
125
- v(() => {
126
- if (o) {
127
- qe(), L.current = !0;
141
+ const W = g(!1);
142
+ b(() => {
143
+ if (n) {
144
+ Xe(), W.current = !0;
128
145
  return;
129
146
  }
130
- if (!L.current) return;
131
- L.current = !1;
132
- const e = P.current;
147
+ if (!W.current) return;
148
+ W.current = !1;
149
+ const e = F.current;
133
150
  if (!e) return;
134
151
  const t = requestAnimationFrame(() => {
135
- document.activeElement === document.body && e.focus({ focusVisible: De() });
152
+ document.activeElement === document.body && e.focus({ focusVisible: qe() });
136
153
  });
137
154
  return () => {
138
155
  cancelAnimationFrame(t);
139
156
  };
140
- }, [o]);
141
- const ee = {
157
+ }, [n]);
158
+ const te = {
142
159
  ref: Pe,
143
- isOpen: o,
160
+ isOpen: n,
144
161
  triggerProps: {
145
162
  onClick: (e) => {
146
- if (o) {
147
- s();
163
+ if (n) {
164
+ a();
148
165
  return;
149
166
  }
150
- le(Ce(e.currentTarget));
151
- const t = e.currentTarget.getBoundingClientRect(), a = t.left + t.width / 2 > window.innerWidth / 2;
152
- fe($ === "auto" ? a ? "end" : "start" : $), V(void 0), Y(S), U(Math.round(window.innerHeight * se)), Re(e.detail === 0), w(!0);
167
+ de(Ie(e.currentTarget));
168
+ const t = e.currentTarget.getBoundingClientRect(), c = t.left + t.width / 2 > window.innerWidth / 2;
169
+ me($ === "auto" ? c ? "end" : "start" : $), V(void 0), z.release(), Y(H), U(Math.round(window.innerHeight * ae)), Ae(e.detail === 0), T(!0);
153
170
  },
154
- "aria-expanded": o,
155
- "aria-controls": o ? g : void 0,
156
- "aria-haspopup": n ? "dialog" : void 0,
157
- "aria-describedby": !n && o ? g : void 0
171
+ "aria-expanded": n,
172
+ "aria-controls": n ? y : void 0,
173
+ "aria-haspopup": r ? "dialog" : void 0,
174
+ "aria-describedby": !r && n ? y : void 0
158
175
  }
159
- }, x = (e) => typeof e == "function" ? e({ close: s }) : e, Te = Xe(b, 500), Fe = k ?? (b === void 0 ? void 0 : /* @__PURE__ */ m(ke, {
160
- dataTest: `${p}-view-results`,
176
+ }, L = (e) => typeof e == "function" ? e({ close: a }) : e, Te = $e(O, 500), Fe = E ?? (O === void 0 ? void 0 : /* @__PURE__ */ h(ke, {
177
+ dataTest: `${o}-view-results`,
161
178
  type: "button",
162
179
  variant: "text",
163
- onClick: s,
164
- children: je(Te, R)
165
- })), Ae = u ? ae : it[I], Oe = u ? ae : void 0;
166
- return E ? /* @__PURE__ */ ie(re, { children: [C(ee), /* @__PURE__ */ m(Ue, {
167
- id: g,
168
- dataTest: p,
169
- open: o,
170
- onClose: s,
180
+ onClick: a,
181
+ children: Ue(Te, M)
182
+ })), Le = m ? ce : st[w], Oe = m ? ce : void 0;
183
+ return A ? /* @__PURE__ */ se(ie, { children: [v(te), /* @__PURE__ */ h(Ve, {
184
+ id: y,
185
+ dataTest: o,
186
+ open: n,
187
+ onClose: a,
171
188
  registerBackClose: !1,
172
- ownerRef: c,
173
- triggerRef: P,
174
- title: y,
189
+ ownerRef: d,
190
+ triggerRef: F,
191
+ title: f,
175
192
  ariaLabel: D,
176
- viewResultsAction: k,
177
- resetAction: H,
178
- footerActions: W,
179
- resultCount: b,
180
- locale: R,
193
+ viewResultsAction: E,
194
+ resetAction: x,
195
+ footerActions: R,
196
+ resultCount: O,
197
+ locale: M,
181
198
  closeLabel: B,
182
199
  className: X,
183
- children: _
184
- })] }) : /* @__PURE__ */ ie(re, { children: [C(ee), o && /* @__PURE__ */ m(ze, {
200
+ children: u
201
+ })] }) : /* @__PURE__ */ se(ie, { children: [v(te), n && /* @__PURE__ */ h(Ge, {
185
202
  root: j,
186
- children: /* @__PURE__ */ m("div", {
187
- ...be(),
188
- onFocusCapture: xe,
189
- ref: we,
190
- id: g,
191
- "data-placement": z,
192
- "data-test": p,
193
- "data-testid": p,
194
- role: n ? "dialog" : void 0,
195
- "aria-labelledby": n && y ? N : void 0,
196
- "aria-label": n && !y ? D : void 0,
197
- tabIndex: n ? void 0 : -1,
198
- ...A ? Me : {},
203
+ children: /* @__PURE__ */ h("div", {
204
+ ...Re(),
205
+ onFocusCapture: be,
206
+ ref: ye,
207
+ id: y,
208
+ "data-placement": G,
209
+ "data-test": o,
210
+ "data-testid": o,
211
+ role: r ? "dialog" : void 0,
212
+ "aria-labelledby": r && f ? N : void 0,
213
+ "aria-label": r && !f ? D : void 0,
214
+ tabIndex: r ? void 0 : -1,
215
+ ...I ? Se : {},
199
216
  style: {
200
- ...A ? Se : {},
201
- ...ge,
202
- minWidth: u ? S : me,
217
+ ...I ? Ce : {},
218
+ ...he,
219
+ minWidth: m ? H : pe,
203
220
  width: Oe,
204
- maxWidth: Ae,
221
+ maxWidth: Le,
205
222
  maxHeight: ue
206
223
  },
207
- className: Le("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", X),
208
- children: /* @__PURE__ */ m(He.Provider, {
209
- value: c,
210
- children: /* @__PURE__ */ m(Ve, {
211
- dataTest: p,
212
- title: y,
224
+ className: Me("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", X),
225
+ children: /* @__PURE__ */ h(He.Provider, {
226
+ value: d,
227
+ children: /* @__PURE__ */ h(Ye, {
228
+ dataTest: o,
229
+ title: f,
213
230
  titleId: N,
214
- viewResultsAction: x(Fe),
215
- resetAction: x(H),
216
- footerActions: x(W),
231
+ viewResultsAction: L(Fe),
232
+ resetAction: L(x),
233
+ footerActions: L(R),
217
234
  closeLabel: B,
218
- onClose: s,
219
- children: x(_)
235
+ onClose: a,
236
+ children: L(u)
220
237
  })
221
238
  })
222
239
  })
223
240
  })] });
224
241
  };
225
242
  export {
226
- Rt as PopoverSheet
243
+ Tt as PopoverSheet
227
244
  };
@@ -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
+ };