braid-design-system 33.2.0 → 33.2.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/CHANGELOG.md +14 -0
- package/dist/lib/components/MenuRenderer/MenuRenderer.actions.cjs +2 -1
- package/dist/lib/components/MenuRenderer/MenuRenderer.actions.mjs +2 -1
- package/dist/lib/components/MenuRenderer/MenuRenderer.cjs +168 -120
- package/dist/lib/components/MenuRenderer/MenuRenderer.css.cjs +24 -13
- package/dist/lib/components/MenuRenderer/MenuRenderer.css.mjs +25 -14
- package/dist/lib/components/MenuRenderer/MenuRenderer.mjs +170 -122
- package/dist/lib/components/OverflowMenu/OverflowMenu.cjs +13 -13
- package/dist/lib/components/OverflowMenu/OverflowMenu.css.cjs +3 -3
- package/dist/lib/components/OverflowMenu/OverflowMenu.css.mjs +3 -3
- package/dist/lib/components/OverflowMenu/OverflowMenu.mjs +14 -14
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.cjs +67 -0
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.css.cjs +86 -0
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.css.mjs +87 -0
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.mjs +68 -0
- package/package.json +3 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
+
import { style, createVar, styleVariants, fallbackVar } from "@vanilla-extract/css";
|
|
3
|
+
setFileScope("src/lib/components/private/ScrollContainer/ScrollContainer.css.ts", "braid-design-system");
|
|
4
|
+
const container = style({
|
|
5
|
+
WebkitOverflowScrolling: "touch",
|
|
6
|
+
WebkitMaskComposite: "destination-in",
|
|
7
|
+
// Fallback for browsers that don't support mask-composite
|
|
8
|
+
maskComposite: "intersect"
|
|
9
|
+
}, "container");
|
|
10
|
+
const hideScrollbar = style({
|
|
11
|
+
scrollbarWidth: "none",
|
|
12
|
+
msOverflowStyle: "none",
|
|
13
|
+
"::-webkit-scrollbar": {
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0
|
|
16
|
+
}
|
|
17
|
+
}, "hideScrollbar");
|
|
18
|
+
const scrollOverlaySize = createVar("scrollOverlaySize");
|
|
19
|
+
const fadeSize = styleVariants({
|
|
20
|
+
small: {
|
|
21
|
+
vars: {
|
|
22
|
+
[scrollOverlaySize]: "40px"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
medium: {
|
|
26
|
+
vars: {
|
|
27
|
+
[scrollOverlaySize]: "60px"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
large: {
|
|
31
|
+
vars: {
|
|
32
|
+
[scrollOverlaySize]: "80px"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, "fadeSize");
|
|
36
|
+
const direction = styleVariants({
|
|
37
|
+
horizontal: {
|
|
38
|
+
overflowX: "auto",
|
|
39
|
+
overflowY: "hidden"
|
|
40
|
+
},
|
|
41
|
+
vertical: {
|
|
42
|
+
overflowX: "hidden",
|
|
43
|
+
overflowY: "auto"
|
|
44
|
+
},
|
|
45
|
+
all: {
|
|
46
|
+
overflow: "auto"
|
|
47
|
+
}
|
|
48
|
+
}, "direction");
|
|
49
|
+
const left = createVar("left");
|
|
50
|
+
const right = createVar("right");
|
|
51
|
+
const top = createVar("top");
|
|
52
|
+
const bottom = createVar("bottom");
|
|
53
|
+
const mask = style({
|
|
54
|
+
maskImage: [`linear-gradient(to bottom, transparent 0, black ${fallbackVar(top, "0")})`, `linear-gradient(to right, transparent 0, black ${fallbackVar(left, "0")})`, `linear-gradient(to left, transparent 0, black ${fallbackVar(right, "0")})`, `linear-gradient(to top, transparent 0, black ${fallbackVar(bottom, "0")})`].join(",")
|
|
55
|
+
}, "mask");
|
|
56
|
+
const maskLeft = style({
|
|
57
|
+
vars: {
|
|
58
|
+
[left]: scrollOverlaySize
|
|
59
|
+
}
|
|
60
|
+
}, "maskLeft");
|
|
61
|
+
const maskRight = style({
|
|
62
|
+
vars: {
|
|
63
|
+
[right]: scrollOverlaySize
|
|
64
|
+
}
|
|
65
|
+
}, "maskRight");
|
|
66
|
+
const maskTop = style({
|
|
67
|
+
vars: {
|
|
68
|
+
[top]: scrollOverlaySize
|
|
69
|
+
}
|
|
70
|
+
}, "maskTop");
|
|
71
|
+
const maskBottom = style({
|
|
72
|
+
vars: {
|
|
73
|
+
[bottom]: scrollOverlaySize
|
|
74
|
+
}
|
|
75
|
+
}, "maskBottom");
|
|
76
|
+
endFileScope();
|
|
77
|
+
export {
|
|
78
|
+
container,
|
|
79
|
+
direction,
|
|
80
|
+
fadeSize,
|
|
81
|
+
hideScrollbar,
|
|
82
|
+
mask,
|
|
83
|
+
maskBottom,
|
|
84
|
+
maskLeft,
|
|
85
|
+
maskRight,
|
|
86
|
+
maskTop
|
|
87
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useCallback } from "react";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from "../../../hooks/useIsomorphicLayoutEffect.mjs";
|
|
4
|
+
import { Box } from "../../Box/Box.mjs";
|
|
5
|
+
import { buildDataAttributes } from "../buildDataAttributes.mjs";
|
|
6
|
+
import { throttle } from "throttle-debounce";
|
|
7
|
+
import { container, mask, hideScrollbar, fadeSize, direction, maskTop, maskBottom, maskLeft, maskRight } from "./ScrollContainer.css.mjs";
|
|
8
|
+
const scrollOffset = 2;
|
|
9
|
+
const maskOverflow = (element, direction2) => {
|
|
10
|
+
const atTop = element.scrollTop <= 0;
|
|
11
|
+
const atBottom = element.scrollHeight - element.offsetHeight - element.scrollTop < scrollOffset;
|
|
12
|
+
const atLeft = element.scrollLeft <= 0;
|
|
13
|
+
const atRight = element.scrollWidth - element.offsetWidth - element.scrollLeft < scrollOffset;
|
|
14
|
+
if (direction2 === "vertical" || direction2 === "all") {
|
|
15
|
+
element.classList[atTop ? "remove" : "add"](maskTop);
|
|
16
|
+
element.classList[atBottom ? "remove" : "add"](maskBottom);
|
|
17
|
+
}
|
|
18
|
+
if (direction2 === "horizontal" || direction2 === "all") {
|
|
19
|
+
element.classList[atLeft ? "remove" : "add"](maskLeft);
|
|
20
|
+
element.classList[atRight ? "remove" : "add"](maskRight);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const ScrollContainer = ({
|
|
24
|
+
children,
|
|
25
|
+
direction: direction$1 = "horizontal",
|
|
26
|
+
fadeSize: fadeSize$1 = "medium",
|
|
27
|
+
hideScrollbar: hideScrollbar$1 = false,
|
|
28
|
+
data,
|
|
29
|
+
...restProps
|
|
30
|
+
}) => {
|
|
31
|
+
const containerRef = useRef(null);
|
|
32
|
+
const updateMask = throttle(
|
|
33
|
+
100,
|
|
34
|
+
useCallback(() => {
|
|
35
|
+
if (containerRef.current) {
|
|
36
|
+
maskOverflow(containerRef.current, direction$1);
|
|
37
|
+
}
|
|
38
|
+
}, [containerRef, direction$1])
|
|
39
|
+
);
|
|
40
|
+
useIsomorphicLayoutEffect(() => {
|
|
41
|
+
if (containerRef.current) {
|
|
42
|
+
updateMask();
|
|
43
|
+
}
|
|
44
|
+
window.addEventListener("resize", updateMask);
|
|
45
|
+
return () => window.removeEventListener("resize", updateMask);
|
|
46
|
+
}, [updateMask]);
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Box,
|
|
49
|
+
{
|
|
50
|
+
ref: containerRef,
|
|
51
|
+
onScroll: updateMask,
|
|
52
|
+
position: "relative",
|
|
53
|
+
height: "full",
|
|
54
|
+
className: [
|
|
55
|
+
container,
|
|
56
|
+
mask,
|
|
57
|
+
hideScrollbar$1 ? hideScrollbar : null,
|
|
58
|
+
fadeSize[fadeSize$1],
|
|
59
|
+
direction[direction$1]
|
|
60
|
+
],
|
|
61
|
+
...buildDataAttributes({ data, validateRestProps: restProps }),
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
ScrollContainer
|
|
68
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braid-design-system",
|
|
3
|
-
"version": "33.2.
|
|
3
|
+
"version": "33.2.1",
|
|
4
4
|
"description": "Themeable design system for the SEEK Group",
|
|
5
5
|
"homepage": "https://seek-oss.github.io/braid-design-system/",
|
|
6
6
|
"bugs": {
|
|
@@ -186,6 +186,7 @@
|
|
|
186
186
|
"react-is": "^18.2.0",
|
|
187
187
|
"react-popper-tooltip": "^4.3.1",
|
|
188
188
|
"react-remove-scroll": "^2.5.3",
|
|
189
|
+
"throttle-debounce": "^5.0.2",
|
|
189
190
|
"utility-types": "^3.10.0",
|
|
190
191
|
"uuid": "^8.3.2"
|
|
191
192
|
},
|
|
@@ -213,6 +214,7 @@
|
|
|
213
214
|
"@types/react-router-dom": "^5.3.3",
|
|
214
215
|
"@types/sanitize-html": "^2.6.2",
|
|
215
216
|
"@types/testing-library__jest-dom": "^5.9.1",
|
|
217
|
+
"@types/throttle-debounce": "^5.0.2",
|
|
216
218
|
"@types/uuid": "^8.3.0",
|
|
217
219
|
"babel-plugin-macros": "^3.1.0",
|
|
218
220
|
"babel-plugin-transform-remove-imports": "^1.7.0",
|