oneslash-design-system 2.20.0 → 2.22.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 +1 -1
- package/dist/DESIGN.md +34 -1
- package/dist/cases/about-page/profile.d.ts +1 -0
- package/dist/cases/about-page/profile.jsx +64 -0
- package/dist/cases/about-page.md +114 -0
- package/dist/cases/admin-inbox/list.d.ts +1 -0
- package/dist/cases/admin-inbox/list.jsx +104 -0
- package/dist/cases/admin-inbox/split.d.ts +1 -0
- package/dist/cases/admin-inbox/split.jsx +68 -0
- package/dist/cases/admin-inbox.md +254 -0
- package/dist/cases/api-keys.md +1 -1
- package/dist/cases/app-shell/top-tabs.jsx +10 -4
- package/dist/cases/app-shell.md +13 -5
- package/dist/cases/blog-index/cards.d.ts +1 -0
- package/dist/cases/blog-index/cards.jsx +45 -0
- package/dist/cases/blog-index/list.d.ts +1 -0
- package/dist/cases/blog-index/list.jsx +46 -0
- package/dist/cases/blog-index.md +160 -0
- package/dist/cases/changelog/by-month.d.ts +1 -0
- package/dist/cases/changelog/by-month.jsx +70 -0
- package/dist/cases/changelog/one-page.d.ts +1 -0
- package/dist/cases/changelog/one-page.jsx +70 -0
- package/dist/cases/changelog.md +200 -0
- package/dist/cases/code-sample/block.d.ts +1 -0
- package/dist/cases/code-sample/block.jsx +19 -0
- package/dist/cases/code-sample/command.d.ts +1 -0
- package/dist/cases/code-sample/command.jsx +17 -0
- package/dist/cases/code-sample.md +96 -0
- package/dist/cases/contact-page/form.d.ts +1 -0
- package/dist/cases/contact-page/form.jsx +83 -0
- package/dist/cases/contact-page/links.d.ts +1 -0
- package/dist/cases/contact-page/links.jsx +19 -0
- package/dist/cases/contact-page.md +142 -0
- package/dist/cases/docs-component-page/reference.d.ts +1 -0
- package/dist/cases/docs-component-page/reference.jsx +93 -0
- package/dist/cases/docs-component-page.md +144 -0
- package/dist/cases/faq/accordion.d.ts +1 -0
- package/dist/cases/faq/accordion.jsx +25 -0
- package/dist/cases/faq/open-list.d.ts +1 -0
- package/dist/cases/faq/open-list.jsx +27 -0
- package/dist/cases/faq.md +110 -0
- package/dist/cases/feature-grid/cards.d.ts +1 -0
- package/dist/cases/feature-grid/cards.jsx +33 -0
- package/dist/cases/feature-grid/rows.d.ts +1 -0
- package/dist/cases/feature-grid/rows.jsx +30 -0
- package/dist/cases/feature-grid.md +132 -0
- package/dist/cases/image-viewer/gallery.d.ts +1 -0
- package/dist/cases/image-viewer/gallery.jsx +32 -0
- package/dist/cases/image-viewer/single.d.ts +1 -0
- package/dist/cases/image-viewer/single.jsx +25 -0
- package/dist/cases/image-viewer.md +123 -0
- package/dist/cases/landing-hero/centered.d.ts +1 -0
- package/dist/cases/landing-hero/centered.jsx +22 -0
- package/dist/cases/landing-hero/split.d.ts +1 -0
- package/dist/cases/landing-hero/split.jsx +30 -0
- package/dist/cases/landing-hero.md +114 -0
- package/dist/cases/legal-page/sections.d.ts +1 -0
- package/dist/cases/legal-page/sections.jsx +61 -0
- package/dist/cases/legal-page.md +96 -0
- package/dist/cases/long-form-page/article.d.ts +1 -0
- package/dist/cases/long-form-page/article.jsx +58 -0
- package/dist/cases/long-form-page/with-contents.d.ts +1 -0
- package/dist/cases/long-form-page/with-contents.jsx +41 -0
- package/dist/cases/long-form-page.md +170 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +11 -8
- package/dist/cases/message-actions/menu.jsx +10 -7
- package/dist/cases/message-actions.md +19 -13
- package/dist/cases/message-attachments/in-composer.jsx +2 -2
- package/dist/cases/message-attachments/in-message.jsx +16 -11
- package/dist/cases/message-attachments.md +29 -17
- package/dist/cases/one-main-action.md +33 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
- package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
- package/dist/cases/overflow-menu.md +16 -10
- package/dist/cases/page-end/cta-band.d.ts +1 -0
- package/dist/cases/page-end/cta-band.jsx +24 -0
- package/dist/cases/page-end/next-link.d.ts +1 -0
- package/dist/cases/page-end/next-link.jsx +18 -0
- package/dist/cases/page-end.md +88 -0
- package/dist/cases/password-gate/inline.d.ts +1 -0
- package/dist/cases/password-gate/inline.jsx +94 -0
- package/dist/cases/password-gate/modal.d.ts +1 -0
- package/dist/cases/password-gate/modal.jsx +81 -0
- package/dist/cases/password-gate/page.d.ts +1 -0
- package/dist/cases/password-gate/page.jsx +82 -0
- package/dist/cases/password-gate.md +351 -0
- package/dist/cases/pricing-section/cards.d.ts +1 -0
- package/dist/cases/pricing-section/cards.jsx +41 -0
- package/dist/cases/pricing-section.md +87 -0
- package/dist/cases/product-cards/grid.d.ts +1 -0
- package/dist/cases/product-cards/grid.jsx +20 -0
- package/dist/cases/product-cards.md +71 -0
- package/dist/cases/reply-feedback/thumbs.jsx +11 -8
- package/dist/cases/reply-feedback/with-reason.jsx +11 -8
- package/dist/cases/reply-feedback.md +20 -14
- package/dist/cases/section-index/cards.d.ts +1 -0
- package/dist/cases/section-index/cards.jsx +25 -0
- package/dist/cases/section-index/list.d.ts +1 -0
- package/dist/cases/section-index/list.jsx +56 -0
- package/dist/cases/section-index.md +140 -0
- package/dist/cases/settings-page/top-tabs.jsx +9 -6
- package/dist/cases/settings-page.md +13 -7
- package/dist/cases/site-header.md +1 -1
- package/dist/cases/site-search/dialog.d.ts +1 -0
- package/dist/cases/site-search/dialog.jsx +131 -0
- package/dist/cases/site-search.md +176 -0
- package/dist/cases/tabbed-panels/tabs.d.ts +1 -0
- package/dist/cases/tabbed-panels/tabs.jsx +40 -0
- package/dist/cases/tabbed-panels.md +81 -0
- package/dist/cases.json +1177 -31
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.jsx +103 -0
- package/dist/components/button.d.ts +2 -0
- package/dist/components/button.jsx +2 -2
- package/dist/components/codeBlock.d.ts +26 -0
- package/dist/components/codeBlock.jsx +101 -0
- package/dist/components/lightbox.d.ts +34 -0
- package/dist/components/lightbox.jsx +206 -0
- package/dist/components/linkCard.d.ts +10 -1
- package/dist/components/linkCard.jsx +32 -6
- package/dist/components/menuItem.jsx +1 -1
- package/dist/components/modal.d.ts +10 -2
- package/dist/components/modal.jsx +17 -12
- package/dist/components/pageHeader.jsx +1 -1
- package/dist/components/searchDialog.d.ts +44 -0
- package/dist/components/searchDialog.jsx +152 -0
- package/dist/components/siteHeader.d.ts +13 -2
- package/dist/components/siteHeader.jsx +21 -12
- package/dist/components/tab.d.ts +5 -1
- package/dist/components/tab.jsx +2 -2
- package/dist/components/tabPanel.d.ts +16 -0
- package/dist/components/tabPanel.jsx +12 -0
- package/dist/components/tabsContainer.d.ts +5 -1
- package/dist/components/tabsContainer.jsx +2 -2
- package/dist/components/tag.d.ts +6 -1
- package/dist/components/tag.jsx +10 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/internal/accordion.d.ts +4 -0
- package/dist/internal/accordion.js +53 -0
- package/dist/internal/combobox.d.ts +20 -0
- package/dist/internal/combobox.js +28 -0
- package/dist/internal/highlight.d.ts +5 -0
- package/dist/internal/highlight.js +18 -0
- package/dist/native-mapping.json +31 -1
- package/dist/stories/Accordion.stories.d.ts +11 -0
- package/dist/stories/Accordion.stories.jsx +93 -0
- package/dist/stories/Button.stories.jsx +12 -8
- package/dist/stories/Cases.generated.stories.d.ts +34 -0
- package/dist/stories/Cases.generated.stories.jsx +68 -0
- package/dist/stories/CodeBlock.stories.d.ts +12 -0
- package/dist/stories/CodeBlock.stories.jsx +65 -0
- package/dist/stories/Lightbox.stories.d.ts +11 -0
- package/dist/stories/Lightbox.stories.jsx +83 -0
- package/dist/stories/LinkCard.stories.d.ts +6 -0
- package/dist/stories/LinkCard.stories.jsx +17 -0
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/PageHeader.stories.d.ts +2 -0
- package/dist/stories/PageHeader.stories.jsx +13 -0
- package/dist/stories/SearchDialog.stories.d.ts +17 -0
- package/dist/stories/SearchDialog.stories.jsx +111 -0
- package/dist/stories/SiteHeader.stories.d.ts +4 -0
- package/dist/stories/SiteHeader.stories.jsx +89 -0
- package/dist/stories/TabPanel.stories.d.ts +7 -0
- package/dist/stories/TabPanel.stories.jsx +31 -0
- package/package.json +1 -1
|
@@ -5,11 +5,11 @@ import { useOverlayTransition } from './useOverlayTransition';
|
|
|
5
5
|
import { initialFocusCandidates } from '../internal/modal';
|
|
6
6
|
import { PICKABLE, claimEvent, isTopOverlay, lockScroll, popOverlay, pushOverlay, trapTab, unlockScroll } from '../internal/overlayStack';
|
|
7
7
|
export default function Modal(_a) {
|
|
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;
|
|
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, ariaLabel = _a["aria-label"], _d = _a.placement, placement = _d === void 0 ? 'center' : _d;
|
|
9
9
|
var panelRef = useRef(null);
|
|
10
10
|
var bodyRef = useRef(null);
|
|
11
11
|
var titleId = useId();
|
|
12
|
-
var
|
|
12
|
+
var _e = useOverlayTransition(isOpen), mounted = _e.mounted, visible = _e.visible;
|
|
13
13
|
// Keep onClose in a ref so a new function each render doesn't re-run the focus effect
|
|
14
14
|
var onCloseRef = useRef(onClose);
|
|
15
15
|
onCloseRef.current = onClose;
|
|
@@ -62,7 +62,14 @@ export default function Modal(_a) {
|
|
|
62
62
|
medium: { width: 'w-[600px]', maxWidth: '600px' },
|
|
63
63
|
large: { width: 'w-[1024px]', maxWidth: '1024px' },
|
|
64
64
|
};
|
|
65
|
-
var
|
|
65
|
+
var fill = size === 'fill';
|
|
66
|
+
var _f = fill
|
|
67
|
+
? { width: 'w-[calc(100vw-16px)] h-[calc(100dvh-16px)] md:w-[calc(100vw-32px)] md:h-[calc(100dvh-32px)]', maxWidth: undefined }
|
|
68
|
+
: sizeConfig[size], modalWidth = _f.width, maxWidth = _f.maxWidth;
|
|
69
|
+
var panelStyle = fill
|
|
70
|
+
? { overflow: 'hidden' }
|
|
71
|
+
: { maxWidth: maxWidth, width: 'calc(100vw - 64px)', maxHeight: '90vh', overflow: 'hidden' };
|
|
72
|
+
var align = placement === 'top' ? 'items-start pt-2 sm:items-center sm:pt-0' : 'items-center';
|
|
66
73
|
// close modal by clicking elsewhere
|
|
67
74
|
var handleOverlayClick = function (e) {
|
|
68
75
|
if (e.target === e.currentTarget) {
|
|
@@ -72,14 +79,12 @@ export default function Modal(_a) {
|
|
|
72
79
|
if (!mounted)
|
|
73
80
|
return null;
|
|
74
81
|
// dark-only edge: a ring only in dark mode, so it keeps a dark: variant (it follows whatever dark variant the app's preset/@theme defines, class-only or OS-aware)
|
|
75
|
-
return (<div className={"fixed bg-misc-scrim/40 flex
|
|
76
|
-
<div ref={panelRef} role="dialog" aria-modal="true" aria-labelledby={title ? titleId : undefined} tabIndex={-1} className={"bg-background-elevated dark:ring-1 dark:ring-misc-divider rounded-control ".concat(modalWidth, " flex flex-col outline-none\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)} style={
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}}>
|
|
82
|
-
{(title || actions) && (<div className="px-6 py-3 border-b border-misc-divider flex justify-between items-start" style={{ flexShrink: 0 }}>
|
|
82
|
+
return (<div className={"fixed bg-misc-scrim/40 flex ".concat(align, " justify-center z-[var(--os-z-overlay)]\n transition-opacity duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none ").concat(visible ? 'opacity-100' : 'opacity-0')} style={{ top: 0, left: 0, right: 0, bottom: 0 }} onClick={handleOverlayClick}>
|
|
83
|
+
<div ref={panelRef} role="dialog" aria-modal="true" aria-label={ariaLabel} aria-labelledby={title && !ariaLabel ? titleId : undefined} tabIndex={-1} className={"bg-background-elevated dark:ring-1 dark:ring-misc-divider rounded-control ".concat(modalWidth, " flex flex-col outline-none\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)} style={panelStyle}>
|
|
84
|
+
{(title || actions) && (
|
|
85
|
+
// Below sm the header wraps and the actions take their own line, end-aligned, so a long action is never cut off.
|
|
86
|
+
// Each phone class is undone from sm up.
|
|
87
|
+
<div className="px-6 py-3 border-b border-misc-divider flex justify-between items-start flex-wrap gap-y-2 sm:flex-nowrap sm:gap-y-0" style={{ flexShrink: 0 }}>
|
|
83
88
|
{title && (<div className="flex flex-col">
|
|
84
89
|
<h2 id={titleId} className="text-h5 text-fg-primary">
|
|
85
90
|
{title}
|
|
@@ -88,7 +93,7 @@ export default function Modal(_a) {
|
|
|
88
93
|
{secondTitle}
|
|
89
94
|
</span>)}
|
|
90
95
|
</div>)}
|
|
91
|
-
{actions && (<div className="flex space-x-2">
|
|
96
|
+
{actions && (<div className="flex space-x-2 basis-full justify-end sm:basis-auto sm:justify-start">
|
|
92
97
|
{actions}
|
|
93
98
|
</div>)}
|
|
94
99
|
</div>)}
|
|
@@ -16,7 +16,7 @@ export default function PageHeader(_a) {
|
|
|
16
16
|
{eyebrow && (<Paragraph tone="secondary" size="body2" measure="none">
|
|
17
17
|
{eyebrow}
|
|
18
18
|
</Paragraph>)}
|
|
19
|
-
<Tag className={"".concat(sizes[level], " text-fg-primary")}>{title}</Tag>
|
|
19
|
+
<Tag className={"".concat(sizes[level], " break-words text-fg-primary")}>{title}</Tag>
|
|
20
20
|
{lede && (<Paragraph tone="secondary" measure="lede">
|
|
21
21
|
{lede}
|
|
22
22
|
</Paragraph>)}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SearchResult {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** A line of the text around the match. The query's words are marked in it, as in the title. */
|
|
6
|
+
excerpt?: string;
|
|
7
|
+
/** Where it is, such as the workspace or the section. */
|
|
8
|
+
secondLabel?: string;
|
|
9
|
+
href: string;
|
|
10
|
+
/** A Lucide icon name for the kind of thing it is. */
|
|
11
|
+
iconName?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SearchGroup {
|
|
14
|
+
/** Names the group, such as 'Docs' or 'Tasks'. */
|
|
15
|
+
label: string;
|
|
16
|
+
items: SearchResult[];
|
|
17
|
+
}
|
|
18
|
+
interface SearchDialogProps {
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
query: string;
|
|
22
|
+
onQueryChange: (query: string) => void;
|
|
23
|
+
/** The results for `query`. While `status` is 'loading', the last results stay on screen. */
|
|
24
|
+
groups: SearchGroup[];
|
|
25
|
+
/**
|
|
26
|
+
* 'idle' before anything is typed, 'loading' while the caller fetches, 'done' with the results, 'error' when the
|
|
27
|
+
* fetch failed. The caller drops a reply for an older query, so `groups` always answer the current `query`.
|
|
28
|
+
*/
|
|
29
|
+
status: 'idle' | 'loading' | 'done' | 'error';
|
|
30
|
+
/** Called by 'Try Again' after a failure. */
|
|
31
|
+
onRetry?: () => void;
|
|
32
|
+
/** Shown before anything is typed, at most 6, most recent first. */
|
|
33
|
+
recent?: SearchResult[];
|
|
34
|
+
/** Names the dialog and the field. Defaults to 'Search'. */
|
|
35
|
+
'aria-label'?: string;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Site search in a Modal: the field first, then the results in groups. Focus stays in the field; the arrows move the
|
|
40
|
+
* highlight, Enter follows the highlighted link, and Escape closes. One polite status says the count, 'Searching'
|
|
41
|
+
* after 300 ms of waiting, that nothing matched, or that search failed. The caller fetches and passes the results.
|
|
42
|
+
*/
|
|
43
|
+
export default function SearchDialog({ isOpen, onClose, query, onQueryChange, groups, status, onRetry, recent, 'aria-label': ariaLabel, placeholder, }: SearchDialogProps): React.JSX.Element;
|
|
44
|
+
export { SearchDialog };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useId, useRef, useState } from 'react';
|
|
3
|
+
import NextLink from 'next/link';
|
|
4
|
+
import Modal from './modal';
|
|
5
|
+
import TextField from './textField';
|
|
6
|
+
import Button from './button';
|
|
7
|
+
import EmptyBox from './emptyBox';
|
|
8
|
+
import Menu from './menu';
|
|
9
|
+
import IconSlot from './iconSlot';
|
|
10
|
+
import { formatCount } from './formatNumber';
|
|
11
|
+
import { focusRing, stateTransition } from './sharedStyles';
|
|
12
|
+
import { comboboxKey, comboboxProps } from '../internal/combobox';
|
|
13
|
+
import { highlightParts } from '../internal/highlight';
|
|
14
|
+
var SLOW_MS = 300;
|
|
15
|
+
var MAX_RECENT = 6;
|
|
16
|
+
function Marked(_a) {
|
|
17
|
+
var text = _a.text, query = _a.query;
|
|
18
|
+
return (<>
|
|
19
|
+
{highlightParts(text, query).map(function (part, i) {
|
|
20
|
+
return part.match ? (<mark key={i} className="rounded-inline bg-accent-main text-accent-contrast">{part.text}</mark>) : (<React.Fragment key={i}>{part.text}</React.Fragment>);
|
|
21
|
+
})}
|
|
22
|
+
</>);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Site search in a Modal: the field first, then the results in groups. Focus stays in the field; the arrows move the
|
|
26
|
+
* highlight, Enter follows the highlighted link, and Escape closes. One polite status says the count, 'Searching'
|
|
27
|
+
* after 300 ms of waiting, that nothing matched, or that search failed. The caller fetches and passes the results.
|
|
28
|
+
*/
|
|
29
|
+
export default function SearchDialog(_a) {
|
|
30
|
+
var isOpen = _a.isOpen, onClose = _a.onClose, query = _a.query, onQueryChange = _a.onQueryChange, groups = _a.groups, status = _a.status, onRetry = _a.onRetry, _b = _a.recent, recent = _b === void 0 ? [] : _b, _c = _a["aria-label"], ariaLabel = _c === void 0 ? 'Search' : _c, _d = _a.placeholder, placeholder = _d === void 0 ? 'Search' : _d;
|
|
31
|
+
var uid = useId();
|
|
32
|
+
var fieldId = "".concat(uid, "-field");
|
|
33
|
+
var listId = "".concat(uid, "-results");
|
|
34
|
+
var optionId = function (i) { return "".concat(uid, "-option-").concat(i); };
|
|
35
|
+
var words = query.trim();
|
|
36
|
+
var typed = words !== '';
|
|
37
|
+
// The last results stay on screen while the next ones load
|
|
38
|
+
var lastGroups = useRef(groups);
|
|
39
|
+
if (status !== 'loading')
|
|
40
|
+
lastGroups.current = groups;
|
|
41
|
+
var shown = !typed
|
|
42
|
+
? recent.length > 0
|
|
43
|
+
? [{ label: 'Recent', items: recent.slice(0, MAX_RECENT) }]
|
|
44
|
+
: []
|
|
45
|
+
: status === 'error'
|
|
46
|
+
? []
|
|
47
|
+
: status === 'loading'
|
|
48
|
+
? lastGroups.current
|
|
49
|
+
: groups;
|
|
50
|
+
var options = shown.flatMap(function (g) { return g.items; });
|
|
51
|
+
var listOpen = options.length > 0;
|
|
52
|
+
var _e = useState(0), active = _e[0], setActive = _e[1];
|
|
53
|
+
var at = Math.min(active, Math.max(options.length - 1, 0));
|
|
54
|
+
useEffect(function () { return setActive(0); }, [query]);
|
|
55
|
+
// 'Searching' only once a reply takes longer than 300 ms, so a fast one does not flash it
|
|
56
|
+
var _f = useState(false), slow = _f[0], setSlow = _f[1];
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (status !== 'loading') {
|
|
59
|
+
setSlow(false);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var timer = setTimeout(function () { return setSlow(true); }, SLOW_MS);
|
|
63
|
+
return function () { return clearTimeout(timer); };
|
|
64
|
+
}, [status, query]);
|
|
65
|
+
var failed = typed && status === 'error';
|
|
66
|
+
var empty = typed && status === 'done' && options.length === 0;
|
|
67
|
+
var count = options.length;
|
|
68
|
+
// Until 'Searching' is due the status keeps its words, so it says nothing new
|
|
69
|
+
var lastStatus = useRef('');
|
|
70
|
+
var statusText = lastStatus.current;
|
|
71
|
+
if (!(status === 'loading' && !slow)) {
|
|
72
|
+
statusText = failed
|
|
73
|
+
? 'Search is not working right now.'
|
|
74
|
+
: status === 'loading'
|
|
75
|
+
? 'Searching'
|
|
76
|
+
: !typed || status === 'idle'
|
|
77
|
+
? ''
|
|
78
|
+
: empty
|
|
79
|
+
? "No results for \"".concat(words, "\"")
|
|
80
|
+
: "".concat(formatCount(count), " ").concat(count === 1 ? 'result' : 'results');
|
|
81
|
+
}
|
|
82
|
+
lastStatus.current = statusText;
|
|
83
|
+
// The status keeps its old visibility with its old words, so the old words never show
|
|
84
|
+
var lastHidden = useRef(true);
|
|
85
|
+
var hideStatus = lastHidden.current;
|
|
86
|
+
if (!(status === 'loading' && !slow))
|
|
87
|
+
hideStatus = failed || empty || !statusText;
|
|
88
|
+
lastHidden.current = hideStatus;
|
|
89
|
+
// Keep the highlighted row in view as the arrows move it
|
|
90
|
+
var activeId = listOpen ? optionId(at) : undefined;
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
if (activeId)
|
|
94
|
+
(_b = (_a = document.getElementById(activeId)) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'nearest' });
|
|
95
|
+
}, [activeId]);
|
|
96
|
+
var focusField = function () { var _a; return (_a = document.getElementById(fieldId)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
97
|
+
function keyDown(e) {
|
|
98
|
+
var _a;
|
|
99
|
+
var action = comboboxKey({ key: e.key, isComposing: e.nativeEvent.isComposing, keyCode: e.keyCode }, at, count);
|
|
100
|
+
if (!action)
|
|
101
|
+
return;
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
if ('move' in action)
|
|
104
|
+
setActive(action.move);
|
|
105
|
+
else
|
|
106
|
+
(_a = document.getElementById(optionId(action.pick))) === null || _a === void 0 ? void 0 : _a.click();
|
|
107
|
+
}
|
|
108
|
+
var index = -1;
|
|
109
|
+
return (<Modal isOpen={isOpen} onClose={onClose} size="medium" initialFocus="body" aria-label={ariaLabel} placement="top">
|
|
110
|
+
<div className="flex flex-col gap-medium">
|
|
111
|
+
<TextField id={fieldId} type="search" aria-label={ariaLabel} placeholder={placeholder} value={query} onChange={function (e) { return onQueryChange(e.target.value); }} onKeyDown={keyDown} {...comboboxProps({ listId: listId, open: listOpen, activeId: activeId })}/>
|
|
112
|
+
{/* The empty and error boxes show their own words, so the status is read but not shown twice */}
|
|
113
|
+
<p role="status" className={hideStatus ? 'sr-only' : 'text-caption text-fg-secondary'}>
|
|
114
|
+
{statusText}
|
|
115
|
+
</p>
|
|
116
|
+
{failed ? (<EmptyBox size="small" icon="SearchX" text="Search is not working right now." secondText="Check your connection, then try again." action={<Button size="medium" type="secondary" state="enabled" label="Try Again" onClickButton={function () {
|
|
117
|
+
focusField();
|
|
118
|
+
onRetry === null || onRetry === void 0 ? void 0 : onRetry();
|
|
119
|
+
}}/>}/>) : empty ? (<EmptyBox size="small" icon="Search" text={"No results for \"".concat(words, "\"")} secondText="Check the spelling, or search for fewer words." action={<Button size="medium" type="secondary" state="enabled" label="Clear Search" onClickButton={function () {
|
|
120
|
+
focusField();
|
|
121
|
+
onQueryChange('');
|
|
122
|
+
}}/>}/>) : (listOpen && (
|
|
123
|
+
// On a phone the list scrolls under the field, which stays put
|
|
124
|
+
<div aria-busy={status === 'loading' || undefined} className="max-h-[60dvh] overflow-y-auto" style={{ scrollbarWidth: 'thin' }}>
|
|
125
|
+
<Menu role="listbox" id={listId} aria-label={typed ? 'Results' : 'Recent'} width="100%">
|
|
126
|
+
{shown.map(function (group, gi) { return (<div key={gi} role="group" aria-labelledby={"".concat(uid, "-group-").concat(gi)}>
|
|
127
|
+
<div id={"".concat(uid, "-group-").concat(gi)} className="px-2 pb-1 pt-2 text-caption text-fg-secondary">
|
|
128
|
+
{group.label}
|
|
129
|
+
</div>
|
|
130
|
+
{group.items.map(function (item) {
|
|
131
|
+
index += 1;
|
|
132
|
+
var i = index;
|
|
133
|
+
return (<NextLink key={item.id} id={optionId(i)} role="option" aria-selected={i === at} tabIndex={-1} onClick={onClose} onMouseMove={function () { return setActive(i); }} className={"flex items-start gap-2 rounded-control p-2 text-left ".concat(stateTransition, " ").concat(focusRing, " hover:bg-background-accent200 ").concat(i === at ? 'bg-background-accent200' : '')} href={item.href}>
|
|
134
|
+
<IconSlot icon={item.iconName} className="size-5 shrink-0 text-fg-secondary"/>
|
|
135
|
+
<span className="flex min-w-0 flex-col">
|
|
136
|
+
<span className="text-body2 text-fg-primary">
|
|
137
|
+
<Marked text={item.title} query={words}/>
|
|
138
|
+
</span>
|
|
139
|
+
{item.secondLabel && <span className="truncate text-caption text-fg-secondary">{item.secondLabel}</span>}
|
|
140
|
+
{item.excerpt && (<span className="line-clamp-2 text-caption text-fg-secondary">
|
|
141
|
+
<Marked text={item.excerpt} query={words}/>
|
|
142
|
+
</span>)}
|
|
143
|
+
</span>
|
|
144
|
+
</NextLink>);
|
|
145
|
+
})}
|
|
146
|
+
</div>); })}
|
|
147
|
+
</Menu>
|
|
148
|
+
</div>))}
|
|
149
|
+
</div>
|
|
150
|
+
</Modal>);
|
|
151
|
+
}
|
|
152
|
+
export { SearchDialog };
|
|
@@ -17,6 +17,11 @@ export interface SiteHeaderLink {
|
|
|
17
17
|
/** The page the reader is on: gets `aria-current="page"` */
|
|
18
18
|
current?: boolean;
|
|
19
19
|
}
|
|
20
|
+
/** A titled group of links: the pages of one section */
|
|
21
|
+
export interface SiteHeaderSection {
|
|
22
|
+
title: string;
|
|
23
|
+
links: SiteHeaderLink[];
|
|
24
|
+
}
|
|
20
25
|
interface SiteHeaderProps {
|
|
21
26
|
brand: SiteBrand;
|
|
22
27
|
/** The main places, in order. From md a row in the bar; below md in the menu. */
|
|
@@ -36,6 +41,11 @@ interface SiteHeaderProps {
|
|
|
36
41
|
* It never moves into the Menu, so keep it short enough for a phone.
|
|
37
42
|
*/
|
|
38
43
|
nav?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* The pages of the open section, such as a docs section's page list. Below md they show in the menu under the main links,
|
|
46
|
+
* titled, with the `current` page marked. From md they are not shown: the page lists them itself.
|
|
47
|
+
*/
|
|
48
|
+
sectionLinks?: SiteHeaderSection;
|
|
39
49
|
/** The Menu IconButton's name, and the Drawer's. Default 'Menu'. */
|
|
40
50
|
menuLabel?: string;
|
|
41
51
|
/** The skip link's text. Default 'Skip to content'. */
|
|
@@ -46,10 +56,11 @@ interface SiteHeaderProps {
|
|
|
46
56
|
/**
|
|
47
57
|
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
48
58
|
* 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
|
|
59
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer, unless `sectionLinks` gives the menu
|
|
60
|
+
* the open section's pages.
|
|
50
61
|
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
51
62
|
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
52
63
|
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
53
64
|
*/
|
|
54
|
-
export default function SiteHeader({ brand, links, actions, phoneAction, nav, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
|
|
65
|
+
export default function SiteHeader({ brand, links, actions, phoneAction, nav, sectionLinks, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
|
|
55
66
|
export { SiteHeader };
|
|
@@ -10,16 +10,18 @@ var WIDE = '(min-width: 768px)';
|
|
|
10
10
|
/**
|
|
11
11
|
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
12
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
|
|
13
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer, unless `sectionLinks` gives the menu
|
|
14
|
+
* the open section's pages.
|
|
14
15
|
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
15
16
|
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
16
17
|
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
17
18
|
*/
|
|
18
19
|
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 brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, sectionLinks = _a.sectionLinks, _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
21
|
var drawerId = useId();
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
var sectionTitleId = useId();
|
|
23
|
+
// Without links, actions or section links there is nothing for a Menu to hold
|
|
24
|
+
var hasMenu = links.length > 0 || !!actions || !!(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length);
|
|
23
25
|
var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
24
26
|
var barRef = useRef(null);
|
|
25
27
|
// Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
|
|
@@ -85,14 +87,15 @@ export default function SiteHeader(_a) {
|
|
|
85
87
|
if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
|
|
86
88
|
setMenuOpen(false);
|
|
87
89
|
};
|
|
90
|
+
var list = function (items, vertical) { return (<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')}>
|
|
91
|
+
{items.map(function (link) { return (<li key={link.href + link.label}>
|
|
92
|
+
<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)}>
|
|
93
|
+
{link.label}
|
|
94
|
+
</a>
|
|
95
|
+
</li>); })}
|
|
96
|
+
</ul>); };
|
|
88
97
|
var linkList = function (vertical) { return (<nav aria-label="Main" className={vertical ? '' : 'hidden min-w-0 flex-1 md:block'}>
|
|
89
|
-
|
|
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>
|
|
98
|
+
{list(links, vertical)}
|
|
96
99
|
</nav>); };
|
|
97
100
|
// The Drawer is a sibling of the header: a sticky header is a stacking context, and the panel must sit above the page
|
|
98
101
|
return (<>
|
|
@@ -116,7 +119,13 @@ export default function SiteHeader(_a) {
|
|
|
116
119
|
</header>
|
|
117
120
|
{hasMenu && (<Drawer id={drawerId} isOpen={menuOpen} onClose={function () { return setMenuOpen(false); }} aria-label={menuLabel} side="start" size="small">
|
|
118
121
|
<div onClick={closeOnChoice} className="flex flex-col gap-4">
|
|
119
|
-
{linkList(true)}
|
|
122
|
+
{(links.length > 0 || !(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length)) && linkList(true)}
|
|
123
|
+
{sectionLinks && sectionLinks.links.length > 0 && (<nav aria-labelledby={sectionTitleId}>
|
|
124
|
+
<h2 id={sectionTitleId} className="px-3 pb-1 text-caption text-fg-secondary">
|
|
125
|
+
{sectionLinks.title}
|
|
126
|
+
</h2>
|
|
127
|
+
{list(sectionLinks.links, true)}
|
|
128
|
+
</nav>)}
|
|
120
129
|
{actions && <div className="flex flex-col items-start gap-2">{actions}</div>}
|
|
121
130
|
</div>
|
|
122
131
|
</Drawer>)}
|
package/dist/components/tab.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ type TabProps = {
|
|
|
13
13
|
actionIcon?: string;
|
|
14
14
|
router?: RouterLike;
|
|
15
15
|
size?: 'medium' | 'small' | 'tiny';
|
|
16
|
+
/** The tab's id, for a `TabPanel`'s `labelledBy` */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** The id of the `TabPanel` this tab shows (`aria-controls`) */
|
|
19
|
+
controls?: string;
|
|
16
20
|
};
|
|
17
|
-
export default function Tab({ label, secondLabel, href, isSelected, onClickTab, onClickActionIcon, decoIcon, actionIcon, router, size, }: TabProps): React.JSX.Element;
|
|
21
|
+
export default function Tab({ label, secondLabel, href, isSelected, onClickTab, onClickActionIcon, decoIcon, actionIcon, router, size, id, controls, }: TabProps): React.JSX.Element;
|
|
18
22
|
export {};
|
package/dist/components/tab.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import IconSlot from './iconSlot';
|
|
|
4
4
|
import { TabsContainerContext, TabsFillContext } from './tabsContainer';
|
|
5
5
|
import { segmentIdleClasses, segmentItemClasses, segmentSelectedClasses, segmentSizes } from './slidingIndicator';
|
|
6
6
|
export default function Tab(_a) {
|
|
7
|
-
var label = _a.label, secondLabel = _a.secondLabel, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, router = _a.router, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
7
|
+
var label = _a.label, secondLabel = _a.secondLabel, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, router = _a.router, _b = _a.size, size = _b === void 0 ? 'medium' : _b, id = _a.id, controls = _a.controls;
|
|
8
8
|
var inContainer = useContext(TabsContainerContext);
|
|
9
9
|
var fill = useContext(TabsFillContext);
|
|
10
10
|
var handleClick = function () {
|
|
@@ -18,7 +18,7 @@ export default function Tab(_a) {
|
|
|
18
18
|
var selectedClasses = inContainer
|
|
19
19
|
? segmentSelectedClasses
|
|
20
20
|
: "bg-primary-dark ".concat(segmentSelectedClasses);
|
|
21
|
-
return (<div data-tab-selected={isSelected} role="tab" aria-selected={isSelected}
|
|
21
|
+
return (<div data-tab-selected={isSelected} role="tab" id={id} aria-controls={controls} aria-selected={isSelected}
|
|
22
22
|
// Inside a container only the selected tab is in the Tab order; arrow keys move between tabs
|
|
23
23
|
tabIndex={inContainer && !isSelected ? -1 : 0} onKeyDown={function (e) {
|
|
24
24
|
if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TabPanelProps {
|
|
3
|
+
/** The panel's id: the `controls` of its `Tab` */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The id of the `Tab` that shows this panel */
|
|
6
|
+
labelledBy: string;
|
|
7
|
+
/** The panel of the selected tab. The others stay in the page, `hidden`. */
|
|
8
|
+
selected: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The panel a `Tab` shows. Every panel is in the server HTML and only the selected one is visible.
|
|
13
|
+
* It takes a Tab stop, so Tab from the selected tab lands on its panel.
|
|
14
|
+
*/
|
|
15
|
+
export default function TabPanel({ id, labelledBy, selected, children }: TabPanelProps): React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { focusRing } from './sharedStyles';
|
|
3
|
+
/**
|
|
4
|
+
* The panel a `Tab` shows. Every panel is in the server HTML and only the selected one is visible.
|
|
5
|
+
* It takes a Tab stop, so Tab from the selected tab lands on its panel.
|
|
6
|
+
*/
|
|
7
|
+
export default function TabPanel(_a) {
|
|
8
|
+
var id = _a.id, labelledBy = _a.labelledBy, selected = _a.selected, children = _a.children;
|
|
9
|
+
return (<div role="tabpanel" id={id} aria-labelledby={labelledBy} hidden={!selected} tabIndex={0} className={"rounded-control ".concat(focusRing)}>
|
|
10
|
+
{children}
|
|
11
|
+
</div>);
|
|
12
|
+
}
|
|
@@ -3,8 +3,12 @@ interface TabsContainerProps {
|
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
/** The container is as wide as its parent and every tab takes an equal share, label centered. */
|
|
5
5
|
fill?: boolean;
|
|
6
|
+
/** Names the tablist */
|
|
7
|
+
'aria-label'?: string;
|
|
8
|
+
/** The id of the heading that names the tablist */
|
|
9
|
+
'aria-labelledby'?: string;
|
|
6
10
|
}
|
|
7
11
|
export declare const TabsContainerContext: React.Context<boolean>;
|
|
8
12
|
export declare const TabsFillContext: React.Context<boolean>;
|
|
9
|
-
export default function TabsContainer({ children, fill, }: TabsContainerProps): React.JSX.Element;
|
|
13
|
+
export default function TabsContainer({ children, fill, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: TabsContainerProps): React.JSX.Element;
|
|
10
14
|
export {};
|
|
@@ -6,12 +6,12 @@ export var TabsContainerContext = createContext(false);
|
|
|
6
6
|
// Lets a Tab know every tab in the container takes an equal share of the width
|
|
7
7
|
export var TabsFillContext = createContext(false);
|
|
8
8
|
export default function TabsContainer(_a) {
|
|
9
|
-
var children = _a.children, _b = _a.fill, fill = _b === void 0 ? false : _b;
|
|
9
|
+
var children = _a.children, _b = _a.fill, fill = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"], ariaLabelledBy = _a["aria-labelledby"];
|
|
10
10
|
var tabCount = React.Children.count(children);
|
|
11
11
|
var _c = useSlidingIndicator(children), containerRef = _c.containerRef, indicator = _c.indicator;
|
|
12
12
|
return (<TabsContainerContext.Provider value={true}>
|
|
13
13
|
<TabsFillContext.Provider value={fill}>
|
|
14
|
-
<div ref={containerRef} role="tablist" onKeyDown={function (e) {
|
|
14
|
+
<div ref={containerRef} role="tablist" aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} onKeyDown={function (e) {
|
|
15
15
|
var _a, _b;
|
|
16
16
|
// Arrow keys move focus to the next tab and select it
|
|
17
17
|
var tabs = Array.from((_b = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="tab"]')) !== null && _b !== void 0 ? _b : []);
|
package/dist/components/tag.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ interface TagProps {
|
|
|
23
23
|
* `state="selected"` still gives the selected look then, but it is only a look. No effect without `onClick`.
|
|
24
24
|
*/
|
|
25
25
|
toggle?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Set by a row with the selected fill (`bg-primary-dark`), such as a selected `MenuItem`. A `dot` or `textOnly`
|
|
28
|
+
* tag then uses `primary-contrast` for its text, dot and border. A `contained` tag keeps its own fill.
|
|
29
|
+
*/
|
|
30
|
+
onSelectedRow?: boolean;
|
|
26
31
|
}
|
|
27
|
-
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, }: TagProps): React.JSX.Element;
|
|
32
|
+
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, onSelectedRow, }: TagProps): React.JSX.Element;
|
|
28
33
|
export {};
|
package/dist/components/tag.jsx
CHANGED
|
@@ -48,7 +48,7 @@ var colorConfig = {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
export default function Tag(_a) {
|
|
51
|
-
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d;
|
|
51
|
+
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d, _e = _a.onSelectedRow, onSelectedRow = _e === void 0 ? false : _e;
|
|
52
52
|
// Size and padding
|
|
53
53
|
var sizeClasses = {
|
|
54
54
|
medium: 'text-body2 px-2 py-1',
|
|
@@ -73,9 +73,14 @@ export default function Tag(_a) {
|
|
|
73
73
|
else if (variant === 'contained') {
|
|
74
74
|
bgClasses = 'bg-background-accent300';
|
|
75
75
|
}
|
|
76
|
+
// On a selected row's fill only primary-contrast is readable; a contained tag keeps its own fill
|
|
77
|
+
var onRowFill = onSelectedRow && variant !== 'contained';
|
|
76
78
|
// Font color
|
|
77
79
|
var fontClasses = '';
|
|
78
|
-
if (
|
|
80
|
+
if (onRowFill) {
|
|
81
|
+
fontClasses = 'text-primary-contrast';
|
|
82
|
+
}
|
|
83
|
+
else if (variant === 'dot') {
|
|
79
84
|
fontClasses = 'text-fg-primary';
|
|
80
85
|
}
|
|
81
86
|
else if (colorStyles) {
|
|
@@ -99,20 +104,20 @@ export default function Tag(_a) {
|
|
|
99
104
|
}
|
|
100
105
|
else if (colorStyles) {
|
|
101
106
|
if (variant === 'textOnly' && colorStyles.hasBorderTextOnly) {
|
|
102
|
-
borderClasses = "border ".concat(colorStyles.border);
|
|
107
|
+
borderClasses = onRowFill ? 'border border-primary-contrast' : "border ".concat(colorStyles.border);
|
|
103
108
|
}
|
|
104
109
|
else if (variant === 'contained') {
|
|
105
110
|
borderClasses = "border ".concat(colorStyles.border);
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
else if (isSelected && variant === 'textOnly') {
|
|
109
|
-
borderClasses = 'border border-accent-main';
|
|
114
|
+
borderClasses = onRowFill ? 'border border-primary-contrast' : 'border border-accent-main';
|
|
110
115
|
}
|
|
111
116
|
else if (variant === 'contained') {
|
|
112
117
|
borderClasses = 'border border-misc-divider';
|
|
113
118
|
}
|
|
114
119
|
// Dot color
|
|
115
|
-
var dotColor = (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
|
|
120
|
+
var dotColor = onRowFill ? 'bg-primary-contrast' : (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
|
|
116
121
|
var isDisabled = !!onClick && disabled;
|
|
117
122
|
// Hover (only when not selected, not disabled, no color, and onClick is provided)
|
|
118
123
|
var hoverClasses = !isSelected && !isDisabled && !color && variant === 'contained' && onClick
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import './designTokens';
|
|
2
|
+
export * from './components/accordion';
|
|
2
3
|
export * from './components/alert';
|
|
3
4
|
export * from './components/appShell';
|
|
4
5
|
export * from './components/button';
|
|
5
6
|
export * from './components/checkBox';
|
|
7
|
+
export * from './components/codeBlock';
|
|
6
8
|
export * from './components/copyField';
|
|
7
9
|
export * from './components/drawer';
|
|
8
10
|
export * from './components/emptyBox';
|
|
@@ -10,6 +12,7 @@ export * from './components/formField';
|
|
|
10
12
|
export * from './components/formatNumber';
|
|
11
13
|
export * from './components/iconButton';
|
|
12
14
|
export * from './components/layout';
|
|
15
|
+
export * from './components/lightbox';
|
|
13
16
|
export * from './components/loadingScreen';
|
|
14
17
|
export * from './components/menu';
|
|
15
18
|
export * from './components/menuItem';
|
|
@@ -20,6 +23,7 @@ export * from './components/pagination';
|
|
|
20
23
|
export * from './components/popover';
|
|
21
24
|
export * from './components/progress';
|
|
22
25
|
export * from './components/radioGroup';
|
|
26
|
+
export * from './components/searchDialog';
|
|
23
27
|
export * from './components/sectionIntro';
|
|
24
28
|
export * from './components/segmentedControl';
|
|
25
29
|
export * from './components/select';
|
|
@@ -36,6 +40,7 @@ export * from './components/tableContainer';
|
|
|
36
40
|
export * from './components/tableHeader';
|
|
37
41
|
export * from './components/tableHeaderCell';
|
|
38
42
|
export * from './components/tableRow';
|
|
43
|
+
export * from './components/tabPanel';
|
|
39
44
|
export * from './components/tabsContainer';
|
|
40
45
|
export * from './components/tag';
|
|
41
46
|
export * from './components/textarea';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import './designTokens';
|
|
2
|
+
export * from './components/accordion';
|
|
2
3
|
export * from './components/alert';
|
|
3
4
|
export * from './components/appShell';
|
|
4
5
|
export * from './components/button';
|
|
5
6
|
export * from './components/checkBox';
|
|
7
|
+
export * from './components/codeBlock';
|
|
6
8
|
export * from './components/copyField';
|
|
7
9
|
export * from './components/drawer';
|
|
8
10
|
export * from './components/emptyBox';
|
|
@@ -10,6 +12,7 @@ export * from './components/formField';
|
|
|
10
12
|
export * from './components/formatNumber';
|
|
11
13
|
export * from './components/iconButton';
|
|
12
14
|
export * from './components/layout';
|
|
15
|
+
export * from './components/lightbox';
|
|
13
16
|
export * from './components/loadingScreen';
|
|
14
17
|
export * from './components/menu';
|
|
15
18
|
export * from './components/menuItem';
|
|
@@ -20,6 +23,7 @@ export * from './components/pagination';
|
|
|
20
23
|
export * from './components/popover';
|
|
21
24
|
export * from './components/progress';
|
|
22
25
|
export * from './components/radioGroup';
|
|
26
|
+
export * from './components/searchDialog';
|
|
23
27
|
export * from './components/sectionIntro';
|
|
24
28
|
export * from './components/segmentedControl';
|
|
25
29
|
export * from './components/select';
|
|
@@ -36,6 +40,7 @@ export * from './components/tableContainer';
|
|
|
36
40
|
export * from './components/tableHeader';
|
|
37
41
|
export * from './components/tableHeaderCell';
|
|
38
42
|
export * from './components/tableRow';
|
|
43
|
+
export * from './components/tabPanel';
|
|
39
44
|
export * from './components/tabsContainer';
|
|
40
45
|
export * from './components/tag';
|
|
41
46
|
export * from './components/textarea';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function normalizeOpen(open: readonly string[], ids: readonly string[], multiple: boolean): string[];
|
|
2
|
+
export declare function toggleOpen(open: readonly string[], id: string, multiple: boolean): string[];
|
|
3
|
+
export declare function hashItem(hash: string, prefix: string, ids: readonly string[]): string | null;
|
|
4
|
+
export declare function nextHeading(key: string, current: number, count: number): number;
|