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
package/dist/components/menu.jsx
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
3
|
+
import { nextIndex } from '../internal/menu';
|
|
4
|
+
var ITEMS = '[role="menuitem"]:not([aria-disabled="true"])';
|
|
3
5
|
var Menu = forwardRef(function (_a, ref) {
|
|
4
|
-
var children = _a.children, width = _a.width, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
6
|
+
var children = _a.children, width = _a.width, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.navigable, navigable = _c === void 0 ? false : _c, role = _a.role, id = _a.id, ariaLabel = _a["aria-label"];
|
|
7
|
+
var listRole = role !== null && role !== void 0 ? role : (navigable ? 'menu' : undefined);
|
|
8
|
+
var listRef = useRef(null);
|
|
9
|
+
var items = function () { var _a, _b; return Array.from((_b = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEMS)) !== null && _b !== void 0 ? _b : []); };
|
|
10
|
+
// Inside a Popover the Menu mounts once the anchor is set, so this runs as the menu opens
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
var _a;
|
|
13
|
+
if (navigable)
|
|
14
|
+
(_a = items()[0]) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
15
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
16
|
+
var handleKeyDown = function (e) {
|
|
17
|
+
if (e.altKey || e.ctrlKey || e.metaKey)
|
|
18
|
+
return;
|
|
19
|
+
var list = items();
|
|
20
|
+
var item = e.target.closest('[role="menuitem"]');
|
|
21
|
+
var current = item ? list.indexOf(item) : -1;
|
|
22
|
+
var labels = list.map(function (el) { var _a; return (_a = el.textContent) !== null && _a !== void 0 ? _a : ''; });
|
|
23
|
+
var next = nextIndex({ key: e.key, current: current, count: list.length, labels: labels });
|
|
24
|
+
if (next === current || next < 0)
|
|
25
|
+
return;
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
list[next].focus();
|
|
28
|
+
};
|
|
5
29
|
// dark-only edge: a ring only in dark mode, so it keeps a dark: variant (it follows whatever dark variant the app's preset/@theme defines, class-only or OS-aware)
|
|
6
30
|
return (<div ref={ref} className={"\n bg-background-overlay\n rounded-container\n shadow-overlay\n dark:ring-1 dark:ring-misc-divider\n overflow-hidden\n ".concat(className, "\n ")} style={{ width: width || 'auto' }}>
|
|
7
31
|
{/* 4px padding keeps the 8px item corners concentric with the 12px menu corners */}
|
|
8
|
-
<div className="p-1 flex flex-col gap-0.5">
|
|
32
|
+
<div ref={listRef} id={id} role={listRole} aria-label={listRole ? ariaLabel : undefined} onKeyDown={navigable ? handleKeyDown : undefined} className="p-1 flex flex-col gap-0.5">
|
|
9
33
|
{children}
|
|
10
34
|
</div>
|
|
11
35
|
</div>);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface MenuItemProps {
|
|
3
|
+
/** Renders the row as a link. The link has no `role`, so a navigable Menu's arrow keys skip it: use `onClick` items there. */
|
|
3
4
|
href?: string;
|
|
4
5
|
iconName?: string;
|
|
5
6
|
icon?: React.ReactNode;
|
|
@@ -24,8 +25,15 @@ interface MenuItemProps {
|
|
|
24
25
|
id?: string;
|
|
25
26
|
/** Keyboard highlight used by Select's listbox */
|
|
26
27
|
isActive?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Only with `role="option"`: wins over the `aria-selected` computed from `isSelected`. In a suggestion
|
|
30
|
+
* list (mentions, commands) pass `aria-selected={isActive}` so it follows the highlighted row.
|
|
31
|
+
*/
|
|
32
|
+
'aria-selected'?: boolean;
|
|
27
33
|
/** Select keeps focus on its trigger and passes -1 */
|
|
28
34
|
tabIndex?: number;
|
|
35
|
+
/** `danger` gives the label and the left icon the error text color, for Delete and the like. `isSelected` wins over it. */
|
|
36
|
+
color?: 'default' | 'danger';
|
|
29
37
|
}
|
|
30
|
-
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, tabIndex, }: MenuItemProps): React.JSX.Element;
|
|
38
|
+
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, 'aria-selected': ariaSelected, tabIndex, color, }: MenuItemProps): React.JSX.Element;
|
|
31
39
|
export {};
|
|
@@ -7,7 +7,7 @@ import Tag from './tag';
|
|
|
7
7
|
import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
8
8
|
export default function MenuItem(_a) {
|
|
9
9
|
var _b;
|
|
10
|
-
var href = _a.href, iconName = _a.iconName, icon = _a.icon, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, secondLabel = _a.secondLabel, isSelected = _a.isSelected, onClick = _a.onClick, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'medium' : _d, tag = _a.tag, iconRight = _a.iconRight, rightAction = _a.rightAction, _e = _a.role, role = _e === void 0 ? 'menuitem' : _e, id = _a.id, _f = _a.isActive, isActive = _f === void 0 ? false : _f, _g = _a.tabIndex, tabIndex = _g === void 0 ? 0 : _g;
|
|
10
|
+
var href = _a.href, iconName = _a.iconName, icon = _a.icon, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, secondLabel = _a.secondLabel, isSelected = _a.isSelected, onClick = _a.onClick, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'medium' : _d, tag = _a.tag, iconRight = _a.iconRight, rightAction = _a.rightAction, _e = _a.role, role = _e === void 0 ? 'menuitem' : _e, id = _a.id, _f = _a.isActive, isActive = _f === void 0 ? false : _f, ariaSelected = _a["aria-selected"], _g = _a.tabIndex, tabIndex = _g === void 0 ? 0 : _g, _h = _a.color, color = _h === void 0 ? 'default' : _h;
|
|
11
11
|
// Size-based icon and text classes
|
|
12
12
|
var iconSize = { tiny: 'w-4 h-4', small: 'w-5 h-5', medium: 'w-6 h-6' }[size];
|
|
13
13
|
var labelClass = { tiny: 'text-caption', small: 'text-body2', medium: 'text-body1' }[size];
|
|
@@ -15,9 +15,10 @@ export default function MenuItem(_a) {
|
|
|
15
15
|
// One step smaller than the row so a tag never makes its row taller
|
|
16
16
|
var tagSize = { tiny: 'tiny', small: 'tiny', medium: 'small' }[size];
|
|
17
17
|
var paddingClass = size === 'tiny' ? 'p-1' : 'p-2';
|
|
18
|
+
var danger = color === 'danger' && !isSelected;
|
|
18
19
|
var content = (<div id={id} role={href ? undefined : role}
|
|
19
20
|
// A link wrapper is already focusable; otherwise the row itself takes focus
|
|
20
|
-
tabIndex={href ? undefined : tabIndex} aria-selected={role === 'option' ? !!isSelected : undefined} className={"\n flex items-center ".concat(paddingClass, " rounded-control cursor-pointer justify-between text-left ").concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(isSelected
|
|
21
|
+
tabIndex={href ? undefined : tabIndex} aria-selected={role === 'option' ? ariaSelected !== null && ariaSelected !== void 0 ? ariaSelected : !!isSelected : undefined} className={"\n flex items-center ".concat(paddingClass, " rounded-control cursor-pointer justify-between text-left ").concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(isSelected
|
|
21
22
|
? 'bg-primary-dark text-primary-contrast'
|
|
22
23
|
: "hover:bg-background-accent200 ".concat(isActive ? 'bg-background-accent200' : ''), "\n ").concat(className, "\n ")} style={{ width: '100%' }} onClick={onClick} onKeyDown={function (e) {
|
|
23
24
|
if (!href && e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) {
|
|
@@ -27,9 +28,9 @@ export default function MenuItem(_a) {
|
|
|
27
28
|
}}>
|
|
28
29
|
{/* Left group: icon/userImg + label with 8px gap */}
|
|
29
30
|
<div className="flex items-center gap-2 min-w-0">
|
|
30
|
-
{userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : icon ? (<span className={"".concat(iconSize, " flex-shrink-0 flex items-center justify-center")}>{icon}</span>) : (<IconSlot icon={iconName} className={"".concat(iconSize, " flex-shrink-0 ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-secondary')}/>)}
|
|
31
|
+
{userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : icon ? (<span className={"".concat(iconSize, " flex-shrink-0 flex items-center justify-center").concat(danger ? ' text-error-text' : '')}>{icon}</span>) : (<IconSlot icon={iconName} className={"".concat(iconSize, " flex-shrink-0 ").concat(isSelected ? 'text-primary-contrast' : danger ? 'text-error-text' : 'text-fg-secondary')}/>)}
|
|
31
32
|
<div className="flex flex-col min-w-0">
|
|
32
|
-
<span className={"truncate ".concat(labelClass, " ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-primary')}>
|
|
33
|
+
<span className={"truncate ".concat(labelClass, " ").concat(isSelected ? 'text-primary-contrast' : danger ? 'text-error-text' : 'text-fg-primary')}>
|
|
33
34
|
{label}
|
|
34
35
|
</span>
|
|
35
36
|
{secondLabel && (<span className={"truncate ".concat(secondLabelClass, " opacity-70 ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-primary')}>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface MessageProps {
|
|
3
|
+
/** A `UserImage`, in a 24px slot on the left. Not shown when `compact`. */
|
|
4
|
+
avatar?: React.ReactNode;
|
|
5
|
+
/** The sender, at the start of the header line */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Shown after the name on the header line: a `Tag`, a model line, a `TimeStamp` */
|
|
8
|
+
meta?: React.ReactNode;
|
|
9
|
+
/** The body */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** Under the body: sources, attachments, reactions */
|
|
12
|
+
footer?: React.ReactNode;
|
|
13
|
+
/** A row of `IconButton`s at the top right. Shown while the pointer is on the row or focus is inside it, and always on a device without hover.
|
|
14
|
+
* Keep them to quick actions; a control that must always be visible, such as Stop, belongs in `footer`. */
|
|
15
|
+
actions?: React.ReactNode;
|
|
16
|
+
/** Shows the actions at all times, for example while a menu opened from one of them is open, so its button stays on screen */
|
|
17
|
+
actionsVisible?: boolean;
|
|
18
|
+
/** A follow-on message from the same sender: no avatar and no header; the body lines up with the one above */
|
|
19
|
+
compact?: boolean;
|
|
20
|
+
/** `highlight` gives the row the accent100 background, for a search hit or a mention */
|
|
21
|
+
tone?: 'default' | 'highlight';
|
|
22
|
+
/** Pass it on every row, compact ones too, with the sender and the time: a compact row shows neither. */
|
|
23
|
+
'aria-label'?: string;
|
|
24
|
+
/** On the row, so a search hit can scroll to it */
|
|
25
|
+
id?: string;
|
|
26
|
+
}
|
|
27
|
+
export default function Message({ avatar, name, meta, children, footer, actions, actionsVisible, compact, tone, 'aria-label': ariaLabel, id, }: MessageProps): React.JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { stateTransition } from './sharedStyles';
|
|
3
|
+
var tones = { default: '', highlight: ' bg-background-accent100' };
|
|
4
|
+
// Opacity only: the actions stay in the tab order, so focus inside the row can reveal them,
|
|
5
|
+
// and they take their space at all times, so showing them moves nothing.
|
|
6
|
+
var actionsReveal = 'opacity-0 group-hover/message:opacity-100 group-focus-within/message:opacity-100 [@media(hover:none)]:opacity-100';
|
|
7
|
+
// One message in a chat list. The list that holds the rows owns `role="log"` (or `feed`), not the row.
|
|
8
|
+
// A named group, so `group-hover:` marks inside the body (RadioGroup, Checkbox) ignore the row,
|
|
9
|
+
// and an outer `.group` does not reveal the actions.
|
|
10
|
+
export default function Message(_a) {
|
|
11
|
+
var avatar = _a.avatar, name = _a.name, meta = _a.meta, children = _a.children, footer = _a.footer, actions = _a.actions, _b = _a.actionsVisible, actionsVisible = _b === void 0 ? false : _b, _c = _a.compact, compact = _c === void 0 ? false : _c, _d = _a.tone, tone = _d === void 0 ? 'default' : _d, ariaLabel = _a["aria-label"], id = _a.id;
|
|
12
|
+
var header = !compact && (name || meta);
|
|
13
|
+
return (<article id={id} aria-label={ariaLabel} className={"group/message flex items-start gap-medium px-2 py-1 rounded-control".concat(tones[tone])}>
|
|
14
|
+
<div className="flex-shrink-0 w-6">{compact ? null : avatar}</div>
|
|
15
|
+
<div className="flex flex-col flex-1 min-w-0 gap-small">
|
|
16
|
+
{header && (<div className="flex flex-wrap items-center gap-medium">
|
|
17
|
+
{name && <span className="min-w-0 break-words text-body1 font-medium text-fg-primary">{name}</span>}
|
|
18
|
+
{meta}
|
|
19
|
+
</div>)}
|
|
20
|
+
<div className="break-words">{children}</div>
|
|
21
|
+
{footer && <div>{footer}</div>}
|
|
22
|
+
</div>
|
|
23
|
+
{actions && <div className={"flex flex-shrink-0 items-center gap-small ".concat(actionsVisible ? '' : "".concat(actionsReveal, " ")).concat(stateTransition)}>{actions}</div>}
|
|
24
|
+
</article>);
|
|
25
|
+
}
|
|
@@ -7,6 +7,7 @@ interface ModalProps {
|
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
actions?: React.ReactNode;
|
|
9
9
|
size?: 'small' | 'medium' | 'large';
|
|
10
|
+
initialFocus?: 'first' | 'body';
|
|
10
11
|
}
|
|
11
|
-
export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, }: ModalProps): React.JSX.Element | null;
|
|
12
|
+
export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, initialFocus, }: ModalProps): React.JSX.Element | null;
|
|
12
13
|
export {};
|
|
@@ -2,26 +2,38 @@
|
|
|
2
2
|
import React, { useEffect, useId, useRef } from 'react';
|
|
3
3
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
4
4
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
5
|
+
import { initialFocusCandidates } from '../internal/modal';
|
|
5
6
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
7
|
+
// For the first focus and the Tab trap: the same, minus a hidden input, which matches but cannot take focus
|
|
8
|
+
var PICKABLE = FOCUSABLE.replace('input:not([disabled])', 'input:not([disabled]):not([type="hidden"])');
|
|
6
9
|
export default function Modal(_a) {
|
|
7
|
-
var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
10
|
+
var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.initialFocus, initialFocus = _c === void 0 ? 'first' : _c;
|
|
8
11
|
var panelRef = useRef(null);
|
|
12
|
+
var bodyRef = useRef(null);
|
|
9
13
|
var titleId = useId();
|
|
10
|
-
var
|
|
14
|
+
var _d = useOverlayTransition(isOpen), mounted = _d.mounted, visible = _d.visible;
|
|
11
15
|
// Keep onClose in a ref so a new function each render doesn't re-run the focus effect
|
|
12
16
|
var onCloseRef = useRef(onClose);
|
|
13
17
|
onCloseRef.current = onClose;
|
|
14
18
|
// Move focus into the panel, trap Tab inside it, close on Escape,
|
|
15
19
|
// lock page scroll, and give focus back to the trigger on close
|
|
16
20
|
useEffect(function () {
|
|
17
|
-
var _a;
|
|
21
|
+
var _a, _b, _c;
|
|
18
22
|
// Wait for the panel to mount before moving focus into it
|
|
19
23
|
if (!isOpen || !mounted)
|
|
20
24
|
return;
|
|
21
25
|
var previouslyFocused = document.activeElement;
|
|
22
26
|
var panel = panelRef.current;
|
|
23
|
-
var
|
|
24
|
-
|
|
27
|
+
var candidates = initialFocusCandidates(Array.from((_a = panel === null || panel === void 0 ? void 0 : panel.querySelectorAll(PICKABLE)) !== null && _a !== void 0 ? _a : []), Array.from((_c = (_b = bodyRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(PICKABLE)) !== null && _c !== void 0 ? _c : []), initialFocus);
|
|
28
|
+
// An element that is hidden or display:none ignores focus(); try the next one
|
|
29
|
+
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
30
|
+
var candidate = candidates_1[_i];
|
|
31
|
+
candidate.focus();
|
|
32
|
+
if (panel === null || panel === void 0 ? void 0 : panel.contains(document.activeElement))
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (panel && !panel.contains(document.activeElement))
|
|
36
|
+
panel.focus();
|
|
25
37
|
var previousOverflow = document.body.style.overflow;
|
|
26
38
|
document.body.style.overflow = 'hidden';
|
|
27
39
|
var handleKeyDown = function (e) {
|
|
@@ -31,7 +43,7 @@ export default function Modal(_a) {
|
|
|
31
43
|
}
|
|
32
44
|
if (e.key !== 'Tab' || !panel)
|
|
33
45
|
return;
|
|
34
|
-
var focusable = Array.from(panel.querySelectorAll(
|
|
46
|
+
var focusable = Array.from(panel.querySelectorAll(PICKABLE));
|
|
35
47
|
if (focusable.length === 0) {
|
|
36
48
|
e.preventDefault();
|
|
37
49
|
return;
|
|
@@ -61,7 +73,7 @@ export default function Modal(_a) {
|
|
|
61
73
|
medium: { width: 'w-[600px]', maxWidth: '600px' },
|
|
62
74
|
large: { width: 'w-[1024px]', maxWidth: '1024px' },
|
|
63
75
|
};
|
|
64
|
-
var
|
|
76
|
+
var _e = sizeConfig[size], modalWidth = _e.width, maxWidth = _e.maxWidth;
|
|
65
77
|
// close modal by clicking elsewhere
|
|
66
78
|
var handleOverlayClick = function (e) {
|
|
67
79
|
if (e.target === e.currentTarget) {
|
|
@@ -92,7 +104,7 @@ export default function Modal(_a) {
|
|
|
92
104
|
</div>)}
|
|
93
105
|
</div>)}
|
|
94
106
|
|
|
95
|
-
<div className="text-body1 space-y-4 text-fg-primary p-6" style={{
|
|
107
|
+
<div ref={bodyRef} className="text-body1 space-y-4 text-fg-primary p-6" style={{
|
|
96
108
|
overflowY: 'auto',
|
|
97
109
|
flexGrow: 1,
|
|
98
110
|
minHeight: 0,
|
|
@@ -8,6 +8,8 @@ interface ParagraphProps {
|
|
|
8
8
|
/** Set in the mono face, for labels, numbers and dates. */
|
|
9
9
|
mono?: boolean;
|
|
10
10
|
className?: string;
|
|
11
|
+
/** On the `<p>`, so a field can point at this line with `aria-describedby` */
|
|
12
|
+
id?: string;
|
|
11
13
|
}
|
|
12
|
-
export default function Paragraph({ children, tone, size, measure, mono, className, }: ParagraphProps): React.JSX.Element;
|
|
14
|
+
export default function Paragraph({ children, tone, size, measure, mono, className, id, }: ParagraphProps): React.JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -9,8 +9,8 @@ var measures = {
|
|
|
9
9
|
none: '',
|
|
10
10
|
};
|
|
11
11
|
export default function Paragraph(_a) {
|
|
12
|
-
var children = _a.children, _b = _a.tone, tone = _b === void 0 ? 'primary' : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c, _d = _a.measure, measure = _d === void 0 ? 'body' : _d, _e = _a.mono, mono = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f;
|
|
13
|
-
return (<p className={"".concat(sizes[size], " ").concat(tones[tone], " ").concat(measures[measure], " ").concat(mono ? 'font-mono' : '', " ").concat(className)}>
|
|
12
|
+
var children = _a.children, _b = _a.tone, tone = _b === void 0 ? 'primary' : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c, _d = _a.measure, measure = _d === void 0 ? 'body' : _d, _e = _a.mono, mono = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f, id = _a.id;
|
|
13
|
+
return (<p id={id} className={"".concat(sizes[size], " ").concat(tones[tone], " ").concat(measures[measure], " ").concat(mono ? 'font-mono' : '', " ").concat(className)}>
|
|
14
14
|
{children}
|
|
15
15
|
</p>);
|
|
16
16
|
}
|
|
@@ -5,6 +5,12 @@ interface PopoverProps {
|
|
|
5
5
|
open: boolean;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* When the Popover closes (Escape, a click outside, or `open` going false), focus goes back to
|
|
10
|
+
* `anchorEl` if it was inside the Popover or nowhere (on the body). Tab or Shift+Tab pressed inside the
|
|
11
|
+
* Popover also closes it (`onClose`) and focuses `anchorEl`. Pass the focusable trigger as `anchorEl`.
|
|
12
|
+
*/
|
|
13
|
+
returnFocus?: boolean;
|
|
8
14
|
}
|
|
9
|
-
export default function Popover({ id, anchorEl, open, onClose, children, }: PopoverProps): React.ReactPortal | null;
|
|
15
|
+
export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, }: PopoverProps): React.ReactPortal | null;
|
|
10
16
|
export {};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, { useState, useEffect, isValidElement } from 'react';
|
|
2
|
+
import React, { useState, useEffect, useRef, isValidElement } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { usePopper } from 'react-popper';
|
|
5
5
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
6
6
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
7
7
|
import Menu from './menu';
|
|
8
8
|
export default function Popover(_a) {
|
|
9
|
-
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children;
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
9
|
+
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? false : _b;
|
|
10
|
+
var _c = useState(null), popoverElement = _c[0], setPopoverElement = _c[1];
|
|
11
|
+
var _d = useState(false), hasMounted = _d[0], setHasMounted = _d[1];
|
|
12
|
+
var _e = useOverlayTransition(open), mounted = _e.mounted, visible = _e.visible;
|
|
13
13
|
// Initialize Popper.js
|
|
14
|
-
var
|
|
14
|
+
var _f = usePopper(anchorEl, popoverElement, {
|
|
15
15
|
placement: 'bottom-start', // Default placement, can be customized
|
|
16
16
|
modifiers: [
|
|
17
17
|
{ name: 'offset', options: { offset: [0, 4] } }, // Same 4px gap as the Select menu and Tooltip
|
|
18
18
|
],
|
|
19
|
-
}), styles =
|
|
19
|
+
}), styles = _f.styles, attributes = _f.attributes;
|
|
20
20
|
// Close on outside clicks and Escape. Clicks on the anchor are left to the
|
|
21
21
|
// anchor's own toggle, otherwise the popover would close and reopen.
|
|
22
22
|
useEffect(function () {
|
|
@@ -27,8 +27,19 @@ export default function Popover(_a) {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
var handleKeyDown = function (event) {
|
|
30
|
-
if (event.key === 'Escape')
|
|
30
|
+
if (event.key === 'Escape') {
|
|
31
|
+
// Close only the Popover: keep this Escape from reaching a Modal's window listener
|
|
32
|
+
event.stopPropagation();
|
|
31
33
|
onClose();
|
|
34
|
+
}
|
|
35
|
+
else if (event.key === 'Tab' && returnFocus && anchorEl && (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(event.target))) {
|
|
36
|
+
// Tab or Shift+Tab leaves the Popover: close it and give focus back to the anchor, before a Modal's
|
|
37
|
+
// Tab trap or the browser moves it somewhere else (the Popover is portaled to the end of the body)
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
anchorEl.focus();
|
|
41
|
+
onClose();
|
|
42
|
+
}
|
|
32
43
|
};
|
|
33
44
|
if (open) {
|
|
34
45
|
document.addEventListener('mousedown', handleClickOutside);
|
|
@@ -38,7 +49,22 @@ export default function Popover(_a) {
|
|
|
38
49
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
39
50
|
document.removeEventListener('keydown', handleKeyDown);
|
|
40
51
|
};
|
|
41
|
-
}, [open, anchorEl, popoverElement, onClose]);
|
|
52
|
+
}, [open, anchorEl, popoverElement, onClose, returnFocus]);
|
|
53
|
+
// On close, wait one task so a click outside has moved focus first: a click on something
|
|
54
|
+
// focusable keeps it there; a click on nothing leaves it on the body, and then the anchor takes it.
|
|
55
|
+
var wasOpen = useRef(open);
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
var closed = wasOpen.current && !open;
|
|
58
|
+
wasOpen.current = open;
|
|
59
|
+
if (!closed || !returnFocus || !anchorEl)
|
|
60
|
+
return;
|
|
61
|
+
var timer = setTimeout(function () {
|
|
62
|
+
var active = document.activeElement;
|
|
63
|
+
if (!active || active === document.body || (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(active)))
|
|
64
|
+
anchorEl.focus();
|
|
65
|
+
}, 0);
|
|
66
|
+
return function () { return clearTimeout(timer); };
|
|
67
|
+
}, [open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
42
68
|
// Ensure popover is only rendered after the component mounts
|
|
43
69
|
useEffect(function () {
|
|
44
70
|
setHasMounted(true);
|
|
@@ -3,12 +3,20 @@ interface RadioOption {
|
|
|
3
3
|
label: string;
|
|
4
4
|
secondLabel?: string;
|
|
5
5
|
value: string;
|
|
6
|
+
/** In the `card` variant, a small info tag beside the label, e.g. "Recommended" */
|
|
7
|
+
badge?: string;
|
|
8
|
+
disabled?: boolean;
|
|
6
9
|
}
|
|
7
10
|
interface RadioGroupProps {
|
|
8
11
|
options: RadioOption[];
|
|
9
12
|
selectedValue: string;
|
|
10
13
|
onChange: (value: string) => void;
|
|
11
14
|
direction?: 'horizontal' | 'vertical';
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
/** `card` draws each option as a bordered card that is the radio's label, with the selected one in the accent border */
|
|
17
|
+
variant?: 'default' | 'card';
|
|
18
|
+
/** Disables every option */
|
|
19
|
+
disabled?: boolean;
|
|
12
20
|
}
|
|
13
|
-
export default function RadioGroup({ options, selectedValue, onChange, direction, }: RadioGroupProps): React.JSX.Element;
|
|
21
|
+
export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, variant, disabled, }: RadioGroupProps): React.JSX.Element;
|
|
14
22
|
export {};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useId } from 'react';
|
|
3
3
|
import { popTransition, stateTransition } from './sharedStyles';
|
|
4
|
+
import Tag from './tag';
|
|
4
5
|
export default function RadioGroup(_a) {
|
|
5
|
-
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b;
|
|
6
|
+
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, ariaLabel = _a["aria-label"], _c = _a.variant, variant = _c === void 0 ? 'default' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d;
|
|
6
7
|
// One shared name gives native arrow-key movement between the options
|
|
7
8
|
var groupName = useId();
|
|
8
|
-
return (<div role="radiogroup" className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
9
|
+
return (<div role="radiogroup" aria-label={ariaLabel} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
9
10
|
{options.map(function (option) {
|
|
10
11
|
var isSelected = selectedValue === option.value;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
var isDisabled = disabled || !!option.disabled;
|
|
13
|
+
var isCard = variant === 'card';
|
|
14
|
+
return (<label key={option.value} className={"group relative flex items-start ".concat(isCard ? "gap-2 rounded-control border-2 p-3 ".concat(isSelected ? 'border-accent-main' : 'border-fg-disabled', " ") : '').concat(isDisabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer')}>
|
|
15
|
+
<input type="radio" name={groupName} value={option.value} checked={isSelected} disabled={isDisabled || undefined} onChange={function () { return onChange(option.value); }} className="peer sr-only"/>
|
|
16
|
+
{/* Keyboard focus rings the card just outside its border, so a selected card keeps its accent border */}
|
|
17
|
+
{isCard && (<span aria-hidden="true" className="pointer-events-none absolute inset-0 rounded-control peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-fg-primary"/>)}
|
|
13
18
|
{/* Hover halo and hit area, same as Checkbox */}
|
|
14
|
-
<span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n group-hover:bg-action-selected\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary")}>
|
|
19
|
+
<span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n ").concat(isDisabled ? '' : 'group-hover:bg-action-selected', "\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary")}>
|
|
15
20
|
{/* outer circle */}
|
|
16
21
|
<span className={"relative flex justify-center items-center w-4 h-4 rounded-full border-2 ".concat(stateTransition, "\n ").concat(isSelected
|
|
17
22
|
? 'border-fg-primary'
|
|
@@ -20,10 +25,16 @@ export default function RadioGroup(_a) {
|
|
|
20
25
|
<span className={"absolute w-2 h-2 rounded-full bg-fg-primary ".concat(popTransition, " ").concat(isSelected ? 'scale-100' : 'scale-0')}/>
|
|
21
26
|
</span>
|
|
22
27
|
</span>
|
|
23
|
-
<span className="flex flex-col
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
{isCard ? (<span className="flex flex-col flex-1">
|
|
29
|
+
<span className="flex flex-wrap items-center gap-2">
|
|
30
|
+
<span className="text-body1 font-medium text-fg-primary">{option.label}</span>
|
|
31
|
+
{option.badge && <Tag variant="contained" size="small" color="info" label={option.badge}/>}
|
|
32
|
+
</span>
|
|
33
|
+
{option.secondLabel && (<span className="text-body2 opacity-70 text-fg-primary">{option.secondLabel}</span>)}
|
|
34
|
+
</span>) : (<span className="flex flex-col ml-2">
|
|
35
|
+
<span className="text-body1 text-fg-primary">{option.label}</span>
|
|
36
|
+
{option.secondLabel && (<span className="text-body2 opacity-70 text-fg-primary">{option.secondLabel}</span>)}
|
|
37
|
+
</span>)}
|
|
27
38
|
</label>);
|
|
28
39
|
})}
|
|
29
40
|
</div>);
|
|
@@ -14,6 +14,7 @@ interface SelectProps {
|
|
|
14
14
|
width?: number | string;
|
|
15
15
|
multiple?: boolean;
|
|
16
16
|
className?: string;
|
|
17
|
+
'aria-label'?: string;
|
|
17
18
|
}
|
|
18
|
-
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, }: SelectProps): React.JSX.Element;
|
|
19
|
+
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, 'aria-label': ariaLabel, }: SelectProps): React.JSX.Element;
|
|
19
20
|
export { Select };
|
|
@@ -42,7 +42,7 @@ var popperOptions = {
|
|
|
42
42
|
};
|
|
43
43
|
export default function Select(_a) {
|
|
44
44
|
var _b, _c;
|
|
45
|
-
var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g;
|
|
45
|
+
var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g, ariaLabel = _a["aria-label"];
|
|
46
46
|
var _h = useState(false), isOpen = _h[0], setIsOpen = _h[1];
|
|
47
47
|
// Option highlighted by the keyboard; focus itself stays on the trigger
|
|
48
48
|
var _j = useState(-1), activeIndex = _j[0], setActiveIndex = _j[1];
|
|
@@ -153,6 +153,8 @@ export default function Select(_a) {
|
|
|
153
153
|
break;
|
|
154
154
|
case 'Escape':
|
|
155
155
|
e.preventDefault();
|
|
156
|
+
// Close only the list: keep this Escape from reaching a Modal's window listener
|
|
157
|
+
e.stopPropagation();
|
|
156
158
|
closeMenu();
|
|
157
159
|
break;
|
|
158
160
|
case 'Tab':
|
|
@@ -208,7 +210,7 @@ export default function Select(_a) {
|
|
|
208
210
|
};
|
|
209
211
|
return (<div className={"relative ".concat(className)} style={{ width: width || '100%' }}>
|
|
210
212
|
{/* Select Button */}
|
|
211
|
-
<div ref={setTrigger} role="combobox" aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
213
|
+
<div ref={setTrigger} role="combobox" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
212
214
|
{/* Inner Content Container; 7px vertical padding makes the control 40px like Button and TextField */}
|
|
213
215
|
<div className={"flex items-center justify-between px-2 py-[7px] ".concat(getTextColor())}>
|
|
214
216
|
{/* Content Container */}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IconSource } from './iconSlot';
|
|
3
|
+
interface SourceCardProps {
|
|
4
|
+
/** Shown at the left in secondary color. A Lucide icon name, an icon component or an element. */
|
|
5
|
+
icon?: IconSource;
|
|
6
|
+
/** One line; a longer title is cut with an ellipsis */
|
|
7
|
+
title: string;
|
|
8
|
+
/** One line of secondary text under the title: where the source lives, or its date */
|
|
9
|
+
meta?: string;
|
|
10
|
+
/** Makes the card a link. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
|
|
11
|
+
href?: string;
|
|
12
|
+
/** Makes the card a button. Ignored when `href` is set: the link wins and `onClick` does not run. */
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
/** A short text at the right end ('Open'), in the info text color. Shown only on a link or button card, and part of its accessible name. */
|
|
15
|
+
action?: string;
|
|
16
|
+
/** With `href`: open in a new tab. Another site (`http(s)://`) always opens in a new tab. */
|
|
17
|
+
openInNewTab?: boolean;
|
|
18
|
+
/** Overrides the accessible name of a link or button card: by default the title, the meta and the action, joined with commas */
|
|
19
|
+
'aria-label'?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The ref reaches the link or the button, so a page can move focus back to the card that opened something. A static card has no ref target. */
|
|
22
|
+
declare const SourceCard: React.ForwardRefExoticComponent<SourceCardProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
23
|
+
export default SourceCard;
|
|
@@ -0,0 +1,56 @@
|
|
|
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, { forwardRef } from 'react';
|
|
14
|
+
import NextLink from 'next/link';
|
|
15
|
+
import IconSlot from './iconSlot';
|
|
16
|
+
import { focusRing, stateTransition } from './sharedStyles';
|
|
17
|
+
// The card for one thing an agent read or made. With `href` or `onClick` it is a link or a
|
|
18
|
+
// button with a hover look and a focus ring; with neither it is plain static text: no role,
|
|
19
|
+
// no hover, no pointer. It fills the width of its parent, so a Grid cell gives it its size.
|
|
20
|
+
// Like Link, it only sets new-tab attributes and shows no extra icon.
|
|
21
|
+
/** The ref reaches the link or the button, so a page can move focus back to the card that opened something. A static card has no ref target. */
|
|
22
|
+
var SourceCard = forwardRef(function SourceCard(_a, ref) {
|
|
23
|
+
var icon = _a.icon, title = _a.title, meta = _a.meta, href = _a.href, onClick = _a.onClick, action = _a.action, _b = _a.openInNewTab, openInNewTab = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"];
|
|
24
|
+
var interactive = href !== undefined || onClick !== undefined;
|
|
25
|
+
var showAction = interactive && !!action;
|
|
26
|
+
// A link or button is named in one string, so the parts are read with a pause between them
|
|
27
|
+
var name = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : [title, meta, showAction && action].filter(Boolean).join(', ');
|
|
28
|
+
var classes = "flex w-full min-w-0 items-center gap-medium rounded-container border border-fg-disabled p-3 text-left".concat(interactive ? " cursor-pointer hover:bg-background-accent200 ".concat(stateTransition, " ").concat(focusRing) : '');
|
|
29
|
+
var content = (<>
|
|
30
|
+
{icon && (<span aria-hidden="true" className="flex shrink-0">
|
|
31
|
+
<IconSlot icon={icon} className="size-5 text-fg-secondary"/>
|
|
32
|
+
</span>)}
|
|
33
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
34
|
+
{/* Block-level lines, so a static card's title and meta are read as two words, not run together */}
|
|
35
|
+
<span className="truncate text-body1 text-fg-primary">{title}</span>
|
|
36
|
+
{meta && <span className="truncate text-caption text-fg-secondary">{meta}</span>}
|
|
37
|
+
</span>
|
|
38
|
+
{showAction && <span className="shrink-0 text-body2 text-info-text">{action}</span>}
|
|
39
|
+
</>);
|
|
40
|
+
if (href !== undefined) {
|
|
41
|
+
var isExternal = href.startsWith('http://') || href.startsWith('https://');
|
|
42
|
+
var newTab = openInNewTab || isExternal;
|
|
43
|
+
var props = __assign({ className: classes, 'aria-label': name }, (newTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
44
|
+
if (newTab) {
|
|
45
|
+
return <a href={href} {...props} ref={ref}>{content}</a>;
|
|
46
|
+
}
|
|
47
|
+
return <NextLink href={href} {...props} ref={ref}>{content}</NextLink>;
|
|
48
|
+
}
|
|
49
|
+
if (onClick) {
|
|
50
|
+
return (<button ref={ref} type="button" className={classes} onClick={onClick} aria-label={name}>
|
|
51
|
+
{content}
|
|
52
|
+
</button>);
|
|
53
|
+
}
|
|
54
|
+
return <div className={classes}>{content}</div>;
|
|
55
|
+
});
|
|
56
|
+
export default SourceCard;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type StepListStatus = 'waiting' | 'running' | 'done' | 'failed' | 'cancelled';
|
|
3
|
+
export interface StepListStep {
|
|
4
|
+
label: string;
|
|
5
|
+
/** Default `waiting` */
|
|
6
|
+
status?: StepListStatus;
|
|
7
|
+
/** One line of secondary text under the label */
|
|
8
|
+
detail?: string;
|
|
9
|
+
}
|
|
10
|
+
interface StepListProps {
|
|
11
|
+
steps: StepListStep[];
|
|
12
|
+
/** Numbers every step in a column before the status mark, for a plan whose order matters */
|
|
13
|
+
numbered?: boolean;
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
}
|
|
16
|
+
export default function StepList({ steps, numbered, 'aria-label': ariaLabel }: StepListProps): React.JSX.Element | null;
|
|
17
|
+
export {};
|