@hackcove/ui-react 0.10.0 → 0.10.2
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 +2 -1
- package/dist/Callout.d.ts +2 -1
- package/dist/Callout.js +5 -2
- 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 +59 -0
- package/dist/CodeBlock.d.ts +8 -5
- package/dist/CodeBlock.js +6 -3
- package/dist/CodeBody.d.ts +3 -2
- package/dist/CodeBody.js +4 -2
- package/dist/CodeText.js +3 -0
- package/dist/Dialog.js +2 -2
- package/dist/Drawer.js +2 -2
- package/dist/EmptyState.js +2 -2
- package/dist/Icon.d.ts +4 -2
- package/dist/Icon.js +4 -2
- package/dist/Input.js +1 -1
- package/dist/InputShell.d.ts +9 -1
- package/dist/InputShell.js +18 -6
- package/dist/ToolCallCard.d.ts +16 -0
- package/dist/ToolCallCard.js +16 -0
- package/dist/control.js +1 -1
- package/dist/highlight.d.ts +8 -7
- package/dist/highlight.js +16 -2
- 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 +3 -3
- package/dist/icons.js +28 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/typography.d.ts +30 -3
- package/dist/typography.js +56 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,7 @@ takes the size of the text around it. Upgrading: `MIGRATING.md`, shipped in the
|
|
|
72
72
|
- Data: `StatTile` (one headline figure: an uppercase `label` over a large tabular `value`, already formatted, an optional `hint` under it; `tone` is `neutral` (default), `positive` or `negative`, and `accent` adds a bar across the top in the same tone), `ProgressBar` (a thin bar with a filled share of `max` (default 100); `label` names it for a screen reader, which also hears the percentage; `tone` is `accent` (default), `positive`, `warn` or `negative`), `SplitBar` (a bar split between `a` and `b` by their shares; `names` says whose is whose to a screen reader; `toneA` (default `negative`) and `toneB` (default `positive`)), `StackedBar` (any number of `segments`, each `{ label, value, tone }`, sized by its share of the sum; `legend` draws a `Legend` under it) and `Legend` (a swatch, a `label` and an optional `detail` per item, the key to a chart's or a row stripe's colours). The three bars take `size`: `sm` 6px, `md` 8px (default), `lg` 12px.
|
|
73
73
|
- Status pages: `NotFound` (404), `ErrorPage` (500 or any failure; `detail` is error text shown in a `CodeBlock`, never a stack trace, and `onRetry` adds "Try again"), `Offline` (`onRetry` too), `Maintenance` and `Forbidden` (403). Each is a whole page with default copy: `title` and `children` replace the heading and the body, `action` is the primary action, and `homeHref`, or `renderHome` for the app's own router `<Link>`, adds a "Back to home" button. With neither there is no home link.
|
|
74
74
|
- Layout (see Layout): `AppShell`, `AppShellBrand`, `appShellRootClassFor`, `Container`, `PageHeader`, `Stack`, `Section`, `Cluster`, `ClusterGrow`, `SideColumn`, and the page layouts `ListLayout`, `DetailLayout`, `FormLayout`, `ProseLayout`, `CardGrid`, `SidebarLayout`, `FullBleedLayout`, `CenteredLayout`.
|
|
75
|
+
- `Prose` (a `div` for long-form content, a docs page or an article, never an app screen: it sets text-base/7 and puts `Text`, `SectionHeading`, `SubsectionHeading` and the `Callout` text on the long-form scale inside it, body 16, h4 16 semibold, h3 20 and h2 24; every other role keeps its size, and a `Dialog`, `Drawer` or `EmptyState` inside it keeps the app sizes; it takes no `className`, `style` or size prop).
|
|
75
76
|
- Typography roles (each pins size + weight, takes a `color` and an `as`): `Display`, `Lead`,
|
|
76
77
|
`PageHeading`, `SectionHeading`, `SubsectionHeading`, `Overline`, `Text`, `Caption`. Opt-in props, none changing today's look: `SectionHeading rule`
|
|
77
78
|
(a hairline under it, with its spacing), `SubsectionHeading size` (`sm`, `md` default, `lg`) and `truncate` (one line with an ellipsis),
|
|
@@ -80,7 +81,7 @@ takes the size of the text around it. Upgrading: `MIGRATING.md`, shipped in the
|
|
|
80
81
|
text colours as a `TableCell` tone, winning over `color`; pair the colour with a word, as in "Saved."),
|
|
81
82
|
`numeric` (tabular figures), `mono` (the monospace face) and `truncate` (one line, cut with an
|
|
82
83
|
ellipsis, the full text in a `title`, so its content is text).
|
|
83
|
-
- Controls: `Button` (`variant` is `primary` (default), `outline`, `ghost`, `link` or `dashed`, the link having no box: text with an underline on hover, for an in-line action, and the dashed one a dashed outline in muted text that fills its container, like `Card dashed`, for an "add another" row, with a leading icon as a child, ignoring `tone`; `size="sm"` is compact, `text-xs`, for table rows and toolbars, `size="lg"` is `text-base` with more padding; `tone="danger"` is red, for delete and clear, and `tone="positive"` green, for accept and approve; `disabledReason` disables it, greys it flat and makes the reason its `title`; `busy` disables it with `aria-busy` and keeps its colour, showing `busyLabel` in place of the children; `pressed` makes it a toggle with `aria-pressed`, on `outline` and `ghost` neutral when off and filled in the tone's primary colour when on, so an `outline` `size="sm"` Button with `pressed` is a filter chip; `count` puts a small number chip after the label, part of the button's name ("Splits, 3"), and a button that opens something also takes `aria-expanded`; with `href`, or `render` to draw the app's own router `<Link>`, it is a link with the same look, `external` opening a new tab), `ButtonGroup` (a wrapping row of buttons; `end` is one item pushed to the far side, `label` makes it a named `role="group"`), `IconButton` (a square button holding one icon; `label` is required and becomes its `aria-label` and `title`; `variant` is `outline` (default) or `ghost`, `tone` is `default` or `danger`, `size` matches a `Button`'s height; `badge` puts a red count on its corner, not shown at 0; with `href` or `render` it is a link, `external` opening a new tab), `Icon` (one bare `<svg>` sized to fill a box, or `name` for one of the set's own icons (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`, `speed`: one 24 grid, a 1.5 stroke, round caps and joins, each the idea and not a product): `size` `sm` 14px, `md` 16px (default), `lg` 20px or `feature` 32px; `tone` is a text tone or `inherit` (default, the text colour around it); `aria-hidden` unless `label` names it as `role="img"`), `ColourSchemeToggle` (a light/dark switch on `<html>`; `id`, `data-*` and other button props go on the button, `store={false}` skips `localStorage`; see Light and dark), `Input` (a text input; `icon` adds a leading icon inside the field; `prefix` is short text inside the border before the value, a currency symbol, on a plain field only; `type="search"` drops the browser's search look and shows a "Clear search" button while the field has a value), `Textarea` (a multi-line text input, `rows` defaults to 3), `Select` (a native `<select>` in the control look; takes `<option>` children and keeps the browser's arrow). `Input`, `Select` and `Textarea` take `size` (`md` default, `sm`: `text-xs`, less padding, for dense forms and table rows, or `lg`: `text-base`, more padding) and `width` (`full` default, the fixed `xs` 5rem, `sm` 7rem, `md` 9rem, `lg` 12rem, `fill`: grows to the room left in a flex row and can shrink to nothing, so the buttons beside it stay on the line, or `auto`: no width class, as wide as the browser makes it); a fixed width replaces `w-full`, so there is no class to collide with. `Input` also takes `align` (`start` default, or `end` to right-align a numeric value). `size` replaces the native `size` attribute, so a multi-row `<select size={4}>` is not reachable through `Select`. `Checkbox` (a native checkbox with its label; other props go on the input; `size="sm"` is `text-xs` with a smaller box and `size="lg"` `text-base` with a larger one, `align="start"` puts the box on the first line of a label that wraps, where the default `center` centres it on all of them, and with no `label` it is a bare box for a table cell, named by `aria-label`; `description` is a muted line under the label, the box's `aria-describedby`). `Switch` (an on/off setting that acts at once, usually by saving to a server: a native `<button role="switch" aria-checked>`, controlled only, with `checked` and `onChange(next)`; give it a `label` (the whole label is the click target) or, with none, an `aria-label`: one is required; `description` is a muted line under the label and its `aria-describedby`; `size` is `sm`, `md` (default) or `lg`; `busy` is the save in flight: `aria-busy`, a click or key does nothing, it keeps its colour and its focus; `disabled` is the native one, washed out; a value sent with a form stays a `Checkbox`). `RadioGroup` and `Radio` (one choice from a few options: the group has a `label`, `value`/`onChange` or `defaultValue`, `name`, `isDisabled`, `isRequired`, `size` (`sm`, `md` default, `lg`, as `Checkbox`) and an `error` shown like `Field`'s with `role="alert"`; each `Radio` has a `value`, a `label`, an optional `description` and `isDisabled`; one tab stop, the arrow keys move and choose). `Disclosure` (a summary button with a chevron and `aria-expanded` over a body that opens and closes; `summary`, `children`, `defaultOpen`; it keeps its own state and replaces `<details>`). `FileDrop` (a dashed drop zone, a `<label>` around a file input that covers it, so a click opens the dialog and a dropped file lands on the input; `children` is the prompt, `accept`, `multiple`, `name`, `disabled` and `onChange` on the input). `CopyButton` (a small text button that writes `text` to the clipboard and swaps `label` ("copy") for `copiedLabel` ("copied"); every other button prop, `disabled` included, goes on the `<button>`). `CopyLine` (one line of mono text in a box with a `CopyButton` beside it; `disabled` disables the button; other props go on the root `<div>`). `Field` (a label above a control, `htmlFor` names the control's id; `hideLabel` keeps the label for assistive tech and draws no text, for a control whose purpose is plain from what surrounds it, and makes `layout="row"` a column; a `hint` sits under it, and an `error` replaces the hint with a `role="alert"` line; `span="full"` runs it across both columns of a `FormGrid`). `FormGrid` (two columns of `Field`s from `md`, one below it), `FormRow` (an inline-edit row: `FormRowField`s side by side, an `action` after them, and one `hint` or `error` under the whole row; see Layout) and `FormRowField` (a compact label over one control, `span` 1 to 4). `Callout` (a tinted notice box; `tone` is `neutral`, `info` (default), `positive`, `warn` or `danger`; an optional `title` sits in bold above the body; `actions` puts a button or link at the end of the row; `banner` makes it a flat strip, bottom border only and no radius, for the top of a `Card flush`). `ListRow` (a full-width row that is a `<button>`, or a link with `href` or `render`, with a hover fill, a left-aligned label and `trailing` content; `divided` draws a hairline above the row, to separate rows in a `Card flush`; `expanded` makes it the header of a collapsible section: `aria-expanded` and a chevron, the caller owning the state and the section; `leading` is content before the label (an `Avatar`), and `leadingWidth="thumbnail"` gives it a fixed width so rows with and without a picture line up; `size` sets the padding (`sm` dense, `md` default, `lg`); `focused` draws the focus ring on the row the keyboard cursor is on, for a list moved with the arrow keys while focus stays on the list; `selected` marks the row in view with a violet fill and `aria-current="true"`; a link row (`href` or `render`) can hold its own link, button or control in `trailing`, which sits above the row's link and takes its own click; `static` makes it a plain `<div>`, for a row that holds its own buttons where the row would otherwise be a `<button>`, and adds `actions`, buttons after `trailing`, and `revealOnHover`, which shows them only on hover or focus inside the row and always on a touch screen; a compact bordered list is `Card flush` around `static` rows at `size="sm"`, `divided` after the first (no separate part); `active` marks the row the pointer or the keyboard is on, with the hover fill and the `revealOnHover` actions shown, for a list that follows both through the row's `onPointerEnter`, `onPointerLeave` and `onFocus`, which every row passes through). `Tabs` (underline tabs for switching a view in place: a row over a bottom rule, the current tab underlined in the accent; `items` are `{ value, label }` buttons, with `value` the current one's `value` and `onChange(value)` the caller's state, one tab stop and the arrow keys, Home and End moving between enabled tabs, or `{ label, href | render, active?, external? }` links in a `<nav>` with `aria-current="page"` on the current one (`active`, or the item whose `value` is `value`); `label` names the group; a button tab takes `disabled` and `controls`, the id of its `role="tabpanel"`, which is the caller's; `variant="pill"` fills the current tab, with no rule, for `PageHeader`'s `tabs` slot, an `AppShell` `nav` or a rail; only a pill row takes `size` and `orientation`, and `orientation="vertical"` stacks it in one column, the content of a `SidebarLayout` rail; `disabled` on the row disables every tab, e.g. until hydration). `SegmentedControl` (a joined pill group, one option filled; the same `items`, `value`, `onChange`, `disabled` and `label` as `Tabs`, as a `radiogroup` with `aria-checked` on each `radio`). On both an item takes `data-*` attributes (typed `data-${string}`) onto its button or link; on `Tabs` and `SegmentedControl` an item takes `count` (a small muted number after the label, part of its name: "Shots 12") and `title`; a `disabled` button option stays in the page as `aria-disabled`, so its `title` is still the hover tooltip and is announced as the reason, it is out of the tab order and the arrow keys, Home and End skip it. `Dialog` (a modal on the browser's `<dialog>`, opened on mount, so render it only while open: `title` is its name, `description` a line under it, `footer` the right-aligned actions; Esc, the backdrop or a `<form method="dialog">` call `onClose`; `size` is `sm` (320px, a list), `md` (440px, default, a form), `lg` (640px, a wider form or a table) or `full` (the whole screen, for media or a player: the body fills the height between the title and the footer and scrolls if taller; there is no backdrop to click, so put a close button on a `<form method="dialog">` in the `footer`)). `FieldDialog` (a `Dialog` with one text field and Cancel and submit buttons, every string passed in: `title`, `description`, `label`, `inputLabel`, `placeholder`, `hint`, `emptyReason`, `submit` and `busyLabel`; `onSubmit` gets the trimmed value and a resolved promise closes it, a rejection shows its message). `Drawer` (a modal slide-over on the right edge, on a native `<dialog>` opened on mount like `Dialog`, so render it only while open: `title` is its name, a close button sits beside it, `children` scroll between the header and an optional pinned `footer`; Esc, the scrim and the close button call `onClose`; `size` is `sm`, `md` (default) or `lg`; `closeLabel` names the close button). `Breadcrumbs` (a `<nav aria-label="Breadcrumb">` over an ordered list; `crumbs` are nodes, or `{ label, href | render, external? }` for one that links; the last is the current page and is never a link and gets `aria-current="page"`, and each crumb truncates). `Table` (a list of records in a rounded, bordered card around a full-width `<table>` that scrolls sideways on a narrow screen; `caption` names it for assistive tech and is not drawn; compose it from `TableHead`, `TableBody`, `TableFoot`, `TableRow`, `TableHeaderCell` (`align` `start`, `center` or `end`; `srLabel` is a visually hidden column name, in place of children, for a column of row actions: "Actions") and `TableCell` (`align`, `indent` of 1 to 3 to set a start-aligned cell in, for a line under a parent row, `tone` `default`, `strong` or `muted`, or the Callout tones `neutral`, `info`, `positive`, `warn` or `danger` for an amount that means something, in the tone's text colour and with no fill, so pair the colour with a sign or a word; `numeric` for tabular figures, `mono` for a small mono face, `truncate` to cap a long value's width, cut it with an ellipsis and put the full text in a `title`, so its content is text (strings and numbers); `secondary` for a second, muted line under the content; `colSpan` passes through, so a `TableCell` with `colSpan` in a row of its own is a full-width panel, an empty state or a note, centred with `align="center"`); `TableEditCell` (a `TableCell` whose value opens an editor in place: `children` is the value, drawn as a button; a click, Enter or Space swaps it for `renderEditor(close)`, a plain control in the cell and not a popover of its own, and moves the focus into it; `close` and Esc put the focus back on the value, and a press outside or Tab out of it closes it too, so the control saves on its own change or submit; `label` names the button and the editor; it takes the `TableCell` props except `truncate`); `InlineEdit` (the same edit trigger without the cell, for a `TableCell` that holds other content too: `label`, `renderEditor(close)` and `children`, with the same keyboard and focus behaviour); `TableFoot` (the `<tfoot>` for totals: its cells are strong by default and each row has a firmer line above it, in a card and in a `plain` table alike); `TableGroupRow` (a full-width group header in the body: `label` spans `colSpan` columns, the table's column count, which is required; optional `trailing` content sits at the far end, and the group's rows follow it); `tone` on a `TableRow` in the body marks the row with a stripe on its leading edge over a soft fill: `neutral`, `info`, `positive`, `warn` or `danger`, as `Callout`, or `muted`, which only fades the row (a transfer, a row that is not the point); a bold subtotal is not a tone: `emphasis` on a `TableRow` in the body gives it a `TableFoot` row's look among the other rows; `stripe` (a text tone) draws the leading stripe alone, with no fill; a row takes one of `tone`, `stripe` and `emphasis`; `variant="plain"` on `Table` drops the card border, fill and shadow, the head strip and the row hover and keeps the row dividers, for a table inside a card of its own; every table element passes `id`, `data-*` and `aria-*` through, and none takes a `className` or `style`). `Timeline` (a named `<ol>` of events; `label` is its `aria-label`, `empty` is drawn instead when there are no items) with `TimelineItem` (a `title`, an already-formatted `time`, the `children` as a note, and `tone`, a Callout tone for the marker dot, `neutral` by default). `KeyValueList` (a `<dl>` of label/value rows; each `KeyValue` takes a `label` and its value as children, the value right-aligned in tabular figures; `total` makes it the sum row, a firm rule above and strong text, and `tone` (`muted`, `positive`, `warn`, `danger`, `info`) colours the value on any row, so `total tone="warn"` is a total that does not reconcile; `align="start"` puts the values left-aligned in one column beside the labels instead, using CSS subgrid: in Chrome before 117 a row stacks its label over its value). `Avatar` (a round badge of the initials of `name`, titled with the name and `aria-hidden`; with `src` (the app's own local image path, never a remote one) it is a round, cropped `<img alt={name}>` instead, and if that image fails to load it shows the initials; `size` is `xs` (16px, for an inline mention), `sm`, `md` (default), `lg`, `xl` (56px), `2xl` (64px) or `3xl` (96px); `onClick` makes it one button named by `name`; `ring` adds a page-colour border and a negative margin for an overlapping stack; the colour is one of seven stock background classes picked by a hash of the name, remapped by each theme, and `avatarColourClass(name)` returns it to colour something else the same way; `initialsOf(name)` is the two letters). `TextLink` (an inline text link in the accent colour; `href` is required unless `render` draws the app's own router `<Link>`, `external` adds `target="_blank"` and `rel="noreferrer"`, `stretch` covers the nearest `relative` ancestor so a whole row or card is the click target, `size` (`sm`, `md` or `lg`) pins the type size where it would otherwise follow the text around it, `mono` sets the monospace face, `tone` (`warn`, `danger`, `positive`, `info` or `muted`) gives it a meaning's colour in place of the accent, every other anchor prop passes through). `MetaList` (a wrapping row of facts or links in muted small text, joined by an `aria-hidden` `separator`: `·` (default), `•` or `none`; branch · SHA · date, or a footer's Privacy · Terms; an item is text, a `Code` or a `TextLink`; `nowrap` keeps each item on one line, for links; `mono` sets the row in the monospace face, for ids and paths). `PageFade` (the page's content area, named for the View Transitions API so a route change cross-fades it while the frame around it stays put; wrap what changes between pages, once per page, or give each a `name` (a CSS identifier) when there are two; it fades when the navigation runs in a view transition, through `startPageTransition(update)` (flushes a synchronous state change inside `document.startViewTransition`) or a router's own option such as TanStack Router `viewTransition`, and otherwise, in a browser without View Transitions, or under `prefers-reduced-motion: reduce`, it swaps with no fade; it renders a small `<style>`, with no colour in it, and the div is a stacking context, so portal an overlay that must rise above the frame). `EmptyState` (what a page or list shows when it has nothing yet: a centred `title`, the `children` as the explanation under it, and `actions` in a centred row; a named `<section>`; `level` is the title's heading level, 2 (default) to 6, and does not change its look; for one muted line inside a card, `Text as="p" color="muted"`). `Steps` (a numbered `<ol>` of `Step`s, each a `title` and the `children` as a detail line, the numbers counted by CSS in a violet disc; for a "get started" list, not for progress). `Divider` (a hairline `<hr>` in the theme's line colour; spacing comes from the layout around it). `BulletList` (a `<ul>` with discs, an indent and a small gap; children are `<li>`s). `Code` (inline code: mono, on a subtle background). `CodeBlock` (a block of code, no client JS: the text is `children` (a string) or `lines` (one entry per line), `language` (`bash`, `css`, `tsx`, `ts` or `json`) colours it and `text`, the default, leaves it in one colour; `label` is a caption naming the language or file; long lines wrap by default, so nothing is cut off and a command copies as one line, and `overflow="scroll"` keeps lines whole and scrolls them under a thin scrollbar in the theme's muted ink; `copy` adds a copy button beside the code, which copies it exactly as given and needs the page hydrated; other props go on the root `<figure>`). `CodeExample` (one framed example: the rendered `children` over the `code` that makes them, coloured as TSX, in one bordered box, with an optional `caption` as its last band; a wide preview or long code scrolls inside the frame under the same thin scrollbar; `copy` adds a button that copies the code; no client JS without `copy`). `Video` (a full-width, rounded `<video>` with controls that loads metadata only; `src` is required, `poster` and a WebVTT `captions` track are optional, children are the fallback). `Kbd` (a keyboard key in mono; its border takes the surrounding text colour, so it reads on a filled button too). `FilterGroup` (a `<fieldset>` with a small uppercase `legend` over a wrapped row of its children, e.g. `outline` `sm` `Button`s with `pressed`). `DateField` (see Dates).
|
|
84
|
+
- Controls: `Button` (`variant` is `primary` (default), `outline`, `ghost`, `link` or `dashed`, the link having no box: text with an underline on hover, for an in-line action, and the dashed one a dashed outline in muted text that fills its container, like `Card dashed`, for an "add another" row, with a leading icon as a child, ignoring `tone`; `size="sm"` is compact, `text-xs`, for table rows and toolbars, `size="lg"` is `text-base` with more padding; `tone="danger"` is red, for delete and clear, and `tone="positive"` green, for accept and approve; `disabledReason` disables it, greys it flat and makes the reason its `title`; `busy` disables it with `aria-busy` and keeps its colour, showing `busyLabel` in place of the children; `pressed` makes it a toggle with `aria-pressed`, on `outline` and `ghost` neutral when off and filled in the tone's primary colour when on, so an `outline` `size="sm"` Button with `pressed` is a filter chip; `count` puts a small number chip after the label, part of the button's name ("Splits, 3"), and a button that opens something also takes `aria-expanded`; with `href`, or `render` to draw the app's own router `<Link>`, it is a link with the same look, `external` opening a new tab), `ButtonGroup` (a wrapping row of buttons; `end` is one item pushed to the far side, `label` makes it a named `role="group"`), `IconButton` (a square button holding one icon; `label` is required and becomes its `aria-label` and `title`; `variant` is `outline` (default) or `ghost`, `tone` is `default` or `danger`, `size` matches a `Button`'s height; `badge` puts a red count on its corner, not shown at 0; with `href` or `render` it is a link, `external` opening a new tab), `Icon` (one bare `<svg>` sized to fill a box, or `name` for one of the set's own icons (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`, `speed`, `search`, `chevron-right`, `chevron-down`, `close`, `external-link`, `settings`, `bell`, `check`, `plus`: feature ideas and UI glyphs on one 24 grid, a 1.5 stroke, round caps and joins, each the idea or action, not a product): `size` `sm` 14px, `md` 16px (default), `lg` 20px or `feature` 32px; `tone` is a text tone or `inherit` (default, the text colour around it); `aria-hidden` unless `label` names it as `role="img"`), `ColourSchemeToggle` (a light/dark switch on `<html>`; `id`, `data-*` and other button props go on the button, `store={false}` skips `localStorage`; see Light and dark), `Input` (a text input; `icon` adds a leading icon inside the field; `prefix` is short text inside the border before the value, a currency symbol, on a plain field only; `type="search"` drops the browser's search look and shows a "Clear search" button while the field has a value), `Textarea` (a multi-line text input, `rows` defaults to 3), `Select` (a native `<select>` in the control look; takes `<option>` children and keeps the browser's arrow). `Input`, `Select` and `Textarea` take `size` (`md` default, `sm`: `text-xs`, less padding, for dense forms and table rows, or `lg`: `text-base`, more padding) and `width` (`full` default, the fixed `xs` 5rem, `sm` 7rem, `md` 9rem, `lg` 12rem, `fill`: grows to the room left in a flex row and can shrink to nothing, so the buttons beside it stay on the line, or `auto`: no width class, as wide as the browser makes it); a fixed width replaces `w-full`, so there is no class to collide with. `Input` also takes `align` (`start` default, or `end` to right-align a numeric value). `size` replaces the native `size` attribute, so a multi-row `<select size={4}>` is not reachable through `Select`. `Checkbox` (a native checkbox with its label; other props go on the input; `size="sm"` is `text-xs` with a smaller box and `size="lg"` `text-base` with a larger one, `align="start"` puts the box on the first line of a label that wraps, where the default `center` centres it on all of them, and with no `label` it is a bare box for a table cell, named by `aria-label`; `description` is a muted line under the label, the box's `aria-describedby`). `Switch` (an on/off setting that acts at once, usually by saving to a server: a native `<button role="switch" aria-checked>`, controlled only, with `checked` and `onChange(next)`; give it a `label` (the whole label is the click target) or, with none, an `aria-label`: one is required; `description` is a muted line under the label and its `aria-describedby`; `size` is `sm`, `md` (default) or `lg`; `busy` is the save in flight: `aria-busy`, a click or key does nothing, it keeps its colour and its focus; `disabled` is the native one, washed out; a value sent with a form stays a `Checkbox`). `RadioGroup` and `Radio` (one choice from a few options: the group has a `label`, `value`/`onChange` or `defaultValue`, `name`, `isDisabled`, `isRequired`, `size` (`sm`, `md` default, `lg`, as `Checkbox`) and an `error` shown like `Field`'s with `role="alert"`; each `Radio` has a `value`, a `label`, an optional `description` and `isDisabled`; one tab stop, the arrow keys move and choose). `Disclosure` (a summary button with a chevron and `aria-expanded` over a body that opens and closes; `summary`, `children`, `defaultOpen`; it keeps its own state and replaces `<details>`). `FileDrop` (a dashed drop zone, a `<label>` around a file input that covers it, so a click opens the dialog and a dropped file lands on the input; `children` is the prompt, `accept`, `multiple`, `name`, `disabled` and `onChange` on the input). `CopyButton` (a small text button that writes `text` to the clipboard and swaps `label` ("copy") for `copiedLabel` ("copied"); every other button prop, `disabled` included, goes on the `<button>`). `CopyLine` (one line of mono text in a box with a `CopyButton` beside it; `disabled` disables the button; other props go on the root `<div>`). `Field` (a label above a control, `htmlFor` names the control's id; `hideLabel` keeps the label for assistive tech and draws no text, for a control whose purpose is plain from what surrounds it, and makes `layout="row"` a column; a `hint` sits under it, and an `error` replaces the hint with a `role="alert"` line; `span="full"` runs it across both columns of a `FormGrid`). `FormGrid` (two columns of `Field`s from `md`, one below it), `FormRow` (an inline-edit row: `FormRowField`s side by side, an `action` after them, and one `hint` or `error` under the whole row; see Layout) and `FormRowField` (a compact label over one control, `span` 1 to 4). `Callout` (a tinted notice box; `tone` is `neutral`, `info` (default), `positive`, `warn` or `danger`; an optional `title` sits in bold above the body; `actions` puts a button or link at the end of the row; `banner` makes it a flat strip, bottom border only and no radius, for the top of a `Card flush`). `ListRow` (a full-width row that is a `<button>`, or a link with `href` or `render`, with a hover fill, a left-aligned label and `trailing` content; `divided` draws a hairline above the row, to separate rows in a `Card flush`; `expanded` makes it the header of a collapsible section: `aria-expanded` and a chevron, the caller owning the state and the section; `leading` is content before the label (an `Avatar`), and `leadingWidth="thumbnail"` gives it a fixed width so rows with and without a picture line up; `size` sets the padding (`sm` dense, `md` default, `lg`); `focused` draws the focus ring on the row the keyboard cursor is on, for a list moved with the arrow keys while focus stays on the list; `selected` marks the row in view with a violet fill and `aria-current="true"`; a link row (`href` or `render`) can hold its own link, button or control in `trailing`, which sits above the row's link and takes its own click; `static` makes it a plain `<div>`, for a row that holds its own buttons where the row would otherwise be a `<button>`, and adds `actions`, buttons after `trailing`, and `revealOnHover`, which shows them only on hover or focus inside the row and always on a touch screen; a compact bordered list is `Card flush` around `static` rows at `size="sm"`, `divided` after the first (no separate part); `active` marks the row the pointer or the keyboard is on, with the hover fill and the `revealOnHover` actions shown, for a list that follows both through the row's `onPointerEnter`, `onPointerLeave` and `onFocus`, which every row passes through). `Tabs` (underline tabs for switching a view in place: a row over a bottom rule, the current tab underlined in the accent; `items` are `{ value, label }` buttons, with `value` the current one's `value` and `onChange(value)` the caller's state, one tab stop and the arrow keys, Home and End moving between enabled tabs, or `{ label, href | render, active?, external? }` links in a `<nav>` with `aria-current="page"` on the current one (`active`, or the item whose `value` is `value`); `label` names the group; a button tab takes `disabled` and `controls`, the id of its `role="tabpanel"`, which is the caller's; `variant="pill"` fills the current tab, with no rule, for `PageHeader`'s `tabs` slot, an `AppShell` `nav` or a rail; only a pill row takes `size` and `orientation`, and `orientation="vertical"` stacks it in one column, the content of a `SidebarLayout` rail; `disabled` on the row disables every tab, e.g. until hydration). `SegmentedControl` (a joined pill group, one option filled; the same `items`, `value`, `onChange`, `disabled` and `label` as `Tabs`, as a `radiogroup` with `aria-checked` on each `radio`). On both an item takes `data-*` attributes (typed `data-${string}`) onto its button or link; on `Tabs` and `SegmentedControl` an item takes `count` (a small muted number after the label, part of its name: "Shots 12") and `title`; a `disabled` button option stays in the page as `aria-disabled`, so its `title` is still the hover tooltip and is announced as the reason, it is out of the tab order and the arrow keys, Home and End skip it. `Dialog` (a modal on the browser's `<dialog>`, opened on mount, so render it only while open: `title` is its name, `description` a line under it, `footer` the right-aligned actions; Esc, the backdrop or a `<form method="dialog">` call `onClose`; `size` is `sm` (320px, a list), `md` (440px, default, a form), `lg` (640px, a wider form or a table) or `full` (the whole screen, for media or a player: the body fills the height between the title and the footer and scrolls if taller; there is no backdrop to click, so put a close button on a `<form method="dialog">` in the `footer`)). `FieldDialog` (a `Dialog` with one text field and Cancel and submit buttons, every string passed in: `title`, `description`, `label`, `inputLabel`, `placeholder`, `hint`, `emptyReason`, `submit` and `busyLabel`; `onSubmit` gets the trimmed value and a resolved promise closes it, a rejection shows its message). `Drawer` (a modal slide-over on the right edge, on a native `<dialog>` opened on mount like `Dialog`, so render it only while open: `title` is its name, a close button sits beside it, `children` scroll between the header and an optional pinned `footer`; Esc, the scrim and the close button call `onClose`; `size` is `sm`, `md` (default) or `lg`; `closeLabel` names the close button). `Breadcrumbs` (a `<nav aria-label="Breadcrumb">` over an ordered list; `crumbs` are nodes, or `{ label, href | render, external? }` for one that links; the last is the current page and is never a link and gets `aria-current="page"`, and each crumb truncates). `Table` (a list of records in a rounded, bordered card around a full-width `<table>` that scrolls sideways on a narrow screen; `caption` names it for assistive tech and is not drawn; compose it from `TableHead`, `TableBody`, `TableFoot`, `TableRow`, `TableHeaderCell` (`align` `start`, `center` or `end`; `srLabel` is a visually hidden column name, in place of children, for a column of row actions: "Actions") and `TableCell` (`align`, `indent` of 1 to 3 to set a start-aligned cell in, for a line under a parent row, `tone` `default`, `strong` or `muted`, or the Callout tones `neutral`, `info`, `positive`, `warn` or `danger` for an amount that means something, in the tone's text colour and with no fill, so pair the colour with a sign or a word; `numeric` for tabular figures, `mono` for a small mono face, `truncate` to cap a long value's width, cut it with an ellipsis and put the full text in a `title`, so its content is text (strings and numbers); `secondary` for a second, muted line under the content; `colSpan` passes through, so a `TableCell` with `colSpan` in a row of its own is a full-width panel, an empty state or a note, centred with `align="center"`); `TableEditCell` (a `TableCell` whose value opens an editor in place: `children` is the value, drawn as a button; a click, Enter or Space swaps it for `renderEditor(close)`, a plain control in the cell and not a popover of its own, and moves the focus into it; `close` and Esc put the focus back on the value, and a press outside or Tab out of it closes it too, so the control saves on its own change or submit; `label` names the button and the editor; it takes the `TableCell` props except `truncate`); `InlineEdit` (the same edit trigger without the cell, for a `TableCell` that holds other content too: `label`, `renderEditor(close)` and `children`, with the same keyboard and focus behaviour); `TableFoot` (the `<tfoot>` for totals: its cells are strong by default and each row has a firmer line above it, in a card and in a `plain` table alike); `TableGroupRow` (a full-width group header in the body: `label` spans `colSpan` columns, the table's column count, which is required; optional `trailing` content sits at the far end, and the group's rows follow it); `tone` on a `TableRow` in the body marks the row with a stripe on its leading edge over a soft fill: `neutral`, `info`, `positive`, `warn` or `danger`, as `Callout`, or `muted`, which only fades the row (a transfer, a row that is not the point); a bold subtotal is not a tone: `emphasis` on a `TableRow` in the body gives it a `TableFoot` row's look among the other rows; `stripe` (a text tone) draws the leading stripe alone, with no fill; a row takes one of `tone`, `stripe` and `emphasis`; `variant="plain"` on `Table` drops the card border, fill and shadow, the head strip and the row hover and keeps the row dividers, for a table inside a card of its own; every table element passes `id`, `data-*` and `aria-*` through, and none takes a `className` or `style`). `Timeline` (a named `<ol>` of events; `label` is its `aria-label`, `empty` is drawn instead when there are no items) with `TimelineItem` (a `title`, an already-formatted `time`, the `children` as a note, and `tone`, a Callout tone for the marker dot, `neutral` by default). `KeyValueList` (a `<dl>` of label/value rows; each `KeyValue` takes a `label` and its value as children, the value right-aligned in tabular figures; `total` makes it the sum row, a firm rule above and strong text, and `tone` (`muted`, `positive`, `warn`, `danger`, `info`) colours the value on any row, so `total tone="warn"` is a total that does not reconcile; `align="start"` puts the values left-aligned in one column beside the labels instead, using CSS subgrid: in Chrome before 117 a row stacks its label over its value). `Avatar` (a round badge of the initials of `name`, titled with the name and `aria-hidden`; with `src` (the app's own local image path, never a remote one) it is a round, cropped `<img alt={name}>` instead, and if that image fails to load it shows the initials; `size` is `xs` (16px, for an inline mention), `sm`, `md` (default), `lg`, `xl` (56px), `2xl` (64px) or `3xl` (96px); `onClick` makes it one button named by `name`; `ring` adds a page-colour border and a negative margin for an overlapping stack; the colour is one of seven stock background classes picked by a hash of the name, remapped by each theme, and `avatarColourClass(name)` returns it to colour something else the same way; `initialsOf(name)` is the two letters). `TextLink` (an inline text link in the accent colour; `href` is required unless `render` draws the app's own router `<Link>`, `external` adds `target="_blank"` and `rel="noreferrer"`, `stretch` covers the nearest `relative` ancestor so a whole row or card is the click target, `size` (`sm`, `md` or `lg`) pins the type size where it would otherwise follow the text around it, `mono` sets the monospace face, `tone` (`warn`, `danger`, `positive`, `info` or `muted`) gives it a meaning's colour in place of the accent, every other anchor prop passes through). `MetaList` (a wrapping row of facts or links in muted small text, joined by an `aria-hidden` `separator`: `·` (default), `•` or `none`; branch · SHA · date, or a footer's Privacy · Terms; an item is text, a `Code` or a `TextLink`; `nowrap` keeps each item on one line, for links; `mono` sets the row in the monospace face, for ids and paths). `PageFade` (the page's content area, named for the View Transitions API so a route change cross-fades it while the frame around it stays put; wrap what changes between pages, once per page, or give each a `name` (a CSS identifier) when there are two; it fades when the navigation runs in a view transition, through `startPageTransition(update)` (flushes a synchronous state change inside `document.startViewTransition`) or a router's own option such as TanStack Router `viewTransition`, and otherwise, in a browser without View Transitions, or under `prefers-reduced-motion: reduce`, it swaps with no fade; it renders a small `<style>`, with no colour in it, and the div is a stacking context, so portal an overlay that must rise above the frame). `EmptyState` (what a page or list shows when it has nothing yet: a centred `title`, the `children` as the explanation under it, and `actions` in a centred row; a named `<section>`; `level` is the title's heading level, 2 (default) to 6, and does not change its look; for one muted line inside a card, `Text as="p" color="muted"`). `Steps` (a numbered `<ol>` of `Step`s, each a `title` and the `children` as a detail line, the numbers counted by CSS in a violet disc; for a "get started" list, not for progress). `Divider` (a hairline `<hr>` in the theme's line colour; spacing comes from the layout around it). `BulletList` (a `<ul>` with discs, an indent and a small gap; children are `<li>`s). `Code` (inline code: mono, on a subtle background). `CodeBlock` (a block of code, no client JS: the text is `children` (a string) or `lines` (one entry per line), `language` (`text` (default, one colour), `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`) colours it, `console` being a shell session where a `$ ` line is a command and the rest is output, and `copy` then copies only the commands; `label` is a caption naming the language or file; long lines wrap by default, so nothing is cut off and a command copies as one line, and `overflow="scroll"` keeps lines whole and scrolls them under a thin scrollbar in the theme's muted ink; `copy` adds a copy button beside the code, which copies it exactly as given and needs the page hydrated; other props go on the root `<figure>`). `CodeExample` (one framed example: the rendered `children` over the `code` that makes them, coloured as TSX, in one bordered box, with an optional `caption` as its last band; a wide preview or long code scrolls inside the frame under the same thin scrollbar; `copy` adds a button that copies the code; no client JS without `copy`). `Video` (a full-width, rounded `<video>` with controls that loads metadata only; `src` is required, `poster` and a WebVTT `captions` track are optional, children are the fallback). `Kbd` (a keyboard key in mono; its border takes the surrounding text colour, so it reads on a filled button too). `FilterGroup` (a `<fieldset>` with a small uppercase `legend` over a wrapped row of its children, e.g. `outline` `sm` `Button`s with `pressed`). `DateField` (see Dates).
|
|
84
85
|
- Dates: `toISODate`, `fromISODate`, and the `CalendarDate` type.
|
|
85
86
|
|
|
86
87
|
## Dates
|
package/dist/Callout.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export type CalloutTone = "neutral" | "info" | "positive" | "warn" | "danger";
|
|
|
5
5
|
/** The soft fill and border of each tone; a toned `Card` uses the same. */
|
|
6
6
|
export declare const TONE_SURFACE: Record<CalloutTone, string>;
|
|
7
7
|
/**
|
|
8
|
-
* A tinted notice box, with an optional bold title above its body.
|
|
8
|
+
* A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7
|
|
9
|
+
* inside a `Prose`, boxed or `banner`). `actions` puts a button or link
|
|
9
10
|
* at the end of the row; `banner` makes it a flat strip (bottom border only, no radius) for the
|
|
10
11
|
* top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column
|
|
11
12
|
* would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink
|
package/dist/Callout.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "./cx.js";
|
|
3
|
+
import { useProse } from "./typography.js";
|
|
3
4
|
/** The soft fill and border of each tone; a toned `Card` uses the same. */
|
|
4
5
|
export const TONE_SURFACE = {
|
|
5
6
|
neutral: "border-slate-200 bg-slate-50",
|
|
@@ -16,13 +17,15 @@ const TONE_TEXT = {
|
|
|
16
17
|
danger: "text-red-800",
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
|
-
* A tinted notice box, with an optional bold title above its body.
|
|
20
|
+
* A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7
|
|
21
|
+
* inside a `Prose`, boxed or `banner`). `actions` puts a button or link
|
|
20
22
|
* at the end of the row; `banner` makes it a flat strip (bottom border only, no radius) for the
|
|
21
23
|
* top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column
|
|
22
24
|
* would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink
|
|
23
25
|
* stretch` there makes the whole callout its click target, like a link in a table row.
|
|
24
26
|
*/
|
|
25
27
|
export function Callout({ tone = "info", title, actions, banner = false, align = "start", children, ...rest }) {
|
|
28
|
+
const size = useProse() ? "text-base/7" : "text-sm";
|
|
26
29
|
const content = title ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "font-semibold", children: title }), _jsx("div", { className: "mt-1", children: children })] })) : (children);
|
|
27
|
-
return (_jsx("div", { className: cx(Boolean(actions) && "relative", banner ? "border-b px-5 py-3
|
|
30
|
+
return (_jsx("div", { className: cx(Boolean(actions) && "relative", banner ? "border-b px-5 py-3" : "rounded-xl border p-4", size, TONE_SURFACE[tone], TONE_TEXT[tone], align === "center" && "text-center"), ...rest, children: actions ? (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: "min-w-0", children: content }), _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] })) : (content) }));
|
|
28
31
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
/**
|
|
4
|
+
* The box a message is typed into, with its button beside it. It keeps its own text. Enter sends
|
|
5
|
+
* the trimmed text and clears the box; Shift+Enter is a newline; empty or whitespace-only text does
|
|
6
|
+
* not send. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing
|
|
7
|
+
* carries on with the text kept for the next send.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ChatComposer({ label, placeholder, disabled, busy, onSend, onStop, sendLabel, stopLabel, ...rest }: {
|
|
10
|
+
/** The box's name for assistive tech; it is not drawn. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The hint inside the empty box. */
|
|
13
|
+
placeholder?: string | undefined;
|
|
14
|
+
/** Disables the box and the button. For a chat that cannot take a message at all, not for a reply in flight: that is `busy`. */
|
|
15
|
+
disabled?: boolean | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* A reply is on its way: the button is Stop and Enter does not send. With no `onStop`, the button
|
|
18
|
+
* stays a disabled Send and no Stop is drawn.
|
|
19
|
+
*/
|
|
20
|
+
busy?: boolean | undefined;
|
|
21
|
+
/** Called with the trimmed text. */
|
|
22
|
+
onSend: (text: string) => void;
|
|
23
|
+
/** Called when the reader presses Stop. */
|
|
24
|
+
onStop?: (() => void) | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The button's word, for sending.
|
|
27
|
+
* @default Send
|
|
28
|
+
*/
|
|
29
|
+
sendLabel?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The button's word, while `busy`.
|
|
32
|
+
* @default Stop
|
|
33
|
+
*/
|
|
34
|
+
stopLabel?: string | undefined;
|
|
35
|
+
} & Passthrough): ReactElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useRef, useState, } from "react";
|
|
3
|
+
import { Button } from "./Button.js";
|
|
4
|
+
import { Cluster, ClusterGrow } from "./Cluster.js";
|
|
5
|
+
import { Field } from "./Field.js";
|
|
6
|
+
import { Textarea } from "./Textarea.js";
|
|
7
|
+
/**
|
|
8
|
+
* An IME is still composing. Safari ends the composition before the Enter's keydown, so there
|
|
9
|
+
* `isComposing` is already false and only the 229 keyCode tells the commit from a real Enter.
|
|
10
|
+
*/
|
|
11
|
+
function isComposing({ nativeEvent }) {
|
|
12
|
+
return nativeEvent.isComposing || nativeEvent.keyCode === 229;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The box a message is typed into, with its button beside it. It keeps its own text. Enter sends
|
|
16
|
+
* the trimmed text and clears the box; Shift+Enter is a newline; empty or whitespace-only text does
|
|
17
|
+
* not send. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing
|
|
18
|
+
* carries on with the text kept for the next send.
|
|
19
|
+
*/
|
|
20
|
+
export function ChatComposer({ label, placeholder, disabled = false, busy = false, onSend, onStop, sendLabel = "Send", stopLabel = "Stop", ...rest }) {
|
|
21
|
+
const id = useId();
|
|
22
|
+
const box = useRef(null);
|
|
23
|
+
const [text, setText] = useState("");
|
|
24
|
+
const trimmed = text.trim();
|
|
25
|
+
const stop = busy && onStop !== undefined;
|
|
26
|
+
const send = () => {
|
|
27
|
+
if (busy || trimmed === "")
|
|
28
|
+
return;
|
|
29
|
+
onSend(trimmed);
|
|
30
|
+
setText("");
|
|
31
|
+
};
|
|
32
|
+
const onKeyDown = (event) => {
|
|
33
|
+
if (event.key !== "Enter" || event.shiftKey || isComposing(event))
|
|
34
|
+
return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
send();
|
|
37
|
+
};
|
|
38
|
+
// One submit button that is Send or Stop, so it is the same element across the swap and keeps its
|
|
39
|
+
// focus. Send goes back to the box: the empty box has just disabled the button under the focus.
|
|
40
|
+
const onSubmit = (event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
if (busy) {
|
|
43
|
+
onStop?.();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
send();
|
|
47
|
+
box.current?.focus();
|
|
48
|
+
};
|
|
49
|
+
return (_jsx("form", { ...rest, onSubmit: onSubmit, children: _jsxs(Cluster, { align: "end", gap: "sm", children: [_jsx(ClusterGrow, { children: _jsx(Field, { label: label, htmlFor: id, hideLabel: true, children: _jsx(Textarea, { ref: box, id: id, rows: 2, value: text, placeholder: placeholder, disabled: disabled, onChange: (event) => setText(event.target.value), onKeyDown: onKeyDown }) }) }), _jsx(Button, { type: "submit", variant: stop ? "outline" : "primary", disabled: disabled || (busy ? !stop : trimmed === ""), children: stop ? stopLabel : sendLabel })] }) }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
/**
|
|
4
|
+
* One message in a chat: a bubble on the sender's side, with an optional line above it and a row of
|
|
5
|
+
* actions under it. `children` is the body as the caller wants it (plain text, which keeps its line
|
|
6
|
+
* breaks, a `Markdown`, an `Image`). `streaming` marks a reply still arriving; with no children it
|
|
7
|
+
* draws the caret alone, the pending state.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ChatMessage({ role, author, meta, actions, streaming, children, ...rest }: {
|
|
10
|
+
/** Whose side it sits on: `user` on the right on the inset fill, `assistant` on the left on the surface. */
|
|
11
|
+
role: "user" | "assistant";
|
|
12
|
+
/** Who sent it, read first by a screen reader and drawn nowhere: alignment alone tells a screen reader nothing. Show a sender with `meta`. */
|
|
13
|
+
author: string;
|
|
14
|
+
/** A small line above the bubble: a sender and a time, already formatted. */
|
|
15
|
+
meta?: ReactNode;
|
|
16
|
+
/** A row under the bubble on the message's own side: copy, retry, a row of reaction `Pill`s. */
|
|
17
|
+
actions?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* The reply is still arriving: sets `aria-busy` and draws a caret after the body, which pulses
|
|
20
|
+
* unless the reader asks for reduced motion.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
streaming?: boolean | undefined;
|
|
24
|
+
/** The body. It may be empty while `streaming`. */
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
} & Passthrough): ReactElement;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
const BUBBLE = "max-w-[90%] rounded-xl px-3 py-2 text-sm text-slate-900";
|
|
4
|
+
const ROLE = {
|
|
5
|
+
user: { side: "items-end", row: "justify-end", bubble: "bg-slate-100" },
|
|
6
|
+
assistant: {
|
|
7
|
+
side: "items-start",
|
|
8
|
+
row: "justify-start",
|
|
9
|
+
bubble: "border border-slate-200 bg-white",
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* One message in a chat: a bubble on the sender's side, with an optional line above it and a row of
|
|
14
|
+
* actions under it. `children` is the body as the caller wants it (plain text, which keeps its line
|
|
15
|
+
* breaks, a `Markdown`, an `Image`). `streaming` marks a reply still arriving; with no children it
|
|
16
|
+
* draws the caret alone, the pending state.
|
|
17
|
+
*/
|
|
18
|
+
export function ChatMessage({ role, author, meta, actions, streaming = false, children, ...rest }) {
|
|
19
|
+
const look = ROLE[role];
|
|
20
|
+
return (_jsxs("article", { ...rest, "aria-busy": streaming || undefined, className: cx("flex w-full min-w-0 flex-col gap-1", look.side), children: [_jsx("span", { className: "sr-only", children: author }), meta && _jsx("div", { className: "text-xs text-slate-500", children: meta }), _jsxs("div", { className: cx(BUBBLE, look.bubble, "wrap-anywhere whitespace-pre-wrap"), children: [children, streaming && (_jsx("span", { "aria-hidden": "true", className: "text-slate-400 motion-safe:animate-pulse", children: "\u258D" }))] }), actions && (_jsx("div", { className: cx("flex flex-wrap items-center gap-1", look.row), children: actions }))] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
/** Whether a box scrolled this far is at its bottom, give or take `BOTTOM_SLACK`. */
|
|
4
|
+
export declare function isAtBottom(scrollTop: number, clientHeight: number, scrollHeight: number): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The scrolling box of a chat: its children are the messages, tool cards and anything else, a gap
|
|
7
|
+
* apart. It follows the newest content unless the reader has scrolled up. It is a named region and
|
|
8
|
+
* a tab stop, so a keyboard can scroll it. It is deliberately not a live region, which would read
|
|
9
|
+
* every streamed token aloud: set `announce` when a message is finished.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ChatThread({ label, height, empty, announce, children, ...rest }: {
|
|
12
|
+
/** Names the region. */
|
|
13
|
+
label: string;
|
|
14
|
+
/**
|
|
15
|
+
* The tallest it gets before it scrolls: `sm` 20rem, `md` 28rem, `lg` 40rem. `fill` takes the
|
|
16
|
+
* height of a parent that sets one.
|
|
17
|
+
* @default md
|
|
18
|
+
*/
|
|
19
|
+
height?: "sm" | "md" | "lg" | "fill" | undefined;
|
|
20
|
+
/** Drawn instead when there are no children: an `EmptyState`. */
|
|
21
|
+
empty?: ReactNode;
|
|
22
|
+
/** Text a screen reader reads out politely when it changes. Set it when a message is finished, not on each token. */
|
|
23
|
+
announce?: string | undefined;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
} & Passthrough): ReactElement;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, useLayoutEffect, useRef } from "react";
|
|
3
|
+
import { cx, focusRing, themedScrollbar } from "./cx.js";
|
|
4
|
+
const HEIGHT = {
|
|
5
|
+
sm: "max-h-80",
|
|
6
|
+
md: "max-h-[28rem]",
|
|
7
|
+
lg: "max-h-[40rem]",
|
|
8
|
+
fill: "h-full min-h-0",
|
|
9
|
+
};
|
|
10
|
+
/** How far above the very bottom, in pixels, still counts as reading the latest message. */
|
|
11
|
+
const BOTTOM_SLACK = 32;
|
|
12
|
+
/** Whether a box scrolled this far is at its bottom, give or take `BOTTOM_SLACK`. */
|
|
13
|
+
export function isAtBottom(scrollTop, clientHeight, scrollHeight) {
|
|
14
|
+
return scrollHeight - scrollTop - clientHeight <= BOTTOM_SLACK;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Starts the box at the bottom and keeps it there as the content grows, until the reader scrolls
|
|
18
|
+
* up; scrolling back to the bottom re-arms it. The box is watched as well as the content: a box
|
|
19
|
+
* that gets shorter (a phone's keyboard opening under `fill`) has moved the bottom out of view too.
|
|
20
|
+
*/
|
|
21
|
+
function useStickToBottom() {
|
|
22
|
+
const box = useRef(null);
|
|
23
|
+
const content = useRef(null);
|
|
24
|
+
const following = useRef(true);
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
const scroller = box.current;
|
|
27
|
+
if (!scroller || !content.current)
|
|
28
|
+
return undefined;
|
|
29
|
+
const follow = () => {
|
|
30
|
+
if (following.current)
|
|
31
|
+
scroller.scrollTop = scroller.scrollHeight;
|
|
32
|
+
};
|
|
33
|
+
follow();
|
|
34
|
+
// jsdom (a consumer's own tests) has no ResizeObserver.
|
|
35
|
+
if (typeof ResizeObserver === "undefined")
|
|
36
|
+
return undefined;
|
|
37
|
+
const observer = new ResizeObserver(follow);
|
|
38
|
+
observer.observe(content.current);
|
|
39
|
+
observer.observe(scroller);
|
|
40
|
+
return () => observer.disconnect();
|
|
41
|
+
}, []);
|
|
42
|
+
const onScroll = () => {
|
|
43
|
+
const scroller = box.current;
|
|
44
|
+
if (!scroller)
|
|
45
|
+
return;
|
|
46
|
+
following.current = isAtBottom(scroller.scrollTop, scroller.clientHeight, scroller.scrollHeight);
|
|
47
|
+
};
|
|
48
|
+
return { box, content, onScroll };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The scrolling box of a chat: its children are the messages, tool cards and anything else, a gap
|
|
52
|
+
* apart. It follows the newest content unless the reader has scrolled up. It is a named region and
|
|
53
|
+
* a tab stop, so a keyboard can scroll it. It is deliberately not a live region, which would read
|
|
54
|
+
* every streamed token aloud: set `announce` when a message is finished.
|
|
55
|
+
*/
|
|
56
|
+
export function ChatThread({ label, height = "md", empty, announce, children, ...rest }) {
|
|
57
|
+
const { box, content, onScroll } = useStickToBottom();
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-live": "polite", className: "sr-only", children: announce }), _jsx("div", { ...rest, ref: box, role: "region", "aria-label": label, tabIndex: 0, onScroll: onScroll, className: cx("overflow-y-auto rounded-lg", HEIGHT[height], themedScrollbar, focusRing), children: _jsx("div", { ref: content, className: "flex flex-col gap-3 text-slate-900", children: Children.toArray(children).length === 0 ? empty : children }) })] }));
|
|
59
|
+
}
|
package/dist/CodeBlock.d.ts
CHANGED
|
@@ -13,9 +13,12 @@ type CodeBlockSource = {
|
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* A block of code: mono, in a bordered inset box. No client JS unless `copy` adds a copy button
|
|
16
|
-
* beside the code, which copies it exactly as given and needs the page hydrated. `language` colours
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
16
|
+
* beside the code, which copies it exactly as given and needs the page hydrated. `language` colours
|
|
17
|
+
* it: `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`. `console` is a shell
|
|
18
|
+
* session: a line starting with `$ ` is a command (coloured as bash, its `$ ` dimmed and not
|
|
19
|
+
* selectable) and any other line is output; with `copy` only the commands are copied, without the
|
|
20
|
+
* `$ `. `label` names the language or file (`bash`, `css`) in a caption above the code. `text` (the
|
|
21
|
+
* default) leaves the code in one colour, for a block that is not a language. Give the text as `children` or as `lines`. Long lines wrap, so
|
|
19
22
|
* nothing is cut off and a command stays one copyable line; `overflow="scroll"` keeps lines whole
|
|
20
23
|
* and scrolls them sideways under a thin themed scrollbar, for code whose layout matters. Every
|
|
21
24
|
* other figure prop goes on the root `<figure>`. For one short line to copy, `CopyLine` is the
|
|
@@ -33,8 +36,8 @@ export declare function CodeBlock({ label, language, overflow, copy, children, l
|
|
|
33
36
|
*/
|
|
34
37
|
overflow?: "wrap" | "scroll";
|
|
35
38
|
/**
|
|
36
|
-
* A copy button beside the code, which copies it exactly as given
|
|
37
|
-
* leave it off on a page that is rendered to static HTML without hydration.
|
|
39
|
+
* A copy button beside the code, which copies it exactly as given (a `console` block copies only
|
|
40
|
+
* its commands). It is a client component: leave it off on a page that is rendered to static HTML without hydration.
|
|
38
41
|
* @default false
|
|
39
42
|
*/
|
|
40
43
|
copy?: boolean;
|
package/dist/CodeBlock.js
CHANGED
|
@@ -2,9 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { CodeBody } from "./CodeBody.js";
|
|
3
3
|
/**
|
|
4
4
|
* A block of code: mono, in a bordered inset box. No client JS unless `copy` adds a copy button
|
|
5
|
-
* beside the code, which copies it exactly as given and needs the page hydrated. `language` colours
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
5
|
+
* beside the code, which copies it exactly as given and needs the page hydrated. `language` colours
|
|
6
|
+
* it: `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`. `console` is a shell
|
|
7
|
+
* session: a line starting with `$ ` is a command (coloured as bash, its `$ ` dimmed and not
|
|
8
|
+
* selectable) and any other line is output; with `copy` only the commands are copied, without the
|
|
9
|
+
* `$ `. `label` names the language or file (`bash`, `css`) in a caption above the code. `text` (the
|
|
10
|
+
* default) leaves the code in one colour, for a block that is not a language. Give the text as `children` or as `lines`. Long lines wrap, so
|
|
8
11
|
* nothing is cut off and a command stays one copyable line; `overflow="scroll"` keeps lines whole
|
|
9
12
|
* and scrolls them sideways under a thin themed scrollbar, for code whose layout matters. Every
|
|
10
13
|
* other figure prop goes on the root `<figure>`. For one short line to copy, `CopyLine` is the
|
package/dist/CodeBody.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type CodeLanguage } from "./highlight.js";
|
|
3
3
|
/**
|
|
4
4
|
* The code of a `CodeBlock` or a `CodeExample`: the `<pre>` and, with `copy`, a `CopyButton` beside
|
|
5
|
-
* it that copies `code` exactly as given (wrapping is CSS, so it adds no characters)
|
|
5
|
+
* it that copies `code` exactly as given (wrapping is CSS, so it adds no characters), except in a
|
|
6
|
+
* `console` block, where it copies only the commands (see `consoleCommands`). `wrap` wraps
|
|
6
7
|
* long lines at whitespace only (a flag with hyphens stays whole; a word wider than the box still
|
|
7
8
|
* breaks inside itself); without it they scroll sideways under a themed thin scrollbar. The button's column has
|
|
8
9
|
* a fixed width, so "copy" turning into "copied" never rewraps the code beside it. The button needs
|
package/dist/CodeBody.js
CHANGED
|
@@ -2,14 +2,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { CodeText } from "./CodeText.js";
|
|
3
3
|
import { CopyButton } from "./CopyButton.js";
|
|
4
4
|
import { cx, themedScrollbar } from "./cx.js";
|
|
5
|
+
import { consoleCommands } from "./highlight.js";
|
|
5
6
|
/**
|
|
6
7
|
* The code of a `CodeBlock` or a `CodeExample`: the `<pre>` and, with `copy`, a `CopyButton` beside
|
|
7
|
-
* it that copies `code` exactly as given (wrapping is CSS, so it adds no characters)
|
|
8
|
+
* it that copies `code` exactly as given (wrapping is CSS, so it adds no characters), except in a
|
|
9
|
+
* `console` block, where it copies only the commands (see `consoleCommands`). `wrap` wraps
|
|
8
10
|
* long lines at whitespace only (a flag with hyphens stays whole; a word wider than the box still
|
|
9
11
|
* breaks inside itself); without it they scroll sideways under a themed thin scrollbar. The button's column has
|
|
10
12
|
* a fixed width, so "copy" turning into "copied" never rewraps the code beside it. The button needs
|
|
11
13
|
* client JS, which is why it is opt-in: a statically rendered page would show a dead one.
|
|
12
14
|
*/
|
|
13
15
|
export function CodeBody({ code, language, wrap, copy, }) {
|
|
14
|
-
return (_jsxs("div", { className: cx("flex items-start", copy && "gap-1 pr-1.5"), children: [_jsx("div", { className: cx("min-w-0 flex-1", !wrap && `overflow-x-auto ${themedScrollbar}`), children: _jsx("pre", { className: cx("px-3 py-2.5 font-mono text-[12.5px] text-slate-900", wrap ? "break-words whitespace-pre-wrap" : "w-max min-w-full whitespace-pre"), children: _jsx(CodeText, { code: code, language: language, breakAtSpaces: wrap }) }) }), copy && (_jsx("div", { className: "flex w-14 shrink-0 justify-end pt-2", children: _jsx(CopyButton, { text: code }) }))] }));
|
|
16
|
+
return (_jsxs("div", { className: cx("flex items-start", copy && "gap-1 pr-1.5"), children: [_jsx("div", { className: cx("min-w-0 flex-1", !wrap && `overflow-x-auto ${themedScrollbar}`), children: _jsx("pre", { className: cx("px-3 py-2.5 font-mono text-[12.5px] text-slate-900", wrap ? "break-words whitespace-pre-wrap" : "w-max min-w-full whitespace-pre"), children: _jsx(CodeText, { code: code, language: language, breakAtSpaces: wrap }) }) }), copy && (_jsx("div", { className: "flex w-14 shrink-0 justify-end pt-2", children: _jsx(CopyButton, { text: language === "console" ? consoleCommands(code) : code }) }))] }));
|
|
15
17
|
}
|
package/dist/CodeText.js
CHANGED
|
@@ -4,6 +4,8 @@ import { highlight } from "./highlight.js";
|
|
|
4
4
|
* Each kind borrows a colour family already in `palette.json`, so a theme recolours code like
|
|
5
5
|
* anything else: keywords and element names read as the accent (violet), strings as positive
|
|
6
6
|
* (emerald), numbers as warn (amber), attribute names as sky, calls as info (blue), comments muted.
|
|
7
|
+
* The `$ ` prompt of a console block is dimmer still and `select-none`, so selecting a command by
|
|
8
|
+
* hand does not pick it up.
|
|
7
9
|
*/
|
|
8
10
|
const TOKEN_CLASS = {
|
|
9
11
|
plain: "",
|
|
@@ -14,6 +16,7 @@ const TOKEN_CLASS = {
|
|
|
14
16
|
string: "text-emerald-700",
|
|
15
17
|
number: "text-amber-700",
|
|
16
18
|
function: "text-blue-700",
|
|
19
|
+
prompt: "text-slate-400 select-none",
|
|
17
20
|
};
|
|
18
21
|
/** One coloured run: bare text for plain, a span with the kind's palette utility otherwise. */
|
|
19
22
|
const colour = (kind, key, text) => kind === "plain" ? (text) : (_jsx("span", { className: TOKEN_CLASS[kind], children: text }, key));
|
package/dist/Dialog.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useId, useLayoutEffect, useRef, } from "react";
|
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
4
|
import { useModal } from "./modal.js";
|
|
5
5
|
import { scrollStopProps, TABBABLE, useScrollStop } from "./scrollStop.js";
|
|
6
|
-
import { HeaderText, SectionHeading } from "./typography.js";
|
|
6
|
+
import { AppScale, HeaderText, SectionHeading } from "./typography.js";
|
|
7
7
|
/** Shared by every size: the surface, its colours and the fade (and the scrim's) in and out. */
|
|
8
8
|
const BASE = "bg-white p-0 text-slate-900 opacity-0 transition-[opacity,translate,overlay,display] transition-discrete duration-200 open:opacity-100 starting:open:opacity-0 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
9
|
/** A floating panel under the top edge: it also slides down 8px as it fades in. */
|
|
@@ -61,5 +61,5 @@ export function Dialog({ title, description, children, footer, size = "md", onCl
|
|
|
61
61
|
const closed = useModal(dialog, onClose);
|
|
62
62
|
const full = size === "full";
|
|
63
63
|
const { attach, props: bodyProps, className: bodyClass, } = useScrollingBody(dialog, titleId, full);
|
|
64
|
-
return (_jsx("dialog", { ...rest, ref: dialog, "aria-labelledby": titleId, onClose: closed, onClick: (event) => event.target === dialog.current && dialog.current?.close(), className: cx(BASE, size === "full" ? FULL : `${WINDOW} ${WIDTH[size]}`), children: _jsxs("div", { className: cx("flex flex-col p-5.5", full ? "min-h-0 flex-1" : CAP), children: [_jsx(SectionHeading, { id: titleId, children: title }), description && (_jsx("div", { className: "mt-1", children: _jsx(HeaderText, { children: description }) })), children && (_jsx("div", { ref: attach, ...bodyProps, className: bodyClass, children: children })), footer && _jsx("div", { className: "mt-5 flex shrink-0 justify-end gap-2", children: footer })] }) }));
|
|
64
|
+
return (_jsx(AppScale, { children: _jsx("dialog", { ...rest, ref: dialog, "aria-labelledby": titleId, onClose: closed, onClick: (event) => event.target === dialog.current && dialog.current?.close(), className: cx(BASE, size === "full" ? FULL : `${WINDOW} ${WIDTH[size]}`), children: _jsxs("div", { className: cx("flex flex-col p-5.5", full ? "min-h-0 flex-1" : CAP), children: [_jsx(SectionHeading, { id: titleId, children: title }), description && (_jsx("div", { className: "mt-1", children: _jsx(HeaderText, { children: description }) })), children && (_jsx("div", { ref: attach, ...bodyProps, className: bodyClass, children: children })), footer && _jsx("div", { className: "mt-5 flex shrink-0 justify-end gap-2", children: footer })] }) }) }));
|
|
65
65
|
}
|
package/dist/Drawer.js
CHANGED
|
@@ -4,7 +4,7 @@ import { cx } from "./cx.js";
|
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
5
|
import { IconButton } from "./IconButton.js";
|
|
6
6
|
import { useModal } from "./modal.js";
|
|
7
|
-
import { SectionHeading } from "./typography.js";
|
|
7
|
+
import { AppScale, SectionHeading } from "./typography.js";
|
|
8
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
9
|
const SIZE = { sm: "w-80", md: "w-110", lg: "w-160" };
|
|
10
10
|
/**
|
|
@@ -18,5 +18,5 @@ export function Drawer({ title, children, footer, size = "md", onClose, closeLab
|
|
|
18
18
|
const dialog = useRef(null);
|
|
19
19
|
const titleId = useId();
|
|
20
20
|
const closed = useModal(dialog, onClose);
|
|
21
|
-
return (_jsxs("dialog", { ...rest, ref: dialog, "aria-labelledby": titleId, onClose: closed, onClick: (event) => event.target === dialog.current && dialog.current?.close(), className: cx(PANEL, SIZE[size]), 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: [_jsx(SectionHeading, { id: titleId, children: title }), _jsx(IconButton, { label: closeLabel, onClick: () => dialog.current?.close(), children: _jsx(Icon, { children: _jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", children: _jsx("path", { d: "M5.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 10l-4.72 4.72a.75.75 0 1 0 1.06 1.06L10 11.06l4.72 4.72a.75.75 0 1 0 1.06-1.06L11.06 10l4.72-4.72a.75.75 0 0 0-1.06-1.06L10 8.94 5.28 4.22Z" }) }) }) })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-5.5 py-4", 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 }))] }));
|
|
21
|
+
return (_jsx(AppScale, { children: _jsxs("dialog", { ...rest, ref: dialog, "aria-labelledby": titleId, onClose: closed, onClick: (event) => event.target === dialog.current && dialog.current?.close(), className: cx(PANEL, SIZE[size]), 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: [_jsx(SectionHeading, { id: titleId, children: title }), _jsx(IconButton, { label: closeLabel, onClick: () => dialog.current?.close(), children: _jsx(Icon, { children: _jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", children: _jsx("path", { d: "M5.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 10l-4.72 4.72a.75.75 0 1 0 1.06 1.06L10 11.06l4.72 4.72a.75.75 0 1 0 1.06-1.06L11.06 10l4.72-4.72a.75.75 0 0 0-1.06-1.06L10 8.94 5.28 4.22Z" }) }) }) })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-5.5 py-4", 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 }))] }) }));
|
|
22
22
|
}
|
package/dist/EmptyState.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
|
-
import { SectionHeading } from "./typography.js";
|
|
4
|
+
import { AppScale, SectionHeading } from "./typography.js";
|
|
5
5
|
/**
|
|
6
6
|
* What a list or a page shows when there is nothing in it yet: a centred `title`, the `children`
|
|
7
7
|
* as the explanation under it (a `Text as="p"`, then `Steps` for a "get started" list), and
|
|
@@ -11,5 +11,5 @@ import { SectionHeading } from "./typography.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export function EmptyState({ title, level = 2, padding = "default", children, actions, ...rest }) {
|
|
13
13
|
const titleId = useId();
|
|
14
|
-
return (_jsxs("section", { ...rest, "aria-labelledby": titleId, className: cx("mx-auto flex w-full max-w-xl flex-col items-center gap-4 text-center", padding === "inset" ? "p-8" : "py-8"), children: [_jsx(SectionHeading, { as: `h${level}`, 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 })] }));
|
|
14
|
+
return (_jsx(AppScale, { children: _jsxs("section", { ...rest, "aria-labelledby": titleId, className: cx("mx-auto flex w-full max-w-xl flex-col items-center gap-4 text-center", padding === "inset" ? "p-8" : "py-8"), children: [_jsx(SectionHeading, { as: `h${level}`, 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 })] }) }));
|
|
15
15
|
}
|
package/dist/Icon.d.ts
CHANGED
|
@@ -14,8 +14,10 @@ type IconProps = Passthrough & {
|
|
|
14
14
|
/**
|
|
15
15
|
* One inline icon, sized to a fixed box (sm 14px, md 16px, lg 20px, `feature` 32px) and drawn in
|
|
16
16
|
* `currentColor`, so it takes the text colour around it unless a `tone` says otherwise. `name`
|
|
17
|
-
* picks one of the library's own icons, all drawn on one grid with one stroke
|
|
18
|
-
* `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`,
|
|
17
|
+
* picks one of the library's own icons, all drawn on one grid with one stroke: feature ideas
|
|
18
|
+
* (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`,
|
|
19
|
+
* `speed`, `search`) and UI glyphs (`chevron-right`, `chevron-down`, `close`, `external-link`,
|
|
20
|
+
* `settings`, `bell`, `check`, `plus`);
|
|
19
21
|
* without a name, a bare `<svg>` child fills the box. It is decorative (`aria-hidden`) by
|
|
20
22
|
* default; a `label` makes it an image with that name, for an icon that carries meaning no text
|
|
21
23
|
* beside it says.
|
package/dist/Icon.js
CHANGED
|
@@ -11,8 +11,10 @@ const BOX = {
|
|
|
11
11
|
/**
|
|
12
12
|
* One inline icon, sized to a fixed box (sm 14px, md 16px, lg 20px, `feature` 32px) and drawn in
|
|
13
13
|
* `currentColor`, so it takes the text colour around it unless a `tone` says otherwise. `name`
|
|
14
|
-
* picks one of the library's own icons, all drawn on one grid with one stroke
|
|
15
|
-
* `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`,
|
|
14
|
+
* picks one of the library's own icons, all drawn on one grid with one stroke: feature ideas
|
|
15
|
+
* (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`,
|
|
16
|
+
* `speed`, `search`) and UI glyphs (`chevron-right`, `chevron-down`, `close`, `external-link`,
|
|
17
|
+
* `settings`, `bell`, `check`, `plus`);
|
|
16
18
|
* without a name, a bare `<svg>` child fills the box. It is decorative (`aria-hidden`) by
|
|
17
19
|
* default; a `label` makes it an image with that name, for an icon that carries meaning no text
|
|
18
20
|
* beside it says.
|
package/dist/Input.js
CHANGED
|
@@ -13,7 +13,7 @@ export function Input({ icon, prefix, size = "md", width = "full", align = "star
|
|
|
13
13
|
return _jsx(SearchInput, { ...rest, icon: icon, size: size, width: width, align: align });
|
|
14
14
|
}
|
|
15
15
|
if (prefix !== undefined) {
|
|
16
|
-
return (_jsx(PrefixShell, { prefix: prefix, size: size, width: width, disabled: rest.disabled, children: _jsx("input", { ...rest, className: cx("min-w-0 flex-1 bg-transparent px-1 outline-none placeholder:text-slate-400", CONTROL_ALIGN[align]) }) }));
|
|
16
|
+
return (_jsx(PrefixShell, { prefix: prefix, size: size, width: width, disabled: rest.disabled, children: _jsx("input", { ...rest, className: cx("min-w-0 flex-1 bg-transparent px-1 text-ellipsis outline-none placeholder:text-slate-400", CONTROL_ALIGN[align]) }) }));
|
|
17
17
|
}
|
|
18
18
|
if (icon === undefined) {
|
|
19
19
|
return (_jsx("input", { ...rest, className: cx(controlClass(size, width), CONTROL_PAD[size].x, CONTROL_ALIGN[align]) }));
|
package/dist/InputShell.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { type ControlProps } from "./control.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The relative wrapper of an `Input` that holds more than the field: a leading `icon` and, for search, the clear button. Not exported from the package.
|
|
5
|
+
*
|
|
6
|
+
* Inside a Card or row (`liftInteractive`, which is `isolate`) the field is lifted to `z-10`, and
|
|
7
|
+
* its opaque background would paint over a z-auto icon. So the icon ranks `z-20` there. It is
|
|
8
|
+
* scoped to an `isolate` ancestor so a field elsewhere on the page never outranks AppShell's
|
|
9
|
+
* sticky header (`z-10`). The clear button is a lifted `button` and comes after the field, so it
|
|
10
|
+
* already sits above it.
|
|
11
|
+
*/
|
|
4
12
|
export declare function InputShell({ icon, size, width, children, }: {
|
|
5
13
|
icon?: ReactNode;
|
|
6
14
|
children: ReactNode;
|