oneslash-design-system 2.15.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/DESIGN.md +100 -73
- package/dist/cases/accept-invite/signed-in.d.ts +1 -0
- package/dist/cases/accept-invite/signed-in.jsx +57 -0
- package/dist/cases/accept-invite/signed-out.d.ts +1 -0
- package/dist/cases/accept-invite/signed-out.jsx +33 -0
- package/dist/cases/accept-invite.md +161 -0
- package/dist/cases/agent-asks-before-risky-action.md +1 -1
- package/dist/cases/agent-cancels-when-unanswered.md +1 -1
- package/dist/cases/agent-options/cards.d.ts +1 -0
- package/dist/cases/agent-options/cards.jsx +91 -0
- package/dist/cases/agent-options.md +168 -0
- package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
- package/dist/cases/agent-pending-reply/steps.jsx +149 -0
- package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
- package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
- package/dist/cases/agent-pending-reply.md +432 -0
- package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
- package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
- package/dist/cases/agent-plan-proposal.md +656 -0
- package/dist/cases/agent-question/choices.d.ts +1 -0
- package/dist/cases/agent-question/choices.jsx +132 -0
- package/dist/cases/agent-question/free-text.d.ts +1 -0
- package/dist/cases/agent-question/free-text.jsx +81 -0
- package/dist/cases/agent-question.md +338 -0
- package/dist/cases/agent-shows-sources.md +2 -2
- package/dist/cases/artifact-card/card.d.ts +1 -0
- package/dist/cases/artifact-card/card.jsx +45 -0
- package/dist/cases/artifact-card.md +103 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
- package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
- package/dist/cases/auth-gate-loading.md +70 -0
- package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
- package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
- package/dist/cases/check-your-email/page.d.ts +1 -0
- package/dist/cases/check-your-email/page.jsx +49 -0
- package/dist/cases/check-your-email.md +184 -0
- package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
- package/dist/cases/composer-limit/notice.d.ts +1 -0
- package/dist/cases/composer-limit/notice.jsx +84 -0
- package/dist/cases/composer-limit.md +286 -0
- package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
- package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
- package/dist/cases/confirm-destructive-action.md +211 -0
- package/dist/cases/confirm-dialogs.md +36 -0
- package/dist/cases/conversation-starters/chips.d.ts +1 -0
- package/dist/cases/conversation-starters/chips.jsx +69 -0
- package/dist/cases/conversation-starters/none.d.ts +1 -0
- package/dist/cases/conversation-starters/none.jsx +45 -0
- package/dist/cases/conversation-starters.md +208 -0
- package/dist/cases/create-modal/quick.d.ts +1 -0
- package/dist/cases/create-modal/quick.jsx +80 -0
- package/dist/cases/create-modal/with-settings.d.ts +1 -0
- package/dist/cases/create-modal/with-settings.jsx +99 -0
- package/dist/cases/create-modal.md +244 -0
- package/dist/cases/device-login/popup.d.ts +1 -0
- package/dist/cases/device-login/popup.jsx +14 -0
- package/dist/cases/device-login/provider-first.d.ts +1 -0
- package/dist/cases/device-login/provider-first.jsx +98 -0
- package/dist/cases/device-login.md +171 -0
- package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
- package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
- package/dist/cases/email-confirmed/page.d.ts +1 -0
- package/dist/cases/email-confirmed/page.jsx +21 -0
- package/dist/cases/email-confirmed.md +151 -0
- package/dist/cases/empty-list/region.d.ts +1 -0
- package/dist/cases/empty-list/region.jsx +13 -0
- package/dist/cases/empty-list/section.d.ts +1 -0
- package/dist/cases/empty-list/section.jsx +17 -0
- package/dist/cases/empty-list.md +77 -0
- package/dist/cases/empty-lists.md +35 -0
- package/dist/cases/empty-not-set-up/action.d.ts +1 -0
- package/dist/cases/empty-not-set-up/action.jsx +16 -0
- package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
- package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
- package/dist/cases/empty-not-set-up.md +88 -0
- package/dist/cases/empty-search/clear-search.d.ts +1 -0
- package/dist/cases/empty-search/clear-search.jsx +29 -0
- package/dist/cases/empty-search.md +77 -0
- package/dist/cases/error-page/full-page.d.ts +1 -0
- package/dist/cases/error-page/full-page.jsx +19 -0
- package/dist/cases/error-page/in-shell.d.ts +1 -0
- package/dist/cases/error-page/in-shell.jsx +39 -0
- package/dist/cases/error-page.md +107 -0
- package/dist/cases/feedback-form/modal.d.ts +1 -0
- package/dist/cases/feedback-form/modal.jsx +89 -0
- package/dist/cases/feedback-form.md +139 -0
- package/dist/cases/forgot-password/in-place.d.ts +1 -0
- package/dist/cases/forgot-password/in-place.jsx +155 -0
- package/dist/cases/forgot-password/own-page.d.ts +1 -0
- package/dist/cases/forgot-password/own-page.jsx +99 -0
- package/dist/cases/forgot-password.md +328 -0
- package/dist/cases/form-errors.md +32 -0
- package/dist/cases/import-checklist/modal.d.ts +1 -0
- package/dist/cases/import-checklist/modal.jsx +125 -0
- package/dist/cases/import-checklist.md +188 -0
- package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
- package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
- package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
- package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
- package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
- package/dist/cases/inline-form-feedback/toast.jsx +66 -0
- package/dist/cases/inline-form-feedback.md +237 -0
- package/dist/cases/invite-member/by-email.d.ts +1 -0
- package/dist/cases/invite-member/by-email.jsx +98 -0
- package/dist/cases/invite-member/by-link.d.ts +1 -0
- package/dist/cases/invite-member/by-link.jsx +122 -0
- package/dist/cases/invite-member.md +321 -0
- package/dist/cases/load-failure/inline.d.ts +1 -0
- package/dist/cases/load-failure/inline.jsx +52 -0
- package/dist/cases/load-failure/region.d.ts +1 -0
- package/dist/cases/load-failure/region.jsx +34 -0
- package/dist/cases/load-failure.md +155 -0
- package/dist/cases/log-out-confirm/modal.d.ts +1 -0
- package/dist/cases/log-out-confirm/modal.jsx +57 -0
- package/dist/cases/log-out-confirm.md +106 -0
- package/dist/cases/login-page/centered.jsx +10 -7
- package/dist/cases/login-page/email-only.jsx +11 -8
- package/dist/cases/login-page/provider-first.jsx +12 -9
- package/dist/cases/login-page/split.jsx +11 -8
- package/dist/cases/login-page.md +58 -41
- package/dist/cases/mention-list/in-composer.d.ts +1 -0
- package/dist/cases/mention-list/in-composer.jsx +169 -0
- package/dist/cases/mention-list.md +252 -0
- package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
- package/dist/cases/message-actions/menu.d.ts +1 -0
- package/dist/cases/message-actions/menu.jsx +258 -0
- package/dist/cases/message-actions.md +651 -0
- package/dist/cases/message-attachments/in-composer.d.ts +1 -0
- package/dist/cases/message-attachments/in-composer.jsx +134 -0
- package/dist/cases/message-attachments/in-message.d.ts +1 -0
- package/dist/cases/message-attachments/in-message.jsx +46 -0
- package/dist/cases/message-attachments.md +310 -0
- package/dist/cases/message-composer/plain.d.ts +1 -0
- package/dist/cases/message-composer/plain.jsx +57 -0
- package/dist/cases/message-composer/with-tools.d.ts +1 -0
- package/dist/cases/message-composer/with-tools.jsx +182 -0
- package/dist/cases/message-composer.md +356 -0
- package/dist/cases/message-edit/in-place.d.ts +1 -0
- package/dist/cases/message-edit/in-place.jsx +99 -0
- package/dist/cases/message-edit.md +179 -0
- package/dist/cases/message-reactions/chips.d.ts +1 -0
- package/dist/cases/message-reactions/chips.jsx +118 -0
- package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
- package/dist/cases/message-reactions/quick-pick.jsx +155 -0
- package/dist/cases/message-reactions.md +371 -0
- package/dist/cases/message-row/grouped.d.ts +1 -0
- package/dist/cases/message-row/grouped.jsx +56 -0
- package/dist/cases/message-row/person-and-agent.d.ts +1 -0
- package/dist/cases/message-row/person-and-agent.jsx +41 -0
- package/dist/cases/message-row.md +189 -0
- package/dist/cases/not-found-page/full-page.d.ts +1 -0
- package/dist/cases/not-found-page/full-page.jsx +16 -0
- package/dist/cases/not-found-page/in-shell.d.ts +1 -0
- package/dist/cases/not-found-page/in-shell.jsx +36 -0
- package/dist/cases/not-found-page.md +98 -0
- package/dist/cases/oauth-consent/simple.d.ts +1 -0
- package/dist/cases/oauth-consent/simple.jsx +73 -0
- package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
- package/dist/cases/oauth-consent/with-scope.jsx +89 -0
- package/dist/cases/oauth-consent.md +233 -0
- package/dist/cases/rename/inline.d.ts +1 -0
- package/dist/cases/rename/inline.jsx +58 -0
- package/dist/cases/rename/modal.d.ts +1 -0
- package/dist/cases/rename/modal.jsx +70 -0
- package/dist/cases/rename.md +205 -0
- package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
- package/dist/cases/reply-feedback/thumbs.jsx +191 -0
- package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
- package/dist/cases/reply-feedback/with-reason.jsx +221 -0
- package/dist/cases/reply-feedback.md +552 -0
- package/dist/cases/reply-sources/cards.d.ts +1 -0
- package/dist/cases/reply-sources/cards.jsx +83 -0
- package/dist/cases/reply-sources/tag-only.d.ts +1 -0
- package/dist/cases/reply-sources/tag-only.jsx +45 -0
- package/dist/cases/reply-sources.md +247 -0
- package/dist/cases/route-loading/full-screen.d.ts +1 -0
- package/dist/cases/route-loading/full-screen.jsx +8 -0
- package/dist/cases/route-loading/region.d.ts +1 -0
- package/dist/cases/route-loading/region.jsx +26 -0
- package/dist/cases/route-loading.md +84 -0
- package/dist/cases/set-new-password/form.d.ts +1 -0
- package/dist/cases/set-new-password/form.jsx +130 -0
- package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
- package/dist/cases/set-new-password/invalid-link.jsx +50 -0
- package/dist/cases/set-new-password.md +247 -0
- package/dist/cases/sign-up-page/centered.d.ts +1 -0
- package/dist/cases/sign-up-page/centered.jsx +124 -0
- package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
- package/dist/cases/sign-up-page/provider-first.jsx +124 -0
- package/dist/cases/sign-up-page/split.d.ts +1 -0
- package/dist/cases/sign-up-page/split.jsx +134 -0
- package/dist/cases/sign-up-page.md +478 -0
- package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
- package/dist/cases/slash-command-list/in-composer.jsx +162 -0
- package/dist/cases/slash-command-list.md +247 -0
- package/dist/cases/success-feedback.md +35 -0
- package/dist/cases/type-to-confirm/inline.d.ts +1 -0
- package/dist/cases/type-to-confirm/inline.jsx +69 -0
- package/dist/cases/type-to-confirm/modal.d.ts +1 -0
- package/dist/cases/type-to-confirm/modal.jsx +73 -0
- package/dist/cases/type-to-confirm.md +222 -0
- package/dist/cases/typing-and-status/line.d.ts +1 -0
- package/dist/cases/typing-and-status/line.jsx +50 -0
- package/dist/cases/typing-and-status.md +96 -0
- package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
- package/dist/cases/unsaved-changes-guard.md +239 -0
- package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
- package/dist/cases/upgrade-prompt/inline.jsx +52 -0
- package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
- package/dist/cases/upgrade-prompt/modal.jsx +43 -0
- package/dist/cases/upgrade-prompt.md +174 -0
- package/dist/cases.json +3138 -59
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +9 -7
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/heading.d.ts +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/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +9 -1
- package/dist/components/menuItem.jsx +5 -4
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- 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 +9 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- 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/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +7 -3
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/textarea.jsx +3 -18
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.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/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/internal/modal.d.ts +2 -0
- package/dist/internal/modal.js +21 -0
- package/dist/internal/toaster.d.ts +19 -0
- package/dist/internal/toaster.js +50 -0
- package/dist/native-mapping.json +38 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- 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 +82 -0
- package/dist/stories/Cases.generated.stories.jsx +164 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- 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/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +36 -0
- package/dist/stories/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +3 -0
- package/dist/stories/RadioGroup.stories.jsx +54 -1
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -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/TabsContainer.stories.d.ts +1 -0
- package/dist/stories/TabsContainer.stories.jsx +12 -0
- package/dist/stories/TextField.stories.d.ts +2 -0
- package/dist/stories/TextField.stories.jsx +22 -0
- package/dist/stories/Toaster.stories.d.ts +6 -0
- package/dist/stories/Toaster.stories.jsx +29 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +4 -3
|
@@ -7,6 +7,8 @@ interface AlertProps {
|
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
showCloseButton?: boolean;
|
|
9
9
|
variant?: 'toast' | 'inline';
|
|
10
|
+
/** 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
|
+
autoDismiss?: boolean;
|
|
10
12
|
}
|
|
11
|
-
export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, }: AlertProps): React.JSX.Element | null;
|
|
13
|
+
export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
|
|
12
14
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import IconButton from './iconButton';
|
|
4
|
+
import { shouldAutoDismiss } from '../internal/alert';
|
|
4
5
|
var bgClassMap = {
|
|
5
6
|
error: 'bg-error-alertBg',
|
|
6
7
|
warning: 'bg-warning-alertBg',
|
|
@@ -17,7 +18,7 @@ var motionClasses = {
|
|
|
17
18
|
};
|
|
18
19
|
export default function Alert(_a) {
|
|
19
20
|
var _b;
|
|
20
|
-
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;
|
|
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
22
|
var _f = useState(false), isVisible = _f[0], setIsVisible = _f[1];
|
|
22
23
|
var _g = useState(false), shouldRender = _g[0], setShouldRender = _g[1];
|
|
23
24
|
// Auto-dismiss pauses while the toast is hovered or focused
|
|
@@ -40,9 +41,10 @@ export default function Alert(_a) {
|
|
|
40
41
|
return function () { return clearTimeout(hideTimer_1); };
|
|
41
42
|
}
|
|
42
43
|
}, [open, showCloseButton, shouldRender]);
|
|
43
|
-
//
|
|
44
|
+
// Auto-dismiss unless autoDismiss says otherwise; by default only an alert with no close button
|
|
45
|
+
var autoDismissOn = shouldAutoDismiss({ autoDismiss: autoDismiss, showCloseButton: showCloseButton });
|
|
44
46
|
useEffect(function () {
|
|
45
|
-
if (!open || !shouldRender ||
|
|
47
|
+
if (!open || !shouldRender || !autoDismissOn || isPaused)
|
|
46
48
|
return;
|
|
47
49
|
var startedAt = Date.now();
|
|
48
50
|
var dismissTimer = setTimeout(function () { return handleClose(); }, remainingMs.current);
|
|
@@ -50,7 +52,7 @@ export default function Alert(_a) {
|
|
|
50
52
|
clearTimeout(dismissTimer);
|
|
51
53
|
remainingMs.current -= Date.now() - startedAt;
|
|
52
54
|
};
|
|
53
|
-
}, [open, shouldRender,
|
|
55
|
+
}, [open, shouldRender, autoDismissOn, isPaused]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
54
56
|
var handleClose = function () {
|
|
55
57
|
setIsVisible(false);
|
|
56
58
|
// Wait for animation to complete before unmounting
|
|
@@ -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
|
|
@@ -116,18 +117,19 @@ export default function Button(_a) {
|
|
|
116
117
|
if (isLink) {
|
|
117
118
|
// A link cannot be disabled: without an href it is not focusable and does nothing
|
|
118
119
|
if (state === 'disabled' || loading) {
|
|
119
|
-
return (<a {...rest} role="link" aria-disabled="true" aria-busy={loading || undefined} className={buttonClasses}>
|
|
120
|
+
return (<a {...rest} ref={ref} role="link" aria-disabled="true" aria-busy={loading || undefined} className={buttonClasses}>
|
|
120
121
|
{content}
|
|
121
122
|
</a>);
|
|
122
123
|
}
|
|
123
124
|
var linkProps = __assign(__assign(__assign({}, rest), { className: buttonClasses, onClick: onClickButton }), (openInNewTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
124
125
|
// Same rule as Link: next/link for paths, a plain <a> for another site
|
|
125
126
|
if (href.startsWith('http://') || href.startsWith('https://')) {
|
|
126
|
-
return <a href={href} {...linkProps}>{content}</a>;
|
|
127
|
+
return <a href={href} {...linkProps} ref={ref}>{content}</a>;
|
|
127
128
|
}
|
|
128
|
-
return <NextLink href={href} replace={replace} {...linkProps}>{content}</NextLink>;
|
|
129
|
+
return <NextLink href={href} replace={replace} {...linkProps} ref={ref}>{content}</NextLink>;
|
|
129
130
|
}
|
|
130
|
-
return (<button {...rest} type={htmlType} className={buttonClasses} disabled={state === 'disabled' || loading} aria-busy={loading || undefined} onClick={onClickButton}>
|
|
131
|
+
return (<button {...rest} ref={ref} type={htmlType} className={buttonClasses} disabled={state === 'disabled' || loading} aria-busy={loading || undefined} onClick={onClickButton}>
|
|
131
132
|
{content}
|
|
132
133
|
</button>);
|
|
133
|
-
}
|
|
134
|
+
});
|
|
135
|
+
export default Button;
|
|
@@ -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;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type IconSource } from './iconSlot';
|
|
2
3
|
interface EmptyBoxProps {
|
|
3
4
|
text: string;
|
|
4
5
|
secondText?: string;
|
|
5
6
|
size: "small" | "large";
|
|
7
|
+
/** Shown under the text, centered, for the one thing to do next. Wrap more than one Button yourself. */
|
|
8
|
+
action?: React.ReactNode;
|
|
9
|
+
/** Replaces the default icon: a Lucide name, an icon component or an element */
|
|
10
|
+
icon?: IconSource;
|
|
6
11
|
}
|
|
7
|
-
export default function EmptyBox({ text, secondText, size, }: EmptyBoxProps): React.JSX.Element;
|
|
12
|
+
export default function EmptyBox({ text, secondText, size, action, icon, }: EmptyBoxProps): React.JSX.Element;
|
|
8
13
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AlertCircle } from 'lucide-react';
|
|
4
|
+
import IconSlot from './iconSlot';
|
|
4
5
|
export default function EmptyBox(_a) {
|
|
5
|
-
var text = _a.text, secondText = _a.secondText, size = _a.size;
|
|
6
|
+
var text = _a.text, secondText = _a.secondText, size = _a.size, action = _a.action, icon = _a.icon;
|
|
6
7
|
// The icon can be faint; the text needs readable contrast
|
|
7
8
|
var iconColor = 'text-fg-disabled';
|
|
8
9
|
var textColor = 'text-fg-secondary';
|
|
9
10
|
var height = size === 'small' ? 'py-6' : 'h-full';
|
|
10
11
|
var iconSize = 'size-6';
|
|
11
12
|
return (<div className={"flex flex-col space-y-2 justify-center items-center w-full ".concat(height)}>
|
|
12
|
-
<AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>
|
|
13
|
+
{icon ? (<IconSlot icon={icon} className={"".concat(iconSize, " ").concat(iconColor)}/>) : (<AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>)}
|
|
13
14
|
<div className="flex flex-col text-center">
|
|
14
15
|
<p className={"text-body1 ".concat(textColor)}>
|
|
15
16
|
{text}
|
|
@@ -18,5 +19,6 @@ export default function EmptyBox(_a) {
|
|
|
18
19
|
{secondText}
|
|
19
20
|
</p>)}
|
|
20
21
|
</div>
|
|
22
|
+
{action}
|
|
21
23
|
</div>);
|
|
22
24
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface HeadingProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
/** The element:
|
|
5
|
-
level?: 2 | 3 | 4;
|
|
4
|
+
/** The element: h1 to h4. Pick the one that fits the page's outline, not the size. */
|
|
5
|
+
level?: 1 | 2 | 3 | 4;
|
|
6
6
|
/** How large it is set. */
|
|
7
7
|
size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
|
|
8
8
|
id?: string;
|
|
@@ -24,6 +24,6 @@ interface IconButtonProps extends React.AriaAttributes {
|
|
|
24
24
|
/** With `href` to a path: replace the current history entry instead of adding one */
|
|
25
25
|
replace?: boolean;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export
|
|
27
|
+
/** The ref reaches the `<button>`, or the `<a>` when `href` is set, so a page can move focus to it */
|
|
28
|
+
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
29
|
+
export default IconButton;
|
|
@@ -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, 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 IconButton = forwardRef(function IconButton(_a, ref) {
|
|
30
31
|
var color = _a.color, state = _a.state, size = _a.size, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _b = _a.loading, loading = _b === void 0 ? false : _b, // Default to false
|
|
31
32
|
ariaLabel = _a.ariaLabel, href = _a.href, _c = _a.openInNewTab, openInNewTab = _c === void 0 ? false : _c, replace = _a.replace, rest = __rest(_a, ["color", "state", "size", "iconName", "icon", "onClick", "loading", "ariaLabel", "href", "openInNewTab", "replace"]);
|
|
32
33
|
var isLink = href !== undefined;
|
|
@@ -108,19 +109,20 @@ export default function IconButton(_a) {
|
|
|
108
109
|
if (isLink) {
|
|
109
110
|
// A link cannot be disabled: without an href it is not focusable and does nothing
|
|
110
111
|
if (isDisabled || loading) {
|
|
111
|
-
return (<a {...rest} role="link" aria-disabled="true" className={className} aria-label={loading ? 'Loading' : label}>
|
|
112
|
+
return (<a {...rest} ref={ref} role="link" aria-disabled="true" className={className} aria-label={loading ? 'Loading' : label}>
|
|
112
113
|
{content}
|
|
113
114
|
</a>);
|
|
114
115
|
}
|
|
115
116
|
var linkProps = __assign(__assign(__assign({}, rest), { className: className, onClick: onClick, 'aria-label': label }), (openInNewTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
116
117
|
// Same rule as Link: next/link for paths, a plain <a> for another site
|
|
117
118
|
if (href.startsWith('http://') || href.startsWith('https://')) {
|
|
118
|
-
return <a href={href} {...linkProps}>{content}</a>;
|
|
119
|
+
return <a href={href} {...linkProps} ref={ref}>{content}</a>;
|
|
119
120
|
}
|
|
120
|
-
return <NextLink href={href} replace={replace} {...linkProps}>{content}</NextLink>;
|
|
121
|
+
return <NextLink href={href} replace={replace} {...linkProps} ref={ref}>{content}</NextLink>;
|
|
121
122
|
}
|
|
122
|
-
return (<button {...rest} type="button" className={className} disabled={isDisabled || loading} // Disable button during loading
|
|
123
|
+
return (<button {...rest} ref={ref} type="button" className={className} disabled={isDisabled || loading} // Disable button during loading
|
|
123
124
|
onClick={onClick} aria-label={loading ? 'Loading' : label}>
|
|
124
125
|
{content}
|
|
125
126
|
</button>);
|
|
126
|
-
}
|
|
127
|
+
});
|
|
128
|
+
export default IconButton;
|
|
@@ -10,7 +10,13 @@ interface StackProps extends LayoutProps {
|
|
|
10
10
|
align?: 'stretch' | 'start';
|
|
11
11
|
}
|
|
12
12
|
export declare function Stack({ children, gap, align, className }: StackProps): React.JSX.Element;
|
|
13
|
-
|
|
13
|
+
interface ClusterProps extends LayoutProps {
|
|
14
|
+
/** `between` pushes the first and last child to the ends; `end` packs the row to the right. */
|
|
15
|
+
justify?: 'start' | 'between' | 'end';
|
|
16
|
+
/** `start` lines the children up along the top edge; `center` along the middle. */
|
|
17
|
+
align?: 'center' | 'start';
|
|
18
|
+
}
|
|
19
|
+
export declare function Cluster({ children, gap, justify, align, className }: ClusterProps): React.JSX.Element;
|
|
14
20
|
interface GridProps extends LayoutProps {
|
|
15
21
|
/** How many columns from the medium breakpoint up. Below it: two for `compact`, otherwise one. */
|
|
16
22
|
columns?: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
@@ -13,10 +13,13 @@ export function Stack(_a) {
|
|
|
13
13
|
var children = _a.children, _b = _a.gap, gap = _b === void 0 ? 'large' : _b, _c = _a.align, align = _c === void 0 ? 'stretch' : _c, _d = _a.className, className = _d === void 0 ? '' : _d;
|
|
14
14
|
return <div className={"flex flex-col ".concat(align === 'start' ? 'items-start' : '', " ").concat(gaps[gap], " ").concat(className)}>{children}</div>;
|
|
15
15
|
}
|
|
16
|
+
var clusterJustify = { start: '', between: ' justify-between', end: ' justify-end' };
|
|
16
17
|
// Things that sit in a row and wrap, a spacing token apart.
|
|
17
18
|
export function Cluster(_a) {
|
|
18
|
-
var children = _a.children, _b = _a.gap, gap = _b === void 0 ? 'medium' : _b, _c = _a.className, className =
|
|
19
|
-
return <div className={"flex flex-wrap items-center ".concat(gaps[gap], " ").concat(className)}>
|
|
19
|
+
var children = _a.children, _b = _a.gap, gap = _b === void 0 ? 'medium' : _b, _c = _a.justify, justify = _c === void 0 ? 'start' : _c, _d = _a.align, align = _d === void 0 ? 'center' : _d, _e = _a.className, className = _e === void 0 ? '' : _e;
|
|
20
|
+
return (<div className={"flex flex-wrap ".concat(align === 'start' ? 'items-start' : 'items-center', " ").concat(gaps[gap]).concat(clusterJustify[justify], " ").concat(className)}>
|
|
21
|
+
{children}
|
|
22
|
+
</div>);
|
|
20
23
|
}
|
|
21
24
|
var mdColumns = {
|
|
22
25
|
2: 'md:grid-cols-2',
|
|
@@ -2,6 +2,10 @@ import React from 'react';
|
|
|
2
2
|
interface LoadingSmallProps {
|
|
3
3
|
size?: 'large' | 'medium' | 'small' | 'tiny';
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
interface LoadingScreenProps {
|
|
6
|
+
/** One line of text centered under the spinner. It is also the status element's accessible name, in place of "Loading". */
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
export default function LoadingScreen({ label }?: LoadingScreenProps): React.JSX.Element;
|
|
6
10
|
export declare function LoadingSmall({ size }: LoadingSmallProps): React.JSX.Element;
|
|
7
11
|
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export default function LoadingScreen() {
|
|
4
|
-
|
|
3
|
+
export default function LoadingScreen(_a) {
|
|
4
|
+
var _b = _a === void 0 ? {} : _a, label = _b.label;
|
|
5
|
+
return (<div role="status" aria-label={label !== null && label !== void 0 ? label : 'Loading'} className={"flex ".concat(label ? 'flex-col ' : '', "justify-center items-center ").concat(label ? 'gap-1 ' : '', "h-full w-full min-h-[200px]")}>
|
|
5
6
|
<div className="w-12 h-12 rounded-full border-4 border-current border-t-transparent text-fg-primary animate-spin"></div>
|
|
7
|
+
{label && <p className="text-body2 text-fg-secondary text-center">{label}</p>}
|
|
6
8
|
</div>);
|
|
7
9
|
}
|
|
8
10
|
;
|
|
@@ -3,6 +3,27 @@ interface MenuProps {
|
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
width?: number | string;
|
|
5
5
|
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Makes the list a keyboard menu (`role="menu"`): on mount it focuses its first item; ArrowDown and
|
|
8
|
+
* ArrowUp move to the next and previous item and wrap, Home and End go to the first and last, and a
|
|
9
|
+
* letter moves to the next item whose label starts with it. The items are the `role="menuitem"`
|
|
10
|
+
* descendants (MenuItem's default role), skipping any with `aria-disabled="true"`. Keys move real
|
|
11
|
+
* focus and leave each item's tabIndex as it is. Open it in a `Popover` with `returnFocus` so Escape,
|
|
12
|
+
* Tab, Shift+Tab and a chosen item close it and give focus back to the trigger. Items with `href` are
|
|
13
|
+
* links without the menuitem role, so the keys skip them: use `onClick` items in a navigable Menu.
|
|
14
|
+
*/
|
|
15
|
+
navigable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The list element's role; wins over the `role="menu"` that `navigable` sets. For a suggestion list
|
|
18
|
+
* (mentions, commands) pass `role="listbox"` and an `id` that the text area's `aria-controls` points at,
|
|
19
|
+
* without `navigable`: the Menu then adds no focus or key handling, and the caller drives
|
|
20
|
+
* `MenuItem role="option" isActive` and `aria-activedescendant` itself, as Select does.
|
|
21
|
+
*/
|
|
22
|
+
role?: string;
|
|
23
|
+
/** On the list element, for `aria-controls` */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** The list's name, such as 'Message actions'. Set only when the list has a role (`role` or `navigable`). */
|
|
26
|
+
'aria-label'?: string;
|
|
6
27
|
}
|
|
7
28
|
declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
29
|
export default Menu;
|