@dxos/react-ui-table 0.3.8 → 0.3.9-main.14901ff
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 +54 -36
- 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.map +1 -1
- package/dist/types/src/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/components/Table/props.d.ts +2 -0
- package/dist/types/src/components/Table/props.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts +2 -2
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/theme.d.ts +0 -2
- package/dist/types/src/theme.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/components/Table/Table.tsx +6 -1
- package/src/components/Table/TableBody.tsx +2 -1
- package/src/components/Table/props.ts +4 -0
- package/src/helpers.tsx +57 -49
- package/src/index.ts +1 -0
- package/src/theme.ts +13 -6
|
@@ -202,7 +202,7 @@ var [TableProvider, useUntypedTableContext] = createContext(TABLE_NAME);
|
|
|
202
202
|
var useTableContext = (consumerName) => useUntypedTableContext(consumerName);
|
|
203
203
|
|
|
204
204
|
// packages/ui/react-ui-table/src/theme.ts
|
|
205
|
-
import { chromeSurface, fixedSurface, focusRing,
|
|
205
|
+
import { chromeSurface, fixedSurface, focusRing, ghostSelected, ghostSelectedCurrent, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
|
|
206
206
|
var currentRow = "!bg-neutral-75 !dark:bg-neutral-850";
|
|
207
207
|
var selectedRow = "!bg-primary-100 dark:!bg-primary-700";
|
|
208
208
|
var flushPadding = "pli-0 plb-0";
|
|
@@ -211,13 +211,13 @@ var headPadding = "pli-2 plb-1.5";
|
|
|
211
211
|
var gridCellFocusRing = "focus:z-[11] focus:outline outline-2 outline-primary-500 dark:outline-primary-400";
|
|
212
212
|
var tableRoot = ({ fullWidth }, ...etc) => mx2("table-fixed", fullWidth && "is-full", ...etc);
|
|
213
213
|
var groupTh = (_props, ...etc) => mx2("text-start font-medium", flushPadding, ...etc);
|
|
214
|
-
var theadRoot = ({ header }, ...etc) => mx2(header ? "sticky block-start-
|
|
214
|
+
var theadRoot = ({ header }, ...etc) => mx2(header ? "sticky block-start-[--sticky-top] z-[1]" : "collapse", header && fixedSurface, ...etc);
|
|
215
215
|
var theadTr = (_props, ...etc) => mx2("group", ...etc);
|
|
216
216
|
var theadTh = ({ border }, ...etc) => mx2("relative text-start font-medium select-none truncate", headPadding, border && "border", border && groupBorder, ...etc);
|
|
217
217
|
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);
|
|
218
218
|
var theadResizeThumb = (_props, ...etc) => mx2("flex group-hover:bg-neutral-700 -ml-[2px] w-[1px] h-full", ...etc);
|
|
219
219
|
var tbodyRoot = (_props, ...etc) => mx2(...etc);
|
|
220
|
-
var tbodyTr = ({
|
|
220
|
+
var tbodyTr = ({ canBeCurrent }, ...etc) => mx2("group", canBeCurrent ? ghostSelectedCurrent : ghostSelected, canBeCurrent && focusRing, canBeCurrent && "cursor-pointer rounded", ...etc);
|
|
221
221
|
var tdRoot = ({ border, isGrid }, ...etc) => mx2("relative", flushPadding, border && "border", border && groupBorder, isGrid && gridCellFocusRing, ...etc);
|
|
222
222
|
var tdContent = (_props, ...etc) => mx2(...etc);
|
|
223
223
|
var tfootRoot = (_props, ...etc) => mx2("sticky block-end-0 z-10", chromeSurface, ...etc);
|
|
@@ -270,13 +270,14 @@ var TableBody = ({ rows }) => {
|
|
|
270
270
|
return /* @__PURE__ */ React3.createElement("tr", {
|
|
271
271
|
key: keyAccessor ? keyAccessor(row.original) : row.id,
|
|
272
272
|
className: tbodyTr({
|
|
273
|
-
isSelected,
|
|
274
|
-
isCurrent,
|
|
275
273
|
canBeCurrent
|
|
276
274
|
}),
|
|
277
275
|
...isCurrent && {
|
|
278
276
|
"aria-current": "location"
|
|
279
277
|
},
|
|
278
|
+
...isSelected && {
|
|
279
|
+
"aria-selected": "true"
|
|
280
|
+
},
|
|
280
281
|
...canBeCurrent && {
|
|
281
282
|
tabIndex: 0,
|
|
282
283
|
onClick: () => {
|
|
@@ -371,7 +372,7 @@ TableHead.displayName = TABLE_HEAD_NAME;
|
|
|
371
372
|
|
|
372
373
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
373
374
|
var Table = (props) => {
|
|
374
|
-
const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange } = props;
|
|
375
|
+
const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange, classNames } = props;
|
|
375
376
|
const TableProvider2 = TableProvider;
|
|
376
377
|
const [rowSelection = {}, directlySetRowSelection] = useControllableState({
|
|
377
378
|
prop: props.rowSelection,
|
|
@@ -461,7 +462,7 @@ var Table = (props) => {
|
|
|
461
462
|
isGrid: role === "grid" || role === "treegrid"
|
|
462
463
|
}, /* @__PURE__ */ React6.createElement("table", {
|
|
463
464
|
role,
|
|
464
|
-
className: tableRoot(props),
|
|
465
|
+
className: tableRoot(props, classNames),
|
|
465
466
|
...!fullWidth && {
|
|
466
467
|
style: {
|
|
467
468
|
width: table.getTotalSize()
|
|
@@ -572,25 +573,20 @@ import { Check as Check2, ClipboardText, X as X2 } from "@phosphor-icons/react";
|
|
|
572
573
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
573
574
|
import format from "date-fns/format";
|
|
574
575
|
import formatDistanceToNow from "date-fns/formatDistanceToNow";
|
|
575
|
-
import defaultsDeep from "lodash.defaultsdeep";
|
|
576
576
|
import React8, { useRef as useRef2, useState as useState4 } from "react";
|
|
577
577
|
import { Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
578
578
|
import { getSize as getSize3, mx as mx5 } from "@dxos/react-ui-theme";
|
|
579
|
-
import { stripUndefinedValues } from "@dxos/util";
|
|
580
579
|
var createColumnBuilder = () => ({
|
|
581
580
|
helper: createColumnHelper(),
|
|
582
581
|
builder: new ColumnBuilder()
|
|
583
582
|
});
|
|
584
|
-
var defaults = (options, ...sources) => {
|
|
585
|
-
return stripUndefinedValues(defaultsDeep({}, options, ...sources));
|
|
586
|
-
};
|
|
587
583
|
var ComboboxBuilderCell = (cellContext) => {
|
|
588
584
|
const { model, onUpdate } = cellContext.column.columnDef.meta;
|
|
589
|
-
return /* @__PURE__ */ React8.createElement(CellCombobox, {
|
|
585
|
+
return model ? /* @__PURE__ */ React8.createElement(CellCombobox, {
|
|
590
586
|
model,
|
|
591
587
|
value: cellContext.getValue(),
|
|
592
588
|
onValueChange: (value) => onUpdate?.(cellContext.row.original, cellContext.column.id, value)
|
|
593
|
-
});
|
|
589
|
+
}) : null;
|
|
594
590
|
};
|
|
595
591
|
var StringBuilderCell = (cellContext) => {
|
|
596
592
|
const { onUpdate } = cellContext.column.columnDef.meta;
|
|
@@ -696,13 +692,16 @@ var ColumnBuilder = class {
|
|
|
696
692
|
* Combobox value
|
|
697
693
|
*/
|
|
698
694
|
combobox({ label, classNames, model, onUpdate, ...props }) {
|
|
699
|
-
return
|
|
695
|
+
return {
|
|
696
|
+
...props,
|
|
700
697
|
minSize: 100,
|
|
701
698
|
meta: {
|
|
699
|
+
...props.meta,
|
|
702
700
|
model,
|
|
703
701
|
onUpdate,
|
|
704
702
|
cell: {
|
|
705
|
-
classNames
|
|
703
|
+
classNames,
|
|
704
|
+
...props.meta?.cell
|
|
706
705
|
}
|
|
707
706
|
},
|
|
708
707
|
header: (column) => {
|
|
@@ -714,17 +713,20 @@ var ColumnBuilder = class {
|
|
|
714
713
|
className: mx5("truncate", classNames)
|
|
715
714
|
}, cellValue ? model?.getText(cellValue) : "");
|
|
716
715
|
}
|
|
717
|
-
}
|
|
716
|
+
};
|
|
718
717
|
}
|
|
719
718
|
/**
|
|
720
719
|
* String formats.
|
|
721
720
|
*/
|
|
722
721
|
string({ label, classNames, onUpdate, ...props } = {}) {
|
|
723
|
-
return
|
|
722
|
+
return {
|
|
723
|
+
...props,
|
|
724
724
|
minSize: 100,
|
|
725
725
|
meta: {
|
|
726
|
+
...props.meta,
|
|
726
727
|
onUpdate,
|
|
727
728
|
cell: {
|
|
729
|
+
...props.meta?.cell,
|
|
728
730
|
classNames
|
|
729
731
|
}
|
|
730
732
|
},
|
|
@@ -738,39 +740,46 @@ var ColumnBuilder = class {
|
|
|
738
740
|
className: mx5("truncate", textPadding, classNames)
|
|
739
741
|
}, value);
|
|
740
742
|
}
|
|
741
|
-
}
|
|
743
|
+
};
|
|
742
744
|
}
|
|
743
745
|
/**
|
|
744
746
|
* Number formats.
|
|
745
747
|
*/
|
|
746
748
|
number({ label, minSize, classNames, digits, onUpdate, ...props } = {}) {
|
|
747
|
-
return
|
|
749
|
+
return {
|
|
750
|
+
...props,
|
|
748
751
|
size: 100,
|
|
749
752
|
minSize: 100,
|
|
750
753
|
meta: {
|
|
754
|
+
...props.meta,
|
|
751
755
|
onUpdate,
|
|
752
756
|
digits,
|
|
753
757
|
header: {
|
|
754
|
-
classNames: "text-end"
|
|
758
|
+
classNames: "text-end",
|
|
759
|
+
...props.meta?.header
|
|
755
760
|
},
|
|
756
761
|
cell: {
|
|
762
|
+
...props.meta?.cell,
|
|
757
763
|
classNames
|
|
758
764
|
}
|
|
759
765
|
},
|
|
760
766
|
header: (cell) => label ?? cell.header.id,
|
|
761
767
|
cell: NumberBuilderCell
|
|
762
|
-
}
|
|
768
|
+
};
|
|
763
769
|
}
|
|
764
770
|
/**
|
|
765
771
|
* Date formats.
|
|
766
772
|
*/
|
|
767
773
|
// TODO(burdon): Date picker (pluggable renderers?)
|
|
768
774
|
date({ label, format: formatSpec, relative, classNames, ...props } = {}) {
|
|
769
|
-
return
|
|
775
|
+
return {
|
|
776
|
+
...props,
|
|
770
777
|
size: 220,
|
|
771
778
|
minSize: 100,
|
|
772
779
|
meta: {
|
|
780
|
+
...props.meta,
|
|
773
781
|
cell: {
|
|
782
|
+
...props.meta?.cell,
|
|
774
783
|
classNames
|
|
775
784
|
}
|
|
776
785
|
},
|
|
@@ -789,20 +798,24 @@ var ColumnBuilder = class {
|
|
|
789
798
|
return null;
|
|
790
799
|
}
|
|
791
800
|
}
|
|
792
|
-
}
|
|
801
|
+
};
|
|
793
802
|
}
|
|
794
803
|
/**
|
|
795
804
|
* PublicKey with tooltip.
|
|
796
805
|
*/
|
|
797
|
-
key({ label, tooltip, ...props } = {}) {
|
|
798
|
-
return
|
|
806
|
+
key({ label, tooltip, classNames, ...props } = {}) {
|
|
807
|
+
return {
|
|
808
|
+
...props,
|
|
799
809
|
size: 94,
|
|
800
810
|
minSize: 94,
|
|
801
811
|
meta: {
|
|
812
|
+
...props.meta,
|
|
802
813
|
cell: {
|
|
814
|
+
...props.meta?.cell,
|
|
803
815
|
classNames: [
|
|
804
816
|
"font-mono",
|
|
805
|
-
textPadding
|
|
817
|
+
textPadding,
|
|
818
|
+
classNames
|
|
806
819
|
]
|
|
807
820
|
}
|
|
808
821
|
},
|
|
@@ -816,21 +829,21 @@ var ColumnBuilder = class {
|
|
|
816
829
|
if (!tooltip) {
|
|
817
830
|
return element;
|
|
818
831
|
}
|
|
819
|
-
return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Content, {
|
|
832
|
+
return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip.Content, {
|
|
820
833
|
side: "right"
|
|
821
834
|
}, /* @__PURE__ */ React8.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React8.createElement(ClipboardText, {
|
|
822
835
|
onClick: (ev) => {
|
|
823
836
|
ev.stopPropagation();
|
|
824
837
|
void navigator.clipboard.writeText(value.toHex());
|
|
825
838
|
}
|
|
826
|
-
}))));
|
|
839
|
+
})))));
|
|
827
840
|
}
|
|
828
|
-
}
|
|
841
|
+
};
|
|
829
842
|
}
|
|
830
843
|
/**
|
|
831
844
|
* Row selector
|
|
832
845
|
*/
|
|
833
|
-
selectRow({
|
|
846
|
+
selectRow({ classNames, onUpdate, id = "selectRow" } = {}) {
|
|
834
847
|
return {
|
|
835
848
|
id,
|
|
836
849
|
size: 32,
|
|
@@ -862,12 +875,15 @@ var ColumnBuilder = class {
|
|
|
862
875
|
* Switch
|
|
863
876
|
*/
|
|
864
877
|
switch({ label, classNames, onUpdate, ...props } = {}) {
|
|
865
|
-
return
|
|
878
|
+
return {
|
|
879
|
+
...props,
|
|
866
880
|
size: 50,
|
|
867
881
|
minSize: 50,
|
|
868
882
|
meta: {
|
|
883
|
+
...props.meta,
|
|
869
884
|
onUpdate,
|
|
870
885
|
cell: {
|
|
886
|
+
...props.meta?.cell,
|
|
871
887
|
classNames: [
|
|
872
888
|
textPadding,
|
|
873
889
|
classNames
|
|
@@ -876,7 +892,7 @@ var ColumnBuilder = class {
|
|
|
876
892
|
},
|
|
877
893
|
header: (column) => label ?? column.header.id,
|
|
878
894
|
cell: SwitchBuilderCell
|
|
879
|
-
}
|
|
895
|
+
};
|
|
880
896
|
}
|
|
881
897
|
/**
|
|
882
898
|
* Icon based on boolean value.
|
|
@@ -884,7 +900,8 @@ var ColumnBuilder = class {
|
|
|
884
900
|
icon({ label, size, on, off, ...props } = {}) {
|
|
885
901
|
const IconOn = on?.Icon ?? Check2;
|
|
886
902
|
const IconOff = off?.Icon ?? X2;
|
|
887
|
-
return
|
|
903
|
+
return {
|
|
904
|
+
...props,
|
|
888
905
|
size: size ?? 32,
|
|
889
906
|
header: (column) => /* @__PURE__ */ React8.createElement("div", {
|
|
890
907
|
className: "justify-center"
|
|
@@ -903,7 +920,7 @@ var ColumnBuilder = class {
|
|
|
903
920
|
return null;
|
|
904
921
|
}
|
|
905
922
|
}
|
|
906
|
-
}
|
|
923
|
+
};
|
|
907
924
|
}
|
|
908
925
|
};
|
|
909
926
|
export {
|
|
@@ -933,6 +950,7 @@ export {
|
|
|
933
950
|
theadResizeThumb,
|
|
934
951
|
theadRoot,
|
|
935
952
|
theadTh,
|
|
936
|
-
theadTr
|
|
953
|
+
theadTr,
|
|
954
|
+
translations_default as translations
|
|
937
955
|
};
|
|
938
956
|
//# sourceMappingURL=index.mjs.map
|