@scalewing/react 1.71.0 → 1.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +118 -2
- package/dist/components/Box.d.ts +3 -2
- package/dist/components/Box.js +3 -2
- package/dist/components/ListGroup.d.ts +11 -3
- package/dist/components/ListGroup.js +6 -3
- package/dist/components/MessageCard.d.ts +43 -0
- package/dist/components/MessageCard.js +40 -0
- package/dist/components/PersonPicker.d.ts +44 -0
- package/dist/components/PersonPicker.js +53 -0
- package/dist/components/PinStep.d.ts +52 -0
- package/dist/components/PinStep.js +45 -0
- package/dist/css/css-action-menu.js +11 -0
- package/dist/css/css-button-group-attached.js +6 -1
- package/dist/css/css-button-natural-width.d.ts +1 -0
- package/dist/css/css-button-natural-width.js +16 -0
- package/dist/css/css-button.js +2 -0
- package/dist/css/css-list-size.d.ts +3 -0
- package/dist/css/css-list-size.js +31 -0
- package/dist/css/css-list-tiles-bounded.d.ts +1 -0
- package/dist/css/css-list-tiles-bounded.js +74 -0
- package/dist/css/css-list-tiles.d.ts +1 -0
- package/dist/css/css-list-tiles.js +37 -7
- package/dist/css/css-list.d.ts +0 -1
- package/dist/css/css-list.js +18 -9
- package/dist/css/css-utilities.js +2 -0
- package/dist/css/list-row-metrics.d.ts +3 -0
- package/dist/css/list-row-metrics.js +18 -0
- package/dist/css/spacing-classes.d.ts +1 -1
- package/dist/css/spacing-classes.js +1 -0
- package/dist/css/stacking.js +2 -1
- package/dist/flex-item-classes.d.ts +15 -0
- package/dist/flex-item-classes.js +6 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/list-options.d.ts +13 -5
- package/dist/list-options.js +15 -7
- package/dist/person-names.d.ts +13 -0
- package/dist/person-names.js +18 -0
- package/dist/styles.css +87 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.73.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f2143f2: New `MessageCard` (with `MessageCardProps`, `MessageCardAction`, `MessageCardActionVariant`, `MessageCardHeadingElement`, `messageCardActionVariants`, `messageCardHeadingElements`): a centred message on an outlined card where a screen cannot go on or has nothing yet, an optional muted `icon` (the consumer's Lucide glyph at size 24, hidden from assistive technology), a `title` (`h2` by default, or `h1` with `headingAs`), muted `lines` (two or fewer; more is allowed but not advised) and one `action` (`{ label, onPress, variant?: 'neutral' | 'primary', icon? }`). By default (`alert`) the card is `role="alert"` and its action takes the focus; `alert={false}` is a plain statement with no role and nothing focused. Blank words or an unknown `headingAs` or variant throw a `RangeError`. No new classes, tokens or dependencies. Request: `docs/requests/teisoro-message-card.md`.
|
|
8
|
+
- 318499b: New `PersonPicker` (with `PersonPickerProps`, `PersonPickerPerson`, `PersonPickerLabels`): people to choose from as large tiles, a `ListGroup` of `lg` tiles three across from `md` and one a row on a phone, each a button named by the person (or its `aria-label`) with an optional `tag`; `onChoose(id)`. From `searchFrom` people (13 by default) a search field narrows them to names starting with what was typed, ignoring capitals and accents, and the tiles scroll inside a named region four rows at a time; nobody left is a muted `role="status"` line. The first tile takes the focus on mount (`autoFocus`, default true). Every word comes from `labels` (`list`, `find`, `noMatch`). The pure filter is exported as `peopleStartingWith` with `comparableName`. No new classes, tokens or dependencies. Request: `docs/requests/teisoro-person-picker.md`.
|
|
9
|
+
- d226efd: New `PinStep` (with `PinStepProps`, `PinStepAction`, `PinStepHeadingElement`, `pinStepHeadingElements`): the step where someone enters a PIN on a shared screen. An optional ghost `back` Button at the top, an `eyebrow` (such as the person's name) over the `heading` (`h1` by default, or `h2` with `headingAs`), `PinField` with its pad and the focus (`autoFocus`, default true here), while `busy` a decorative `Spinner` and a `role="status"` line, and an optional ghost `secondaryAction` under it. Every other `PinField` prop passes through and the ref reaches the input. Blank words or an unknown `headingAs` throw a `RangeError`. No new classes, tokens or dependencies. Request: `docs/requests/teisoro-pin-step.md`.
|
|
10
|
+
|
|
11
|
+
## 1.72.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 942b480: A `Button`, `ButtonLink` and `ActionMenu` keep their natural width as an item of a flex row (`flex-shrink: 0`) and are never wider than their container (`max-width: 100%`): in a crowded row their siblings give way first, so their words stay on the one line they take, and only where the words are longer than the whole container do they wrap, inside the pill. Words are never cut, and no component's DOM changes. The buttons of an attached `ButtonGroup` still share its one row and shrink as before, so a joined control wraps its words inside its segments on a phone rather than spilling past the column. New `shrink={false}` on every Box-based component (`FlexItemProps`, class `sw-no-shrink`) keeps a box such as a header's actions in their own `Inline` at its natural size along its parent's main axis. No new tokens, no new dependency; no prop is removed or renamed. Request: `docs/requests/teisoro-button-natural-width.md`.
|
|
16
|
+
|
|
17
|
+
Migration: nothing to change in code, but check these after upgrading. Any `Inline` without `wrap` (not wrapping is its default) whose Buttons or menus together are wider than it now overflows where their words used to wrap as they were squeezed: give it `wrap`, or a row of its own below `md`. A Button or menu in a nested `Inline` in a crowded row: give that `Inline` `shrink={false}`, or its controls spill out of it.
|
|
18
|
+
|
|
19
|
+
- 38fe3cc: `ListGroup` `size="lg"` (opt-in; `listGroupSizes`, `ListGroupSize`, class `sw-list-group-lg`): every row of the group at least 56 px on every pointer, its parts centred, such as names pressed at a shared counter. `variant="tiles"` now takes `maxHeight` (it threw): the grid scrolls inside the same named region, `rows` counting rows of tiles, the edge shade drawn over the opaque tiles, and a tile focused from the keyboard scrolled fully into view, its ring whole; tiles still take no `footer` (its error now reads "A ListGroup of tiles takes no footer"). A tile's row now fills its tile, so beside a taller tile on the same grid row its press area, fill and focus ring reach the tile's edges (an `action` stays centred). Other variants and sizes render as before. No new tokens, no new dependency. Request: `docs/requests/teisoro-list-group-tiles-scroll.md`.
|
|
20
|
+
|
|
3
21
|
## 1.71.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
DescriptionList,
|
|
49
49
|
DescriptionItem,
|
|
50
50
|
EmptyState,
|
|
51
|
+
MessageCard,
|
|
51
52
|
FixtureCard,
|
|
52
53
|
FixtureGroup,
|
|
53
54
|
FixtureRow,
|
|
@@ -55,6 +56,7 @@ import {
|
|
|
55
56
|
DateToggleCalendar,
|
|
56
57
|
ListGroup,
|
|
57
58
|
ListRow,
|
|
59
|
+
PersonPicker,
|
|
58
60
|
LiveRegion,
|
|
59
61
|
MarkdownView,
|
|
60
62
|
DenominationGrid,
|
|
@@ -64,6 +66,7 @@ import {
|
|
|
64
66
|
Field,
|
|
65
67
|
FileField,
|
|
66
68
|
PinField,
|
|
69
|
+
PinStep,
|
|
67
70
|
Article,
|
|
68
71
|
Stepper,
|
|
69
72
|
Steps,
|
|
@@ -316,6 +319,27 @@ The digits are never in the page. The input's own value is a mask, one `•` per
|
|
|
316
319
|
/>
|
|
317
320
|
```
|
|
318
321
|
|
|
322
|
+
`PinStep` is the step where someone enters a PIN on a shared screen, around `PinField`: an optional `back` (`{ label, onPress }`, a ghost Button at the top), an `eyebrow` (such as the person's name, label text) over the `heading` (heading size; `headingAs` `"h1"` by default, or `"h2"` under a page heading, `pinStepHeadingElements`), then `PinField` with its pad, focused on mount (`autoFocus`, true by default here), then while `busy` is set a decorative `Spinner` beside its words in a polite status line, a `LiveRegion` always mounted under the field (empty and taking no room while idle, so its words are read when they appear; pass `disabled` with it: busy does not disable the field), and an optional `secondaryAction` (`{ label, onPress }`, a ghost Button under it, such as "Forgot your PIN?"). It takes every other `PinField` prop (`label`, `labelVisuallyHidden`, `value`, `onChange`, `onComplete`, `length`, `disabled`, `description`, `error`, `labels`, `id`) and forwards its ref to the input, so you can put the focus back after a refused code. Spacing is a `Stack` gap 4, the eyebrow and heading gap 1. A blank heading, eyebrow, busy line or action label, or an unknown `headingAs`, throws a `RangeError`.
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
<PinStep
|
|
326
|
+
ref={field}
|
|
327
|
+
back={{ label: 'Back', onPress: backToNames }}
|
|
328
|
+
eyebrow={person.name}
|
|
329
|
+
heading="Enter your PIN"
|
|
330
|
+
label={`PIN for ${person.name}`}
|
|
331
|
+
labelVisuallyHidden
|
|
332
|
+
value={pin}
|
|
333
|
+
onChange={setPin}
|
|
334
|
+
onComplete={send}
|
|
335
|
+
disabled={checking}
|
|
336
|
+
busy={checking ? 'Checking…' : undefined}
|
|
337
|
+
description="Your four to six digits."
|
|
338
|
+
error={refused ? 'That PIN is not right.' : undefined}
|
|
339
|
+
secondaryAction={{ label: 'Forgot your PIN?', onPress: forgot }}
|
|
340
|
+
/>
|
|
341
|
+
```
|
|
342
|
+
|
|
319
343
|
`Stepper` is a whole-number count changed with − and + or typed. The count is a native text input with `role="spinbutton"` and `inputmode="numeric"`, named by `label` (visible above it, or `labelVisuallyHidden` where table headers say it) and the one tab stop: ArrowUp and ArrowDown step it by `step` (default 1), Home goes to `min` and End to a finite `max` (a range below zero takes `inputmode="text"`, since a phone's numeric pad has no minus key). The − and + buttons are pointer targets outside the tab order, named by `decrementLabel` and `incrementLabel` (your copy), and a press on one leaves focus where it was; the count and both buttons sit in a `group` named by the label. − is disabled at `min` (default 0) and + at `max` (no upper bound when left out). `value` is a count or `null` for an empty box, which the buttons treat as `min` and `placeholder` can fill. Typed text is refused unless it is digits (with a leading minus when `min` is below zero), so `onChange` only receives a whole number or `null`; a typed count is reported as typed even outside the bounds, so say why in `error` (a polite message, `aria-invalid` and the danger border, as `Field`'s), and the buttons then move it back inside them. `aria-describedby` takes ids of elements that describe the count, such as the value it adds up to, read before an `error`'s message. `changed` takes `Field`'s changed look; `readOnly` keeps the count focusable and hides the buttons in their own room; `disabled` stops all three. `limitAppearance="plain"` (default `"faded"`) keeps − at `min` and + at `max` in their usual look instead of faded, for a count sheet where a faded − reads as broken; they are still disabled, a disabled or read-only Stepper is unchanged, forced colors still grey them, and an unknown value throws a `RangeError`. The count is a few digits wide and keeps that width (`width="fixed"`), or fills its container (`width="full"`, for a table cell). `unit` (opt-in) is a short muted word after the count inside its frame, such as "min" or "players": the frame (`sw-stepper-count`) draws the control surface, focus ring and the invalid, changed and disabled states, a press on the word focuses the count, and the count keeps its few-digit width with its digits against the word, so the frame never follows it. The word (`sw-stepper-unit`) is hidden from assistive technology; the count is read with it (`aria-valuetext` "90 min", none while the box is empty), and a `valueText` you pass wins. The default joins the count and the word as given, so a word that changes with the count ("players") reads "1 players": pass `valueText` in your language's right form ("1 player", "11 players"). A blank `unit` throws a `RangeError`. Bounds that are not whole numbers, `min` above `max`, or a `step` that is not above zero throw a `RangeError`.
|
|
320
344
|
|
|
321
345
|
`Stepper` `onCommit` (opt-in) is the finished count once per entry, for a page that saves as you go: it fires on blur, on Enter (a form round the count still submits), and `commitDelay` ms (default 600) after the last − / + press or step key (ArrowUp, ArrowDown, Home, End), each press restarting the wait; blur or Enter while it waits commits at once. Typed digits never commit by themselves. It gives the count you hold at that moment, `null` or outside the bounds included as `onChange` reports them, so check it before saving. It does not fire when that count is the one last committed, or, before the first commit, the one held before the first edit; a count you set while nothing waits (a server's answer) becomes the new baseline. A commit still waiting when the Stepper unmounts is made then. `onChange` is unchanged. A `commitDelay` that is negative or not finite throws a `RangeError`.
|
|
@@ -444,6 +468,29 @@ On the web, `variant="neutral"` is a quiet grey fill (the muted color at 16 %, t
|
|
|
444
468
|
|
|
445
469
|
`Button` `width` is `'content'` (the default: as wide as its words) or `'full'`: the button fills its container's inline size in a `Stack`, a `Grid` cell or any column, and in an `Inline` row takes the space its siblings leave, as a full `Select` does, so an Edit beside a ••• `ActionMenu` fills the row and the menu keeps its own square at the end. The row rule holds for a `Button` that is a direct child of the `Inline`; wrapped in another box it fills that box instead. In a wrapping `Inline` (`wrap`) a full button grows from its words' width and moves to a line of its own when the row runs out, rather than shrinking past its words. Inside a `ButtonGroup` it is not needed: the group already stacks its buttons full width below `md`. The words stay centred. An unknown width throws a `RangeError`. The class is `sw-button-full`.
|
|
446
470
|
|
|
471
|
+
A `Button` (and a `ButtonLink`) keeps its natural width as an item of a flex row (an `Inline` that does not wrap, a header's actions): it gives up none of it (`flex-shrink: 0`), so the row's other items give way first and its words stay on the one line they take at that width, never squeezed onto two or three. It is never wider than its container (`max-width: 100%`): where its words are longer than the whole row or column it is in (a narrow column, a `ButtonGroup` stacked on a phone), they wrap inside the pill, every word shown; they are never cut. A `width="full"` button in an `Inline` still shares the row as before, and so do an attached `ButtonGroup`'s buttons, which shrink to share its one row and wrap their words inside their segments on a narrow phone. Any `Inline` without `wrap` (not wrapping is its default) whose Buttons together are wider than it overflows rather than squeezing them: give it `wrap`, or put the buttons on a row of their own on a narrow screen. A box of several controls that must keep its width as one, such as a header's Button and account menu in their own `Inline`, takes `shrink={false}` (below); an `Inline` otherwise shrinks below its content (`min-width: 0`).
|
|
472
|
+
|
|
473
|
+
```tsx
|
|
474
|
+
<Inline justify="between" align="center" gap={3} wrap={false}>
|
|
475
|
+
<Inline align="center" gap={6} wrap>
|
|
476
|
+
{brand}
|
|
477
|
+
{areas}
|
|
478
|
+
</Inline>
|
|
479
|
+
<Inline align="center" gap={2} wrap={false} shrink={false}>
|
|
480
|
+
<Button size="sm" variant="neutral" onPress={switchRoost}>
|
|
481
|
+
Switch to the night roost
|
|
482
|
+
</Button>
|
|
483
|
+
<ActionMenu
|
|
484
|
+
label={`${colony} · ${habitat}`}
|
|
485
|
+
trigger={colony}
|
|
486
|
+
triggerAppearance="text"
|
|
487
|
+
align="end"
|
|
488
|
+
items={items}
|
|
489
|
+
/>
|
|
490
|
+
</Inline>
|
|
491
|
+
</Inline>
|
|
492
|
+
```
|
|
493
|
+
|
|
447
494
|
On a coarse pointer (a phone or a tablet, `(pointer: coarse)`) every `Button`, `ButtonLink` and control built on them is at least 44 × 44 px (the md control height), whatever its `size`: an `xs` or `sm` Button keeps its padding and type but its box grows to the touch target, so a small row action in a table or a checklist is still easy to tap. A fine pointer keeps each size's height (28, 32 and 44 px). Rows holding small Buttons are taller on touch; two layouts keep `min-width: 0` so their Buttons can share a row, a full-width attached `ButtonGroup` below `md` and a `width="full"` Button in an `Inline`, and both keep the 44 px height. Popovers holding small Buttons grow too, such as `DateField`'s calendar with its footer.
|
|
448
495
|
|
|
449
496
|
`ButtonLink` is a link drawn as a `Button`, for a destination that reads as an action, such as a site's Contact us or Sign in: an `<a href>` with the Button's `variant` (default `primary`), `size` (default `md`) and `width`, so it opens like any link (a new tab, a page rendered with no script) and keeps its variant's words over the canvas link colour, hover included. `aria-current="page"` marks the one that is the current page with the pressed button's ring (a Highlight border in forced colours). A link has no disabled state: render none instead. Use `Button` for a press that does something on the page. An unknown variant, size or width throws a `RangeError`; the class is `sw-button-link` beside the Button's own.
|
|
@@ -485,7 +532,7 @@ A `Button` that toggles something passes `aria-pressed`. The pressed button gets
|
|
|
485
532
|
|
|
486
533
|
`ActionMenu` `header` is a non-interactive block above the commands, such as who is signed in: each child a line of its own, in the caption size and the muted color, set off by a hairline. It sits outside the `role="menu"` element and the arrow keys, and is the menu's description (`aria-describedby`), read as the menu opens; `null`, `false` and `''` are no header. An item's `lang` (a BCP 47 tag) marks its label as another language than the page's, such as "English" on a Spanish page (WCAG 3.1.2).
|
|
487
534
|
|
|
488
|
-
`ActionMenu` `triggerAppearance="text"` (opt-in; default `"framed"`, `actionMenuTriggerAppearances`) draws the trigger as its words (`trigger`, or `label`) in label type at medium weight in the text color, with the shared muted chevron pointing down after them and no fill or outline; the quiet grey fill shows on hover and while the menu is open. It is the sm control height (the 44 px target on a coarse pointer). Name the trigger with `label` as before, and include the words shown in it (WCAG 2.5.3, so voice control can say them): a person's name that opens their account menu takes a `label` such as "Account, Ada Okafor". The trigger's words are one flex item (mixed inline content keeps its spaces), then the chevron. Forced colors draw its border in the system's border color, the chevron in CanvasText, and an open trigger's border in Highlight. An unknown value throws a `RangeError`.
|
|
535
|
+
`ActionMenu` `triggerAppearance="text"` (opt-in; default `"framed"`, `actionMenuTriggerAppearances`) draws the trigger as its words (`trigger`, or `label`) in label type at medium weight in the text color, with the shared muted chevron pointing down after them and no fill or outline; the quiet grey fill shows on hover and while the menu is open. It is the sm control height (the 44 px target on a coarse pointer). Name the trigger with `label` as before, and include the words shown in it (WCAG 2.5.3, so voice control can say them): a person's name that opens their account menu takes a `label` such as "Account, Ada Okafor". The trigger's words are one flex item (mixed inline content keeps its spaces), then the chevron. Every `ActionMenu` keeps its natural width in a crowded flex row, as a `Button` does, so a name in a header stays on its one line while the row's other items give way; it is never wider than its container, and where its words are longer than the whole row they wrap inside the trigger, never cut. Forced colors draw its border in the system's border color, the chevron in CanvasText, and an open trigger's border in Highlight. An unknown value throws a `RangeError`.
|
|
489
536
|
|
|
490
537
|
`ContextSwitcher` is a button showing the context in use, such as a workspace, a competition or a season, that opens a popup to switch it. `label` says what is switched ("Season"); `trigger` is what the button shows, usually the current context (words, or a mark and words on two lines); the button is named by both ("Season Fall 2026", the visible words in the name). `groups` is a list of `{ id, label?, options }`, each option `{ id, label, detail?, icon?, badge?: { label, tone }, count?, countLabel?, countTone? }`: a decorative mark, the label over a muted detail, a status `Badge`, and the shared count pill (`NavCount`'s tones), all read in the option's name, a `countLabel` in place of the number; a `count` of 0 shows no pill, as `NavCount`'s. `currentId` is the option in use, checked and `aria-selected`. The popup is a non-modal dialog named by `label` on the top layer, placed as `ActionMenu`'s list is (`align` `"start"` or `"end"`). Focus moves into it: to the `filter` field when there is one (`{ label, placeholder?, emptyText, minOptions? }`, a combobox that narrows the options by label or detail, case and accents ignored, shows and announces `emptyText` when nothing is left, and appears only from `minOptions` options, 0 by default), else to the listbox. ↓ and ↑ move the active row and Enter chooses it; in the listbox Home and End go to the ends, letters jump by typeahead and Space chooses. Choosing closes the popup, puts focus back on the trigger, then calls `onSelect(option)`; the current option only closes it. `actions` (`{ id, label, icon?, onSelect }`) are commands in a footer under a hairline, reached with Tab, that close the popup and return focus to the trigger before they run. Escape closes it with focus on the trigger (and stops there, so an `AppShell` drawer round it stays open); a press outside or Tab out of it (or Shift+Tab back to the trigger) closes it where focus went. Focus leaving the window (another app, a browser tab) leaves it open until the next press. A press on the popup's caption, padding or a row keeps focus in the field or the listbox, so the keys keep working; Enter while an input method composes is the method's. The popup is at least 15rem and never narrower than the trigger, capped by the viewport, and follows the trigger's width while open. `triggerAppearance` is `"framed"` (default, the outlined control), `"text"` (words and a chevron, no fill until hovered or open), `"pill"` (a rounded outlined pill at label weight) or `"icon"` (a glyph alone in a round quiet button, no chevron, named by `label` and the current option's label, for a rail); `width="full"` fills the column, such as a sidebar's top. The trigger, options and commands are 44 px on a coarse pointer; forced colours draw the active row in `Highlight`. Keep state shared by several copies (an `AppShell` header and its rail, for instance) in your own component. Blank words, empty or duplicate groups, options or actions, a bad count, badge or tone, a `currentId` that names no option, a trigger that draws nothing, and an unknown `triggerAppearance`, `width` or `align` throw a `RangeError`.
|
|
491
538
|
|
|
@@ -1028,6 +1075,25 @@ Use `LiveRegion` rather than your own `role="status"` or `aria-live` whenever wo
|
|
|
1028
1075
|
/>
|
|
1029
1076
|
```
|
|
1030
1077
|
|
|
1078
|
+
`MessageCard` is a centred message on an outlined card where a screen cannot go on, or has nothing to show yet, such as a paused account, a list that could not load or a device that was removed: an optional `icon` over the `title`, up to two muted `lines`, and one `action`. The card is a `Card` (`variant="outlined"`, padding 6) holding a centred `Stack` (gap 3). `icon` is your Lucide glyph at spacing step 5 (`size={24} strokeWidth={1.75}`), drawn in the muted colour and hidden from assistive technology. `title` is a heading-size heading at `headingAs` (`messageCardHeadingElements`: `"h2"` by default, `"h1"` where the card is the whole page), centred. `lines` are muted centred paragraphs: two or fewer (more is allowed but not advised). An empty `icon` (nothing, `false`, `''`) draws no box. `action` is `{ label, onPress, variant?, icon? }`, a `Button` under them (padded by step 2) of `variant` `"neutral"` (the default, grey) or `"primary"` (where it is the page's one way on, `messageCardActionVariants`), its `icon` (a glyph at step 4) before its words. `alert` (default `true`) makes the card `role="alert"`, read when it appears, and gives its action the focus; `alert={false}` is a plain statement, nothing announced or focused, for a state the person did not cause. Use `EmptyState` for an empty list inside a page and `Notice` for a note in a page's flow. A blank title, line or action label, or an unknown `headingAs` or variant, throws a `RangeError`.
|
|
1079
|
+
|
|
1080
|
+
```tsx
|
|
1081
|
+
<MessageCard
|
|
1082
|
+
icon={<CirclePause size={24} strokeWidth={1.75} aria-hidden />}
|
|
1083
|
+
title="This list is paused."
|
|
1084
|
+
lines={['Its owner can turn it back on.']}
|
|
1085
|
+
action={{ label: 'Go back', onPress: goBack }}
|
|
1086
|
+
/>
|
|
1087
|
+
|
|
1088
|
+
<MessageCard
|
|
1089
|
+
alert={false}
|
|
1090
|
+
icon={<Users size={24} strokeWidth={1.75} aria-hidden />}
|
|
1091
|
+
title="Nobody is set up yet"
|
|
1092
|
+
lines={['Add someone in Settings to use this page.']}
|
|
1093
|
+
action={{ label: 'Open Settings', onPress: openSettings }}
|
|
1094
|
+
/>
|
|
1095
|
+
```
|
|
1096
|
+
|
|
1031
1097
|
`GlyphTile` is a small rounded square in a categorical colour with the consumer's glyph in white: the mark of a kind beside its name, such as a service in a list. `hue` is one of the `@scalewing/tokens` categorical colours (`green`, `blue`, `orange`, `purple`, `teal`, `rose`, or `neutral`); which kind takes which hue is yours. `size` is `sm` (24), `md` (28, the default) or `lg` (32); the glyph is drawn at spacing step 4 in white, which keeps 3:1 on every fill; pass the SVG (a Lucide component) as the tile's direct child, since only a direct-child SVG is sized. It is always `aria-hidden`, so put the kind's name in visible text beside it. An unknown `hue` or `size` throws a `RangeError`. It may hold up to three letters in place of the glyph, such as initials (`<GlyphTile hue="neutral" size="sm">NSL</GlyphTile>`): words given as its children are drawn in one line at weight 600 and sized from the tile, not the text round it (one letter at half its side, two at 0.42, three at a third), so they fit every size; blank words or more than three letters throw a `RangeError`.
|
|
1032
1098
|
|
|
1033
1099
|
```tsx
|
|
@@ -1362,7 +1428,55 @@ The frame is centred at `SiteHeader`'s bar width with its gutters, so the naviga
|
|
|
1362
1428
|
</Card>
|
|
1363
1429
|
```
|
|
1364
1430
|
|
|
1365
|
-
`ListGroup` is rows in one list with a hairline between each pair, the web twin of react-native's: a `ul` (its list role kept) named by `aria-label` or `aria-labelledby`. `variant="panel"` (the default) is one bordered panel; `plain` draws no panel and a hairline above the first row too, for rows inside a `Card`. `variant="tiles"` keeps one list (its name, its list items, a screen reader's count of them) and lays its rows out as tiles: each row its own bordered panel on the surface with no hairline between them, in `tileColumns` equal columns (`2`, `3` the default, or `4`; `listTileColumnCounts`, `ListGroupTileColumns`) a spacing step 3 apart from `md` up, one a row below it, such as a strip of new arrivals under its heading. A row's press fill and inset focus ring stay inside its tile; `truncate` keeps a long title to one line in a narrow tile.
|
|
1431
|
+
`ListGroup` is rows in one list with a hairline between each pair, the web twin of react-native's: a `ul` (its list role kept) named by `aria-label` or `aria-labelledby`. `variant="panel"` (the default) is one bordered panel; `plain` draws no panel and a hairline above the first row too, for rows inside a `Card`. `variant="tiles"` keeps one list (its name, its list items, a screen reader's count of them) and lays its rows out as tiles: each row its own bordered panel on the surface with no hairline between them, in `tileColumns` equal columns (`2`, `3` the default, or `4`; `listTileColumnCounts`, `ListGroupTileColumns`) a spacing step 3 apart from `md` up, one a row below it, such as a strip of new arrivals under its heading. A row's press fill and inset focus ring stay inside its tile, and fill it: tiles on one grid row are as tall as the tallest, and a shorter tile's row stretches to its edges (an `action` stays centred); `truncate` keeps a long title to one line in a narrow tile. With `maxHeight`, tiles scroll as a bounded list does: the grid sits in the same named scroll region (a keyboard stop, its name required), `rows` counts rows of tiles (each the counted row of a title and one detail line, 62 px, inside its two hairlines, the gap between them; one tile a row on a phone), and the shade on an edge with more past it is drawn over the tiles, which would hide one drawn under them. Since the count assumes a detail line, title-only `lg` tiles (58 px with their hairlines) show a part of the next row under the shade, which says there is more. Tab moves through the tiles in their reading order, row by row, and the region keeps a spacing-step-5 margin (`scroll-padding-block`) so a focused tile scrolls fully into view, clear of the shade, its ring whole; the margin is clamped to what the region has over one row of tiles, so a region one row tall (`rows: 1`) keeps none: its focused tile is whole, with its ring, but may sit under both shades. There is no virtualisation: every tile is in the DOM. Tiles take no `footer` (they do not add up to a total), and `tileColumns` needs `tiles`; either throws a `RangeError`, as does a count other than 2, 3 or 4. `size="lg"` (opt-in; default `"md"`, `listGroupSizes`, `ListGroupSize`) makes every row of the group at least 56 px tall on every pointer (spacing steps 8 and 2, class `sw-list-group-lg`), its parts centred in the row, a larger press target than the 44 px a pressable row takes on a coarse pointer, such as a grid of names chosen at a shared counter; a row of a title and a detail is taller than that already. A bounded list counts the same rows at either size. An unknown size throws a `RangeError`.
|
|
1432
|
+
|
|
1433
|
+
```tsx
|
|
1434
|
+
<ListGroup
|
|
1435
|
+
aria-labelledby="who"
|
|
1436
|
+
variant="tiles"
|
|
1437
|
+
size="lg"
|
|
1438
|
+
maxHeight={{ rows: 4 }}
|
|
1439
|
+
>
|
|
1440
|
+
{people.map((person) => (
|
|
1441
|
+
<ListRow
|
|
1442
|
+
key={person.id}
|
|
1443
|
+
title={person.name}
|
|
1444
|
+
truncate
|
|
1445
|
+
accessory="none"
|
|
1446
|
+
onPress={() => choose(person)}
|
|
1447
|
+
/>
|
|
1448
|
+
))}
|
|
1449
|
+
</ListGroup>
|
|
1450
|
+
```
|
|
1451
|
+
|
|
1452
|
+
Each `ListRow` has a `title` (weight 600, or the body weight with `titleAppearance="plain"`; `tone="danger"` for a row that ends something), an optional muted `detail` line, an optional `value` at its end (weight 600, tabular figures; `valueTone` `success`, `danger`, `muted`, `accent` or `warning`, the warning colour's ink moved halfway to the text colour so it keeps 4.5:1 on the surface in every palette; `valueBadge` draws the value as a `Badge` in that tone instead, such as a status, still read in the row's name, never with `valueTone`; `valueDetail` a muted line under it) and an optional `leading` mark such as a status dot, hidden from assistive technology, so the words say what it means. With `onPress` the whole row is a button, and with `href` a link (`onPress` then takes a plain press for a client router); either adds a chevron, a quiet fill under the pointer and 44 px on a coarse pointer, and the row is named by its title and value and described by its detail lines (`aria-label` replaces the name). `selected` makes a pressable row a choice: a check while true, `aria-pressed` on a button or `aria-current` on a link (on a row with neither `onPress` nor `href` it throws, since nothing could read the state). `accessory="none"` hides the chevron of a row that acts in place; `disabled` blocks presses. A row with neither `onPress` nor `href` only states something. `maxHeight={{ rows }}` bounds the list to that many rows of a title and one detail line, the rest scrolling inside its own named region, which shades an edge with more rows past it; a bounded list must be named. `footer` stays pinned under the rows, outside the scroll, such as a `ListRow` with the count and the total (a row there is not a list item). An empty title or value, an unknown variant, tone or badge tone, a `valueDetail`, `valueTone` or `valueBadge` without a value, a value both toned and a badge, or a bad row count throws a `RangeError`.
|
|
1453
|
+
|
|
1454
|
+
`PersonPicker` is people to choose from as large tiles, such as the names at a shared sign-in screen: a `ListGroup` of `lg` tiles (`tileColumns` 3 from `md`, one a row below it), each a `ListRow` button named by the person's `name` (or its `aria-label`, such as "Ada O., PIN locked", where the name alone is not enough), with an optional `tag` (a `Badge`) before its end and no chevron. `people` is `{ id, name, tag?, 'aria-label'? }[]` in the order to show them; `onChoose(id)` gets the pressed person's id. From `searchFrom` people (13 by default, a whole number from 1) a search `Field` labelled `labels.find` comes first and narrows the tiles to names starting with what was typed, its outer spaces trimmed, compared without capitals or accents (NFD, marks removed); the tiles then scroll inside a region named `labels.list`, four rows at a time (`maxHeight={{ rows: 4 }}`). With nobody to show, a muted `role="status"` line says `labels.noMatch`; while the search is shown that status is mounted from the start, empty and taking no room, so a screen reader reads its words when they appear (an empty `people` shows the line too). The first tile takes the focus when the picker mounts (`autoFocus`, default true; pass `false` where something else should); narrowing leaves the focus in the field. The same filter is exported as `peopleStartingWith(people, typed)`, with `comparableName`. Blank labels or names, a repeated id and a bad `searchFrom` throw a `RangeError`.
|
|
1455
|
+
|
|
1456
|
+
```tsx
|
|
1457
|
+
<PersonPicker
|
|
1458
|
+
people={people.map((person) => ({
|
|
1459
|
+
id: person.id,
|
|
1460
|
+
name: person.name,
|
|
1461
|
+
...(person.locked
|
|
1462
|
+
? {
|
|
1463
|
+
'aria-label': `${person.name}, PIN locked`,
|
|
1464
|
+
tag: (
|
|
1465
|
+
<Badge tone="warning" size="sm">
|
|
1466
|
+
PIN locked
|
|
1467
|
+
</Badge>
|
|
1468
|
+
),
|
|
1469
|
+
}
|
|
1470
|
+
: {}),
|
|
1471
|
+
}))}
|
|
1472
|
+
onChoose={choose}
|
|
1473
|
+
labels={{
|
|
1474
|
+
list: 'Who’s working?',
|
|
1475
|
+
find: 'Find your name',
|
|
1476
|
+
noMatch: 'No name starts with that.',
|
|
1477
|
+
}}
|
|
1478
|
+
/>
|
|
1479
|
+
```
|
|
1366
1480
|
|
|
1367
1481
|
`FixtureRow` is one pairing of two sides, such as a game: `home` and `away` (`{ name, mark? }`, the mark a hidden crest beside the name on the centre's side), `center` (a kickoff time, `centerKind="time"`, the default, in a small grey chip, or a score, `"score"`, in bold figures; both tabular), then `meta` (muted, such as the field) and `status` (`{ label, tone }`, a small `Badge`) at the end. The home side ends at the centre and the away side starts from it, mirrored in right-to-left; names wrap. Rows live in a `FixtureGroup` (`{ title, children }`), a caption that names their list (a date and a venue): the list is one grid and each row a subgrid of it, so the centres and ends line up down the run whatever the names (a browser without subgrid, before Chrome 117 or Safari 16, draws each row on its own grid, unaligned). Below `md` the end moves under the sides; `metaHideBelow` (`md` or `lg`) leaves the meta out below it. With `href` the whole row is a link and with `onPress` alone a button (with both, `onPress` takes a plain press on the link for a client router), with a chevron, a hover fill, an inset focus ring and 44 px; `aria-label` names it in your words ("Heron Marsh with Otter Pool, 8:00"), otherwise it is named by what it shows, in order. A blank title, a row outside a group, a side without a name, a blank centre, an unknown `centerKind` or `metaHideBelow`, a bad status, a blank `href`, or an `aria-label` that is blank or on a row with neither `href` nor `onPress` throws a `RangeError`.
|
|
1368
1482
|
|
|
@@ -1682,6 +1796,8 @@ Every `Box`-based component (`Box`, `Stack`, `Inline`, `Card`, `Grid`, …) take
|
|
|
1682
1796
|
|
|
1683
1797
|
Values outside the catalog throw a `RangeError`. There is no per-breakpoint span and no arbitrary column template.
|
|
1684
1798
|
|
|
1799
|
+
Every `Box`-based component also takes `shrink`. `shrink={false}` (opt-in, the generated `sw-no-shrink`, `flex-shrink: 0`) keeps the box at its natural size along its parent's main axis when the parent is a flex container short of room (its width in an `Inline` row, its height in a `Stack` column): it gives up none of it and its siblings give way instead, such as a header's actions (a `Button` and an account `ActionMenu` in their own `Inline`) beside navigation that wraps. An `Inline` or `Stack` otherwise shrinks below its content (`min-width: 0`), so the controls in it would be squeezed or spill out of it. The box can then be larger than its parent, so keep it for content that fits at the widths you support. `shrink` left out or `true` changes nothing.
|
|
1800
|
+
|
|
1685
1801
|
`Grid` `align` (`start`, `center`, `end`, `stretch`) sets where each child sits in the height of its row, with the same generated `sw-align-*` classes as `Stack` and `Inline`. Unset, children stretch. `align="end"` keeps a row of fields level when one label wraps:
|
|
1686
1802
|
|
|
1687
1803
|
```tsx
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { type AnchorHTMLAttributes, type HTMLAttributes } from 'react';
|
|
|
3
3
|
import { type BoxBorderValue } from '../css/css-box-border.js';
|
|
4
4
|
import { type BoxLinkAppearance } from '../css/css-box-link.js';
|
|
5
5
|
import { type ColumnSpanProps } from '../column-span-classes.js';
|
|
6
|
+
import { type FlexItemProps } from '../flex-item-classes.js';
|
|
6
7
|
import { type SpacingProps } from '../spacing-classes.js';
|
|
7
8
|
import { type VisibilityProps } from '../visibility-classes.js';
|
|
8
9
|
export type BoxElement = 'div' | 'section' | 'article' | 'header' | 'footer' | 'main' | 'nav' | 'aside' | 'span' | 'a' | 'label';
|
|
9
|
-
export type BoxProps = SpacingProps & VisibilityProps & ColumnSpanProps & HTMLAttributes<HTMLElement> & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'download' | 'href' | 'rel' | 'target'> & {
|
|
10
|
+
export type BoxProps = SpacingProps & VisibilityProps & ColumnSpanProps & FlexItemProps & HTMLAttributes<HTMLElement> & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'download' | 'href' | 'rel' | 'target'> & {
|
|
10
11
|
as?: BoxElement;
|
|
11
12
|
background?: Extract<SemanticColorKey, 'background' | 'surface'>;
|
|
12
13
|
radius?: RadiusStep;
|
|
@@ -43,7 +44,7 @@ export type BoxProps = SpacingProps & VisibilityProps & ColumnSpanProps & HTMLAt
|
|
|
43
44
|
};
|
|
44
45
|
export type BoxBorder = BoxBorderValue;
|
|
45
46
|
export type BoxLink = BoxLinkAppearance;
|
|
46
|
-
export declare const Box: import("react").ForwardRefExoticComponent<SpacingProps & VisibilityProps & ColumnSpanProps & HTMLAttributes<HTMLElement> & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, "rel" | "download" | "href" | "target"> & {
|
|
47
|
+
export declare const Box: import("react").ForwardRefExoticComponent<SpacingProps & VisibilityProps & ColumnSpanProps & FlexItemProps & HTMLAttributes<HTMLElement> & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, "rel" | "download" | "href" | "target"> & {
|
|
47
48
|
as?: BoxElement;
|
|
48
49
|
background?: Extract<SemanticColorKey, "background" | "surface">;
|
|
49
50
|
radius?: RadiusStep;
|
package/dist/components/Box.js
CHANGED
|
@@ -4,11 +4,12 @@ import { cx } from '../class-names.js';
|
|
|
4
4
|
import { boxBorderClass } from '../css/css-box-border.js';
|
|
5
5
|
import { assertBoxLink, boxLinkClass, } from '../css/css-box-link.js';
|
|
6
6
|
import { columnSpanClassNames, } from '../column-span-classes.js';
|
|
7
|
+
import { flexItemClassNames, } from '../flex-item-classes.js';
|
|
7
8
|
import { spacingClassNames } from '../spacing-classes.js';
|
|
8
9
|
import { assertBoxExternal, externalLinkContent, externalLinkRel, } from './box/external-link.js';
|
|
9
10
|
import { tabStop } from '../tab-stop.js';
|
|
10
11
|
import { visibilityClassNames, } from '../visibility-classes.js';
|
|
11
|
-
export const Box = forwardRef(function Box({ as = 'div', background, border, children, className, columnSpan, external, hideBelow, hideFrom, link, newTabLabel, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, radius, rel, style, tabIndex, target, ...rest }, ref) {
|
|
12
|
+
export const Box = forwardRef(function Box({ as = 'div', background, border, children, className, columnSpan, external, hideBelow, hideFrom, link, newTabLabel, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, radius, rel, shrink, style, tabIndex, target, ...rest }, ref) {
|
|
12
13
|
assertBoxLink(link, as);
|
|
13
14
|
assertBoxExternal({ as, external, newTabLabel });
|
|
14
15
|
// assertBoxExternal has made sure an external link has its words.
|
|
@@ -24,7 +25,7 @@ export const Box = forwardRef(function Box({ as = 'div', background, border, chi
|
|
|
24
25
|
paddingTop,
|
|
25
26
|
paddingX,
|
|
26
27
|
paddingY,
|
|
27
|
-
}), ...visibilityClassNames({ hideBelow, hideFrom }), ...columnSpanClassNames({ columnSpan }), boxBorderClass(border), boxLinkClass(link), className), style: {
|
|
28
|
+
}), ...visibilityClassNames({ hideBelow, hideFrom }), ...columnSpanClassNames({ columnSpan }), ...flexItemClassNames({ shrink }), boxBorderClass(border), boxLinkClass(link), className), style: {
|
|
28
29
|
backgroundColor: background
|
|
29
30
|
? `var(--sw-color-${background})`
|
|
30
31
|
: undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type ListGroupTileColumns } from '../css/css-list-tiles.js';
|
|
3
|
-
import { type ListGroupMaxHeight, type ListGroupVariant } from '../list-options.js';
|
|
3
|
+
import { type ListGroupMaxHeight, type ListGroupSize, type ListGroupVariant } from '../list-options.js';
|
|
4
4
|
export type ListGroupProps = {
|
|
5
5
|
/** `ListRow` elements; the group draws a hairline between each pair. */
|
|
6
6
|
children: ReactNode;
|
|
@@ -16,10 +16,17 @@ export type ListGroupProps = {
|
|
|
16
16
|
variant?: ListGroupVariant;
|
|
17
17
|
/** How many tiles share a row from `md` up (`tiles` only): 2, 3 (default) or 4. */
|
|
18
18
|
tileColumns?: ListGroupTileColumns;
|
|
19
|
+
/**
|
|
20
|
+
* `md` (the default) rows are as tall as their words; `lg` rows stand
|
|
21
|
+
* at least 56 px on every pointer with their words centred, a larger
|
|
22
|
+
* press target such as a name pressed at a shared counter.
|
|
23
|
+
*/
|
|
24
|
+
size?: ListGroupSize;
|
|
19
25
|
/**
|
|
20
26
|
* Bounds the list to a row count of its own region, `{ rows }` rows of a
|
|
21
27
|
* title and one detail line, where the rest scroll; the region is a named
|
|
22
|
-
* keyboard stop and shades an edge with more rows past it.
|
|
28
|
+
* keyboard stop and shades an edge with more rows past it. With `tiles`
|
|
29
|
+
* it counts rows of tiles, the grid scrolling inside the region.
|
|
23
30
|
*/
|
|
24
31
|
maxHeight?: ListGroupMaxHeight;
|
|
25
32
|
/**
|
|
@@ -33,6 +40,7 @@ export type ListGroupProps = {
|
|
|
33
40
|
/**
|
|
34
41
|
* Rows in one list (`ul`, its list role kept) with hairlines between them:
|
|
35
42
|
* a panel of its own, or plain rows inside a surface; or the same list's
|
|
36
|
-
* rows as tiles, each a panel
|
|
43
|
+
* rows as tiles, each a panel, bounded to a count of rows (of tiles)
|
|
44
|
+
* that scroll in a named region. The ref reaches the outer box.
|
|
37
45
|
*/
|
|
38
46
|
export declare const ListGroup: import("react").ForwardRefExoticComponent<ListGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { cx } from '../class-names.js';
|
|
5
|
+
import { listGroupLargeClass } from '../css/css-list-size.js';
|
|
5
6
|
import { listTileColumnsClass, } from '../css/css-list-tiles.js';
|
|
6
7
|
import { assertListGroup, listMaxHeightStyle, } from '../list-options.js';
|
|
7
8
|
import { ListRowContainer } from './list/list-row-container.js';
|
|
@@ -9,13 +10,15 @@ import { ScrollRegion } from './ScrollRegion.js';
|
|
|
9
10
|
/**
|
|
10
11
|
* Rows in one list (`ul`, its list role kept) with hairlines between them:
|
|
11
12
|
* a panel of its own, or plain rows inside a surface; or the same list's
|
|
12
|
-
* rows as tiles, each a panel
|
|
13
|
+
* rows as tiles, each a panel, bounded to a count of rows (of tiles)
|
|
14
|
+
* that scroll in a named region. The ref reaches the outer box.
|
|
13
15
|
*/
|
|
14
|
-
export const ListGroup = forwardRef(function ListGroup({ children, 'aria-label': label, 'aria-labelledby': labelledBy, variant = 'panel', tileColumns, maxHeight, footer, className, id, }, ref) {
|
|
16
|
+
export const ListGroup = forwardRef(function ListGroup({ children, 'aria-label': label, 'aria-labelledby': labelledBy, variant = 'panel', tileColumns, size = 'md', maxHeight, footer, className, id, }, ref) {
|
|
15
17
|
assertListGroup({
|
|
16
18
|
label,
|
|
17
19
|
labelledBy,
|
|
18
20
|
variant,
|
|
21
|
+
size,
|
|
19
22
|
maxHeight,
|
|
20
23
|
tileColumns,
|
|
21
24
|
hasFooter: footer !== undefined,
|
|
@@ -23,5 +26,5 @@ export const ListGroup = forwardRef(function ListGroup({ children, 'aria-label':
|
|
|
23
26
|
const list = (_jsx("ul", { "aria-label": label, "aria-labelledby": labelledBy, className: "sw-list",
|
|
24
27
|
// A list styled without bullets loses its role in Safari.
|
|
25
28
|
role: "list", children: _jsx(ListRowContainer.Provider, { value: "li", children: children }) }));
|
|
26
|
-
return (_jsxs("div", { className: cx('sw-list-group', `sw-list-group-${variant}`, variant === 'tiles' && listTileColumnsClass(tileColumns ?? 3), className), id: id, ref: ref, children: [maxHeight === undefined ? (list) : (_jsx(ScrollRegion, { "aria-label": label, "aria-labelledby": labelledBy, className: "sw-list-group-scroll", style: listMaxHeightStyle(maxHeight), children: list })), footer === undefined ? null : (_jsx("div", { className: "sw-list-group-footer", children: _jsx(ListRowContainer.Provider, { value: "div", children: footer }) }))] }));
|
|
29
|
+
return (_jsxs("div", { className: cx('sw-list-group', `sw-list-group-${variant}`, variant === 'tiles' && listTileColumnsClass(tileColumns ?? 3), size === 'lg' && listGroupLargeClass, className), id: id, ref: ref, children: [maxHeight === undefined ? (list) : (_jsx(ScrollRegion, { "aria-label": label, "aria-labelledby": labelledBy, className: "sw-list-group-scroll", style: listMaxHeightStyle(maxHeight), children: list })), footer === undefined ? null : (_jsx("div", { className: "sw-list-group-footer", children: _jsx(ListRowContainer.Provider, { value: "div", children: footer }) }))] }));
|
|
27
30
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare const messageCardHeadingElements: readonly ["h1", "h2"];
|
|
3
|
+
/** The title's level: `h2` (the default) in a page, `h1` where the card is the page. */
|
|
4
|
+
export type MessageCardHeadingElement = (typeof messageCardHeadingElements)[number];
|
|
5
|
+
export declare const messageCardActionVariants: readonly ["neutral", "primary"];
|
|
6
|
+
/** The action's look: `neutral` (the default) grey, or `primary` where it is the page's one way on. */
|
|
7
|
+
export type MessageCardActionVariant = (typeof messageCardActionVariants)[number];
|
|
8
|
+
/** The card's one button. */
|
|
9
|
+
export type MessageCardAction = {
|
|
10
|
+
label: string;
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
variant?: MessageCardActionVariant;
|
|
13
|
+
/** A decorative glyph before the words (Lucide in the consumer, at spacing step 4). */
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
export type MessageCardProps = {
|
|
17
|
+
/** What happened or what is true, such as "This list is paused." */
|
|
18
|
+
title: string;
|
|
19
|
+
/** `h2` (the default) or `h1`. */
|
|
20
|
+
headingAs?: MessageCardHeadingElement;
|
|
21
|
+
/** Muted lines under the title: two or fewer (more is allowed but not advised). None blank. */
|
|
22
|
+
lines?: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* A decorative glyph over the title, drawn in the muted colour (Lucide
|
|
25
|
+
* in the consumer, at spacing step 5: `size={24} strokeWidth={1.75}`,
|
|
26
|
+
* `aria-hidden`).
|
|
27
|
+
*/
|
|
28
|
+
icon?: ReactNode;
|
|
29
|
+
action?: MessageCardAction;
|
|
30
|
+
/**
|
|
31
|
+
* `true` (the default): the card is an alert, read when it appears, and
|
|
32
|
+
* its action takes the focus, for a refusal the person ran into.
|
|
33
|
+
* `false`: a plain statement, nothing announced or focused, for a state
|
|
34
|
+
* the person did not cause (such as nothing set up yet).
|
|
35
|
+
*/
|
|
36
|
+
alert?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A centred message on an outlined card, such as a screen that cannot go
|
|
40
|
+
* on: a muted glyph, a title, a line or two and one button. By default an
|
|
41
|
+
* alert whose button takes the focus.
|
|
42
|
+
*/
|
|
43
|
+
export declare function MessageCard(props: MessageCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isOneOf } from '../is-one-of.js';
|
|
3
|
+
import { hasSlot } from './slot.js';
|
|
4
|
+
import { Box } from './Box.js';
|
|
5
|
+
import { Button } from './Button.js';
|
|
6
|
+
import { Card } from './Card.js';
|
|
7
|
+
import { Stack } from './Stack.js';
|
|
8
|
+
import { Text } from './Text.js';
|
|
9
|
+
export const messageCardHeadingElements = ['h1', 'h2'];
|
|
10
|
+
export const messageCardActionVariants = ['neutral', 'primary'];
|
|
11
|
+
function isBlank(value) {
|
|
12
|
+
return typeof value !== 'string' || value.trim() === '';
|
|
13
|
+
}
|
|
14
|
+
/** Fails closed on blank words or an unknown heading level or variant. */
|
|
15
|
+
function assertMessageCard({ title, headingAs, lines, action, }) {
|
|
16
|
+
if (isBlank(title))
|
|
17
|
+
throw new RangeError('MessageCard title must be nonempty');
|
|
18
|
+
if (headingAs !== undefined &&
|
|
19
|
+
!isOneOf(messageCardHeadingElements, headingAs))
|
|
20
|
+
throw new RangeError(`Unknown MessageCard headingAs: ${String(headingAs)}`);
|
|
21
|
+
if (lines?.some(isBlank))
|
|
22
|
+
throw new RangeError('MessageCard lines must be nonempty');
|
|
23
|
+
if (action === undefined)
|
|
24
|
+
return;
|
|
25
|
+
if (isBlank(action.label))
|
|
26
|
+
throw new RangeError('MessageCard action.label must be nonempty');
|
|
27
|
+
if (action.variant !== undefined &&
|
|
28
|
+
!isOneOf(messageCardActionVariants, action.variant))
|
|
29
|
+
throw new RangeError(`Unknown MessageCard action variant: ${String(action.variant)}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A centred message on an outlined card, such as a screen that cannot go
|
|
33
|
+
* on: a muted glyph, a title, a line or two and one button. By default an
|
|
34
|
+
* alert whose button takes the focus.
|
|
35
|
+
*/
|
|
36
|
+
export function MessageCard(props) {
|
|
37
|
+
assertMessageCard(props);
|
|
38
|
+
const { title, headingAs = 'h2', lines = [], icon, action, alert = true, } = props;
|
|
39
|
+
return (_jsx(Card, { padding: 6, role: alert ? 'alert' : undefined, variant: "outlined", children: _jsxs(Stack, { align: "center", gap: 3, children: [hasSlot(icon) ? (_jsx(Text, { "aria-hidden": "true", as: "span", color: "muted", children: icon })) : null, _jsx(Text, { align: "center", as: headingAs, variant: "heading", children: title }), lines.map((line, index) => (_jsx(Text, { align: "center", color: "muted", children: line }, index))), action ? (_jsx(Box, { paddingTop: 2, children: _jsxs(Button, { autoFocus: alert, onPress: action.onPress, variant: action.variant ?? 'neutral', children: [action.icon, action.label] }) })) : null] }) }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** One person to choose: their id, the name on the tile, and an optional status. */
|
|
3
|
+
export type PersonPickerPerson = {
|
|
4
|
+
id: string;
|
|
5
|
+
/** The name drawn on the tile, and the tile's name unless `aria-label` is given. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** A status before the tile's end, such as a `Badge`, which describes the tile. */
|
|
8
|
+
tag?: ReactNode;
|
|
9
|
+
/** The tile's whole name where the name alone is not enough ("Ada O., locked"). */
|
|
10
|
+
'aria-label'?: string;
|
|
11
|
+
};
|
|
12
|
+
/** PersonPicker's words, all of them the consumer's. */
|
|
13
|
+
export type PersonPickerLabels = {
|
|
14
|
+
/** Names the list (and, while it scrolls, its scroll region). */
|
|
15
|
+
list: string;
|
|
16
|
+
/** The search field's label. */
|
|
17
|
+
find: string;
|
|
18
|
+
/** Said when nobody's name starts with what was typed. */
|
|
19
|
+
noMatch: string;
|
|
20
|
+
};
|
|
21
|
+
export type PersonPickerProps = {
|
|
22
|
+
/** The people, in the order the tiles show them. Ids are unique, names not blank. */
|
|
23
|
+
people: readonly PersonPickerPerson[];
|
|
24
|
+
/** Called with the chosen person's id. */
|
|
25
|
+
onChoose: (id: string) => void;
|
|
26
|
+
labels: PersonPickerLabels;
|
|
27
|
+
/**
|
|
28
|
+
* From this many people (13 by default) a search field narrows the
|
|
29
|
+
* tiles to names starting with what was typed, and the tiles scroll
|
|
30
|
+
* inside their region, four rows at a time.
|
|
31
|
+
*/
|
|
32
|
+
searchFrom?: number;
|
|
33
|
+
/** Focuses the first tile when the picker mounts. Default true. */
|
|
34
|
+
autoFocus?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* People to choose from as large tiles: three across from `md`, one a row
|
|
38
|
+
* below it, each a button named by the person. From `searchFrom` people a
|
|
39
|
+
* search field narrows them to names starting with what was typed (case
|
|
40
|
+
* and accents ignored) and the tiles scroll inside a named region, four
|
|
41
|
+
* rows at a time; nobody left is a muted status line. The first tile has
|
|
42
|
+
* the focus when the picker mounts.
|
|
43
|
+
*/
|
|
44
|
+
export declare function PersonPicker({ people, onChoose, labels, searchFrom, autoFocus, }: PersonPickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { peopleStartingWith } from '../person-names.js';
|
|
5
|
+
import { Box } from './Box.js';
|
|
6
|
+
import { Field } from './Field.js';
|
|
7
|
+
import { ListGroup } from './ListGroup.js';
|
|
8
|
+
import { ListRow } from './ListRow.js';
|
|
9
|
+
import { Stack } from './Stack.js';
|
|
10
|
+
import { Text } from './Text.js';
|
|
11
|
+
/** The rows of tiles a scrolling picker shows at a time: 12 names three across. */
|
|
12
|
+
const scrollRows = 4;
|
|
13
|
+
const defaultSearchFrom = 13;
|
|
14
|
+
/** Fails closed on blank words, a bad threshold, or a blank or repeated person. */
|
|
15
|
+
function assertPersonPicker({ people, labels, searchFrom, }) {
|
|
16
|
+
for (const key of ['list', 'find', 'noMatch']) {
|
|
17
|
+
if (typeof labels[key] !== 'string' || labels[key].trim() === '')
|
|
18
|
+
throw new RangeError(`PersonPicker labels.${key} must be nonempty`);
|
|
19
|
+
}
|
|
20
|
+
if (!Number.isInteger(searchFrom) || searchFrom < 1)
|
|
21
|
+
throw new RangeError('PersonPicker searchFrom must be a whole number from 1');
|
|
22
|
+
const ids = new Set();
|
|
23
|
+
for (const person of people) {
|
|
24
|
+
if (person.name.trim() === '')
|
|
25
|
+
throw new RangeError('PersonPicker names must be nonempty');
|
|
26
|
+
if (ids.has(person.id))
|
|
27
|
+
throw new RangeError(`PersonPicker ids must be unique: ${person.id}`);
|
|
28
|
+
ids.add(person.id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* People to choose from as large tiles: three across from `md`, one a row
|
|
33
|
+
* below it, each a button named by the person. From `searchFrom` people a
|
|
34
|
+
* search field narrows them to names starting with what was typed (case
|
|
35
|
+
* and accents ignored) and the tiles scroll inside a named region, four
|
|
36
|
+
* rows at a time; nobody left is a muted status line. The first tile has
|
|
37
|
+
* the focus when the picker mounts.
|
|
38
|
+
*/
|
|
39
|
+
export function PersonPicker({ people, onChoose, labels, searchFrom = defaultSearchFrom, autoFocus = true, }) {
|
|
40
|
+
assertPersonPicker({ people, labels, searchFrom });
|
|
41
|
+
const [typed, setTyped] = useState('');
|
|
42
|
+
const list = useRef(null);
|
|
43
|
+
const searching = people.length >= searchFrom;
|
|
44
|
+
const shown = searching ? peopleStartingWith(people, typed) : people;
|
|
45
|
+
// Read once: only the mount focuses, so a search narrowing the tiles
|
|
46
|
+
// leaves the focus in the field.
|
|
47
|
+
const focusOnMount = useRef(autoFocus);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (focusOnMount.current)
|
|
50
|
+
list.current?.querySelector('button')?.focus();
|
|
51
|
+
}, []);
|
|
52
|
+
return (_jsxs(Stack, { gap: 3, children: [searching ? (_jsx(Field, { label: labels.find, children: _jsx("input", { autoComplete: "off", onChange: (event) => setTyped(event.target.value), type: "search", value: typed }) })) : null, _jsxs(Box, { ref: list, children: [searching || shown.length === 0 ? (_jsx(Text, { color: "muted", role: "status", children: shown.length === 0 ? labels.noMatch : null })) : null, shown.length === 0 ? null : (_jsx(ListGroup, { "aria-label": labels.list, size: "lg", tileColumns: 3, variant: "tiles", ...(searching ? { maxHeight: { rows: scrollRows } } : {}), children: shown.map((person) => (_jsx(ListRow, { accessory: "none", "aria-label": person['aria-label'], onPress: () => onChoose(person.id), tag: person.tag, title: person.name }, person.id))) }))] })] }));
|
|
53
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type PinFieldProps } from './PinField.js';
|
|
2
|
+
export declare const pinStepHeadingElements: readonly ["h1", "h2"];
|
|
3
|
+
/** The heading's level: `h1` (the default) where the step is the page, `h2` under a page heading. */
|
|
4
|
+
export type PinStepHeadingElement = (typeof pinStepHeadingElements)[number];
|
|
5
|
+
/** A quiet press action of the step: its words and what it does. */
|
|
6
|
+
export type PinStepAction = {
|
|
7
|
+
label: string;
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
};
|
|
10
|
+
export type PinStepProps = Omit<PinFieldProps, 'pad'> & {
|
|
11
|
+
/** What the step asks, such as "Enter your PIN". */
|
|
12
|
+
heading: string;
|
|
13
|
+
/** `h1` (the default) or `h2`. */
|
|
14
|
+
headingAs?: PinStepHeadingElement;
|
|
15
|
+
/** A short line over the heading, such as the person's name. */
|
|
16
|
+
eyebrow?: string;
|
|
17
|
+
/** A ghost button at the top that leaves the step, such as Back. */
|
|
18
|
+
back?: PinStepAction;
|
|
19
|
+
/**
|
|
20
|
+
* While set, a decorative spinner and these words under the field, such
|
|
21
|
+
* as "Checking…", in a polite status that is always mounted (empty and
|
|
22
|
+
* taking no room while idle), so they are read. Pair it with `disabled`.
|
|
23
|
+
*/
|
|
24
|
+
busy?: string;
|
|
25
|
+
/** A ghost button under the field, such as "Forgot your PIN?". */
|
|
26
|
+
secondaryAction?: PinStepAction;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The step where someone enters a PIN on a shared screen: an optional
|
|
30
|
+
* ghost Back, a short line over the heading, `PinField` with its pad
|
|
31
|
+
* (focused on mount), a spinner and a status line while the code is
|
|
32
|
+
* checked, and an optional ghost action under it. The ref reaches the
|
|
33
|
+
* field's input, to put the focus back after a refusal.
|
|
34
|
+
*/
|
|
35
|
+
export declare const PinStep: import("react").ForwardRefExoticComponent<Omit<PinFieldProps, "pad"> & {
|
|
36
|
+
/** What the step asks, such as "Enter your PIN". */
|
|
37
|
+
heading: string;
|
|
38
|
+
/** `h1` (the default) or `h2`. */
|
|
39
|
+
headingAs?: PinStepHeadingElement;
|
|
40
|
+
/** A short line over the heading, such as the person's name. */
|
|
41
|
+
eyebrow?: string;
|
|
42
|
+
/** A ghost button at the top that leaves the step, such as Back. */
|
|
43
|
+
back?: PinStepAction;
|
|
44
|
+
/**
|
|
45
|
+
* While set, a decorative spinner and these words under the field, such
|
|
46
|
+
* as "Checking…", in a polite status that is always mounted (empty and
|
|
47
|
+
* taking no room while idle), so they are read. Pair it with `disabled`.
|
|
48
|
+
*/
|
|
49
|
+
busy?: string;
|
|
50
|
+
/** A ghost button under the field, such as "Forgot your PIN?". */
|
|
51
|
+
secondaryAction?: PinStepAction;
|
|
52
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|