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