@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.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +76 -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/PinField.d.ts +48 -0
  8. package/dist/components/PinField.js +63 -0
  9. package/dist/components/pin-field/PinPad.d.ts +15 -0
  10. package/dist/components/pin-field/PinPad.js +20 -0
  11. package/dist/css/css-action-menu.js +11 -0
  12. package/dist/css/css-button-group-attached.js +6 -1
  13. package/dist/css/css-button-natural-width.d.ts +1 -0
  14. package/dist/css/css-button-natural-width.js +16 -0
  15. package/dist/css/css-button.js +2 -0
  16. package/dist/css/css-components.js +3 -0
  17. package/dist/css/css-list-size.d.ts +3 -0
  18. package/dist/css/css-list-size.js +31 -0
  19. package/dist/css/css-list-tiles-bounded.d.ts +1 -0
  20. package/dist/css/css-list-tiles-bounded.js +74 -0
  21. package/dist/css/css-list-tiles.d.ts +1 -0
  22. package/dist/css/css-list-tiles.js +37 -7
  23. package/dist/css/css-list.d.ts +0 -1
  24. package/dist/css/css-list.js +18 -9
  25. package/dist/css/css-pin-field.d.ts +6 -0
  26. package/dist/css/css-pin-field.js +240 -0
  27. package/dist/css/css-utilities.js +2 -0
  28. package/dist/css/list-row-metrics.d.ts +3 -0
  29. package/dist/css/list-row-metrics.js +18 -0
  30. package/dist/css/spacing-classes.d.ts +1 -1
  31. package/dist/css/spacing-classes.js +1 -0
  32. package/dist/css/stacking.js +2 -1
  33. package/dist/css/stylesheet.js +2 -0
  34. package/dist/flex-item-classes.d.ts +15 -0
  35. package/dist/flex-item-classes.js +6 -0
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.js +2 -1
  38. package/dist/list-options.d.ts +13 -5
  39. package/dist/list-options.js +15 -7
  40. package/dist/pin-entry.d.ts +26 -0
  41. package/dist/pin-entry.js +46 -0
  42. package/dist/pin-field-labels.d.ts +17 -0
  43. package/dist/pin-field-labels.js +13 -0
  44. package/dist/styles.css +276 -15
  45. package/package.json +1 -1
