asma-ui-core 3.87.0 → 3.87.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.
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
import { ACTIONS_COLUMN_ID as
|
|
1
|
+
import { ACTIONS_COLUMN_ID as j } from "../types.js";
|
|
2
2
|
import { useRootContext as ge } from "../context/RootContext.js";
|
|
3
3
|
import n from "./StyledTable.module.js";
|
|
4
4
|
import { compact as he } from "../../helpers/arrays.js";
|
|
5
|
-
import
|
|
6
|
-
import { Fragment as pe, useCallback as
|
|
7
|
-
import { Fragment as Se, jsx as s, jsxs as
|
|
5
|
+
import q from "clsx";
|
|
6
|
+
import { Fragment as pe, useCallback as K, useEffect as xe, useLayoutEffect as be, useMemo as m, useRef as Ce, useState as Re } from "react";
|
|
7
|
+
import { Fragment as Se, jsx as s, jsxs as C } from "react/jsx-runtime";
|
|
8
8
|
import { useSortable as De } from "@dnd-kit/sortable";
|
|
9
9
|
import { flexRender as ye } from "@tanstack/react-table";
|
|
10
10
|
import { CSS as Ne } from "@dnd-kit/utilities";
|
|
11
|
-
var
|
|
12
|
-
const t =
|
|
13
|
-
|
|
11
|
+
var ve = (R) => {
|
|
12
|
+
const t = R.closest("table");
|
|
13
|
+
if (!t) return !1;
|
|
14
|
+
const r = Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).find((g) => !t.contains(g) && !!(t.compareDocumentPosition(g) & Node.DOCUMENT_POSITION_FOLLOWING));
|
|
15
|
+
return r ? (r.focus(), document.activeElement === r) : !1;
|
|
14
16
|
};
|
|
15
|
-
function Oe({ styledTableProps:
|
|
16
|
-
const { loading: G, getRowClassName: l, rowHeight:
|
|
17
|
+
function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWindow: { paddingLeft: h, paddingRight: p, indexes: T } }) {
|
|
18
|
+
const { loading: G, getRowClassName: l, rowHeight: x, onRowClick: S, expandArrow: V, enableDnd: w, disableDndForRow: Y, tdClassName: A, customSubRowData: B, renderSubRows: J, defaultExpanded: Q, actions: D, customActionsNode: X, textExpandArrow: L, enableMultiRowSelection: Z, enableRowSelection: ee, singleSelectionRow: te } = R, y = Y?.(t), { transform: ne, transition: oe, setNodeRef: M, isDragging: H } = De({
|
|
17
19
|
id: t.original.id,
|
|
18
|
-
disabled: !
|
|
20
|
+
disabled: !w || y
|
|
19
21
|
}), ie = {
|
|
20
22
|
transform: Ne.Transform.toString(ne),
|
|
21
23
|
transition: oe,
|
|
22
|
-
opacity:
|
|
23
|
-
zIndex:
|
|
24
|
+
opacity: H ? 0.8 : 1,
|
|
25
|
+
zIndex: H ? 1 : 0,
|
|
24
26
|
position: "relative"
|
|
25
|
-
}, { isResizing: se, disableResizingFlag: le } = ge(),
|
|
27
|
+
}, { isResizing: se, disableResizingFlag: le } = ge(), N = t.isExpanded(), b = Ce(null), [ae, ce] = Re(void 0);
|
|
26
28
|
be(() => {
|
|
27
|
-
!
|
|
28
|
-
}, [
|
|
29
|
-
const de =
|
|
30
|
-
|
|
31
|
-
}, [
|
|
29
|
+
!N && b.current && ce(b.current.cells[0]?.clientHeight ?? b.current.offsetHeight);
|
|
30
|
+
}, [N]);
|
|
31
|
+
const de = K((e) => {
|
|
32
|
+
b.current = e, y || M(e);
|
|
33
|
+
}, [y, M]), O = N ? ae ?? x : x;
|
|
32
34
|
xe(() => {
|
|
33
35
|
Q && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
|
|
34
36
|
}, []);
|
|
35
|
-
const
|
|
37
|
+
const U = (e) => {
|
|
36
38
|
t.getCanExpand() && !V && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
|
|
37
|
-
const o = window.getSelection()?.type !== "Range" && !se, i =
|
|
38
|
-
!i &&
|
|
39
|
+
const o = window.getSelection()?.type !== "Range" && !se, i = S instanceof Function;
|
|
40
|
+
!i && L && o ? t.toggleExpand() : i && o && S(e, t), le();
|
|
39
41
|
}, re = (e) => {
|
|
40
|
-
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") ||
|
|
41
|
-
},
|
|
42
|
+
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || U(e);
|
|
43
|
+
}, u = t.getVisibleCells().map((e, o, i) => ({
|
|
42
44
|
...e,
|
|
43
45
|
left: i.slice(0, o).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
|
|
44
|
-
})),
|
|
46
|
+
})), W = m(() => u.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [u]), a = m(() => u.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, o, i) => ({
|
|
45
47
|
...e,
|
|
46
48
|
right: i.slice(o + 1).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
|
|
47
|
-
})), [
|
|
48
|
-
const i = e.column.id ===
|
|
49
|
+
})), [u]), _ = m(() => a.some((e) => e.column.id === j), [a]), z = !!D || !!X, P = m(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), f = m(() => u.filter((e) => e.column.columnDef.fixedLeft), [u]), v = !Z && !ee && te, F = t.getIsSelected() && v, k = S instanceof Function, $ = T.length > 0 ? he(T.map((e) => W[e])) : W, E = K((e, o) => {
|
|
50
|
+
const i = e.column.id === j, c = e.column.columnDef.fixedLeft, d = !!e.column.columnDef.fixedRight, ue = e.id === f.at(-1)?.id, fe = e.id === a.at(0)?.id && !i, me = t.isExpanded(), I = o === 0;
|
|
49
51
|
return /* @__PURE__ */ s("td", {
|
|
50
|
-
className:
|
|
52
|
+
className: q(n["t-cell"], k && "cursor-pointer", A, i && n["action-cell"], i && (!z || P) && n["action-cell--no-shadow"], i && !!D && f.length && n.shadowed, i && (l?.(t) ? l?.(t) : n["action-cell-default-background"]), c && n["fixed-cell"], d && n["fixed-right-cell"], ue && n.shadowed, fe && n["shadowed-right"], t.getIsSelected() && n.selected, c && (l?.(t) ? l?.(t) : n["fixed-cell-default-background"]), d && (l?.(t) ? l?.(t) : n["fixed-right-cell-default-background"]), me && n.expanded_row, !!F && n["single-selection"]),
|
|
51
53
|
style: {
|
|
52
54
|
left: c ? e.left : void 0,
|
|
53
|
-
right: d ? e.right + (
|
|
55
|
+
right: d ? e.right + (_ ? -1 : 0) : void 0
|
|
54
56
|
},
|
|
55
|
-
children: /* @__PURE__ */
|
|
57
|
+
children: /* @__PURE__ */ C("div", {
|
|
56
58
|
style: {
|
|
57
59
|
display: "flex",
|
|
58
60
|
alignItems: "center",
|
|
59
|
-
minWidth:
|
|
60
|
-
minHeight:
|
|
61
|
+
minWidth: I ? 32 : void 0,
|
|
62
|
+
minHeight: O,
|
|
61
63
|
position: "relative"
|
|
62
64
|
},
|
|
63
|
-
children: [
|
|
65
|
+
children: [I && F && /* @__PURE__ */ s("span", {
|
|
64
66
|
style: {
|
|
65
67
|
display: "inline-flex",
|
|
66
68
|
alignItems: "center",
|
|
@@ -69,10 +71,10 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
|
|
|
69
71
|
top: "50%",
|
|
70
72
|
transform: "translateY(-50%)"
|
|
71
73
|
},
|
|
72
|
-
children: /* @__PURE__ */ s(
|
|
74
|
+
children: /* @__PURE__ */ s(Fe, {})
|
|
73
75
|
}), /* @__PURE__ */ s("span", {
|
|
74
76
|
style: {
|
|
75
|
-
marginLeft:
|
|
77
|
+
marginLeft: I && v ? 30 : 0,
|
|
76
78
|
width: "100%"
|
|
77
79
|
},
|
|
78
80
|
children: ye(e.column.columnDef.cell, e.getContext())
|
|
@@ -81,29 +83,29 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
|
|
|
81
83
|
}, e.id);
|
|
82
84
|
}, [
|
|
83
85
|
F,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
D,
|
|
87
|
+
O,
|
|
86
88
|
l,
|
|
87
89
|
k,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
_,
|
|
91
|
+
P,
|
|
92
|
+
f,
|
|
91
93
|
a,
|
|
92
94
|
t,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
z,
|
|
96
|
+
v,
|
|
97
|
+
A
|
|
96
98
|
]);
|
|
97
|
-
return /* @__PURE__ */
|
|
99
|
+
return /* @__PURE__ */ C(pe, { children: [/* @__PURE__ */ C("tr", {
|
|
98
100
|
"aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
|
|
99
|
-
tabIndex: t.isFocused() ||
|
|
100
|
-
"data-index":
|
|
101
|
+
tabIndex: t.isFocused() || r === 0 && !g ? 0 : -1,
|
|
102
|
+
"data-index": r,
|
|
101
103
|
"data-test": t.id,
|
|
102
104
|
id: t.id,
|
|
103
|
-
className:
|
|
105
|
+
className: q(n["t-row"], G && n["is-loading"], l?.(t)),
|
|
104
106
|
style: {
|
|
105
|
-
height:
|
|
106
|
-
...
|
|
107
|
+
height: x ? `${x}px` : "inherit",
|
|
108
|
+
...w && ie
|
|
107
109
|
},
|
|
108
110
|
ref: de,
|
|
109
111
|
onFocus: (e) => {
|
|
@@ -111,15 +113,19 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
|
|
|
111
113
|
},
|
|
112
114
|
onMouseUp: re,
|
|
113
115
|
onMouseDown: (e) => {
|
|
114
|
-
e.detail > 1 && !k &&
|
|
116
|
+
e.detail > 1 && !k && L && e.preventDefault();
|
|
115
117
|
},
|
|
116
118
|
onKeyDown: (e) => {
|
|
117
119
|
switch (e.key) {
|
|
118
120
|
case "Tab":
|
|
119
|
-
if (e.
|
|
120
|
-
if (t.focusPrevRow())
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
if (e.shiftKey) {
|
|
122
|
+
if (t.focusPrevRow()) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
const o = e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]');
|
|
127
|
+
o && (e.preventDefault(), o.focus());
|
|
128
|
+
} else (t.focusNextRow() || ve(e.currentTarget)) && e.preventDefault();
|
|
123
129
|
break;
|
|
124
130
|
case "ArrowDown":
|
|
125
131
|
t.focusNextRow() && e.preventDefault();
|
|
@@ -128,43 +134,43 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
|
|
|
128
134
|
t.focusPrevRow() && e.preventDefault();
|
|
129
135
|
break;
|
|
130
136
|
case "Enter":
|
|
131
|
-
|
|
137
|
+
U(e);
|
|
132
138
|
break;
|
|
133
139
|
}
|
|
134
140
|
},
|
|
135
141
|
children: [
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
f.map((e, o) => E(e, o)),
|
|
143
|
+
h > 0 && /* @__PURE__ */ s("td", {
|
|
138
144
|
"aria-hidden": !0,
|
|
139
145
|
className: n["t-cell"],
|
|
140
146
|
style: {
|
|
141
|
-
width: String(
|
|
142
|
-
minWidth: String(
|
|
143
|
-
maxWidth: String(
|
|
147
|
+
width: String(h) + "px",
|
|
148
|
+
minWidth: String(h) + "px",
|
|
149
|
+
maxWidth: String(h) + "px",
|
|
144
150
|
padding: 0,
|
|
145
151
|
border: "none"
|
|
146
152
|
}
|
|
147
153
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
$.map((e, o) => E(e, f.length + o)),
|
|
155
|
+
p > 0 && /* @__PURE__ */ s("td", {
|
|
150
156
|
"aria-hidden": !0,
|
|
151
157
|
className: n["t-cell"],
|
|
152
158
|
style: {
|
|
153
|
-
width: String(
|
|
154
|
-
minWidth: String(
|
|
155
|
-
maxWidth: String(
|
|
159
|
+
width: String(p) + "px",
|
|
160
|
+
minWidth: String(p) + "px",
|
|
161
|
+
maxWidth: String(p) + "px",
|
|
156
162
|
padding: 0,
|
|
157
163
|
border: "none"
|
|
158
164
|
}
|
|
159
165
|
}),
|
|
160
|
-
a.map((e, o) =>
|
|
166
|
+
a.map((e, o) => E(e, f.length + $.length + o))
|
|
161
167
|
]
|
|
162
|
-
}), t.getIsExpanded() && /* @__PURE__ */ s(Se, { children:
|
|
163
|
-
rows:
|
|
168
|
+
}), t.getIsExpanded() && /* @__PURE__ */ s(Se, { children: B && J?.({
|
|
169
|
+
rows: B.get(t.original.id.toString()) ?? [],
|
|
164
170
|
row: t.original
|
|
165
171
|
}) })] }, t.id);
|
|
166
172
|
}
|
|
167
|
-
var
|
|
173
|
+
var Fe = () => /* @__PURE__ */ C("svg", {
|
|
168
174
|
xmlns: "http://www.w3.org/2000/svg",
|
|
169
175
|
width: "20",
|
|
170
176
|
height: "20",
|