@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +118 -2
  3. package/dist/components/Box.d.ts +3 -2
  4. package/dist/components/Box.js +3 -2
  5. package/dist/components/ListGroup.d.ts +11 -3
  6. package/dist/components/ListGroup.js +6 -3
  7. package/dist/components/MessageCard.d.ts +43 -0
  8. package/dist/components/MessageCard.js +40 -0
  9. package/dist/components/PersonPicker.d.ts +44 -0
  10. package/dist/components/PersonPicker.js +53 -0
  11. package/dist/components/PinStep.d.ts +52 -0
  12. package/dist/components/PinStep.js +45 -0
  13. package/dist/css/css-action-menu.js +11 -0
  14. package/dist/css/css-button-group-attached.js +6 -1
  15. package/dist/css/css-button-natural-width.d.ts +1 -0
  16. package/dist/css/css-button-natural-width.js +16 -0
  17. package/dist/css/css-button.js +2 -0
  18. package/dist/css/css-list-size.d.ts +3 -0
  19. package/dist/css/css-list-size.js +31 -0
  20. package/dist/css/css-list-tiles-bounded.d.ts +1 -0
  21. package/dist/css/css-list-tiles-bounded.js +74 -0
  22. package/dist/css/css-list-tiles.d.ts +1 -0
  23. package/dist/css/css-list-tiles.js +37 -7
  24. package/dist/css/css-list.d.ts +0 -1
  25. package/dist/css/css-list.js +18 -9
  26. package/dist/css/css-utilities.js +2 -0
  27. package/dist/css/list-row-metrics.d.ts +3 -0
  28. package/dist/css/list-row-metrics.js +18 -0
  29. package/dist/css/spacing-classes.d.ts +1 -1
  30. package/dist/css/spacing-classes.js +1 -0
  31. package/dist/css/stacking.js +2 -1
  32. package/dist/flex-item-classes.d.ts +15 -0
  33. package/dist/flex-item-classes.js +6 -0
  34. package/dist/index.d.ts +6 -1
  35. package/dist/index.js +5 -1
  36. package/dist/list-options.d.ts +13 -5
  37. package/dist/list-options.js +15 -7
  38. package/dist/person-names.d.ts +13 -0
  39. package/dist/person-names.js +18 -0
  40. package/dist/styles.css +87 -15
  41. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { isOneOf } from '../is-one-of.js';
5
+ import { Box } from './Box.js';
6
+ import { Button } from './Button.js';
7
+ import { Inline } from './Inline.js';
8
+ import { LiveRegion } from './LiveRegion.js';
9
+ import { PinField } from './PinField.js';
10
+ import { Spinner } from './Spinner.js';
11
+ import { Stack } from './Stack.js';
12
+ import { Text } from './Text.js';
13
+ export const pinStepHeadingElements = ['h1', 'h2'];
14
+ function isBlank(value) {
15
+ return typeof value !== 'string' || value.trim() === '';
16
+ }
17
+ function assertAction(name, action) {
18
+ if (action !== undefined && isBlank(action.label))
19
+ throw new RangeError(`PinStep ${name}.label must be nonempty`);
20
+ }
21
+ /** Fails closed on blank words or an unknown heading level. */
22
+ function assertPinStep({ heading, headingAs, eyebrow, back, busy, secondaryAction, }) {
23
+ if (isBlank(heading))
24
+ throw new RangeError('PinStep heading must be nonempty');
25
+ if (headingAs !== undefined && !isOneOf(pinStepHeadingElements, headingAs))
26
+ throw new RangeError(`Unknown PinStep headingAs: ${String(headingAs)}`);
27
+ if (eyebrow !== undefined && isBlank(eyebrow))
28
+ throw new RangeError('PinStep eyebrow must be nonempty');
29
+ if (busy !== undefined && isBlank(busy))
30
+ throw new RangeError('PinStep busy must be nonempty');
31
+ assertAction('back', back);
32
+ assertAction('secondaryAction', secondaryAction);
33
+ }
34
+ /**
35
+ * The step where someone enters a PIN on a shared screen: an optional
36
+ * ghost Back, a short line over the heading, `PinField` with its pad
37
+ * (focused on mount), a spinner and a status line while the code is
38
+ * checked, and an optional ghost action under it. The ref reaches the
39
+ * field's input, to put the focus back after a refusal.
40
+ */
41
+ export const PinStep = forwardRef(function PinStep(props, ref) {
42
+ assertPinStep(props);
43
+ const { heading, headingAs = 'h1', eyebrow, back, busy, secondaryAction, autoFocus = true, ...field } = props;
44
+ return (_jsxs(Stack, { gap: 4, children: [back ? (_jsx(Inline, { children: _jsx(Button, { onPress: back.onPress, variant: "ghost", children: back.label }) })) : null, _jsxs(Stack, { gap: 1, children: [eyebrow !== undefined ? (_jsx(Text, { variant: "label", children: eyebrow })) : null, _jsx(Text, { as: headingAs, variant: "heading", children: heading })] }), _jsxs(Box, { children: [_jsx(PinField, { ...field, autoFocus: autoFocus, pad: true, ref: ref }), _jsx(Box, { paddingTop: busy === undefined ? undefined : 4, children: _jsxs(Inline, { align: "center", gap: 2, children: [busy === undefined ? null : _jsx(Spinner, { decorative: true }), _jsx(LiveRegion, { children: busy ?? '' })] }) })] }), secondaryAction ? (_jsx(Inline, { children: _jsx(Button, { onPress: secondaryAction.onPress, variant: "ghost", children: secondaryAction.label }) })) : null] }));
45
+ });
@@ -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
+ }
@@ -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
 
