@multiplatform.one/table 7.69.2 → 7.71.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/DataTableCardControls.cjs +74 -12
- package/dist/cjs/components/DataTable/DataTableCardControls.native.js +83 -12
- package/dist/cjs/components/DataTable/DataTableCardControls.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableDocumentList.cjs +180 -114
- package/dist/cjs/components/DataTable/DataTableDocumentList.native.js +193 -124
- package/dist/cjs/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableMobileCards.cjs +260 -127
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js +287 -156
- package/dist/cjs/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/cjs/components/DataTable/DataTableRoot.cjs +34 -5
- package/dist/cjs/components/DataTable/DataTableRoot.native.js +36 -5
- package/dist/cjs/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/cjs/components/DataTable/PhonePager.cjs +56 -0
- package/dist/cjs/components/DataTable/PhonePager.native.js +60 -0
- package/dist/cjs/components/DataTable/PhonePager.native.js.map +1 -0
- package/dist/cjs/components/DataTable/index.native.js +64 -7
- package/dist/cjs/components/DataTable/index.native.js.map +1 -1
- package/dist/cjs/components/DataTable/rowSlotParts.cjs +158 -0
- package/dist/cjs/components/DataTable/rowSlotParts.native.js +170 -0
- package/dist/cjs/components/DataTable/rowSlotParts.native.js.map +1 -0
- package/dist/cjs/components/DataTable/rowSlots.cjs +150 -0
- package/dist/cjs/components/DataTable/rowSlots.native.js +239 -0
- package/dist/cjs/components/DataTable/rowSlots.native.js.map +1 -0
- package/dist/cjs/components/DataTableFilterButton/index.cjs +25 -3
- package/dist/cjs/components/DataTableFilterButton/index.native.js +25 -3
- package/dist/cjs/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/cjs/components/DataTablePagination/index.cjs +23 -0
- package/dist/cjs/components/DataTablePagination/index.native.js +25 -0
- package/dist/cjs/components/DataTablePagination/index.native.js.map +1 -1
- package/dist/cjs/components/DataTableToolbar/glyph.cjs +54 -0
- package/dist/cjs/components/DataTableToolbar/glyph.native.js +57 -0
- package/dist/cjs/components/DataTableToolbar/glyph.native.js.map +1 -0
- package/dist/cjs/components/DataTableToolbar/index.cjs +206 -114
- package/dist/cjs/components/DataTableToolbar/index.native.js +217 -112
- package/dist/cjs/components/DataTableToolbar/index.native.js.map +1 -1
- package/dist/cjs/index.cjs +5 -1
- package/dist/cjs/index.native.js +5 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableCardControls.mjs +74 -13
- package/dist/esm/components/DataTable/DataTableCardControls.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableCardControls.native.js +83 -13
- package/dist/esm/components/DataTable/DataTableCardControls.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableDocumentList.mjs +179 -113
- package/dist/esm/components/DataTable/DataTableDocumentList.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableDocumentList.native.js +192 -123
- package/dist/esm/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs +261 -129
- package/dist/esm/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js +288 -158
- package/dist/esm/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.mjs +36 -7
- package/dist/esm/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/esm/components/DataTable/DataTableRoot.native.js +38 -7
- package/dist/esm/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/esm/components/DataTable/PhonePager.mjs +31 -0
- package/dist/esm/components/DataTable/PhonePager.mjs.map +1 -0
- package/dist/esm/components/DataTable/PhonePager.native.js +32 -0
- package/dist/esm/components/DataTable/PhonePager.native.js.map +1 -0
- package/dist/esm/components/DataTable/index.native.js +67 -10
- package/dist/esm/components/DataTable/index.native.js.map +1 -1
- package/dist/esm/components/DataTable/rowSlotParts.mjs +130 -0
- package/dist/esm/components/DataTable/rowSlotParts.mjs.map +1 -0
- package/dist/esm/components/DataTable/rowSlotParts.native.js +139 -0
- package/dist/esm/components/DataTable/rowSlotParts.native.js.map +1 -0
- package/dist/esm/components/DataTable/rowSlots.mjs +121 -0
- package/dist/esm/components/DataTable/rowSlots.mjs.map +1 -0
- package/dist/esm/components/DataTable/rowSlots.native.js +207 -0
- package/dist/esm/components/DataTable/rowSlots.native.js.map +1 -0
- package/dist/esm/components/DataTableFilterButton/index.mjs +24 -3
- package/dist/esm/components/DataTableFilterButton/index.mjs.map +1 -1
- package/dist/esm/components/DataTableFilterButton/index.native.js +24 -3
- package/dist/esm/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/esm/components/DataTablePagination/index.mjs +23 -0
- package/dist/esm/components/DataTablePagination/index.mjs.map +1 -1
- package/dist/esm/components/DataTablePagination/index.native.js +25 -0
- package/dist/esm/components/DataTablePagination/index.native.js.map +1 -1
- package/dist/esm/components/DataTableToolbar/glyph.mjs +27 -0
- package/dist/esm/components/DataTableToolbar/glyph.mjs.map +1 -0
- package/dist/esm/components/DataTableToolbar/glyph.native.js +27 -0
- package/dist/esm/components/DataTableToolbar/glyph.native.js.map +1 -0
- package/dist/esm/components/DataTableToolbar/index.mjs +211 -119
- package/dist/esm/components/DataTableToolbar/index.mjs.map +1 -1
- package/dist/esm/components/DataTableToolbar/index.native.js +222 -117
- package/dist/esm/components/DataTableToolbar/index.native.js.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableCardControls.mjs +74 -13
- package/dist/jsx/components/DataTable/DataTableCardControls.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableCardControls.native.js +83 -12
- package/dist/jsx/components/DataTable/DataTableCardControls.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableDocumentList.mjs +179 -113
- package/dist/jsx/components/DataTable/DataTableDocumentList.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableDocumentList.native.js +193 -124
- package/dist/jsx/components/DataTable/DataTableDocumentList.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs +261 -129
- package/dist/jsx/components/DataTable/DataTableMobileCards.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js +287 -156
- package/dist/jsx/components/DataTable/DataTableMobileCards.native.js.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.mjs +36 -7
- package/dist/jsx/components/DataTable/DataTableRoot.mjs.map +1 -1
- package/dist/jsx/components/DataTable/DataTableRoot.native.js +36 -5
- package/dist/jsx/components/DataTable/DataTableRoot.native.js.map +1 -1
- package/dist/jsx/components/DataTable/PhonePager.mjs +31 -0
- package/dist/jsx/components/DataTable/PhonePager.mjs.map +1 -0
- package/dist/jsx/components/DataTable/PhonePager.native.js +60 -0
- package/dist/jsx/components/DataTable/PhonePager.native.js.map +1 -0
- package/dist/jsx/components/DataTable/index.native.js +64 -7
- package/dist/jsx/components/DataTable/index.native.js.map +1 -1
- package/dist/jsx/components/DataTable/rowSlotParts.mjs +130 -0
- package/dist/jsx/components/DataTable/rowSlotParts.mjs.map +1 -0
- package/dist/jsx/components/DataTable/rowSlotParts.native.js +170 -0
- package/dist/jsx/components/DataTable/rowSlotParts.native.js.map +1 -0
- package/dist/jsx/components/DataTable/rowSlots.mjs +121 -0
- package/dist/jsx/components/DataTable/rowSlots.mjs.map +1 -0
- package/dist/jsx/components/DataTable/rowSlots.native.js +239 -0
- package/dist/jsx/components/DataTable/rowSlots.native.js.map +1 -0
- package/dist/jsx/components/DataTableFilterButton/index.mjs +24 -3
- package/dist/jsx/components/DataTableFilterButton/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableFilterButton/index.native.js +25 -3
- package/dist/jsx/components/DataTableFilterButton/index.native.js.map +1 -1
- package/dist/jsx/components/DataTablePagination/index.mjs +23 -0
- package/dist/jsx/components/DataTablePagination/index.mjs.map +1 -1
- package/dist/jsx/components/DataTablePagination/index.native.js +25 -0
- package/dist/jsx/components/DataTablePagination/index.native.js.map +1 -1
- package/dist/jsx/components/DataTableToolbar/glyph.mjs +27 -0
- package/dist/jsx/components/DataTableToolbar/glyph.mjs.map +1 -0
- package/dist/jsx/components/DataTableToolbar/glyph.native.js +57 -0
- package/dist/jsx/components/DataTableToolbar/glyph.native.js.map +1 -0
- package/dist/jsx/components/DataTableToolbar/index.mjs +211 -119
- package/dist/jsx/components/DataTableToolbar/index.mjs.map +1 -1
- package/dist/jsx/components/DataTableToolbar/index.native.js +217 -112
- package/dist/jsx/components/DataTableToolbar/index.native.js.map +1 -1
- package/dist/jsx/index.js +2 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +5 -1
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +12 -12
- package/src/components/DataTable/DataTable.spec.tsx +12 -9
- package/src/components/DataTable/DataTable.stories.tsx +110 -43
- package/src/components/DataTable/DataTableCardControls.tsx +103 -24
- package/src/components/DataTable/DataTableDocumentList.stories.tsx +113 -0
- package/src/components/DataTable/DataTableDocumentList.tsx +210 -120
- package/src/components/DataTable/DataTableMobileCards.tsx +280 -147
- package/src/components/DataTable/DataTableRoot.tsx +56 -5
- package/src/components/DataTable/PhonePager.tsx +44 -0
- package/src/components/DataTable/cardLayout.spec.tsx +20 -12
- package/src/components/DataTable/cardToolbar.spec.tsx +31 -26
- package/src/components/DataTable/dataTableCardControls.spec.tsx +10 -9
- package/src/components/DataTable/dataTableDocumentList.spec.tsx +98 -10
- package/src/components/DataTable/dataTableMobileCards.spec.tsx +29 -14
- package/src/components/DataTable/index.native.tsx +90 -9
- package/src/components/DataTable/nativeCardParity.spec.tsx +15 -0
- package/src/components/DataTable/pageRange.spec.tsx +12 -1
- package/src/components/DataTable/rowSlotParts.tsx +184 -0
- package/src/components/DataTable/rowSlots.ts +239 -0
- package/src/components/DataTable/smallTableFooter.spec.tsx +10 -0
- package/src/components/DataTableFilterButton/DataTableFilterButton.spec.tsx +3 -3
- package/src/components/DataTableFilterButton/index.tsx +30 -2
- package/src/components/DataTablePagination/index.tsx +30 -0
- package/src/components/DataTableToolbar/DataTableToolbar.spec.tsx +10 -0
- package/src/components/DataTableToolbar/DataTableToolbar.stories.tsx +16 -7
- package/src/components/DataTableToolbar/compactRow.spec.tsx +197 -0
- package/src/components/DataTableToolbar/glyph.ts +33 -0
- package/src/components/DataTableToolbar/index.tsx +269 -131
- package/src/components/Table/accessibility.spec.tsx +4 -3
- package/src/components/noMiddotJoin.spec.tsx +315 -0
- package/src/components/phoneBottomAccessory.spec.tsx +218 -0
- package/src/components/phoneCardPolish.spec.tsx +214 -0
- package/src/components/phoneCardsDefault.spec.tsx +34 -6
- package/src/components/phonePager.spec.tsx +141 -0
- package/src/components/tableDropdowns.spec.tsx +4 -3
- package/src/index.ts +5 -0
- package/src/types.ts +23 -0
- package/types/components/DataTable/DataTableCardControls.d.ts +12 -0
- package/types/components/DataTable/DataTableCardControls.d.ts.map +1 -1
- package/types/components/DataTable/DataTableDocumentList.d.ts +13 -7
- package/types/components/DataTable/DataTableDocumentList.d.ts.map +1 -1
- package/types/components/DataTable/DataTableMobileCards.d.ts +38 -12
- package/types/components/DataTable/DataTableMobileCards.d.ts.map +1 -1
- package/types/components/DataTable/DataTableRoot.d.ts +1 -1
- package/types/components/DataTable/DataTableRoot.d.ts.map +1 -1
- package/types/components/DataTable/PhonePager.d.ts +24 -0
- package/types/components/DataTable/PhonePager.d.ts.map +1 -0
- package/types/components/DataTable/index.native.d.ts +1 -1
- package/types/components/DataTable/index.native.d.ts.map +1 -1
- package/types/components/DataTable/rowSlotParts.d.ts +30 -0
- package/types/components/DataTable/rowSlotParts.d.ts.map +1 -0
- package/types/components/DataTable/rowSlots.d.ts +74 -0
- package/types/components/DataTable/rowSlots.d.ts.map +1 -0
- package/types/components/DataTableFilterButton/index.d.ts +1 -0
- package/types/components/DataTableFilterButton/index.d.ts.map +1 -1
- package/types/components/DataTablePagination/index.d.ts +5 -0
- package/types/components/DataTablePagination/index.d.ts.map +1 -1
- package/types/components/DataTableToolbar/glyph.d.ts +65 -0
- package/types/components/DataTableToolbar/glyph.d.ts.map +1 -0
- package/types/components/DataTableToolbar/index.d.ts +24 -0
- package/types/components/DataTableToolbar/index.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +23 -0
- package/types/types.d.ts.map +1 -1
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
EmptyState,
|
|
34
34
|
Tooltip,
|
|
35
35
|
useDirection,
|
|
36
|
+
useRevealTop,
|
|
36
37
|
Text,
|
|
37
38
|
} from "@multiplatform.one/components";
|
|
38
39
|
import type { FontSizeTokens, SizeTokens } from "tamagui";
|
|
@@ -50,6 +51,7 @@ import type {
|
|
|
50
51
|
} from "../../types";
|
|
51
52
|
import { DataTableColumnPinning } from "../DataTableColumnPinning";
|
|
52
53
|
import { DataTablePagination } from "../DataTablePagination";
|
|
54
|
+
import { PhonePager } from "./PhonePager";
|
|
53
55
|
import { DataTableCardToolbar, DataTableToolbar } from "../DataTableToolbar";
|
|
54
56
|
import { DataTableBulkActions } from "../DataTableBulkActions";
|
|
55
57
|
import { DataTableCell } from "../DataTableCell";
|
|
@@ -79,7 +81,7 @@ import { tableCellKeyboardProps, tableRowStateProps } from "./rowStateChrome";
|
|
|
79
81
|
import { warnColumnWidthIgnored } from "../../shared/devWarn";
|
|
80
82
|
import { alignToFlex, getDefaultColumnAlign } from "../../utils/columnAlign";
|
|
81
83
|
import { mapFieldToFilterType } from "../../utils/filterFields";
|
|
82
|
-
import { INFINITE_TRIGGER_ROWS } from "../../utils/paginationDefaults";
|
|
84
|
+
import { DEFAULT_PAGE_SIZE_OPTIONS, INFINITE_TRIGGER_ROWS } from "../../utils/paginationDefaults";
|
|
83
85
|
import { isInteractiveInnerTarget } from "../../utils/rowPress";
|
|
84
86
|
import { bidiIsolate, withInterp } from "../../utils/withInterp";
|
|
85
87
|
|
|
@@ -159,6 +161,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
159
161
|
onRowPress,
|
|
160
162
|
rowLabel,
|
|
161
163
|
enableRowSelection = false,
|
|
164
|
+
selectMode = false,
|
|
162
165
|
selectAllScope: selectAllScopeProp,
|
|
163
166
|
bulkActions,
|
|
164
167
|
readOnly = false,
|
|
@@ -1164,6 +1167,24 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1164
1167
|
table.getVisibleLeafColumns().some((column) => column.getCanSort());
|
|
1165
1168
|
const defaultCardToolbar = showCards && !renderToolbar;
|
|
1166
1169
|
const ToolbarComponent = defaultCardToolbar ? DataTableCardToolbar : DataTableToolbar;
|
|
1170
|
+
// FZ-7889: at the compact width the pager is one row of dots, so rows per
|
|
1171
|
+
// page moves into the toolbar's view menu. A table that fits its smallest
|
|
1172
|
+
// page has nothing to choose, so it gets no menu and no toolbar row for it.
|
|
1173
|
+
const viewMenuSizes = pageSizeOptions ?? [...DEFAULT_PAGE_SIZE_OPTIONS];
|
|
1174
|
+
const viewMenu =
|
|
1175
|
+
sm === false &&
|
|
1176
|
+
enablePagination &&
|
|
1177
|
+
!infinite &&
|
|
1178
|
+
!renderPagination &&
|
|
1179
|
+
!renderToolbar &&
|
|
1180
|
+
table.getRowCount() > Math.min(state.pagination.pageSize, ...viewMenuSizes)
|
|
1181
|
+
? {
|
|
1182
|
+
value: state.pagination.pageSize,
|
|
1183
|
+
options: viewMenuSizes,
|
|
1184
|
+
onChange: (pageSize: number) => actions.setPagination({ pageIndex: 0, pageSize }),
|
|
1185
|
+
disabled,
|
|
1186
|
+
}
|
|
1187
|
+
: undefined;
|
|
1167
1188
|
const renderToolbarComponent = () => {
|
|
1168
1189
|
const activeFilterCount = table.getState().columnFilters?.length || 0;
|
|
1169
1190
|
|
|
@@ -1186,11 +1207,12 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1186
1207
|
globalFilter={state.globalFilter || ""}
|
|
1187
1208
|
onGlobalFilterChange={actions.setGlobalFilter}
|
|
1188
1209
|
onClearFilters={actions.clearFilters}
|
|
1189
|
-
|
|
1210
|
+
fieldActions={
|
|
1190
1211
|
defaultCardToolbar && hasCardSort ? (
|
|
1191
1212
|
<DataTableCardSortControl table={table} disabled={disabled} contained />
|
|
1192
1213
|
) : undefined
|
|
1193
1214
|
}
|
|
1215
|
+
pageSize={viewMenu}
|
|
1194
1216
|
activeFilterCount={activeFilterCount}
|
|
1195
1217
|
onSaveView={actions.saveView}
|
|
1196
1218
|
onLoadView={actions.loadView}
|
|
@@ -1201,6 +1223,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1201
1223
|
enableFiltering={enableFiltering}
|
|
1202
1224
|
size={knobProps.sizeToken}
|
|
1203
1225
|
isFetching={Boolean(state.isFetching)}
|
|
1226
|
+
divider={!showCards && !(showList && sm === false)}
|
|
1204
1227
|
/>
|
|
1205
1228
|
);
|
|
1206
1229
|
};
|
|
@@ -1236,7 +1259,11 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1236
1259
|
) => Promise<void>,
|
|
1237
1260
|
) => {
|
|
1238
1261
|
const hasToolbar =
|
|
1239
|
-
enableGlobalSearch ||
|
|
1262
|
+
enableGlobalSearch ||
|
|
1263
|
+
enableFiltering ||
|
|
1264
|
+
enableViews ||
|
|
1265
|
+
Boolean(viewMenu) ||
|
|
1266
|
+
(defaultCardToolbar && hasCardSort);
|
|
1240
1267
|
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
|
1241
1268
|
|
|
1242
1269
|
// DF-12 / Axiom 6 HONEST STATE — a height-constrained body clips rows
|
|
@@ -1266,6 +1293,19 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1266
1293
|
// and column pinning share the content-View scrollport).
|
|
1267
1294
|
useDragScroll(scrollContainerRef, hScroll && !isSSR);
|
|
1268
1295
|
|
|
1296
|
+
// FZ-7889: turning the page replaces the rows in place, so a reader who
|
|
1297
|
+
// had scrolled down the last page lands mid-way through the new one.
|
|
1298
|
+
// The page scrolls back to the table's top, as a list reloads at its
|
|
1299
|
+
// first row; a table whose top is still on screen stays put.
|
|
1300
|
+
const pageReveal = useRevealTop();
|
|
1301
|
+
const shownPage = state.pagination.pageIndex;
|
|
1302
|
+
const lastShownPage = useRef(shownPage);
|
|
1303
|
+
useEffect(() => {
|
|
1304
|
+
if (lastShownPage.current === shownPage) return;
|
|
1305
|
+
lastShownPage.current = shownPage;
|
|
1306
|
+
if (enablePagination && !infinite) pageReveal.reveal();
|
|
1307
|
+
}, [shownPage, enablePagination, infinite, pageReveal]);
|
|
1308
|
+
|
|
1269
1309
|
// Visible row range for the footer summary (1-based, clamped to total).
|
|
1270
1310
|
const rangeTotal = state.pagination.totalCount ?? 0;
|
|
1271
1311
|
const rangeStart =
|
|
@@ -1340,6 +1380,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1340
1380
|
...(isWeb ? ({ inert: true } as any) : { pointerEvents: "none" as const }),
|
|
1341
1381
|
}
|
|
1342
1382
|
: {})}
|
|
1383
|
+
ref={pageReveal.ref as never}
|
|
1343
1384
|
{...props}
|
|
1344
1385
|
>
|
|
1345
1386
|
<Surface size={resolvedSize}>
|
|
@@ -1387,6 +1428,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
1387
1428
|
selectRowLabel={deriveSelectRowLabel}
|
|
1388
1429
|
queryInFlight={queryInFlight}
|
|
1389
1430
|
bleed={bleed}
|
|
1431
|
+
selectMode={selectMode}
|
|
1390
1432
|
{...(rowPressActive ? { getRowPressProps } : {})}
|
|
1391
1433
|
/>
|
|
1392
1434
|
) : showCards ? (
|
|
@@ -2331,7 +2373,16 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
2331
2373
|
</Surface>
|
|
2332
2374
|
|
|
2333
2375
|
{/* Pagination footer (pages mode only; infinite replaces it with the tail status) */}
|
|
2334
|
-
{enablePagination && !infinite && (
|
|
2376
|
+
{enablePagination && !infinite && sm === false && !renderPagination && (
|
|
2377
|
+
<PhonePager
|
|
2378
|
+
value={stateContextValue}
|
|
2379
|
+
disabled={disabled}
|
|
2380
|
+
chrome={disabled ? disabledState.chromeKnobProps : undefined}
|
|
2381
|
+
>
|
|
2382
|
+
{renderPaginationComponent()}
|
|
2383
|
+
</PhonePager>
|
|
2384
|
+
)}
|
|
2385
|
+
{enablePagination && !infinite && (sm !== false || renderPagination) && (
|
|
2335
2386
|
<View
|
|
2336
2387
|
paddingTop="$3"
|
|
2337
2388
|
flexDirection="row"
|
|
@@ -2345,7 +2396,7 @@ export function DataTableRoot<TData extends Record<string, any> = Record<string,
|
|
|
2345
2396
|
{/* DF-12 / Axiom 6: visible range/total — the footer states how
|
|
2346
2397
|
many rows exist even when a height-constrained body clips
|
|
2347
2398
|
some below the fold ("1–6 of 6", not "what you see is all"). */}
|
|
2348
|
-
{showPageRange ? (
|
|
2399
|
+
{showPageRange && sm !== false ? (
|
|
2349
2400
|
<TamaguiText
|
|
2350
2401
|
fontSize={knobProps.sizeToken}
|
|
2351
2402
|
color="$color11"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LC-174 BOTTOM-ACCESSORY: at the compact width a DataTable's pager is the
|
|
3
|
+
* page's bottom accessory. It renders in the page's bottom slot when a
|
|
4
|
+
* `Screen` hosts one, so it stays at the bottom of the screen while the cards
|
|
5
|
+
* scroll; with no slot it stays in the table's footer (a sticky bar on web).
|
|
6
|
+
*
|
|
7
|
+
* The slot renders the pager outside the table's tree, so the table's state
|
|
8
|
+
* context travels with it, and so does a disabled table's dead input (the
|
|
9
|
+
* table's own `inert` frame no longer covers it). A single-page table has no
|
|
10
|
+
* pager and registers nothing, so the page draws no empty bar. A custom
|
|
11
|
+
* `renderPagination` stays in the table: it may read contexts the slot does
|
|
12
|
+
* not carry.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { BottomAccessory } from "@multiplatform.one/components";
|
|
16
|
+
import type { DisabledChromeProps } from "@multiplatform.one/theme";
|
|
17
|
+
import type { ReactNode } from "react";
|
|
18
|
+
import { View } from "tamagui";
|
|
19
|
+
import { DataTableStateContext, type DataTableStateContextValue } from "./DataTableStateContext";
|
|
20
|
+
|
|
21
|
+
export interface PhonePagerProps {
|
|
22
|
+
value: DataTableStateContextValue<any>;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
chrome?: DisabledChromeProps;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function PhonePager({ value, disabled = false, chrome, children }: PhonePagerProps) {
|
|
29
|
+
if (value.computed.totalPages <= 1) return null;
|
|
30
|
+
return (
|
|
31
|
+
<BottomAccessory>
|
|
32
|
+
<DataTableStateContext.Provider value={value}>
|
|
33
|
+
<View
|
|
34
|
+
width="100%"
|
|
35
|
+
{...({ "data-table-phone-pager": "true" } as object)}
|
|
36
|
+
{...(disabled ? { pointerEvents: "none" as const, "aria-disabled": true } : null)}
|
|
37
|
+
{...chrome}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</View>
|
|
41
|
+
</DataTableStateContext.Provider>
|
|
42
|
+
</BottomAccessory>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -140,18 +140,26 @@ describe("DataTable card layout", () => {
|
|
|
140
140
|
expect(title!.textContent).toContain("John");
|
|
141
141
|
expect(within(firstCard).queryByText("First Name")).toBeNull();
|
|
142
142
|
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
|
|
143
|
+
// LC-261: line 2 is the subtitle and its facts, no " · " run. The
|
|
144
|
+
// email is the one subtitle; its column name reaches assistive tech
|
|
145
|
+
// through a hidden node that costs no layout.
|
|
146
|
+
const subtitle = firstCard.querySelector('[data-card-slot="subtitle"]');
|
|
147
|
+
expect(subtitle?.textContent).toContain("john@example.com");
|
|
146
148
|
expect(within(firstCard).queryByText("Email")).toBeNull();
|
|
147
|
-
expect(firstCard.textContent).toContain("Last Name:");
|
|
148
149
|
expect(firstCard.textContent).toContain("Email:");
|
|
149
150
|
|
|
150
|
-
// A figure
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
expect(
|
|
154
|
-
expect(firstCard
|
|
151
|
+
// A figure is an icon fact (LC-260): the glyph names it, so "Age"
|
|
152
|
+
// never prints, and the name stays with assistive tech.
|
|
153
|
+
const fact = firstCard.querySelector('[data-card-slot="fact"]');
|
|
154
|
+
expect(fact?.textContent).toContain("28");
|
|
155
|
+
expect(within(firstCard).queryByText("Age")).toBeNull();
|
|
156
|
+
expect(firstCard.textContent).toContain("Age:");
|
|
157
|
+
|
|
158
|
+
// A second text column has no slot beside the email subtitle, so it
|
|
159
|
+
// stays in the grid and the detail view instead of joining a run.
|
|
160
|
+
expect(firstCard.textContent).not.toContain("Doe");
|
|
161
|
+
expect(firstCard.textContent).not.toContain("Last Name:");
|
|
162
|
+
expect(firstCard.textContent).not.toContain("·");
|
|
155
163
|
});
|
|
156
164
|
|
|
157
165
|
it("names a control from meta.label when the header is a render function", () => {
|
|
@@ -188,9 +196,9 @@ describe("DataTable card layout", () => {
|
|
|
188
196
|
<DataTable data={sampleData} columns={mixedColumns} onStateChange={vi.fn()} />,
|
|
189
197
|
);
|
|
190
198
|
const [firstCard] = getCards(container);
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
expect(
|
|
199
|
+
// No label prints on a card (LC-260/261). meta.label still names the
|
|
200
|
+
// fact for assistive tech, and the id fallback stays honest.
|
|
201
|
+
expect(firstCard.textContent).toContain("Age (years):");
|
|
194
202
|
expect(within(firstCard).queryByText("♥")).toBeNull();
|
|
195
203
|
expect(firstCard.textContent).toContain("email_addr:");
|
|
196
204
|
});
|
|
@@ -48,33 +48,34 @@ function AllCardActionsToolbar(props: Record<string, any>) {
|
|
|
48
48
|
enableExport
|
|
49
49
|
enableViews
|
|
50
50
|
isFetching
|
|
51
|
-
|
|
51
|
+
fieldActions={<DataTableCardSortControl table={table} contained />}
|
|
52
52
|
/>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
describe("default card toolbar", () => {
|
|
57
|
-
it("owns Filter and Sort in one
|
|
57
|
+
it("owns Filter and Sort in the one toolbar row with no duplicate controls", () => {
|
|
58
58
|
const { container } = renderWithProviders(<Cards />);
|
|
59
59
|
const toolbar = screen.getByRole("toolbar", { name: "Table toolbar" });
|
|
60
60
|
expect(screen.getAllByRole("toolbar")).toHaveLength(1);
|
|
61
|
-
const primary = container.querySelector<HTMLElement>("[data-table-
|
|
61
|
+
const primary = container.querySelector<HTMLElement>("[data-table-toolbar-actions]")!;
|
|
62
62
|
expect(toolbar.contains(primary)).toBe(true);
|
|
63
63
|
expect(primary.contains(screen.getByRole("button", { name: FILTER_NAME }))).toBe(true);
|
|
64
64
|
expect(primary.contains(screen.getByLabelText("Sort rows"))).toBe(true);
|
|
65
65
|
expect(screen.queryByText("Add Filter")).toBeNull();
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
it("keeps search and
|
|
68
|
+
it("keeps search and the fetching spinner in the row, and save view behind More", async () => {
|
|
69
69
|
const { container } = renderWithProviders(<Cards enableGlobalSearch enableViews isFetching />);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
expect(primary).not.toBeNull();
|
|
73
|
-
expect(secondary).not.toBeNull();
|
|
70
|
+
const row = screen.getByRole("toolbar", { name: "Table toolbar" });
|
|
71
|
+
const primary = container.querySelector<HTMLElement>("[data-table-toolbar-actions]")!;
|
|
74
72
|
expect(primary.contains(screen.getByLabelText("Search table data"))).toBe(false);
|
|
75
|
-
expect(
|
|
76
|
-
expect(
|
|
77
|
-
expect(primary.
|
|
73
|
+
expect(row.contains(screen.getByLabelText("Search table data"))).toBe(true);
|
|
74
|
+
expect(row.querySelector("[data-table-fetching]")).not.toBeNull();
|
|
75
|
+
expect(primary.querySelector("[data-table-fetching]")).toBeNull();
|
|
76
|
+
expect(screen.queryByLabelText("Save view")).toBeNull();
|
|
77
|
+
fireEvent.click(within(primary).getByRole("button", { name: "More table actions" }));
|
|
78
|
+
expect(await screen.findByRole("textbox", { name: "View name" })).toBeTruthy();
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
it("keeps a sort-only toolbar when search, filtering and views are all off", () => {
|
|
@@ -94,7 +95,7 @@ describe("default card toolbar", () => {
|
|
|
94
95
|
expect(screen.queryByRole("toolbar")).toBeNull();
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
it("exposes the full active sorting identity
|
|
98
|
+
it("exposes the full active sorting identity on the bare sort glyph", () => {
|
|
98
99
|
const longHeader = "Form with a deliberately long distinguishing classification suffix";
|
|
99
100
|
renderWithProviders(
|
|
100
101
|
<Cards
|
|
@@ -104,7 +105,8 @@ describe("default card toolbar", () => {
|
|
|
104
105
|
);
|
|
105
106
|
const trigger = screen.getByLabelText("Sort rows");
|
|
106
107
|
expect(trigger.getAttribute("aria-description")).toBe(`${longHeader} ↓`);
|
|
107
|
-
expect(trigger.
|
|
108
|
+
expect(trigger.hasAttribute("data-table-toolbar-glyph")).toBe(true);
|
|
109
|
+
expect(trigger.textContent).toBe("");
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
it("retains hidden Year filtering, chip edit and removal in readOnly cards", async () => {
|
|
@@ -155,7 +157,7 @@ describe("default card toolbar", () => {
|
|
|
155
157
|
expect(screen.getByRole("toolbar", { name: "Card list controls" })).toBeTruthy();
|
|
156
158
|
});
|
|
157
159
|
|
|
158
|
-
it("
|
|
160
|
+
it("moves export, a long saved view and save behind More, apart from Filter and Sort", async () => {
|
|
159
161
|
const name = "Saved view with a deliberately long distinguishing classification suffix";
|
|
160
162
|
const { container } = renderWithProviders(
|
|
161
163
|
<Cards
|
|
@@ -176,17 +178,20 @@ describe("default card toolbar", () => {
|
|
|
176
178
|
renderToolbar={(props: any) => <AllCardActionsToolbar {...props} />}
|
|
177
179
|
/>,
|
|
178
180
|
);
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
+
const row = screen.getByRole("toolbar", { name: "Table toolbar" });
|
|
182
|
+
const primary = container.querySelector<HTMLElement>("[data-table-toolbar-actions]")!;
|
|
181
183
|
expect(within(primary).getByLabelText("Sort rows")).toBeTruthy();
|
|
182
184
|
expect(within(primary).getByRole("button", { name: FILTER_NAME })).toBeTruthy();
|
|
183
|
-
expect(
|
|
184
|
-
expect(within(
|
|
185
|
-
expect(within(secondary).getByLabelText("Save view")).toBeTruthy();
|
|
186
|
-
expect(secondary.querySelector("[data-table-fetching]")).not.toBeNull();
|
|
187
|
-
expect(within(primary).queryByLabelText("Saved views")).toBeNull();
|
|
185
|
+
expect(row.querySelector("[data-table-fetching]")).not.toBeNull();
|
|
186
|
+
expect(within(row).queryByLabelText("Saved views")).toBeNull();
|
|
188
187
|
const sort = primary.querySelector("[data-table-card-sort]")!;
|
|
189
188
|
expect(sort.contains(within(primary).getByLabelText("Sort rows"))).toBe(true);
|
|
189
|
+
fireEvent.click(within(primary).getByRole("button", { name: "More table actions" }));
|
|
190
|
+
await waitFor(() => expect(document.querySelector("[data-table-toolbar-more]")).not.toBeNull());
|
|
191
|
+
const more = document.querySelector<HTMLElement>("[data-table-toolbar-more]")!;
|
|
192
|
+
expect(within(more).getByRole("button", { name: /Export as CSV/ })).toBeTruthy();
|
|
193
|
+
expect(within(more).getByLabelText("Saved views").textContent).toContain(name);
|
|
194
|
+
expect(within(more).getByRole("textbox", { name: "View name" })).toBeTruthy();
|
|
190
195
|
});
|
|
191
196
|
|
|
192
197
|
it("retains hidden filters and sort order when cards change to grid and back", () => {
|
|
@@ -226,7 +231,7 @@ describe("default card toolbar", () => {
|
|
|
226
231
|
expect(screen.queryByRole("button", { name: /Edit filter/ })).toBeNull();
|
|
227
232
|
});
|
|
228
233
|
|
|
229
|
-
it("
|
|
234
|
+
it("gives the public standalone toolbar the same one row on a phone", () => {
|
|
230
235
|
const { container } = renderWithProviders(
|
|
231
236
|
<DataTableToolbar
|
|
232
237
|
enableGlobalSearch
|
|
@@ -234,9 +239,9 @@ describe("default card toolbar", () => {
|
|
|
234
239
|
customActions={<button type="button">Custom action</button>}
|
|
235
240
|
/>,
|
|
236
241
|
);
|
|
237
|
-
|
|
238
|
-
expect(
|
|
239
|
-
|
|
240
|
-
expect(screen.getByText("Custom action")).
|
|
242
|
+
const row = container.querySelector<HTMLElement>("[data-table-toolbar-row]")!;
|
|
243
|
+
expect(row.contains(screen.getByLabelText("Search table data"))).toBe(true);
|
|
244
|
+
const custom = row.querySelector<HTMLElement>("[data-table-toolbar-custom]")!;
|
|
245
|
+
expect(custom.contains(screen.getByText("Custom action"))).toBe(true);
|
|
241
246
|
});
|
|
242
247
|
});
|
|
@@ -74,28 +74,29 @@ describe("DataTableCardControls", () => {
|
|
|
74
74
|
expect(screen.queryByText("Add Filter")).toBeNull();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
// FZ-8039: the trigger is a bare glyph; the active sort is its description.
|
|
78
|
+
it("with no sort applied the glyph carries no sort description", () => {
|
|
78
79
|
renderCards({ enableSorting: true });
|
|
79
|
-
expect(sortTrigger().textContent).
|
|
80
|
-
expect(sortTrigger().
|
|
80
|
+
expect(sortTrigger().textContent).toBe("");
|
|
81
|
+
expect(sortTrigger().getAttribute("aria-description")).toBeNull();
|
|
81
82
|
});
|
|
82
83
|
|
|
83
|
-
it("an active ascending sort is named
|
|
84
|
+
it("an active ascending sort is named in the glyph's description, arrow and all", () => {
|
|
84
85
|
renderCards({ enableSorting: true, initialState: { sorting: [{ id: "age", desc: false }] } });
|
|
85
|
-
expect(sortTrigger().
|
|
86
|
+
expect(sortTrigger().getAttribute("aria-description")).toBe("Age ↑");
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
it("an active descending sort flips the arrow
|
|
89
|
+
it("an active descending sort flips the arrow in the glyph's description", () => {
|
|
89
90
|
renderCards({ enableSorting: true, initialState: { sorting: [{ id: "age", desc: true }] } });
|
|
90
|
-
expect(sortTrigger().
|
|
91
|
+
expect(sortTrigger().getAttribute("aria-description")).toBe("Age ↓");
|
|
91
92
|
});
|
|
92
93
|
|
|
93
|
-
it("picking a column from the menu updates the
|
|
94
|
+
it("picking a column from the menu updates the glyph's description", async () => {
|
|
94
95
|
renderCards({ enableSorting: true });
|
|
95
96
|
fireEvent.click(sortTrigger());
|
|
96
97
|
fireEvent.click(await screen.findByLabelText("Sort by Age"));
|
|
97
98
|
await waitFor(() => {
|
|
98
|
-
expect(sortTrigger().
|
|
99
|
+
expect(sortTrigger().getAttribute("aria-description")).toBe("Age ↑");
|
|
99
100
|
});
|
|
100
101
|
});
|
|
101
102
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
14
|
-
import { screen, waitFor } from "@testing-library/react";
|
|
14
|
+
import { fireEvent, screen, waitFor } from "@testing-library/react";
|
|
15
15
|
import { describe, expect, it, vi } from "vitest";
|
|
16
16
|
import type { DataTableColumn, TableFilter } from "../../types";
|
|
17
17
|
import { documentListShowsCheckboxes } from "./DataTableDocumentList";
|
|
@@ -53,7 +53,38 @@ describe("DataTableDocumentList", () => {
|
|
|
53
53
|
);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("
|
|
56
|
+
it("parts rows with a border from the text's leading edge, never a sub-pixel filled line Blink can drop", () => {
|
|
57
|
+
const { container } = renderList();
|
|
58
|
+
const rows = Array.from(
|
|
59
|
+
container.querySelectorAll('[data-testid="data-table-list-row"]'),
|
|
60
|
+
) as HTMLElement[];
|
|
61
|
+
expect(rows).toHaveLength(tasks.length);
|
|
62
|
+
const content = rows.map(
|
|
63
|
+
(row) => row.querySelector<HTMLElement>('[data-list-slot="content"]')!,
|
|
64
|
+
);
|
|
65
|
+
expect(content[1].contains(rows[1].querySelector('[data-list-slot="title"]'))).toBe(true);
|
|
66
|
+
expect(getComputedStyle(rows[1]).borderTopWidth).toMatch(/^(0px|)$/);
|
|
67
|
+
expect(getComputedStyle(content[0]).borderTopWidth).toMatch(/^(0px|)$/);
|
|
68
|
+
expect(parseFloat(getComputedStyle(content[1]).borderTopWidth)).toBeGreaterThan(0);
|
|
69
|
+
expect(container.querySelector('[data-testid="data-table-list"] .mp-hairline-h')).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("is one inset group on the Card theme on a phone, its rows painting the group's fill", () => {
|
|
73
|
+
const width = window.innerWidth;
|
|
74
|
+
window.innerWidth = 390;
|
|
75
|
+
try {
|
|
76
|
+
const { container } = renderList();
|
|
77
|
+
const list = container.querySelector<HTMLElement>('[data-testid="data-table-list"]')!;
|
|
78
|
+
const row = list.querySelector<HTMLElement>('[data-testid="data-table-list-row"]')!;
|
|
79
|
+
const bg = (el: Element) => Array.from(el.classList).find((name) => /^_bg-(?!0)/.test(name));
|
|
80
|
+
expect(bg(list)).toBeDefined();
|
|
81
|
+
expect(bg(row)).toBe(bg(list));
|
|
82
|
+
} finally {
|
|
83
|
+
window.innerWidth = width;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("puts compact numbers in the meta line as glyph facts,the status beside the title and activity on the right (LC-261)", () => {
|
|
57
88
|
const width = window.innerWidth;
|
|
58
89
|
window.innerWidth = 390;
|
|
59
90
|
try {
|
|
@@ -67,19 +98,26 @@ describe("DataTableDocumentList", () => {
|
|
|
67
98
|
],
|
|
68
99
|
});
|
|
69
100
|
const row = container.querySelector('[data-testid="data-table-list-row"]')!;
|
|
70
|
-
|
|
101
|
+
// The title shares its line with the status, so the subject column is
|
|
102
|
+
// the title line's parent.
|
|
103
|
+
const subject = row.querySelector('[data-list-slot="title"]')!.parentElement!.parentElement!;
|
|
71
104
|
expect(getComputedStyle(row).flexWrap).toBe("nowrap");
|
|
72
105
|
expect(getComputedStyle(subject).flexGrow).toBe("1");
|
|
73
106
|
expect(getComputedStyle(subject).minWidth).toBe("0px");
|
|
74
107
|
const metaLine = subject.querySelector('[data-list-slot="meta-line"]')!;
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
expect(metaLine.querySelector('[data-list-slot="labelled-meta"]')).toBeNull();
|
|
109
|
+
const fact = metaLine.querySelector('[data-list-slot="fact"]')!;
|
|
110
|
+
expect(fact.querySelector("svg")).not.toBeNull();
|
|
111
|
+
expect(fact.textContent).toBe("Points: 1");
|
|
77
112
|
expect(row.querySelector('[data-list-slot="trailing"]')).toBeNull();
|
|
113
|
+
expect(
|
|
114
|
+
Array.from(subject.querySelectorAll('[data-list-slot="status"]')).map((n) => n.textContent),
|
|
115
|
+
).toEqual(["Open", "Open"]);
|
|
78
116
|
const cluster = row.querySelector('[data-list-slot="trailing-cluster"]')!;
|
|
117
|
+
// LC-155: the desk's activity time is the row's top-right caption.
|
|
118
|
+
expect(getComputedStyle(cluster).alignSelf).toBe("flex-start");
|
|
79
119
|
expect(subject.contains(cluster)).toBe(false);
|
|
80
|
-
|
|
81
|
-
expect(cluster.contains(row.querySelector(`[data-list-slot="${slot}"]`))).toBe(true);
|
|
82
|
-
}
|
|
120
|
+
expect(cluster.contains(row.querySelector('[data-list-slot="actions"]'))).toBe(true);
|
|
83
121
|
} finally {
|
|
84
122
|
window.innerWidth = width;
|
|
85
123
|
}
|
|
@@ -179,7 +217,8 @@ describe("DataTableDocumentList", () => {
|
|
|
179
217
|
Array.from(lines[0].querySelectorAll('[data-list-slot="meta"]')).map((n) => n.textContent),
|
|
180
218
|
).toEqual(["Ada", "Core", "Paris"]);
|
|
181
219
|
// The subject column holds exactly two lines: the title and that meta line.
|
|
182
|
-
const subject = row.querySelector('[data-list-slot="title"]')?.parentElement
|
|
220
|
+
const subject = row.querySelector('[data-list-slot="title"]')?.parentElement
|
|
221
|
+
?.parentElement as HTMLElement;
|
|
183
222
|
expect(subject.children.length).toBe(2);
|
|
184
223
|
});
|
|
185
224
|
|
|
@@ -261,6 +300,35 @@ describe("DataTableDocumentList", () => {
|
|
|
261
300
|
).toBe(false);
|
|
262
301
|
});
|
|
263
302
|
|
|
303
|
+
it("select mode draws Mail's round mark centred before the row, a tap on it selects (FZ-8039)", async () => {
|
|
304
|
+
const width = window.innerWidth;
|
|
305
|
+
window.innerWidth = 390;
|
|
306
|
+
try {
|
|
307
|
+
const { container } = renderList({ enableRowSelection: true, selectMode: true });
|
|
308
|
+
const marks = screen.getAllByRole("checkbox", { name: /^Select row / });
|
|
309
|
+
expect(marks).toHaveLength(tasks.length);
|
|
310
|
+
const mark = container.querySelector('[data-list-slot="select-mark"]')!;
|
|
311
|
+
expect(getComputedStyle(mark).alignSelf).toBe("center");
|
|
312
|
+
expect(mark.getAttribute("aria-checked")).toBe("false");
|
|
313
|
+
const row = container.querySelector('[data-testid="data-table-list-row"]')!;
|
|
314
|
+
expect(row.firstElementChild).toBe(mark);
|
|
315
|
+
fireEvent.click(mark);
|
|
316
|
+
await waitFor(() => expect(mark.getAttribute("aria-checked")).toBe("true"));
|
|
317
|
+
} finally {
|
|
318
|
+
window.innerWidth = width;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("stripes no rows on a phone, whatever the zebra knob (LC-144)", () => {
|
|
323
|
+
atPhone(() => {
|
|
324
|
+
const { container } = renderList();
|
|
325
|
+
const zebra = Array.from(
|
|
326
|
+
container.querySelectorAll('[data-testid="data-table-list-row"]'),
|
|
327
|
+
).map((row) => row.getAttribute("data-table-zebra"));
|
|
328
|
+
expect(zebra.every((value) => value === "off")).toBe(true);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
264
332
|
it("puts the row's date at the top right as a caption, out of the meta line", () => {
|
|
265
333
|
atPhone(() => {
|
|
266
334
|
const { container } = renderList({
|
|
@@ -276,11 +344,31 @@ describe("DataTableDocumentList", () => {
|
|
|
276
344
|
expect(getComputedStyle(stamp).alignSelf).toBe("flex-start");
|
|
277
345
|
const metaLine = row.querySelector('[data-list-slot="meta-line"]')!;
|
|
278
346
|
expect(metaLine.contains(stamp)).toBe(false);
|
|
279
|
-
expect(metaLine.textContent).
|
|
347
|
+
expect(metaLine.querySelector('[data-list-slot="fact"]')?.textContent).toBe("Points: 1");
|
|
280
348
|
expect(metaLine.textContent).not.toContain("Modified");
|
|
281
349
|
});
|
|
282
350
|
});
|
|
283
351
|
|
|
352
|
+
it("keeps one status beside the title and moves the rest, and a date beside activity, to line 2", () => {
|
|
353
|
+
atPhone(() => {
|
|
354
|
+
const { container } = renderList({
|
|
355
|
+
columns: [
|
|
356
|
+
...columns,
|
|
357
|
+
{ id: "priority", accessorKey: "status", meta: { role: "indicator" } },
|
|
358
|
+
{ id: "due", accessorKey: "owner", header: "Due", meta: { fieldtype: "Date" } },
|
|
359
|
+
{ id: "_activity", accessorKey: "owner" },
|
|
360
|
+
],
|
|
361
|
+
});
|
|
362
|
+
const row = container.querySelector('[data-testid="data-table-list-row"]')!;
|
|
363
|
+
const titleLine = row.querySelector('[data-list-slot="title"]')!.parentElement!;
|
|
364
|
+
const metaLine = row.querySelector('[data-list-slot="meta-line"]')!;
|
|
365
|
+
expect(titleLine.querySelectorAll('[data-list-slot="status"]')).toHaveLength(1);
|
|
366
|
+
expect(metaLine.querySelectorAll('[data-list-slot="status"]')).toHaveLength(1);
|
|
367
|
+
expect(row.querySelector('[data-list-slot="stamp"]')).toBeNull();
|
|
368
|
+
expect(metaLine.textContent).toContain("Due: ");
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
284
372
|
it("drops the meta line's opacity: its ink comes from the meta role", () => {
|
|
285
373
|
atPhone(() => {
|
|
286
374
|
const { container } = renderList();
|