@@ -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(),
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The web PinField: a label over a frame of dots with an unseen input, and
3
+ * with `sw-pin-field-with-pad` a centred column of dots over twelve keys.
4
+ */
5
+ export declare function cssPinFieldClasses(): string;
6
+ export declare function pinFieldClassCatalog(): string[];
@@ -0,0 +1,240 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { controlSurface, disabledControlForcedColors, disabledControlSurface, } from './css-document.js';
3
+ const heading = typographyVariants.heading;
4
+ /** A pad key's least size both ways: two space-6, 64 px. */
5
+ const keySize = 'calc(2 * var(--sw-space-6))';
6
+ /*
7
+ * The entry is the field's frame: it draws the canvas control surface, the
8
+ * dots and, while its input has the focus, the accent ring. The input fills
9
+ * it at opacity 0, so the mask characters it holds and its caret are never
10
+ * painted (in forced colours either, where a transparent text colour would
11
+ * be drawn), yet it takes every press and the focus. Its type stays the
12
+ * canvas's body size, so iOS does not zoom when it is focused.
13
+ * `input.sw-pin-field-input` matches the canvas's typed-input rule's
14
+ * specificity and comes later in the sheet.
15
+ */
16
+ function entryRules() {
17
+ return `.sw-pin-field {
18
+ min-width: 0;
19
+ /* Holds its hidden label, count and empty error region, which leave the flow. */
20
+ position: relative;
21
+ }
22
+
23
+ .sw-pin-field-entry {
24
+ ${controlSurface}
25
+ align-items: center;
26
+ box-sizing: border-box;
27
+ cursor: text;
28
+ display: flex;
29
+ min-height: var(--sw-control-md-min-height);
30
+ position: relative;
31
+ }
32
+
33
+ [data-theme] input.sw-pin-field-input {
34
+ border: 0;
35
+ cursor: inherit;
36
+ height: 100%;
37
+ inset: 0;
38
+ margin: 0;
39
+ min-height: 0;
40
+ opacity: 0;
41
+ padding: 0;
42
+ position: absolute;
43
+ width: 100%;
44
+ }
45
+
46
+ /* The canvas sets a disabled text control's opacity back to 1: not this one's. */
47
+ [data-theme] input.sw-pin-field-input:disabled { opacity: 0; }
48
+
49
+ .sw-pin-field-entry:focus-within {
50
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
51
+ outline-offset: var(--sw-focus-ring-offset);
52
+ }
53
+
54
+ .sw-field-invalid .sw-pin-field-entry { border-color: var(--sw-color-danger); }
55
+
56
+ /* The frame draws the surface, so it carries the disabled look for its input. */
57
+ .sw-pin-field-entry:has(> input:disabled) {
58
+ ${disabledControlSurface}
59
+ }`;
60
+ }
61
+ /*
62
+ * One dot per digit of the code: a ring in the muted colour (3:1 or more on
63
+ * the surface and on the subtle fill in every palette), filled in the text
64
+ * colour for a digit entered. A border draws the ring, so forced colours
65
+ * keep it.
66
+ */
67
+ function dotRules() {
68
+ return `.sw-pin-field-dots {
69
+ display: flex;
70
+ gap: var(--sw-space-3);
71
+ pointer-events: none;
72
+ }
73
+
74
+ .sw-pin-field-dot {
75
+ border: 2px solid var(--sw-color-muted);
76
+ border-radius: var(--sw-radius-pill);
77
+ box-sizing: border-box;
78
+ flex: none;
79
+ height: var(--sw-space-4);
80
+ width: var(--sw-space-4);
81
+ }
82
+
83
+ .sw-pin-field-dot-filled {
84
+ background: var(--sw-color-text);
85
+ border-color: var(--sw-color-text);
86
+ }`;
87
+ }
88
+ /*
89
+ * With its pad the field is one centred column, ten space-6 wide at most:
90
+ * the dots stand without a frame (the ring still shows where the focus is),
91
+ * and the keys are three equal columns. A key is at least 64 px both ways,
92
+ * on the subtle fill inside an edge in the muted colour (3:1 or more
93
+ * against the fill and the surface), its digit at the heading size. Delete
94
+ * has the same edge on no fill. The hover fill is for a pointer that
95
+ * hovers, so it never sticks after a touch.
96
+ */
97
+ function padRules() {
98
+ return `.sw-pin-field-with-pad {
99
+ /* Centred in a column wider than it, whatever the column's alignment. */
100
+ margin-inline: auto;
101
+ max-inline-size: calc(10 * var(--sw-space-6));
102
+ text-align: center;
103
+ width: 100%;
104
+ }
105
+
106
+ .sw-pin-field-with-pad .sw-pin-field-entry,
107
+ .sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) {
108
+ background-color: transparent;
109
+ border-width: 0;
110
+ justify-content: center;
111
+ }
112
+
113
+ .sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots {
114
+ opacity: var(--sw-disabled-opacity);
115
+ }
116
+
117
+ .sw-pin-field-pad {
118
+ display: grid;
119
+ gap: var(--sw-space-2);
120
+ grid-template-columns: repeat(3, minmax(0, 1fr));
121
+ margin-block-start: var(--sw-space-3);
122
+ }
123
+
124
+ /* The hint or the error under the keys stands a little apart from them. */
125
+ .sw-pin-field-pad ~ :is(.sw-field-description, .sw-field-error:not(:empty)) {
126
+ margin-block-start: var(--sw-space-2);
127
+ }
128
+
129
+ .sw-pin-field-key {
130
+ align-items: center;
131
+ appearance: none;
132
+ background: var(--sw-color-subtle);
133
+ border: 1px solid var(--sw-color-muted);
134
+ border-radius: var(--sw-radius-md);
135
+ box-sizing: border-box;
136
+ color: var(--sw-color-text);
137
+ cursor: pointer;
138
+ display: inline-flex;
139
+ font-family: var(--sw-font-sans);
140
+ font-size: ${heading.fontSize}px;
141
+ font-variant-numeric: tabular-nums;
142
+ font-weight: 400;
143
+ justify-content: center;
144
+ line-height: ${heading.lineHeight}px;
145
+ margin: 0;
146
+ min-block-size: ${keySize};
147
+ min-inline-size: ${keySize};
148
+ padding: 0;
149
+ touch-action: manipulation;
150
+ user-select: none;
151
+ -webkit-tap-highlight-color: transparent;
152
+ }
153
+
154
+ .sw-pin-field-key-delete { background: transparent; }
155
+
156
+ @media (hover: hover) {
157
+ .sw-pin-field-key:hover:not(:disabled, [aria-disabled='true']) {
158
+ background: var(--sw-color-border);
159
+ }
160
+ }
161
+
162
+ .sw-pin-field-key:active:not(:disabled, [aria-disabled='true']) {
163
+ background: var(--sw-color-border);
164
+ }
165
+
166
+ .sw-pin-field-key:focus { outline: none; }
167
+
168
+ .sw-pin-field-key:focus-visible {
169
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
170
+ outline-offset: var(--sw-focus-ring-offset);
171
+ }
172
+
173
+ .sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
174
+ cursor: not-allowed;
175
+ opacity: var(--sw-disabled-opacity);
176
+ }
177
+
178
+ .sw-pin-field-glyph {
179
+ fill: none;
180
+ flex: none;
181
+ height: var(--sw-space-5);
182
+ stroke: currentColor;
183
+ stroke-linecap: round;
184
+ stroke-linejoin: round;
185
+ /* The stroke of the system's other private glyphs and of consumer icons (ADR 0008). */
186
+ stroke-width: 1.75;
187
+ width: var(--sw-space-5);
188
+ }
189
+
190
+ /* The mark points the way a deletion goes. */
191
+ [dir='rtl'] .sw-pin-field-glyph { transform: scaleX(-1); }`;
192
+ }
193
+ /* Forced colours: system edges and fills; a disabled part in GrayText, unfaded. */
194
+ function forcedColorRules() {
195
+ return `@media (forced-colors: active) {
196
+ .sw-field-invalid .sw-pin-field-entry { border-color: Mark; }
197
+ .sw-pin-field-entry:has(> input:disabled) {
198
+ ${disabledControlForcedColors}
199
+ }
200
+ .sw-pin-field-dot { border-color: CanvasText; }
201
+ .sw-pin-field-dot-filled { background: CanvasText; }
202
+ .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot { border-color: GrayText; }
203
+ .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot-filled { background: GrayText; }
204
+ .sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots { opacity: 1; }
205
+ .sw-pin-field-key { border-color: ButtonText; }
206
+ .sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
207
+ border-color: GrayText;
208
+ color: GrayText;
209
+ opacity: 1;
210
+ }
211
+ }`;
212
+ }
213
+ /**
214
+ * The web PinField: a label over a frame of dots with an unseen input, and
215
+ * with `sw-pin-field-with-pad` a centred column of dots over twelve keys.
216
+ */
217
+ export function cssPinFieldClasses() {
218
+ return `${entryRules()}
219
+
220
+ ${dotRules()}
221
+
222
+ ${padRules()}
223
+
224
+ ${forcedColorRules()}`;
225
+ }
226
+ export function pinFieldClassCatalog() {
227
+ return [
228
+ 'sw-pin-field',
229
+ 'sw-pin-field-with-pad',
230
+ 'sw-pin-field-entry',
231
+ 'sw-pin-field-input',
232
+ 'sw-pin-field-dots',
233
+ 'sw-pin-field-dot',
234
+ 'sw-pin-field-dot-filled',
235
+ 'sw-pin-field-pad',
236
+ 'sw-pin-field-key',
237
+ 'sw-pin-field-key-delete',
238
+ 'sw-pin-field-glyph',
239
+ ];
240
+ }
@@ -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.
@@ -10,6 +10,7 @@ import { dateFieldClassCatalog } from './css-date-field.js';
10
10
  import { calendarButtonClassCatalog } from './css-calendar-button.js';
