reshaped 2.4.5 → 2.4.8
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 +6 -0
- package/bundle.css +1 -1
- package/bundle.js +8 -8
- package/components/Accordion/tests/Accordion.stories.js +1 -1
- package/components/Actionable/Actionable.js +4 -4
- package/components/Autocomplete/Autocomplete.js +8 -2
- package/components/Button/Button.js +1 -1
- package/components/Button/Button.module.css +1 -1
- package/components/Button/Button.types.d.ts +6 -6
- package/components/Button/ButtonAligner.js +2 -8
- package/components/Button/tests/Button.stories.js +5 -5
- package/components/FormControl/FormControl.context.d.ts +53 -53
- package/components/MenuItem/MenuItem.js +1 -1
- package/components/MenuItem/MenuItem.module.css +1 -1
- package/components/MenuItem/MenuItemAligner.d.ts +2 -2
- package/components/MenuItem/MenuItemAligner.js +2 -4
- package/components/MenuItem/tests/MenuItem.stories.js +1 -1
- package/components/TextArea/TextArea.d.ts +4 -1
- package/components/TextArea/TextArea.js +3 -1
- package/components/TextArea/TextArea.module.css +1 -1
- package/components/TextArea/tests/TextArea.stories.d.ts +1 -0
- package/components/TextArea/tests/TextArea.stories.js +16 -0
- package/components/TextField/TextField.d.ts +4 -1
- package/components/TextField/TextField.js +3 -1
- package/components/TextField/TextField.module.css +1 -1
- package/components/TextField/tests/TextField.stories.d.ts +1 -0
- package/components/TextField/tests/TextField.stories.js +16 -0
- package/components/Theme/GlobalColorMode.js +7 -3
- package/components/_private/Aligner/Aligner.d.ts +12 -0
- package/components/_private/Aligner/Aligner.js +18 -0
- package/components/_private/Aligner/Aligner.module.css +1 -0
- package/components/_private/Aligner/Aligner.types.d.ts +9 -0
- package/components/_private/Aligner/Aligner.types.js +1 -0
- package/components/_private/Aligner/index.d.ts +2 -0
- package/components/_private/Aligner/index.js +1 -0
- package/components/_private/Flyout/FlyoutTrigger.js +3 -12
- package/components/_private/Portal/Portal.d.ts +1 -1
- package/package.json +17 -17
- package/types/global.d.ts +1 -1
- package/config/next.d.ts +0 -4
- package/config/next.js +0 -22
@@ -3,6 +3,9 @@ import { Example, Placeholder } from "../../../utilities/storybook/index.js";
|
|
3
3
|
import IconZap from "../../../icons/Zap.js";
|
4
4
|
import TextField from "../index.js";
|
5
5
|
import FormControl from "../../FormControl/index.js";
|
6
|
+
import View from "../../View/index.js";
|
7
|
+
import Text from "../../Text/index.js";
|
8
|
+
import Button from "../../Button/index.js";
|
6
9
|
export default { title: "Components/TextField" };
|
7
10
|
export const value = () => (<Example>
|
8
11
|
<Example.Item title="no value, placeholder">
|
@@ -98,3 +101,16 @@ export const formControl = () => (<Example>
|
|
98
101
|
</FormControl>
|
99
102
|
</Example.Item>
|
100
103
|
</Example>);
|
104
|
+
export const aligner = () => (<Example>
|
105
|
+
<Example.Item title="aligner">
|
106
|
+
<View gap={2}>
|
107
|
+
<Text variant="featured-2">What problem are you trying to solve?</Text>
|
108
|
+
<TextField.Aligner>
|
109
|
+
<TextField variant="headless" placeholder="Try something like 'I have a job'" name="description"/>
|
110
|
+
</TextField.Aligner>
|
111
|
+
<View.Item>
|
112
|
+
<Button>Next</Button>
|
113
|
+
</View.Item>
|
114
|
+
</View>
|
115
|
+
</Example.Item>
|
116
|
+
</Example>);
|
@@ -7,10 +7,14 @@ const GlobalColorMode = (props) => {
|
|
7
7
|
const { defaultMode, children } = props;
|
8
8
|
const [mode, setMode] = React.useState(defaultMode || "light");
|
9
9
|
const changeColorMode = React.useCallback((targetMode) => {
|
10
|
-
// Avoid components styles animating when switching to another color mode
|
11
|
-
disableTransitions();
|
12
10
|
document.documentElement.setAttribute("data-rs-color-mode", targetMode);
|
13
|
-
setMode(
|
11
|
+
setMode((prevMode) => {
|
12
|
+
if (prevMode !== targetMode) {
|
13
|
+
// Avoid components styles animating when switching to another color mode
|
14
|
+
disableTransitions();
|
15
|
+
}
|
16
|
+
return targetMode;
|
17
|
+
});
|
14
18
|
}, []);
|
15
19
|
useIsomorphicLayoutEffect(() => {
|
16
20
|
onNextFrame(() => {
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Aligner is a utility used across multiple components to apply
|
3
|
+
* negative margin based on the component padding to align its text content
|
4
|
+
* visually with the rest of the page
|
5
|
+
*
|
6
|
+
* It relies on using a data-rs-aligner-target attribute in other components and works based
|
7
|
+
* on the --rs-p, --rs-p-v and --rs-p-h css variables
|
8
|
+
*/
|
9
|
+
import React from "react";
|
10
|
+
import type * as T from "./Aligner.types";
|
11
|
+
declare const Aligner: (props: T.Props) => React.JSX.Element;
|
12
|
+
export default Aligner;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Aligner is a utility used across multiple components to apply
|
3
|
+
* negative margin based on the component padding to align its text content
|
4
|
+
* visually with the rest of the page
|
5
|
+
*
|
6
|
+
* It relies on using a data-rs-aligner-target attribute in other components and works based
|
7
|
+
* on the --rs-p, --rs-p-v and --rs-p-h css variables
|
8
|
+
*/
|
9
|
+
import React from "react";
|
10
|
+
import { classNames } from "../../../utilities/helpers.js";
|
11
|
+
import s from "./Aligner.module.css";
|
12
|
+
const Aligner = (props) => {
|
13
|
+
const { side: passedSide = "all", children, className, attributes } = props;
|
14
|
+
const sides = typeof passedSide === "string" ? [passedSide] : passedSide;
|
15
|
+
const rootClassNames = classNames(s.root, sides.map((side) => s[`--side-${side}`]), className);
|
16
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: rootClassNames }), children));
|
17
|
+
};
|
18
|
+
export default Aligner;
|
@@ -0,0 +1 @@
|
|
1
|
+
.root [data-rs-aligner-target]{--rs-aligner-p-h:var(--rs-p-h,var(--rs-p));--rs-aligner-p-v:var(--rs-p-v,var(--rs-p))}.root.--side-all [data-rs-aligner-target]{margin:calc(var(--rs-aligner-p-v) * -1) calc(var(--rs-aligner-p-h) * -1)}.root.--side-inline [data-rs-aligner-target],.root.--side-start [data-rs-aligner-target]{margin-inline-start:calc(var(--rs-aligner-p-h) * -1)}.root.--side-end [data-rs-aligner-target],.root.--side-inline [data-rs-aligner-target]{margin-inline-end:calc(var(--rs-aligner-p-h) * -1)}.root.--side-block [data-rs-aligner-target],.root.--side-top [data-rs-aligner-target]{margin-block-start:calc(var(--rs-aligner-p-v) * -1)}.root.--side-block [data-rs-aligner-target],.root.--side-bottom [data-rs-aligner-target]{margin-block-end:calc(var(--rs-aligner-p-v) * -1)}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type * as G from "../../../types/global";
|
2
|
+
type Side = "start" | "end" | "top" | "bottom" | "inline" | "block" | "all";
|
3
|
+
export type Props = {
|
4
|
+
children: React.ReactElement;
|
5
|
+
side?: Side | Side[];
|
6
|
+
className?: G.ClassName;
|
7
|
+
attributes?: G.Attributes<"div", Props>;
|
8
|
+
};
|
9
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "./Aligner.js";
|
@@ -1,30 +1,21 @@
|
|
1
1
|
"use client";
|
2
2
|
import React from "react";
|
3
|
-
import useHotkeys from "../../../hooks/useHotkeys.js";
|
4
|
-
import * as keys from "../../../constants/keys.js";
|
5
3
|
import { useFlyoutContext } from "./Flyout.context.js";
|
6
4
|
const FlyoutTrigger = (props) => {
|
7
5
|
const { children } = props;
|
8
|
-
const { id, triggerElRef, triggerType, flyout, handleFocus, handleBlur, handleMouseEnter, handleMouseLeave, handleClick,
|
9
|
-
useHotkeys({
|
10
|
-
[`${keys.UP},${keys.DOWN}`]: () => {
|
11
|
-
if (flyout.status !== "idle")
|
12
|
-
return;
|
13
|
-
handleOpen();
|
14
|
-
},
|
15
|
-
}, [handleOpen, flyout.status], { ref: triggerElRef });
|
6
|
+
const { id, triggerElRef, triggerType, flyout, handleFocus, handleBlur, handleMouseEnter, handleMouseLeave, handleClick, trapFocusMode, } = useFlyoutContext();
|
16
7
|
let childrenAttributes = {
|
17
8
|
onBlur: handleBlur,
|
18
9
|
ref: triggerElRef,
|
19
10
|
};
|
20
|
-
if (triggerType === "click") {
|
11
|
+
if (triggerType === "click" || trapFocusMode === "action-menu") {
|
21
12
|
childrenAttributes.onClick = handleClick;
|
22
13
|
}
|
23
14
|
if (triggerType === "hover") {
|
24
15
|
childrenAttributes.onMouseEnter = handleMouseEnter;
|
25
16
|
childrenAttributes.onMouseLeave = handleMouseLeave;
|
26
17
|
}
|
27
|
-
if (triggerType === "hover" || triggerType === "focus") {
|
18
|
+
if ((triggerType === "hover" && trapFocusMode !== "action-menu") || triggerType === "focus") {
|
28
19
|
childrenAttributes.onFocus = handleFocus;
|
29
20
|
childrenAttributes["aria-describedby"] = id;
|
30
21
|
}
|
@@ -6,7 +6,7 @@ export declare const usePortalScope: () => T.Context;
|
|
6
6
|
* That gives Portal time to receive scope on first render
|
7
7
|
*/
|
8
8
|
declare const Portal: {
|
9
|
-
(props: T.Props):
|
9
|
+
(props: T.Props): any;
|
10
10
|
Scope: typeof PortalScope;
|
11
11
|
};
|
12
12
|
declare function PortalScope<T extends HTMLElement>(props: T.ScopeProps<T>): React.JSX.Element;
|
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": "2.4.
|
4
|
+
"version": "2.4.8",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -80,19 +80,19 @@
|
|
80
80
|
],
|
81
81
|
"devDependencies": {
|
82
82
|
"@size-limit/preset-big-lib": "9.0.0",
|
83
|
-
"@storybook/addon-a11y": "7.4.
|
84
|
-
"@storybook/react": "7.4.
|
85
|
-
"@storybook/react-vite": "7.4.
|
86
|
-
"@testing-library/jest-dom": "6.1.
|
83
|
+
"@storybook/addon-a11y": "7.4.6",
|
84
|
+
"@storybook/react": "7.4.6",
|
85
|
+
"@storybook/react-vite": "7.4.6",
|
86
|
+
"@testing-library/jest-dom": "6.1.4",
|
87
87
|
"@testing-library/react": "14.0.0",
|
88
|
-
"@testing-library/user-event": "14.
|
88
|
+
"@testing-library/user-event": "14.5.1",
|
89
89
|
"@types/events": "3.0.0",
|
90
|
-
"@types/jest": "29.5.
|
91
|
-
"@types/node": "20.6
|
92
|
-
"@types/react": "18.2.
|
93
|
-
"@types/react-dom": "18.2.
|
94
|
-
"@typescript-eslint/eslint-plugin": "6.
|
95
|
-
"@typescript-eslint/parser": "6.
|
90
|
+
"@types/jest": "29.5.5",
|
91
|
+
"@types/node": "20.8.6",
|
92
|
+
"@types/react": "18.2.28",
|
93
|
+
"@types/react-dom": "18.2.13",
|
94
|
+
"@typescript-eslint/eslint-plugin": "6.7.5",
|
95
|
+
"@typescript-eslint/parser": "6.7.5",
|
96
96
|
"@vitejs/plugin-react": "4.0.4",
|
97
97
|
"chromatic": "7.1.0",
|
98
98
|
"eslint": "8.49.0",
|
@@ -104,11 +104,11 @@
|
|
104
104
|
"eslint-plugin-react": "7.33.2",
|
105
105
|
"eslint-plugin-react-hooks": "4.6.0",
|
106
106
|
"identity-obj-proxy": "3.0.0",
|
107
|
-
"jest": "29.
|
108
|
-
"jest-environment-jsdom": "29.
|
107
|
+
"jest": "29.7.0",
|
108
|
+
"jest-environment-jsdom": "29.7.0",
|
109
109
|
"jest-matchmedia-mock": "1.1.0",
|
110
|
-
"lefthook": "1.
|
111
|
-
"postcss": "8.4.
|
110
|
+
"lefthook": "1.5.2",
|
111
|
+
"postcss": "8.4.31",
|
112
112
|
"postcss-cli": "10.1.0",
|
113
113
|
"postcss-each": "1.1.0",
|
114
114
|
"postcss-import": "15.1.0",
|
@@ -118,7 +118,7 @@
|
|
118
118
|
"react-dom": "18.2.0",
|
119
119
|
"resolve-tspaths": "0.8.15",
|
120
120
|
"size-limit": "9.0.0",
|
121
|
-
"storybook": "7.4.
|
121
|
+
"storybook": "7.4.6",
|
122
122
|
"stylelint": "15.10.3",
|
123
123
|
"stylelint-config-prettier": "9.0.5",
|
124
124
|
"stylelint-config-standard": "34.0.0",
|
package/types/global.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
type ClassNameValue = string | null | undefined | false;
|
3
|
-
export type ClassName = ClassNameValue | ClassNameValue[];
|
3
|
+
export type ClassName = ClassNameValue | ClassNameValue[] | ClassName[];
|
4
4
|
export type CSSVariable = `--${string}`;
|
5
5
|
export type StyleAttribute = React.CSSProperties & Record<CSSVariable, string | number | undefined>;
|
6
6
|
type DataAttributes = Record<`data-${string}`, string | boolean>;
|
package/config/next.d.ts
DELETED
package/config/next.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* TODO: Work in progress
|
4
|
-
* Needs named exports support before we can use it
|
5
|
-
*/
|
6
|
-
// export const config = {
|
7
|
-
// modularizeImports: {
|
8
|
-
// reshaped: {
|
9
|
-
// transform: {
|
10
|
-
// // Utilities
|
11
|
-
// // classNames: "reshaped/utilities/classNames",
|
12
|
-
// // Hooks
|
13
|
-
// useToast: "reshaped/components/Toast",
|
14
|
-
// useFormControl: "reshaped/components/FormControl",
|
15
|
-
// useTheme: "reshaped/components/Theme",
|
16
|
-
// "use.*": "reshaped/hooks/{{ member }}",
|
17
|
-
// // Components
|
18
|
-
// "*": "reshaped/components/{{ member }}",
|
19
|
-
// },
|
20
|
-
// },
|
21
|
-
// },
|
22
|
-
// };
|