oneslash-design-system 2.16.0 → 2.17.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/README.md +1 -1
- package/dist/DESIGN.md +26 -3
- package/dist/cases/accept-invite/signed-in.jsx +1 -1
- package/dist/cases/accept-invite/signed-out.jsx +1 -1
- package/dist/cases/accept-invite.md +2 -2
- package/dist/cases/agent-options/cards.d.ts +1 -0
- package/dist/cases/agent-options/cards.jsx +91 -0
- package/dist/cases/agent-options.md +168 -0
- package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
- package/dist/cases/agent-pending-reply/steps.jsx +149 -0
- package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
- package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
- package/dist/cases/agent-pending-reply.md +432 -0
- package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
- package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
- package/dist/cases/agent-plan-proposal.md +656 -0
- package/dist/cases/agent-question/choices.d.ts +1 -0
- package/dist/cases/agent-question/choices.jsx +132 -0
- package/dist/cases/agent-question/free-text.d.ts +1 -0
- package/dist/cases/agent-question/free-text.jsx +81 -0
- package/dist/cases/agent-question.md +338 -0
- package/dist/cases/agent-shows-sources.md +2 -2
- package/dist/cases/artifact-card/card.d.ts +1 -0
- package/dist/cases/artifact-card/card.jsx +45 -0
- package/dist/cases/artifact-card.md +103 -0
- package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
- package/dist/cases/composer-limit/notice.d.ts +1 -0
- package/dist/cases/composer-limit/notice.jsx +84 -0
- package/dist/cases/composer-limit.md +286 -0
- package/dist/cases/conversation-starters/chips.d.ts +1 -0
- package/dist/cases/conversation-starters/chips.jsx +69 -0
- package/dist/cases/conversation-starters/none.d.ts +1 -0
- package/dist/cases/conversation-starters/none.jsx +45 -0
- package/dist/cases/conversation-starters.md +208 -0
- package/dist/cases/mention-list/in-composer.d.ts +1 -0
- package/dist/cases/mention-list/in-composer.jsx +169 -0
- package/dist/cases/mention-list.md +252 -0
- package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
- package/dist/cases/message-actions/menu.d.ts +1 -0
- package/dist/cases/message-actions/menu.jsx +258 -0
- package/dist/cases/message-actions.md +651 -0
- package/dist/cases/message-attachments/in-composer.d.ts +1 -0
- package/dist/cases/message-attachments/in-composer.jsx +134 -0
- package/dist/cases/message-attachments/in-message.d.ts +1 -0
- package/dist/cases/message-attachments/in-message.jsx +46 -0
- package/dist/cases/message-attachments.md +310 -0
- package/dist/cases/message-composer/plain.d.ts +1 -0
- package/dist/cases/message-composer/plain.jsx +57 -0
- package/dist/cases/message-composer/with-tools.d.ts +1 -0
- package/dist/cases/message-composer/with-tools.jsx +182 -0
- package/dist/cases/message-composer.md +356 -0
- package/dist/cases/message-edit/in-place.d.ts +1 -0
- package/dist/cases/message-edit/in-place.jsx +99 -0
- package/dist/cases/message-edit.md +179 -0
- package/dist/cases/message-reactions/chips.d.ts +1 -0
- package/dist/cases/message-reactions/chips.jsx +118 -0
- package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
- package/dist/cases/message-reactions/quick-pick.jsx +155 -0
- package/dist/cases/message-reactions.md +371 -0
- package/dist/cases/message-row/grouped.d.ts +1 -0
- package/dist/cases/message-row/grouped.jsx +56 -0
- package/dist/cases/message-row/person-and-agent.d.ts +1 -0
- package/dist/cases/message-row/person-and-agent.jsx +41 -0
- package/dist/cases/message-row.md +189 -0
- package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
- package/dist/cases/reply-feedback/thumbs.jsx +191 -0
- package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
- package/dist/cases/reply-feedback/with-reason.jsx +221 -0
- package/dist/cases/reply-feedback.md +552 -0
- package/dist/cases/reply-sources/cards.d.ts +1 -0
- package/dist/cases/reply-sources/cards.jsx +83 -0
- package/dist/cases/reply-sources/tag-only.d.ts +1 -0
- package/dist/cases/reply-sources/tag-only.jsx +45 -0
- package/dist/cases/reply-sources.md +247 -0
- package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
- package/dist/cases/slash-command-list/in-composer.jsx +162 -0
- package/dist/cases/slash-command-list.md +247 -0
- package/dist/cases/success-feedback.md +1 -1
- package/dist/cases/typing-and-status/line.d.ts +1 -0
- package/dist/cases/typing-and-status/line.jsx +50 -0
- package/dist/cases/typing-and-status.md +96 -0
- package/dist/cases.json +1276 -14
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +9 -7
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/iconButton.d.ts +3 -3
- package/dist/components/iconButton.jsx +9 -7
- package/dist/components/layout.d.ts +7 -1
- package/dist/components/layout.jsx +5 -2
- package/dist/components/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +9 -1
- package/dist/components/menuItem.jsx +5 -4
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/paragraph.d.ts +3 -1
- package/dist/components/paragraph.jsx +2 -2
- package/dist/components/popover.d.ts +7 -1
- package/dist/components/popover.jsx +35 -9
- package/dist/components/radioGroup.d.ts +8 -1
- package/dist/components/radioGroup.jsx +19 -8
- package/dist/components/sourceCard.d.ts +23 -0
- package/dist/components/sourceCard.jsx +56 -0
- package/dist/components/stepList.d.ts +17 -0
- package/dist/components/stepList.jsx +79 -0
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textarea.jsx +3 -18
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/internal/autoGrow.d.ts +11 -0
- package/dist/internal/autoGrow.js +28 -0
- package/dist/internal/composer.d.ts +16 -0
- package/dist/internal/composer.js +18 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/native-mapping.json +32 -1
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +17 -1
- package/dist/stories/Cases.generated.stories.d.ts +30 -0
- package/dist/stories/Cases.generated.stories.jsx +60 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- package/dist/stories/Menu.stories.d.ts +4 -0
- package/dist/stories/Menu.stories.jsx +46 -1
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/Message.stories.d.ts +10 -0
- package/dist/stories/Message.stories.jsx +77 -0
- package/dist/stories/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +2 -0
- package/dist/stories/RadioGroup.stories.jsx +40 -1
- package/dist/stories/SourceCard.stories.d.ts +8 -0
- package/dist/stories/SourceCard.stories.jsx +33 -0
- package/dist/stories/StepList.stories.d.ts +8 -0
- package/dist/stories/StepList.stories.jsx +35 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +4 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Menu's pure helper, kept out of the public API (index.ts and the package exports do not reach internal/)
|
|
2
|
+
// The index of the item a key moves focus to in a navigable Menu, or `current` when the key does
|
|
3
|
+
// nothing. ArrowDown and ArrowUp wrap; with no item focused yet (`current` -1) they go to the first
|
|
4
|
+
// and the last. Home and End go to the first and the last. A single character moves to the next
|
|
5
|
+
// item after `current` whose label starts with it, ignoring case and wrapping.
|
|
6
|
+
export function nextIndex(_a) {
|
|
7
|
+
var _b;
|
|
8
|
+
var key = _a.key, current = _a.current, count = _a.count, labels = _a.labels;
|
|
9
|
+
if (count === 0)
|
|
10
|
+
return current;
|
|
11
|
+
switch (key) {
|
|
12
|
+
case 'ArrowDown':
|
|
13
|
+
return current < 0 ? 0 : (current + 1) % count;
|
|
14
|
+
case 'ArrowUp':
|
|
15
|
+
return current < 0 ? count - 1 : (current - 1 + count) % count;
|
|
16
|
+
case 'Home':
|
|
17
|
+
return 0;
|
|
18
|
+
case 'End':
|
|
19
|
+
return count - 1;
|
|
20
|
+
}
|
|
21
|
+
// Space activates an item, so it is not a character to search for
|
|
22
|
+
if (key.length !== 1 || key.trim() === '')
|
|
23
|
+
return current;
|
|
24
|
+
var letter = key.toLowerCase();
|
|
25
|
+
for (var step = 1; step <= count; step++) {
|
|
26
|
+
var index = (current + step + count) % count;
|
|
27
|
+
if (((_b = labels[index]) !== null && _b !== void 0 ? _b : '').trim().toLowerCase().startsWith(letter))
|
|
28
|
+
return index;
|
|
29
|
+
}
|
|
30
|
+
return current;
|
|
31
|
+
}
|
package/dist/native-mapping.json
CHANGED
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"swiftui": "`Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS)",
|
|
23
23
|
"compose": "`Checkbox`"
|
|
24
24
|
},
|
|
25
|
+
{
|
|
26
|
+
"ods": "composer",
|
|
27
|
+
"swiftui": "`TextField(_:text:axis: .vertical)` with `.lineLimit(1...6)` over a toolbar `HStack` of the tool `Button`s and a send `Button`",
|
|
28
|
+
"compose": "`OutlinedTextField` with `maxLines = 6` over a `Row` of the tool `IconButton`s and a send `IconButton`",
|
|
29
|
+
"note": "On iPhone and Android, Return adds a line and the send button sends. While an agent works, send becomes Stop."
|
|
30
|
+
},
|
|
25
31
|
{
|
|
26
32
|
"ods": "emptyBox",
|
|
27
33
|
"swiftui": "`ContentUnavailableView`",
|
|
@@ -40,6 +46,12 @@
|
|
|
40
46
|
"compose": "Not applicable: web page pattern",
|
|
41
47
|
"note": "In an app screen: an `Image` with a caption `Text` in the caption text style."
|
|
42
48
|
},
|
|
49
|
+
{
|
|
50
|
+
"ods": "fileChip",
|
|
51
|
+
"swiftui": "A capsule `Label` (`.labelStyle(.titleAndIcon)`) with the file icon, the name and size, and a `Button` with `xmark.circle.fill` to remove it",
|
|
52
|
+
"compose": "An `InputChip` with a `trailingIcon` that removes it",
|
|
53
|
+
"note": "An uploading chip gets a `ProgressView`; a failed one an alert symbol, not color alone. Say the state in the VoiceOver / TalkBack label."
|
|
54
|
+
},
|
|
43
55
|
{
|
|
44
56
|
"ods": "form",
|
|
45
57
|
"swiftui": "`Form`",
|
|
@@ -110,6 +122,12 @@
|
|
|
110
122
|
"compose": "`DropdownMenuItem`",
|
|
111
123
|
"note": "In a sidebar: a `List` row / `NavigationDrawerItem`."
|
|
112
124
|
},
|
|
125
|
+
{
|
|
126
|
+
"ods": "message",
|
|
127
|
+
"swiftui": "An `HStack` with `ODSAvatar` and a `VStack` of the header and the body",
|
|
128
|
+
"compose": "A `Row` with `OdsAvatar` and a `Column` of the header and the body",
|
|
129
|
+
"note": "SwiftUI and Compose have no message row. Mark an agent with `ODSTag` / `OdsTag` after its name."
|
|
130
|
+
},
|
|
113
131
|
{
|
|
114
132
|
"ods": "modal",
|
|
115
133
|
"swiftui": "`.sheet` or `.alert`",
|
|
@@ -153,7 +171,8 @@
|
|
|
153
171
|
{
|
|
154
172
|
"ods": "radioGroup",
|
|
155
173
|
"swiftui": "`Picker` (`.inline` on iOS, `.radioGroup` on macOS)",
|
|
156
|
-
"compose": "`RadioButton`s in a `Column` with `Modifier.selectableGroup()`"
|
|
174
|
+
"compose": "`RadioButton`s in a `Column` with `Modifier.selectableGroup()`",
|
|
175
|
+
"note": "`variant=\"card\"`: each option is a bordered card with the radio in it, a `Picker` with custom rows on iOS / selectable `Card`s with a `RadioButton` in a `selectableGroup` on Android."
|
|
157
176
|
},
|
|
158
177
|
{
|
|
159
178
|
"ods": "sectionIntro",
|
|
@@ -166,6 +185,18 @@
|
|
|
166
185
|
"swiftui": "`Picker` or `Menu`",
|
|
167
186
|
"compose": "`ExposedDropdownMenuBox`"
|
|
168
187
|
},
|
|
188
|
+
{
|
|
189
|
+
"ods": "sourceCard",
|
|
190
|
+
"swiftui": "`Link` or `Button` with a `Label` (icon, title) and the meta as a secondary line",
|
|
191
|
+
"compose": "A `Card` with `onClick`, or a `ListItem` with a leading `Icon`",
|
|
192
|
+
"note": "With no destination it is a plain `Label`, not a button."
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"ods": "stepList",
|
|
196
|
+
"swiftui": "A `List` of `Label`s with an SF Symbol per status (`circle`, `checkmark.circle.fill`, `xmark.circle.fill`, `minus.circle`); `ProgressView` for the running one",
|
|
197
|
+
"compose": "A `Column` of `ListItem`s with an `Icon` per status; `CircularProgressIndicator` for the running one",
|
|
198
|
+
"note": "Give each row a status text for VoiceOver / TalkBack, not color alone."
|
|
199
|
+
},
|
|
169
200
|
{
|
|
170
201
|
"ods": "surface",
|
|
171
202
|
"swiftui": "Not applicable: web page pattern",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
2
|
import { ChevronDown, ChevronRight, ExternalLink, Plus, Star } from "lucide-react";
|
|
3
3
|
import Button from "../components/button";
|
|
4
4
|
var meta = {
|
|
@@ -199,3 +199,19 @@ export var FullWidth = {
|
|
|
199
199
|
<Button size="medium" type="primary" state="enabled" label="Link, fits content" href="/gallery"/>
|
|
200
200
|
</div>); },
|
|
201
201
|
};
|
|
202
|
+
// For tests/interactions.spec.ts: the ref reaches the <button> and the link, so focus can be moved to them
|
|
203
|
+
function FocusFromOutsideDemo() {
|
|
204
|
+
var buttonRef = useRef(null);
|
|
205
|
+
var linkRef = useRef(null);
|
|
206
|
+
return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
207
|
+
<Button ref={buttonRef} size="small" type="secondary" state="enabled" label="Stop"/>
|
|
208
|
+
<Button ref={linkRef} size="small" type="tertiary" state="enabled" label="New Project" href="/new"/>
|
|
209
|
+
<Button size="small" type="secondary" state="enabled" label="Focus Button" onClickButton={function () { var _a; return (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}/>
|
|
210
|
+
<Button size="small" type="secondary" state="enabled" label="Focus Link" onClickButton={function () { var _a; return (_a = linkRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}/>
|
|
211
|
+
</div>);
|
|
212
|
+
}
|
|
213
|
+
export var FocusFromOutside = {
|
|
214
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
215
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
216
|
+
render: function () { return <FocusFromOutsideDemo />; },
|
|
217
|
+
};
|
|
@@ -4,12 +4,24 @@ export default meta;
|
|
|
4
4
|
type Story = StoryObj;
|
|
5
5
|
export declare const AcceptInvite_SignedOut: Story;
|
|
6
6
|
export declare const AcceptInvite_SignedIn: Story;
|
|
7
|
+
export declare const AgentOptions_Cards: Story;
|
|
8
|
+
export declare const AgentPendingReply_Steps: Story;
|
|
9
|
+
export declare const AgentPendingReply_Streaming: Story;
|
|
10
|
+
export declare const AgentPlanProposal_Steps: Story;
|
|
11
|
+
export declare const AgentPlanProposal_Changes: Story;
|
|
12
|
+
export declare const AgentQuestion_Choices: Story;
|
|
13
|
+
export declare const AgentQuestion_FreeText: Story;
|
|
14
|
+
export declare const ArtifactCard_Card: Story;
|
|
7
15
|
export declare const AuthGateLoading_Spinner: Story;
|
|
8
16
|
export declare const AuthGateLoading_SpinnerWithLine: Story;
|
|
9
17
|
export declare const CheckYourEmail_Page: Story;
|
|
10
18
|
export declare const CheckYourEmail_AlertOnLogin: Story;
|
|
19
|
+
export declare const ComposerLimit_Notice: Story;
|
|
20
|
+
export declare const ComposerLimit_NoticeWithAction: Story;
|
|
11
21
|
export declare const ConfirmDestructiveAction_Modal: Story;
|
|
12
22
|
export declare const ConfirmDestructiveAction_Inline: Story;
|
|
23
|
+
export declare const ConversationStarters_Chips: Story;
|
|
24
|
+
export declare const ConversationStarters_None: Story;
|
|
13
25
|
export declare const CreateModal_Quick: Story;
|
|
14
26
|
export declare const CreateModal_WithSettings: Story;
|
|
15
27
|
export declare const DeviceLogin_ProviderFirst: Story;
|
|
@@ -39,12 +51,28 @@ export declare const LoginPage_Centered: Story;
|
|
|
39
51
|
export declare const LoginPage_Split: Story;
|
|
40
52
|
export declare const LoginPage_ProviderFirst: Story;
|
|
41
53
|
export declare const LoginPage_EmailOnly: Story;
|
|
54
|
+
export declare const MentionList_InComposer: Story;
|
|
55
|
+
export declare const MessageActions_HoverToolbar: Story;
|
|
56
|
+
export declare const MessageActions_Menu: Story;
|
|
57
|
+
export declare const MessageAttachments_InComposer: Story;
|
|
58
|
+
export declare const MessageAttachments_InMessage: Story;
|
|
59
|
+
export declare const MessageComposer_Plain: Story;
|
|
60
|
+
export declare const MessageComposer_WithTools: Story;
|
|
61
|
+
export declare const MessageEdit_InPlace: Story;
|
|
62
|
+
export declare const MessageReactions_Chips: Story;
|
|
63
|
+
export declare const MessageReactions_QuickPick: Story;
|
|
64
|
+
export declare const MessageRow_PersonAndAgent: Story;
|
|
65
|
+
export declare const MessageRow_Grouped: Story;
|
|
42
66
|
export declare const NotFoundPage_FullPage: Story;
|
|
43
67
|
export declare const NotFoundPage_InShell: Story;
|
|
44
68
|
export declare const OauthConsent_Simple: Story;
|
|
45
69
|
export declare const OauthConsent_WithScope: Story;
|
|
46
70
|
export declare const Rename_Modal: Story;
|
|
47
71
|
export declare const Rename_Inline: Story;
|
|
72
|
+
export declare const ReplyFeedback_Thumbs: Story;
|
|
73
|
+
export declare const ReplyFeedback_WithReason: Story;
|
|
74
|
+
export declare const ReplySources_Cards: Story;
|
|
75
|
+
export declare const ReplySources_TagOnly: Story;
|
|
48
76
|
export declare const RouteLoading_FullScreen: Story;
|
|
49
77
|
export declare const RouteLoading_Region: Story;
|
|
50
78
|
export declare const SetNewPassword_Form: Story;
|
|
@@ -52,8 +80,10 @@ export declare const SetNewPassword_InvalidLink: Story;
|
|
|
52
80
|
export declare const SignUpPage_Centered: Story;
|
|
53
81
|
export declare const SignUpPage_Split: Story;
|
|
54
82
|
export declare const SignUpPage_ProviderFirst: Story;
|
|
83
|
+
export declare const SlashCommandList_InComposer: Story;
|
|
55
84
|
export declare const TypeToConfirm_Modal: Story;
|
|
56
85
|
export declare const TypeToConfirm_Inline: Story;
|
|
86
|
+
export declare const TypingAndStatus_Line: Story;
|
|
57
87
|
export declare const UnsavedChangesGuard_SaveOrDiscard: Story;
|
|
58
88
|
export declare const UnsavedChangesGuard_Discard: Story;
|
|
59
89
|
export declare const UpgradePrompt_Modal: Story;
|
|
@@ -2,12 +2,24 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import AcceptInvite_SignedOutExample from "../cases/accept-invite/signed-out";
|
|
4
4
|
import AcceptInvite_SignedInExample from "../cases/accept-invite/signed-in";
|
|
5
|
+
import AgentOptions_CardsExample from "../cases/agent-options/cards";
|
|
6
|
+
import AgentPendingReply_StepsExample from "../cases/agent-pending-reply/steps";
|
|
7
|
+
import AgentPendingReply_StreamingExample from "../cases/agent-pending-reply/streaming";
|
|
8
|
+
import AgentPlanProposal_StepsExample from "../cases/agent-plan-proposal/steps";
|
|
9
|
+
import AgentPlanProposal_ChangesExample from "../cases/agent-plan-proposal/changes";
|
|
10
|
+
import AgentQuestion_ChoicesExample from "../cases/agent-question/choices";
|
|
11
|
+
import AgentQuestion_FreeTextExample from "../cases/agent-question/free-text";
|
|
12
|
+
import ArtifactCard_CardExample from "../cases/artifact-card/card";
|
|
5
13
|
import AuthGateLoading_SpinnerExample from "../cases/auth-gate-loading/spinner";
|
|
6
14
|
import AuthGateLoading_SpinnerWithLineExample from "../cases/auth-gate-loading/spinner-with-line";
|
|
7
15
|
import CheckYourEmail_PageExample from "../cases/check-your-email/page";
|
|
8
16
|
import CheckYourEmail_AlertOnLoginExample from "../cases/check-your-email/alert-on-login";
|
|
17
|
+
import ComposerLimit_NoticeExample from "../cases/composer-limit/notice";
|
|
18
|
+
import ComposerLimit_NoticeWithActionExample from "../cases/composer-limit/notice-with-action";
|
|
9
19
|
import ConfirmDestructiveAction_ModalExample from "../cases/confirm-destructive-action/modal";
|
|
10
20
|
import ConfirmDestructiveAction_InlineExample from "../cases/confirm-destructive-action/inline";
|
|
21
|
+
import ConversationStarters_ChipsExample from "../cases/conversation-starters/chips";
|
|
22
|
+
import ConversationStarters_NoneExample from "../cases/conversation-starters/none";
|
|
11
23
|
import CreateModal_QuickExample from "../cases/create-modal/quick";
|
|
12
24
|
import CreateModal_WithSettingsExample from "../cases/create-modal/with-settings";
|
|
13
25
|
import DeviceLogin_ProviderFirstExample from "../cases/device-login/provider-first";
|
|
@@ -37,12 +49,28 @@ import LoginPage_CenteredExample from "../cases/login-page/centered";
|
|
|
37
49
|
import LoginPage_SplitExample from "../cases/login-page/split";
|
|
38
50
|
import LoginPage_ProviderFirstExample from "../cases/login-page/provider-first";
|
|
39
51
|
import LoginPage_EmailOnlyExample from "../cases/login-page/email-only";
|
|
52
|
+
import MentionList_InComposerExample from "../cases/mention-list/in-composer";
|
|
53
|
+
import MessageActions_HoverToolbarExample from "../cases/message-actions/hover-toolbar";
|
|
54
|
+
import MessageActions_MenuExample from "../cases/message-actions/menu";
|
|
55
|
+
import MessageAttachments_InComposerExample from "../cases/message-attachments/in-composer";
|
|
56
|
+
import MessageAttachments_InMessageExample from "../cases/message-attachments/in-message";
|
|
57
|
+
import MessageComposer_PlainExample from "../cases/message-composer/plain";
|
|
58
|
+
import MessageComposer_WithToolsExample from "../cases/message-composer/with-tools";
|
|
59
|
+
import MessageEdit_InPlaceExample from "../cases/message-edit/in-place";
|
|
60
|
+
import MessageReactions_ChipsExample from "../cases/message-reactions/chips";
|
|
61
|
+
import MessageReactions_QuickPickExample from "../cases/message-reactions/quick-pick";
|
|
62
|
+
import MessageRow_PersonAndAgentExample from "../cases/message-row/person-and-agent";
|
|
63
|
+
import MessageRow_GroupedExample from "../cases/message-row/grouped";
|
|
40
64
|
import NotFoundPage_FullPageExample from "../cases/not-found-page/full-page";
|
|
41
65
|
import NotFoundPage_InShellExample from "../cases/not-found-page/in-shell";
|
|
42
66
|
import OauthConsent_SimpleExample from "../cases/oauth-consent/simple";
|
|
43
67
|
import OauthConsent_WithScopeExample from "../cases/oauth-consent/with-scope";
|
|
44
68
|
import Rename_ModalExample from "../cases/rename/modal";
|
|
45
69
|
import Rename_InlineExample from "../cases/rename/inline";
|
|
70
|
+
import ReplyFeedback_ThumbsExample from "../cases/reply-feedback/thumbs";
|
|
71
|
+
import ReplyFeedback_WithReasonExample from "../cases/reply-feedback/with-reason";
|
|
72
|
+
import ReplySources_CardsExample from "../cases/reply-sources/cards";
|
|
73
|
+
import ReplySources_TagOnlyExample from "../cases/reply-sources/tag-only";
|
|
46
74
|
import RouteLoading_FullScreenExample from "../cases/route-loading/full-screen";
|
|
47
75
|
import RouteLoading_RegionExample from "../cases/route-loading/region";
|
|
48
76
|
import SetNewPassword_FormExample from "../cases/set-new-password/form";
|
|
@@ -50,8 +78,10 @@ import SetNewPassword_InvalidLinkExample from "../cases/set-new-password/invalid
|
|
|
50
78
|
import SignUpPage_CenteredExample from "../cases/sign-up-page/centered";
|
|
51
79
|
import SignUpPage_SplitExample from "../cases/sign-up-page/split";
|
|
52
80
|
import SignUpPage_ProviderFirstExample from "../cases/sign-up-page/provider-first";
|
|
81
|
+
import SlashCommandList_InComposerExample from "../cases/slash-command-list/in-composer";
|
|
53
82
|
import TypeToConfirm_ModalExample from "../cases/type-to-confirm/modal";
|
|
54
83
|
import TypeToConfirm_InlineExample from "../cases/type-to-confirm/inline";
|
|
84
|
+
import TypingAndStatus_LineExample from "../cases/typing-and-status/line";
|
|
55
85
|
import UnsavedChangesGuard_SaveOrDiscardExample from "../cases/unsaved-changes-guard/save-or-discard";
|
|
56
86
|
import UnsavedChangesGuard_DiscardExample from "../cases/unsaved-changes-guard/discard";
|
|
57
87
|
import UpgradePrompt_ModalExample from "../cases/upgrade-prompt/modal";
|
|
@@ -60,12 +90,24 @@ var meta = { title: "Cases" };
|
|
|
60
90
|
export default meta;
|
|
61
91
|
export var AcceptInvite_SignedOut = { render: function () { return <AcceptInvite_SignedOutExample />; } };
|
|
62
92
|
export var AcceptInvite_SignedIn = { render: function () { return <AcceptInvite_SignedInExample />; } };
|
|
93
|
+
export var AgentOptions_Cards = { render: function () { return <AgentOptions_CardsExample />; } };
|
|
94
|
+
export var AgentPendingReply_Steps = { render: function () { return <AgentPendingReply_StepsExample />; } };
|
|
95
|
+
export var AgentPendingReply_Streaming = { render: function () { return <AgentPendingReply_StreamingExample />; } };
|
|
96
|
+
export var AgentPlanProposal_Steps = { render: function () { return <AgentPlanProposal_StepsExample />; } };
|
|
97
|
+
export var AgentPlanProposal_Changes = { render: function () { return <AgentPlanProposal_ChangesExample />; } };
|
|
98
|
+
export var AgentQuestion_Choices = { render: function () { return <AgentQuestion_ChoicesExample />; } };
|
|
99
|
+
export var AgentQuestion_FreeText = { render: function () { return <AgentQuestion_FreeTextExample />; } };
|
|
100
|
+
export var ArtifactCard_Card = { render: function () { return <ArtifactCard_CardExample />; } };
|
|
63
101
|
export var AuthGateLoading_Spinner = { render: function () { return <AuthGateLoading_SpinnerExample />; } };
|
|
64
102
|
export var AuthGateLoading_SpinnerWithLine = { render: function () { return <AuthGateLoading_SpinnerWithLineExample />; } };
|
|
65
103
|
export var CheckYourEmail_Page = { render: function () { return <CheckYourEmail_PageExample />; } };
|
|
66
104
|
export var CheckYourEmail_AlertOnLogin = { render: function () { return <CheckYourEmail_AlertOnLoginExample />; } };
|
|
105
|
+
export var ComposerLimit_Notice = { render: function () { return <ComposerLimit_NoticeExample />; } };
|
|
106
|
+
export var ComposerLimit_NoticeWithAction = { render: function () { return <ComposerLimit_NoticeWithActionExample />; } };
|
|
67
107
|
export var ConfirmDestructiveAction_Modal = { render: function () { return <ConfirmDestructiveAction_ModalExample />; } };
|
|
68
108
|
export var ConfirmDestructiveAction_Inline = { render: function () { return <ConfirmDestructiveAction_InlineExample />; } };
|
|
109
|
+
export var ConversationStarters_Chips = { render: function () { return <ConversationStarters_ChipsExample />; } };
|
|
110
|
+
export var ConversationStarters_None = { render: function () { return <ConversationStarters_NoneExample />; } };
|
|
69
111
|
export var CreateModal_Quick = { render: function () { return <CreateModal_QuickExample />; } };
|
|
70
112
|
export var CreateModal_WithSettings = { render: function () { return <CreateModal_WithSettingsExample />; } };
|
|
71
113
|
export var DeviceLogin_ProviderFirst = { render: function () { return <DeviceLogin_ProviderFirstExample />; } };
|
|
@@ -95,12 +137,28 @@ export var LoginPage_Centered = { render: function () { return <LoginPage_Center
|
|
|
95
137
|
export var LoginPage_Split = { render: function () { return <LoginPage_SplitExample />; } };
|
|
96
138
|
export var LoginPage_ProviderFirst = { render: function () { return <LoginPage_ProviderFirstExample />; } };
|
|
97
139
|
export var LoginPage_EmailOnly = { render: function () { return <LoginPage_EmailOnlyExample />; } };
|
|
140
|
+
export var MentionList_InComposer = { render: function () { return <MentionList_InComposerExample />; } };
|
|
141
|
+
export var MessageActions_HoverToolbar = { render: function () { return <MessageActions_HoverToolbarExample />; } };
|
|
142
|
+
export var MessageActions_Menu = { render: function () { return <MessageActions_MenuExample />; } };
|
|
143
|
+
export var MessageAttachments_InComposer = { render: function () { return <MessageAttachments_InComposerExample />; } };
|
|
144
|
+
export var MessageAttachments_InMessage = { render: function () { return <MessageAttachments_InMessageExample />; } };
|
|
145
|
+
export var MessageComposer_Plain = { render: function () { return <MessageComposer_PlainExample />; } };
|
|
146
|
+
export var MessageComposer_WithTools = { render: function () { return <MessageComposer_WithToolsExample />; } };
|
|
147
|
+
export var MessageEdit_InPlace = { render: function () { return <MessageEdit_InPlaceExample />; } };
|
|
148
|
+
export var MessageReactions_Chips = { render: function () { return <MessageReactions_ChipsExample />; } };
|
|
149
|
+
export var MessageReactions_QuickPick = { render: function () { return <MessageReactions_QuickPickExample />; } };
|
|
150
|
+
export var MessageRow_PersonAndAgent = { render: function () { return <MessageRow_PersonAndAgentExample />; } };
|
|
151
|
+
export var MessageRow_Grouped = { render: function () { return <MessageRow_GroupedExample />; } };
|
|
98
152
|
export var NotFoundPage_FullPage = { render: function () { return <NotFoundPage_FullPageExample />; } };
|
|
99
153
|
export var NotFoundPage_InShell = { render: function () { return <NotFoundPage_InShellExample />; } };
|
|
100
154
|
export var OauthConsent_Simple = { render: function () { return <OauthConsent_SimpleExample />; } };
|
|
101
155
|
export var OauthConsent_WithScope = { render: function () { return <OauthConsent_WithScopeExample />; } };
|
|
102
156
|
export var Rename_Modal = { render: function () { return <Rename_ModalExample />; } };
|
|
103
157
|
export var Rename_Inline = { render: function () { return <Rename_InlineExample />; } };
|
|
158
|
+
export var ReplyFeedback_Thumbs = { render: function () { return <ReplyFeedback_ThumbsExample />; } };
|
|
159
|
+
export var ReplyFeedback_WithReason = { render: function () { return <ReplyFeedback_WithReasonExample />; } };
|
|
160
|
+
export var ReplySources_Cards = { render: function () { return <ReplySources_CardsExample />; } };
|
|
161
|
+
export var ReplySources_TagOnly = { render: function () { return <ReplySources_TagOnlyExample />; } };
|
|
104
162
|
export var RouteLoading_FullScreen = { render: function () { return <RouteLoading_FullScreenExample />; } };
|
|
105
163
|
export var RouteLoading_Region = { render: function () { return <RouteLoading_RegionExample />; } };
|
|
106
164
|
export var SetNewPassword_Form = { render: function () { return <SetNewPassword_FormExample />; } };
|
|
@@ -108,8 +166,10 @@ export var SetNewPassword_InvalidLink = { render: function () { return <SetNewPa
|
|
|
108
166
|
export var SignUpPage_Centered = { render: function () { return <SignUpPage_CenteredExample />; } };
|
|
109
167
|
export var SignUpPage_Split = { render: function () { return <SignUpPage_SplitExample />; } };
|
|
110
168
|
export var SignUpPage_ProviderFirst = { render: function () { return <SignUpPage_ProviderFirstExample />; } };
|
|
169
|
+
export var SlashCommandList_InComposer = { render: function () { return <SlashCommandList_InComposerExample />; } };
|
|
111
170
|
export var TypeToConfirm_Modal = { render: function () { return <TypeToConfirm_ModalExample />; } };
|
|
112
171
|
export var TypeToConfirm_Inline = { render: function () { return <TypeToConfirm_InlineExample />; } };
|
|
172
|
+
export var TypingAndStatus_Line = { render: function () { return <TypingAndStatus_LineExample />; } };
|
|
113
173
|
export var UnsavedChangesGuard_SaveOrDiscard = { render: function () { return <UnsavedChangesGuard_SaveOrDiscardExample />; } };
|
|
114
174
|
export var UnsavedChangesGuard_Discard = { render: function () { return <UnsavedChangesGuard_DiscardExample />; } };
|
|
115
175
|
export var UpgradePrompt_Modal = { render: function () { return <UpgradePrompt_ModalExample />; } };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Composer from "../components/composer";
|
|
3
|
+
declare const meta: Meta<typeof Composer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Composer>;
|
|
6
|
+
export declare const Empty: Story;
|
|
7
|
+
export declare const WithText: Story;
|
|
8
|
+
export declare const WithTools: Story;
|
|
9
|
+
export declare const WithAttachments: Story;
|
|
10
|
+
export declare const Stop: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
12
|
+
export declare const WithActions: Story;
|
|
13
|
+
interface ProbeArgs {
|
|
14
|
+
submitOnEnter: boolean;
|
|
15
|
+
canSubmit?: boolean;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
sending: boolean;
|
|
18
|
+
stop: boolean;
|
|
19
|
+
withActions: boolean;
|
|
20
|
+
takeEnter: boolean;
|
|
21
|
+
withAbove: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const Probe: StoryObj<ProbeArgs>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import React, { useRef, useState } from "react";
|
|
22
|
+
import Composer from "../components/composer";
|
|
23
|
+
import IconButton from "../components/iconButton";
|
|
24
|
+
import Tag from "../components/tag";
|
|
25
|
+
import Alert from "../components/alert";
|
|
26
|
+
import Button from "../components/button";
|
|
27
|
+
import Paragraph from "../components/paragraph";
|
|
28
|
+
import { Cluster } from "../components/layout";
|
|
29
|
+
import Menu from "../components/menu";
|
|
30
|
+
import MenuItem from "../components/menuItem";
|
|
31
|
+
var meta = {
|
|
32
|
+
title: "Components/Composer",
|
|
33
|
+
component: Composer,
|
|
34
|
+
decorators: [
|
|
35
|
+
function (Story) { return (<div style={{ maxWidth: "560px" }}>
|
|
36
|
+
<Story />
|
|
37
|
+
</div>); },
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
export default meta;
|
|
41
|
+
// The caller owns the value and clears it once the message is taken
|
|
42
|
+
function Box(_a) {
|
|
43
|
+
var _b = _a.initial, initial = _b === void 0 ? "" : _b, props = __rest(_a, ["initial"]);
|
|
44
|
+
var _c = useState(initial), value = _c[0], setValue = _c[1];
|
|
45
|
+
return (<Composer id="story-composer" aria-label="Message Acme Agent" placeholder="Message Acme Agent" value={value} onChange={setValue} onSubmit={function () { return setValue(""); }} {...props}/>);
|
|
46
|
+
}
|
|
47
|
+
var tools = (<>
|
|
48
|
+
<IconButton color="iconOnly" state="enabled" size="small" iconName="Paperclip" ariaLabel="Attach Files"/>
|
|
49
|
+
<IconButton color="iconOnly" state="enabled" size="small" iconName="AtSign" ariaLabel="Mention"/>
|
|
50
|
+
</>);
|
|
51
|
+
export var Empty = { render: function () { return <Box />; } };
|
|
52
|
+
export var WithText = {
|
|
53
|
+
render: function () { return <Box initial={"Can you check the numbers in the Q3 plan?\nThe March rows look off."}/>; },
|
|
54
|
+
};
|
|
55
|
+
export var WithTools = { render: function () { return <Box tools={tools} initial="Here is the sheet."/>; } };
|
|
56
|
+
export var WithAttachments = {
|
|
57
|
+
render: function () { return (<Box tools={tools} initial="Both files are attached." above={<Cluster gap="small">
|
|
58
|
+
<Tag variant="contained" size="medium" label="q3-plan.xlsx" iconName="FileSpreadsheet"/>
|
|
59
|
+
<Tag variant="contained" size="medium" label="notes.pdf" iconName="FileText"/>
|
|
60
|
+
</Cluster>}/>); },
|
|
61
|
+
};
|
|
62
|
+
export var Stop = { render: function () { return <Box tools={tools} onStop={function () { }}/>; } };
|
|
63
|
+
export var Disabled = {
|
|
64
|
+
render: function () { return (<Box disabled tools={<IconButton color="iconOnly" state="disabled" size="small" iconName="Paperclip" ariaLabel="Attach Files"/>} above={<Alert variant="inline" type="info" message="You have used all of today's messages to Acme Agent." autoDismiss={false}/>}/>); },
|
|
65
|
+
};
|
|
66
|
+
// Editing a sent message: Cancel and Save take the send control's place; Enter still saves
|
|
67
|
+
export var WithActions = {
|
|
68
|
+
render: function () { return (<Box initial="The totals match the sheet." actions={<Cluster gap="small">
|
|
69
|
+
<Button size="small" type="secondary" state="enabled" label="Cancel"/>
|
|
70
|
+
<Button size="small" type="primary" state="enabled" label="Save"/>
|
|
71
|
+
</Cluster>}/>); },
|
|
72
|
+
};
|
|
73
|
+
// For tests/interactions.spec.ts: counts submits and stops on screen. Its args are set from the URL.
|
|
74
|
+
function ProbeBox(_a) {
|
|
75
|
+
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;
|
|
76
|
+
var ref = useRef(null);
|
|
77
|
+
var _b = useState(""), value = _b[0], setValue = _b[1];
|
|
78
|
+
var _c = useState(0), submits = _c[0], setSubmits = _c[1];
|
|
79
|
+
var _d = useState(0), stops = _d[0], setStops = _d[1];
|
|
80
|
+
var _e = useState([]), log = _e[0], setLog = _e[1];
|
|
81
|
+
var note = function (entry) { return setLog(function (l) { return __spreadArray(__spreadArray([], l, true), [entry], false); }); };
|
|
82
|
+
// onFocus, onBlur and onSelect, kept apart from the key log; empty until the field is used
|
|
83
|
+
var _f = useState([]), events = _f[0], setEvents = _f[1];
|
|
84
|
+
var noteEvent = function (entry) { return setEvents(function (l) { return __spreadArray(__spreadArray([], l, true), [entry], false); }); };
|
|
85
|
+
return (<div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
|
|
86
|
+
<Composer ref={ref} id="probe" aria-label="Probe" placeholder="Probe" value={value} onChange={setValue} onSubmit={function () {
|
|
87
|
+
setSubmits(function (n) { return n + 1; });
|
|
88
|
+
note("submit");
|
|
89
|
+
}} canSubmit={canSubmit} submitOnEnter={submitOnEnter} disabled={disabled} sending={sending} onStop={stop ? function () { return setStops(function (n) { return n + 1; }); } : undefined} actions={withActions ? <Button size="small" type="primary" state="enabled" label="Save"/> : undefined} above={withAbove ? (<>
|
|
90
|
+
<Paragraph>Acme Agent is reading the sheet.</Paragraph>
|
|
91
|
+
<Menu role="listbox" aria-label="People">
|
|
92
|
+
<MenuItem role="option" size="small" tabIndex={-1} label="Ada Brown" onClick={function () { return note("picked:Ada"); }}/>
|
|
93
|
+
</Menu>
|
|
94
|
+
</>) : undefined} onKeyDown={function (e) {
|
|
95
|
+
note("key:".concat(e.key));
|
|
96
|
+
if (takeEnter && e.key === "Enter")
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
}} onFocus={function () { return noteEvent("focus"); }} onBlur={function () { return noteEvent("blur"); }} onSelect={function (e) { return noteEvent("select:".concat(e.currentTarget.selectionStart, "-").concat(e.currentTarget.selectionEnd)); }}/>
|
|
99
|
+
<Paragraph>
|
|
100
|
+
Submits: <output data-testid="submits">{submits}</output> Stops: <output data-testid="stops">{stops}</output>
|
|
101
|
+
</Paragraph>
|
|
102
|
+
<Paragraph>
|
|
103
|
+
<span data-testid="log">{log.join(" ")}</span>
|
|
104
|
+
<span data-testid="events">{events.join(" ")}</span>
|
|
105
|
+
</Paragraph>
|
|
106
|
+
<Button size="small" type="secondary" state="enabled" label="Focus End" onClickButton={function () {
|
|
107
|
+
var field = ref.current;
|
|
108
|
+
if (!field)
|
|
109
|
+
return;
|
|
110
|
+
field.focus();
|
|
111
|
+
field.setSelectionRange(field.value.length, field.value.length);
|
|
112
|
+
}}/>
|
|
113
|
+
</div>);
|
|
114
|
+
}
|
|
115
|
+
export var Probe = {
|
|
116
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
117
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
118
|
+
args: { submitOnEnter: true, disabled: false, sending: false, stop: false, withActions: false, takeEnter: false, withAbove: false },
|
|
119
|
+
argTypes: { canSubmit: { control: "boolean" } },
|
|
120
|
+
render: function (args) { return <ProbeBox {...args}/>; },
|
|
121
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import FileChip from "../components/fileChip";
|
|
3
|
+
declare const meta: Meta<typeof FileChip>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FileChip>;
|
|
6
|
+
export declare const States: Story;
|
|
7
|
+
export declare const RemoveProbe: Story;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import FileChip from "../components/fileChip";
|
|
3
|
+
import { Stack } from "../components/layout";
|
|
4
|
+
var meta = {
|
|
5
|
+
title: "Components/FileChip",
|
|
6
|
+
component: FileChip,
|
|
7
|
+
decorators: [
|
|
8
|
+
function (Story) { return (<div style={{ maxWidth: "560px" }}>
|
|
9
|
+
<Story />
|
|
10
|
+
</div>); },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export var States = {
|
|
15
|
+
render: function () { return (<Stack gap="medium" align="start">
|
|
16
|
+
<FileChip name="plan.pdf" kind="PDF" meta="2.1 MB" href="/files/plan"/>
|
|
17
|
+
<FileChip name="notes.txt" kind="TXT" meta="4 KB" onClick={function () { }} onRemove={function () { }}/>
|
|
18
|
+
<FileChip name="budget.xlsx" kind="XLS" meta="Uploading" state="uploading" onRemove={function () { }}/>
|
|
19
|
+
<FileChip name="photo.png" kind="PNG" meta="Upload failed" state="failed" onRemove={function () { }}/>
|
|
20
|
+
<FileChip name="sent-contract.pdf" kind="PDF" meta="1 MB"/>
|
|
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
|
+
</Stack>); },
|
|
23
|
+
};
|
|
24
|
+
// For tests/interactions.spec.ts: the remove button calls onRemove, which drops the chip here
|
|
25
|
+
function RemoveProbeBox() {
|
|
26
|
+
var _a = useState(["plan.pdf", "notes.txt"]), names = _a[0], setNames = _a[1];
|
|
27
|
+
return (<Stack gap="medium" align="start">
|
|
28
|
+
{names.map(function (name) { return (<FileChip key={name} name={name} meta="1 MB" onRemove={function () { return setNames(function (n) { return n.filter(function (x) { return x !== name; }); }); }}/>); })}
|
|
29
|
+
</Stack>);
|
|
30
|
+
}
|
|
31
|
+
export var RemoveProbe = {
|
|
32
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
33
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
34
|
+
render: function () { return <RemoveProbeBox />; },
|
|
35
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
2
|
import { Plus, Settings } from "lucide-react";
|
|
3
3
|
import IconButton from "../components/iconButton";
|
|
4
|
+
import Button from "../components/button";
|
|
4
5
|
var meta = {
|
|
5
6
|
title: "Components/IconButton",
|
|
6
7
|
component: IconButton,
|
|
@@ -119,3 +120,19 @@ export var AsLink = {
|
|
|
119
120
|
<IconButton color="secondary" state="disabled" size="medium" iconName="Settings" href="/settings"/>
|
|
120
121
|
</div>); },
|
|
121
122
|
};
|
|
123
|
+
// For tests/interactions.spec.ts: the ref reaches the <button> and the link, so focus can be moved to them
|
|
124
|
+
function FocusFromOutsideDemo() {
|
|
125
|
+
var buttonRef = useRef(null);
|
|
126
|
+
var linkRef = useRef(null);
|
|
127
|
+
return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
128
|
+
<IconButton ref={buttonRef} color="tertiary" state="enabled" size="small" icon={Settings} ariaLabel="Open settings"/>
|
|
129
|
+
<IconButton ref={linkRef} color="tertiary" state="enabled" size="small" icon={Plus} ariaLabel="New project" href="/new"/>
|
|
130
|
+
<Button size="small" type="secondary" state="enabled" label="Focus Button" onClickButton={function () { var _a; return (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}/>
|
|
131
|
+
<Button size="small" type="secondary" state="enabled" label="Focus Link" onClickButton={function () { var _a; return (_a = linkRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}/>
|
|
132
|
+
</div>);
|
|
133
|
+
}
|
|
134
|
+
export var FocusFromOutside = {
|
|
135
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
136
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
137
|
+
render: function () { return <FocusFromOutsideDemo />; },
|
|
138
|
+
};
|
|
@@ -6,3 +6,7 @@ type Story = StoryObj<typeof Menu>;
|
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const WithSelectedItem: Story;
|
|
8
8
|
export declare const WithTags: Story;
|
|
9
|
+
interface NavigableArgs {
|
|
10
|
+
inModal: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Navigable: StoryObj<NavigableArgs>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import Menu from "../components/menu";
|
|
3
3
|
import MenuItem from "../components/menuItem";
|
|
4
|
+
import Button from "../components/button";
|
|
5
|
+
import Popover from "../components/popover";
|
|
6
|
+
import Modal from "../components/modal";
|
|
7
|
+
import Paragraph from "../components/paragraph";
|
|
4
8
|
var meta = {
|
|
5
9
|
title: "Components/Menu",
|
|
6
10
|
component: Menu,
|
|
@@ -40,3 +44,44 @@ export var WithTags = {
|
|
|
40
44
|
width: 220,
|
|
41
45
|
},
|
|
42
46
|
};
|
|
47
|
+
// For tests/interactions.spec.ts: a Button opens a navigable Menu in a Popover with returnFocus.
|
|
48
|
+
// `inModal` (from the URL, `inModal:!true`) puts the Button in an open Modal. Closed on first render.
|
|
49
|
+
function NavigableBox(_a) {
|
|
50
|
+
var inModal = _a.inModal;
|
|
51
|
+
var _b = useState(null), anchor = _b[0], setAnchor = _b[1];
|
|
52
|
+
var _c = useState(false), open = _c[0], setOpen = _c[1];
|
|
53
|
+
var _d = useState(""), chosen = _d[0], setChosen = _d[1];
|
|
54
|
+
var choose = function (label) { return function () {
|
|
55
|
+
setChosen(label);
|
|
56
|
+
setOpen(false);
|
|
57
|
+
}; };
|
|
58
|
+
var trigger = (<div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", gap: "8px" }}>
|
|
59
|
+
<Button size="medium" type="secondary" state="enabled" label="Actions" aria-haspopup="menu" aria-expanded={open} onClickButton={function (e) {
|
|
60
|
+
setAnchor(e.currentTarget);
|
|
61
|
+
setOpen(!open);
|
|
62
|
+
}}/>
|
|
63
|
+
<Paragraph>
|
|
64
|
+
Chosen: <output data-testid="chosen">{chosen}</output>
|
|
65
|
+
</Paragraph>
|
|
66
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
67
|
+
<Menu navigable aria-label="Actions" width={200}>
|
|
68
|
+
<MenuItem size="small" iconName="SmilePlus" label="React" onClick={choose("React")}/>
|
|
69
|
+
<MenuItem size="small" iconName="Copy" label="Copy" onClick={choose("Copy")}/>
|
|
70
|
+
<MenuItem size="small" iconName="Pencil" label="Edit" onClick={choose("Edit")}/>
|
|
71
|
+
<MenuItem size="small" iconName="ClipboardPlus" label="Create Task" onClick={choose("Create Task")}/>
|
|
72
|
+
<MenuItem size="small" iconName="Trash2" label="Delete" color="danger" onClick={choose("Delete")}/>
|
|
73
|
+
</Menu>
|
|
74
|
+
</Popover>
|
|
75
|
+
</div>);
|
|
76
|
+
if (!inModal)
|
|
77
|
+
return trigger;
|
|
78
|
+
return (<Modal isOpen title="Probe Modal" size="small" onClose={function () { return setChosen("modal closed"); }}>
|
|
79
|
+
{trigger}
|
|
80
|
+
</Modal>);
|
|
81
|
+
}
|
|
82
|
+
export var Navigable = {
|
|
83
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
84
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
85
|
+
args: { inModal: false },
|
|
86
|
+
render: function (args) { return <NavigableBox {...args}/>; },
|
|
87
|
+
};
|