@harpercollins/harpercollins-design-system 1.38.0 → 1.38.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/.DS_Store +0 -0
- package/dist/cjs/components/data-display/DataGrid/TableToolbar.cjs +26 -3
- package/dist/cjs/components/data-display/Table/hooks/useStickyHeader.cjs +1 -1
- package/dist/esm/components/data-display/DataGrid/TableToolbar.js +51 -28
- package/dist/esm/components/data-display/Table/hooks/useStickyHeader.js +41 -32
- package/package.json +4 -4
package/dist/.DS_Store
ADDED
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),u=require("react"),n=require("styled-components"),h=require("../Typography/Typography.cjs"),f=require("./ExportToExcelButton.cjs"),g=require("./FilterChipsSection.cjs"),w=require("./ManageColumnsDropdown.cjs"),T=require("./TableSettingsDropdown.cjs"),s=require("../../../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/Box/Box.cjs"),m=n(s)`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 8px;
|
|
@@ -9,9 +9,32 @@
|
|
|
9
9
|
position: sticky;
|
|
10
10
|
top: 0;
|
|
11
11
|
z-index: 1;
|
|
12
|
-
`,
|
|
12
|
+
`,y=n(s)`
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
justify-content: space-between;
|
|
16
|
+
gap: 8px;
|
|
16
17
|
width: 100%;
|
|
17
|
-
|
|
18
|
+
/* Allow the start/end groups to wrap onto separate lines when they
|
|
19
|
+
no longer fit side by side (e.g. many filters on a narrow viewport). */
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
`,i=n(s)`
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
/* min-width: 0 lets the group shrink below its content width so children
|
|
26
|
+
(filter chips) can wrap or ellipsis instead of overflowing the toolbar. */
|
|
27
|
+
min-width: 0;
|
|
28
|
+
flex-wrap: wrap;
|
|
29
|
+
`,j=n(i)`
|
|
30
|
+
flex: 1 1 auto;
|
|
31
|
+
`,b=n(i)`
|
|
32
|
+
flex: 0 0 auto;
|
|
33
|
+
justify-content: flex-end;
|
|
34
|
+
|
|
35
|
+
/* On small screens, drop the controls onto their own full-width line. */
|
|
36
|
+
@media (max-width: 768px) {
|
|
37
|
+
flex: 1 1 100%;
|
|
38
|
+
justify-content: flex-start;
|
|
39
|
+
}
|
|
40
|
+
`;function R({toolbar:e,columnFilters:r,table:o,resetColumnVisibility:l,wrapText:a,onWrapTextToggle:c},d){const p=o.getFilteredRowModel().rows.length,x=r.length>0;return t.jsx(m,{ref:d,children:t.jsxs(y,{children:[t.jsxs(j,{children:[e.leftContent?e.leftContent:null,e.exportToExcel?.enabled&&t.jsx(f,{onExport:e.exportToExcel.onExport,disabled:e.exportToExcel.disabled}),e.showFilterChips?t.jsx(g,{columnFilters:r,table:o}):null]}),t.jsxs(b,{children:[e.totalResults!==void 0&&t.jsx(h,{level:"body-sm",sx:{fontWeight:500},children:x?`Showing ${p.toLocaleString()} of ${e.totalResults.toLocaleString()} results`:`Total Results: ${e.totalResults.toLocaleString()}`}),e.rightContent?e.rightContent:null,e.manageColumns?.enabled&&t.jsx(w,{table:o,onReset:l}),e.tableSettings?.enabled&&t.jsx(T,{wrapText:a,onWrapTextToggle:c})]})]})})}const q=u.forwardRef(R);module.exports=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react");function H({enabled:y,stickyHeaderOffset:h,tableWrapperRef:v,theadRef:a,toolbarRef:m}){const[w,p]=n.useState(!1),c=n.useRef(!1),t=n.useRef(null),l=n.useRef(!1),S=n.useRef(0),u=n.useRef(0);return n.useEffect(()=>{if(!y){p(!1),c.current=!1;const e=a.current;e&&(e.style.setProperty("--header-top","0px"),e.style.opacity="1");return}const i=v.current,r=a.current,f=m.current;if(!i||!r)return;u.current=f?.offsetHeight??0;const s=()=>{const T=r.getBoundingClientRect().top,g=h+u.current;if(T<=g){l.current||(l.current=!0,r.style.opacity="0"),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{l.current=!1,r.style.opacity="1"},150);const E=g-T;r.style.setProperty("--header-top",`${E}px`),c.current||(c.current=!0,p(!0))}else r.style.opacity="1",l.current=!1,t.current&&clearTimeout(t.current),r.style.setProperty("--header-top","0px"),c.current&&(c.current=!1,p(!1))};s(),window.addEventListener("scroll",s,{passive:!0});const R=()=>{const e=i.scrollTop;e!==S.current&&(S.current=e,s())};i.addEventListener("scroll",R,{passive:!0});let d,o=null;return f&&typeof ResizeObserver<"u"&&(d=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null;const e=f.offsetHeight;e!==u.current&&(u.current=e,s())}))}),d.observe(f)),()=>{window.removeEventListener("scroll",s),i.removeEventListener("scroll",R),d?.disconnect(),o!==null&&cancelAnimationFrame(o),t.current&&clearTimeout(t.current)}},[y,h,v,a,m]),w}exports.useStickyHeader=H;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import x from "react";
|
|
3
|
+
import o from "styled-components";
|
|
4
|
+
import m from "../Typography/Typography.js";
|
|
5
|
+
import u from "./ExportToExcelButton.js";
|
|
6
|
+
import g from "./FilterChipsSection.js";
|
|
7
|
+
import w from "./ManageColumnsDropdown.js";
|
|
8
8
|
import T from "./TableSettingsDropdown.js";
|
|
9
|
-
import
|
|
10
|
-
const
|
|
9
|
+
import l 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/Box/Box.js";
|
|
10
|
+
const y = o(l)`
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
13
|
gap: 8px;
|
|
@@ -18,54 +18,77 @@ const w = r(o)`
|
|
|
18
18
|
position: sticky;
|
|
19
19
|
top: 0;
|
|
20
20
|
z-index: 1;
|
|
21
|
-
`,
|
|
21
|
+
`, b = o(l)`
|
|
22
22
|
display: flex;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: space-between;
|
|
25
|
+
gap: 8px;
|
|
25
26
|
width: 100%;
|
|
27
|
+
/* Allow the start/end groups to wrap onto separate lines when they
|
|
28
|
+
no longer fit side by side (e.g. many filters on a narrow viewport). */
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
`, s = o(l)`
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 8px;
|
|
34
|
+
/* min-width: 0 lets the group shrink below its content width so children
|
|
35
|
+
(filter chips) can wrap or ellipsis instead of overflowing the toolbar. */
|
|
36
|
+
min-width: 0;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
`, R = o(s)`
|
|
39
|
+
flex: 1 1 auto;
|
|
40
|
+
`, C = o(s)`
|
|
41
|
+
flex: 0 0 auto;
|
|
42
|
+
justify-content: flex-end;
|
|
43
|
+
|
|
44
|
+
/* On small screens, drop the controls onto their own full-width line. */
|
|
45
|
+
@media (max-width: 768px) {
|
|
46
|
+
flex: 1 1 100%;
|
|
47
|
+
justify-content: flex-start;
|
|
48
|
+
}
|
|
26
49
|
`;
|
|
27
|
-
function
|
|
50
|
+
function S({
|
|
28
51
|
toolbar: e,
|
|
29
52
|
columnFilters: i,
|
|
30
53
|
table: n,
|
|
31
|
-
resetColumnVisibility:
|
|
32
|
-
wrapText:
|
|
33
|
-
onWrapTextToggle:
|
|
34
|
-
},
|
|
35
|
-
const
|
|
36
|
-
return /* @__PURE__ */ t(
|
|
37
|
-
/* @__PURE__ */
|
|
54
|
+
resetColumnVisibility: a,
|
|
55
|
+
wrapText: p,
|
|
56
|
+
onWrapTextToggle: d
|
|
57
|
+
}, c) {
|
|
58
|
+
const f = n.getFilteredRowModel().rows.length, h = i.length > 0;
|
|
59
|
+
return /* @__PURE__ */ t(y, { ref: c, children: /* @__PURE__ */ r(b, { children: [
|
|
60
|
+
/* @__PURE__ */ r(R, { children: [
|
|
38
61
|
e.leftContent ? e.leftContent : null,
|
|
39
62
|
e.exportToExcel?.enabled && /* @__PURE__ */ t(
|
|
40
|
-
|
|
63
|
+
u,
|
|
41
64
|
{
|
|
42
65
|
onExport: e.exportToExcel.onExport,
|
|
43
66
|
disabled: e.exportToExcel.disabled
|
|
44
67
|
}
|
|
45
68
|
),
|
|
46
|
-
e.showFilterChips ? /* @__PURE__ */ t(
|
|
69
|
+
e.showFilterChips ? /* @__PURE__ */ t(g, { columnFilters: i, table: n }) : null
|
|
47
70
|
] }),
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
e.totalResults !== void 0 && /* @__PURE__ */ t(
|
|
71
|
+
/* @__PURE__ */ r(C, { children: [
|
|
72
|
+
e.totalResults !== void 0 && /* @__PURE__ */ t(m, { level: "body-sm", sx: { fontWeight: 500 }, children: h ? `Showing ${f.toLocaleString()} of ${e.totalResults.toLocaleString()} results` : `Total Results: ${e.totalResults.toLocaleString()}` }),
|
|
50
73
|
e.rightContent ? e.rightContent : null,
|
|
51
74
|
e.manageColumns?.enabled && /* @__PURE__ */ t(
|
|
52
|
-
|
|
75
|
+
w,
|
|
53
76
|
{
|
|
54
77
|
table: n,
|
|
55
|
-
onReset:
|
|
78
|
+
onReset: a
|
|
56
79
|
}
|
|
57
80
|
),
|
|
58
81
|
e.tableSettings?.enabled && /* @__PURE__ */ t(
|
|
59
82
|
T,
|
|
60
83
|
{
|
|
61
|
-
wrapText:
|
|
62
|
-
onWrapTextToggle:
|
|
84
|
+
wrapText: p,
|
|
85
|
+
onWrapTextToggle: d
|
|
63
86
|
}
|
|
64
87
|
)
|
|
65
88
|
] })
|
|
66
89
|
] }) });
|
|
67
90
|
}
|
|
68
|
-
const
|
|
91
|
+
const B = x.forwardRef(S);
|
|
69
92
|
export {
|
|
70
|
-
|
|
93
|
+
B as default
|
|
71
94
|
};
|
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
enabled:
|
|
4
|
-
stickyHeaderOffset:
|
|
5
|
-
tableWrapperRef:
|
|
6
|
-
theadRef:
|
|
7
|
-
toolbarRef:
|
|
1
|
+
import n from "react";
|
|
2
|
+
function H({
|
|
3
|
+
enabled: y,
|
|
4
|
+
stickyHeaderOffset: h,
|
|
5
|
+
tableWrapperRef: m,
|
|
6
|
+
theadRef: a,
|
|
7
|
+
toolbarRef: v
|
|
8
8
|
}) {
|
|
9
|
-
const [
|
|
10
|
-
return
|
|
11
|
-
if (!
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
9
|
+
const [w, p] = n.useState(!1), c = n.useRef(!1), t = n.useRef(null), l = n.useRef(!1), R = n.useRef(0), u = n.useRef(0);
|
|
10
|
+
return n.useEffect(() => {
|
|
11
|
+
if (!y) {
|
|
12
|
+
p(!1), c.current = !1;
|
|
13
|
+
const e = a.current;
|
|
14
|
+
e && (e.style.setProperty("--header-top", "0px"), e.style.opacity = "1");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const i = m.current, r = a.current, f = v.current;
|
|
18
|
+
if (!i || !r) return;
|
|
19
|
+
u.current = f?.offsetHeight ?? 0;
|
|
20
|
+
const s = () => {
|
|
21
|
+
const T = r.getBoundingClientRect().top, g = h + u.current;
|
|
22
|
+
if (T <= g) {
|
|
23
|
+
l.current || (l.current = !0, r.style.opacity = "0"), t.current && clearTimeout(t.current), t.current = setTimeout(() => {
|
|
24
|
+
l.current = !1, r.style.opacity = "1";
|
|
24
25
|
}, 150);
|
|
25
|
-
const E =
|
|
26
|
-
|
|
26
|
+
const E = g - T;
|
|
27
|
+
r.style.setProperty("--header-top", `${E}px`), c.current || (c.current = !0, p(!0));
|
|
27
28
|
} else
|
|
28
|
-
|
|
29
|
+
r.style.opacity = "1", l.current = !1, t.current && clearTimeout(t.current), r.style.setProperty("--header-top", "0px"), c.current && (c.current = !1, p(!1));
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
s(), window.addEventListener("scroll", s, { passive: !0 });
|
|
32
|
+
const S = () => {
|
|
33
|
+
const e = i.scrollTop;
|
|
34
|
+
e !== R.current && (R.current = e, s());
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
+
i.addEventListener("scroll", S, {
|
|
36
37
|
passive: !0
|
|
37
|
-
})
|
|
38
|
-
|
|
38
|
+
});
|
|
39
|
+
let d, o = null;
|
|
40
|
+
return f && typeof ResizeObserver < "u" && (d = new ResizeObserver(() => {
|
|
41
|
+
o === null && (o = requestAnimationFrame(() => {
|
|
42
|
+
o = null;
|
|
43
|
+
const e = f.offsetHeight;
|
|
44
|
+
e !== u.current && (u.current = e, s());
|
|
45
|
+
}));
|
|
46
|
+
}), d.observe(f)), () => {
|
|
47
|
+
window.removeEventListener("scroll", s), i.removeEventListener("scroll", S), d?.disconnect(), o !== null && cancelAnimationFrame(o), t.current && clearTimeout(t.current);
|
|
39
48
|
};
|
|
40
|
-
}, [
|
|
49
|
+
}, [y, h, m, a, v]), w;
|
|
41
50
|
}
|
|
42
51
|
export {
|
|
43
|
-
|
|
52
|
+
H as useStickyHeader
|
|
44
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harpercollins/harpercollins-design-system",
|
|
3
|
-
"version": "1.38.
|
|
3
|
+
"version": "1.38.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git@ssh.dev.azure.com:v3/HarperCollinsUK/HCDesignSystem/HCDesignSystem"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@tanstack/react-virtual": "^3.13.12",
|
|
43
43
|
"@types/react-datepicker": "^6.2.0",
|
|
44
44
|
"@vitejs/plugin-react": "^4.2.1",
|
|
45
|
-
"chromatic": "^
|
|
45
|
+
"chromatic": "^18.13.3",
|
|
46
46
|
"date-fns": "^3.6.0",
|
|
47
47
|
"focus-trap-react": "^10.2.3",
|
|
48
48
|
"react": "^18.2.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@chromatic-com/storybook": "^4.1.3",
|
|
62
|
-
"@playwright/test": "^1.
|
|
62
|
+
"@playwright/test": "^1.64.1",
|
|
63
63
|
"@rollup/plugin-babel": "^6.0.3",
|
|
64
64
|
"@rollup/plugin-commonjs": "^24.1.0",
|
|
65
65
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
94
94
|
"eslint-plugin-storybook": "^10.0.8",
|
|
95
95
|
"happy-dom": "^14.3.8",
|
|
96
|
-
"playwright": "^1.
|
|
96
|
+
"playwright": "^1.64.1",
|
|
97
97
|
"prettier": "^3.2.5",
|
|
98
98
|
"react-syntax-highlighter": "^15.5.0",
|
|
99
99
|
"storybook": "^10.0.8",
|