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