@@ -0,0 +1,3 @@
1
+ export declare const listGroupLargeClass = "sw-list-group-lg";
2
+ export declare function cssListSizeClasses(): string;
3
+ export declare function listSizeClassCatalog(): string[];
@@ -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;
@@ -0,0 +1,74 @@
1
+ import { listTileGap } from './css-list-tiles.js';
2
+ import { blockShade } from './css-scroll-region.js';
3
+ import { listCountedRowHeight } from './list-row-metrics.js';
4
+ import { zIndex } from './stacking.js';
5
+ const region = '.sw-list-group-tiles > .sw-list-group-scroll';
6
+ /* How deep the scroll shade is, as a bounded list's and table's. */
7
+ const shadeDepth = 'var(--sw-space-5)';
8
+ /* One counted row of tiles: the counted row inside its tile's two hairlines. */
9
+ const tileRow = `(${listCountedRowHeight} + 2px)`;
10
+ /*
11
+ * A bounded grid of tiles (`variant="tiles"` with `maxHeight`) is the
12
+ * same named scroll region as a bounded list, its grid scrolling inside
13
+ * it. `rows` counts rows of tiles: each the counted row (a title and one
14
+ * detail line) inside its tile's two hairlines, with the grid's gap
15
+ * between them, so a phone's one column counts its tiles one by one.
16
+ *
17
+ * The tiles are opaque panels, so the shade a bounded list paints under
18
+ * its rows would be hidden under them. Here the region's `::before` and
19
+ * `::after` are the shade, stuck to its top and bottom edges over the
20
+ * tiles (the sticky-cell layer of `stacking.ts`, as a table's pinned
21
+ * head is over its scrolling cells) while `ScrollRegion` marks more past
22
+ * that edge: each is a space-5 strip pulled out of the flow by an equal
23
+ * negative margin, so it moves no tile, and takes no press.
24
+ *
25
+ * Focus scrolling keeps a space-5 margin at either edge
26
+ * (`scroll-padding-block`), so a tile focused from the keyboard is
27
+ * scrolled fully into view, clear of the shade, its ring whole. The
28
+ * margin is clamped to half of what the region has over one counted row
29
+ * of tiles, so a region one row tall (`rows: 1`) keeps no margin (never a
30
+ * negative one): its focused tile is scrolled fully into view, whole and
31
+ * with its ring, but may sit under both shades, which leave it no room
32
+ * to clear them. Forced colours draw no shade (the system's scrollbar is the
33
+ * cue); printed, every tile shows.
34
+ */
35
+ export function cssListTilesBoundedClasses() {
36
+ const rows = 'var(--sw-list-max-rows)';
37
+ return `${region} {
38
+ max-height: calc(${rows} * ${tileRow} + (${rows} - 1) * ${listTileGap});
39
+ scroll-padding-block: max(0px, min(${shadeDepth}, calc((100% - ${tileRow}) / 2)));
40
+ }
41
+
42
+ ${region}::before,
43
+ ${region}::after {
44
+ content: '';
45
+ display: block;
46
+ height: ${shadeDepth};
47
+ pointer-events: none;
48
+ position: sticky;
49
+ ${zIndex('stickyCell')}
50
+ }
51
+
52
+ ${region}::before {
53
+ margin-block-end: calc(-1 * ${shadeDepth});
54
+ top: 0;
55
+ }
56
+
57
+ ${region}::after {
58
+ bottom: 0;
59
+ margin-block-start: calc(-1 * ${shadeDepth});
60
+ }
61
+
62
+ ${region}.sw-scroll-more-top::before { background-image: ${blockShade('bottom')}; }
63
+
64
+ ${region}.sw-scroll-more-bottom::after { background-image: ${blockShade('top')}; }
65
+
66
+ @media (forced-colors: active) {
67
+ ${region}::before,
68
+ ${region}::after { display: none; }
69
+ }
70
+
71
+ @media print {
72
+ ${region} { max-height: none; }
73
+ }`;
74
+ }
@@ -2,5 +2,6 @@
2
2
  export declare const listTileColumnCounts: readonly [2, 3, 4];
