asma-ui-core 3.45.1 → 3.46.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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/navigation/tabs/StyledTabs.js +35 -35
- package/dist/src/table/helpers/injectColumns.d.ts +1 -1
- package/dist/src/table/hooks/useColumnSizingPersistence.d.ts +3 -0
- package/dist/table/components/StyledTable.module.js +52 -52
- package/dist/table/components/StyledTableIndex.js +31 -27
- package/dist/table/components/TableRow.js +69 -61
- package/dist/table/components/columns/expandColumn.js +14 -10
- package/dist/table/components/columns/showTextColumn.js +20 -16
- package/dist/table/components/table-header/TableHeaderCell.js +34 -53
- package/dist/table/helpers/injectColumns.js +7 -7
- package/dist/table/hooks/useColumnSizingPersistence.js +36 -0
- package/dist/table/hooks/useColumnVirtualizer.js +4 -3
- package/dist/table/hooks/useStyledTable.js +48 -40
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { cn as n } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { ChevronRightIcon as
|
|
4
|
-
import { ChevronLeftIcon as
|
|
5
|
-
import { consumerOverrides as
|
|
6
|
-
import { TabsContext as
|
|
7
|
-
import { Children as
|
|
8
|
-
import { jsx as l, jsxs as
|
|
9
|
-
var I = 120,
|
|
10
|
-
const a =
|
|
2
|
+
import { resolveSx as M } from "../../../helpers/sx.js";
|
|
3
|
+
import { ChevronRightIcon as V } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
|
|
4
|
+
import { ChevronLeftIcon as _ } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
|
|
5
|
+
import { consumerOverrides as q } from "../../../helpers/classOverride.js";
|
|
6
|
+
import { TabsContext as z } from "./TabsContext.js";
|
|
7
|
+
import { Children as F, cloneElement as G, isValidElement as J, useCallback as u, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
|
|
8
|
+
import { jsx as l, jsxs as B } from "react/jsx-runtime";
|
|
9
|
+
var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: b = "default", className: x, sx: N, children: y }) => {
|
|
10
|
+
const a = E(null), d = E(/* @__PURE__ */ new Map()), [h, O] = A({
|
|
11
11
|
left: 0,
|
|
12
12
|
width: 0,
|
|
13
13
|
disabled: !1
|
|
14
|
-
}), [c, W] =
|
|
14
|
+
}), [c, W] = A({
|
|
15
15
|
left: !1,
|
|
16
16
|
right: !1
|
|
17
17
|
}), p = g === "scrollable", v = u((e, t) => {
|
|
18
18
|
t ? d.current.set(e, t) : d.current.delete(e);
|
|
19
|
-
}, []),
|
|
19
|
+
}, []), S = u((e, t) => m?.(e, t), [m]), f = u(() => {
|
|
20
20
|
const e = d.current.get(i), t = a.current;
|
|
21
21
|
if (e && O({
|
|
22
22
|
left: e.offsetLeft,
|
|
@@ -30,19 +30,19 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}, [i]);
|
|
33
|
-
|
|
33
|
+
Q(() => {
|
|
34
34
|
f();
|
|
35
35
|
const e = a.current;
|
|
36
36
|
if (!e) return;
|
|
37
37
|
const t = new ResizeObserver(f);
|
|
38
38
|
return t.observe(e), () => t.disconnect();
|
|
39
39
|
}, [f, y]);
|
|
40
|
-
const
|
|
40
|
+
const k = (e) => {
|
|
41
41
|
a.current?.scrollBy({
|
|
42
42
|
left: e,
|
|
43
43
|
behavior: "smooth"
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, D = (e) => {
|
|
46
46
|
if (![
|
|
47
47
|
"ArrowRight",
|
|
48
48
|
"ArrowLeft",
|
|
@@ -55,42 +55,42 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
55
55
|
const o = t.findIndex((s) => s === document.activeElement);
|
|
56
56
|
let r = o;
|
|
57
57
|
e.key === "ArrowRight" ? r = (o + 1) % t.length : e.key === "ArrowLeft" ? r = (o - 1 + t.length) % t.length : e.key === "Home" ? r = 0 : e.key === "End" && (r = t.length - 1), t[r]?.focus();
|
|
58
|
-
},
|
|
58
|
+
}, L = p && w !== !1, R = w === !0, P = L && (R || c.left), T = L && (R || c.right), H = q(x, "padding-x"), K = U(() => ({
|
|
59
59
|
value: i,
|
|
60
60
|
size: b,
|
|
61
|
-
onSelect:
|
|
61
|
+
onSelect: S,
|
|
62
62
|
register: v
|
|
63
63
|
}), [
|
|
64
64
|
i,
|
|
65
65
|
b,
|
|
66
|
-
|
|
66
|
+
S,
|
|
67
67
|
v
|
|
68
|
-
]),
|
|
69
|
-
return /* @__PURE__ */ l(
|
|
70
|
-
value:
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
className: n("relative flex items-center rounded-t-lg bg-white", !
|
|
73
|
-
style:
|
|
68
|
+
]), C = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
|
|
69
|
+
return /* @__PURE__ */ l(z.Provider, {
|
|
70
|
+
value: K,
|
|
71
|
+
children: /* @__PURE__ */ B("div", {
|
|
72
|
+
className: n("relative flex items-center rounded-t-lg bg-white", !H && "px-4", x),
|
|
73
|
+
style: M(N),
|
|
74
74
|
children: [
|
|
75
|
-
|
|
75
|
+
P && /* @__PURE__ */ l("button", {
|
|
76
76
|
type: "button",
|
|
77
77
|
"aria-label": "scroll tabs left",
|
|
78
|
-
className: n(
|
|
78
|
+
className: n(C, "mr-2"),
|
|
79
79
|
disabled: !c.left,
|
|
80
|
-
onClick: () =>
|
|
81
|
-
children: /* @__PURE__ */ l(
|
|
80
|
+
onClick: () => k(-I),
|
|
81
|
+
children: /* @__PURE__ */ l(_, {
|
|
82
82
|
width: 24,
|
|
83
83
|
height: 24
|
|
84
84
|
})
|
|
85
85
|
}),
|
|
86
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ B("div", {
|
|
87
87
|
ref: a,
|
|
88
88
|
role: "tablist",
|
|
89
89
|
"aria-orientation": "horizontal",
|
|
90
|
-
onKeyDown:
|
|
90
|
+
onKeyDown: D,
|
|
91
91
|
onScroll: f,
|
|
92
92
|
className: n("relative flex border-x-0 border-b border-t-0 border-solid border-delta-200 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", p ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", b === "small" && "min-h-9"),
|
|
93
|
-
children: [
|
|
93
|
+
children: [F.map(y, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
|
|
94
94
|
"aria-hidden": !0,
|
|
95
95
|
className: n("absolute bottom-0 h-0.5 transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
|
|
96
96
|
style: {
|
|
@@ -99,13 +99,13 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
99
99
|
}
|
|
100
100
|
})]
|
|
101
101
|
}),
|
|
102
|
-
|
|
102
|
+
T && /* @__PURE__ */ l("button", {
|
|
103
103
|
type: "button",
|
|
104
104
|
"aria-label": "scroll tabs right",
|
|
105
|
-
className: n(
|
|
105
|
+
className: n(C, "ml-2"),
|
|
106
106
|
disabled: !c.right,
|
|
107
|
-
onClick: () =>
|
|
108
|
-
children: /* @__PURE__ */ l(
|
|
107
|
+
onClick: () => k(I),
|
|
108
|
+
children: /* @__PURE__ */ l(V, {
|
|
109
109
|
width: 24,
|
|
110
110
|
height: 24
|
|
111
111
|
})
|
|
@@ -115,5 +115,5 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
export {
|
|
118
|
-
|
|
118
|
+
le as StyledTabs
|
|
119
119
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StyledTableProps } from '../types';
|
|
2
2
|
export declare const injectColumns: <TData extends {
|
|
3
3
|
id: string | number;
|
|
4
|
-
}, TCustomData = Record<string, unknown>>(props: StyledTableProps<TData, TCustomData>) =>
|
|
4
|
+
}, TCustomData = Record<string, unknown>>(props: StyledTableProps<TData, TCustomData>) => StyledTableProps<TData, TCustomData>["columns"];
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
var e = "
|
|
2
|
-
"asma-ui-table-styled-table": "_asma-ui-table-styled-
|
|
3
|
-
"table-wrapper": "_table-
|
|
4
|
-
"table-shell": "_table-
|
|
5
|
-
"table-wrapper--no-rows": "_table-wrapper--no-
|
|
6
|
-
"table-wrapper--proxy": "_table-wrapper--
|
|
7
|
-
"table-wrapper--proxy-bottom": "_table-wrapper--proxy-
|
|
8
|
-
"table-wrapper-fetching": "_table-wrapper-
|
|
9
|
-
"table-scroll": "_table-
|
|
10
|
-
"table-x--fill-height": "_table-x--fill-
|
|
11
|
-
"table-x": "_table-
|
|
12
|
-
"table-content": "_table-
|
|
13
|
-
"table-header--sticky": "_table-header--
|
|
14
|
-
"table-hscroll": "_table-
|
|
15
|
-
"table-hscroll__content": "_table-
|
|
16
|
-
"no-rows-overlay-container": "_no-rows-overlay-
|
|
17
|
-
"no-rows-overlay-content": "_no-rows-overlay-
|
|
18
|
-
"styled-table": "_styled-
|
|
1
|
+
var e = "_tbody_1g04u_124", _ = "_expanded_row_1g04u_187", l = "_selected_1g04u_205", t = "_shadowed_1g04u_234", a = "_resizer_1g04u_288", o = "_isResizing_1g04u_300", r = {
|
|
2
|
+
"asma-ui-table-styled-table": "_asma-ui-table-styled-table_1g04u_1",
|
|
3
|
+
"table-wrapper": "_table-wrapper_1g04u_26",
|
|
4
|
+
"table-shell": "_table-shell_1g04u_33",
|
|
5
|
+
"table-wrapper--no-rows": "_table-wrapper--no-rows_1g04u_39",
|
|
6
|
+
"table-wrapper--proxy": "_table-wrapper--proxy_1g04u_42",
|
|
7
|
+
"table-wrapper--proxy-bottom": "_table-wrapper--proxy-bottom_1g04u_43",
|
|
8
|
+
"table-wrapper-fetching": "_table-wrapper-fetching_1g04u_53",
|
|
9
|
+
"table-scroll": "_table-scroll_1g04u_56",
|
|
10
|
+
"table-x--fill-height": "_table-x--fill-height_1g04u_65",
|
|
11
|
+
"table-x": "_table-x_1g04u_65",
|
|
12
|
+
"table-content": "_table-content_1g04u_80",
|
|
13
|
+
"table-header--sticky": "_table-header--sticky_1g04u_85",
|
|
14
|
+
"table-hscroll": "_table-hscroll_1g04u_90",
|
|
15
|
+
"table-hscroll__content": "_table-hscroll__content_1g04u_100",
|
|
16
|
+
"no-rows-overlay-container": "_no-rows-overlay-container_1g04u_103",
|
|
17
|
+
"no-rows-overlay-content": "_no-rows-overlay-content_1g04u_111",
|
|
18
|
+
"styled-table": "_styled-table_1g04u_115",
|
|
19
19
|
tbody: e,
|
|
20
|
-
"loading-icon": "_loading-
|
|
21
|
-
"t-row": "_t-
|
|
22
|
-
"t-cell": "_t-
|
|
23
|
-
"action-cell": "_action-
|
|
24
|
-
"fixed-cell": "_fixed-
|
|
25
|
-
"fixed-right-cell": "_fixed-right-
|
|
20
|
+
"loading-icon": "_loading-icon_1g04u_129",
|
|
21
|
+
"t-row": "_t-row_1g04u_136",
|
|
22
|
+
"t-cell": "_t-cell_1g04u_136",
|
|
23
|
+
"action-cell": "_action-cell_1g04u_146",
|
|
24
|
+
"fixed-cell": "_fixed-cell_1g04u_150",
|
|
25
|
+
"fixed-right-cell": "_fixed-right-cell_1g04u_153",
|
|
26
26
|
expanded_row: _,
|
|
27
|
-
selected:
|
|
28
|
-
"single-selection": "_single-
|
|
29
|
-
"action-cell--no-shadow": "_action-cell--no-
|
|
30
|
-
"action-cell--not-fixed": "_action-cell--not-
|
|
31
|
-
shadowed:
|
|
32
|
-
"shadowed-right": "_shadowed-
|
|
33
|
-
"is-loading": "_is-
|
|
34
|
-
"action-cell-default-background": "_action-cell-default-
|
|
35
|
-
"fixed-cell-default-background": "_fixed-cell-default-
|
|
36
|
-
"fixed-right-cell-default-background": "_fixed-right-cell-default-
|
|
37
|
-
"sortable-column": "_sortable-
|
|
38
|
-
resizer:
|
|
39
|
-
isResizing:
|
|
40
|
-
"hide-table-header": "_hide-table-
|
|
41
|
-
"show-table-header": "_show-table-
|
|
42
|
-
"table-header": "_table-
|
|
43
|
-
"hide-header": "_hide-
|
|
44
|
-
"t-cell__actions": "_t-
|
|
45
|
-
"t-cell__actions--no-shadow": "_t-cell__actions--no-
|
|
46
|
-
"t-cell__actions--not-fixed": "_t-cell__actions--not-
|
|
47
|
-
"t-cell__fixed": "_t-
|
|
48
|
-
"t-cell__fixed-right": "_t-cell__fixed-
|
|
49
|
-
"sort-icon": "_sort-
|
|
50
|
-
"table-footer--sticky": "_table-footer--
|
|
51
|
-
"table-footer--inline": "_table-footer--
|
|
52
|
-
"table-bottom": "_table-
|
|
53
|
-
"table-bottom--sticky": "_table-bottom--
|
|
54
|
-
"cursor-not-allowed": "_cursor-not-
|
|
27
|
+
selected: l,
|
|
28
|
+
"single-selection": "_single-selection_1g04u_208",
|
|
29
|
+
"action-cell--no-shadow": "_action-cell--no-shadow_1g04u_225",
|
|
30
|
+
"action-cell--not-fixed": "_action-cell--not-fixed_1g04u_228",
|
|
31
|
+
shadowed: t,
|
|
32
|
+
"shadowed-right": "_shadowed-right_1g04u_268",
|
|
33
|
+
"is-loading": "_is-loading_1g04u_272",
|
|
34
|
+
"action-cell-default-background": "_action-cell-default-background_1g04u_275",
|
|
35
|
+
"fixed-cell-default-background": "_fixed-cell-default-background_1g04u_278",
|
|
36
|
+
"fixed-right-cell-default-background": "_fixed-right-cell-default-background_1g04u_281",
|
|
37
|
+
"sortable-column": "_sortable-column_1g04u_284",
|
|
38
|
+
resizer: a,
|
|
39
|
+
isResizing: o,
|
|
40
|
+
"hide-table-header": "_hide-table-header_1g04u_312",
|
|
41
|
+
"show-table-header": "_show-table-header_1g04u_316",
|
|
42
|
+
"table-header": "_table-header_1g04u_85",
|
|
43
|
+
"hide-header": "_hide-header_1g04u_348",
|
|
44
|
+
"t-cell__actions": "_t-cell__actions_1g04u_351",
|
|
45
|
+
"t-cell__actions--no-shadow": "_t-cell__actions--no-shadow_1g04u_359",
|
|
46
|
+
"t-cell__actions--not-fixed": "_t-cell__actions--not-fixed_1g04u_362",
|
|
47
|
+
"t-cell__fixed": "_t-cell__fixed_1g04u_369",
|
|
48
|
+
"t-cell__fixed-right": "_t-cell__fixed-right_1g04u_376",
|
|
49
|
+
"sort-icon": "_sort-icon_1g04u_383",
|
|
50
|
+
"table-footer--sticky": "_table-footer--sticky_1g04u_386",
|
|
51
|
+
"table-footer--inline": "_table-footer--inline_1g04u_397",
|
|
52
|
+
"table-bottom": "_table-bottom_1g04u_408",
|
|
53
|
+
"table-bottom--sticky": "_table-bottom--sticky_1g04u_422",
|
|
54
|
+
"cursor-not-allowed": "_cursor-not-allowed_1g04u_426"
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
57
|
r as default
|
|
@@ -17,7 +17,7 @@ import { DndContext as fe, closestCenter as he } from "@dnd-kit/core";
|
|
|
17
17
|
import { restrictToParentElement as be, restrictToVerticalAxis as ue } from "@dnd-kit/modifiers";
|
|
18
18
|
import { arrayMove as pe } from "@dnd-kit/sortable";
|
|
19
19
|
function we({ enabled: l, data: o, setData: i, children: v }) {
|
|
20
|
-
const y = O(() => o.map((c) => c.id), [o]),
|
|
20
|
+
const y = O(() => o.map((c) => c.id), [o]), P = (c) => {
|
|
21
21
|
if (!l || !i) return;
|
|
22
22
|
const { active: m, over: f } = c;
|
|
23
23
|
!m || !f || m.id === f.id || i((g) => pe(g, y.indexOf(m.id), y.indexOf(f.id)));
|
|
@@ -25,7 +25,7 @@ function we({ enabled: l, data: o, setData: i, children: v }) {
|
|
|
25
25
|
return l ? /* @__PURE__ */ t(fe, {
|
|
26
26
|
collisionDetection: he,
|
|
27
27
|
modifiers: [ue, be],
|
|
28
|
-
onDragEnd:
|
|
28
|
+
onDragEnd: P,
|
|
29
29
|
children: v
|
|
30
30
|
}) : /* @__PURE__ */ t(X, { children: v });
|
|
31
31
|
}
|
|
@@ -36,61 +36,65 @@ function ve({ enabled: l, className: o, children: i }) {
|
|
|
36
36
|
}) : /* @__PURE__ */ t(X, { children: i });
|
|
37
37
|
}
|
|
38
38
|
var Ve = (l) => {
|
|
39
|
-
const o = O(() =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const o = O(() => {
|
|
40
|
+
const r = {
|
|
41
|
+
...l,
|
|
42
|
+
rowHeight: l.rowHeight ?? 48
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...r,
|
|
46
|
+
columns: le(r)
|
|
47
|
+
};
|
|
48
|
+
}, [l]), { className: i, tableClassName: v, height: y, noRowsOverlay: P, data: c, enableDnd: m, setData: f, loading: g } = o, { table: a } = ne(o), C = c.length > 0, F = C && !!g, h = !C && !g, z = oe(re()), n = !!o.stickyFooter && !z, [G, M] = me(!1), x = L(null), W = L(null), S = o.hideHeader ? 0 : 32, { tableScrollRef: R, tableXRef: H, hScrollRef: J, hScrollContentRef: K } = ce(!n);
|
|
45
49
|
q(() => {
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
50
|
+
const r = n ? x.current : H.current ?? R.current;
|
|
51
|
+
if (!r) {
|
|
48
52
|
M(!1);
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
|
-
const s =
|
|
52
|
-
const u =
|
|
55
|
+
const s = r.querySelector("table"), b = () => {
|
|
56
|
+
const u = r.scrollWidth > r.clientWidth;
|
|
53
57
|
M((I) => I === u ? I : u);
|
|
54
58
|
};
|
|
55
59
|
b();
|
|
56
60
|
const d = new ResizeObserver(b);
|
|
57
|
-
return d.observe(
|
|
61
|
+
return d.observe(r), s && d.observe(s), () => {
|
|
58
62
|
d.disconnect();
|
|
59
63
|
};
|
|
60
64
|
}, [
|
|
61
|
-
|
|
65
|
+
n,
|
|
62
66
|
H,
|
|
63
67
|
R
|
|
64
68
|
]);
|
|
65
69
|
const { ref: Q, heightPx: k } = $(), { ref: U, heightPx: D } = $(), N = o.rowHeight ?? 48, E = a.getRowModel().rows.length, V = o.hideHeader ? 0 : 32, _ = 12, Y = O(() => {
|
|
66
70
|
if (N <= 0) return 0;
|
|
67
|
-
const
|
|
71
|
+
const r = n ? 0 : V + D + _, s = Math.max(0, k - r);
|
|
68
72
|
return Math.floor(s / N);
|
|
69
73
|
}, [
|
|
70
|
-
|
|
74
|
+
n,
|
|
71
75
|
D,
|
|
72
76
|
V,
|
|
73
77
|
_,
|
|
74
78
|
N,
|
|
75
79
|
k
|
|
76
|
-
]), T = !
|
|
80
|
+
]), T = !n && E > 0 && E <= Y, Z = p(n ? e["table-wrapper"] : T || !n && h ? e["table-wrapper--proxy-bottom"] : e["table-wrapper--proxy"], F && e["table-wrapper-fetching"], h && e["table-wrapper--no-rows"], i), { columnWindow: j } = de({
|
|
77
81
|
table: a,
|
|
78
|
-
scrollRef:
|
|
82
|
+
scrollRef: n ? x : R,
|
|
79
83
|
isMobileView: z
|
|
80
84
|
});
|
|
81
85
|
q(() => {
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
86
|
+
const r = x.current, s = W.current, b = () => r?.style.removeProperty("--no-rows-content-height");
|
|
87
|
+
if (!r || !h || !s) {
|
|
84
88
|
b();
|
|
85
89
|
return;
|
|
86
90
|
}
|
|
87
|
-
const d = () =>
|
|
91
|
+
const d = () => r.style.setProperty("--no-rows-content-height", `${Math.ceil(s.getBoundingClientRect().height) + S}px`);
|
|
88
92
|
d();
|
|
89
93
|
const u = new ResizeObserver(d);
|
|
90
94
|
return u.observe(s), () => {
|
|
91
95
|
u.disconnect(), b();
|
|
92
96
|
};
|
|
93
|
-
}, [h,
|
|
97
|
+
}, [h, S]);
|
|
94
98
|
const A = /* @__PURE__ */ w("div", {
|
|
95
99
|
className: e["table-content"],
|
|
96
100
|
children: [/* @__PURE__ */ w("table", {
|
|
@@ -113,11 +117,11 @@ var Ve = (l) => {
|
|
|
113
117
|
}), /* @__PURE__ */ t(ae, { fetching: !!F })]
|
|
114
118
|
}), ee = h ? /* @__PURE__ */ t("div", {
|
|
115
119
|
className: e["no-rows-overlay-container"],
|
|
116
|
-
style: { top:
|
|
120
|
+
style: { top: S },
|
|
117
121
|
children: /* @__PURE__ */ t("div", {
|
|
118
122
|
ref: W,
|
|
119
123
|
className: e["no-rows-overlay-content"],
|
|
120
|
-
children:
|
|
124
|
+
children: P
|
|
121
125
|
})
|
|
122
126
|
}) : null;
|
|
123
127
|
return /* @__PURE__ */ t(te, { children: /* @__PURE__ */ t(we, {
|
|
@@ -130,12 +134,12 @@ var Ve = (l) => {
|
|
|
130
134
|
"data-x-overflow": G ? "true" : "false",
|
|
131
135
|
style: { height: y },
|
|
132
136
|
children: [/* @__PURE__ */ t(ve, {
|
|
133
|
-
enabled:
|
|
137
|
+
enabled: n,
|
|
134
138
|
className: e["table-shell"],
|
|
135
139
|
children: /* @__PURE__ */ w("div", {
|
|
136
140
|
ref: x,
|
|
137
141
|
className: Z,
|
|
138
|
-
children: [
|
|
142
|
+
children: [n ? A : /* @__PURE__ */ w("div", {
|
|
139
143
|
ref: R,
|
|
140
144
|
className: p(e["table-scroll"]),
|
|
141
145
|
children: [
|
|
@@ -164,7 +168,7 @@ var Ve = (l) => {
|
|
|
164
168
|
]
|
|
165
169
|
}), ee]
|
|
166
170
|
})
|
|
167
|
-
}),
|
|
171
|
+
}), n && /* @__PURE__ */ t(B, {
|
|
168
172
|
table: a,
|
|
169
173
|
styledTableProps: o,
|
|
170
174
|
canShowStickyFooter: !0
|
|
@@ -1,55 +1,62 @@
|
|
|
1
|
-
import { ACTIONS_COLUMN_ID as
|
|
2
|
-
import { useRootContext as
|
|
1
|
+
import { ACTIONS_COLUMN_ID as O } from "../types.js";
|
|
2
|
+
import { useRootContext as ue } from "../context/RootContext.js";
|
|
3
3
|
import n from "./StyledTable.module.js";
|
|
4
|
-
import { compact as
|
|
5
|
-
import
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { useSortable as
|
|
9
|
-
import { flexRender as
|
|
10
|
-
import { CSS as
|
|
11
|
-
function
|
|
12
|
-
const { loading:
|
|
4
|
+
import { compact as fe } from "../../helpers/arrays.js";
|
|
5
|
+
import $ from "clsx";
|
|
6
|
+
import { Fragment as he, useCallback as j, useEffect as pe, useLayoutEffect as xe, useMemo as g, useRef as Ce, useState as Re } from "react";
|
|
7
|
+
import { Fragment as Se, jsx as l, jsxs as C } from "react/jsx-runtime";
|
|
8
|
+
import { useSortable as be } from "@dnd-kit/sortable";
|
|
9
|
+
import { flexRender as De } from "@tanstack/react-table";
|
|
10
|
+
import { CSS as ke } from "@dnd-kit/utilities";
|
|
11
|
+
function Me({ styledTableProps: P, row: t, index: K, columnWindow: { paddingLeft: u, paddingRight: f, indexes: N } }) {
|
|
12
|
+
const { loading: V, getRowClassName: s, rowHeight: h, onRowClick: R, expandArrow: Y, enableDnd: I, disableDndForRow: q, tdClassName: w, customSubRowData: B, renderSubRows: G, defaultExpanded: J, actions: S, customActionsNode: Q, textExpandArrow: A, enableMultiRowSelection: X, enableRowSelection: Z, singleSelectionRow: ee } = P, b = q?.(t), { transform: te, transition: ne, setNodeRef: H, isDragging: L } = be({
|
|
13
13
|
id: t.original.id,
|
|
14
|
-
disabled: !
|
|
15
|
-
}),
|
|
16
|
-
transform:
|
|
17
|
-
transition:
|
|
18
|
-
opacity:
|
|
19
|
-
zIndex:
|
|
14
|
+
disabled: !I || b
|
|
15
|
+
}), ie = {
|
|
16
|
+
transform: ke.Transform.toString(te),
|
|
17
|
+
transition: ne,
|
|
18
|
+
opacity: L ? 0.8 : 1,
|
|
19
|
+
zIndex: L ? 1 : 0,
|
|
20
20
|
position: "relative"
|
|
21
|
-
}, { isResizing:
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
}, { isResizing: oe, disableResizingFlag: le } = ue(), D = t.isExpanded(), p = Ce(null), [se, ae] = Re(void 0);
|
|
22
|
+
xe(() => {
|
|
23
|
+
!D && p.current && ae(p.current.cells[0]?.clientHeight ?? p.current.offsetHeight);
|
|
24
|
+
}, [D]);
|
|
25
|
+
const de = j((e) => {
|
|
26
|
+
p.current = e, b || H(e);
|
|
27
|
+
}, [b, H]), M = D ? se ?? h : h;
|
|
28
|
+
pe(() => {
|
|
29
|
+
J && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
|
|
24
30
|
}, []);
|
|
25
|
-
const
|
|
26
|
-
t.getCanExpand() &&
|
|
27
|
-
const i = window.getSelection()?.type !== "Range" && !
|
|
28
|
-
!o &&
|
|
29
|
-
},
|
|
30
|
-
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") ||
|
|
31
|
+
const T = (e) => {
|
|
32
|
+
t.getCanExpand() && !Y && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
|
|
33
|
+
const i = window.getSelection()?.type !== "Range" && !oe, o = R instanceof Function;
|
|
34
|
+
!o && A && i ? t.toggleExpand() : o && i && R(e, t), le();
|
|
35
|
+
}, ce = (e) => {
|
|
36
|
+
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || T(e);
|
|
31
37
|
}, r = t.getVisibleCells().map((e, i, o) => ({
|
|
32
38
|
...e,
|
|
33
39
|
left: o.slice(0, i).reduce((d, c) => d + (c.column.getSize() ?? 0), 0)
|
|
34
|
-
})),
|
|
40
|
+
})), z = g(() => r.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [r]), a = g(() => r.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, i, o) => ({
|
|
35
41
|
...e,
|
|
36
42
|
right: o.slice(i + 1).reduce((d, c) => d + (c.column.getSize() ?? 0), 0)
|
|
37
|
-
})), [r]),
|
|
38
|
-
const o = e.column.id ===
|
|
43
|
+
})), [r]), U = g(() => a.some((e) => e.column.id === O), [a]), x = !!S || !!Q, W = g(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), m = g(() => r.filter((e) => e.column.columnDef.fixedLeft), [r]), k = !X && !Z && ee, y = t.getIsSelected() && k, F = R instanceof Function, _ = N.length > 0 ? fe(N.map((e) => z[e])) : z, E = j((e, i) => {
|
|
44
|
+
const o = e.column.id === O, d = e.column.columnDef.fixedLeft, c = !!e.column.columnDef.fixedRight, re = e.id === m.at(-1)?.id, me = e.id === a.at(0)?.id && !o, ge = t.isExpanded(), v = i === 0;
|
|
39
45
|
return /* @__PURE__ */ l("td", {
|
|
40
|
-
className:
|
|
46
|
+
className: $(n["t-cell"], F && "cursor-pointer", w, o && n["action-cell"], o && !x && n["action-cell--not-fixed"], o && x && W && n["action-cell--no-shadow"], o && x && !!S && m.length && n.shadowed, o && (s?.(t) ? s?.(t) : n["action-cell-default-background"]), d && n["fixed-cell"], c && n["fixed-right-cell"], re && n.shadowed, me && n["shadowed-right"], t.getIsSelected() && n.selected, d && (s?.(t) ? s?.(t) : n["fixed-cell-default-background"]), c && (s?.(t) ? s?.(t) : n["fixed-right-cell-default-background"]), ge && n.expanded_row, (!!y || t.isFocused()) && n["single-selection"]),
|
|
41
47
|
style: {
|
|
42
48
|
left: d ? e.left : void 0,
|
|
43
|
-
right: c ? e.right + (
|
|
49
|
+
right: c ? e.right + (U ? -1 : 0) : void 0
|
|
44
50
|
},
|
|
45
|
-
children: /* @__PURE__ */
|
|
51
|
+
children: /* @__PURE__ */ C("div", {
|
|
46
52
|
style: {
|
|
47
53
|
display: "flex",
|
|
48
54
|
alignItems: "center",
|
|
49
|
-
minWidth:
|
|
55
|
+
minWidth: v ? 32 : void 0,
|
|
56
|
+
minHeight: M,
|
|
50
57
|
position: "relative"
|
|
51
58
|
},
|
|
52
|
-
children: [
|
|
59
|
+
children: [v && y && /* @__PURE__ */ l("span", {
|
|
53
60
|
style: {
|
|
54
61
|
display: "inline-flex",
|
|
55
62
|
alignItems: "center",
|
|
@@ -58,45 +65,46 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
|
|
|
58
65
|
top: "50%",
|
|
59
66
|
transform: "translateY(-50%)"
|
|
60
67
|
},
|
|
61
|
-
children: /* @__PURE__ */ l(
|
|
68
|
+
children: /* @__PURE__ */ l(ye, {})
|
|
62
69
|
}), /* @__PURE__ */ l("span", {
|
|
63
70
|
style: {
|
|
64
|
-
marginLeft:
|
|
71
|
+
marginLeft: v && k ? 30 : 0,
|
|
65
72
|
width: "100%"
|
|
66
73
|
},
|
|
67
|
-
children:
|
|
74
|
+
children: De(e.column.columnDef.cell, e.getContext())
|
|
68
75
|
})]
|
|
69
76
|
})
|
|
70
77
|
}, e.id);
|
|
71
78
|
}, [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
s,
|
|
75
|
-
R,
|
|
76
|
-
L,
|
|
79
|
+
y,
|
|
80
|
+
S,
|
|
77
81
|
M,
|
|
82
|
+
s,
|
|
83
|
+
F,
|
|
84
|
+
U,
|
|
85
|
+
W,
|
|
78
86
|
m,
|
|
79
87
|
a,
|
|
80
88
|
t,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
x,
|
|
90
|
+
k,
|
|
91
|
+
w
|
|
84
92
|
]);
|
|
85
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ C(he, { children: [/* @__PURE__ */ C("tr", {
|
|
86
94
|
"aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
|
|
87
95
|
tabIndex: t.isFocused() ? 0 : -1,
|
|
88
|
-
"data-index":
|
|
96
|
+
"data-index": K,
|
|
89
97
|
"data-test": t.id,
|
|
90
98
|
id: t.id,
|
|
91
|
-
className:
|
|
99
|
+
className: $(n["t-row"], V && n["is-loading"], s?.(t)),
|
|
92
100
|
style: {
|
|
93
|
-
height:
|
|
94
|
-
...
|
|
101
|
+
height: h ? `${h}px` : "inherit",
|
|
102
|
+
...I && ie
|
|
95
103
|
},
|
|
96
|
-
ref:
|
|
97
|
-
onMouseUp:
|
|
104
|
+
ref: de,
|
|
105
|
+
onMouseUp: ce,
|
|
98
106
|
onMouseDown: (e) => {
|
|
99
|
-
e.detail > 1 && !
|
|
107
|
+
e.detail > 1 && !F && A && e.preventDefault();
|
|
100
108
|
},
|
|
101
109
|
onKeyDown: (e) => {
|
|
102
110
|
switch (e.key) {
|
|
@@ -108,12 +116,12 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
|
|
|
108
116
|
t.focusPrevRow(), e.preventDefault();
|
|
109
117
|
break;
|
|
110
118
|
case "Enter":
|
|
111
|
-
|
|
119
|
+
T(e);
|
|
112
120
|
break;
|
|
113
121
|
}
|
|
114
122
|
},
|
|
115
123
|
children: [
|
|
116
|
-
m.map((e, i) =>
|
|
124
|
+
m.map((e, i) => E(e, i)),
|
|
117
125
|
u > 0 && /* @__PURE__ */ l("td", {
|
|
118
126
|
"aria-hidden": !0,
|
|
119
127
|
className: n["t-cell"],
|
|
@@ -125,7 +133,7 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
|
|
|
125
133
|
border: "none"
|
|
126
134
|
}
|
|
127
135
|
}),
|
|
128
|
-
|
|
136
|
+
_.map((e, i) => E(e, m.length + i)),
|
|
129
137
|
f > 0 && /* @__PURE__ */ l("td", {
|
|
130
138
|
"aria-hidden": !0,
|
|
131
139
|
className: n["t-cell"],
|
|
@@ -137,14 +145,14 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
|
|
|
137
145
|
border: "none"
|
|
138
146
|
}
|
|
139
147
|
}),
|
|
140
|
-
a.map((e, i) =>
|
|
148
|
+
a.map((e, i) => E(e, m.length + _.length + i))
|
|
141
149
|
]
|
|
142
|
-
}), t.getIsExpanded() && /* @__PURE__ */ l(
|
|
143
|
-
rows:
|
|
150
|
+
}), t.getIsExpanded() && /* @__PURE__ */ l(Se, { children: B && G?.({
|
|
151
|
+
rows: B.get(t.original.id.toString()) ?? [],
|
|
144
152
|
row: t.original
|
|
145
153
|
}) })] }, t.id);
|
|
146
154
|
}
|
|
147
|
-
var
|
|
155
|
+
var ye = () => /* @__PURE__ */ C("svg", {
|
|
148
156
|
xmlns: "http://www.w3.org/2000/svg",
|
|
149
157
|
width: "20",
|
|
150
158
|
height: "20",
|
|
@@ -156,5 +164,5 @@ var he = () => /* @__PURE__ */ p("svg", {
|
|
|
156
164
|
})]
|
|
157
165
|
});
|
|
158
166
|
export {
|
|
159
|
-
|
|
167
|
+
Me as TableRow
|
|
160
168
|
};
|