11
11
  import { dateRangeClassCatalog } from './css-date-range.js';
12
12
  import { fileFieldClassCatalog } from './css-file-field.js';
13
+ import { pinFieldClassCatalog } from './css-pin-field.js';
13
14
  import { articleClassCatalog } from './css-article.js';
14
15
  import { documentViewerClassCatalog } from './css-document-viewer.js';
15
16
  import { fixtureClassCatalog } from './css-fixture.js';
@@ -170,6 +171,7 @@ export function utilityClassCatalog() {
170
171
  ...denominationGridClassCatalog(),
171
172
  ...fieldClassCatalog(),
172
173
  ...stepperClassCatalog(),
174
+ ...pinFieldClassCatalog(),
173
175
  ...stepsClassCatalog(),
174
176
  ...taskListClassCatalog(),
175
177
  ...splitClassCatalog(),
@@ -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
@@ -8,11 +8,12 @@ export { CalendarButton, type CalendarButtonLabels, type CalendarButtonProps, ty
8
8
  export { DateRangeButton, type DateRangeButtonLabels, type DateRangeButtonProps, type DateRangeButtonValue, type DateRangePreset, } from './components/DateRangeButton.js';
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
+ export { defaultPinFieldLabels, PinField, type PinFieldLabels, type PinFieldProps, } from './components/PinField.js';
11
12
  export { DocumentViewer, type DocumentViewerLabels, type DocumentViewerProps, } from './components/DocumentViewer.js';
12
13
  export { ListGroup, type ListGroupProps } from './components/ListGroup.js';
13
14
  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';
14
15
  export { ListRow, type ListRowProps } from './components/ListRow.js';
15
- export { listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, type ListGroupMaxHeight, type ListGroupVariant, type ListRowTitleAppearance, type ListRowTone, type ListRowValueTone, } from './list-options.js';
16
+ export { listGroupSizes, listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, type ListGroupMaxHeight, type ListGroupSize, type ListGroupVariant, type ListRowTitleAppearance, type ListRowTone, type ListRowValueTone, } from './list-options.js';
16
17
  export { listTileColumnCounts, type ListGroupTileColumns, } from './css/css-list-tiles.js';
17
18
  export { Checkbox, checkboxAppearances, type CheckboxAppearance, type CheckboxProps, } from './components/Checkbox.js';
18
19
  export { PasteRows, type PasteRowsColumn, type PasteRowsProps, } from './components/PasteRows.js';
@@ -115,6 +116,7 @@ export { Grid, gridFits, gridRails } from './components/Grid.js';
115
116
  export type { GridColumns, GridFit, GridProps, GridRail, } from './components/Grid.js';
116
117
  export type { GridColumnSpan } from './css/css-grid-span.js';
117
118
  export type { ColumnSpanProps } from './column-span-classes.js';
119
+ export type { FlexItemProps } from './flex-item-classes.js';
118
120
  export { DenominationGrid, denominationCellToneAppearances, denominationGridFrames, denominationLabelAppearances, denominationNegativeAppearances, denominationTotalEmphases, denominationTransposeBreakpoints, } from './components/DenominationGrid.js';
119
121
  export type { DenominationCellToneAppearance, DenominationGridColumn, DenominationGridEntry, DenominationGridFrame, DenominationGridLayout, DenominationGridNegativeAppearance, DenominationGridProps, DenominationGridRow, DenominationGridRowEmphasis, DenominationGridRowRole, DenominationGridTone, DenominationGridValueRow, DenominationLabelAppearance, DenominationLabelWidth, DenominationTotalEmphasis, DenominationTransposeBreakpoint, } from './components/DenominationGrid.js';
120
122
  export { FilterChips, filterChipCountAppearances, filterChipsOverflows, filterChipsSelectedStyles, filterChipTones, } from './components/FilterChips.js';
package/dist/index.js CHANGED
@@ -7,11 +7,12 @@ export { CalendarButton, } from './components/CalendarButton.js';
7
7
  export { DateRangeButton, } from './components/DateRangeButton.js';
8
8
  export { Article, articleTitleElements, } from './components/Article.js';
9
9
  export { FileField, } from './components/FileField.js';
10
+ export { defaultPinFieldLabels, PinField, } from './components/PinField.js';
10
11
  export { DocumentViewer, } from './components/DocumentViewer.js';
11
12
  export { ListGroup } from './components/ListGroup.js';
12
13
  export { inspectMarkdown, markdownOmissionKinds, MarkdownView, } from './components/MarkdownView.js';
13
14
  export { ListRow } from './components/ListRow.js';
14
- export { listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, } from './list-options.js';
15
+ export { listGroupSizes, listGroupVariants, listRowTitleAppearances, listRowTones, listRowValueTones, } from './list-options.js';
15
16
  export { listTileColumnCounts, } from './css/css-list-tiles.js';
16
17
  export { Checkbox, checkboxAppearances, } from './components/Checkbox.js';
17
18
  export { PasteRows, } from './components/PasteRows.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 = {