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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface AlertProps {
|
|
3
|
+
/** Lets a control point at the alert with `aria-describedby`, such as a Select whose save failed. */
|
|
4
|
+
id?: string;
|
|
3
5
|
open?: boolean;
|
|
4
6
|
type: 'success' | 'warning' | 'error' | 'info' | 'default';
|
|
5
7
|
message: string;
|
|
@@ -10,5 +12,5 @@ interface AlertProps {
|
|
|
10
12
|
/** Not set: the alert dismisses itself after 5 seconds unless it has a close button. `false` keeps it open; `true` dismisses it even with a close button. */
|
|
11
13
|
autoDismiss?: boolean;
|
|
12
14
|
}
|
|
13
|
-
export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
|
|
15
|
+
export default function Alert({ id, open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
|
|
14
16
|
export {};
|
|
@@ -18,7 +18,7 @@ var motionClasses = {
|
|
|
18
18
|
};
|
|
19
19
|
export default function Alert(_a) {
|
|
20
20
|
var _b;
|
|
21
|
-
var _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss;
|
|
21
|
+
var id = _a.id, _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss;
|
|
22
22
|
var _f = useState(false), isVisible = _f[0], setIsVisible = _f[1];
|
|
23
23
|
var _g = useState(false), shouldRender = _g[0], setShouldRender = _g[1];
|
|
24
24
|
// Auto-dismiss pauses while the toast is hovered or focused
|
|
@@ -66,7 +66,7 @@ export default function Alert(_a) {
|
|
|
66
66
|
var bgClasses = (_b = bgClassMap[type]) !== null && _b !== void 0 ? _b : bgClassMap.default;
|
|
67
67
|
// The default alert sits on secondary.main, whose label is secondary.contrast; the status backgrounds take text.primary
|
|
68
68
|
var textClasses = bgClasses === bgClassMap.default ? 'text-secondary-contrast' : 'text-fg-primary';
|
|
69
|
-
var alertContent = (<div
|
|
69
|
+
var alertContent = (<div id={id}
|
|
70
70
|
// Errors interrupt screen readers; everything else is announced politely
|
|
71
71
|
role={type === 'error' ? 'alert' : 'status'} onMouseEnter={function () { return setIsPaused(true); }} onMouseLeave={function () { return setIsPaused(false); }} onFocus={function () { return setIsPaused(true); }} onBlur={function () { return setIsPaused(false); }} className={"flex ".concat(secondMessage ? 'items-start' : 'items-center', " justify-between w-full p-2 rounded-control transition-[opacity,transform] ").concat(isVisible ? motionClasses.enter : motionClasses.exit, " motion-reduce:transition-none ").concat(bgClasses, " ").concat(isVisible ? 'opacity-100 translate-y-0' : variant === 'toast' ? 'opacity-0 -translate-y-[calc(100%+1rem)]' : 'opacity-0', " ").concat(variant === 'toast' ? 'max-w-md pointer-events-auto' : '')}>
|
|
72
72
|
<div className={"flex items-start gap-2 ".concat(textClasses)}>
|
|
@@ -29,5 +29,6 @@ interface ButtonProps extends React.AriaAttributes {
|
|
|
29
29
|
/** The `<button>`'s own `type`. Use `submit` for a form's submit button. Defaults to `button`. */
|
|
30
30
|
htmlType?: 'button' | 'submit' | 'reset';
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/** The ref reaches the `<button>`, or the `<a>` when `href` is set, so a page can move focus to it */
|
|
33
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
34
|
+
export default Button;
|
|
@@ -21,12 +21,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
}
|
|
22
22
|
return t;
|
|
23
23
|
};
|
|
24
|
-
import React from 'react';
|
|
24
|
+
import React, { forwardRef } from 'react';
|
|
25
25
|
import NextLink from 'next/link';
|
|
26
26
|
import IconSlot from './iconSlot';
|
|
27
27
|
import { LoadingSmall } from './loadingScreen';
|
|
28
28
|
import { focusRing, focusRingDanger, pressFeedback, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
29
|
-
|
|
29
|
+
/** The ref reaches the `<button>`, or the `<a>` when `href` is set, so a page can move focus to it */
|
|
30
|
+
var Button = forwardRef(function Button(_a, ref) {
|
|
30
31
|
var size = _a.size, type = _a.type, _b = _a.color, color = _b === void 0 ? 'default' : _b, state = _a.state, label = _a.label, secondLabel = _a.secondLabel, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.loading, loading = _d === void 0 ? false : _d, href = _a.href, _e = _a.openInNewTab, openInNewTab = _e === void 0 ? false : _e, replace = _a.replace, _f = _a.htmlType, htmlType = _f === void 0 ? 'button' : _f, rest = __rest(_a, ["size", "type", "color", "state", "label", "secondLabel", "decoIcon", "actionIcon", "onClickButton", "onClickActionIcon", "className", "loading", "href", "openInNewTab", "replace", "htmlType"]);
|
|
31
32
|
var isLink = href !== undefined;
|
|
32
33
|
// Horizontal padding sits on the button so an icon and the label are inset equally
|
|
@@ -104,11 +105,14 @@ export default function Button(_a) {
|
|
|
104
105
|
</div>
|
|
105
106
|
</div>
|
|
106
107
|
{actionIcon && (<span onClick={function (e) {
|
|
108
|
+
// With no handler of its own, the icon is part of the button and the click goes through
|
|
109
|
+
if (!onClickActionIcon)
|
|
110
|
+
return;
|
|
107
111
|
// Don't also trigger the button's own click, or follow the link
|
|
108
112
|
e.stopPropagation();
|
|
109
|
-
if (isLink
|
|
113
|
+
if (isLink)
|
|
110
114
|
e.preventDefault();
|
|
111
|
-
onClickActionIcon
|
|
115
|
+
onClickActionIcon();
|
|
112
116
|
}} className="cursor-pointer">
|
|
113
117
|
<IconSlot icon={actionIcon} className={"".concat(sizeIcon, " flex-shrink-0")}/>
|
|
114
118
|
</span>)}
|
|
@@ -116,18 +120,19 @@ export default function Button(_a) {
|
|
|
116
120
|
if (isLink) {
|
|
117
121
|
// A link cannot be disabled: without an href it is not focusable and does nothing
|
|
118
122
|
if (state === 'disabled' || loading) {
|
|
119
|
-
return (<a {...rest} role="link" aria-disabled="true" aria-busy={loading || undefined} className={buttonClasses}>
|
|
123
|
+
return (<a {...rest} ref={ref} role="link" aria-disabled="true" aria-busy={loading || undefined} className={buttonClasses}>
|
|
120
124
|
{content}
|
|
121
125
|
</a>);
|
|
122
126
|
}
|
|
123
127
|
var linkProps = __assign(__assign(__assign({}, rest), { className: buttonClasses, onClick: onClickButton }), (openInNewTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
124
128
|
// Same rule as Link: next/link for paths, a plain <a> for another site
|
|
125
129
|
if (href.startsWith('http://') || href.startsWith('https://')) {
|
|
126
|
-
return <a href={href} {...linkProps}>{content}</a>;
|
|
130
|
+
return <a href={href} {...linkProps} ref={ref}>{content}</a>;
|
|
127
131
|
}
|
|
128
|
-
return <NextLink href={href} replace={replace} {...linkProps}>{content}</NextLink>;
|
|
132
|
+
return <NextLink href={href} replace={replace} {...linkProps} ref={ref}>{content}</NextLink>;
|
|
129
133
|
}
|
|
130
|
-
return (<button {...rest} type={htmlType} className={buttonClasses} disabled={state === 'disabled' || loading} aria-busy={loading || undefined} onClick={onClickButton}>
|
|
134
|
+
return (<button {...rest} ref={ref} type={htmlType} className={buttonClasses} disabled={state === 'disabled' || loading} aria-busy={loading || undefined} onClick={onClickButton}>
|
|
131
135
|
{content}
|
|
132
136
|
</button>);
|
|
133
|
-
}
|
|
137
|
+
});
|
|
138
|
+
export default Button;
|
|
@@ -5,6 +5,10 @@ interface CheckboxProps {
|
|
|
5
5
|
checked?: boolean;
|
|
6
6
|
onChange?: (checked: boolean) => void;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
/** On the `<input>`, so a `FormField` label can point at it */
|
|
9
|
+
id?: string;
|
|
10
|
+
/** Id of the element that describes the checkbox, e.g. help or error text */
|
|
11
|
+
'aria-describedby'?: string;
|
|
8
12
|
}
|
|
9
|
-
export default function Checkbox({ label, secondLabel, checked, onChange, disabled }: CheckboxProps): React.JSX.Element;
|
|
13
|
+
export default function Checkbox({ label, secondLabel, checked, onChange, disabled, id, 'aria-describedby': ariaDescribedBy, }: CheckboxProps): React.JSX.Element;
|
|
10
14
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import { popTransition, stateTransition } from './sharedStyles';
|
|
4
4
|
export default function Checkbox(_a) {
|
|
5
|
-
var label = _a.label, secondLabel = _a.secondLabel, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
|
|
5
|
+
var label = _a.label, secondLabel = _a.secondLabel, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.disabled, disabled = _c === void 0 ? false : _c, id = _a.id, ariaDescribedBy = _a["aria-describedby"];
|
|
6
6
|
var _d = useState(checked), isChecked = _d[0], setIsChecked = _d[1];
|
|
7
7
|
// Follow the parent when it changes `checked` (e.g. resetting a form)
|
|
8
8
|
useEffect(function () {
|
|
@@ -16,7 +16,7 @@ export default function Checkbox(_a) {
|
|
|
16
16
|
};
|
|
17
17
|
return (<label className={"group relative flex items-start ".concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer')}>
|
|
18
18
|
{/* Native input keeps keyboard focus, Space to toggle and screen-reader semantics */}
|
|
19
|
-
<input type="checkbox" className="peer sr-only" checked={isChecked} disabled={disabled} onChange={handleChange}/>
|
|
19
|
+
<input type="checkbox" id={id} aria-describedby={ariaDescribedBy} className="peer sr-only" checked={isChecked} disabled={disabled} onChange={handleChange}/>
|
|
20
20
|
<span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary\n ").concat(disabled ? '' : 'group-hover:bg-action-selected')}>
|
|
21
21
|
{/* Checkbox */}
|
|
22
22
|
<span className={"relative w-4 h-4 border-2 rounded ".concat(stateTransition, " ").concat(disabled
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** `role` and every `aria-*` prop are passed to the `<textarea>`, as is the ref */
|
|
3
|
+
interface ComposerProps extends React.AriaAttributes {
|
|
4
|
+
/** On the text area */
|
|
5
|
+
id: string;
|
|
6
|
+
value: string;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Called by Enter (see `submitOnEnter`) and by the send control when there is something to send
|
|
10
|
+
* (`canSubmit`) and the Composer is not `disabled` or `sending`. Enter with nothing to send does
|
|
11
|
+
* nothing. The Composer never clears `value` itself: the caller owns it and sets it to `''` once
|
|
12
|
+
* the message is taken.
|
|
13
|
+
*/
|
|
14
|
+
onSubmit: () => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/** The text area's name. Required: the field has no visible label, and `placeholder` is not one. */
|
|
17
|
+
'aria-label': string;
|
|
18
|
+
/** On the text area: `combobox` while a mention or command list is attached to it */
|
|
19
|
+
role?: React.AriaRole;
|
|
20
|
+
/** The text area and the send control are disabled; `above` still shows. Disable your own `tools` and `actions`. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** The text area grows from one line to this many, then scrolls */
|
|
23
|
+
maxRows?: number;
|
|
24
|
+
autoFocus?: boolean;
|
|
25
|
+
/** Inside the border, over the text: attachment chips, a notice, a suggestion list */
|
|
26
|
+
above?: React.ReactNode;
|
|
27
|
+
/** Bottom left, inside the border: `IconButton`s such as attach or mention the agent */
|
|
28
|
+
tools?: React.ReactNode;
|
|
29
|
+
/** Bottom right, in place of the send or stop control: 'Cancel' and 'Save' when editing a message.
|
|
30
|
+
* Enter still calls `onSubmit` under the same rule. */
|
|
31
|
+
actions?: React.ReactNode;
|
|
32
|
+
/** The send control's name, kept while it shows `sending` */
|
|
33
|
+
sendLabel?: string;
|
|
34
|
+
/** The send control shows that it is loading, and Enter does not send */
|
|
35
|
+
sending?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* When set, the send control becomes a stop control that calls this. Stop stays pressable whatever
|
|
38
|
+
* the text and `canSubmit`, and while `disabled`, so a run can always be stopped. With both `onStop`
|
|
39
|
+
* and `sending`, the stop control shows and Enter is blocked. With `onStop` and without `sending`, Enter
|
|
40
|
+
* still calls `onSubmit`: a message to the people in the thread while an agent runs.
|
|
41
|
+
*/
|
|
42
|
+
onStop?: () => void;
|
|
43
|
+
stopLabel?: string;
|
|
44
|
+
/** Whether there is something to send. Defaults to: the trimmed value is not empty. Set it when an
|
|
45
|
+
* attachment alone can be sent. It drives Enter and the send control, never Stop. */
|
|
46
|
+
canSubmit?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* `true` (default): Enter sends and Shift+Enter adds a line. `false`: Enter adds a line and only the
|
|
49
|
+
* send control sends. Cmd+Enter and Ctrl+Enter send in both. Option/Alt+Enter counts as Enter. Set `false` on touch devices, where
|
|
50
|
+
* Return should add a line; an Android soft keyboard may also report Enter as keyCode 229, which
|
|
51
|
+
* counts as composing and so never sends.
|
|
52
|
+
*/
|
|
53
|
+
submitOnEnter?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Called first, for every key. Call `preventDefault()` to take a key from the Composer: a suggestion
|
|
56
|
+
* list does this for the arrows, Enter and Escape. For Escape also call `stopPropagation()`, so a
|
|
57
|
+
* Modal around the Composer does not close (Select does the same).
|
|
58
|
+
*/
|
|
59
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
60
|
+
/** On the text area, after the Composer's own focus tracking (the box's outline) */
|
|
61
|
+
onFocus?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
62
|
+
/** On the text area, after the Composer's own focus tracking. A suggestion list closes here. */
|
|
63
|
+
onBlur?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
64
|
+
/**
|
|
65
|
+
* React's `onSelect` on the text area: called while it has focus each time its caret or selection
|
|
66
|
+
* has moved, by typing, an arrow key, Home or End, a click or a drag. A key that leaves the caret
|
|
67
|
+
* where it was does not call it, and setting `value` does not call it by itself. Read
|
|
68
|
+
* `event.currentTarget.selectionStart` there: a suggestion list closes when the caret leaves the
|
|
69
|
+
* word it completes.
|
|
70
|
+
*/
|
|
71
|
+
onSelect?: (event: React.SyntheticEvent<HTMLTextAreaElement>) => void;
|
|
72
|
+
}
|
|
73
|
+
declare const Composer: React.ForwardRefExoticComponent<ComposerProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
74
|
+
export default Composer;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
14
|
+
import { ArrowUp, Square } from 'lucide-react';
|
|
15
|
+
import IconButton from './iconButton';
|
|
16
|
+
import { Cluster } from './layout';
|
|
17
|
+
import { stateTransition } from './sharedStyles';
|
|
18
|
+
import { fitToContent } from '../internal/autoGrow';
|
|
19
|
+
import { isComposing, shouldSubmit } from '../internal/composer';
|
|
20
|
+
// The outline the text area's focus gives the box: Textarea's focus look, on the border around everything
|
|
21
|
+
var focusedOutline = 'outline outline-1 outline-offset-2 outline-fg-primary';
|
|
22
|
+
// The message box: a text area with its tools inside one border. Enter sends, Shift+Enter adds a line,
|
|
23
|
+
// and Enter that confirms an input method's text (Korean, Japanese, Chinese) does neither.
|
|
24
|
+
var Composer = forwardRef(function Composer(_a, ref) {
|
|
25
|
+
var id = _a.id, value = _a.value, onChange = _a.onChange, onSubmit = _a.onSubmit, placeholder = _a.placeholder, ariaLabel = _a["aria-label"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? false : _d, above = _a.above, tools = _a.tools, actions = _a.actions, _e = _a.sendLabel, sendLabel = _e === void 0 ? 'Send' : _e, _f = _a.sending, sending = _f === void 0 ? false : _f, onStop = _a.onStop, _g = _a.stopLabel, stopLabel = _g === void 0 ? 'Stop' : _g, canSubmit = _a.canSubmit, _h = _a.submitOnEnter, submitOnEnter = _h === void 0 ? true : _h, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, onSelect = _a.onSelect, textareaProps = __rest(_a, ["id", "value", "onChange", "onSubmit", "placeholder", 'aria-label', "disabled", "maxRows", "autoFocus", "above", "tools", "actions", "sendLabel", "sending", "onStop", "stopLabel", "canSubmit", "submitOnEnter", "onKeyDown", "onFocus", "onBlur", "onSelect"]) // role and aria-*
|
|
26
|
+
;
|
|
27
|
+
var textareaRef = useRef(null);
|
|
28
|
+
useImperativeHandle(ref, function () { return textareaRef.current; }, []);
|
|
29
|
+
// Between compositionstart and compositionend
|
|
30
|
+
var composingRef = useRef(false);
|
|
31
|
+
var aboveRef = useRef(null);
|
|
32
|
+
var _j = useState(false), focused = _j[0], setFocused = _j[1];
|
|
33
|
+
var adjustHeight = useCallback(function () {
|
|
34
|
+
if (textareaRef.current)
|
|
35
|
+
fitToContent(textareaRef.current, maxRows);
|
|
36
|
+
}, [maxRows]);
|
|
37
|
+
// Also re-measure when the value changes from outside (e.g. cleared after submit)
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
adjustHeight();
|
|
40
|
+
}, [adjustHeight, value]);
|
|
41
|
+
var hasSomething = canSubmit !== null && canSubmit !== void 0 ? canSubmit : value.trim() !== '';
|
|
42
|
+
var canSend = hasSomething && !disabled && !sending;
|
|
43
|
+
var handleKeyDown = function (e) {
|
|
44
|
+
if (onKeyDown)
|
|
45
|
+
onKeyDown(e);
|
|
46
|
+
if (e.defaultPrevented || e.key !== 'Enter')
|
|
47
|
+
return;
|
|
48
|
+
var composing = isComposing({
|
|
49
|
+
composing: composingRef.current,
|
|
50
|
+
nativeIsComposing: e.nativeEvent.isComposing,
|
|
51
|
+
keyCode: e.keyCode,
|
|
52
|
+
});
|
|
53
|
+
if (composing)
|
|
54
|
+
return; // The input method's Enter
|
|
55
|
+
var submitKey = e.metaKey || e.ctrlKey || (submitOnEnter && !e.shiftKey);
|
|
56
|
+
if (!submitKey)
|
|
57
|
+
return; // A new line
|
|
58
|
+
e.preventDefault(); // A send key never adds a line, even when there is nothing to send
|
|
59
|
+
var submit = shouldSubmit({
|
|
60
|
+
key: e.key,
|
|
61
|
+
shiftKey: e.shiftKey,
|
|
62
|
+
metaKey: e.metaKey,
|
|
63
|
+
ctrlKey: e.ctrlKey,
|
|
64
|
+
isComposing: composing,
|
|
65
|
+
canSubmit: hasSomething,
|
|
66
|
+
disabled: disabled,
|
|
67
|
+
sending: sending,
|
|
68
|
+
submitOnEnter: submitOnEnter,
|
|
69
|
+
});
|
|
70
|
+
if (submit)
|
|
71
|
+
onSubmit();
|
|
72
|
+
};
|
|
73
|
+
// Keep focus in the field: the send control disables once the message is taken
|
|
74
|
+
var handleSend = function () {
|
|
75
|
+
var _a;
|
|
76
|
+
onSubmit();
|
|
77
|
+
(_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
78
|
+
};
|
|
79
|
+
// A press on the box's padding or the empty part of a row goes to the text area. In `above`, only a
|
|
80
|
+
// suggestion row does that (focus stays in the field, the click still lands); text there stays selectable.
|
|
81
|
+
var handleMouseDown = function (e) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
var target = e.target;
|
|
84
|
+
if (disabled || target.closest('button, a, input, textarea'))
|
|
85
|
+
return;
|
|
86
|
+
if (((_a = aboveRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) && !target.closest('[role="option"],[role="menuitem"]'))
|
|
87
|
+
return;
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
(_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
90
|
+
};
|
|
91
|
+
var boxClasses = disabled
|
|
92
|
+
? 'bg-transparent border-fg-disabled'
|
|
93
|
+
: "bg-background-default border-fg-disabled hover:border-fg-secondary cursor-text".concat(focused ? " ".concat(focusedOutline) : '');
|
|
94
|
+
var textClasses = disabled ? 'text-fg-disabled cursor-not-allowed' : 'text-fg-primary';
|
|
95
|
+
// IconButton names a loading button 'Loading'; aria-labelledby wins over that name
|
|
96
|
+
var sendLabelId = "".concat(id, "-send-label");
|
|
97
|
+
var control = actions !== null && actions !== void 0 ? actions : (onStop ? (<IconButton color="primary" state="enabled" size="small" icon={Square} ariaLabel={stopLabel} onClick={onStop}/>) : (<>
|
|
98
|
+
{sending && (<span id={sendLabelId} hidden>
|
|
99
|
+
{sendLabel}
|
|
100
|
+
</span>)}
|
|
101
|
+
<IconButton color="primary" state={canSend || sending ? 'enabled' : 'disabled'} size="small" icon={ArrowUp} ariaLabel={sendLabel} aria-labelledby={sending ? sendLabelId : undefined} loading={sending} onClick={canSend ? handleSend : undefined}/>
|
|
102
|
+
</>));
|
|
103
|
+
return (<div className={"flex flex-col gap-small w-full p-2 border rounded-control ".concat(stateTransition, " ").concat(boxClasses)} onMouseDown={handleMouseDown}>
|
|
104
|
+
{above && <div ref={aboveRef}>{above}</div>}
|
|
105
|
+
<textarea {...textareaProps} ref={textareaRef} id={id} rows={1} className={"block w-full px-1 bg-transparent outline-none resize-none [&::-webkit-scrollbar]:hidden text-body1 leading-[22px] placeholder:text-fg-disabled ".concat(textClasses)} value={value} onChange={function (e) { return onChange(e.target.value); }} onInput={adjustHeight} onKeyDown={handleKeyDown} onFocus={function (e) {
|
|
106
|
+
setFocused(true);
|
|
107
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
108
|
+
}} onBlur={function (e) {
|
|
109
|
+
setFocused(false);
|
|
110
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
111
|
+
}} onSelect={onSelect} onCompositionStart={function () {
|
|
112
|
+
composingRef.current = true;
|
|
113
|
+
}} onCompositionEnd={function () {
|
|
114
|
+
composingRef.current = false;
|
|
115
|
+
}} placeholder={placeholder} aria-label={ariaLabel} autoFocus={autoFocus} disabled={disabled} autoComplete="off"/>
|
|
116
|
+
<Cluster justify={tools ? 'between' : 'end'}>
|
|
117
|
+
{tools && <Cluster gap="small">{tools}</Cluster>}
|
|
118
|
+
{control}
|
|
119
|
+
</Cluster>
|
|
120
|
+
</div>);
|
|
121
|
+
});
|
|
122
|
+
export default Composer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface CopyFieldProps {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
/** The button's words. Defaults to "Copy". */
|
|
7
|
+
copyLabel?: string;
|
|
8
|
+
/** The button's words for 2 seconds after the text is on the clipboard. Defaults to "Copied". */
|
|
9
|
+
copiedLabel?: string;
|
|
10
|
+
/** A monospace font, for keys and addresses */
|
|
11
|
+
mono?: boolean;
|
|
12
|
+
/** `once` adds the line "Copy it now. You will not see it again." under the field, for a secret shown a single time */
|
|
13
|
+
reveal?: 'once';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A read-only field with a button at its right that copies its text. "Copied" shows only after the
|
|
17
|
+
* browser accepted the text; when it refuses or has no clipboard, a line says to copy by hand.
|
|
18
|
+
*/
|
|
19
|
+
export default function CopyField({ id, label, value, copyLabel, copiedLabel, mono, reveal, }: CopyFieldProps): React.JSX.Element;
|
|
20
|
+
export { CopyField };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
39
|
+
import { copyText } from '../internal/copyField';
|
|
40
|
+
import Button from './button';
|
|
41
|
+
import TextField from './textField';
|
|
42
|
+
/**
|
|
43
|
+
* A read-only field with a button at its right that copies its text. "Copied" shows only after the
|
|
44
|
+
* browser accepted the text; when it refuses or has no clipboard, a line says to copy by hand.
|
|
45
|
+
*/
|
|
46
|
+
export default function CopyField(_a) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
var id = _a.id, label = _a.label, value = _a.value, _b = _a.copyLabel, copyLabel = _b === void 0 ? 'Copy' : _b, _c = _a.copiedLabel, copiedLabel = _c === void 0 ? 'Copied' : _c, _d = _a.mono, mono = _d === void 0 ? false : _d, reveal = _a.reveal;
|
|
49
|
+
var _e = useState(false), copied = _e[0], setCopied = _e[1];
|
|
50
|
+
var _f = useState(false), blocked = _f[0], setBlocked = _f[1];
|
|
51
|
+
var timer = useRef(undefined);
|
|
52
|
+
var mounted = useRef(false);
|
|
53
|
+
useEffect(function () {
|
|
54
|
+
mounted.current = true;
|
|
55
|
+
return function () {
|
|
56
|
+
mounted.current = false;
|
|
57
|
+
clearTimeout(timer.current);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
var handleCopy = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
+
var ok;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, copyText(typeof navigator === 'undefined' ? undefined : navigator.clipboard, value)];
|
|
65
|
+
case 1:
|
|
66
|
+
ok = _a.sent();
|
|
67
|
+
if (!mounted.current)
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
clearTimeout(timer.current);
|
|
70
|
+
setBlocked(!ok);
|
|
71
|
+
setCopied(ok);
|
|
72
|
+
if (ok)
|
|
73
|
+
timer.current = setTimeout(function () { return setCopied(false); }, 2000);
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
var revealId = "".concat(id, "-reveal");
|
|
79
|
+
var blockedId = "".concat(id, "-blocked");
|
|
80
|
+
var describedBy = [reveal ? revealId : '', blocked ? blockedId : ''].filter(Boolean).join(' ') || undefined;
|
|
81
|
+
return (<div className="flex flex-col w-full">
|
|
82
|
+
<div className={"flex items-end gap-2".concat(mono ? ' [&_input]:font-mono' : '')}>
|
|
83
|
+
<TextField id={id} label={label} value={value} readOnly onChange={function () { }} onFocus={function (e) { return e.target.select(); }} aria-describedby={describedBy}/>
|
|
84
|
+
<div className="flex-shrink-0">
|
|
85
|
+
<Button size="medium" type="secondary" state="enabled" label={copied ? copiedLabel : copyLabel} aria-label={"".concat(copied ? copiedLabel : copyLabel, " ").concat(label)} onClickButton={handleCopy}/>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
{reveal && (<p id={revealId} className="mt-1 text-fg-secondary text-body2">
|
|
89
|
+
Copy it now. You will not see it again.
|
|
90
|
+
</p>)}
|
|
91
|
+
{blocked && (<p id={blockedId} role="alert" className="mt-1 text-error-text text-body2">
|
|
92
|
+
Copying is blocked here. Select the text and copy it.
|
|
93
|
+
</p>)}
|
|
94
|
+
<span role="status" className="sr-only">
|
|
95
|
+
{copied ? copiedLabel : ''}
|
|
96
|
+
</span>
|
|
97
|
+
</div>);
|
|
98
|
+
}
|
|
99
|
+
export { CopyField };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface FileChipProps {
|
|
3
|
+
/** One line; a longer name is cut at the end with an ellipsis */
|
|
4
|
+
name: string;
|
|
5
|
+
/** A short type label such as 'PDF', shown in a small tinted box before the name */
|
|
6
|
+
kind?: string;
|
|
7
|
+
/**
|
|
8
|
+
* One line of secondary text: the size, or the status. An uploading or failed chip
|
|
9
|
+
* does not announce its state in words, so put the words here ('Uploading', 'Upload failed').
|
|
10
|
+
* A change of `state` is not announced either: when it matters, the caller announces it in a live region.
|
|
11
|
+
*/
|
|
12
|
+
meta?: string;
|
|
13
|
+
/** Default `ready`. `uploading` shows a spinner in place of `kind` and sets `aria-busy`; `failed` shows an alert icon and the error color. */
|
|
14
|
+
state?: 'ready' | 'uploading' | 'failed';
|
|
15
|
+
/**
|
|
16
|
+
* Adds a remove button beside the name. A failed chip can still be removed. After it runs, the
|
|
17
|
+
* caller moves focus: to the next chip, or to the message box when none is left.
|
|
18
|
+
*/
|
|
19
|
+
onRemove?: () => void;
|
|
20
|
+
/** Default `Remove <name>` */
|
|
21
|
+
removeLabel?: string;
|
|
22
|
+
/** Makes the name part a link. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
|
|
23
|
+
href?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Makes the name part a button. Ignored when `href` is set: the link wins and `onClick` does not run.
|
|
26
|
+
* A retry for a failed chip is the caller's: pass `onClick` that retries, and a `meta` such as 'Failed. Try again'.
|
|
27
|
+
*/
|
|
28
|
+
onClick?: () => void;
|
|
29
|
+
/** With `href`: open in a new tab. Another site (`http(s)://`) always opens in a new tab. */
|
|
30
|
+
openInNewTab?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export default function FileChip({ name, kind, meta, state, onRemove, removeLabel, href, onClick, openInNewTab, }: FileChipProps): React.JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import NextLink from 'next/link';
|
|
15
|
+
import { AlertCircle, X } from 'lucide-react';
|
|
16
|
+
import IconButton from './iconButton';
|
|
17
|
+
import { LoadingSmall } from './loadingScreen';
|
|
18
|
+
import { focusRing, stateTransition } from './sharedStyles';
|
|
19
|
+
// A file attached to a message, waiting in the message box or already sent. One row, at most
|
|
20
|
+
// 28rem wide so a long name does not stretch it. The name part is the link or button; the remove
|
|
21
|
+
// button is its sibling, never inside it. With no `href` and no `onClick` the name is static text.
|
|
22
|
+
export default function FileChip(_a) {
|
|
23
|
+
var name = _a.name, kind = _a.kind, meta = _a.meta, _b = _a.state, state = _b === void 0 ? 'ready' : _b, onRemove = _a.onRemove, removeLabel = _a.removeLabel, href = _a.href, onClick = _a.onClick, _c = _a.openInNewTab, openInNewTab = _c === void 0 ? false : _c;
|
|
24
|
+
var failed = state === 'failed';
|
|
25
|
+
var interactive = href !== undefined || onClick !== undefined;
|
|
26
|
+
var nameClasses = "flex min-w-0 flex-1 items-center gap-2 rounded-control text-left".concat(interactive ? " cursor-pointer ".concat(stateTransition, " ").concat(focusRing) : '');
|
|
27
|
+
var lead = state === 'uploading' ? (
|
|
28
|
+
// The caller says "Uploading" in `meta`; the spinner's own "Loading" status is hidden.
|
|
29
|
+
<span aria-hidden="true" className="flex size-6 shrink-0 items-center justify-center text-fg-primary">
|
|
30
|
+
<LoadingSmall size="tiny"/>
|
|
31
|
+
</span>) : failed ? (<AlertCircle role="img" aria-label="Failed" className="size-6 shrink-0 p-1 text-error-text" strokeWidth={2}/>) : kind ? (<span aria-hidden="true" className="flex h-6 shrink-0 items-center rounded-inline bg-background-accent300 px-1.5 text-caption text-fg-primary">
|
|
32
|
+
{kind}
|
|
33
|
+
</span>) : null;
|
|
34
|
+
var content = (<>
|
|
35
|
+
{lead}
|
|
36
|
+
<span className="truncate text-body2 text-fg-primary">{name}</span>
|
|
37
|
+
{meta && <span className={"shrink-0 text-caption ".concat(failed ? 'text-error-text' : 'text-fg-secondary')}>{meta}</span>}
|
|
38
|
+
</>);
|
|
39
|
+
// A link or button is named in one string: the failed state first, then the name and the meta.
|
|
40
|
+
// Static, the name and the meta are separate flex items, so they are read as separate words.
|
|
41
|
+
var label = [failed && 'Failed', name, meta].filter(Boolean).join(', ');
|
|
42
|
+
var main;
|
|
43
|
+
if (href !== undefined) {
|
|
44
|
+
var isExternal = href.startsWith('http://') || href.startsWith('https://');
|
|
45
|
+
var newTab = openInNewTab || isExternal;
|
|
46
|
+
var props = __assign({ className: "".concat(nameClasses, " hover:bg-background-accent200"), 'aria-label': label }, (newTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
47
|
+
main = newTab ? <a href={href} {...props}>{content}</a> : <NextLink href={href} {...props}>{content}</NextLink>;
|
|
48
|
+
}
|
|
49
|
+
else if (onClick) {
|
|
50
|
+
main = (<button type="button" className={"".concat(nameClasses, " hover:bg-background-accent200")} onClick={onClick} aria-label={label}>
|
|
51
|
+
{content}
|
|
52
|
+
</button>);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
main = <span className={nameClasses}>{content}</span>;
|
|
56
|
+
}
|
|
57
|
+
return (<div aria-busy={state === 'uploading' ? true : undefined} className={"inline-flex max-w-md items-center gap-1 rounded-control border px-2 py-1 ".concat(failed ? 'border-error-main' : 'border-fg-disabled')}>
|
|
58
|
+
{main}
|
|
59
|
+
{onRemove && (<IconButton color="iconOnly" state="enabled" size="small" icon={X} ariaLabel={removeLabel !== null && removeLabel !== void 0 ? removeLabel : "Remove ".concat(name)} onClick={onRemove}/>)}
|
|
60
|
+
</div>);
|
|
61
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
/** What a FormField hands to its control */
|
|
3
|
+
export interface FormFieldControlProps {
|
|
4
|
+
id: string;
|
|
5
|
+
/** The help text's id, or the error text's id while there is an error. Absent when neither is shown. */
|
|
6
|
+
'aria-describedby'?: string;
|
|
7
|
+
/** `true` while there is an error. Absent otherwise. */
|
|
8
|
+
'aria-invalid'?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface FormFieldProps {
|
|
11
|
+
/** The control's id. The label points at it. */
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
/** A line under the control. The error replaces it while `error` is set. */
|
|
15
|
+
help?: string;
|
|
16
|
+
/** Shown under the control in place of the help text, and marks the control invalid */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** Adds a required mark to the label that screen readers read as "required" */
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A function that returns the control, e.g.
|
|
22
|
+
* `{(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} … />}`.
|
|
23
|
+
* A render prop, not a cloned child: the ids reach the control through props you can see, so
|
|
24
|
+
* nothing needs a `className`, a spread or a wrapper, and it works with any ODS control that
|
|
25
|
+
* takes `id` and `aria-describedby` (TextField, Textarea, Select, RadioGroup, Checkbox). Only
|
|
26
|
+
* TextField and Textarea take `aria-invalid`.
|
|
27
|
+
* The `<label for>` only names an input, textarea or button. Give a Select or RadioGroup the same
|
|
28
|
+
* text as its `aria-label`.
|
|
29
|
+
*/
|
|
30
|
+
children: (field: FormFieldControlProps) => ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/** A label, a control and its help or error text, tied together for screen readers */
|
|
33
|
+
export default function FormField({ id, label, help, error, required, children }: FormFieldProps): React.JSX.Element;
|
|
34
|
+
export { FormField };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** A label, a control and its help or error text, tied together for screen readers */
|
|
3
|
+
export default function FormField(_a) {
|
|
4
|
+
var id = _a.id, label = _a.label, help = _a.help, error = _a.error, _b = _a.required, required = _b === void 0 ? false : _b, children = _a.children;
|
|
5
|
+
var helpId = "".concat(id, "-help");
|
|
6
|
+
var errorId = "".concat(id, "-error");
|
|
7
|
+
var describedBy = error ? errorId : help ? helpId : undefined;
|
|
8
|
+
return (<div className="flex flex-col w-full">
|
|
9
|
+
<label htmlFor={id} className="mb-1 text-body2 text-fg-secondary">
|
|
10
|
+
{label}
|
|
11
|
+
{required && (<>
|
|
12
|
+
<span aria-hidden="true" className="text-error-text ml-0.5">*</span>
|
|
13
|
+
<span className="sr-only"> required</span>
|
|
14
|
+
</>)}
|
|
15
|
+
</label>
|
|
16
|
+
{children({
|
|
17
|
+
id: id,
|
|
18
|
+
'aria-describedby': describedBy,
|
|
19
|
+
'aria-invalid': error ? true : undefined,
|
|
20
|
+
})}
|
|
21
|
+
{error ? (<p id={errorId} className="mt-1 text-error-text text-body2">
|
|
22
|
+
{error}
|
|
23
|
+
</p>) : (help && (<p id={helpId} className="mt-1 text-fg-secondary text-body2">
|
|
24
|
+
{help}
|
|
25
|
+
</p>))}
|
|
26
|
+
</div>);
|
|
27
|
+
}
|
|
28
|
+
export { FormField };
|
|
@@ -5,8 +5,10 @@ interface HeadingProps {
|
|
|
5
5
|
level?: 1 | 2 | 3 | 4;
|
|
6
6
|
/** How large it is set. */
|
|
7
7
|
size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
|
|
8
|
+
/** `danger` gives the heading the error text color, for a danger zone. */
|
|
9
|
+
color?: 'default' | 'danger';
|
|
8
10
|
id?: string;
|
|
9
11
|
className?: string;
|
|
10
12
|
}
|
|
11
|
-
export default function Heading({ children, level, size, id, className }: HeadingProps): React.JSX.Element;
|
|
13
|
+
export default function Heading({ children, level, size, color, id, className }: HeadingProps): React.JSX.Element;
|
|
12
14
|
export {};
|