asma-ui-core 3.136.2 → 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,14 +1,14 @@
1
- import { cn as ee } from "../../../helpers/cn.js";
2
- import { resolveSx as te } from "../../../helpers/sx.js";
3
- import { firstFocusable as oe, firstTabbable as ne } from "../../../helpers/focusable.js";
4
- import { TOP_LAYER_PROPS as re, TOP_LAYER_RESET_STYLE as se, getOpenModalDialogAncestor as ie, shouldUsePopoverTopLayer as ce, useTopLayerRef as le } from "../../../hooks/useTopLayer.hook.js";
5
- import { Fragment as ae, cloneElement as fe, useCallback as ue, useEffect as U, useId as pe, useLayoutEffect as L, useMemo as de, useRef as H, useState as me } from "react";
6
- import { Fragment as k, jsx as b, jsxs as _ } from "react/jsx-runtime";
7
- import { FloatingArrow as ge, FloatingPortal as be, arrow as Re, autoUpdate as ye, flip as ve, offset as Ee, safePolygon as he, shift as Pe, useDismiss as xe, useFloating as Te, useFocus as we, useHover as Fe, useInteractions as Oe, useMergeRefs as Ae, useRole as Le } from "@floating-ui/react";
8
- var _e = "#363E4A", De = (t) => {
1
+ import { cn as te } from "../../../helpers/cn.js";
2
+ import { resolveSx as oe } from "../../../helpers/sx.js";
3
+ import { firstFocusable as ne, firstTabbable as re } from "../../../helpers/focusable.js";
4
+ import { TOP_LAYER_PROPS as se, TOP_LAYER_RESET_STYLE as ie, getOpenModalDialogAncestor as ce, shouldUsePopoverTopLayer as le, useTopLayerRef as ae } from "../../../hooks/useTopLayer.hook.js";
5
+ import { Fragment as fe, cloneElement as ue, useCallback as pe, useEffect as H, useId as de, useLayoutEffect as L, useMemo as me, useRef as k, useState as ge } from "react";
6
+ import { Fragment as Y, jsx as R, jsxs as _ } from "react/jsx-runtime";
7
+ import { FloatingArrow as Re, FloatingPortal as be, arrow as ye, autoUpdate as ve, flip as Ee, offset as he, safePolygon as Pe, shift as xe, useDismiss as Te, useFloating as we, useFocus as Fe, useHover as Oe, useInteractions as Ae, useMergeRefs as Le, useRole as _e } from "@floating-ui/react";
8
+ var De = "#363E4A", Me = (t) => {
9
9
  const n = document.createRange();
10
10
  return n.selectNodeContents(t), n.getBoundingClientRect();
11
- }, Me = [
11
+ }, Se = [
12
12
  "onFocus",
13
13
  "onBlur",
14
14
  "onMouseEnter",
@@ -18,41 +18,41 @@ var _e = "#363E4A", De = (t) => {
18
18
  "onPointerEnter",
19
19
  "onPointerUp",
20
20
  "onKeyDown"
21
- ], ke = ({ children: t, ...n }) => {
22
- const s = H({ element: null }), E = ue((i) => {
21
+ ], Ye = ({ children: t, ...n }) => {
22
+ const s = k({ element: null }), E = pe((i) => {
23
23
  s.current.element = i, s.current.setReference?.(i);
24
- }, []), c = t.type === ae, l = c ? /* @__PURE__ */ b("span", {
24
+ }, []), c = t.type === fe, l = c ? /* @__PURE__ */ R("span", {
25
25
  style: { display: "contents" },
26
26
  children: t
27
- }) : t, a = l.props, R = Ae([E, Object.getOwnPropertyDescriptor(a, "ref")?.value ?? Object.getOwnPropertyDescriptor(l, "ref")?.value]), h = de(() => Object.fromEntries(Me.map((i) => [i, (P) => {
27
+ }) : t, a = l.props, b = Le([E, Object.getOwnPropertyDescriptor(a, "ref")?.value ?? Object.getOwnPropertyDescriptor(l, "ref")?.value]), h = me(() => Object.fromEntries(Se.map((i) => [i, (P) => {
28
28
  const d = (s.current.getReferenceProps?.(a) ?? a)[i];
29
29
  d?.(P);
30
30
  }])), [a]), y = !!n.title || n.title === 0;
31
- return /* @__PURE__ */ _(k, { children: [y ? fe(l, {
31
+ return /* @__PURE__ */ _(Y, { children: [y ? ue(l, {
32
32
  ...h,
33
- ref: R
34
- }) : l, y && /* @__PURE__ */ b(Se, {
33
+ ref: b
34
+ }) : l, y && /* @__PURE__ */ R(Ce, {
35
35
  ...n,
36
36
  referenceRef: s,
37
37
  isFragment: c
38
38
  })] });
39
- }, Se = ({ title: t, referenceRef: n, isFragment: s, placement: E = "top", arrow: c = !1, enterDelay: l = 500, leaveDelay: a = 0, open: R, onOpen: h, onClose: y, disableHoverListener: i, disableFocusListener: P, openOnTap: d, persistentDescription: Y, persistentDescriptionId: z, offsetDistance: G, className: K, slotProps: x }) => {
40
- const [V, W] = me(!1), T = R !== void 0, D = !!t || t === 0, m = D && (R ?? V), w = D && Y, M = H(null), S = (e) => {
41
- T || W(e), e ? h?.() : y?.();
42
- }, { refs: o, floatingStyles: $, context: f } = Te({
39
+ }, Ce = ({ title: t, referenceRef: n, isFragment: s, placement: E = "top", arrow: c = !1, enterDelay: l = 500, leaveDelay: a = 0, open: b, onOpen: h, onClose: y, disableHoverListener: i, disableFocusListener: P, openOnTap: d, persistentDescription: z, persistentDescriptionId: G, describesTrigger: D = !0, offsetDistance: K, className: V, slotProps: x }) => {
40
+ const [W, $] = ge(!1), T = b !== void 0, M = !!t || t === 0, m = M && (b ?? W), w = M && D && z, S = k(null), C = (e) => {
41
+ T || $(e), e ? h?.() : y?.();
42
+ }, { refs: o, floatingStyles: q, context: f } = we({
43
43
  open: m,
44
- onOpenChange: S,
44
+ onOpenChange: C,
45
45
  placement: E,
46
46
  strategy: "fixed",
47
- whileElementsMounted: ye,
47
+ whileElementsMounted: ve,
48
48
  middleware: [
49
- Ee(G ?? (c ? 8 : 6)),
50
- ve({ padding: 8 }),
51
- Pe({ padding: 8 }),
52
- ...c ? [Re({ element: M })] : []
49
+ he(K ?? (c ? 8 : 6)),
50
+ Ee({ padding: 8 }),
51
+ xe({ padding: 8 }),
52
+ ...c ? [ye({ element: S })] : []
53
53
  ]
54
- }), { getReferenceProps: C, getFloatingProps: q } = Oe([
55
- Fe(f, {
54
+ }), { getReferenceProps: B, getFloatingProps: J } = Ae([
55
+ Oe(f, {
56
56
  enabled: !T && !i,
57
57
  delay: {
58
58
  open: l,
@@ -60,13 +60,13 @@ var _e = "#363E4A", De = (t) => {
60
60
  },
61
61
  move: !1,
62
62
  mouseOnly: !!d,
63
- handleClose: he()
63
+ handleClose: Pe()
64
64
  }),
65
- we(f, { enabled: !T && !P }),
66
- xe(f, { ancestorScroll: !!d }),
67
- Le(f, { role: "tooltip" }),
65
+ Fe(f, { enabled: !T && !P }),
66
+ Te(f, { ancestorScroll: !!d }),
67
+ _e(f, { role: "tooltip" }),
68
68
  { reference: { onPointerUp: (e) => {
69
- !d || e.pointerType !== "touch" || S(!m);
69
+ !d || e.pointerType !== "touch" || C(!m);
70
70
  } } }
71
71
  ]);
72
72
  L(() => {
@@ -75,19 +75,19 @@ var _e = "#363E4A", De = (t) => {
75
75
  e.setReference = void 0, e.getReferenceProps = void 0, o.setReference(null);
76
76
  };
77
77
  }, [n, o]), L(() => {
78
- n.current.getReferenceProps = C;
79
- }, [n, C]);
80
- const B = m ? ie(o.domReference.current) : void 0, F = ce(B), J = le(o.setFloating, F), { floatingId: Q } = f, X = pe(), j = z ?? X, u = w ? j : Q, O = !!w || m, I = (e) => ne(e) ?? oe(e) ?? e, A = typeof t == "string" || typeof t == "number" ? String(t).trim() : "", N = (e, r) => {
78
+ n.current.getReferenceProps = B;
79
+ }, [n, B]);
80
+ const j = m ? ce(o.domReference.current) : void 0, F = le(j), Q = ae(o.setFloating, F), { floatingId: X } = f, Z = de(), I = G ?? Z, u = w ? I : X, O = D && (!!w || m), N = (e) => re(e) ?? ne(e) ?? e, A = typeof t == "string" || typeof t == "number" ? String(t).trim() : "", U = (e, r) => {
81
81
  const p = e.getAttribute("aria-describedby"), g = p?.split(/\s+/) ?? [];
82
82
  if (g.includes(r)) return;
83
- const Z = (v) => document.getElementById(v)?.textContent?.trim();
84
- A && g.some((v) => v !== r && Z(v) === A) || e.setAttribute("aria-describedby", p ? `${p} ${r}` : r);
83
+ const ee = (v) => document.getElementById(v)?.textContent?.trim();
84
+ A && g.some((v) => v !== r && ee(v) === A) || e.setAttribute("aria-describedby", p ? `${p} ${r}` : r);
85
85
  };
86
- return U(() => {
86
+ return H(() => {
87
87
  const e = o.domReference.current;
88
88
  if (!O || !u || !(e instanceof HTMLElement)) return;
89
- const r = I(e);
90
- return N(r, u), () => {
89
+ const r = N(e);
90
+ return U(r, u), () => {
91
91
  const p = r.getAttribute("aria-describedby")?.split(/\s+/).filter((g) => g && g !== u).join(" ");
92
92
  p ? r.setAttribute("aria-describedby", p) : r.removeAttribute("aria-describedby");
93
93
  };
@@ -96,42 +96,42 @@ var _e = "#363E4A", De = (t) => {
96
96
  o.domReference,
97
97
  u,
98
98
  A
99
- ]), U(() => {
99
+ ]), H(() => {
100
100
  const e = o.domReference.current;
101
- !O || !u || !(e instanceof HTMLElement) || N(I(e), u);
101
+ !O || !u || !(e instanceof HTMLElement) || U(N(e), u);
102
102
  }), L(() => {
103
103
  const e = o.domReference.current;
104
104
  !s || !e || o.setPositionReference({
105
105
  contextElement: e,
106
- getBoundingClientRect: () => De(e)
106
+ getBoundingClientRect: () => Me(e)
107
107
  });
108
- }, [s, o]), /* @__PURE__ */ _(k, { children: [w && /* @__PURE__ */ b("span", {
109
- id: j,
108
+ }, [s, o]), /* @__PURE__ */ _(Y, { children: [w && /* @__PURE__ */ R("span", {
109
+ id: I,
110
110
  hidden: !0,
111
111
  children: t
112
- }), m && /* @__PURE__ */ b(be, {
113
- root: B,
112
+ }), m && /* @__PURE__ */ R(be, {
113
+ root: j,
114
114
  children: /* @__PURE__ */ _("div", {
115
- ref: J,
116
- ...F ? re : {},
117
- ...q(),
115
+ ref: Q,
116
+ ...F ? se : {},
117
+ ...J(),
118
118
  style: {
119
- ...F ? se : {},
120
- ...$,
119
+ ...F ? ie : {},
120
+ ...q,
121
121
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
122
122
  overflow: "visible",
123
123
  ...x?.tooltip?.style,
124
- ...te(x?.tooltip?.sx)
124
+ ...oe(x?.tooltip?.sx)
125
125
  },
126
- className: ee("z-[1500] block max-w-[320px] whitespace-normal break-words rounded-[3px] bg-[#363E4A] px-2 py-1 text-sm leading-5 text-white shadow-[0px_1px_6px_0px_rgba(0,0,0,0.15)]", K, x?.tooltip?.className),
127
- children: [t, c && /* @__PURE__ */ b(ge, {
128
- ref: M,
126
+ className: te("z-[1500] block max-w-[320px] whitespace-normal break-words rounded-[3px] bg-[#363E4A] px-2 py-1 text-sm leading-5 text-white shadow-[0px_1px_6px_0px_rgba(0,0,0,0.15)]", V, x?.tooltip?.className),
127
+ children: [t, c && /* @__PURE__ */ R(Re, {
128
+ ref: S,
129
129
  context: f,
130
- fill: _e
130
+ fill: De
131
131
  })]
132
132
  })
133
133
  })] });
134
134
  };
135
135
  export {
136
- ke as StyledTooltip
136
+ Ye as StyledTooltip
137
137
  };
@@ -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;
@@ -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.2",
6
+ "version": "3.137.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",