oneslash-design-system 2.26.0 → 2.27.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/dist/cases/message-attachments.md +3 -0
- package/dist/cases/side-pane.md +1 -0
- package/dist/cases.json +4 -0
- package/dist/components/accordion.d.ts +6 -0
- package/dist/components/accordion.jsx +11 -4
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/appShell.jsx +5 -2
- package/dist/components/avatarStack.d.ts +3 -1
- package/dist/components/avatarStack.jsx +2 -2
- package/dist/components/codeBlock.d.ts +7 -2
- package/dist/components/codeBlock.jsx +5 -3
- package/dist/components/composer.d.ts +29 -0
- package/dist/components/composer.jsx +19 -5
- package/dist/components/dropZone.jsx +5 -64
- package/dist/components/fileChip.d.ts +9 -1
- package/dist/components/fileChip.jsx +16 -3
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +1 -0
- package/dist/components/image.d.ts +3 -1
- package/dist/components/image.jsx +3 -2
- package/dist/components/list.d.ts +15 -1
- package/dist/components/list.jsx +8 -3
- package/dist/components/menuItem.d.ts +22 -4
- package/dist/components/menuItem.jsx +16 -8
- package/dist/components/paragraph.d.ts +10 -3
- package/dist/components/paragraph.jsx +7 -5
- package/dist/components/popover.d.ts +32 -2
- package/dist/components/popover.jsx +72 -15
- package/dist/components/sharedStyles.d.ts +2 -0
- package/dist/components/sharedStyles.jsx +4 -0
- package/dist/components/sidePane.d.ts +20 -0
- package/dist/components/sidePane.jsx +4 -4
- package/dist/components/sourceCard.d.ts +6 -0
- package/dist/components/sourceCard.jsx +2 -2
- package/dist/components/textField.d.ts +6 -2
- package/dist/components/textField.jsx +9 -3
- package/dist/components/titleBar.d.ts +9 -2
- package/dist/components/titleBar.jsx +11 -7
- package/dist/internal/dropZone.d.ts +23 -0
- package/dist/internal/dropZone.js +71 -1
- package/dist/stories/Accordion.stories.d.ts +1 -0
- package/dist/stories/Accordion.stories.jsx +18 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +14 -0
- package/dist/stories/AppShell.stories.d.ts +1 -0
- package/dist/stories/AppShell.stories.jsx +17 -0
- package/dist/stories/AvatarStack.stories.d.ts +1 -0
- package/dist/stories/AvatarStack.stories.jsx +4 -0
- package/dist/stories/CodeBlock.stories.d.ts +1 -0
- package/dist/stories/CodeBlock.stories.jsx +11 -0
- package/dist/stories/Composer.stories.d.ts +4 -0
- package/dist/stories/Composer.stories.jsx +41 -0
- package/dist/stories/FileChip.stories.d.ts +2 -0
- package/dist/stories/FileChip.stories.jsx +27 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +4 -0
- package/dist/stories/Image.stories.d.ts +1 -0
- package/dist/stories/Image.stories.jsx +4 -0
- package/dist/stories/List.stories.d.ts +2 -0
- package/dist/stories/List.stories.jsx +6 -0
- package/dist/stories/MenuItem.stories.d.ts +4 -0
- package/dist/stories/MenuItem.stories.jsx +63 -0
- package/dist/stories/Paragraph.stories.d.ts +7 -0
- package/dist/stories/Paragraph.stories.jsx +30 -0
- package/dist/stories/Popover.stories.d.ts +4 -0
- package/dist/stories/Popover.stories.jsx +123 -0
- package/dist/stories/SidePane.stories.d.ts +2 -0
- package/dist/stories/SidePane.stories.jsx +34 -1
- package/dist/stories/SourceCard.stories.d.ts +1 -0
- package/dist/stories/SourceCard.stories.jsx +17 -1
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +19 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// Checks a set of files against what a DropZone accepts
|
|
1
|
+
// Checks a set of files against what a DropZone accepts (pure, so it can be tested without a browser), and
|
|
2
|
+
// the drag state DropZone and Composer share.
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
4
|
function matchesType(file, pattern) {
|
|
3
5
|
var p = pattern.trim().toLowerCase();
|
|
4
6
|
if (!p)
|
|
@@ -40,3 +42,71 @@ export function checkFiles(files, _a) {
|
|
|
40
42
|
});
|
|
41
43
|
return { accepted: accepted, rejected: rejected };
|
|
42
44
|
}
|
|
45
|
+
var hasFiles = function (e) { var _a, _b; return Array.from((_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) !== null && _b !== void 0 ? _b : []).includes('Files'); };
|
|
46
|
+
/**
|
|
47
|
+
* The handlers for a box that takes dropped files, and whether a file drag is over it. Only a drag whose types
|
|
48
|
+
* include 'Files' is handled, so a text drag stays native. The state clears on drag leave, on drop and when the
|
|
49
|
+
* drag is cancelled.
|
|
50
|
+
*/
|
|
51
|
+
export function useFileDrag(_a) {
|
|
52
|
+
var off = _a.off, ignore = _a.ignore, onFiles = _a.onFiles;
|
|
53
|
+
// Entering a child fires dragenter before the parent's dragleave, so count them to keep the state steady
|
|
54
|
+
var depth = useRef(0);
|
|
55
|
+
var _b = useState(false), dragging = _b[0], setDragging = _b[1];
|
|
56
|
+
var stop = function () {
|
|
57
|
+
depth.current = 0;
|
|
58
|
+
setDragging(false);
|
|
59
|
+
};
|
|
60
|
+
// A drag cancelled with Escape, or dropped somewhere else, may not reach the box: clear on the page's events
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
if (!dragging)
|
|
63
|
+
return;
|
|
64
|
+
var onKey = function (e) {
|
|
65
|
+
if (e.key === 'Escape')
|
|
66
|
+
stop();
|
|
67
|
+
};
|
|
68
|
+
window.addEventListener('drop', stop);
|
|
69
|
+
window.addEventListener('dragend', stop);
|
|
70
|
+
window.addEventListener('keydown', onKey);
|
|
71
|
+
return function () {
|
|
72
|
+
window.removeEventListener('drop', stop);
|
|
73
|
+
window.removeEventListener('dragend', stop);
|
|
74
|
+
window.removeEventListener('keydown', onKey);
|
|
75
|
+
};
|
|
76
|
+
}, [dragging]);
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
if (off || ignore)
|
|
79
|
+
stop();
|
|
80
|
+
}, [off, ignore]);
|
|
81
|
+
var onDragEnter = function (e) {
|
|
82
|
+
if (off || !hasFiles(e))
|
|
83
|
+
return;
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
if (ignore)
|
|
86
|
+
return;
|
|
87
|
+
depth.current += 1;
|
|
88
|
+
setDragging(true);
|
|
89
|
+
};
|
|
90
|
+
var onDragOver = function (e) {
|
|
91
|
+
if (off || !hasFiles(e))
|
|
92
|
+
return;
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
};
|
|
95
|
+
var onDragLeave = function (e) {
|
|
96
|
+
if (off || !hasFiles(e))
|
|
97
|
+
return;
|
|
98
|
+
depth.current = Math.max(0, depth.current - 1);
|
|
99
|
+
if (depth.current === 0)
|
|
100
|
+
setDragging(false);
|
|
101
|
+
};
|
|
102
|
+
var onDrop = function (e) {
|
|
103
|
+
if (off || !hasFiles(e))
|
|
104
|
+
return;
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
stop();
|
|
107
|
+
if (ignore)
|
|
108
|
+
return;
|
|
109
|
+
onFiles(Array.from(e.dataTransfer.files));
|
|
110
|
+
};
|
|
111
|
+
return { dragging: dragging, dropProps: { onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop } };
|
|
112
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useLayoutEffect } from "react";
|
|
1
|
+
import React, { useLayoutEffect, useState } from "react";
|
|
2
2
|
import Accordion from "../components/accordion";
|
|
3
3
|
import SiteHeader from "../components/siteHeader";
|
|
4
4
|
import Paragraph from "../components/paragraph";
|
|
@@ -91,3 +91,20 @@ export var DeepLinkScrolledOn = {
|
|
|
91
91
|
decorators: [],
|
|
92
92
|
render: function () { return <Page jump scrolledOn/>; },
|
|
93
93
|
};
|
|
94
|
+
var reviews = [
|
|
95
|
+
{ id: "security", title: "Security", preview: "The new route checks the session but not the workspace, so any signed-in person can read it.", text: "Check that the person belongs to the workspace before you return the file." },
|
|
96
|
+
{ id: "design", title: "Design", preview: "The empty state has no action. Add a Button that starts the first export.", text: "Add a Button that starts the first export." },
|
|
97
|
+
];
|
|
98
|
+
// A closed item shows one line of its panel; an open item leaves secondTitle off
|
|
99
|
+
function PreviewBox() {
|
|
100
|
+
var _a = useState(["security"]), open = _a[0], setOpen = _a[1];
|
|
101
|
+
return (<Accordion id="accordion-second-title" open={open} onOpenChange={setOpen} items={reviews.map(function (review) { return ({
|
|
102
|
+
id: review.id,
|
|
103
|
+
title: review.title,
|
|
104
|
+
secondTitle: open.includes(review.id) ? undefined : review.preview,
|
|
105
|
+
content: <Paragraph>{review.text}</Paragraph>,
|
|
106
|
+
}); })}/>);
|
|
107
|
+
}
|
|
108
|
+
export var SecondTitle = {
|
|
109
|
+
render: function () { return <PreviewBox />; },
|
|
110
|
+
};
|
|
@@ -15,6 +15,7 @@ var meta = {
|
|
|
15
15
|
},
|
|
16
16
|
message: { control: "text" },
|
|
17
17
|
showCloseButton: { control: "boolean" },
|
|
18
|
+
closeLabel: { control: "text" },
|
|
18
19
|
},
|
|
19
20
|
};
|
|
20
21
|
export default meta;
|
|
@@ -135,3 +136,16 @@ export var InlineAllTypes = {
|
|
|
135
136
|
<Alert type="default" message="Default alert message" variant="inline" showCloseButton/>
|
|
136
137
|
</div>); },
|
|
137
138
|
};
|
|
139
|
+
// The close button says what it turns off, not "Dismiss"
|
|
140
|
+
export var CloseLabel = {
|
|
141
|
+
render: function (args) { return <InlineAlertWrapper {...args}/>; },
|
|
142
|
+
args: {
|
|
143
|
+
type: "info",
|
|
144
|
+
message: "Plan mode",
|
|
145
|
+
secondMessage: "The next request needs a plan first",
|
|
146
|
+
variant: "inline",
|
|
147
|
+
showCloseButton: true,
|
|
148
|
+
closeLabel: "Turn off plan mode",
|
|
149
|
+
autoDismiss: false,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
@@ -135,3 +135,20 @@ export var Probe = {
|
|
|
135
135
|
tags: ["!dev", "!autodocs", "test-only"],
|
|
136
136
|
render: function () { return <ShellBox resizable/>; },
|
|
137
137
|
};
|
|
138
|
+
// For tests/interactions.spec.ts only: a disabled item leaves the phone menu open; the item under it closes it
|
|
139
|
+
function DisabledChoiceBox() {
|
|
140
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
141
|
+
return (<Bleed>
|
|
142
|
+
<AppShell title="Inbox" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={<Navigation aria-label="Main">
|
|
143
|
+
<MenuItem size="small" iconName="Loader" label="Creating…" disabled/>
|
|
144
|
+
<MenuItem size="small" iconName="Globe" label="Website" href="#website" disabled/>
|
|
145
|
+
<MenuItem size="small" iconName="Inbox" label="Inbox" onClick={function () { }}/>
|
|
146
|
+
</Navigation>}>
|
|
147
|
+
<TitleBar title="Inbox"/>
|
|
148
|
+
</AppShell>
|
|
149
|
+
</Bleed>);
|
|
150
|
+
}
|
|
151
|
+
export var DisabledChoice = {
|
|
152
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
153
|
+
render: function () { return <DisabledChoiceBox />; },
|
|
154
|
+
};
|
|
@@ -5,6 +5,7 @@ export default meta;
|
|
|
5
5
|
type Story = StoryObj<typeof CodeBlock>;
|
|
6
6
|
export declare const Short: Story;
|
|
7
7
|
export declare const LongLine: Story;
|
|
8
|
+
export declare const MaxRows: Story;
|
|
8
9
|
interface ProbeArgs {
|
|
9
10
|
clipboard: "refuse" | "missing" | "accept";
|
|
10
11
|
wrap?: boolean;
|
|
@@ -7,6 +7,7 @@ var meta = {
|
|
|
7
7
|
label: { control: "text" },
|
|
8
8
|
language: { control: "text" },
|
|
9
9
|
wrap: { control: "boolean" },
|
|
10
|
+
maxRows: { control: "number" },
|
|
10
11
|
copyLabel: { control: "text" },
|
|
11
12
|
copiedLabel: { control: "text" },
|
|
12
13
|
},
|
|
@@ -27,6 +28,16 @@ export var LongLine = {
|
|
|
27
28
|
tags: ["phone"],
|
|
28
29
|
args: { id: "codeblock-long-line", label: "Install command", language: "bash", code: longLine },
|
|
29
30
|
};
|
|
31
|
+
// Five lines tall; the rest scrolls inside the block, and Copy takes all of it
|
|
32
|
+
export var MaxRows = {
|
|
33
|
+
args: {
|
|
34
|
+
id: "codeblock-max-rows",
|
|
35
|
+
label: "Tool result",
|
|
36
|
+
wrap: true,
|
|
37
|
+
maxRows: 5,
|
|
38
|
+
code: Array.from({ length: 12 }, function (_, i) { return "Row ".concat(i + 1, ": read file ").concat(i + 1, " of 12"); }).join("\n"),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
30
41
|
// For tests/interactions.spec.ts: a 300-character line, and a stubbed navigator.clipboard that refuses, is missing or accepts.
|
|
31
42
|
// `writes` counts what reached the clipboard.
|
|
32
43
|
function ProbeBox(_a) {
|
|
@@ -10,6 +10,10 @@ export declare const WithAttachments: Story;
|
|
|
10
10
|
export declare const Stop: Story;
|
|
11
11
|
export declare const Disabled: Story;
|
|
12
12
|
export declare const WithActions: Story;
|
|
13
|
+
export declare const DropAndPaste: Story;
|
|
14
|
+
export declare const DropProbe: StoryObj<{
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}>;
|
|
13
17
|
interface ProbeArgs {
|
|
14
18
|
submitOnEnter: boolean;
|
|
15
19
|
canSubmit?: boolean;
|
|
@@ -22,6 +22,7 @@ import React, { useRef, useState } from "react";
|
|
|
22
22
|
import Composer from "../components/composer";
|
|
23
23
|
import IconButton from "../components/iconButton";
|
|
24
24
|
import Tag from "../components/tag";
|
|
25
|
+
import FileChip from "../components/fileChip";
|
|
25
26
|
import Alert from "../components/alert";
|
|
26
27
|
import Button from "../components/button";
|
|
27
28
|
import Paragraph from "../components/paragraph";
|
|
@@ -70,6 +71,46 @@ export var WithActions = {
|
|
|
70
71
|
<Button size="small" type="primary" state="enabled" label="Save"/>
|
|
71
72
|
</Cluster>}/>); },
|
|
72
73
|
};
|
|
74
|
+
// Dropped and pasted files wait in `above`. The attach button stays, for people who do not drag.
|
|
75
|
+
// A live line says what was added: the Composer announces nothing.
|
|
76
|
+
function DropBox(_a) {
|
|
77
|
+
var _b = _a.disabled, disabled = _b === void 0 ? false : _b;
|
|
78
|
+
var _c = useState([]), files = _c[0], setFiles = _c[1];
|
|
79
|
+
var _d = useState(0), drops = _d[0], setDrops = _d[1];
|
|
80
|
+
var _e = useState(""), said = _e[0], setSaid = _e[1];
|
|
81
|
+
var add = function (added) {
|
|
82
|
+
setFiles(function (list) { return __spreadArray(__spreadArray([], list, true), added.map(function (f) { return f.name; }), true); });
|
|
83
|
+
setSaid(added.length === 1 ? "".concat(added[0].name, " added") : "".concat(added.length, " files added"));
|
|
84
|
+
};
|
|
85
|
+
return (<>
|
|
86
|
+
<Box disabled={disabled} tools={tools} spellCheck lang="en" onDropFiles={function (added) {
|
|
87
|
+
setDrops(function (n) { return n + 1; });
|
|
88
|
+
add(added);
|
|
89
|
+
}} onPaste={function (e) {
|
|
90
|
+
var pasted = Array.from(e.clipboardData.files);
|
|
91
|
+
if (pasted.length === 0)
|
|
92
|
+
return; // Text pastes as usual
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
add(pasted);
|
|
95
|
+
}} above={files.length > 0 ? (<Cluster gap="small">
|
|
96
|
+
{files.map(function (name, i) { return (<FileChip key={"".concat(name, "-").concat(i)} name={name} onRemove={function () { return setFiles(function (list) { return list.filter(function (_, n) { return n !== i; }); }); }}/>); })}
|
|
97
|
+
</Cluster>) : undefined}/>
|
|
98
|
+
<Paragraph size="caption" tone="secondary">
|
|
99
|
+
<span role="status">{said}</span>
|
|
100
|
+
</Paragraph>
|
|
101
|
+
<output data-testid="drops" hidden>
|
|
102
|
+
{drops}
|
|
103
|
+
</output>
|
|
104
|
+
</>);
|
|
105
|
+
}
|
|
106
|
+
// Drag a file from the desktop onto the box: its border turns dashed. Dropped and pasted files are added.
|
|
107
|
+
export var DropAndPaste = { render: function () { return <DropBox />; } };
|
|
108
|
+
export var DropProbe = {
|
|
109
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
110
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
111
|
+
args: { disabled: false },
|
|
112
|
+
render: function (args) { return <DropBox disabled={args.disabled}/>; },
|
|
113
|
+
};
|
|
73
114
|
// For tests/interactions.spec.ts: counts submits and stops on screen. Its args are set from the URL.
|
|
74
115
|
function ProbeBox(_a) {
|
|
75
116
|
var submitOnEnter = _a.submitOnEnter, canSubmit = _a.canSubmit, disabled = _a.disabled, sending = _a.sending, stop = _a.stop, withActions = _a.withActions, takeEnter = _a.takeEnter, withAbove = _a.withAbove;
|
|
@@ -4,4 +4,6 @@ declare const meta: Meta<typeof FileChip>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof FileChip>;
|
|
6
6
|
export declare const States: Story;
|
|
7
|
+
export declare const Thumbnails: Story;
|
|
7
8
|
export declare const RemoveProbe: Story;
|
|
9
|
+
export declare const ThumbnailProbe: Story;
|
|
@@ -21,6 +21,16 @@ export var States = {
|
|
|
21
21
|
<FileChip name="a-very-long-file-name-that-would-stretch-the-row-if-it-were-not-cut-at-the-end-of-the-line.pdf" kind="PDF" meta="9 MB" onRemove={function () { }}/>
|
|
22
22
|
</Stack>); },
|
|
23
23
|
};
|
|
24
|
+
var picture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E";
|
|
25
|
+
// A thumbnail takes the place of `kind`. Uploading and failed keep their marks; a picture that does not load shows `kind`.
|
|
26
|
+
export var Thumbnails = {
|
|
27
|
+
render: function () { return (<Stack gap="medium" align="start">
|
|
28
|
+
<FileChip name="hills.png" kind="PNG" thumbnail={picture} meta="2.1 MB" onRemove={function () { }}/>
|
|
29
|
+
<FileChip name="uploading.png" kind="PNG" thumbnail={picture} meta="Uploading" state="uploading" onRemove={function () { }}/>
|
|
30
|
+
<FileChip name="too-large.png" kind="PNG" thumbnail={picture} meta="Upload failed" state="failed" onRemove={function () { }}/>
|
|
31
|
+
<FileChip name="broken.png" kind="PNG" thumbnail="data:image/png;base64,bm90IGFuIGltYWdl" meta="4 KB" onRemove={function () { }}/>
|
|
32
|
+
</Stack>); },
|
|
33
|
+
};
|
|
24
34
|
// For tests/interactions.spec.ts: the remove button calls onRemove, which drops the chip here
|
|
25
35
|
function RemoveProbeBox() {
|
|
26
36
|
var _a = useState(["plan.pdf", "notes.txt"]), names = _a[0], setNames = _a[1];
|
|
@@ -33,3 +43,20 @@ export var RemoveProbe = {
|
|
|
33
43
|
tags: ["!dev", "!autodocs", "test-only"],
|
|
34
44
|
render: function () { return <RemoveProbeBox />; },
|
|
35
45
|
};
|
|
46
|
+
// For tests/interactions.spec.ts only: the buttons change one chip's thumbnail URL
|
|
47
|
+
function ThumbnailProbeBox() {
|
|
48
|
+
var _a = useState("data:image/png;base64,bm90IGFuIGltYWdl"), url = _a[0], setUrl = _a[1];
|
|
49
|
+
return (<>
|
|
50
|
+
<FileChip name="hills.png" kind="PNG" thumbnail={url}/>
|
|
51
|
+
<button type="button" onClick={function () { return setUrl(picture); }}>
|
|
52
|
+
Good URL
|
|
53
|
+
</button>
|
|
54
|
+
<button type="button" onClick={function () { return setUrl("data:image/png;base64,bm90IGFuIGltYWdl"); }}>
|
|
55
|
+
Broken URL
|
|
56
|
+
</button>
|
|
57
|
+
</>);
|
|
58
|
+
}
|
|
59
|
+
export var ThumbnailProbe = {
|
|
60
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
61
|
+
render: function () { return <ThumbnailProbeBox />; },
|
|
62
|
+
};
|
|
@@ -25,3 +25,7 @@ export var RefProbe = {
|
|
|
25
25
|
tags: ["!dev", "!autodocs", "test-only"],
|
|
26
26
|
render: function () { return <RefProbeView />; },
|
|
27
27
|
};
|
|
28
|
+
// `size="subtitle2"` is the smallest heading. The element still follows `level`.
|
|
29
|
+
export var Subtitle2 = {
|
|
30
|
+
args: { level: 4, size: "subtitle2", children: "Notification rules" },
|
|
31
|
+
};
|
|
@@ -16,3 +16,7 @@ export var Default = {
|
|
|
16
16
|
export var Decoration = {
|
|
17
17
|
args: { src: src, alt: "", width: 160, height: 90, fit: "cover" },
|
|
18
18
|
};
|
|
19
|
+
// `className` adds spacing and corners to the <img> itself, so it needs no wrapper
|
|
20
|
+
export var ClassName = {
|
|
21
|
+
args: { src: src, alt: "A grey rectangle with round corners", width: 320, height: 180, className: "my-2 block max-w-full rounded-control" },
|
|
22
|
+
};
|
|
@@ -25,3 +25,9 @@ export var None = { args: { marker: "none" } };
|
|
|
25
25
|
export var Dot = { args: { marker: "dot" } };
|
|
26
26
|
export var Number = { args: { marker: "number" } };
|
|
27
27
|
export var SecondaryDot = { args: { marker: "dot", tone: "secondary" } };
|
|
28
|
+
// `start` keeps the numbers of a list that was split in two
|
|
29
|
+
export var NumberStart = { args: { marker: "number", start: 4 } };
|
|
30
|
+
// `itemProps` gives an item an id, so an in-page link can point at it, or classes
|
|
31
|
+
export var ItemProps = {
|
|
32
|
+
args: { marker: "number", itemProps: [{ id: "note-1" }, undefined, { className: "list-none" }] },
|
|
33
|
+
};
|
|
@@ -14,3 +14,7 @@ export declare const WithRightAction: Story;
|
|
|
14
14
|
export declare const WithCustomIcon: Story;
|
|
15
15
|
export declare const Danger: Story;
|
|
16
16
|
export declare const SelectedWithTags: Story;
|
|
17
|
+
export declare const Levels: Story;
|
|
18
|
+
export declare const Disabled: Story;
|
|
19
|
+
export declare const ClickProbe: Story;
|
|
20
|
+
export declare const NavigableDisabledProbe: Story;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React from "react";
|
|
2
13
|
import MenuItem from "../components/menuItem";
|
|
14
|
+
import Menu from "../components/menu";
|
|
3
15
|
import IconButton from "../components/iconButton";
|
|
4
16
|
var meta = {
|
|
5
17
|
title: "Components/MenuItem",
|
|
@@ -104,3 +116,54 @@ export var SelectedWithTags = {
|
|
|
104
116
|
<MenuItem label="Offline" iconName="Users" tag={{ label: "Away", variant: "dot", color: "warning" }}/>
|
|
105
117
|
</div>); },
|
|
106
118
|
};
|
|
119
|
+
// level 2 is a place inside a place; level 3 is a place inside a level 2 place. Nothing goes deeper.
|
|
120
|
+
export var Levels = {
|
|
121
|
+
render: function () { return (<div style={{ width: 280 }} className="flex flex-col gap-1">
|
|
122
|
+
<MenuItem size="small" iconName="Building2" label="Acme" role="button" aria-expanded iconRight="ChevronDown"/>
|
|
123
|
+
<MenuItem size="small" iconName="Folder" label="Website" level={2}/>
|
|
124
|
+
<MenuItem size="small" iconName="File" label="Launch checklist" level={3}/>
|
|
125
|
+
<MenuItem size="small" iconName="File" label="Pricing page" level={3} href="/pricing" isSelected aria-current="page"/>
|
|
126
|
+
</div>); },
|
|
127
|
+
};
|
|
128
|
+
// A disabled row is dimmed and cannot be chosen. A selected one keeps its fill. With href there is no link.
|
|
129
|
+
export var Disabled = {
|
|
130
|
+
render: function () { return (<div style={{ width: 280 }} className="flex flex-col gap-1">
|
|
131
|
+
<MenuItem size="small" iconName="Plus" label="Creating…" role="button" disabled/>
|
|
132
|
+
<MenuItem size="small" iconName="Inbox" label="Inbox" isSelected disabled tag={{ label: "3", variant: "textOnly" }}/>
|
|
133
|
+
<MenuItem size="small" iconName="Globe" label="Website" href="/website" disabled/>
|
|
134
|
+
<MenuItem size="small" iconName="Trash2" label="Delete" color="danger" disabled/>
|
|
135
|
+
<MenuItem size="small" iconName="Copy" label="Duplicate"/>
|
|
136
|
+
</div>); },
|
|
137
|
+
};
|
|
138
|
+
// For tests/interactions.spec.ts: counts how often each row's onClick runs. The link goes to a hash,
|
|
139
|
+
// and 'Stay here' cancels its navigation.
|
|
140
|
+
function ClickProbeRows() {
|
|
141
|
+
var _a = React.useState({ link: 0, stay: 0, row: 0, off: 0 }), counts = _a[0], setCounts = _a[1];
|
|
142
|
+
var count = function (key) { return setCounts(function (c) {
|
|
143
|
+
var _a;
|
|
144
|
+
return (__assign(__assign({}, c), (_a = {}, _a[key] = c[key] + 1, _a)));
|
|
145
|
+
}); };
|
|
146
|
+
return (<div style={{ width: 280 }} className="flex flex-col gap-1">
|
|
147
|
+
<MenuItem size="small" label="Profile" href="#profile" onClick={function () { return count("link"); }}/>
|
|
148
|
+
<MenuItem size="small" label="Stay here" href="#stay" onClick={function (e) {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
count("stay");
|
|
151
|
+
}}/>
|
|
152
|
+
<MenuItem size="small" label="Rename" onClick={function () { return count("row"); }}/>
|
|
153
|
+
<MenuItem size="small" label="Creating" href="#creating" disabled onClick={function () { return count("off"); }}/>
|
|
154
|
+
<output>{"link ".concat(counts.link, ", stay ").concat(counts.stay, ", row ").concat(counts.row, ", disabled ").concat(counts.off)}</output>
|
|
155
|
+
</div>);
|
|
156
|
+
}
|
|
157
|
+
export var ClickProbe = {
|
|
158
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
159
|
+
render: function () { return <ClickProbeRows />; },
|
|
160
|
+
};
|
|
161
|
+
// For tests/interactions.spec.ts only: a navigable Menu's keys skip a disabled row
|
|
162
|
+
export var NavigableDisabledProbe = {
|
|
163
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
164
|
+
render: function () { return (<Menu navigable aria-label="Row actions" width="240px">
|
|
165
|
+
<MenuItem size="small" label="Open" role="menuitem"/>
|
|
166
|
+
<MenuItem size="small" label="Rename" role="menuitem" disabled/>
|
|
167
|
+
<MenuItem size="small" label="Delete" role="menuitem"/>
|
|
168
|
+
</Menu>); },
|
|
169
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Paragraph from "../components/paragraph";
|
|
3
|
+
declare const meta: Meta<typeof Paragraph>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Paragraph>;
|
|
6
|
+
export declare const InheritTone: Story;
|
|
7
|
+
export declare const Status: Story;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import Paragraph from "../components/paragraph";
|
|
3
|
+
import Button from "../components/button";
|
|
4
|
+
import { Stack } from "../components/layout";
|
|
5
|
+
var meta = {
|
|
6
|
+
title: "Components/Paragraph",
|
|
7
|
+
component: Paragraph,
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
// `tone="inherit"` takes the parent's color, here the secondary color of the block around it
|
|
11
|
+
export var InheritTone = {
|
|
12
|
+
render: function () { return (<blockquote className="text-fg-secondary">
|
|
13
|
+
<Paragraph tone="inherit" size="body2" measure="none">
|
|
14
|
+
This line takes the color of the quote around it.
|
|
15
|
+
</Paragraph>
|
|
16
|
+
</blockquote>); },
|
|
17
|
+
};
|
|
18
|
+
function StatusView() {
|
|
19
|
+
var _a = useState(0), done = _a[0], setDone = _a[1];
|
|
20
|
+
return (<Stack gap="medium" align="start">
|
|
21
|
+
<Paragraph role="status" tone="secondary" size="body2" measure="none">
|
|
22
|
+
{done} of 3 pages imported.
|
|
23
|
+
</Paragraph>
|
|
24
|
+
<Button size="medium" type="secondary" state="enabled" label="Import next page" onClickButton={function () { return setDone(function (n) { return Math.min(3, n + 1); }); }}/>
|
|
25
|
+
</Stack>);
|
|
26
|
+
}
|
|
27
|
+
// `role="status"` reads the new text aloud when it changes. The line is on the page before the first change.
|
|
28
|
+
export var Status = {
|
|
29
|
+
render: function () { return <StatusView />; },
|
|
30
|
+
};
|
|
@@ -8,3 +8,7 @@ export declare const WithMenu: Story;
|
|
|
8
8
|
export declare const ClearAnchorProbe: Story;
|
|
9
9
|
export declare const NamesProbe: Story;
|
|
10
10
|
export declare const LabelledByProbe: Story;
|
|
11
|
+
export declare const VirtualAnchorOnSelection: Story;
|
|
12
|
+
export declare const TabWithin: Story;
|
|
13
|
+
export declare const InModalProbe: Story;
|
|
14
|
+
export declare const TabWithinControlsProbe: Story;
|