@scalewing/react 1.34.0 → 1.35.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.35.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 287d933: `Table` `stickyHeader="page"` pins the header row to the page's top while the page scrolls, without a sticky `TableFooter` (`docs/requests/teisoro-table-sticky-page.md`, Teisoro F-011 task 2180). While the table fits its width its region stops being a scroll box, as it already did for a sticky footer; a table wider than its region scrolls sideways in it and pins inside it. `true` (the default) and `false` are unchanged; any other value (including an untyped `null` or `0`, which used to mean not sticky) throws a `RangeError`. New type `TableStickyHeader` and generated class `sw-table-sticky-page`. No new tokens, no new dependency.
8
+
3
9
  ## 1.34.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -416,6 +416,14 @@ A header `TableCell` (`as="th"`) with `sort` (`'ascending'`, `'descending'` or `
416
416
 
417
417
  A ledger read across as well as down takes `Table` `columnRules` (a hairline at the inline start of every cell after a row's first, mirrored right to left) and `TableCell` `tone` (`success`, `danger`, `muted` or `accent`: the cell's text in the theme colour, as `Text color` uses it; never the only signal, so keep the sign or the words). `TableRow` `variant="sub"` (default `"default"`) sets a row under the one above, as a batch's items: its row header, a `TableCell as="th" scope="row"`, is indented a `space-6` step with a guide bar at the indent (a sub row without a row header is not indented). `TableRow` `struck` keeps a voided row on the record: the subtle fill and the text muted and struck through, toned cells included; it works with either variant. A line-through is not read aloud, so say why in the row, such as a `Badge` "Voided": a Badge in a line of text is not struck, but one that is itself a flex item (a direct child of `Inline`) is, so put it in the title's line. A row header in the body or footer (`th scope="row"`) reads as body text. An unknown `tone` or `variant` throws a `RangeError`.
418
418
 
419
+ `Table` `stickyHeader` pins the header row: `true` (default) to the top of the table's own scroll region, `false` lets it scroll away, and `'page'` pins it to the page's top as the page scrolls. With `'page'`, while the table fits its width its region stops being a scroll box (`sw-table-sticky-page`), so the header stays in view under any sticky `AppHeader` (which covers it); a table wider than its region scrolls sideways in it and pins inside it. Use it for a long table whose last row, such as a non-sticky `TableFooter` total, should scroll with the rows. An unknown value throws a `RangeError`.
420
+
421
+ ```tsx
422
+ <Table aria-label="Site census" stickyHeader="page">
423
+ …
424
+ </Table>
425
+ ```
426
+
419
427
  `TableFooter` is the table's `tfoot`, for a total: its cells are set at weight 600 under a 2 px rule across its first row (drawn on each cell's `::before`, so forced colors keep it), and a `TableCell as="th" scope="row"` in it names the total. `sticky` pins the footer to the bottom edge on the header's glass (solid under Reduce Transparency, the system canvas in forced colors), on its own layer over the cells and the pinned header. While the table fits its width, a table with a sticky footer stops being a scroll box, so the footer pins to the page's bottom and the sticky header to its top as the page scrolls; a sticky `AppHeader` covers that header. A table wider than its region scrolls sideways in it and pins to the region instead. A sticky `ActionBar` covers a pinned footer, and so does a `Dialog`'s pinned footer, so do not pair them.
420
428
 
421
429
  `BarChart` `formatValue` writes the axis's values and each value without its own `valueLabel`, such as a currency. `diverging` puts zero in the middle of each track behind a hairline: a positive bar grows toward the inline end and a negative one toward the start, on one scale, and the axis reads minus the maximum, zero and the maximum. Without it every bar grows from the start. An item's `tone` (`BarChartTone`: `'accent'`, `'success'`, `'warning'` or `'danger'`, listed in the exported `barChartTones`) colors its bar by what it means in place of its sign's default (the accent, or danger for a negative value), such as a diverging chart's overage in `'warning'` and shortage in `'danger'`; a toned bar keeps its sign's place, every tone keeps 3:1 against the track, and an unknown tone throws a `RangeError`. Forced colors draw every bar in the system text color, so the value and its side of zero carry the meaning there.
@@ -1,19 +1,23 @@
1
1
  import { type HTMLAttributes } from 'react';
2
- import { type TableLayout, type TableVerticalAlign } from './table/table-layout.js';
2
+ import { type TableLayout, type TableStickyHeader, type TableVerticalAlign } from './table/table-layout.js';
3
3
  export { TableCell, type TableCellProps, type TableColumnWidth, type TableSort, } from './table/TableCell.js';
4
4
  export { TableRow, type TableRowProps, type TableRowVariant, } from './table/TableRow.js';
