@slashsuite/ui-react 0.0.0-stage → 0.11.3
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/LICENSE +21 -0
- package/MIGRATING.md +540 -0
- package/README.md +548 -2
- package/dist/AppShell.d.ts +127 -0
- package/dist/AppShell.js +119 -0
- package/dist/AppShellMenu.d.ts +26 -0
- package/dist/AppShellMenu.js +66 -0
- package/dist/Avatar.d.ts +75 -0
- package/dist/Avatar.js +95 -0
- package/dist/AvatarStack.d.ts +31 -0
- package/dist/AvatarStack.js +34 -0
- package/dist/Badge.d.ts +15 -0
- package/dist/Badge.js +15 -0
- package/dist/BottomSheet.d.ts +36 -0
- package/dist/BottomSheet.js +142 -0
- package/dist/Breadcrumbs.d.ts +27 -0
- package/dist/Breadcrumbs.js +29 -0
- package/dist/BulletList.d.ts +18 -0
- package/dist/BulletList.js +18 -0
- package/dist/Button.d.ts +121 -0
- package/dist/Button.js +182 -0
- package/dist/ButtonGroup.d.ts +15 -0
- package/dist/ButtonGroup.js +10 -0
- package/dist/Callout.d.ts +43 -0
- package/dist/Callout.js +45 -0
- package/dist/Card.d.ts +148 -0
- package/dist/Card.js +171 -0
- package/dist/CardBadge.d.ts +7 -0
- package/dist/CardBadge.js +12 -0
- package/dist/CardBody.d.ts +28 -0
- package/dist/CardBody.js +30 -0
- package/dist/CardGrid.d.ts +53 -0
- package/dist/CardGrid.js +52 -0
- package/dist/CardParts.d.ts +40 -0
- package/dist/CardParts.js +41 -0
- package/dist/ChatComposer.d.ts +35 -0
- package/dist/ChatComposer.js +50 -0
- package/dist/ChatMessage.d.ts +26 -0
- package/dist/ChatMessage.js +21 -0
- package/dist/ChatThread.d.ts +25 -0
- package/dist/ChatThread.js +60 -0
- package/dist/Checkbox.d.ts +42 -0
- package/dist/Checkbox.js +63 -0
- package/dist/Chevron.d.ts +5 -0
- package/dist/Chevron.js +6 -0
- package/dist/Cluster.d.ts +70 -0
- package/dist/Cluster.js +47 -0
- package/dist/Code.d.ts +6 -0
- package/dist/Code.js +5 -0
- package/dist/CodeBlock.d.ts +46 -0
- package/dist/CodeBlock.js +21 -0
- package/dist/CodeBody.d.ts +20 -0
- package/dist/CodeBody.js +38 -0
- package/dist/CodeExample.d.ts +25 -0
- package/dist/CodeExample.js +17 -0
- package/dist/CodeText.d.ts +11 -0
- package/dist/CodeText.js +64 -0
- package/dist/ColourSchemeToggle.d.ts +36 -0
- package/dist/ColourSchemeToggle.js +64 -0
- package/dist/Container.d.ts +22 -0
- package/dist/Container.js +26 -0
- package/dist/CopyButton.d.ts +17 -0
- package/dist/CopyButton.js +39 -0
- package/dist/CopyLine.d.ts +9 -0
- package/dist/CopyLine.js +7 -0
- package/dist/DateCalendar.d.ts +23 -0
- package/dist/DateCalendar.js +89 -0
- package/dist/DateField.d.ts +124 -0
- package/dist/DateField.js +111 -0
- package/dist/DateFieldCalendar.d.ts +24 -0
- package/dist/DateFieldCalendar.js +50 -0
- package/dist/DateRangePicker.d.ts +47 -0
- package/dist/DateRangePicker.js +44 -0
- package/dist/Dialog.d.ts +56 -0
- package/dist/Dialog.js +94 -0
- package/dist/Disclosure.d.ts +29 -0
- package/dist/Disclosure.js +23 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +5 -0
- package/dist/DocsLayout.d.ts +69 -0
- package/dist/DocsLayout.js +64 -0
- package/dist/Drawer.d.ts +30 -0
- package/dist/Drawer.js +24 -0
- package/dist/EmptyState.d.ts +47 -0
- package/dist/EmptyState.js +34 -0
- package/dist/Field.d.ts +44 -0
- package/dist/Field.js +51 -0
- package/dist/FieldDialog.d.ts +26 -0
- package/dist/FieldDialog.js +31 -0
- package/dist/Fieldset.d.ts +21 -0
- package/dist/Fieldset.js +22 -0
- package/dist/FileDrop.d.ts +17 -0
- package/dist/FileDrop.js +14 -0
- package/dist/FormRow.d.ts +46 -0
- package/dist/FormRow.js +39 -0
- package/dist/Hero.d.ts +23 -0
- package/dist/Hero.js +28 -0
- package/dist/Icon.d.ts +40 -0
- package/dist/Icon.js +30 -0
- package/dist/IconButton.d.ts +72 -0
- package/dist/IconButton.js +65 -0
- package/dist/Image.d.ts +58 -0
- package/dist/Image.js +69 -0
- package/dist/InlineEdit.d.ts +22 -0
- package/dist/InlineEdit.js +60 -0
- package/dist/Input.d.ts +40 -0
- package/dist/Input.js +42 -0
- package/dist/InputShell.d.ts +24 -0
- package/dist/InputShell.js +40 -0
- package/dist/Kbd.d.ts +6 -0
- package/dist/Kbd.js +5 -0
- package/dist/KeyValueList.d.ts +34 -0
- package/dist/KeyValueList.js +35 -0
- package/dist/Lightbox.d.ts +45 -0
- package/dist/Lightbox.js +46 -0
- package/dist/ListRow.d.ts +26 -0
- package/dist/ListRow.js +151 -0
- package/dist/Markdown.d.ts +11 -0
- package/dist/Markdown.js +49 -0
- package/dist/MediaTile.d.ts +66 -0
- package/dist/MediaTile.js +50 -0
- package/dist/Menu.d.ts +64 -0
- package/dist/Menu.js +86 -0
- package/dist/MetaList.d.ts +23 -0
- package/dist/MetaList.js +20 -0
- package/dist/Morph.d.ts +41 -0
- package/dist/Morph.js +107 -0
- package/dist/NavigationProgress.d.ts +20 -0
- package/dist/NavigationProgress.js +26 -0
- package/dist/OutlineRegion.d.ts +60 -0
- package/dist/OutlineRegion.js +51 -0
- package/dist/PageFade.d.ts +30 -0
- package/dist/PageFade.js +46 -0
- package/dist/PageHeader.d.ts +26 -0
- package/dist/PageHeader.js +18 -0
- package/dist/PageLayouts.d.ts +100 -0
- package/dist/PageLayouts.js +78 -0
- package/dist/Pagination.d.ts +38 -0
- package/dist/Pagination.js +65 -0
- package/dist/Pill.d.ts +79 -0
- package/dist/Pill.js +121 -0
- package/dist/ProgressBar.d.ts +47 -0
- package/dist/ProgressBar.js +47 -0
- package/dist/RadioGroup.d.ts +55 -0
- package/dist/RadioGroup.js +53 -0
- package/dist/ScrollStrip.d.ts +21 -0
- package/dist/ScrollStrip.js +12 -0
- package/dist/SearchInput.d.ts +9 -0
- package/dist/SearchInput.js +55 -0
- package/dist/Section.d.ts +93 -0
- package/dist/Section.js +55 -0
- package/dist/SegmentedControl.d.ts +47 -0
- package/dist/SegmentedControl.js +78 -0
- package/dist/Select.d.ts +28 -0
- package/dist/Select.js +19 -0
- package/dist/Show.d.ts +33 -0
- package/dist/Show.js +27 -0
- package/dist/SideColumn.d.ts +50 -0
- package/dist/SideColumn.js +45 -0
- package/dist/SidebarLayout.d.ts +32 -0
- package/dist/SidebarLayout.js +77 -0
- package/dist/SiteFooter.d.ts +31 -0
- package/dist/SiteFooter.js +24 -0
- package/dist/SiteSearch.d.ts +40 -0
- package/dist/SiteSearch.js +150 -0
- package/dist/SortableList.d.ts +86 -0
- package/dist/SortableList.js +191 -0
- package/dist/SplitBar.d.ts +29 -0
- package/dist/SplitBar.js +22 -0
- package/dist/Stack.d.ts +114 -0
- package/dist/Stack.js +76 -0
- package/dist/StackedBar.d.ts +64 -0
- package/dist/StackedBar.js +58 -0
- package/dist/StatTile.d.ts +33 -0
- package/dist/StatTile.js +44 -0
- package/dist/StatusPages.d.ts +49 -0
- package/dist/StatusPages.js +63 -0
- package/dist/Steps.d.ts +29 -0
- package/dist/Steps.js +43 -0
- package/dist/StickyBar.d.ts +12 -0
- package/dist/StickyBar.js +10 -0
- package/dist/Switch.d.ts +56 -0
- package/dist/Switch.js +91 -0
- package/dist/Table.d.ts +92 -0
- package/dist/Table.js +92 -0
- package/dist/TableCells.d.ts +97 -0
- package/dist/TableCells.js +104 -0
- package/dist/TableEditCell.d.ts +31 -0
- package/dist/TableEditCell.js +17 -0
- package/dist/TableExpandCell.d.ts +25 -0
- package/dist/TableExpandCell.js +15 -0
- package/dist/Tabs.d.ts +38 -0
- package/dist/Tabs.js +46 -0
- package/dist/TextLink.d.ts +51 -0
- package/dist/TextLink.js +38 -0
- package/dist/Textarea.d.ts +11 -0
- package/dist/Textarea.js +11 -0
- package/dist/Timeline.d.ts +31 -0
- package/dist/Timeline.js +38 -0
- package/dist/ToastRegion.d.ts +44 -0
- package/dist/ToastRegion.js +37 -0
- package/dist/Tooltip.d.ts +46 -0
- package/dist/Tooltip.js +181 -0
- package/dist/TrendChart.d.ts +36 -0
- package/dist/TrendChart.js +58 -0
- package/dist/Video.d.ts +13 -0
- package/dist/Video.js +9 -0
- package/dist/blocked.d.ts +31 -0
- package/dist/blocked.js +31 -0
- package/dist/cardContext.d.ts +8 -0
- package/dist/cardContext.js +14 -0
- package/dist/cardWait.d.ts +13 -0
- package/dist/cardWait.js +16 -0
- package/dist/colourScheme.d.ts +22 -0
- package/dist/colourScheme.js +53 -0
- package/dist/control.d.ts +29 -0
- package/dist/control.js +37 -0
- package/dist/copyScript.d.ts +13 -0
- package/dist/copyScript.js +13 -0
- package/dist/cx.d.ts +19 -0
- package/dist/cx.js +21 -0
- package/dist/density.d.ts +38 -0
- package/dist/density.js +77 -0
- package/dist/emptySlot.d.ts +11 -0
- package/dist/emptySlot.js +16 -0
- package/dist/fieldControl.d.ts +23 -0
- package/dist/fieldControl.js +24 -0
- package/dist/fieldWait.d.ts +30 -0
- package/dist/fieldWait.js +27 -0
- package/dist/foldedColumn.d.ts +18 -0
- package/dist/foldedColumn.js +51 -0
- package/dist/headingLevel.d.ts +10 -0
- package/dist/headingLevel.js +18 -0
- package/dist/highlight.d.ts +18 -0
- package/dist/highlight.js +306 -0
- package/dist/highlightConsole.d.ts +9 -0
- package/dist/highlightConsole.js +42 -0
- package/dist/highlightHtml.d.ts +7 -0
- package/dist/highlightHtml.js +132 -0
- package/dist/highlightKit.d.ts +16 -0
- package/dist/highlightKit.js +23 -0
- package/dist/highlightYaml.d.ts +3 -0
- package/dist/highlightYaml.js +143 -0
- package/dist/icons.d.ts +16 -0
- package/dist/icons.js +108 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +92 -0
- package/dist/isoDate.d.ts +5 -0
- package/dist/isoDate.js +16 -0
- package/dist/labelWords.d.ts +20 -0
- package/dist/labelWords.js +28 -0
- package/dist/layoutWait.d.ts +15 -0
- package/dist/layoutWait.js +18 -0
- package/dist/link.d.ts +82 -0
- package/dist/link.js +68 -0
- package/dist/listRowProps.d.ts +108 -0
- package/dist/listRowProps.js +1 -0
- package/dist/listRowWait.d.ts +6 -0
- package/dist/listRowWait.js +14 -0
- package/dist/modal.d.ts +25 -0
- package/dist/modal.js +61 -0
- package/dist/navFold.d.ts +15 -0
- package/dist/navFold.js +46 -0
- package/dist/pillTip.d.ts +8 -0
- package/dist/pillTip.js +25 -0
- package/dist/props.d.ts +26 -0
- package/dist/props.js +14 -0
- package/dist/scrollEdges.d.ts +12 -0
- package/dist/scrollEdges.js +40 -0
- package/dist/scrollStop.d.ts +32 -0
- package/dist/scrollStop.js +79 -0
- package/dist/sheetSnap.d.ts +27 -0
- package/dist/sheetSnap.js +45 -0
- package/dist/shownDate.d.ts +88 -0
- package/dist/shownDate.js +186 -0
- package/dist/size.d.ts +45 -0
- package/dist/size.js +12 -0
- package/dist/skeleton.d.ts +83 -0
- package/dist/skeleton.js +88 -0
- package/dist/stackGap.d.ts +9 -0
- package/dist/stackGap.js +16 -0
- package/dist/stickyColumn.d.ts +38 -0
- package/dist/stickyColumn.js +38 -0
- package/dist/switcher.d.ts +93 -0
- package/dist/switcher.js +78 -0
- package/dist/tableColumns.d.ts +31 -0
- package/dist/tableColumns.js +72 -0
- package/dist/tableEmpty.d.ts +15 -0
- package/dist/tableEmpty.js +26 -0
- package/dist/tableRow.d.ts +67 -0
- package/dist/tableRow.js +49 -0
- package/dist/tableSort.d.ts +22 -0
- package/dist/tableSort.js +19 -0
- package/dist/textBox.d.ts +10 -0
- package/dist/textBox.js +23 -0
- package/dist/tone.d.ts +11 -0
- package/dist/tone.js +1 -0
- package/dist/trend.d.ts +26 -0
- package/dist/trend.js +64 -0
- package/dist/typography.d.ts +203 -0
- package/dist/typography.js +242 -0
- package/dist/useImageFailed.d.ts +19 -0
- package/dist/useImageFailed.js +21 -0
- package/package.json +84 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { cx, focusRing } from "./cx.js";
|
|
4
|
+
import { FoldedColumn } from "./foldedColumn.js";
|
|
5
|
+
import { renderLink } from "./link.js";
|
|
6
|
+
import { PageHeaderContent } from "./PageHeader.js";
|
|
7
|
+
import { useScrollEdges } from "./scrollEdges.js";
|
|
8
|
+
import { SidebarLayout } from "./SidebarLayout.js";
|
|
9
|
+
import { Stack } from "./Stack.js";
|
|
10
|
+
import { STICKY_ASIDE_XL, STICKY_FADE_XL, STICKY_SCROLL_XL } from "./stickyColumn.js";
|
|
11
|
+
import { Tabs } from "./Tabs.js";
|
|
12
|
+
import { Overline } from "./typography.js";
|
|
13
|
+
/** The rail: each group's title over a vertical list of its pages, the groups `md` apart. */
|
|
14
|
+
function DocsNav({ nav, navLabel }) {
|
|
15
|
+
return (_jsx(Stack, { gap: "md", children: nav.map((group, index) => (_jsxs(Stack, { gap: "xs", children: [group.title !== undefined && _jsx(Overline, { children: group.title }), _jsx(Tabs, { orientation: "vertical", size: "sm", label: group.title ?? navLabel, items: group.items })] }, group.title ?? `group-${index}`))) }));
|
|
16
|
+
}
|
|
17
|
+
const ENTRY = `rounded text-sm/6 transition ${focusRing}`;
|
|
18
|
+
const ENTRY_ON = "font-medium text-violet-700";
|
|
19
|
+
const ENTRY_OFF = "text-slate-600 hover:text-violet-700";
|
|
20
|
+
/**
|
|
21
|
+
* "On this page": one `<nav>` at every width. From `xl` a 12rem column right of the article that
|
|
22
|
+
* sticks under the header and scrolls itself when it is taller than the screen; below `xl` the same
|
|
23
|
+
* element folds behind a closed disclosure named `label`, above the article.
|
|
24
|
+
*/
|
|
25
|
+
function DocsContents({ contents, current, label, }) {
|
|
26
|
+
const [scroller, setScroller] = useState(null);
|
|
27
|
+
useScrollEdges(scroller, "y");
|
|
28
|
+
return (_jsx("nav", { "aria-label": label, className: cx("xl:col-start-2 xl:row-span-2 xl:row-start-1", STICKY_ASIDE_XL), children: _jsx("div", { ref: setScroller, className: cx(STICKY_SCROLL_XL, STICKY_FADE_XL), children: _jsxs(FoldedColumn, { from: "xl", label: label, children: [_jsx("div", { className: "hidden pb-2 xl:block", children: _jsx(Overline, { children: label }) }), _jsx("ul", { className: "flex flex-col gap-1", children: contents.map((entry) => (_jsx("li", { className: entry.level === 3 ? "pl-3" : undefined, children: _jsx("a", { href: `#${entry.id}`, "aria-current": entry.id === current ? "location" : undefined, className: cx(ENTRY, entry.id === current ? ENTRY_ON : ENTRY_OFF), children: entry.label }) }, entry.id))) })] }) }) }));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One way onwards: the small `word` line over the page's label, in a bordered box. Its name is its
|
|
32
|
+
* visible text, the two read in order ("Previous Install"), so a speech-input user can say what
|
|
33
|
+
* they see.
|
|
34
|
+
*/
|
|
35
|
+
function Neighbour({ to, word, end }) {
|
|
36
|
+
return renderLink({
|
|
37
|
+
href: to.href,
|
|
38
|
+
className: cx("flex flex-col gap-1 rounded-lg border border-slate-200 px-4 py-3 hover:border-violet-400", end && "text-right sm:col-start-2", focusRing),
|
|
39
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-sm text-slate-500", children: word }), " ", _jsx("span", { className: "font-medium text-slate-900", children: to.label })] })),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Previous and next: up to two links, previous at the start and next at the end, two columns from `sm`. */
|
|
43
|
+
function DocsPager({ previous, next, previousLabel, nextLabel, }) {
|
|
44
|
+
if (!previous && !next)
|
|
45
|
+
return null;
|
|
46
|
+
return (_jsxs("nav", { "aria-label": `${previousLabel} and ${nextLabel}`, className: "grid gap-4 sm:grid-cols-2", children: [previous && _jsx(Neighbour, { to: previous, word: previousLabel, end: false }), next && _jsx(Neighbour, { to: next, word: nextLabel, end: true })] }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A docs page: a `SidebarLayout` whose rail is the docs `nav` (each group's title over its links,
|
|
50
|
+
* folded behind a disclosure named `navLabel` below `md`), and a canvas of the page's title, an
|
|
51
|
+
* "On this page" list of its `contents`, the article and the previous and next links.
|
|
52
|
+
*
|
|
53
|
+
* The contents list is rendered once: from `xl` a 12rem column right of the article that sticks
|
|
54
|
+
* under the header, below `xl` a closed disclosure above the article. `current` marks the heading
|
|
55
|
+
* being read; it is a value the page passes (a site that follows the reader computes it), with no
|
|
56
|
+
* scroll spy inside. The previous and next links are links, not cards, so they add no heading to
|
|
57
|
+
* the page's outline.
|
|
58
|
+
*/
|
|
59
|
+
export function DocsLayout({ nav, navLabel, title, description, breadcrumbs, contents = [], current, contentsLabel = "On this page", previous, next, previousLabel = "Previous", nextLabel = "Next", children, ...rest }) {
|
|
60
|
+
const listed = contents.length >= 2;
|
|
61
|
+
return (_jsx(SidebarLayout, { ...rest, asideLabel: navLabel, aside: _jsx(DocsNav, { nav: nav, navLabel: navLabel }), children: _jsxs("div", { className: cx("flex flex-col gap-12 sm:gap-16",
|
|
62
|
+
// The contents column only when there is a list, so a page without one keeps the width.
|
|
63
|
+
listed && "xl:grid xl:grid-cols-[minmax(0,1fr)_12rem] xl:gap-x-10"), children: [_jsx(PageHeaderContent, { breadcrumbs: breadcrumbs, title: title, description: description, className: "xl:col-start-1" }), listed && _jsx(DocsContents, { contents: contents, current: current, label: contentsLabel }), _jsx("div", { className: "min-w-0 xl:col-start-1", children: _jsxs(Stack, { gap: "xl", children: [children, _jsx(DocsPager, { previous: previous, next: next, previousLabel: previousLabel, nextLabel: nextLabel })] }) })] }) }));
|
|
64
|
+
}
|
package/dist/Drawer.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
import type { Size } from "./size.js";
|
|
4
|
+
export type DrawerProps = {
|
|
5
|
+
/** The drawer's accessible name, shown as its heading. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** A muted line under the title, as on a `Dialog`. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/** Actions pinned under the scrolling body, right-aligned. */
|
|
11
|
+
footer?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The panel's width: `md` holds a form or a record; `sm` (320px) is narrower and `lg` (640px) wider.
|
|
14
|
+
* @default md
|
|
15
|
+
*/
|
|
16
|
+
width?: Size | undefined;
|
|
17
|
+
/** Called when the drawer closes: Esc, a click on the scrim or the close button. */
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
/** The accessible name of the close button. */
|
|
20
|
+
closeLabel?: string;
|
|
21
|
+
} & Passthrough;
|
|
22
|
+
/**
|
|
23
|
+
* A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened
|
|
24
|
+
* with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
|
|
25
|
+
* closes it and focus stays inside; a click on the scrim (the `<dialog>` element itself, not its
|
|
26
|
+
* contents) closes it too. The header holds the title, an optional `description` under it and a
|
|
27
|
+
* close button; the body scrolls between
|
|
28
|
+
* it and an optional pinned `footer`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Drawer({ title, description, children, footer, width, onClose, closeLabel, ...rest }: DrawerProps): ReactElement;
|
package/dist/Drawer.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useRef } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
import { BodyContext, ModalScope } from "./Dialog.js";
|
|
5
|
+
import { IconButton } from "./IconButton.js";
|
|
6
|
+
import { useBackdropClose, useModal } from "./modal.js";
|
|
7
|
+
import { HeaderText, SectionHeading } from "./typography.js";
|
|
8
|
+
const PANEL = "fixed inset-y-0 right-0 left-auto m-0 h-dvh max-h-none max-w-full flex-col overflow-hidden border-l border-slate-200 bg-white p-0 text-slate-900 shadow-2xl translate-x-full transition-[translate,overlay,display] transition-discrete duration-200 open:flex open:translate-x-0 starting:open:translate-x-full backdrop:bg-slate-900/35 backdrop:opacity-0 backdrop:transition-[opacity,overlay,display] backdrop:transition-discrete backdrop:duration-200 open:backdrop:opacity-100 starting:open:backdrop:opacity-0 motion-reduce:transition-none motion-reduce:backdrop:transition-none";
|
|
9
|
+
const WIDTH = { sm: "w-80", md: "w-110", lg: "w-160" };
|
|
10
|
+
/**
|
|
11
|
+
* A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened
|
|
12
|
+
* with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
|
|
13
|
+
* closes it and focus stays inside; a click on the scrim (the `<dialog>` element itself, not its
|
|
14
|
+
* contents) closes it too. The header holds the title, an optional `description` under it and a
|
|
15
|
+
* close button; the body scrolls between
|
|
16
|
+
* it and an optional pinned `footer`.
|
|
17
|
+
*/
|
|
18
|
+
export function Drawer({ title, description, children, footer, width = "md", onClose, closeLabel = "Close", ...rest }) {
|
|
19
|
+
const dialog = useRef(null);
|
|
20
|
+
const titleId = useId();
|
|
21
|
+
const closed = useModal(dialog, onClose);
|
|
22
|
+
const backdrop = useBackdropClose(dialog);
|
|
23
|
+
return (_jsx(ModalScope, { children: _jsxs("dialog", { ...rest, ref: dialog, "aria-labelledby": titleId, onClose: closed, ...backdrop, className: cx(PANEL, WIDTH[width]), children: [_jsxs("header", { className: "flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-5.5 py-3.5", children: [_jsxs("div", { className: "min-w-0", children: [_jsx(SectionHeading, { id: titleId, children: title }), description && (_jsx("div", { className: "mt-1", children: _jsx(HeaderText, { children: description }) }))] }), _jsx(IconButton, { label: closeLabel, onClick: () => dialog.current?.close(), icon: "close" })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-5.5 py-4", children: _jsx(BodyContext, { children: children }) }), footer && (_jsx("footer", { className: "flex shrink-0 justify-end gap-2 border-t border-slate-200 px-5.5 py-3.5", children: footer }))] }) }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import { type EmptySize } from "./emptySlot.js";
|
|
3
|
+
import { type HeadingLevel } from "./headingLevel.js";
|
|
4
|
+
import type { IconName } from "./icons.js";
|
|
5
|
+
import type { Passthrough } from "./props.js";
|
|
6
|
+
/**
|
|
7
|
+
* The one empty look: what a list, a table or a page shows when there is nothing in it yet. Give it
|
|
8
|
+
* to the part's `empty` slot (`ListLayout`, `CardGrid`, `TableBody`, `Timeline`, `ChatThread`, a
|
|
9
|
+
* `Stack as="ul"`), which shows it when the part has no children and picks its size.
|
|
10
|
+
*
|
|
11
|
+
* `md` is a centred `title`, the `children` as the explanation under it (a `Text`, then `Steps` for
|
|
12
|
+
* a "get started" list), and `actions` (buttons, links) in a centred row at the bottom, with an
|
|
13
|
+
* optional `icon` above the title. A named `<section>`. On its own it draws a dashed frame round
|
|
14
|
+
* itself; inside a `Card` the card is the frame. `level` is the title's heading level, one below
|
|
15
|
+
* the heading that holds it: a 2 on the page, a 3 in a `Section`.
|
|
16
|
+
*
|
|
17
|
+
* `sm` is the one-line form for inside a table, a timeline or a list: the title as one centred
|
|
18
|
+
* muted line, the `children` under it in the same small text and the `actions` after. It is a plain
|
|
19
|
+
* block with no heading and no landmark, so a table cell or a card does not grow a region.
|
|
20
|
+
*/
|
|
21
|
+
export declare function EmptyState({ title, icon, level, size, padding, children, actions, ...rest }: {
|
|
22
|
+
/** The heading, centred: what is missing ("No projects yet"). It names the section. */
|
|
23
|
+
title: ReactNode;
|
|
24
|
+
/** One of the library's icons, at feature size in the muted ink above the title. */
|
|
25
|
+
icon?: IconName | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The title's heading level, 2 to 6. It does not change how the title looks.
|
|
28
|
+
* @default one below the heading that holds it: 2 on the page
|
|
29
|
+
*/
|
|
30
|
+
level?: HeadingLevel | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* `inset` pads all four sides, for an empty state in a `Card flush`, whose body has no padding
|
|
33
|
+
* of its own. `default` pads above and below only. On its own, outside a card, it pads all four
|
|
34
|
+
* sides inside its frame either way.
|
|
35
|
+
* @default default
|
|
36
|
+
*/
|
|
37
|
+
padding?: "default" | "inset" | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* `md` is the titled block; `sm` one muted line with no heading, for inside a table, a timeline or
|
|
40
|
+
* a list. `icon` and `level` do nothing at `sm`.
|
|
41
|
+
* @default the slot's: sm in a TableBody, a Timeline or a Stack as="ul", else md
|
|
42
|
+
*/
|
|
43
|
+
size?: EmptySize | undefined;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
/** Buttons or links in a centred row at the bottom. */
|
|
46
|
+
actions?: ReactNode;
|
|
47
|
+
} & Passthrough): ReactElement;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { useInCard } from "./cardContext.js";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { useEmptySize } from "./emptySlot.js";
|
|
6
|
+
import { useHeadingLevel } from "./headingLevel.js";
|
|
7
|
+
import { Icon } from "./Icon.js";
|
|
8
|
+
import { AppScale, SectionHeading } from "./typography.js";
|
|
9
|
+
/**
|
|
10
|
+
* The one empty look: what a list, a table or a page shows when there is nothing in it yet. Give it
|
|
11
|
+
* to the part's `empty` slot (`ListLayout`, `CardGrid`, `TableBody`, `Timeline`, `ChatThread`, a
|
|
12
|
+
* `Stack as="ul"`), which shows it when the part has no children and picks its size.
|
|
13
|
+
*
|
|
14
|
+
* `md` is a centred `title`, the `children` as the explanation under it (a `Text`, then `Steps` for
|
|
15
|
+
* a "get started" list), and `actions` (buttons, links) in a centred row at the bottom, with an
|
|
16
|
+
* optional `icon` above the title. A named `<section>`. On its own it draws a dashed frame round
|
|
17
|
+
* itself; inside a `Card` the card is the frame. `level` is the title's heading level, one below
|
|
18
|
+
* the heading that holds it: a 2 on the page, a 3 in a `Section`.
|
|
19
|
+
*
|
|
20
|
+
* `sm` is the one-line form for inside a table, a timeline or a list: the title as one centred
|
|
21
|
+
* muted line, the `children` under it in the same small text and the `actions` after. It is a plain
|
|
22
|
+
* block with no heading and no landmark, so a table cell or a card does not grow a region.
|
|
23
|
+
*/
|
|
24
|
+
export function EmptyState({ title, icon, level, size, padding = "default", children, actions, ...rest }) {
|
|
25
|
+
const titleId = useId();
|
|
26
|
+
const own = useHeadingLevel(level);
|
|
27
|
+
const framed = !useInCard();
|
|
28
|
+
if (useEmptySize(size) === "sm") {
|
|
29
|
+
return (_jsx(AppScale, { children: _jsxs("div", { ...rest, className: "flex w-full flex-col items-center gap-2 py-2 text-center", children: [_jsx("p", { className: "text-sm text-slate-500", children: title }), children != null && (_jsx("div", { className: "flex flex-col items-center gap-1 text-sm text-slate-500", children: children })), actions != null && _jsx("div", { className: "flex flex-wrap justify-center gap-2", children: actions })] }) }));
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(AppScale, { children: _jsxs("section", { ...rest, "aria-labelledby": titleId, className: cx("flex w-full flex-col items-center gap-4 text-center", framed
|
|
32
|
+
? "rounded-xl border border-dashed border-slate-300 p-8"
|
|
33
|
+
: cx("mx-auto max-w-xl", padding === "inset" ? "p-8" : "py-8")), children: [icon && (_jsx("span", { className: "flex text-slate-400", children: _jsx(Icon, { name: icon, size: "feature" }) })), _jsx(SectionHeading, { as: `h${own}`, id: titleId, children: title }), children != null && (_jsx("div", { className: "flex w-full flex-col items-center gap-5", children: children })), actions != null && _jsx("div", { className: "flex flex-wrap justify-center gap-2", children: actions })] }) }));
|
|
34
|
+
}
|
package/dist/Field.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
import { type LoadingProps } from "./skeleton.js";
|
|
4
|
+
/** The line under a control or a row: an error (`role="alert"`) replaces the hint; neither draws nothing. */
|
|
5
|
+
export declare function fieldNote(hint: ReactNode, error: ReactNode, ids?: {
|
|
6
|
+
hint: string;
|
|
7
|
+
error: string;
|
|
8
|
+
}): ReactElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* A label above a control, with a hint or an error line under it. An error replaces the hint.
|
|
11
|
+
* Inside a `FormGrid`, `span="full"` runs the field across both columns. The `Input`, `Select`,
|
|
12
|
+
* `Textarea` or `FileDrop` inside takes the label, the note (`aria-describedby`) and, with an error,
|
|
13
|
+
* `aria-invalid` and a red edge by itself: give it no `id` and the Field no `htmlFor`. While
|
|
14
|
+
* `loading` the label is drawn and the control is a bone of its height, read from the density
|
|
15
|
+
* around it (`sm` in a `sm` card or table).
|
|
16
|
+
*/
|
|
17
|
+
export declare function Field({ label, htmlFor, hint, error, span, layout, labelHidden, loading, loadingLabel, children, ...rest }: {
|
|
18
|
+
/** The text above the control. */
|
|
19
|
+
label: ReactNode;
|
|
20
|
+
/** A fixed id for the control inside, only when something else must name it. Unset, the Field makes one. */
|
|
21
|
+
htmlFor?: string | undefined;
|
|
22
|
+
/** A muted line under the control that says more. */
|
|
23
|
+
hint?: ReactNode;
|
|
24
|
+
/** Replaces the hint when set. */
|
|
25
|
+
error?: ReactNode;
|
|
26
|
+
/** `full` spans every column of a `FormGrid`; unset takes one. It does nothing outside a `FormGrid`. */
|
|
27
|
+
span?: "full" | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* `row` puts the label beside the control, for a compact setting or a drawer row; the hint or
|
|
30
|
+
* error sits under the control. Every row label takes the same fixed column, so stacked rows line
|
|
31
|
+
* their controls up; a long label wraps inside it. `column` puts the label above it.
|
|
32
|
+
* @default column
|
|
33
|
+
*/
|
|
34
|
+
layout?: "column" | "row" | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Keeps the `label` in the page for assistive tech and draws no text, for a control whose purpose
|
|
37
|
+
* is plain from what surrounds it (a search box in a toolbar). `label` stays required, so the
|
|
38
|
+
* control always has a name. With `layout="row"` the field draws as a column: an empty label
|
|
39
|
+
* column helps nobody.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
labelHidden?: boolean | undefined;
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
} & LoadingProps & Passthrough): ReactElement;
|
package/dist/Field.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
import { FieldContext } from "./fieldControl.js";
|
|
5
|
+
import { ControlBone } from "./fieldWait.js";
|
|
6
|
+
import { BusyLabel, busy, useLoading } from "./skeleton.js";
|
|
7
|
+
/** The line under a control or a row: an error (`role="alert"`) replaces the hint; neither draws nothing. */
|
|
8
|
+
export function fieldNote(hint, error, ids) {
|
|
9
|
+
if (error) {
|
|
10
|
+
return (_jsx("p", { id: ids?.error, role: "alert", className: "text-xs text-red-700", children: error }));
|
|
11
|
+
}
|
|
12
|
+
if (hint) {
|
|
13
|
+
return (_jsx("p", { id: ids?.hint, className: "text-xs text-slate-500", children: hint }));
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/** The control's id, the note's id and the note itself: the error, or else the hint, or nothing. */
|
|
18
|
+
function useFieldNote(htmlFor, hint, error) {
|
|
19
|
+
const generatedId = useId();
|
|
20
|
+
const ids = { hint: useId(), error: useId() };
|
|
21
|
+
const note = fieldNote(hint, error, ids);
|
|
22
|
+
let describedBy;
|
|
23
|
+
if (error)
|
|
24
|
+
describedBy = ids.error;
|
|
25
|
+
else if (hint)
|
|
26
|
+
describedBy = ids.hint;
|
|
27
|
+
return {
|
|
28
|
+
control: { id: htmlFor ?? generatedId, describedBy, invalid: Boolean(error) },
|
|
29
|
+
note,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** A field's label: hidden, or drawn, and free to wrap anywhere beside a control in a row. */
|
|
33
|
+
function labelLook(hidden, row) {
|
|
34
|
+
return hidden
|
|
35
|
+
? "sr-only"
|
|
36
|
+
: cx("text-sm font-medium text-slate-700", row && "min-w-0 wrap-anywhere");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A label above a control, with a hint or an error line under it. An error replaces the hint.
|
|
40
|
+
* Inside a `FormGrid`, `span="full"` runs the field across both columns. The `Input`, `Select`,
|
|
41
|
+
* `Textarea` or `FileDrop` inside takes the label, the note (`aria-describedby`) and, with an error,
|
|
42
|
+
* `aria-invalid` and a red edge by itself: give it no `id` and the Field no `htmlFor`. While
|
|
43
|
+
* `loading` the label is drawn and the control is a bone of its height, read from the density
|
|
44
|
+
* around it (`sm` in a `sm` card or table).
|
|
45
|
+
*/
|
|
46
|
+
export function Field({ label, htmlFor, hint, error, span, layout = "column", labelHidden = false, loading, loadingLabel, children, ...rest }) {
|
|
47
|
+
const row = layout === "row" && !labelHidden;
|
|
48
|
+
const { control, note } = useFieldNote(htmlFor, hint, error);
|
|
49
|
+
const { loading: waiting, owner } = useLoading(loading);
|
|
50
|
+
return (_jsxs("div", { ...rest, ...busy(owner, waiting), className: cx(row ? "grid grid-cols-[8rem_1fr] items-center gap-x-3 gap-y-1.5" : "flex flex-col gap-1.5", span === "full" && "col-span-full"), children: [_jsx("label", { htmlFor: control.id, className: labelLook(labelHidden, row), children: label }), _jsx(FieldContext.Provider, { value: control, children: waiting ? _jsx(ControlBone, {}) : children }), note && row ? _jsx("div", { className: "col-start-2", children: note }) : note, _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
export type FieldDialogProps = {
|
|
4
|
+
/** The dialog's heading and accessible name. */
|
|
5
|
+
title: string;
|
|
6
|
+
/** A muted line under the title. */
|
|
7
|
+
description?: string;
|
|
8
|
+
/** The visible label above the field, which names it. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** The field's placeholder. */
|
|
11
|
+
placeholder: string;
|
|
12
|
+
/** A muted line under the field; `emptyReason` takes its place while the field is empty. */
|
|
13
|
+
hint: string;
|
|
14
|
+
/** Said when the field is empty and the submit button is blocked. */
|
|
15
|
+
emptyReason: string;
|
|
16
|
+
/** The submit button's text. */
|
|
17
|
+
submit: string;
|
|
18
|
+
/** What the submit button says while `onSubmit` runs. */
|
|
19
|
+
busyLabel: string;
|
|
20
|
+
/** Gets the trimmed value. Resolving closes the dialog; a rejection shows its message in it. */
|
|
21
|
+
onSubmit: (value: string) => Promise<unknown>;
|
|
22
|
+
/** Called when the dialog closes: Cancel, Esc, the backdrop, or a resolved `onSubmit`. */
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
} & Passthrough;
|
|
25
|
+
/** A `Dialog` with one text field and Cancel / submit buttons. Render it only while open. */
|
|
26
|
+
export declare function FieldDialog({ title, description, label, placeholder, hint, emptyReason, submit, busyLabel, onSubmit, onClose, ...rest }: FieldDialogProps): ReactElement;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Button } from "./Button.js";
|
|
4
|
+
import { Dialog } from "./Dialog.js";
|
|
5
|
+
import { Field } from "./Field.js";
|
|
6
|
+
import { Input } from "./Input.js";
|
|
7
|
+
/** The field's value and its in-flight state; `send` is the form's submit handler. */
|
|
8
|
+
function useFieldSubmit(onSubmit) {
|
|
9
|
+
const [value, setValue] = useState("");
|
|
10
|
+
const [busy, setBusy] = useState(false);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const empty = value.trim().length === 0;
|
|
13
|
+
const send = (event) => {
|
|
14
|
+
if (empty || busy)
|
|
15
|
+
return;
|
|
16
|
+
// Close the <dialog> itself, so it animates out before `onClose` unmounts it.
|
|
17
|
+
const dialog = event.currentTarget.closest("dialog");
|
|
18
|
+
setError(null);
|
|
19
|
+
setBusy(true);
|
|
20
|
+
void onSubmit(value.trim()).then(() => dialog?.close(), (e) => {
|
|
21
|
+
setBusy(false);
|
|
22
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return { value, setValue, busy, error, empty, send };
|
|
26
|
+
}
|
|
27
|
+
/** A `Dialog` with one text field and Cancel / submit buttons. Render it only while open. */
|
|
28
|
+
export function FieldDialog({ title, description, label, placeholder, hint, emptyReason, submit, busyLabel, onSubmit, onClose, ...rest }) {
|
|
29
|
+
const { value, setValue, busy, error, empty, send } = useFieldSubmit(onSubmit);
|
|
30
|
+
return (_jsx(Dialog, { ...rest, title: title, description: description, onClose: onClose, onSubmit: send, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", onClick: (event) => event.currentTarget.closest("dialog")?.close(), children: "Cancel" }), _jsx(Button, { type: "submit", disabledReason: empty ? emptyReason : undefined, busy: busy && (busyLabel || true), children: submit })] }), children: _jsx(Field, { label: label, hint: empty ? emptyReason : hint, error: error ?? undefined, children: _jsx(Input, { autoFocus: true, placeholder: placeholder, value: value, onChange: (e) => setValue(e.target.value), autoComplete: "off" }) }) }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Unstyled } from "./props.js";
|
|
3
|
+
/**
|
|
4
|
+
* A labelled group of controls: several `Checkbox`es answering one question, a set of `Field`s that
|
|
5
|
+
* belong together, or the filter chips of one facet (a `ButtonGroup` of `outline` `sm` pressed
|
|
6
|
+
* `Button`s). It is a `<fieldset>` named by its `label`, drawn as its `<legend>` in the `Field`
|
|
7
|
+
* label's look, over the children in one column; a `ButtonGroup` or a `FormGrid` inside lays out a
|
|
8
|
+
* row. `hint` is a muted line under the group and its `aria-describedby`; `error` replaces it in red
|
|
9
|
+
* with `role="alert"`. `disabled` disables every control inside. One choice of several is a
|
|
10
|
+
* `RadioGroup`, never inside a `Fieldset`. Other props go on the `<fieldset>`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Fieldset({ label, hint, error, children, "aria-describedby": ownDescribedBy, ...rest }: {
|
|
13
|
+
/** The group's name, drawn as its `<legend>`. */
|
|
14
|
+
label: ReactNode;
|
|
15
|
+
/** A muted line under the group. */
|
|
16
|
+
hint?: ReactNode;
|
|
17
|
+
/** A red line under the group, in place of the hint, announced as an alert. */
|
|
18
|
+
error?: ReactNode;
|
|
19
|
+
/** `Checkbox`es, `Field`s (in a `FormGrid` for a row), or a `ButtonGroup` of chips. */
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
} & Unstyled<ComponentPropsWithoutRef<"fieldset">>): ReactElement;
|
package/dist/Fieldset.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { fieldNote } from "./Field.js";
|
|
4
|
+
/**
|
|
5
|
+
* A labelled group of controls: several `Checkbox`es answering one question, a set of `Field`s that
|
|
6
|
+
* belong together, or the filter chips of one facet (a `ButtonGroup` of `outline` `sm` pressed
|
|
7
|
+
* `Button`s). It is a `<fieldset>` named by its `label`, drawn as its `<legend>` in the `Field`
|
|
8
|
+
* label's look, over the children in one column; a `ButtonGroup` or a `FormGrid` inside lays out a
|
|
9
|
+
* row. `hint` is a muted line under the group and its `aria-describedby`; `error` replaces it in red
|
|
10
|
+
* with `role="alert"`. `disabled` disables every control inside. One choice of several is a
|
|
11
|
+
* `RadioGroup`, never inside a `Fieldset`. Other props go on the `<fieldset>`.
|
|
12
|
+
*/
|
|
13
|
+
export function Fieldset({ label, hint, error, children, "aria-describedby": ownDescribedBy, ...rest }) {
|
|
14
|
+
const ids = { hint: useId(), error: useId() };
|
|
15
|
+
let note;
|
|
16
|
+
if (error)
|
|
17
|
+
note = ids.error;
|
|
18
|
+
else if (hint)
|
|
19
|
+
note = ids.hint;
|
|
20
|
+
const describedBy = [ownDescribedBy, note].filter(Boolean).join(" ");
|
|
21
|
+
return (_jsxs("fieldset", { ...rest, "aria-describedby": describedBy === "" ? undefined : describedBy, className: "min-w-0", children: [_jsx("legend", { className: "text-sm font-medium text-slate-700", children: label }), _jsx("div", { className: "mt-2 flex flex-col gap-2.5", children: children }), (error || hint) && _jsx("div", { className: "mt-1.5", children: fieldNote(hint, error, ids) })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Unstyled } from "./props.js";
|
|
3
|
+
import type { Size } from "./size.js";
|
|
4
|
+
/**
|
|
5
|
+
* A dashed drop zone around a file input. The input covers the whole zone, invisible, so a click
|
|
6
|
+
* opens the file dialog and a file dragged onto it is taken by the browser as it is by any file
|
|
7
|
+
* input. `children` is the prompt; show the chosen file's name there from `onChange`. The label also shows
|
|
8
|
+
* the keyboard focus ring, the input being invisible. Every prop (`accept`, `multiple`, `name`, `disabled`, `onChange`) goes on the input.
|
|
9
|
+
*/
|
|
10
|
+
export declare function FileDrop({ size, children, ...rest }: {
|
|
11
|
+
/**
|
|
12
|
+
* `sm` is a compact chip or tile: dense padding; `lg` is one step roomier than `md`.
|
|
13
|
+
* @default md
|
|
14
|
+
*/
|
|
15
|
+
size?: Size;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
} & Unstyled<Omit<ComponentPropsWithoutRef<"input">, "type" | "children" | "size" | "width">>): ReactElement;
|
package/dist/FileDrop.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { useFieldControl } from "./fieldControl.js";
|
|
4
|
+
const PAD = { sm: "px-3 py-2", md: "px-4 py-6", lg: "px-5 py-8" };
|
|
5
|
+
/**
|
|
6
|
+
* A dashed drop zone around a file input. The input covers the whole zone, invisible, so a click
|
|
7
|
+
* opens the file dialog and a file dragged onto it is taken by the browser as it is by any file
|
|
8
|
+
* input. `children` is the prompt; show the chosen file's name there from `onChange`. The label also shows
|
|
9
|
+
* the keyboard focus ring, the input being invisible. Every prop (`accept`, `multiple`, `name`, `disabled`, `onChange`) goes on the input.
|
|
10
|
+
*/
|
|
11
|
+
export function FileDrop({ size = "md", children, ...rest }) {
|
|
12
|
+
const field = useFieldControl(rest);
|
|
13
|
+
return (_jsxs("label", { className: cx("relative flex items-center justify-center rounded-lg border border-dashed border-slate-300 text-center text-sm text-slate-500 transition hover:border-violet-400 has-aria-invalid:border-red-200 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-violet-600", PAD[size], rest.disabled && "opacity-50"), children: [_jsx("input", { type: "file", className: "absolute inset-0 h-full w-full cursor-pointer rounded-lg opacity-0 disabled:cursor-not-allowed", ...rest, ...field }), children] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
import { type LoadingProps } from "./skeleton.js";
|
|
4
|
+
/** Relative widths in a `FormRow`: a field of `span` 2 is twice as wide as one of `span` 1. */
|
|
5
|
+
export type FormRowSpan = 1 | 2 | 3 | 4;
|
|
6
|
+
/**
|
|
7
|
+
* Two columns of `Field`s from `md`, one below it. A `Field` takes one column; `span="full"` runs
|
|
8
|
+
* it across both, and a `FormRow` is always full width.
|
|
9
|
+
*/
|
|
10
|
+
export declare function FormGrid({ children, ...rest }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
} & Passthrough): ReactElement;
|
|
13
|
+
/**
|
|
14
|
+
* An inline-edit row: several controls side by side with proportional widths (`FormRowField`
|
|
15
|
+
* `span` 1 to 4), optional `actions` after them (a save button), and one `hint` or `error` line
|
|
16
|
+
* under the whole row. Every control sits on the bottom edge, so the actions line up with them
|
|
17
|
+
* whatever the labels do. Under `md` the fields and the actions stack.
|
|
18
|
+
*
|
|
19
|
+
* The row owns the note, so the fields beside each other keep their height: a `FormRowField` has
|
|
20
|
+
* no `hint` or `error` of its own.
|
|
21
|
+
*/
|
|
22
|
+
export declare function FormRow({ actions, hint, error, children, ...rest }: {
|
|
23
|
+
/** A button or two after the last field. It keeps its own width. */
|
|
24
|
+
actions?: ReactNode;
|
|
25
|
+
/** One muted line under the whole row. */
|
|
26
|
+
hint?: ReactNode;
|
|
27
|
+
/** Replaces the hint when set, as `Field`'s does. */
|
|
28
|
+
error?: ReactNode;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
} & Passthrough): ReactElement;
|
|
31
|
+
/**
|
|
32
|
+
* A compact label over one control, for a `FormRow`. `span` is its share of the row (1 default).
|
|
33
|
+
* While `loading` the label is drawn and the control is a bone of its height, as in a `Field`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function FormRowField({ label, htmlFor, span, loading, loadingLabel, children, ...rest }: {
|
|
36
|
+
/** The small label above the control. */
|
|
37
|
+
label: ReactNode;
|
|
38
|
+
/** The id of the control inside; the label's htmlFor. */
|
|
39
|
+
htmlFor: string;
|
|
40
|
+
/**
|
|
41
|
+
* The field's share of the row, 1 to 4: a `span` of 2 is twice as wide as a 1.
|
|
42
|
+
* @default 1
|
|
43
|
+
*/
|
|
44
|
+
span?: FormRowSpan | undefined;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
} & LoadingProps & Passthrough): ReactElement;
|
package/dist/FormRow.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { fieldNote } from "./Field.js";
|
|
4
|
+
import { ControlBone } from "./fieldWait.js";
|
|
5
|
+
import { BusyLabel, busy, useLoading } from "./skeleton.js";
|
|
6
|
+
const SPAN = {
|
|
7
|
+
1: "md:flex-1",
|
|
8
|
+
2: "md:flex-2",
|
|
9
|
+
3: "md:flex-3",
|
|
10
|
+
4: "md:flex-4",
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Two columns of `Field`s from `md`, one below it. A `Field` takes one column; `span="full"` runs
|
|
14
|
+
* it across both, and a `FormRow` is always full width.
|
|
15
|
+
*/
|
|
16
|
+
export function FormGrid({ children, ...rest }) {
|
|
17
|
+
return (_jsx("div", { ...rest, className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: children }));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An inline-edit row: several controls side by side with proportional widths (`FormRowField`
|
|
21
|
+
* `span` 1 to 4), optional `actions` after them (a save button), and one `hint` or `error` line
|
|
22
|
+
* under the whole row. Every control sits on the bottom edge, so the actions line up with them
|
|
23
|
+
* whatever the labels do. Under `md` the fields and the actions stack.
|
|
24
|
+
*
|
|
25
|
+
* The row owns the note, so the fields beside each other keep their height: a `FormRowField` has
|
|
26
|
+
* no `hint` or `error` of its own.
|
|
27
|
+
*/
|
|
28
|
+
export function FormRow({ actions, hint, error, children, ...rest }) {
|
|
29
|
+
const note = fieldNote(hint, error);
|
|
30
|
+
return (_jsxs("div", { ...rest, className: "col-span-full flex flex-col gap-1.5", children: [_jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [children, actions && _jsx("div", { className: "flex items-center gap-2 md:shrink-0", children: actions })] }), note] }));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A compact label over one control, for a `FormRow`. `span` is its share of the row (1 default).
|
|
34
|
+
* While `loading` the label is drawn and the control is a bone of its height, as in a `Field`.
|
|
35
|
+
*/
|
|
36
|
+
export function FormRowField({ label, htmlFor, span = 1, loading, loadingLabel, children, ...rest }) {
|
|
37
|
+
const { loading: waiting, owner } = useLoading(loading);
|
|
38
|
+
return (_jsxs("div", { ...rest, ...busy(owner, waiting), className: cx("flex min-w-0 flex-col gap-1", SPAN[span]), children: [_jsx("label", { htmlFor: htmlFor, className: "text-xs font-medium text-slate-700", children: label }), waiting ? _jsx(ControlBone, {}) : children, _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }));
|
|
39
|
+
}
|
package/dist/Hero.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
/** The one keyframes name the glow drifts on; a consumer's own CSS never needs it. */
|
|
4
|
+
export declare const HERO_DRIFT = "hc-hero-tide";
|
|
5
|
+
export type HeroProps = {
|
|
6
|
+
/** The small label above the title, set in the monospace face. */
|
|
7
|
+
overline?: ReactNode;
|
|
8
|
+
/** The page's `h1`, at display size. */
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
/** What follows the title: a `Lead`, and the page's first actions if it has any. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A landing page's top block: an overline, the display title (the page's `h1`) and the lede under
|
|
15
|
+
* it, over a soft glow of three tilted ribbons that drift slowly behind the text. The glow is always
|
|
16
|
+
* there and its colours and strength are the theme's (the palette's `glow` role), so a paper theme
|
|
17
|
+
* keeps it faint. It is anchored to the text's own column (`max-w-3xl`, at the parent's start edge),
|
|
18
|
+
* never the viewport, and clipped to it, so nothing scrolls sideways on a phone. It is
|
|
19
|
+
* `aria-hidden`, and the text sits above it. Under `prefers-reduced-motion: reduce` it stands still.
|
|
20
|
+
* Pure markup and one inline stylesheet: it works rendered on the server with no script.
|
|
21
|
+
* One per page, on a landing page; every other page opens with a `PageHeader`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Hero({ overline, title, children, ...rest }: HeroProps & Passthrough): ReactElement;
|
package/dist/Hero.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Display, Overline } from "./typography.js";
|
|
3
|
+
/** The one keyframes name the glow drifts on; a consumer's own CSS never needs it. */
|
|
4
|
+
export const HERO_DRIFT = "hc-hero-tide";
|
|
5
|
+
// What Tailwind classes cannot say: the soft fade at the layer's four edges (two masks, intersected,
|
|
6
|
+
// so no ribbon ends in a hard line where the layer clips it) and the drift. The drift is a slow
|
|
7
|
+
// sideways sway and stretch, like light on water, each ribbon on its own period so the three never
|
|
8
|
+
// line up; it runs only under `prefers-reduced-motion: no-preference`, so a visitor who asks for less
|
|
9
|
+
// motion sees the ribbons standing at their resting place. It sets no colour (the mask's black and
|
|
10
|
+
// transparent only set how much shows): the theme paints the ribbons.
|
|
11
|
+
const css = `[data-hero-glow]{mask-image:linear-gradient(to bottom,transparent,black 22%,black 78%,transparent),linear-gradient(to right,transparent,black 8%,black 92%,transparent);mask-composite:intersect}
|
|
12
|
+
@media (prefers-reduced-motion:no-preference){[data-hero-glow] span{animation:${HERO_DRIFT} 41s ease-in-out -7s infinite alternate}[data-hero-glow] span:nth-child(2){animation-duration:53s;animation-delay:-29s}[data-hero-glow] span:nth-child(3){animation-duration:67s;animation-delay:-43s;animation-direction:alternate-reverse}}
|
|
13
|
+
@keyframes ${HERO_DRIFT}{0%{translate:-7% 0;scale:1 1}50%{translate:5% 10%;scale:1.14 .86}100%{translate:12% -6%;scale:.92 1.1}}`;
|
|
14
|
+
/** Every ribbon: an ellipse, blurred soft. Its place, size, tilt and colour follow. */
|
|
15
|
+
const RIBBON = "absolute rounded-[50%] blur-[56px]";
|
|
16
|
+
/**
|
|
17
|
+
* A landing page's top block: an overline, the display title (the page's `h1`) and the lede under
|
|
18
|
+
* it, over a soft glow of three tilted ribbons that drift slowly behind the text. The glow is always
|
|
19
|
+
* there and its colours and strength are the theme's (the palette's `glow` role), so a paper theme
|
|
20
|
+
* keeps it faint. It is anchored to the text's own column (`max-w-3xl`, at the parent's start edge),
|
|
21
|
+
* never the viewport, and clipped to it, so nothing scrolls sideways on a phone. It is
|
|
22
|
+
* `aria-hidden`, and the text sits above it. Under `prefers-reduced-motion: reduce` it stands still.
|
|
23
|
+
* Pure markup and one inline stylesheet: it works rendered on the server with no script.
|
|
24
|
+
* One per page, on a landing page; every other page opens with a `PageHeader`.
|
|
25
|
+
*/
|
|
26
|
+
export function Hero({ overline, title, children, ...rest }) {
|
|
27
|
+
return (_jsxs("div", { ...rest, className: "relative isolate max-w-3xl", children: [_jsx("style", { children: css }), _jsxs("div", { "aria-hidden": "true", "data-hero-glow": "", className: "pointer-events-none absolute inset-x-0 -inset-y-14 -z-10 overflow-hidden", children: [_jsx("span", { className: `${RIBBON} top-[14%] left-[-6%] h-[34%] w-[78%] -rotate-[7deg] bg-indigo-400/25` }), _jsx("span", { className: `${RIBBON} top-[34%] left-[28%] h-[30%] w-[70%] rotate-[4deg] bg-teal-400/25` }), _jsx("span", { className: `${RIBBON} top-[56%] left-[6%] h-[26%] w-[58%] -rotate-[2deg] bg-rose-400/25` })] }), _jsxs("div", { className: "relative flex flex-col gap-4", children: [_jsxs("header", { children: [overline != null && overline !== false && _jsx(Overline, { mono: true, children: overline }), _jsx(Display, { children: title })] }), children] })] }));
|
|
28
|
+
}
|
package/dist/Icon.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { type IconName } from "./icons.js";
|
|
3
|
+
import type { Passthrough } from "./props.js";
|
|
4
|
+
import { type ResponsiveSize, type Size } from "./size.js";
|
|
5
|
+
import { type TextTone } from "./typography.js";
|
|
6
|
+
/** The box table and its `md:` twin, for the data test. */
|
|
7
|
+
export declare const iconSizeTables: {
|
|
8
|
+
box: Record<"feature" | Size, string>;
|
|
9
|
+
boxMd: Record<Size, string>;
|
|
10
|
+
};
|
|
11
|
+
type IconProps = Passthrough & {
|
|
12
|
+
/** The box: sm 14px, md 16px (the default), lg 20px, `feature` 32px for an icon that stands for an idea on its own (a feature card). `{ base, md }` (sm, md, lg) changes at the `md` breakpoint (48rem), as the icon in a Button of that size does. */
|
|
13
|
+
size?: Size | "feature" | ResponsiveSize;
|
|
14
|
+
/** A text tone. Left out, the icon takes the colour of the text around it. */
|
|
15
|
+
tone?: TextTone | undefined;
|
|
16
|
+
/** Names the icon (`role="img"`). Without one the icon is hidden from assistive tech. */
|
|
17
|
+
label?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* One inline icon, sized to a fixed box (sm 14px, md 16px, lg 20px, `feature` 32px) and drawn in
|
|
21
|
+
* `currentColor`, so it takes the text colour around it unless a `tone` says otherwise. `name`
|
|
22
|
+
* picks one of the library's own icons, all drawn on one grid with one stroke: feature ideas
|
|
23
|
+
* (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`,
|
|
24
|
+
* `speed`, `search`) and UI glyphs (`chevron-right`, `chevron-down`, `close`, `external-link`,
|
|
25
|
+
* `settings`, `bell`, `check`, `plus`, `more`) and the ideas the docs sections stand for (`grid`, `window`,
|
|
26
|
+
* `type`, `card`, `pointer`, `field`, `table`, `compass`, `page`, `briefcase`);
|
|
27
|
+
* without a name, a bare `<svg>` child fills the box. It is decorative (`aria-hidden`) by
|
|
28
|
+
* default; a `label` makes it an image with that name, for an icon that carries meaning no text
|
|
29
|
+
* beside it says.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Icon({ size, tone, label, name, children, ...rest }: IconProps & ({
|
|
32
|
+
/** One of the library's icons, named for the idea it stands for. */
|
|
33
|
+
name: IconName;
|
|
34
|
+
children?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
name?: undefined;
|
|
37
|
+
/** The `<svg>`, drawn in `currentColor`; it fills the box. */
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
})): ReactElement;
|
|
40
|
+
export {};
|