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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SettingsSectionProps {
|
|
3
|
+
title: string;
|
|
4
|
+
/** One line under the title, in secondary text. */
|
|
5
|
+
description?: string;
|
|
6
|
+
/** The section's controls, in one column. */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** `danger` colors the title and the line above with the error colors, for a danger zone. */
|
|
9
|
+
tone?: 'default' | 'danger';
|
|
10
|
+
/** The section's id; the title gets `<id>-title`. Lets a nav link to the section. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** The title's element. Default 2. */
|
|
13
|
+
level?: 2 | 3 | 4;
|
|
14
|
+
}
|
|
15
|
+
export default function SettingsSection({ title, description, children, tone, id, level }: SettingsSectionProps): React.JSX.Element;
|
|
16
|
+
interface SettingsColumnsProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare function SettingsColumns({ children }: SettingsColumnsProps): React.JSX.Element;
|
|
20
|
+
interface SettingsLayoutProps {
|
|
21
|
+
/** The side navigation, a `Navigation`. */
|
|
22
|
+
nav: React.ReactNode;
|
|
23
|
+
/** The open area's content. */
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
/** Below md, show the content (`true`) or the nav (`false`). From md up the nav and the content always sit side by side. */
|
|
26
|
+
showContent: boolean;
|
|
27
|
+
/** A Button that goes back to the nav. Shown only below md, above the content. */
|
|
28
|
+
back?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* The nav column from md up: `narrow` (16rem, default) for a settings nav, `wide` (22rem) for a list of rows beside its detail.
|
|
31
|
+
* Below md a `wide` list is the whole screen: it drops its divider, and its open row (the one with `aria-current`) does not look selected.
|
|
32
|
+
*/
|
|
33
|
+
navWidth?: 'narrow' | 'wide';
|
|
34
|
+
}
|
|
35
|
+
export declare function SettingsLayout({ nav, children, showContent, back, navWidth }: SettingsLayoutProps): React.JSX.Element;
|
|
36
|
+
export { SettingsSection };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useId, useRef } from 'react';
|
|
3
|
+
import Heading from './heading';
|
|
4
|
+
// A hairline, a title, a description and then the controls. Reads as one block, so it never splits.
|
|
5
|
+
export default function SettingsSection(_a) {
|
|
6
|
+
var title = _a.title, description = _a.description, children = _a.children, _b = _a.tone, tone = _b === void 0 ? 'default' : _b, id = _a.id, _c = _a.level, level = _c === void 0 ? 2 : _c;
|
|
7
|
+
var generated = useId();
|
|
8
|
+
var titleId = id ? "".concat(id, "-title") : generated;
|
|
9
|
+
var danger = tone === 'danger';
|
|
10
|
+
return (<section id={id} aria-labelledby={titleId} className={"flex flex-col gap-large border-t pt-large ".concat(danger ? 'border-error-main' : 'border-misc-divider')}>
|
|
11
|
+
<div className="flex flex-col gap-small">
|
|
12
|
+
<Heading level={level} id={titleId} color={danger ? 'danger' : 'default'}>
|
|
13
|
+
{title}
|
|
14
|
+
</Heading>
|
|
15
|
+
{description && <p className="text-body2 text-fg-secondary">{description}</p>}
|
|
16
|
+
</div>
|
|
17
|
+
<div className="flex flex-col gap-medium">{children}</div>
|
|
18
|
+
</section>);
|
|
19
|
+
}
|
|
20
|
+
// Sections in one column, two from md up. A grid, so a section is never cut across columns.
|
|
21
|
+
export function SettingsColumns(_a) {
|
|
22
|
+
var children = _a.children;
|
|
23
|
+
return <div className="grid grid-cols-1 items-start gap-xlarge md:grid-cols-2">{children}</div>;
|
|
24
|
+
}
|
|
25
|
+
// A side nav beside its content from md up. On a phone the nav is the page and an item opens its content, so only one shows at a time.
|
|
26
|
+
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
27
|
+
var isHidden = function (el) { return !el || getComputedStyle(el).display === 'none'; };
|
|
28
|
+
// Written out whole so the app's Tailwind finds them
|
|
29
|
+
var navColumns = {
|
|
30
|
+
narrow: 'md:grid-cols-[16rem_minmax(0,1fr)]',
|
|
31
|
+
wide: 'md:grid-cols-[22rem_minmax(0,1fr)]',
|
|
32
|
+
};
|
|
33
|
+
// Below md a list of rows is the screen on its own: no divider beside nothing, and no row marked open while nothing is open
|
|
34
|
+
var listOnPhone = 'max-md:[&>nav]:border-r-0 max-md:[&_[aria-current]:not([aria-current=false])]:bg-transparent max-md:[&_[aria-current]:not([aria-current=false])_*]:bg-transparent max-md:[&_[aria-current]:not([aria-current=false])_*]:text-fg-primary';
|
|
35
|
+
export function SettingsLayout(_a) {
|
|
36
|
+
var nav = _a.nav, children = _a.children, showContent = _a.showContent, back = _a.back, _b = _a.navWidth, navWidth = _b === void 0 ? 'narrow' : _b;
|
|
37
|
+
var navRef = useRef(null);
|
|
38
|
+
var contentRef = useRef(null);
|
|
39
|
+
var prev = useRef(showContent);
|
|
40
|
+
// On a phone one side hides the other, and the focused control goes with it. Move focus to the side that shows:
|
|
41
|
+
// the back Button (or the first control) when the content opens, the open item when the nav returns.
|
|
42
|
+
// From md up both sides show, so focus stays where it is.
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
// Compare with the last value, not a first-run flag: StrictMode runs the effect twice on mount.
|
|
46
|
+
if (prev.current === showContent)
|
|
47
|
+
return;
|
|
48
|
+
prev.current = showContent;
|
|
49
|
+
if (showContent && isHidden(navRef.current)) {
|
|
50
|
+
(_b = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(FOCUSABLE)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
51
|
+
}
|
|
52
|
+
else if (!showContent && isHidden(contentRef.current)) {
|
|
53
|
+
var items = navRef.current;
|
|
54
|
+
(_d = ((_c = items === null || items === void 0 ? void 0 : items.querySelector('[aria-current]')) !== null && _c !== void 0 ? _c : items === null || items === void 0 ? void 0 : items.querySelector(FOCUSABLE))) === null || _d === void 0 ? void 0 : _d.focus();
|
|
55
|
+
}
|
|
56
|
+
}, [showContent]);
|
|
57
|
+
return (<div className={"grid grid-cols-1 items-start gap-xlarge ".concat(navColumns[navWidth])}>
|
|
58
|
+
<div ref={navRef} className={"".concat(showContent ? 'hidden md:block' : 'block').concat(navWidth === 'wide' ? " ".concat(listOnPhone) : '')}>{nav}</div>
|
|
59
|
+
<div ref={contentRef} className={"flex-col gap-large ".concat(showContent ? 'flex' : 'hidden md:flex')}>
|
|
60
|
+
{back && <div className="md:hidden">{back}</div>}
|
|
61
|
+
{children}
|
|
62
|
+
</div>
|
|
63
|
+
</div>);
|
|
64
|
+
}
|
|
65
|
+
export { SettingsSection };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SidePaneProps {
|
|
3
|
+
/** Names the pane and shows in its title bar */
|
|
4
|
+
title: string;
|
|
5
|
+
/** Close and Escape call it; the page then removes the pane */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Buttons in the title bar, before Close */
|
|
9
|
+
actions?: React.ReactNode;
|
|
10
|
+
/** The width in px from lg up. Default 24rem. */
|
|
11
|
+
width?: number;
|
|
12
|
+
/** Makes the start edge a handle that resizes the pane, by pointer or by arrow keys */
|
|
13
|
+
onWidthChange?: (width: number) => void;
|
|
14
|
+
/** The smallest width in px. Default 320. */
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
/** The largest width in px. Default 60% of the window. */
|
|
17
|
+
maxWidth?: number;
|
|
18
|
+
/** The Close button's name. Default 'Close <title>'. */
|
|
19
|
+
closeLabel?: string;
|
|
20
|
+
}
|
|
21
|
+
/** What a ref on SidePane gets: `focus()` moves focus to the pane's title, to bring an open pane forward */
|
|
22
|
+
export interface SidePaneHandle {
|
|
23
|
+
focus(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A pane beside the page, not over it: no scrim, the page stays usable. Focus moves to its title on
|
|
27
|
+
* open and back to the opener on close. Escape closes it while focus is inside and no overlay is on top.
|
|
28
|
+
* Escape anywhere inside the pane closes it, including an Escape that hides a tooltip or clears a field.
|
|
29
|
+
*/
|
|
30
|
+
declare const SidePane: React.ForwardRefExoticComponent<SidePaneProps & React.RefAttributes<SidePaneHandle>>;
|
|
31
|
+
export default SidePane;
|
|
32
|
+
export { SidePane };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { X } from 'lucide-react';
|
|
4
|
+
import IconButton from './iconButton';
|
|
5
|
+
import TitleBar from './titleBar';
|
|
6
|
+
import { focusRing } from './sharedStyles';
|
|
7
|
+
import { claimEvent, isInTopOverlay } from '../internal/overlayStack';
|
|
8
|
+
import { clampWidth, dragWidth, keyWidth, paneLimits } from '../internal/resize';
|
|
9
|
+
// useLayoutEffect warns on a server render, where it cannot run; useEffect is the same there and silent
|
|
10
|
+
var useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
11
|
+
var DEFAULT_WIDTH = 384;
|
|
12
|
+
/**
|
|
13
|
+
* A pane beside the page, not over it: no scrim, the page stays usable. Focus moves to its title on
|
|
14
|
+
* open and back to the opener on close. Escape closes it while focus is inside and no overlay is on top.
|
|
15
|
+
* Escape anywhere inside the pane closes it, including an Escape that hides a tooltip or clears a field.
|
|
16
|
+
*/
|
|
17
|
+
var SidePane = forwardRef(function SidePane(_a, ref) {
|
|
18
|
+
var title = _a.title, onClose = _a.onClose, children = _a.children, actions = _a.actions, width = _a.width, onWidthChange = _a.onWidthChange, _b = _a.minWidth, minWidth = _b === void 0 ? 320 : _b, maxWidth = _a.maxWidth, closeLabel = _a.closeLabel;
|
|
19
|
+
var asideRef = useRef(null);
|
|
20
|
+
var titleId = useId();
|
|
21
|
+
var onCloseRef = useRef(onClose);
|
|
22
|
+
onCloseRef.current = onClose;
|
|
23
|
+
var focusTitle = function () { var _a; return (_a = document.getElementById(titleId)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
24
|
+
useImperativeHandle(ref, function () { return ({ focus: focusTitle }); });
|
|
25
|
+
// Focus the title on mount, and on unmount give focus back to what had it, if focus was in the pane.
|
|
26
|
+
// A layout effect, so the cleanup runs while the pane is still on the page and can tell.
|
|
27
|
+
var returnTo = useRef(null);
|
|
28
|
+
var mounted = useRef(false);
|
|
29
|
+
useIsomorphicLayoutEffect(function () {
|
|
30
|
+
mounted.current = true;
|
|
31
|
+
var aside = asideRef.current;
|
|
32
|
+
var active = document.activeElement;
|
|
33
|
+
// StrictMode runs this twice; the second run finds focus already in the pane and keeps the opener
|
|
34
|
+
if (active && !(aside === null || aside === void 0 ? void 0 : aside.contains(active)))
|
|
35
|
+
returnTo.current = active;
|
|
36
|
+
focusTitle();
|
|
37
|
+
return function () {
|
|
38
|
+
mounted.current = false;
|
|
39
|
+
if (!(aside === null || aside === void 0 ? void 0 : aside.contains(document.activeElement)))
|
|
40
|
+
return;
|
|
41
|
+
var target = returnTo.current;
|
|
42
|
+
// After the commit: the opener may be in content that shows again in the same update
|
|
43
|
+
// (AppShell hides main beside a pane below lg). A remount in StrictMode cancels it.
|
|
44
|
+
queueMicrotask(function () {
|
|
45
|
+
if (!mounted.current)
|
|
46
|
+
target === null || target === void 0 ? void 0 : target.focus();
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
50
|
+
// On window, after Popover's document listener, which keeps a menu's Escape to itself
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
var handleKeyDown = function (e) {
|
|
53
|
+
if (e.key !== 'Escape' || e.defaultPrevented)
|
|
54
|
+
return;
|
|
55
|
+
var aside = asideRef.current;
|
|
56
|
+
if (!aside || !aside.contains(document.activeElement) || !isInTopOverlay(aside))
|
|
57
|
+
return;
|
|
58
|
+
if (claimEvent(e))
|
|
59
|
+
onCloseRef.current();
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
62
|
+
return function () { return window.removeEventListener('keydown', handleKeyDown); };
|
|
63
|
+
}, []);
|
|
64
|
+
var resizable = !!onWidthChange;
|
|
65
|
+
var sized = resizable || width !== undefined;
|
|
66
|
+
// The default maximum needs the window, so it is known only after mount (the server uses the width)
|
|
67
|
+
var _c = useState(null), windowWidth = _c[0], setWindowWidth = _c[1];
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
if (!sized || maxWidth !== undefined)
|
|
70
|
+
return;
|
|
71
|
+
var update = function () { return setWindowWidth(window.innerWidth); };
|
|
72
|
+
update();
|
|
73
|
+
window.addEventListener('resize', update);
|
|
74
|
+
return function () { return window.removeEventListener('resize', update); };
|
|
75
|
+
}, [sized, maxWidth]);
|
|
76
|
+
var limits = maxWidth !== undefined || windowWidth !== null
|
|
77
|
+
? paneLimits(minWidth, maxWidth, windowWidth !== null && windowWidth !== void 0 ? windowWidth : 0)
|
|
78
|
+
: { min: minWidth, max: Math.max(minWidth, width !== null && width !== void 0 ? width : DEFAULT_WIDTH) };
|
|
79
|
+
var current = clampWidth(width !== null && width !== void 0 ? width : DEFAULT_WIDTH, limits.min, limits.max);
|
|
80
|
+
var drag = useRef(null);
|
|
81
|
+
var endDrag = function (e) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
drag.current = null;
|
|
84
|
+
if ((_b = (_a = e.currentTarget).hasPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId))
|
|
85
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
86
|
+
};
|
|
87
|
+
return (<aside ref={asideRef} aria-labelledby={titleId} style={sized ? { '--side-pane-width': "".concat(current, "px") } : undefined} className={"relative flex w-full min-w-0 flex-col bg-background-default lg:h-full lg:shrink-0 lg:border-l lg:border-misc-divider ".concat(sized ? 'lg:w-[var(--side-pane-width)]' : 'lg:w-[24rem]')}>
|
|
88
|
+
{resizable && (<div role="separator" aria-orientation="vertical" aria-valuenow={current} aria-valuemin={limits.min} aria-valuemax={limits.max} aria-label={"Resize ".concat(title)} tabIndex={0} className={"group absolute inset-y-0 left-0 z-10 w-3 -translate-x-1/2 cursor-col-resize touch-none hidden lg:block ".concat(focusRing)} onKeyDown={function (e) {
|
|
89
|
+
var next = keyWidth(e.key, current, limits.min, limits.max);
|
|
90
|
+
if (next === null)
|
|
91
|
+
return;
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
onWidthChange(next);
|
|
94
|
+
}} onPointerDown={function (e) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
if (e.button !== 0)
|
|
97
|
+
return;
|
|
98
|
+
// No text selection while dragging
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
(_b = (_a = e.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId);
|
|
101
|
+
drag.current = { x: e.clientX, width: current };
|
|
102
|
+
}} onPointerMove={function (e) {
|
|
103
|
+
if (!drag.current)
|
|
104
|
+
return;
|
|
105
|
+
// The button came up somewhere the up event never reached us
|
|
106
|
+
if (e.buttons === 0) {
|
|
107
|
+
drag.current = null;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
onWidthChange(dragWidth(drag.current.width, drag.current.x, e.clientX, limits.min, limits.max));
|
|
111
|
+
}} onPointerUp={endDrag} onPointerCancel={endDrag} onLostPointerCapture={function () {
|
|
112
|
+
drag.current = null;
|
|
113
|
+
}}>
|
|
114
|
+
<div className="mx-auto h-full w-0.5 group-hover:bg-fg-secondary group-active:bg-fg-primary"/>
|
|
115
|
+
</div>)}
|
|
116
|
+
<div className="shrink-0 border-b border-misc-divider py-2 pl-4 pr-2">
|
|
117
|
+
<TitleBar title={title} level={2} id={titleId} actions={<>
|
|
118
|
+
{actions}
|
|
119
|
+
<IconButton color="iconOnly" state="enabled" size="medium" icon={X} ariaLabel={closeLabel !== null && closeLabel !== void 0 ? closeLabel : "Close ".concat(title)} onClick={onClose}/>
|
|
120
|
+
</>}/>
|
|
121
|
+
</div>
|
|
122
|
+
<div className="min-h-0 flex-1 overflow-y-auto px-4 py-4 text-body1 text-fg-primary" style={{ scrollbarWidth: 'thin' }}>
|
|
123
|
+
{children}
|
|
124
|
+
</div>
|
|
125
|
+
</aside>);
|
|
126
|
+
});
|
|
127
|
+
export default SidePane;
|
|
128
|
+
export { SidePane };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SiteBrand } from './siteHeader';
|
|
3
|
+
export interface SiteFooterLink {
|
|
4
|
+
label: string;
|
|
5
|
+
href: string;
|
|
6
|
+
/** Opens in a new tab and says so: a small icon and the hidden words '(opens in a new tab)' */
|
|
7
|
+
external?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SiteFooterColumn {
|
|
10
|
+
title: string;
|
|
11
|
+
links: SiteFooterLink[];
|
|
12
|
+
}
|
|
13
|
+
interface SiteFooterProps {
|
|
14
|
+
brand?: SiteBrand;
|
|
15
|
+
/** Titled lists of links: two across on a phone, up to four from md */
|
|
16
|
+
columns?: SiteFooterColumn[];
|
|
17
|
+
/** Links without a column: one row that wraps */
|
|
18
|
+
links?: SiteFooterLink[];
|
|
19
|
+
/** The caption line, e.g. '© 2026 Acme' */
|
|
20
|
+
legal?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A site's footer: the brand, a `<nav aria-label="Footer">` of linked columns and a row of links, and a legal line */
|
|
23
|
+
export default function SiteFooter({ brand, columns, links, legal }: SiteFooterProps): React.JSX.Element;
|
|
24
|
+
export { SiteFooter };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useId } from 'react';
|
|
3
|
+
import Link from './link';
|
|
4
|
+
import { SiteBrandLink } from '../internal/siteBrand';
|
|
5
|
+
// Written out whole so Tailwind finds them
|
|
6
|
+
var columnCount = ['md:grid-cols-1', 'md:grid-cols-1', 'md:grid-cols-2', 'md:grid-cols-3', 'md:grid-cols-4'];
|
|
7
|
+
var FooterLink = function (_a) {
|
|
8
|
+
var link = _a.link;
|
|
9
|
+
return (<Link href={link.href} size="body2" openInNewTab={link.external} announceNewTab={link.external}>
|
|
10
|
+
{link.label}
|
|
11
|
+
</Link>);
|
|
12
|
+
};
|
|
13
|
+
/** A site's footer: the brand, a `<nav aria-label="Footer">` of linked columns and a row of links, and a legal line */
|
|
14
|
+
export default function SiteFooter(_a) {
|
|
15
|
+
var brand = _a.brand, columns = _a.columns, links = _a.links, legal = _a.legal;
|
|
16
|
+
var hasNav = !!(columns === null || columns === void 0 ? void 0 : columns.length) || !!(links === null || links === void 0 ? void 0 : links.length);
|
|
17
|
+
return (<footer className="border-t border-misc-divider bg-background-default">
|
|
18
|
+
<div className="mx-auto flex w-full max-w-page-wide flex-col gap-xlarge px-xlarge py-xxlarge md:px-xxlarge">
|
|
19
|
+
{brand && <SiteBrandLink brand={brand}/>}
|
|
20
|
+
{hasNav && (<nav aria-label="Footer" className="flex flex-col gap-xlarge">
|
|
21
|
+
{!!(columns === null || columns === void 0 ? void 0 : columns.length) && (<div className={"grid grid-cols-2 gap-x-4 gap-y-xlarge ".concat(columnCount[Math.min(columns.length, 4)])}>
|
|
22
|
+
{columns.map(function (column) { return (<FooterColumn key={column.title} column={column}/>); })}
|
|
23
|
+
</div>)}
|
|
24
|
+
{!!(links === null || links === void 0 ? void 0 : links.length) && (<ul className="m-0 flex list-none flex-wrap gap-x-4 gap-y-2 p-0">
|
|
25
|
+
{links.map(function (link) { return (<li key={link.href + link.label}>
|
|
26
|
+
<FooterLink link={link}/>
|
|
27
|
+
</li>); })}
|
|
28
|
+
</ul>)}
|
|
29
|
+
</nav>)}
|
|
30
|
+
{legal && <p className="m-0 text-caption text-fg-secondary">{legal}</p>}
|
|
31
|
+
</div>
|
|
32
|
+
</footer>);
|
|
33
|
+
}
|
|
34
|
+
function FooterColumn(_a) {
|
|
35
|
+
var column = _a.column;
|
|
36
|
+
var titleId = useId();
|
|
37
|
+
return (<div className="flex min-w-0 flex-col gap-2">
|
|
38
|
+
<p id={titleId} className="m-0 text-subtitle2 text-fg-primary">
|
|
39
|
+
{column.title}
|
|
40
|
+
</p>
|
|
41
|
+
<ul aria-labelledby={titleId} className="m-0 flex list-none flex-col gap-2 p-0">
|
|
42
|
+
{column.links.map(function (link) { return (<li key={link.href + link.label}>
|
|
43
|
+
<FooterLink link={link}/>
|
|
44
|
+
</li>); })}
|
|
45
|
+
</ul>
|
|
46
|
+
</div>);
|
|
47
|
+
}
|
|
48
|
+
export { SiteFooter };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** The site's name and its way home, shared by `SiteHeader` and `SiteFooter` */
|
|
3
|
+
export interface SiteBrand {
|
|
4
|
+
/** Where the brand goes: the home page */
|
|
5
|
+
href: string;
|
|
6
|
+
/** The site's name. It is the logo's alt text, and the text shown when there is no logo. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The logo's file. Without it the name is shown as text. */
|
|
9
|
+
src?: string;
|
|
10
|
+
/** The logo's size in px; set both so the bar keeps its height while the file loads. Default height 28. */
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SiteHeaderLink {
|
|
15
|
+
label: string;
|
|
16
|
+
href: string;
|
|
17
|
+
/** The page the reader is on: gets `aria-current="page"` */
|
|
18
|
+
current?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface SiteHeaderProps {
|
|
21
|
+
brand: SiteBrand;
|
|
22
|
+
/** The main places, in order. From md a row in the bar; below md in the menu. */
|
|
23
|
+
links: SiteHeaderLink[];
|
|
24
|
+
/**
|
|
25
|
+
* The secondary Buttons, e.g. 'Log In': at the end of the bar from md; below md under the links in the menu,
|
|
26
|
+
* and only there. A Button here that opens its own Modal or menu should be moved out: choosing in the menu closes it.
|
|
27
|
+
*/
|
|
28
|
+
actions?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* The main action, e.g. 'Sign Up': last in the bar at every width, so below md it stays beside the brand and the
|
|
31
|
+
* Menu IconButton. It is not in the menu, so do not repeat it in `actions`.
|
|
32
|
+
*/
|
|
33
|
+
phoneAction?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* A second row inside the bar at every width, under the brand and the actions: e.g. the section `Tab`s of a docs site.
|
|
36
|
+
* It never moves into the Menu, so keep it short enough for a phone.
|
|
37
|
+
*/
|
|
38
|
+
nav?: React.ReactNode;
|
|
39
|
+
/** The Menu IconButton's name, and the Drawer's. Default 'Menu'. */
|
|
40
|
+
menuLabel?: string;
|
|
41
|
+
/** The skip link's text. Default 'Skip to content'. */
|
|
42
|
+
skipLabel?: string;
|
|
43
|
+
/** The id the skip link goes to. Default 'main'. Give `PageShell` (or your `<main>`) `id={mainId}` and `tabIndex={-1}`, so focus can move into it. */
|
|
44
|
+
mainId?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
48
|
+
* links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
|
|
49
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer.
|
|
50
|
+
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
51
|
+
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
52
|
+
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
53
|
+
*/
|
|
54
|
+
export default function SiteHeader({ brand, links, actions, phoneAction, nav, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
|
|
55
|
+
export { SiteHeader };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useId, useRef, useState } from 'react';
|
|
3
|
+
import { Menu } from 'lucide-react';
|
|
4
|
+
import Drawer from './drawer';
|
|
5
|
+
import IconButton from './iconButton';
|
|
6
|
+
import { focusRing } from './sharedStyles';
|
|
7
|
+
import { SiteBrandLink } from '../internal/siteBrand';
|
|
8
|
+
// Tailwind's md breakpoint: the links are a row in the bar from here up
|
|
9
|
+
var WIDE = '(min-width: 768px)';
|
|
10
|
+
/**
|
|
11
|
+
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
12
|
+
* links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
|
|
13
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer.
|
|
14
|
+
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
15
|
+
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
16
|
+
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
17
|
+
*/
|
|
18
|
+
export default function SiteHeader(_a) {
|
|
19
|
+
var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
|
|
20
|
+
var drawerId = useId();
|
|
21
|
+
// Without links or actions there is nothing for a Menu to hold
|
|
22
|
+
var hasMenu = links.length > 0 || !!actions;
|
|
23
|
+
var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
24
|
+
var barRef = useRef(null);
|
|
25
|
+
// Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
|
|
26
|
+
var refocusAfterWiden = useRef(false);
|
|
27
|
+
// Publish the bar's height for what sticks or scrolls below it (PageShell's aside, OnThisPage, heading scroll-margin)
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
var bar = barRef.current;
|
|
30
|
+
if (!bar)
|
|
31
|
+
return;
|
|
32
|
+
var root = document.documentElement;
|
|
33
|
+
var publish = function () { return root.style.setProperty('--os-header-offset', "".concat(bar.getBoundingClientRect().height, "px")); };
|
|
34
|
+
publish();
|
|
35
|
+
// On a server-rendered page the browser scrolled to the #hash before the offset existed, so the heading sits under
|
|
36
|
+
// the bar. Scroll to it once more, now with the scroll margin. Only on the first publish, never on a resize.
|
|
37
|
+
var target = null;
|
|
38
|
+
try {
|
|
39
|
+
target = location.hash.length > 1 ? document.getElementById(decodeURIComponent(location.hash.slice(1))) : null;
|
|
40
|
+
}
|
|
41
|
+
catch (_a) {
|
|
42
|
+
// a malformed hash names no heading
|
|
43
|
+
}
|
|
44
|
+
// Only a heading under the bar: one far above it means the person (or the browser's restore) scrolled on
|
|
45
|
+
var top = target === null || target === void 0 ? void 0 : target.getBoundingClientRect().top;
|
|
46
|
+
if (target && top !== undefined && top > -2 && top < bar.getBoundingClientRect().height) {
|
|
47
|
+
target.scrollIntoView({ block: 'start', behavior: 'instant' });
|
|
48
|
+
}
|
|
49
|
+
var observer = new ResizeObserver(publish);
|
|
50
|
+
observer.observe(bar);
|
|
51
|
+
return function () {
|
|
52
|
+
observer.disconnect();
|
|
53
|
+
root.style.removeProperty('--os-header-offset');
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
// The Drawer is for a phone: widening past md closes it, so the page is never left locked under it
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (!menuOpen)
|
|
59
|
+
return;
|
|
60
|
+
var wide = window.matchMedia(WIDE);
|
|
61
|
+
var closeIfWide = function () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!wide.matches)
|
|
64
|
+
return;
|
|
65
|
+
refocusAfterWiden.current = !!((_a = document.getElementById(drawerId)) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement));
|
|
66
|
+
setMenuOpen(false);
|
|
67
|
+
};
|
|
68
|
+
closeIfWide();
|
|
69
|
+
wide.addEventListener('change', closeIfWide);
|
|
70
|
+
return function () { return wide.removeEventListener('change', closeIfWide); };
|
|
71
|
+
}, [menuOpen]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
72
|
+
// After the close commits (the Drawer's cleanup has already sent focus to the hidden Menu IconButton),
|
|
73
|
+
// focus the current link in the bar that is now on screen, or else the brand.
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
var _a, _b, _c, _d;
|
|
76
|
+
if (menuOpen || !refocusAfterWiden.current)
|
|
77
|
+
return;
|
|
78
|
+
refocusAfterWiden.current = false;
|
|
79
|
+
(_d = ((_b = (_a = barRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('nav [aria-current]')) !== null && _b !== void 0 ? _b : (_c = barRef.current) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]'))) === null || _d === void 0 ? void 0 : _d.focus();
|
|
80
|
+
}, [menuOpen]);
|
|
81
|
+
// A link or a Button in the menu closes it. A Button that opens its own menu (aria-haspopup) does not.
|
|
82
|
+
var closeOnChoice = function (e) {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
var choice = (_b = (_a = e.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'a[href], button');
|
|
85
|
+
if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
|
|
86
|
+
setMenuOpen(false);
|
|
87
|
+
};
|
|
88
|
+
var linkList = function (vertical) { return (<nav aria-label="Main" className={vertical ? '' : 'hidden min-w-0 flex-1 md:block'}>
|
|
89
|
+
<ul className={"m-0 flex list-none p-0 ".concat(vertical ? 'flex-col gap-0.5' : 'flex-wrap items-center gap-x-1 gap-y-0.5')}>
|
|
90
|
+
{links.map(function (link) { return (<li key={link.href + link.label}>
|
|
91
|
+
<a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
|
|
92
|
+
{link.label}
|
|
93
|
+
</a>
|
|
94
|
+
</li>); })}
|
|
95
|
+
</ul>
|
|
96
|
+
</nav>); };
|
|
97
|
+
// The Drawer is a sibling of the header: a sticky header is a stacking context, and the panel must sit above the page
|
|
98
|
+
return (<>
|
|
99
|
+
<header ref={barRef} className="sticky top-0 z-10 border-b border-misc-divider bg-background-default">
|
|
100
|
+
<a href={"#".concat(mainId)} className={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[var(--os-z-tooltip)] focus:rounded-control focus:bg-background-elevated focus:px-3 focus:py-2 focus:text-body2 focus:text-fg-primary focus:shadow-overlay ".concat(focusRing)}>
|
|
101
|
+
{skipLabel}
|
|
102
|
+
</a>
|
|
103
|
+
<div className="mx-auto flex w-full max-w-page-wide items-center gap-2 py-2 pl-2 pr-4 md:gap-4 md:px-xxlarge">
|
|
104
|
+
{hasMenu && (<div className="shrink-0 md:hidden">
|
|
105
|
+
<IconButton color="iconOnly" state="enabled" size="medium" icon={Menu} ariaLabel={menuLabel} aria-expanded={menuOpen} aria-controls={drawerId} onClick={function () { return setMenuOpen(true); }}/>
|
|
106
|
+
</div>)}
|
|
107
|
+
<SiteBrandLink brand={brand}/>
|
|
108
|
+
{/* Not while the menu is open, so the links and actions are mounted once. menuOpen is true only below md. */}
|
|
109
|
+
{!menuOpen && links.length > 0 && linkList(false)}
|
|
110
|
+
<div className="ml-auto flex shrink-0 items-center gap-2">
|
|
111
|
+
{actions && !menuOpen && <div className="hidden items-center gap-2 md:flex">{actions}</div>}
|
|
112
|
+
{phoneAction}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
{nav && <div className="mx-auto w-full max-w-page-wide px-4 pb-2 md:px-xxlarge">{nav}</div>}
|
|
116
|
+
</header>
|
|
117
|
+
{hasMenu && (<Drawer id={drawerId} isOpen={menuOpen} onClose={function () { return setMenuOpen(false); }} aria-label={menuLabel} side="start" size="small">
|
|
118
|
+
<div onClick={closeOnChoice} className="flex flex-col gap-4">
|
|
119
|
+
{linkList(true)}
|
|
120
|
+
{actions && <div className="flex flex-col items-start gap-2">{actions}</div>}
|
|
121
|
+
</div>
|
|
122
|
+
</Drawer>)}
|
|
123
|
+
</>);
|
|
124
|
+
}
|
|
125
|
+
export { SiteHeader };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type IndicatorRect = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
animate: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** The track around the items. `filled` is false for an empty track, which stays transparent. */
|
|
10
|
+
export declare function segmentTrackClasses(fill: boolean, filled: boolean): string;
|
|
11
|
+
export declare const segmentTrackStyle: React.CSSProperties;
|
|
12
|
+
/** The classes every item has, selected or not */
|
|
13
|
+
export declare function segmentItemClasses(fill: boolean, sizeClass: string, selectedClasses: string): string;
|
|
14
|
+
/** Item text and icon sizes. Items use `data-tab-selected="true"` on the selected one. */
|
|
15
|
+
export declare const segmentSizes: {
|
|
16
|
+
medium: {
|
|
17
|
+
tab: string;
|
|
18
|
+
label: string;
|
|
19
|
+
secondLabel: string;
|
|
20
|
+
icon: string;
|
|
21
|
+
};
|
|
22
|
+
small: {
|
|
23
|
+
tab: string;
|
|
24
|
+
label: string;
|
|
25
|
+
secondLabel: string;
|
|
26
|
+
icon: string;
|
|
27
|
+
};
|
|
28
|
+
tiny: {
|
|
29
|
+
tab: string;
|
|
30
|
+
label: string;
|
|
31
|
+
secondLabel: string;
|
|
32
|
+
icon: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const segmentSelectedClasses = "text-primary-contrast";
|
|
36
|
+
export declare const segmentIdleClasses = "text-fg-primary hover:bg-background-accent200";
|
|
37
|
+
/**
|
|
38
|
+
* Places a pill behind the item marked `data-tab-selected="true"` inside the container, keeps it
|
|
39
|
+
* there as items resize, and scrolls a newly selected item into view. Pass the container's `ref`
|
|
40
|
+
* and `children` (the effect runs again when they change).
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSlidingIndicator(children: unknown): {
|
|
43
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
44
|
+
indicator: IndicatorRect | null;
|
|
45
|
+
};
|
|
46
|
+
/** The pill itself. Render it first inside the track. */
|
|
47
|
+
export declare function SlidingPill({ indicator }: {
|
|
48
|
+
indicator: IndicatorRect | null;
|
|
49
|
+
}): React.JSX.Element | null;
|
|
50
|
+
export {};
|