@dloizides/ui-tables 1.15.0 → 1.16.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,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.16.0
4
+
5
+ **The responsive card-stack now reads as a proper mobile layout — and keeps every E2E hook.**
6
+
7
+ `DataTable` has always collapsed to a label:value card-stack below a breakpoint (`stackBreakpoint`),
8
+ but on a phone the multi-column tables it powers (e.g. the organizer Passes table) were still hard
9
+ to read, and the card-stack silently dropped test hooks a wide-viewport E2E suite relies on. This
10
+ release makes the card-stack the readable, self-explanatory mobile layout it was meant to be —
11
+ **with no change to the desktop grid and no broken selectors.**
12
+
13
+ ### What changed
14
+
15
+ | Area | Before | Now |
16
+ |---|---|---|
17
+ | **Default breakpoint** | `640` | `768` — the kit-wide narrow-viewport threshold, aligned with `@dloizides/ui-layout`'s `MENU_BREAKPOINT` (already the collapse point for the nav menu and tabs). `CARD_STACK_BREAKPOINT` is re-exported at the new value. |
18
+ | **Card line layout** | label LEFT, value RIGHT on one `space-between` row (cramped for long values / action buttons) | each column's header sits **ABOVE** its value, both left-aligned, so the value gets the full card width |
19
+ | **Per-cell test id `${row}-${colKey}`** | resolved **only** on the desktop grid | resolves in **BOTH** layouts (the card line carries the same id the desktop cell does) |
20
+ | **Head test id `ui-data-table-head`** | **absent** in card-stack mode | resolves in **BOTH** layouts via a hidden, a11y-inert carrier (`display: none`, `aria-hidden`) — E2E selectors survive at every width |
21
+
22
+ ### Backward compatibility
23
+
24
+ - **The desktop grid is byte-for-byte unchanged.** Opt out of the card-stack entirely, at every
25
+ width, with `stackBreakpoint={0}` (unchanged).
26
+ - A column's `render` node (badge, link, **action button**) renders identically in a card cell.
27
+ - Row / per-cell / head / detail-panel / select-checkbox test ids are all preserved; the only
28
+ net-new guarantee is that per-cell and head ids now ALSO resolve in the card-stack.
29
+ - The one observable difference for an existing consumer is cosmetic: tables between 640px and
30
+ 768px wide now show the card-stack (they showed the cramped desktop row before), and cards read
31
+ vertically rather than as a `space-between` row. Both are strict readability improvements — which
32
+ is what keeps this a MINOR bump.
33
+
34
+ All 272 tests pass (6 added for the both-layouts test-hook contract + the vertical card layout).
35
+
3
36
  ## 1.15.0
4
37
 
5
38
  **A re-fetch no longer blanks the grid — the server-paged paging defect.**
