reshaped 3.8.0-canary.2 → 3.8.0-canary.4
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 +14 -0
- package/dist/bundle.js +9 -9
- package/dist/components/Actionable/Actionable.js +16 -3
- package/dist/components/Actionable/Actionable.types.d.ts +15 -3
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +13 -1
- package/dist/components/Actionable/tests/Actionable.stories.js +127 -7
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/Button.types.d.ts +1 -1
- package/dist/components/Button/tests/Button.test.stories.d.ts +1 -0
- package/dist/components/Button/tests/Button.test.stories.js +23 -0
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +1 -1
- package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/Link/Link.js +2 -2
- package/dist/components/Link/Link.types.d.ts +1 -1
- package/dist/components/Link/tests/Link.stories.d.ts +1 -1
- package/dist/components/Link/tests/Link.test.stories.d.ts +2 -1
- package/dist/components/Link/tests/Link.test.stories.js +9 -0
- package/dist/components/MenuItem/MenuItem.js +2 -2
- package/dist/components/MenuItem/MenuItem.types.d.ts +1 -1
- package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +1 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.js +16 -0
- package/dist/components/Modal/tests/Modal.stories.js +5 -0
- package/dist/hooks/_private/useIsDismissible.js +1 -9
- package/package.json +2 -2
- package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +0 -32
- package/dist/components/Actionable/tests/Actionable.test.stories.js +0 -130
@@ -1,11 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import { forwardRef } from "react";
|
4
4
|
import { classNames } from "../../utilities/props.js";
|
5
5
|
import * as keys from "../../constants/keys.js";
|
6
6
|
import s from "./Actionable.module.css";
|
7
7
|
const Actionable = forwardRef((props, ref) => {
|
8
|
-
const { children, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, stopPropagation, fullWidth, touchHitbox, className, attributes, } = props;
|
8
|
+
const { children, render, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, stopPropagation, fullWidth, touchHitbox, className, attributes, } = props;
|
9
9
|
const rootClassNames = classNames(s.root, className, disabled && s["--disabled"], borderRadius && s[`--radius-${borderRadius}`], insetFocus && s["--inset"], disableFocusRing && s["--disabled-focus-ring"], fullWidth && s["--full-width"]);
|
10
10
|
const rootAttributes = { ...attributes };
|
11
11
|
const hasClickHandler = onClick || attributes?.onClick;
|
@@ -57,7 +57,20 @@ const Actionable = forwardRef((props, ref) => {
|
|
57
57
|
event.preventDefault();
|
58
58
|
handlePress(event);
|
59
59
|
};
|
60
|
-
|
60
|
+
const childrenNode = (_jsxs(_Fragment, { children: [touchHitbox && (isLink || isButton) && !disabled && _jsx("span", { className: s.touch }), children] }));
|
61
|
+
const tagAttributes = {
|
62
|
+
ref: ref,
|
63
|
+
// rootAttributes can receive ref from Flyout
|
64
|
+
...rootAttributes,
|
65
|
+
className: rootClassNames,
|
66
|
+
onClick: handlePress,
|
67
|
+
onKeyDown: handleKeyDown,
|
68
|
+
"aria-disabled": disabled ? true : undefined,
|
69
|
+
children: childrenNode,
|
70
|
+
};
|
71
|
+
if (render)
|
72
|
+
return render(tagAttributes);
|
73
|
+
return _jsx(TagName, { ...tagAttributes });
|
61
74
|
});
|
62
75
|
Actionable.displayName = "Actionable";
|
63
76
|
export default Actionable;
|
@@ -1,8 +1,21 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
|
+
export type AttributesRef = React.RefObject<HTMLButtonElement | null>;
|
4
|
+
type Attributes = G.Attributes<"button"> & Omit<React.JSX.IntrinsicElements["a"], keyof G.Attributes<"button">> & {
|
5
|
+
ref?: AttributesRef;
|
6
|
+
};
|
3
7
|
export type Props = {
|
4
8
|
/** Node for inserting the content */
|
5
9
|
children?: React.ReactNode;
|
10
|
+
/** Render a custom root element, useful for integrating with routers */
|
11
|
+
render?: (attributes: Attributes & {
|
12
|
+
ref: AttributesRef;
|
13
|
+
className: string;
|
14
|
+
onClick: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
15
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
|
16
|
+
"aria-disabled"?: boolean;
|
17
|
+
children: React.ReactNode;
|
18
|
+
}) => React.ReactNode;
|
6
19
|
/** Callback when clicked, renders it as a button tag if href is not provided */
|
7
20
|
onClick?: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
8
21
|
/** URL, renders it as an anchor tag */
|
@@ -28,8 +41,7 @@ export type Props = {
|
|
28
41
|
/** Additional classname for the root element */
|
29
42
|
className?: G.ClassName;
|
30
43
|
/** Additional attributes for the root element */
|
31
|
-
attributes?:
|
32
|
-
ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
|
33
|
-
};
|
44
|
+
attributes?: Attributes;
|
34
45
|
};
|
35
46
|
export type Ref = React.Ref<HTMLButtonElement | HTMLAnchorElement>;
|
47
|
+
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { StoryObj } from "@storybook/react-vite";
|
2
|
+
import { fn } from "storybook/test";
|
2
3
|
declare const _default: {
|
3
4
|
title: string;
|
4
5
|
component: import("react").ForwardRefExoticComponent<import("./..").ActionableProps & import("react").RefAttributes<import("./..").ActionableRef>>;
|
@@ -9,7 +10,10 @@ declare const _default: {
|
|
9
10
|
};
|
10
11
|
};
|
11
12
|
export default _default;
|
12
|
-
export declare const base: StoryObj
|
13
|
+
export declare const base: StoryObj<{
|
14
|
+
handleClick: ReturnType<typeof fn>;
|
15
|
+
handleSecondClick: ReturnType<typeof fn>;
|
16
|
+
}>;
|
13
17
|
export declare const disabled: StoryObj;
|
14
18
|
export declare const fullWidth: StoryObj;
|
15
19
|
export declare const insetFocus: {
|
@@ -27,3 +31,11 @@ export declare const borderRadius: {
|
|
27
31
|
render: () => import("react").JSX.Element;
|
28
32
|
play: () => Promise<void>;
|
29
33
|
};
|
34
|
+
export declare const type: StoryObj<{
|
35
|
+
handleSubmit: ReturnType<typeof fn>;
|
36
|
+
}>;
|
37
|
+
export declare const as: StoryObj;
|
38
|
+
export declare const stopPropagation: StoryObj<{
|
39
|
+
handleParentClick: ReturnType<typeof fn>;
|
40
|
+
}>;
|
41
|
+
export declare const className: StoryObj;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { userEvent, expect } from "storybook/test";
|
1
|
+
import { userEvent, expect, fn } from "storybook/test";
|
2
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
3
3
|
import Actionable from "../index.js";
|
4
4
|
import View from "../../View/index.js";
|
@@ -12,17 +12,64 @@ export default {
|
|
12
12
|
},
|
13
13
|
};
|
14
14
|
export const base = {
|
15
|
-
name: "
|
16
|
-
|
17
|
-
|
15
|
+
name: "href, onClick",
|
16
|
+
args: {
|
17
|
+
handleClick: fn(),
|
18
|
+
handleSecondClick: fn(),
|
19
|
+
},
|
20
|
+
render: (args) => (<Example>
|
21
|
+
<Example.Item title="span">
|
22
|
+
<Actionable>Span</Actionable>
|
23
|
+
</Example.Item>
|
24
|
+
<Example.Item title="onClick">
|
25
|
+
<Actionable onClick={args.handleClick}>Button</Actionable>
|
26
|
+
</Example.Item>
|
27
|
+
<Example.Item title="href">
|
18
28
|
<Actionable href="https://reshaped.so" attributes={{ target: "_blank" }}>
|
19
29
|
Link
|
20
30
|
</Actionable>
|
21
31
|
</Example.Item>
|
22
|
-
|
23
|
-
|
32
|
+
|
33
|
+
<Example.Item title="attributes.href">
|
34
|
+
<Actionable attributes={{ href: "https://reshaped.so" }}>Link with attributes</Actionable>
|
35
|
+
</Example.Item>
|
36
|
+
|
37
|
+
<Example.Item title="href, onClick">
|
38
|
+
<Actionable onClick={(e) => {
|
39
|
+
e.preventDefault();
|
40
|
+
args.handleSecondClick(e);
|
41
|
+
}} href="https://reshaped.so">
|
42
|
+
Link with onClick
|
43
|
+
</Actionable>
|
24
44
|
</Example.Item>
|
25
45
|
</Example>),
|
46
|
+
play: async ({ canvas, args }) => {
|
47
|
+
const span = canvas.getByText("Span");
|
48
|
+
const link = canvas.getByText("Link");
|
49
|
+
const button = canvas.getByText("Button");
|
50
|
+
const linkWithAttributes = canvas.getByText("Link with attributes");
|
51
|
+
const linkWithOnClick = canvas.getByText("Link with onClick");
|
52
|
+
expect(span).toBeInTheDocument();
|
53
|
+
expect(span.tagName).toBe("SPAN");
|
54
|
+
expect(link).toBeInTheDocument();
|
55
|
+
expect(link).toHaveRole("link");
|
56
|
+
expect(link).toHaveAttribute("href", "https://reshaped.so");
|
57
|
+
await userEvent.click(button);
|
58
|
+
expect(button).toBeInTheDocument();
|
59
|
+
expect(button).toHaveRole("button");
|
60
|
+
expect(button).toHaveAttribute("type", "button");
|
61
|
+
expect(args.handleClick).toHaveBeenCalledTimes(1);
|
62
|
+
expect(args.handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: button }));
|
63
|
+
expect(linkWithAttributes).toBeInTheDocument();
|
64
|
+
expect(linkWithAttributes).toHaveRole("link");
|
65
|
+
expect(linkWithAttributes).toHaveAttribute("href", "https://reshaped.so");
|
66
|
+
await userEvent.click(linkWithOnClick);
|
67
|
+
expect(linkWithOnClick).toBeInTheDocument();
|
68
|
+
expect(linkWithOnClick).toHaveRole("link");
|
69
|
+
expect(linkWithOnClick).toHaveAttribute("href", "https://reshaped.so");
|
70
|
+
expect(args.handleSecondClick).toHaveBeenCalledTimes(1);
|
71
|
+
expect(args.handleSecondClick).toHaveBeenCalledWith(expect.objectContaining({ target: linkWithOnClick }));
|
72
|
+
},
|
26
73
|
};
|
27
74
|
export const disabled = {
|
28
75
|
name: "disabled",
|
@@ -88,7 +135,7 @@ export const disableFocusRing = {
|
|
88
135
|
export const borderRadius = {
|
89
136
|
name: "borderRadius",
|
90
137
|
render: () => (<Example>
|
91
|
-
<Example.Item title="
|
138
|
+
<Example.Item title="borderRadius: inherit">
|
92
139
|
<Actionable borderRadius="inherit" onClick={() => { }}>
|
93
140
|
<View borderRadius="large">Actionable</View>
|
94
141
|
</Actionable>
|
@@ -98,3 +145,76 @@ export const borderRadius = {
|
|
98
145
|
await userEvent.keyboard("{Tab/}");
|
99
146
|
},
|
100
147
|
};
|
148
|
+
export const type = {
|
149
|
+
name: "type",
|
150
|
+
args: {
|
151
|
+
handleSubmit: fn(),
|
152
|
+
},
|
153
|
+
render: (args) => (<Example>
|
154
|
+
<Example.Item title="type: submit">
|
155
|
+
<form onSubmit={(e) => {
|
156
|
+
e.preventDefault();
|
157
|
+
args.handleSubmit();
|
158
|
+
}}>
|
159
|
+
<Actionable onClick={() => { }} type="submit">
|
160
|
+
Submit
|
161
|
+
</Actionable>
|
162
|
+
</form>
|
163
|
+
</Example.Item>
|
164
|
+
</Example>),
|
165
|
+
play: async ({ canvas, args }) => {
|
166
|
+
const button = canvas.getAllByRole("button")[0];
|
167
|
+
await userEvent.click(button);
|
168
|
+
expect(args.handleSubmit).toHaveBeenCalledTimes(1);
|
169
|
+
},
|
170
|
+
};
|
171
|
+
export const as = {
|
172
|
+
name: "as, render",
|
173
|
+
render: () => (<Example>
|
174
|
+
<Example.Item title="as: span">
|
175
|
+
<Actionable onClick={() => { }} as="span">
|
176
|
+
Trigger
|
177
|
+
</Actionable>
|
178
|
+
</Example.Item>
|
179
|
+
<Example.Item title="render, disabled">
|
180
|
+
<Actionable disabled onClick={() => { }} render={(props) => <section {...props}/>}>
|
181
|
+
Trigger
|
182
|
+
</Actionable>
|
183
|
+
</Example.Item>
|
184
|
+
</Example>),
|
185
|
+
play: ({ canvas }) => {
|
186
|
+
const [asEl, renderEl] = canvas.getAllByText("Trigger");
|
187
|
+
expect(asEl.tagName).toBe("SPAN");
|
188
|
+
expect(renderEl.tagName).toBe("SECTION");
|
189
|
+
expect(renderEl).toHaveAttribute("aria-disabled", "true");
|
190
|
+
},
|
191
|
+
};
|
192
|
+
export const stopPropagation = {
|
193
|
+
name: "stopPropagation",
|
194
|
+
args: {
|
195
|
+
handleParentClick: fn(),
|
196
|
+
},
|
197
|
+
render: (args) => (<div onClick={args.handleParentClick}>
|
198
|
+
<Actionable stopPropagation onClick={() => { }}>
|
199
|
+
Trigger
|
200
|
+
</Actionable>
|
201
|
+
</div>),
|
202
|
+
play: async ({ canvas, args }) => {
|
203
|
+
const button = canvas.getAllByRole("button")[0];
|
204
|
+
await userEvent.click(button);
|
205
|
+
expect(args.handleParentClick).not.toHaveBeenCalled();
|
206
|
+
},
|
207
|
+
};
|
208
|
+
export const className = {
|
209
|
+
name: "className, attributes",
|
210
|
+
render: () => (<div data-testid="root">
|
211
|
+
<Actionable className="test-classname" attributes={{ id: "test-id" }}>
|
212
|
+
Trigger
|
213
|
+
</Actionable>
|
214
|
+
</div>),
|
215
|
+
play: async ({ canvas }) => {
|
216
|
+
const root = canvas.getByTestId("root").firstChild;
|
217
|
+
expect(root).toHaveClass("test-classname");
|
218
|
+
expect(root).toHaveAttribute("id", "test-id");
|
219
|
+
},
|
220
|
+
};
|
@@ -8,7 +8,7 @@ import ButtonGroup from "./ButtonGroup.js";
|
|
8
8
|
import ButtonAligner from "./ButtonAligner.js";
|
9
9
|
import s from "./Button.module.css";
|
10
10
|
const Button = forwardRef((props, ref) => {
|
11
|
-
const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, loadingAriaLabel, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, stopPropagation, as, className, attributes, } = props;
|
11
|
+
const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, loadingAriaLabel, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, stopPropagation, as, render, className, attributes, } = props;
|
12
12
|
const iconOnly = (icon || endIcon) && !children;
|
13
13
|
const rootClassName = classNames(s.root, className, color && s[`--color-${color}`], variant && s[`--variant-${variant}`], responsiveClassNames(s, "--size", size), responsiveClassNames(s, "--full-width", fullWidth), elevated && variant !== "ghost" && s["--elevated"], rounded && s["--rounded"], disabled && s["--disabled"], loading && s["--loading"], highlighted && s["--highlighted"], iconOnly && s["--icon-only"]);
|
14
14
|
const renderIcon = (position) => {
|
@@ -30,7 +30,7 @@ const Button = forwardRef((props, ref) => {
|
|
30
30
|
return (_jsxs(Actionable, { disabled: disabled || loading, className: rootClassName, attributes: {
|
31
31
|
...attributes,
|
32
32
|
"data-rs-aligner-target": true,
|
33
|
-
}, type: type, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit", attributes: { "aria-label": loadingAriaLabel } }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
|
33
|
+
}, type: type, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, render: render, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit", attributes: { "aria-label": loadingAriaLabel } }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
|
34
34
|
});
|
35
35
|
Button.Group = ButtonGroup;
|
36
36
|
Button.Aligner = ButtonAligner;
|
@@ -4,7 +4,7 @@ import type { ActionableProps, ActionableRef } from "../Actionable";
|
|
4
4
|
import type { AlignerProps as BaseAlignerProps } from "../_private/Aligner";
|
5
5
|
import type * as G from "../../types/global";
|
6
6
|
export type Size = "xlarge" | "large" | "medium" | "small";
|
7
|
-
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation"> & {
|
7
|
+
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation" | "render"> & {
|
8
8
|
/** Component color scheme
|
9
9
|
* @default "neutral"
|
10
10
|
*/
|
@@ -22,6 +22,7 @@ export declare const hrefOnClick: StoryObj<{
|
|
22
22
|
handleClick: ReturnType<typeof fn>;
|
23
23
|
}>;
|
24
24
|
export declare const disabled: StoryObj;
|
25
|
+
export declare const as: StoryObj;
|
25
26
|
export declare const className: StoryObj;
|
26
27
|
export declare const group: StoryObj;
|
27
28
|
export declare const groupClassName: StoryObj;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { userEvent, expect, fn } from "storybook/test";
|
2
2
|
import Button from "../index.js";
|
3
|
+
import Example from "../../../utilities/storybook/Example.js";
|
3
4
|
export default {
|
4
5
|
title: "Components/Button/tests",
|
5
6
|
component: Button,
|
@@ -72,6 +73,28 @@ export const disabled = {
|
|
72
73
|
expect(el).toBeDisabled();
|
73
74
|
},
|
74
75
|
};
|
76
|
+
export const as = {
|
77
|
+
name: "as, render",
|
78
|
+
render: () => (<Example>
|
79
|
+
<Example.Item title="as: span">
|
80
|
+
<Button onClick={() => { }} as="span">
|
81
|
+
Trigger
|
82
|
+
</Button>
|
83
|
+
</Example.Item>
|
84
|
+
<Example.Item title="render, disabled">
|
85
|
+
<Button disabled onClick={() => { }} render={(props) => <section {...props}/>} attributes={{ "data-testid": "render-el" }}>
|
86
|
+
Trigger
|
87
|
+
</Button>
|
88
|
+
</Example.Item>
|
89
|
+
</Example>),
|
90
|
+
play: ({ canvas }) => {
|
91
|
+
const [asEl] = canvas.getAllByText("Trigger");
|
92
|
+
const renderEl = canvas.getByTestId("render-el");
|
93
|
+
expect(asEl.tagName).toBe("SPAN");
|
94
|
+
expect(renderEl.tagName).toBe("SECTION");
|
95
|
+
expect(renderEl).toHaveAttribute("aria-disabled", "true");
|
96
|
+
},
|
97
|
+
};
|
75
98
|
export const className = {
|
76
99
|
name: "className, attributes",
|
77
100
|
render: () => (<div data-testid="root">
|
@@ -10,7 +10,7 @@ declare const Card: React.ForwardRefExoticComponent<{
|
|
10
10
|
as?: keyof React.JSX.IntrinsicElements | undefined;
|
11
11
|
className?: import("../../types/global").ClassName;
|
12
12
|
attributes?: (import("../..").Attributes<keyof React.JSX.IntrinsicElements> & ((import("../..").Attributes<"button"> & Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "form" | "slot" | "style" | "title" | "disabled" | "key" | "value" | "hidden" | "color" | "content" | "children" | "className" | "ref" | "aria-orientation" | "role" | "suppressHydrationWarning" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dir" | "name" | "type" | "translate" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture"> & {
|
13
|
-
ref?:
|
13
|
+
ref?: import("../Actionable/Actionable.types").AttributesRef;
|
14
14
|
}) | undefined)) | undefined;
|
15
15
|
} & Pick<import("../View").ViewProps, "height"> & React.RefAttributes<HTMLElement>>;
|
16
16
|
export default Card;
|
@@ -12,7 +12,7 @@ declare const _default: {
|
|
12
12
|
as?: keyof React.JSX.IntrinsicElements | undefined;
|
13
13
|
className?: import("../../../types/global").ClassName;
|
14
14
|
attributes?: (import("../../../types/global").Attributes<keyof React.JSX.IntrinsicElements> & ((import("../../../types/global").Attributes<"button"> & Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "children" | "ref" | "style" | "form" | "slot" | "title" | "disabled" | "key" | "value" | "hidden" | "color" | "content" | "className" | "aria-orientation" | "role" | "suppressHydrationWarning" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dir" | "name" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "onToggle" | "type" | "id" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture"> & {
|
15
|
-
ref?:
|
15
|
+
ref?: import("../../Actionable/Actionable.types").AttributesRef;
|
16
16
|
}) | undefined)) | undefined;
|
17
17
|
} & Pick<import("../../View").ViewProps, "height"> & React.RefAttributes<HTMLElement>>;
|
18
18
|
parameters: {
|
@@ -14,7 +14,7 @@ declare const _default: {
|
|
14
14
|
as?: keyof React.JSX.IntrinsicElements | undefined;
|
15
15
|
className?: import("../../../types/global").ClassName;
|
16
16
|
attributes?: (import("../../../types/global").Attributes<keyof React.JSX.IntrinsicElements> & ((import("../../../types/global").Attributes<"button"> & Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "children" | "ref" | "style" | "form" | "slot" | "title" | "disabled" | "key" | "value" | "hidden" | "color" | "content" | "className" | "aria-orientation" | "role" | "suppressHydrationWarning" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dir" | "name" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "onToggle" | "type" | "id" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture"> & {
|
17
|
-
ref?:
|
17
|
+
ref?: import("../../Actionable/Actionable.types").AttributesRef;
|
18
18
|
}) | undefined)) | undefined;
|
19
19
|
} & Pick<import("../../View").ViewProps, "height"> & React.RefAttributes<HTMLElement>>;
|
20
20
|
parameters: {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { type ActionableRef } from "../Actionable";
|
2
|
-
declare const Link: import("react").ForwardRefExoticComponent<Pick<import("../Actionable").ActionableProps, "disabled" | "children" | "className" | "attributes" | "type" | "href" | "onClick" | "stopPropagation"> & {
|
2
|
+
declare const Link: import("react").ForwardRefExoticComponent<Pick<import("../Actionable").ActionableProps, "disabled" | "children" | "className" | "attributes" | "render" | "type" | "href" | "onClick" | "stopPropagation"> & {
|
3
3
|
icon?: import("../Icon").IconProps["svg"];
|
4
4
|
color?: "inherit" | "critical" | "primary" | "positive" | "warning";
|
5
5
|
variant?: "plain" | "underline";
|
@@ -5,9 +5,9 @@ import Actionable from "../Actionable/index.js";
|
|
5
5
|
import Icon from "../Icon/index.js";
|
6
6
|
import s from "./Link.module.css";
|
7
7
|
const Link = forwardRef((props, ref) => {
|
8
|
-
const { icon, disabled, href, color = "primary", variant = "underline", className, children, attributes, type, onClick, stopPropagation, } = props;
|
8
|
+
const { icon, disabled, href, color = "primary", variant = "underline", className, children, attributes, type, onClick, stopPropagation, render, } = props;
|
9
9
|
const rootClassNames = classNames(s.root, className, disabled && s["--disabled"], variant && s[`--variant-${variant}`], color && s[`--color-${color}`], icon && s["--with-icon"]);
|
10
|
-
return (_jsxs(Actionable, { href: href, disabled: disabled, className: rootClassNames, attributes: attributes, type: type, onClick: onClick, ref: ref, stopPropagation: stopPropagation, children: [icon && _jsx(Icon, { svg: icon }), children] }));
|
10
|
+
return (_jsxs(Actionable, { href: href, disabled: disabled, className: rootClassNames, attributes: attributes, type: type, onClick: onClick, ref: ref, stopPropagation: stopPropagation, render: render, children: [icon && _jsx(Icon, { svg: icon }), children] }));
|
11
11
|
});
|
12
12
|
Link.displayName = "Link";
|
13
13
|
export default Link;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ActionableProps } from "../Actionable";
|
2
2
|
import type { IconProps } from "../Icon";
|
3
|
-
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "stopPropagation"> & {
|
3
|
+
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "stopPropagation" | "render"> & {
|
4
4
|
/** Icon at the start position */
|
5
5
|
icon?: IconProps["svg"];
|
6
6
|
/** Link color, based on the color tokens
|
@@ -1,6 +1,6 @@
|
|
1
1
|
declare const _default: {
|
2
2
|
title: string;
|
3
|
-
component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "type" | "onClick" | "href" | "stopPropagation"> & {
|
3
|
+
component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "render" | "type" | "onClick" | "href" | "stopPropagation"> & {
|
4
4
|
icon?: import("../../Icon").IconProps["svg"];
|
5
5
|
color?: "inherit" | "critical" | "primary" | "positive" | "warning";
|
6
6
|
variant?: "plain" | "underline";
|
@@ -2,7 +2,7 @@ import { StoryObj } from "@storybook/react-vite";
|
|
2
2
|
import { fn } from "storybook/test";
|
3
3
|
declare const _default: {
|
4
4
|
title: string;
|
5
|
-
component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "type" | "onClick" | "href" | "stopPropagation"> & {
|
5
|
+
component: import("react").ForwardRefExoticComponent<Pick<import("../../Actionable").ActionableProps, "children" | "disabled" | "className" | "attributes" | "render" | "type" | "onClick" | "href" | "stopPropagation"> & {
|
6
6
|
icon?: import("../../Icon").IconProps["svg"];
|
7
7
|
color?: "inherit" | "critical" | "primary" | "positive" | "warning";
|
8
8
|
variant?: "plain" | "underline";
|
@@ -26,4 +26,5 @@ export declare const hrefOnClick: StoryObj<{
|
|
26
26
|
handleClick: ReturnType<typeof fn>;
|
27
27
|
}>;
|
28
28
|
export declare const disabled: StoryObj;
|
29
|
+
export declare const render: StoryObj;
|
29
30
|
export declare const className: StoryObj;
|
@@ -72,6 +72,15 @@ export const disabled = {
|
|
72
72
|
expect(el).toBeDisabled();
|
73
73
|
},
|
74
74
|
};
|
75
|
+
export const render = {
|
76
|
+
name: "render",
|
77
|
+
render: () => <Link render={(props) => <section {...props}/>}>Trigger</Link>,
|
78
|
+
play: async ({ canvas }) => {
|
79
|
+
const el = canvas.getByText("Trigger");
|
80
|
+
expect(el).toBeInTheDocument();
|
81
|
+
expect(el.tagName).toBe("SECTION");
|
82
|
+
},
|
83
|
+
};
|
75
84
|
export const className = {
|
76
85
|
name: "className, attributes",
|
77
86
|
render: () => (<div data-testid="root">
|
@@ -7,11 +7,11 @@ import View from "../View/index.js";
|
|
7
7
|
import MenuItemAligner from "./MenuItemAligner.js";
|
8
8
|
import s from "./MenuItem.module.css";
|
9
9
|
const MenuItem = forwardRef((props, ref) => {
|
10
|
-
const { icon, startSlot, endSlot, children, color = "primary", selected, highlighted, disabled, onClick, href, size = "medium", roundedCorners, stopPropagation, as, className, attributes, } = props;
|
10
|
+
const { icon, startSlot, endSlot, children, color = "primary", selected, highlighted, disabled, onClick, href, size = "medium", roundedCorners, stopPropagation, as, render, className, attributes, } = props;
|
11
11
|
const rootClassNames = classNames(s.root, className, responsiveClassNames(s, "--size", size), responsiveClassNames(s, "--rounded-corners", roundedCorners), color && s[`--color-${color}`], selected && s["--selected"], disabled && s["--disabled"], highlighted && s["--highlighted"]);
|
12
12
|
const gapSize = responsivePropDependency(size, (size) => (size === "large" ? 3 : 2));
|
13
13
|
const iconSize = responsivePropDependency(size, (size) => (size === "large" ? 5 : 4));
|
14
|
-
return (_jsx(Actionable, { disabled: disabled, className: rootClassNames, attributes: { ...attributes, "data-rs-aligner-target": true }, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, children: _jsxs(View, { direction: "row", gap: gapSize, align: "center", children: [icon && _jsx(Icon, { svg: icon, className: s.icon, size: iconSize }), !icon && startSlot, children && (_jsx(View.Item, { grow: true, className: s.content, children: children })), endSlot] }) }));
|
14
|
+
return (_jsx(Actionable, { disabled: disabled, className: rootClassNames, attributes: { ...attributes, "data-rs-aligner-target": true }, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, render: render, children: _jsxs(View, { direction: "row", gap: gapSize, align: "center", children: [icon && _jsx(Icon, { svg: icon, className: s.icon, size: iconSize }), !icon && startSlot, children && (_jsx(View.Item, { grow: true, className: s.content, children: children })), endSlot] }) }));
|
15
15
|
});
|
16
16
|
MenuItem.Aligner = MenuItemAligner;
|
17
17
|
MenuItem.displayName = "MenuItem";
|
@@ -3,7 +3,7 @@ import type { IconProps } from "../Icon";
|
|
3
3
|
import type { ActionableProps, ActionableRef } from "../Actionable";
|
4
4
|
import type * as G from "../../types/global";
|
5
5
|
export type Size = "small" | "medium" | "large";
|
6
|
-
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "as" | "stopPropagation"> & {
|
6
|
+
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "as" | "stopPropagation" | "render"> & {
|
7
7
|
/** Component color, based on the color tokens */
|
8
8
|
color?: "neutral" | "critical" | "primary";
|
9
9
|
/** Icon at the start position */
|
@@ -22,5 +22,6 @@ export declare const hrefOnClick: StoryObj<{
|
|
22
22
|
handleClick: ReturnType<typeof fn>;
|
23
23
|
}>;
|
24
24
|
export declare const disabled: StoryObj;
|
25
|
+
export declare const as: StoryObj;
|
25
26
|
export declare const className: StoryObj;
|
26
27
|
export declare const alignerClassName: StoryObj;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { userEvent, expect, fn } from "storybook/test";
|
2
2
|
import MenuItem from "../index.js";
|
3
|
+
import Example from "../../../utilities/storybook/Example.js";
|
3
4
|
export default {
|
4
5
|
title: "Components/MenuItem/tests",
|
5
6
|
component: MenuItem,
|
@@ -72,6 +73,21 @@ export const disabled = {
|
|
72
73
|
expect(el).toBeDisabled();
|
73
74
|
},
|
74
75
|
};
|
76
|
+
export const as = {
|
77
|
+
name: "as, render",
|
78
|
+
render: () => (<Example>
|
79
|
+
<Example.Item title="render, disabled">
|
80
|
+
<MenuItem disabled onClick={() => { }} render={(props) => <section {...props}/>} attributes={{ "data-testid": "render-el" }}>
|
81
|
+
Trigger
|
82
|
+
</MenuItem>
|
83
|
+
</Example.Item>
|
84
|
+
</Example>),
|
85
|
+
play: ({ canvas }) => {
|
86
|
+
const renderEl = canvas.getByTestId("render-el");
|
87
|
+
expect(renderEl.tagName).toBe("SECTION");
|
88
|
+
expect(renderEl).toHaveAttribute("aria-disabled", "true");
|
89
|
+
},
|
90
|
+
};
|
75
91
|
export const className = {
|
76
92
|
name: "className, attributes",
|
77
93
|
render: () => (<div data-testid="root">
|
@@ -166,6 +166,7 @@ export const containerRef = () => {
|
|
166
166
|
};
|
167
167
|
export const edgeCases = () => {
|
168
168
|
const menuModalToggle = useToggle();
|
169
|
+
const menuModalToggleInner = useToggle();
|
169
170
|
const scrollModalToggle = useToggle();
|
170
171
|
const inputRef = React.useRef(null);
|
171
172
|
return (<Example>
|
@@ -233,7 +234,11 @@ export const edgeCases = () => {
|
|
233
234
|
<DropdownMenu.Item>Item 2</DropdownMenu.Item>
|
234
235
|
</DropdownMenu.Content>
|
235
236
|
</DropdownMenu>
|
237
|
+
<Button onClick={menuModalToggleInner.activate}>Open dialog</Button>
|
236
238
|
<Button onClick={menuModalToggle.deactivate}>Close</Button>
|
239
|
+
<Modal active={menuModalToggleInner.active} onClose={menuModalToggleInner.deactivate}>
|
240
|
+
<Button onClick={menuModalToggleInner.deactivate}>Close</Button>
|
241
|
+
</Modal>
|
237
242
|
</View>
|
238
243
|
</Modal>
|
239
244
|
</Example.Item>
|
@@ -4,7 +4,6 @@
|
|
4
4
|
*/
|
5
5
|
import React from "react";
|
6
6
|
import useElementId from "../useElementId.js";
|
7
|
-
import { onNextFrame } from "../../utilities/animation.js";
|
8
7
|
let queue = {};
|
9
8
|
let latestId = null;
|
10
9
|
const removeFromQueue = (id) => {
|
@@ -28,19 +27,12 @@ const useIsDismissible = (args) => {
|
|
28
27
|
React.useEffect(() => {
|
29
28
|
if (!active)
|
30
29
|
return;
|
31
|
-
|
30
|
+
addToQueue(id, contentRef, triggerRef);
|
32
31
|
return () => removeFromQueue(id);
|
33
32
|
}, [active, id, contentRef, triggerRef]);
|
34
33
|
return React.useCallback(() => {
|
35
34
|
if (!active)
|
36
35
|
return true;
|
37
|
-
const latest = latestId ? queue[latestId] : undefined;
|
38
|
-
const latestTrigger = latest?.triggerRef?.current;
|
39
|
-
const prev = latest?.parentId ? queue[latest.parentId] : undefined;
|
40
|
-
const prevContent = prev?.contentRef.current;
|
41
|
-
// Don't block independently rendered components that are not nested in each other
|
42
|
-
if (!prevContent || !latestTrigger || !prevContent.contains(latestTrigger))
|
43
|
-
return true;
|
44
36
|
return latestId === id;
|
45
37
|
}, [id, active]);
|
46
38
|
};
|
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
|
+
"version": "3.8.0-canary.4",
|
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",
|
92
|
+
"release:canary": "pnpm build && yarn publish --tag canary && git push --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)",
|