@scalewing/react 1.70.0 → 1.72.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 +16 -0
- package/README.md +76 -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/PinField.d.ts +48 -0
- package/dist/components/PinField.js +63 -0
- package/dist/components/pin-field/PinPad.d.ts +15 -0
- package/dist/components/pin-field/PinPad.js +20 -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-components.js +3 -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-pin-field.d.ts +6 -0
- package/dist/css/css-pin-field.js +240 -0
- 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/css/stylesheet.js +2 -0
- package/dist/flex-item-classes.d.ts +15 -0
- package/dist/flex-item-classes.js +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/list-options.d.ts +13 -5
- package/dist/list-options.js +15 -7
- package/dist/pin-entry.d.ts +26 -0
- package/dist/pin-entry.js +46 -0
- package/dist/pin-field-labels.d.ts +17 -0
- package/dist/pin-field-labels.js +13 -0
- package/dist/styles.css +276 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.72.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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`.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
- 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`.
|
|
12
|
+
|
|
13
|
+
## 1.71.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 399d27e: `PinField`: a code of a fixed number of digits (`length`, 6 by default) that is never shown. One dot per digit over one real input (`type="text"`, `inputmode="numeric"`, never a password field, kept out of autofill), named by `label`, with `Field`'s `description` and `error`. The consumer holds the digits (`value`, `onChange`); the input's own value is a mask, so no digit is in the page's text, attributes or accessible names. Typing and pasting keep digits only, Backspace removes the last, and `onComplete` is called once at the last digit. The count ("3 of 6 digits entered", `labels.count`) describes the input and is announced politely after each entry. `pad` adds twelve on-screen keys (1 to 9, 0 and Delete), each a button of at least 64 px that keeps the focus when pressed. Also `disabled`, `autoFocus`, `labelVisuallyHidden`, `id`, `aria-describedby` and a ref to the input. New exports `PinField`, `PinFieldProps`, `PinFieldLabels`, `defaultPinFieldLabels`; new `sw-pin-field*` classes. No new tokens, no new dependency. Request: `docs/requests/teisoro-pin-field.md`.
|
|
18
|
+
|
|
3
19
|
## 1.70.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
DateField,
|
|
64
64
|
Field,
|
|
65
65
|
FileField,
|
|
66
|
+
PinField,
|
|
66
67
|
Article,
|
|
67
68
|
Stepper,
|
|
68
69
|
Steps,
|
|
@@ -288,6 +289,33 @@ A chosen photo can show itself: `value.preview` is the address of a small image
|
|
|
288
289
|
/>
|
|
289
290
|
```
|
|
290
291
|
|
|
292
|
+
`PinField` is a code of a fixed number of digits (`length`, 6 by default, 1 to 12) that is never shown: a short PIN or a door code. It draws one dot per digit, filled for the digits entered, over one real input: a native `<input type="text" inputmode="numeric">` named by `label` (above it, or hidden with `labelVisuallyHidden` where a heading says it). It is never a password field, so the browser does not offer to save the code over the account's password, and it is kept out of autofill (`autocomplete="off"`, no `name`, the password managers' ignore hints). You hold the digits: `value` is a string of 0 to 9, `onChange` receives the new one after a key, a paste or a pad press. Typed and pasted text keeps its ASCII digits and drops the rest; digits are added after those already entered and cut to `length`; Backspace removes the last. `onComplete(value)` is called once, after `onChange`, by the entry that fills the last dot (not for a `value` you set, and not again while the field stays full).
|
|
293
|
+
|
|
294
|
+
The digits are never in the page. The input's own value is a mask, one `•` per digit, and nothing the field renders depends on which digits were entered, only on how many: not its text, not an attribute (the input's `value` included), not an accessible name. So read the code from the `value` you hold, never from the input or a form submission, and do not render, log or store it yourself. The input is described by the count ("3 of 6 digits entered") and the same words are announced politely after each entry; `labels.count` is your template, with `{count}` and `{length}`. A screen reader that reads a text field's value also reads the mask ("bullet bullet bullet") beside the count, never a digit. A desktop screen reader set to echo typed keys still says the keys it hears from the keyboard, as in any text field that is not a password field.
|
|
295
|
+
|
|
296
|
+
`pad` adds on-screen keys under the dots: 1 to 9, an empty place, 0 and Delete, in a group named `labels.pad` ("Number pad"). Each key is a real button and Tab stop of at least 64 px with a visible edge; a press enters or deletes as typing does and leaves the focus on the key. Delete is named `labels.delete` ("Delete the last digit") and is `aria-disabled` while there is nothing to delete. With the pad the field is a centred column at most 320 px wide (centred in a wider parent too), the dots stand without a frame, and the hint and error sit under the keys, so the keys never move. The input keeps `inputmode="numeric"`, so on a touch screen focusing it also opens the system's number keyboard; leave `autoFocus` off there if only the pad should show.
|
|
297
|
+
|
|
298
|
+
`description` and `error` are `Field`'s (the error a polite live region in place of the hint, `aria-invalid`, the frame's edge in the danger color); `disabled` turns the input and every key off; `autoFocus` focuses the input on mount; the ref and `id` are the input's, and `aria-describedby` adds your own descriptions before the field's. A blank `label`, a `length` outside 1 to 12, a `value` that is not digits or is longer than `length`, or a blank word in `labels` throws a `RangeError`.
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
<PinField
|
|
302
|
+
label="New code"
|
|
303
|
+
description="Six digits."
|
|
304
|
+
value={code}
|
|
305
|
+
onChange={setCode}
|
|
306
|
+
/>
|
|
307
|
+
|
|
308
|
+
<PinField
|
|
309
|
+
label="Enter your code"
|
|
310
|
+
labelVisuallyHidden
|
|
311
|
+
pad
|
|
312
|
+
value={code}
|
|
313
|
+
onChange={setCode}
|
|
314
|
+
onComplete={check}
|
|
315
|
+
error={refused ? 'That code is not right. Try again.' : undefined}
|
|
316
|
+
/>
|
|
317
|
+
```
|
|
318
|
+
|
|
291
319
|
`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`.
|
|
292
320
|
|
|
293
321
|
`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`.
|
|
@@ -416,6 +444,29 @@ On the web, `variant="neutral"` is a quiet grey fill (the muted color at 16 %, t
|
|
|
416
444
|
|
|
417
445
|
`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`.
|
|
418
446
|
|
|
447
|
+
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`).
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
<Inline justify="between" align="center" gap={3} wrap={false}>
|
|
451
|
+
<Inline align="center" gap={6} wrap>
|
|
452
|
+
{brand}
|
|
453
|
+
{areas}
|
|
454
|
+
</Inline>
|
|
455
|
+
<Inline align="center" gap={2} wrap={false} shrink={false}>
|
|
456
|
+
<Button size="sm" variant="neutral" onPress={switchRoost}>
|
|
457
|
+
Switch to the night roost
|
|
458
|
+
</Button>
|
|
459
|
+
<ActionMenu
|
|
460
|
+
label={`${colony} · ${habitat}`}
|
|
461
|
+
trigger={colony}
|
|
462
|
+
triggerAppearance="text"
|
|
463
|
+
align="end"
|
|
464
|
+
items={items}
|
|
465
|
+
/>
|
|
466
|
+
</Inline>
|
|
467
|
+
</Inline>
|
|
468
|
+
```
|
|
469
|
+
|
|
419
470
|
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.
|
|
420
471
|
|
|
421
472
|
`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.
|
|
@@ -457,7 +508,7 @@ A `Button` that toggles something passes `aria-pressed`. The pressed button gets
|
|
|
457
508
|
|
|
458
509
|
`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).
|
|
459
510
|
|
|
460
|
-
`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`.
|
|
511
|
+
`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`.
|
|
461
512
|
|
|
462
513
|
`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`.
|
|
463
514
|
|
|
@@ -1334,7 +1385,28 @@ The frame is centred at `SiteHeader`'s bar width with its gutters, so the naviga
|
|
|
1334
1385
|
</Card>
|
|
1335
1386
|
```
|
|
1336
1387
|
|
|
1337
|
-
`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.
|
|
1388
|
+
`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`.
|
|
1389
|
+
|
|
1390
|
+
```tsx
|
|
1391
|
+
<ListGroup
|
|
1392
|
+
aria-labelledby="who"
|
|
1393
|
+
variant="tiles"
|
|
1394
|
+
size="lg"
|
|
1395
|
+
maxHeight={{ rows: 4 }}
|
|
1396
|
+
>
|
|
1397
|
+
{people.map((person) => (
|
|
1398
|
+
<ListRow
|
|
1399
|
+
key={person.id}
|
|
1400
|
+
title={person.name}
|
|
1401
|
+
truncate
|
|
1402
|
+
accessory="none"
|
|
1403
|
+
onPress={() => choose(person)}
|
|
1404
|
+
/>
|
|
1405
|
+
))}
|
|
1406
|
+
</ListGroup>
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1409
|
+
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`.
|
|
1338
1410
|
|
|
1339
1411
|
`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`.
|
|
1340
1412
|
|
|
@@ -1654,6 +1726,8 @@ Every `Box`-based component (`Box`, `Stack`, `Inline`, `Card`, `Grid`, …) take
|
|
|
1654
1726
|
|
|
1655
1727
|
Values outside the catalog throw a `RangeError`. There is no per-breakpoint span and no arbitrary column template.
|
|
1656
1728
|
|
|
1729
|
+
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.
|
|
1730
|
+
|
|
1657
1731
|
`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:
|
|
1658
1732
|
|
|
1659
1733
|
```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,48 @@
|
|
|
1
|
+
import { type PinFieldLabels } from '../pin-field-labels.js';
|
|
2
|
+
export { defaultPinFieldLabels, type PinFieldLabels, } from '../pin-field-labels.js';
|
|
3
|
+
export type PinFieldProps = {
|
|
4
|
+
/** The field's label, drawn above it as Field's, and the input's name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Keeps the label as the name only, where a heading already says it. */
|
|
7
|
+
labelVisuallyHidden?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The digits entered so far, held by the consumer: only 0 to 9, at most
|
|
10
|
+
* `length` of them. They are never written to the page.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/** Called with the digits after a key, a paste or a pad press changed them. */
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called once, after `onChange`, by the entry that brings the count to
|
|
17
|
+
* `length`. Not called for a `value` the consumer sets.
|
|
18
|
+
*/
|
|
19
|
+
onComplete?: (value: string) => void;
|
|
20
|
+
/** How many digits the code has, 1 to 12. Default 6. */
|
|
21
|
+
length?: number;
|
|
22
|
+
/** A muted hint under the field. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Replaces the hint with an error, in a polite live region. */
|
|
25
|
+
error?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Focuses the input when the field mounts. */
|
|
28
|
+
autoFocus?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Draws on-screen keys under the dots: 1 to 9, 0 and Delete, each a
|
|
31
|
+
* button of at least 64 px. Default false: typed only.
|
|
32
|
+
*/
|
|
33
|
+
pad?: boolean;
|
|
34
|
+
/** The field's own words, over English defaults. */
|
|
35
|
+
labels?: Partial<PinFieldLabels>;
|
|
36
|
+
/** The input's id; the ids of the field's parts start with it. */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Ids of elements that describe the field, read before its own words. */
|
|
39
|
+
'aria-describedby'?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A code of a fixed number of digits that is never shown: dots for the
|
|
43
|
+
* digits entered, typed in one real input or pressed on an optional pad.
|
|
44
|
+
* The input holds a mask character per digit, never the digits, which live
|
|
45
|
+
* only in the consumer's `value`; the count is read with the field and
|
|
46
|
+
* announced politely after each entry.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PinField: import("react").ForwardRefExoticComponent<PinFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useId, useState } from 'react';
|
|
4
|
+
import { cx } from '../class-names.js';
|
|
5
|
+
import { assertPinLength, assertPinValue, defaultPinLength, pinCountText, pinMask, readPinEntry, } from '../pin-entry.js';
|
|
6
|
+
import { resolvePinFieldLabels, } from '../pin-field-labels.js';
|
|
7
|
+
import { FieldErrorRegion } from './FieldErrorRegion.js';
|
|
8
|
+
import { FieldLabelText } from './FieldLabelText.js';
|
|
9
|
+
import { LiveRegion } from './LiveRegion.js';
|
|
10
|
+
import { PinPad } from './pin-field/PinPad.js';
|
|
11
|
+
import { Stack } from './Stack.js';
|
|
12
|
+
export { defaultPinFieldLabels, } from '../pin-field-labels.js';
|
|
13
|
+
/**
|
|
14
|
+
* A code of a fixed number of digits that is never shown: dots for the
|
|
15
|
+
* digits entered, typed in one real input or pressed on an optional pad.
|
|
16
|
+
* The input holds a mask character per digit, never the digits, which live
|
|
17
|
+
* only in the consumer's `value`; the count is read with the field and
|
|
18
|
+
* announced politely after each entry.
|
|
19
|
+
*/
|
|
20
|
+
export const PinField = forwardRef(function PinField({ label, labelVisuallyHidden = false, value, onChange, onComplete, length = defaultPinLength, description, error, disabled = false, autoFocus = false, pad = false, labels, id, 'aria-describedby': describedBy, }, ref) {
|
|
21
|
+
if (label.trim() === '')
|
|
22
|
+
throw new RangeError('PinField needs a label');
|
|
23
|
+
assertPinLength(length);
|
|
24
|
+
assertPinValue(value, length);
|
|
25
|
+
const words = resolvePinFieldLabels(labels);
|
|
26
|
+
const ownId = useId();
|
|
27
|
+
const inputId = id ?? ownId;
|
|
28
|
+
const ids = {
|
|
29
|
+
count: `${inputId}-count`,
|
|
30
|
+
hint: `${inputId}-hint`,
|
|
31
|
+
error: `${inputId}-error`,
|
|
32
|
+
};
|
|
33
|
+
// Nothing is announced until the person has entered something.
|
|
34
|
+
const [entered, setEntered] = useState(false);
|
|
35
|
+
const count = value.length;
|
|
36
|
+
const countText = pinCountText(words.count, count, length);
|
|
37
|
+
function enter(next) {
|
|
38
|
+
if (next === value)
|
|
39
|
+
return;
|
|
40
|
+
setEntered(true);
|
|
41
|
+
onChange(next);
|
|
42
|
+
if (next.length === length && count < length)
|
|
43
|
+
onComplete?.(next);
|
|
44
|
+
}
|
|
45
|
+
// No digit stays in the input: after an edit that changes nothing here
|
|
46
|
+
// (a refused key, a full field, a consumer that keeps its value), React
|
|
47
|
+
// restores the controlled value, the mask, over what the browser typed.
|
|
48
|
+
function onEdit(event) {
|
|
49
|
+
enter(readPinEntry(event.currentTarget.value, value, length));
|
|
50
|
+
}
|
|
51
|
+
const invalid = Boolean(error);
|
|
52
|
+
const messages = (_jsxs(_Fragment, { children: [description && !invalid ? (_jsx("span", { className: "sw-field-description", id: ids.hint, children: description })) : null, _jsx(FieldErrorRegion, { className: "sw-field-error", id: ids.error, message: error })] }));
|
|
53
|
+
return (_jsxs(Stack, { className: cx('sw-field', 'sw-pin-field', pad && 'sw-pin-field-with-pad', invalid && 'sw-field-invalid'), gap: labelVisuallyHidden ? 0 : 1, children: [_jsx("label", { className: labelVisuallyHidden ? 'sw-sr-only' : undefined, htmlFor: inputId, children: _jsx(FieldLabelText, { label: label }) }), _jsxs("div", { className: "sw-pin-field-entry", children: [_jsx("input", { ref: ref, "aria-describedby": [
|
|
54
|
+
describedBy?.trim() || null,
|
|
55
|
+
ids.count,
|
|
56
|
+
description && !invalid ? ids.hint : null,
|
|
57
|
+
invalid ? ids.error : null,
|
|
58
|
+
]
|
|
59
|
+
.filter((part) => part !== null)
|
|
60
|
+
.join(' '), "aria-invalid": invalid || undefined, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", autoFocus: autoFocus, className: "sw-pin-field-input", "data-1p-ignore": "", "data-bwignore": "", "data-form-type": "other", "data-lpignore": "true", disabled: disabled, id: inputId, inputMode: "numeric", onChange: onEdit, spellCheck: false, type: "text",
|
|
61
|
+
// Never the digits: one mask character for each one entered.
|
|
62
|
+
value: pinMask(count) }), _jsx("span", { "aria-hidden": "true", className: "sw-pin-field-dots", children: Array.from({ length }, (_, index) => (_jsx("span", { className: cx('sw-pin-field-dot', index < count && 'sw-pin-field-dot-filled') }, index))) })] }), _jsx("span", { hidden: true, id: ids.count, children: countText }), _jsx(LiveRegion, { visuallyHidden: true, children: entered ? countText : '' }), pad ? (_jsx(PinPad, { canDelete: count > 0, deleteLabel: words.delete, disabled: disabled, label: words.pad, onDelete: () => enter(value.slice(0, -1)), onDigit: (digit) => enter((value + digit).slice(0, length)) })) : null, messages] }));
|
|
63
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PinField's on-screen keys: twelve positions in three columns, 1 to 9,
|
|
3
|
+
* an empty one, 0 and Delete. Each key is a native button and its own Tab
|
|
4
|
+
* stop; a press reports the key and moves no focus. Delete with nothing to
|
|
5
|
+
* delete is `aria-disabled`, never `disabled`, so the focus it holds after
|
|
6
|
+
* the last digit goes is not dropped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PinPad({ canDelete, deleteLabel, disabled, label, onDelete, onDigit, }: {
|
|
9
|
+
canDelete: boolean;
|
|
10
|
+
deleteLabel: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
onDelete: () => void;
|
|
14
|
+
onDigit: (digit: string) => void;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tabStop } from '../../tab-stop.js';
|
|
3
|
+
const digitKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
4
|
+
/** Private control chrome: the Delete key's backspace mark. */
|
|
5
|
+
function DeleteGlyph() {
|
|
6
|
+
return (_jsx("svg", { "aria-hidden": "true", className: "sw-pin-field-glyph", focusable: "false", viewBox: "0 0 24 24", children: _jsx("path", { d: "M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM17 9l-5 6M12 9l5 6" }) }));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A PinField's on-screen keys: twelve positions in three columns, 1 to 9,
|
|
10
|
+
* an empty one, 0 and Delete. Each key is a native button and its own Tab
|
|
11
|
+
* stop; a press reports the key and moves no focus. Delete with nothing to
|
|
12
|
+
* delete is `aria-disabled`, never `disabled`, so the focus it holds after
|
|
13
|
+
* the last digit goes is not dropped.
|
|
14
|
+
*/
|
|
15
|
+
export function PinPad({ canDelete, deleteLabel, disabled, label, onDelete, onDigit, }) {
|
|
16
|
+
function digitKey(digit) {
|
|
17
|
+
return (_jsx("button", { className: "sw-pin-field-key", disabled: disabled, onClick: () => onDigit(digit), tabIndex: tabStop, type: "button", children: digit }, digit));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { "aria-label": label, className: "sw-pin-field-pad", role: "group", children: [digitKeys.map(digitKey), _jsx("span", { "aria-hidden": "true" }), digitKey('0'), _jsx("button", { "aria-disabled": !disabled && !canDelete ? true : undefined, "aria-label": deleteLabel, className: "sw-pin-field-key sw-pin-field-key-delete", disabled: disabled, onClick: onDelete, tabIndex: tabStop, type: "button", children: _jsx(DeleteGlyph, {}) })] }));
|
|
20
|
+
}
|
|
@@ -6,9 +6,19 @@ import { coarsePointerQuery, touchTarget } from './touch-target.js';
|
|
|
6
6
|
import { quietFill } from './quiet-fill.js';
|
|
7
7
|
const caption = typographyVariants.caption;
|
|
8
8
|
const label = typographyVariants.label;
|
|
9
|
+
/*
|
|
10
|
+
* A menu keeps its natural width as an item of a crowded flex row, as a
|
|
11
|
+
* Button does (css-button-natural-width.ts): it gives up none of it
|
|
12
|
+
* (`flex-shrink: 0`), so the row's other items give way first and a name
|
|
13
|
+
* in a header stays on its one line. The menu and its trigger are never
|
|
14
|
+
* wider than their container (`max-width: 100%`): where the trigger's
|
|
15
|
+
* words are longer than the whole row, they wrap inside it, never cut.
|
|
16
|
+
*/
|
|
9
17
|
export function cssActionMenuClasses() {
|
|
10
18
|
return `.sw-action-menu {
|
|
11
19
|
display: inline-flex;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
max-width: 100%;
|
|
12
22
|
position: relative;
|
|
13
23
|
}
|
|
14
24
|
|
|
@@ -20,6 +30,7 @@ export function cssActionMenuClasses() {
|
|
|
20
30
|
color: var(--sw-color-text);
|
|
21
31
|
cursor: pointer;
|
|
22
32
|
font: inherit;
|
|
33
|
+
max-width: 100%;
|
|
23
34
|
min-height: var(--sw-control-xs-min-height);
|
|
24
35
|
padding-inline: var(--sw-control-xs-padding-inline);
|
|
25
36
|
}
|
|
@@ -11,7 +11,11 @@ export function buttonGroupFullWidthClass(breakpoint) {
|
|
|
11
11
|
* height, their borders overlapping into single dividers, the inner
|
|
12
12
|
* corners square and the outer ones the sm radius. It keeps its row on a
|
|
13
13
|
* phone (it never stacks) and sizes to its buttons, even in a Stack that
|
|
14
|
-
* would stretch it, so `justify` does not apply.
|
|
14
|
+
* would stretch it, so `justify` does not apply. Its buttons share that
|
|
15
|
+
* row: they shrink as flex items again (`flex-shrink: 1`, over a Button's
|
|
16
|
+
* natural width, css-button-natural-width.ts), so a joined control wider
|
|
17
|
+
* than a phone's column wraps its words inside its segments rather than
|
|
18
|
+
* spilling past the column.
|
|
15
19
|
*
|
|
16
20
|
* A borderless variant (primary, tertiary, ghost, danger) draws its
|
|
17
21
|
* divider in its own text colour at low strength, so a joined row of them
|
|
@@ -42,6 +46,7 @@ export function cssButtonGroupAttachedClasses() {
|
|
|
42
46
|
|
|
43
47
|
${group} > .sw-button {
|
|
44
48
|
border-radius: 0;
|
|
49
|
+
flex-shrink: 1;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
${group} > .sw-button ~ .sw-button {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cssButtonNaturalWidthClasses(): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A Button keeps its natural width as an item of a flex row (an Inline
|
|
3
|
+
* that does not wrap, a header's actions): it gives up none of it
|
|
4
|
+
* (`flex-shrink: 0`), so a crowded row's other items give way first and
|
|
5
|
+
* its words stay on the one line they take at that width. It is never
|
|
6
|
+
* wider than its container (`max-width: 100%`): where its words are
|
|
7
|
+
* longer than the whole row or column it is in, they wrap inside the
|
|
8
|
+
* pill, every word shown, never cut. A full button's own rules
|
|
9
|
+
* (css-button-width.ts) still let it shrink and grow in an Inline.
|
|
10
|
+
*/
|
|
11
|
+
export function cssButtonNaturalWidthClasses() {
|
|
12
|
+
return `.sw-button {
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
}`;
|
|
16
|
+
}
|
package/dist/css/css-button.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buttonSizes, buttonVariants, typographyVariants, } from '@scalewing/tokens';
|
|
2
2
|
import { breakpointQuery } from './breakpoints.js';
|
|
3
3
|
import { buttonGroupAttachedClassCatalog, cssButtonGroupAttachedClasses, } from './css-button-group-attached.js';
|
|
4
|
+
import { cssButtonNaturalWidthClasses } from './css-button-natural-width.js';
|
|
4
5
|
import { buttonWidthClassCatalog, cssButtonWidthClasses, } from './css-button-width.js';
|
|
5
6
|
import { quietFill } from './quiet-fill.js';
|
|
6
7
|
import { coarsePointerQuery, touchTarget } from './touch-target.js';
|
|
@@ -147,6 +148,7 @@ ${disabledNeutralRules()}
|
|
|
147
148
|
${pressedRules()}
|
|
148
149
|
${ariaDisabledForcedRules()}
|
|
149
150
|
${sizeRules()}
|
|
151
|
+
${cssButtonNaturalWidthClasses()}
|
|
150
152
|
${cssButtonWidthClasses()}
|
|
151
153
|
${groupRules()}
|
|
152
154
|
|
|
@@ -9,6 +9,7 @@ import { cssButtonLinkClasses } from './css-button-link.js';
|
|
|
9
9
|
import { cssCalendarButtonClasses } from './css-calendar-button.js';
|
|
10
10
|
import { cssDateRangeClasses } from './css-date-range.js';
|
|
11
11
|
import { cssFileFieldClasses } from './css-file-field.js';
|
|
12
|
+
import { cssPinFieldClasses } from './css-pin-field.js';
|
|
12
13
|
import { cssArticleClasses } from './css-article.js';
|
|
13
14
|
import { cssDocumentViewerClasses } from './css-document-viewer.js';
|
|
14
15
|
import { cssFixtureClasses } from './css-fixture.js';
|
|
@@ -291,6 +292,8 @@ ${cssFieldClasses()}
|
|
|
291
292
|
|
|
292
293
|
${cssStepperClasses()}
|
|
293
294
|
|
|
295
|
+
${cssPinFieldClasses()}
|
|
296
|
+
|
|
294
297
|
${cssStepsClasses()}
|
|
295
298
|
|
|
296
299
|
${cssTaskListClasses()}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { listRowLargeMinHeight } from './list-row-metrics.js';
|
|
2
|
+
export const listGroupLargeClass = 'sw-list-group-lg';
|
|
3
|
+
const group = `.${listGroupLargeClass}`;
|
|
4
|
+
/*
|
|
5
|
+
* The group's own rows only, never a ListGroup nested inside one of
|
|
6
|
+
* them: its list's rows, the same list inside its scroll region when it
|
|
7
|
+
* is bounded, and its footer's row.
|
|
8
|
+
*/
|
|
9
|
+
const ownRows = [
|
|
10
|
+
`${group} > .sw-list > .sw-list-item > .sw-list-row`,
|
|
11
|
+
`${group} > .sw-list-group-scroll > .sw-list > .sw-list-item > .sw-list-row`,
|
|
12
|
+
`${group} > .sw-list-group-footer > .sw-list-item > .sw-list-row`,
|
|
13
|
+
].join(',\n');
|
|
14
|
+
/*
|
|
15
|
+
* An `lg` group's rows stand at least 56 px on every pointer, past the
|
|
16
|
+
* 44 px a pressable row takes on a coarse one, with their parts centred
|
|
17
|
+
* on the row's height rather than set at its top, so a one-line name sits
|
|
18
|
+
* in the middle of its tile. The chained classes outrank the
|
|
19
|
+
* coarse-pointer target, which follows the rows in the sheet. Every row
|
|
20
|
+
* of the group is the same floor, pressable or not, in a panel, plain
|
|
21
|
+
* rows or tiles.
|
|
22
|
+
*/
|
|
23
|
+
export function cssListSizeClasses() {
|
|
24
|
+
return `${ownRows} {
|
|
25
|
+
align-items: center;
|
|
26
|
+
min-height: ${listRowLargeMinHeight};
|
|
27
|
+
}`;
|
|
28
|
+
}
|
|
29
|
+
export function listSizeClassCatalog() {
|
|
30
|
+
return [listGroupLargeClass];
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cssListTilesBoundedClasses(): string;
|