@dxos/react-ui-table 0.4.9-main.f3fe18b → 0.4.9-next.a3cfaa7
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/lib/browser/index.mjs +124 -119
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Table/Table.d.ts +2 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableBody.d.ts +3 -3
- package/dist/types/src/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContext.d.ts +5 -4
- package/dist/types/src/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableFooter.d.ts +1 -1
- package/dist/types/src/components/Table/TableFooter.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableHead.d.ts +1 -1
- package/dist/types/src/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/components/Table/props.d.ts +1 -1
- package/dist/types/src/components/Table/props.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/theme.d.ts +4 -3
- package/dist/types/src/theme.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/components/Cell/Cell.tsx +3 -3
- package/src/components/Table/Table.tsx +10 -8
- package/src/components/Table/TableBody.tsx +4 -5
- package/src/components/Table/TableContext.tsx +16 -11
- package/src/components/Table/TableFooter.tsx +3 -3
- package/src/components/Table/TableHead.tsx +13 -18
- package/src/components/Table/props.ts +1 -1
- package/src/helpers.tsx +2 -1
- package/src/theme.ts +21 -20
|
@@ -229,36 +229,44 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
229
229
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
230
230
|
import { getCoreRowModel, getSortedRowModel, useReactTable, getGroupedRowModel, getExpandedRowModel } from "@tanstack/react-table";
|
|
231
231
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
232
|
-
import
|
|
232
|
+
import React8, { Fragment, useCallback, useEffect, useState as useState2 } from "react";
|
|
233
233
|
import { log } from "@dxos/log";
|
|
234
234
|
import { useDefaultValue, useOnTransition } from "@dxos/react-ui";
|
|
235
235
|
|
|
236
236
|
// packages/ui/react-ui-table/src/components/Table/TableBody.tsx
|
|
237
237
|
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
238
238
|
import { flexRender } from "@tanstack/react-table";
|
|
239
|
-
import
|
|
239
|
+
import React5 from "react";
|
|
240
240
|
|
|
241
241
|
// packages/ui/react-ui-table/src/components/Table/TableContext.tsx
|
|
242
|
-
import { createContext } from "
|
|
243
|
-
var
|
|
244
|
-
var
|
|
245
|
-
|
|
242
|
+
import React3, { useContext, createContext } from "react";
|
|
243
|
+
var TableContext = /* @__PURE__ */ createContext({});
|
|
244
|
+
var TableProvider = ({ children, ...value }) => {
|
|
245
|
+
return /* @__PURE__ */ React3.createElement(TableContext.Provider, {
|
|
246
|
+
value
|
|
247
|
+
}, children);
|
|
248
|
+
};
|
|
249
|
+
var useTableContext = () => {
|
|
250
|
+
const context = useContext(TableContext);
|
|
251
|
+
return context;
|
|
252
|
+
};
|
|
246
253
|
|
|
247
254
|
// packages/ui/react-ui-table/src/theme.ts
|
|
248
|
-
import { modalSurface,
|
|
255
|
+
import { modalSurface, focusRing, ghostSelected, ghostSelectedCurrent, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
|
|
249
256
|
var currentRow = "!bg-neutral-75 !dark:bg-neutral-850";
|
|
250
257
|
var selectedRow = "!bg-primary-100 dark:!bg-primary-700";
|
|
251
258
|
var flushPadding = "pli-0 plb-0";
|
|
252
259
|
var textPadding = "pli-2 plb-0.5";
|
|
253
|
-
var headPadding = "pli-2 plb-1
|
|
260
|
+
var headPadding = "pli-2 plb-1";
|
|
254
261
|
var gridCellFocusRing = "focus-within:z-[11] focus-within:outline outline-2 outline-primary-500 dark:outline-primary-400";
|
|
255
262
|
var tableRoot = ({ fullWidth }, ...etc) => mx2("table-fixed", fullWidth && "is-full", ...etc);
|
|
256
263
|
var groupTh = (_props, ...etc) => mx2("text-start font-medium", flushPadding, ...etc);
|
|
257
|
-
var theadRoot = ({ header, stickyHeader }, ...etc) => mx2(header ? stickyHeader && "sticky block-start-[--sticky-top] z-[1]" : "collapse", header &&
|
|
264
|
+
var theadRoot = ({ header, stickyHeader }, ...etc) => mx2(header ? stickyHeader && "sticky block-start-[--sticky-top] z-[1]" : "collapse", header && "base-surface", "drop-shadow-sm", ...etc);
|
|
258
265
|
var theadTr = (_props, ...etc) => mx2("group", ...etc);
|
|
259
|
-
var theadTh = ({ border }, ...etc) => mx2("relative text-start font-medium select-none truncate", headPadding, border &&
|
|
260
|
-
var theadResizeRoot = (
|
|
261
|
-
|
|
266
|
+
var theadTh = ({ border }, ...etc) => mx2("relative", "text-start font-medium select-none truncate", headPadding, border && groupBorder, border && "border border-t-0 border-b-0 border-neutral-200", ...etc);
|
|
267
|
+
var theadResizeRoot = ({ isResizing }) => {
|
|
268
|
+
return mx2("absolute h-full w-[4px] top-0 right-0", "cursor-col-resize", "user-select-none", "touch-action-none", !isResizing && "group-hover:bg-neutral-100 dark:group-hover:bg-neutral-800", "pointer-coarse:bg-neutral-100 dark:pointer-coarse:bg-neutral-800", isResizing && "bg-primary-500 dark:bg-primary-400");
|
|
269
|
+
};
|
|
262
270
|
var tbodyRoot = (_props, ...etc) => mx2(...etc);
|
|
263
271
|
var tbodyTr = ({ canBeCurrent }, ...etc) => mx2("group", canBeCurrent ? ghostSelectedCurrent : ghostSelected, canBeCurrent && focusRing, canBeCurrent && "cursor-pointer rounded", ...etc);
|
|
264
272
|
var tdRoot = ({ border, isGrid }, ...etc) => mx2("relative", flushPadding, border && "border", border && groupBorder, isGrid && gridCellFocusRing, ...etc);
|
|
@@ -269,30 +277,30 @@ var tfootTh = ({ border }, ...etc) => mx2(textPadding, modalSurface, border && g
|
|
|
269
277
|
|
|
270
278
|
// packages/ui/react-ui-table/src/components/Cell/Cell.tsx
|
|
271
279
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
272
|
-
import
|
|
280
|
+
import React4 from "react";
|
|
273
281
|
var CELL_NAME = "Cell";
|
|
274
282
|
var FocusableCell = ({ cell, children }) => {
|
|
275
|
-
const tableContext = useTableContext(
|
|
283
|
+
const tableContext = useTableContext();
|
|
276
284
|
const domAttributes = useFocusableGroup({
|
|
277
285
|
tabBehavior: "limited"
|
|
278
286
|
});
|
|
279
287
|
const className = tdRoot(tableContext, cell.column.columnDef.meta?.cell?.classNames);
|
|
280
|
-
return /* @__PURE__ */
|
|
288
|
+
return /* @__PURE__ */ React4.createElement("td", {
|
|
281
289
|
tabIndex: 0,
|
|
282
290
|
...domAttributes,
|
|
283
291
|
className
|
|
284
292
|
}, children);
|
|
285
293
|
};
|
|
286
294
|
var StaticCell = ({ cell, children }) => {
|
|
287
|
-
const tableContext = useTableContext(
|
|
288
|
-
return /* @__PURE__ */
|
|
295
|
+
const tableContext = useTableContext();
|
|
296
|
+
return /* @__PURE__ */ React4.createElement("td", {
|
|
289
297
|
className: tdRoot(tableContext, cell.column.columnDef.meta?.cell?.classNames)
|
|
290
298
|
}, children);
|
|
291
299
|
};
|
|
292
300
|
var Cell = ({ cell, children }) => {
|
|
293
|
-
const { isGrid } = useTableContext(
|
|
301
|
+
const { isGrid } = useTableContext();
|
|
294
302
|
const Root = isGrid ? FocusableCell : StaticCell;
|
|
295
|
-
return /* @__PURE__ */
|
|
303
|
+
return /* @__PURE__ */ React4.createElement(Root, {
|
|
296
304
|
cell
|
|
297
305
|
}, children);
|
|
298
306
|
};
|
|
@@ -301,16 +309,16 @@ Cell.displayName = CELL_NAME;
|
|
|
301
309
|
// packages/ui/react-ui-table/src/components/Table/TableBody.tsx
|
|
302
310
|
var TABLE_BODY_NAME = "TableBody";
|
|
303
311
|
var TableBody = ({ rows }) => {
|
|
304
|
-
const { table, keyAccessor, currentDatum, debug, expand, isGrid, onDatumClick } = useTableContext(
|
|
312
|
+
const { table, keyAccessor, currentDatum, debug, expand, isGrid, onDatumClick } = useTableContext();
|
|
305
313
|
const rowSelection = table.getState().rowSelection;
|
|
306
314
|
const domAttributes = useArrowNavigationGroup({
|
|
307
315
|
axis: "grid"
|
|
308
316
|
});
|
|
309
317
|
const canBeCurrent = !isGrid && !!onDatumClick;
|
|
310
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ React5.createElement("tbody", isGrid && domAttributes, rows.map((row) => {
|
|
311
319
|
const isCurrent = currentDatum === row.original;
|
|
312
320
|
const isSelected = rowSelection?.[row.id];
|
|
313
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ React5.createElement("tr", {
|
|
314
322
|
key: keyAccessor ? keyAccessor(row.original) : row.id,
|
|
315
323
|
className: tbodyTr({
|
|
316
324
|
canBeCurrent
|
|
@@ -332,83 +340,80 @@ var TableBody = ({ rows }) => {
|
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
342
|
}
|
|
335
|
-
}, debug && /* @__PURE__ */
|
|
336
|
-
return /* @__PURE__ */
|
|
343
|
+
}, debug && /* @__PURE__ */ React5.createElement("td", null, row.id), row.getVisibleCells().map((cell) => {
|
|
344
|
+
return /* @__PURE__ */ React5.createElement(Cell, {
|
|
337
345
|
key: cell.id,
|
|
338
346
|
cell
|
|
339
347
|
}, flexRender(cell.column.columnDef.cell, {
|
|
340
348
|
className: "pli-2",
|
|
341
349
|
...cell.getContext()
|
|
342
350
|
}));
|
|
343
|
-
}), expand && /* @__PURE__ */
|
|
351
|
+
}), expand && /* @__PURE__ */ React5.createElement("td", null));
|
|
344
352
|
}));
|
|
345
353
|
};
|
|
346
354
|
TableBody.displayName = TABLE_BODY_NAME;
|
|
347
355
|
|
|
348
356
|
// packages/ui/react-ui-table/src/components/Table/TableFooter.tsx
|
|
349
357
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
350
|
-
import
|
|
358
|
+
import React6 from "react";
|
|
351
359
|
var TABLE_FOOT_NAME = "TableFooter";
|
|
352
360
|
var TableFooter = (props) => {
|
|
353
|
-
const tableContext = useTableContext(
|
|
361
|
+
const tableContext = useTableContext();
|
|
354
362
|
const { table, expand, debug } = tableContext;
|
|
355
363
|
const footers = table.getFooterGroups();
|
|
356
|
-
return /* @__PURE__ */
|
|
364
|
+
return /* @__PURE__ */ React6.createElement("tfoot", {
|
|
357
365
|
className: tfootRoot(props)
|
|
358
|
-
}, footers.map((footerGroup) => /* @__PURE__ */
|
|
366
|
+
}, footers.map((footerGroup) => /* @__PURE__ */ React6.createElement("tr", {
|
|
359
367
|
key: footerGroup.id,
|
|
360
368
|
className: tfootTr(tableContext)
|
|
361
|
-
}, debug && /* @__PURE__ */
|
|
362
|
-
return /* @__PURE__ */
|
|
369
|
+
}, debug && /* @__PURE__ */ React6.createElement("th", null), footerGroup.headers.map((footer) => {
|
|
370
|
+
return /* @__PURE__ */ React6.createElement("th", {
|
|
363
371
|
key: footer.id,
|
|
364
372
|
className: tfootTh(tableContext, footer.column.columnDef.meta?.footer?.classNames)
|
|
365
373
|
}, footer.isPlaceholder ? null : flexRender2(footer.column.columnDef.footer, footer.getContext()));
|
|
366
|
-
}), expand && /* @__PURE__ */
|
|
374
|
+
}), expand && /* @__PURE__ */ React6.createElement("th", null))));
|
|
367
375
|
};
|
|
368
376
|
TableFooter.displayName = TABLE_FOOT_NAME;
|
|
369
377
|
|
|
370
378
|
// packages/ui/react-ui-table/src/components/Table/TableHead.tsx
|
|
371
379
|
import { flexRender as flexRender3 } from "@tanstack/react-table";
|
|
372
|
-
import
|
|
373
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
380
|
+
import React7 from "react";
|
|
374
381
|
var TABLE_HEAD_NAME = "TableHeader";
|
|
375
382
|
var TableHead = (_props) => {
|
|
376
|
-
const tableContext = useTableContext(
|
|
383
|
+
const tableContext = useTableContext();
|
|
377
384
|
const headerGroups = tableContext.table.getHeaderGroups();
|
|
378
|
-
|
|
379
|
-
return /* @__PURE__ */ React6.createElement("thead", {
|
|
385
|
+
return /* @__PURE__ */ React7.createElement("thead", {
|
|
380
386
|
className: theadRoot(tableContext)
|
|
381
387
|
}, headerGroups.map((headerGroup) => {
|
|
382
388
|
return (
|
|
383
389
|
// Group element to hover resize handles.
|
|
384
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ React7.createElement("tr", {
|
|
385
391
|
key: headerGroup.id,
|
|
386
392
|
className: theadTr(tableContext)
|
|
387
|
-
}, tableContext.debug && /* @__PURE__ */
|
|
393
|
+
}, tableContext.debug && /* @__PURE__ */ React7.createElement("th", {
|
|
388
394
|
className: "font-mono",
|
|
389
395
|
style: {
|
|
390
396
|
width: 32
|
|
391
397
|
}
|
|
392
398
|
}, "#"), headerGroup.headers.map((header) => {
|
|
393
399
|
const isResizing = header.column.getIsResizing();
|
|
394
|
-
const
|
|
395
|
-
|
|
400
|
+
const onResize = header.getResizeHandler();
|
|
401
|
+
const resizable = header.column.columnDef.meta?.resizable;
|
|
402
|
+
return /* @__PURE__ */ React7.createElement("th", {
|
|
396
403
|
key: header.id,
|
|
397
404
|
style: {
|
|
398
405
|
width: header.getSize()
|
|
399
406
|
},
|
|
400
407
|
className: theadTh(tableContext, header.column.columnDef.meta?.header?.classNames)
|
|
401
|
-
}, !header || header.isPlaceholder ? null : flexRender3(header.column.columnDef.header, header.getContext()),
|
|
402
|
-
className: theadResizeRoot(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
onMouseDown:
|
|
407
|
-
onTouchStart:
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
})));
|
|
411
|
-
}), tableContext.expand && /* @__PURE__ */ React6.createElement("th", null))
|
|
408
|
+
}, !header || header.isPlaceholder ? null : flexRender3(header.column.columnDef.header, header.getContext()), resizable && /* @__PURE__ */ React7.createElement("div", {
|
|
409
|
+
className: theadResizeRoot({
|
|
410
|
+
isResizing
|
|
411
|
+
}),
|
|
412
|
+
onDoubleClick: header.column.resetSize,
|
|
413
|
+
onMouseDown: onResize,
|
|
414
|
+
onTouchStart: onResize
|
|
415
|
+
}));
|
|
416
|
+
}), tableContext.expand && /* @__PURE__ */ React7.createElement("th", null))
|
|
412
417
|
);
|
|
413
418
|
}));
|
|
414
419
|
};
|
|
@@ -535,13 +540,13 @@ var Table = (props) => {
|
|
|
535
540
|
C: (f, a) => f(...a)
|
|
536
541
|
});
|
|
537
542
|
}
|
|
538
|
-
return /* @__PURE__ */
|
|
543
|
+
return /* @__PURE__ */ React8.createElement(TableProvider2, {
|
|
539
544
|
...props,
|
|
540
545
|
table,
|
|
541
546
|
header,
|
|
542
547
|
expand,
|
|
543
548
|
isGrid: role === "grid" || role === "treegrid"
|
|
544
|
-
}, /* @__PURE__ */
|
|
549
|
+
}, /* @__PURE__ */ React8.createElement(TableImpl, {
|
|
545
550
|
debug: false,
|
|
546
551
|
getScrollElement,
|
|
547
552
|
...props
|
|
@@ -549,7 +554,7 @@ var Table = (props) => {
|
|
|
549
554
|
};
|
|
550
555
|
var TableImpl = (props) => {
|
|
551
556
|
const { debug, classNames, getScrollElement, role, footer, grouping, fullWidth } = props;
|
|
552
|
-
const { table } = useTableContext(
|
|
557
|
+
const { table } = useTableContext();
|
|
553
558
|
const centerRows = table.getCenterRows();
|
|
554
559
|
const bottomRows = table.getBottomRows();
|
|
555
560
|
const rows = [
|
|
@@ -557,12 +562,13 @@ var TableImpl = (props) => {
|
|
|
557
562
|
...bottomRows
|
|
558
563
|
];
|
|
559
564
|
if (debug) {
|
|
560
|
-
return /* @__PURE__ */
|
|
565
|
+
return /* @__PURE__ */ React8.createElement("pre", {
|
|
561
566
|
className: "font-mono text-xs text-neutral-500 m-1 p-2 ring"
|
|
562
|
-
}, /* @__PURE__ */
|
|
567
|
+
}, /* @__PURE__ */ React8.createElement("code", null, JSON.stringify(table.getState(), void 0, 2)));
|
|
563
568
|
}
|
|
569
|
+
const virtualisable = getScrollElement !== void 0;
|
|
564
570
|
const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn;
|
|
565
|
-
return /* @__PURE__ */
|
|
571
|
+
return /* @__PURE__ */ React8.createElement("table", {
|
|
566
572
|
role,
|
|
567
573
|
className: tableRoot(props, classNames),
|
|
568
574
|
...!fullWidth && {
|
|
@@ -570,16 +576,16 @@ var TableImpl = (props) => {
|
|
|
570
576
|
width: table.getTotalSize()
|
|
571
577
|
}
|
|
572
578
|
}
|
|
573
|
-
}, /* @__PURE__ */
|
|
579
|
+
}, /* @__PURE__ */ React8.createElement(TableHead, null), grouping?.length !== 0 ? virtualisable ? isResizingColumn ? /* @__PURE__ */ React8.createElement(MemoizedVirtualisedTableContent, {
|
|
574
580
|
getScrollElement
|
|
575
|
-
}) : /* @__PURE__ */
|
|
581
|
+
}) : /* @__PURE__ */ React8.createElement(VirtualizedTableContent, {
|
|
576
582
|
getScrollElement
|
|
577
|
-
}) : /* @__PURE__ */
|
|
583
|
+
}) : /* @__PURE__ */ React8.createElement(TableBody, {
|
|
578
584
|
rows
|
|
579
|
-
}) : /* @__PURE__ */
|
|
585
|
+
}) : /* @__PURE__ */ React8.createElement(GroupedTableContent, null), footer && /* @__PURE__ */ React8.createElement(TableFooter, null));
|
|
580
586
|
};
|
|
581
587
|
var VirtualizedTableContent = ({ getScrollElement }) => {
|
|
582
|
-
const { table } = useTableContext(
|
|
588
|
+
const { table } = useTableContext();
|
|
583
589
|
const centerRows = table.getCenterRows();
|
|
584
590
|
const pinnedRows = table.getBottomRows();
|
|
585
591
|
const rows = [
|
|
@@ -589,46 +595,46 @@ var VirtualizedTableContent = ({ getScrollElement }) => {
|
|
|
589
595
|
const { getTotalSize, getVirtualItems } = useVirtualizer({
|
|
590
596
|
getScrollElement,
|
|
591
597
|
count: rows.length,
|
|
592
|
-
overscan:
|
|
593
|
-
estimateSize: () =>
|
|
598
|
+
overscan: 8,
|
|
599
|
+
estimateSize: () => 40
|
|
594
600
|
});
|
|
595
601
|
const virtualRows = getVirtualItems();
|
|
596
602
|
const totalSize = getTotalSize();
|
|
597
603
|
const paddingTop = virtualRows.length > 0 ? virtualRows?.[0]?.start || 0 : 0;
|
|
598
604
|
const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows?.[virtualRows.length - 1]?.end || 0) : 0;
|
|
599
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, paddingTop > 0 && /* @__PURE__ */ React8.createElement("tbody", {
|
|
600
606
|
role: "none"
|
|
601
|
-
}, /* @__PURE__ */
|
|
607
|
+
}, /* @__PURE__ */ React8.createElement("tr", {
|
|
602
608
|
role: "none"
|
|
603
|
-
}, /* @__PURE__ */
|
|
609
|
+
}, /* @__PURE__ */ React8.createElement("td", {
|
|
604
610
|
style: {
|
|
605
611
|
height: `${paddingTop}px`
|
|
606
612
|
},
|
|
607
613
|
role: "none"
|
|
608
|
-
}))), /* @__PURE__ */
|
|
614
|
+
}))), /* @__PURE__ */ React8.createElement(TableBody, {
|
|
609
615
|
rows: virtualRows.map((virtualRow) => rows[virtualRow.index])
|
|
610
|
-
}), paddingBottom > 0 && /* @__PURE__ */
|
|
616
|
+
}), paddingBottom > 0 && /* @__PURE__ */ React8.createElement("tbody", {
|
|
611
617
|
role: "none"
|
|
612
|
-
}, /* @__PURE__ */
|
|
618
|
+
}, /* @__PURE__ */ React8.createElement("tr", {
|
|
613
619
|
role: "none"
|
|
614
|
-
}, /* @__PURE__ */
|
|
620
|
+
}, /* @__PURE__ */ React8.createElement("td", {
|
|
615
621
|
style: {
|
|
616
622
|
height: `${paddingBottom}px`
|
|
617
623
|
},
|
|
618
624
|
role: "none"
|
|
619
625
|
}))));
|
|
620
626
|
};
|
|
621
|
-
var MemoizedVirtualisedTableContent = /* @__PURE__ */
|
|
627
|
+
var MemoizedVirtualisedTableContent = /* @__PURE__ */ React8.memo(VirtualizedTableContent);
|
|
622
628
|
var GroupedTableContent = () => {
|
|
623
|
-
const { table: { getGroupedRowModel: getGroupedRowModel2, getHeaderGroups, getState }, debug } = useTableContext(
|
|
624
|
-
return /* @__PURE__ */
|
|
625
|
-
return /* @__PURE__ */
|
|
629
|
+
const { table: { getGroupedRowModel: getGroupedRowModel2, getHeaderGroups, getState }, debug } = useTableContext();
|
|
630
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, getGroupedRowModel2().rows.map((row, i) => {
|
|
631
|
+
return /* @__PURE__ */ React8.createElement(Fragment, {
|
|
626
632
|
key: i
|
|
627
|
-
}, /* @__PURE__ */
|
|
633
|
+
}, /* @__PURE__ */ React8.createElement("thead", null, /* @__PURE__ */ React8.createElement("tr", null, debug && /* @__PURE__ */ React8.createElement("th", null), /* @__PURE__ */ React8.createElement("th", {
|
|
628
634
|
// TODO(burdon): Calculate row span.
|
|
629
635
|
colSpan: getHeaderGroups()[0].headers.length,
|
|
630
636
|
className: groupTh({})
|
|
631
|
-
}, getState().grouping[0], "[", String(row.getGroupingValue(getState().grouping[0])), "]"))), /* @__PURE__ */
|
|
637
|
+
}, getState().grouping[0], "[", String(row.getGroupingValue(getState().grouping[0])), "]"))), /* @__PURE__ */ React8.createElement(TableBody, {
|
|
632
638
|
rows: row.subRows
|
|
633
639
|
}));
|
|
634
640
|
}));
|
|
@@ -636,10 +642,10 @@ var GroupedTableContent = () => {
|
|
|
636
642
|
|
|
637
643
|
// packages/ui/react-ui-table/src/components/Cell/CellCombobox.tsx
|
|
638
644
|
import { CaretDown } from "@phosphor-icons/react";
|
|
639
|
-
import
|
|
645
|
+
import React9, { useCallback as useCallback2, useState as useState3 } from "react";
|
|
640
646
|
import { Popover as Popover2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
641
647
|
import { PopoverCombobox } from "@dxos/react-ui-searchlist";
|
|
642
|
-
import { descriptionText, getSize as getSize3, mx as
|
|
648
|
+
import { descriptionText, getSize as getSize3, mx as mx3, staticPlaceholderText } from "@dxos/react-ui-theme";
|
|
643
649
|
var initialItems = (model, value) => value ? {
|
|
644
650
|
[model.getId(value)]: {
|
|
645
651
|
label: model.getText(value),
|
|
@@ -670,37 +676,37 @@ var CellCombobox = ({ model, value, onValueChange }) => {
|
|
|
670
676
|
items,
|
|
671
677
|
onValueChange
|
|
672
678
|
]);
|
|
673
|
-
return /* @__PURE__ */
|
|
679
|
+
return /* @__PURE__ */ React9.createElement(PopoverCombobox.Root, {
|
|
674
680
|
placeholder: t("no selection label")
|
|
675
|
-
}, /* @__PURE__ */
|
|
681
|
+
}, /* @__PURE__ */ React9.createElement(PopoverCombobox.Trigger, {
|
|
676
682
|
variant: "ghost",
|
|
677
683
|
classNames: "is-full rounded-none ring-inset"
|
|
678
|
-
}, value ? /* @__PURE__ */
|
|
679
|
-
className:
|
|
680
|
-
}, model.getText(value)), /* @__PURE__ */
|
|
684
|
+
}, value ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement("span", {
|
|
685
|
+
className: mx3("font-normal text-start text-base flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
|
|
686
|
+
}, model.getText(value)), /* @__PURE__ */ React9.createElement(CaretDown, {
|
|
681
687
|
weight: "bold",
|
|
682
688
|
className: getSize3(3)
|
|
683
|
-
})) : null), /* @__PURE__ */
|
|
689
|
+
})) : null), /* @__PURE__ */ React9.createElement(PopoverCombobox.Content, {
|
|
684
690
|
shouldFilter: false,
|
|
685
691
|
classNames: "is-[--radix-popover-trigger-width]"
|
|
686
|
-
}, /* @__PURE__ */
|
|
692
|
+
}, /* @__PURE__ */ React9.createElement(PopoverCombobox.Input, {
|
|
687
693
|
value: searchInputValue,
|
|
688
694
|
onValueChange: handleSearchInputValueChange
|
|
689
|
-
}), /* @__PURE__ */
|
|
690
|
-
className:
|
|
691
|
-
}, "Start typing to search") : loading ? /* @__PURE__ */
|
|
692
|
-
className:
|
|
693
|
-
}, "Searching\u2026") : /* @__PURE__ */
|
|
695
|
+
}), /* @__PURE__ */ React9.createElement(PopoverCombobox.List, null, searchInputValue.length < 1 ? /* @__PURE__ */ React9.createElement("p", {
|
|
696
|
+
className: mx3("text-center", descriptionText)
|
|
697
|
+
}, "Start typing to search") : loading ? /* @__PURE__ */ React9.createElement("p", {
|
|
698
|
+
className: mx3("text-center", descriptionText)
|
|
699
|
+
}, "Searching\u2026") : /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(PopoverCombobox.Empty, {
|
|
694
700
|
classNames: [
|
|
695
701
|
"text-center",
|
|
696
702
|
descriptionText
|
|
697
703
|
]
|
|
698
|
-
}, "No results"), Object.entries(items).map(([id, { label }]) => /* @__PURE__ */
|
|
704
|
+
}, "No results"), Object.entries(items).map(([id, { label }]) => /* @__PURE__ */ React9.createElement(PopoverCombobox.Item, {
|
|
699
705
|
key: id,
|
|
700
706
|
value: id,
|
|
701
707
|
onSelect: handleValueChange,
|
|
702
708
|
classNames: "truncate"
|
|
703
|
-
}, label)))), /* @__PURE__ */
|
|
709
|
+
}, label)))), /* @__PURE__ */ React9.createElement(Popover2.Arrow, null)));
|
|
704
710
|
};
|
|
705
711
|
|
|
706
712
|
// packages/ui/react-ui-table/src/helpers.tsx
|
|
@@ -709,10 +715,10 @@ import { Check as Check2, ClipboardText, X as X2 } from "@phosphor-icons/react";
|
|
|
709
715
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
710
716
|
import { format } from "date-fns/format";
|
|
711
717
|
import { formatDistanceToNow } from "date-fns/formatDistanceToNow";
|
|
712
|
-
import
|
|
718
|
+
import React10, { useEffect as useEffect2, useRef as useRef2, useState as useState4 } from "react";
|
|
713
719
|
import { log as log2 } from "@dxos/log";
|
|
714
720
|
import { Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
715
|
-
import { getSize as getSize4, mx as
|
|
721
|
+
import { getSize as getSize4, mx as mx4 } from "@dxos/react-ui-theme";
|
|
716
722
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/helpers.tsx";
|
|
717
723
|
var createColumnBuilder = () => ({
|
|
718
724
|
helper: createColumnHelper(),
|
|
@@ -720,7 +726,7 @@ var createColumnBuilder = () => ({
|
|
|
720
726
|
});
|
|
721
727
|
var ComboboxBuilderCell = (cellContext) => {
|
|
722
728
|
const { model, onUpdate } = cellContext.column.columnDef.meta;
|
|
723
|
-
return model ? /* @__PURE__ */
|
|
729
|
+
return model ? /* @__PURE__ */ React10.createElement(CellCombobox, {
|
|
724
730
|
model,
|
|
725
731
|
value: cellContext.getValue(),
|
|
726
732
|
onValueChange: (value) => onUpdate?.(cellContext.row.original, cellContext.column.id, value)
|
|
@@ -750,7 +756,7 @@ var StringBuilderCell = (cellContext) => {
|
|
|
750
756
|
const rowCount = cellContext.table.getRowModel().rows.length;
|
|
751
757
|
placeholder = cellContext.row.index === rowCount - 1 && columns[0].id === cellContext.column.id;
|
|
752
758
|
}
|
|
753
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.TextInput, {
|
|
754
760
|
ref,
|
|
755
761
|
variant: "subdued",
|
|
756
762
|
placeholder: placeholder ? "Add row..." : void 0,
|
|
@@ -797,7 +803,7 @@ var NumberBuilderCell = (cellContext) => {
|
|
|
797
803
|
setText(displayNumber(value, digits));
|
|
798
804
|
ref.current && findPrevFocusable(ref.current)?.focus();
|
|
799
805
|
};
|
|
800
|
-
return /* @__PURE__ */
|
|
806
|
+
return /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.TextInput, {
|
|
801
807
|
ref,
|
|
802
808
|
variant: "subdued",
|
|
803
809
|
value: text,
|
|
@@ -820,10 +826,10 @@ var RowSelectorBuilderCell = (cellContext) => {
|
|
|
820
826
|
const { cell } = cellContext.column.columnDef.meta;
|
|
821
827
|
const { row } = cellContext;
|
|
822
828
|
const checked = row.getCanSelect() ? row.getIsSelected() : row.getCanSelectSubRows() && (row.getIsSomeSelected() ? "indeterminate" : row.getIsAllSubRowsSelected());
|
|
823
|
-
return /* @__PURE__ */
|
|
829
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
824
830
|
className: "flex justify-center w-full h-full",
|
|
825
831
|
role: "presentation"
|
|
826
|
-
}, /* @__PURE__ */
|
|
832
|
+
}, /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Checkbox, {
|
|
827
833
|
size: 4,
|
|
828
834
|
classNames: [
|
|
829
835
|
cell?.classNames
|
|
@@ -840,7 +846,7 @@ var RowSelectorBuilderCell = (cellContext) => {
|
|
|
840
846
|
var SwitchBuilderCell = (cellContext) => {
|
|
841
847
|
const { onUpdate } = cellContext.column.columnDef.meta;
|
|
842
848
|
const value = cellContext.getValue();
|
|
843
|
-
return /* @__PURE__ */
|
|
849
|
+
return /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Switch, {
|
|
844
850
|
classNames: "block mli-auto",
|
|
845
851
|
onClick: (event) => event.stopPropagation(),
|
|
846
852
|
disabled: !onUpdate,
|
|
@@ -862,8 +868,8 @@ var ColumnBuilder = class {
|
|
|
862
868
|
},
|
|
863
869
|
cell: model && onUpdate ? ComboboxBuilderCell : (cellContext) => {
|
|
864
870
|
const cellValue = cellContext.getValue();
|
|
865
|
-
return /* @__PURE__ */
|
|
866
|
-
className:
|
|
871
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
872
|
+
className: mx4("truncate", classNames)
|
|
867
873
|
}, cellValue ? model?.getText(cellValue) : "");
|
|
868
874
|
},
|
|
869
875
|
...props,
|
|
@@ -893,8 +899,8 @@ var ColumnBuilder = class {
|
|
|
893
899
|
if (typeof value === "object" && value?.__typename === "dxos.Text.v0") {
|
|
894
900
|
value = value.content;
|
|
895
901
|
}
|
|
896
|
-
return /* @__PURE__ */
|
|
897
|
-
className:
|
|
902
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
903
|
+
className: mx4("truncate", textPadding, classNames)
|
|
898
904
|
}, value);
|
|
899
905
|
},
|
|
900
906
|
...props,
|
|
@@ -948,8 +954,8 @@ var ColumnBuilder = class {
|
|
|
948
954
|
const str = value ? formatSpec ? format(value, formatSpec) : relative ? formatDistanceToNow(value, {
|
|
949
955
|
addSuffix: true
|
|
950
956
|
}) : value.toISOString() : void 0;
|
|
951
|
-
return /* @__PURE__ */
|
|
952
|
-
className:
|
|
957
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
958
|
+
className: mx4(textPadding, classNames)
|
|
953
959
|
}, str);
|
|
954
960
|
} catch (err) {
|
|
955
961
|
log2.info("formatError", {
|
|
@@ -990,9 +996,9 @@ var ColumnBuilder = class {
|
|
|
990
996
|
if (!tooltip) {
|
|
991
997
|
return element;
|
|
992
998
|
}
|
|
993
|
-
return /* @__PURE__ */
|
|
999
|
+
return /* @__PURE__ */ React10.createElement(Tooltip.Provider, null, /* @__PURE__ */ React10.createElement(Tooltip.Root, null, /* @__PURE__ */ React10.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React10.createElement(Tooltip.Portal, null, /* @__PURE__ */ React10.createElement(Tooltip.Content, {
|
|
994
1000
|
side: "right"
|
|
995
|
-
}, /* @__PURE__ */
|
|
1001
|
+
}, /* @__PURE__ */ React10.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React10.createElement(ClipboardText, {
|
|
996
1002
|
onClick: (ev) => {
|
|
997
1003
|
ev.stopPropagation();
|
|
998
1004
|
void navigator.clipboard.writeText(value.toHex());
|
|
@@ -1028,12 +1034,12 @@ var ColumnBuilder = class {
|
|
|
1028
1034
|
}
|
|
1029
1035
|
},
|
|
1030
1036
|
header: ({ table }) => {
|
|
1031
|
-
const { rowsSelectable } = useTableContext(
|
|
1037
|
+
const { rowsSelectable } = useTableContext();
|
|
1032
1038
|
const checked = table.getIsSomeRowsSelected() ? "indeterminate" : table.getIsAllRowsSelected();
|
|
1033
|
-
return rowsSelectable === "multi" ? /* @__PURE__ */
|
|
1039
|
+
return rowsSelectable === "multi" ? /* @__PURE__ */ React10.createElement("div", {
|
|
1034
1040
|
className: "flex justify-center w-full h-full",
|
|
1035
1041
|
role: "presentation"
|
|
1036
|
-
}, /* @__PURE__ */
|
|
1042
|
+
}, /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Checkbox, {
|
|
1037
1043
|
size: 4,
|
|
1038
1044
|
classNames: [
|
|
1039
1045
|
"mli-auto",
|
|
@@ -1081,18 +1087,18 @@ var ColumnBuilder = class {
|
|
|
1081
1087
|
size: size ?? 32,
|
|
1082
1088
|
// TODO(Zan): Implement sort algorithm
|
|
1083
1089
|
enableSorting: false,
|
|
1084
|
-
header: (column) => /* @__PURE__ */
|
|
1090
|
+
header: (column) => /* @__PURE__ */ React10.createElement("div", {
|
|
1085
1091
|
className: "justify-center"
|
|
1086
1092
|
}, label ?? column.header.id),
|
|
1087
1093
|
cell: (cell) => {
|
|
1088
1094
|
const value = cell.getValue();
|
|
1089
1095
|
if (value) {
|
|
1090
|
-
return /* @__PURE__ */
|
|
1091
|
-
className:
|
|
1096
|
+
return /* @__PURE__ */ React10.createElement(IconOn, {
|
|
1097
|
+
className: mx4("block mli-auto", getSize4(6), on?.className ?? "text-green-700")
|
|
1092
1098
|
});
|
|
1093
1099
|
} else if (value === false) {
|
|
1094
|
-
return /* @__PURE__ */
|
|
1095
|
-
className:
|
|
1100
|
+
return /* @__PURE__ */ React10.createElement(IconOff, {
|
|
1101
|
+
className: mx4("block mli-auto", getSize4(6), off?.className ?? "text-red-700")
|
|
1096
1102
|
});
|
|
1097
1103
|
} else {
|
|
1098
1104
|
return null;
|
|
@@ -1126,7 +1132,6 @@ export {
|
|
|
1126
1132
|
tfootTh,
|
|
1127
1133
|
tfootTr,
|
|
1128
1134
|
theadResizeRoot,
|
|
1129
|
-
theadResizeThumb,
|
|
1130
1135
|
theadRoot,
|
|
1131
1136
|
theadTh,
|
|
1132
1137
|
theadTr,
|