5
5
  export type { TableCellTone } from '../css/css-table-ledger.js';
6
6
  export { tableCellTones, tableRowVariants } from '../css/css-table-ledger.js';
7
- export type { TableLayout, TableVerticalAlign };
7
+ export type { TableLayout, TableStickyHeader, TableVerticalAlign };
8
8
  export type TableDensity = 'comfortable' | 'compact';
9
9
  export type TableProps = HTMLAttributes<HTMLTableElement> & {
10
10
  density?: TableDensity;
11
11
  /**
12
12
  * Pins the header row to the top of the table's own scroll region
13
- * (default). In a table with a sticky `TableFooter` that fits its width
14
- * the region does not scroll, so the header pins to the page's top.
13
+ * (`true`, default). `'page'` pins it to the page's top while the page
14
+ * scrolls: while the table fits its width its region stops being a
15
+ * scroll box (under any sticky AppHeader, which covers it); a table
16
+ * wider than its region scrolls sideways in it and pins to the region.
17
+ * A table with a sticky `TableFooter` that fits its width pins its
18
+ * header to the page with `true` too. `false` lets it scroll away.
15
19
  */
16
- stickyHeader?: boolean;
20
+ stickyHeader?: TableStickyHeader;
17
21
  /**
18
22
  * `auto` (default) sizes each column by its content. `fixed` sizes the
19
23
  * columns from the header row's `width`s alone (`table-layout: fixed`),
@@ -42,10 +46,14 @@ export declare const Table: import("react").ForwardRefExoticComponent<HTMLAttrib
42
46
  density?: TableDensity;
43
47
  /**
44
48
  * Pins the header row to the top of the table's own scroll region
45
- * (default). In a table with a sticky `TableFooter` that fits its width
46
- * the region does not scroll, so the header pins to the page's top.
49
+ * (`true`, default). `'page'` pins it to the page's top while the page
50
+ * scrolls: while the table fits its width its region stops being a
51
+ * scroll box (under any sticky AppHeader, which covers it); a table
52
+ * wider than its region scrolls sideways in it and pins to the region.
53
+ * A table with a sticky `TableFooter` that fits its width pins its
54
+ * header to the page with `true` too. `false` lets it scroll away.
47
55
  */
48
- stickyHeader?: boolean;
56
+ stickyHeader?: TableStickyHeader;
49
57
  /**
50
58
  * `auto` (default) sizes each column by its content. `fixed` sizes the
51
59
  * columns from the header row's `width`s alone (`table-layout: fixed`),
@@ -2,15 +2,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { cx } from '../class-names.js';
4
4
  import { ScrollRegion } from './ScrollRegion.js';
5
- import { assertTableLayout, assertTableVerticalAlign, } from './table/table-layout.js';
5
+ import { assertTableLayout, assertTableStickyHeader, assertTableVerticalAlign, } from './table/table-layout.js';
6
6
  export { TableCell, } from './table/TableCell.js';
7
7
  export { TableRow, } from './table/TableRow.js';
8
8
  export { tableCellTones, tableRowVariants } from '../css/css-table-ledger.js';
9
9
  /** A wide table scrolls inside its own `ScrollRegion`, named after the table. */
10
10
  export const Table = forwardRef(function Table({ children, className, columnRules = false, density = 'comfortable', layout = 'auto', stickyHeader = true, verticalAlign = 'middle', ...rest }, ref) {
11
11
  assertTableLayout(layout);
12
+ assertTableStickyHeader(stickyHeader);
12
13
  assertTableVerticalAlign(verticalAlign);
13
- return (_jsx(ScrollRegion, { "aria-label": rest['aria-label'], "aria-labelledby": rest['aria-labelledby'], className: "sw-table-wrap", markFits: true, children: _jsx("table", { ref: ref, className: cx('sw-table', density === 'compact' && 'sw-table-compact', layout === 'fixed' && 'sw-table-fixed', stickyHeader && 'sw-table-sticky', verticalAlign === 'top' && 'sw-table-top', columnRules && 'sw-table-column-rules', className), ...rest, children: children }) }));
14
+ return (_jsx(ScrollRegion, { "aria-label": rest['aria-label'], "aria-labelledby": rest['aria-labelledby'], className: "sw-table-wrap", markFits: true, children: _jsx("table", { ref: ref, className: cx('sw-table', density === 'compact' && 'sw-table-compact', layout === 'fixed' && 'sw-table-fixed', stickyHeader !== false && 'sw-table-sticky', stickyHeader === 'page' && 'sw-table-sticky-page', verticalAlign === 'top' && 'sw-table-top', columnRules && 'sw-table-column-rules', className), ...rest, children: children }) }));
14
15
  });
15
16
  export const TableHeader = forwardRef(function TableHeader({ className, ...rest }, ref) {
16
17
  return _jsx("thead", { ref: ref, className: className, ...rest });
@@ -5,6 +5,12 @@ export type { TableColumnWidth };
5
5
  export type TableLayout = 'auto' | 'fixed';
6
6
  /** Where a cell's content sits in a row taller than it. */
7
7
  export type TableVerticalAlign = 'middle' | 'top';
8
+ /**
9
+ * Whether the header row pins: `true` to the top of the table's own scroll
10
+ * region, `'page'` to the page's top while the table fits its width.
11
+ */
12
+ export type TableStickyHeader = boolean | 'page';
13
+ export declare function assertTableStickyHeader(sticky: TableStickyHeader): void;
8
14
  export declare function assertTableLayout(layout: TableLayout): void;
9
15
  export declare function assertTableVerticalAlign(align: TableVerticalAlign): void;
10
16
  export declare function assertTableColumnWidth(width: TableColumnWidth | undefined): void;
@@ -1,5 +1,9 @@
1
1
  import { tableColumnWidths, } from '../../css/css-table-layout.js';
2
2
  export { tableColumnWidthClass } from '../../css/css-table-layout.js';
3
+ export function assertTableStickyHeader(sticky) {
4
+ if (typeof sticky !== 'boolean' && sticky !== 'page')
5
+ throw new RangeError(`Unknown Table stickyHeader: ${String(sticky)}`);
6
+ }
3
7
  export function assertTableLayout(layout) {
4
8
  if (layout !== 'auto' && layout !== 'fixed')
5
9
  throw new RangeError(`Unknown Table layout: ${String(layout)}`);
@@ -10,12 +10,8 @@ import { zIndex } from './stacking.js';
10
10
  * (solid surface under reduced transparency, the system canvas in forced
11
11
  * colours, as the pinned header cells), on the `stickyFooter` layer: over
12
12
  * the cells and the pinned header cells, under the ActionBar, which covers
13
- * it, so a page does not pair the two. A table's region is a scroll box,
14
- * which would pin it to the region's own bottom; while the table fits its
15
- * width (`sw-scroll-fits`) a region that holds a sticky footer stops being
16
- * one, so the footer pins to the page's bottom and the sticky header to
17
- * its top, under any sticky top chrome (an AppHeader covers it). A table
18
- * wider than its region scrolls sideways in it and pins to the region.
13
+ * it, so a page does not pair the two. Where it pins (the page or the
14
+ * table's own region) is `css-table-page-pin.ts`.
19
15
  */
20
16
  export function cssTableFooterClasses() {
21
17
  return `.sw-table tfoot :is(th, td) {
@@ -42,10 +38,6 @@ export function cssTableFooterClasses() {
42
38
  ${zIndex('stickyFooter')}
43
39
  }
44
40
 
45
- .sw-table-wrap.sw-scroll-fits:has(> .sw-table > .sw-table-footer-sticky) {
46
- overflow: visible;
47
- }
48
-
49
41
  @media (forced-colors: active) {
50
42
  .sw-table tfoot > tr:first-child > :is(th, td)::before { border-color: CanvasText; }
51
43
  .sw-table .sw-table-footer-sticky :is(th, td),
@@ -53,5 +45,5 @@ export function cssTableFooterClasses() {
53
45
  }`;
54
46
  }
55
47
  export function tableFooterClassCatalog() {
56
- return ['sw-table-footer-sticky', 'sw-scroll-fits'];
48
+ return ['sw-table-footer-sticky'];
57
49
  }
@@ -0,0 +1,2 @@
1
+ export declare function cssTablePagePinClasses(): string;
2
+ export declare function tablePagePinClassCatalog(): string[];
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Where a table's pinned rows pin. A table's region is a scroll box (it
3
+ * scrolls a wide table sideways), and a sticky cell pins to its nearest
4
+ * scroll box: the region, which never scrolls vertically, so on a page
5
+ * that scrolls nothing would stay in view. While the table fits its width
6
+ * (`sw-scroll-fits`, set once the region is measured) a region that holds
7
+ * a sticky footer, or a table whose header pins to the page
8
+ * (`stickyHeader="page"`, `sw-table-sticky-page`), stops being a scroll
9
+ * box, so the footer pins to the page's bottom edge and the sticky header
10
+ * to its top, under any sticky top chrome (an AppHeader covers it). A
11
+ * table wider than its region scrolls sideways in it and pins to the
12
+ * region instead.
13
+ */
14
+ export function cssTablePagePinClasses() {
15
+ return `.sw-table-wrap.sw-scroll-fits:has(> .sw-table > .sw-table-footer-sticky),
16
+ .sw-table-wrap.sw-scroll-fits:has(> .sw-table-sticky-page) {
17
+ overflow: visible;
18
+ }`;
19
+ }
20
+ export function tablePagePinClassCatalog() {
21
+ return ['sw-scroll-fits', 'sw-table-sticky-page'];
22
+ }
@@ -3,6 +3,7 @@ import { scrollRegionRules } from './css-scroll-region.js';
3
3
  import { cssTableLayoutClasses, tableLayoutClassCatalog, } from './css-table-layout.js';
4
4
  import { cssTableLedgerClasses, tableLedgerClassCatalog, } from './css-table-ledger.js';
5
5
  import { cssTableFooterClasses, tableFooterClassCatalog, } from './css-table-footer.js';
6
+ import { cssTablePagePinClasses, tablePagePinClassCatalog, } from './css-table-page-pin.js';
6
7
  import { cssTablePressClasses, tablePressClassCatalog, } from './css-table-press.js';
7
8
  import { cssTableSortClasses, tableSortClassCatalog, } from './css-table-sort.js';
8
9
  import { zIndex } from './stacking.js';
@@ -96,6 +97,8 @@ ${cssTableLedgerClasses()}
96
97
 
97
98
  ${cssTableFooterClasses()}
98
99
 
100
+ ${cssTablePagePinClasses()}
101
+
99
102
  ${cssTablePressClasses()}
100
103
 
101
104
  ${selectedRowRules()}`;
@@ -114,6 +117,7 @@ export function tableClassCatalog() {
114
117
  ...tableSortClassCatalog(),
115
118
  ...tableLedgerClassCatalog(),
116
119
  ...tableFooterClassCatalog(),
120
+ ...tablePagePinClassCatalog(),
117
121
  ...tablePressClassCatalog(),
118
122
  ];
119
123
  }
package/dist/index.d.ts CHANGED
@@ -42,7 +42,7 @@ export { Select } from './components/Select.js';
42
42
  export type { SelectAction, SelectOption, SelectProps, SelectWidth, } from './components/Select.js';
43
43
  export { MultiSelect, type MultiSelectAlign, type MultiSelectOption, type MultiSelectProps, } from './components/MultiSelect.js';
44
44
  export { Stack, type Align, type Justify, type StackProps, } from './components/Stack.js';
45
- export { Table, TableBody, TableCell, TableFooter, TableHeader, TableRow, tableCellTones, tableRowVariants, type TableBodyProps, type TableCellProps, type TableCellTone, type TableColumnWidth, type TableDensity, type TableFooterProps, type TableHeaderProps, type TableLayout, type TableProps, type TableRowProps, type TableRowVariant, type TableSort, type TableVerticalAlign, } from './components/Table.js';
45
+ export { Table, TableBody, TableCell, TableFooter, TableHeader, TableRow, tableCellTones, tableRowVariants, type TableBodyProps, type TableCellProps, type TableCellTone, type TableColumnWidth, type TableDensity, type TableFooterProps, type TableHeaderProps, type TableLayout, type TableProps, type TableRowProps, type TableRowVariant, type TableSort, type TableStickyHeader, type TableVerticalAlign, } from './components/Table.js';
46
46
  export { Text, type TextAlign, type TextElement, type TextProps, } from './components/Text.js';
47
47
  export { ThemeProvider, useTheme, type ThemeProviderProps, } from './theme/ThemeProvider.js';
48
48
  export { utilityClassCatalog } from './css/stylesheet.js';
package/dist/styles.css CHANGED
@@ -1831,16 +1831,17 @@ body {
1831
1831
  z-index: 2;
1832
1832
  }
1833
1833
 
1834
- .sw-table-wrap.sw-scroll-fits:has(> .sw-table > .sw-table-footer-sticky) {
1835
- overflow: visible;
1836
- }
1837
-
1838
1834
  @media (forced-colors: active) {
1839
1835
  .sw-table tfoot > tr:first-child > :is(th, td)::before { border-color: CanvasText; }
1840
1836
  .sw-table .sw-table-footer-sticky :is(th, td),
1841
1837
  .sw-table-sticky thead th { background: Canvas; backdrop-filter: none; -webkit-backdrop-filter: none; }
1842
1838
  }
1843
1839
 
1840
+ .sw-table-wrap.sw-scroll-fits:has(> .sw-table > .sw-table-footer-sticky),
1841
+ .sw-table-wrap.sw-scroll-fits:has(> .sw-table-sticky-page) {
1842
+ overflow: visible;
1843
+ }
1844
+
1844
1845
  .sw-table-row-press {
1845
1846
  cursor: pointer;
1846
1847
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalewing/react",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "Scalewing DOM components and package-owned CSS utilities.",
5
5
  "type": "module",
6
6
  "license": "MIT",