oneslash-design-system 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/DESIGN.md +55 -14
- package/dist/cases/accept-invite.md +1 -5
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- package/dist/cases/agent-options.md +0 -4
- package/dist/cases/agent-pending-reply.md +0 -4
- package/dist/cases/agent-plan-proposal.md +0 -4
- package/dist/cases/agent-question.md +0 -4
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +0 -2
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- package/dist/cases/app-shell/sidebar.d.ts +1 -0
- package/dist/cases/app-shell/sidebar.jsx +124 -0
- package/dist/cases/app-shell/top-tabs.d.ts +1 -0
- package/dist/cases/app-shell/top-tabs.jsx +106 -0
- package/dist/cases/app-shell.md +364 -0
- package/dist/cases/artifact-card/card.jsx +32 -6
- package/dist/cases/artifact-card.md +55 -11
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -0
- package/dist/cases/composer-limit.md +0 -4
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- package/dist/cases/conversation-starters.md +0 -4
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -25
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/master-detail/list-then-page.d.ts +1 -0
- package/dist/cases/master-detail/list-then-page.jsx +65 -0
- package/dist/cases/master-detail/split.d.ts +1 -0
- package/dist/cases/master-detail/split.jsx +49 -0
- package/dist/cases/master-detail.md +213 -0
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -0
- package/dist/cases/mention-list.md +0 -4
- package/dist/cases/message-actions.md +0 -4
- package/dist/cases/message-attachments.md +0 -4
- package/dist/cases/message-composer.md +0 -4
- package/dist/cases/message-edit.md +0 -4
- package/dist/cases/message-reactions.md +0 -4
- package/dist/cases/message-row.md +0 -4
- package/dist/cases/mobile-menu/links.d.ts +1 -0
- package/dist/cases/mobile-menu/links.jsx +24 -0
- package/dist/cases/mobile-menu/sections.d.ts +1 -0
- package/dist/cases/mobile-menu/sections.jsx +61 -0
- package/dist/cases/mobile-menu.md +170 -0
- package/dist/cases/not-found-page/in-shell.jsx +26 -17
- package/dist/cases/not-found-page.md +41 -24
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/on-this-page/aside.d.ts +1 -0
- package/dist/cases/on-this-page/aside.jsx +39 -0
- package/dist/cases/on-this-page.md +80 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/page-header/actions.d.ts +1 -0
- package/dist/cases/page-header/actions.jsx +65 -0
- package/dist/cases/page-header/sub-page.d.ts +1 -0
- package/dist/cases/page-header/sub-page.jsx +37 -0
- package/dist/cases/page-header.md +195 -0
- package/dist/cases/phone-navigation.md +32 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- package/dist/cases/reply-feedback.md +0 -4
- package/dist/cases/reply-sources.md +0 -4
- package/dist/cases/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -23
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/side-pane/beside.d.ts +1 -0
- package/dist/cases/side-pane/beside.jsx +79 -0
- package/dist/cases/side-pane/over.d.ts +1 -0
- package/dist/cases/side-pane/over.jsx +58 -0
- package/dist/cases/side-pane.md +238 -0
- package/dist/cases/sidebar-nav/flat.d.ts +1 -0
- package/dist/cases/sidebar-nav/flat.jsx +81 -0
- package/dist/cases/sidebar-nav/nested.d.ts +1 -0
- package/dist/cases/sidebar-nav/nested.jsx +122 -0
- package/dist/cases/sidebar-nav.md +261 -0
- package/dist/cases/sign-up-page.md +1 -5
- package/dist/cases/site-footer/columns.d.ts +1 -0
- package/dist/cases/site-footer/columns.jsx +51 -0
- package/dist/cases/site-footer/simple.d.ts +1 -0
- package/dist/cases/site-footer/simple.jsx +24 -0
- package/dist/cases/site-footer.md +133 -0
- package/dist/cases/site-header/links.d.ts +1 -0
- package/dist/cases/site-header/links.jsx +26 -0
- package/dist/cases/site-header/sections.d.ts +1 -0
- package/dist/cases/site-header/sections.jsx +64 -0
- package/dist/cases/site-header.md +183 -0
- package/dist/cases/slash-command-list.md +0 -4
- package/dist/cases/success-feedback.md +0 -4
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/theme-switcher/menu.d.ts +1 -0
- package/dist/cases/theme-switcher/menu.jsx +47 -0
- package/dist/cases/theme-switcher/segmented.d.ts +1 -0
- package/dist/cases/theme-switcher/segmented.jsx +26 -0
- package/dist/cases/theme-switcher.md +149 -0
- package/dist/cases/type-to-confirm.md +0 -4
- package/dist/cases/typing-and-status.md +0 -4
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +1737 -315
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/button.jsx +5 -2
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +5 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/link.d.ts +6 -1
- package/dist/components/link.jsx +11 -3
- package/dist/components/menu.jsx +2 -2
- package/dist/components/menuItem.d.ts +10 -2
- package/dist/components/menuItem.jsx +4 -3
- package/dist/components/modal.jsx +12 -23
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- package/dist/components/onThisPage.d.ts +29 -0
- package/dist/components/onThisPage.jsx +151 -0
- package/dist/components/pageShell.d.ts +7 -1
- package/dist/components/pageShell.jsx +14 -1
- package/dist/components/popover.jsx +4 -0
- package/dist/components/radioGroup.d.ts +5 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +36 -0
- package/dist/components/settingsSection.jsx +65 -0
- package/dist/components/sidePane.d.ts +32 -0
- package/dist/components/sidePane.jsx +128 -0
- package/dist/components/siteFooter.d.ts +24 -0
- package/dist/components/siteFooter.jsx +48 -0
- package/dist/components/siteHeader.d.ts +55 -0
- package/dist/components/siteHeader.jsx +125 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- package/dist/components/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +3 -3
- package/dist/components/titleBar.d.ts +17 -0
- package/dist/components/titleBar.jsx +17 -0
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/internal/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/overlayStack.d.ts +24 -0
- package/dist/internal/overlayStack.js +71 -0
- package/dist/internal/resize.d.ts +9 -0
- package/dist/internal/resize.js +31 -0
- package/dist/internal/scrollSpy.d.ts +24 -0
- package/dist/internal/scrollSpy.js +53 -0
- package/dist/internal/siteBrand.d.ts +6 -0
- package/dist/internal/siteBrand.jsx +11 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +72 -0
- package/dist/stories/AppShell.stories.d.ts +15 -0
- package/dist/stories/AppShell.stories.jsx +137 -0
- package/dist/stories/Cases.generated.stories.d.ts +42 -0
- package/dist/stories/Cases.generated.stories.jsx +84 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/Drawer.stories.d.ts +10 -0
- package/dist/stories/Drawer.stories.jsx +123 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/Link.stories.d.ts +1 -0
- package/dist/stories/Link.stories.jsx +8 -0
- package/dist/stories/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/OnThisPage.stories.d.ts +10 -0
- package/dist/stories/OnThisPage.stories.jsx +105 -0
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +12 -0
- package/dist/stories/SettingsSection.stories.jsx +91 -0
- package/dist/stories/SidePane.stories.d.ts +6 -0
- package/dist/stories/SidePane.stories.jsx +37 -0
- package/dist/stories/SiteFooter.stories.d.ts +7 -0
- package/dist/stories/SiteFooter.stories.jsx +63 -0
- package/dist/stories/SiteHeader.stories.d.ts +10 -0
- package/dist/stories/SiteHeader.stories.jsx +94 -0
- package/dist/stories/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/TitleBar.stories.d.ts +6 -0
- package/dist/stories/TitleBar.stories.jsx +34 -0
- package/package.json +5 -1
package/dist/components/link.jsx
CHANGED
|
@@ -12,9 +12,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import NextLink from 'next/link';
|
|
15
|
+
import { ExternalLink } from 'lucide-react';
|
|
15
16
|
import { focusRing } from './sharedStyles';
|
|
16
17
|
export default function Link(_a) {
|
|
17
|
-
var href = _a.href, children = _a.children, _b = _a.color, color = _b === void 0 ? 'info' : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c, _d = _a.openInNewTab, openInNewTab = _d === void 0 ? false : _d, _e = _a.className, className =
|
|
18
|
+
var href = _a.href, children = _a.children, _b = _a.color, color = _b === void 0 ? 'info' : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c, _d = _a.openInNewTab, openInNewTab = _d === void 0 ? false : _d, _e = _a.announceNewTab, announceNewTab = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f;
|
|
18
19
|
// Color classes based on the color prop
|
|
19
20
|
// Light mode uses the -dark shade so link text keeps 4.5:1 on light backgrounds
|
|
20
21
|
var colorClasses = {
|
|
@@ -63,13 +64,20 @@ export default function Link(_a) {
|
|
|
63
64
|
target: '_blank',
|
|
64
65
|
rel: 'noopener noreferrer',
|
|
65
66
|
}));
|
|
67
|
+
var content = (<>
|
|
68
|
+
{children}
|
|
69
|
+
{announceNewTab && shouldOpenInNewTab && (<>
|
|
70
|
+
<ExternalLink aria-hidden="true" className="ml-1 inline size-[1em] align-[-0.125em]"/>
|
|
71
|
+
<span className="sr-only"> (opens in a new tab)</span>
|
|
72
|
+
</>)}
|
|
73
|
+
</>);
|
|
66
74
|
// Use NextLink for internal links, regular <a> for external
|
|
67
75
|
if (isExternal || shouldOpenInNewTab) {
|
|
68
76
|
return (<a href={href} {...commonProps}>
|
|
69
|
-
{children}
|
|
77
|
+
{announceNewTab ? content : children}
|
|
70
78
|
</a>);
|
|
71
79
|
}
|
|
72
80
|
return (<NextLink href={href} {...commonProps}>
|
|
73
|
-
{children}
|
|
81
|
+
{announceNewTab ? content : children}
|
|
74
82
|
</NextLink>);
|
|
75
83
|
}
|
package/dist/components/menu.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
3
3
|
import { nextIndex } from '../internal/menu';
|
|
4
|
-
var ITEMS = '[role="menuitem"]:not([aria-disabled="true"])';
|
|
4
|
+
var ITEMS = '[role="menuitem"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"])';
|
|
5
5
|
var Menu = forwardRef(function (_a, ref) {
|
|
6
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
7
|
var listRole = role !== null && role !== void 0 ? role : (navigable ? 'menu' : undefined);
|
|
@@ -17,7 +17,7 @@ var Menu = forwardRef(function (_a, ref) {
|
|
|
17
17
|
if (e.altKey || e.ctrlKey || e.metaKey)
|
|
18
18
|
return;
|
|
19
19
|
var list = items();
|
|
20
|
-
var item = e.target.closest('[role="menuitem"]');
|
|
20
|
+
var item = e.target.closest('[role="menuitem"], [role="menuitemradio"]');
|
|
21
21
|
var current = item ? list.indexOf(item) : -1;
|
|
22
22
|
var labels = list.map(function (el) { var _a; return (_a = el.textContent) !== null && _a !== void 0 ? _a : ''; });
|
|
23
23
|
var next = nextIndex({ key: e.key, current: current, count: list.length, labels: labels });
|
|
@@ -20,7 +20,7 @@ interface MenuItemProps {
|
|
|
20
20
|
};
|
|
21
21
|
iconRight?: string;
|
|
22
22
|
rightAction?: React.ReactNode;
|
|
23
|
-
/** ARIA role; Select passes 'option'. Defaults to 'menuitem'. */
|
|
23
|
+
/** ARIA role; Select passes 'option'. Defaults to 'menuitem'. Pass 'menuitemradio' for one current choice among several: `isSelected` then sets `aria-checked`. */
|
|
24
24
|
role?: string;
|
|
25
25
|
id?: string;
|
|
26
26
|
/** Keyboard highlight used by Select's listbox */
|
|
@@ -34,6 +34,14 @@ interface MenuItemProps {
|
|
|
34
34
|
tabIndex?: number;
|
|
35
35
|
/** `danger` gives the label and the left icon the error text color, for Delete and the like. `isSelected` wins over it. */
|
|
36
36
|
color?: 'default' | 'danger';
|
|
37
|
+
/** Marks the current page in a side nav so a screen reader announces it. On a link it goes on the `<a>`, otherwise on the row. */
|
|
38
|
+
'aria-current'?: 'page' | boolean;
|
|
39
|
+
/** The row's name when the label and tag alone do not say it, e.g. a count: 'Inbox, 3 unread'. On a link it goes on the `<a>`. */
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
/** For a row that shows or hides others (a group of places): whether they are shown. Use with `role="button"`. On a link it goes on the `<a>`. */
|
|
42
|
+
'aria-expanded'?: boolean;
|
|
43
|
+
/** `2` indents the row one step, for a place inside another place. Default 1. */
|
|
44
|
+
level?: 1 | 2;
|
|
37
45
|
}
|
|
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;
|
|
46
|
+
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, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, 'aria-expanded': ariaExpanded, level, }: MenuItemProps): React.JSX.Element;
|
|
39
47
|
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, ariaSelected = _a["aria-selected"], _g = _a.tabIndex, tabIndex = _g === void 0 ? 0 : _g, _h = _a.color, color = _h === void 0 ? 'default' : _h;
|
|
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, ariaCurrent = _a["aria-current"], ariaLabel = _a["aria-label"], ariaExpanded = _a["aria-expanded"], _j = _a.level, level = _j === void 0 ? 1 : _j;
|
|
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];
|
|
@@ -18,7 +18,7 @@ export default function MenuItem(_a) {
|
|
|
18
18
|
var danger = color === 'danger' && !isSelected;
|
|
19
19
|
var content = (<div id={id} role={href ? undefined : role}
|
|
20
20
|
// A link wrapper is already focusable; otherwise the row itself takes focus
|
|
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
|
+
tabIndex={href ? undefined : tabIndex} aria-selected={role === 'option' ? ariaSelected !== null && ariaSelected !== void 0 ? ariaSelected : !!isSelected : undefined} aria-checked={!href && role === 'menuitemradio' ? !!isSelected : undefined} aria-current={href ? undefined : ariaCurrent} aria-label={href ? undefined : ariaLabel} aria-expanded={href ? undefined : ariaExpanded} className={"\n flex items-center ".concat(paddingClass, " rounded-control cursor-pointer justify-between text-left ").concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(isSelected
|
|
22
22
|
? 'bg-primary-dark text-primary-contrast'
|
|
23
23
|
: "hover:bg-background-accent200 ".concat(isActive ? 'bg-background-accent200' : ''), "\n ").concat(className, "\n ")} style={{ width: '100%' }} onClick={onClick} onKeyDown={function (e) {
|
|
24
24
|
if (!href && e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) {
|
|
@@ -50,5 +50,6 @@ export default function MenuItem(_a) {
|
|
|
50
50
|
</div>)}
|
|
51
51
|
</div>
|
|
52
52
|
</div>);
|
|
53
|
-
|
|
53
|
+
var row = href ? <NextLink href={href} aria-label={ariaLabel} aria-current={ariaCurrent} aria-expanded={ariaExpanded} className={"block rounded-control ".concat(focusRing)}>{content}</NextLink> : content;
|
|
54
|
+
return level === 2 ? <div className="pl-6">{row}</div> : row;
|
|
54
55
|
}
|
|
@@ -3,9 +3,7 @@ import React, { useEffect, useId, useRef } from 'react';
|
|
|
3
3
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
4
4
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
5
5
|
import { initialFocusCandidates } from '../internal/modal';
|
|
6
|
-
|
|
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
|
+
import { PICKABLE, claimEvent, isTopOverlay, lockScroll, popOverlay, pushOverlay, trapTab, unlockScroll } from '../internal/overlayStack';
|
|
9
7
|
export default function Modal(_a) {
|
|
10
8
|
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;
|
|
11
9
|
var panelRef = useRef(null);
|
|
@@ -16,7 +14,8 @@ export default function Modal(_a) {
|
|
|
16
14
|
var onCloseRef = useRef(onClose);
|
|
17
15
|
onCloseRef.current = onClose;
|
|
18
16
|
// Move focus into the panel, trap Tab inside it, close on Escape,
|
|
19
|
-
// lock page scroll, and give focus back to the trigger on close
|
|
17
|
+
// lock page scroll, and give focus back to the trigger on close.
|
|
18
|
+
// Escape and Tab act only while this Modal is the top overlay (see internal/overlayStack).
|
|
20
19
|
useEffect(function () {
|
|
21
20
|
var _a, _b, _c;
|
|
22
21
|
// Wait for the panel to mount before moving focus into it
|
|
@@ -34,36 +33,26 @@ export default function Modal(_a) {
|
|
|
34
33
|
}
|
|
35
34
|
if (panel && !panel.contains(document.activeElement))
|
|
36
35
|
panel.focus();
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
pushOverlay(titleId, panel);
|
|
37
|
+
lockScroll();
|
|
39
38
|
var handleKeyDown = function (e) {
|
|
39
|
+
if (!isTopOverlay(titleId))
|
|
40
|
+
return;
|
|
40
41
|
if (e.key === 'Escape') {
|
|
41
|
-
|
|
42
|
+
if (claimEvent(e))
|
|
43
|
+
onCloseRef.current();
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
if (e.key !== 'Tab' || !panel)
|
|
45
47
|
return;
|
|
46
|
-
|
|
47
|
-
if (focusable.length === 0) {
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
var first = focusable[0];
|
|
52
|
-
var last = focusable[focusable.length - 1];
|
|
53
|
-
if (e.shiftKey && document.activeElement === first) {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
last.focus();
|
|
56
|
-
}
|
|
57
|
-
else if (!e.shiftKey && document.activeElement === last) {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
first.focus();
|
|
60
|
-
}
|
|
48
|
+
trapTab(panel, e);
|
|
61
49
|
};
|
|
62
50
|
window.addEventListener('keydown', handleKeyDown);
|
|
63
51
|
return function () {
|
|
64
52
|
var _a;
|
|
65
53
|
window.removeEventListener('keydown', handleKeyDown);
|
|
66
|
-
|
|
54
|
+
popOverlay(titleId);
|
|
55
|
+
unlockScroll();
|
|
67
56
|
(_a = previouslyFocused === null || previouslyFocused === void 0 ? void 0 : previouslyFocused.focus) === null || _a === void 0 ? void 0 : _a.call(previouslyFocused);
|
|
68
57
|
};
|
|
69
58
|
}, [isOpen, mounted]);
|
|
@@ -2,6 +2,14 @@ import React from 'react';
|
|
|
2
2
|
interface NavigationProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
/** Names the landmark when a page has more than one nav, e.g. "Settings". */
|
|
6
|
+
'aria-label'?: string;
|
|
5
7
|
}
|
|
6
|
-
export default function Navigation({ children, className, }: NavigationProps): React.JSX.Element;
|
|
8
|
+
export default function Navigation({ children, className, 'aria-label': ariaLabel, }: NavigationProps): React.JSX.Element;
|
|
9
|
+
interface NavigationGroupProps {
|
|
10
|
+
/** The small label above the items. It names the group for a screen reader. */
|
|
11
|
+
label: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function NavigationGroup({ label, children }: NavigationGroupProps): React.JSX.Element;
|
|
7
15
|
export { Navigation };
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useId } from 'react';
|
|
3
3
|
export default function Navigation(_a) {
|
|
4
|
-
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
5
|
-
return (<nav className={"\n bg-background-default\n border-r border-misc-divider\n p-2 flex flex-col gap-0.5\n ".concat(className, "\n ")}>
|
|
4
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, ariaLabel = _a["aria-label"];
|
|
5
|
+
return (<nav aria-label={ariaLabel} className={"\n bg-background-default\n border-r border-misc-divider\n p-2 flex flex-col gap-0.5\n ".concat(className, "\n ")}>
|
|
6
6
|
{children}
|
|
7
7
|
</nav>);
|
|
8
8
|
}
|
|
9
|
+
// A labelled set of items inside a Navigation. A `role="group"` suits it because Navigation's
|
|
10
|
+
// items are rows, not a list: the group needs no list markup, and it keeps the label tied to them.
|
|
11
|
+
export function NavigationGroup(_a) {
|
|
12
|
+
var label = _a.label, children = _a.children;
|
|
13
|
+
var labelId = useId();
|
|
14
|
+
return (<div role="group" aria-labelledby={labelId} className="flex flex-col gap-0.5 mt-3 first:mt-0">
|
|
15
|
+
<div id={labelId} className="px-2 pb-1 text-caption text-fg-secondary">
|
|
16
|
+
{label}
|
|
17
|
+
</div>
|
|
18
|
+
{children}
|
|
19
|
+
</div>);
|
|
20
|
+
}
|
|
9
21
|
export { Navigation };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface OnThisPageItem {
|
|
3
|
+
/** The id of the heading on the page; the link goes to `#id` */
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** 3 is indented under the 2 above it. Default 2. */
|
|
7
|
+
level?: 2 | 3;
|
|
8
|
+
}
|
|
9
|
+
interface OnThisPageProps {
|
|
10
|
+
/** The page's headings, in page order. Fewer than two render nothing. */
|
|
11
|
+
items: OnThisPageItem[];
|
|
12
|
+
/** Names the nav. Default 'On this page'. */
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
/** The id of the element that scrolls, when it is not the window */
|
|
15
|
+
root?: string;
|
|
16
|
+
/**
|
|
17
|
+
* How far below the top of the scroll area a heading counts as reached, in px. Default 40, plus the height of a
|
|
18
|
+
* `SiteHeader` above the page (`--os-header-offset`) when the window scrolls. A click scrolls the heading to just
|
|
19
|
+
* under that header.
|
|
20
|
+
*/
|
|
21
|
+
offset?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Links to a long page's headings, with the one the reader is at marked. The current heading is the last one
|
|
25
|
+
* above `offset`; the last item at the end of the scroll; the one in the `#hash` on load. A click keeps its item
|
|
26
|
+
* current until the scroll ends. Reduced motion jumps instead of scrolling.
|
|
27
|
+
*/
|
|
28
|
+
export default function OnThisPage({ items, 'aria-label': ariaLabel, root, offset }: OnThisPageProps): React.JSX.Element | null;
|
|
29
|
+
export { OnThisPage };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useSlidingIndicator } from './slidingIndicator';
|
|
4
|
+
import { focusRing } from './sharedStyles';
|
|
5
|
+
import { hashId, isAtBottom, pickCurrent } from '../internal/scrollSpy';
|
|
6
|
+
// A click or a #hash pins its item as current while the page scrolls there, so the items in between don't flash past
|
|
7
|
+
var PIN_LIMIT = 1000;
|
|
8
|
+
var headerOffset = function () { return parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--os-header-offset')) || 0; };
|
|
9
|
+
var INPUT_EVENTS = ['wheel', 'touchstart', 'keydown', 'pointerdown'];
|
|
10
|
+
/**
|
|
11
|
+
* Links to a long page's headings, with the one the reader is at marked. The current heading is the last one
|
|
12
|
+
* above `offset`; the last item at the end of the scroll; the one in the `#hash` on load. A click keeps its item
|
|
13
|
+
* current until the scroll ends. Reduced motion jumps instead of scrolling.
|
|
14
|
+
*/
|
|
15
|
+
export default function OnThisPage(_a) {
|
|
16
|
+
var _b, _c;
|
|
17
|
+
var items = _a.items, _d = _a["aria-label"], ariaLabel = _d === void 0 ? 'On this page' : _d, root = _a.root, offset = _a.offset;
|
|
18
|
+
var ids = items.map(function (item) { return item.id; });
|
|
19
|
+
var key = ids.join('\n');
|
|
20
|
+
var _e = useState((_c = (_b = items[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null), current = _e[0], setCurrent = _e[1];
|
|
21
|
+
var _f = useSlidingIndicator("".concat(key, "|").concat(current)), containerRef = _f.containerRef, indicator = _f.indicator;
|
|
22
|
+
var pin = useRef(null);
|
|
23
|
+
var pinTimer = useRef(undefined);
|
|
24
|
+
// The effect below puts its recompute here, for the click handler
|
|
25
|
+
var refresh = useRef(function () { });
|
|
26
|
+
var setPin = function (id, until) {
|
|
27
|
+
clearTimeout(pinTimer.current);
|
|
28
|
+
pin.current = { id: id, until: until };
|
|
29
|
+
setCurrent(id);
|
|
30
|
+
// Where scrollend exists it ends the pin; the timer is for a browser without it
|
|
31
|
+
if (until === 'scrollend' && !('onscrollend' in window)) {
|
|
32
|
+
pinTimer.current = setTimeout(function () {
|
|
33
|
+
pin.current = null;
|
|
34
|
+
refresh.current();
|
|
35
|
+
}, PIN_LIMIT);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (ids.length < 2)
|
|
40
|
+
return;
|
|
41
|
+
var rootEl = root ? document.getElementById(root) : null;
|
|
42
|
+
var target = rootEl !== null && rootEl !== void 0 ? rootEl : window;
|
|
43
|
+
var frame = 0;
|
|
44
|
+
var compute = function () {
|
|
45
|
+
frame = 0;
|
|
46
|
+
if (pin.current)
|
|
47
|
+
return;
|
|
48
|
+
var base = rootEl ? rootEl.getBoundingClientRect().top : 0;
|
|
49
|
+
var tops = ids.map(function (id) {
|
|
50
|
+
var el = document.getElementById(id);
|
|
51
|
+
return el ? el.getBoundingClientRect().top - base : null;
|
|
52
|
+
});
|
|
53
|
+
var metrics = rootEl
|
|
54
|
+
? { scrollTop: rootEl.scrollTop, clientHeight: rootEl.clientHeight, scrollHeight: rootEl.scrollHeight }
|
|
55
|
+
: {
|
|
56
|
+
scrollTop: window.scrollY,
|
|
57
|
+
clientHeight: window.innerHeight,
|
|
58
|
+
scrollHeight: document.documentElement.scrollHeight,
|
|
59
|
+
};
|
|
60
|
+
var i = pickCurrent(tops, offset !== null && offset !== void 0 ? offset : 40 + (rootEl ? 0 : headerOffset()), isAtBottom(metrics));
|
|
61
|
+
if (i >= 0)
|
|
62
|
+
setCurrent(ids[i]);
|
|
63
|
+
};
|
|
64
|
+
var schedule = function () {
|
|
65
|
+
if (!frame)
|
|
66
|
+
frame = requestAnimationFrame(compute);
|
|
67
|
+
};
|
|
68
|
+
refresh.current = compute;
|
|
69
|
+
var release = function (only) {
|
|
70
|
+
if (!pin.current || (only && pin.current.until !== only))
|
|
71
|
+
return;
|
|
72
|
+
clearTimeout(pinTimer.current);
|
|
73
|
+
pin.current = null;
|
|
74
|
+
schedule();
|
|
75
|
+
};
|
|
76
|
+
var onInput = function () { return release(); };
|
|
77
|
+
var onScrollEnd = function () { return release('scrollend'); };
|
|
78
|
+
var onHashChange = function () {
|
|
79
|
+
var id = hashId(window.location.hash, ids);
|
|
80
|
+
if (id)
|
|
81
|
+
setPin(id, 'scrollend');
|
|
82
|
+
};
|
|
83
|
+
// Opened with a #hash: that item is current until the reader scrolls
|
|
84
|
+
var initial = hashId(window.location.hash, ids);
|
|
85
|
+
if (initial)
|
|
86
|
+
setPin(initial, 'input');
|
|
87
|
+
else
|
|
88
|
+
compute();
|
|
89
|
+
target.addEventListener('scroll', schedule, { passive: true });
|
|
90
|
+
target.addEventListener('scrollend', onScrollEnd);
|
|
91
|
+
window.addEventListener('resize', schedule);
|
|
92
|
+
window.addEventListener('hashchange', onHashChange);
|
|
93
|
+
INPUT_EVENTS.forEach(function (type) { return target.addEventListener(type, onInput, { passive: true }); });
|
|
94
|
+
return function () {
|
|
95
|
+
cancelAnimationFrame(frame);
|
|
96
|
+
clearTimeout(pinTimer.current);
|
|
97
|
+
pin.current = null;
|
|
98
|
+
refresh.current = function () { };
|
|
99
|
+
target.removeEventListener('scroll', schedule);
|
|
100
|
+
target.removeEventListener('scrollend', onScrollEnd);
|
|
101
|
+
window.removeEventListener('resize', schedule);
|
|
102
|
+
window.removeEventListener('hashchange', onHashChange);
|
|
103
|
+
INPUT_EVENTS.forEach(function (type) { return target.removeEventListener(type, onInput); });
|
|
104
|
+
};
|
|
105
|
+
}, [key, root, offset]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
106
|
+
var onLinkClick = function (e, id) {
|
|
107
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
|
|
108
|
+
return;
|
|
109
|
+
var heading = document.getElementById(id);
|
|
110
|
+
if (!heading)
|
|
111
|
+
return;
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
var rootEl = root ? document.getElementById(root) : null;
|
|
114
|
+
var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
115
|
+
// The heading ends just under a header above the page; 'instant' ignores a page's own `scroll-behavior: smooth`
|
|
116
|
+
var behavior = reduced ? 'instant' : 'smooth';
|
|
117
|
+
var gap = rootEl ? 0 : headerOffset();
|
|
118
|
+
var delta = heading.getBoundingClientRect().top - (rootEl ? rootEl.getBoundingClientRect().top : 0) - gap;
|
|
119
|
+
window.history.pushState(window.history.state, '', "#".concat(encodeURIComponent(id)));
|
|
120
|
+
var top = rootEl ? rootEl.scrollTop : window.scrollY;
|
|
121
|
+
var room = rootEl
|
|
122
|
+
? rootEl.scrollHeight - rootEl.clientHeight - top
|
|
123
|
+
: document.documentElement.scrollHeight - window.innerHeight - top;
|
|
124
|
+
if (Math.abs(delta > 0 ? Math.min(delta, room) : Math.max(delta, -top)) < 1) {
|
|
125
|
+
// Nowhere to scroll (already there, or at an end): no scrollend to wait for
|
|
126
|
+
setCurrent(id);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setPin(id, 'scrollend');
|
|
130
|
+
if (rootEl)
|
|
131
|
+
rootEl.scrollBy({ top: delta, behavior: behavior });
|
|
132
|
+
else
|
|
133
|
+
window.scrollBy({ top: delta, behavior: behavior });
|
|
134
|
+
};
|
|
135
|
+
if (items.length < 2)
|
|
136
|
+
return null;
|
|
137
|
+
return (<nav ref={containerRef} aria-label={ariaLabel} className="relative border-l border-misc-divider">
|
|
138
|
+
{indicator && (<span aria-hidden className={"pointer-events-none absolute -left-px top-0 w-0.5 rounded-full bg-primary-dark ".concat(indicator.animate ? 'transition-[transform,height] duration-[var(--os-duration-slide)] ease-emphasized motion-reduce:transition-none' : '')} style={{ transform: "translateY(".concat(indicator.y, "px)"), height: indicator.height }}/>)}
|
|
139
|
+
<ul className="m-0 flex list-none flex-col p-0">
|
|
140
|
+
{items.map(function (item) {
|
|
141
|
+
var isCurrent = item.id === current;
|
|
142
|
+
return (<li key={item.id}>
|
|
143
|
+
<a href={"#".concat(item.id)} aria-current={isCurrent ? 'location' : undefined} data-tab-selected={isCurrent ? 'true' : undefined} onClick={function (e) { return onLinkClick(e, item.id); }} className={"block rounded-control py-1 pr-2 text-body2 hover:text-fg-primary ".concat(item.level === 3 ? 'pl-6' : 'pl-3', " ").concat(isCurrent ? 'text-fg-primary' : 'text-fg-secondary', " ").concat(focusRing)}>
|
|
144
|
+
{item.label}
|
|
145
|
+
</a>
|
|
146
|
+
</li>);
|
|
147
|
+
})}
|
|
148
|
+
</ul>
|
|
149
|
+
</nav>);
|
|
150
|
+
}
|
|
151
|
+
export { OnThisPage };
|
|
@@ -5,6 +5,12 @@ interface PageShellProps extends React.ComponentPropsWithoutRef<'main'> {
|
|
|
5
5
|
wide?: boolean;
|
|
6
6
|
/** Let the column run the full width of the window, for a page that is a feed of images. Keeps the side space. */
|
|
7
7
|
fluid?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* A column beside the page, for an `OnThisPage`: 220px and sticky from the xl breakpoint, hidden below it. It sticks below a `SiteHeader` (`--os-header-offset`).
|
|
10
|
+
* The page also gives each level 2 and 3 heading with an `id` a scroll margin the height of that header, so a `#hash` link lands below it.
|
|
11
|
+
* Not for content a phone needs.
|
|
12
|
+
*/
|
|
13
|
+
aside?: React.ReactNode;
|
|
8
14
|
}
|
|
9
|
-
export default function PageShell({ children, wide, fluid, className, ...rest }: PageShellProps): React.JSX.Element;
|
|
15
|
+
export default function PageShell({ children, wide, fluid, aside, className, ...rest }: PageShellProps): React.JSX.Element;
|
|
10
16
|
export {};
|
|
@@ -13,7 +13,20 @@ import React from 'react';
|
|
|
13
13
|
// The frame of a page: the column, its side space, and the space between sections.
|
|
14
14
|
// Anything else given (data-* attributes, an id) goes to the <main>.
|
|
15
15
|
export default function PageShell(_a) {
|
|
16
|
-
var children = _a.children, _b = _a.wide, wide = _b === void 0 ? false : _b, _c = _a.fluid, fluid = _c === void 0 ? false : _c, _d = _a.className, className = _d === void 0 ? '' : _d, rest = __rest(_a, ["children", "wide", "fluid", "className"]);
|
|
16
|
+
var children = _a.children, _b = _a.wide, wide = _b === void 0 ? false : _b, _c = _a.fluid, fluid = _c === void 0 ? false : _c, aside = _a.aside, _d = _a.className, className = _d === void 0 ? '' : _d, rest = __rest(_a, ["children", "wide", "fluid", "aside", "className"]);
|
|
17
|
+
if (aside) {
|
|
18
|
+
// The page column and the aside sit side by side from xl, centered together
|
|
19
|
+
return (<main className={"min-h-screen [&_:is(h2,h3)[id]]:scroll-mt-[var(--os-header-offset,0px)] ".concat(className)} {...rest}>
|
|
20
|
+
<div className="mx-auto flex w-full items-start justify-center">
|
|
21
|
+
<div className={"flex min-w-0 w-full flex-col gap-section px-xlarge pb-page pt-giant md:px-xxlarge ".concat(fluid ? '' : "max-w-page ".concat(wide ? '2xl:max-w-page-wide' : ''))}>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
<div className="sticky top-[calc(var(--os-header-offset,0px)+1.5rem)] mr-xxlarge mt-giant hidden max-h-[calc(100dvh-var(--os-header-offset,0px)-3rem)] w-[220px] shrink-0 overflow-y-auto xl:block">
|
|
25
|
+
{aside}
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</main>);
|
|
29
|
+
}
|
|
17
30
|
return (<main className={"min-h-screen ".concat(className)} {...rest}>
|
|
18
31
|
<div className={"mx-auto flex w-full flex-col gap-section px-xlarge pb-page pt-giant md:px-xxlarge ".concat(fluid ? '' : "max-w-page ".concat(wide ? '2xl:max-w-page-wide' : ''))}>
|
|
19
32
|
{children}
|
|
@@ -5,6 +5,7 @@ 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
|
+
import { isInTopOverlay } from '../internal/overlayStack';
|
|
8
9
|
export default function Popover(_a) {
|
|
9
10
|
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
11
|
var _c = useState(null), popoverElement = _c[0], setPopoverElement = _c[1];
|
|
@@ -28,6 +29,9 @@ export default function Popover(_a) {
|
|
|
28
29
|
};
|
|
29
30
|
var handleKeyDown = function (event) {
|
|
30
31
|
if (event.key === 'Escape') {
|
|
32
|
+
// Under a Modal or Drawer opened after it, the Escape belongs to that overlay
|
|
33
|
+
if (!isInTopOverlay(anchorEl))
|
|
34
|
+
return;
|
|
31
35
|
// Close only the Popover: keep this Escape from reaching a Modal's window listener
|
|
32
36
|
event.stopPropagation();
|
|
33
37
|
onClose();
|
|
@@ -12,11 +12,15 @@ interface RadioGroupProps {
|
|
|
12
12
|
selectedValue: string;
|
|
13
13
|
onChange: (value: string) => void;
|
|
14
14
|
direction?: 'horizontal' | 'vertical';
|
|
15
|
+
/** On the `radiogroup` element, so a `FormField` label and help text can point at it */
|
|
16
|
+
id?: string;
|
|
15
17
|
'aria-label'?: string;
|
|
18
|
+
/** Id of the element that describes the group, e.g. help or error text */
|
|
19
|
+
'aria-describedby'?: string;
|
|
16
20
|
/** `card` draws each option as a bordered card that is the radio's label, with the selected one in the accent border */
|
|
17
21
|
variant?: 'default' | 'card';
|
|
18
22
|
/** Disables every option */
|
|
19
23
|
disabled?: boolean;
|
|
20
24
|
}
|
|
21
|
-
export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, variant, disabled, }: RadioGroupProps): React.JSX.Element;
|
|
25
|
+
export default function RadioGroup({ options, selectedValue, onChange, direction, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, variant, disabled, }: RadioGroupProps): React.JSX.Element;
|
|
22
26
|
export {};
|
|
@@ -3,10 +3,10 @@ import React, { useId } from 'react';
|
|
|
3
3
|
import { popTransition, stateTransition } from './sharedStyles';
|
|
4
4
|
import Tag from './tag';
|
|
5
5
|
export default function RadioGroup(_a) {
|
|
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
|
+
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, id = _a.id, ariaLabel = _a["aria-label"], ariaDescribedBy = _a["aria-describedby"], _c = _a.variant, variant = _c === void 0 ? 'default' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d;
|
|
7
7
|
// One shared name gives native arrow-key movement between the options
|
|
8
8
|
var groupName = useId();
|
|
9
|
-
return (<div role="radiogroup" aria-label={ariaLabel} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
9
|
+
return (<div role="radiogroup" id={id} aria-label={ariaLabel} aria-describedby={ariaDescribedBy} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
10
10
|
{options.map(function (option) {
|
|
11
11
|
var isSelected = selectedValue === option.value;
|
|
12
12
|
var isDisabled = disabled || !!option.disabled;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SegmentedControlProps {
|
|
3
|
+
options: {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
/** The selected option's value. The control stays controlled: it shows `value` until the parent changes it. */
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
/** Names the group, e.g. "Range". Required: the options alone do not say what they choose. */
|
|
11
|
+
'aria-label': string;
|
|
12
|
+
size?: 'medium' | 'small' | 'tiny';
|
|
13
|
+
/** `fill` takes the width of its container. `fit` is as wide as its options, for a control that sits beside a heading. */
|
|
14
|
+
width?: 'fill' | 'fit';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A row of options that sets one value on the same page, with the look of `TabsContainer fill`.
|
|
18
|
+
* Use tabs to switch panels and this to change a value. Arrow keys move and select; only the
|
|
19
|
+
* selected option is in the tab order.
|
|
20
|
+
*/
|
|
21
|
+
export default function SegmentedControl({ options, value, onChange, 'aria-label': ariaLabel, size, width, }: SegmentedControlProps): React.JSX.Element;
|
|
22
|
+
export { SegmentedControl };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import { SlidingPill, segmentIdleClasses, segmentItemClasses, segmentSelectedClasses, segmentSizes, segmentTrackClasses, segmentTrackStyle, useSlidingIndicator, } from './slidingIndicator';
|
|
4
|
+
/**
|
|
5
|
+
* A row of options that sets one value on the same page, with the look of `TabsContainer fill`.
|
|
6
|
+
* Use tabs to switch panels and this to change a value. Arrow keys move and select; only the
|
|
7
|
+
* selected option is in the tab order.
|
|
8
|
+
*/
|
|
9
|
+
export default function SegmentedControl(_a) {
|
|
10
|
+
var options = _a.options, value = _a.value, onChange = _a.onChange, ariaLabel = _a["aria-label"], _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.width, width = _c === void 0 ? 'fill' : _c;
|
|
11
|
+
var _d = useSlidingIndicator(options), containerRef = _d.containerRef, indicator = _d.indicator;
|
|
12
|
+
var refs = useRef([]);
|
|
13
|
+
var sizeClasses = segmentSizes[size];
|
|
14
|
+
var selectedIndex = options.findIndex(function (o) { return o.value === value; });
|
|
15
|
+
// With no match the first option is the way in
|
|
16
|
+
var tabStop = selectedIndex === -1 ? 0 : selectedIndex;
|
|
17
|
+
var move = function (to) {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = refs.current[to]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
20
|
+
onChange(options[to].value);
|
|
21
|
+
};
|
|
22
|
+
var handleKeyDown = function (e) {
|
|
23
|
+
var current = refs.current.findIndex(function (el) { return el === document.activeElement; });
|
|
24
|
+
if (current === -1 || options.length === 0)
|
|
25
|
+
return;
|
|
26
|
+
var last = options.length - 1;
|
|
27
|
+
var next = {
|
|
28
|
+
ArrowRight: current === last ? 0 : current + 1,
|
|
29
|
+
ArrowDown: current === last ? 0 : current + 1,
|
|
30
|
+
ArrowLeft: current === 0 ? last : current - 1,
|
|
31
|
+
ArrowUp: current === 0 ? last : current - 1,
|
|
32
|
+
Home: 0,
|
|
33
|
+
End: last,
|
|
34
|
+
}[e.key];
|
|
35
|
+
if (next === undefined)
|
|
36
|
+
return;
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
move(next);
|
|
39
|
+
};
|
|
40
|
+
return (<div ref={containerRef} role="radiogroup" aria-label={ariaLabel} onKeyDown={handleKeyDown} className={segmentTrackClasses(width === 'fill', options.length > 0)} style={segmentTrackStyle}>
|
|
41
|
+
<SlidingPill indicator={indicator}/>
|
|
42
|
+
{options.map(function (option, i) {
|
|
43
|
+
var selected = i === selectedIndex;
|
|
44
|
+
return (<button key={option.value} ref={function (el) {
|
|
45
|
+
refs.current[i] = el;
|
|
46
|
+
}} type="button" role="radio" aria-checked={selected} tabIndex={i === tabStop ? 0 : -1} data-tab-selected={selected} onClick={function () { return onChange(option.value); }} className={segmentItemClasses(width === 'fill', sizeClasses.tab, selected ? segmentSelectedClasses : segmentIdleClasses)}>
|
|
47
|
+
<div className={"flex flex-col text-center ".concat(sizeClasses.label)}>
|
|
48
|
+
<span className="whitespace-nowrap">{option.label}</span>
|
|
49
|
+
</div>
|
|
50
|
+
</button>);
|
|
51
|
+
})}
|
|
52
|
+
</div>);
|
|
53
|
+
}
|
|
54
|
+
export { SegmentedControl };
|
|
@@ -14,7 +14,11 @@ interface SelectProps {
|
|
|
14
14
|
width?: number | string;
|
|
15
15
|
multiple?: boolean;
|
|
16
16
|
className?: string;
|
|
17
|
+
/** On the combobox element, so a `FormField` label and help text can point at it */
|
|
18
|
+
id?: string;
|
|
17
19
|
'aria-label'?: string;
|
|
20
|
+
/** Id of the element that describes the select, e.g. help or error text */
|
|
21
|
+
'aria-describedby'?: string;
|
|
18
22
|
}
|
|
19
|
-
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, 'aria-label': ariaLabel, }: SelectProps): React.JSX.Element;
|
|
23
|
+
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }: SelectProps): React.JSX.Element;
|
|
20
24
|
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, ariaLabel = _a["aria-label"];
|
|
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, id = _a.id, ariaLabel = _a["aria-label"], ariaDescribedBy = _a["aria-describedby"];
|
|
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];
|
|
@@ -210,7 +210,7 @@ export default function Select(_a) {
|
|
|
210
210
|
};
|
|
211
211
|
return (<div className={"relative ".concat(className)} style={{ width: width || '100%' }}>
|
|
212
212
|
{/* Select Button */}
|
|
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}>
|
|
213
|
+
<div ref={setTrigger} role="combobox" id={id} aria-label={ariaLabel} aria-describedby={ariaDescribedBy} 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}>
|
|
214
214
|
{/* Inner Content Container; 7px vertical padding makes the control 40px like Button and TextField */}
|
|
215
215
|
<div className={"flex items-center justify-between px-2 py-[7px] ".concat(getTextColor())}>
|
|
216
216
|
{/* Content Container */}
|