reshaped 3.8.0-canary.3 → 3.8.0-canary.5
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/bundle.js +7 -7
- package/dist/components/Modal/tests/Modal.stories.js +5 -0
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/hooks/_private/useIsDismissible.d.ts +1 -0
- package/dist/hooks/_private/useIsDismissible.js +6 -6
- package/package.json +2 -2
@@ -166,6 +166,7 @@ export const containerRef = () => {
|
|
166
166
|
};
|
167
167
|
export const edgeCases = () => {
|
168
168
|
const menuModalToggle = useToggle();
|
169
|
+
const menuModalToggleInner = useToggle();
|
169
170
|
const scrollModalToggle = useToggle();
|
170
171
|
const inputRef = React.useRef(null);
|
171
172
|
return (<Example>
|
@@ -233,7 +234,11 @@ export const edgeCases = () => {
|
|
233
234
|
<DropdownMenu.Item>Item 2</DropdownMenu.Item>
|
234
235
|
</DropdownMenu.Content>
|
235
236
|
</DropdownMenu>
|
237
|
+
<Button onClick={menuModalToggleInner.activate}>Open dialog</Button>
|
236
238
|
<Button onClick={menuModalToggle.deactivate}>Close</Button>
|
239
|
+
<Modal active={menuModalToggleInner.active} onClose={menuModalToggleInner.deactivate}>
|
240
|
+
<Button onClick={menuModalToggleInner.deactivate}>Close</Button>
|
241
|
+
</Modal>
|
237
242
|
</View>
|
238
243
|
</Modal>
|
239
244
|
</Example.Item>
|
@@ -31,7 +31,7 @@ const Overlay = (props) => {
|
|
31
31
|
// Separating rendered and visible states to make sure animation is triggered only once overlay was added to the dom
|
32
32
|
const { active: rendered, activate: render, deactivate: remove } = useToggle(active || false);
|
33
33
|
const { active: visible, activate: show, deactivate: hide } = useToggle(active || false);
|
34
|
-
const isDismissible = useIsDismissible({ active, contentRef });
|
34
|
+
const isDismissible = useIsDismissible({ active, contentRef, hasTrigger: false });
|
35
35
|
const rootClassNames = classNames(s.root, visible && s["--visible"], isTransparent && s["--click-through"], blurred && s["--blurred"], animated && s["--animated"], containerRef && s["--contained"], overflow === "auto" && s["--overflow-auto"], className);
|
36
36
|
const isInsideContent = (el) => {
|
37
37
|
if (!contentRef.current)
|
@@ -4,7 +4,6 @@
|
|
4
4
|
*/
|
5
5
|
import React from "react";
|
6
6
|
import useElementId from "../useElementId.js";
|
7
|
-
import { onNextFrame } from "../../utilities/animation.js";
|
8
7
|
let queue = {};
|
9
8
|
let latestId = null;
|
10
9
|
const removeFromQueue = (id) => {
|
@@ -23,12 +22,12 @@ const addToQueue = (id, contentRef, triggerRef) => {
|
|
23
22
|
latestId = id;
|
24
23
|
};
|
25
24
|
const useIsDismissible = (args) => {
|
26
|
-
const { active, contentRef, triggerRef } = args;
|
25
|
+
const { active, contentRef, triggerRef, hasTrigger = true } = args;
|
27
26
|
const id = useElementId();
|
28
27
|
React.useEffect(() => {
|
29
28
|
if (!active)
|
30
29
|
return;
|
31
|
-
|
30
|
+
addToQueue(id, contentRef, triggerRef);
|
32
31
|
return () => removeFromQueue(id);
|
33
32
|
}, [active, id, contentRef, triggerRef]);
|
34
33
|
return React.useCallback(() => {
|
@@ -38,10 +37,11 @@ const useIsDismissible = (args) => {
|
|
38
37
|
const latestTrigger = latest?.triggerRef?.current;
|
39
38
|
const prev = latest?.parentId ? queue[latest.parentId] : undefined;
|
40
39
|
const prevContent = prev?.contentRef.current;
|
40
|
+
const nested = prevContent && latestTrigger && prevContent.contains(latestTrigger);
|
41
41
|
// Don't block independently rendered components that are not nested in each other
|
42
|
-
if (
|
42
|
+
if (hasTrigger && !nested)
|
43
43
|
return true;
|
44
|
-
return latestId === id;
|
45
|
-
}, [id, active]);
|
44
|
+
return !latestId || latestId === id;
|
45
|
+
}, [id, active, hasTrigger]);
|
46
46
|
};
|
47
47
|
export default useIsDismissible;
|
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.8.0-canary.
|
4
|
+
"version": "3.8.0-canary.5",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -89,7 +89,7 @@
|
|
89
89
|
"release:minor": "node bin/release.js minor",
|
90
90
|
"release:major": "node bin/release.js major",
|
91
91
|
"release:lib": "pnpm build && pnpm publish",
|
92
|
-
"release:canary": "pnpm build && yarn publish --tag canary && git push --tags",
|
92
|
+
"release:canary": "pnpm build && yarn publish --tag canary && git push --follow-tags",
|
93
93
|
"release:test": "pnpm build && pnpm pack --filename reshaped-test.tgz",
|
94
94
|
"release:copy": "sh ./bin/release-copy.sh",
|
95
95
|
"chromatic": "chromatic -b build:chromatic --project-token=$(cat .chromatic)",
|