oneslash-design-system 2.19.0 → 2.21.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 +62 -5
- 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/billing-page/billed-elsewhere.d.ts +1 -0
- package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
- package/dist/cases/billing-page/self-serve.d.ts +1 -0
- package/dist/cases/billing-page/self-serve.jsx +134 -0
- package/dist/cases/billing-page.md +247 -0
- 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/breakdown-list/bars.d.ts +1 -0
- package/dist/cases/breakdown-list/bars.jsx +47 -0
- package/dist/cases/breakdown-list/table.d.ts +1 -0
- package/dist/cases/breakdown-list/table.jsx +69 -0
- package/dist/cases/breakdown-list.md +158 -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/composer-limit/notice-with-action.jsx +3 -3
- package/dist/cases/composer-limit/notice.jsx +3 -3
- package/dist/cases/composer-limit.md +8 -8
- 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/dashboard/numbers-first.d.ts +1 -0
- package/dist/cases/dashboard/numbers-first.jsx +165 -0
- package/dist/cases/dashboard/work-first.d.ts +1 -0
- package/dist/cases/dashboard/work-first.jsx +165 -0
- package/dist/cases/dashboard.md +507 -0
- package/dist/cases/data-table-page/all-rows.d.ts +1 -0
- package/dist/cases/data-table-page/all-rows.jsx +226 -0
- package/dist/cases/data-table-page/paged.d.ts +1 -0
- package/dist/cases/data-table-page/paged.jsx +284 -0
- package/dist/cases/data-table-page.md +771 -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/invoice-list/table.d.ts +1 -0
- package/dist/cases/invoice-list/table.jsx +64 -0
- package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
- package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
- package/dist/cases/invoice-list.md +237 -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/load-failure/inline.jsx +2 -2
- package/dist/cases/load-failure.md +2 -2
- 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/members-list/rows.jsx +2 -1
- package/dist/cases/members-list/table.jsx +8 -9
- package/dist/cases/members-list.md +12 -13
- 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/number-format.md +36 -0
- 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/paged-card/pager.d.ts +1 -0
- package/dist/cases/paged-card/pager.jsx +41 -0
- package/dist/cases/paged-card/see-all.d.ts +1 -0
- package/dist/cases/paged-card/see-all.jsx +34 -0
- package/dist/cases/paged-card.md +147 -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/payment-method/none.d.ts +1 -0
- package/dist/cases/payment-method/none.jsx +17 -0
- package/dist/cases/payment-method/on-file.d.ts +1 -0
- package/dist/cases/payment-method/on-file.jsx +92 -0
- package/dist/cases/payment-method.md +182 -0
- package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
- package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
- package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
- package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
- package/dist/cases/plan-change-confirm.md +261 -0
- package/dist/cases/plan-picker/cards.d.ts +1 -0
- package/dist/cases/plan-picker/cards.jsx +97 -0
- package/dist/cases/plan-picker/list.d.ts +1 -0
- package/dist/cases/plan-picker/list.jsx +103 -0
- package/dist/cases/plan-picker.md +297 -0
- package/dist/cases/pricing-section/cards.d.ts +1 -0
- package/dist/cases/pricing-section/cards.jsx +40 -0
- package/dist/cases/pricing-section.md +85 -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/range-switch/segmented.jsx +11 -7
- package/dist/cases/range-switch.md +16 -11
- 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 +4 -3
- package/dist/cases/settings-page.md +5 -4
- 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/stat-row/featured.d.ts +1 -0
- package/dist/cases/stat-row/featured.jsx +17 -0
- package/dist/cases/stat-row/tiles.d.ts +1 -0
- package/dist/cases/stat-row/tiles.jsx +34 -0
- package/dist/cases/stat-row.md +104 -0
- package/dist/cases/status-label/dot.d.ts +1 -0
- package/dist/cases/status-label/dot.jsx +39 -0
- package/dist/cases/status-label/text.d.ts +1 -0
- package/dist/cases/status-label/text.jsx +44 -0
- package/dist/cases/status-label.md +143 -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/upgrade-prompt/inline.jsx +4 -2
- package/dist/cases/upgrade-prompt/modal.jsx +2 -1
- package/dist/cases/upgrade-prompt.md +10 -6
- package/dist/cases/usage-meters/by-person.d.ts +1 -0
- package/dist/cases/usage-meters/by-person.jsx +72 -0
- package/dist/cases/usage-meters/meters.d.ts +1 -0
- package/dist/cases/usage-meters/meters.jsx +49 -0
- package/dist/cases/usage-meters/with-cap.d.ts +1 -0
- package/dist/cases/usage-meters/with-cap.jsx +73 -0
- package/dist/cases/usage-meters.md +303 -0
- package/dist/cases.json +2178 -97
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.jsx +103 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.jsx +11 -5
- package/dist/components/codeBlock.d.ts +26 -0
- package/dist/components/codeBlock.jsx +101 -0
- package/dist/components/formatNumber.d.ts +25 -0
- package/dist/components/formatNumber.js +125 -0
- package/dist/components/iconButton.jsx +12 -7
- package/dist/components/lightbox.d.ts +31 -0
- package/dist/components/lightbox.jsx +161 -0
- package/dist/components/linkCard.d.ts +10 -1
- package/dist/components/linkCard.jsx +32 -6
- 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/pagination.d.ts +28 -0
- package/dist/components/pagination.jsx +89 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.jsx +50 -0
- package/dist/components/searchDialog.d.ts +44 -0
- package/dist/components/searchDialog.jsx +152 -0
- package/dist/components/skeleton.d.ts +21 -0
- package/dist/components/skeleton.jsx +41 -0
- package/dist/components/statTile.d.ts +32 -0
- package/dist/components/statTile.jsx +61 -0
- 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/tableContainer.d.ts +5 -1
- package/dist/components/tableContainer.jsx +9 -1
- package/dist/components/tableHeaderCell.d.ts +3 -1
- package/dist/components/tableHeaderCell.jsx +2 -2
- package/dist/components/tabsContainer.d.ts +5 -1
- package/dist/components/tabsContainer.jsx +2 -2
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +4 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -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 +57 -3
- package/dist/stories/Accordion.stories.d.ts +11 -0
- package/dist/stories/Accordion.stories.jsx +93 -0
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +19 -1
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +120 -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 +8 -0
- package/dist/stories/Lightbox.stories.jsx +40 -0
- package/dist/stories/LinkCard.stories.d.ts +6 -0
- package/dist/stories/LinkCard.stories.jsx +17 -0
- package/dist/stories/PageHeader.stories.d.ts +2 -0
- package/dist/stories/PageHeader.stories.jsx +13 -0
- package/dist/stories/Pagination.stories.d.ts +9 -0
- package/dist/stories/Pagination.stories.jsx +75 -0
- package/dist/stories/Progress.stories.d.ts +9 -0
- package/dist/stories/Progress.stories.jsx +43 -0
- package/dist/stories/SearchDialog.stories.d.ts +17 -0
- package/dist/stories/SearchDialog.stories.jsx +111 -0
- package/dist/stories/Skeleton.stories.d.ts +7 -0
- package/dist/stories/Skeleton.stories.jsx +27 -0
- package/dist/stories/StatTile.stories.d.ts +10 -0
- package/dist/stories/StatTile.stories.jsx +55 -0
- package/dist/stories/TabPanel.stories.d.ts +7 -0
- package/dist/stories/TabPanel.stories.jsx +31 -0
- package/dist/stories/Table.stories.d.ts +1 -0
- package/dist/stories/Table.stories.jsx +49 -1
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +7 -0
- package/package.json +5 -1
|
@@ -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 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Width = 'full' | 'large' | 'medium' | 'small';
|
|
3
|
+
interface SkeletonProps {
|
|
4
|
+
/** The shape of what will load. `text` is one body line (`lines` stacks several), `block` a card or a row, `circle` an avatar. */
|
|
5
|
+
variant?: 'text' | 'block' | 'circle';
|
|
6
|
+
/** `full` is 100%, `large` 75%, `medium` 50%, `small` 25%. A `circle` ignores it. */
|
|
7
|
+
width?: Width;
|
|
8
|
+
/** For `text`: how many lines. The last one is shorter. */
|
|
9
|
+
lines?: number;
|
|
10
|
+
/** For `block`: 24px, 48px or 120px. */
|
|
11
|
+
height?: 'small' | 'medium' | 'large';
|
|
12
|
+
/** Names the loading for a screen reader, e.g. "Loading invoices", in a visually hidden `role="status"`. Without it the skeleton is silent. */
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A still block in the shape of what will load, so a table or a tile keeps its size while it loads.
|
|
17
|
+
* It is hidden from the accessibility tree; give it a `label` once per region so the loading is announced once.
|
|
18
|
+
* The slow pulse stops under reduced motion. A status region announces most reliably when it stays mounted and its text changes.
|
|
19
|
+
*/
|
|
20
|
+
export default function Skeleton({ variant, width, lines, height, label }: SkeletonProps): React.JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var widthClasses = { full: 'w-full', large: 'w-3/4', medium: 'w-1/2', small: 'w-1/4' };
|
|
3
|
+
var shorter = { full: 'large', large: 'medium', medium: 'small', small: 'small' };
|
|
4
|
+
var heightClasses = { small: 'h-6', medium: 'h-12', large: 'h-[120px]' };
|
|
5
|
+
var base = 'bg-fg-primary/10 animate-pulse motion-reduce:animate-none';
|
|
6
|
+
// A body line is 24px tall: each bar sits in a 24px slot so the text that replaces it does not move the page
|
|
7
|
+
var TextLine = function (_a) {
|
|
8
|
+
var width = _a.width;
|
|
9
|
+
return (<div className="flex h-6 items-center">
|
|
10
|
+
<div className={"".concat(widthClasses[width], " h-4 rounded-control ").concat(base)}/>
|
|
11
|
+
</div>);
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A still block in the shape of what will load, so a table or a tile keeps its size while it loads.
|
|
15
|
+
* It is hidden from the accessibility tree; give it a `label` once per region so the loading is announced once.
|
|
16
|
+
* The slow pulse stops under reduced motion. A status region announces most reliably when it stays mounted and its text changes.
|
|
17
|
+
*/
|
|
18
|
+
export default function Skeleton(_a) {
|
|
19
|
+
var _b = _a.variant, variant = _b === void 0 ? 'text' : _b, _c = _a.width, width = _c === void 0 ? 'full' : _c, _d = _a.lines, lines = _d === void 0 ? 1 : _d, _e = _a.height, height = _e === void 0 ? 'medium' : _e, label = _a.label;
|
|
20
|
+
var shape;
|
|
21
|
+
if (variant === 'circle') {
|
|
22
|
+
shape = <div aria-hidden="true" className={"h-7 w-7 shrink-0 rounded-full ".concat(base)}/>;
|
|
23
|
+
}
|
|
24
|
+
else if (variant === 'block') {
|
|
25
|
+
shape = <div aria-hidden="true" className={"".concat(widthClasses[width], " ").concat(heightClasses[height], " rounded-container ").concat(base)}/>;
|
|
26
|
+
}
|
|
27
|
+
else if (lines > 1) {
|
|
28
|
+
shape = (<div aria-hidden="true" className="flex flex-col w-full">
|
|
29
|
+
{Array.from({ length: lines }, function (_, i) { return (<TextLine key={i} width={i === lines - 1 ? shorter[width] : width}/>); })}
|
|
30
|
+
</div>);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
shape = <div aria-hidden="true" className="w-full"><TextLine width={width}/></div>;
|
|
34
|
+
}
|
|
35
|
+
if (!label)
|
|
36
|
+
return <>{shape}</>;
|
|
37
|
+
return (<>
|
|
38
|
+
{shape}
|
|
39
|
+
<span role="status" className="sr-only">{label}</span>
|
|
40
|
+
</>);
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ChangePeriod } from './formatNumber';
|
|
3
|
+
interface StatTileProps {
|
|
4
|
+
/** What the number is, e.g. "Responses". It is the tile's name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The number. `null` means there is no data yet; it shows 'No data yet', never 0. A percent is a fraction (0.124 is 12%). */
|
|
7
|
+
value: number | null;
|
|
8
|
+
/** How the number reads: a count (default), money, a percent, bytes (base 1024) or a duration in milliseconds. */
|
|
9
|
+
format?: 'count' | 'money' | 'percent' | 'bytes' | 'duration';
|
|
10
|
+
/** For `money`: the currency code. Defaults to USD. */
|
|
11
|
+
currency?: string;
|
|
12
|
+
/** What is counted, e.g. "responses", set after the number. */
|
|
13
|
+
unit?: string;
|
|
14
|
+
/** The value for the period before, in the same unit. Gives the change line; without it there is none. */
|
|
15
|
+
previous?: number | null;
|
|
16
|
+
/** The period `previous` is from. Defaults to week. */
|
|
17
|
+
period?: ChangePeriod;
|
|
18
|
+
/** A line under the number, e.g. "7 of 8 seats used". */
|
|
19
|
+
caption?: string;
|
|
20
|
+
/** Shows a skeleton in place of the number and the change line, and marks the tile busy. */
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
/** The number is h5 at every width. `large` sets it h4, and h3 from `md` up. */
|
|
23
|
+
size?: 'default' | 'large';
|
|
24
|
+
id?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One headline number: a label, the number, how it changed and an optional note. From 10,000 up a count or an amount
|
|
28
|
+
* shows in its short form ('1.2M') and the exact number is in hidden text, so a screen reader hears '1,234,567'.
|
|
29
|
+
* The change line is never colored: more is not good or bad by itself. A row of tiles is `<Grid compact columns={4}>`.
|
|
30
|
+
*/
|
|
31
|
+
export default function StatTile({ label, value, format, currency, unit, previous, period, caption, loading, size, id, }: StatTileProps): React.JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrowDown, ArrowUp } from 'lucide-react';
|
|
3
|
+
import Skeleton from './skeleton';
|
|
4
|
+
import { formatBytes, formatChange, formatCount, formatDuration, formatMoney, formatPercent, } from './formatNumber';
|
|
5
|
+
/**
|
|
6
|
+
* One headline number: a label, the number, how it changed and an optional note. From 10,000 up a count or an amount
|
|
7
|
+
* shows in its short form ('1.2M') and the exact number is in hidden text, so a screen reader hears '1,234,567'.
|
|
8
|
+
* The change line is never colored: more is not good or bad by itself. A row of tiles is `<Grid compact columns={4}>`.
|
|
9
|
+
*/
|
|
10
|
+
export default function StatTile(_a) {
|
|
11
|
+
var label = _a.label, value = _a.value, _b = _a.format, format = _b === void 0 ? 'count' : _b, _c = _a.currency, currency = _c === void 0 ? 'USD' : _c, unit = _a.unit, previous = _a.previous, _d = _a.period, period = _d === void 0 ? 'week' : _d, caption = _a.caption, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? 'default' : _f, id = _a.id;
|
|
12
|
+
// The default number is h5 at every width, so four tiles across keep '2 h 24 min' on one line
|
|
13
|
+
var valueSize = size === 'large' ? 'text-h4 md:text-h3' : 'text-h5';
|
|
14
|
+
// A line keeps its height while it loads, so the tile does not jump
|
|
15
|
+
var valueLine = size === 'large' ? 'min-h-[41px] md:min-h-[58px]' : 'min-h-[29px]';
|
|
16
|
+
var shown = null;
|
|
17
|
+
var exact = null;
|
|
18
|
+
if (value !== null) {
|
|
19
|
+
switch (format) {
|
|
20
|
+
case 'money':
|
|
21
|
+
exact = formatMoney(value, { currency: currency });
|
|
22
|
+
shown = formatMoney(value, { currency: currency, compact: true });
|
|
23
|
+
break;
|
|
24
|
+
case 'percent':
|
|
25
|
+
shown = formatPercent(value);
|
|
26
|
+
break;
|
|
27
|
+
case 'bytes':
|
|
28
|
+
shown = formatBytes(value);
|
|
29
|
+
break;
|
|
30
|
+
case 'duration':
|
|
31
|
+
shown = formatDuration(value);
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
exact = formatCount(value);
|
|
35
|
+
shown = formatCount(value, { compact: true });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var compact = shown !== null && exact !== null && shown !== exact;
|
|
39
|
+
var change = loading ? null : formatChange(value, previous, period);
|
|
40
|
+
return (<dl id={id} aria-busy={loading || undefined} className="flex min-w-0 flex-col gap-1">
|
|
41
|
+
<dt className="text-caption text-fg-secondary">{label}</dt>
|
|
42
|
+
<dd className={"flex items-center ".concat(valueLine)}>
|
|
43
|
+
{loading ? (<Skeleton width="medium" label={"Loading ".concat(label)}/>) : shown === null ? (<span className="text-body1 text-fg-secondary">No data yet</span>) : (<span className={"min-w-0 break-words font-mono tabular-nums text-fg-primary ".concat(valueSize)}>
|
|
44
|
+
{compact ? (<>
|
|
45
|
+
<span aria-hidden="true">{shown}</span>
|
|
46
|
+
<span className="sr-only">{exact}</span>
|
|
47
|
+
</>) : (shown)}
|
|
48
|
+
{unit && <span className="font-sans text-body2 text-fg-secondary">{' '}{unit}</span>}
|
|
49
|
+
</span>)}
|
|
50
|
+
</dd>
|
|
51
|
+
{loading ? (<dd className="m-0">
|
|
52
|
+
<Skeleton width="large"/>
|
|
53
|
+
</dd>) : (change &&
|
|
54
|
+
change.direction !== null && (<dd className="m-0 flex items-center gap-1 text-body2 text-fg-secondary">
|
|
55
|
+
{change.direction === 'up' && <ArrowUp aria-hidden="true" className="size-4 shrink-0"/>}
|
|
56
|
+
{change.direction === 'down' && <ArrowDown aria-hidden="true" className="size-4 shrink-0"/>}
|
|
57
|
+
{change.text}
|
|
58
|
+
</dd>))}
|
|
59
|
+
{caption && <dd className="m-0 text-body2 text-fg-secondary">{caption}</dd>}
|
|
60
|
+
</dl>);
|
|
61
|
+
}
|
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
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface TableContainerProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
+
/** Names the table. Name it when it can overflow; a named table is a Tab stop. With a name the table sits in a scrollable `role="region"` of the same name that a keyboard can focus and scroll, for a table wider than a phone. */
|
|
5
|
+
'aria-label'?: string;
|
|
6
|
+
/** With `aria-label`: the width the table keeps, e.g. '640px', so its columns do not squeeze and the region scrolls sideways. Ignored without a name. */
|
|
7
|
+
minWidth?: string;
|
|
4
8
|
}
|
|
5
|
-
export default function TableContainer({ children }: TableContainerProps): React.JSX.Element;
|
|
9
|
+
export default function TableContainer({ children, 'aria-label': ariaLabel, minWidth }: TableContainerProps): React.JSX.Element;
|
|
6
10
|
export {};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { focusRing } from './sharedStyles';
|
|
3
4
|
export default function TableContainer(_a) {
|
|
4
|
-
var children = _a.children;
|
|
5
|
+
var children = _a.children, ariaLabel = _a["aria-label"], minWidth = _a.minWidth;
|
|
6
|
+
if (ariaLabel) {
|
|
7
|
+
return (<div role="region" aria-label={ariaLabel} tabIndex={0} className={"w-full overflow-x-auto bg-background-default rounded-control ".concat(focusRing)}>
|
|
8
|
+
<div role="table" aria-label={ariaLabel} className="w-full bg-background-default" style={minWidth ? { minWidth: minWidth } : undefined}>
|
|
9
|
+
{children}
|
|
10
|
+
</div>
|
|
11
|
+
</div>);
|
|
12
|
+
}
|
|
5
13
|
return (<div role="table" className="w-full overflow-x-auto bg-background-default">
|
|
6
14
|
{children}
|
|
7
15
|
</div>);
|
|
@@ -4,6 +4,8 @@ interface TableHeaderCellProps {
|
|
|
4
4
|
width?: string;
|
|
5
5
|
minWidth?: string;
|
|
6
6
|
align?: 'left' | 'center' | 'right';
|
|
7
|
+
/** Marks the column the table is sorted by. Set it on the one sorted column. Leave `sort` unset on the other columns. A sort Button inside is named by its label alone, and its arrow stays. */
|
|
8
|
+
sort?: 'ascending' | 'descending' | 'none';
|
|
7
9
|
}
|
|
8
|
-
export default function TableHeaderCell({ children, width, minWidth, align }: TableHeaderCellProps): React.JSX.Element;
|
|
10
|
+
export default function TableHeaderCell({ children, width, minWidth, align, sort }: TableHeaderCellProps): React.JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export default function TableHeaderCell(_a) {
|
|
4
|
-
var children = _a.children, width = _a.width, minWidth = _a.minWidth, _b = _a.align, align = _b === void 0 ? 'left' : _b;
|
|
4
|
+
var children = _a.children, width = _a.width, minWidth = _a.minWidth, _b = _a.align, align = _b === void 0 ? 'left' : _b, sort = _a.sort;
|
|
5
5
|
var alignClass = align === 'center' ? 'text-center' : align === 'right' ? 'text-right' : 'text-left';
|
|
6
6
|
var widthStyle = width ? { width: width, minWidth: minWidth || width } : {};
|
|
7
7
|
var flexClass = width ? '' : 'flex-1';
|
|
8
|
-
return (<div role="columnheader" className={"".concat(flexClass, " p-2 text-body2 text-fg-secondary ").concat(alignClass)} style={widthStyle}>
|
|
8
|
+
return (<div role="columnheader" aria-sort={sort} className={"".concat(flexClass, " p-2 text-body2 text-fg-secondary ").concat(alignClass)} style={widthStyle}>
|
|
9
9
|
{children}
|
|
10
10
|
</div>);
|
|
11
11
|
}
|
|
@@ -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 : []);
|
|
@@ -8,10 +8,12 @@ interface TitleBarProps {
|
|
|
8
8
|
back?: React.ReactNode;
|
|
9
9
|
/** Buttons at the end of the row. They never shrink; a long title wraps instead. */
|
|
10
10
|
actions?: React.ReactNode;
|
|
11
|
+
/** Below md the `actions` take their own line under the title, as `back` does above it, for a control too wide to sit beside the title (a range switch). From md up nothing changes. Ignored with `phoneActions`. */
|
|
12
|
+
actionsBelow?: boolean;
|
|
11
13
|
/** Below md these replace `actions`: the main action and a More menu holding the rest */
|
|
12
14
|
phoneActions?: React.ReactNode;
|
|
13
15
|
/** The heading's id */
|
|
14
16
|
id?: string;
|
|
15
17
|
}
|
|
16
|
-
export default function TitleBar({ title, level, back, actions, phoneActions, id }: TitleBarProps): React.JSX.Element;
|
|
18
|
+
export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, id }: TitleBarProps): React.JSX.Element;
|
|
17
19
|
export { TitleBar };
|
|
@@ -4,13 +4,14 @@ import Heading from './heading';
|
|
|
4
4
|
// A row without Back is one row at every width. The heading takes tabIndex -1 so a page or a pane can
|
|
5
5
|
// move focus to it (a pane does on open) without adding it to the tab order.
|
|
6
6
|
export default function TitleBar(_a) {
|
|
7
|
-
var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, phoneActions = _a.phoneActions, id = _a.id;
|
|
8
|
-
|
|
7
|
+
var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, id = _a.id;
|
|
8
|
+
var below = actionsBelow && !phoneActions;
|
|
9
|
+
return (<div className={"flex min-w-0 items-center gap-2".concat(back || below ? ' flex-wrap md:flex-nowrap' : '')}>
|
|
9
10
|
{back && <div className="flex shrink-0 basis-full items-center md:basis-auto">{back}</div>}
|
|
10
11
|
<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
|
|
11
12
|
{title}
|
|
12
13
|
</Heading>
|
|
13
|
-
{actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2")}>{actions}</div>}
|
|
14
|
+
{actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
|
|
14
15
|
{phoneActions && <div className="flex shrink-0 items-center gap-2 md:hidden">{phoneActions}</div>}
|
|
15
16
|
</div>);
|
|
16
17
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
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';
|
|
9
11
|
export * from './components/formField';
|
|
12
|
+
export * from './components/formatNumber';
|
|
10
13
|
export * from './components/iconButton';
|
|
11
14
|
export * from './components/layout';
|
|
15
|
+
export * from './components/lightbox';
|
|
12
16
|
export * from './components/loadingScreen';
|
|
13
17
|
export * from './components/menu';
|
|
14
18
|
export * from './components/menuItem';
|
|
15
19
|
export * from './components/modal';
|
|
16
20
|
export * from './components/navigation';
|
|
17
21
|
export * from './components/onThisPage';
|
|
22
|
+
export * from './components/pagination';
|
|
18
23
|
export * from './components/popover';
|
|
24
|
+
export * from './components/progress';
|
|
19
25
|
export * from './components/radioGroup';
|
|
26
|
+
export * from './components/searchDialog';
|
|
20
27
|
export * from './components/sectionIntro';
|
|
21
28
|
export * from './components/segmentedControl';
|
|
22
29
|
export * from './components/select';
|
|
@@ -24,6 +31,8 @@ export * from './components/settingsSection';
|
|
|
24
31
|
export * from './components/sidePane';
|
|
25
32
|
export * from './components/siteFooter';
|
|
26
33
|
export * from './components/siteHeader';
|
|
34
|
+
export * from './components/skeleton';
|
|
35
|
+
export * from './components/statTile';
|
|
27
36
|
export * from './components/switch';
|
|
28
37
|
export * from './components/tab';
|
|
29
38
|
export * from './components/tableCell';
|
|
@@ -31,6 +40,7 @@ export * from './components/tableContainer';
|
|
|
31
40
|
export * from './components/tableHeader';
|
|
32
41
|
export * from './components/tableHeaderCell';
|
|
33
42
|
export * from './components/tableRow';
|
|
43
|
+
export * from './components/tabPanel';
|
|
34
44
|
export * from './components/tabsContainer';
|
|
35
45
|
export * from './components/tag';
|
|
36
46
|
export * from './components/textarea';
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
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';
|
|
9
11
|
export * from './components/formField';
|
|
12
|
+
export * from './components/formatNumber';
|
|
10
13
|
export * from './components/iconButton';
|
|
11
14
|
export * from './components/layout';
|
|
15
|
+
export * from './components/lightbox';
|
|
12
16
|
export * from './components/loadingScreen';
|
|
13
17
|
export * from './components/menu';
|
|
14
18
|
export * from './components/menuItem';
|
|
15
19
|
export * from './components/modal';
|
|
16
20
|
export * from './components/navigation';
|
|
17
21
|
export * from './components/onThisPage';
|
|
22
|
+
export * from './components/pagination';
|
|
18
23
|
export * from './components/popover';
|
|
24
|
+
export * from './components/progress';
|
|
19
25
|
export * from './components/radioGroup';
|
|
26
|
+
export * from './components/searchDialog';
|
|
20
27
|
export * from './components/sectionIntro';
|
|
21
28
|
export * from './components/segmentedControl';
|
|
22
29
|
export * from './components/select';
|
|
@@ -24,6 +31,8 @@ export * from './components/settingsSection';
|
|
|
24
31
|
export * from './components/sidePane';
|
|
25
32
|
export * from './components/siteFooter';
|
|
26
33
|
export * from './components/siteHeader';
|
|
34
|
+
export * from './components/skeleton';
|
|
35
|
+
export * from './components/statTile';
|
|
27
36
|
export * from './components/switch';
|
|
28
37
|
export * from './components/tab';
|
|
29
38
|
export * from './components/tableCell';
|
|
@@ -31,6 +40,7 @@ export * from './components/tableContainer';
|
|
|
31
40
|
export * from './components/tableHeader';
|
|
32
41
|
export * from './components/tableHeaderCell';
|
|
33
42
|
export * from './components/tableRow';
|
|
43
|
+
export * from './components/tabPanel';
|
|
34
44
|
export * from './components/tabsContainer';
|
|
35
45
|
export * from './components/tag';
|
|
36
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;
|