@scalewing/react 1.66.0 → 1.67.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalewing/react
2
2
 
3
+ ## 1.67.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 17f6237: `DenominationGrid pinEnd`: while transposed, the last column (the last grid row's value line with its total, else its counts and total) stays in view at the inline end, with the end shade before it, while the columns between scroll (Teisoro F-001, request `docs/requests/teisoro-denomination-pin-end.md`). Needs `transposeBelow`; the default is unchanged. New classes `sw-denomination-scroll-pin-end`, `sw-denomination-transposed-end`. No new tokens or dependencies.
8
+
3
9
  ## 1.66.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -1669,6 +1669,7 @@ Values outside the catalog throw a `RangeError`. There is no per-breakpoint span
1669
1669
 
1670
1670
  - A row's `negativeAppearance="plain"` (`denominationNegativeAppearances`, default `"danger"`) sets its negative counts in the text colour with their minus. Use it for counts that go out by design, such as bills paid out: going out is not an error, so never red. `"danger"` stays for a shortage.
1671
1671
  - `transposeBelow="md"` (or `"lg"`; `denominationTransposeBreakpoints`; the strip layout only) draws the strip transposed below that width, for a phone. Each denomination is a row (its label and caption, pinned while the columns scroll), each grid row a column (its label over its counts, entry steppers or value line), and the totals a last row named by `totalLabel`. Names, entry, cell tones, the zero label and quiet and disabled rows are the strip's; a disabled row says so on its column heads. It reads the width with the breakpoint's media query, so a server render draws the strip, and crossing the breakpoint (turning a phone) remounts the grid, so a count being typed loses focus.
1672
+ - `pinEnd` (opt-in; needs `transposeBelow`, a `TypeError` otherwise) keeps the transposed grid's last column in view at the inline end while the columns between scroll: the last grid row's value line with its total (or, without one, its counts and total), on the glass fill with the end shade before it while there is more to scroll, so a phone always sees each denomination's worth and the total, as a long table keeps its total pinned. It changes nothing while the strip is not transposed. New classes `sw-denomination-scroll-pin-end`, `sw-denomination-transposed-end`.
1672
1673
  - `countDigits` (3 to 6, entry rows only) keeps that many digits' room in every entry count before the strip scrolls, such as 4 for counts in the thousands in seven columns. The default room is 3.
1673
1674
  - An unknown appearance or breakpoint, `transposeBelow` on tiles, or a `countDigits` out of range or without entry rows throws a `RangeError`.
1674
1675
 
