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
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Components
|
3
3
|
*/
|
4
|
-
export { default as Accordion } from "./components/Accordion";
|
5
|
-
export type { AccordionProps } from "./components/Accordion";
|
6
|
-
export { default as Actionable } from "./components/Actionable";
|
7
|
-
export type { ActionableProps, ActionableRef } from "./components/Actionable";
|
8
4
|
export { default as ActionBar } from "./components/ActionBar";
|
9
5
|
export type { ActionBarProps } from "./components/ActionBar";
|
10
6
|
export { default as Alert } from "./components/Alert";
|
@@ -29,32 +25,16 @@ export { default as Checkbox } from "./components/Checkbox";
|
|
29
25
|
export type { CheckboxProps } from "./components/Checkbox";
|
30
26
|
export { default as CheckboxGroup } from "./components/CheckboxGroup";
|
31
27
|
export type { CheckboxGroupProps } from "./components/CheckboxGroup";
|
32
|
-
export { default as Container } from "./components/Container";
|
33
|
-
export type { ContainerProps } from "./components/Container";
|
34
28
|
export { default as ContextMenu } from "./components/ContextMenu";
|
35
29
|
export type { ContextMenuProps } from "./components/ContextMenu";
|
36
|
-
export { default as Dismissible } from "./components/Dismissible";
|
37
|
-
export type { DismissibleProps } from "./components/Dismissible";
|
38
30
|
export { default as Divider } from "./components/Divider";
|
39
31
|
export type { DividerProps } from "./components/Divider";
|
40
32
|
export { default as DropdownMenu } from "./components/DropdownMenu";
|
41
33
|
export type { DropdownMenuProps, DropdownMenuInstance } from "./components/DropdownMenu";
|
42
34
|
export { default as FileUpload } from "./components/FileUpload";
|
43
35
|
export type { FileUploadProps } from "./components/FileUpload";
|
44
|
-
export { default as FormControl } from "./components/FormControl";
|
45
|
-
export type { FormControlProps } from "./components/FormControl";
|
46
|
-
export { default as Grid } from "./components/Grid";
|
47
|
-
export type { GridProps, GridItemProps } from "./components/Grid";
|
48
|
-
export { default as Hidden } from "./components/Hidden";
|
49
|
-
export type { HiddenProps } from "./components/Hidden";
|
50
|
-
export { default as HiddenVisually } from "./components/HiddenVisually";
|
51
|
-
export type { HiddenVisuallyProps } from "./components/HiddenVisually";
|
52
36
|
export { default as Hotkey } from "./components/Hotkey";
|
53
37
|
export type { HotkeyProps } from "./components/Hotkey";
|
54
|
-
export { default as Icon } from "./components/Icon";
|
55
|
-
export type { IconProps } from "./components/Icon";
|
56
|
-
export { default as Image } from "./components/Image";
|
57
|
-
export type { ImageProps } from "./components/Image";
|
58
38
|
export { default as Link } from "./components/Link";
|
59
39
|
export type { LinkProps } from "./components/Link";
|
60
40
|
export { default as Loader } from "./components/Loader";
|
@@ -65,8 +45,6 @@ export { default as Modal } from "./components/Modal";
|
|
65
45
|
export type { ModalProps } from "./components/Modal";
|
66
46
|
export { default as NumberField } from "./components/NumberField";
|
67
47
|
export type { NumberFieldProps } from "./components/NumberField";
|
68
|
-
export { default as Overlay } from "./components/Overlay";
|
69
|
-
export type { OverlayProps } from "./components/Overlay";
|
70
48
|
export { default as Pagination } from "./components/Pagination";
|
71
49
|
export type { PaginationProps } from "./components/Pagination";
|
72
50
|
export { default as PinField } from "./components/PinField";
|
@@ -81,14 +59,8 @@ export { default as Radio } from "./components/Radio";
|
|
81
59
|
export type { RadioProps } from "./components/Radio";
|
82
60
|
export { default as RadioGroup } from "./components/RadioGroup";
|
83
61
|
export type { RadioGroupProps } from "./components/RadioGroup";
|
84
|
-
export { default as Reshaped } from "./components/Reshaped";
|
85
|
-
export type { ReshapedProps } from "./components/Reshaped";
|
86
|
-
export { default as Resizable } from "./components/Resizable";
|
87
|
-
export type { ResizableProps, ResizableItemProps, ResizableHandleProps, } from "./components/Resizable";
|
88
62
|
export { default as Scrim } from "./components/Scrim";
|
89
63
|
export type { ScrimProps } from "./components/Scrim";
|
90
|
-
export { default as ScrollArea } from "./components/ScrollArea";
|
91
|
-
export type { ScrollAreaProps } from "./components/ScrollArea";
|
92
64
|
export { default as Select } from "./components/Select";
|
93
65
|
export type { SelectProps } from "./components/Select";
|
94
66
|
export { default as Skeleton } from "./components/Skeleton";
|
@@ -103,8 +75,6 @@ export { default as Table } from "./components/Table";
|
|
103
75
|
export type { TableProps, TableBodyProps, TableHeadProps, TableHeadingProps, TableCellProps, TableRowProps, } from "./components/Table";
|
104
76
|
export { default as Tabs } from "./components/Tabs";
|
105
77
|
export type { TabsProps } from "./components/Tabs";
|
106
|
-
export { default as Text } from "./components/Text";
|
107
|
-
export type { TextProps } from "./components/Text";
|
108
78
|
export { default as TextArea } from "./components/TextArea";
|
109
79
|
export type { TextAreaProps } from "./components/TextArea";
|
110
80
|
export { default as TextField } from "./components/TextField";
|
@@ -115,6 +85,41 @@ export { useToast, ToastProvider } from "./components/Toast";
|
|
115
85
|
export type { ToastProps, ToastProviderProps, ToastShowProps } from "./components/Toast";
|
116
86
|
export { default as Tooltip } from "./components/Tooltip";
|
117
87
|
export type { TooltipProps } from "./components/Tooltip";
|
88
|
+
/**
|
89
|
+
* Utility components
|
90
|
+
*/
|
91
|
+
export { default as Reshaped } from "./components/Reshaped";
|
92
|
+
export type { ReshapedProps } from "./components/Reshaped";
|
93
|
+
export { default as Accordion } from "./components/Accordion";
|
94
|
+
export type { AccordionProps } from "./components/Accordion";
|
95
|
+
export { default as Actionable } from "./components/Actionable";
|
96
|
+
export type { ActionableProps, ActionableRef } from "./components/Actionable";
|
97
|
+
export { default as Container } from "./components/Container";
|
98
|
+
export type { ContainerProps } from "./components/Container";
|
99
|
+
export { default as Dismissible } from "./components/Dismissible";
|
100
|
+
export type { DismissibleProps } from "./components/Dismissible";
|
101
|
+
export { default as Flyout } from "./components/Flyout";
|
102
|
+
export type { FlyoutProps, FlyoutInstance } from "./components/Flyout";
|
103
|
+
export { default as FormControl } from "./components/FormControl";
|
104
|
+
export type { FormControlProps } from "./components/FormControl";
|
105
|
+
export { default as Grid } from "./components/Grid";
|
106
|
+
export type { GridProps, GridItemProps } from "./components/Grid";
|
107
|
+
export { default as Hidden } from "./components/Hidden";
|
108
|
+
export type { HiddenProps } from "./components/Hidden";
|
109
|
+
export { default as HiddenVisually } from "./components/HiddenVisually";
|
110
|
+
export type { HiddenVisuallyProps } from "./components/HiddenVisually";
|
111
|
+
export { default as Icon } from "./components/Icon";
|
112
|
+
export type { IconProps } from "./components/Icon";
|
113
|
+
export { default as Image } from "./components/Image";
|
114
|
+
export type { ImageProps } from "./components/Image";
|
115
|
+
export { default as Overlay } from "./components/Overlay";
|
116
|
+
export type { OverlayProps } from "./components/Overlay";
|
117
|
+
export { default as Resizable } from "./components/Resizable";
|
118
|
+
export type { ResizableProps, ResizableItemProps, ResizableHandleProps, } from "./components/Resizable";
|
119
|
+
export { default as ScrollArea } from "./components/ScrollArea";
|
120
|
+
export type { ScrollAreaProps } from "./components/ScrollArea";
|
121
|
+
export { default as Text } from "./components/Text";
|
122
|
+
export type { TextProps } from "./components/Text";
|
118
123
|
export { default as View } from "./components/View";
|
119
124
|
export type { ViewProps, ViewItemProps } from "./components/View";
|
120
125
|
/**
|
@@ -132,7 +137,7 @@ export { default as useRTL } from "./hooks/useRTL";
|
|
132
137
|
export { default as useScrollLock } from "./hooks/useScrollLock";
|
133
138
|
export { default as useToggle } from "./hooks/useToggle";
|
134
139
|
/**
|
135
|
-
*
|
140
|
+
* Utility functions
|
136
141
|
*/
|
137
142
|
export { classNames, responsiveClassNames, responsivePropDependency } from "./utilities/helpers";
|
138
143
|
export { TrapFocus } from "./utilities/a11y";
|
package/dist/index.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Components
|
3
3
|
*/
|
4
|
-
export { default as Accordion } from "./components/Accordion/index.js";
|
5
|
-
export { default as Actionable } from "./components/Actionable/index.js";
|
6
4
|
export { default as ActionBar } from "./components/ActionBar/index.js";
|
7
5
|
export { default as Alert } from "./components/Alert/index.js";
|
8
6
|
export { default as Autocomplete } from "./components/Autocomplete/index.js";
|
@@ -15,25 +13,16 @@ export { default as Card } from "./components/Card/index.js";
|
|
15
13
|
export { default as Carousel } from "./components/Carousel/index.js";
|
16
14
|
export { default as Checkbox } from "./components/Checkbox/index.js";
|
17
15
|
export { default as CheckboxGroup } from "./components/CheckboxGroup/index.js";
|
18
|
-
export { default as Container } from "./components/Container/index.js";
|
19
16
|
export { default as ContextMenu } from "./components/ContextMenu/index.js";
|
20
|
-
export { default as Dismissible } from "./components/Dismissible/index.js";
|
21
17
|
export { default as Divider } from "./components/Divider/index.js";
|
22
18
|
export { default as DropdownMenu } from "./components/DropdownMenu/index.js";
|
23
19
|
export { default as FileUpload } from "./components/FileUpload/index.js";
|
24
|
-
export { default as FormControl } from "./components/FormControl/index.js";
|
25
|
-
export { default as Grid } from "./components/Grid/index.js";
|
26
|
-
export { default as Hidden } from "./components/Hidden/index.js";
|
27
|
-
export { default as HiddenVisually } from "./components/HiddenVisually/index.js";
|
28
20
|
export { default as Hotkey } from "./components/Hotkey/index.js";
|
29
|
-
export { default as Icon } from "./components/Icon/index.js";
|
30
|
-
export { default as Image } from "./components/Image/index.js";
|
31
21
|
export { default as Link } from "./components/Link/index.js";
|
32
22
|
export { default as Loader } from "./components/Loader/index.js";
|
33
23
|
export { default as MenuItem } from "./components/MenuItem/index.js";
|
34
24
|
export { default as Modal } from "./components/Modal/index.js";
|
35
25
|
export { default as NumberField } from "./components/NumberField/index.js";
|
36
|
-
export { default as Overlay } from "./components/Overlay/index.js";
|
37
26
|
export { default as Pagination } from "./components/Pagination/index.js";
|
38
27
|
export { default as PinField } from "./components/PinField/index.js";
|
39
28
|
export { default as Popover } from "./components/Popover/index.js";
|
@@ -41,10 +30,7 @@ export { default as Progress } from "./components/Progress/index.js";
|
|
41
30
|
export { default as ProgressIndicator } from "./components/ProgressIndicator/index.js";
|
42
31
|
export { default as Radio } from "./components/Radio/index.js";
|
43
32
|
export { default as RadioGroup } from "./components/RadioGroup/index.js";
|
44
|
-
export { default as Reshaped } from "./components/Reshaped/index.js";
|
45
|
-
export { default as Resizable } from "./components/Resizable/index.js";
|
46
33
|
export { default as Scrim } from "./components/Scrim/index.js";
|
47
|
-
export { default as ScrollArea } from "./components/ScrollArea/index.js";
|
48
34
|
export { default as Select } from "./components/Select/index.js";
|
49
35
|
export { default as Skeleton } from "./components/Skeleton/index.js";
|
50
36
|
export { default as Slider } from "./components/Slider/index.js";
|
@@ -52,12 +38,30 @@ export { default as Stepper } from "./components/Stepper/index.js";
|
|
52
38
|
export { default as Switch } from "./components/Switch/index.js";
|
53
39
|
export { default as Table } from "./components/Table/index.js";
|
54
40
|
export { default as Tabs } from "./components/Tabs/index.js";
|
55
|
-
export { default as Text } from "./components/Text/index.js";
|
56
41
|
export { default as TextArea } from "./components/TextArea/index.js";
|
57
42
|
export { default as TextField } from "./components/TextField/index.js";
|
58
43
|
export { default as Timeline } from "./components/Timeline/index.js";
|
59
44
|
export { useToast, ToastProvider } from "./components/Toast/index.js";
|
60
45
|
export { default as Tooltip } from "./components/Tooltip/index.js";
|
46
|
+
/**
|
47
|
+
* Utility components
|
48
|
+
*/
|
49
|
+
export { default as Reshaped } from "./components/Reshaped/index.js";
|
50
|
+
export { default as Accordion } from "./components/Accordion/index.js";
|
51
|
+
export { default as Actionable } from "./components/Actionable/index.js";
|
52
|
+
export { default as Container } from "./components/Container/index.js";
|
53
|
+
export { default as Dismissible } from "./components/Dismissible/index.js";
|
54
|
+
export { default as Flyout } from "./components/Flyout/index.js";
|
55
|
+
export { default as FormControl } from "./components/FormControl/index.js";
|
56
|
+
export { default as Grid } from "./components/Grid/index.js";
|
57
|
+
export { default as Hidden } from "./components/Hidden/index.js";
|
58
|
+
export { default as HiddenVisually } from "./components/HiddenVisually/index.js";
|
59
|
+
export { default as Icon } from "./components/Icon/index.js";
|
60
|
+
export { default as Image } from "./components/Image/index.js";
|
61
|
+
export { default as Overlay } from "./components/Overlay/index.js";
|
62
|
+
export { default as Resizable } from "./components/Resizable/index.js";
|
63
|
+
export { default as ScrollArea } from "./components/ScrollArea/index.js";
|
64
|
+
export { default as Text } from "./components/Text/index.js";
|
61
65
|
export { default as View } from "./components/View/index.js";
|
62
66
|
/**
|
63
67
|
* Hooks
|
@@ -74,7 +78,7 @@ export { default as useRTL } from "./hooks/useRTL.js";
|
|
74
78
|
export { default as useScrollLock } from "./hooks/useScrollLock.js";
|
75
79
|
export { default as useToggle } from "./hooks/useToggle.js";
|
76
80
|
/**
|
77
|
-
*
|
81
|
+
* Utility functions
|
78
82
|
*/
|
79
83
|
export { classNames, responsiveClassNames, responsivePropDependency } from "./utilities/helpers.js";
|
80
84
|
export { TrapFocus } from "./utilities/a11y/index.js";
|
@@ -1,13 +1,10 @@
|
|
1
1
|
export declare const findParent: (element: HTMLElement, condition: (el: HTMLElement) => boolean) => HTMLElement | null;
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
export declare const
|
2
|
+
export declare const findClosestPositionContainer: (args: {
|
3
|
+
el: HTMLElement | null;
|
4
|
+
iteration?: number;
|
5
|
+
}) => HTMLElement;
|
6
|
+
export declare const findClosestScrollableContainer: (args: {
|
7
7
|
el: HTMLElement | null;
|
8
8
|
iteration?: number;
|
9
9
|
overflowOnly?: boolean;
|
10
|
-
}) =>
|
11
|
-
el: HTMLElement;
|
12
|
-
scrollable?: boolean;
|
13
|
-
};
|
10
|
+
}) => HTMLElement;
|
@@ -8,28 +8,30 @@ export const findParent = (element, condition) => {
|
|
8
8
|
}
|
9
9
|
return null;
|
10
10
|
};
|
11
|
-
|
12
|
-
|
13
|
-
* mostly used in flyouts since the have to accommodate for positioning and overflow
|
14
|
-
*/
|
15
|
-
export const findClosestRenderContainer = (args) => {
|
16
|
-
const { el, iteration = 0, overflowOnly } = args;
|
11
|
+
export const findClosestPositionContainer = (args) => {
|
12
|
+
const { el, iteration = 0 } = args;
|
17
13
|
const style = el && window.getComputedStyle(el);
|
18
|
-
const overflowY = style?.overflowY;
|
19
14
|
const position = style?.position;
|
20
|
-
const isScrollable = overflowY?.includes("scroll") || overflowY?.includes("auto");
|
21
15
|
const isFixed = position === "fixed" || position === "sticky";
|
22
|
-
// Only check shadow root on the first run
|
23
16
|
if (iteration === 0) {
|
24
17
|
const shadowRoot = getShadowRoot(el);
|
25
18
|
if (shadowRoot?.firstElementChild)
|
26
|
-
return
|
19
|
+
return shadowRoot.firstElementChild;
|
27
20
|
}
|
28
21
|
if (el === document.body || !el)
|
29
|
-
return
|
22
|
+
return document.body;
|
23
|
+
if (isFixed)
|
24
|
+
return el;
|
25
|
+
return findClosestPositionContainer({ el: el.parentElement, iteration: iteration + 1 });
|
26
|
+
};
|
27
|
+
export const findClosestScrollableContainer = (args) => {
|
28
|
+
const { el, iteration = 0 } = args;
|
29
|
+
const style = el && window.getComputedStyle(el);
|
30
|
+
const overflowY = style?.overflowY;
|
31
|
+
const isScrollable = overflowY?.includes("scroll") || overflowY?.includes("auto");
|
32
|
+
if (el === document.body || !el)
|
33
|
+
return document.body;
|
30
34
|
if (isScrollable && el.scrollHeight > el.clientHeight)
|
31
|
-
return
|
32
|
-
|
33
|
-
return { el };
|
34
|
-
return findClosestRenderContainer({ el: el.parentElement, iteration: iteration + 1 });
|
35
|
+
return el;
|
36
|
+
return findClosestScrollableContainer({ el: el.parentElement, iteration: iteration + 1 });
|
35
37
|
};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { getRectFromCoordinates } from "./flyout";
|
2
2
|
export { getShadowRoot } from "./shadowDom";
|
3
3
|
export { enableUserSelect, disableUserSelect } from "./userSelect";
|
4
|
-
export { findParent,
|
4
|
+
export { findParent, findClosestScrollableContainer, findClosestPositionContainer } from "./find";
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { getRectFromCoordinates } from "./flyout.js";
|
2
2
|
export { getShadowRoot } from "./shadowDom.js";
|
3
3
|
export { enableUserSelect, disableUserSelect } from "./userSelect.js";
|
4
|
-
export { findParent,
|
4
|
+
export { findParent, findClosestScrollableContainer, findClosestPositionContainer } from "./find.js";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { isIOS } from "../platform.js";
|
2
|
-
import {
|
2
|
+
import { findClosestScrollableContainer } from "../dom/index.js";
|
3
3
|
import lockSafariScroll from "./lockSafari.js";
|
4
4
|
import lockStandardScroll from "./lockStandard.js";
|
5
5
|
let bodyLockedCount = 0;
|
@@ -7,8 +7,9 @@ let reset = () => { };
|
|
7
7
|
export const lockScroll = (args) => {
|
8
8
|
const isIOSLock = isIOS() && !args.containerEl && !args.originEl;
|
9
9
|
let container = document.body;
|
10
|
-
if (args.originEl && !isIOSLock)
|
11
|
-
container =
|
10
|
+
if (args.originEl && !isIOSLock) {
|
11
|
+
container = findClosestScrollableContainer({ el: args.originEl });
|
12
|
+
}
|
12
13
|
if (args.containerEl && !isIOSLock)
|
13
14
|
container = args.containerEl;
|
14
15
|
if (container === document.body)
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "3.
|
4
|
+
"version": "3.6.0-canary.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -21,9 +21,10 @@
|
|
21
21
|
"bugs": {
|
22
22
|
"url": "https://github.com/formaat-design/reshaped/issues"
|
23
23
|
},
|
24
|
-
"
|
25
|
-
"
|
26
|
-
|
24
|
+
"repository": {
|
25
|
+
"type": "git",
|
26
|
+
"url": "https://github.com/formaat-design/reshaped"
|
27
|
+
},
|
27
28
|
"files": [
|
28
29
|
"bin/cli.js",
|
29
30
|
"dist/**/*"
|
@@ -57,6 +58,7 @@
|
|
57
58
|
"./themes/fragments/twitter/*": "./dist/themes/fragments/twitter/*",
|
58
59
|
"./package.json": "./package.json"
|
59
60
|
},
|
61
|
+
"sideEffects": false,
|
60
62
|
"bin": {
|
61
63
|
"reshaped": "./bin/cli.js"
|
62
64
|
},
|
@@ -74,8 +76,8 @@
|
|
74
76
|
"build:storybook": "storybook build -o dist/app --disable-telemetry",
|
75
77
|
"build:chromatic": "STORYBOOK_ENV=chromatic storybook build",
|
76
78
|
"release": "read -p 'Have you updated chromatic tests?' && yarn release:lib && yarn release:source && yarn build:storybook && yarn release:copy",
|
77
|
-
"release:lib": "yarn build && yarn publish
|
78
|
-
"release:canary": "yarn build && yarn publish --tag canary
|
79
|
+
"release:lib": "yarn build && yarn publish",
|
80
|
+
"release:canary": "yarn build && yarn publish --tag canary",
|
79
81
|
"release:test": "yarn build && yarn pack --filename reshaped-test.tgz",
|
80
82
|
"release:source": "sh ./bin/release-source.sh",
|
81
83
|
"release:copy": "sh ./bin/release-copy.sh",
|
@@ -87,7 +89,7 @@
|
|
87
89
|
"lint": "yarn lint:js && yarn lint:css",
|
88
90
|
"lint:js": "eslint './src/**/*.{ts,tsx}' --fix",
|
89
91
|
"lint:css": "stylelint 'src/**/*.css'",
|
90
|
-
"commit": "
|
92
|
+
"commit": "git-cz"
|
91
93
|
},
|
92
94
|
"browserslist": [
|
93
95
|
"defaults and not IE 11"
|
@@ -116,7 +118,6 @@
|
|
116
118
|
"@vitest/coverage-istanbul": "3.1.2",
|
117
119
|
"@vitest/coverage-v8": "3.1.2",
|
118
120
|
"chromatic": "11.28.2",
|
119
|
-
"conventional-changelog-cli": "^5.0.0",
|
120
121
|
"cz-conventional-changelog": "3.3.0",
|
121
122
|
"eslint": "9.25.1",
|
122
123
|
"eslint-config-prettier": "10.1.2",
|
@@ -142,7 +143,7 @@
|
|
142
143
|
"stylelint-config-standard": "38.0.0",
|
143
144
|
"ts-node": "10.9.2",
|
144
145
|
"typescript": "5.8.3",
|
145
|
-
"typescript-eslint": "8.
|
146
|
+
"typescript-eslint": "8.31.0",
|
146
147
|
"vite": "6.3.2",
|
147
148
|
"vite-tsconfig-paths": "5.1.4",
|
148
149
|
"vitest": "3.1.2",
|
package/CHANGELOG-old.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
## WIP 3.5.2
|
2
|
-
|
3
|
-
- Tailwind 3: Preflight compatibility
|
4
|
-
- ScrollArea: fixed maxHeight
|
5
|
-
- Updated sideEffects to \*.css
|
6
|
-
|
7
|
-
## 3.5.1
|
8
|
-
|
9
|
-
- NumberField: user-select none for touch devices
|
10
|
-
- Tabs: Fixed arrow navigation
|
11
|
-
- Slider: Fixed drag propagation when used in swipeable modals
|
12
|
-
- Card: Removed internal content wrapper to fix Safari absolute positioning of contents inside the card
|
13
|
-
- [Pro] Storybook: Preserve theme and mode values while navigating stories
|
14
|
-
- [Pro] Storybook config: switched to js to resolve TS resolving issues
|
@@ -1,211 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import useRTL from "../../../hooks/useRTL.js";
|
3
|
-
import { findClosestRenderContainer, getShadowRoot, getRectFromCoordinates } from "../../../utilities/dom/index.js";
|
4
|
-
import calculatePosition from "./utilities/calculatePosition.js";
|
5
|
-
import getPositionFallbacks from "./utilities/getPositionFallbacks.js";
|
6
|
-
import isFullyVisible from "./utilities/isFullyVisible.js";
|
7
|
-
/**
|
8
|
-
* Order of keys here is responsible for the order of styles applied
|
9
|
-
*/
|
10
|
-
const defaultStyles = {
|
11
|
-
left: 0,
|
12
|
-
top: 0,
|
13
|
-
width: "auto",
|
14
|
-
height: "auto",
|
15
|
-
// z-index doesn't accept strings
|
16
|
-
zIndex: "var(--rs-z-index-flyout)",
|
17
|
-
};
|
18
|
-
const resetStyles = {
|
19
|
-
left: 0,
|
20
|
-
top: 0,
|
21
|
-
position: "absolute",
|
22
|
-
visibility: "hidden",
|
23
|
-
animation: "none",
|
24
|
-
transition: "none",
|
25
|
-
zIndex: "var(--rs-z-index-tooltip)",
|
26
|
-
};
|
27
|
-
/**
|
28
|
-
* Set position of the target element to fit on the screen
|
29
|
-
*/
|
30
|
-
const flyout = (args) => {
|
31
|
-
const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, ...options } = args;
|
32
|
-
const { position, fallbackPositions, width, container, lastUsedFallback, onFallback } = options;
|
33
|
-
const targetClone = flyoutEl.cloneNode(true);
|
34
|
-
const baseUnit = getComputedStyle(flyoutEl).getPropertyValue("--rs-unit-x1");
|
35
|
-
const unitModifier = baseUnit ? parseInt(baseUnit) : 0;
|
36
|
-
const internalTriggerBounds = triggerEl?.getBoundingClientRect();
|
37
|
-
const triggerBounds = passedTriggerBounds || internalTriggerBounds;
|
38
|
-
if (!triggerBounds)
|
39
|
-
return;
|
40
|
-
const resolvedTriggerBounds = getRectFromCoordinates(triggerBounds);
|
41
|
-
// Reset all styles applied on the previous hook execution
|
42
|
-
targetClone.style.cssText = "";
|
43
|
-
Object.keys(resetStyles).forEach((key) => {
|
44
|
-
const value = resetStyles[key];
|
45
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
46
|
-
// @ts-ignore
|
47
|
-
if (value)
|
48
|
-
targetClone.style[key] = value.toString();
|
49
|
-
});
|
50
|
-
if (width) {
|
51
|
-
if (width === "trigger") {
|
52
|
-
targetClone.style.width = `${resolvedTriggerBounds.width}px`;
|
53
|
-
}
|
54
|
-
else if (width !== "full") {
|
55
|
-
targetClone.style.width = width;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
const shadowRoot = triggerEl && getShadowRoot(triggerEl);
|
59
|
-
// Insert inside shadow root if possible to make sure styles are applied correctly
|
60
|
-
(shadowRoot || document.body).appendChild(targetClone);
|
61
|
-
const flyoutBounds = targetClone.getBoundingClientRect();
|
62
|
-
const closestRenderContainer = !container && triggerEl ? findClosestRenderContainer({ el: triggerEl }) : undefined;
|
63
|
-
const containerParent = container ||
|
64
|
-
// Only render inside non-scrollable container to make sure it doesn't get clipped by overflow auto
|
65
|
-
// We render those cases in the document root and then sync the position on scroll instead
|
66
|
-
(!closestRenderContainer?.scrollable ? closestRenderContainer?.el : undefined) ||
|
67
|
-
document.body;
|
68
|
-
const containerBounds = containerParent.getBoundingClientRect();
|
69
|
-
const scopeOffset = {
|
70
|
-
top: containerBounds.top + document.documentElement.scrollTop - containerParent.scrollTop,
|
71
|
-
left: containerBounds.left + document.documentElement.scrollLeft - containerParent.scrollLeft,
|
72
|
-
};
|
73
|
-
let calculated = null;
|
74
|
-
const testOrder = getPositionFallbacks(position, fallbackPositions);
|
75
|
-
testOrder.some((currentPosition) => {
|
76
|
-
const tested = calculatePosition({
|
77
|
-
...options,
|
78
|
-
triggerBounds: resolvedTriggerBounds,
|
79
|
-
flyoutBounds,
|
80
|
-
scopeOffset,
|
81
|
-
position: currentPosition,
|
82
|
-
contentGap: contentGap * unitModifier,
|
83
|
-
contentShift: contentShift * unitModifier,
|
84
|
-
});
|
85
|
-
const visible = isFullyVisible({ ...tested, container });
|
86
|
-
const validPosition = visible || fallbackPositions?.length === 0;
|
87
|
-
// Saving first try in case non of the options work
|
88
|
-
if (validPosition || lastUsedFallback === currentPosition) {
|
89
|
-
calculated = tested;
|
90
|
-
onFallback(currentPosition);
|
91
|
-
}
|
92
|
-
return validPosition;
|
93
|
-
});
|
94
|
-
if (!calculated) {
|
95
|
-
throw new Error(`[Reshaped] Can't calculate styles for the ${position} position`);
|
96
|
-
}
|
97
|
-
targetClone.parentNode?.removeChild(targetClone);
|
98
|
-
return calculated;
|
99
|
-
};
|
100
|
-
const flyoutReducer = (state, action) => {
|
101
|
-
switch (action.type) {
|
102
|
-
case "render":
|
103
|
-
if (state.status !== "idle")
|
104
|
-
return state;
|
105
|
-
// Disable events before it's positioned to avoid mouseleave getting triggered
|
106
|
-
return { ...state, status: "rendered", styles: { pointerEvents: "none", ...resetStyles } };
|
107
|
-
case "position":
|
108
|
-
if (!action.payload.sync && state.status !== "rendered")
|
109
|
-
return state;
|
110
|
-
if (action.payload.sync && state.status !== "visible")
|
111
|
-
return state;
|
112
|
-
return {
|
113
|
-
...state,
|
114
|
-
status: action.payload.sync ? "visible" : "positioned",
|
115
|
-
position: action.payload.position,
|
116
|
-
styles: { ...defaultStyles, ...action.payload.styles },
|
117
|
-
};
|
118
|
-
case "show":
|
119
|
-
if (state.status !== "positioned")
|
120
|
-
return state;
|
121
|
-
return { ...state, status: "visible" };
|
122
|
-
case "hide":
|
123
|
-
if (state.status !== "visible")
|
124
|
-
return state;
|
125
|
-
return { ...state, status: "hidden" };
|
126
|
-
case "remove":
|
127
|
-
if (state.status !== "hidden" && state.status !== "visible")
|
128
|
-
return state;
|
129
|
-
return { ...state, status: "idle", styles: resetStyles };
|
130
|
-
default:
|
131
|
-
throw new Error("[Reshaped] Invalid flyout reducer type");
|
132
|
-
}
|
133
|
-
};
|
134
|
-
const useFlyout = (args) => {
|
135
|
-
const { triggerElRef, flyoutElRef, triggerBounds, contentGap, contentShift, ...options } = args;
|
136
|
-
const { position: defaultPosition = "bottom", fallbackPositions, width, container } = options;
|
137
|
-
const lastUsedFallbackRef = React.useRef(defaultPosition);
|
138
|
-
// Memo the array internally to avoid new arrays triggering useCallback
|
139
|
-
const cachedFallbackPositions = React.useMemo(() => fallbackPositions,
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
141
|
-
[fallbackPositions?.join(" ")]);
|
142
|
-
const [isRTL] = useRTL();
|
143
|
-
const [state, dispatch] = React.useReducer(flyoutReducer, {
|
144
|
-
position: defaultPosition,
|
145
|
-
styles: defaultStyles,
|
146
|
-
status: "idle",
|
147
|
-
});
|
148
|
-
const render = React.useCallback(() => {
|
149
|
-
dispatch({ type: "render" });
|
150
|
-
}, []);
|
151
|
-
const show = React.useCallback(() => {
|
152
|
-
dispatch({ type: "show" });
|
153
|
-
}, []);
|
154
|
-
const hide = React.useCallback(() => {
|
155
|
-
dispatch({ type: "hide" });
|
156
|
-
}, []);
|
157
|
-
const remove = React.useCallback(() => {
|
158
|
-
dispatch({ type: "remove" });
|
159
|
-
}, []);
|
160
|
-
const handleFallback = React.useCallback((position) => {
|
161
|
-
lastUsedFallbackRef.current = position;
|
162
|
-
}, []);
|
163
|
-
const updatePosition = React.useCallback((options) => {
|
164
|
-
if (!flyoutElRef.current)
|
165
|
-
return;
|
166
|
-
const nextFlyoutData = flyout({
|
167
|
-
triggerEl: triggerElRef.current,
|
168
|
-
flyoutEl: flyoutElRef.current,
|
169
|
-
triggerBounds,
|
170
|
-
width,
|
171
|
-
position: defaultPosition,
|
172
|
-
fallbackPositions: cachedFallbackPositions,
|
173
|
-
lastUsedFallback: lastUsedFallbackRef.current,
|
174
|
-
onFallback: handleFallback,
|
175
|
-
rtl: isRTL,
|
176
|
-
container,
|
177
|
-
contentGap,
|
178
|
-
contentShift,
|
179
|
-
});
|
180
|
-
if (nextFlyoutData) {
|
181
|
-
dispatch({ type: "position", payload: { ...nextFlyoutData, sync: options?.sync } });
|
182
|
-
}
|
183
|
-
}, [
|
184
|
-
container,
|
185
|
-
defaultPosition,
|
186
|
-
cachedFallbackPositions,
|
187
|
-
isRTL,
|
188
|
-
flyoutElRef,
|
189
|
-
triggerElRef,
|
190
|
-
triggerBounds,
|
191
|
-
width,
|
192
|
-
contentGap,
|
193
|
-
contentShift,
|
194
|
-
handleFallback,
|
195
|
-
]);
|
196
|
-
React.useEffect(() => {
|
197
|
-
if (state.status === "rendered")
|
198
|
-
updatePosition();
|
199
|
-
}, [state.status, updatePosition]);
|
200
|
-
return React.useMemo(() => ({
|
201
|
-
position: state.position,
|
202
|
-
styles: state.styles,
|
203
|
-
status: state.status,
|
204
|
-
updatePosition,
|
205
|
-
render,
|
206
|
-
hide,
|
207
|
-
remove,
|
208
|
-
show,
|
209
|
-
}), [render, updatePosition, hide, remove, show, state.position, state.styles, state.status]);
|
210
|
-
};
|
211
|
-
export default useFlyout;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type * as T from "../Flyout.types";
|
2
|
-
/**
|
3
|
-
* Calculate styles for the current position
|
4
|
-
*/
|
5
|
-
declare const calculatePosition: (args: T.Options & {
|
6
|
-
triggerBounds: DOMRect;
|
7
|
-
flyoutBounds: DOMRect;
|
8
|
-
scopeOffset: Record<"left" | "top", number>;
|
9
|
-
}) => {
|
10
|
-
styles: {
|
11
|
-
left: number;
|
12
|
-
top: number;
|
13
|
-
width: number;
|
14
|
-
height: number;
|
15
|
-
};
|
16
|
-
position: T.Position;
|
17
|
-
scopeOffset: Record<"left" | "top", number>;
|
18
|
-
};
|
19
|
-
export default calculatePosition;
|