@multiplatform.one/table 7.47.4 → 7.48.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/dist/cjs/components/ChildTable/index.native.js +1 -1
- package/dist/cjs/components/ChildTable/index.native.js.map +1 -1
- package/dist/cjs/components/ColumnHeaderFilter/index.native.js +1 -1
- package/dist/cjs/components/ColumnHeaderFilter/index.native.js.map +1 -1
- package/dist/cjs/components/DataTable/CellContent.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableCardControls.native.js +1 -1
- package/dist/cjs/components/DataTable/DataTableCardControls.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableContext.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableInfiniteTail.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableMobileCards.cjs +9 -19
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js +9 -19
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableRoot.cjs +17 -5
- package/dist/cjs/components/DataTable/DataTableRoot.native.js +24 -12
- package/dist/cjs/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableStateContext.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableVirtualized.native.js.map +1 -1
- package/dist/cjs/components/DataTable/NativeInfiniteSentinel.native.js.map +1 -1
- package/dist/cjs/components/DataTable/dataTableChrome.native.js.map +1 -1
- package/dist/cjs/components/DataTable/documentListSlots.native.js.map +1 -1
- package/dist/cjs/components/DataTable/index.native.js +10 -11
- package/dist/cjs/components/DataTable/index.native.js.map +1 -1
- package/dist/cjs/components/DataTable/rowStateChrome.native.js.map +1 -1
- package/dist/cjs/components/DataTableBulkActions/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableCell/CellOptionsEditor.native.js.map +1 -1
- package/dist/cjs/components/DataTableCell/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableColumnPinning/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableDateFilter/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableExport/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFacetMenu/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilterButton/index.native.js +1 -1
- package/dist/cjs/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilterChips/FilterChip.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilterChips/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilters/index.native.js +2 -2
- package/dist/cjs/components/DataTableFilters/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableGrouping/index.native.js.map +1 -1
- package/dist/cjs/components/DataTablePagination/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableSearch/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableToolbar/index.native.js +2 -2
- package/dist/cjs/components/DataTableToolbar/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableViewOptions/index.native.js.map +1 -1
- package/dist/cjs/components/FilterManager.native.js.map +1 -1
- package/dist/cjs/components/FilterOperatorValueEditor/index.native.js.map +1 -1
- package/dist/cjs/components/KnobDialog.native.js.map +1 -1
- package/dist/cjs/components/SavedFilterDropdown.native.js.map +1 -1
- package/dist/cjs/components/SimpleTable/columnSizing.native.js.map +1 -1
- package/dist/cjs/components/SimpleTable/index.cjs +2 -17
- package/dist/cjs/components/SimpleTable/index.native.js +2 -17
- package/dist/cjs/components/SimpleTable/index.native.js.map +1 -1
- package/dist/cjs/components/TableInput/RowDetailEditor.native.js +1 -1
- package/dist/cjs/components/TableInput/index.native.js +1 -1
- package/dist/cjs/components/TableInput/shared.native.js.map +1 -1
- package/dist/cjs/hooks/useDataTable.native.js.map +1 -1
- package/dist/cjs/hooks/useDataTableKeyboard.native.js.map +1 -1
- package/dist/cjs/hooks/useDragScroll.native.js.map +1 -1
- package/dist/cjs/hooks/useInfiniteRows.cjs +2 -2
- package/dist/cjs/hooks/useInfiniteRows.native.js +4 -2
- package/dist/cjs/hooks/useInfiniteRows.native.js.map +1 -1
- package/dist/cjs/hooks/useSavedFilters.native.js.map +1 -1
- package/dist/cjs/hooks/useTableColumnPinning.native.js.map +1 -1
- package/dist/cjs/hooks/useTableFiltering.native.js.map +1 -1
- package/dist/cjs/hooks/useTableGrouping.native.js.map +1 -1
- package/dist/cjs/hooks/useTableKeyboard.native.js.map +1 -1
- package/dist/cjs/hooks/useTablePagination.native.js.map +1 -1
- package/dist/cjs/hooks/useTableSearch.native.js.map +1 -1
- package/dist/cjs/hooks/useTableSelection.native.js.map +1 -1
- package/dist/cjs/hooks/useTableSorting.native.js.map +1 -1
- package/dist/cjs/hooks/useTableUrlSync.native.js.map +1 -1
- package/dist/cjs/hooks/useTableViews.native.js.map +1 -1
- package/dist/cjs/index.native.js +20 -20
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/shared/devWarn.native.js.map +1 -1
- package/dist/cjs/shared/t.native.js.map +1 -1
- package/dist/cjs/shims/primitives.native.js.map +1 -1
- package/dist/cjs/shims/tableCellContext.native.js.map +1 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/utils/chromeIcons.native.js.map +1 -1
- package/dist/cjs/utils/columnAlign.native.js.map +1 -1
- package/dist/cjs/utils/filterFields.native.js.map +1 -1
- package/dist/cjs/utils/filterUtils.native.js.map +1 -1
- package/dist/cjs/utils/money.native.js.map +1 -1
- package/dist/cjs/utils/paginationDefaults.native.js.map +1 -1
- package/dist/cjs/utils/rowAccumulator.native.js.map +1 -1
- package/dist/cjs/utils/rowPress.native.js.map +1 -1
- package/dist/cjs/utils/urlStateUtils.native.js.map +1 -1
- package/dist/cjs/utils/viewData.native.js.map +1 -1
- package/dist/cjs/utils/withInterp.native.js.map +1 -1
- package/dist/esm/components/ChildTable/index.native.js.map +1 -1
- package/dist/esm/components/ColumnHeaderFilter/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/CellContent.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableCardControls.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableContext.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableInfiniteTail.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs +11 -21
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js +11 -21
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.mjs +17 -5
- package/dist/esm/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.native.js +17 -5
- package/dist/esm/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableStateContext.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableVirtualized.native.js.map +1 -1
- package/dist/esm/components/DataTable/NativeInfiniteSentinel.native.js.map +1 -1
- package/dist/esm/components/DataTable/dataTableChrome.native.js.map +1 -1
- package/dist/esm/components/DataTable/documentListSlots.native.js.map +1 -1
- package/dist/esm/components/DataTable/index.native.js +0 -1
- package/dist/esm/components/DataTable/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/rowStateChrome.native.js.map +1 -1
- package/dist/esm/components/DataTableBulkActions/index.native.js.map +1 -1
- package/dist/esm/components/DataTableCell/CellOptionsEditor.native.js.map +1 -1
- package/dist/esm/components/DataTableCell/index.native.js.map +1 -1
- package/dist/esm/components/DataTableColumnPinning/index.native.js.map +1 -1
- package/dist/esm/components/DataTableDateFilter/index.native.js.map +1 -1
- package/dist/esm/components/DataTableExport/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFacetMenu/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFilterChips/FilterChip.native.js.map +1 -1
- package/dist/esm/components/DataTableFilterChips/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFilters/index.native.js.map +1 -1
- package/dist/esm/components/DataTableGrouping/index.native.js.map +1 -1
- package/dist/esm/components/DataTablePagination/index.native.js.map +1 -1
- package/dist/esm/components/DataTableSearch/index.native.js.map +1 -1
- package/dist/esm/components/DataTableToolbar/index.native.js.map +1 -1
- package/dist/esm/components/DataTableViewOptions/index.native.js.map +1 -1
- package/dist/esm/components/FilterManager.native.js.map +1 -1
- package/dist/esm/components/FilterOperatorValueEditor/index.native.js.map +1 -1
- package/dist/esm/components/KnobDialog.native.js.map +1 -1
- package/dist/esm/components/SavedFilterDropdown.native.js.map +1 -1
- package/dist/esm/components/SimpleTable/columnSizing.native.js.map +1 -1
- package/dist/esm/components/SimpleTable/index.mjs +3 -18
- package/dist/esm/components/SimpleTable/index.mjs.map +1 -1
- package/dist/esm/components/SimpleTable/index.native.js +3 -18
- package/dist/esm/components/SimpleTable/index.native.js.map +1 -1
- package/dist/esm/components/TableInput/shared.native.js.map +1 -1
- package/dist/esm/hooks/useDataTable.native.js.map +1 -1
- package/dist/esm/hooks/useDataTableKeyboard.native.js.map +1 -1
- package/dist/esm/hooks/useDragScroll.native.js.map +1 -1
- package/dist/esm/hooks/useInfiniteRows.mjs +2 -2
- package/dist/esm/hooks/useInfiniteRows.mjs.map +1 -1
- package/dist/esm/hooks/useInfiniteRows.native.js +4 -2
- package/dist/esm/hooks/useInfiniteRows.native.js.map +1 -1
- package/dist/esm/hooks/useSavedFilters.native.js.map +1 -1
- package/dist/esm/hooks/useTableColumnPinning.native.js.map +1 -1
- package/dist/esm/hooks/useTableFiltering.native.js.map +1 -1
- package/dist/esm/hooks/useTableGrouping.native.js.map +1 -1
- package/dist/esm/hooks/useTableKeyboard.native.js.map +1 -1
- package/dist/esm/hooks/useTablePagination.native.js.map +1 -1
- package/dist/esm/hooks/useTableSearch.native.js.map +1 -1
- package/dist/esm/hooks/useTableSelection.native.js.map +1 -1
- package/dist/esm/hooks/useTableSorting.native.js.map +1 -1
- package/dist/esm/hooks/useTableUrlSync.native.js.map +1 -1
- package/dist/esm/hooks/useTableViews.native.js.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/shared/devWarn.native.js.map +1 -1
- package/dist/esm/shared/t.native.js.map +1 -1
- package/dist/esm/shims/primitives.native.js.map +1 -1
- package/dist/esm/shims/tableCellContext.native.js.map +1 -1
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/utils/chromeIcons.native.js.map +1 -1
- package/dist/esm/utils/columnAlign.native.js.map +1 -1
- package/dist/esm/utils/filterFields.native.js.map +1 -1
- package/dist/esm/utils/filterUtils.native.js.map +1 -1
- package/dist/esm/utils/money.native.js.map +1 -1
- package/dist/esm/utils/paginationDefaults.native.js.map +1 -1
- package/dist/esm/utils/rowAccumulator.native.js.map +1 -1
- package/dist/esm/utils/rowPress.native.js.map +1 -1
- package/dist/esm/utils/urlStateUtils.native.js.map +1 -1
- package/dist/esm/utils/viewData.native.js.map +1 -1
- package/dist/esm/utils/withInterp.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs +11 -21
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js +9 -19
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.mjs +17 -5
- package/dist/jsx/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.native.js +17 -5
- package/dist/jsx/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/jsx/components/DataTable/index.native.js +0 -1
- package/dist/jsx/components/DataTable/index.native.js.map +1 -1
- package/dist/jsx/components/SimpleTable/index.mjs +3 -18
- package/dist/jsx/components/SimpleTable/index.mjs.map +1 -1
- package/dist/jsx/components/SimpleTable/index.native.js +2 -17
- package/dist/jsx/components/SimpleTable/index.native.js.map +1 -1
- package/dist/jsx/hooks/useInfiniteRows.mjs +2 -2
- package/dist/jsx/hooks/useInfiniteRows.mjs.map +1 -1
- package/dist/jsx/hooks/useInfiniteRows.native.js +4 -2
- package/dist/jsx/hooks/useInfiniteRows.native.js.map +1 -1
- package/package.json +12 -12
- package/src/components/DataTable/DataTable.spec.tsx +1 -1
- package/src/components/DataTable/DataTable.stories.tsx +13 -12
- package/src/components/DataTable/DataTableMobileCards.tsx +18 -32
- package/src/components/DataTable/DataTableRoot.tsx +15 -5
- package/src/components/DataTable/columnWidthLayout.spec.tsx +10 -0
- package/src/components/DataTable/dataTableMobileCards.spec.tsx +9 -12
- package/src/components/DataTable/index.native.tsx +0 -1
- package/src/components/DataTable/infiniteMode.spec.tsx +25 -0
- package/src/components/DataTable/pinningGeometry.spec.tsx +10 -0
- package/src/components/DataTableBulkActions/DataTableBulkActions.spec.tsx +3 -3
- package/src/components/SimpleTable/index.tsx +4 -23
- package/src/components/SimpleTable/simpleTable.spec.tsx +3 -3
- package/src/components/phoneCardsDefault.spec.tsx +177 -0
- package/src/components/phoneTableBleed.spec.tsx +11 -4
- package/src/components/tableZebraDefault.spec.tsx +13 -6
- package/src/hooks/useInfiniteRows.ts +4 -2
- package/types/components/DataTable/DataTableMobileCards.d.ts +10 -8
- package/types/components/DataTable/DataTableMobileCards.d.ts.map +1 -1
- package/types/components/DataTable/DataTableRoot.d.ts.map +1 -1
- package/types/components/DataTable/index.native.d.ts.map +1 -1
- package/types/components/SimpleTable/index.d.ts.map +1 -1
- package/types/hooks/useInfiniteRows.d.ts.map +1 -1
|
@@ -13,27 +13,26 @@
|
|
|
13
13
|
* through the same cell renderers as the grid, inside `TableCellContext`
|
|
14
14
|
* so fields stay chromeless (useIsInTableCell).
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* gap
|
|
16
|
+
* Inside a panel the card is FLAT: no border, no elevation. The panel
|
|
17
|
+
* already has its own frame, and an outlined, shadowed card inside it reads
|
|
18
|
+
* as a box inside a box; the `cardSurface` fill (one step off the panel) and
|
|
19
|
+
* the gap separate one record from the next. On the page line that fill is
|
|
20
|
+
* the page's own, so the card takes the table card frame (border and
|
|
21
|
+
* elevation, as SimpleTable's and the Table primitive's cards do).
|
|
22
|
+
*
|
|
23
|
+
* A card is its own surface: it keeps the page gutter (LC-146 bleeds rows,
|
|
24
|
+
* not cards) and never stripes (LC-144 stripes rows, not cards).
|
|
20
25
|
*/
|
|
21
26
|
|
|
22
27
|
import { TrashIcon } from "@phosphor-icons/react";
|
|
23
28
|
import { EmptyState, Text } from "@multiplatform.one/components";
|
|
24
29
|
import { Button, Checkbox } from "@multiplatform.one/forms";
|
|
25
|
-
import { hairline,
|
|
30
|
+
import { hairline, usePageGutter, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
26
31
|
import type React from "react";
|
|
27
32
|
import { useCallback } from "react";
|
|
28
33
|
import { View, VisuallyHidden, XStack } from "tamagui";
|
|
29
34
|
import { useTranslation } from "react-i18next";
|
|
30
|
-
import {
|
|
31
|
-
TableCellContext,
|
|
32
|
-
phoneBleedListProps,
|
|
33
|
-
phoneBleedRowProps,
|
|
34
|
-
tablePressFill,
|
|
35
|
-
tableZebraFill,
|
|
36
|
-
} from "@multiplatform.one/table-primitives";
|
|
35
|
+
import { TableCellContext, tablePressFill } from "@multiplatform.one/table-primitives";
|
|
37
36
|
import type { DataTableColumn, DataTableField } from "../../types";
|
|
38
37
|
import { withInterp } from "../../utils/withInterp";
|
|
39
38
|
import { rowIntentProps } from "./dataTableChrome";
|
|
@@ -143,8 +142,6 @@ export interface DataTableMobileCardsProps<TData> {
|
|
|
143
142
|
getRowPressProps?: (row: any, rowIndex: number, variant?: "row" | "card") => Record<string, any>;
|
|
144
143
|
/** In-flight refetch: do not paint empty-state over a blank body. */
|
|
145
144
|
queryInFlight?: boolean;
|
|
146
|
-
/** LC-146: the list runs edge to edge and each card carries the gutter. */
|
|
147
|
-
bleed?: PhoneTableBleed | null;
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
@@ -165,11 +162,10 @@ export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
|
165
162
|
selectRowLabel,
|
|
166
163
|
getRowPressProps,
|
|
167
164
|
queryInFlight = false,
|
|
168
|
-
bleed = null,
|
|
169
165
|
}: DataTableMobileCardsProps<TData>) {
|
|
170
166
|
const { t } = useTranslation();
|
|
171
167
|
const { knobProps } = useResolvedKnobs({ component: "DataTable" });
|
|
172
|
-
const
|
|
168
|
+
const onPageLine = usePageGutter() !== null;
|
|
173
169
|
|
|
174
170
|
const renderCell = useCallback(
|
|
175
171
|
(cell: any, index: number, rowData: TData) => (
|
|
@@ -197,20 +193,17 @@ export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
|
197
193
|
else if (kind === "control") controls.push(cell);
|
|
198
194
|
}
|
|
199
195
|
const hasBody = bare.length > 0 || figures.length > 0 || controls.length > 0;
|
|
200
|
-
const
|
|
201
|
-
const restFill = tableZebraOn && index % 2 === 1 ? tableZebraFill(cardFill) : cardFill;
|
|
196
|
+
const restFill = knobProps.cardSurface.backgroundColor;
|
|
202
197
|
const pressProps = getRowPressProps?.(row, index, "card") ?? {};
|
|
203
198
|
|
|
204
199
|
return (
|
|
205
200
|
<View
|
|
206
201
|
key={`${row.id}-${index}`}
|
|
207
202
|
testID="data-table-card"
|
|
203
|
+
{...(onPageLine ? knobProps.surface : {})}
|
|
208
204
|
{...knobProps.cardSurface}
|
|
209
|
-
|
|
210
|
-
{...(
|
|
211
|
-
{...({
|
|
212
|
-
"data-table-zebra": tableZebraOn ? (index % 2 === 0 ? "even" : "odd") : "off",
|
|
213
|
-
} as any)}
|
|
205
|
+
{...(onPageLine ? { elevation: knobProps.elevation } : {})}
|
|
206
|
+
{...({ "data-table-zebra": "off" } as any)}
|
|
214
207
|
{...(pressProps as any)}
|
|
215
208
|
{...(pressProps.onPress
|
|
216
209
|
? { pressStyle: { backgroundColor: tablePressFill(restFill) } }
|
|
@@ -361,7 +354,7 @@ export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
|
361
354
|
renderCell,
|
|
362
355
|
onDeleteRow,
|
|
363
356
|
knobProps,
|
|
364
|
-
|
|
357
|
+
onPageLine,
|
|
365
358
|
t,
|
|
366
359
|
selectRowLabel,
|
|
367
360
|
getRowPressProps,
|
|
@@ -376,15 +369,9 @@ export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
|
376
369
|
// Roving-focus DOM scope for onRowPress arrow keys (LC-49) — keeps
|
|
377
370
|
// ArrowUp/Down/Home/End inside THIS table's card list.
|
|
378
371
|
{...(getRowPressProps ? ({ "data-row-press-scope": "true" } as any) : {})}
|
|
379
|
-
{...(bleed ? { ...phoneBleedListProps(bleed), "data-phone-bleed": "true" } : {})}
|
|
380
372
|
>
|
|
381
373
|
{enableRowSelection && tableRows.length > 0 && (
|
|
382
|
-
<XStack
|
|
383
|
-
alignItems="center"
|
|
384
|
-
gap="$2"
|
|
385
|
-
paddingBottom="$2"
|
|
386
|
-
{...(bleed ? { paddingHorizontal: bleed.inset } : {})}
|
|
387
|
-
>
|
|
374
|
+
<XStack alignItems="center" gap="$2" paddingBottom="$2">
|
|
388
375
|
<Checkbox
|
|
389
376
|
checked={selectAllIndeterminate ? "indeterminate" : selectAllChecked}
|
|
390
377
|
onChange={(checked) => {
|
|
@@ -406,7 +393,6 @@ export function DataTableMobileCards<TData extends Record<string, any>>({
|
|
|
406
393
|
size="$3"
|
|
407
394
|
backgroundColor="$color1"
|
|
408
395
|
{...knobProps.borderRadius}
|
|
409
|
-
{...(bleed ? { marginHorizontal: bleed.inset } : {})}
|
|
410
396
|
aria-live="polite"
|
|
411
397
|
title={hasActiveFilters ? t("No results found") : t("No data available")}
|
|
412
398
|
/>
|
|
@@ -199,6 +199,9 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
199
199
|
// pinned via the `layout` prop. Same table state drives both layouts.
|
|
200
200
|
const showList = layout === "list";
|
|
201
201
|
const showCards = !showList && (layout === "cards" || (layout === "auto" && sm === false));
|
|
202
|
+
// Rows on a phone (an explicit `layout="table"`) are the desktop table:
|
|
203
|
+
// every column keeps its own width and the grid scrolls sideways.
|
|
204
|
+
const phoneRows = !showList && !showCards && sm === false;
|
|
202
205
|
const intent = resolveDataTableIntent({ accent, error, warning, success });
|
|
203
206
|
// `size` is a token: the toolbar, search, pagination, header filters and
|
|
204
207
|
// bulk bar render at it through the Surface below; cells one key below.
|
|
@@ -354,7 +357,9 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
354
357
|
flexBasis: "auto" as const,
|
|
355
358
|
};
|
|
356
359
|
}
|
|
357
|
-
if (columnLayout === "equal" && !enableColumnResizing)
|
|
360
|
+
if (columnLayout === "equal" && !enableColumnResizing) {
|
|
361
|
+
return phoneRows ? { width: col.getSize() } : {};
|
|
362
|
+
}
|
|
358
363
|
// Scroll layout needs one concrete width per column (from the column
|
|
359
364
|
// def, TanStack default otherwise) so independent flex rows stay
|
|
360
365
|
// aligned while the table grows past its container.
|
|
@@ -363,7 +368,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
363
368
|
}
|
|
364
369
|
return {};
|
|
365
370
|
},
|
|
366
|
-
[enableColumnResizing, columnLayout, enableColumnPinning],
|
|
371
|
+
[enableColumnResizing, columnLayout, enableColumnPinning, phoneRows],
|
|
367
372
|
);
|
|
368
373
|
|
|
369
374
|
// HTML5 column drag-and-drop (web only). Reorder swaps the dragged column
|
|
@@ -469,7 +474,8 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
469
474
|
// must be overridden to overflow:visible — otherwise the body scrolls on
|
|
470
475
|
// its own while the header stays put and pinned cells stick to the wrong
|
|
471
476
|
// scrollport (the LTR pinning breakage).
|
|
472
|
-
const hScroll =
|
|
477
|
+
const hScroll =
|
|
478
|
+
isWeb && (phoneRows || (isFlexLayout && (columnLayout === "scroll" || enableColumnPinning)));
|
|
473
479
|
// In the horizontal-overflow modes, body cell content is clipped to the
|
|
474
480
|
// cell box: flex-mode cells default to overflow:visible, so overlong text
|
|
475
481
|
// paints over neighbor cells and bleeds out from under sticky pinned
|
|
@@ -490,8 +496,13 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
490
496
|
if (enableColumnResizing) {
|
|
491
497
|
return { flexGrow: 0, flexShrink: 0, flexBasis: "auto" as const, minWidth: 0 };
|
|
492
498
|
}
|
|
499
|
+
// Phone rows: the column's width is the floor and a wide screen's spare
|
|
500
|
+
// room is shared out, so the grid overflows into the sideways scroll.
|
|
501
|
+
if (phoneRows) {
|
|
502
|
+
return { flexGrow: 1, flexShrink: 0, flexBasis: "auto" as const, minWidth: 0 };
|
|
503
|
+
}
|
|
493
504
|
return { flex: 1, flexShrink: 1, flexGrow: 1, flexBasis: 0, minWidth: 0 };
|
|
494
|
-
}, [isFlexLayout, columnLayout, enableColumnResizing]);
|
|
505
|
+
}, [isFlexLayout, columnLayout, enableColumnResizing, phoneRows]);
|
|
495
506
|
|
|
496
507
|
// Columns offered by the card-layout filter builder (grid mode filters
|
|
497
508
|
// through ColumnHeaderFilter in the headers instead).
|
|
@@ -1409,7 +1420,6 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1409
1420
|
onToggleSelectAll={toggleSelectAll}
|
|
1410
1421
|
selectRowLabel={deriveSelectRowLabel}
|
|
1411
1422
|
queryInFlight={queryInFlight}
|
|
1412
|
-
bleed={bleed}
|
|
1413
1423
|
{...(rowPressActive ? { getRowPressProps } : {})}
|
|
1414
1424
|
/>
|
|
1415
1425
|
</>
|
|
@@ -18,6 +18,16 @@ import type { DataTableColumn } from "../../types";
|
|
|
18
18
|
import { __resetTableDevWarnSeen, warnColumnWidthIgnored } from "../../shared/devWarn";
|
|
19
19
|
import { DataTable } from "./index";
|
|
20
20
|
|
|
21
|
+
// A wide screen: below `$sm` an explicit rows table keeps each column's width
|
|
22
|
+
// and scrolls sideways (FZ-7816), which is not the geometry under test here.
|
|
23
|
+
vi.mock("tamagui", async (importOriginal) => {
|
|
24
|
+
const actual = await importOriginal<typeof import("tamagui")>();
|
|
25
|
+
return {
|
|
26
|
+
...actual,
|
|
27
|
+
useMedia: (...args: any[]) => ({ ...(actual.useMedia as any)(...args), sm: true }),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
21
31
|
vi.mock("@tanstack/react-virtual", async (importOriginal) => {
|
|
22
32
|
const actual = await importOriginal<typeof import("@tanstack/react-virtual")>();
|
|
23
33
|
return {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
18
18
|
import { Preset } from "@multiplatform.one/theme";
|
|
19
|
-
import { fireEvent, screen, waitFor, within } from "@testing-library/react";
|
|
19
|
+
import { cleanup, fireEvent, screen, waitFor, within } from "@testing-library/react";
|
|
20
20
|
import { Theme } from "tamagui";
|
|
21
21
|
import { describe, expect, it, vi } from "vitest";
|
|
22
22
|
import type React from "react";
|
|
@@ -198,7 +198,7 @@ describe("DataTableMobileCards", () => {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
describe("
|
|
201
|
+
describe("a card never stripes, with tableZebra on (FZ-7816, was MPO-401)", () => {
|
|
202
202
|
function cardFills(scheme: "light" | "dark") {
|
|
203
203
|
const ui = (
|
|
204
204
|
<Preset overrides={{ tableZebra: "on" }}>
|
|
@@ -213,14 +213,11 @@ describe("DataTableMobileCards", () => {
|
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
it("
|
|
217
|
-
const [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
it("keeps light on $background and $color3", () => {
|
|
223
|
-
expect(cardFills("light").slice(0, 2)).toEqual([["_bg-background"], ["_bg-color3"]]);
|
|
216
|
+
it("keeps every card on $background, light and dark", () => {
|
|
217
|
+
for (const scheme of ["light", "dark"] as const) {
|
|
218
|
+
expect(cardFills(scheme).slice(0, 2)).toEqual([["_bg-background"], ["_bg-background"]]);
|
|
219
|
+
cleanup();
|
|
220
|
+
}
|
|
224
221
|
});
|
|
225
222
|
});
|
|
226
223
|
|
|
@@ -295,7 +292,7 @@ describe("DataTableMobileCards", () => {
|
|
|
295
292
|
elevations.flatMap((elevation) =>
|
|
296
293
|
zebras.map((zebra) => [
|
|
297
294
|
`${scheme} ${elevation} zebra-${zebra}`,
|
|
298
|
-
["background>color4",
|
|
295
|
+
["background>color4", "background>color4"],
|
|
299
296
|
]),
|
|
300
297
|
),
|
|
301
298
|
),
|
|
@@ -341,7 +338,7 @@ describe("DataTableMobileCards", () => {
|
|
|
341
338
|
);
|
|
342
339
|
expect(cards(container).slice(0, 2).map(paint)).toEqual([
|
|
343
340
|
"background>color4",
|
|
344
|
-
"
|
|
341
|
+
"background>color4",
|
|
345
342
|
]);
|
|
346
343
|
});
|
|
347
344
|
});
|
|
@@ -855,7 +855,6 @@ function DataTableRoot<TData extends Record<string, any> = Record<string, any>>(
|
|
|
855
855
|
onToggleSelectAll={toggleSelectAll}
|
|
856
856
|
selectRowLabel={deriveSelectRowLabel}
|
|
857
857
|
queryInFlight={queryInFlight}
|
|
858
|
-
bleed={bleed}
|
|
859
858
|
{...(rowPressActive ? { getRowPressProps } : {})}
|
|
860
859
|
/>
|
|
861
860
|
</Surface>
|
|
@@ -117,6 +117,28 @@ describe("DataTable paginationMode", () => {
|
|
|
117
117
|
expect(loader.mock.calls.map(([q]) => q.pageIndex)).toEqual([0]);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
it("loader mode's first paint is loading, never the empty state", () => {
|
|
121
|
+
const observer = new MutationObserver(() => {});
|
|
122
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
123
|
+
const pending = vi.fn((_q: PageLoadQuery) => new Promise<PageLoadResult<Row>>(() => {}));
|
|
124
|
+
const { container } = renderWithProviders(
|
|
125
|
+
<DataTable
|
|
126
|
+
data={[]}
|
|
127
|
+
columns={columns}
|
|
128
|
+
readOnly
|
|
129
|
+
paginationMode="infinite"
|
|
130
|
+
loadPage={pending}
|
|
131
|
+
initialState={{ pagination: { pageIndex: 0, pageSize: 10 } }}
|
|
132
|
+
/>,
|
|
133
|
+
);
|
|
134
|
+
const painted = observer
|
|
135
|
+
.takeRecords()
|
|
136
|
+
.flatMap((record) => [...Array.from(record.addedNodes), ...Array.from(record.removedNodes)]);
|
|
137
|
+
observer.disconnect();
|
|
138
|
+
expect(painted.some((node) => node.textContent?.includes("No data available"))).toBe(false);
|
|
139
|
+
expect(container.querySelector('[aria-busy="true"]')).not.toBeNull();
|
|
140
|
+
});
|
|
141
|
+
|
|
120
142
|
// MPO-485 / LC-84 DG-ST-01: empty is not error is not loading.
|
|
121
143
|
describe("loader failures", () => {
|
|
122
144
|
afterEach(() => {
|
|
@@ -192,6 +214,9 @@ describe("DataTable paginationMode", () => {
|
|
|
192
214
|
/>,
|
|
193
215
|
);
|
|
194
216
|
|
|
217
|
+
// Two transitions, awaited one at a time: page 0's rows land, then the
|
|
218
|
+
// sentinel's append (the failed prefetch is retried) fails into the tail.
|
|
219
|
+
await waitFor(() => expect(screen.getByText("Row 10")).toBeDefined());
|
|
195
220
|
await waitFor(() => expect(screen.getByText("Row read refused")).toBeDefined());
|
|
196
221
|
expect(screen.getByText("Row 1")).toBeDefined();
|
|
197
222
|
expect(screen.getByText("Row 10")).toBeDefined();
|
|
@@ -20,6 +20,16 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
20
20
|
import type { DataTableColumn } from "../../types";
|
|
21
21
|
import { DataTable } from "./index";
|
|
22
22
|
|
|
23
|
+
// A wide screen: below `$sm` an explicit rows table keeps each column's width
|
|
24
|
+
// and scrolls sideways (FZ-7816), which is not the geometry under test here.
|
|
25
|
+
vi.mock("tamagui", async (importOriginal) => {
|
|
26
|
+
const actual = await importOriginal<typeof import("tamagui")>();
|
|
27
|
+
return {
|
|
28
|
+
...actual,
|
|
29
|
+
useMedia: (...args: any[]) => ({ ...(actual.useMedia as any)(...args), sm: true }),
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
23
33
|
type Person = { id: number; firstName: string; lastName: string; age: number };
|
|
24
34
|
|
|
25
35
|
const sampleData: Person[] = [
|
|
@@ -309,9 +309,9 @@ describe("DataTableBulkActions", () => {
|
|
|
309
309
|
);
|
|
310
310
|
|
|
311
311
|
fireEvent.click(screen.getByText("Export"));
|
|
312
|
-
// Button switches to the loading affordance:
|
|
313
|
-
//
|
|
314
|
-
expect(screen.
|
|
312
|
+
// Button switches to the loading affordance: the spinner sits beside the
|
|
313
|
+
// label (FZ-7812) and the control reads disabled while executing.
|
|
314
|
+
expect(screen.getByText("Export").closest("[aria-busy]")).toBeTruthy();
|
|
315
315
|
expect(document.querySelector('[aria-disabled="true"]')).toBeTruthy();
|
|
316
316
|
});
|
|
317
317
|
|
|
@@ -26,12 +26,7 @@ import { resolveSimpleTableColumns, type SimpleTableColumn } from "./columnSizin
|
|
|
26
26
|
import { PinnedCell, ScrollFrame } from "./ScrollFrame";
|
|
27
27
|
export type { SimpleTableColumn, SimpleTableSizeToken } from "./columnSizing";
|
|
28
28
|
export { resolveSimpleTableColumns } from "./columnSizing";
|
|
29
|
-
import {
|
|
30
|
-
Table,
|
|
31
|
-
phoneBleedListProps,
|
|
32
|
-
phoneBleedRowProps,
|
|
33
|
-
tableZebraFill,
|
|
34
|
-
} from "@multiplatform.one/table-primitives";
|
|
29
|
+
import { Table, tableZebraFill } from "@multiplatform.one/table-primitives";
|
|
35
30
|
import type { DataTableLayout } from "../../types";
|
|
36
31
|
import { isInteractiveInnerTarget } from "../../utils/rowPress";
|
|
37
32
|
import { withInterp } from "../../utils/withInterp";
|
|
@@ -334,9 +329,6 @@ function SimpleTableMobileCards({
|
|
|
334
329
|
rowLabel,
|
|
335
330
|
disabled,
|
|
336
331
|
});
|
|
337
|
-
const tableZebraOn = knobProps.tableZebra === "on";
|
|
338
|
-
// LC-146: on the page line below `$sm` the cards run edge to edge.
|
|
339
|
-
const bleed = usePhoneTableBleed();
|
|
340
332
|
const [titleCol, ...detailCols] = columns;
|
|
341
333
|
const typeSize = knobProps.label.fontSize;
|
|
342
334
|
const motion = transitionProps(knobProps.motion.control);
|
|
@@ -363,14 +355,9 @@ function SimpleTableMobileCards({
|
|
|
363
355
|
flexDirection="column"
|
|
364
356
|
{...knobProps.gap}
|
|
365
357
|
{...(rowPressActive ? ({ "data-row-press-scope": "true" } as any) : {})}
|
|
366
|
-
{...(bleed ? { ...phoneBleedListProps(bleed), "data-phone-bleed": "true" } : {})}
|
|
367
358
|
>
|
|
368
359
|
{caption ? (
|
|
369
|
-
<Text
|
|
370
|
-
{...knobProps.label}
|
|
371
|
-
color={knobProps.textAccentColor}
|
|
372
|
-
{...(bleed ? { paddingHorizontal: bleed.inset } : {})}
|
|
373
|
-
>
|
|
360
|
+
<Text {...knobProps.label} color={knobProps.textAccentColor}>
|
|
374
361
|
{caption}
|
|
375
362
|
</Text>
|
|
376
363
|
) : null}
|
|
@@ -387,18 +374,12 @@ function SimpleTableMobileCards({
|
|
|
387
374
|
testID="simple-table-card"
|
|
388
375
|
{...knobProps.surface}
|
|
389
376
|
{...knobProps.cardSurface}
|
|
390
|
-
{
|
|
391
|
-
{...(tableZebraOn && rowIndex % 2 === 1
|
|
392
|
-
? { backgroundColor: tableZebraFill(knobProps.cardSurface.backgroundColor) }
|
|
393
|
-
: {})}
|
|
377
|
+
elevation={knobProps.elevation}
|
|
394
378
|
{...(intent ? { theme: intent, backgroundColor: "$color3" as const } : {})}
|
|
395
|
-
{...(bleed ? phoneBleedRowProps(bleed.inset) : {})}
|
|
396
379
|
{...(disabled ? {} : { hoverStyle: { backgroundColor: "$backgroundHover" } })}
|
|
397
380
|
{...motion}
|
|
398
381
|
{...disabledChrome(Boolean(disabled), disabledState)}
|
|
399
|
-
{...({
|
|
400
|
-
"data-table-zebra": tableZebraOn ? (rowIndex % 2 === 0 ? "even" : "odd") : "off",
|
|
401
|
-
} as any)}
|
|
382
|
+
{...({ "data-table-zebra": "off" } as any)}
|
|
402
383
|
{...(getRowPressProps(row, rowIndex, "card") as any)}
|
|
403
384
|
>
|
|
404
385
|
{titleCol ? (
|
|
@@ -252,7 +252,7 @@ describe("SimpleTable", () => {
|
|
|
252
252
|
expect(on.querySelectorAll("[data-table-zebra='odd']").length).toBeGreaterThan(0);
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
it("stripes
|
|
255
|
+
it("never stripes a card, with the knob on, in light and dark (FZ-7816)", () => {
|
|
256
256
|
const columns: SimpleTableColumn[] = [{ accessorKey: "name", header: "Name" }];
|
|
257
257
|
const data = [{ name: "A" }, { name: "B" }];
|
|
258
258
|
const cardFills = (scheme: "light" | "dark") => {
|
|
@@ -269,8 +269,8 @@ describe("SimpleTable", () => {
|
|
|
269
269
|
Array.from(card.classList).filter((name) => /^_bg-(background|color\d+)$/.test(name)),
|
|
270
270
|
);
|
|
271
271
|
};
|
|
272
|
-
expect(cardFills("dark")).toEqual([["_bg-background"], ["_bg-
|
|
273
|
-
expect(cardFills("light")).toEqual([["_bg-background"], ["_bg-
|
|
272
|
+
expect(cardFills("dark")).toEqual([["_bg-background"], ["_bg-background"]]);
|
|
273
|
+
expect(cardFills("light")).toEqual([["_bg-background"], ["_bg-background"]]);
|
|
274
274
|
});
|
|
275
275
|
|
|
276
276
|
it("renders a custom cell renderer and a visible caption", () => {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-7816, amending LC-144 TABLE-ZEBRA and LC-146 PHONE-TABLE-BLEED: on a
|
|
3
|
+
* phone a DataTable shows its records as cards unless the consumer asks for
|
|
4
|
+
* rows with `layout="table"`. Cards never stripe and never bleed; phone rows
|
|
5
|
+
* are the desktop table, scrolling sideways with every column at its own
|
|
6
|
+
* width, striped and bled. A wide screen keeps the grid as it was.
|
|
7
|
+
*
|
|
8
|
+
* Tamagui's useMedia resolves `{ sm: false }` (a phone) in this env; `wide`
|
|
9
|
+
* flips it to a desktop for the tests that need one.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Table } from "@multiplatform.one/table-primitives";
|
|
13
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
14
|
+
import { PageGutter } from "@multiplatform.one/theme";
|
|
15
|
+
import { cleanup } from "@testing-library/react";
|
|
16
|
+
import type React from "react";
|
|
17
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
18
|
+
import type { DataTableColumn } from "../types";
|
|
19
|
+
import { DataTable } from "./DataTable";
|
|
20
|
+
import { SimpleTable, type SimpleTableColumn } from "./SimpleTable";
|
|
21
|
+
|
|
22
|
+
const media = vi.hoisted(() => ({ wide: false }));
|
|
23
|
+
|
|
24
|
+
vi.mock("tamagui", async (importOriginal) => {
|
|
25
|
+
const actual = await importOriginal<typeof import("tamagui")>();
|
|
26
|
+
return {
|
|
27
|
+
...actual,
|
|
28
|
+
useMedia: (...args: any[]) => {
|
|
29
|
+
const resolved = (actual.useMedia as any)(...args);
|
|
30
|
+
return media.wide ? { ...resolved, sm: true } : resolved;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
media.wide = false;
|
|
37
|
+
cleanup();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
type Row = { id: number; name: string; role: string; city: string };
|
|
41
|
+
|
|
42
|
+
const rows: Row[] = [
|
|
43
|
+
{ id: 1, name: "Ada Lovelace", role: "Engineer", city: "London" },
|
|
44
|
+
{ id: 2, name: "Grace Hopper", role: "Admiral", city: "New York" },
|
|
45
|
+
{ id: 3, name: "Alan Turing", role: "Scientist", city: "Wilmslow" },
|
|
46
|
+
{ id: 4, name: "Margaret Hamilton", role: "Director", city: "Boston" },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const columns: DataTableColumn<Row>[] = [
|
|
50
|
+
{ accessorKey: "name", header: "Name", meta: { role: "title" } },
|
|
51
|
+
{ accessorKey: "role", header: "Role" },
|
|
52
|
+
{ accessorKey: "city", header: "City", size: 180 },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const stripes = (container: HTMLElement, selector = "[data-table-zebra]") =>
|
|
56
|
+
Array.from(container.querySelectorAll(selector)).map((n) => n.getAttribute("data-table-zebra"));
|
|
57
|
+
|
|
58
|
+
const classes = (el: Element | null) => String(el?.className ?? "");
|
|
59
|
+
|
|
60
|
+
function hasStyle(el: HTMLElement, inlineKey: string, value: string, atomic: string): boolean {
|
|
61
|
+
return (el.style as any)[inlineKey] === value || classes(el).includes(atomic);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const grid = (container: HTMLElement) =>
|
|
65
|
+
container.querySelector('[data-table-grid="true"]') as HTMLElement | null;
|
|
66
|
+
|
|
67
|
+
function onPage(ui: React.ReactElement) {
|
|
68
|
+
return renderWithProviders(<PageGutter inset="$4">{ui}</PageGutter>);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
describe("phone DataTable: cards by default (FZ-7816)", () => {
|
|
72
|
+
it("an unconfigured DataTable renders its records as cards on a phone", () => {
|
|
73
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} />);
|
|
74
|
+
expect(container.querySelectorAll('[data-testid="data-table-card"]').length).toBe(4);
|
|
75
|
+
expect(grid(container)).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("cards never stripe, with the zebra knob on by default", () => {
|
|
79
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} />);
|
|
80
|
+
expect(stripes(container, '[data-testid="data-table-card"]')).toEqual([
|
|
81
|
+
"off",
|
|
82
|
+
"off",
|
|
83
|
+
"off",
|
|
84
|
+
"off",
|
|
85
|
+
]);
|
|
86
|
+
const fills = Array.from(container.querySelectorAll('[data-testid="data-table-card"]')).map(
|
|
87
|
+
(card) => Array.from(card.classList).filter((c) => /^_bg-(background|color\d+)$/.test(c)),
|
|
88
|
+
);
|
|
89
|
+
expect(new Set(fills.map((f) => f.join(" "))).size).toBe(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("cards keep the page gutter and, on the page line, take the table card frame", () => {
|
|
93
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} />);
|
|
94
|
+
expect(container.querySelectorAll("[data-phone-bleed]").length).toBe(0);
|
|
95
|
+
const card = container.querySelector('[data-testid="data-table-card"]') as HTMLElement;
|
|
96
|
+
// The `surface` border: not the bled row's hairline-only bottom rule.
|
|
97
|
+
expect(classes(card)).toMatch(/_btw-/);
|
|
98
|
+
expect(classes(card)).toMatch(/_blw-/);
|
|
99
|
+
expect(classes(card)).not.toMatch(/_btlr-0px|_borderTopLeftRadius-0px/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("SimpleTable's and the Table primitive's cards do not stripe or bleed either", () => {
|
|
103
|
+
const simpleColumns: SimpleTableColumn[] = [
|
|
104
|
+
{ accessorKey: "name", header: "Name" },
|
|
105
|
+
{ accessorKey: "role", header: "Role" },
|
|
106
|
+
];
|
|
107
|
+
const { container } = onPage(
|
|
108
|
+
<>
|
|
109
|
+
<SimpleTable data={rows} columns={simpleColumns} />
|
|
110
|
+
<Table layout="cards">
|
|
111
|
+
<Table.Body>
|
|
112
|
+
{rows.map((row) => (
|
|
113
|
+
<Table.Row key={row.id}>
|
|
114
|
+
<Table.Cell>{row.name}</Table.Cell>
|
|
115
|
+
</Table.Row>
|
|
116
|
+
))}
|
|
117
|
+
</Table.Body>
|
|
118
|
+
</Table>
|
|
119
|
+
</>,
|
|
120
|
+
);
|
|
121
|
+
expect(stripes(container, '[data-testid="simple-table-card"]')).toEqual([
|
|
122
|
+
"off",
|
|
123
|
+
"off",
|
|
124
|
+
"off",
|
|
125
|
+
"off",
|
|
126
|
+
]);
|
|
127
|
+
expect(stripes(container, '[data-testid="table-card"]')).toEqual(["off", "off", "off", "off"]);
|
|
128
|
+
expect(container.querySelectorAll("[data-phone-bleed]").length).toBe(0);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('phone DataTable: layout="table" is the desktop table', () => {
|
|
133
|
+
it("renders the grid, not cards", () => {
|
|
134
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} layout="table" />);
|
|
135
|
+
expect(grid(container)).not.toBeNull();
|
|
136
|
+
expect(container.querySelector('[data-testid="data-table-card"]')).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("stripes odd rows and bleeds to the screen edges", () => {
|
|
140
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} layout="table" />);
|
|
141
|
+
expect(stripes(container)).toEqual(["even", "odd", "even", "odd"]);
|
|
142
|
+
expect(grid(container)?.hasAttribute("data-phone-bleed")).toBe(false);
|
|
143
|
+
expect(container.querySelectorAll("[data-phone-bleed]").length).toBeGreaterThan(0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("scrolls sideways, every column at its own width", () => {
|
|
147
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} layout="table" />);
|
|
148
|
+
const viewport = grid(container) as HTMLElement;
|
|
149
|
+
expect(hasStyle(viewport, "overflowX", "auto", "_ox-auto")).toBe(true);
|
|
150
|
+
const table = container.querySelector('[role="table"]') as HTMLElement;
|
|
151
|
+
expect(table.style.minWidth).toBe("max-content");
|
|
152
|
+
const firstRow = container.querySelector('[aria-label="Table data"] [role="row"]');
|
|
153
|
+
const cells = Array.from(firstRow?.querySelectorAll('[role="cell"]') ?? []) as HTMLElement[];
|
|
154
|
+
expect(cells.length).toBe(3);
|
|
155
|
+
// The declared size, and TanStack's default size where none is declared.
|
|
156
|
+
expect(hasStyle(cells[2], "width", "180px", "_w-180px")).toBe(true);
|
|
157
|
+
expect(hasStyle(cells[0], "width", "150px", "_w-150px")).toBe(true);
|
|
158
|
+
// Basis auto, no shrink: the widths are floors, not flex shares.
|
|
159
|
+
expect(classes(cells[0])).toMatch(/_fs-0/);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("desktop DataTable is unchanged", () => {
|
|
164
|
+
it("an unconfigured DataTable keeps the grid, striped, with no sideways scroll", () => {
|
|
165
|
+
media.wide = true;
|
|
166
|
+
const { container } = onPage(<DataTable data={rows} columns={columns} />);
|
|
167
|
+
const viewport = grid(container);
|
|
168
|
+
expect(viewport).not.toBeNull();
|
|
169
|
+
expect(container.querySelector('[data-testid="data-table-card"]')).toBeNull();
|
|
170
|
+
expect(stripes(container)).toEqual(["even", "odd", "even", "odd"]);
|
|
171
|
+
expect(hasStyle(viewport as HTMLElement, "overflowX", "auto", "_ox-auto")).toBe(false);
|
|
172
|
+
const table = container.querySelector('[role="table"]') as HTMLElement;
|
|
173
|
+
expect(table.style.minWidth).not.toBe("max-content");
|
|
174
|
+
const cell = container.querySelector('[aria-label="Table data"] [role="cell"]') as HTMLElement;
|
|
175
|
+
expect(hasStyle(cell, "width", "150px", "_w-150px")).toBe(false);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -100,7 +100,7 @@ describe("LC-146 PHONE-TABLE-BLEED", () => {
|
|
|
100
100
|
expect(pads(last, "l")).toEqual(pads(middle, "l"));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it("SimpleTable's grid
|
|
103
|
+
it("SimpleTable's grid bleeds, header and body cells alike; its cards keep the gutter", () => {
|
|
104
104
|
const grid = renderWithProviders(
|
|
105
105
|
<PageGutter inset="$4">
|
|
106
106
|
<SimpleTableDesktop data={rows} columns={simpleColumns} />
|
|
@@ -118,11 +118,18 @@ describe("LC-146 PHONE-TABLE-BLEED", () => {
|
|
|
118
118
|
<SimpleTable data={rows} columns={simpleColumns} />
|
|
119
119
|
</PageGutter>,
|
|
120
120
|
);
|
|
121
|
-
expect(bled(cards.container)).toBe(
|
|
121
|
+
expect(bled(cards.container)).toBe(0);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
it("DataTable's grid
|
|
125
|
-
|
|
124
|
+
it("DataTable's grid and document list bleed their bodies; its cards keep the gutter", () => {
|
|
125
|
+
const cards = renderWithProviders(
|
|
126
|
+
<PageGutter inset="$4">
|
|
127
|
+
<DataTable data={rows} columns={dataColumns} layout="cards" onStateChange={vi.fn()} />
|
|
128
|
+
</PageGutter>,
|
|
129
|
+
);
|
|
130
|
+
expect(bled(cards.container)).toBe(0);
|
|
131
|
+
cleanup();
|
|
132
|
+
for (const layout of ["table", "list"] as const) {
|
|
126
133
|
const { container } = renderWithProviders(
|
|
127
134
|
<PageGutter inset="$4">
|
|
128
135
|
<DataTable data={rows} columns={dataColumns} layout={layout} onStateChange={vi.fn()} />
|