reshaped 3.5.3 → 3.6.0-canary.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/CHANGELOG.md +11 -21
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +36 -31
- package/dist/bundle.js +10 -10
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -1
- package/dist/components/Button/Button.types.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.module.css +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +1 -1
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +1 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +6 -0
- package/dist/components/Flyout/Flyout.constants.js +19 -0
- package/dist/components/{_private/Flyout → Flyout}/Flyout.types.d.ts +3 -3
- package/dist/components/{_private/Flyout → Flyout}/FlyoutContent.js +25 -20
- package/dist/components/{_private/Flyout → Flyout}/FlyoutControlled.js +9 -9
- package/dist/components/{_private/Flyout → Flyout}/tests/Flyout.stories.d.ts +6 -4
- package/dist/components/{_private/Flyout → Flyout}/tests/Flyout.stories.js +128 -118
- package/dist/components/{_private/Flyout → Flyout}/useFlyout.d.ts +1 -1
- package/dist/components/Flyout/useFlyout.js +116 -0
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +30 -0
- package/dist/components/Flyout/utilities/calculatePosition.js +129 -0
- package/dist/components/Flyout/utilities/flyout.d.ts +11 -0
- package/dist/components/Flyout/utilities/flyout.js +79 -0
- package/dist/components/Flyout/utilities/isFullyVisible.d.ts +10 -0
- package/dist/components/Flyout/utilities/isFullyVisible.js +24 -0
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +1 -1
- package/dist/components/Popover/Popover.js +1 -1
- package/dist/components/Popover/Popover.types.d.ts +2 -1
- package/dist/components/Popover/tests/Popover.stories.d.ts +2 -2
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +2 -2
- package/dist/components/Radio/Radio.module.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +6 -3
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +4 -13
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +30 -129
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +23 -0
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +66 -0
- package/dist/components/Tabs/TabsContext.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/config/tailwind.d.ts +1 -1
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
- package/dist/index.d.ts +36 -31
- package/dist/index.js +20 -16
- package/dist/utilities/dom/find.d.ts +6 -9
- package/dist/utilities/dom/find.js +17 -15
- package/dist/utilities/dom/index.d.ts +1 -1
- package/dist/utilities/dom/index.js +1 -1
- package/dist/utilities/scroll/lock.js +4 -3
- package/package.json +10 -9
- package/CHANGELOG-old.md +0 -14
- package/dist/components/_private/Flyout/Flyout.constants.d.ts +0 -3
- package/dist/components/_private/Flyout/Flyout.constants.js +0 -3
- package/dist/components/_private/Flyout/useFlyout.js +0 -211
- package/dist/components/_private/Flyout/utilities/calculatePosition.d.ts +0 -19
- package/dist/components/_private/Flyout/utilities/calculatePosition.js +0 -102
- package/dist/components/_private/Flyout/utilities/isFullyVisible.d.ts +0 -8
- package/dist/components/_private/Flyout/utilities/isFullyVisible.js +0 -16
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.context.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.context.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.module.css +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/Flyout.types.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutContent.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutControlled.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutTrigger.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutTrigger.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutUncontrolled.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/FlyoutUncontrolled.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/index.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/index.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/utilities/cooldown.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/utilities/cooldown.js +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/utilities/getPositionFallbacks.d.ts +0 -0
- /package/dist/components/{_private/Flyout → Flyout}/utilities/getPositionFallbacks.js +0 -0
@@ -1,102 +0,0 @@
|
|
1
|
-
const SCREEN_OFFSET = 16;
|
2
|
-
const getRTLPosition = (position) => {
|
3
|
-
if (position.includes("start"))
|
4
|
-
return position.replace("start", "end");
|
5
|
-
if (position.includes("end"))
|
6
|
-
return position.replace("end", "start");
|
7
|
-
return position;
|
8
|
-
};
|
9
|
-
/**
|
10
|
-
* Get a position value which centers 2 elements vertically or horizontally
|
11
|
-
*/
|
12
|
-
const centerBySize = (originSize, targetSize) => {
|
13
|
-
return Math.floor(originSize / 2 - targetSize / 2);
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* Calculate styles for the current position
|
17
|
-
*/
|
18
|
-
const calculatePosition = (args) => {
|
19
|
-
const { triggerBounds, flyoutBounds, scopeOffset, position: passedPosition, rtl, width, contentGap = 0, contentShift = 0, } = args;
|
20
|
-
const isFullWidth = width === "full" || width === "100%";
|
21
|
-
let left = 0;
|
22
|
-
let top = 0;
|
23
|
-
let position = passedPosition;
|
24
|
-
if (rtl)
|
25
|
-
position = getRTLPosition(position);
|
26
|
-
if (isFullWidth || width === "trigger") {
|
27
|
-
position = position.includes("top") ? "top" : "bottom";
|
28
|
-
}
|
29
|
-
const isHorizontalPosition = position.match(/^(start|end)/);
|
30
|
-
const isVerticalPosition = position.match(/^(top|bottom)/);
|
31
|
-
const flyoutWidth = flyoutBounds.width + (isHorizontalPosition ? contentGap : 0);
|
32
|
-
const flyoutHeight = flyoutBounds.height + (isVerticalPosition ? contentGap : 0);
|
33
|
-
switch (position) {
|
34
|
-
case "bottom":
|
35
|
-
case "top":
|
36
|
-
left = centerBySize(triggerBounds.width, flyoutWidth) + triggerBounds.left + contentShift;
|
37
|
-
break;
|
38
|
-
case "start":
|
39
|
-
case "start-top":
|
40
|
-
case "start-bottom":
|
41
|
-
left = triggerBounds.left - flyoutWidth;
|
42
|
-
break;
|
43
|
-
case "end":
|
44
|
-
case "end-top":
|
45
|
-
case "end-bottom":
|
46
|
-
left = triggerBounds.right;
|
47
|
-
break;
|
48
|
-
case "top-start":
|
49
|
-
case "bottom-start":
|
50
|
-
left = triggerBounds.left + contentShift + contentShift;
|
51
|
-
break;
|
52
|
-
case "top-end":
|
53
|
-
case "bottom-end":
|
54
|
-
left = triggerBounds.right - flyoutWidth + contentShift;
|
55
|
-
break;
|
56
|
-
default:
|
57
|
-
break;
|
58
|
-
}
|
59
|
-
switch (position) {
|
60
|
-
case "top":
|
61
|
-
case "top-start":
|
62
|
-
case "top-end":
|
63
|
-
top = triggerBounds.top - flyoutHeight;
|
64
|
-
break;
|
65
|
-
case "bottom":
|
66
|
-
case "bottom-start":
|
67
|
-
case "bottom-end":
|
68
|
-
top = triggerBounds.bottom;
|
69
|
-
break;
|
70
|
-
case "start":
|
71
|
-
case "end":
|
72
|
-
top = centerBySize(triggerBounds.height, flyoutHeight) + triggerBounds.top + contentShift;
|
73
|
-
break;
|
74
|
-
case "start-top":
|
75
|
-
case "end-top":
|
76
|
-
top = triggerBounds.top + contentShift;
|
77
|
-
break;
|
78
|
-
case "start-bottom":
|
79
|
-
case "end-bottom":
|
80
|
-
top = triggerBounds.bottom - flyoutHeight + contentShift;
|
81
|
-
break;
|
82
|
-
default:
|
83
|
-
break;
|
84
|
-
}
|
85
|
-
if (top === undefined || left === undefined) {
|
86
|
-
throw Error(`[Reshaped, flyout]: ${position} position is not valid`);
|
87
|
-
}
|
88
|
-
top = Math.round(top + (window.scrollY || 0) - scopeOffset.top);
|
89
|
-
left = Math.round(left + (window.scrollX || 0) - scopeOffset.left);
|
90
|
-
let widthStyle = Math.ceil(flyoutWidth);
|
91
|
-
const height = Math.ceil(flyoutHeight);
|
92
|
-
if (isFullWidth) {
|
93
|
-
left = SCREEN_OFFSET;
|
94
|
-
widthStyle = window.innerWidth - SCREEN_OFFSET * 2;
|
95
|
-
}
|
96
|
-
else if (width === "trigger") {
|
97
|
-
widthStyle = triggerBounds.width;
|
98
|
-
}
|
99
|
-
const styles = { left, top, width: widthStyle, height };
|
100
|
-
return { styles, position, scopeOffset };
|
101
|
-
};
|
102
|
-
export default calculatePosition;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import calculatePosition from "./calculatePosition";
|
2
|
-
/**
|
3
|
-
* Check if element visually fits on the screen
|
4
|
-
*/
|
5
|
-
declare const isFullyVisible: (args: ReturnType<typeof calculatePosition> & {
|
6
|
-
container?: HTMLElement | null;
|
7
|
-
}) => boolean;
|
8
|
-
export default isFullyVisible;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Check if element visually fits on the screen
|
3
|
-
*/
|
4
|
-
const isFullyVisible = (args) => {
|
5
|
-
const { styles, scopeOffset, container } = args;
|
6
|
-
const htmlEl = container || document.documentElement;
|
7
|
-
const pageLeft = htmlEl.scrollLeft;
|
8
|
-
const pageRight = pageLeft + htmlEl.clientWidth;
|
9
|
-
const pageTop = htmlEl.scrollTop;
|
10
|
-
const pageBottom = pageTop + htmlEl.clientHeight;
|
11
|
-
return (styles.left + scopeOffset.left >= pageLeft &&
|
12
|
-
styles.left + styles.width + scopeOffset.left <= pageRight &&
|
13
|
-
styles.top + scopeOffset.top >= pageTop &&
|
14
|
-
styles.top + styles.height + scopeOffset.top <= pageBottom);
|
15
|
-
};
|
16
|
-
export default isFullyVisible;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|