@@ -6,4 +6,4 @@ export type { DenominationCellToneAppearance, DenominationGridColumn, Denominati
6
6
  export { denominationNegativeAppearances, denominationTransposeBreakpoints, } from './denomination-grid/types.js';
7
7
  export type { DenominationLabelAppearance } from '../css/css-denomination-label.js';
8
8
  export { denominationCellToneAppearances, denominationGridFrames, denominationLabelAppearances, denominationTotalEmphases, };
9
- export declare function DenominationGrid({ label, columns, rows, layout, subtotal, zeroLabel, totalLabel, rowRole, labelWidth, labelAppearance, frame, totalEmphasis, cellToneAppearance, transposeBelow, countDigits, }: DenominationGridProps): import("react").JSX.Element;
9
+ export declare function DenominationGrid({ label, columns, rows, layout, subtotal, zeroLabel, totalLabel, rowRole, labelWidth, labelAppearance, frame, totalEmphasis, cellToneAppearance, transposeBelow, pinEnd, countDigits, }: DenominationGridProps): import("react").JSX.Element;
@@ -22,12 +22,14 @@ function assertOneOf(values, value, prop) {
22
22
  if (!values.includes(value))
23
23
  throw new RangeError(`Unknown ${prop}: ${String(value)}`);
24
24
  }
25
- export function DenominationGrid({ label, columns, rows, layout = 'strip', subtotal, zeroLabel = '—', totalLabel, rowRole = 'region', labelWidth, labelAppearance = 'tone', frame = 'none', totalEmphasis = 'default', cellToneAppearance = 'text', transposeBelow, countDigits, }) {
25
+ export function DenominationGrid({ label, columns, rows, layout = 'strip', subtotal, zeroLabel = '—', totalLabel, rowRole = 'region', labelWidth, labelAppearance = 'tone', frame = 'none', totalEmphasis = 'default', cellToneAppearance = 'text', transposeBelow, pinEnd = false, countDigits, }) {
26
26
  assertDenominationGrid(label, columns, rows);
27
27
  assertDenominationExtras(layout, columns, rows);
28
28
  assertDenominationEntries(layout, columns, rows);
29
29
  assertDenominationValueRows(layout, columns, rows);
30
30
  assertDenominationOptions(layout, rows, transposeBelow, countDigits);
31
+ if (pinEnd && transposeBelow === undefined)
32
+ throw new TypeError('DenominationGrid pinEnd needs transposeBelow');
31
33
  if (typeof zeroLabel !== 'string')
32
34
  throw new RangeError('zeroLabel must be a string');
33
35
  if (totalLabel !== undefined && !totalLabel.trim())
@@ -52,6 +54,6 @@ export function DenominationGrid({ label, columns, rows, layout = 'strip', subto
52
54
  if (layout === 'tiles')
53
55
  return (_jsx(DenominationTiles, { className: appearanceClass || undefined, columns: columns, label: label, rowRole: rowRole, rows: rows, subtotal: subtotal, zeroLabel: zeroLabel }));
54
56
  if (transposeBelow !== undefined && transposed)
55
- return (_jsx(TransposedStrip, { className: appearanceClass || undefined, columns: columns, label: label, rows: rows, style: countStyle, totalLabel: totalLabel, zeroLabel: zeroLabel }));
57
+ return (_jsx(TransposedStrip, { className: appearanceClass || undefined, columns: columns, label: label, rows: rows, pinEnd: pinEnd, style: countStyle, totalLabel: totalLabel, zeroLabel: zeroLabel }));
56
58
  return (_jsx(DenominationStrip, { className: appearanceClass || undefined, countStyle: countStyle, columns: columns, framed: frame === 'table', label: label, labelWidth: labelWidth, rows: rows, totalLabel: totalLabel, zeroLabel: zeroLabel }));
57
59
  }
@@ -1,6 +1,6 @@
1
1
  import { type CSSProperties } from 'react';
2
2
  import { type DenominationGridProps } from './types.js';
3
- type TransposedProps = Required<Pick<DenominationGridProps, 'label' | 'columns' | 'rows' | 'zeroLabel'>> & Pick<DenominationGridProps, 'totalLabel'> & {
3
+ type TransposedProps = Required<Pick<DenominationGridProps, 'label' | 'columns' | 'rows' | 'zeroLabel'>> & Pick<DenominationGridProps, 'totalLabel' | 'pinEnd'> & {
4
4
  /** The grid's appearance classes (cell tones), if any. */
5
5
  className?: string;
6
6
  /** The entry counts' room, as the strip's. */
@@ -11,7 +11,9 @@ type TransposedProps = Required<Pick<DenominationGridProps, 'label' | 'columns'
11
11
  * caption), a column per grid row (its counts, read-only or entered, then
12
12
  * its value line's values), and the totals in a last row named by
13
13
  * `totalLabel`. Names, entry, tones and the zero label are the strip's;
14
- * the denomination column stays in view while the columns scroll under it.
14
+ * the denomination column stays in view while the columns scroll under it,
15
+ * and with `pinEnd` the last column (the last grid row's value line, which
16
+ * holds its total, else its counts and total) stays in view at the end.
15
17
  */
16
- export declare function TransposedStrip({ className, style, label, columns, rows, zeroLabel, totalLabel, }: TransposedProps): import("react").JSX.Element;
18
+ export declare function TransposedStrip({ className, style, label, columns, rows, zeroLabel, totalLabel, pinEnd, }: TransposedProps): import("react").JSX.Element;
17
19
  export {};
@@ -7,6 +7,8 @@ import { CountCell } from './CountCell.js';
7
7
  import { EntryCell } from './EntryCell.js';
8
8
  import { RowLabelLine } from './RowLabelLine.js';
9
9
  import { hasValue, valueCellId } from './StripValueRow.js';
10
+ /** The class of the cells of the column pinned at the inline end. */
11
+ const endClass = 'sw-denomination-transposed-end';
10
12
  /** The look a grid row lends each of its cells in a column. */
11
13
  function columnClass(row) {
12
14
  return (cx(row.emphasis === 'quiet' && 'sw-denomination-transposed-quiet', row.disabled && 'sw-denomination-transposed-disabled') || undefined);
@@ -17,12 +19,12 @@ function columnClass(row) {
17
19
  * `aria-disabled`), as the strip's row does, since a column has no element
18
20
  * of its own.
19
21
  */
20
- function RowHeads({ row }) {
21
- return (_jsxs(_Fragment, { children: [_jsx("th", { "aria-disabled": row.disabled || undefined, className: cx('sw-denomination-head sw-denomination-transposed-head', columnClass(row)), scope: "col", children: _jsx(RowLabelLine, { row: row }) }), row.valueRow ? (_jsx("th", { "aria-disabled": row.disabled || undefined, "aria-label": `${row.label} ${row.valueRow.label}`, className: cx('sw-denomination-head sw-denomination-transposed-head', columnClass(row)), scope: "col", children: row.valueRow.label })) : null] }));
22
+ function RowHeads({ row, pinned, }) {
23
+ return (_jsxs(_Fragment, { children: [_jsx("th", { "aria-disabled": row.disabled || undefined, className: cx('sw-denomination-head sw-denomination-transposed-head', columnClass(row), pinned && !row.valueRow && endClass), scope: "col", children: _jsx(RowLabelLine, { row: row }) }), row.valueRow ? (_jsx("th", { "aria-disabled": row.disabled || undefined, "aria-label": `${row.label} ${row.valueRow.label}`, className: cx('sw-denomination-head sw-denomination-transposed-head', columnClass(row), pinned && endClass), scope: "col", children: row.valueRow.label })) : null] }));
22
24
  }
23
25
  /** A grid row's total: under its value line when it has one, else under its counts. */
24
- function RowTotal({ row }) {
25
- const total = (_jsx("td", { className: cx('sw-denomination-transposed-total', `sw-denomination-row-${row.tone ?? 'neutral'}`, columnClass(row)), children: row.total ?? '' }));
26
+ function RowTotal({ row, pinned, }) {
27
+ const total = (_jsx("td", { className: cx('sw-denomination-transposed-total', `sw-denomination-row-${row.tone ?? 'neutral'}`, columnClass(row), pinned && endClass), children: row.total ?? '' }));
26
28
  return row.valueRow ? (_jsxs(_Fragment, { children: [_jsx("td", { className: columnClass(row) }), total] })) : (total);
27
29
  }
28
30
  /**
@@ -30,14 +32,20 @@ function RowTotal({ row }) {
30
32
  * caption), a column per grid row (its counts, read-only or entered, then
31
33
  * its value line's values), and the totals in a last row named by
32
34
  * `totalLabel`. Names, entry, tones and the zero label are the strip's;
33
- * the denomination column stays in view while the columns scroll under it.
35
+ * the denomination column stays in view while the columns scroll under it,
36
+ * and with `pinEnd` the last column (the last grid row's value line, which
37
+ * holds its total, else its counts and total) stays in view at the end.
34
38
  */
35
- export function TransposedStrip({ className, style, label, columns, rows, zeroLabel, totalLabel, }) {
39
+ export function TransposedStrip({ className, style, label, columns, rows, zeroLabel, totalLabel, pinEnd = false, }) {
36
40
  const idPrefix = useId();
41
+ const last = rows.length - 1;
42
+ const pinned = (rowIndex) => pinEnd && rowIndex === last;
43
+ /** A count cell is the pinned one when its row has no value line after it. */
44
+ const countEnd = (row, rowIndex) => pinned(rowIndex) && !row.valueRow && endClass;
37
45
  const hasTotals = rows.some((row) => row.total !== undefined);
38
- return (_jsx(ScrollRegion, { "aria-label": label, className: "sw-denomination-scroll sw-denomination-scroll-transposed", children: _jsxs("table", { className: cx('sw-denomination-grid sw-denomination-transposed', rows.some((row) => row.entry) && 'sw-denomination-transposed-entry', className), style: style, children: [_jsx("caption", { className: "sw-sr-only", children: label }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", { className: "sw-denomination-corner" }), rows.map((row) => (_jsx(RowHeads, { row: row }, row.id)))] }) }), _jsx("tbody", { children: columns.map((column, index) => (_jsxs("tr", { className: "sw-denomination-row", children: [_jsx("th", { className: "sw-denomination-transposed-label", scope: "row", children: _jsx(ColumnHeadText, { column: column }) }), rows.map((row, rowIndex) => {
46
+ return (_jsx(ScrollRegion, { "aria-label": label, className: cx('sw-denomination-scroll sw-denomination-scroll-transposed', pinEnd && 'sw-denomination-scroll-pin-end'), children: _jsxs("table", { className: cx('sw-denomination-grid sw-denomination-transposed', rows.some((row) => row.entry) && 'sw-denomination-transposed-entry', className), style: style, children: [_jsx("caption", { className: "sw-sr-only", children: label }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", { className: "sw-denomination-corner" }), rows.map((row, rowIndex) => (_jsx(RowHeads, { pinned: pinned(rowIndex), row: row }, row.id)))] }) }), _jsx("tbody", { children: columns.map((column, index) => (_jsxs("tr", { className: "sw-denomination-row", children: [_jsx("th", { className: "sw-denomination-transposed-label", scope: "row", children: _jsx(ColumnHeadText, { column: column }) }), rows.map((row, rowIndex) => {
39
47
  const value = row.valueRow?.cells[index];
40
48
  const valueId = valueCellId(idPrefix, rowIndex, index);
41
- return (_jsxs(Fragment, { children: [row.entry ? (_jsx(EntryCell, { className: columnClass(row), column: column, describedBy: hasValue(value) ? valueId : undefined, entry: row.entry, index: index, row: row })) : (_jsx(CountCell, { className: columnClass(row), index: index, row: row, zeroLabel: zeroLabel })), row.valueRow ? (_jsx("td", { className: cx('sw-denomination-transposed-value', columnClass(row)), id: valueId, children: hasValue(value) ? value : '' })) : null] }, row.id));
42
- })] }, column.key))) }), hasTotals ? (_jsx("tfoot", { children: _jsxs("tr", { className: "sw-denomination-row", children: [totalLabel === undefined ? (_jsx("td", { className: "sw-denomination-corner" })) : (_jsx("th", { className: "sw-denomination-transposed-label", scope: "row", children: totalLabel })), rows.map((row) => (_jsx(RowTotal, { row: row }, row.id)))] }) })) : null] }) }));
49
+ return (_jsxs(Fragment, { children: [row.entry ? (_jsx(EntryCell, { className: cx(columnClass(row), countEnd(row, rowIndex)), column: column, describedBy: hasValue(value) ? valueId : undefined, entry: row.entry, index: index, row: row })) : (_jsx(CountCell, { className: cx(columnClass(row), countEnd(row, rowIndex)), index: index, row: row, zeroLabel: zeroLabel })), row.valueRow ? (_jsx("td", { className: cx('sw-denomination-transposed-value', columnClass(row), pinned(rowIndex) && endClass), id: valueId, children: hasValue(value) ? value : '' })) : null] }, row.id));
50
+ })] }, column.key))) }), hasTotals ? (_jsx("tfoot", { children: _jsxs("tr", { className: "sw-denomination-row", children: [totalLabel === undefined ? (_jsx("td", { className: "sw-denomination-corner" })) : (_jsx("th", { className: "sw-denomination-transposed-label", scope: "row", children: totalLabel })), rows.map((row, rowIndex) => (_jsx(RowTotal, { pinned: pinned(rowIndex), row: row }, row.id)))] }) })) : null] }) }));
43
51
  }
