@teselagen/ui 0.8.6-beta.23 → 0.8.6-beta.25
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/DataTable/EditabelCell.d.ts +7 -0
- package/DataTable/defaultProps.d.ts +43 -0
- package/DataTable/utils/computePresets.d.ts +1 -0
- package/DataTable/utils/convertSchema.d.ts +22 -2
- package/DataTable/utils/formatPasteData.d.ts +11 -5
- package/DataTable/utils/getAllRows.d.ts +4 -1
- package/DataTable/utils/getCellCopyText.d.ts +1 -1
- package/DataTable/utils/getCellInfo.d.ts +20 -15
- package/DataTable/utils/getFieldPathToField.d.ts +5 -1
- package/DataTable/utils/getIdOrCodeOrIndex.d.ts +2 -1
- package/DataTable/utils/getLastSelectedEntity.d.ts +7 -1
- package/DataTable/utils/getNewEntToSelect.d.ts +7 -6
- package/DataTable/utils/getRowCopyText.d.ts +1 -1
- package/DataTable/utils/handleCopyColumn.d.ts +1 -1
- package/DataTable/utils/handleCopyTable.d.ts +1 -1
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +22 -1
- package/DataTable/utils/isBottomRightCornerOfRectangle.d.ts +10 -8
- package/DataTable/utils/isEntityClean.d.ts +3 -1
- package/DataTable/utils/primarySelectedValue.d.ts +1 -1
- package/DataTable/utils/removeCleanRows.d.ts +11 -3
- package/DataTable/utils/selection.d.ts +3 -1
- package/DataTable/utils/types/Entity.d.ts +5 -0
- package/DataTable/utils/types/Field.d.ts +4 -0
- package/DataTable/utils/types/OrderBy.d.ts +11 -0
- package/DataTable/utils/types/Schema.d.ts +4 -0
- package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
- package/DataTable/utils/useTableEntities.d.ts +17 -4
- package/DataTable/utils/useTableParams.d.ts +49 -0
- package/DataTable/utils/utils.d.ts +16 -5
- package/index.cjs.js +147 -121
- package/index.es.js +147 -121
- package/package.json +2 -2
- package/src/DataTable/Columns.jsx +945 -0
- package/src/DataTable/EditabelCell.js +44 -0
- package/src/DataTable/EditabelCell.jsx +44 -0
- package/src/DataTable/RenderCell.jsx +191 -0
- package/src/DataTable/defaultProps.js +45 -0
- package/src/DataTable/index.js +96 -68
- package/src/DataTable/utils/computePresets.js +42 -0
- package/src/DataTable/utils/convertSchema.ts +79 -0
- package/src/DataTable/utils/formatPasteData.ts +34 -0
- package/src/DataTable/utils/getAllRows.js +2 -6
- package/src/DataTable/utils/getAllRows.ts +11 -0
- package/src/DataTable/utils/getCellCopyText.ts +7 -0
- package/src/DataTable/utils/getCellInfo.ts +46 -0
- package/src/DataTable/utils/getFieldPathToField.ts +10 -0
- package/src/DataTable/utils/getIdOrCodeOrIndex.ts +14 -0
- package/src/DataTable/utils/getLastSelectedEntity.ts +15 -0
- package/src/DataTable/utils/getNewEntToSelect.ts +32 -0
- package/src/DataTable/utils/handleCopyColumn.js +2 -2
- package/src/DataTable/utils/handleCopyTable.js +2 -2
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.ts +35 -0
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +27 -0
- package/src/DataTable/utils/isEntityClean.ts +15 -0
- package/src/DataTable/utils/primarySelectedValue.ts +1 -0
- package/src/DataTable/utils/removeCleanRows.ts +25 -0
- package/src/DataTable/utils/selection.ts +11 -0
- package/src/DataTable/utils/types/Entity.ts +7 -0
- package/src/DataTable/utils/types/Field.ts +4 -0
- package/src/DataTable/utils/types/OrderBy.ts +15 -0
- package/src/DataTable/utils/types/Schema.ts +5 -0
- package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
- package/src/DataTable/utils/useTableEntities.ts +60 -0
- package/src/DataTable/utils/useTableParams.js +361 -0
- package/src/DataTable/utils/utils.ts +39 -0
- package/style.css +10537 -0
package/index.es.js
CHANGED
|
@@ -15849,6 +15849,7 @@ var itemSizeEstimator = /* @__PURE__ */ __name(function itemSizeEstimator2() {
|
|
|
15849
15849
|
return 41.36;
|
|
15850
15850
|
}, "itemSizeEstimator");
|
|
15851
15851
|
var ReactTableDefaults = defaultProps;
|
|
15852
|
+
var VIRTUALIZE_CUTOFF_LENGTH = 200;
|
|
15852
15853
|
var ReactTable = function(_Methods) {
|
|
15853
15854
|
_inherits$8(ReactTable2, _Methods);
|
|
15854
15855
|
function ReactTable2(props) {
|
|
@@ -16434,7 +16435,7 @@ var ReactTable = function(_Methods) {
|
|
|
16434
16435
|
minWidth: rowMinWidth + "px"
|
|
16435
16436
|
})
|
|
16436
16437
|
}, tBodyProps.rest),
|
|
16437
|
-
pageRows.length <
|
|
16438
|
+
_this2.props.noVirtual || pageRows.length < VIRTUALIZE_CUTOFF_LENGTH ? pageRows.map(function(d2, i2) {
|
|
16438
16439
|
return makePageRow(d2, i2);
|
|
16439
16440
|
}) : React__default.createElement(ReactList, {
|
|
16440
16441
|
type: "variable",
|
|
@@ -16527,18 +16528,21 @@ function isEntityClean(e) {
|
|
|
16527
16528
|
}
|
|
16528
16529
|
__name(isEntityClean, "isEntityClean");
|
|
16529
16530
|
const getIdOrCodeOrIndex = /* @__PURE__ */ __name((record, rowIndex) => {
|
|
16530
|
-
if (record.id || record.id === 0) {
|
|
16531
|
+
if ("id" in record && (record.id || record.id === 0)) {
|
|
16531
16532
|
return record.id;
|
|
16532
|
-
} else if (record.code) {
|
|
16533
|
+
} else if ("code" in record && record.code) {
|
|
16533
16534
|
return record.code;
|
|
16534
16535
|
} else {
|
|
16536
|
+
if (rowIndex === void 0 || rowIndex === null) {
|
|
16537
|
+
throw new Error("id, code, or rowIndex must be provided");
|
|
16538
|
+
}
|
|
16535
16539
|
return rowIndex;
|
|
16536
16540
|
}
|
|
16537
16541
|
}, "getIdOrCodeOrIndex");
|
|
16538
16542
|
const getSelectedRowsFromEntities = /* @__PURE__ */ __name((entities, idMap) => {
|
|
16539
16543
|
if (!idMap) return [];
|
|
16540
16544
|
return entities.reduce((acc, entity, i2) => {
|
|
16541
|
-
return idMap[getIdOrCodeOrIndex(entity, i2)] ? acc.concat(i2) : acc;
|
|
16545
|
+
return idMap[getIdOrCodeOrIndex(entity, i2)] ? acc.concat([i2]) : acc;
|
|
16542
16546
|
}, []);
|
|
16543
16547
|
}, "getSelectedRowsFromEntities");
|
|
16544
16548
|
const removeCleanRows = /* @__PURE__ */ __name((entities, cellValidation) => {
|
|
@@ -16618,17 +16622,22 @@ const getFieldPathToField = /* @__PURE__ */ __name((schema) => {
|
|
|
16618
16622
|
});
|
|
16619
16623
|
return fieldPathToField;
|
|
16620
16624
|
}, "getFieldPathToField");
|
|
16621
|
-
const formatPasteData = /* @__PURE__ */ __name(({
|
|
16625
|
+
const formatPasteData = /* @__PURE__ */ __name(({
|
|
16626
|
+
schema,
|
|
16627
|
+
newVal,
|
|
16628
|
+
path: path2
|
|
16629
|
+
}) => {
|
|
16622
16630
|
const pathToField = getFieldPathToField(schema);
|
|
16623
16631
|
const column = pathToField[path2];
|
|
16624
16632
|
if (column.type === "genericSelect") {
|
|
16625
|
-
|
|
16626
|
-
|
|
16633
|
+
const value = newVal;
|
|
16634
|
+
if (value.__genSelCol === path2) {
|
|
16635
|
+
newVal = value.__strVal;
|
|
16627
16636
|
} else {
|
|
16628
16637
|
newVal = void 0;
|
|
16629
16638
|
}
|
|
16630
16639
|
} else {
|
|
16631
|
-
newVal =
|
|
16640
|
+
newVal = typeof newVal === "object" && newVal !== null && "__strVal" in newVal ? newVal.__strVal : newVal;
|
|
16632
16641
|
}
|
|
16633
16642
|
return newVal;
|
|
16634
16643
|
}, "formatPasteData");
|
|
@@ -16653,18 +16662,19 @@ const endsWithNumber = /* @__PURE__ */ __name((str) => {
|
|
|
16653
16662
|
return /[0-9]+$/.test(str);
|
|
16654
16663
|
}, "endsWithNumber");
|
|
16655
16664
|
const getNumberStrAtEnd = /* @__PURE__ */ __name((str) => {
|
|
16665
|
+
var _a;
|
|
16656
16666
|
if (endsWithNumber(str)) {
|
|
16657
|
-
return str.match(/[0-9]+$/)[0];
|
|
16667
|
+
return (_a = str.match(/[0-9]+$/)) == null ? void 0 : _a[0];
|
|
16658
16668
|
}
|
|
16659
16669
|
return null;
|
|
16660
16670
|
}, "getNumberStrAtEnd");
|
|
16661
16671
|
const stripNumberAtEnd = /* @__PURE__ */ __name((str) => {
|
|
16662
16672
|
var _a;
|
|
16663
|
-
return (_a = str == null ? void 0 : str.replace) == null ? void 0 : _a.call(str, getNumberStrAtEnd(str), "");
|
|
16673
|
+
return (_a = str == null ? void 0 : str.replace) == null ? void 0 : _a.call(str, getNumberStrAtEnd(str) || "", "");
|
|
16664
16674
|
}, "stripNumberAtEnd");
|
|
16665
|
-
const getAllRows = /* @__PURE__ */ __name((
|
|
16666
|
-
|
|
16667
|
-
const allRowEls =
|
|
16675
|
+
const getAllRows = /* @__PURE__ */ __name((tableRef) => {
|
|
16676
|
+
var _a, _b;
|
|
16677
|
+
const allRowEls = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr");
|
|
16668
16678
|
if (!allRowEls || !allRowEls.length) {
|
|
16669
16679
|
return;
|
|
16670
16680
|
}
|
|
@@ -16697,7 +16707,7 @@ const getNewEntToSelect = /* @__PURE__ */ __name(({
|
|
|
16697
16707
|
}, "getNewEntToSelect");
|
|
16698
16708
|
const getLastSelectedEntity = /* @__PURE__ */ __name((idMap) => {
|
|
16699
16709
|
let lastSelectedEnt;
|
|
16700
|
-
let latestTime;
|
|
16710
|
+
let latestTime = null;
|
|
16701
16711
|
Object.values(idMap).forEach(({ time, entity }) => {
|
|
16702
16712
|
if (!latestTime || time > latestTime) {
|
|
16703
16713
|
lastSelectedEnt = entity;
|
|
@@ -16737,9 +16747,9 @@ const getCellInfo = /* @__PURE__ */ __name(({
|
|
|
16737
16747
|
};
|
|
16738
16748
|
}, "getCellInfo");
|
|
16739
16749
|
const getCellCopyText = /* @__PURE__ */ __name((cellWrapper) => {
|
|
16740
|
-
const text2 = cellWrapper
|
|
16741
|
-
const jsonText = cellWrapper
|
|
16742
|
-
const textContent = text2 || cellWrapper.textContent || "";
|
|
16750
|
+
const text2 = cellWrapper == null ? void 0 : cellWrapper.getAttribute("data-copy-text");
|
|
16751
|
+
const jsonText = cellWrapper == null ? void 0 : cellWrapper.getAttribute("data-copy-json");
|
|
16752
|
+
const textContent = text2 || (cellWrapper == null ? void 0 : cellWrapper.textContent) || "";
|
|
16743
16753
|
return [textContent, jsonText];
|
|
16744
16754
|
}, "getCellCopyText");
|
|
16745
16755
|
const getRowCopyText = /* @__PURE__ */ __name((rowEl, { specificColumn } = {}) => {
|
|
@@ -16931,14 +16941,14 @@ const handleCopyRows = /* @__PURE__ */ __name((rowElsToCopy, { specificColumn, o
|
|
|
16931
16941
|
handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
|
|
16932
16942
|
}
|
|
16933
16943
|
}, "handleCopyRows");
|
|
16934
|
-
const handleCopyColumn = /* @__PURE__ */ __name((
|
|
16944
|
+
const handleCopyColumn = /* @__PURE__ */ __name((tableRef, cellWrapper, selectedRecords) => {
|
|
16935
16945
|
const specificColumn = cellWrapper.getAttribute("data-test");
|
|
16936
|
-
let rowElsToCopy = getAllRows(
|
|
16946
|
+
let rowElsToCopy = getAllRows(tableRef);
|
|
16937
16947
|
if (!rowElsToCopy) return;
|
|
16938
16948
|
if (selectedRecords) {
|
|
16939
|
-
const ids2 = selectedRecords.map((
|
|
16949
|
+
const ids2 = selectedRecords.map((e) => {
|
|
16940
16950
|
var _a;
|
|
16941
|
-
return (_a = getIdOrCodeOrIndex(
|
|
16951
|
+
return (_a = getIdOrCodeOrIndex(e)) == null ? void 0 : _a.toString();
|
|
16942
16952
|
});
|
|
16943
16953
|
rowElsToCopy = Array.from(rowElsToCopy).filter((rowEl) => {
|
|
16944
16954
|
var _a;
|
|
@@ -16971,9 +16981,9 @@ const isBottomRightCornerOfRectangle = /* @__PURE__ */ __name(({
|
|
|
16971
16981
|
const isBottomRight = i2 === lastRowIndex && cellIndex === lastCellIndex;
|
|
16972
16982
|
return isBottomRight;
|
|
16973
16983
|
}, "isBottomRightCornerOfRectangle");
|
|
16974
|
-
const handleCopyTable = /* @__PURE__ */ __name((
|
|
16984
|
+
const handleCopyTable = /* @__PURE__ */ __name((tableRef, opts) => {
|
|
16975
16985
|
try {
|
|
16976
|
-
const allRowEls = getAllRows(
|
|
16986
|
+
const allRowEls = getAllRows(tableRef);
|
|
16977
16987
|
if (!allRowEls) return;
|
|
16978
16988
|
handleCopyRows(allRowEls, __spreadProps(__spreadValues({}, opts), {
|
|
16979
16989
|
onFinishMsg: "Table Copied"
|
|
@@ -17010,13 +17020,15 @@ const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
|
|
|
17010
17020
|
},
|
|
17011
17021
|
[dispatch, tableFormName]
|
|
17012
17022
|
);
|
|
17013
|
-
const { allOrderedEntities, selectedEntities } = useSelector(
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17017
|
-
|
|
17018
|
-
|
|
17019
|
-
|
|
17023
|
+
const { allOrderedEntities, selectedEntities } = useSelector(
|
|
17024
|
+
(state) => {
|
|
17025
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17026
|
+
return {
|
|
17027
|
+
allOrderedEntities: (_c = (_b = (_a = state.form) == null ? void 0 : _a[tableFormName]) == null ? void 0 : _b.values) == null ? void 0 : _c.allOrderedEntities,
|
|
17028
|
+
selectedEntities: (_f = (_e = (_d = state.form) == null ? void 0 : _d[tableFormName]) == null ? void 0 : _e.values) == null ? void 0 : _f.reduxFormSelectedEntityIdMap
|
|
17029
|
+
};
|
|
17030
|
+
}
|
|
17031
|
+
);
|
|
17020
17032
|
return { selectTableEntities, allOrderedEntities, selectedEntities };
|
|
17021
17033
|
}, "useTableEntities");
|
|
17022
17034
|
const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
|
|
@@ -19886,8 +19898,9 @@ function initializeHasuraWhereAndFilter(additionalFilter, where = {}, currentPar
|
|
|
19886
19898
|
if (newWhere) {
|
|
19887
19899
|
Object.assign(where, newWhere);
|
|
19888
19900
|
}
|
|
19889
|
-
} else if (typeof additionalFilter === "object")
|
|
19901
|
+
} else if (typeof additionalFilter === "object" && additionalFilter !== null) {
|
|
19890
19902
|
where._and.push(additionalFilter);
|
|
19903
|
+
}
|
|
19891
19904
|
}
|
|
19892
19905
|
__name(initializeHasuraWhereAndFilter, "initializeHasuraWhereAndFilter");
|
|
19893
19906
|
const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
|
|
@@ -37214,7 +37227,7 @@ const multiViewColumn = __spreadProps(__spreadValues({}, viewColumn), {
|
|
|
37214
37227
|
));
|
|
37215
37228
|
}, "render")
|
|
37216
37229
|
});
|
|
37217
|
-
|
|
37230
|
+
const convertSchema = /* @__PURE__ */ __name((schema) => {
|
|
37218
37231
|
let schemaToUse = schema;
|
|
37219
37232
|
if (!schemaToUse.fields && Array.isArray(schema)) {
|
|
37220
37233
|
schemaToUse = {
|
|
@@ -37223,35 +37236,26 @@ function convertSchema(schema) {
|
|
|
37223
37236
|
}
|
|
37224
37237
|
schemaToUse = __spreadValues({}, schemaToUse);
|
|
37225
37238
|
schemaToUse.fields = schemaToUse.fields.map((field, i2) => {
|
|
37226
|
-
let fieldToUse = field;
|
|
37227
37239
|
if (typeof field === "string") {
|
|
37228
|
-
|
|
37240
|
+
return {
|
|
37229
37241
|
displayName: startCase(camelCase(field)),
|
|
37230
37242
|
path: field,
|
|
37231
37243
|
type: "string"
|
|
37232
37244
|
};
|
|
37233
|
-
} else
|
|
37234
|
-
fieldToUse =
|
|
37235
|
-
|
|
37236
|
-
|
|
37237
|
-
|
|
37238
|
-
|
|
37239
|
-
|
|
37240
|
-
|
|
37241
|
-
}
|
|
37242
|
-
|
|
37243
|
-
if (!fieldToUse.path) {
|
|
37244
|
-
fieldToUse = __spreadProps(__spreadValues({}, fieldToUse), {
|
|
37245
|
-
filterDisabled: true,
|
|
37246
|
-
sortDisabled: true,
|
|
37247
|
-
path: "fake-path" + i2
|
|
37248
|
-
});
|
|
37245
|
+
} else {
|
|
37246
|
+
const fieldToUse = __spreadValues({}, field);
|
|
37247
|
+
fieldToUse.type = fieldToUse.type || "string";
|
|
37248
|
+
fieldToUse.displayName = fieldToUse.displayName || startCase(camelCase(fieldToUse.path || ""));
|
|
37249
|
+
if (!fieldToUse.path) {
|
|
37250
|
+
fieldToUse.filterDisabled = true;
|
|
37251
|
+
fieldToUse.sortDisabled = true;
|
|
37252
|
+
fieldToUse.path = "fake-path" + i2;
|
|
37253
|
+
}
|
|
37254
|
+
return fieldToUse;
|
|
37249
37255
|
}
|
|
37250
|
-
return fieldToUse;
|
|
37251
37256
|
});
|
|
37252
37257
|
return schemaToUse;
|
|
37253
|
-
}
|
|
37254
|
-
__name(convertSchema, "convertSchema");
|
|
37258
|
+
}, "convertSchema");
|
|
37255
37259
|
function mergeSchemas(_originalSchema, _overrideSchema) {
|
|
37256
37260
|
const originalSchema = convertSchema(_originalSchema);
|
|
37257
37261
|
const overrideSchema = convertSchema(_overrideSchema);
|
|
@@ -56302,6 +56306,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
56302
56306
|
);
|
|
56303
56307
|
const tableRef = useRef();
|
|
56304
56308
|
const alreadySelected = useRef(false);
|
|
56309
|
+
const [noVirtual, setNoVirtual] = useState(false);
|
|
56305
56310
|
const [onlyShowRowsWErrors, setOnlyShowRowsWErrors] = useState(false);
|
|
56306
56311
|
const [entitiesUndoRedoStack, setEntitiesUndoRedoStack] = useState({
|
|
56307
56312
|
currentVersion: 0
|
|
@@ -57143,76 +57148,94 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
57143
57148
|
updateEntitiesHelper,
|
|
57144
57149
|
updateValidation
|
|
57145
57150
|
]);
|
|
57146
|
-
const
|
|
57147
|
-
(
|
|
57148
|
-
|
|
57149
|
-
|
|
57150
|
-
|
|
57151
|
-
|
|
57152
|
-
|
|
57153
|
-
|
|
57154
|
-
|
|
57155
|
-
|
|
57156
|
-
|
|
57157
|
-
|
|
57158
|
-
|
|
57159
|
-
|
|
57160
|
-
|
|
57161
|
-
|
|
57162
|
-
|
|
57163
|
-
|
|
57164
|
-
|
|
57165
|
-
|
|
57166
|
-
|
|
57167
|
-
|
|
57168
|
-
|
|
57169
|
-
|
|
57170
|
-
|
|
57171
|
-
|
|
57172
|
-
|
|
57173
|
-
|
|
57174
|
-
|
|
57175
|
-
|
|
57176
|
-
|
|
57177
|
-
|
|
57178
|
-
|
|
57179
|
-
|
|
57180
|
-
if (
|
|
57181
|
-
|
|
57182
|
-
} else {
|
|
57183
|
-
const jsonRow = [];
|
|
57184
|
-
let [rowCopyText, json] = getRowCopyText(allRows[i2 + 1]);
|
|
57185
|
-
rowCopyText = rowCopyText.split(" ");
|
|
57186
|
-
times(row.length, (i22) => {
|
|
57187
|
-
const cell = row[i22];
|
|
57188
|
-
if (cell) {
|
|
57189
|
-
fullCellText += rowCopyText[i22];
|
|
57190
|
-
jsonRow.push(json[i22]);
|
|
57191
|
-
}
|
|
57192
|
-
if (i22 !== row.length - 1 && i22 >= firstCellIndex)
|
|
57193
|
-
fullCellText += " ";
|
|
57194
|
-
});
|
|
57195
|
-
fullJson.push(jsonRow);
|
|
57151
|
+
const waitUntilAllRowsAreRendered = useCallback(() => {
|
|
57152
|
+
return new Promise((resolve) => {
|
|
57153
|
+
const interval = setInterval(() => {
|
|
57154
|
+
var _a2, _b;
|
|
57155
|
+
const allRowEls = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr-group");
|
|
57156
|
+
if ((allRowEls == null ? void 0 : allRowEls.length) === entities.length) {
|
|
57157
|
+
clearInterval(interval);
|
|
57158
|
+
resolve();
|
|
57159
|
+
}
|
|
57160
|
+
}, 50);
|
|
57161
|
+
});
|
|
57162
|
+
}, []);
|
|
57163
|
+
const handleCopySelectedCells = useCallback(() => __async(void 0, null, function* () {
|
|
57164
|
+
if (isEmpty$1(selectedCells)) return;
|
|
57165
|
+
if (entities.length > VIRTUALIZE_CUTOFF_LENGTH) {
|
|
57166
|
+
setNoVirtual(true);
|
|
57167
|
+
yield waitUntilAllRowsAreRendered();
|
|
57168
|
+
}
|
|
57169
|
+
const pathToIndex = getFieldPathToIndex(schema);
|
|
57170
|
+
const entityIdToEntity = getEntityIdToEntity(entities);
|
|
57171
|
+
const selectionGrid = [];
|
|
57172
|
+
let firstRowIndex;
|
|
57173
|
+
let firstCellIndex;
|
|
57174
|
+
Object.keys(selectedCells).forEach((key) => {
|
|
57175
|
+
const [rowId, path2] = key.split(":");
|
|
57176
|
+
const eInfo = entityIdToEntity[rowId];
|
|
57177
|
+
if (eInfo) {
|
|
57178
|
+
if (firstRowIndex === void 0 || eInfo.i < firstRowIndex) {
|
|
57179
|
+
firstRowIndex = eInfo.i;
|
|
57180
|
+
}
|
|
57181
|
+
if (!selectionGrid[eInfo.i]) {
|
|
57182
|
+
selectionGrid[eInfo.i] = [];
|
|
57183
|
+
}
|
|
57184
|
+
const cellIndex = pathToIndex[path2];
|
|
57185
|
+
if (firstCellIndex === void 0 || cellIndex < firstCellIndex) {
|
|
57186
|
+
firstCellIndex = cellIndex;
|
|
57196
57187
|
}
|
|
57197
|
-
|
|
57198
|
-
|
|
57199
|
-
|
|
57200
|
-
|
|
57201
|
-
|
|
57202
|
-
|
|
57188
|
+
selectionGrid[eInfo.i][cellIndex] = true;
|
|
57189
|
+
}
|
|
57190
|
+
});
|
|
57191
|
+
if (firstRowIndex === void 0) return;
|
|
57192
|
+
const allRows = getAllRows(tableRef);
|
|
57193
|
+
let fullCellText = "";
|
|
57194
|
+
const fullJson = [];
|
|
57195
|
+
times(selectionGrid.length, (i2) => {
|
|
57196
|
+
const row = selectionGrid[i2];
|
|
57197
|
+
if (fullCellText) {
|
|
57198
|
+
fullCellText += "\n";
|
|
57199
|
+
}
|
|
57200
|
+
if (!row) {
|
|
57201
|
+
return;
|
|
57202
|
+
} else {
|
|
57203
|
+
const jsonRow = [];
|
|
57204
|
+
let [rowCopyText, json] = getRowCopyText(allRows[i2 + 1]);
|
|
57205
|
+
rowCopyText = rowCopyText.split(" ");
|
|
57206
|
+
times(row.length, (i22) => {
|
|
57207
|
+
const cell = row[i22];
|
|
57208
|
+
if (cell) {
|
|
57209
|
+
fullCellText += rowCopyText[i22];
|
|
57210
|
+
jsonRow.push(json[i22]);
|
|
57211
|
+
}
|
|
57212
|
+
if (i22 !== row.length - 1 && i22 >= firstCellIndex) fullCellText += " ";
|
|
57213
|
+
});
|
|
57214
|
+
fullJson.push(jsonRow);
|
|
57215
|
+
}
|
|
57216
|
+
});
|
|
57217
|
+
if (!fullCellText) return window.toastr.warning("No text to copy");
|
|
57218
|
+
handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
|
|
57219
|
+
setNoVirtual(false);
|
|
57220
|
+
}), [entities, selectedCells, schema, waitUntilAllRowsAreRendered]);
|
|
57203
57221
|
const handleCopySelectedRows = useCallback(
|
|
57204
|
-
(selectedRecords,
|
|
57205
|
-
|
|
57206
|
-
|
|
57222
|
+
(selectedRecords) => __async(void 0, null, function* () {
|
|
57223
|
+
if (entities.length > VIRTUALIZE_CUTOFF_LENGTH) {
|
|
57224
|
+
setNoVirtual(true);
|
|
57225
|
+
yield waitUntilAllRowsAreRendered();
|
|
57226
|
+
}
|
|
57227
|
+
const idToIndex = entities.reduce((acc, e, i2) => {
|
|
57228
|
+
acc[e.id || e.code] = i2;
|
|
57207
57229
|
return acc;
|
|
57208
57230
|
}, {});
|
|
57209
57231
|
const rowNumbersToCopy = selectedRecords.map((rec) => idToIndex[rec.id || rec.code] + 1).sort();
|
|
57210
57232
|
if (!rowNumbersToCopy.length) return;
|
|
57211
57233
|
rowNumbersToCopy.unshift(0);
|
|
57212
57234
|
try {
|
|
57213
|
-
const allRowEls = getAllRows(
|
|
57235
|
+
const allRowEls = getAllRows(tableRef);
|
|
57214
57236
|
if (!allRowEls) return;
|
|
57215
57237
|
const rowEls = rowNumbersToCopy.map((i2) => allRowEls[i2]);
|
|
57238
|
+
if (window.Cypress) window.Cypress.__copiedRowsLength = rowEls.length;
|
|
57216
57239
|
handleCopyRows(rowEls, {
|
|
57217
57240
|
onFinishMsg: "Selected rows copied"
|
|
57218
57241
|
});
|
|
@@ -57220,8 +57243,9 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
57220
57243
|
console.error(`error:`, error);
|
|
57221
57244
|
window.toastr.error("Error copying rows.");
|
|
57222
57245
|
}
|
|
57223
|
-
|
|
57224
|
-
|
|
57246
|
+
setNoVirtual(false);
|
|
57247
|
+
}),
|
|
57248
|
+
[entities, waitUntilAllRowsAreRendered]
|
|
57225
57249
|
);
|
|
57226
57250
|
const handleCopyHotkey = useCallback(
|
|
57227
57251
|
(e) => {
|
|
@@ -57988,7 +58012,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
57988
58012
|
{
|
|
57989
58013
|
key: "copyColumn",
|
|
57990
58014
|
onClick: /* @__PURE__ */ __name(() => {
|
|
57991
|
-
handleCopyColumn(
|
|
58015
|
+
handleCopyColumn(tableRef, cellWrapper);
|
|
57992
58016
|
}, "onClick"),
|
|
57993
58017
|
text: "Column"
|
|
57994
58018
|
}
|
|
@@ -58001,7 +58025,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58001
58025
|
{
|
|
58002
58026
|
key: "copyColumnSelected",
|
|
58003
58027
|
onClick: /* @__PURE__ */ __name(() => {
|
|
58004
|
-
handleCopyColumn(
|
|
58028
|
+
handleCopyColumn(tableRef, cellWrapper, selectedRecords);
|
|
58005
58029
|
}, "onClick"),
|
|
58006
58030
|
text: "Column (Selected)"
|
|
58007
58031
|
}
|
|
@@ -58044,7 +58068,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58044
58068
|
{
|
|
58045
58069
|
key: "copyFullTableRows",
|
|
58046
58070
|
onClick: /* @__PURE__ */ __name(() => {
|
|
58047
|
-
handleCopyTable(
|
|
58071
|
+
handleCopyTable(tableRef);
|
|
58048
58072
|
}, "onClick"),
|
|
58049
58073
|
text: "Table"
|
|
58050
58074
|
}
|
|
@@ -58581,6 +58605,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58581
58605
|
__spreadValues({
|
|
58582
58606
|
data: filteredEnts,
|
|
58583
58607
|
ref: tableRef,
|
|
58608
|
+
noVirtual,
|
|
58584
58609
|
className: classNames({
|
|
58585
58610
|
isCellEditable,
|
|
58586
58611
|
"tg-table-loading": isLoading,
|
|
@@ -58648,7 +58673,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58648
58673
|
resizePersist,
|
|
58649
58674
|
resized,
|
|
58650
58675
|
rowsToShow,
|
|
58651
|
-
style
|
|
58676
|
+
style,
|
|
58677
|
+
noVirtual
|
|
58652
58678
|
]
|
|
58653
58679
|
);
|
|
58654
58680
|
return /* @__PURE__ */ React__default.createElement("div", { tabIndex: "1", onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -58931,8 +58957,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58931
58957
|
), /* @__PURE__ */ React__default.createElement(
|
|
58932
58958
|
Button,
|
|
58933
58959
|
{
|
|
58934
|
-
onClick: /* @__PURE__ */ __name((
|
|
58935
|
-
handleCopyTable(
|
|
58960
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
58961
|
+
handleCopyTable(tableRef, { isDownload: true });
|
|
58936
58962
|
}, "onClick"),
|
|
58937
58963
|
"data-tip": "Download Table as CSV",
|
|
58938
58964
|
minimal: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/ui",
|
|
3
|
-
"version": "0.8.6-beta.
|
|
3
|
+
"version": "0.8.6-beta.25",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@dnd-kit/core": "^6.1.0",
|
|
18
18
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
19
19
|
"@dnd-kit/sortable": "^8.0.0",
|
|
20
|
-
"@teselagen/react-table": "6.10.
|
|
20
|
+
"@teselagen/react-table": "6.10.18",
|
|
21
21
|
"classnames": "^2.3.2",
|
|
22
22
|
"color": "^3.2.1",
|
|
23
23
|
"copy-to-clipboard": "^3.3.1",
|