reshaped 3.8.0-canary.4 → 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.
@@ -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)
@@ -8,5 +8,6 @@ declare const useIsDismissible: (args: {
8
8
  active?: boolean;
9
9
  contentRef: Ref;
10
10
  triggerRef?: Ref;
11
+ hasTrigger?: boolean;
11
12
  }) => () => boolean;
12
13
  export default useIsDismissible;
@@ -22,7 +22,7 @@ const addToQueue = (id, contentRef, triggerRef) => {
22
22
  latestId = id;
23
23
  };
24
24
  const useIsDismissible = (args) => {
25
- const { active, contentRef, triggerRef } = args;
25
+ const { active, contentRef, triggerRef, hasTrigger = true } = args;
26
26
  const id = useElementId();
27
27
  React.useEffect(() => {
28
28
  if (!active)
@@ -33,7 +33,15 @@ const useIsDismissible = (args) => {
33
33
  return React.useCallback(() => {
34
34
  if (!active)
35
35
  return true;
36
- return latestId === id;
37
- }, [id, active]);
36
+ const latest = latestId ? queue[latestId] : undefined;
37
+ const latestTrigger = latest?.triggerRef?.current;
38
+ const prev = latest?.parentId ? queue[latest.parentId] : undefined;
39
+ const prevContent = prev?.contentRef.current;
40
+ const nested = prevContent && latestTrigger && prevContent.contains(latestTrigger);
41
+ // Don't block independently rendered components that are not nested in each other
42
+ if (hasTrigger && !nested)
43
+ return true;
44
+ return !latestId || latestId === id;
45
+ }, [id, active, hasTrigger]);
38
46
  };
39
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",
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)",