reshaped 3.5.1-canary.0 → 3.5.1
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 +5 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +10 -10
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Card/Card.module.css +1 -1
- package/dist/components/Slider/Slider.types.d.ts +1 -1
- package/dist/components/Slider/SliderControlled.js +4 -2
- package/dist/components/Slider/tests/Slider.stories.d.ts +1 -0
- package/dist/components/Slider/tests/Slider.stories.js +8 -0
- package/dist/components/View/View.d.ts +2 -2
- package/dist/components/View/tests/View.stories.d.ts +2 -2
- package/dist/components/View/tests/View.test.stories.d.ts +2 -2
- package/dist/utilities/a11y/focus.d.ts +3 -6
- package/dist/utilities/a11y/focus.js +11 -8
- package/dist/utilities/a11y/types.d.ts +4 -0
- package/package.json +1 -1
@@ -28,9 +28,9 @@ const Card = forwardRef((props, ref) => {
|
|
28
28
|
if (isActionable) {
|
29
29
|
return (_jsx(Actionable, { className: rootClassNames, attributes: { ...attributes, style }, href: href, as: TagName, onClick: onClick,
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
31
|
-
ref: ref, children:
|
31
|
+
ref: ref, children: children }));
|
32
32
|
}
|
33
|
-
return (_jsx(TagName, { ...attributes, onClick: onClick, href: href, ref: ref, className: rootClassNames, style: style, children:
|
33
|
+
return (_jsx(TagName, { ...attributes, onClick: onClick, href: href, ref: ref, className: rootClassNames, style: style, children: children }));
|
34
34
|
});
|
35
35
|
Card.displayName = "Card";
|
36
36
|
export default Card;
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-border-width:1px;background:var(--rs-color-background-elevation-base);border:var(--rs-border-width) solid var(--rs-color-border-neutral-faded);color:var(--rs-color-foreground-neutral);display:block;overflow:hidden;text-align:initial;transition:var(--rs-duration-fast) var(--rs-easing-accelerate);transition-property:box-shadow,border-color}
|
1
|
+
.root{--rs-border-width:1px;background:var(--rs-color-background-elevation-base);border:var(--rs-border-width) solid var(--rs-color-border-neutral-faded);color:var(--rs-color-foreground-neutral);display:block;overflow:hidden;position:relative;text-align:initial;transition:var(--rs-duration-fast) var(--rs-easing-accelerate);transition-property:box-shadow,border-color}.--selected{border-color:transparent;box-shadow:0 0 0 2px var(--rs-color-border-primary);transition-timing-function:var(--rs-easing-decelerate)}.--elevated{background:var(--rs-color-background-elevation-raised);box-shadow:var(--rs-shadow-raised)}.--actionable:not(.--selected){color:inherit;cursor:pointer;outline:none;text-decoration:none}[data-rs-keyboard] .--actionable:not(.--selected):focus{box-shadow:var(--rs-focus-shadow)}.--actionable:not(.--selected):before{background:rgba(var(--rs-color-rgb-background-neutral-faded),32%);content:"";inset:0;opacity:0;pointer-events:none;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--actionable:not(.--selected):hover:before{opacity:1}
|
@@ -71,7 +71,7 @@ export type ThumbProps = {
|
|
71
71
|
onChange: (value: number, options?: {
|
72
72
|
commit?: boolean;
|
73
73
|
}) => void;
|
74
|
-
onDragStart: () => void;
|
74
|
+
onDragStart: (e: React.TouchEvent | React.MouseEvent) => void;
|
75
75
|
max: number;
|
76
76
|
min: number;
|
77
77
|
step: NonNullable<BaseProps["step"]>;
|
@@ -136,14 +136,16 @@ const SliderControlled = (props) => {
|
|
136
136
|
disableScroll();
|
137
137
|
setDraggingId(closestId);
|
138
138
|
};
|
139
|
-
const handleMinDragStart = () => {
|
139
|
+
const handleMinDragStart = (e) => {
|
140
140
|
if (disabled)
|
141
141
|
return;
|
142
|
+
e.stopPropagation();
|
142
143
|
setDraggingId(minId);
|
143
144
|
};
|
144
|
-
const handleMaxDragStart = () => {
|
145
|
+
const handleMaxDragStart = (e) => {
|
145
146
|
if (disabled)
|
146
147
|
return;
|
148
|
+
e.stopPropagation();
|
147
149
|
setDraggingId(maxId);
|
148
150
|
};
|
149
151
|
const handleDragStop = React.useCallback(() => {
|
@@ -14,3 +14,4 @@ export declare const step: () => import("react").JSX.Element;
|
|
14
14
|
export declare const boundaries: () => import("react").JSX.Element;
|
15
15
|
export declare const status: () => import("react").JSX.Element;
|
16
16
|
export declare const customRender: () => import("react").JSX.Element;
|
17
|
+
export declare const testModal: () => import("react").JSX.Element;
|
@@ -2,6 +2,8 @@ import { Example } from "../../../utilities/storybook/index.js";
|
|
2
2
|
import Slider from "../index.js";
|
3
3
|
import View from "../../View/index.js";
|
4
4
|
import FormControl from "../../FormControl/index.js";
|
5
|
+
import Modal from "../../Modal/index.js";
|
6
|
+
import useToggle from "../../../hooks/useToggle.js";
|
5
7
|
export default {
|
6
8
|
title: "Components/Slider",
|
7
9
|
component: Slider,
|
@@ -61,3 +63,9 @@ export const customRender = () => (<Example>
|
|
61
63
|
</FormControl>
|
62
64
|
</Example.Item>
|
63
65
|
</Example>);
|
66
|
+
export const testModal = () => {
|
67
|
+
const toggle = useToggle(true);
|
68
|
+
return (<Modal active={toggle.active} onClose={toggle.deactivate} position="end">
|
69
|
+
<Slider name="slider" defaultValue={30} renderValue={false}/>
|
70
|
+
</Modal>);
|
71
|
+
};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type * as T from "./View.types";
|
3
3
|
declare const View: {
|
4
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: T.Props<As>):
|
4
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: T.Props<As>): import("react/jsx-runtime").JSX.Element;
|
5
5
|
Item: {
|
6
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: T.ItemProps<As>):
|
6
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: T.ItemProps<As>): import("react/jsx-runtime").JSX.Element;
|
7
7
|
displayName: string;
|
8
8
|
};
|
9
9
|
displayName: string;
|
@@ -3,9 +3,9 @@ import { type ViewProps } from "./..";
|
|
3
3
|
declare const _default: {
|
4
4
|
title: string;
|
5
5
|
component: {
|
6
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: ViewProps<As>): React.
|
6
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: ViewProps<As>): React.JSX.Element;
|
7
7
|
Item: {
|
8
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewItemProps<As>): React.
|
8
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewItemProps<As>): React.JSX.Element;
|
9
9
|
displayName: string;
|
10
10
|
};
|
11
11
|
displayName: string;
|
@@ -2,9 +2,9 @@ import { StoryObj } from "@storybook/react";
|
|
2
2
|
declare const _default: {
|
3
3
|
title: string;
|
4
4
|
component: {
|
5
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewProps<As>):
|
5
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewProps<As>): import("react").JSX.Element;
|
6
6
|
Item: {
|
7
|
-
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewItemProps<As>):
|
7
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewItemProps<As>): import("react").JSX.Element;
|
8
8
|
displayName: string;
|
9
9
|
};
|
10
10
|
displayName: string;
|
@@ -1,18 +1,15 @@
|
|
1
|
-
import type { FocusableElement } from "./types";
|
1
|
+
import type { FocusableElement, FocusableOptions } from "./types";
|
2
2
|
export declare const focusableSelector = "a,button,input:not([type=\"hidden\"]),textarea,select,details,[tabindex],[contenteditable]";
|
3
3
|
export declare const getActiveElement: (originEl?: HTMLElement | null) => HTMLButtonElement;
|
4
4
|
export declare const focusElement: (el: FocusableElement, options?: {
|
5
5
|
pseudoFocus?: boolean;
|
6
6
|
}) => void;
|
7
|
-
export declare const getFocusableElements: (rootEl: HTMLElement, options?:
|
8
|
-
additionalElement?: FocusableElement | null;
|
9
|
-
}) => FocusableElement[];
|
7
|
+
export declare const getFocusableElements: (rootEl: HTMLElement, options?: FocusableOptions) => FocusableElement[];
|
10
8
|
export declare const getFocusData: (args: {
|
11
9
|
root: HTMLElement;
|
12
10
|
target: "next" | "prev" | "first" | "last";
|
13
|
-
options?: {
|
11
|
+
options?: FocusableOptions & {
|
14
12
|
circular?: boolean;
|
15
|
-
additionalElement?: FocusableElement | null;
|
16
13
|
};
|
17
14
|
}) => {
|
18
15
|
overflow: boolean;
|
@@ -26,7 +26,7 @@ export const getFocusableElements = (rootEl, options) => {
|
|
26
26
|
if (el.clientHeight === 0)
|
27
27
|
return false;
|
28
28
|
// Using getAttribute here since browser sets el.tabIndex to -1 by default
|
29
|
-
if (el.getAttribute("tabindex") === "-1")
|
29
|
+
if (!options?.includeNegativeTabIndex && el.getAttribute("tabindex") === "-1")
|
30
30
|
return false;
|
31
31
|
if (el.type === "radio") {
|
32
32
|
let sameNameRadioEls;
|
@@ -65,7 +65,10 @@ export const getFocusableElements = (rootEl, options) => {
|
|
65
65
|
};
|
66
66
|
export const getFocusData = (args) => {
|
67
67
|
const { root, target, options } = args;
|
68
|
-
const focusable = getFocusableElements(root, {
|
68
|
+
const focusable = getFocusableElements(root, {
|
69
|
+
additionalElement: options?.additionalElement,
|
70
|
+
includeNegativeTabIndex: options?.includeNegativeTabIndex,
|
71
|
+
});
|
69
72
|
const focusableLimit = focusable.length - 1;
|
70
73
|
const currentElement = getActiveElement(root);
|
71
74
|
const currentIndex = focusable.indexOf(currentElement);
|
@@ -87,11 +90,11 @@ export const getFocusData = (args) => {
|
|
87
90
|
}
|
88
91
|
return { overflow: isOverflow, el: focusable[nextIndex] };
|
89
92
|
};
|
90
|
-
const focusTargetElement = (root, target) => {
|
91
|
-
const data = getFocusData({ root, target });
|
93
|
+
const focusTargetElement = (root, target, options) => {
|
94
|
+
const data = getFocusData({ root, target, options });
|
92
95
|
focusElement(data.el);
|
93
96
|
};
|
94
|
-
export const focusNextElement = (root) => focusTargetElement(root, "next");
|
95
|
-
export const focusPreviousElement = (root) => focusTargetElement(root, "prev");
|
96
|
-
export const focusFirstElement = (root) => focusTargetElement(root, "first");
|
97
|
-
export const focusLastElement = (root) => focusTargetElement(root, "last");
|
97
|
+
export const focusNextElement = (root) => focusTargetElement(root, "next", { includeNegativeTabIndex: true });
|
98
|
+
export const focusPreviousElement = (root) => focusTargetElement(root, "prev", { includeNegativeTabIndex: true });
|
99
|
+
export const focusFirstElement = (root) => focusTargetElement(root, "first", { includeNegativeTabIndex: true });
|
100
|
+
export const focusLastElement = (root) => focusTargetElement(root, "last", { includeNegativeTabIndex: true });
|
@@ -18,3 +18,7 @@
|
|
18
18
|
*/
|
19
19
|
export type TrapMode = "dialog" | "action-menu" | "action-bar" | "content-menu" | "selection-menu";
|
20
20
|
export type FocusableElement = HTMLButtonElement | HTMLInputElement;
|
21
|
+
export type FocusableOptions = {
|
22
|
+
additionalElement?: FocusableElement | null;
|
23
|
+
includeNegativeTabIndex?: boolean;
|
24
|
+
};
|
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.5.1
|
4
|
+
"version": "3.5.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|