@teselagen/ui 0.8.6-beta.23 → 0.8.6-beta.24

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.
Files changed (38) hide show
  1. package/DataTable/EditabelCell.d.ts +7 -0
  2. package/DataTable/defaultProps.d.ts +43 -0
  3. package/DataTable/utils/computePresets.d.ts +1 -0
  4. package/DataTable/utils/convertSchema.d.ts +22 -2
  5. package/DataTable/utils/getAllRows.d.ts +1 -1
  6. package/DataTable/utils/handleCopyColumn.d.ts +1 -1
  7. package/DataTable/utils/handleCopyTable.d.ts +1 -1
  8. package/DataTable/utils/isBottomRightCornerOfRectangle.d.ts +10 -8
  9. package/DataTable/utils/isEntityClean.d.ts +3 -1
  10. package/DataTable/utils/primarySelectedValue.d.ts +1 -1
  11. package/DataTable/utils/removeCleanRows.d.ts +11 -3
  12. package/DataTable/utils/selection.d.ts +3 -1
  13. package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
  14. package/DataTable/utils/useTableEntities.d.ts +17 -4
  15. package/DataTable/utils/useTableParams.d.ts +49 -0
  16. package/index.cjs.js +124 -108
  17. package/index.es.js +124 -108
  18. package/package.json +2 -2
  19. package/src/DataTable/Columns.jsx +945 -0
  20. package/src/DataTable/EditabelCell.js +44 -0
  21. package/src/DataTable/EditabelCell.jsx +44 -0
  22. package/src/DataTable/RenderCell.jsx +191 -0
  23. package/src/DataTable/defaultProps.js +45 -0
  24. package/src/DataTable/index.js +96 -68
  25. package/src/DataTable/utils/computePresets.js +42 -0
  26. package/src/DataTable/utils/convertSchema.ts +79 -0
  27. package/src/DataTable/utils/getAllRows.js +2 -6
  28. package/src/DataTable/utils/handleCopyColumn.js +2 -2
  29. package/src/DataTable/utils/handleCopyTable.js +2 -2
  30. package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +27 -0
  31. package/src/DataTable/utils/isEntityClean.ts +15 -0
  32. package/src/DataTable/utils/primarySelectedValue.ts +1 -0
  33. package/src/DataTable/utils/removeCleanRows.ts +25 -0
  34. package/src/DataTable/utils/selection.ts +11 -0
  35. package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
  36. package/src/DataTable/utils/useTableEntities.ts +60 -0
  37. package/src/DataTable/utils/useTableParams.js +361 -0
  38. package/style.css +10537 -0
