@dxos/react-ui-table 0.7.5-main.499c70c → 0.7.5-main.937ce75
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 +158 -117
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +146 -102
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +158 -117
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +6 -15
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +48 -0
- package/dist/types/src/model/table-sorting.d.ts.map +1 -0
- package/package.json +29 -29
- package/src/components/Table/CreateRefPanel.tsx +3 -4
- package/src/model/table-model.ts +28 -86
- package/src/model/table-presentation.ts +5 -2
- package/src/model/table-sorting.ts +131 -0
- package/src/playwright/smoke.spec.ts +16 -1
package/dist/lib/node/index.cjs
CHANGED
|
@@ -77,7 +77,6 @@ var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
|
77
77
|
var import_react6 = __toESM(require("react"));
|
|
78
78
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
79
79
|
var import_signals_core = require("@preact/signals-core");
|
|
80
|
-
var import_lodash = __toESM(require("lodash.orderby"));
|
|
81
80
|
var import_context = require("@dxos/context");
|
|
82
81
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
83
82
|
var import_invariant2 = require("@dxos/invariant");
|
|
@@ -92,15 +91,19 @@ var import_react_client2 = require("@dxos/react-client");
|
|
|
92
91
|
var import_echo5 = require("@dxos/react-client/echo");
|
|
93
92
|
var import_schema = require("@dxos/schema");
|
|
94
93
|
var import_signals_core3 = require("@preact/signals-core");
|
|
95
|
-
var
|
|
96
|
-
var import_signals_core4 = require("@preact/signals-core");
|
|
94
|
+
var import_lodash = __toESM(require("lodash.orderby"));
|
|
97
95
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
98
96
|
var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
97
|
+
var import_signals_core4 = require("@preact/signals-core");
|
|
98
|
+
var import_log2 = require("@dxos/log");
|
|
99
|
+
var import_signals_core5 = require("@preact/signals-core");
|
|
100
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
101
|
+
var import_react_ui_form6 = require("@dxos/react-ui-form");
|
|
99
102
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
100
103
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
101
104
|
var import_schema2 = require("@dxos/schema");
|
|
102
105
|
var import_react7 = __toESM(require("react"));
|
|
103
|
-
var
|
|
106
|
+
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
104
107
|
var import_invariant3 = require("@dxos/invariant");
|
|
105
108
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
106
109
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
@@ -242,7 +245,9 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
242
245
|
if (!space || state?.type !== "createRefPanel") {
|
|
243
246
|
return;
|
|
244
247
|
}
|
|
245
|
-
const schema2 = space.db.schemaRegistry.
|
|
248
|
+
const [schema2] = space.db.schemaRegistry.query({
|
|
249
|
+
typename: state.typename
|
|
250
|
+
}).runSync();
|
|
246
251
|
if (schema2) {
|
|
247
252
|
const omit = import_echo_schema2.S.omit("id");
|
|
248
253
|
return omit(schema2);
|
|
@@ -255,7 +260,9 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
255
260
|
if (!model || !space || state?.type !== "createRefPanel") {
|
|
256
261
|
return;
|
|
257
262
|
}
|
|
258
|
-
const schema2 = space.db.schemaRegistry.
|
|
263
|
+
const [schema2] = space.db.schemaRegistry.query({
|
|
264
|
+
typename: state.typename
|
|
265
|
+
}).runSync();
|
|
259
266
|
if (schema2) {
|
|
260
267
|
const obj = space.db.add((0, import_echo3.create)(schema2, values));
|
|
261
268
|
state.onCreate?.(obj);
|
|
@@ -630,6 +637,93 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
630
637
|
return this._allSelected;
|
|
631
638
|
}
|
|
632
639
|
};
|
|
640
|
+
var TableSorting = class {
|
|
641
|
+
constructor(rows, _table, _projection) {
|
|
642
|
+
this._table = _table;
|
|
643
|
+
this._projection = _projection;
|
|
644
|
+
this._displayToDataIndex = /* @__PURE__ */ new Map();
|
|
645
|
+
this._sorting = (0, import_signals_core3.signal)(void 0);
|
|
646
|
+
this._rows = rows;
|
|
647
|
+
this.sortedRows = this.initialiseSortedRows();
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* @reactive
|
|
651
|
+
*/
|
|
652
|
+
get sorting() {
|
|
653
|
+
return this._sorting.value;
|
|
654
|
+
}
|
|
655
|
+
getDataIndex(displayIndex) {
|
|
656
|
+
return this._displayToDataIndex.get(displayIndex) ?? displayIndex;
|
|
657
|
+
}
|
|
658
|
+
setSort(fieldId, direction) {
|
|
659
|
+
this._sorting.value = {
|
|
660
|
+
fieldId,
|
|
661
|
+
direction
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
//
|
|
665
|
+
// Initialisation.
|
|
666
|
+
//
|
|
667
|
+
initialiseSortedRows() {
|
|
668
|
+
return (0, import_signals_core3.computed)(() => {
|
|
669
|
+
this._displayToDataIndex.clear();
|
|
670
|
+
const sort = this._sorting.value;
|
|
671
|
+
if (!sort) {
|
|
672
|
+
return this._rows.value;
|
|
673
|
+
}
|
|
674
|
+
const field = this._table.view?.target?.fields.find((f) => f.id === sort.fieldId);
|
|
675
|
+
if (!field) {
|
|
676
|
+
return this._rows.value;
|
|
677
|
+
}
|
|
678
|
+
const { props } = this._projection.getFieldProjection(field.id);
|
|
679
|
+
const dataWithIndices = this._rows.value.map((item, index) => {
|
|
680
|
+
const sortValue = this.getSortValue(props, field, item);
|
|
681
|
+
const isEmpty = !(props.type === import_echo_schema5.TypeEnum.Boolean) && (sortValue == null || sortValue === "");
|
|
682
|
+
return {
|
|
683
|
+
item,
|
|
684
|
+
index,
|
|
685
|
+
value: sortValue,
|
|
686
|
+
isEmpty
|
|
687
|
+
};
|
|
688
|
+
});
|
|
689
|
+
const ordered = (0, import_lodash.default)(dataWithIndices, [
|
|
690
|
+
"isEmpty",
|
|
691
|
+
"value"
|
|
692
|
+
], [
|
|
693
|
+
"asc",
|
|
694
|
+
sort.direction
|
|
695
|
+
]);
|
|
696
|
+
ordered.forEach(({ index: dataIndex }, displayIndex) => {
|
|
697
|
+
if (displayIndex !== dataIndex) {
|
|
698
|
+
this._displayToDataIndex.set(displayIndex, dataIndex);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
return ordered.map(({ item }) => item);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
getSortValue(props, field, item) {
|
|
705
|
+
const { type, format } = props;
|
|
706
|
+
const value = (0, import_echo_schema5.getValue)(item, field.path);
|
|
707
|
+
if (type === import_echo_schema5.TypeEnum.Boolean) {
|
|
708
|
+
return !!value;
|
|
709
|
+
}
|
|
710
|
+
if (type === import_echo_schema5.TypeEnum.Number) {
|
|
711
|
+
return value;
|
|
712
|
+
}
|
|
713
|
+
if (value == null) {
|
|
714
|
+
return value;
|
|
715
|
+
}
|
|
716
|
+
if (format === import_echo_schema5.FormatEnum.Ref && field.referencePath) {
|
|
717
|
+
const refValue = (0, import_echo_schema5.getValue)(value.target, field.referencePath);
|
|
718
|
+
return refValue;
|
|
719
|
+
}
|
|
720
|
+
return (0, import_react_ui_form5.formatForDisplay)({
|
|
721
|
+
type,
|
|
722
|
+
format,
|
|
723
|
+
value
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
};
|
|
633
727
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
634
728
|
var TableModel = class extends import_context.Resource {
|
|
635
729
|
constructor({ table, projection, sorting = [], pinnedRows = {
|
|
@@ -648,8 +742,6 @@ var TableModel = class extends import_context.Resource {
|
|
|
648
742
|
col: 0
|
|
649
743
|
}
|
|
650
744
|
});
|
|
651
|
-
this._displayToDataIndex = /* @__PURE__ */ new Map();
|
|
652
|
-
this._sorting = (0, import_signals_core.signal)(void 0);
|
|
653
745
|
this._rows = (0, import_signals_core.signal)([]);
|
|
654
746
|
this.setRows = (obj) => {
|
|
655
747
|
this._rows.value = obj;
|
|
@@ -657,11 +749,11 @@ var TableModel = class extends import_context.Resource {
|
|
|
657
749
|
this.getRowCount = () => this._rows.value.length;
|
|
658
750
|
this.getColumnCount = () => this.table.view?.target?.fields.length ?? 0;
|
|
659
751
|
this.insertRow = (rowIndex) => {
|
|
660
|
-
const row = rowIndex !== void 0 ? this.
|
|
752
|
+
const row = rowIndex !== void 0 ? this._sorting.getDataIndex(rowIndex) : this._rows.value.length;
|
|
661
753
|
this._onInsertRow?.(row);
|
|
662
754
|
};
|
|
663
755
|
this.deleteRow = (rowIndex) => {
|
|
664
|
-
const row = this.
|
|
756
|
+
const row = this._sorting.getDataIndex(rowIndex);
|
|
665
757
|
const obj = this._rows.value[row];
|
|
666
758
|
const objectsToDelete = [];
|
|
667
759
|
if (this._selection.hasSelection.value) {
|
|
@@ -678,7 +770,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
678
770
|
return void 0;
|
|
679
771
|
}
|
|
680
772
|
const field = fields[col];
|
|
681
|
-
const dataIndex = this.
|
|
773
|
+
const dataIndex = this._sorting.getDataIndex(row);
|
|
682
774
|
const value = (0, import_echo_schema3.getValue)(this._rows.value[dataIndex], field.path);
|
|
683
775
|
if (value == null) {
|
|
684
776
|
return "";
|
|
@@ -701,7 +793,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
701
793
|
}
|
|
702
794
|
};
|
|
703
795
|
this.setCellData = ({ col, row }, value) => {
|
|
704
|
-
const rowIdx = this.
|
|
796
|
+
const rowIdx = this._sorting.getDataIndex(row);
|
|
705
797
|
const fields = this.table.view?.target?.fields ?? [];
|
|
706
798
|
if (col < 0 || col >= fields.length) {
|
|
707
799
|
return;
|
|
@@ -727,7 +819,11 @@ var TableModel = class extends import_context.Resource {
|
|
|
727
819
|
};
|
|
728
820
|
this._table = table;
|
|
729
821
|
this._projection = projection;
|
|
730
|
-
this._sorting
|
|
822
|
+
this._sorting = new TableSorting(this._rows, table, projection);
|
|
823
|
+
if (sorting.length > 0) {
|
|
824
|
+
const [sort] = sorting;
|
|
825
|
+
this._sorting.setSort(sort.fieldId, sort.direction);
|
|
826
|
+
}
|
|
731
827
|
this._pinnedRows = pinnedRows;
|
|
732
828
|
this._onInsertRow = onInsertRow;
|
|
733
829
|
this._onDeleteRows = onDeleteRows;
|
|
@@ -742,7 +838,13 @@ var TableModel = class extends import_context.Resource {
|
|
|
742
838
|
return this._projection;
|
|
743
839
|
}
|
|
744
840
|
get rows() {
|
|
745
|
-
return this.
|
|
841
|
+
return this._sorting.sortedRows;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* @reactive
|
|
845
|
+
*/
|
|
846
|
+
get sorting() {
|
|
847
|
+
return this._sorting.sorting;
|
|
746
848
|
}
|
|
747
849
|
get pinnedRows() {
|
|
748
850
|
return this._pinnedRows;
|
|
@@ -759,9 +861,6 @@ var TableModel = class extends import_context.Resource {
|
|
|
759
861
|
});
|
|
760
862
|
return this._columnMeta;
|
|
761
863
|
}
|
|
762
|
-
get sorting() {
|
|
763
|
-
return this._sorting.value;
|
|
764
|
-
}
|
|
765
864
|
get selection() {
|
|
766
865
|
return this._selection;
|
|
767
866
|
}
|
|
@@ -770,9 +869,8 @@ var TableModel = class extends import_context.Resource {
|
|
|
770
869
|
//
|
|
771
870
|
async _open() {
|
|
772
871
|
this.initializeColumnMeta();
|
|
773
|
-
this.initializeSorting();
|
|
774
872
|
this.initializeEffects();
|
|
775
|
-
this._selection = new SelectionModel(this.
|
|
873
|
+
this._selection = new SelectionModel(this._sorting.sortedRows, () => this._onRowOrderChanged?.());
|
|
776
874
|
await this._selection.open(this._ctx);
|
|
777
875
|
}
|
|
778
876
|
initializeColumnMeta() {
|
|
@@ -802,60 +900,9 @@ var TableModel = class extends import_context.Resource {
|
|
|
802
900
|
};
|
|
803
901
|
});
|
|
804
902
|
}
|
|
805
|
-
initializeSorting() {
|
|
806
|
-
this._sortedRows = (0, import_signals_core.computed)(() => {
|
|
807
|
-
this._displayToDataIndex.clear();
|
|
808
|
-
const sort = this._sorting.value;
|
|
809
|
-
if (!sort) {
|
|
810
|
-
return this._rows.value;
|
|
811
|
-
}
|
|
812
|
-
const field = this._table.view?.target?.fields.find((field2) => field2.id === sort.fieldId);
|
|
813
|
-
if (!field) {
|
|
814
|
-
return this._rows.value;
|
|
815
|
-
}
|
|
816
|
-
const { props } = this._projection.getFieldProjection(field.id);
|
|
817
|
-
const dataWithIndices = this._rows.value.map((item, index) => {
|
|
818
|
-
const rawValue = (0, import_echo_schema3.getValue)(item, field.path);
|
|
819
|
-
let sortValue = rawValue;
|
|
820
|
-
if (props.type.startsWith("boolean")) {
|
|
821
|
-
sortValue = !!rawValue;
|
|
822
|
-
} else if (rawValue != null) {
|
|
823
|
-
if (props.format === import_echo_schema3.FormatEnum.Ref && field.referencePath) {
|
|
824
|
-
sortValue = (0, import_echo_schema3.getValue)(rawValue, field.referencePath);
|
|
825
|
-
} else {
|
|
826
|
-
sortValue = (0, import_react_ui_form4.formatForDisplay)({
|
|
827
|
-
type: props.type,
|
|
828
|
-
format: props.format,
|
|
829
|
-
value: rawValue
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
return {
|
|
834
|
-
item,
|
|
835
|
-
index,
|
|
836
|
-
value: sortValue,
|
|
837
|
-
isEmpty: !props.type.startsWith("boolean") && (sortValue == null || sortValue === "")
|
|
838
|
-
};
|
|
839
|
-
});
|
|
840
|
-
const sorted = (0, import_lodash.default)(dataWithIndices, [
|
|
841
|
-
"isEmpty",
|
|
842
|
-
"value"
|
|
843
|
-
], [
|
|
844
|
-
"asc",
|
|
845
|
-
sort.direction
|
|
846
|
-
]);
|
|
847
|
-
for (let displayIndex = 0; displayIndex < sorted.length; displayIndex++) {
|
|
848
|
-
const { index: dataIndex } = sorted[displayIndex];
|
|
849
|
-
if (displayIndex !== dataIndex) {
|
|
850
|
-
this._displayToDataIndex.set(displayIndex, dataIndex);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
return sorted.map(({ item }) => item);
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
903
|
initializeEffects() {
|
|
857
904
|
const rowOrderWatcher = (0, import_signals_core.effect)(() => {
|
|
858
|
-
touch(this.
|
|
905
|
+
touch(this._sorting.sortedRows.value);
|
|
859
906
|
this._onRowOrderChanged?.();
|
|
860
907
|
});
|
|
861
908
|
this._ctx.onDispose(rowOrderWatcher);
|
|
@@ -864,7 +911,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
864
911
|
const rowEffects = [];
|
|
865
912
|
for (let row = start.row; row <= end.row; row++) {
|
|
866
913
|
rowEffects.push((0, import_signals_core.effect)(() => {
|
|
867
|
-
const obj = this.
|
|
914
|
+
const obj = this._sorting.sortedRows.value[row];
|
|
868
915
|
this?._table?.view?.target?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
|
|
869
916
|
this._onCellUpdate?.({
|
|
870
917
|
row,
|
|
@@ -883,7 +930,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
883
930
|
* @param {(value: any) => any} update - A function that takes the current value and returns the updated value.
|
|
884
931
|
*/
|
|
885
932
|
updateCellData({ col, row }, update) {
|
|
886
|
-
const dataRow = this.
|
|
933
|
+
const dataRow = this._sorting.getDataIndex(row);
|
|
887
934
|
const fields = this.table.view?.target?.fields ?? [];
|
|
888
935
|
const field = fields[col];
|
|
889
936
|
const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
|
|
@@ -899,9 +946,6 @@ var TableModel = class extends import_context.Resource {
|
|
|
899
946
|
}
|
|
900
947
|
const field = this.table.view.target?.fields.find((field2) => field2.id === fieldId);
|
|
901
948
|
if (field && this._onDeleteColumn) {
|
|
902
|
-
if (this._sorting.value?.fieldId === fieldId) {
|
|
903
|
-
this.clearSort();
|
|
904
|
-
}
|
|
905
949
|
this._onDeleteColumn(field.id);
|
|
906
950
|
}
|
|
907
951
|
}
|
|
@@ -922,13 +966,10 @@ var TableModel = class extends import_context.Resource {
|
|
|
922
966
|
// Sorting
|
|
923
967
|
//
|
|
924
968
|
setSort(fieldId, direction) {
|
|
925
|
-
this._sorting.
|
|
926
|
-
fieldId,
|
|
927
|
-
direction
|
|
928
|
-
};
|
|
969
|
+
this._sorting.setSort(fieldId, direction);
|
|
929
970
|
}
|
|
930
971
|
clearSort() {
|
|
931
|
-
this._sorting.
|
|
972
|
+
this._sorting.setSort("", "asc");
|
|
932
973
|
}
|
|
933
974
|
//
|
|
934
975
|
// Pinning
|
|
@@ -945,7 +986,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
945
986
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/modal-controller.ts";
|
|
946
987
|
var ModalController = class {
|
|
947
988
|
constructor() {
|
|
948
|
-
this._state = (0,
|
|
989
|
+
this._state = (0, import_signals_core4.signal)({
|
|
949
990
|
type: "closed"
|
|
950
991
|
});
|
|
951
992
|
this._triggerRef = {
|
|
@@ -1027,7 +1068,7 @@ var ModalController = class {
|
|
|
1027
1068
|
}
|
|
1028
1069
|
};
|
|
1029
1070
|
var TablePresentation = class {
|
|
1030
|
-
constructor(model, _visibleRange = (0,
|
|
1071
|
+
constructor(model, _visibleRange = (0, import_signals_core5.signal)({
|
|
1031
1072
|
start: {
|
|
1032
1073
|
row: 0,
|
|
1033
1074
|
col: 0
|
|
@@ -1066,22 +1107,22 @@ var TablePresentation = class {
|
|
|
1066
1107
|
const { props } = this.model.projection.getFieldProjection(field.id);
|
|
1067
1108
|
const cell = {
|
|
1068
1109
|
get value() {
|
|
1069
|
-
const value = (0,
|
|
1110
|
+
const value = (0, import_echo_schema6.getValue)(obj, field.path);
|
|
1070
1111
|
if (value == null) {
|
|
1071
1112
|
return "";
|
|
1072
1113
|
}
|
|
1073
1114
|
switch (props.format) {
|
|
1074
|
-
case
|
|
1115
|
+
case import_echo_schema6.FormatEnum.Boolean: {
|
|
1075
1116
|
return "";
|
|
1076
1117
|
}
|
|
1077
|
-
case
|
|
1118
|
+
case import_echo_schema6.FormatEnum.Ref: {
|
|
1078
1119
|
if (!field.referencePath) {
|
|
1079
1120
|
return "";
|
|
1080
1121
|
}
|
|
1081
|
-
return (0,
|
|
1122
|
+
return (0, import_echo_schema6.getValue)(value.target, field.referencePath);
|
|
1082
1123
|
}
|
|
1083
1124
|
default: {
|
|
1084
|
-
return (0,
|
|
1125
|
+
return (0, import_react_ui_form6.formatForDisplay)({
|
|
1085
1126
|
type: props.type,
|
|
1086
1127
|
format: props.format,
|
|
1087
1128
|
value
|
|
@@ -1091,22 +1132,22 @@ var TablePresentation = class {
|
|
|
1091
1132
|
}
|
|
1092
1133
|
};
|
|
1093
1134
|
const classes = [];
|
|
1094
|
-
const formatClasses = (0,
|
|
1135
|
+
const formatClasses = (0, import_react_ui_form6.cellClassesForFieldType)({
|
|
1095
1136
|
type: props.type,
|
|
1096
1137
|
format: props.format
|
|
1097
1138
|
});
|
|
1098
1139
|
if (formatClasses) {
|
|
1099
1140
|
classes.push(formatClasses);
|
|
1100
1141
|
}
|
|
1101
|
-
const rowSelectionClasses = (0,
|
|
1142
|
+
const rowSelectionClasses = (0, import_react_ui_form6.cellClassesForRowSelection)(this.model.selection.isObjectSelected(obj));
|
|
1102
1143
|
if (rowSelectionClasses) {
|
|
1103
1144
|
classes.push(rowSelectionClasses);
|
|
1104
1145
|
}
|
|
1105
1146
|
if (classes.length > 0) {
|
|
1106
1147
|
cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
|
|
1107
1148
|
}
|
|
1108
|
-
if (props.format ===
|
|
1109
|
-
const targetObj = (0,
|
|
1149
|
+
if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
|
|
1150
|
+
const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
|
|
1110
1151
|
if (targetObj) {
|
|
1111
1152
|
cell.accessoryHtml = tableButtons.referencedCell.render({
|
|
1112
1153
|
targetId: targetObj.id,
|
|
@@ -1114,8 +1155,8 @@ var TablePresentation = class {
|
|
|
1114
1155
|
});
|
|
1115
1156
|
}
|
|
1116
1157
|
}
|
|
1117
|
-
if (props.format ===
|
|
1118
|
-
const value = (0,
|
|
1158
|
+
if (props.format === import_echo_schema6.FormatEnum.Boolean) {
|
|
1159
|
+
const value = (0, import_echo_schema6.getValue)(obj, field.path);
|
|
1119
1160
|
cell.accessoryHtml = tableControls.switch.render({
|
|
1120
1161
|
colIndex,
|
|
1121
1162
|
rowIndex: displayIndex,
|
|
@@ -1155,7 +1196,8 @@ var TablePresentation = class {
|
|
|
1155
1196
|
resizeHandle: "col",
|
|
1156
1197
|
accessoryHtml: tableButtons.columnSettings.render({
|
|
1157
1198
|
fieldId: field.id
|
|
1158
|
-
})
|
|
1199
|
+
}),
|
|
1200
|
+
className: "!bg-gridHeader"
|
|
1159
1201
|
};
|
|
1160
1202
|
}
|
|
1161
1203
|
return cells;
|
|
@@ -1164,7 +1206,7 @@ var TablePresentation = class {
|
|
|
1164
1206
|
const cells = {};
|
|
1165
1207
|
for (let row = range.start.row; row <= range.end.row && row < this.model.getRowCount(); row++) {
|
|
1166
1208
|
const isSelected = this.model.selection.isRowIndexSelected(row);
|
|
1167
|
-
const classes = (0,
|
|
1209
|
+
const classes = (0, import_react_ui_form6.cellClassesForRowSelection)(isSelected);
|
|
1168
1210
|
cells[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1169
1211
|
col: 0,
|
|
1170
1212
|
row
|
|
@@ -1184,7 +1226,7 @@ var TablePresentation = class {
|
|
|
1184
1226
|
const cells = {};
|
|
1185
1227
|
for (let row = range.start.row; row <= range.end.row && row < this.model.getRowCount(); row++) {
|
|
1186
1228
|
const isSelected = this.model.selection.isRowIndexSelected(row);
|
|
1187
|
-
const classes = (0,
|
|
1229
|
+
const classes = (0, import_react_ui_form6.cellClassesForRowSelection)(isSelected);
|
|
1188
1230
|
cells[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1189
1231
|
col: 0,
|
|
1190
1232
|
row
|
|
@@ -1205,13 +1247,14 @@ var TablePresentation = class {
|
|
|
1205
1247
|
col: 0,
|
|
1206
1248
|
row: 0
|
|
1207
1249
|
})]: {
|
|
1208
|
-
value: "",
|
|
1209
1250
|
accessoryHtml: tableControls.checkbox.render({
|
|
1210
1251
|
rowIndex: 0,
|
|
1211
1252
|
header: true,
|
|
1212
1253
|
checked: this.model.selection.allRowsSeleted.value
|
|
1213
1254
|
}),
|
|
1214
|
-
|
|
1255
|
+
className: "!bg-gridHeader",
|
|
1256
|
+
readonly: true,
|
|
1257
|
+
value: ""
|
|
1215
1258
|
}
|
|
1216
1259
|
};
|
|
1217
1260
|
}
|
|
@@ -1221,11 +1264,12 @@ var TablePresentation = class {
|
|
|
1221
1264
|
col: 0,
|
|
1222
1265
|
row: 0
|
|
1223
1266
|
})]: {
|
|
1224
|
-
value: "",
|
|
1225
1267
|
accessoryHtml: tableButtons.addColumn.render({
|
|
1226
1268
|
disabled: (this.model.table.view?.target?.fields?.length ?? 0) >= import_schema2.VIEW_FIELD_LIMIT
|
|
1227
1269
|
}),
|
|
1228
|
-
|
|
1270
|
+
className: "!bg-gridHeader",
|
|
1271
|
+
readonly: true,
|
|
1272
|
+
value: ""
|
|
1229
1273
|
}
|
|
1230
1274
|
};
|
|
1231
1275
|
}
|
|
@@ -1357,7 +1401,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1357
1401
|
];
|
|
1358
1402
|
if (onQuery) {
|
|
1359
1403
|
switch (fieldProjection.props.format) {
|
|
1360
|
-
case
|
|
1404
|
+
case import_echo_schema7.FormatEnum.Ref: {
|
|
1361
1405
|
extension2.push([
|
|
1362
1406
|
completion({
|
|
1363
1407
|
onQuery: (text) => onQuery(fieldProjection, text),
|