asma-ui-core 3.136.2 → 3.137.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/data-display/tooltip/StyledTooltip.js +59 -59
- package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +14 -14
- package/dist/src/components/data-display/tooltip/StyledTooltip.d.ts +7 -0
- package/dist/src/table/components/table-header/useHeaderTruncation.d.ts +33 -0
- package/dist/src/table/helpers/headerLabel.d.ts +7 -0
- package/dist/src/table/helpers/headerLabel.test.d.ts +1 -0
- package/dist/table/components/columns/action-column/components/HeaderActionMenu.js +41 -40
- package/dist/table/components/table-header/TableHeaderCell.js +67 -56
- package/dist/table/components/table-header/useHeaderTruncation.js +35 -0
- package/dist/table/helpers/headerLabel.js +4 -0
- package/package.json +1 -1
|
@@ -1,72 +1,83 @@
|
|
|
1
|
-
import { ACTIONS_COLUMN_ID as
|
|
2
|
-
import { useRootContext as
|
|
3
|
-
import { hasFixedWidth as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
10
|
-
import { jsx as
|
|
11
|
-
import { flexRender as
|
|
12
|
-
function
|
|
13
|
-
const { hideHeader:
|
|
14
|
-
sorted:
|
|
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
|
-
}),
|
|
19
|
-
|
|
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":
|
|
22
|
-
className: _(
|
|
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
|
-
...
|
|
66
|
+
...W({
|
|
25
67
|
enableResizing: m,
|
|
26
68
|
header: o,
|
|
27
|
-
tableWidth:
|
|
69
|
+
tableWidth: I
|
|
28
70
|
}),
|
|
29
71
|
...g && { left: N },
|
|
30
|
-
...f && { right:
|
|
72
|
+
...f && { right: H }
|
|
31
73
|
},
|
|
32
|
-
children: /* @__PURE__ */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
+
};
|