@@ -0,0 +1,7 @@
1
+ export function EditableCell({ cancelEdit, dataTest, finishEdit, isNumeric, initialValue }: {
2
+ cancelEdit: any;
3
+ dataTest: any;
4
+ finishEdit: any;
5
+ isNumeric: any;
6
+ initialValue: any;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { noop } from 'lodash-es';
2
+ declare namespace _default {
3
+ export { noop as addFilters };
4
+ export let className: string;
5
+ export { noop as clearFilters };
6
+ export { noop as contextMenu };
7
+ export let disabled: boolean;
8
+ export let entities: never[];
9
+ export let extraClasses: string;
10
+ export let filters: never[];
11
+ export let isCopyable: boolean;
12
+ export { noop as isEntityDisabled };
13
+ export let isLoading: boolean;
14
+ export let isSimple: boolean;
15
+ export let isSingleSelect: boolean;
16
+ export let maxHeight: number;
17
+ export let noHeader: boolean;
18
+ export let noSelect: boolean;
19
+ export let noUserSelect: boolean;
20
+ export { noop as onDeselect };
21
+ export { noop as onMultiRowSelect };
22
+ export { noop as onRowClick };
23
+ export { noop as onRowSelect };
24
+ export { noop as onSingleRowSelect };
25
+ export let page: number;
26
+ export let pageSize: number;
27
+ export let reduxFormExpandedEntityIdMap: {};
28
+ export let reduxFormSearchInput: string;
29
+ export let reduxFormSelectedEntityIdMap: {};
30
+ export { noop as removeSingleFilter };
31
+ export let resized: never[];
32
+ export { noop as resizePersist };
33
+ export { noop as setFilter };
34
+ export { noop as setOrder };
35
+ export { noop as setPage };
36
+ export { noop as setPageSize };
37
+ export { noop as setSearchTerm };
38
+ export let showCount: boolean;
39
+ export let style: {};
40
+ export let withCheckboxes: boolean;
41
+ export let withSort: boolean;
42
+ }
43
+ export default _default;
@@ -0,0 +1 @@
1
+ export default function computePresets(props?: {}): import('lodash').Dictionary<any>;
@@ -1,3 +1,23 @@
1
- export function mergeSchemas(_originalSchema: any, _overrideSchema: any): any;
1
+ type Field = {
2
+ type?: string;
3
+ displayName?: string;
4
+ path?: string;
5
+ filterDisabled?: boolean;
6
+ sortDisabled?: boolean;
7
+ };
8
+ type Schema = {
9
+ fields: (Field | string)[];
10
+ };
11
+ type CompleteField = Field & {
12
+ type: string;
13
+ displayName: string;
14
+ path: string;
15
+ };
16
+ type CompleteSchema = {
17
+ fields: CompleteField[];
18
+ };
19
+ declare const convertSchema: (schema: Schema) => CompleteSchema;
20
+ export declare function mergeSchemas(_originalSchema: Schema, _overrideSchema: Schema): {
21
+ fields: CompleteField[];
22
+ };
2
23
  export default convertSchema;
3
- declare function convertSchema(schema: any): any;
@@ -1 +1 @@
1
- export function getAllRows(e: any): any;
1
+ export function getAllRows(tableRef: any): any;
@@ -1 +1 @@
1
- export function handleCopyColumn(e: any, cellWrapper: any, selectedRecords: any): void;
1
+ export function handleCopyColumn(tableRef: any, cellWrapper: any, selectedRecords: any): void;
@@ -1 +1 @@
1
- export function handleCopyTable(e: any, opts: any): void;
1
+ export function handleCopyTable(tableRef: any, opts: any): void;
@@ -1,8 +1,10 @@
1
- export function isBottomRightCornerOfRectangle({ cellId, selectionGrid, lastRowIndex, lastCellIndex, entityMap, pathToIndex }: {
2
- cellId: any;
3
- selectionGrid: any;
4
- lastRowIndex: any;
5
- lastCellIndex: any;
6
- entityMap: any;
7
- pathToIndex: any;
8
- }): boolean | undefined;
1
+ export declare const isBottomRightCornerOfRectangle: ({ cellId, selectionGrid, lastRowIndex, lastCellIndex, entityMap, pathToIndex }: {
2
+ cellId: string;
3
+ selectionGrid: (string | undefined)[][];
4
+ lastRowIndex: number;
5
+ lastCellIndex: number;
6
+ entityMap: Record<string, {
7
+ i: number;
8
+ }>;
9
+ pathToIndex: Record<string, number>;
10
+ }) => boolean | undefined;
@@ -1 +1,3 @@
1
- export function isEntityClean(e: any): boolean;
1
+ export declare function isEntityClean(e: {
2
+ [key: string]: unknown;
3
+ } | null): boolean;
@@ -1 +1 @@
1
- export const PRIMARY_SELECTED_VAL: "main_cell";
1
+ export declare const PRIMARY_SELECTED_VAL = "main_cell";
@@ -1,4 +1,12 @@
1
- export function removeCleanRows(entities: any, cellValidation: any): {
2
- entsToUse: any;
3
- validationToUse: {};
1
+ export declare const removeCleanRows: (entities: ({
2
+ [key: string]: unknown;
3
+ } & {
4
+ _isClean?: boolean;
5
+ })[], cellValidation: Record<string, unknown>) => {
6
+ entsToUse: ({
7
+ [key: string]: unknown;
8
+ } & {
9
+ _isClean?: boolean;
10
+ })[];
11
+ validationToUse: Record<string, unknown>;
4
12
  };
@@ -1 +1,3 @@
1
- export function getSelectedRowsFromEntities(entities: any, idMap: any): any;
1
+ export declare const getSelectedRowsFromEntities: (entities: {
2
+ [key: string]: unknown;
3
+ }[], idMap: Record<string, boolean>) => number[];
@@ -0,0 +1 @@
1
+ export function useDeepEqualMemo(value: any): undefined;
@@ -1,5 +1,18 @@
1
- export function useTableEntities(tableFormName: any): {
2
- selectTableEntities: (entities?: any[]) => void;
3
- allOrderedEntities: any;
4
- selectedEntities: any;
1
+ type _Entity = {
2
+ [key: string]: unknown;
3
+ } & {
4
+ id: string;
5
5
  };
6
+ type SelectedEntityIdMap<Entity extends _Entity> = Record<string, {
7
+ entity: Entity;
8
+ time: number;
9
+ index?: number;
10
+ }>;
11
+ export declare const useTableEntities: <Entity extends _Entity>(tableFormName: string) => {
12
+ selectTableEntities: (entities?: {
13
+ id: string;
14
+ }[]) => void;
15
+ allOrderedEntities: Entity[] | undefined;
16
+ selectedEntities: SelectedEntityIdMap<Entity> | undefined;
17
+ };
18
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
3
+ *
4
+ * @export
5
+ *
6
+ * @param {compOrOpts} compOrOpts
7
+ * @typedef {object} compOrOpts
8
+ * @property {*string} formName - required unique identifier for the table
9
+ * @property {Object | Function} schema - The data table schema or a function returning it. The function wll be called with props as the argument.
10
+ * @property {boolean} urlConnected - whether the table should connect to/update the URL
11
+ * @property {boolean} withSelectedEntities - whether or not to pass the selected entities
12
+ * @property {boolean} isCodeModel - whether the model is keyed by code instead of id in the db
13
+ * @property {object} defaults - tableParam defaults such as pageSize, filter, etc
14
+ * @property {boolean} noOrderError - won't console an error if an order is not found on schema
15
+ */
16
+ export default function useTableParams(props: any): any;
17
+ /**
18
+ * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
19
+ */
20
+ export type compOrOpts = {
21
+ /**
22
+ * } formName - required unique identifier for the table
23
+ */
24
+ string: any;
25
+ /**
26
+ * - The data table schema or a function returning it. The function wll be called with props as the argument.
27
+ */
28
+ schema: Object | Function;
29
+ /**
30
+ * - whether the table should connect to/update the URL
31
+ */
32
+ urlConnected: boolean;
33
+ /**
34
+ * - whether or not to pass the selected entities
35
+ */
36
+ withSelectedEntities: boolean;
37
+ /**
38
+ * - whether the model is keyed by code instead of id in the db
39
+ */
40
+ isCodeModel: boolean;
41
+ /**
42
+ * - tableParam defaults such as pageSize, filter, etc
43
+ */
44
+ defaults: object;
45
+ /**
46
+ * - won't console an error if an order is not found on schema
47
+ */
48
+ noOrderError: boolean;
49
+ };
package/index.cjs.js CHANGED
@@ -15867,6 +15867,7 @@ var itemSizeEstimator = /* @__PURE__ */ __name(function itemSizeEstimator2() {
15867
15867
  return 41.36;
15868
15868
  }, "itemSizeEstimator");
15869
15869
  var ReactTableDefaults = defaultProps;
15870
+ var VIRTUALIZE_CUTOFF_LENGTH = 200;
15870
15871
  var ReactTable = function(_Methods) {
15871
15872
  _inherits$8(ReactTable2, _Methods);
15872
15873
  function ReactTable2(props) {
@@ -16452,7 +16453,7 @@ var ReactTable = function(_Methods) {
16452
16453
  minWidth: rowMinWidth + "px"
16453
16454
  })
16454
16455
  }, tBodyProps.rest),
16455
- pageRows.length < 200 ? pageRows.map(function(d2, i2) {
16456
+ _this2.props.noVirtual || pageRows.length < VIRTUALIZE_CUTOFF_LENGTH ? pageRows.map(function(d2, i2) {
16456
16457
  return makePageRow(d2, i2);
16457
16458
  }) : React.createElement(ReactList, {
16458
16459
  type: "variable",
@@ -16556,7 +16557,7 @@ const getIdOrCodeOrIndex = /* @__PURE__ */ __name((record, rowIndex) => {
16556
16557
  const getSelectedRowsFromEntities = /* @__PURE__ */ __name((entities, idMap) => {
16557
16558
  if (!idMap) return [];
16558
16559
  return entities.reduce((acc, entity, i2) => {
16559
- return idMap[getIdOrCodeOrIndex(entity, i2)] ? acc.concat(i2) : acc;
16560
+ return idMap[getIdOrCodeOrIndex(entity, i2)] ? acc.concat([i2]) : acc;
16560
16561
  }, []);
16561
16562
  }, "getSelectedRowsFromEntities");
16562
16563
  const removeCleanRows = /* @__PURE__ */ __name((entities, cellValidation) => {
@@ -16680,9 +16681,9 @@ const stripNumberAtEnd = /* @__PURE__ */ __name((str) => {
16680
16681
  var _a;
16681
16682
  return (_a = str == null ? void 0 : str.replace) == null ? void 0 : _a.call(str, getNumberStrAtEnd(str), "");
16682
16683
  }, "stripNumberAtEnd");
16683
- const getAllRows = /* @__PURE__ */ __name((e) => {
16684
- const el = e.target.querySelector(".data-table-container") ? e.target.querySelector(".data-table-container") : e.target.closest(".data-table-container");
16685
- const allRowEls = el.querySelectorAll(".rt-tr");
16684
+ const getAllRows = /* @__PURE__ */ __name((tableRef) => {
16685
+ var _a, _b;
16686
+ const allRowEls = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr");
16686
16687
  if (!allRowEls || !allRowEls.length) {
16687
16688
  return;
16688
16689
  }
@@ -16949,14 +16950,14 @@ const handleCopyRows = /* @__PURE__ */ __name((rowElsToCopy, { specificColumn, o
16949
16950
  handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
16950
16951
  }
16951
16952
  }, "handleCopyRows");
16952
- const handleCopyColumn = /* @__PURE__ */ __name((e, cellWrapper, selectedRecords) => {
16953
+ const handleCopyColumn = /* @__PURE__ */ __name((tableRef, cellWrapper, selectedRecords) => {
16953
16954
  const specificColumn = cellWrapper.getAttribute("data-test");
16954
- let rowElsToCopy = getAllRows(e);
16955
+ let rowElsToCopy = getAllRows(tableRef);
16955
16956
  if (!rowElsToCopy) return;
16956
16957
  if (selectedRecords) {
16957
- const ids2 = selectedRecords.map((e2) => {
16958
+ const ids2 = selectedRecords.map((e) => {
16958
16959
  var _a;
16959
- return (_a = getIdOrCodeOrIndex(e2)) == null ? void 0 : _a.toString();
16960
+ return (_a = getIdOrCodeOrIndex(e)) == null ? void 0 : _a.toString();
16960
16961
  });
16961
16962
  rowElsToCopy = Array.from(rowElsToCopy).filter((rowEl) => {
16962
16963
  var _a;
@@ -16989,9 +16990,9 @@ const isBottomRightCornerOfRectangle = /* @__PURE__ */ __name(({
16989
16990
  const isBottomRight = i2 === lastRowIndex && cellIndex === lastCellIndex;
16990
16991
  return isBottomRight;
16991
16992
  }, "isBottomRightCornerOfRectangle");
16992
- const handleCopyTable = /* @__PURE__ */ __name((e, opts) => {
16993
+ const handleCopyTable = /* @__PURE__ */ __name((tableRef, opts) => {
16993
16994
  try {
16994
- const allRowEls = getAllRows(e);
16995
+ const allRowEls = getAllRows(tableRef);
16995
16996
  if (!allRowEls) return;
16996
16997
  handleCopyRows(allRowEls, __spreadProps(__spreadValues({}, opts), {
16997
16998
  onFinishMsg: "Table Copied"
@@ -17028,13 +17029,15 @@ const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
17028
17029
  },
17029
17030
  [dispatch, tableFormName]
17030
17031
  );
17031
- const { allOrderedEntities, selectedEntities } = reactRedux.useSelector((state) => {
17032
- var _a, _b, _c, _d, _e, _f;
17033
- return {
17034
- allOrderedEntities: (_c = (_b = (_a = state.form) == null ? void 0 : _a[tableFormName]) == null ? void 0 : _b.values) == null ? void 0 : _c.allOrderedEntities,
17035
- selectedEntities: (_f = (_e = (_d = state.form) == null ? void 0 : _d[tableFormName]) == null ? void 0 : _e.values) == null ? void 0 : _f.reduxFormSelectedEntityIdMap
17036
- };
17037
- });
17032
+ const { allOrderedEntities, selectedEntities } = reactRedux.useSelector(
17033
+ (state) => {
17034
+ var _a, _b, _c, _d, _e, _f;
17035
+ return {
17036
+ allOrderedEntities: (_c = (_b = (_a = state.form) == null ? void 0 : _a[tableFormName]) == null ? void 0 : _b.values) == null ? void 0 : _c.allOrderedEntities,
17037
+ selectedEntities: (_f = (_e = (_d = state.form) == null ? void 0 : _d[tableFormName]) == null ? void 0 : _e.values) == null ? void 0 : _f.reduxFormSelectedEntityIdMap
17038
+ };
17039
+ }
17040
+ );
17038
17041
  return { selectTableEntities, allOrderedEntities, selectedEntities };
17039
17042
  }, "useTableEntities");
17040
17043
  const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
@@ -37232,7 +37235,7 @@ const multiViewColumn = __spreadProps(__spreadValues({}, viewColumn), {
37232
37235
  ));
37233
37236
  }, "render")
37234
37237
  });
37235
- function convertSchema(schema) {
37238
+ const convertSchema = /* @__PURE__ */ __name((schema) => {
37236
37239
  let schemaToUse = schema;
37237
37240
  if (!schemaToUse.fields && Array.isArray(schema)) {
37238
37241
  schemaToUse = {
@@ -37241,35 +37244,26 @@ function convertSchema(schema) {
37241
37244
  }
37242
37245
  schemaToUse = __spreadValues({}, schemaToUse);
37243
37246
  schemaToUse.fields = schemaToUse.fields.map((field, i2) => {
37244
- let fieldToUse = field;
37245
37247
  if (typeof field === "string") {
37246
- fieldToUse = {
37248
+ return {
37247
37249
  displayName: startCase(camelCase(field)),
37248
37250
  path: field,
37249
37251
  type: "string"
37250
37252
  };
37251
- } else if (!field.type) {
37252
- fieldToUse = __spreadProps(__spreadValues({}, field), {
37253
- type: "string"
37254
- });
37255
- }
37256
- if (!fieldToUse.displayName) {
37257
- fieldToUse = __spreadProps(__spreadValues({}, fieldToUse), {
37258
- displayName: startCase(camelCase(fieldToUse.path))
37259
- });
37260
- }
37261
- if (!fieldToUse.path) {
37262
- fieldToUse = __spreadProps(__spreadValues({}, fieldToUse), {
37263
- filterDisabled: true,
37264
- sortDisabled: true,
37265
- path: "fake-path" + i2
37266
- });
37253
+ } else {
37254
+ const fieldToUse = __spreadValues({}, field);
37255
+ fieldToUse.type = fieldToUse.type || "string";
37256
+ fieldToUse.displayName = fieldToUse.displayName || startCase(camelCase(fieldToUse.path || ""));
37257
+ if (!fieldToUse.path) {
37258
+ fieldToUse.filterDisabled = true;
37259
+ fieldToUse.sortDisabled = true;
37260
+ fieldToUse.path = "fake-path" + i2;
37261
+ }
37262
+ return fieldToUse;
37267
37263
  }
37268
- return fieldToUse;
37269
37264
  });
37270
37265
  return schemaToUse;
37271
- }
37272
- __name(convertSchema, "convertSchema");
37266
+ }, "convertSchema");
37273
37267
  function mergeSchemas(_originalSchema, _overrideSchema) {
37274
37268
  const originalSchema = convertSchema(_originalSchema);
37275
37269
  const overrideSchema = convertSchema(_overrideSchema);
@@ -56320,6 +56314,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
56320
56314
  );
56321
56315
  const tableRef = React.useRef();
56322
56316
  const alreadySelected = React.useRef(false);
56317
+ const [noVirtual, setNoVirtual] = React.useState(false);
56323
56318
  const [onlyShowRowsWErrors, setOnlyShowRowsWErrors] = React.useState(false);
56324
56319
  const [entitiesUndoRedoStack, setEntitiesUndoRedoStack] = React.useState({
56325
56320
  currentVersion: 0
@@ -57161,76 +57156,94 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
57161
57156
  updateEntitiesHelper,
57162
57157
  updateValidation
57163
57158
  ]);
57164
- const handleCopySelectedCells = React.useCallback(
57165
- (e) => {
57166
- if (isEmpty$1(selectedCells)) return;
57167
- const pathToIndex = getFieldPathToIndex(schema);
57168
- const entityIdToEntity = getEntityIdToEntity(entities);
57169
- const selectionGrid = [];
57170
- let firstRowIndex;
57171
- let firstCellIndex;
57172
- Object.keys(selectedCells).forEach((key) => {
57173
- const [rowId, path2] = key.split(":");
57174
- const eInfo = entityIdToEntity[rowId];
57175
- if (eInfo) {
57176
- if (firstRowIndex === void 0 || eInfo.i < firstRowIndex) {
57177
- firstRowIndex = eInfo.i;
57178
- }
57179
- if (!selectionGrid[eInfo.i]) {
57180
- selectionGrid[eInfo.i] = [];
57181
- }
57182
- const cellIndex = pathToIndex[path2];
57183
- if (firstCellIndex === void 0 || cellIndex < firstCellIndex) {
57184
- firstCellIndex = cellIndex;
57185
- }
57186
- selectionGrid[eInfo.i][cellIndex] = true;
57187
- }
57188
- });
57189
- if (firstRowIndex === void 0) return;
57190
- const allRows = getAllRows(e);
57191
- let fullCellText = "";
57192
- const fullJson = [];
57193
- times(selectionGrid.length, (i2) => {
57194
- const row = selectionGrid[i2];
57195
- if (fullCellText) {
57196
- fullCellText += "\n";
57197
- }
57198
- if (!row) {
57199
- return;
57200
- } else {
57201
- const jsonRow = [];
57202
- let [rowCopyText, json] = getRowCopyText(allRows[i2 + 1]);
57203
- rowCopyText = rowCopyText.split(" ");
57204
- times(row.length, (i22) => {
57205
- const cell = row[i22];
57206
- if (cell) {
57207
- fullCellText += rowCopyText[i22];
57208
- jsonRow.push(json[i22]);
57209
- }
57210
- if (i22 !== row.length - 1 && i22 >= firstCellIndex)
57211
- fullCellText += " ";
57212
- });
57213
- fullJson.push(jsonRow);
57159
+ const waitUntilAllRowsAreRendered = React.useCallback(() => {
57160
+ return new Promise((resolve) => {
57161
+ const interval = setInterval(() => {
57162
+ var _a2, _b;
57163
+ const allRowEls = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr-group");
57164
+ if ((allRowEls == null ? void 0 : allRowEls.length) === entities.length) {
57165
+ clearInterval(interval);
57166
+ resolve();
57167
+ }
57168
+ }, 50);
57169
+ });
57170
+ }, []);
57171
+ const handleCopySelectedCells = React.useCallback(() => __async(exports, null, function* () {
57172
+ if (isEmpty$1(selectedCells)) return;
57173
+ if (entities.length > VIRTUALIZE_CUTOFF_LENGTH) {
57174
+ setNoVirtual(true);
57175
+ yield waitUntilAllRowsAreRendered();
57176
+ }
57177
+ const pathToIndex = getFieldPathToIndex(schema);
57178
+ const entityIdToEntity = getEntityIdToEntity(entities);
57179
+ const selectionGrid = [];
57180
+ let firstRowIndex;
57181
+ let firstCellIndex;
57182
+ Object.keys(selectedCells).forEach((key) => {
57183
+ const [rowId, path2] = key.split(":");
57184
+ const eInfo = entityIdToEntity[rowId];
57185
+ if (eInfo) {
57186
+ if (firstRowIndex === void 0 || eInfo.i < firstRowIndex) {
57187
+ firstRowIndex = eInfo.i;
57188
+ }
57189
+ if (!selectionGrid[eInfo.i]) {
57190
+ selectionGrid[eInfo.i] = [];
57191
+ }
57192
+ const cellIndex = pathToIndex[path2];
57193
+ if (firstCellIndex === void 0 || cellIndex < firstCellIndex) {
57194
+ firstCellIndex = cellIndex;
57214
57195
  }
57215
- });
57216
- if (!fullCellText) return window.toastr.warning("No text to copy");
57217
- handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
57218
- },
57219
- [entities, selectedCells, schema]
57220
- );
57196
+ selectionGrid[eInfo.i][cellIndex] = true;
57197
+ }
57198
+ });
57199
+ if (firstRowIndex === void 0) return;
57200
+ const allRows = getAllRows(tableRef);
57201
+ let fullCellText = "";
57202
+ const fullJson = [];
57203
+ times(selectionGrid.length, (i2) => {
57204
+ const row = selectionGrid[i2];
57205
+ if (fullCellText) {
57206
+ fullCellText += "\n";
57207
+ }
57208
+ if (!row) {
57209
+ return;
57210
+ } else {
57211
+ const jsonRow = [];
57212
+ let [rowCopyText, json] = getRowCopyText(allRows[i2 + 1]);
57213
+ rowCopyText = rowCopyText.split(" ");
57214
+ times(row.length, (i22) => {
57215
+ const cell = row[i22];
57216
+ if (cell) {
57217
+ fullCellText += rowCopyText[i22];
57218
+ jsonRow.push(json[i22]);
57219
+ }
57220
+ if (i22 !== row.length - 1 && i22 >= firstCellIndex) fullCellText += " ";
57221
+ });
57222
+ fullJson.push(jsonRow);
57223
+ }
57224
+ });
57225
+ if (!fullCellText) return window.toastr.warning("No text to copy");
57226
+ handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
57227
+ setNoVirtual(false);
57228
+ }), [entities, selectedCells, schema, waitUntilAllRowsAreRendered]);
57221
57229
  const handleCopySelectedRows = React.useCallback(
57222
- (selectedRecords, e) => {
57223
- const idToIndex = entities.reduce((acc, e2, i2) => {
57224
- acc[e2.id || e2.code] = i2;
57230
+ (selectedRecords) => __async(exports, null, function* () {
57231
+ if (entities.length > VIRTUALIZE_CUTOFF_LENGTH) {
57232
+ setNoVirtual(true);
57233
+ yield waitUntilAllRowsAreRendered();
57234
+ }
57235
+ const idToIndex = entities.reduce((acc, e, i2) => {
57236
+ acc[e.id || e.code] = i2;
57225
57237
  return acc;
57226
57238
  }, {});
57227
57239
  const rowNumbersToCopy = selectedRecords.map((rec) => idToIndex[rec.id || rec.code] + 1).sort();
57228
57240
  if (!rowNumbersToCopy.length) return;
57229
57241
  rowNumbersToCopy.unshift(0);
57230
57242
  try {
57231
- const allRowEls = getAllRows(e);
57243
+ const allRowEls = getAllRows(tableRef);
57232
57244
  if (!allRowEls) return;
57233
57245
  const rowEls = rowNumbersToCopy.map((i2) => allRowEls[i2]);
57246
+ if (window.Cypress) window.Cypress.__copiedRowsLength = rowEls.length;
57234
57247
  handleCopyRows(rowEls, {
57235
57248
  onFinishMsg: "Selected rows copied"
57236
57249
  });
@@ -57238,8 +57251,9 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
57238
57251
  console.error(`error:`, error);
57239
57252
  window.toastr.error("Error copying rows.");
57240
57253
  }
57241
- },
57242
- [entities]
57254
+ setNoVirtual(false);
57255
+ }),
57256
+ [entities, waitUntilAllRowsAreRendered]
57243
57257
  );
57244
57258
  const handleCopyHotkey = React.useCallback(
57245
57259
  (e) => {
@@ -58006,7 +58020,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58006
58020
  {
58007
58021
  key: "copyColumn",
58008
58022
  onClick: /* @__PURE__ */ __name(() => {
58009
- handleCopyColumn(e, cellWrapper);
58023
+ handleCopyColumn(tableRef, cellWrapper);
58010
58024
  }, "onClick"),
58011
58025
  text: "Column"
58012
58026
  }
@@ -58019,7 +58033,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58019
58033
  {
58020
58034
  key: "copyColumnSelected",
58021
58035
  onClick: /* @__PURE__ */ __name(() => {
58022
- handleCopyColumn(e, cellWrapper, selectedRecords);
58036
+ handleCopyColumn(tableRef, cellWrapper, selectedRecords);
58023
58037
  }, "onClick"),
58024
58038
  text: "Column (Selected)"
58025
58039
  }
@@ -58062,7 +58076,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58062
58076
  {
58063
58077
  key: "copyFullTableRows",
58064
58078
  onClick: /* @__PURE__ */ __name(() => {
58065
- handleCopyTable(e);
58079
+ handleCopyTable(tableRef);
58066
58080
  }, "onClick"),
58067
58081
  text: "Table"
58068
58082
  }
@@ -58599,6 +58613,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58599
58613
  __spreadValues({
58600
58614
  data: filteredEnts,
58601
58615
  ref: tableRef,
58616
+ noVirtual,
58602
58617
  className: classNames({
58603
58618
  isCellEditable,
58604
58619
  "tg-table-loading": isLoading,
@@ -58666,7 +58681,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58666
58681
  resizePersist,
58667
58682
  resized,
58668
58683
  rowsToShow,
58669
- style
58684
+ style,
58685
+ noVirtual
58670
58686
  ]
58671
58687
  );
58672
58688
  return /* @__PURE__ */ React.createElement("div", { tabIndex: "1", onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, /* @__PURE__ */ React.createElement(
@@ -58949,8 +58965,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58949
58965
  ), /* @__PURE__ */ React.createElement(
58950
58966
  core.Button,
58951
58967
  {
58952
- onClick: /* @__PURE__ */ __name((e) => {
58953
- handleCopyTable(e, { isDownload: true });
58968
+ onClick: /* @__PURE__ */ __name(() => {
58969
+ handleCopyTable(tableRef, { isDownload: true });
58954
58970
  }, "onClick"),
58955
58971
  "data-tip": "Download Table as CSV",
58956
58972
  minimal: true,