@@ -188,6 +188,15 @@ export type DenominationGridProps = {
188
188
  * and zero label are the strip's. The `strip` layout only.
189
189
  */
190
190
  transposeBelow?: DenominationTransposeBreakpoint;
191
+ /**
192
+ * While transposed, the last column (the last grid row's value line,
193
+ * which holds its total, else its counts and total) stays in view at the
194
+ * inline end, as the denomination column does at the start, and only the
195
+ * columns between them scroll, so a phone always sees each row's worth
196
+ * and the total. It needs `transposeBelow` (a `TypeError` otherwise) and
197
+ * changes nothing while the strip is not transposed.
198
+ */
199
+ pinEnd?: boolean;
191
200
  /**
192
201
  * The digits an entry count holds without clipping, from 3 (the
193
202
  * default room) to 6: a column of steppers keeps that many digits'
@@ -0,0 +1,2 @@
1
+ export declare function cssDenominationPinEndClasses(): string;
2
+ export declare function denominationPinEndClassCatalog(): string[];
@@ -0,0 +1,36 @@
1
+ import { pinnedEndShadeRules } from './css-scroll-region.js';
2
+ import { zIndex } from './stacking.js';
3
+ const region = '.sw-denomination-scroll-pin-end';
4
+ const end = '.sw-denomination-transposed-end';
5
+ /*
6
+ * A transposed strip with `pinEnd`: the last column stays in view at the
7
+ * inline end, on the glass fill as the pinned denomination column is (its
8
+ * value cells and a quiet row's cells keep their subtle fill over the
9
+ * blur), and casts the end shade just before it while there is more to
10
+ * scroll to. A disabled last row cannot fade its pinned cells (the columns
11
+ * scrolling under them would show through), so they stay opaque and their
12
+ * words take the muted colour instead.
13
+ */
14
+ export function cssDenominationPinEndClasses() {
15
+ return `${region} ${end} {
16
+ backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
17
+ -webkit-backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
18
+ inset-inline-end: 0;
19
+ position: sticky;
20
+ ${zIndex('stickyCell')}
21
+ }
22
+
23
+ ${region} ${end}:not(.sw-denomination-transposed-value, .sw-denomination-transposed-quiet) {
24
+ background-color: var(--sw-glass-fill);
25
+ }
26
+
27
+ ${region} .sw-denomination-grid.sw-denomination-transposed ${end}.sw-denomination-transposed-disabled {
28
+ color: var(--sw-color-muted);
29
+ opacity: 1;
30
+ }
31
+
32
+ ${pinnedEndShadeRules(region, [end])}`;
33
+ }
34
+ export function denominationPinEndClassCatalog() {
35
+ return ['sw-denomination-scroll-pin-end', 'sw-denomination-transposed-end'];
36
+ }
@@ -1,4 +1,5 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
+ import { cssDenominationPinEndClasses, denominationPinEndClassCatalog, } from './css-denomination-pin-end.js';
2
3
  import { pinnedStartShadeRules } from './css-scroll-region.js';
3
4
  import { zIndex } from './stacking.js';
4
5
  const body = typographyVariants.body;
@@ -158,6 +159,8 @@ function countRules() {
158
159
  export function cssDenominationTransposedClasses() {
159
160
  return `${transposedRules()}
160
161
 
162
+ ${cssDenominationPinEndClasses()}
163
+
161
164
  ${countRules()}`;
162
165
  }
163
166
  export function denominationTransposedClassCatalog() {
@@ -174,5 +177,6 @@ export function denominationTransposedClassCatalog() {
174
177
  'sw-denomination-cell-signed',
175
178
  'sw-denomination-cell-plain',
176
179
  denominationCountDigitsClass,
180
+ ...denominationPinEndClassCatalog(),
177
181
  ];
178
182
  }
@@ -51,3 +51,9 @@ export declare function scrollRegionClassCatalog(): string[];
51
51
  * draw no shade here either.
52
52
  */
53
53
  export declare function pinnedStartShadeRules(region: string, pinned: readonly string[]): string;
54
+ /**
55
+ * The end-side twin of `pinnedStartShadeRules`: a region whose end column
56
+ * is pinned hides its end shade under that column, so the column casts the
57
+ * shade just before its inline start, drawn by its `::before`.
58
+ */
59
+ export declare function pinnedEndShadeRules(region: string, pinned: readonly string[]): string;
@@ -139,3 +139,30 @@ ${after(':dir(rtl)')} {
139
139
  ${after('').replaceAll('\n', '\n ')} { display: none; }
140
140
  }`;
141
141
  }
142
+ /**
143
+ * The end-side twin of `pinnedStartShadeRules`: a region whose end column
144
+ * is pinned hides its end shade under that column, so the column casts the
145
+ * shade just before its inline start, drawn by its `::before`.
146
+ */
147
+ export function pinnedEndShadeRules(region, pinned) {
148
+ const before = (direction) => pinned
149
+ .map((cell) => `${region}.sw-scroll-more-end${direction} ${cell}::before`)
150
+ .join(',\n');
151
+ return `${before('')} {
152
+ background: linear-gradient(to left, ${scrollShadeColor}, transparent);
153
+ content: '';
154
+ inset-block: 0;
155
+ inset-inline-end: 100%;
156
+ pointer-events: none;
157
+ position: absolute;
158
+ width: var(--sw-space-5);
159
+ }
160
+
161
+ ${before(':dir(rtl)')} {
162
+ background: linear-gradient(to right, ${scrollShadeColor}, transparent);
163
+ }
164
+
165
+ @media (forced-colors: active) {
166
+ ${before('').replaceAll('\n', '\n ')} { display: none; }
167
+ }`;
168
+ }
package/dist/styles.css CHANGED
@@ -10459,6 +10459,41 @@ html:has(.sw-site-header-sticky) .sw-docs-layout {
10459
10459
  .sw-denomination-transposed-total { color: CanvasText; }
10460
10460
  }
10461
10461
 
10462
+ .sw-denomination-scroll-pin-end .sw-denomination-transposed-end {
10463
+ backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
10464
+ -webkit-backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
10465
+ inset-inline-end: 0;
10466
+ position: sticky;
10467
+ z-index: 1;
10468
+ }
10469
+
10470
+ .sw-denomination-scroll-pin-end .sw-denomination-transposed-end:not(.sw-denomination-transposed-value, .sw-denomination-transposed-quiet) {
10471
+ background-color: var(--sw-glass-fill);
10472
+ }
10473
+
10474
+ .sw-denomination-scroll-pin-end .sw-denomination-grid.sw-denomination-transposed .sw-denomination-transposed-end.sw-denomination-transposed-disabled {
10475
+ color: var(--sw-color-muted);
10476
+ opacity: 1;
10477
+ }
10478
+
10479
+ .sw-denomination-scroll-pin-end.sw-scroll-more-end .sw-denomination-transposed-end::before {
10480
+ background: linear-gradient(to left, color-mix(in srgb, var(--sw-color-text) 28%, transparent), transparent);
10481
+ content: '';
10482
+ inset-block: 0;
10483
+ inset-inline-end: 100%;
10484
+ pointer-events: none;
10485
+ position: absolute;
10486
+ width: var(--sw-space-5);
10487
+ }
10488
+
10489
+ .sw-denomination-scroll-pin-end.sw-scroll-more-end:dir(rtl) .sw-denomination-transposed-end::before {
10490
+ background: linear-gradient(to right, color-mix(in srgb, var(--sw-color-text) 28%, transparent), transparent);
10491
+ }
10492
+
10493
+ @media (forced-colors: active) {
10494
+ .sw-denomination-scroll-pin-end.sw-scroll-more-end .sw-denomination-transposed-end::before { display: none; }
10495
+ }
10496
+
10462
10497
  .sw-denomination-cell-signed.sw-denomination-cell-positive {
10463
10498
  color: var(--sw-color-success);
10464
10499
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalewing/react",
3
- "version": "1.66.0",
3
+ "version": "1.67.0",
4
4
  "description": "Scalewing DOM components and package-owned CSS utilities.",
5
5
  "type": "module",
6
6
  "license": "MIT",