package/README.md CHANGED
@@ -226,10 +226,20 @@ const overrides: DataTableStyleOverrides = {
226
226
  | `Pager` | `PagerStyleOverrides` | `pager`, `pagerInfo`, `pagerNav`, `pagerRowsLabel`, `sizeGroup`, `control`, `controlText`, `sizePill`, `sizePillText` |
227
227
  | `FilterBar` | `FilterBarStyleOverrides` | `filters`, `filtersSpacer`, `results`, `filtersActions` |
228
228
 
229
- **Disabling the card-stack**: the label:value card-stack renders when `width < stackBreakpoint`,
230
- so `stackBreakpoint={0}` (never true) keeps the desktop grid at every width — the opt-out for a
231
- consumer whose table never had a card-stack. Omit `styleOverrides` entirely and every component
232
- renders exactly as it always has.
229
+ **The responsive card-stack** (default breakpoint `768`, aligned with `@dloizides/ui-layout`'s
230
+ `MENU_BREAKPOINT`): below `stackBreakpoint` each row collapses to a card where every column's
231
+ header sits **above** its value (left-aligned label:value pairs), so a narrow phone never crams a
232
+ multi-column table into a side-scrolling row. The desktop grid above the breakpoint is unchanged.
233
+
234
+ - **Test hooks survive both layouts.** The head test id (`ui-data-table-head`), the row test ids
235
+ (`${testID}-row-${key}`) and the **per-cell** test ids (`${testID}-row-${key}-${col.key}`) all
236
+ resolve in the card-stack exactly as they do on the desktop grid — so an E2E suite written
237
+ against the wide layout keeps working when a table goes card-stack on mobile. A column's `render`
238
+ node (badge, link, action button) renders identically in a card cell.
239
+ - **Disabling the card-stack**: it renders when `width < stackBreakpoint`, so `stackBreakpoint={0}`
240
+ (never true) keeps the desktop grid at every width — the opt-out for a table that never had one.
241
+
242
+ Omit `styleOverrides` entirely and every component renders exactly as it always has.
233
243
 
234
244
  Colours come entirely from `useUi().theme` (drive it with `@dloizides/design-tokens` via `tokensToUiTheme`), so the grid re-themes per tenant. Every component-authored string is routed through the UiProvider `t` — provide the `uiTables.*` keys (see `TABLE_I18N`) in your locale files; a caller may also pass already-translated `loadingLabel` / `emptyLabel` / `resultsLabel` directly.
235
245
 
package/dist/index.d.mts CHANGED
@@ -167,7 +167,9 @@ interface DataTableProps<T> {
167
167
  /** Empty text (already translated). Falls back to the kit's `empty` translation. */
168
168
  emptyLabel?: string;
169
169
  /**
170
- * Below this width (px) rows collapse to a label:value card. Default 640.
170
+ * Below this width (px) rows collapse to a stacked label:value card (each column's
171
+ * header sits above its value). Default 768 — the kit-wide narrow-viewport threshold,
172
+ * aligned with `@dloizides/ui-layout`'s `MENU_BREAKPOINT` (`CARD_STACK_BREAKPOINT`).
171
173
  *
172
174
  * **Opt out of the card-stack entirely with `stackBreakpoint={0}`**: the stack is
173
175
  * chosen by `width < stackBreakpoint`, which is never true for 0, so the desktop
@@ -362,8 +364,17 @@ declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange,
362
364
  * Keeps every literal (test ids, i18n keys, layout numbers) in one place so the
363
365
  * components hold no magic numbers and no ad-hoc strings.
364
366
  */
365
- /** Default breakpoint (px): below this a row collapses to a label:value card. */
366
- declare const CARD_STACK_BREAKPOINT = 640;
367
+ /**
368
+ * Default breakpoint (px): below this a row collapses to a label:value card.
369
+ *
370
+ * Aligned with `@dloizides/ui-layout`'s `MENU_BREAKPOINT` (768) — the kit's single
371
+ * "this is a phone / narrow tablet" threshold, already the collapse point for the nav
372
+ * menu (`ModalDropdown`) and the tabs bar (`TABS_COLLAPSE_BREAKPOINT`). Kept as a plain
373
+ * literal rather than an import so a table has no runtime dependency on the layout kit
374
+ * for one number; the value is what is shared, and it is documented here as such. A table
375
+ * that never wants the card-stack still opts out with `stackBreakpoint={0}`.
376
+ */
377
+ declare const CARD_STACK_BREAKPOINT = 768;
367
378
  /** Default rows-per-page choices, matching the vanilla console's GRID.md pager. */
368
379
  declare const DEFAULT_PAGE_SIZE_OPTIONS: readonly number[];
369
380
  /** Stable test ids so consumers/e2e can target the shared chrome. */
package/dist/index.d.ts CHANGED
@@ -167,7 +167,9 @@ interface DataTableProps<T> {
167
167
  /** Empty text (already translated). Falls back to the kit's `empty` translation. */
168
168
  emptyLabel?: string;
169
169
  /**
170
- * Below this width (px) rows collapse to a label:value card. Default 640.
170
+ * Below this width (px) rows collapse to a stacked label:value card (each column's
171
+ * header sits above its value). Default 768 — the kit-wide narrow-viewport threshold,
172
+ * aligned with `@dloizides/ui-layout`'s `MENU_BREAKPOINT` (`CARD_STACK_BREAKPOINT`).
171
173
  *
172
174
  * **Opt out of the card-stack entirely with `stackBreakpoint={0}`**: the stack is
173
175
  * chosen by `width < stackBreakpoint`, which is never true for 0, so the desktop
@@ -362,8 +364,17 @@ declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange,
362
364
  * Keeps every literal (test ids, i18n keys, layout numbers) in one place so the
363
365
  * components hold no magic numbers and no ad-hoc strings.
364
366
  */
365
- /** Default breakpoint (px): below this a row collapses to a label:value card. */
366
- declare const CARD_STACK_BREAKPOINT = 640;
367
+ /**
368
+ * Default breakpoint (px): below this a row collapses to a label:value card.
369
+ *
370
+ * Aligned with `@dloizides/ui-layout`'s `MENU_BREAKPOINT` (768) — the kit's single
371
+ * "this is a phone / narrow tablet" threshold, already the collapse point for the nav
372
+ * menu (`ModalDropdown`) and the tabs bar (`TABS_COLLAPSE_BREAKPOINT`). Kept as a plain
373
+ * literal rather than an import so a table has no runtime dependency on the layout kit
374
+ * for one number; the value is what is shared, and it is documented here as such. A table
375
+ * that never wants the card-stack still opts out with `stackBreakpoint={0}`.
376
+ */
377
+ declare const CARD_STACK_BREAKPOINT = 768;
367
378
  /** Default rows-per-page choices, matching the vanilla console's GRID.md pager. */
368
379
  declare const DEFAULT_PAGE_SIZE_OPTIONS: readonly number[];
369
380
  /** Stable test ids so consumers/e2e can target the shared chrome. */
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var uiForms = require('@dloizides/ui-forms');
10
10
  // src/StatCard/StatCard.tsx
11
11
 
12
12
  // src/DataTable/constants.ts
13
- var CARD_STACK_BREAKPOINT = 640;
13
+ var CARD_STACK_BREAKPOINT = 768;
14
14
  var DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100, 200];
15
15
  var TABLE_TEST_IDS = {
16
16
  root: "ui-data-table",
@@ -150,8 +150,8 @@ var STATE_PAD_V = 34;
150
150
  var HEAD_FONT = 12;
151
151
  var CELL_FONT = 14;
152
152
  var STATE_FONT = 14;
153
- var CARD_LINE_PAD_V = 3;
154
- var CARD_LINE_GAP = 12;
153
+ var CARD_LINE_PAD_V = 5;
154
+ var CARD_LABEL_GAP = 3;
155
155
  var PILL_RADIUS = 999;
156
156
  var PAGER_GAP = 8;
157
157
  var PAGER_SIZE_GAP = 6;
@@ -205,9 +205,22 @@ var tableStyles = reactNative.StyleSheet.create({
205
205
  /** Full-width panel under an expanded row — spans every column (the wrap is a column flexbox). */
206
206
  rowDetail: { width: FULL_WIDTH, paddingHorizontal: ROW_PAD_H, paddingVertical: ROW_PAD_V, borderTopWidth: BORDER_WIDTH },
207
207
  card: { paddingHorizontal: ROW_PAD_H, paddingVertical: ROW_PAD_V, borderTopWidth: BORDER_WIDTH },
208
- cardLine: { flexDirection: "row", justifyContent: "space-between", alignItems: "baseline", paddingVertical: CARD_LINE_PAD_V, gap: CARD_LINE_GAP },
208
+ /**
209
+ * A card line is a VERTICAL label:value pair — the header sits ABOVE its value, both
210
+ * left-aligned, so a narrow phone column never cramps the value against the label the
211
+ * way the old `space-between` row did (an Actions cell of buttons or a long text value
212
+ * now gets the full card width). `paddingVertical` gives the stacked lines their rhythm.
213
+ */
214
+ cardLine: { flexDirection: "column", alignItems: "stretch", paddingVertical: CARD_LINE_PAD_V, gap: CARD_LABEL_GAP },
209
215
  cardLabel: { fontSize: HEAD_FONT, fontWeight: "600", textTransform: "uppercase", letterSpacing: LABEL_LETTER_SPACING },
210
- cardValue: { flexShrink: 1, alignItems: "flex-end" }
216
+ cardValue: { alignItems: "flex-start" },
217
+ /**
218
+ * A zero-footprint carrier for the `ui-data-table-head` test id in the card-stack layout
219
+ * (which has no visible header row). `display: 'none'` keeps it out of layout AND the
220
+ * accessibility tree, while the `data-testid` stays queryable — so an E2E selector that
221
+ * targets the head survives at every viewport width.
222
+ */
223
+ headSentinel: { display: "none" }
211
224
  });
212
225
  var selectionStyles = reactNative.StyleSheet.create({
213
226
  /** The fixed-width gutter holding the checkbox, in both the header and every row. */
@@ -314,10 +327,15 @@ function RowCells({
314
327
  styleOverrides: o
315
328
  }) {
316
329
  if (stacked) {
317
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [tableStyles.cardLine, o?.cardLine], children: [
318
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [tableStyles.cardLabel, { color: labelColor }, o?.cardLabel], children: col.header }),
319
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [tableStyles.cardValue, o?.cardValue], children: cellContent(col, row, textColor, o) })
320
- ] }, col.key)) });
330
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map((col) => (
331
+ // The SAME per-cell test id the desktop cell carries (`${rowTestID}-${col.key}`),
332
+ // so an E2E selector like `${rowTestID}-${col.key}` resolves in BOTH layouts — the
333
+ // card-stack must not silently drop the hooks a wide-viewport test relies on.
334
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [tableStyles.cardLine, o?.cardLine], testID: `${rowTestID2}-${col.key}`, children: [
335
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [tableStyles.cardLabel, { color: labelColor }, o?.cardLabel], children: col.header }),
336
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [tableStyles.cardValue, o?.cardValue], children: cellContent(col, row, textColor, o) })
337
+ ] }, col.key)
338
+ )) });
321
339
  }
322
340
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
323
341
  DesktopCell,
@@ -901,6 +919,7 @@ function DataTable(props) {
901
919
  if (stacked) {
902
920
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [tableStyles.wrap, frame, o?.wrap], testID, "aria-busy": loading, children: [
903
921
  banner,
922
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: tableStyles.headSentinel, testID: TABLE_TEST_IDS.head, "aria-hidden": true }),
904
923
  rows.map((row, i) => {
905
924
  const key = rowKeys[i] ?? keyExtractor(row);
906
925
  const bg = rowBg(row, i, key);