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