oneslash-design-system 2.23.1 → 2.25.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 +20 -5
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +248 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +551 -0
- package/dist/cases/billing-page/self-serve.jsx +4 -4
- package/dist/cases/billing-page/trial.d.ts +1 -0
- package/dist/cases/billing-page/trial.jsx +115 -0
- package/dist/cases/billing-page.md +166 -5
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/collapsible-search/popover.jsx +1 -1
- package/dist/cases/collapsible-search.md +2 -2
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/cookie-choice/banner.d.ts +1 -0
- package/dist/cases/cookie-choice/banner.jsx +82 -0
- package/dist/cases/cookie-choice/settings.d.ts +1 -0
- package/dist/cases/cookie-choice/settings.jsx +75 -0
- package/dist/cases/cookie-choice.md +234 -0
- package/dist/cases/dashboard/numbers-first.jsx +63 -2
- package/dist/cases/dashboard/work-first.jsx +1 -1
- package/dist/cases/dashboard.md +77 -5
- package/dist/cases/data-table-page/all-rows.jsx +1 -1
- package/dist/cases/data-table-page/paged.jsx +1 -1
- package/dist/cases/data-table-page.md +2 -2
- package/dist/cases/invoice-list/table.jsx +21 -9
- package/dist/cases/invoice-list.md +27 -12
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/message-reactions/picker.jsx +1 -1
- package/dist/cases/message-reactions.md +2 -2
- package/dist/cases/message-row.md +2 -1
- package/dist/cases/newsletter-signup/inline.d.ts +1 -0
- package/dist/cases/newsletter-signup/inline.jsx +72 -0
- package/dist/cases/newsletter-signup/section.d.ts +1 -0
- package/dist/cases/newsletter-signup/section.jsx +72 -0
- package/dist/cases/newsletter-signup.md +234 -0
- package/dist/cases/number-format.md +9 -3
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/people-row/stack.jsx +1 -1
- package/dist/cases/people-row.md +2 -2
- package/dist/cases/plan-comparison/table.d.ts +1 -0
- package/dist/cases/plan-comparison/table.jsx +47 -0
- package/dist/cases/plan-comparison.md +94 -0
- package/dist/cases/plan-picker.md +1 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/pricing-section.md +1 -1
- package/dist/cases/site-footer/columns.jsx +2 -1
- package/dist/cases/site-footer.md +3 -1
- package/dist/cases/stat-row/tiles.jsx +2 -1
- package/dist/cases/stat-row.md +5 -2
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +883 -30
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +92 -0
- package/dist/components/dateField.jsx +1 -1
- package/dist/components/formatNumber.d.ts +10 -2
- package/dist/components/formatNumber.js +44 -9
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/layout.d.ts +4 -2
- package/dist/components/layout.jsx +13 -2
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.jsx +81 -0
- package/dist/components/pageShell.d.ts +3 -3
- package/dist/components/pageShell.jsx +6 -5
- package/dist/components/popover.d.ts +5 -1
- package/dist/components/popover.jsx +3 -2
- package/dist/components/progress.jsx +1 -1
- package/dist/components/select.jsx +5 -2
- package/dist/components/statTile.d.ts +1 -1
- package/dist/components/statTile.jsx +7 -2
- package/dist/components/tableCell.d.ts +4 -3
- package/dist/components/tableCell.jsx +2 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/components/toaster.jsx +81 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/internal/markdown.d.ts +40 -0
- package/dist/internal/markdown.js +577 -0
- package/dist/internal/toaster.d.ts +2 -0
- package/dist/internal/toaster.js +8 -0
- package/dist/native-mapping.json +28 -4
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +22 -0
- package/dist/stories/Cases.generated.stories.jsx +44 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Markdown.stories.d.ts +9 -0
- package/dist/stories/Markdown.stories.jsx +66 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +2 -0
- package/dist/stories/Popover.stories.jsx +33 -0
- package/dist/stories/StatTile.stories.d.ts +4 -0
- package/dist/stories/StatTile.stories.jsx +47 -2
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/dist/stories/Toaster.stories.d.ts +4 -0
- package/dist/stories/Toaster.stories.jsx +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { parseMarkdown } from '../internal/markdown';
|
|
3
|
+
import CodeBlock from './codeBlock';
|
|
4
|
+
import Heading from './heading';
|
|
5
|
+
import { Stack } from './layout';
|
|
6
|
+
import Line from './line';
|
|
7
|
+
import Link from './link';
|
|
8
|
+
import List from './list';
|
|
9
|
+
import Paragraph from './paragraph';
|
|
10
|
+
function Inline(_a) {
|
|
11
|
+
var nodes = _a.nodes, size = _a.size;
|
|
12
|
+
return (<>
|
|
13
|
+
{nodes.map(function (node, i) {
|
|
14
|
+
switch (node.type) {
|
|
15
|
+
case 'text':
|
|
16
|
+
return <React.Fragment key={i}>{node.text}</React.Fragment>;
|
|
17
|
+
case 'strong':
|
|
18
|
+
return (<strong key={i}>
|
|
19
|
+
<Inline nodes={node.children} size={size}/>
|
|
20
|
+
</strong>);
|
|
21
|
+
case 'em':
|
|
22
|
+
return (<em key={i}>
|
|
23
|
+
<Inline nodes={node.children} size={size}/>
|
|
24
|
+
</em>);
|
|
25
|
+
case 'code':
|
|
26
|
+
return (<code key={i} className="font-mono text-[0.9em] rounded bg-background-accent200 px-1">
|
|
27
|
+
{node.text}
|
|
28
|
+
</code>);
|
|
29
|
+
case 'link':
|
|
30
|
+
// A link in a reply opens a new tab and says so, so the person keeps the conversation. mailto stays.
|
|
31
|
+
return node.href.startsWith('mailto:') ? (<Link key={i} href={node.href} size={size}>
|
|
32
|
+
<Inline nodes={node.children} size={size}/>
|
|
33
|
+
</Link>) : (<Link key={i} href={node.href} size={size} openInNewTab announceNewTab>
|
|
34
|
+
<Inline nodes={node.children} size={size}/>
|
|
35
|
+
</Link>);
|
|
36
|
+
}
|
|
37
|
+
})}
|
|
38
|
+
</>);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A message's markdown set in ODS parts: Heading, Paragraph, List, CodeBlock, Link and Line. The subset is
|
|
42
|
+
* headings (`#` to `###`), lists one level deep, fenced code, rules, bold, italic, inline code and links.
|
|
43
|
+
* A table shows as a code block named 'Table', an image as its alt text, and HTML as text. Only http, https
|
|
44
|
+
* and mailto links become links. A fence that is still open (a reply still streaming) runs to the end.
|
|
45
|
+
*/
|
|
46
|
+
export default function Markdown(_a) {
|
|
47
|
+
var id = _a.id, text = _a.text, _b = _a.headingLevel, headingLevel = _b === void 0 ? 3 : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c;
|
|
48
|
+
var blocks = parseMarkdown(text);
|
|
49
|
+
var codeCount = 0;
|
|
50
|
+
var renderBlock = function (block, key, className) {
|
|
51
|
+
if (className === void 0) { className = ''; }
|
|
52
|
+
switch (block.type) {
|
|
53
|
+
case 'heading':
|
|
54
|
+
return (<Heading key={key} level={Math.min(headingLevel + block.depth - 1, 4)} size={block.depth === 1 ? 'h6' : 'subtitle1'} className={className}>
|
|
55
|
+
<Inline nodes={block.children} size={block.depth === 1 ? 'h6' : 'subtitle1'}/>
|
|
56
|
+
</Heading>);
|
|
57
|
+
case 'paragraph':
|
|
58
|
+
return (<Paragraph key={key} measure="none" size={size} className={className}>
|
|
59
|
+
<Inline nodes={block.children} size={size}/>
|
|
60
|
+
</Paragraph>);
|
|
61
|
+
case 'list':
|
|
62
|
+
return (<List key={key} marker={block.ordered ? 'number' : 'dot'} size={size} className={className} items={block.items.map(function (item) {
|
|
63
|
+
return item.map(function (child, j) {
|
|
64
|
+
// The item's first line sits beside its marker; what follows starts a little below
|
|
65
|
+
return j === 0 && child.type === 'paragraph' ? (<Inline key={j} nodes={child.children} size={size}/>) : child.type === 'code' ? (<div key={j} className={j === 0 ? '' : 'mt-medium'}>
|
|
66
|
+
{renderBlock(child, j)}
|
|
67
|
+
</div>) : (renderBlock(child, j, j === 0 ? '' : 'mt-medium'));
|
|
68
|
+
});
|
|
69
|
+
})}/>);
|
|
70
|
+
case 'code': {
|
|
71
|
+
var n = codeCount;
|
|
72
|
+
codeCount += 1;
|
|
73
|
+
return (<CodeBlock key={key} id={"".concat(id, "-code-").concat(n)} label={block.table ? 'Table' : block.language ? "".concat(block.language, " code") : 'Code'} code={block.code}/>);
|
|
74
|
+
}
|
|
75
|
+
case 'rule':
|
|
76
|
+
return <Line key={key} className={className}/>;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return <Stack gap="medium">{blocks.map(function (block, i) { return renderBlock(block, i); })}</Stack>;
|
|
80
|
+
}
|
|
81
|
+
export { Markdown };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface PageShellProps extends React.ComponentPropsWithoutRef<'main'> {
|
|
2
|
+
export interface PageShellProps extends React.ComponentPropsWithoutRef<'main'> {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
/** Let the column grow from the 2xl breakpoint, for pages with wide figures. */
|
|
5
5
|
wide?: boolean;
|
|
@@ -12,5 +12,5 @@ interface PageShellProps extends React.ComponentPropsWithoutRef<'main'> {
|
|
|
12
12
|
*/
|
|
13
13
|
aside?: React.ReactNode;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export
|
|
15
|
+
declare const PageShell: React.ForwardRefExoticComponent<PageShellProps & React.RefAttributes<HTMLElement>>;
|
|
16
|
+
export default PageShell;
|
|
@@ -11,12 +11,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
13
|
// The frame of a page: the column, its side space, and the space between sections.
|
|
14
|
-
// Anything else given (data-* attributes, an id) goes to the <main>.
|
|
15
|
-
|
|
14
|
+
// Anything else given (data-* attributes, an id) goes to the <main>. So does a ref, so a page can move focus there (with tabIndex -1).
|
|
15
|
+
var PageShell = React.forwardRef(function PageShell(_a, ref) {
|
|
16
16
|
var children = _a.children, _b = _a.wide, wide = _b === void 0 ? false : _b, _c = _a.fluid, fluid = _c === void 0 ? false : _c, aside = _a.aside, _d = _a.className, className = _d === void 0 ? '' : _d, rest = __rest(_a, ["children", "wide", "fluid", "aside", "className"]);
|
|
17
17
|
if (aside) {
|
|
18
18
|
// The page column and the aside sit side by side from xl, centered together
|
|
19
|
-
return (<main className={"min-h-screen [&_:is(h2,h3)[id]]:scroll-mt-[var(--os-header-offset,0px)] ".concat(className)} {...rest}>
|
|
19
|
+
return (<main ref={ref} className={"min-h-screen [&_:is(h2,h3)[id]]:scroll-mt-[var(--os-header-offset,0px)] ".concat(className)} {...rest}>
|
|
20
20
|
<div className="mx-auto flex w-full items-start justify-center">
|
|
21
21
|
<div className={"flex min-w-0 w-full flex-col gap-section px-xlarge pb-page pt-giant md:px-xxlarge ".concat(fluid ? '' : "max-w-page ".concat(wide ? '2xl:max-w-page-wide' : ''))}>
|
|
22
22
|
{children}
|
|
@@ -27,9 +27,10 @@ export default function PageShell(_a) {
|
|
|
27
27
|
</div>
|
|
28
28
|
</main>);
|
|
29
29
|
}
|
|
30
|
-
return (<main className={"min-h-screen ".concat(className)} {...rest}>
|
|
30
|
+
return (<main ref={ref} className={"min-h-screen ".concat(className)} {...rest}>
|
|
31
31
|
<div className={"mx-auto flex w-full flex-col gap-section px-xlarge pb-page pt-giant md:px-xxlarge ".concat(fluid ? '' : "max-w-page ".concat(wide ? '2xl:max-w-page-wide' : ''))}>
|
|
32
32
|
{children}
|
|
33
33
|
</div>
|
|
34
34
|
</main>);
|
|
35
|
-
}
|
|
35
|
+
});
|
|
36
|
+
export default PageShell;
|
|
@@ -11,6 +11,10 @@ interface PopoverProps {
|
|
|
11
11
|
* Popover also closes it (`onClose`) and focuses `anchorEl`. Pass the focusable trigger as `anchorEl`.
|
|
12
12
|
*/
|
|
13
13
|
returnFocus?: boolean;
|
|
14
|
+
/** The dialog's name. Give one unless the content is a `navigable` (or `role`d) `Menu` with its own `aria-label`: that Menu names itself, and the Popover around it stays unnamed so it is not heard twice. */
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
/** The id of the element that names the dialog, as an alternative to `aria-label`. */
|
|
17
|
+
'aria-labelledby'?: string;
|
|
14
18
|
}
|
|
15
|
-
export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, }: PopoverProps): React.ReactPortal | null;
|
|
19
|
+
export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, }: PopoverProps): React.ReactPortal | null;
|
|
16
20
|
export {};
|
|
@@ -7,7 +7,7 @@ import { useOverlayTransition } from './useOverlayTransition';
|
|
|
7
7
|
import Menu from './menu';
|
|
8
8
|
import { isInTopOverlay } from '../internal/overlayStack';
|
|
9
9
|
export default function Popover(_a) {
|
|
10
|
-
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? false : _b;
|
|
10
|
+
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"];
|
|
11
11
|
var _c = useState(null), popoverElement = _c[0], setPopoverElement = _c[1];
|
|
12
12
|
var _d = useState(false), hasMounted = _d[0], setHasMounted = _d[1];
|
|
13
13
|
var _e = useOverlayTransition(open), mounted = _e.mounted, visible = _e.visible;
|
|
@@ -83,12 +83,13 @@ export default function Popover(_a) {
|
|
|
83
83
|
// A Menu brings its own surface (4px inset, container corners), so the
|
|
84
84
|
// popover adds none around it rather than doubling the padding and edges.
|
|
85
85
|
var isMenu = isValidElement(children) && children.type === Menu;
|
|
86
|
+
var dialogLabel = ariaLabelledby ? undefined : ariaLabel;
|
|
86
87
|
var panelClass = isMenu
|
|
87
88
|
? ''
|
|
88
89
|
: 'bg-background-overlay dark:ring-1 dark:ring-misc-divider rounded-control shadow-overlay p-2';
|
|
89
90
|
// Render popover in a portal to prevent layout shifts and positioning issues
|
|
90
91
|
// 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)
|
|
91
|
-
return createPortal(<div id={id} ref={setPopoverElement} style={styles.popper} {...attributes.popper} className="z-[var(--os-z-overlay)]" role="dialog">
|
|
92
|
+
return createPortal(<div id={id} ref={setPopoverElement} style={styles.popper} {...attributes.popper} className="z-[var(--os-z-overlay)]" role="dialog" aria-label={dialogLabel} aria-labelledby={ariaLabelledby}>
|
|
92
93
|
{/* Popper owns the outer transform, so the fade and scale go on this inner panel */}
|
|
93
94
|
<div className={"".concat(panelClass, " origin-top-left\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)}>
|
|
94
95
|
{children}
|
|
@@ -29,7 +29,7 @@ export default function Progress(_a) {
|
|
|
29
29
|
var text = valueText !== null && valueText !== void 0 ? valueText : (share ? withUnit("".concat(formatPercent(max > 0 ? value / max : 0), ", ").concat(formatCount(value))) : withUnit("".concat(formatCount(value), " of ").concat(formatCount(max))));
|
|
30
30
|
var suffix = share ? '' : status === 'error' ? (value > max ? ', over the limit' : ', at the limit') : status === 'warning' ? ', almost at the limit' : '';
|
|
31
31
|
var statusWords = { error: 'Limit reached', warning: 'Almost at the limit', primary: '' }[status];
|
|
32
|
-
var bar = { error: 'bg-error-main', warning: 'bg-warning-
|
|
32
|
+
var bar = { error: 'bg-error-main', warning: 'bg-warning-fill', primary: 'bg-accent-main' }[status];
|
|
33
33
|
var wordColor = { error: 'text-error-text', warning: 'text-warning-text', primary: '' }[status];
|
|
34
34
|
var percent = Math.min(100, Math.max(0, fraction * 100));
|
|
35
35
|
return (
|
|
@@ -59,6 +59,9 @@ export default function Select(_a) {
|
|
|
59
59
|
var menuRef = useRef(null);
|
|
60
60
|
var listboxId = useId();
|
|
61
61
|
var optionId = function (index) { return "".concat(listboxId, "-option-").concat(index); };
|
|
62
|
+
// Without an aria-label the shown value is the name. With one, the label is the name and the
|
|
63
|
+
// value is the combobox's value, which browsers expose from its contents.
|
|
64
|
+
var valueId = ariaLabel ? undefined : "".concat(listboxId, "-value");
|
|
62
65
|
// Synchronous lookup so the icon renders on the first paint
|
|
63
66
|
// Close menu when clicking outside
|
|
64
67
|
useEffect(function () {
|
|
@@ -210,7 +213,7 @@ export default function Select(_a) {
|
|
|
210
213
|
};
|
|
211
214
|
return (<div className={"relative ".concat(className)} style={{ width: width || '100%' }}>
|
|
212
215
|
{/* Select Button */}
|
|
213
|
-
<div ref={setTrigger} role="combobox" id={id} aria-label={ariaLabel} aria-describedby={ariaDescribedBy} aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
216
|
+
<div ref={setTrigger} role="combobox" id={id} aria-label={ariaLabel} aria-labelledby={valueId} aria-describedby={ariaDescribedBy} aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
214
217
|
{/* Inner Content Container; 7px vertical padding makes the control 40px like Button and TextField */}
|
|
215
218
|
<div className={"flex items-center justify-between px-2 py-[7px] ".concat(getTextColor())}>
|
|
216
219
|
{/* Content Container */}
|
|
@@ -219,7 +222,7 @@ export default function Select(_a) {
|
|
|
219
222
|
<IconSlot icon={decoIconName} className={"w-6 h-6 flex-shrink-0 ".concat(getIconColor())}/>
|
|
220
223
|
|
|
221
224
|
{/* Display Text */}
|
|
222
|
-
<span className="text-body1 truncate">
|
|
225
|
+
<span id={valueId} className="text-body1 truncate">
|
|
223
226
|
{getDisplayLabel()}
|
|
224
227
|
</span>
|
|
225
228
|
</div>
|
|
@@ -11,7 +11,7 @@ interface StatTileProps {
|
|
|
11
11
|
currency?: string;
|
|
12
12
|
/** What is counted, e.g. "responses", set after the number. */
|
|
13
13
|
unit?: string;
|
|
14
|
-
/** The value for the period before, in the same unit. Gives the change line; without it there is none. */
|
|
14
|
+
/** The value for the period before, in the same unit. Gives the change line; without it there is none. For `percent` it is a fraction too, and the change reads in points ('Up 3 pts from last week'), which a screen reader hears as 'percentage points'. */
|
|
15
15
|
previous?: number | null;
|
|
16
16
|
/** The period `previous` is from. Defaults to week. */
|
|
17
17
|
period?: ChangePeriod;
|
|
@@ -36,7 +36,9 @@ export default function StatTile(_a) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
var compact = shown !== null && exact !== null && shown !== exact;
|
|
39
|
-
var change = loading ? null : formatChange(value, previous, period);
|
|
39
|
+
var change = loading ? null : formatChange(value, previous, period, { as: format === 'percent' ? 'points' : 'relative' });
|
|
40
|
+
// The tile shows 'pts', which a screen reader may spell out, so it hears 'percentage points' in words
|
|
41
|
+
var spoken = change === null || change === void 0 ? void 0 : change.text.replace(/ (pts?) /, function (_, pts) { return (pts === 'pt' ? ' percentage point ' : ' percentage points '); });
|
|
40
42
|
return (<dl id={id} aria-busy={loading || undefined} className="flex min-w-0 flex-col gap-1">
|
|
41
43
|
<dt className="text-caption text-fg-secondary">{label}</dt>
|
|
42
44
|
<dd className={"flex items-center ".concat(valueLine)}>
|
|
@@ -54,7 +56,10 @@ export default function StatTile(_a) {
|
|
|
54
56
|
change.direction !== null && (<dd className="m-0 flex items-center gap-1 text-body2 text-fg-secondary">
|
|
55
57
|
{change.direction === 'up' && <ArrowUp aria-hidden="true" className="size-4 shrink-0"/>}
|
|
56
58
|
{change.direction === 'down' && <ArrowDown aria-hidden="true" className="size-4 shrink-0"/>}
|
|
57
|
-
{change.text
|
|
59
|
+
{format === 'percent' && spoken !== change.text ? (<>
|
|
60
|
+
<span aria-hidden="true">{change.text}</span>
|
|
61
|
+
<span className="sr-only">{spoken}</span>
|
|
62
|
+
</>) : (change.text)}
|
|
58
63
|
</dd>))}
|
|
59
64
|
{caption && <dd className="m-0 text-body2 text-fg-secondary">{caption}</dd>}
|
|
60
65
|
</dl>);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface TableCellProps {
|
|
2
|
+
export interface TableCellProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
width?: string;
|
|
5
5
|
minWidth?: string;
|
|
6
6
|
align?: 'left' | 'center' | 'right';
|
|
7
|
+
/** Makes the cell its row's header, such as a feature name in the first column of a comparison: `role="rowheader"` in place of `role="cell"`. A screen reader then reads it with each cell of the row. */
|
|
8
|
+
rowHeader?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export default function TableCell({ children, width, minWidth, align }: TableCellProps): React.JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
+
export default function TableCell({ children, width, minWidth, align, rowHeader }: TableCellProps): React.JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export default function TableCell(_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, _c = _a.rowHeader, rowHeader = _c === void 0 ? false : _c;
|
|
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=
|
|
8
|
+
return (<div role={rowHeader ? 'rowheader' : 'cell'} className={"".concat(flexClass, " p-2 text-body2 text-fg-primary border-t border-misc-divider ").concat(alignClass)} style={widthStyle}>
|
|
9
9
|
{children}
|
|
10
10
|
</div>);
|
|
11
11
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TimelineItem {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** The time as the caller wrote it ('Nov 16, 2026, 2:40 PM'), so the server and the browser print the same */
|
|
6
|
+
when: string;
|
|
7
|
+
/** The ISO value for `<time dateTime>` */
|
|
8
|
+
dateTime: string;
|
|
9
|
+
/** Who did it. `agent` shows the agent face and no picture. */
|
|
10
|
+
actor?: {
|
|
11
|
+
name: string;
|
|
12
|
+
imageUrl?: string;
|
|
13
|
+
agent?: boolean;
|
|
14
|
+
};
|
|
15
|
+
detail?: string;
|
|
16
|
+
/** Makes the title a link. Ignored with `onSelect`: the row is a button then, and a link cannot sit in a button. */
|
|
17
|
+
href?: string;
|
|
18
|
+
tag?: {
|
|
19
|
+
label: string;
|
|
20
|
+
color?: 'info' | 'warning' | 'error' | 'success';
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface TimelineProps {
|
|
24
|
+
items: TimelineItem[];
|
|
25
|
+
'aria-label'?: string;
|
|
26
|
+
/** The row marked `aria-current="true"`, with the selected fill. Only with `onSelect`. */
|
|
27
|
+
selectedId?: string;
|
|
28
|
+
/** Makes each row one button that calls this with the row's id */
|
|
29
|
+
onSelect?: (id: string) => void;
|
|
30
|
+
id?: string;
|
|
31
|
+
}
|
|
32
|
+
export default function Timeline({ items, 'aria-label': ariaLabel, selectedId, onSelect, id }: TimelineProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Bot } from 'lucide-react';
|
|
4
|
+
import UserImage from './userImage';
|
|
5
|
+
import Tag from './tag';
|
|
6
|
+
import Link from './link';
|
|
7
|
+
import { focusRing, stateTransition } from './sharedStyles';
|
|
8
|
+
// A history or an activity feed: who did what, and when. An ordered list in the caller's order
|
|
9
|
+
// (newest first). Each row has a dot level with the title's first line and a line down to the next
|
|
10
|
+
// row; the last row has no line. The dot is the same for every row, so color carries nothing.
|
|
11
|
+
// With `onSelect` each row is one button and every row is a tab stop: a history is read top to
|
|
12
|
+
// bottom, not moved through, so there is no roving focus. Empty `items` renders nothing; the caller
|
|
13
|
+
// shows `EmptyBox`. Not a `StepList`: a step list is a plan's status, a timeline has actors and times.
|
|
14
|
+
export default function Timeline(_a) {
|
|
15
|
+
var items = _a.items, ariaLabel = _a["aria-label"], selectedId = _a.selectedId, onSelect = _a.onSelect, id = _a.id;
|
|
16
|
+
if (items.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
var selectable = !!onSelect;
|
|
19
|
+
return (<ol role="list" id={id} aria-label={ariaLabel} className="flex flex-col">
|
|
20
|
+
{items.map(function (item, i) {
|
|
21
|
+
var last = i === items.length - 1;
|
|
22
|
+
var selected = selectable && item.id === selectedId;
|
|
23
|
+
var title = (<span className="break-words text-body1 text-fg-primary">
|
|
24
|
+
{item.href && !selectable ? <Link href={item.href}>{item.title}</Link> : item.title}
|
|
25
|
+
</span>);
|
|
26
|
+
var body = (<>
|
|
27
|
+
{title}
|
|
28
|
+
<span className="flex flex-wrap items-center gap-small text-body2 text-fg-secondary">
|
|
29
|
+
{item.actor && (<>
|
|
30
|
+
<UserImage decorative size={20} userHandle={item.actor.name} userImgUrl={item.actor.agent ? undefined : item.actor.imageUrl} icon={item.actor.agent ? Bot : undefined}/>
|
|
31
|
+
<span>{item.actor.name}</span>
|
|
32
|
+
<span aria-hidden="true"> · </span>
|
|
33
|
+
</>)}
|
|
34
|
+
<time dateTime={item.dateTime}>{item.when}</time>
|
|
35
|
+
</span>
|
|
36
|
+
{item.detail && <span className="break-words text-body2 text-fg-secondary">{item.detail}</span>}
|
|
37
|
+
{item.tag && (<span className="flex pt-small">
|
|
38
|
+
<Tag variant="dot" size="small" color={item.tag.color} label={item.tag.label}/>
|
|
39
|
+
</span>)}
|
|
40
|
+
</>);
|
|
41
|
+
return (<li key={item.id} className={"flex gap-small ".concat(last ? '' : 'pb-medium')}>
|
|
42
|
+
<span aria-hidden="true" className={"flex w-6 flex-shrink-0 flex-col items-center ".concat(selectable ? 'pt-small' : '', " ").concat(last ? '' : '-mb-medium')}>
|
|
43
|
+
<span className="flex h-6 items-center justify-center">
|
|
44
|
+
<span className="w-2.5 h-2.5 rounded-full bg-fg-secondary"/>
|
|
45
|
+
</span>
|
|
46
|
+
{!last && <span className="w-px flex-1 bg-misc-divider"/>}
|
|
47
|
+
</span>
|
|
48
|
+
{selectable ? (<button type="button" aria-current={selected ? 'true' : undefined} onClick={function () { return onSelect(item.id); }} className={"flex min-w-0 flex-1 w-full flex-col text-left px-medium py-small rounded-control cursor-pointer ".concat(selected ? 'bg-background-accent200' : 'hover:bg-background-accent100', " ").concat(stateTransition, " ").concat(focusRing)}>
|
|
49
|
+
{body}
|
|
50
|
+
</button>) : (<span className="flex min-w-0 flex-1 flex-col">{body}</span>)}
|
|
51
|
+
</li>);
|
|
52
|
+
})}
|
|
53
|
+
</ol>);
|
|
54
|
+
}
|
|
@@ -12,8 +12,10 @@ interface TitleBarProps {
|
|
|
12
12
|
actionsBelow?: boolean;
|
|
13
13
|
/** Below md these replace `actions`: the main action and a More menu holding the rest */
|
|
14
14
|
phoneActions?: React.ReactNode;
|
|
15
|
+
/** One line under the title: a status Tag, an AvatarStack, short facts. It wraps at every width and is not part of the heading. */
|
|
16
|
+
meta?: React.ReactNode;
|
|
15
17
|
/** The heading's id */
|
|
16
18
|
id?: string;
|
|
17
19
|
}
|
|
18
|
-
export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, id }: TitleBarProps): React.JSX.Element;
|
|
20
|
+
export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, meta, id }: TitleBarProps): React.JSX.Element;
|
|
19
21
|
export { TitleBar };
|
|
@@ -4,13 +4,18 @@ 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, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, id = _a.id;
|
|
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, meta = _a.meta, id = _a.id;
|
|
8
8
|
var below = actionsBelow && !phoneActions;
|
|
9
9
|
return (<div className={"flex min-w-0 items-center gap-2".concat(back || below ? ' flex-wrap md:flex-nowrap' : '')}>
|
|
10
10
|
{back && <div className="flex shrink-0 basis-full items-center md:basis-auto">{back}</div>}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
{meta ? (<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
12
|
+
<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 break-words outline-none">
|
|
13
|
+
{title}
|
|
14
|
+
</Heading>
|
|
15
|
+
<div className="flex flex-wrap items-center gap-small text-body2 text-fg-secondary">{meta}</div>
|
|
16
|
+
</div>) : (<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
|
|
17
|
+
{title}
|
|
18
|
+
</Heading>)}
|
|
14
19
|
{actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
|
|
15
20
|
{phoneActions && <div className="flex shrink-0 items-center gap-2 md:hidden">{phoneActions}</div>}
|
|
16
21
|
</div>);
|
|
@@ -21,9 +21,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
21
21
|
};
|
|
22
22
|
import React, { useEffect, useReducer, useRef, useState, useSyncExternalStore } from 'react';
|
|
23
23
|
import Alert from './alert';
|
|
24
|
-
import { addToast, removeToast, visibleToasts, pauseReducer, isPaused } from '../internal/toaster';
|
|
24
|
+
import { addToast, removeToast, visibleToasts, pauseReducer, isPaused, announcementText, liveRegionFor } from '../internal/toaster';
|
|
25
25
|
// Matches Alert's exit transition
|
|
26
26
|
var EXIT_MS = 150;
|
|
27
|
+
// The announcer writes one toast per tick, so a screen reader hears each one in a burst
|
|
28
|
+
var ANNOUNCE_EVERY_MS = 150;
|
|
29
|
+
// An announced text leaves its region, so a reader browsing the page later does not find it
|
|
30
|
+
var ANNOUNCE_CLEAR_MS = 5000;
|
|
27
31
|
var store = { toasts: [], mounts: [] };
|
|
28
32
|
var serverStore = { toasts: [], mounts: [] };
|
|
29
33
|
var listeners = new Set();
|
|
@@ -78,26 +82,92 @@ function Toast(_a) {
|
|
|
78
82
|
// Focus moving to another element inside the same toast has not left it
|
|
79
83
|
onBlur={function (e) { if (!e.currentTarget.contains(e.relatedTarget))
|
|
80
84
|
dispatch('blur'); }}>
|
|
81
|
-
<Alert variant="inline" showCloseButton autoDismiss={false} open={open} type={item.type} message={item.message} secondMessage={item.secondMessage}
|
|
85
|
+
<Alert variant="inline" showCloseButton autoDismiss={false} open={open} type={item.type} message={item.message} secondMessage={item.secondMessage}
|
|
86
|
+
// The Toaster's live regions announce it; a role here would make it heard twice
|
|
87
|
+
announce={false} onClose={function () { return dismissToast(item.id); }}/>
|
|
82
88
|
</div>);
|
|
83
89
|
}
|
|
84
90
|
// Mount once near the app root. A second Toaster renders nothing.
|
|
85
91
|
export default function Toaster() {
|
|
86
92
|
var _a = useSyncExternalStore(subscribe, function () { return store; }, function () { return serverStore; }), toasts = _a.toasts, mounts = _a.mounts;
|
|
87
93
|
var me = useState(function () { return Symbol('Toaster'); })[0];
|
|
94
|
+
var first = mounts[0] === me;
|
|
95
|
+
// The live regions are in the page before any text goes in, since a region that arrives filled is often not read
|
|
96
|
+
var polite = useRef(null);
|
|
97
|
+
var assertive = useRef(null);
|
|
98
|
+
var seen = useRef(new Set());
|
|
99
|
+
var queue = useRef([]);
|
|
100
|
+
// The tick runs only while toasts wait to be announced, so a page with no toast starts no timer
|
|
101
|
+
var tickRef = useRef(null);
|
|
102
|
+
var frame = useRef(null);
|
|
103
|
+
var clearTimers = useRef({});
|
|
88
104
|
useEffect(function () {
|
|
89
105
|
setStore(__assign(__assign({}, store), { mounts: __spreadArray(__spreadArray([], store.mounts, true), [me], false) }));
|
|
90
106
|
return function () { return setStore(__assign(__assign({}, store), { mounts: store.mounts.filter(function (m) { return m !== me; }) })); };
|
|
91
107
|
}, [me]);
|
|
92
|
-
|
|
108
|
+
// Each tick: empty the next toast's region, then write its text on the next frame, so the same text twice is heard twice
|
|
109
|
+
var tick = function () {
|
|
110
|
+
if (frame.current !== null)
|
|
111
|
+
return;
|
|
112
|
+
var next = queue.current[0];
|
|
113
|
+
if (!next) {
|
|
114
|
+
clearInterval(tickRef.current);
|
|
115
|
+
tickRef.current = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var el = (next.region === 'assertive' ? assertive : polite).current;
|
|
119
|
+
if (!el)
|
|
120
|
+
return;
|
|
121
|
+
queue.current.shift();
|
|
122
|
+
el.textContent = '';
|
|
123
|
+
frame.current = requestAnimationFrame(function () {
|
|
124
|
+
frame.current = null;
|
|
125
|
+
el.textContent = next.text;
|
|
126
|
+
clearTimeout(clearTimers.current[next.region]);
|
|
127
|
+
clearTimers.current[next.region] = setTimeout(function () { el.textContent = ''; }, ANNOUNCE_CLEAR_MS);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
// Each new toast is queued once, oldest first; a dismissed toast does not change the queue
|
|
131
|
+
useEffect(function () {
|
|
132
|
+
var _a;
|
|
133
|
+
var fresh = toasts.filter(function (t) { return !seen.current.has(t.id); }).reverse();
|
|
134
|
+
seen.current = new Set(toasts.map(function (t) { return t.id; }));
|
|
135
|
+
// Another Toaster announces
|
|
136
|
+
if (mounts.length > 0 && !first) {
|
|
137
|
+
queue.current = [];
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
(_a = queue.current).push.apply(_a, fresh.map(function (t) { return ({ text: announcementText(t), region: liveRegionFor(t.type) }); }));
|
|
141
|
+
if (first && queue.current.length > 0 && tickRef.current === null)
|
|
142
|
+
tickRef.current = setInterval(tick, ANNOUNCE_EVERY_MS);
|
|
143
|
+
}, [toasts, mounts, first]);
|
|
144
|
+
// Stop everything when this Toaster stops announcing or unmounts
|
|
145
|
+
useEffect(function () {
|
|
146
|
+
if (!first)
|
|
147
|
+
return;
|
|
148
|
+
return function () {
|
|
149
|
+
if (tickRef.current !== null)
|
|
150
|
+
clearInterval(tickRef.current);
|
|
151
|
+
tickRef.current = null;
|
|
152
|
+
if (frame.current !== null)
|
|
153
|
+
cancelAnimationFrame(frame.current);
|
|
154
|
+
frame.current = null;
|
|
155
|
+
Object.values(clearTimers.current).forEach(clearTimeout);
|
|
156
|
+
clearTimers.current = {};
|
|
157
|
+
};
|
|
158
|
+
}, [first]);
|
|
159
|
+
if (!first)
|
|
93
160
|
return null;
|
|
94
161
|
var shown = visibleToasts(toasts);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
162
|
+
return (<>
|
|
163
|
+
<div ref={polite} className="sr-only" role="status" aria-live="polite" aria-atomic="true"/>
|
|
164
|
+
<div ref={assertive} className="sr-only" role="alert" aria-live="assertive" aria-atomic="true"/>
|
|
165
|
+
{shown.length > 0 && (
|
|
166
|
+
// Above modals; the column lets clicks through beside and between the toasts
|
|
167
|
+
<div className="fixed top-4 inset-x-0 z-[var(--os-z-tooltip)] flex justify-center px-4 pointer-events-none">
|
|
168
|
+
<div className="flex flex-col gap-2 w-full max-w-md">
|
|
169
|
+
{shown.map(function (item) { return <Toast key={item.id} item={item}/>; })}
|
|
170
|
+
</div>
|
|
171
|
+
</div>)}
|
|
172
|
+
</>);
|
|
103
173
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './components/iconButton';
|
|
|
14
14
|
export * from './components/layout';
|
|
15
15
|
export * from './components/lightbox';
|
|
16
16
|
export * from './components/loadingScreen';
|
|
17
|
+
export * from './components/markdown';
|
|
17
18
|
export * from './components/menu';
|
|
18
19
|
export * from './components/menuItem';
|
|
19
20
|
export * from './components/modal';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './components/iconButton';
|
|
|
14
14
|
export * from './components/layout';
|
|
15
15
|
export * from './components/lightbox';
|
|
16
16
|
export * from './components/loadingScreen';
|
|
17
|
+
export * from './components/markdown';
|
|
17
18
|
export * from './components/menu';
|
|
18
19
|
export * from './components/menuItem';
|
|
19
20
|
export * from './components/modal';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type ChartFormat = 'count' | 'money';
|
|
2
|
+
/**
|
|
3
|
+
* The y ticks from 0: round steps of 1, 2, 2.5 or 5 × 10ⁿ, the last tick at or above `max`, 3 to 5 ticks.
|
|
4
|
+
* `max` 0 (or below, or not a number) gives `[0, 1]`. With `integer` (counts) the step is a whole number of
|
|
5
|
+
* at least 1, so max 1 gives `[0, 1]`, max 2 `[0, 1, 2]` and max 10 `[0, 5, 10]`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function niceTicks(max: number, count?: number, { integer }?: {
|
|
8
|
+
integer?: boolean;
|
|
9
|
+
}): number[];
|
|
10
|
+
/**
|
|
11
|
+
* The indexes of the x labels to print: the first, the last and every `ceil(n / most)`th. When the run
|
|
12
|
+
* misses the last, the last replaces the run's final label: it is right-aligned and takes up to a step of
|
|
13
|
+
* room, so beside a label less than a step away it would always overlap.
|
|
14
|
+
*/
|
|
15
|
+
export declare function labelEvery(n: number, most?: number): number[];
|
|
16
|
+
/**
|
|
17
|
+
* The point a key moves to: Left and Right by one with no wrap, Home the first, End the last. Any other key
|
|
18
|
+
* keeps `current`. `current` -1 is no point yet: Right and Home start at the first, Left and End at the last.
|
|
19
|
+
*/
|
|
20
|
+
export declare function nextPoint(key: string, current: number, count: number): number;
|
|
21
|
+
/** The x of point `i` of `n` in a 0 to 100 box. One point sits in the middle. */
|
|
22
|
+
export declare const pointX: (i: number, n: number) => number;
|
|
23
|
+
/**
|
|
24
|
+
* An SVG `d` in a 0 to 100 box, 0 at the bottom and `top` at the top. Each run of values starts with `M`, so a
|
|
25
|
+
* `null` breaks the line. The axis starts at 0, so a value below 0 is drawn at 0 and never below the plot.
|
|
26
|
+
*/
|
|
27
|
+
export declare function linePath(values: (number | null)[], top: number): string;
|
|
28
|
+
/** A tick: compact from 10,000 up ('12.4K', '$12.4K'), else exact. */
|
|
29
|
+
export declare function axisText(n: number, format?: ChartFormat): string;
|
|
30
|
+
/** The exact value with its unit, for the readout and the table: '1,234,567 comments', '$18.40', 'No data'. */
|
|
31
|
+
export declare function exactText(n: number | null, format?: ChartFormat, unit?: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* A point of named series in words, each value's exact text before its name: 'Nov 14: 58 opened, 41 done'.
|
|
34
|
+
* A gap in one series reads 'No data for done'; a point with no value in any series reads 'Nov 14: No data'.
|
|
35
|
+
*/
|
|
36
|
+
export declare function seriesReadout(label: string, points: {
|
|
37
|
+
name: string;
|
|
38
|
+
value: number | null;
|
|
39
|
+
}[], format?: ChartFormat, unit?: string): string;
|