oneslash-design-system 2.16.0 → 2.18.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 +2 -2
- package/dist/DESIGN.md +56 -17
- 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 +3 -7
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- 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 +164 -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 +428 -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 +652 -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 +334 -0
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +2 -4
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- 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 +99 -0
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -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 +282 -0
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- 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 +204 -0
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page.md +0 -4
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -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 +248 -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 +647 -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 +306 -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 +352 -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 +175 -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 +367 -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 +185 -0
- package/dist/cases/not-found-page.md +0 -4
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- 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 +548 -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 +243 -0
- package/dist/cases/route-loading.md +0 -2
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/sign-up-page.md +1 -5
- 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 +243 -0
- package/dist/cases/success-feedback.md +1 -5
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/type-to-confirm.md +0 -4
- 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 +92 -0
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +2331 -294
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +14 -9
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +2 -2
- 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 +12 -2
- package/dist/components/menuItem.jsx +6 -5
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- 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 +12 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +31 -0
- package/dist/components/settingsSection.jsx +58 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- 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/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +6 -21
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- 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/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +62 -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 +53 -0
- package/dist/stories/Cases.generated.stories.jsx +106 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -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/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- 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/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +11 -0
- package/dist/stories/SettingsSection.stories.jsx +64 -0
- 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/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +8 -3
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import { Bot } from 'lucide-react';
|
|
13
|
+
import Message from '../../components/message';
|
|
14
|
+
import UserImage from '../../components/userImage';
|
|
15
|
+
import Tag from '../../components/tag';
|
|
16
|
+
import TimeStamp from '../../components/timeStamp';
|
|
17
|
+
import Heading from '../../components/heading';
|
|
18
|
+
import Paragraph from '../../components/paragraph';
|
|
19
|
+
import Button from '../../components/button';
|
|
20
|
+
import Surface from '../../components/surface';
|
|
21
|
+
import RadioGroup from '../../components/radioGroup';
|
|
22
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
23
|
+
var agentName = 'Acme Agent';
|
|
24
|
+
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you plan the new pricing page?' };
|
|
25
|
+
var askedAt = new Date('2025-01-15T11:41:00Z');
|
|
26
|
+
// The agent has three questions. Each one replaces the one before it in the same card.
|
|
27
|
+
var questions = [
|
|
28
|
+
{
|
|
29
|
+
question: 'Which plans should the pricing page show?',
|
|
30
|
+
options: [
|
|
31
|
+
{ value: 'three', label: 'Free, Pro and Team' },
|
|
32
|
+
{ value: 'two', label: 'Pro and Team only' },
|
|
33
|
+
{ value: 'four', label: 'Free, Pro, Team and Enterprise' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
question: 'Should prices show per month or per year?',
|
|
38
|
+
options: [
|
|
39
|
+
{ value: 'month', label: 'Per month' },
|
|
40
|
+
{ value: 'year', label: 'Per year' },
|
|
41
|
+
{ value: 'both', label: 'Both, with a switch' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
question: 'Where should the plan table go?',
|
|
46
|
+
options: [
|
|
47
|
+
{ value: 'top', label: 'At the top of the page' },
|
|
48
|
+
{ value: 'below', label: 'Below the feature list' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
53
|
+
function agentMeta(at) {
|
|
54
|
+
return (<>
|
|
55
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
56
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
57
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
58
|
+
</>);
|
|
59
|
+
}
|
|
60
|
+
export default function AgentQuestionChoices() {
|
|
61
|
+
var _a = useState(0), index = _a[0], setIndex = _a[1];
|
|
62
|
+
var _b = useState([]), outcomes = _b[0], setOutcomes = _b[1];
|
|
63
|
+
// No option is recommended, so nothing starts selected.
|
|
64
|
+
var _c = useState(''), selected = _c[0], setSelected = _c[1];
|
|
65
|
+
var _d = useState(null), pending = _d[0], setPending = _d[1];
|
|
66
|
+
var timer = useRef();
|
|
67
|
+
// On unmount it stops the request.
|
|
68
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
69
|
+
var done = outcomes.length === questions.length;
|
|
70
|
+
var _e = questions[index], question = _e.question, options = _e.options;
|
|
71
|
+
// After an answer or a skip, the next question replaces this one in the same card, with nothing selected.
|
|
72
|
+
// A real app moves focus to its first answer. After the last one the buttons are gone, and a real app
|
|
73
|
+
// moves focus to the message box.
|
|
74
|
+
function send(action) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (pending || done || (action === 'answer' && selected === ''))
|
|
77
|
+
return;
|
|
78
|
+
setPending(action);
|
|
79
|
+
var outcome = action === 'answer' ? (_b = (_a = options.find(function (o) { return o.value === selected; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null : null;
|
|
80
|
+
// Stands in for the request to the server.
|
|
81
|
+
timer.current = setTimeout(function () {
|
|
82
|
+
setPending(null);
|
|
83
|
+
setOutcomes(function (list) { return __spreadArray(__spreadArray([], list, true), [outcome], false); });
|
|
84
|
+
setSelected('');
|
|
85
|
+
if (index < questions.length - 1)
|
|
86
|
+
setIndex(index + 1);
|
|
87
|
+
}, 1200);
|
|
88
|
+
}
|
|
89
|
+
return (<Center width="page">
|
|
90
|
+
<Stack gap="large">
|
|
91
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
92
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
93
|
+
<Stack gap="small">
|
|
94
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
95
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
96
|
+
</Message>
|
|
97
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(askedAt)}>
|
|
98
|
+
<Surface padding="small">
|
|
99
|
+
{done ? (
|
|
100
|
+
// Every question is decided: the card is the record, with each answer or skip.
|
|
101
|
+
// A real app announces the decided Tag in a polite live region.
|
|
102
|
+
<Stack gap="medium">
|
|
103
|
+
{questions.map(function (q, i) {
|
|
104
|
+
var _a;
|
|
105
|
+
return (<Stack key={q.question} gap="small">
|
|
106
|
+
<Cluster gap="small">
|
|
107
|
+
<Heading level={2} size="subtitle1">{q.question}</Heading>
|
|
108
|
+
{outcomes[i] === null
|
|
109
|
+
? <Tag variant="contained" size="small" label="Skipped"/>
|
|
110
|
+
: <Tag variant="contained" size="small" color="success" label="Answered"/>}
|
|
111
|
+
</Cluster>
|
|
112
|
+
<Paragraph measure="none">{(_a = outcomes[i]) !== null && _a !== void 0 ? _a : 'Acme Agent will list this as an open question in the plan.'}</Paragraph>
|
|
113
|
+
</Stack>);
|
|
114
|
+
})}
|
|
115
|
+
</Stack>) : (<Stack gap="medium">
|
|
116
|
+
{/* The agent has more than one question, so the card says which one this is. */}
|
|
117
|
+
<Paragraph size="caption" tone="secondary" measure="none">{"Question ".concat(index + 1, " of ").concat(questions.length)}</Paragraph>
|
|
118
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
119
|
+
<RadioGroup variant="card" aria-label={question} options={options} selectedValue={selected} onChange={setSelected} disabled={pending !== null}/>
|
|
120
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
121
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
122
|
+
<Cluster gap="small">
|
|
123
|
+
<Button size="small" type="tertiary" state={pending === 'answer' ? 'disabled' : 'enabled'} label="Skip" loading={pending === 'skip'} onClickButton={function () { return send('skip'); }}/>
|
|
124
|
+
<Button size="small" type="primary" state={selected === '' || pending === 'skip' ? 'disabled' : 'enabled'} label="Answer" loading={pending === 'answer'} onClickButton={function () { return send('answer'); }}/>
|
|
125
|
+
</Cluster>
|
|
126
|
+
</Stack>)}
|
|
127
|
+
</Surface>
|
|
128
|
+
</Message>
|
|
129
|
+
</Stack>
|
|
130
|
+
</Stack>
|
|
131
|
+
</Center>);
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentQuestionFreeText(): import("react").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Bot } from 'lucide-react';
|
|
4
|
+
import Message from '../../components/message';
|
|
5
|
+
import UserImage from '../../components/userImage';
|
|
6
|
+
import Tag from '../../components/tag';
|
|
7
|
+
import TimeStamp from '../../components/timeStamp';
|
|
8
|
+
import Heading from '../../components/heading';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import Surface from '../../components/surface';
|
|
12
|
+
import Textarea from '../../components/textarea';
|
|
13
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
14
|
+
var agentName = 'Acme Agent';
|
|
15
|
+
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you add the Team plan to the pricing page?' };
|
|
16
|
+
var askedAt = new Date('2025-01-15T11:41:00Z');
|
|
17
|
+
var question = 'What should the Team plan say under its price?';
|
|
18
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
19
|
+
function agentMeta(at) {
|
|
20
|
+
return (<>
|
|
21
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
22
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
23
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
24
|
+
</>);
|
|
25
|
+
}
|
|
26
|
+
export default function AgentQuestionFreeText() {
|
|
27
|
+
var _a = useState(''), text = _a[0], setText = _a[1];
|
|
28
|
+
var _b = useState('open'), status = _b[0], setStatus = _b[1];
|
|
29
|
+
var _c = useState(null), pending = _c[0], setPending = _c[1];
|
|
30
|
+
var timer = useRef();
|
|
31
|
+
// On unmount it stops the request.
|
|
32
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
33
|
+
var empty = text.trim() === '';
|
|
34
|
+
// Ctrl+Enter or Cmd+Enter in the field answers too, and Enter adds a line.
|
|
35
|
+
// Once it is answered or skipped the buttons are gone, and a real app moves focus to the message box.
|
|
36
|
+
function send(action) {
|
|
37
|
+
if (pending || status !== 'open' || (action === 'answer' && empty))
|
|
38
|
+
return;
|
|
39
|
+
setPending(action);
|
|
40
|
+
// Stands in for the request to the server.
|
|
41
|
+
timer.current = setTimeout(function () {
|
|
42
|
+
setPending(null);
|
|
43
|
+
setStatus(action === 'answer' ? 'answered' : 'skipped');
|
|
44
|
+
}, 1200);
|
|
45
|
+
}
|
|
46
|
+
return (<Center width="page">
|
|
47
|
+
<Stack gap="large">
|
|
48
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
49
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
50
|
+
<Stack gap="small">
|
|
51
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
52
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
53
|
+
</Message>
|
|
54
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(askedAt)}>
|
|
55
|
+
<Surface padding="small">
|
|
56
|
+
<Stack gap="medium">
|
|
57
|
+
{/* One question only, so there is no 'Question 1 of 3' line. */}
|
|
58
|
+
{/* A real app announces the decided Tag in a polite live region. */}
|
|
59
|
+
<Cluster gap="small">
|
|
60
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
61
|
+
{status === 'answered' && <Tag variant="contained" size="small" color="success" label="Answered"/>}
|
|
62
|
+
{status === 'skipped' && <Tag variant="contained" size="small" label="Skipped"/>}
|
|
63
|
+
</Cluster>
|
|
64
|
+
{status === 'open' && (<>
|
|
65
|
+
<Textarea id="agent-question-answer" label="Your answer" value={text} onChange={function (e) { return setText(e.target.value); }} onSubmit={function () { return send('answer'); }} disabled={pending !== null}/>
|
|
66
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
67
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
68
|
+
<Cluster gap="small">
|
|
69
|
+
<Button size="small" type="tertiary" state={pending === 'answer' ? 'disabled' : 'enabled'} label="Skip" loading={pending === 'skip'} onClickButton={function () { return send('skip'); }}/>
|
|
70
|
+
<Button size="small" type="primary" state={empty || pending === 'skip' ? 'disabled' : 'enabled'} label="Answer" loading={pending === 'answer'} onClickButton={function () { return send('answer'); }}/>
|
|
71
|
+
</Cluster>
|
|
72
|
+
</>)}
|
|
73
|
+
{status === 'answered' && <Paragraph measure="none">{text.trim()}</Paragraph>}
|
|
74
|
+
{status === 'skipped' && <Paragraph measure="none">Acme Agent will list this as an open question in the plan.</Paragraph>}
|
|
75
|
+
</Stack>
|
|
76
|
+
</Surface>
|
|
77
|
+
</Message>
|
|
78
|
+
</Stack>
|
|
79
|
+
</Stack>
|
|
80
|
+
</Center>);
|
|
81
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Agent question
|
|
2
|
+
|
|
3
|
+
The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Put the card in the agent's `Message`, in a `Surface` with the question as its heading.
|
|
8
|
+
- Say which question it is in a caption when there are several: 'Question 1 of 3'.
|
|
9
|
+
- Replace the question with the next one in the same card once it is answered or skipped, and move focus to its first answer.
|
|
10
|
+
- Show a few answers as `<RadioGroup variant="card">`, with an `aria-label` that starts with the question.
|
|
11
|
+
- Preselect nothing unless the agent recommends an answer. Then give it the `badge` 'Recommended' and preselect it.
|
|
12
|
+
- Take a free answer in a `Textarea` with a visible label.
|
|
13
|
+
- Let Cmd+Enter or Ctrl+Enter in the field answer. Enter adds a line.
|
|
14
|
+
- Order the buttons 'Skip', a tertiary Button that is always there, then 'Answer' as the primary Button.
|
|
15
|
+
- Disable 'Answer' until an answer is picked or typed.
|
|
16
|
+
- Make the pressed Button `loading` and keep its label. Disable the field and the other Button while the request runs.
|
|
17
|
+
- Keep the card and its buttons when a request fails. Show an inline error `Alert` above the buttons, as the rule 'A form error shows next to the problem' says.
|
|
18
|
+
- Follow the rule 'An agent cancels and reports when nobody answers': show the waiting time on the card, 'Waits 10 more minutes, then cancels.'
|
|
19
|
+
- Notify the person who asked when the agent needs their answer.
|
|
20
|
+
- Show the answer as text with an 'Answered' `Tag` once it is sent, and remove the buttons.
|
|
21
|
+
- Mark a skipped question with a 'Skipped' `Tag`, and say that the agent will list it as an open question in the plan.
|
|
22
|
+
- Mark the card with a 'Cancelled' `Tag` when the waiting time is up. Add one compact agent row under it that says what was not done: 'Cancelled. Nothing was changed.'
|
|
23
|
+
- Announce the decided `Tag` politely: the app wraps it in a polite live region.
|
|
24
|
+
- Move focus to the message box once the last question is answered or skipped, since its buttons are gone.
|
|
25
|
+
|
|
26
|
+
## Don't
|
|
27
|
+
|
|
28
|
+
- Do not treat no answer as a yes.
|
|
29
|
+
- Do not send an answer the person did not choose.
|
|
30
|
+
- Do not recommend or preselect an option that does more than the others, such as one that deletes, publishes or widens access.
|
|
31
|
+
- Do not leave a question waiting with no end, and do not cancel it without saying so in the thread.
|
|
32
|
+
- Do not hide 'Skip'.
|
|
33
|
+
- Do not change a Button's label while it is loading, such as to 'Submitting...'.
|
|
34
|
+
|
|
35
|
+
## Option: Choices
|
|
36
|
+
|
|
37
|
+
Use when: The answer is one of a few.
|
|
38
|
+
|
|
39
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `RadioGroup`, `Stack`, `Surface`, `Tag`, `TimeStamp`, `UserImage`
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
'use client';
|
|
43
|
+
import { useEffect, useRef, useState } from 'react';
|
|
44
|
+
import { Bot } from 'lucide-react';
|
|
45
|
+
import Message from 'oneslash-design-system/components/message';
|
|
46
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
47
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
48
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
49
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
50
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
51
|
+
import Button from 'oneslash-design-system/components/button';
|
|
52
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
53
|
+
import RadioGroup from 'oneslash-design-system/components/radioGroup';
|
|
54
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
55
|
+
|
|
56
|
+
const agentName = 'Acme Agent';
|
|
57
|
+
|
|
58
|
+
const request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you plan the new pricing page?' };
|
|
59
|
+
const askedAt = new Date('2025-01-15T11:41:00Z');
|
|
60
|
+
|
|
61
|
+
// The agent has three questions. Each one replaces the one before it in the same card.
|
|
62
|
+
const questions = [
|
|
63
|
+
{
|
|
64
|
+
question: 'Which plans should the pricing page show?',
|
|
65
|
+
options: [
|
|
66
|
+
{ value: 'three', label: 'Free, Pro and Team' },
|
|
67
|
+
{ value: 'two', label: 'Pro and Team only' },
|
|
68
|
+
{ value: 'four', label: 'Free, Pro, Team and Enterprise' },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
question: 'Should prices show per month or per year?',
|
|
73
|
+
options: [
|
|
74
|
+
{ value: 'month', label: 'Per month' },
|
|
75
|
+
{ value: 'year', label: 'Per year' },
|
|
76
|
+
{ value: 'both', label: 'Both, with a switch' },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
question: 'Where should the plan table go?',
|
|
81
|
+
options: [
|
|
82
|
+
{ value: 'top', label: 'At the top of the page' },
|
|
83
|
+
{ value: 'below', label: 'Below the feature list' },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
// What the person did with each question: the label of the answer, or null when it was skipped.
|
|
89
|
+
type Outcome = string | null;
|
|
90
|
+
|
|
91
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
92
|
+
function agentMeta(at: Date) {
|
|
93
|
+
return (
|
|
94
|
+
<>
|
|
95
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
96
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
97
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default function AgentQuestionChoices() {
|
|
103
|
+
const [index, setIndex] = useState(0);
|
|
104
|
+
const [outcomes, setOutcomes] = useState<Outcome[]>([]);
|
|
105
|
+
// No option is recommended, so nothing starts selected.
|
|
106
|
+
const [selected, setSelected] = useState('');
|
|
107
|
+
const [pending, setPending] = useState<'answer' | 'skip' | null>(null);
|
|
108
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
109
|
+
|
|
110
|
+
// On unmount it stops the request.
|
|
111
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
112
|
+
|
|
113
|
+
const done = outcomes.length === questions.length;
|
|
114
|
+
const { question, options } = questions[index];
|
|
115
|
+
|
|
116
|
+
// After an answer or a skip, the next question replaces this one in the same card, with nothing selected.
|
|
117
|
+
// A real app moves focus to its first answer. After the last one the buttons are gone, and a real app
|
|
118
|
+
// moves focus to the message box.
|
|
119
|
+
function send(action: 'answer' | 'skip') {
|
|
120
|
+
if (pending || done || (action === 'answer' && selected === '')) return;
|
|
121
|
+
setPending(action);
|
|
122
|
+
const outcome = action === 'answer' ? options.find((o) => o.value === selected)?.label ?? null : null;
|
|
123
|
+
// Stands in for the request to the server.
|
|
124
|
+
timer.current = setTimeout(() => {
|
|
125
|
+
setPending(null);
|
|
126
|
+
setOutcomes((list) => [...list, outcome]);
|
|
127
|
+
setSelected('');
|
|
128
|
+
if (index < questions.length - 1) setIndex(index + 1);
|
|
129
|
+
}, 1200);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Center width="page">
|
|
134
|
+
<Stack gap="large">
|
|
135
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
136
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
137
|
+
<Stack gap="small">
|
|
138
|
+
<Message
|
|
139
|
+
aria-label={request.from}
|
|
140
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
141
|
+
name={request.from}
|
|
142
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
143
|
+
>
|
|
144
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
145
|
+
</Message>
|
|
146
|
+
<Message
|
|
147
|
+
aria-label={`${agentName}, agent`}
|
|
148
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
149
|
+
name={agentName}
|
|
150
|
+
meta={agentMeta(askedAt)}
|
|
151
|
+
>
|
|
152
|
+
<Surface padding="small">
|
|
153
|
+
{done ? (
|
|
154
|
+
// Every question is decided: the card is the record, with each answer or skip.
|
|
155
|
+
// A real app announces the decided Tag in a polite live region.
|
|
156
|
+
<Stack gap="medium">
|
|
157
|
+
{questions.map((q, i) => (
|
|
158
|
+
<Stack key={q.question} gap="small">
|
|
159
|
+
<Cluster gap="small">
|
|
160
|
+
<Heading level={2} size="subtitle1">{q.question}</Heading>
|
|
161
|
+
{outcomes[i] === null
|
|
162
|
+
? <Tag variant="contained" size="small" label="Skipped" />
|
|
163
|
+
: <Tag variant="contained" size="small" color="success" label="Answered" />}
|
|
164
|
+
</Cluster>
|
|
165
|
+
<Paragraph measure="none">{outcomes[i] ?? 'Acme Agent will list this as an open question in the plan.'}</Paragraph>
|
|
166
|
+
</Stack>
|
|
167
|
+
))}
|
|
168
|
+
</Stack>
|
|
169
|
+
) : (
|
|
170
|
+
<Stack gap="medium">
|
|
171
|
+
{/* The agent has more than one question, so the card says which one this is. */}
|
|
172
|
+
<Paragraph size="caption" tone="secondary" measure="none">{`Question ${index + 1} of ${questions.length}`}</Paragraph>
|
|
173
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
174
|
+
<RadioGroup
|
|
175
|
+
variant="card"
|
|
176
|
+
aria-label={question}
|
|
177
|
+
options={options}
|
|
178
|
+
selectedValue={selected}
|
|
179
|
+
onChange={setSelected}
|
|
180
|
+
disabled={pending !== null}
|
|
181
|
+
/>
|
|
182
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
183
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
184
|
+
<Cluster gap="small">
|
|
185
|
+
<Button size="small" type="tertiary" state={pending === 'answer' ? 'disabled' : 'enabled'} label="Skip" loading={pending === 'skip'} onClickButton={() => send('skip')} />
|
|
186
|
+
<Button
|
|
187
|
+
size="small"
|
|
188
|
+
type="primary"
|
|
189
|
+
state={selected === '' || pending === 'skip' ? 'disabled' : 'enabled'}
|
|
190
|
+
label="Answer"
|
|
191
|
+
loading={pending === 'answer'}
|
|
192
|
+
onClickButton={() => send('answer')}
|
|
193
|
+
/>
|
|
194
|
+
</Cluster>
|
|
195
|
+
</Stack>
|
|
196
|
+
)}
|
|
197
|
+
</Surface>
|
|
198
|
+
</Message>
|
|
199
|
+
</Stack>
|
|
200
|
+
</Stack>
|
|
201
|
+
</Center>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Option: Free text
|
|
207
|
+
|
|
208
|
+
Use when: The answer is the person's own words.
|
|
209
|
+
|
|
210
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `Stack`, `Surface`, `Tag`, `Textarea`, `TimeStamp`, `UserImage`
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
'use client';
|
|
214
|
+
import { useEffect, useRef, useState } from 'react';
|
|
215
|
+
import { Bot } from 'lucide-react';
|
|
216
|
+
import Message from 'oneslash-design-system/components/message';
|
|
217
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
218
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
219
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
220
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
221
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
222
|
+
import Button from 'oneslash-design-system/components/button';
|
|
223
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
224
|
+
import Textarea from 'oneslash-design-system/components/textarea';
|
|
225
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
226
|
+
|
|
227
|
+
const agentName = 'Acme Agent';
|
|
228
|
+
|
|
229
|
+
const request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you add the Team plan to the pricing page?' };
|
|
230
|
+
const askedAt = new Date('2025-01-15T11:41:00Z');
|
|
231
|
+
|
|
232
|
+
const question = 'What should the Team plan say under its price?';
|
|
233
|
+
|
|
234
|
+
type Status = 'open' | 'answered' | 'skipped';
|
|
235
|
+
|
|
236
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
237
|
+
function agentMeta(at: Date) {
|
|
238
|
+
return (
|
|
239
|
+
<>
|
|
240
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
241
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
242
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
243
|
+
</>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default function AgentQuestionFreeText() {
|
|
248
|
+
const [text, setText] = useState('');
|
|
249
|
+
const [status, setStatus] = useState<Status>('open');
|
|
250
|
+
const [pending, setPending] = useState<'answer' | 'skip' | null>(null);
|
|
251
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
252
|
+
|
|
253
|
+
// On unmount it stops the request.
|
|
254
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
255
|
+
|
|
256
|
+
const empty = text.trim() === '';
|
|
257
|
+
|
|
258
|
+
// Ctrl+Enter or Cmd+Enter in the field answers too, and Enter adds a line.
|
|
259
|
+
// Once it is answered or skipped the buttons are gone, and a real app moves focus to the message box.
|
|
260
|
+
function send(action: 'answer' | 'skip') {
|
|
261
|
+
if (pending || status !== 'open' || (action === 'answer' && empty)) return;
|
|
262
|
+
setPending(action);
|
|
263
|
+
// Stands in for the request to the server.
|
|
264
|
+
timer.current = setTimeout(() => {
|
|
265
|
+
setPending(null);
|
|
266
|
+
setStatus(action === 'answer' ? 'answered' : 'skipped');
|
|
267
|
+
}, 1200);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<Center width="page">
|
|
272
|
+
<Stack gap="large">
|
|
273
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
274
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
275
|
+
<Stack gap="small">
|
|
276
|
+
<Message
|
|
277
|
+
aria-label={request.from}
|
|
278
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
279
|
+
name={request.from}
|
|
280
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
281
|
+
>
|
|
282
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
283
|
+
</Message>
|
|
284
|
+
<Message
|
|
285
|
+
aria-label={`${agentName}, agent`}
|
|
286
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
287
|
+
name={agentName}
|
|
288
|
+
meta={agentMeta(askedAt)}
|
|
289
|
+
>
|
|
290
|
+
<Surface padding="small">
|
|
291
|
+
<Stack gap="medium">
|
|
292
|
+
{/* One question only, so there is no 'Question 1 of 3' line. */}
|
|
293
|
+
{/* A real app announces the decided Tag in a polite live region. */}
|
|
294
|
+
<Cluster gap="small">
|
|
295
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
296
|
+
{status === 'answered' && <Tag variant="contained" size="small" color="success" label="Answered" />}
|
|
297
|
+
{status === 'skipped' && <Tag variant="contained" size="small" label="Skipped" />}
|
|
298
|
+
</Cluster>
|
|
299
|
+
{status === 'open' && (
|
|
300
|
+
<>
|
|
301
|
+
<Textarea
|
|
302
|
+
id="agent-question-answer"
|
|
303
|
+
label="Your answer"
|
|
304
|
+
value={text}
|
|
305
|
+
onChange={(e) => setText(e.target.value)}
|
|
306
|
+
onSubmit={() => send('answer')}
|
|
307
|
+
disabled={pending !== null}
|
|
308
|
+
/>
|
|
309
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
310
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
311
|
+
<Cluster gap="small">
|
|
312
|
+
<Button size="small" type="tertiary" state={pending === 'answer' ? 'disabled' : 'enabled'} label="Skip" loading={pending === 'skip'} onClickButton={() => send('skip')} />
|
|
313
|
+
<Button
|
|
314
|
+
size="small"
|
|
315
|
+
type="primary"
|
|
316
|
+
state={empty || pending === 'skip' ? 'disabled' : 'enabled'}
|
|
317
|
+
label="Answer"
|
|
318
|
+
loading={pending === 'answer'}
|
|
319
|
+
onClickButton={() => send('answer')}
|
|
320
|
+
/>
|
|
321
|
+
</Cluster>
|
|
322
|
+
</>
|
|
323
|
+
)}
|
|
324
|
+
{status === 'answered' && <Paragraph measure="none">{text.trim()}</Paragraph>}
|
|
325
|
+
{status === 'skipped' && <Paragraph measure="none">Acme Agent will list this as an open question in the plan.</Paragraph>}
|
|
326
|
+
</Stack>
|
|
327
|
+
</Surface>
|
|
328
|
+
</Message>
|
|
329
|
+
</Stack>
|
|
330
|
+
</Stack>
|
|
331
|
+
</Center>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
```
|
|
@@ -6,8 +6,6 @@ The product will not let the agent answer a request, for example because the wor
|
|
|
6
6
|
|
|
7
7
|
The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.
|
|
8
8
|
|
|
9
|
-
**Not built yet:** Scindo on the web does not follow this yet: it shows the Upgrade button to everyone. Scindo's Apple app shows it only to admins.
|
|
10
|
-
|
|
11
9
|
## Why
|
|
12
10
|
|
|
13
11
|
A person who is refused needs to know why and what to do next, or they will just send the request again.
|
|
@@ -27,5 +25,3 @@ A person who is refused needs to know why and what to do next, or they will just
|
|
|
27
25
|
## Native
|
|
28
26
|
|
|
29
27
|
On Apple the refusal is a row above the composer, with an Upgrade or Change Budget Cap button for admins and never a link to a web page.
|
|
30
|
-
|
|
31
|
-
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentSettingsForm(): import("react").JSX.Element;
|