3
3
  export type ListGroupTileColumns = (typeof listTileColumnCounts)[number];
4
4
  export declare function listTileColumnsClass(columns: ListGroupTileColumns): string;
5
+ export declare const listTileGap = "var(--sw-space-3)";
5
6
  export declare function cssListTilesClasses(): string;
6
7
  export declare function listTilesClassCatalog(): string[];
@@ -5,6 +5,19 @@ export function listTileColumnsClass(columns) {
5
5
  return `sw-list-group-tiles-${columns}`;
6
6
  }
7
7
  const tiles = '.sw-list-group-tiles';
8
+ /* The space between tiles, across and down; a bounded grid counts it too. */
9
+ export const listTileGap = 'var(--sw-space-3)';
10
+ /*
11
+ * The list a group's class lays out, the group's own child or, bounded
12
+ * (`maxHeight`), its scroll region's: a selector list, so each keeps the
13
+ * specificity it would have alone and the order below still decides.
14
+ */
15
+ function tileList(group, inner = '') {
16
+ return [
17
+ `${group} > .sw-list${inner}`,
18
+ `${group} > .sw-list-group-scroll > .sw-list${inner}`,
19
+ ].join(',\n');
20
+ }
8
21
  /*
9
22
  * A tiled ListGroup is still one list (`sw-list`), its rows laid out as
10
23
  * tiles: equal columns a space-3 apart from `md` up, one column below it,
@@ -15,31 +28,48 @@ const tiles = '.sw-list-group-tiles';
15
28
  * Generated after the list's hairline rules (css-list.ts), whose
16
29
  * `.sw-list > .sw-list-item + .sw-list-item` has the same specificity as
17
30
  * the tile rule: being later is what lets a tile's own border replace the
18
- * hairline. `list-group-tiles.test.tsx` holds that order.
31
+ * hairline. `list-group-tiles.test.tsx` holds that order. A bounded
32
+ * group's grid sits in its scroll region and takes the same rules.
33
+ *
34
+ * Tiles on one grid row are as tall as the tallest of them, so each tile
35
+ * is a flex box whose row fills it (`flex: 1 1 auto`, stretched across
36
+ * its height): a short row's press area, fill and inset ring reach its
37
+ * tile's edges beside a taller one. A tile with an `action` stretches its
38
+ * row the same way and keeps the action centred on it.
19
39
  */
