asma-ui-core 3.136.1 → 3.137.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,46 +1,126 @@
1
- import { useRef as d, useState as p } from "react";
2
- var f = 0.3, g = 48, l = 4, h = (i, u, c) => {
3
- const [s, o] = p(0), n = d(null), a = (r, t) => {
4
- const e = n.current;
5
- e?.pointerId === r.pointerId && (n.current = null, r.currentTarget.hasPointerCapture(r.pointerId) && r.currentTarget.releasePointerCapture(r.pointerId), o(0), e.captured && (t > e.height * f ? u() : t < -g && c?.()));
1
+ import { useEffect as v, useRef as w, useState as m } from "react";
2
+ var S = 0.3, O = 48, g = 4, E = 0.5, N = 80, B = (H, f, p, d, a) => {
3
+ const [R, I] = m(0), [_, Y] = m(0), [x, D] = m(null), h = w(null), u = w({
4
+ onDismiss: f,
5
+ onDragUp: p,
6
+ onCollapse: d
7
+ });
8
+ v(() => {
9
+ u.current = {
10
+ onDismiss: f,
11
+ onDragUp: p,
12
+ onCollapse: d
13
+ };
14
+ }, [
15
+ f,
16
+ p,
17
+ d
18
+ ]);
19
+ const L = (t) => {
20
+ const e = H.current;
21
+ if (!e) return null;
22
+ const n = performance.now();
23
+ return {
24
+ startY: t,
25
+ height: e.getBoundingClientRect().height,
26
+ captured: !1,
27
+ onDragUp: u.current.onDragUp,
28
+ onCollapse: u.current.onCollapse,
29
+ samples: [{
30
+ y: t,
31
+ t: n
32
+ }]
33
+ };
34
+ }, T = (t, e) => {
35
+ const n = performance.now();
36
+ for (t.samples.push({
37
+ y: e,
38
+ t: n
39
+ }); t.samples.length > 2 && n - (t.samples[0]?.t ?? n) > N; ) t.samples.shift();
40
+ const c = e - t.startY, i = Math.max(0, c);
41
+ I(i), Y(t.height ? Math.min(1, i / t.height) : 0), D(t.onDragUp && c < 0 ? t.height - c : null);
42
+ }, M = (t, e) => {
43
+ if (I(0), Y(0), D(null), !t.captured || e === null) return;
44
+ const n = e - t.startY, c = t.samples[0], i = c ? performance.now() - c.t : 0, s = c && i > 0 ? (e - c.y) / i : 0;
45
+ if (t.onCollapse && n > 0) {
46
+ const r = window.innerHeight / 2;
47
+ s >= 0 && t.height - n < r * (1 - S) ? u.current.onDismiss() : (s > E || s >= 0 && n > O) && t.onCollapse();
48
+ return;
49
+ }
50
+ s > E || s >= 0 && n > t.height * S ? u.current.onDismiss() : (s < -E || n < -O) && t.onDragUp?.();
51
+ };
52
+ v(() => {
53
+ if (!a) return;
54
+ let t = null, e = !1, n = 0;
55
+ const c = (r) => {
56
+ const o = r.touches[0];
57
+ r.touches.length !== 1 || !o || (r.target instanceof Element ? r.target : null)?.closest('input, textarea, select, [contenteditable="true"]') || (t = L(o.clientY), e = !1, n = o.clientX);
58
+ }, i = (r) => {
59
+ const o = r.touches[0];
60
+ if (!t || !o) return;
61
+ const l = o.clientY - t.startY;
62
+ if (!e) {
63
+ const P = o.clientX - n;
64
+ if (Math.abs(l) < g && Math.abs(P) < g) return;
65
+ e = !0;
66
+ const A = l > 0 && a.scrollTop <= 0, U = l < 0 && !!t.onDragUp;
67
+ if (Math.abs(l) <= Math.abs(P) || !A && !U) {
68
+ t = null;
69
+ return;
70
+ }
71
+ t.captured = !0, t.startY = o.clientY;
72
+ }
73
+ r.cancelable && r.preventDefault(), T(t, o.clientY);
74
+ }, s = (r) => {
75
+ const o = t;
76
+ if (t = null, !o) return;
77
+ const l = r.changedTouches[0];
78
+ M(o, r.type === "touchcancel" || !l ? null : l.clientY);
79
+ };
80
+ return a.addEventListener("touchstart", c, { passive: !0 }), a.addEventListener("touchmove", i, { passive: !1 }), a.addEventListener("touchend", s), a.addEventListener("touchcancel", s), () => {
81
+ a.removeEventListener("touchstart", c), a.removeEventListener("touchmove", i), a.removeEventListener("touchend", s), a.removeEventListener("touchcancel", s);
82
+ };
83
+ }, [a]);
84
+ const C = (t, e) => {
85
+ const n = h.current;
86
+ n?.pointerId === t.pointerId && (h.current = null, t.currentTarget.hasPointerCapture(t.pointerId) && t.currentTarget.releasePointerCapture(t.pointerId), M(n, e));
6
87
  };
7
88
  return {
8
- dragOffset: s,
89
+ dragOffset: R,
90
+ dragRatio: _,
91
+ liftedHeight: x,
9
92
  dragHandleProps: {
10
- onPointerDown: (r) => {
11
- if (r.pointerType === "mouse" && r.button !== 0 || r.target instanceof Element && r.target.closest("button:not([data-drag-handle])")) return;
12
- const t = i.current;
13
- t && (n.current = {
14
- pointerId: r.pointerId,
15
- startY: r.clientY,
16
- height: t.getBoundingClientRect().height,
17
- captured: !1
93
+ onPointerDown: (t) => {
94
+ if (t.pointerType === "mouse" && t.button !== 0 || t.target instanceof Element && t.target.closest("button:not([data-drag-handle])")) return;
95
+ const e = L(t.clientY);
96
+ e && (h.current = {
97
+ ...e,
98
+ pointerId: t.pointerId
18
99
  });
19
100
  },
20
- onPointerMove: (r) => {
21
- const t = n.current;
22
- if (t?.pointerId !== r.pointerId) return;
23
- const e = r.clientY - t.startY;
24
- if (!t.captured) {
25
- if (Math.abs(e) < l) return;
26
- t.captured = !0;
27
- try {
28
- r.currentTarget.setPointerCapture(r.pointerId);
29
- } catch {
101
+ onPointerMove: (t) => {
102
+ const e = h.current;
103
+ if (e?.pointerId === t.pointerId) {
104
+ if (!e.captured) {
105
+ if (Math.abs(t.clientY - e.startY) < g) return;
106
+ e.captured = !0;
107
+ try {
108
+ t.currentTarget.setPointerCapture(t.pointerId);
109
+ } catch {
110
+ }
30
111
  }
112
+ T(e, t.clientY);
31
113
  }
32
- o(Math.max(0, e));
33
114
  },
34
- onPointerUp: (r) => {
35
- const t = n.current;
36
- a(r, t ? r.clientY - t.startY : 0);
115
+ onPointerUp: (t) => {
116
+ C(t, t.clientY);
37
117
  },
38
- onPointerCancel: (r) => {
39
- a(r, 0);
118
+ onPointerCancel: (t) => {
119
+ C(t, null);
40
120
  }
41
121
  }
42
122
  };
43
123
  };
44
124
  export {
45
- h as useDragToDismiss
125
+ B as useDragToDismiss
46
126
  };
@@ -43,6 +43,13 @@ export interface TooltipProps {
43
43
  persistentDescription?: boolean;
44
44
  /** Share the persistent description with every focusable item in a composite control. */
45
45
  persistentDescriptionId?: string;
46
+ /**
47
+ * Whether the trigger gets `aria-describedby` pointing at the tooltip while it is open. It does by default.
48
+ * Pass `false` for a tooltip that only repeats text the trigger's accessible name already holds, such as a truncated
49
+ * label shown in full (a table header): the tooltip is then visual only, and a screen reader does not hear the text
50
+ * twice. It ignores `persistentDescription`, which exists to describe the trigger.
51
+ */
52
+ describesTrigger?: boolean;
46
53
  offsetDistance?: number;
47
54
  className?: string;
48
55
  slotProps?: TooltipSlotProps;
@@ -73,8 +73,14 @@ export interface StyledBottomSheetProps {
73
73
  * can be expanded to 90vh — by dragging the handle up, or by activating it (Tab lands on it, Space /
74
74
  * Enter toggle between the two heights) — and scrolls internally from there. Below 480px of viewport
75
75
  * height (a phone in landscape) it becomes a full-screen dialog instead. Five equivalent dismiss
76
- * routes — close button, "Vis resultater", scrim, Escape, dragging down past 30% — and none of them
77
- * commits or discards anything: filters apply as the user goes and actions commit on activation.
76
+ * routes — close button, "Vis resultater", scrim, Escape, dragging down past 30% or flinging down — and
77
+ * none of them commits or discards anything: filters apply as the user goes and actions commit on
78
+ * activation.
79
+ *
80
+ * Motion follows Material 3: the sheet tracks the finger (on the handle, or on the body while it is
81
+ * scrolled to the top or can still expand), the scrim fades with a downward drag, a release settles on
82
+ * emphasized-decelerate, and closing slides the sheet out on emphasized-accelerate before the dialog
83
+ * closes. `prefers-reduced-motion` keeps all of it instant.
78
84
  *
79
85
  * Interaction model is the popover's: `role="dialog"`, `Tab` only, no `role="menu"`, no arrow keys.
80
86
  * Focus moves to the sheet on open (so the title is announced first) and back to the trigger on
@@ -10,15 +10,26 @@ interface DragToDismiss {
10
10
  dragHandleProps: DragHandleProps;
11
11
  /** How far the sheet is currently dragged down, in px. `0` when at rest. */
12
12
  dragOffset: number;
13
+ /** `dragOffset` as a share of the sheet's height, for the scrim to fade with the drag. */
14
+ dragRatio: number;
15
+ /** While the sheet is dragged up and can expand: its height under the finger, in px. */
16
+ liftedHeight: number | null;
13
17
  }
14
18
  /**
15
- * Drag the sheet down past 30% of its height to dismiss it; release earlier and it snaps back. Drag it
16
- * up by 48px and `onDragUp` runs, which expands a sheet that has a taller height.
19
+ * Drag the sheet down past 30% of its height, or fling it down, to dismiss it; release earlier and it
20
+ * settles back. Dragged up, a sheet that could expand when the gesture started follows the finger
21
+ * (`liftedHeight`); released after 48px or flung up, `onDragUp` expands it, otherwise it settles back.
22
+ * The way back is a drag too: an expanded sheet (`onCollapse`) dragged down 48px or flung down returns
23
+ * to half height, and only a drag that leaves less than 70% of that half on screen dismisses it.
24
+ *
25
+ * The drag starts on the handle row (any pointer) or, on touch, anywhere in the `body` while
26
+ * the body is scrolled to its top and the finger moves down, or while the sheet can still expand and the
27
+ * finger moves up — as Material's bottom sheet does. Otherwise the body just scrolls.
17
28
  *
18
29
  * Deliberately never the only exit or the only way to resize (WCAG 2.5.7): the close button, the scrim
19
30
  * and Escape close it, and the drag handle toggles the height as a button. A press that starts on any
20
31
  * other button in the drag zone is left alone, so the close control keeps working as a plain click.
21
32
  * The pointer is captured only once it has moved, so a tap on the drag handle stays a click.
22
33
  */
23
- export declare const useDragToDismiss: (sheetRef: RefObject<HTMLElement | null>, onDismiss: () => void, onDragUp?: () => void) => DragToDismiss;
34
+ export declare const useDragToDismiss: (sheetRef: RefObject<HTMLElement | null>, onDismiss: () => void, onDragUp?: () => void, onCollapse?: () => void, body?: HTMLElement | null) => DragToDismiss;
24
35
  export {};
@@ -0,0 +1,33 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Whether a header's label is cut short by its column, as an ellipsis shows it, or is about to be.
4
+ *
5
+ * A text header is the label element itself, and an element header (a function header) is a child that the stylesheet
6
+ * clamps to the label, so both are read. `scrollWidth` and `clientWidth` are whole pixels, so an overflow of less
7
+ * than half a pixel is not seen.
8
+ *
9
+ * An unsorted sortable header takes its 20px slot from the label while it is hovered or keyboard-focused. A label with
10
+ * less than that left over is cut short the moment the pointer arrives, so it counts as truncated at rest: the
11
+ * tooltip has to be ready for that hover, because it cannot open for a pointer that is already there.
12
+ */
13
+ export declare const isHeaderLabelTruncated: (row: HTMLElement, label: HTMLElement) => boolean;
14
+ /**
15
+ * Tells a header cell whether its label is truncated, and keeps telling it as the column is resized, the label
16
+ * changes or the sort slot opens (ASMA-8597, a tooltip for the truncated header text).
17
+ *
18
+ * `rowRef` goes on the header's content row (the sortable element) and `labelRef` on the label's box. Two observers
19
+ * between them see every change that can alter the answer:
20
+ * - a `ResizeObserver` on the row and the label sees a resize of the column, the sort slot opening and a text that
21
+ * changes the width of a label that is as wide as its text (a sortable header's), and gives the first answer;
22
+ * - a `MutationObserver` on the label's content sees the text, the children and the `style` and `class` of anything in it
23
+ * change. A header that cannot sort fills its column, so a new text, or a `style` or `class` that widens it, at the same
24
+ * column width changes only the label's `scrollWidth`, which no resize observation reports. Only those two attributes
25
+ * are watched, and nothing this hook, the tooltip or the header does sets one inside the label, so measuring never
26
+ * causes the next measuring (a test counts the callbacks).
27
+ * Nothing is measured while `enabled` is false.
28
+ */
29
+ export declare const useHeaderTruncation: (enabled: boolean) => {
30
+ rowRef: RefObject<HTMLDivElement>;
31
+ labelRef: RefObject<HTMLDivElement>;
32
+ truncated: boolean;
33
+ };
@@ -0,0 +1,7 @@
1
+ import { ColumnDef, RowData } from '@tanstack/react-table';
2
+ /**
3
+ * The text a column is called by: `pinnedHeaderText` when the column sets it (a function header cannot say its own text),
4
+ * else a string header, else `undefined`. The column settings list a column by this text (falling back to the column id),
5
+ * and a truncated header shows it in a tooltip, so the two always read alike.
6
+ */
7
+ export declare const headerLabelText: <TData extends RowData, TValue>(columnDef: ColumnDef<TData, TValue>) => string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { cn as v } from "../../../../../helpers/cn.js";
2
2
  import { StyledBadge as N } from "../../../../../components/data-display/badge/StyledBadge.js";
3
3
  import { PinIcon as _ } from "../../../../../components/icons/pin-icon/PinIcon.js";
4
- import { StyledPopover as D } from "../../../../../components/utils/popover/StyledPopover.js";
5
- import { message as T } from "../../../../../components/feedback/snack-bar/message.js";
4
+ import { StyledPopover as T } from "../../../../../components/utils/popover/StyledPopover.js";
5
+ import { message as D } from "../../../../../components/feedback/snack-bar/message.js";
6
6
  import { INTERNAL_COLUMN_IDS as L } from "../../../../types.js";
7
7
  import { hasChangedColumnLayout as k } from "../../../../custom-features/order-columns/columnLayout.js";
8
8
  import { StyledCheckbox as A } from "../../../../shared-components/StyledCheckbox.js";
@@ -11,23 +11,24 @@ import { useToggleMenuVisibility as H } from "../../../../hooks/useToggleMenuVis
11
11
  import f from "./TableActions.module.js";
12
12
  import d from "./HeaderActionMenu.module.js";
13
13
  import { DotsHorizontalIcon as O } from "../../../../shared-components/DotsHorizontalIcon.js";
14
- import { useTranslations as R } from "../../../../hooks/useTranslations.js";
15
- import { StyledButton as w } from "../../../../shared-components/button/StyledButton.js";
16
- import { compact as E } from "../../../../../helpers/arrays.js";
17
- import { jsx as o, jsxs as u } from "react/jsx-runtime";
18
- import { DndContext as M, PointerSensor as P, closestCenter as V, useSensor as W, useSensors as z } from "@dnd-kit/core";
19
- import { restrictToParentElement as B, restrictToVerticalAxis as j } from "@dnd-kit/modifiers";
20
- import { SortableContext as U, arrayMove as Y, useSortable as $, verticalListSortingStrategy as q } from "@dnd-kit/sortable";
21
- import { CSS as F } from "@dnd-kit/utilities";
22
- function G({ id: n, disabled: p, children: h }) {
23
- const { attributes: c, listeners: b, setNodeRef: g, transform: m, transition: l } = $({
14
+ import { headerLabelText as R } from "../../../../helpers/headerLabel.js";
15
+ import { useTranslations as w } from "../../../../hooks/useTranslations.js";
16
+ import { StyledButton as E } from "../../../../shared-components/button/StyledButton.js";
17
+ import { compact as M } from "../../../../../helpers/arrays.js";
18
+ import { jsx as i, jsxs as u } from "react/jsx-runtime";
19
+ import { DndContext as P, PointerSensor as V, closestCenter as W, useSensor as z, useSensors as B } from "@dnd-kit/core";
20
+ import { restrictToParentElement as j, restrictToVerticalAxis as U } from "@dnd-kit/modifiers";
21
+ import { SortableContext as Y, arrayMove as $, useSortable as q, verticalListSortingStrategy as F } from "@dnd-kit/sortable";
22
+ import { CSS as G } from "@dnd-kit/utilities";
23
+ function J({ id: n, disabled: p, children: h }) {
24
+ const { attributes: c, listeners: b, setNodeRef: g, transform: m, transition: l } = q({
24
25
  id: n,
25
26
  disabled: p
26
27
  });
27
- return /* @__PURE__ */ o("div", {
28
+ return /* @__PURE__ */ i("div", {
28
29
  ref: g,
29
30
  style: {
30
- transform: F.Transform.toString(m),
31
+ transform: G.Transform.toString(m),
31
32
  transition: l
32
33
  },
33
34
  className: d["drag-item"],
@@ -37,14 +38,14 @@ function G({ id: n, disabled: p, children: h }) {
37
38
  })
38
39
  });
39
40
  }
40
- function be({ headerData: n, locale: p }) {
41
+ function xe({ headerData: n, locale: p }) {
41
42
  const { anchorEl: h, open: c, handleClose: b, handleOpen: g } = H(), m = k(n.table), l = n.table.getAllLeafColumns(), S = (e) => {
42
43
  const { active: r, over: t } = e;
43
- !r || !t || r.id === t.id || l.find((i) => i.id === t.id)?.columnDef.fixedLeft || l.find((i) => i.id === t.id)?.columnDef.fixedRight || n.table.setColumnOrder((i) => {
44
- const a = E(i ?? []).length ? i : n.table.getAllLeafColumns().map((C) => C.id);
45
- return Y(a, a.indexOf(r.id), a.indexOf(t.id));
44
+ !r || !t || r.id === t.id || l.find((o) => o.id === t.id)?.columnDef.fixedLeft || l.find((o) => o.id === t.id)?.columnDef.fixedRight || n.table.setColumnOrder((o) => {
45
+ const a = M(o ?? []).length ? o : n.table.getAllLeafColumns().map((C) => C.id);
46
+ return $(a, a.indexOf(r.id), a.indexOf(t.id));
46
47
  });
47
- }, y = z(W(P, { activationConstraint: { distance: 8 } })), s = R(p), x = l.filter((e) => !L.includes(e.id) && !!e.columnDef.header);
48
+ }, y = B(z(V, { activationConstraint: { distance: 8 } })), s = w(p), x = l.filter((e) => !L.includes(e.id) && !!e.columnDef.header);
48
49
  return /* @__PURE__ */ u("div", {
49
50
  className: f["actions-header-wrapper"],
50
51
  children: [/* @__PURE__ */ u("button", {
@@ -55,13 +56,13 @@ function be({ headerData: n, locale: p }) {
55
56
  tabIndex: n.table.options.meta?.hideHeader ? -1 : void 0,
56
57
  className: f["actions-header"],
57
58
  onClick: g,
58
- children: [/* @__PURE__ */ o(_, { className: f["pin-icon"] }), m && /* @__PURE__ */ o(N, {
59
+ children: [/* @__PURE__ */ i(_, { className: f["pin-icon"] }), m && /* @__PURE__ */ i(N, {
59
60
  dataTest: "column-settings-dot",
60
61
  variant: "dot",
61
62
  purpose: "filter",
62
63
  className: f["pin-dot"]
63
64
  })]
64
- }), /* @__PURE__ */ u(D, {
65
+ }), /* @__PURE__ */ u(T, {
65
66
  anchorEl: h,
66
67
  anchorOrigin: {
67
68
  horizontal: "left",
@@ -74,25 +75,25 @@ function be({ headerData: n, locale: p }) {
74
75
  overflowY: "auto",
75
76
  scrollbarWidth: "thin"
76
77
  } } },
77
- children: [/* @__PURE__ */ o(M, {
78
- modifiers: [j, B],
78
+ children: [/* @__PURE__ */ i(P, {
79
+ modifiers: [U, j],
79
80
  onDragEnd: S,
80
- collisionDetection: (e) => V(e).filter((r) => {
81
- const t = x.find((i) => i.id === r.id);
81
+ collisionDetection: (e) => W(e).filter((r) => {
82
+ const t = x.find((o) => o.id === r.id);
82
83
  return !t?.columnDef.fixedLeft && !t?.columnDef.fixedRight;
83
84
  }),
84
85
  sensors: y,
85
- children: /* @__PURE__ */ o(U, {
86
+ children: /* @__PURE__ */ i(Y, {
86
87
  items: x.map((e) => e.id),
87
- strategy: q,
88
+ strategy: F,
88
89
  children: x.map((e) => {
89
90
  const r = !!e.columnDef.fixedLeft || !!e.columnDef.fixedRight, t = e.columnDef.enableHiding === !1;
90
- let i = null;
91
- return r && t ? i = s.column_reorder_and_hidden : r ? i = s.column_reorder : t && (i = s.column_hidden), /* @__PURE__ */ o(G, {
91
+ let o = null;
92
+ return r && t ? o = s.column_reorder_and_hidden : r ? o = s.column_reorder : t && (o = s.column_hidden), /* @__PURE__ */ i(J, {
92
93
  id: e.id,
93
94
  disabled: r,
94
- children: ({ listeners: a, attributes: C }) => /* @__PURE__ */ o(I, {
95
- title: i,
95
+ children: ({ listeners: a, attributes: C }) => /* @__PURE__ */ i(I, {
96
+ title: o,
96
97
  arrow: !0,
97
98
  children: /* @__PURE__ */ u("button", {
98
99
  type: "button",
@@ -101,7 +102,7 @@ function be({ headerData: n, locale: p }) {
101
102
  },
102
103
  className: d["table-action-item"],
103
104
  children: [
104
- /* @__PURE__ */ o(O, {
105
+ /* @__PURE__ */ i(O, {
105
106
  width: 20,
106
107
  height: 20,
107
108
  ...C,
@@ -114,9 +115,9 @@ function be({ headerData: n, locale: p }) {
114
115
  },
115
116
  className: v(d["drag-icon"], r ? d["drag-icon--disabled"] : d["drag-icon--enabled"])
116
117
  }),
117
- /* @__PURE__ */ o("span", {
118
+ /* @__PURE__ */ i("span", {
118
119
  className: "px-2",
119
- children: /* @__PURE__ */ o(A, {
120
+ children: /* @__PURE__ */ i(A, {
120
121
  readOnly: t,
121
122
  dataTest: `${e.id}-column-visibility-checkbox`,
122
123
  size: "small",
@@ -126,9 +127,9 @@ function be({ headerData: n, locale: p }) {
126
127
  className: "pointer-events-none"
127
128
  })
128
129
  }),
129
- /* @__PURE__ */ o("span", {
130
+ /* @__PURE__ */ i("span", {
130
131
  className: "font-roboto text-base text-delta-700",
131
- children: e.columnDef.pinnedHeaderText ?? (typeof e.columnDef.header == "string" ? e.columnDef.header : e.id)
132
+ children: R(e.columnDef) ?? e.id
132
133
  })
133
134
  ]
134
135
  })
@@ -136,14 +137,14 @@ function be({ headerData: n, locale: p }) {
136
137
  }, e.id);
137
138
  })
138
139
  })
139
- }), /* @__PURE__ */ o("div", {
140
+ }), /* @__PURE__ */ i("div", {
140
141
  className: "pb-2 pl-2",
141
- children: /* @__PURE__ */ o(w, {
142
+ children: /* @__PURE__ */ i(E, {
142
143
  dataTest: "reset-order-button",
143
144
  variant: "text",
144
145
  className: "h-10",
145
146
  onClick: () => {
146
- n.table.resetColumnSettings(), T.info(s.columns_reset, { closeButton: !0 });
147
+ n.table.resetColumnSettings(), D.info(s.columns_reset, { closeButton: !0 });
147
148
  },
148
149
  children: s.reset_columns
149
150
  })
@@ -152,5 +153,5 @@ function be({ headerData: n, locale: p }) {
152
153
  });
153
154
  }
154
155
  export {
155
- be as HeaderActionMenu
156
+ xe as HeaderActionMenu
156
157
  };
@@ -1,72 +1,83 @@
1
- import { ACTIONS_COLUMN_ID as D, INTERNAL_COLUMN_IDS as R } from "../../types.js";
2
- import { useRootContext as L } from "../../context/RootContext.js";
3
- import { hasFixedWidth as A } from "../../helpers/columnSizingDefaults.js";
4
- import e from "../StyledTable.module.js";
5
- import { SortIndicator as O } from "./SortIndicator.js";
6
- import { getTableHeaderStyle as E } from "../../helpers/getTableHeaderStyle.js";
7
- import { getSortPreview as M } from "../../helpers/sortPreview.js";
1
+ import { ACTIONS_COLUMN_ID as C, INTERNAL_COLUMN_IDS as b } from "../../types.js";
2
+ import { useRootContext as j } from "../../context/RootContext.js";
3
+ import { hasFixedWidth as U } from "../../helpers/columnSizingDefaults.js";
4
+ import t from "../StyledTable.module.js";
5
+ import { StyledTooltip as $ } from "../../shared-components/tooltip/index.js";
6
+ import { headerLabelText as Z } from "../../helpers/headerLabel.js";
7
+ import { SortIndicator as K } from "./SortIndicator.js";
8
+ import { getTableHeaderStyle as W } from "../../helpers/getTableHeaderStyle.js";
9
+ import { getSortPreview as q } from "../../helpers/sortPreview.js";
10
+ import { useHeaderTruncation as J } from "./useHeaderTruncation.js";
8
11
  import _ from "clsx";
9
- import { useMemo as r } from "react";
10
- import { jsx as l, jsxs as k } from "react/jsx-runtime";
11
- import { flexRender as B } from "@tanstack/react-table";
12
- function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, right: v, tableWidth: H }) {
13
- const { hideHeader: c = !1, enableResizing: m = !1, actions: I, customActionsNode: T } = z, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = L(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === D, h = !!I || !!T, S = r(() => o.headerGroup.headers.some((t) => t.id === D), [o.headerGroup.headers]), w = r(() => o.headerGroup.headers.some((t) => !!t.column.columnDef.fixedRight), [o.headerGroup.headers]), y = r(() => o.headerGroup.headers[o.headerGroup.headers.length - (S ? 2 : 1)], [o.headerGroup.headers, S]), n = o.column.getCanSort(), s = o.column.getIsSorted(), x = o.getContext().table.getState().sorting, F = M({
14
- sorted: s,
12
+ import { useMemo as c, useState as Q } from "react";
13
+ import { jsx as s, jsxs as V } from "react/jsx-runtime";
14
+ import { flexRender as X } from "@tanstack/react-table";
15
+ function po({ styledTableProps: T, header: o, tableCanResize: v = !1, left: N, right: H, tableWidth: I }) {
16
+ const { hideHeader: l = !1, enableResizing: m = !1, actions: w, customActionsNode: y } = T, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = j(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === C, L = !!w || !!y, S = c(() => o.headerGroup.headers.some((e) => e.id === C), [o.headerGroup.headers]), h = c(() => o.headerGroup.headers.some((e) => !!e.column.columnDef.fixedRight), [o.headerGroup.headers]), F = c(() => o.headerGroup.headers[o.headerGroup.headers.length - (S ? 2 : 1)], [o.headerGroup.headers, S]), n = o.column.getCanSort(), r = o.column.getIsSorted(), x = o.getContext().table.getState().sorting, G = q({
17
+ sorted: r,
15
18
  firstDirection: o.column.getFirstSortDir(),
16
19
  nextOrder: o.column.getNextSortingOrder(),
17
20
  isLastSortEntry: x[x.length - 1]?.id === o.column.id
18
- }), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !== y?.id) && o.column.getCanResize() && !A(o.column.columnDef) && !R.includes(o.column.id);
19
- return /* @__PURE__ */ l("th", {
21
+ }), M = n ? r === "asc" ? "ascending" : r === "desc" ? "descending" : "none" : void 0, R = v && (m ? !0 : o.id !== F?.id) && o.column.getCanResize() && !U(o.column.columnDef) && !b.includes(o.column.id), D = Z(o.column.columnDef), { rowRef: O, labelRef: A, truncated: E } = J(!l && !!D?.trim()), [B, z] = Q(!1), k = E && !o.column.getIsResizing() && !B ? D : "", P = /* @__PURE__ */ V("div", {
22
+ ref: O,
23
+ className: _("flex items-center justify-start", l ? t["hide-table-header"] : t["show-table-header"], n && t["sortable-column"], R && t["has-resize-zone"], o.column.columnDef.className),
24
+ role: n ? "button" : void 0,
25
+ tabIndex: n && !l ? 0 : void 0,
26
+ onClick: (e) => {
27
+ const i = o.column.getToggleSortingHandler();
28
+ !a && i && i(e), d();
29
+ },
30
+ onKeyDown: n ? (e) => {
31
+ if (e.key !== "Enter" && e.key !== " ") return;
32
+ e.preventDefault();
33
+ const i = o.column.getToggleSortingHandler();
34
+ !a && i && i(e), d();
35
+ } : void 0,
36
+ children: [
37
+ /* @__PURE__ */ s("div", {
38
+ ref: A,
39
+ className: t["header-content"],
40
+ children: X(o.column.columnDef.header, o.getContext())
41
+ }),
42
+ n && /* @__PURE__ */ s(K, {
43
+ sorted: r,
44
+ firstDirection: o.column.getFirstSortDir(),
45
+ preview: G
46
+ }),
47
+ R && /* @__PURE__ */ s("div", {
48
+ onMouseEnter: () => z(!0),
49
+ onMouseLeave: () => z(!1),
50
+ onDoubleClick: () => o.column.resetSize(),
51
+ onMouseDown: (e) => {
52
+ e.stopPropagation(), u(), o.getResizeHandler()(e);
53
+ },
54
+ onTouchStart: (e) => {
55
+ e.stopPropagation(), u(), o.getResizeHandler()(e);
56
+ },
57
+ className: `${t.resizer} ${o.column.getIsResizing() ? t.isResizing : ""}`
58
+ })
59
+ ]
60
+ });
61
+ return /* @__PURE__ */ s("th", {
20
62
  colSpan: o.colSpan,
21
- "aria-sort": G,
22
- className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], c && e["hide-header"], p && e["t-cell__actions"], p && (!h || w) && e["t-cell__actions--no-shadow"], g && e["t-cell__fixed"], f && e["t-cell__fixed-right"]),
63
+ "aria-sort": M,
64
+ className: _(t["t-cell"], !b.includes(o.column.id) && o.column.getSize() > 64 && t["data-cell"], o.column.id === "select" && t["select-cell"], l && t["hide-header"], p && t["t-cell__actions"], p && (!L || h) && t["t-cell__actions--no-shadow"], g && t["t-cell__fixed"], f && t["t-cell__fixed-right"]),
23
65
  style: {
24
- ...E({
66
+ ...W({
25
67
  enableResizing: m,
26
68
  header: o,
27
- tableWidth: H
69
+ tableWidth: I
28
70
  }),
29
71
  ...g && { left: N },
30
- ...f && { right: v }
72
+ ...f && { right: H }
31
73
  },
32
- children: /* @__PURE__ */ k("div", {
33
- className: _("flex items-center justify-start", c ? e["hide-table-header"] : e["show-table-header"], n && e["sortable-column"], C && e["has-resize-zone"], o.column.columnDef.className),
34
- role: n ? "button" : void 0,
35
- tabIndex: n && !c ? 0 : void 0,
36
- onClick: (t) => {
37
- const i = o.column.getToggleSortingHandler();
38
- !a && i && i(t), d();
39
- },
40
- onKeyDown: n ? (t) => {
41
- if (t.key !== "Enter" && t.key !== " ") return;
42
- t.preventDefault();
43
- const i = o.column.getToggleSortingHandler();
44
- !a && i && i(t), d();
45
- } : void 0,
46
- children: [
47
- /* @__PURE__ */ l("div", {
48
- className: e["header-content"],
49
- children: B(o.column.columnDef.header, o.getContext())
50
- }),
51
- n && /* @__PURE__ */ l(O, {
52
- sorted: s,
53
- firstDirection: o.column.getFirstSortDir(),
54
- preview: F
55
- }),
56
- C && /* @__PURE__ */ l("div", {
57
- onDoubleClick: () => o.column.resetSize(),
58
- onMouseDown: (t) => {
59
- t.stopPropagation(), u(), o.getResizeHandler()(t);
60
- },
61
- onTouchStart: (t) => {
62
- t.stopPropagation(), u(), o.getResizeHandler()(t);
63
- },
64
- className: `${e.resizer} ${o.column.getIsResizing() ? e.isResizing : ""}`
65
- })
66
- ]
74
+ children: /* @__PURE__ */ s($, {
75
+ title: k,
76
+ describesTrigger: !1,
77
+ children: P
67
78
  })
68
79
  }, o.id);
69
80
  }
70
81
  export {
71
- Z as TableHeaderCell
82
+ po as TableHeaderCell
72
83
  };
@@ -0,0 +1,35 @@
1
+ import { useEffect as f, useRef as l, useState as g } from "react";
2
+ var v = 20, d = (e) => e.scrollWidth > e.clientWidth, b = (e, t) => {
3
+ if (d(t) || Array.from(t.children).some((r) => r instanceof HTMLElement && d(r))) return !0;
4
+ const s = e.querySelector("[data-sort-state]");
5
+ if (!s) return !1;
6
+ const n = v - s.getBoundingClientRect().width;
7
+ if (n <= 0) return !1;
8
+ const i = getComputedStyle(e);
9
+ return e.getBoundingClientRect().right - parseFloat(i.paddingRight) - parseFloat(i.borderRightWidth) - t.getBoundingClientRect().right < n;
10
+ }, h = (e) => {
11
+ const t = l(null), s = l(null), [n, i] = g(!1);
12
+ return f(() => {
13
+ const r = t.current, o = s.current;
14
+ if (!e || !r || !o || typeof ResizeObserver > "u") return;
15
+ const a = () => i(b(r, o)), u = new ResizeObserver(a);
16
+ u.observe(r), u.observe(o);
17
+ const c = new MutationObserver(a);
18
+ return c.observe(o, {
19
+ attributeFilter: ["style", "class"],
20
+ attributes: !0,
21
+ characterData: !0,
22
+ childList: !0,
23
+ subtree: !0
24
+ }), () => {
25
+ u.disconnect(), c.disconnect();
26
+ };
27
+ }, [e]), {
28
+ rowRef: t,
29
+ labelRef: s,
30
+ truncated: e && n
31
+ };
32
+ };
33
+ export {
34
+ h as useHeaderTruncation
35
+ };
@@ -0,0 +1,4 @@
1
+ var r = (e) => e.pinnedHeaderText ?? (typeof e.header == "string" ? e.header : void 0);
2
+ export {
3
+ r as headerLabelText
4
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.136.1",
6
+ "version": "3.137.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",