reshaped 3.8.0-canary.8 → 3.8.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/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +2 -1
- package/dist/bundle.js +9 -9
- package/dist/components/Accordion/AccordionControlled.js +1 -0
- package/dist/components/Actionable/Actionable.js +1 -0
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/Badge.types.d.ts +2 -0
- package/dist/components/Badge/tests/Badge.stories.d.ts +4 -0
- package/dist/components/Badge/tests/Badge.stories.js +10 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -0
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Button/tests/Button.stories.js +1 -1
- package/dist/components/Calendar/CalendarMonth.js +1 -0
- package/dist/components/Carousel/Carousel.js +1 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +1 -1
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +21 -4
- package/dist/components/Flyout/FlyoutContent.js +3 -0
- package/dist/components/Flyout/FlyoutControlled.js +6 -1
- package/dist/components/Flyout/index.d.ts +1 -1
- package/dist/components/FormControl/FormControl.context.d.ts +1 -1
- package/dist/components/Hidden/Hidden.js +1 -2
- package/dist/components/Modal/tests/Modal.stories.d.ts +3 -7
- package/dist/components/Modal/tests/Modal.stories.js +5 -22
- package/dist/components/NumberField/NumberFieldControlled.js +22 -22
- package/dist/components/Overlay/Overlay.js +1 -0
- package/dist/components/Resizable/Resizable.js +3 -4
- package/dist/components/Select/Select.js +1 -0
- package/dist/components/Select/SelectCustomControlled.js +7 -3
- package/dist/components/Select/SelectOption.js +0 -2
- package/dist/components/Select/SelectOptionGroup.js +0 -2
- package/dist/components/Table/Table.js +5 -6
- package/dist/components/Tabs/Tabs.module.css +1 -1
- package/dist/components/Tabs/TabsControlled.js +1 -0
- package/dist/components/Tabs/TabsItem.js +1 -1
- package/dist/components/Tabs/TabsList.js +3 -20
- package/dist/components/Text/Text.module.css +1 -1
- package/dist/components/TextField/TextField.js +10 -2
- package/dist/components/TextField/TextField.module.css +1 -1
- package/dist/components/TextField/TextField.types.d.ts +5 -1
- package/dist/components/TextField/tests/TextField.stories.js +11 -5
- package/dist/components/Timeline/Timeline.js +3 -4
- package/dist/components/Toast/ToastContainer.js +1 -0
- package/dist/components/Toast/ToastRegion.js +1 -0
- package/dist/components/Toast/tests/Toast.stories.js +5 -3
- package/dist/components/ToggleButton/ToggleButton.types.d.ts +5 -1
- package/dist/components/ToggleButton/ToggleButtonControlled.js +9 -2
- package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +4 -0
- package/dist/components/ToggleButton/tests/ToggleButton.stories.js +10 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.types.d.ts +10 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +6 -41
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +1 -0
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +17 -0
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +2 -2
- package/dist/components/View/View.js +12 -7
- package/dist/components/View/View.types.d.ts +1 -1
- package/dist/components/_private/Expandable/Expandable.js +3 -1
- package/dist/components/_private/Portal/Portal.js +4 -1
- package/dist/hooks/_private/usePrevious.js +1 -0
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +15 -0
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +128 -0
- package/dist/hooks/useKeyboardArrowNavigation.d.ts +9 -0
- package/dist/hooks/useKeyboardArrowNavigation.js +62 -0
- package/dist/hooks/useOnClickOutside.js +0 -2
- package/dist/hooks/useScrollLock.js +5 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/styles/resolvers/align/align.css +1 -1
- package/dist/styles/resolvers/aspectRatio/aspectRatio.css +1 -1
- package/dist/styles/resolvers/bleed/bleed.module.css +1 -1
- package/dist/styles/resolvers/justify/justify.css +1 -1
- package/dist/styles/resolvers/maxHeight/maxHeight.module.css +1 -1
- package/dist/styles/resolvers/maxWidth/maxWidth.module.css +1 -1
- package/dist/styles/resolvers/minHeight/minHeight.module.css +1 -1
- package/dist/styles/resolvers/minWidth/minWidth.module.css +1 -1
- package/dist/styles/resolvers/position/position.css +1 -1
- package/dist/styles/resolvers/textAlign/textAlign.css +1 -1
- package/dist/styles/resolvers/width/width.module.css +1 -1
- package/dist/utilities/a11y/focus.d.ts +21 -4
- package/dist/utilities/a11y/focus.js +4 -3
- package/dist/utilities/props.d.ts +0 -3
- package/dist/utilities/props.js +0 -19
- package/dist/utilities/scroll/index.d.ts +1 -1
- package/dist/utilities/scroll/index.js +1 -1
- package/dist/utilities/scroll/lock.d.ts +1 -2
- package/dist/utilities/scroll/lock.js +14 -15
- package/package.json +195 -201
- package/CHANGELOG-extra.md +0 -3
- package/CHANGELOG.md +0 -114
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +0 -21
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +0 -11
- package/dist/components/Link/tests/Link.test.stories.d.ts +0 -17
- package/dist/components/Link/tests/Link.test.stories.js +0 -11
- package/dist/components/Loader/tests/Loader.test.stories.d.ts +0 -13
- package/dist/components/Loader/tests/Loader.test.stories.js +0 -11
- package/dist/components/Table/tests/Table.test.stories.d.ts +0 -19
- package/dist/components/Table/tests/Table.test.stories.js +0 -11
- package/dist/components/TextField/tests/TextField.test.stories.d.ts +0 -15
- package/dist/components/TextField/tests/TextField.test.stories.js +0 -11
- package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +0 -15
- package/dist/components/Timeline/tests/Timeline.test.stories.js +0 -11
- package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +0 -13
- package/dist/components/Tooltip/tests/Tooltip.test.stories.js +0 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { FlyoutProps,
|
|
2
|
+
import type { FlyoutProps, FlyoutTriggerAttributes } from "../Flyout";
|
|
3
3
|
export type Props = Pick<FlyoutProps, "id" | "position" | "onOpen" | "onClose" | "active" | "disabled" | "disableContentHover" | "containerRef" | "contentGap" | "contentShift" | "originCoordinates" | "contentAttributes" | "contentClassName"> & {
|
|
4
4
|
/** Node for inserting children */
|
|
5
|
-
children: (attributes:
|
|
5
|
+
children: (attributes: FlyoutTriggerAttributes) => React.ReactNode;
|
|
6
6
|
/** Text content for the tooltip */
|
|
7
7
|
text?: React.ReactNode;
|
|
8
8
|
/** Color of the tooltip
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElement as _createElement } from "react";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { classNames,
|
|
3
|
+
import React, { isValidElement } from "react";
|
|
4
|
+
import { classNames, responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
|
|
5
5
|
import Divider from "../Divider/index.js";
|
|
6
6
|
import Hidden from "../Hidden/index.js";
|
|
7
7
|
import s from "./View.module.css";
|
|
@@ -100,13 +100,15 @@ const View = (props) => {
|
|
|
100
100
|
return (_jsx("div", { className: dividerClassName, children: _jsx(Divider, { vertical: isDividerVertical, blank: true }) }, `${key}-divider`));
|
|
101
101
|
};
|
|
102
102
|
const renderItem = ({ className, child, index }) => {
|
|
103
|
-
const
|
|
104
|
-
const
|
|
103
|
+
const isElement = isValidElement(child);
|
|
104
|
+
const isItem = isElement && child.type === ViewItem;
|
|
105
|
+
const isView = isElement && child.type === View;
|
|
105
106
|
const key = child.key;
|
|
106
107
|
const dividerElement = !!index && divided && renderDivider({ className, key });
|
|
107
108
|
let itemElement;
|
|
108
109
|
if (isItem) {
|
|
109
110
|
itemElement = React.cloneElement(child, {
|
|
111
|
+
// @ts-expect-error -- child is guaranteed to be an element
|
|
110
112
|
className: classNames(className, child.props.className),
|
|
111
113
|
});
|
|
112
114
|
}
|
|
@@ -120,10 +122,13 @@ const View = (props) => {
|
|
|
120
122
|
itemElement = (_jsx("div", { className: className, children: child }, key));
|
|
121
123
|
}
|
|
122
124
|
// Passing grow here because it's responsive and nowrap should follow it
|
|
125
|
+
// @ts-expect-error -- child is guaranteed to be an element
|
|
123
126
|
if ((isItem || isView) && child.props?.grow) {
|
|
127
|
+
// @ts-expect-error -- child is guaranteed to be an element
|
|
124
128
|
nowrap = child.props.grow;
|
|
125
129
|
isFlex = true;
|
|
126
130
|
}
|
|
131
|
+
// @ts-expect-error -- child is guaranteed to be an element
|
|
127
132
|
if (isItem && child.props?.gap === "auto")
|
|
128
133
|
nowrap = true;
|
|
129
134
|
return (_jsxs(React.Fragment, { children: [dividerElement, itemElement] }, key ? `${key}-fragment` : undefined));
|
|
@@ -134,8 +139,10 @@ const View = (props) => {
|
|
|
134
139
|
if (!child)
|
|
135
140
|
return null;
|
|
136
141
|
const usedIndex = renderedItemIndex;
|
|
142
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
137
143
|
renderedItemIndex += 1;
|
|
138
|
-
if (
|
|
144
|
+
if (isValidElement(child) && child.type === Hidden) {
|
|
145
|
+
// @ts-expect-error -- child is guaranteed to be an element
|
|
139
146
|
const { children: hiddenChild, ...hiddenProps } = child.props;
|
|
140
147
|
const key = child.key || index;
|
|
141
148
|
return (_createElement(Hidden, { ...hiddenProps, key: key }, renderItem({ child: hiddenChild, index: usedIndex })));
|
|
@@ -167,8 +174,6 @@ const View = (props) => {
|
|
|
167
174
|
return (_jsx(TagName, { ...attributes, className: rootClassNames, style: rootVariables, children: formattedChildren }));
|
|
168
175
|
};
|
|
169
176
|
View.Item = ViewItem;
|
|
170
|
-
setComponentChildId(View.Item, "View.Item");
|
|
171
|
-
setComponentChildId(View, "View");
|
|
172
177
|
View.displayName = "View";
|
|
173
178
|
ViewItem.displayName = "View.Item";
|
|
174
179
|
export default View;
|
|
@@ -87,7 +87,7 @@ export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
|
|
|
87
87
|
/** z-index style */
|
|
88
88
|
zIndex?: number;
|
|
89
89
|
/** Shadow style, based on the shadow tokens */
|
|
90
|
-
shadow?: "raised" | "overlay"
|
|
90
|
+
shadow?: "raised" | "overlay";
|
|
91
91
|
/** Overflow style */
|
|
92
92
|
overflow?: "hidden" | "auto";
|
|
93
93
|
/** Add transition for the properties */
|
|
@@ -10,7 +10,9 @@ const Expandable = (props) => {
|
|
|
10
10
|
const rootRef = React.useRef(null);
|
|
11
11
|
const mountedRef = React.useRef(false);
|
|
12
12
|
const [animatedHeight, setAnimatedHeight] = React.useState(active ? "auto" : null);
|
|
13
|
-
const contentClassNames = classNames(s.root,
|
|
13
|
+
const contentClassNames = classNames(s.root,
|
|
14
|
+
// eslint-disable-next-line react-hooks/refs
|
|
15
|
+
mountedRef.current && animatedHeight !== "auto" && s["--animated"]);
|
|
14
16
|
const handleTransitionEnd = (e) => {
|
|
15
17
|
if (e.propertyName !== "height")
|
|
16
18
|
return;
|
|
@@ -18,18 +18,20 @@ const Portal = (props) => {
|
|
|
18
18
|
const { children, targetRef } = props;
|
|
19
19
|
const mountedToggle = useToggle();
|
|
20
20
|
const rootRef = React.useRef(null);
|
|
21
|
+
// eslint-disable-next-line react-hooks/refs
|
|
21
22
|
const rootNode = rootRef.current?.getRootNode();
|
|
22
23
|
const isShadowDom = rootNode instanceof ShadowRoot;
|
|
23
24
|
const defaultTargetEl = isShadowDom ? rootNode : document.body;
|
|
24
25
|
/**
|
|
25
26
|
* Check for parent portal to render inside it
|
|
26
|
-
* To avoid z-
|
|
27
|
+
* To avoid z-index issues
|
|
27
28
|
* Example:
|
|
28
29
|
* Dropdown rendered on the page should render under the modal
|
|
29
30
|
* Dropdown inside the modal should render above it
|
|
30
31
|
*/
|
|
31
32
|
const portal = usePortalScope();
|
|
32
33
|
const nextScopeRef = targetRef || portal.scopeRef;
|
|
34
|
+
// eslint-disable-next-line react-hooks/refs
|
|
33
35
|
const targetEl = nextScopeRef?.current || defaultTargetEl;
|
|
34
36
|
useIsomorphicLayoutEffect(() => {
|
|
35
37
|
mountedToggle.activate();
|
|
@@ -37,6 +39,7 @@ const Portal = (props) => {
|
|
|
37
39
|
}, []);
|
|
38
40
|
/* Preserve the current theme when rendered in body */
|
|
39
41
|
return [
|
|
42
|
+
// eslint-disable-next-line react-hooks/refs
|
|
40
43
|
ReactDOM.createPortal(_jsx(Theme, { children: children }), targetEl),
|
|
41
44
|
// Make sure this element doesn't affect components using :last-child when their children use portals
|
|
42
45
|
!mountedToggle.active && _jsx("div", { ref: rootRef, className: s.root }, "root"),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
parameters: {
|
|
5
|
+
chromatic: {
|
|
6
|
+
disableSnapshot: boolean;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
11
|
+
export declare const base: StoryObj;
|
|
12
|
+
export declare const horizontal: StoryObj;
|
|
13
|
+
export declare const vertical: StoryObj;
|
|
14
|
+
export declare const circular: StoryObj;
|
|
15
|
+
export declare const disabled: StoryObj;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import { expect, userEvent } from "storybook/test";
|
|
3
|
+
import View from "../../components/View/index.js";
|
|
4
|
+
import Button from "../../components/Button/index.js";
|
|
5
|
+
import useKeyboardArrowNavigation from "../useKeyboardArrowNavigation.js";
|
|
6
|
+
export default {
|
|
7
|
+
title: "Hooks/useKeyboardArrowNavigation",
|
|
8
|
+
parameters: {
|
|
9
|
+
chromatic: { disableSnapshot: true },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export const base = {
|
|
13
|
+
name: "base",
|
|
14
|
+
render: () => {
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
useKeyboardArrowNavigation({ ref });
|
|
17
|
+
return (<View gap={2} direction="row" attributes={{ ref }}>
|
|
18
|
+
<Button onClick={() => { }}>Action 1</Button>
|
|
19
|
+
<Button onClick={() => { }}>Action 2</Button>
|
|
20
|
+
<Button onClick={() => { }}>Action 3</Button>
|
|
21
|
+
</View>);
|
|
22
|
+
},
|
|
23
|
+
play: async ({ canvas }) => {
|
|
24
|
+
const buttons = canvas.getAllByRole("button");
|
|
25
|
+
buttons[0].focus();
|
|
26
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
27
|
+
expect(document.activeElement).toBe(buttons[1]);
|
|
28
|
+
await userEvent.keyboard("{ArrowDown/}");
|
|
29
|
+
expect(document.activeElement).toBe(buttons[2]);
|
|
30
|
+
await userEvent.keyboard("{ArrowUp/}");
|
|
31
|
+
expect(document.activeElement).toBe(buttons[1]);
|
|
32
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
|
33
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export const horizontal = {
|
|
37
|
+
name: "orientation: horizontal",
|
|
38
|
+
render: () => {
|
|
39
|
+
const ref = useRef(null);
|
|
40
|
+
useKeyboardArrowNavigation({ ref, orientation: "horizontal" });
|
|
41
|
+
return (<View gap={2} direction="row" attributes={{ ref }}>
|
|
42
|
+
<Button onClick={() => { }}>Action 1</Button>
|
|
43
|
+
<Button onClick={() => { }}>Action 2</Button>
|
|
44
|
+
<Button onClick={() => { }}>Action 3</Button>
|
|
45
|
+
</View>);
|
|
46
|
+
},
|
|
47
|
+
play: async ({ canvas }) => {
|
|
48
|
+
const buttons = canvas.getAllByRole("button");
|
|
49
|
+
expect(buttons[0]).toHaveAttribute("tabindex", "0");
|
|
50
|
+
expect(buttons[1]).toHaveAttribute("tabindex", "-1");
|
|
51
|
+
expect(buttons[2]).toHaveAttribute("tabindex", "-1");
|
|
52
|
+
buttons[0].focus();
|
|
53
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
54
|
+
expect(document.activeElement).toBe(buttons[1]);
|
|
55
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
|
56
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
57
|
+
await userEvent.keyboard("{ArrowDown/}");
|
|
58
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
59
|
+
await userEvent.keyboard("{ArrowUp/}");
|
|
60
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const vertical = {
|
|
64
|
+
name: "orientation: vertical",
|
|
65
|
+
render: () => {
|
|
66
|
+
const ref = useRef(null);
|
|
67
|
+
useKeyboardArrowNavigation({ ref, orientation: "vertical" });
|
|
68
|
+
return (<View gap={2} direction="column" attributes={{ ref }}>
|
|
69
|
+
<Button onClick={() => { }}>Action 1</Button>
|
|
70
|
+
<Button onClick={() => { }}>Action 2</Button>
|
|
71
|
+
<Button onClick={() => { }}>Action 3</Button>
|
|
72
|
+
</View>);
|
|
73
|
+
},
|
|
74
|
+
play: async ({ canvas }) => {
|
|
75
|
+
const buttons = canvas.getAllByRole("button");
|
|
76
|
+
buttons[0].focus();
|
|
77
|
+
await userEvent.keyboard("{ArrowDown/}");
|
|
78
|
+
expect(document.activeElement).toBe(buttons[1]);
|
|
79
|
+
await userEvent.keyboard("{ArrowUp/}");
|
|
80
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
81
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
82
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
83
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
|
84
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
export const circular = {
|
|
88
|
+
name: "circular",
|
|
89
|
+
render: () => {
|
|
90
|
+
const ref = useRef(null);
|
|
91
|
+
useKeyboardArrowNavigation({ ref, circular: true });
|
|
92
|
+
return (<View gap={2} direction="row" attributes={{ ref }}>
|
|
93
|
+
<Button onClick={() => { }}>Action 1</Button>
|
|
94
|
+
<Button onClick={() => { }}>Action 2</Button>
|
|
95
|
+
<Button onClick={() => { }}>Action 3</Button>
|
|
96
|
+
</View>);
|
|
97
|
+
},
|
|
98
|
+
play: async ({ canvas }) => {
|
|
99
|
+
const buttons = canvas.getAllByRole("button");
|
|
100
|
+
buttons[0].focus();
|
|
101
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
102
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
103
|
+
expect(document.activeElement).toBe(buttons[2]);
|
|
104
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
105
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
106
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
|
107
|
+
expect(document.activeElement).toBe(buttons[2]);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
export const disabled = {
|
|
111
|
+
name: "disabled",
|
|
112
|
+
render: () => {
|
|
113
|
+
const ref = useRef(null);
|
|
114
|
+
useKeyboardArrowNavigation({ ref, disabled: true });
|
|
115
|
+
return (<View gap={2} direction="row" attributes={{ ref }}>
|
|
116
|
+
<Button onClick={() => { }}>Action 1</Button>
|
|
117
|
+
<Button onClick={() => { }}>Action 2</Button>
|
|
118
|
+
<Button onClick={() => { }}>Action 3</Button>
|
|
119
|
+
</View>);
|
|
120
|
+
},
|
|
121
|
+
play: async ({ canvas }) => {
|
|
122
|
+
const buttons = canvas.getAllByRole("button");
|
|
123
|
+
buttons[0].focus();
|
|
124
|
+
await userEvent.keyboard("{ArrowRight/}");
|
|
125
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
126
|
+
expect(buttons[0]).not.toHaveAttribute("tabindex");
|
|
127
|
+
},
|
|
128
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
ref: React.RefObject<HTMLElement | null>;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
orientation?: "vertical" | "horizontal";
|
|
6
|
+
circular?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const useKeyboardArrowNavigation: (props: Props) => void;
|
|
9
|
+
export default useKeyboardArrowNavigation;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { focusFirstElement, focusLastElement, focusNextElement, focusPreviousElement, getFocusableElements, } from "../utilities/a11y/index.js";
|
|
3
|
+
import useHotkeys from "./useHotkeys.js";
|
|
4
|
+
const useKeyboardArrowNavigation = (props) => {
|
|
5
|
+
const { ref, disabled, orientation, circular } = props;
|
|
6
|
+
const backHotkeys = [];
|
|
7
|
+
const forwardHotkeys = [];
|
|
8
|
+
if (!orientation || orientation === "vertical") {
|
|
9
|
+
backHotkeys.push("ArrowUp");
|
|
10
|
+
forwardHotkeys.push("ArrowDown");
|
|
11
|
+
}
|
|
12
|
+
if (!orientation || orientation === "horizontal") {
|
|
13
|
+
backHotkeys.push("ArrowLeft");
|
|
14
|
+
forwardHotkeys.push("ArrowRight");
|
|
15
|
+
}
|
|
16
|
+
const updateTabIndex = React.useCallback((options) => {
|
|
17
|
+
const { el, focusableElements } = options;
|
|
18
|
+
const initialEl = focusableElements.find((el) => el.getAttribute("tabindex") !== "-1");
|
|
19
|
+
const activeEl = el ?? initialEl ?? focusableElements[0];
|
|
20
|
+
focusableElements.forEach((el) => el.setAttribute("tabindex", "-1"));
|
|
21
|
+
activeEl?.setAttribute("tabindex", "0");
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!ref.current)
|
|
25
|
+
return;
|
|
26
|
+
if (disabled)
|
|
27
|
+
return;
|
|
28
|
+
const focusableElements = getFocusableElements(ref.current);
|
|
29
|
+
updateTabIndex({ focusableElements });
|
|
30
|
+
}, [ref, updateTabIndex, disabled]);
|
|
31
|
+
useHotkeys({
|
|
32
|
+
[backHotkeys.join(", ")]: () => {
|
|
33
|
+
if (!ref.current)
|
|
34
|
+
return;
|
|
35
|
+
const data = focusPreviousElement(ref.current, { circular });
|
|
36
|
+
updateTabIndex(data);
|
|
37
|
+
},
|
|
38
|
+
[forwardHotkeys.join(", ")]: () => {
|
|
39
|
+
if (!ref.current)
|
|
40
|
+
return;
|
|
41
|
+
const data = focusNextElement(ref.current, { circular });
|
|
42
|
+
updateTabIndex(data);
|
|
43
|
+
},
|
|
44
|
+
Home: () => {
|
|
45
|
+
if (!ref.current)
|
|
46
|
+
return;
|
|
47
|
+
const data = focusFirstElement(ref.current);
|
|
48
|
+
updateTabIndex(data);
|
|
49
|
+
},
|
|
50
|
+
End: () => {
|
|
51
|
+
if (!ref.current)
|
|
52
|
+
return;
|
|
53
|
+
const data = focusLastElement(ref.current);
|
|
54
|
+
updateTabIndex(data);
|
|
55
|
+
},
|
|
56
|
+
}, [updateTabIndex, circular], {
|
|
57
|
+
ref,
|
|
58
|
+
preventDefault: true,
|
|
59
|
+
disabled,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export default useKeyboardArrowNavigation;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { lockScroll
|
|
3
|
+
import { lockScroll } from "../utilities/scroll/index.js";
|
|
4
4
|
const useScrollLock = (options) => {
|
|
5
5
|
const { containerRef, originRef } = options || {};
|
|
6
6
|
const [locked, setLocked] = React.useState(false);
|
|
7
|
+
const unlockScrollRef = React.useRef(null);
|
|
7
8
|
const handleLockScroll = React.useCallback(() => {
|
|
8
|
-
lockScroll({
|
|
9
|
+
unlockScrollRef.current = lockScroll({
|
|
9
10
|
containerEl: containerRef?.current,
|
|
10
11
|
originEl: originRef?.current,
|
|
11
12
|
cb: () => setLocked(true),
|
|
12
13
|
});
|
|
13
14
|
}, [containerRef, originRef]);
|
|
14
15
|
const handleUnlockScroll = React.useCallback(() => {
|
|
15
|
-
|
|
16
|
+
unlockScrollRef.current?.(() => setLocked(false));
|
|
17
|
+
unlockScrollRef.current = null;
|
|
16
18
|
}, []);
|
|
17
19
|
return React.useMemo(() => ({
|
|
18
20
|
scrollLocked: locked,
|
package/dist/index.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export type { ContainerProps } from "./components/Container";
|
|
|
103
103
|
export { default as Dismissible } from "./components/Dismissible";
|
|
104
104
|
export type { DismissibleProps } from "./components/Dismissible";
|
|
105
105
|
export { default as Flyout } from "./components/Flyout";
|
|
106
|
-
export type { FlyoutProps, FlyoutInstance } from "./components/Flyout";
|
|
106
|
+
export type { FlyoutProps, FlyoutInstance, FlyoutTriggerAttributes } from "./components/Flyout";
|
|
107
107
|
export { default as FormControl } from "./components/FormControl";
|
|
108
108
|
export type { FormControlProps } from "./components/FormControl";
|
|
109
109
|
export { default as Grid } from "./components/Grid";
|
|
@@ -135,6 +135,7 @@ export { default as useHandlerRef } from "./hooks/useHandlerRef";
|
|
|
135
135
|
export { default as useHotkeys } from "./hooks/useHotkeys";
|
|
136
136
|
export { default as useIsomorphicLayoutEffect } from "./hooks/useIsomorphicLayoutEffect";
|
|
137
137
|
export { default as useKeyboardMode } from "./hooks/useKeyboardMode";
|
|
138
|
+
export { default as useKeyboardArrowNavigation } from "./hooks/useKeyboardArrowNavigation";
|
|
138
139
|
export { default as useOnClickOutside } from "./hooks/useOnClickOutside";
|
|
139
140
|
export { default as useResponsiveClientValue } from "./hooks/useResponsiveClientValue";
|
|
140
141
|
export { default as useRTL } from "./hooks/useRTL";
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,7 @@ export { default as useHandlerRef } from "./hooks/useHandlerRef.js";
|
|
|
74
74
|
export { default as useHotkeys } from "./hooks/useHotkeys.js";
|
|
75
75
|
export { default as useIsomorphicLayoutEffect } from "./hooks/useIsomorphicLayoutEffect.js";
|
|
76
76
|
export { default as useKeyboardMode } from "./hooks/useKeyboardMode.js";
|
|
77
|
+
export { default as useKeyboardArrowNavigation } from "./hooks/useKeyboardArrowNavigation.js";
|
|
77
78
|
export { default as useOnClickOutside } from "./hooks/useOnClickOutside.js";
|
|
78
79
|
export { default as useResponsiveClientValue } from "./hooks/useResponsiveClientValue.js";
|
|
79
80
|
export { default as useRTL } from "./hooks/useRTL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[style*="--rs-align-
|
|
1
|
+
[style*="--rs-align-"]{align-items:var(--rs-align)!important;--rs-align-s: ;--rs-align-m:var(--rs-align-s);--rs-align-l:var(--rs-align-m);--rs-align-xl:var(--rs-align-l);--rs-align:var(--rs-align-s)}@media (--rs-viewport-m ){[style*="--rs-align-"]{--rs-align:var(--rs-align-m)}}@media (--rs-viewport-l ){[style*="--rs-align-"]{--rs-align:var(--rs-align-l)}}@media (--rs-viewport-xl ){[style*="--rs-align-"]{--rs-align:var(--rs-align-xl)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[style*="--rs-ratio-
|
|
1
|
+
[style*="--rs-ratio-"]{--rs-ratio-s:0;--rs-ratio-m:var(--rs-ratio-s);--rs-ratio-l:var(--rs-ratio-m);--rs-ratio-xl:var(--rs-ratio-l);--rs-ratio:var(--rs-ratio-s)}[style*="--rs-ratio-s:"]:empty,[style*="--rs-ratio-s:"]:not(:empty)>*{aspect-ratio:var(--rs-ratio)}[style*="--rs-ratio-s:"]>img{object-fit:cover}@media (--rs-viewport-m ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-m)}}@media (--rs-viewport-l ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-l)}}@media (--rs-viewport-xl ){[style*="--rs-ratio-"]{--rs-ratio:var(--rs-ratio-xl)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-bleed-
|
|
1
|
+
.root[style*="--rs-bleed-"]{margin-left:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);margin-right:calc(var(--rs-unit-x1) * var(--rs-bleed) * -1);--rs-bleed-s:0;--rs-bleed-m:var(--rs-bleed-s);--rs-bleed-l:var(--rs-bleed-m);--rs-bleed-xl:var(--rs-bleed-l);--rs-bleed:var(--rs-bleed-s)}.--bleed{border-left-style:none!important;border-radius:0!important;border-right-style:none!important}@media (--rs-viewport-m ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-m)}.--bleed-true--m{border-left-style:none!important;border-radius:0!important;border-right-style:none!important}.--bleed-false--m{border-left-style:solid!important;border-radius:var(--rs-radius)!important;border-right-style:solid!important}}@media (--rs-viewport-l ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-l)}.--bleed-true--l{border-left-style:none!important;border-radius:0!important;border-right-style:none!important}.--bleed-false--l{border-left-style:solid!important;border-radius:var(--rs-radius)!important;border-right-style:solid!important}}@media (--rs-viewport-xl ){.root[style*="--rs-bleed-"]{--rs-bleed:var(--rs-bleed-xl)}.--bleed-true--xl{border-left-style:none!important;border-radius:0!important;border-right-style:none!important}.--bleed-false--xl{border-left-style:solid!important;border-radius:var(--rs-radius)!important;border-right-style:solid!important}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[style*="--rs-justify-
|
|
1
|
+
[style*="--rs-justify-"]{justify-content:var(--rs-justify)!important;--rs-justify-s: ;--rs-justify-m:var(--rs-justify-s);--rs-justify-l:var(--rs-justify-m);--rs-justify-xl:var(--rs-justify-l);--rs-justify:var(--rs-justify-s)}@media (--rs-viewport-m ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-m)}}@media (--rs-viewport-l ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-l)}}@media (--rs-viewport-xl ){[style*="--rs-justify-"]{--rs-justify:var(--rs-justify-xl)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-max-h-
|
|
1
|
+
.root[style*="--rs-max-h-"]{--rs-max-h-s:none;--rs-max-h-m:var(--rs-max-h-s);--rs-max-h-l:var(--rs-max-h-m);--rs-max-h-xl:var(--rs-max-h-l);--rs-max-h:var(--rs-max-h-s)}.--type-literal{max-height:var(--rs-max-h)!important}.--type-unit{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-m)}.--type-literal--m{max-height:var(--rs-max-h)!important}.--type-unit--m{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-l)}.--type-literal--l{max-height:var(--rs-max-h)!important}.--type-unit--l{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-max-h-"]{--rs-max-h:var(--rs-max-h-xl)}.--type-literal--xl{max-height:var(--rs-max-h)!important}.--type-unit--xl{max-height:calc(var(--rs-max-h) * var(--rs-unit-x1))!important}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-max-w-
|
|
1
|
+
.root[style*="--rs-max-w-"]{--rs-max-w-s:none;--rs-max-w-m:var(--rs-max-w-s);--rs-max-w-l:var(--rs-max-w-m);--rs-max-w-xl:var(--rs-max-w-l);--rs-max-w:var(--rs-max-w-s)}.--type-literal{max-width:var(--rs-max-w)!important}.--type-unit{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-m)}.--type-literal--m{max-width:var(--rs-max-w)!important}.--type-unit--m{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-l)}.--type-literal--l{max-width:var(--rs-max-w)!important}.--type-unit--l{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-max-w-"]{--rs-max-w:var(--rs-max-w-xl)}.--type-literal--xl{max-width:var(--rs-max-w)!important}.--type-unit--xl{max-width:calc(var(--rs-max-w) * var(--rs-unit-x1))!important}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-min-h-
|
|
1
|
+
.root[style*="--rs-min-h-"]{--rs-min-h-s:none;--rs-min-h-m:var(--rs-min-h-s);--rs-min-h-l:var(--rs-min-h-m);--rs-min-h-xl:var(--rs-min-h-l);--rs-min-h:var(--rs-min-h-s)}.--type-literal{min-height:var(--rs-min-h)!important}.--type-unit{min-height:calc(var(--rs-min-h) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-min-h-"]{--rs-min-h:var(--rs-min-h-m)}.--type-literal--m{min-height:var(--rs-min-h)!important}.--type-unit--m{min-height:calc(var(--rs-min-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-min-h-"]{--rs-min-h:var(--rs-min-h-l)}.--type-literal--l{min-height:var(--rs-min-h)!important}.--type-unit--l{min-height:calc(var(--rs-min-h) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-min-h-"]{--rs-min-h:var(--rs-min-h-xl)}.--type-literal--xl{min-height:var(--rs-min-h)!important}.--type-unit--xl{min-height:calc(var(--rs-min-h) * var(--rs-unit-x1))!important}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-min-w-
|
|
1
|
+
.root[style*="--rs-min-w-"]{--rs-min-w-s:none;--rs-min-w-m:var(--rs-min-w-s);--rs-min-w-l:var(--rs-min-w-m);--rs-min-w-xl:var(--rs-min-w-l);--rs-min-w:var(--rs-min-w-s)}.--type-literal{min-width:var(--rs-min-w)!important}.--type-unit{min-width:calc(var(--rs-min-w) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-min-w-"]{--rs-min-w:var(--rs-min-w-m)}.--type-literal--m{min-width:var(--rs-min-w)!important}.--type-unit--m{min-width:calc(var(--rs-min-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-min-w-"]{--rs-min-w:var(--rs-min-w-l)}.--type-literal--l{min-width:var(--rs-min-w)!important}.--type-unit--l{min-width:calc(var(--rs-min-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-min-w-"]{--rs-min-w:var(--rs-min-w-xl)}.--type-literal--xl{min-width:var(--rs-min-w)!important}.--type-unit--xl{min-width:calc(var(--rs-min-w) * var(--rs-unit-x1))!important}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[style*="--rs-position-
|
|
1
|
+
[style*="--rs-position-"]{position:var(--rs-position)!important;--rs-position-s: ;--rs-position-m:var(--rs-position-s);--rs-position-l:var(--rs-position-m);--rs-position-xl:var(--rs-position-l);--rs-position:var(--rs-position-s)}@media (--rs-viewport-m ){[style*="--rs-position-"]{--rs-position:var(--rs-position-m)}}@media (--rs-viewport-l ){[style*="--rs-position-"]{--rs-position:var(--rs-position-l)}}@media (--rs-viewport-xl ){[style*="--rs-position-"]{--rs-position:var(--rs-position-xl)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[style*="--rs-text-align-
|
|
1
|
+
[style*="--rs-text-align-"]{text-align:var(--rs-text-align)!important;--rs-text-align-s: ;--rs-text-align-m:var(--rs-text-align-s);--rs-text-align-l:var(--rs-text-align-m);--rs-text-align-xl:var(--rs-text-align-l);--rs-text-align:var(--rs-text-align-s)}@media (--rs-viewport-m ){[style*="--rs-text-align-"]{--rs-text-align:var(--rs-text-align-m)}}@media (--rs-viewport-l ){[style*="--rs-text-align-"]{--rs-text-align:var(--rs-text-align-l)}}@media (--rs-viewport-xl ){[style*="--rs-text-align-"]{--rs-text-align:var(--rs-text-align-xl)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.root[style*="--rs-w-
|
|
1
|
+
.root[style*="--rs-w-"]{--rs-w-s:auto;--rs-w-m:var(--rs-w-s);--rs-w-l:var(--rs-w-m);--rs-w-xl:var(--rs-w-l);--rs-w:var(--rs-w-s)}.--type-literal{width:var(--rs-w)!important}.--type-unit{width:calc(var(--rs-w) * var(--rs-unit-x1))!important}@media (--rs-viewport-m ){.root[style*="--rs-w-"]{--rs-w:var(--rs-w-m)}.--type-literal--m{width:var(--rs-w)!important}.--type-unit--m{width:calc(var(--rs-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-l ){.root[style*="--rs-w-"]{--rs-w:var(--rs-w-l)}.--type-literal--l{width:var(--rs-w)!important}.--type-unit--l{width:calc(var(--rs-w) * var(--rs-unit-x1))!important}}@media (--rs-viewport-xl ){.root[style*="--rs-w-"]{--rs-w:var(--rs-w-xl)}.--type-literal--xl{width:var(--rs-w)!important}.--type-unit--xl{width:calc(var(--rs-w) * var(--rs-unit-x1))!important}}
|
|
@@ -14,8 +14,25 @@ export declare const getFocusData: (args: {
|
|
|
14
14
|
}) => {
|
|
15
15
|
overflow: boolean;
|
|
16
16
|
el: FocusableElement;
|
|
17
|
+
focusableElements: FocusableElement[];
|
|
18
|
+
};
|
|
19
|
+
export declare const focusNextElement: (root: HTMLElement, options?: {
|
|
20
|
+
circular?: boolean;
|
|
21
|
+
}) => {
|
|
22
|
+
el: FocusableElement;
|
|
23
|
+
focusableElements: FocusableElement[];
|
|
24
|
+
};
|
|
25
|
+
export declare const focusPreviousElement: (root: HTMLElement, options?: {
|
|
26
|
+
circular?: boolean;
|
|
27
|
+
}) => {
|
|
28
|
+
el: FocusableElement;
|
|
29
|
+
focusableElements: FocusableElement[];
|
|
30
|
+
};
|
|
31
|
+
export declare const focusFirstElement: (root: HTMLElement) => {
|
|
32
|
+
el: FocusableElement;
|
|
33
|
+
focusableElements: FocusableElement[];
|
|
34
|
+
};
|
|
35
|
+
export declare const focusLastElement: (root: HTMLElement) => {
|
|
36
|
+
el: FocusableElement;
|
|
37
|
+
focusableElements: FocusableElement[];
|
|
17
38
|
};
|
|
18
|
-
export declare const focusNextElement: (root: HTMLElement) => void;
|
|
19
|
-
export declare const focusPreviousElement: (root: HTMLElement) => void;
|
|
20
|
-
export declare const focusFirstElement: (root: HTMLElement) => void;
|
|
21
|
-
export declare const focusLastElement: (root: HTMLElement) => void;
|
|
@@ -88,13 +88,14 @@ export const getFocusData = (args) => {
|
|
|
88
88
|
nextIndex = target === "prev" ? positions.first : positions.last;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
return { overflow: isOverflow, el: focusable[nextIndex] };
|
|
91
|
+
return { overflow: isOverflow, el: focusable[nextIndex], focusableElements: focusable };
|
|
92
92
|
};
|
|
93
93
|
const focusTargetElement = (root, target, options) => {
|
|
94
94
|
const data = getFocusData({ root, target, options });
|
|
95
95
|
focusElement(data.el);
|
|
96
|
+
return { el: data.el, focusableElements: data.focusableElements };
|
|
96
97
|
};
|
|
97
|
-
export const focusNextElement = (root) => focusTargetElement(root, "next", { includeNegativeTabIndex: true });
|
|
98
|
-
export const focusPreviousElement = (root) => focusTargetElement(root, "prev", { includeNegativeTabIndex: true });
|
|
98
|
+
export const focusNextElement = (root, options) => focusTargetElement(root, "next", { ...options, includeNegativeTabIndex: true });
|
|
99
|
+
export const focusPreviousElement = (root, options) => focusTargetElement(root, "prev", { ...options, includeNegativeTabIndex: true });
|
|
99
100
|
export const focusFirstElement = (root) => focusTargetElement(root, "first", { includeNegativeTabIndex: true });
|
|
100
101
|
export const focusLastElement = (root) => focusTargetElement(root, "last", { includeNegativeTabIndex: true });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import type * as G from "../types/global";
|
|
3
2
|
type Value = string | boolean | number | undefined;
|
|
4
3
|
type ClassNameResolver = string | ((value: Value) => string);
|
|
@@ -11,6 +10,4 @@ export declare const responsiveClassNames: <V extends G.Responsive<Value>>(s: Re
|
|
|
11
10
|
}) => string[];
|
|
12
11
|
export declare const responsiveVariables: <V extends Value = Value>(variableName: G.CSSVariable, value?: G.Responsive<V>) => Record<G.CSSVariable, V>;
|
|
13
12
|
export declare const responsivePropDependency: <Result, T>(prop: G.Responsive<T>, resolver: (value: T, key: G.Viewport) => Result) => Result;
|
|
14
|
-
export declare const setComponentChildId: (Component: React.FC<any>, id: string) => string;
|
|
15
|
-
export declare const isMatchingComponentChildId: (child: React.ReactNode, id: string) => boolean | null;
|
|
16
13
|
export {};
|
package/dist/utilities/props.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
/**
|
|
3
2
|
* Resolve an array of values into a classname string
|
|
4
3
|
*/
|
|
@@ -82,21 +81,3 @@ export const responsivePropDependency = (prop, resolver) => {
|
|
|
82
81
|
return { ...acc, [viewport]: resolver(viewportValue, viewport) };
|
|
83
82
|
}, {});
|
|
84
83
|
};
|
|
85
|
-
/**
|
|
86
|
-
* Add unique ids to components relying on React.Children.map
|
|
87
|
-
* Relying on an id instead of child.type makes it work in dev mode during HMR
|
|
88
|
-
*/
|
|
89
|
-
const getComponentChildId = (id) => `__rs-child-${id}`;
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
-
export const setComponentChildId = (Component, id) => {
|
|
92
|
-
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
return (Component.__reshapedChildId = getComponentChildId(id));
|
|
95
|
-
};
|
|
96
|
-
export const isMatchingComponentChildId = (child, id) => {
|
|
97
|
-
if (!React.isValidElement(child))
|
|
98
|
-
return null;
|
|
99
|
-
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
return child.type.__reshapedChildId === getComponentChildId(id);
|
|
102
|
-
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { disableScroll, enableScroll } from "./disable";
|
|
2
|
-
export { lockScroll
|
|
2
|
+
export { lockScroll } from "./lock";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { disableScroll, enableScroll } from "./disable.js";
|
|
2
|
-
export { lockScroll
|
|
2
|
+
export { lockScroll } from "./lock.js";
|