strata-react 0.1.17 → 1.0.1
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 +13 -10
- package/dist/components/async-button.d.ts +15 -3
- package/dist/components/button.d.ts +17 -7
- package/dist/components/checkbox.d.ts +3 -3
- package/dist/components/commands.d.ts +104 -0
- package/dist/components/composition.d.ts +1 -1
- package/dist/components/data-table.d.ts +16 -3
- package/dist/components/data-view.d.ts +12 -1
- package/dist/components/dialog.d.ts +45 -0
- package/dist/components/field.d.ts +3 -1
- package/dist/components/infinite-list.d.ts +35 -2
- package/dist/components/job-status.d.ts +36 -0
- package/dist/components/popover.d.ts +20 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/thumbnail.d.ts +17 -7
- package/dist/components/toggle.d.ts +43 -0
- package/dist/components/toolbar.d.ts +15 -0
- package/dist/components/tooltip.d.ts +19 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.js +1380 -355
- package/dist/index.js.map +1 -1
- package/dist/lib/chords.d.ts +20 -0
- package/dist/lib/errors.d.ts +28 -4
- package/dist/lib/format.d.ts +57 -6
- package/dist/lib/overlay.d.ts +1 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/query/index.d.ts +13 -4
- package/dist/query/job.d.ts +22 -0
- package/dist/{query-BlPgaCBG.js → query-BVh4zv7Y.js} +146 -41
- package/dist/query-BVh4zv7Y.js.map +1 -0
- package/dist/{run-N6Juz-kN.js → run-DFf1BBA3.js} +13 -3
- package/dist/run-DFf1BBA3.js.map +1 -0
- package/dist/strata.css +17 -0
- package/dist/testing/buttons.d.ts +7 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing.js +31 -2
- package/dist/testing.js.map +1 -1
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +8 -7
- package/dist/query-BlPgaCBG.js.map +0 -1
- package/dist/run-N6Juz-kN.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,8 +27,8 @@ npm install -D tailwindcss @tailwindcss/vite
|
|
|
27
27
|
|
|
28
28
|
The npm package is built: nothing runs on install. It needs **Node 26 or later**, for apps as
|
|
29
29
|
well as for this repo; an older Node gets an `EBADENGINE` warning, so upgrade it. Strata's own dependencies
|
|
30
|
-
(TanStack Table and Virtual, class-variance-authority, clsx, tailwind-merge,
|
|
31
|
-
|
|
30
|
+
(React Aria Components, TanStack Table and Virtual, class-variance-authority, clsx, tailwind-merge,
|
|
31
|
+
lucide-react) come with it, so an app does not list them.
|
|
32
32
|
|
|
33
33
|
**Peers.** What an app installs follows from what it imports, and the integration suite checks
|
|
34
34
|
it against the built files:
|
|
@@ -116,22 +116,25 @@ function KilnRoom() {
|
|
|
116
116
|
|
|
117
117
|
| Group | Exports | Notes |
|
|
118
118
|
|---|---|---|
|
|
119
|
-
| Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; `useAsyncAction` returns `{ phase, run, error }` with a stable `run`,
|
|
120
|
-
| Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid
|
|
121
|
-
| Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`) |
|
|
122
|
-
| Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LineChart` | `DataView` requires skeleton and empty,
|
|
119
|
+
| Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; buttons carry `data-variant` and `AsyncButton` `data-phase` for tests; `useAsyncAction` returns `{ phase, run, error, thrown, fieldErrors, clearFieldError }` with a stable `run`, describes an `HttpError` in a sentence with the server's own reason for a 4xx (`describeActionError`, or the product's own `describeError`), and `validate` plus a server's 422 put messages on `fieldErrors` for each `Field` |
|
|
120
|
+
| Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid`, and `action` puts a one-field form's button on the control's row with the hint and error under both; `Checkbox` requires `label` and is one target with it, and has a mixed state |
|
|
121
|
+
| Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job: a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends |
|
|
122
|
+
| Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables and lists virtualise from 100 rows; a `DataTable` column with `value` sorts by type with missing values last both ways and draws a placeholder (`missing`, default an en dash); `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard, and `scroll="page"` draws a grid that scrolls with the page; `LoadMore` is that next-page row for any list or grid; charts label values directly |
|
|
123
123
|
| Selection | `useSelection`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles |
|
|
124
124
|
| Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
|
|
125
|
-
| Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `toLoad`, `staleOf`, `fetchJson`, `HttpError` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once |
|
|
125
|
+
| Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `toLoad`, `staleOf`, `fetchJson`, `HttpError`, `readErrorBody`, `fieldErrorsOf` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once; `useJob` polls a job's status only while it runs and invalidates the queries it changes once, when it ends; `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`) |
|
|
126
126
|
| Page and navigation | `AppShell`, `SideNav`, `Breadcrumb`, `Tabs`, `PageHeader`, `LinkCard`, `LinkCardList` | React Router; tab and sort state in the URL; a `LinkCard` is one link named by its title, described by its text and `Status` marks, with the whole card as the target (`to` a route, `href` elsewhere, marked with an arrow) |
|
|
127
127
|
| Keyboard | `useHotkeys`, `KeysLegend`, `Shortcut`, `useActiveItem`, `ActiveList`, `isTypingTarget` | For queues worked from the keyboard; one shortcut list drives the handler and the legend; keys never fire while typing; answering moves focus to the next item |
|
|
128
128
|
| Theme | `ThemeProvider`, `useColorScheme`, `useSystemColorScheme`, `ColorSchemeChoice`, `colorSchemeScript` | System, light or dark; sets `.dark`, persists in localStorage when it can; `ColorSchemeChoice` is a radio list for a settings page, or `compact` icon segments named "Appearance" for an app with no settings page |
|
|
129
|
+
| Toolbar and toggles | `Toolbar`, `ToolbarSeparator`, `Toggle`, `ToggleGroup`, `Switch` | A toolbar is one tab stop with arrows, Home and End inside; needs a `label`. `Toggle` (`aria-pressed`) and `ToggleGroup` (one of 2 to 7, always one chosen) show chosen as an ink border on a tint, never the filled primary, so they do not break the one-filled-button rule; an icon-only toggle still needs its `label` (shown as a tooltip). `Switch` is only for a setting that applies at once, label and control one target |
|
|
130
|
+
| Commands | `Command`, `useCommands`, `Menu`, `ContextMenu`, `CommandMenu`, `CommandLegend`, `formatChord`, `matchesChord` | A command is declared once (label or label function, chords, `disabled` with a reason, `destructive`, `checked`) and drives the key handler, dropdown and menu-bar menus, the context menu, the searchable command menu (Mod+K) and the legend, so they cannot disagree. Chords are written once ("Mod+Shift+Z") and shown per platform (⇧⌘Z, Ctrl+Shift+Z); they never fire while typing or during IME composition, and a chord the browser keeps (Ctrl+S) needs `claim: true`. `useHotkeys` is unchanged for single keys |
|
|
131
|
+
| Overlays | `Dialog`, `DialogProps`, `AlertDialog`, `Popover`, `Tooltip` | React Aria underneath. A dialog always has a title and, via `actions`'s close render prop, a way out; `closable={false}` while work cannot stop; `placement="end"` is a sheet. `AlertDialog` is the only confirm: required verb on the confirm button, Cancel focused first, no outside dismiss, stays open with the reason when an async confirm fails. `Popover` needs a `label`. `Tooltip` opens on hover and focus and `IconButton` uses it. All portal onto the `layer-*` stacking utilities |
|
|
129
132
|
| Feedback | `UndoBar`, `useUndoable`, `Done` | Undo before confirm; the hook owns which rows are out of view (`isRemoved`), a failed commit brings the row back with Try again in the same bar, and `flush()` commits before a dependent action; `Done` is the one celebration, and it must say what happens next |
|
|
130
|
-
| Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units (`byteUnit` shares one unit across figures); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `createFormat(locale, { timeZone })` fixes the zone; units and counts join with a non-breaking space |
|
|
131
|
-
| Testing | `strata-react/testing`: `renderWithStrata`, `renderRoutes`, `createTestQueryClient`, `installLayoutShims`, `installFakeIntersectionObserver` | Router + query client around Testing Library's `render`; `renderRoutes(routes, { route, basename })` renders the app's own `RouteObject[]` in a memory data router, so layout routes, redirects, loaders and error elements run, and returns the `router` (where a redirect landed is `router.state.location`) and an act-wrapped `navigate`; a fixed box and ResizeObserver so measuring components render in jsdom; an IntersectionObserver the test fires with `scrollToEnd()` or `intersect(el)
|
|
133
|
+
| Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units (`byteUnit` shares one unit across figures); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `format.ago(at, now?)` ("3 weeks ago"), `format.compact(n)` ("1.2k", and `count(n, one, many, { compact: true })`), `format.runningTime(seconds)` ("1:02:09") and `format.share(n)` ("<1%" for a part that rounds to 0); every number and date formatter prints the placeholder (`format.missing`, an en dash) for `null` or `undefined`; `createFormat(locale, { timeZone, missing })` fixes the zone and the placeholder; units and counts join with a non-breaking space |
|
|
134
|
+
| Testing | `strata-react/testing`: `renderWithStrata`, `renderRoutes`, `createTestQueryClient`, `installLayoutShims`, `installFakeIntersectionObserver`, `filledButtons`, `expectOneFilledButton`, `asyncButtonPhase` | Router + query client around Testing Library's `render`; `renderRoutes(routes, { route, basename })` renders the app's own `RouteObject[]` in a memory data router, so layout routes, redirects, loaders and error elements run, and returns the `router` (where a redirect landed is `router.state.location`) and an act-wrapped `navigate`; a fixed box and ResizeObserver so measuring components render in jsdom; an IntersectionObserver the test fires with `scrollToEnd()` or `intersect(el)`; `filledButtons()` and `expectOneFilledButton()` check "one filled button per view" from `data-variant`, and `asyncButtonPhase(el)` reads an `AsyncButton`'s phase. Role names keep the non-breaking space from `format.count`, so match them with the same call or a `\s` regex |
|
|
132
135
|
| Visual regression | `strata-react/visual` and the `strata-visual` command | Screenshots an app's Storybook and its routes in each MSW state, light and dark, against baselines in the app's repo |
|
|
133
136
|
|
|
134
|
-
Specs for the components not built yet (
|
|
137
|
+
Specs for the components not built yet (menus, toasts, command menu, prose)
|
|
135
138
|
are in ux-research `ui-library/components.md`.
|
|
136
139
|
|
|
137
140
|
## Visual regression for apps
|
|
@@ -16,14 +16,20 @@ export declare function AsyncButton({ phase, labels, error, disabled, ...props }
|
|
|
16
16
|
/** What went wrong, in the product's words (`useAsyncAction`'s `error`). Announced with the error label when `phase` is `error`. */
|
|
17
17
|
error?: string;
|
|
18
18
|
}): React.JSX.Element;
|
|
19
|
+
/** Messages for a form's fields, keyed by field name. */
|
|
20
|
+
export type FieldErrors = Readonly<Record<string, string>>;
|
|
19
21
|
/** Options for `useAsyncAction`. */
|
|
20
|
-
export type AsyncActionOptions = {
|
|
22
|
+
export type AsyncActionOptions<A extends unknown[] = unknown[]> = {
|
|
21
23
|
/** How long `done` shows before returning to `idle`. Default 2000ms. */
|
|
22
24
|
settleMs?: number;
|
|
23
25
|
/** Called with whatever the action threw, once the `error` render has committed: for logging, or to move focus to the retry button or an error message. */
|
|
24
26
|
onError?: (error: unknown) => void;
|
|
25
27
|
/** Turns what was thrown into `error`'s sentence, in the product's words. Default `describeActionError`: HTTP status sentences for `fetchJson`'s `HttpError`, else the Error's message. */
|
|
26
28
|
describeError?: (error: unknown) => string | undefined;
|
|
29
|
+
/** Checks the arguments before the action runs. A message for any field stops the run and is put on `fieldErrors`; the button stays idle. */
|
|
30
|
+
validate?: (...args: A) => Record<string, string | undefined> | undefined;
|
|
31
|
+
/** Called once validation's messages are on screen: to move focus to the first field named. */
|
|
32
|
+
onInvalid?: (fieldErrors: FieldErrors) => void;
|
|
27
33
|
};
|
|
28
34
|
/** What `useAsyncAction` returns: the phase for `AsyncButton`, a stable `run`, and what went wrong while `phase` is `error`. */
|
|
29
35
|
export type AsyncAction<A extends unknown[]> = {
|
|
@@ -31,6 +37,12 @@ export type AsyncAction<A extends unknown[]> = {
|
|
|
31
37
|
run: (...args: A) => Promise<void>;
|
|
32
38
|
/** What went wrong, from `describeError`, while `phase` is `error`; otherwise undefined. Pass it to `AsyncButton`'s `error`. */
|
|
33
39
|
error: string | undefined;
|
|
40
|
+
/** What the action threw, while `phase` is `error`: to read more than the sentence (an HttpError's `status` or `body`). */
|
|
41
|
+
thrown: unknown;
|
|
42
|
+
/** Messages per field, from `validate` or from the server (an HttpError's `fieldErrors`). Pass each to its `Field`'s `error`. Cleared by the next run. */
|
|
43
|
+
fieldErrors: FieldErrors;
|
|
44
|
+
/** Clears one field's message (as the person edits it), or all of them. */
|
|
45
|
+
clearFieldError: (field?: string) => void;
|
|
34
46
|
};
|
|
35
|
-
/** Runs an async action and reports its phase and
|
|
36
|
-
export declare function useAsyncAction<A extends unknown[]>(action: (...args: A) => Promise<unknown>, { settleMs, onError, describeError }?: AsyncActionOptions): AsyncAction<A>;
|
|
47
|
+
/** Runs an async action and reports its phase, its error and any field messages. `done` returns to `idle` after `settleMs`; `run` never changes identity. */
|
|
48
|
+
export declare function useAsyncAction<A extends unknown[]>(action: (...args: A) => Promise<unknown>, { settleMs, onError, describeError, validate, onInvalid }?: AsyncActionOptions<A>): AsyncAction<A>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PressEvent } from 'react-aria-components';
|
|
1
2
|
import { VariantProps } from 'class-variance-authority';
|
|
2
3
|
import { IconComponent } from '../lib/icon';
|
|
3
4
|
import * as React from "react";
|
|
@@ -5,18 +6,27 @@ export declare const buttonVariants: (props?: ({
|
|
|
5
6
|
variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
|
|
6
7
|
size?: "default" | "sm" | "icon" | null | undefined;
|
|
7
8
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
|
-
export type ButtonProps = React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
9
|
-
|
|
9
|
+
export type ButtonProps = Omit<React.ComponentProps<"button">, "className" | "style"> & VariantProps<typeof buttonVariants> & {
|
|
10
|
+
className?: string;
|
|
11
|
+
/** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */
|
|
12
|
+
onPress?: (event: PressEvent) => void;
|
|
10
13
|
};
|
|
11
|
-
/**
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves
|
|
16
|
+
* the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is
|
|
17
|
+
* `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
|
|
18
|
+
* `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Button({ className, variant, size, type, disabled, ...props }: ButtonProps): React.JSX.Element;
|
|
13
21
|
export type IconButtonProps = Omit<ButtonProps, "size" | "children" | "aria-label"> & {
|
|
14
22
|
icon: IconComponent;
|
|
15
23
|
label: string;
|
|
24
|
+
/** Shown after the label in its tooltip, muted: "Ctrl+Z". */
|
|
25
|
+
hint?: React.ReactNode;
|
|
16
26
|
};
|
|
17
|
-
/** An icon-only button. `label` is required and becomes the accessible name and tooltip. */
|
|
18
|
-
export declare function IconButton({ icon: Icon, label, variant, ...props }: IconButtonProps): React.JSX.Element;
|
|
19
|
-
export type RowActionProps = Omit<ButtonProps, "children" | "aria-label"
|
|
27
|
+
/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */
|
|
28
|
+
export declare function IconButton({ icon: Icon, label, hint, variant, ...props }: IconButtonProps): React.JSX.Element;
|
|
29
|
+
export type RowActionProps = Omit<ButtonProps, "children" | "aria-label"> & {
|
|
20
30
|
/** The visible verb, sentence case: "Withdraw", "Remove". */
|
|
21
31
|
label: string;
|
|
22
32
|
/** What the row is, as a person would say it: "Tom Ellery", "Moonbeam". Completes the accessible name. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
/** A checkbox with its label as one target. `label` is required; `checked="mixed"` is indeterminate. */
|
|
3
|
-
export type CheckboxProps = Omit<React.ComponentProps<"input">, "type" | "checked" | "onChange" | "aria-label" | "children"> & {
|
|
3
|
+
export type CheckboxProps = Omit<React.ComponentProps<"input">, "type" | "checked" | "onChange" | "aria-label" | "children" | "style"> & {
|
|
4
4
|
/** Names the checkbox. Shown beside it unless `hideLabel`. */
|
|
5
5
|
label: string;
|
|
6
6
|
/** Keep the label as the accessible name only, for a cell or toolbar where the context shows what it is. */
|
|
@@ -15,8 +15,8 @@ export type CheckboxProps = Omit<React.ComponentProps<"input">, "type" | "checke
|
|
|
15
15
|
export type CheckboxGesture = {
|
|
16
16
|
shiftKey: boolean;
|
|
17
17
|
};
|
|
18
|
-
/** A
|
|
19
|
-
export declare function Checkbox({ label, hideLabel, detail, checked, onCheckedChange, className, disabled, ...props }: CheckboxProps): React.JSX.Element;
|
|
18
|
+
/** A checkbox and its label as one target. `label` is required; `hideLabel` keeps it as the accessible name only. */
|
|
19
|
+
export declare function Checkbox({ label, hideLabel, detail, checked, onCheckedChange, className, disabled, required, ...props }: CheckboxProps): React.JSX.Element;
|
|
20
20
|
/** Notes Shift on the press that leads to a checkbox's change event, which has no modifier keys of its own. */
|
|
21
21
|
export declare function useShiftNote(): {
|
|
22
22
|
handlers: {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { IconComponent } from '../lib/icon';
|
|
2
|
+
import { Platform } from '../lib/chords';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/** A command: what it is called, how it is run, and everything the menus need to draw it. */
|
|
5
|
+
export type Command = {
|
|
6
|
+
/** Stable key for the command. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The verb phrase, sentence case, in the product's words ("Split clip"); a function when it follows state ("Undo move clip"). */
|
|
9
|
+
label: string | (() => string);
|
|
10
|
+
run: () => void;
|
|
11
|
+
/** Chords that run it, written once ("Mod+Z", "Delete", "Shift+?"); the first is the one shown. */
|
|
12
|
+
keys?: string[];
|
|
13
|
+
/** Cannot run now. A sentence says why ("Nothing to undo") and is shown in menus. */
|
|
14
|
+
disabled?: boolean | string;
|
|
15
|
+
/** Cannot be undone or removes something: drawn with an icon and the danger colour. */
|
|
16
|
+
destructive?: boolean;
|
|
17
|
+
/** Makes a menu item checkable: whether it is on now. `run` toggles it. */
|
|
18
|
+
checked?: boolean;
|
|
19
|
+
icon?: IconComponent;
|
|
20
|
+
/** Fire again while the key is held (for moving). Default false. */
|
|
21
|
+
repeat?: boolean;
|
|
22
|
+
/** Run from inside a text field too. Default false: a field keeps its own keys. */
|
|
23
|
+
inFields?: boolean;
|
|
24
|
+
/** Take over a chord the browser uses (Ctrl+S, Ctrl+P). Required for those; otherwise the command is not bound. */
|
|
25
|
+
claim?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** What goes in a menu: a command, a separator, a titled group, or a submenu. */
|
|
28
|
+
export type MenuEntry = Command | "separator" | {
|
|
29
|
+
group: string;
|
|
30
|
+
items: Command[];
|
|
31
|
+
} | {
|
|
32
|
+
submenu: string;
|
|
33
|
+
items: MenuEntry[];
|
|
34
|
+
};
|
|
35
|
+
/** The text of a command's label, whether it is a string or a function. */
|
|
36
|
+
export declare const labelOf: (c: Command) => string;
|
|
37
|
+
/** Options for `useCommands`. */
|
|
38
|
+
export type CommandsOptions = {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
/** Which platform's `Mod` to use; read from the browser when left out. */
|
|
41
|
+
platform?: Platform;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Binds every command's chords on the window. Never while typing (unless the command says
|
|
45
|
+
* `inFields`), never during IME composition, not on a held key (unless `repeat`), not for a disabled
|
|
46
|
+
* command, and not for a chord the browser uses unless the command `claim`s it. A command's chord
|
|
47
|
+
* that clashes with another's is a mistake: the first in the list wins, and a dev warning names both.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useCommands(commands: readonly Command[], { enabled, platform }?: CommandsOptions): void;
|
|
50
|
+
/** The shortcut a command shows in menus and legends ("⌘Z", "Ctrl+Z"), or undefined. */
|
|
51
|
+
export declare function commandShortcut(c: Command, platform?: Platform): string | undefined;
|
|
52
|
+
/** A quiet legend built from the same commands the key handler runs: only commands with keys, disabled ones muted. */
|
|
53
|
+
export declare function CommandLegend({ commands, platform, label, className, }: {
|
|
54
|
+
commands: readonly Command[];
|
|
55
|
+
platform?: Platform;
|
|
56
|
+
label?: string;
|
|
57
|
+
className?: string;
|
|
58
|
+
}): React.JSX.Element;
|
|
59
|
+
/** Props for `Menu`. */
|
|
60
|
+
export type MenuProps = {
|
|
61
|
+
/** Names the menu: "File", "Edit". Required. */
|
|
62
|
+
label: string;
|
|
63
|
+
/** The control that opens it. */
|
|
64
|
+
trigger: React.ReactElement;
|
|
65
|
+
items: readonly MenuEntry[];
|
|
66
|
+
/** Controlled open state, for a story or a test that needs it shown. */
|
|
67
|
+
open?: boolean;
|
|
68
|
+
onOpenChange?: (open: boolean) => void;
|
|
69
|
+
platform?: Platform;
|
|
70
|
+
className?: string;
|
|
71
|
+
};
|
|
72
|
+
/** A dropdown menu of commands: the menu roles and keyboard model, shortcuts shown per platform, unavailable items with their reason, separators, groups, checkable groups and submenus. */
|
|
73
|
+
export declare function Menu({ label, trigger, items, open, onOpenChange, platform, className }: MenuProps): React.JSX.Element;
|
|
74
|
+
/** Props for `ContextMenu`. */
|
|
75
|
+
export type ContextMenuProps = {
|
|
76
|
+
/** Names the menu: "Clip actions". Required. */
|
|
77
|
+
label: string;
|
|
78
|
+
items: readonly MenuEntry[];
|
|
79
|
+
/** The object it belongs to. It becomes the thing the menu opens on: right-click, the context-menu key and Shift+F10. */
|
|
80
|
+
children: React.ReactElement<React.HTMLAttributes<HTMLElement>>;
|
|
81
|
+
platform?: Platform;
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A context menu for an object: opens on right-click at the pointer, and from the keyboard (the
|
|
86
|
+
* context-menu key or Shift+F10) beside the focused object, with the same items and shortcuts as
|
|
87
|
+
* every other menu. The child gets the handlers, so it should be focusable (a row, a clip).
|
|
88
|
+
*/
|
|
89
|
+
export declare function ContextMenu({ label, items, children, platform, disabled }: ContextMenuProps): React.JSX.Element;
|
|
90
|
+
/** Props for `CommandMenu`. */
|
|
91
|
+
export type CommandMenuProps = {
|
|
92
|
+
/** The commands to search, usually the same list given to `useCommands`. Entries may be grouped. */
|
|
93
|
+
commands: readonly MenuEntry[];
|
|
94
|
+
/** Controlled open state; otherwise it opens on `shortcut`. */
|
|
95
|
+
open?: boolean;
|
|
96
|
+
onOpenChange?: (open: boolean) => void;
|
|
97
|
+
/** The chord that opens it. Default `Mod+K`. `null` for none. */
|
|
98
|
+
shortcut?: string | null;
|
|
99
|
+
/** The search field's name and placeholder. Default "Search commands". */
|
|
100
|
+
label?: string;
|
|
101
|
+
platform?: Platform;
|
|
102
|
+
};
|
|
103
|
+
/** A searchable list of every command, opened by a chord (default Mod+K). Choosing one closes it and runs it; an unavailable command is shown with its reason and does nothing. */
|
|
104
|
+
export declare function CommandMenu({ commands, open, onOpenChange, shortcut, label, platform }: CommandMenuProps): React.JSX.Element;
|
|
@@ -13,7 +13,7 @@ export type CompositionBarProps = {
|
|
|
13
13
|
label: string;
|
|
14
14
|
parts: CompositionPart[];
|
|
15
15
|
formatValue: (value: number) => string;
|
|
16
|
-
/** Formats a part's share of the whole (0 to 1). Defaults to `format.
|
|
16
|
+
/** Formats a part's share of the whole (0 to 1). Defaults to `format.share` ("<1%" for a part that rounds to 0). */
|
|
17
17
|
formatShare?: (share: number) => string;
|
|
18
18
|
/** Header of the parts column, for screen readers and over the table. Defaults to "Part". */
|
|
19
19
|
partHeader?: string;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
/** What a column's `value` may be: a number, text or a date, or `null`/`undefined` when the row has none. */
|
|
3
|
+
export type CellValue = number | string | Date | null | undefined;
|
|
2
4
|
export type Column<T> = {
|
|
3
5
|
key: string;
|
|
4
6
|
header: string;
|
|
5
|
-
cell: (row: T) => React.ReactNode;
|
|
6
7
|
/** Right-aligns and sets tabular figures. Use for every quantity. */
|
|
7
8
|
numeric?: boolean;
|
|
8
|
-
|
|
9
|
+
/** Orders two rows. With `value`, it orders only rows that have one (missing ones go last); `false` turns off `value`'s default sort. */
|
|
10
|
+
sort?: ((a: T, b: T) => number) | false;
|
|
11
|
+
/** What the cell shows when the row's `value` is missing, where the word carries meaning ("Never"). Default an en dash. */
|
|
12
|
+
missing?: string;
|
|
9
13
|
/** Cells that may hold long text get truncated rather than stretching the table. */
|
|
10
14
|
truncate?: boolean;
|
|
11
15
|
/** Keep the header for screen readers only, as for a column of row actions. `header` still names it. */
|
|
12
16
|
hideHeader?: boolean;
|
|
13
17
|
className?: string;
|
|
14
|
-
}
|
|
18
|
+
} & ({
|
|
19
|
+
cell: (row: T) => React.ReactNode;
|
|
20
|
+
/** The row's value for this column: gives a typed default sort with missing values last, and the missing placeholder. */
|
|
21
|
+
value?: (row: T) => CellValue;
|
|
22
|
+
} | {
|
|
23
|
+
/** How a row with a value is drawn. Default: numbers through `format.decimal`, dates through `format.date`, text as it is. */
|
|
24
|
+
cell?: (row: T) => React.ReactNode;
|
|
25
|
+
/** The row's value for this column: gives a typed default sort with missing values last, and the missing placeholder. */
|
|
26
|
+
value: (row: T) => CellValue;
|
|
27
|
+
});
|
|
15
28
|
/** Row selection for a `DataTable`: the chosen row keys, how to change them, and how to name each row's checkbox. */
|
|
16
29
|
export type RowSelection<T> = {
|
|
17
30
|
/** Keys (from `rowKey`) of the chosen rows. */
|
|
@@ -22,8 +22,17 @@ export type Load<T> = {
|
|
|
22
22
|
data: T;
|
|
23
23
|
stale?: Stale;
|
|
24
24
|
};
|
|
25
|
+
/** What a failed read hands to an `error` renderer: the sentence for a person, and the Try again. */
|
|
26
|
+
export type LoadFailure = {
|
|
27
|
+
message: string;
|
|
28
|
+
retry: () => void;
|
|
29
|
+
};
|
|
30
|
+
/** The default failed-read panel: the reason on the danger tint, with Try again. Its parent carries `role="alert"`. */
|
|
31
|
+
export declare function LoadError({ message, retry, className }: LoadFailure & {
|
|
32
|
+
className?: string;
|
|
33
|
+
}): React.JSX.Element;
|
|
25
34
|
/** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`, under a `StaleNotice` when a refresh failed. The skeleton and empty state are required. */
|
|
26
|
-
export declare function DataView<T>({ state, isEmpty, skeleton, empty, children, staleNotice, className, }: {
|
|
35
|
+
export declare function DataView<T>({ state, isEmpty, skeleton, empty, children, staleNotice, error, className, }: {
|
|
27
36
|
state: Load<T>;
|
|
28
37
|
/** When the loaded data counts as empty. For arrays, `(rows) => rows.length === 0`. */
|
|
29
38
|
isEmpty: (data: T) => boolean;
|
|
@@ -34,6 +43,8 @@ export declare function DataView<T>({ state, isEmpty, skeleton, empty, children,
|
|
|
34
43
|
children: (data: T) => React.ReactNode;
|
|
35
44
|
/** Shown above the data when a refresh failed. Defaults to a `StaleNotice`; pass one with the product's words for what is old ("Readings from 13:50"). */
|
|
36
45
|
staleNotice?: (stale: Stale) => React.ReactNode;
|
|
46
|
+
/** Draws a read that failed with no data, given the message and the retry. Defaults to `LoadError`. Rendered inside a `role="alert"` box. */
|
|
47
|
+
error?: (failure: LoadFailure) => React.ReactNode;
|
|
37
48
|
className?: string;
|
|
38
49
|
}): React.JSX.Element;
|
|
39
50
|
/** The notice over data whose refresh failed: what happened, how old the data shown is, and Try again. A polite status, not an alert: nothing was lost. */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type Common = {
|
|
3
|
+
/** What it is for: "Export video", "Delete 3 firings?". Required. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** Shown under the title when it is not enough alone. */
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
/** The control that opens it. Leave out and drive it with `open` and `onOpenChange`. */
|
|
8
|
+
trigger?: React.ReactElement;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Props for `Dialog`. */
|
|
14
|
+
export type DialogProps = Common & {
|
|
15
|
+
/** The body. It scrolls inside the dialog when it is taller than the window. */
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
/** The buttons along the bottom, built with `DialogActions`'s `close` render prop when one should close it. One filled button at most. */
|
|
18
|
+
actions?: React.ReactNode | ((close: () => void) => React.ReactNode);
|
|
19
|
+
/** Keep the title for screen readers only, when the body already says it. */
|
|
20
|
+
hideTitle?: boolean;
|
|
21
|
+
/** `false` while work cannot be interrupted: no close control, Escape or outside press. Default true. */
|
|
22
|
+
closable?: boolean;
|
|
23
|
+
/** `center` is a dialog; `end` is a sheet down the right edge. Default `center`. */
|
|
24
|
+
placement?: "center" | "end";
|
|
25
|
+
size?: "sm" | "md" | "lg";
|
|
26
|
+
};
|
|
27
|
+
/** A modal dialog with a required title; focus goes in and returns, Escape and a close control dismiss it. `placement="end"` makes it a sheet. */
|
|
28
|
+
export declare function Dialog({ title, description, trigger, open, onOpenChange, className, children, actions, hideTitle, closable, placement, size, }: DialogProps): React.JSX.Element;
|
|
29
|
+
/** Props for `AlertDialog`. */
|
|
30
|
+
export type AlertDialogProps = Common & {
|
|
31
|
+
/** The verb, repeating the action: "Delete 3 firings". Required; "OK" and "Confirm" are what this prevents. */
|
|
32
|
+
confirm: string;
|
|
33
|
+
/** Runs on confirm. When it returns a promise the dialog waits, shows the button busy, and stays open with the reason if it rejects. */
|
|
34
|
+
onConfirm: () => void | Promise<unknown>;
|
|
35
|
+
/** The safe choice, which has initial focus. Default "Cancel". */
|
|
36
|
+
cancel?: string;
|
|
37
|
+
/** `destructive` fills the confirm button with the destructive role. Default `destructive`. */
|
|
38
|
+
tone?: "destructive" | "default";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A confirm for what cannot be undone. Names the object and the consequence in `title`, repeats the
|
|
42
|
+
* verb on the confirm button, focuses Cancel first and ignores outside presses.
|
|
43
|
+
*/
|
|
44
|
+
export declare function AlertDialog({ title, description, trigger, open, onOpenChange, className, confirm, onConfirm, cancel, tone, }: AlertDialogProps): React.JSX.Element;
|
|
45
|
+
export {};
|
|
@@ -7,11 +7,13 @@ export type FieldProps = {
|
|
|
7
7
|
hint?: React.ReactNode;
|
|
8
8
|
/** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */
|
|
9
9
|
error?: string;
|
|
10
|
+
/** A button on the control's row, for a one-field form (an `AsyncButton` "Add"). The hint and error run under both; on a narrow screen it wraps under the control. */
|
|
11
|
+
action?: React.ReactNode;
|
|
10
12
|
children: React.ReactNode;
|
|
11
13
|
className?: string;
|
|
12
14
|
};
|
|
13
15
|
/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */
|
|
14
|
-
export declare function Field({ label, id: idProp, hint, error, children, className }: FieldProps): React.JSX.Element;
|
|
16
|
+
export declare function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps): React.JSX.Element;
|
|
15
17
|
/** A text input that picks up its id and descriptions from the surrounding `Field`. */
|
|
16
18
|
export declare function Input({ className, id, ...props }: React.ComponentProps<"input">): React.JSX.Element;
|
|
17
19
|
/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
import { LoadFailure } from './data-view';
|
|
1
2
|
import { InfiniteLoad } from '../query/infinite';
|
|
2
3
|
import * as React from "react";
|
|
4
|
+
/** The next-page row's props: `InfiniteList`'s, for a list or grid the app draws itself. */
|
|
5
|
+
export type LoadMoreProps<T> = {
|
|
6
|
+
state: InfiniteLoad<T>;
|
|
7
|
+
/** The button behind the sentinel, in the product's words: "Show older firings". */
|
|
8
|
+
moreLabel: string;
|
|
9
|
+
/** The items of a page on its way, mirroring the ones already drawn. */
|
|
10
|
+
moreSkeleton: React.ReactNode;
|
|
11
|
+
/** After the last page: say that this is everything. */
|
|
12
|
+
end?: React.ReactNode;
|
|
13
|
+
/** How far before the end the next page is asked for (IntersectionObserver `rootMargin`). Default 400px. */
|
|
14
|
+
rootMargin?: string;
|
|
15
|
+
/** Load more whenever fewer than this many items are held. */
|
|
16
|
+
keepAtLeast?: number;
|
|
17
|
+
/** Draws a failed later page, given the reason and the Try again. Rendered inside a `role="alert"` box. */
|
|
18
|
+
error?: (failure: LoadFailure) => React.ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The row after a cursor-paged list or grid: loads the next page as it nears the screen, shows
|
|
23
|
+
* `moreSkeleton` while it comes, says why it failed with Try again, offers Show more for the
|
|
24
|
+
* keyboard, and `end` after the last page. After Show more it focuses the first new item: mark
|
|
25
|
+
* each item with `data-index` and put this row beside the list, in the same parent.
|
|
26
|
+
*/
|
|
27
|
+
export declare function LoadMore<T>({ state, moreLabel, moreSkeleton, end, rootMargin, keepAtLeast, error: drawError, className, }: LoadMoreProps<T>): React.JSX.Element | null;
|
|
3
28
|
/** The infinite list's props. */
|
|
4
29
|
export type InfiniteListProps<T> = {
|
|
5
30
|
state: InfiniteLoad<T>;
|
|
@@ -20,10 +45,18 @@ export type InfiniteListProps<T> = {
|
|
|
20
45
|
rootMargin?: string;
|
|
21
46
|
/** Load more whenever fewer than this many items are held. */
|
|
22
47
|
keepAtLeast?: number;
|
|
48
|
+
/** `region` (default): rows in a scroll region of `height`, virtual from `virtualizeFrom`. `page`: a plain list that scrolls with the page, laid out by `listClassName`. */
|
|
49
|
+
scroll?: "region" | "page";
|
|
50
|
+
/** With `scroll="page"`: the classes of the `ul`, such as a responsive grid (`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`). */
|
|
51
|
+
listClassName?: string;
|
|
52
|
+
/** Draws a failed first page. Defaults to DataView's `LoadError`. */
|
|
53
|
+
error?: (failure: LoadFailure) => React.ReactNode;
|
|
54
|
+
/** Draws a failed later page. Defaults to a danger row with Try again. */
|
|
55
|
+
moreError?: (failure: LoadFailure) => React.ReactNode;
|
|
23
56
|
estimateSize?: number;
|
|
24
57
|
height?: number;
|
|
25
58
|
virtualizeFrom?: number;
|
|
26
59
|
className?: string;
|
|
27
60
|
};
|
|
28
|
-
/** A cursor-paged list for `useInfiniteLoad`: DataView's first-page states, virtual rows, and a
|
|
29
|
-
export declare function InfiniteList<T>({ state, label, children, skeleton, empty, moreLabel, moreSkeleton, end, rootMargin, keepAtLeast, estimateSize, height, virtualizeFrom, className, }: InfiniteListProps<T>): React.JSX.Element;
|
|
61
|
+
/** A cursor-paged list for `useInfiniteLoad`: DataView's first-page states, virtual rows (or a page-scrolled grid), and a `LoadMore` row that loads on approach, shows a skeleton, or says why it failed with Try again. */
|
|
62
|
+
export declare function InfiniteList<T>({ state, label, children, skeleton, empty, moreLabel, moreSkeleton, end, rootMargin, keepAtLeast, scroll, listClassName, error, moreError, estimateSize, height, virtualizeFrom, className, }: InfiniteListProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** An item a job could not do, and why, in the product's words. */
|
|
3
|
+
export type JobFailure = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
reason: string;
|
|
7
|
+
};
|
|
8
|
+
/** A job's three states as words, all required: "Syncing", "Finished", "Finished with failures". */
|
|
9
|
+
export type JobWords = {
|
|
10
|
+
running: string;
|
|
11
|
+
finished: string;
|
|
12
|
+
failed: string;
|
|
13
|
+
};
|
|
14
|
+
/** The job status's props. */
|
|
15
|
+
export type JobStatusProps = {
|
|
16
|
+
/** What the job is ("Library sync"): names the section and the progress bar. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** The job is still going. */
|
|
19
|
+
running: boolean;
|
|
20
|
+
words: JobWords;
|
|
21
|
+
/** The app's sentence for where the job is or how it went: "Syncing 2 of 3: Night Sky." */
|
|
22
|
+
summary: string;
|
|
23
|
+
/** Items done or being done, with `total`, for the bar. */
|
|
24
|
+
current?: number;
|
|
25
|
+
/** Items in all, when known. No bar without it. */
|
|
26
|
+
total?: number;
|
|
27
|
+
/** Each item that failed, with its reason. Any failure makes a finished job `failed`'s word. */
|
|
28
|
+
failures?: JobFailure[];
|
|
29
|
+
/** The job failed as a whole, for a reason that names no item (the summary says it). */
|
|
30
|
+
failed?: boolean;
|
|
31
|
+
/** Names the list of failures for screen readers. Default "Failures". */
|
|
32
|
+
failuresLabel?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
/** A long-running server job: its state as a required word beside the app's sentence, a progress bar when the total is known, each failure named with its reason, and a polite announcement only when the item changes or the job ends. */
|
|
36
|
+
export declare function JobStatus({ label, running, words, summary, current, total, failures, failed, failuresLabel, className, }: JobStatusProps): React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** Props for `Popover`. */
|
|
3
|
+
export type PopoverProps = {
|
|
4
|
+
/** What the popover is, as a screen reader names it: "Line colour", "Filters". Required. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The control that opens it (a `Button`); it gets `aria-expanded` and focus back on close. */
|
|
7
|
+
trigger: React.ReactElement;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
10
|
+
/** Where along the trigger it lines up. Default `start`. */
|
|
11
|
+
align?: "start" | "center" | "end";
|
|
12
|
+
/** Controlled open state. */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
/** Width of the surface. Default `md` (18rem). */
|
|
16
|
+
size?: "sm" | "md" | "lg";
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
/** A floating panel anchored to its trigger, for a small form or choice. Requires a `label`; closes on Escape and outside press, and returns focus. */
|
|
20
|
+
export declare function Popover({ label, trigger, children, side, align, open, onOpenChange, size, className }: PopoverProps): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Props for `Switch`. */
|
|
2
|
+
export type SwitchProps = {
|
|
3
|
+
/** What it turns on, as the visible label: "Show elevation profile". Required. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** A muted second line under the label. */
|
|
6
|
+
detail?: string;
|
|
7
|
+
on?: boolean;
|
|
8
|
+
defaultOn?: boolean;
|
|
9
|
+
onChange?: (on: boolean) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
/** An on/off setting that applies at once, its label and control one target. */
|
|
14
|
+
export declare function Switch({ label, detail, on, defaultOn, onChange, disabled, className }: SwitchProps): import('react').JSX.Element;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
/** A width-over-height ratio: a number (`1.5`) or a fraction (`"4/3"`). */
|
|
3
3
|
export type AspectRatio = number | `${number}/${number}`;
|
|
4
|
-
/** The thumbnail's props. */
|
|
4
|
+
/** The thumbnail's props. Either `missing` (the words shown when there is no image) or a `fallback` drawing is required. */
|
|
5
5
|
export type ThumbnailProps = {
|
|
6
6
|
/** The image URL. `null` when the record has no photo: the `missing` words show without a request. */
|
|
7
7
|
src: string | null;
|
|
8
8
|
/** What the photo shows ("Celadon bowl, front"). `""` only when the text beside it already says it. */
|
|
9
9
|
alt: string;
|
|
10
|
-
/** What to show when there is no photo or it cannot be loaded, in the product's words: "Photo not found". */
|
|
11
|
-
missing: string;
|
|
12
10
|
/** Width over height. The box has this shape before the image loads. Default `1`. */
|
|
13
11
|
aspect?: AspectRatio;
|
|
14
12
|
/** `cover` crops to fill the box (default); `contain` fits the whole image in it. */
|
|
@@ -19,11 +17,23 @@ export type ThumbnailProps = {
|
|
|
19
17
|
eager?: boolean;
|
|
20
18
|
/** How far outside the scroll region the request starts (IntersectionObserver `rootMargin`). */
|
|
21
19
|
rootMargin?: string;
|
|
22
|
-
/** Layout at the call site: a width (`w-24`, `w-full`). The height follows from `aspect`. */
|
|
20
|
+
/** Layout at the call site: a width (`w-24`, `w-full`), or `rounded-pill` for an avatar. The height follows from `aspect`. */
|
|
23
21
|
className?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
/** Overlays drawn above the image in the same box (a running time, a "Saved" badge), in place whether the image has loaded, failed or is missing. */
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
} & ({
|
|
25
|
+
/** What to show when there is no photo or it cannot be loaded, in the product's words: "Photo not found". */
|
|
26
|
+
missing: string;
|
|
27
|
+
/** Drawn instead of the icon and `missing` words when there is no image: a letter on a disc for an avatar. */
|
|
28
|
+
fallback?: React.ReactNode;
|
|
29
|
+
} | {
|
|
30
|
+
/** Added to the missing state's name after `alt` ("Night Sky: No picture"), when given. */
|
|
31
|
+
missing?: string;
|
|
32
|
+
/** Drawn when there is no image or it cannot be loaded: a letter on a disc for an avatar. */
|
|
33
|
+
fallback: React.ReactNode;
|
|
34
|
+
});
|
|
35
|
+
/** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words (or a `fallback`) if it cannot, a request only when it nears the screen, and `children` overlaid in its corners. `alt` and `missing` or `fallback` are required. */
|
|
36
|
+
export declare function Thumbnail({ src, alt, missing, aspect, fit, srcSet, sizes, eager, rootMargin, className, fallback, children, }: ThumbnailProps): React.JSX.Element;
|
|
27
37
|
/** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */
|
|
28
38
|
export declare function ThumbnailSkeleton({ aspect, className }: {
|
|
29
39
|
aspect?: AspectRatio;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IconComponent } from '../lib/icon';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const sizes: {
|
|
4
|
+
readonly default: "h-(--control-h)";
|
|
5
|
+
readonly sm: "h-(--control-h-sm)";
|
|
6
|
+
};
|
|
7
|
+
type Size = keyof typeof sizes;
|
|
8
|
+
/** Props for `Toggle`. */
|
|
9
|
+
export type ToggleProps = {
|
|
10
|
+
/** The name, always. Shown as the text unless `icon` is given with `iconOnly`, then it is the accessible name and the tooltip. */
|
|
11
|
+
label: string;
|
|
12
|
+
icon?: IconComponent;
|
|
13
|
+
/** Show only the icon; `label` stays the name and tooltip. */
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
pressed?: boolean;
|
|
16
|
+
defaultPressed?: boolean;
|
|
17
|
+
onChange?: (pressed: boolean) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
size?: Size;
|
|
20
|
+
className?: string;
|
|
21
|
+
};
|
|
22
|
+
/** A button that is pressed or not (`aria-pressed`). Chosen reads as an ink border on a tint, never as the filled primary. */
|
|
23
|
+
export declare function Toggle({ label, icon, iconOnly, pressed, defaultPressed, onChange, disabled, size, className }: ToggleProps): React.JSX.Element;
|
|
24
|
+
/** One option of a `ToggleGroup`. */
|
|
25
|
+
export type ToggleOption = {
|
|
26
|
+
value: string;
|
|
27
|
+
label: string;
|
|
28
|
+
icon?: IconComponent;
|
|
29
|
+
iconOnly?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** Props for `ToggleGroup`. */
|
|
32
|
+
export type ToggleGroupProps = {
|
|
33
|
+
/** Names the group for screen readers: "Preview quality". Required. */
|
|
34
|
+
label: string;
|
|
35
|
+
options: readonly ToggleOption[];
|
|
36
|
+
value: string;
|
|
37
|
+
onChange: (value: string) => void;
|
|
38
|
+
size?: Size;
|
|
39
|
+
className?: string;
|
|
40
|
+
};
|
|
41
|
+
/** A single-choice set of toggle buttons for 2 to 7 short options that switch a view. One is always chosen; arrow keys move between them. */
|
|
42
|
+
export declare function ToggleGroup({ label, options, value, onChange, size, className }: ToggleGroupProps): React.JSX.Element;
|
|
43
|
+
export {};
|