20
40
  export function cssListTilesClasses() {
21
- const columns = listTileColumnCounts.map((count) => `.${listTileColumnsClass(count)} > .sw-list { grid-template-columns: repeat(${count}, minmax(0, 1fr)); }`);
22
- return `${tiles} > .sw-list {
41
+ const columns = listTileColumnCounts.map((count) => `${tileList(`.${listTileColumnsClass(count)}`)} { grid-template-columns: repeat(${count}, minmax(0, 1fr)); }`);
42
+ const item = ' > .sw-list-item';
43
+ return `${tileList(tiles)} {
23
44
  display: grid;
24
- gap: var(--sw-space-3);
45
+ gap: ${listTileGap};
25
46
  }
26
47
 
27
48
  ${columns.join('\n')}
28
49
 
29
- ${tiles} > .sw-list > .sw-list-item {
50
+ ${tileList(tiles, item)} {
51
+ align-items: stretch;
30
52
  background: var(--sw-color-surface);
31
53
  border: 1px solid var(--sw-color-border);
32
54
  border-radius: var(--sw-radius-md);
55
+ display: flex;
33
56
  min-width: 0;
34
57
  overflow: clip;
35
58
  }
36
59
 
60
+ ${tileList(tiles, `${item} > .sw-list-row`)} {
61
+ flex: 1 1 auto;
62
+ min-width: 0;
63
+ }
64
+
65
+ ${tileList(tiles, `${item} > .sw-list-row-action`)} { align-self: center; }
66
+
37
67
  @media ${breakpointQuery('below', 'md')} {
38
- ${tiles} > .sw-list { grid-template-columns: minmax(0, 1fr); }
68
+ ${tileList(tiles).replaceAll('\n', '\n ')} { grid-template-columns: minmax(0, 1fr); }
39
69
  }
40
70
 
41
71
  @media (forced-colors: active) {
42
- ${tiles} > .sw-list > .sw-list-item { border-color: CanvasText; }
72
+ ${tileList(tiles, item).replaceAll('\n', '\n ')} { border-color: CanvasText; }
43
73
  }`;
44
74
  }
45
75
  export function listTilesClassCatalog() {
@@ -1,3 +1,2 @@
1
- export declare const listRowPadBlock = "var(--sw-space-3)";
2
1
  export declare function cssListClasses(): string;
3
2
  export declare function listClassCatalog(): string[];
@@ -1,14 +1,18 @@
1
- import { typographyVariants } from '@scalewing/tokens';
2
1
  import { cssListRowClasses, listRowClassCatalog } from './css-list-row.js';
3
2
  import { cssListRowTrailingClasses, listRowTrailingClassCatalog, } from './css-list-row-trailing.js';
4
3
  import { cssListRowTruncateClasses, listRowTruncateClassCatalog, } from './css-list-row-truncate.js';
5
4
  import { cssListTilesClasses, listTilesClassCatalog, } from './css-list-tiles.js';
5
+ import { cssListSizeClasses, listSizeClassCatalog } from './css-list-size.js';
6
+ import { cssListTilesBoundedClasses } from './css-list-tiles-bounded.js';
6
7
  import { blockEdgeShadeRules, scrollRegionRules } from './css-scroll-region.js';
7
- const label = typographyVariants.label;
8
- const caption = typographyVariants.caption;
9
- /* A row's padding, shared by the row rules and the bounded list's height. */
10
- export const listRowPadBlock = 'var(--sw-space-3)';
8
+ import { listCountedRowHeight } from './list-row-metrics.js';
11
9
  const scroll = '.sw-list-group-scroll';
10
+ /*
11
+ * The region of a bounded list of rows, not of tiles: tiles are opaque
12
+ * panels that would hide a shade drawn under them, so a bounded grid of
13
+ * tiles draws its own over them (css-list-tiles-bounded.ts).
14
+ */
15
+ const rowScroll = `.sw-list-group:not(.sw-list-group-tiles) > ${scroll}`;
12
16
  /*
13
17
  * A ListGroup is one list (`sw-list`) with a hairline between its rows:
14
18
  * a bordered panel on the surface, or plain rows inside a surface that
@@ -46,12 +50,12 @@ function groupRules() {
46
50
  * shows.
47
51
  */
48
52
  function boundedRules() {
49
- const top = `${scroll}.sw-scroll-more-top`;
50
- const bottom = `${scroll}.sw-scroll-more-bottom`;
53
+ const top = `${rowScroll}.sw-scroll-more-top`;
54
+ const bottom = `${rowScroll}.sw-scroll-more-bottom`;
51
55
  return `${scrollRegionRules(scroll)}
52
56
 
53
57
  ${scroll} {
54
- max-height: calc(var(--sw-list-max-rows) * (2 * ${listRowPadBlock} + ${label.lineHeight}px + ${caption.lineHeight}px + 1px));
58
+ max-height: calc(var(--sw-list-max-rows) * (${listCountedRowHeight} + 1px));
55
59
  }
56
60
 
57
61
  ${blockEdgeShadeRules({ top, bottom, both: `${top}.sw-scroll-more-bottom` })}
@@ -78,7 +82,11 @@ ${cssListRowTrailingClasses()}
78
82
 
79
83
  ${cssListRowTruncateClasses()}
80
84
 
81
- ${cssListTilesClasses()}`;
85
+ ${cssListSizeClasses()}
86
+
87
+ ${cssListTilesClasses()}
88
+
89
+ ${cssListTilesBoundedClasses()}`;
82
90
  }
83
91
  export function listClassCatalog() {
84
92
  return [
@@ -89,6 +97,7 @@ export function listClassCatalog() {
89
97
  'sw-list-group-plain',
90
98
  'sw-list-group-scroll',
91
99
  'sw-list-group-footer',
100
+ ...listSizeClassCatalog(),
92
101
  ...listTilesClassCatalog(),
93
102
  ...listRowClassCatalog(),
94
103
  ...listRowTrailingClassCatalog(),
@@ -39,6 +39,8 @@ const layoutRules = {
39
39
  'sw-inline': '.sw-inline { display: flex; flex-direction: row; align-items: center; min-width: 0; }',
40
40
  'sw-wrap': '.sw-wrap { flex-wrap: wrap; }',
41
41
  'sw-grow': '.sw-grow { flex-grow: 1; }',
42
+ // A flex item that keeps its natural width (Box `shrink={false}`).
43
+ 'sw-no-shrink': '.sw-no-shrink { flex-shrink: 0; }',
42
44
  'sw-full-width': '.sw-full-width { width: 100%; }',
43
45
  'sw-container': '.sw-container { width: 100%; max-width: var(--sw-container-max); margin-inline: auto; }',
44
46
  // A narrower centred column at the reading width (Article's), for a
@@ -0,0 +1,3 @@
1
+ export declare const listRowPadBlock = "var(--sw-space-3)";
2
+ export declare const listCountedRowHeight: string;
3
+ export declare const listRowLargeMinHeight = "calc(var(--sw-space-8) + var(--sw-space-2))";
@@ -0,0 +1,18 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ const label = typographyVariants.label;
3
+ const caption = typographyVariants.caption;
4
+ /* A row's padding, shared by the row rules and a bounded list's height. */
5
+ export const listRowPadBlock = 'var(--sw-space-3)';
6
+ /*
7
+ * The row a bounded list counts (`maxHeight: { rows }`): a title and one
8
+ * detail line inside the row's padding, 62 px. A taller row shows fewer
9
+ * at a time and a shorter one more. It is taller than an `lg` row's
10
+ * 56 px floor, so the count is the same at either size. A sum, for a
11
+ * caller to add its hairlines to inside its own parentheses.
12
+ */
13
+ export const listCountedRowHeight = `2 * ${listRowPadBlock} + ${label.lineHeight}px + ${caption.lineHeight}px`;
14
+ /*
15
+ * An `lg` row's floor, 56 px (space-8 and space-2) on every pointer: a
16
+ * larger press target than the 44 px coarse-pointer one.
17
+ */
18
+ export const listRowLargeMinHeight = 'calc(var(--sw-space-8) + var(--sw-space-2))';
@@ -7,4 +7,4 @@ export type SpacingKind = 'padding' | 'gap';
7
7
  export declare function spacingClass(kind: SpacingKind, axis: PaddingAxis | GapAxis, step: SpacingStep): string;
8
8
  export declare function paddingClassNames(): string[];
9
9
  export declare function gapClassNames(): string[];
10
- export declare const layoutClassNames: readonly ["sw-stack", "sw-inline", "sw-wrap", "sw-grow", "sw-full-width", "sw-container", "sw-container-reading", "sw-sr-only", "sw-align-start", "sw-align-center", "sw-align-end", "sw-align-stretch", "sw-justify-start", "sw-justify-center", "sw-justify-end", "sw-justify-between"];
10
+ export declare const layoutClassNames: readonly ["sw-stack", "sw-inline", "sw-wrap", "sw-grow", "sw-no-shrink", "sw-full-width", "sw-container", "sw-container-reading", "sw-sr-only", "sw-align-start", "sw-align-center", "sw-align-end", "sw-align-stretch", "sw-justify-start", "sw-justify-center", "sw-justify-end", "sw-justify-between"];
@@ -26,6 +26,7 @@ export const layoutClassNames = [
26
26
  'sw-inline',
27
27
  'sw-wrap',
28
28
  'sw-grow',
29
+ 'sw-no-shrink',
29
30
  'sw-full-width',
30
31
  'sw-container',
31
32
  'sw-container-reading',
@@ -3,7 +3,8 @@
3
3
  * `z-index` reads a layer from here, lowest first:
4
4
  *
5
5
  * 1. `stickyCell`: a sticky table head group (every row in a sticky
6
- * `thead`) or row label over the cells that scroll under it.
6
+ * `thead`) or row label over the cells that scroll under it, and a
7
+ * bounded grid of tiles' sticky edge shade over the tiles under it.
7
8
  * 2. `stickyFooter`: a sticky table footer (a pinned total row) over the
8
9
  * cells and pinned header cells that scroll under it, and under the
9
10
  * ActionBar, which stays the page's last word at the bottom edge.
@@ -0,0 +1,15 @@
1
+ export declare const noShrinkClass = "sw-no-shrink";
2
+ export type FlexItemProps = {
3
+ /**
4
+ * `false` keeps this box at its natural size along its parent's main
5
+ * axis when the parent is a flex container short of room (its width in
6
+ * an `Inline` row, its height in a `Stack` column): it gives up none of
7
+ * it, and its siblings give way instead, such as a header's actions (a
8
+ * Button and an account menu in their own Inline) beside a title or
9
+ * navigation that may wrap. The box can then be larger than its parent,
10
+ * so keep it for content that fits. `true` (the default) lets it shrink
11
+ * as any flex item.
12
+ */
13
+ shrink?: boolean;
14
+ };
15
+ export declare function flexItemClassNames({ shrink }: FlexItemProps): string[];
@@ -0,0 +1,6 @@
1
+ export const noShrinkClass = 'sw-no-shrink';
2
+ export function flexItemClassNames({ shrink }) {
3
+ if (shrink === undefined || shrink)
4
+ return [];
5
+ return [noShrinkClass];
6
+ }
package/dist/index.d.ts CHANGED
@@ -9,11 +9,14 @@ export { DateRangeButton, type DateRangeButtonLabels, type DateRangeButtonProps,
9
9
  export { Article, articleTitleElements, type ArticleCover, type ArticleProps, type ArticleTitleElement, } from './components/Article.js';
10
10
  export { FileField, type FileFieldProps, type FileFieldValue, } from './components/FileField.js';
11
11
  export { defaultPinFieldLabels, PinField, type PinFieldLabels, type PinFieldProps, } from './components/PinField.js';
12
+ export { PinStep, pinStepHeadingElements, type PinStepAction, type PinStepHeadingElement, type PinStepProps, } from './components/PinStep.js';
12
13
  export { DocumentViewer, type DocumentViewerLabels, type DocumentViewerProps, } from './components/DocumentViewer.js';
13
14
  export { ListGroup, type ListGroupProps } from './components/ListGroup.js';
15
+ export { PersonPicker, type PersonPickerLabels, type PersonPickerPerson, type PersonPickerProps, } from './components/PersonPicker.js';
16
+ export { comparableName, peopleStartingWith } from './person-names.js';
14
17
  export { inspectMarkdown, markdownOmissionKinds, MarkdownView, type MarkdownHeading, type MarkdownInspection, type MarkdownImage, type MarkdownImageResolver, type MarkdownOmission, type MarkdownOmissionCounts, type MarkdownOmissionKind, type MarkdownOptions, type MarkdownViewProps, } from './components/MarkdownView.js';
15
18
  export { ListRow, type ListRowProps } from './components/ListRow.js';
16
- export { listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, type ListGroupMaxHeight, type ListGroupVariant, type ListRowTitleAppearance, type ListRowTone, type ListRowValueTone, } from './list-options.js';
19
+ export { listGroupSizes, listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, type ListGroupMaxHeight, type ListGroupSize, type ListGroupVariant, type ListRowTitleAppearance, type ListRowTone, type ListRowValueTone, } from './list-options.js';
17
20
  export { listTileColumnCounts, type ListGroupTileColumns, } from './css/css-list-tiles.js';
18
21
  export { Checkbox, checkboxAppearances, type CheckboxAppearance, type CheckboxProps, } from './components/Checkbox.js';
19
22
  export { PasteRows, type PasteRowsColumn, type PasteRowsProps, } from './components/PasteRows.js';
@@ -22,6 +25,7 @@ export { Spinner, type SpinnerProps, type SpinnerSize, } from './components/Spin
22
25
  export { LiveRegion, liveRegionPolitenesses, type LiveRegionPoliteness, type LiveRegionProps, } from './components/LiveRegion.js';
23
26
  export { Skeleton, skeletonVariants, type SkeletonProps, type SkeletonVariant, } from './components/Skeleton.js';
24
27
  export { EmptyState, emptyStateTitleElements, type EmptyStateProps, type EmptyStateTitleElement, } from './components/EmptyState.js';
28
+ export { MessageCard, messageCardActionVariants, messageCardHeadingElements, type MessageCardAction, type MessageCardActionVariant, type MessageCardHeadingElement, type MessageCardProps, } from './components/MessageCard.js';
25
29
  export { GlyphTile, glyphTileSizes, type GlyphTileHue, type GlyphTileProps, type GlyphTileSize, } from './components/GlyphTile.js';
26
30
  export { Notice, noticeTones, noticeVariants, type NoticeProps, type NoticeRole, type NoticeTone, type NoticeVariant, } from './components/Notice.js';
27
31
  export { Progress, progressTones, type ProgressProps, type ProgressTone, } from './components/Progress.js';
@@ -116,6 +120,7 @@ export { Grid, gridFits, gridRails } from './components/Grid.js';
116
120
  export type { GridColumns, GridFit, GridProps, GridRail, } from './components/Grid.js';
117
121
  export type { GridColumnSpan } from './css/css-grid-span.js';
118
122
  export type { ColumnSpanProps } from './column-span-classes.js';
123
+ export type { FlexItemProps } from './flex-item-classes.js';
119
124
  export { DenominationGrid, denominationCellToneAppearances, denominationGridFrames, denominationLabelAppearances, denominationNegativeAppearances, denominationTotalEmphases, denominationTransposeBreakpoints, } from './components/DenominationGrid.js';
120
125
  export type { DenominationCellToneAppearance, DenominationGridColumn, DenominationGridEntry, DenominationGridFrame, DenominationGridLayout, DenominationGridNegativeAppearance, DenominationGridProps, DenominationGridRow, DenominationGridRowEmphasis, DenominationGridRowRole, DenominationGridTone, DenominationGridValueRow, DenominationLabelAppearance, DenominationLabelWidth, DenominationTotalEmphasis, DenominationTransposeBreakpoint, } from './components/DenominationGrid.js';
121
126
  export { FilterChips, filterChipCountAppearances, filterChipsOverflows, filterChipsSelectedStyles, filterChipTones, } from './components/FilterChips.js';
package/dist/index.js CHANGED
@@ -8,11 +8,14 @@ export { DateRangeButton, } from './components/DateRangeButton.js';
8
8
  export { Article, articleTitleElements, } from './components/Article.js';
9
9
  export { FileField, } from './components/FileField.js';
10
10
  export { defaultPinFieldLabels, PinField, } from './components/PinField.js';
11
+ export { PinStep, pinStepHeadingElements, } from './components/PinStep.js';
11
12
  export { DocumentViewer, } from './components/DocumentViewer.js';
12
13
  export { ListGroup } from './components/ListGroup.js';
14
+ export { PersonPicker, } from './components/PersonPicker.js';
15
+ export { comparableName, peopleStartingWith } from './person-names.js';
13
16
  export { inspectMarkdown, markdownOmissionKinds, MarkdownView, } from './components/MarkdownView.js';
14
17
  export { ListRow } from './components/ListRow.js';
15
- export { listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, } from './list-options.js';
18
+ export { listGroupSizes, listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, } from './list-options.js';
16
19
  export { listTileColumnCounts, } from './css/css-list-tiles.js';
17
20
  export { Checkbox, checkboxAppearances, } from './components/Checkbox.js';
18
21
  export { PasteRows, } from './components/PasteRows.js';
@@ -21,6 +24,7 @@ export { Spinner, } from './components/Spinner.js';
21
24
  export { LiveRegion, liveRegionPolitenesses, } from './components/LiveRegion.js';
22
25
  export { Skeleton, skeletonVariants, } from './components/Skeleton.js';
23
26
  export { EmptyState, emptyStateTitleElements, } from './components/EmptyState.js';
27
+ export { MessageCard, messageCardActionVariants, messageCardHeadingElements, } from './components/MessageCard.js';
24
28
  export { GlyphTile, glyphTileSizes, } from './components/GlyphTile.js';
25
29
  export { Notice, noticeTones, noticeVariants, } from './components/Notice.js';
26
30
  export { Progress, progressTones, } from './components/Progress.js';
@@ -18,6 +18,14 @@ export type ListGroupVariant = (typeof listGroupVariants)[number];
18
18
  export type ListGroupMaxHeight = {
19
19
  rows: number;
20
20
  };
21
+ /**
22
+ * How tall a group's rows stand at least: `md` (the default) is as tall as
23
+ * the words (44 px for a pressable row on a coarse pointer); `lg` is a
24
+ * 56 px row on every pointer, its words centred in it, such as a grid of
25
+ * names pressed at a shared counter.
26
+ */
27
+ export declare const listGroupSizes: readonly ["md", "lg"];
28
+ export type ListGroupSize = (typeof listGroupSizes)[number];
21
29
  /** `danger` draws the title in the danger colour, for a row that ends something. */
22
30
  export declare const listRowTones: readonly ["default", "danger"];
23
31
  export type ListRowTone = (typeof listRowTones)[number];
@@ -31,19 +39,19 @@ export type ListGroupInput = {
31
39
  label: string | undefined;
32
40
  labelledBy: string | undefined;
33
41
  variant: unknown;
42
+ size: unknown;
34
43
  maxHeight: ListGroupMaxHeight | undefined;
35
44
  tileColumns: unknown;
36
45
  hasFooter: boolean;
37
46
  };
38
47
  /**
39
- * Fails closed on a ListGroup it cannot draw: an unknown variant, a
40
- * `maxHeight` that is not a whole row count from 1, a bounded list with
48
+ * Fails closed on a ListGroup it cannot draw: an unknown variant or size,
49
+ * a `maxHeight` that is not a whole row count from 1, a bounded list with
41
50
  * no name (its scroll region is a keyboard stop and must say what it
42
51
  * holds), `tileColumns` other than 2, 3 or 4 or on a list that is not
43
- * tiles, or tiles with `maxHeight` or a `footer` (tiles neither scroll as
44
- * rows nor add up to a total).
52
+ * tiles, or tiles with a `footer` (tiles do not add up to a total).
45
53
  */
46
- export declare function assertListGroup({ label, labelledBy, variant, maxHeight, tileColumns, hasFooter, }: ListGroupInput): void;
54
+ export declare function assertListGroup({ label, labelledBy, variant, size, maxHeight, tileColumns, hasFooter, }: ListGroupInput): void;
47
55
  /** The row count the generated `sw-list-group-scroll` height reads. */
48
56
  export declare function listMaxHeightStyle(maxHeight: ListGroupMaxHeight): CSSProperties;
49
57
  export type ListRowInput = {
@@ -10,6 +10,13 @@ import { isOneOf } from './is-one-of.js';
10
10
  * `md`).
11
11
  */
12
12
  export const listGroupVariants = ['panel', 'plain', 'tiles'];
13
+ /**
14
+ * How tall a group's rows stand at least: `md` (the default) is as tall as
15
+ * the words (44 px for a pressable row on a coarse pointer); `lg` is a
16
+ * 56 px row on every pointer, its words centred in it, such as a grid of
17
+ * names pressed at a shared counter.
18
+ */
19
+ export const listGroupSizes = ['md', 'lg'];
13
20
  /** `danger` draws the title in the danger colour, for a row that ends something. */
14
21
  export const listRowTones = ['default', 'danger'];
15
22
  /** `strong` (the default) sets the title at the label weight; `plain` at the body's. */
@@ -19,24 +26,25 @@ function isBlank(text) {
19
26
  return typeof text !== 'string' || text.trim() === '';
20
27
  }
21
28
  /**
22
- * Fails closed on a ListGroup it cannot draw: an unknown variant, a
23
- * `maxHeight` that is not a whole row count from 1, a bounded list with
29
+ * Fails closed on a ListGroup it cannot draw: an unknown variant or size,
30
+ * a `maxHeight` that is not a whole row count from 1, a bounded list with
24
31
  * no name (its scroll region is a keyboard stop and must say what it
25
32
  * holds), `tileColumns` other than 2, 3 or 4 or on a list that is not
26
- * tiles, or tiles with `maxHeight` or a `footer` (tiles neither scroll as
27
- * rows nor add up to a total).
33
+ * tiles, or tiles with a `footer` (tiles do not add up to a total).
28
34
  */
29
- export function assertListGroup({ label, labelledBy, variant, maxHeight, tileColumns, hasFooter, }) {
35
+ export function assertListGroup({ label, labelledBy, variant, size, maxHeight, tileColumns, hasFooter, }) {
30
36
  if (!isOneOf(listGroupVariants, variant))
31
37
  throw new RangeError(`Unknown ListGroup variant: ${String(variant)}`);
38
+ if (!isOneOf(listGroupSizes, size))
39
+ throw new RangeError(`Unknown ListGroup size: ${String(size)}`);
32
40
  if (tileColumns !== undefined) {
33
41
  if (variant !== 'tiles')
34
42
  throw new RangeError('ListGroup tileColumns needs variant="tiles"');
35
43
  if (!listTileColumnCounts.includes(tileColumns))
36
44
  throw new RangeError(`ListGroup tileColumns must be 2, 3 or 4: ${String(tileColumns)}`);
37
45
  }
38
- if (variant === 'tiles' && (maxHeight !== undefined || hasFooter))
39
- throw new RangeError('A ListGroup of tiles takes no maxHeight or footer');
46
+ if (variant === 'tiles' && hasFooter)
47
+ throw new RangeError('A ListGroup of tiles takes no footer');
40
48
  if (maxHeight === undefined)
41
49
  return;
42
50
  const rows = typeof maxHeight === 'object' && maxHeight !== null