oneslash-design-system 2.26.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +56 -12
- 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
|
@@ -3,6 +3,9 @@ import Popover from "../components/popover";
|
|
|
3
3
|
import Button from "../components/button";
|
|
4
4
|
import Menu from "../components/menu";
|
|
5
5
|
import MenuItem from "../components/menuItem";
|
|
6
|
+
import TextField from "../components/textField";
|
|
7
|
+
import Modal from "../components/modal";
|
|
8
|
+
import RadioGroup from "../components/radioGroup";
|
|
6
9
|
var meta = {
|
|
7
10
|
title: "Components/Popover",
|
|
8
11
|
component: Popover,
|
|
@@ -95,3 +98,123 @@ export var LabelledByProbe = {
|
|
|
95
98
|
tags: ["!dev", "!autodocs", "test-only"],
|
|
96
99
|
render: function () { return <NamesProbeBox labelled/>; },
|
|
97
100
|
};
|
|
101
|
+
// `anchorEl` can be a VirtualAnchor instead of an element: here the saved Range of a text selection, so a
|
|
102
|
+
// Quote button sits under the selected words. The anchor is held in state, so it stays one object.
|
|
103
|
+
var SelectionQuoteBox = function () {
|
|
104
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
105
|
+
var _b = useState(""), quote = _b[0], setQuote = _b[1];
|
|
106
|
+
var textRef = useRef(null);
|
|
107
|
+
var readSelection = function () {
|
|
108
|
+
var selection = window.getSelection();
|
|
109
|
+
var body = textRef.current;
|
|
110
|
+
if (!selection || selection.isCollapsed || !body || !body.contains(selection.anchorNode))
|
|
111
|
+
return;
|
|
112
|
+
var range = selection.getRangeAt(0).cloneRange();
|
|
113
|
+
setAnchor({ getBoundingClientRect: function () { return range.getBoundingClientRect(); }, contextElement: body });
|
|
114
|
+
};
|
|
115
|
+
return (<div style={{ padding: "100px" }}>
|
|
116
|
+
<p ref={textRef} className="text-body1 text-fg-primary" onMouseUp={readSelection} onKeyUp={readSelection}>
|
|
117
|
+
Select some of these words. Acme ships the new home page on Friday.
|
|
118
|
+
</p>
|
|
119
|
+
{quote && <p className="text-body2 text-fg-secondary">Quoted: {quote}</p>}
|
|
120
|
+
<Popover open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} aria-label="Selected text">
|
|
121
|
+
{/* preventDefault on mousedown keeps the selection while the button is pressed */}
|
|
122
|
+
<div onMouseDown={function (event) { return event.preventDefault(); }}>
|
|
123
|
+
<Button size="small" type="textOnly" state="enabled" label="Quote" onClickButton={function () {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
setQuote((_b = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "");
|
|
126
|
+
setAnchor(null);
|
|
127
|
+
}}/>
|
|
128
|
+
</div>
|
|
129
|
+
</Popover>
|
|
130
|
+
</div>);
|
|
131
|
+
};
|
|
132
|
+
export var VirtualAnchorOnSelection = {
|
|
133
|
+
render: function () { return <SelectionQuoteBox />; },
|
|
134
|
+
};
|
|
135
|
+
// `tabWithin` with `returnFocus`: Tab moves through the form, and only leaving it at either end closes it
|
|
136
|
+
var TabWithinForm = function () {
|
|
137
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
138
|
+
var _b = useState(""), title = _b[0], setTitle = _b[1];
|
|
139
|
+
return (<div style={{ padding: "100px" }}>
|
|
140
|
+
<Button size="medium" type="secondary" state="enabled" label="Create Task" aria-haspopup="dialog" aria-expanded={anchor !== null} onClickButton={function (event) { return setAnchor(anchor ? null : event.currentTarget); }}/>
|
|
141
|
+
<Popover open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} returnFocus tabWithin aria-label="Create task">
|
|
142
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "8px", width: "240px" }}>
|
|
143
|
+
<TextField id="tab-within-title" label="Title" value={title} onChange={function (event) { return setTitle(event.target.value); }} autoFocus/>
|
|
144
|
+
<div style={{ display: "flex", justifyContent: "flex-end", gap: "8px" }}>
|
|
145
|
+
<Button size="small" type="textOnly" state="enabled" label="Cancel" onClickButton={function () { return setAnchor(null); }}/>
|
|
146
|
+
<Button size="small" type="primary" state="enabled" label="Create" onClickButton={function () { return setAnchor(null); }}/>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</Popover>
|
|
150
|
+
</div>);
|
|
151
|
+
};
|
|
152
|
+
export var TabWithin = {
|
|
153
|
+
render: function () { return <TabWithinForm />; },
|
|
154
|
+
};
|
|
155
|
+
// A virtual anchor and a `tabWithin` form inside a Modal: Escape closes only the Popover, and the Modal's
|
|
156
|
+
// Tab trap does not take focus from it
|
|
157
|
+
var InModalProbeBox = function () {
|
|
158
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
159
|
+
return (<>
|
|
160
|
+
<Modal isOpen title="Probe" onClose={function () { }}>
|
|
161
|
+
<button type="button" onClick={function (event) {
|
|
162
|
+
var button = event.currentTarget;
|
|
163
|
+
setAnchor({ getBoundingClientRect: function () { return button.getBoundingClientRect(); }, contextElement: button });
|
|
164
|
+
}}>
|
|
165
|
+
Open virtual
|
|
166
|
+
</button>
|
|
167
|
+
<TabWithinForm />
|
|
168
|
+
</Modal>
|
|
169
|
+
<Popover open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} aria-label="Virtual">
|
|
170
|
+
<button type="button">Inside virtual</button>
|
|
171
|
+
</Popover>
|
|
172
|
+
</>);
|
|
173
|
+
};
|
|
174
|
+
export var InModalProbe = {
|
|
175
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
176
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
177
|
+
render: function () { return <InModalProbeBox />; },
|
|
178
|
+
};
|
|
179
|
+
// Controls whose tab order a plain selector gets wrong: radio groups, a summary and editable text
|
|
180
|
+
var TabWithinControlsBox = function () {
|
|
181
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
182
|
+
var _b = useState("medium"), priority = _b[0], setPriority = _b[1];
|
|
183
|
+
var _c = useState(""), owner = _c[0], setOwner = _c[1];
|
|
184
|
+
return (<div style={{ padding: "40px" }}>
|
|
185
|
+
<button type="button" onClick={function (event) { return setAnchor(event.currentTarget); }}>
|
|
186
|
+
Open controls
|
|
187
|
+
</button>
|
|
188
|
+
<Popover open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} returnFocus tabWithin aria-label="Controls">
|
|
189
|
+
<button type="button">Before</button>
|
|
190
|
+
<RadioGroup aria-label="Priority" options={[
|
|
191
|
+
{ label: "Low", value: "low" },
|
|
192
|
+
{ label: "Medium", value: "medium" },
|
|
193
|
+
{ label: "High", value: "high" },
|
|
194
|
+
]} selectedValue={priority} onChange={setPriority}/>
|
|
195
|
+
<details>
|
|
196
|
+
<summary>More</summary>
|
|
197
|
+
<button type="button">Hidden until open</button>
|
|
198
|
+
</details>
|
|
199
|
+
{/* Tab skips these two, so tabWithin must too */}
|
|
200
|
+
<div ref={function (element) { return element === null || element === void 0 ? void 0 : element.setAttribute("inert", ""); }}>
|
|
201
|
+
<button type="button">Inert</button>
|
|
202
|
+
</div>
|
|
203
|
+
<div style={{ contentVisibility: "hidden" }}>
|
|
204
|
+
<button type="button">Not drawn</button>
|
|
205
|
+
</div>
|
|
206
|
+
<div contentEditable suppressContentEditableWarning role="textbox" aria-label="Notes">
|
|
207
|
+
Notes
|
|
208
|
+
</div>
|
|
209
|
+
<RadioGroup aria-label="Owner" options={[
|
|
210
|
+
{ label: "Ann", value: "ann" },
|
|
211
|
+
{ label: "Ben", value: "ben" },
|
|
212
|
+
]} selectedValue={owner} onChange={setOwner}/>
|
|
213
|
+
</Popover>
|
|
214
|
+
</div>);
|
|
215
|
+
};
|
|
216
|
+
export var TabWithinControlsProbe = {
|
|
217
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
218
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
219
|
+
render: function () { return <TabWithinControlsBox />; },
|
|
220
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
2
|
import SidePane from "../components/sidePane";
|
|
3
3
|
import IconButton from "../components/iconButton";
|
|
4
|
+
import Button from "../components/button";
|
|
4
5
|
import Paragraph from "../components/paragraph";
|
|
5
6
|
import TitleBar from "../components/titleBar";
|
|
6
7
|
var meta = {
|
|
@@ -35,3 +36,35 @@ export var Resizable = {
|
|
|
35
36
|
tags: ["shell"],
|
|
36
37
|
render: function () { return <ResizableBox />; },
|
|
37
38
|
};
|
|
39
|
+
// `back` goes one step up inside the pane, and `meta` is one line under the title. The pane keeps its name.
|
|
40
|
+
function BackAndMetaBox() {
|
|
41
|
+
var _a = useState("history"), step = _a[0], setStep = _a[1];
|
|
42
|
+
var pane = useRef(null);
|
|
43
|
+
var history = step === "history";
|
|
44
|
+
return (<div style={{ margin: "-1rem", display: "flex", justifyContent: "flex-end", height: "100dvh" }}>
|
|
45
|
+
<SidePane ref={pane} title={history ? "History" : "Plan"} onClose={function () { }} width={448} back={history ? (<Button size="small" type="textOnly" state="enabled" label="Back to Plan" decoIcon="ChevronLeft" onClickButton={function () {
|
|
46
|
+
setStep("plan");
|
|
47
|
+
// The button goes away, so the title takes focus once it shows the new step
|
|
48
|
+
requestAnimationFrame(function () { var _a; return (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
49
|
+
}}/>) : undefined} meta="2 of 5 done">
|
|
50
|
+
<Paragraph measure="none">{history ? "Dana Lee changed the second step." : "Ship the new home page on Friday."}</Paragraph>
|
|
51
|
+
</SidePane>
|
|
52
|
+
</div>);
|
|
53
|
+
}
|
|
54
|
+
export var BackAndMeta = {
|
|
55
|
+
tags: ["shell"],
|
|
56
|
+
render: function () { return <BackAndMetaBox />; },
|
|
57
|
+
};
|
|
58
|
+
// `padding="none"`: for content that draws its own edges, such as code or a full-width list
|
|
59
|
+
export var NoPadding = {
|
|
60
|
+
tags: ["shell"],
|
|
61
|
+
render: function () { return (<div style={{ margin: "-1rem", display: "flex", justifyContent: "flex-end", height: "100dvh" }}>
|
|
62
|
+
<SidePane title="Documents" onClose={function () { }} width={448} padding="none">
|
|
63
|
+
<ul>
|
|
64
|
+
{["Launch plan", "Brief", "Release notes"].map(function (name) { return (<li key={name} className="px-4 py-3">
|
|
65
|
+
{name}
|
|
66
|
+
</li>); })}
|
|
67
|
+
</ul>
|
|
68
|
+
</SidePane>
|
|
69
|
+
</div>); },
|
|
70
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import { CheckSquare, FileText, MessageSquare, Paperclip } from "lucide-react";
|
|
3
3
|
import SourceCard from "../components/sourceCard";
|
|
4
4
|
import { Grid as CardGrid } from "../components/layout";
|
|
@@ -31,3 +31,19 @@ export var WithAction = {
|
|
|
31
31
|
<SourceCard icon={CheckSquare} title="Write the release notes" meta="Task" action="Show" onClick={function () { }}/>
|
|
32
32
|
</CardGrid>); },
|
|
33
33
|
};
|
|
34
|
+
// The page hears the link's click. This story keeps the page here with preventDefault; without it the link opens.
|
|
35
|
+
function LinkClickBox() {
|
|
36
|
+
var _a = useState(0), clicks = _a[0], setClicks = _a[1];
|
|
37
|
+
return (<div>
|
|
38
|
+
<SourceCard icon={FileText} title="Pricing notes" meta="Knowledge base" href="/docs/pricing" onLinkClick={function (event) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
setClicks(function (n) { return n + 1; });
|
|
41
|
+
}}/>
|
|
42
|
+
<p className="text-body2 text-fg-primary">
|
|
43
|
+
Clicks: <output data-testid="link-clicks">{clicks}</output>
|
|
44
|
+
</p>
|
|
45
|
+
</div>);
|
|
46
|
+
}
|
|
47
|
+
export var LinkClick = {
|
|
48
|
+
render: function () { return <LinkClickBox />; },
|
|
49
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import TextField from "../components/textField";
|
|
3
|
+
import Button from "../components/button";
|
|
4
|
+
import { Stack } from "../components/layout";
|
|
3
5
|
var meta = {
|
|
4
6
|
title: "Components/TextField",
|
|
5
7
|
component: TextField,
|
|
@@ -204,3 +206,20 @@ export var SearchWithName = {
|
|
|
204
206
|
size: "medium",
|
|
205
207
|
},
|
|
206
208
|
};
|
|
209
|
+
function RefFocusView(_a) {
|
|
210
|
+
var multiline = _a.multiline;
|
|
211
|
+
var ref = React.useRef(null);
|
|
212
|
+
var _b = useState("Roadmap"), value = _b[0], setValue = _b[1];
|
|
213
|
+
return (<Stack gap="medium" align="start">
|
|
214
|
+
<TextField ref={ref} id="ref-textfield" label="Search pages" value={value} multiline={multiline} onChange={function (e) { return setValue(e.target.value); }}/>
|
|
215
|
+
<Button size="medium" type="secondary" state="enabled" label="Clear search" onClickButton={function () {
|
|
216
|
+
var _a;
|
|
217
|
+
setValue("");
|
|
218
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
219
|
+
}}/>
|
|
220
|
+
</Stack>);
|
|
221
|
+
}
|
|
222
|
+
// A ref reaches the <input>, so a button can clear the field and put focus back in it
|
|
223
|
+
export var RefFocus = {
|
|
224
|
+
render: function () { return <RefFocusView />; },
|
|
225
|
+
};
|
|
@@ -52,3 +52,16 @@ export var WithMeta = {
|
|
|
52
52
|
</>}/>
|
|
53
53
|
</div>); },
|
|
54
54
|
};
|
|
55
|
+
// actionsWrap follows the column, not the window: in the narrow column the actions take their own line,
|
|
56
|
+
// because beside them the title would have less than 15rem. In the wide one they stay on the title's line.
|
|
57
|
+
export var ActionsWrap = {
|
|
58
|
+
render: function () { return (<div style={{ display: "flex", flexDirection: "column", gap: "32px" }}>
|
|
59
|
+
{[360, 720].map(function (width) { return (<div key={width} style={{ width: width }} className="border border-misc-divider p-2">
|
|
60
|
+
<TitleBar title="Launch checklist" level={2} actionsWrap meta={<span>Due Nov 20, 2026</span>} actions={<>
|
|
61
|
+
<Button size="small" type="secondary" state="enabled" label="In progress"/>
|
|
62
|
+
<Button size="small" type="primary" state="enabled" label="Share"/>
|
|
63
|
+
{more}
|
|
64
|
+
</>}/>
|
|
65
|
+
</div>); })}
|
|
66
|
+
</div>); },
|
|
67
|
+
};
|