reshaped 3.3.0 → 3.3.2
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 +2 -52
- package/dist/bundle.js +10 -10
- package/dist/components/_private/Flyout/Flyout.context.d.ts +4 -4
- package/dist/components/_private/Flyout/Flyout.context.js +2 -2
- package/dist/components/_private/Flyout/Flyout.types.d.ts +6 -1
- package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
- package/dist/components/_private/Flyout/FlyoutControlled.js +8 -4
- package/dist/components/_private/Flyout/FlyoutTrigger.js +1 -1
- package/dist/utilities/a11y/TrapFocus.js +2 -1
- package/dist/utilities/scroll/lock.js +2 -6
- package/package.json +1 -1
@@ -2,10 +2,10 @@ import React from "react";
|
|
2
2
|
import type * as T from "./Flyout.types";
|
3
3
|
declare const FlyoutContext: React.Context<T.ContextProps>;
|
4
4
|
declare const useFlyoutContext: () => T.ContextProps;
|
5
|
-
declare const useFlyoutTriggerContext: () => T.TriggerContextProps;
|
6
|
-
declare const useFlyoutContentContext: () =>
|
5
|
+
declare const useFlyoutTriggerContext: () => T.TriggerContextProps | null;
|
6
|
+
declare const useFlyoutContentContext: () => T.ContentContextProps | null;
|
7
7
|
declare const Provider: React.Provider<T.ContextProps>;
|
8
|
-
declare const TriggerProvider: React.Provider<T.TriggerContextProps>;
|
9
|
-
declare const ContentProvider: React.Provider<
|
8
|
+
declare const TriggerProvider: React.Provider<T.TriggerContextProps | null>;
|
9
|
+
declare const ContentProvider: React.Provider<T.ContentContextProps | null>;
|
10
10
|
export { Provider, TriggerProvider, ContentProvider, useFlyoutContext, useFlyoutTriggerContext, useFlyoutContentContext, };
|
11
11
|
export default FlyoutContext;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use client";
|
2
2
|
import React from "react";
|
3
3
|
const FlyoutContext = React.createContext({});
|
4
|
-
const FlyoutTriggerContext = React.createContext(
|
5
|
-
const FlyoutContentContext = React.createContext(
|
4
|
+
const FlyoutTriggerContext = React.createContext(null);
|
5
|
+
const FlyoutContentContext = React.createContext(null);
|
6
6
|
const useFlyoutContext = () => React.useContext(FlyoutContext);
|
7
7
|
const useFlyoutTriggerContext = () => React.useContext(FlyoutTriggerContext);
|
8
8
|
const useFlyoutContentContext = () => React.useContext(FlyoutContentContext);
|
@@ -134,5 +134,10 @@ export type ContextProps = {
|
|
134
134
|
handleContentMouseUp: () => void;
|
135
135
|
isSubmenu: boolean;
|
136
136
|
} & Pick<Props, "triggerType" | "contentClassName" | "contentAttributes" | "trapFocusMode" | "contentGap" | "contentShift" | "containerRef" | "disableContentHover">;
|
137
|
-
export type TriggerContextProps =
|
137
|
+
export type TriggerContextProps = {
|
138
|
+
elRef?: ContextProps["triggerElRef"];
|
139
|
+
};
|
140
|
+
export type ContentContextProps = {
|
141
|
+
elRef?: ContextProps["flyoutElRef"];
|
142
|
+
};
|
138
143
|
export {};
|
@@ -48,7 +48,7 @@ const FlyoutContent = (props) => {
|
|
48
48
|
else if (trapFocusMode === "action-menu") {
|
49
49
|
role = "menu";
|
50
50
|
}
|
51
|
-
const content = (_jsx(ContentProvider, { value:
|
51
|
+
const content = (_jsx(ContentProvider, { value: { elRef: flyoutElRef }, children: _jsx("div", { className: contentClassNames, style: {
|
52
52
|
...styles,
|
53
53
|
"--rs-flyout-gap": contentGap,
|
54
54
|
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...attributes, id: id, "aria-modal": triggerType === "click", style: contentAttributes?.style, className: innerClassNames, children: children }) }) }));
|
@@ -21,8 +21,8 @@ const FlyoutRoot = (props) => {
|
|
21
21
|
const onCloseRef = useHandlerRef(onClose);
|
22
22
|
const resolvedActive = disabled === true ? false : passedActive;
|
23
23
|
const parentFlyoutContext = useFlyoutContext();
|
24
|
-
const
|
25
|
-
const
|
24
|
+
const { elRef: parentTriggerRef } = useFlyoutTriggerContext() || {};
|
25
|
+
const { elRef: parentContentRef } = useFlyoutContentContext() || {};
|
26
26
|
const isSubmenu = parentFlyoutContext.trapFocusMode === "action-menu" ||
|
27
27
|
parentFlyoutContext.trapFocusMode === "content-menu";
|
28
28
|
const [isRTL] = useRTL();
|
@@ -30,9 +30,13 @@ const FlyoutRoot = (props) => {
|
|
30
30
|
/**
|
31
31
|
* Reuse the parent trigger ref in case we render nested triggers
|
32
32
|
* For example, when we apply tooltip and popover to the same button
|
33
|
+
*
|
34
|
+
* Resolving the same inside another Flyout.Content should reset the inheritance
|
35
|
+
* For example, if you have a tooltip -> popover inside another popover.content, tooltip shouldn't use its parent context anymore
|
33
36
|
*/
|
34
|
-
const
|
35
|
-
|
37
|
+
const isParentTriggerInsideFlyout = !!parentTriggerRef?.current && parentContentRef?.current?.contains(parentTriggerRef.current);
|
38
|
+
const tryParentTrigger = !parentContentRef || isParentTriggerInsideFlyout;
|
39
|
+
const triggerElRef = (tryParentTrigger && parentTriggerRef) || internalTriggerElRef;
|
36
40
|
const triggerBoundsRef = React.useRef();
|
37
41
|
const flyoutElRef = React.useRef(null);
|
38
42
|
const id = useElementId(passedId);
|
@@ -36,6 +36,6 @@ const FlyoutTrigger = (props) => {
|
|
36
36
|
childrenAttributes["aria-expanded"] = flyout.status !== "idle";
|
37
37
|
childrenAttributes["aria-controls"] = flyout.status !== "idle" ? id : undefined;
|
38
38
|
}
|
39
|
-
return (_jsx(TriggerProvider, { value: { triggerElRef }, children: children(childrenAttributes) }));
|
39
|
+
return (_jsx(TriggerProvider, { value: { elRef: triggerElRef }, children: children(childrenAttributes) }));
|
40
40
|
};
|
41
41
|
export default FlyoutTrigger;
|
@@ -21,7 +21,8 @@ class TrapFocus {
|
|
21
21
|
* Handle keyboard navigation while focus is trapped
|
22
22
|
*/
|
23
23
|
handleKeyDown = (event) => {
|
24
|
-
|
24
|
+
if (event.defaultPrevented)
|
25
|
+
return;
|
25
26
|
if (TrapFocus.chain.tailId !== this.chainId)
|
26
27
|
return;
|
27
28
|
const { mode, onNavigateOutside, pseudoFocus, includeTrigger } = this.options;
|
@@ -1,21 +1,17 @@
|
|
1
1
|
import { isIOS } from "../platform.js";
|
2
2
|
import lockSafariScroll from "./lockSafari.js";
|
3
3
|
import lockStandardScroll from "./lockStandard.js";
|
4
|
-
import { findClosestRenderContainer } from "../dom/index.js";
|
5
4
|
let lockedCount = 0;
|
6
5
|
let reset = () => { };
|
7
6
|
export const lockScroll = (args) => {
|
8
7
|
lockedCount += 1;
|
9
8
|
if (lockedCount > 1)
|
10
9
|
return;
|
11
|
-
const customLockTargetEl = args.containerEl
|
12
|
-
? findClosestRenderContainer({ el: args.containerEl, overflowOnly: true })
|
13
|
-
: undefined;
|
14
10
|
if (isIOS()) {
|
15
|
-
reset = lockSafariScroll(
|
11
|
+
reset = lockSafariScroll(args.containerEl);
|
16
12
|
}
|
17
13
|
else {
|
18
|
-
reset = lockStandardScroll(
|
14
|
+
reset = lockStandardScroll(args.containerEl);
|
19
15
|
}
|
20
16
|
args.cb?.();
|
21
17
|
};
|
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.3.
|
4
|
+
"version": "3.3.2",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|