@harpercollins/harpercollins-design-system 1.33.0 → 1.35.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/cjs/components/data-display/DataGrid/DataGrid.cjs +1 -0
- package/dist/cjs/components/data-display/{Table → DataGrid}/TableToolbar.cjs +1 -1
- package/dist/cjs/components/data-display/DataGrid/hooks/useDataGrid.cjs +1 -0
- package/dist/cjs/components/data-display/DataGrid/tableUrlUtils.cjs +1 -0
- package/dist/cjs/components/data-display/Table/Table.cjs +1 -1
- package/dist/cjs/components/data-display/Table/Table.styles.cjs +2 -2
- package/dist/cjs/components/data-display/Table/TableHeader.cjs +1 -0
- package/dist/cjs/components/data-display/Table/TableLayout.cjs +1 -0
- package/dist/cjs/hooks/useServerSideTableState.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/data-display/DataGrid/DataGrid.js +70 -0
- package/dist/esm/components/data-display/{Table → DataGrid}/TableToolbar.js +10 -8
- package/dist/esm/components/data-display/DataGrid/hooks/useDataGrid.js +189 -0
- package/dist/esm/components/data-display/DataGrid/tableUrlUtils.js +108 -0
- package/dist/esm/components/data-display/Table/Table.js +51 -346
- package/dist/esm/components/data-display/Table/Table.styles.js +4 -5
- package/dist/esm/components/data-display/Table/TableHeader.js +92 -0
- package/dist/esm/components/data-display/Table/TableLayout.js +112 -0
- package/dist/esm/hooks/useServerSideTableState.js +47 -0
- package/dist/esm/index.js +221 -210
- package/dist/index.d.ts +163 -12
- package/package.json +1 -1
- package/dist/cjs/components/data-display/Table/index.cjs +0 -1
- package/dist/esm/components/data-display/Table/index.js +0 -4
- /package/dist/cjs/components/data-display/{Table → DataGrid}/ExportToExcelButton.cjs +0 -0
- /package/dist/cjs/components/data-display/{Table → DataGrid}/FilterChipsSection.cjs +0 -0
- /package/dist/cjs/components/data-display/{Table → DataGrid}/filters/FilterComponents.cjs +0 -0
- /package/dist/cjs/components/data-display/{Table → DataGrid}/filters/filterFunctions.cjs +0 -0
- /package/dist/cjs/components/data-display/{Table → DataGrid}/hooks/useInfiniteScroll.cjs +0 -0
- /package/dist/esm/components/data-display/{Table → DataGrid}/ExportToExcelButton.js +0 -0
- /package/dist/esm/components/data-display/{Table → DataGrid}/FilterChipsSection.js +0 -0
- /package/dist/esm/components/data-display/{Table → DataGrid}/filters/FilterComponents.js +0 -0
- /package/dist/esm/components/data-display/{Table → DataGrid}/filters/filterFunctions.js +0 -0
- /package/dist/esm/components/data-display/{Table → DataGrid}/hooks/useInfiniteScroll.js +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsxs as u, Fragment as I, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { flexRender as G } from "../../../node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.js";
|
|
3
|
+
import c from "react";
|
|
4
|
+
import M from "./StickyHorizontalScrollbar.js";
|
|
5
|
+
import { TableWrapper as V, getTableStyles as W } from "./Table.styles.js";
|
|
6
|
+
import { TableBody as j } from "./TableBody.js";
|
|
7
|
+
import E from "./TableHeader.js";
|
|
8
|
+
import { useStickyHeader as _ } from "./hooks/useStickyHeader.js";
|
|
9
|
+
import { useStickyScrollbar as A } from "./hooks/useStickyScrollbar.js";
|
|
10
|
+
import D from "../../../node_modules/.pnpm/@mui_joy@5.0.0-beta.52_@emotion_react@11.14.0_@types_react@18.3.28_react@18.3.1__@emoti_58201694b486b0db36cbf79098c4edaa/node_modules/@mui/joy/Table/Table.js";
|
|
11
|
+
function Y({
|
|
12
|
+
ctx: p,
|
|
13
|
+
maxHeight: d = !1,
|
|
14
|
+
wrapText: f = !1,
|
|
15
|
+
rowRender: g,
|
|
16
|
+
showStickyScrollbar: S = !1,
|
|
17
|
+
enableStickyHeader: h = !1,
|
|
18
|
+
stickyHeaderOffset: b = 0,
|
|
19
|
+
footer: z
|
|
20
|
+
}) {
|
|
21
|
+
const {
|
|
22
|
+
id: a,
|
|
23
|
+
table: e,
|
|
24
|
+
rows: T,
|
|
25
|
+
isVirtual: i,
|
|
26
|
+
virtualItems: R,
|
|
27
|
+
paddingTop: v,
|
|
28
|
+
paddingBottom: y,
|
|
29
|
+
measureElement: w,
|
|
30
|
+
wrapperRef: n,
|
|
31
|
+
toolbarRef: x,
|
|
32
|
+
loading: H,
|
|
33
|
+
fetchMoreOnBottomReached: k
|
|
34
|
+
} = p, m = c.useRef(null), F = A(n), $ = _({
|
|
35
|
+
enabled: h,
|
|
36
|
+
stickyHeaderOffset: b,
|
|
37
|
+
tableWrapperRef: n,
|
|
38
|
+
theadRef: m,
|
|
39
|
+
toolbarRef: x
|
|
40
|
+
}), B = c.useMemo(() => {
|
|
41
|
+
const o = e.getFlatHeaders(), t = {};
|
|
42
|
+
for (let l = 0; l < o.length; l += 1) {
|
|
43
|
+
const s = o[l];
|
|
44
|
+
t[`--${a}-header-${s.id}-size`] = s.getSize(), t[`--${a}-col-${s.column.id}-size`] = s.column.getSize();
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
|
+
}, [a, e.getState().columnSizingInfo, e.getState().columnSizing]), C = c.useMemo(() => e.getFlatHeaders().reduce((t, l) => t + l.getSize(), 0), [e.getState().columnSizingInfo, e.getState().columnSizing]);
|
|
48
|
+
return /* @__PURE__ */ u(I, { children: [
|
|
49
|
+
/* @__PURE__ */ r(
|
|
50
|
+
V,
|
|
51
|
+
{
|
|
52
|
+
ref: n,
|
|
53
|
+
"data-testid": "table-wrapper",
|
|
54
|
+
$maxHeight: d,
|
|
55
|
+
onScroll: (o) => k(o.currentTarget),
|
|
56
|
+
children: /* @__PURE__ */ u(
|
|
57
|
+
D,
|
|
58
|
+
{
|
|
59
|
+
hoverRow: !0,
|
|
60
|
+
"data-testid": a,
|
|
61
|
+
sx: W(
|
|
62
|
+
B,
|
|
63
|
+
C,
|
|
64
|
+
f,
|
|
65
|
+
$,
|
|
66
|
+
d
|
|
67
|
+
),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ r(
|
|
70
|
+
E,
|
|
71
|
+
{
|
|
72
|
+
headerGroups: e.getHeaderGroups(),
|
|
73
|
+
id: a,
|
|
74
|
+
theadRef: m
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ r(
|
|
78
|
+
j,
|
|
79
|
+
{
|
|
80
|
+
rows: T,
|
|
81
|
+
columns: e.getAllColumns(),
|
|
82
|
+
rowRender: g,
|
|
83
|
+
loading: H,
|
|
84
|
+
rowSelectionState: e.getState().rowSelection,
|
|
85
|
+
virtualItems: i ? R : void 0,
|
|
86
|
+
paddingTop: i ? v : void 0,
|
|
87
|
+
paddingBottom: i ? y : void 0,
|
|
88
|
+
measureElement: i ? w : void 0
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
z && e.getFooterGroups().length > 0 && /* @__PURE__ */ r("tfoot", { children: e.getFooterGroups().map((o) => /* @__PURE__ */ r("tr", { children: o.headers.map((t) => /* @__PURE__ */ r("td", { colSpan: t.colSpan, children: G(
|
|
92
|
+
t.column.columnDef.footer,
|
|
93
|
+
t.getContext()
|
|
94
|
+
) }, t.id)) }, o.id)) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
S && /* @__PURE__ */ r(
|
|
101
|
+
M,
|
|
102
|
+
{
|
|
103
|
+
scrollContainerRef: n,
|
|
104
|
+
visible: F,
|
|
105
|
+
constrainToContainer: "main"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
Y as default
|
|
112
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useState as f, useRef as d, useEffect as h } from "react";
|
|
2
|
+
import { extractColumnFilterTypes as U, parseSortingFromUrl as P, parseFiltersFromUrl as T, syncStateToUrl as C, buildSortQueryString as R, buildFilterQueryString as x } from "../components/data-display/DataGrid/tableUrlUtils.js";
|
|
3
|
+
const L = (m = {}) => {
|
|
4
|
+
const {
|
|
5
|
+
initialSortField: s,
|
|
6
|
+
initialSortDirection: p = "asc",
|
|
7
|
+
syncUrl: r = !1,
|
|
8
|
+
urlParamPrefix: e = "",
|
|
9
|
+
columns: a,
|
|
10
|
+
columnFilterTypes: S = {}
|
|
11
|
+
} = m, o = a ? U(a) : S, [t, w] = f(() => {
|
|
12
|
+
if (r && typeof window < "u") {
|
|
13
|
+
const i = new URLSearchParams(window.location.search), u = P(i, e);
|
|
14
|
+
if (u.length > 0) return u;
|
|
15
|
+
}
|
|
16
|
+
return s ? [{ id: s, desc: p === "desc" }] : [];
|
|
17
|
+
}), [n, y] = f(() => {
|
|
18
|
+
if (r && typeof window < "u") {
|
|
19
|
+
const i = new URLSearchParams(window.location.search);
|
|
20
|
+
return T(i, e, o);
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
}), l = d(e);
|
|
24
|
+
l.current = e;
|
|
25
|
+
const c = d(o);
|
|
26
|
+
c.current = o, h(() => {
|
|
27
|
+
!r || typeof window > "u" || C(
|
|
28
|
+
t,
|
|
29
|
+
n,
|
|
30
|
+
l.current,
|
|
31
|
+
c.current
|
|
32
|
+
);
|
|
33
|
+
}, [t, n, r]);
|
|
34
|
+
const F = R(t, ""), g = x(n, "");
|
|
35
|
+
return {
|
|
36
|
+
sorting: t,
|
|
37
|
+
onSortingChange: w,
|
|
38
|
+
columnFilters: n,
|
|
39
|
+
onColumnFiltersChange: y,
|
|
40
|
+
sortParams: F,
|
|
41
|
+
filterParams: g
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
L as default,
|
|
46
|
+
U as extractColumnFilterTypes
|
|
47
|
+
};
|