@multiplatform.one/table 7.45.1 → 7.47.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/DataTable/DataTableDocumentList.cjs +16 -6
- package/dist/cjs/components/DataTable/DataTableDocumentList.native.js +16 -6
- package/dist/cjs/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableMobileCards.cjs +17 -5
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js +17 -5
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableRoot.cjs +46 -33
- package/dist/cjs/components/DataTable/DataTableRoot.native.js +58 -36
- package/dist/cjs/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableVirtualized.cjs +8 -3
- package/dist/cjs/components/DataTable/DataTableVirtualized.native.js +9 -3
- package/dist/cjs/components/DataTable/DataTableVirtualized.native.js.map +1 -1
- package/dist/cjs/components/DataTable/dataTableChrome.cjs +12 -0
- package/dist/cjs/components/DataTable/dataTableChrome.native.js +12 -0
- package/dist/cjs/components/DataTable/dataTableChrome.native.js.map +1 -1
- package/dist/cjs/components/DataTable/index.native.js +58 -32
- package/dist/cjs/components/DataTable/index.native.js.map +1 -1
- package/dist/cjs/components/DataTable/rowStateChrome.cjs +3 -2
- package/dist/cjs/components/DataTable/rowStateChrome.native.js +4 -3
- package/dist/cjs/components/DataTable/rowStateChrome.native.js.map +1 -1
- package/dist/cjs/components/DataTableDateFilter/index.cjs +2 -2
- package/dist/cjs/components/DataTableDateFilter/index.native.js +2 -2
- package/dist/cjs/components/DataTableDateFilter/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableExport/index.cjs +4 -4
- package/dist/cjs/components/DataTableExport/index.native.js +4 -4
- package/dist/cjs/components/DataTableExport/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilterButton/index.cjs +3 -3
- package/dist/cjs/components/DataTableFilterButton/index.native.js +3 -3
- package/dist/cjs/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableFilters/index.cjs +2 -1
- package/dist/cjs/components/DataTableFilters/index.native.js +2 -1
- package/dist/cjs/components/DataTableFilters/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableGrouping/index.cjs +19 -13
- package/dist/cjs/components/DataTableGrouping/index.native.js +20 -13
- package/dist/cjs/components/DataTableGrouping/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableSearch/index.cjs +2 -1
- package/dist/cjs/components/DataTableSearch/index.native.js +2 -1
- package/dist/cjs/components/DataTableSearch/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableViewOptions/index.cjs +4 -5
- package/dist/cjs/components/DataTableViewOptions/index.native.js +4 -5
- package/dist/cjs/components/DataTableViewOptions/index.native.js.map +1 -1
- package/dist/cjs/components/FilterManager.cjs +3 -2
- package/dist/cjs/components/FilterManager.native.js +3 -2
- package/dist/cjs/components/FilterManager.native.js.map +1 -1
- package/dist/cjs/components/SimpleTable/index.cjs +16 -2
- package/dist/cjs/components/SimpleTable/index.native.js +17 -2
- package/dist/cjs/components/SimpleTable/index.native.js.map +1 -1
- package/dist/cjs/components/TableInput/index.cjs +3 -3
- package/dist/cjs/components/TableInput/index.native.js +5 -4
- package/dist/cjs/components/TableInput/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableDocumentList.mjs +16 -6
- package/dist/esm/components/DataTable/DataTableDocumentList.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableDocumentList.native.js +16 -6
- package/dist/esm/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs +16 -4
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js +16 -4
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.mjs +49 -36
- package/dist/esm/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.native.js +61 -39
- package/dist/esm/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableVirtualized.mjs +10 -5
- package/dist/esm/components/DataTable/DataTableVirtualized.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableVirtualized.native.js +11 -5
- package/dist/esm/components/DataTable/DataTableVirtualized.native.js.map +1 -1
- package/dist/esm/components/DataTable/dataTableChrome.mjs +12 -1
- package/dist/esm/components/DataTable/dataTableChrome.mjs.map +1 -1
- package/dist/esm/components/DataTable/dataTableChrome.native.js +12 -1
- package/dist/esm/components/DataTable/dataTableChrome.native.js.map +1 -1
- package/dist/esm/components/DataTable/index.native.js +61 -35
- package/dist/esm/components/DataTable/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/rowStateChrome.mjs +3 -2
- package/dist/esm/components/DataTable/rowStateChrome.mjs.map +1 -1
- package/dist/esm/components/DataTable/rowStateChrome.native.js +4 -3
- package/dist/esm/components/DataTable/rowStateChrome.native.js.map +1 -1
- package/dist/esm/components/DataTableDateFilter/index.mjs +7 -7
- package/dist/esm/components/DataTableDateFilter/index.mjs.map +1 -1
- package/dist/esm/components/DataTableDateFilter/index.native.js +7 -7
- package/dist/esm/components/DataTableDateFilter/index.native.js.map +1 -1
- package/dist/esm/components/DataTableExport/index.mjs +7 -7
- package/dist/esm/components/DataTableExport/index.mjs.map +1 -1
- package/dist/esm/components/DataTableExport/index.native.js +7 -7
- package/dist/esm/components/DataTableExport/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFilterButton/index.mjs +2 -2
- package/dist/esm/components/DataTableFilterButton/index.mjs.map +1 -1
- package/dist/esm/components/DataTableFilterButton/index.native.js +2 -2
- package/dist/esm/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/esm/components/DataTableFilters/index.mjs +2 -1
- package/dist/esm/components/DataTableFilters/index.mjs.map +1 -1
- package/dist/esm/components/DataTableFilters/index.native.js +2 -1
- package/dist/esm/components/DataTableFilters/index.native.js.map +1 -1
- package/dist/esm/components/DataTableGrouping/index.mjs +18 -12
- package/dist/esm/components/DataTableGrouping/index.mjs.map +1 -1
- package/dist/esm/components/DataTableGrouping/index.native.js +19 -12
- package/dist/esm/components/DataTableGrouping/index.native.js.map +1 -1
- package/dist/esm/components/DataTableSearch/index.mjs +7 -6
- package/dist/esm/components/DataTableSearch/index.mjs.map +1 -1
- package/dist/esm/components/DataTableSearch/index.native.js +7 -6
- package/dist/esm/components/DataTableSearch/index.native.js.map +1 -1
- package/dist/esm/components/DataTableViewOptions/index.mjs +10 -11
- package/dist/esm/components/DataTableViewOptions/index.mjs.map +1 -1
- package/dist/esm/components/DataTableViewOptions/index.native.js +10 -11
- package/dist/esm/components/DataTableViewOptions/index.native.js.map +1 -1
- package/dist/esm/components/FilterManager.mjs +2 -1
- package/dist/esm/components/FilterManager.mjs.map +1 -1
- package/dist/esm/components/FilterManager.native.js +2 -1
- package/dist/esm/components/FilterManager.native.js.map +1 -1
- package/dist/esm/components/SimpleTable/index.mjs +18 -4
- package/dist/esm/components/SimpleTable/index.mjs.map +1 -1
- package/dist/esm/components/SimpleTable/index.native.js +19 -4
- package/dist/esm/components/SimpleTable/index.native.js.map +1 -1
- package/dist/esm/components/TableInput/index.mjs +2 -2
- package/dist/esm/components/TableInput/index.mjs.map +1 -1
- package/dist/esm/components/TableInput/index.native.js +2 -1
- package/dist/esm/components/TableInput/index.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableDocumentList.mjs +16 -6
- package/dist/jsx/components/DataTable/DataTableDocumentList.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableDocumentList.native.js +16 -6
- package/dist/jsx/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs +16 -4
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js +17 -5
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.mjs +49 -36
- package/dist/jsx/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.native.js +58 -36
- package/dist/jsx/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableVirtualized.mjs +10 -5
- package/dist/jsx/components/DataTable/DataTableVirtualized.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableVirtualized.native.js +9 -3
- package/dist/jsx/components/DataTable/DataTableVirtualized.native.js.map +1 -1
- package/dist/jsx/components/DataTable/dataTableChrome.mjs +12 -1
- package/dist/jsx/components/DataTable/dataTableChrome.mjs.map +1 -1
- package/dist/jsx/components/DataTable/dataTableChrome.native.js +12 -0
- package/dist/jsx/components/DataTable/dataTableChrome.native.js.map +1 -1
- package/dist/jsx/components/DataTable/index.native.js +58 -32
- package/dist/jsx/components/DataTable/index.native.js.map +1 -1
- package/dist/jsx/components/DataTable/rowStateChrome.mjs +3 -2
- package/dist/jsx/components/DataTable/rowStateChrome.mjs.map +1 -1
- package/dist/jsx/components/DataTable/rowStateChrome.native.js +4 -3
- package/dist/jsx/components/DataTable/rowStateChrome.native.js.map +1 -1
- package/dist/jsx/components/DataTableDateFilter/index.mjs +7 -7
- package/dist/jsx/components/DataTableDateFilter/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableDateFilter/index.native.js +2 -2
- package/dist/jsx/components/DataTableDateFilter/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableExport/index.mjs +7 -7
- package/dist/jsx/components/DataTableExport/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableExport/index.native.js +4 -4
- package/dist/jsx/components/DataTableExport/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableFilterButton/index.mjs +2 -2
- package/dist/jsx/components/DataTableFilterButton/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableFilterButton/index.native.js +3 -3
- package/dist/jsx/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableFilters/index.mjs +2 -1
- package/dist/jsx/components/DataTableFilters/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableFilters/index.native.js +2 -1
- package/dist/jsx/components/DataTableFilters/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableGrouping/index.mjs +18 -12
- package/dist/jsx/components/DataTableGrouping/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableGrouping/index.native.js +20 -13
- package/dist/jsx/components/DataTableGrouping/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableSearch/index.mjs +7 -6
- package/dist/jsx/components/DataTableSearch/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableSearch/index.native.js +2 -1
- package/dist/jsx/components/DataTableSearch/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableViewOptions/index.mjs +10 -11
- package/dist/jsx/components/DataTableViewOptions/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableViewOptions/index.native.js +4 -5
- package/dist/jsx/components/DataTableViewOptions/index.native.js.map +1 -1
- package/dist/jsx/components/FilterManager.mjs +2 -1
- package/dist/jsx/components/FilterManager.mjs.map +1 -1
- package/dist/jsx/components/FilterManager.native.js +3 -2
- package/dist/jsx/components/FilterManager.native.js.map +1 -1
- package/dist/jsx/components/SimpleTable/index.mjs +18 -4
- package/dist/jsx/components/SimpleTable/index.mjs.map +1 -1
- package/dist/jsx/components/SimpleTable/index.native.js +17 -2
- package/dist/jsx/components/SimpleTable/index.native.js.map +1 -1
- package/dist/jsx/components/TableInput/index.mjs +2 -2
- package/dist/jsx/components/TableInput/index.mjs.map +1 -1
- package/dist/jsx/components/TableInput/index.native.js +5 -4
- package/dist/jsx/components/TableInput/index.native.js.map +1 -1
- package/package.json +12 -12
- package/src/components/DataTable/DataTable.stories.tsx +72 -2
- package/src/components/DataTable/DataTableCardControls.stories.tsx +2 -1
- package/src/components/DataTable/DataTableDocumentList.tsx +17 -3
- package/src/components/DataTable/DataTableMobileCards.tsx +17 -4
- package/src/components/DataTable/DataTableRoot.tsx +126 -89
- package/src/components/DataTable/DataTableVirtualized.tsx +10 -5
- package/src/components/DataTable/FieldsInCells.stories.tsx +4 -3
- package/src/components/DataTable/caretTransform.native.spec.tsx +129 -0
- package/src/components/DataTable/dataTableCardControls.spec.tsx +18 -9
- package/src/components/DataTable/dataTableChrome.ts +21 -0
- package/src/components/DataTable/index.native.tsx +87 -35
- package/src/components/DataTable/numericHeaderEdge.spec.tsx +96 -0
- package/src/components/DataTable/rowStateChrome.ts +9 -2
- package/src/components/DataTableBulkActions/DataTableBulkActions.stories.tsx +2 -1
- package/src/components/DataTableCell/CellOptionsEditor.stories.tsx +2 -1
- package/src/components/DataTableCell/DataTableCell.stories.tsx +8 -7
- package/src/components/DataTableColumnPinning/DataTableColumnPinning.stories.tsx +2 -1
- package/src/components/DataTableDateFilter/DataTableDateFilter.stories.tsx +2 -1
- package/src/components/DataTableDateFilter/index.tsx +20 -12
- package/src/components/DataTableExport/DataTableExport.stories.tsx +2 -1
- package/src/components/DataTableExport/index.tsx +12 -12
- package/src/components/DataTableFilterButton/index.tsx +2 -2
- package/src/components/DataTableFilterChips/FilterChip.stories.tsx +2 -1
- package/src/components/DataTableFilters/DataTableFilters.stories.tsx +2 -2
- package/src/components/DataTableFilters/index.tsx +2 -1
- package/src/components/DataTableGrouping/DataTableGrouping.stories.tsx +2 -1
- package/src/components/DataTableGrouping/index.tsx +22 -19
- package/src/components/DataTablePagination/DataTablePagination.stories.tsx +9 -4
- package/src/components/DataTableSearch/index.tsx +12 -11
- package/src/components/DataTableViewOptions/DataTableViewOptions.stories.tsx +2 -1
- package/src/components/DataTableViewOptions/index.tsx +26 -19
- package/src/components/FilterManager.tsx +2 -1
- package/src/components/FilterOperatorValueEditor/FilterOperatorValueEditor.stories.tsx +2 -1
- package/src/components/KnobDialog.stories.tsx +2 -1
- package/src/components/SimpleTable/SimpleTable.stories.tsx +28 -0
- package/src/components/SimpleTable/index.tsx +27 -4
- package/src/components/SimpleTable/simpleTable.spec.tsx +1 -1
- package/src/components/TableInput/TableInput.stories.tsx +6 -5
- package/src/components/TableInput/index.native.tsx +2 -1
- package/src/components/TableInput/index.tsx +2 -1
- package/src/components/phoneTableBleed.spec.tsx +224 -0
- package/src/components/tableZebraDefault.spec.tsx +98 -0
- package/types/components/DataTable/DataTableDocumentList.d.ts +4 -1
- package/types/components/DataTable/DataTableDocumentList.d.ts.map +1 -1
- package/types/components/DataTable/DataTableMobileCards.d.ts +4 -1
- package/types/components/DataTable/DataTableMobileCards.d.ts.map +1 -1
- package/types/components/DataTable/DataTableRoot.d.ts.map +1 -1
- package/types/components/DataTable/DataTableVirtualized.d.ts.map +1 -1
- package/types/components/DataTable/dataTableChrome.d.ts +6 -0
- package/types/components/DataTable/dataTableChrome.d.ts.map +1 -1
- package/types/components/DataTable/index.native.d.ts.map +1 -1
- package/types/components/DataTable/rowStateChrome.d.ts +6 -0
- package/types/components/DataTable/rowStateChrome.d.ts.map +1 -1
- package/types/components/DataTableDateFilter/index.d.ts.map +1 -1
- package/types/components/DataTableFilters/index.d.ts.map +1 -1
- package/types/components/DataTableGrouping/index.d.ts.map +1 -1
- package/types/components/DataTableSearch/index.d.ts.map +1 -1
- package/types/components/DataTableViewOptions/index.d.ts.map +1 -1
- package/types/components/FilterManager.d.ts.map +1 -1
- package/types/components/SimpleTable/index.d.ts.map +1 -1
- package/types/components/TableInput/index.d.ts.map +1 -1
- package/types/components/TableInput/index.native.d.ts.map +1 -1
|
@@ -23,13 +23,20 @@ import { useVirtualizer } from "@tanstack/react-virtual";
|
|
|
23
23
|
import {
|
|
24
24
|
ensureFocusVisibleRing,
|
|
25
25
|
sizeTokenBelow,
|
|
26
|
+
usePhoneTableBleed,
|
|
26
27
|
useResolvedKnobs,
|
|
27
28
|
Surface,
|
|
28
29
|
} from "@multiplatform.one/theme";
|
|
29
30
|
import React, { useEffect, useRef, useMemo, useCallback, useState } from "react";
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
AsyncBoundary,
|
|
33
|
+
EmptyState,
|
|
34
|
+
Tooltip,
|
|
35
|
+
useDirection,
|
|
36
|
+
Text,
|
|
37
|
+
} from "@multiplatform.one/components";
|
|
31
38
|
import type { FontSizeTokens, SizeTokens } from "tamagui";
|
|
32
|
-
import { SizableText, Text, View, isWeb, useMedia } from "tamagui";
|
|
39
|
+
import { SizableText, Text as TamaguiText, View, isWeb, useMedia } from "tamagui";
|
|
33
40
|
import { useTranslation } from "react-i18next";
|
|
34
41
|
import { useDataTable } from "../../hooks/useDataTable";
|
|
35
42
|
import { useDragScroll } from "../../hooks/useDragScroll";
|
|
@@ -62,7 +69,12 @@ import { DataTableDocumentList } from "./DataTableDocumentList";
|
|
|
62
69
|
import { DataTableInfiniteTail } from "./DataTableInfiniteTail";
|
|
63
70
|
import { CellContent } from "./CellContent";
|
|
64
71
|
import { DataTableVirtualized } from "./DataTableVirtualized";
|
|
65
|
-
import {
|
|
72
|
+
import {
|
|
73
|
+
bledDataTableChrome,
|
|
74
|
+
dataTableChrome,
|
|
75
|
+
resolveDataTableIntent,
|
|
76
|
+
rowIntentProps,
|
|
77
|
+
} from "./dataTableChrome";
|
|
66
78
|
import { tableCellKeyboardProps, tableRowStateProps } from "./rowStateChrome";
|
|
67
79
|
import { warnColumnWidthIgnored } from "../../shared/devWarn";
|
|
68
80
|
import { alignToFlex, getDefaultColumnAlign } from "../../utils/columnAlign";
|
|
@@ -181,6 +193,8 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
181
193
|
warnColumnWidthIgnored({ columnLayout, enableColumnResizing, columns });
|
|
182
194
|
const { t } = useTranslation();
|
|
183
195
|
const { sm } = useMedia();
|
|
196
|
+
// LC-146: on the page line below `$sm` the body runs edge to edge.
|
|
197
|
+
const bleed = usePhoneTableBleed();
|
|
184
198
|
// Resolved responsive layout: cards below `$sm` (W11 compact class) unless
|
|
185
199
|
// pinned via the `layout` prop. Same table state drives both layouts.
|
|
186
200
|
const showList = layout === "list";
|
|
@@ -193,7 +207,11 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
193
207
|
component: "DataTable",
|
|
194
208
|
size,
|
|
195
209
|
});
|
|
196
|
-
const chrome =
|
|
210
|
+
const chrome = bledDataTableChrome(
|
|
211
|
+
dataTableChrome(String(knobProps.sizeToken)),
|
|
212
|
+
bleed?.inset,
|
|
213
|
+
enableRowSelection,
|
|
214
|
+
);
|
|
197
215
|
const rowHeightPx = chrome.rowPx;
|
|
198
216
|
const selectionColWidth = chrome.selectionCol;
|
|
199
217
|
// Collapsed expand-caret points toward inline-end, so it mirrors in RTL via
|
|
@@ -629,7 +647,11 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
629
647
|
},
|
|
630
648
|
onBlur: (e: React.FocusEvent) => {
|
|
631
649
|
const next = e.relatedTarget;
|
|
632
|
-
if (
|
|
650
|
+
if (
|
|
651
|
+
typeof Element === "undefined" ||
|
|
652
|
+
!(next instanceof Element) ||
|
|
653
|
+
!next.closest('[data-row-press="true"]')
|
|
654
|
+
) {
|
|
633
655
|
setRowPressAnchor(0);
|
|
634
656
|
setRowPressHasFocus(false);
|
|
635
657
|
}
|
|
@@ -1354,6 +1376,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1354
1376
|
renderCellContent={renderCellContent}
|
|
1355
1377
|
selectRowLabel={deriveSelectRowLabel}
|
|
1356
1378
|
queryInFlight={queryInFlight}
|
|
1379
|
+
bleed={bleed}
|
|
1357
1380
|
{...(rowPressActive ? { getRowPressProps } : {})}
|
|
1358
1381
|
/>
|
|
1359
1382
|
) : showCards ? (
|
|
@@ -1386,6 +1409,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1386
1409
|
onToggleSelectAll={toggleSelectAll}
|
|
1387
1410
|
selectRowLabel={deriveSelectRowLabel}
|
|
1388
1411
|
queryInFlight={queryInFlight}
|
|
1412
|
+
bleed={bleed}
|
|
1389
1413
|
{...(rowPressActive ? { getRowPressProps } : {})}
|
|
1390
1414
|
/>
|
|
1391
1415
|
</>
|
|
@@ -1401,7 +1425,11 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1401
1425
|
}
|
|
1402
1426
|
}}
|
|
1403
1427
|
flexDirection="column"
|
|
1404
|
-
|
|
1428
|
+
// LC-146: the scroll viewport is the frame that bleeds, so
|
|
1429
|
+
// the grid scrolls edge to edge and its cells carry the gutter.
|
|
1430
|
+
{...(bleed
|
|
1431
|
+
? { ...bleed.frame, width: "auto" as const, alignSelf: "stretch" as const }
|
|
1432
|
+
: { width: "100%" as const })}
|
|
1405
1433
|
// Grow 0 / shrink 1 / basis auto: the grid frame hugs its
|
|
1406
1434
|
// rows and only compresses (into internal scroll) when the
|
|
1407
1435
|
// parent is shorter. flexGrow 1 stretched the frame to fill
|
|
@@ -1435,6 +1463,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1435
1463
|
<Table
|
|
1436
1464
|
size={resolvedSize}
|
|
1437
1465
|
cellSize={cellSize}
|
|
1466
|
+
edgeInset={bleed?.inset ?? null}
|
|
1438
1467
|
displayMode={displayMode}
|
|
1439
1468
|
alignCells={{ x: "start", y: "center" }}
|
|
1440
1469
|
alignHeaderCells={{ x: "start", y: "center" }}
|
|
@@ -1475,12 +1504,14 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1475
1504
|
: rowCounter.current === allRowsLength - 1
|
|
1476
1505
|
? "last"
|
|
1477
1506
|
: "middle",
|
|
1478
|
-
borderTopRightRadius:
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1507
|
+
borderTopRightRadius:
|
|
1508
|
+
hasToolbar || bleed
|
|
1509
|
+
? "$0"
|
|
1510
|
+
: knobProps.borderRadiusOuter.borderRadius,
|
|
1511
|
+
borderTopLeftRadius:
|
|
1512
|
+
hasToolbar || bleed
|
|
1513
|
+
? "$0"
|
|
1514
|
+
: knobProps.borderRadiusOuter.borderRadius,
|
|
1484
1515
|
borderBottomLeftRadius: "$0",
|
|
1485
1516
|
borderBottomRightRadius: "$0",
|
|
1486
1517
|
"aria-rowindex": rowCounter.current,
|
|
@@ -1562,6 +1593,39 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1562
1593
|
const headerJustify = alignToFlex(columnAlign);
|
|
1563
1594
|
const isRightAligned = columnAlign === "right";
|
|
1564
1595
|
|
|
1596
|
+
const hasHeaderTools =
|
|
1597
|
+
(enableFiltering && header.column.getCanFilter()) ||
|
|
1598
|
+
Boolean(pinning && enableColumnPinning);
|
|
1599
|
+
const sortGlyph = isSortableHeader ? (
|
|
1600
|
+
<Tooltip
|
|
1601
|
+
content={
|
|
1602
|
+
sortDirection === "asc"
|
|
1603
|
+
? t("Sorted ascending (click to sort descending)")
|
|
1604
|
+
: sortDirection === "desc"
|
|
1605
|
+
? t("Sorted descending (click to clear)")
|
|
1606
|
+
: t("Click to sort (Shift+click for multi-sort)")
|
|
1607
|
+
}
|
|
1608
|
+
>
|
|
1609
|
+
<View aria-hidden={true} role="presentation" flexShrink={0}>
|
|
1610
|
+
{sortDirection === "asc" && (
|
|
1611
|
+
<CaretDownIcon size={chrome.iconPx} color="var(--color11)" />
|
|
1612
|
+
)}
|
|
1613
|
+
{sortDirection === "desc" && (
|
|
1614
|
+
<CaretDownIcon
|
|
1615
|
+
size={chrome.iconPx}
|
|
1616
|
+
color="var(--color11)"
|
|
1617
|
+
style={{ transform: "rotate(180deg)" }}
|
|
1618
|
+
/>
|
|
1619
|
+
)}
|
|
1620
|
+
{sortDirection === false && (
|
|
1621
|
+
<CaretUpDownIcon
|
|
1622
|
+
size={chrome.iconPx}
|
|
1623
|
+
color="var(--color11)"
|
|
1624
|
+
/>
|
|
1625
|
+
)}
|
|
1626
|
+
</View>
|
|
1627
|
+
</Tooltip>
|
|
1628
|
+
) : null;
|
|
1565
1629
|
const isFirstHeaderCell =
|
|
1566
1630
|
headerIndex === 0 &&
|
|
1567
1631
|
!enableRowSelection &&
|
|
@@ -1681,7 +1745,10 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1681
1745
|
minWidth={0}
|
|
1682
1746
|
justifyContent={isRightAligned ? "flex-end" : undefined}
|
|
1683
1747
|
>
|
|
1684
|
-
|
|
1748
|
+
{/* A right-aligned label ends on its values'
|
|
1749
|
+
edge, so its sort glyph leads (DG-TBL-01). */}
|
|
1750
|
+
{isRightAligned ? sortGlyph : null}
|
|
1751
|
+
<TamaguiText
|
|
1685
1752
|
fontSize={knobProps.sizeToken}
|
|
1686
1753
|
userSelect="none"
|
|
1687
1754
|
flexShrink={1}
|
|
@@ -1696,81 +1763,50 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1696
1763
|
header.column.columnDef.header,
|
|
1697
1764
|
header.getContext(),
|
|
1698
1765
|
)}
|
|
1699
|
-
</
|
|
1700
|
-
{
|
|
1701
|
-
<Tooltip
|
|
1702
|
-
content={
|
|
1703
|
-
sortDirection === "asc"
|
|
1704
|
-
? t("Sorted ascending (click to sort descending)")
|
|
1705
|
-
: sortDirection === "desc"
|
|
1706
|
-
? t("Sorted descending (click to clear)")
|
|
1707
|
-
: t("Click to sort (Shift+click for multi-sort)")
|
|
1708
|
-
}
|
|
1709
|
-
>
|
|
1710
|
-
<View
|
|
1711
|
-
aria-hidden={true}
|
|
1712
|
-
role="presentation"
|
|
1713
|
-
flexShrink={0}
|
|
1714
|
-
>
|
|
1715
|
-
{sortDirection === "asc" && (
|
|
1716
|
-
<CaretDownIcon
|
|
1717
|
-
size={chrome.iconPx}
|
|
1718
|
-
color="var(--color11)"
|
|
1719
|
-
/>
|
|
1720
|
-
)}
|
|
1721
|
-
{sortDirection === "desc" && (
|
|
1722
|
-
<CaretDownIcon
|
|
1723
|
-
size={chrome.iconPx}
|
|
1724
|
-
color="var(--color11)"
|
|
1725
|
-
style={{ transform: "rotate(180deg)" }}
|
|
1726
|
-
/>
|
|
1727
|
-
)}
|
|
1728
|
-
{sortDirection === false && (
|
|
1729
|
-
<CaretUpDownIcon
|
|
1730
|
-
size={chrome.iconPx}
|
|
1731
|
-
color="var(--color11)"
|
|
1732
|
-
/>
|
|
1733
|
-
)}
|
|
1734
|
-
</View>
|
|
1735
|
-
</Tooltip>
|
|
1736
|
-
)}
|
|
1766
|
+
</TamaguiText>
|
|
1767
|
+
{isRightAligned ? null : sortGlyph}
|
|
1737
1768
|
</View>
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
+
{/* Absent rather than empty: an empty cluster
|
|
1770
|
+
still takes a gap and pulls a right-aligned
|
|
1771
|
+
label off its values' edge. */}
|
|
1772
|
+
{hasHeaderTools ? (
|
|
1773
|
+
<View
|
|
1774
|
+
flexDirection="row"
|
|
1775
|
+
gap="$1"
|
|
1776
|
+
alignItems="center"
|
|
1777
|
+
flexShrink={0}
|
|
1778
|
+
>
|
|
1779
|
+
{enableFiltering && header.column.getCanFilter() && (
|
|
1780
|
+
<ColumnHeaderFilter
|
|
1781
|
+
columnId={header.column.id}
|
|
1782
|
+
columnLabel={
|
|
1783
|
+
typeof header.column.columnDef.header === "string"
|
|
1784
|
+
? header.column.columnDef.header
|
|
1785
|
+
: header.column.id
|
|
1786
|
+
}
|
|
1787
|
+
columnType={mapFieldToFilterType(
|
|
1788
|
+
getColumnField(
|
|
1789
|
+
header.column.columnDef as DataTableColumn,
|
|
1790
|
+
),
|
|
1791
|
+
)}
|
|
1792
|
+
filterValue={header.column.getFilterValue()}
|
|
1793
|
+
onFilterChange={(value) =>
|
|
1794
|
+
header.column.setFilterValue(value)
|
|
1795
|
+
}
|
|
1796
|
+
isFiltered={header.column.getIsFiltered()}
|
|
1797
|
+
options={
|
|
1798
|
+
(header.column.columnDef as any).fieldProps?.options
|
|
1799
|
+
}
|
|
1800
|
+
/>
|
|
1801
|
+
)}
|
|
1802
|
+
{pinning && enableColumnPinning && (
|
|
1803
|
+
/* One compact cycle control per header
|
|
1769
1804
|
(left → right → unpin) — two full
|
|
1770
1805
|
buttons crowded the header (owner). */
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1806
|
+
<pinning.PinButton columnId={header.column.id} />
|
|
1807
|
+
)}
|
|
1808
|
+
</View>
|
|
1809
|
+
) : null}
|
|
1774
1810
|
</View>
|
|
1775
1811
|
{canResize && resizeHandler && (
|
|
1776
1812
|
<View
|
|
@@ -1948,9 +1984,9 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1948
1984
|
},
|
|
1949
1985
|
} as any)}
|
|
1950
1986
|
>
|
|
1951
|
-
<
|
|
1987
|
+
<TamaguiText fontFamily="$mono" fontSize="$3">
|
|
1952
1988
|
{row.getIsExpanded() ? "▼" : "▶"}
|
|
1953
|
-
</
|
|
1989
|
+
</TamaguiText>
|
|
1954
1990
|
<SizableText
|
|
1955
1991
|
fontFamily={knobProps.heading.fontFamily}
|
|
1956
1992
|
size="$4"
|
|
@@ -1974,6 +2010,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1974
2010
|
zebraOn: tableZebraOn,
|
|
1975
2011
|
index,
|
|
1976
2012
|
pressable: rowPressActive,
|
|
2013
|
+
surface: bleed ? "$background" : undefined,
|
|
1977
2014
|
}) as any)}
|
|
1978
2015
|
{...({ animation: "quick" } as any)}
|
|
1979
2016
|
flexShrink={0}
|
|
@@ -2300,7 +2337,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
2300
2337
|
many rows exist even when a height-constrained body clips
|
|
2301
2338
|
some below the fold ("1–6 of 6", not "what you see is all"). */}
|
|
2302
2339
|
{showPageRange ? (
|
|
2303
|
-
<
|
|
2340
|
+
<TamaguiText
|
|
2304
2341
|
fontSize={knobProps.sizeToken}
|
|
2305
2342
|
color="$color11"
|
|
2306
2343
|
aria-live="polite"
|
|
@@ -2318,7 +2355,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
2318
2355
|
{ start: rangeStart, end: rangeEnd, total: rangeTotal },
|
|
2319
2356
|
),
|
|
2320
2357
|
)}
|
|
2321
|
-
</
|
|
2358
|
+
</TamaguiText>
|
|
2322
2359
|
) : null}
|
|
2323
2360
|
</View>
|
|
2324
2361
|
)}
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import { dataTableChrome, rowIntentProps } from "./dataTableChrome";
|
|
11
11
|
import { tableRowStateProps } from "./rowStateChrome";
|
|
12
|
-
import { Skeleton } from "@multiplatform.one/components";
|
|
13
|
-
import {
|
|
12
|
+
import { Skeleton, Text } from "@multiplatform.one/components";
|
|
13
|
+
import { TableEdgeCells, useTableEdgeInset } from "@multiplatform.one/table-primitives";
|
|
14
|
+
import { SizableText, Text as TamaguiText, View } from "tamagui";
|
|
14
15
|
|
|
15
16
|
export interface DataTableVirtualizedProps {
|
|
16
17
|
virtualItems: any[];
|
|
@@ -74,6 +75,7 @@ export function DataTableVirtualized({
|
|
|
74
75
|
tableZebraOn = false,
|
|
75
76
|
}: DataTableVirtualizedProps) {
|
|
76
77
|
const rowHeightPx = rowHeightPxProp ?? dataTableChrome("$4").rowPx;
|
|
78
|
+
const edgeInset = useTableEdgeInset();
|
|
77
79
|
return (
|
|
78
80
|
<div
|
|
79
81
|
style={{
|
|
@@ -165,9 +167,9 @@ export function DataTableVirtualized({
|
|
|
165
167
|
},
|
|
166
168
|
} as any)}
|
|
167
169
|
>
|
|
168
|
-
<
|
|
170
|
+
<TamaguiText fontFamily="$mono" fontSize="$3">
|
|
169
171
|
{row.getIsExpanded() ? "▼" : "▶"}
|
|
170
|
-
</
|
|
172
|
+
</TamaguiText>
|
|
171
173
|
<SizableText fontFamily="$heading" size="$4">
|
|
172
174
|
{String(row.groupingValue ?? "—")}
|
|
173
175
|
</SizableText>
|
|
@@ -198,6 +200,7 @@ export function DataTableVirtualized({
|
|
|
198
200
|
zebraOn: tableZebraOn,
|
|
199
201
|
index: virtualRow.index,
|
|
200
202
|
pressable: Boolean(getRowPressProps),
|
|
203
|
+
surface: edgeInset ? "$background" : undefined,
|
|
201
204
|
}) as any)}
|
|
202
205
|
{...({
|
|
203
206
|
"data-table-zebra": tableZebraOn
|
|
@@ -213,7 +216,9 @@ export function DataTableVirtualized({
|
|
|
213
216
|
>
|
|
214
217
|
{/* div cells (role="cell" via the primitive): a real <td> is
|
|
215
218
|
not a valid child of the absolutely-positioned div rows */}
|
|
216
|
-
|
|
219
|
+
<TableEdgeCells>
|
|
220
|
+
{renderRowContent(row, virtualRow.index, isLastRow, "div")}
|
|
221
|
+
</TableEdgeCells>
|
|
217
222
|
</View>
|
|
218
223
|
);
|
|
219
224
|
})}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
8
8
|
import { fn } from "storybook/test";
|
|
9
9
|
import React from "react";
|
|
10
|
-
import { Text, View, YStack
|
|
10
|
+
import { Text as TamaguiText, View, YStack } from "tamagui";
|
|
11
11
|
import type { DataTableColumn, DataTableData } from "../../types";
|
|
12
12
|
import { DataTable } from "./index";
|
|
13
|
+
import { H3, Text } from "@multiplatform.one/components";
|
|
13
14
|
|
|
14
15
|
interface SampleRow extends DataTableData {
|
|
15
16
|
id: string;
|
|
@@ -233,14 +234,14 @@ function WiredTable<TData extends DataTableData>({
|
|
|
233
234
|
{...rest}
|
|
234
235
|
/>
|
|
235
236
|
</YStack>
|
|
236
|
-
<
|
|
237
|
+
<TamaguiText
|
|
237
238
|
testID="fields-in-cells-data"
|
|
238
239
|
fontSize="$1"
|
|
239
240
|
color="$placeholderColor"
|
|
240
241
|
fontFamily="$mono"
|
|
241
242
|
>
|
|
242
243
|
committed: {JSON.stringify(data)}
|
|
243
|
-
</
|
|
244
|
+
</TamaguiText>
|
|
244
245
|
</YStack>
|
|
245
246
|
);
|
|
246
247
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-7741, the native DataTable arm. The report grid's descending caret threw
|
|
3
|
+
* "Expected transform functions but "r" found" on iOS: a phosphor glyph is
|
|
4
|
+
* react-native-svg's Svg there, and Svg parses a style transform string as an
|
|
5
|
+
* SVG attribute, which takes `rotate(180)` and not CSS's `rotate(180deg)`.
|
|
6
|
+
* index.native.tsx handed its glyphs the same strings: `rotate(180deg)` on a
|
|
7
|
+
* descending header and `none` or `rotate(90deg)` on every expand caret, so a
|
|
8
|
+
* table-layout DataTable with expandable rows could not render on a tablet.
|
|
9
|
+
*
|
|
10
|
+
* The suite runs on web, so the native root renders through react-native-web
|
|
11
|
+
* with FlashList stubbed (the ./nativeRoot.spec.tsx precedent), and each glyph's
|
|
12
|
+
* props go through the parse Svg runs on device.
|
|
13
|
+
*/
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
16
|
+
import { cleanup, fireEvent, screen } from "@testing-library/react";
|
|
17
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
18
|
+
import type { DataTableColumn } from "../../types";
|
|
19
|
+
import { DataTable } from "./index.native";
|
|
20
|
+
|
|
21
|
+
const { glyphs } = vi.hoisted(() => ({
|
|
22
|
+
glyphs: [] as { name: string; props: Record<string, unknown> }[],
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock("@shopify/flash-list", () => ({ FlashList: () => null }));
|
|
26
|
+
|
|
27
|
+
// Each phosphor glyph records the props the native shim would hand to Svg.
|
|
28
|
+
vi.mock("@phosphor-icons/react", async (importOriginal) => {
|
|
29
|
+
const actual = await importOriginal<Record<string, unknown>>();
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
Object.entries(actual).map(([key, value]) => [
|
|
32
|
+
key,
|
|
33
|
+
key.endsWith("Icon")
|
|
34
|
+
? (props: Record<string, unknown>) => {
|
|
35
|
+
glyphs.push({ name: key, props });
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
: value,
|
|
39
|
+
]),
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Loaded past the suite's react-native-svg -> @tamagui/react-native-svg
|
|
44
|
+
// alias: this is the parse Svg.render runs on device.
|
|
45
|
+
const { extractTransformSvgView } = createRequire(import.meta.url)(
|
|
46
|
+
"react-native-svg/lib/commonjs/lib/extract/extractTransform.js",
|
|
47
|
+
) as { extractTransformSvgView: (props: { transform: unknown }) => unknown };
|
|
48
|
+
|
|
49
|
+
/** Svg.render: a style transform wins over the prop, and a truthy one is parsed. */
|
|
50
|
+
function svgTransform(props: Record<string, unknown>): unknown {
|
|
51
|
+
const style = Object.assign({}, ...[props.style].flat(Number.POSITIVE_INFINITY).filter(Boolean));
|
|
52
|
+
const transform = style.transform ?? props.transform;
|
|
53
|
+
if (transform) extractTransformSvgView({ transform });
|
|
54
|
+
return transform;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type Person = { id: number; name: string; subRows?: Person[] };
|
|
58
|
+
|
|
59
|
+
const data: Person[] = [
|
|
60
|
+
{ id: 1, name: "John", subRows: [{ id: 11, name: "John Detail" }] },
|
|
61
|
+
{ id: 2, name: "Jane" },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const columns: DataTableColumn<Person>[] = [
|
|
65
|
+
{ accessorKey: "name", header: "Name" },
|
|
66
|
+
{ accessorKey: "id", header: "ID" },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
function expectGlyphsParse() {
|
|
70
|
+
expect(glyphs.length).toBeGreaterThan(0);
|
|
71
|
+
for (const glyph of glyphs) {
|
|
72
|
+
expect(() => svgTransform(glyph.props), glyph.name).not.toThrow();
|
|
73
|
+
expect(typeof svgTransform(glyph.props), glyph.name).not.toBe("string");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
afterEach(() => {
|
|
78
|
+
cleanup();
|
|
79
|
+
glyphs.length = 0;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("native DataTable carets survive react-native-svg (FZ-7741)", () => {
|
|
83
|
+
it("the parse used here is the one that failed on device", () => {
|
|
84
|
+
expect(() => extractTransformSvgView({ transform: "rotate(180deg)" })).toThrow(
|
|
85
|
+
'Expected transform functions but "r" found',
|
|
86
|
+
);
|
|
87
|
+
expect(() => extractTransformSvgView({ transform: "none" })).toThrow();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("a descending header and collapsed and expanded rows render glyphs Svg can take", () => {
|
|
91
|
+
renderWithProviders(
|
|
92
|
+
<DataTable
|
|
93
|
+
data={data}
|
|
94
|
+
columns={columns as DataTableColumn<Record<string, any>>[]}
|
|
95
|
+
layout="table"
|
|
96
|
+
enableSorting
|
|
97
|
+
enableRowExpansion
|
|
98
|
+
initialState={{ sorting: [{ id: "name", desc: true }] }}
|
|
99
|
+
/>,
|
|
100
|
+
);
|
|
101
|
+
expect(glyphs.some((glyph) => glyph.name === "CaretDownIcon")).toBe(true);
|
|
102
|
+
expect(glyphs.some((glyph) => /^Caret(Right|Left)Icon$/.test(glyph.name))).toBe(true);
|
|
103
|
+
expectGlyphsParse();
|
|
104
|
+
|
|
105
|
+
glyphs.length = 0;
|
|
106
|
+
fireEvent.click(screen.getAllByLabelText(/^Expand row \d+$/)[0]);
|
|
107
|
+
expect(screen.getAllByLabelText(/^Collapse row \d+$/)).toHaveLength(1);
|
|
108
|
+
expectGlyphsParse();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("paints carets with a concrete theme ink, never a token Svg cannot read (LC-84)", () => {
|
|
112
|
+
renderWithProviders(
|
|
113
|
+
<DataTable
|
|
114
|
+
data={data}
|
|
115
|
+
columns={columns as DataTableColumn<Record<string, any>>[]}
|
|
116
|
+
layout="table"
|
|
117
|
+
enableSorting
|
|
118
|
+
enableRowExpansion
|
|
119
|
+
/>,
|
|
120
|
+
);
|
|
121
|
+
const carets = glyphs.filter((glyph) => glyph.name.startsWith("Caret"));
|
|
122
|
+
expect(carets.length).toBeGreaterThan(0);
|
|
123
|
+
for (const glyph of carets) {
|
|
124
|
+
expect(String(glyph.props.color), glyph.name).not.toMatch(
|
|
125
|
+
/^var\(|^\$|^currentColor$|^undefined$/,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -39,12 +39,21 @@ function renderCards(props: Record<string, any> = {}) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// The open menu repeats the trigger as its first row, same name (LC-112).
|
|
43
|
+
function sortTrigger() {
|
|
44
|
+
const trigger = screen
|
|
45
|
+
.getAllByRole("button", { name: "Sort rows" })
|
|
46
|
+
.find((button) => !button.closest("[data-fp-trigger-row]"));
|
|
47
|
+
if (!trigger) throw new Error("no Sort rows trigger outside the menu");
|
|
48
|
+
return trigger;
|
|
49
|
+
}
|
|
50
|
+
|
|
42
51
|
describe("DataTableCardControls", () => {
|
|
43
52
|
it("is a labelled toolbar above the card list", () => {
|
|
44
53
|
renderCards({ enableSorting: true, enableFiltering: true });
|
|
45
54
|
const toolbar = screen.getByRole("toolbar", { name: "Table toolbar" });
|
|
46
55
|
expect(toolbar).toBeTruthy();
|
|
47
|
-
expect(
|
|
56
|
+
expect(sortTrigger()).toBeTruthy();
|
|
48
57
|
});
|
|
49
58
|
|
|
50
59
|
it("renders no toolbar at all when neither sorting nor filtering is enabled", () => {
|
|
@@ -54,7 +63,7 @@ describe("DataTableCardControls", () => {
|
|
|
54
63
|
|
|
55
64
|
it("sorting only: the sort menu is there, the filter chrome is not", () => {
|
|
56
65
|
renderCards({ enableSorting: true, enableFiltering: false });
|
|
57
|
-
expect(
|
|
66
|
+
expect(sortTrigger()).toBeTruthy();
|
|
58
67
|
expect(screen.queryByText("Add Filter")).toBeNull();
|
|
59
68
|
});
|
|
60
69
|
|
|
@@ -67,32 +76,32 @@ describe("DataTableCardControls", () => {
|
|
|
67
76
|
|
|
68
77
|
it("with no sort applied the trigger reads the neutral label", () => {
|
|
69
78
|
renderCards({ enableSorting: true });
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
79
|
+
expect(sortTrigger().textContent).toContain("Sort");
|
|
80
|
+
expect(sortTrigger().textContent).not.toContain("Age");
|
|
72
81
|
});
|
|
73
82
|
|
|
74
83
|
it("an active ascending sort is named on the trigger, arrow and all", () => {
|
|
75
84
|
renderCards({ enableSorting: true, initialState: { sorting: [{ id: "age", desc: false }] } });
|
|
76
|
-
expect(
|
|
85
|
+
expect(sortTrigger().textContent).toContain("Age ↑");
|
|
77
86
|
});
|
|
78
87
|
|
|
79
88
|
it("an active descending sort flips the arrow on the trigger", () => {
|
|
80
89
|
renderCards({ enableSorting: true, initialState: { sorting: [{ id: "age", desc: true }] } });
|
|
81
|
-
expect(
|
|
90
|
+
expect(sortTrigger().textContent).toContain("Age ↓");
|
|
82
91
|
});
|
|
83
92
|
|
|
84
93
|
it("picking a column from the menu updates the trigger label", async () => {
|
|
85
94
|
renderCards({ enableSorting: true });
|
|
86
|
-
fireEvent.click(
|
|
95
|
+
fireEvent.click(sortTrigger());
|
|
87
96
|
fireEvent.click(await screen.findByLabelText("Sort by Age"));
|
|
88
97
|
await waitFor(() => {
|
|
89
|
-
expect(
|
|
98
|
+
expect(sortTrigger().textContent).toContain("Age ↑");
|
|
90
99
|
});
|
|
91
100
|
});
|
|
92
101
|
|
|
93
102
|
it("offers one menu entry per sortable column and no more", async () => {
|
|
94
103
|
renderCards({ enableSorting: true });
|
|
95
|
-
fireEvent.click(
|
|
104
|
+
fireEvent.click(sortTrigger());
|
|
96
105
|
expect(await screen.findByLabelText("Sort by First Name")).toBeTruthy();
|
|
97
106
|
expect(screen.getByLabelText("Sort by Age")).toBeTruthy();
|
|
98
107
|
expect(screen.queryByLabelText("Sort by Email")).toBeNull();
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { sizeRecipeForToken } from "@multiplatform.one/theme";
|
|
10
|
+
import { getTokenValue } from "tamagui";
|
|
10
11
|
|
|
11
12
|
export type DataTableIntentName = "accent" | "error" | "warning" | "success";
|
|
12
13
|
|
|
@@ -46,3 +47,23 @@ export function dataTableChrome(sizeToken: string) {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export type DataTableChrome = ReturnType<typeof dataTableChrome>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* LC-146: a full-bleed grid's edge cells carry the page gutter inside their
|
|
53
|
+
* width, so a fixed chrome column on an edge (selection or row numbers first,
|
|
54
|
+
* delete last) widens by the gutter instead of squeezing its control.
|
|
55
|
+
*/
|
|
56
|
+
export function bledDataTableChrome(
|
|
57
|
+
chrome: DataTableChrome,
|
|
58
|
+
inset: string | null | undefined,
|
|
59
|
+
selectionLeads: boolean,
|
|
60
|
+
): DataTableChrome {
|
|
61
|
+
if (!inset) return chrome;
|
|
62
|
+
const px = Number(getTokenValue(inset as Parameters<typeof getTokenValue>[0], "space")) || 0;
|
|
63
|
+
return {
|
|
64
|
+
...chrome,
|
|
65
|
+
selectionCol: chrome.selectionCol + px,
|
|
66
|
+
rowNumberCol: chrome.rowNumberCol + (selectionLeads ? 0 : px),
|
|
67
|
+
deleteCol: chrome.deleteCol + px,
|
|
68
|
+
};
|
|
69
|
+
}
|