@teselagen/ui 0.4.14 → 0.4.15
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/AdvancedOptions.d.ts +1 -1
- package/AssignDefaultsModeContext.d.ts +1 -1
- package/AsyncValidateFieldSpinner/index.d.ts +1 -1
- package/BlueprintError/index.d.ts +1 -1
- package/BounceLoader/index.d.ts +1 -1
- package/CollapsibleCard/index.d.ts +1 -1
- package/DNALoader/index.d.ts +1 -1
- package/DataTable/CellDragHandle.d.ts +1 -1
- package/DataTable/ColumnFilterMenu.d.ts +14 -0
- package/DataTable/DisabledLoadingComponent.d.ts +1 -1
- package/DataTable/DisplayOptions.d.ts +2 -2
- package/DataTable/DropdownCell.d.ts +8 -0
- package/DataTable/EditabelCell.d.ts +10 -0
- package/DataTable/FilterAndSortMenu.d.ts +2 -2
- package/DataTable/SearchBar.d.ts +1 -1
- package/DataTable/SortableColumns.d.ts +2 -2
- package/DataTable/TableFormTrackerContext.d.ts +1 -1
- package/DataTable/defaultProps.d.ts +1 -1
- package/DataTable/index.d.ts +0 -5
- package/DataTable/utils/computePresets.d.ts +1 -1
- package/DataTable/utils/formatPasteData.d.ts +5 -0
- package/DataTable/utils/getAllRows.d.ts +1 -0
- package/DataTable/utils/getCellCopyText.d.ts +1 -0
- package/DataTable/utils/getCellInfo.d.ts +17 -0
- package/DataTable/utils/getFieldPathToField.d.ts +1 -0
- package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
- package/DataTable/utils/getLastSelectedEntity.d.ts +1 -0
- package/DataTable/utils/getNewEntToSelect.d.ts +6 -0
- package/DataTable/utils/getRowCopyText.d.ts +3 -0
- package/DataTable/utils/handleCopyColumn.d.ts +1 -0
- package/DataTable/utils/handleCopyHelper.d.ts +1 -0
- package/DataTable/utils/handleCopyRows.d.ts +5 -0
- package/DataTable/utils/index.d.ts +21 -0
- package/DataTable/utils/isBottomRightCornerOfRectangle.d.ts +8 -0
- package/DataTable/utils/isEntityClean.d.ts +1 -0
- package/DataTable/utils/removeCleanRows.d.ts +4 -0
- package/DataTable/utils/rowClick.d.ts +10 -2
- package/DataTable/utils/utils.d.ts +5 -0
- package/DataTable/viewColumn.d.ts +2 -2
- package/DialogFooter/index.d.ts +1 -1
- package/DropdownButton.d.ts +1 -1
- package/FillWindow.d.ts +1 -1
- package/FormComponents/LoadingDots.d.ts +1 -1
- package/FormComponents/Uploader.d.ts +29 -1
- package/FormComponents/index.d.ts +34 -34
- package/FormComponents/itemUpload.d.ts +1 -1
- package/HotkeysDialog/index.d.ts +1 -1
- package/InfoHelper/index.d.ts +1 -1
- package/IntentText/index.d.ts +1 -1
- package/MatchHeaders.d.ts +1 -1
- package/MenuBar/index.d.ts +4 -4
- package/PromptUnsavedChanges/index.d.ts +1 -1
- package/README.md +18 -0
- package/ResizableDraggableDialog/index.d.ts +2 -2
- package/ScrollToTop/index.d.ts +1 -1
- package/SimpleStepViz.d.ts +1 -1
- package/Tag.d.ts +1 -1
- package/TagSelect/index.d.ts +1 -1
- package/TgSelect/index.d.ts +2 -2
- package/TgSuggest/index.d.ts +3 -3
- package/Timeline/TimelineEvent.d.ts +1 -1
- package/Timeline/index.d.ts +2 -2
- package/UploadCsvWizard.d.ts +1 -1
- package/customIcons.d.ts +19 -19
- package/enhancers/withField.d.ts +1 -1
- package/enhancers/withFields.d.ts +1 -1
- package/enhancers/withLocalStorage.d.ts +1 -1
- package/index.cjs.js +14026 -12765
- package/index.d.ts +60 -60
- package/index.es.js +13844 -12583
- package/package.json +7 -4
- package/showConfirmationDialog/index.d.ts +2 -2
- package/src/DataTable/CellDragHandle.js +6 -7
- package/src/DataTable/ColumnFilterMenu.js +60 -0
- package/src/DataTable/DropdownCell.js +61 -0
- package/src/DataTable/EditabelCell.js +55 -0
- package/src/DataTable/PagingTool.js +1 -1
- package/src/DataTable/SortableColumns.js +53 -18
- package/src/DataTable/dataTableEnhancer.js +1 -1
- package/src/DataTable/index.js +385 -759
- package/src/DataTable/utils/formatPasteData.js +16 -0
- package/src/DataTable/utils/getAllRows.js +11 -0
- package/src/DataTable/utils/getCellCopyText.js +7 -0
- package/src/DataTable/utils/getCellInfo.js +36 -0
- package/src/DataTable/utils/getFieldPathToField.js +7 -0
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
- package/src/DataTable/utils/getLastSelectedEntity.js +11 -0
- package/src/DataTable/utils/getNewEntToSelect.js +25 -0
- package/src/DataTable/utils/getRowCopyText.js +28 -0
- package/src/DataTable/utils/handleCopyColumn.js +21 -0
- package/src/DataTable/utils/handleCopyHelper.js +15 -0
- package/src/DataTable/utils/handleCopyRows.js +23 -0
- package/src/DataTable/utils/index.js +51 -0
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +20 -0
- package/src/DataTable/utils/isEntityClean.js +15 -0
- package/src/DataTable/utils/removeCleanRows.js +22 -0
- package/src/DataTable/utils/rowClick.js +7 -4
- package/src/DataTable/utils/selection.js +1 -1
- package/src/DataTable/utils/utils.js +37 -0
- package/src/DataTable/validateTableWideErrors.js +1 -1
- package/src/FillWindow.js +2 -3
- package/src/FormComponents/Uploader.js +400 -400
- package/src/FormComponents/tryToMatchSchemas.js +0 -6
- package/src/UploadCsvWizard.js +312 -371
- package/src/index.js +3 -3
- package/src/showDialogOnDocBody.js +5 -9
- package/src/useDialog.js +7 -4
- package/src/utils/renderOnDoc.js +8 -5
- package/style.css +7 -7
- package/useDialog.d.ts +2 -2
- package/utils/adHoc.d.ts +1 -1
- package/utils/commandControls.d.ts +5 -5
- package/utils/hotkeyUtils.d.ts +1 -1
- package/utils/menuUtils.d.ts +7 -7
- package/utils/renderOnDoc.d.ts +1 -1
- package/utils/tagUtils.d.ts +1 -1
- package/utils/tgFormValues.d.ts +1 -1
- package/utils/withStore.d.ts +1 -1
- package/wrapDialog.d.ts +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getFieldPathToField } from "./getFieldPathToField";
|
|
2
|
+
|
|
3
|
+
export const formatPasteData = ({ schema, newVal, path }) => {
|
|
4
|
+
const pathToField = getFieldPathToField(schema);
|
|
5
|
+
const column = pathToField[path];
|
|
6
|
+
if (column.type === "genericSelect") {
|
|
7
|
+
if (newVal?.__genSelCol === path) {
|
|
8
|
+
newVal = newVal.__strVal;
|
|
9
|
+
} else {
|
|
10
|
+
newVal = undefined;
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
|
|
14
|
+
}
|
|
15
|
+
return newVal;
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const getAllRows = e => {
|
|
2
|
+
const el = e.target.querySelector(".data-table-container")
|
|
3
|
+
? e.target.querySelector(".data-table-container")
|
|
4
|
+
: e.target.closest(".data-table-container");
|
|
5
|
+
|
|
6
|
+
const allRowEls = el.querySelectorAll(".rt-tr");
|
|
7
|
+
if (!allRowEls || !allRowEls.length) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return allRowEls;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const getCellCopyText = cellWrapper => {
|
|
2
|
+
const text = cellWrapper && cellWrapper.getAttribute("data-copy-text");
|
|
3
|
+
const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
|
|
4
|
+
|
|
5
|
+
const textContent = text || cellWrapper.textContent || "";
|
|
6
|
+
return [textContent, jsonText];
|
|
7
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
2
|
+
|
|
3
|
+
export const getCellInfo = ({
|
|
4
|
+
columnIndex,
|
|
5
|
+
columnPath,
|
|
6
|
+
rowId,
|
|
7
|
+
schema,
|
|
8
|
+
entities,
|
|
9
|
+
rowIndex,
|
|
10
|
+
isEntityDisabled,
|
|
11
|
+
entity
|
|
12
|
+
}) => {
|
|
13
|
+
const leftpath = schema.fields[columnIndex - 1]?.path;
|
|
14
|
+
const rightpath = schema.fields[columnIndex + 1]?.path;
|
|
15
|
+
const cellIdToLeft = leftpath && `${rowId}:${leftpath}`;
|
|
16
|
+
const cellIdToRight = rightpath && `${rowId}:${rightpath}`;
|
|
17
|
+
const rowAboveId =
|
|
18
|
+
entities[rowIndex - 1] &&
|
|
19
|
+
getIdOrCodeOrIndex(entities[rowIndex - 1], rowIndex - 1);
|
|
20
|
+
const rowBelowId =
|
|
21
|
+
entities[rowIndex + 1] &&
|
|
22
|
+
getIdOrCodeOrIndex(entities[rowIndex + 1], rowIndex + 1);
|
|
23
|
+
const cellIdAbove = rowAboveId && `${rowAboveId}:${columnPath}`;
|
|
24
|
+
const cellIdBelow = rowBelowId && `${rowBelowId}:${columnPath}`;
|
|
25
|
+
|
|
26
|
+
const cellId = `${rowId}:${columnPath}`;
|
|
27
|
+
const rowDisabled = isEntityDisabled(entity);
|
|
28
|
+
return {
|
|
29
|
+
cellId,
|
|
30
|
+
cellIdAbove,
|
|
31
|
+
cellIdToRight,
|
|
32
|
+
cellIdBelow,
|
|
33
|
+
cellIdToLeft,
|
|
34
|
+
rowDisabled
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const getLastSelectedEntity = idMap => {
|
|
2
|
+
let lastSelectedEnt;
|
|
3
|
+
let latestTime;
|
|
4
|
+
Object.values(idMap).forEach(({ time, entity }) => {
|
|
5
|
+
if (!latestTime || time > latestTime) {
|
|
6
|
+
lastSelectedEnt = entity;
|
|
7
|
+
latestTime = time;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
return lastSelectedEnt;
|
|
11
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const getNewEntToSelect = ({
|
|
2
|
+
type,
|
|
3
|
+
lastSelectedIndex,
|
|
4
|
+
entities,
|
|
5
|
+
isEntityDisabled
|
|
6
|
+
}) => {
|
|
7
|
+
let newIndexToSelect;
|
|
8
|
+
if (type === "up") {
|
|
9
|
+
newIndexToSelect = lastSelectedIndex - 1;
|
|
10
|
+
} else {
|
|
11
|
+
newIndexToSelect = lastSelectedIndex + 1;
|
|
12
|
+
}
|
|
13
|
+
const newEntToSelect = entities[newIndexToSelect];
|
|
14
|
+
if (!newEntToSelect) return;
|
|
15
|
+
if (isEntityDisabled && isEntityDisabled(newEntToSelect)) {
|
|
16
|
+
return getNewEntToSelect({
|
|
17
|
+
type,
|
|
18
|
+
lastSelectedIndex: newIndexToSelect,
|
|
19
|
+
entities,
|
|
20
|
+
isEntityDisabled
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
return newEntToSelect;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getCellCopyText } from "./getCellCopyText";
|
|
2
|
+
import { flatMap } from "lodash-es";
|
|
3
|
+
|
|
4
|
+
export const getRowCopyText = (rowEl, { specificColumn } = {}) => {
|
|
5
|
+
//takes in a row element
|
|
6
|
+
if (!rowEl) return [];
|
|
7
|
+
const textContent = [];
|
|
8
|
+
const jsonText = [];
|
|
9
|
+
|
|
10
|
+
for (const cellEl of rowEl.children) {
|
|
11
|
+
const cellChild = cellEl.querySelector(`[data-copy-text]`);
|
|
12
|
+
if (!cellChild) {
|
|
13
|
+
if (specificColumn) continue; //strip it
|
|
14
|
+
continue; //just leave it blank
|
|
15
|
+
}
|
|
16
|
+
if (
|
|
17
|
+
specificColumn &&
|
|
18
|
+
cellChild.getAttribute("data-test") !== specificColumn
|
|
19
|
+
) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const [t, j] = getCellCopyText(cellChild);
|
|
23
|
+
textContent.push(t);
|
|
24
|
+
jsonText.push(j);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return [flatMap(textContent).join("\t"), jsonText];
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getAllRows } from "./getAllRows";
|
|
2
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
3
|
+
import { handleCopyRows } from "./handleCopyRows";
|
|
4
|
+
|
|
5
|
+
export const handleCopyColumn = (e, cellWrapper, selectedRecords) => {
|
|
6
|
+
const specificColumn = cellWrapper.getAttribute("data-test");
|
|
7
|
+
let rowElsToCopy = getAllRows(e);
|
|
8
|
+
if (!rowElsToCopy) return;
|
|
9
|
+
if (selectedRecords) {
|
|
10
|
+
const ids = selectedRecords.map(e => getIdOrCodeOrIndex(e)?.toString());
|
|
11
|
+
rowElsToCopy = Array.from(rowElsToCopy).filter(rowEl => {
|
|
12
|
+
const id = rowEl.closest(".rt-tr-group")?.getAttribute("data-test-id");
|
|
13
|
+
return id !== undefined && ids.includes(id);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!rowElsToCopy) return;
|
|
17
|
+
handleCopyRows(rowElsToCopy, {
|
|
18
|
+
specificColumn,
|
|
19
|
+
onFinishMsg: "Column Copied"
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import copy from "copy-to-clipboard";
|
|
2
|
+
|
|
3
|
+
export const handleCopyHelper = (stringToCopy, jsonToCopy, message) => {
|
|
4
|
+
!window.Cypress &&
|
|
5
|
+
copy(stringToCopy, {
|
|
6
|
+
onCopy: clipboardData => {
|
|
7
|
+
clipboardData.setData("application/json", JSON.stringify(jsonToCopy));
|
|
8
|
+
},
|
|
9
|
+
// keep this so that pasting into spreadsheets works.
|
|
10
|
+
format: "text/plain"
|
|
11
|
+
});
|
|
12
|
+
if (message) {
|
|
13
|
+
window.toastr.success(message);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import download from "downloadjs";
|
|
2
|
+
import { getRowCopyText } from "./getRowCopyText";
|
|
3
|
+
import { handleCopyHelper } from "./handleCopyHelper";
|
|
4
|
+
|
|
5
|
+
export const handleCopyRows = (
|
|
6
|
+
rowElsToCopy,
|
|
7
|
+
{ specificColumn, onFinishMsg, isDownload } = {}
|
|
8
|
+
) => {
|
|
9
|
+
let textToCopy = [];
|
|
10
|
+
const jsonToCopy = [];
|
|
11
|
+
rowElsToCopy.forEach(rowEl => {
|
|
12
|
+
const [t, j] = getRowCopyText(rowEl, { specificColumn });
|
|
13
|
+
textToCopy.push(t);
|
|
14
|
+
jsonToCopy.push(j);
|
|
15
|
+
});
|
|
16
|
+
textToCopy = textToCopy.filter(text => text).join("\n");
|
|
17
|
+
if (!textToCopy) return window.toastr.warning("No text to copy");
|
|
18
|
+
if (isDownload) {
|
|
19
|
+
download(textToCopy.replaceAll("\t", ","), "tableData.csv", "text/csv");
|
|
20
|
+
} else {
|
|
21
|
+
handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isEntityClean } from "./isEntityClean";
|
|
2
|
+
import { getSelectedRowsFromEntities } from "./selection";
|
|
3
|
+
import { removeCleanRows } from "./removeCleanRows";
|
|
4
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
5
|
+
import computePresets from "./computePresets";
|
|
6
|
+
import { getRecordsFromIdMap } from "./withSelectedEntities";
|
|
7
|
+
import { formatPasteData } from "./formatPasteData";
|
|
8
|
+
import { getFieldPathToField } from "./getFieldPathToField";
|
|
9
|
+
import {
|
|
10
|
+
defaultParsePaste,
|
|
11
|
+
getEntityIdToEntity,
|
|
12
|
+
getFieldPathToIndex,
|
|
13
|
+
getNumberStrAtEnd,
|
|
14
|
+
stripNumberAtEnd
|
|
15
|
+
} from "./utils";
|
|
16
|
+
import { getAllRows } from "./getAllRows";
|
|
17
|
+
import { getNewEntToSelect } from "./getNewEntToSelect";
|
|
18
|
+
import { getLastSelectedEntity } from "./getLastSelectedEntity";
|
|
19
|
+
import { getCellInfo } from "./getCellInfo";
|
|
20
|
+
import { getCellCopyText } from "./getCellCopyText";
|
|
21
|
+
import { getRowCopyText } from "./getRowCopyText";
|
|
22
|
+
import { handleCopyHelper } from "./handleCopyHelper";
|
|
23
|
+
import { handleCopyRows } from "./handleCopyRows";
|
|
24
|
+
import { handleCopyColumn } from "./handleCopyColumn";
|
|
25
|
+
import { isBottomRightCornerOfRectangle } from "./isBottomRightCornerOfRectangle";
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
computePresets,
|
|
29
|
+
defaultParsePaste,
|
|
30
|
+
formatPasteData,
|
|
31
|
+
getAllRows,
|
|
32
|
+
getCellCopyText,
|
|
33
|
+
getCellInfo,
|
|
34
|
+
getEntityIdToEntity,
|
|
35
|
+
getFieldPathToIndex,
|
|
36
|
+
getFieldPathToField,
|
|
37
|
+
getIdOrCodeOrIndex,
|
|
38
|
+
getLastSelectedEntity,
|
|
39
|
+
getNewEntToSelect,
|
|
40
|
+
getNumberStrAtEnd,
|
|
41
|
+
getRecordsFromIdMap,
|
|
42
|
+
getRowCopyText,
|
|
43
|
+
getSelectedRowsFromEntities,
|
|
44
|
+
handleCopyColumn,
|
|
45
|
+
handleCopyHelper,
|
|
46
|
+
handleCopyRows,
|
|
47
|
+
isBottomRightCornerOfRectangle,
|
|
48
|
+
isEntityClean,
|
|
49
|
+
removeCleanRows,
|
|
50
|
+
stripNumberAtEnd
|
|
51
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const isBottomRightCornerOfRectangle = ({
|
|
2
|
+
cellId,
|
|
3
|
+
selectionGrid,
|
|
4
|
+
lastRowIndex,
|
|
5
|
+
lastCellIndex,
|
|
6
|
+
entityMap,
|
|
7
|
+
pathToIndex
|
|
8
|
+
}) => {
|
|
9
|
+
selectionGrid.forEach(row => {
|
|
10
|
+
// remove undefineds from start of row
|
|
11
|
+
while (row[0] === undefined && row.length) row.shift();
|
|
12
|
+
});
|
|
13
|
+
const [rowId, cellPath] = cellId.split(":");
|
|
14
|
+
const ent = entityMap[rowId];
|
|
15
|
+
if (!ent) return;
|
|
16
|
+
const { i } = ent;
|
|
17
|
+
const cellIndex = pathToIndex[cellPath];
|
|
18
|
+
const isBottomRight = i === lastRowIndex && cellIndex === lastCellIndex;
|
|
19
|
+
return isBottomRight;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isEntityClean(e) {
|
|
2
|
+
if (typeof e !== "object" || e === null) {
|
|
3
|
+
return true; // or return false depending on what you want for non-object inputs
|
|
4
|
+
}
|
|
5
|
+
let isClean = true;
|
|
6
|
+
for (const [key, val] of Object.entries(e)) {
|
|
7
|
+
if (key === "id") continue;
|
|
8
|
+
if (key === "_isClean") continue;
|
|
9
|
+
if (val) {
|
|
10
|
+
isClean = false;
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return isClean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isEntityClean } from "./isEntityClean";
|
|
2
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
3
|
+
|
|
4
|
+
export const removeCleanRows = (reduxFormEntities, reduxFormCellValidation) => {
|
|
5
|
+
const toFilterOut = {};
|
|
6
|
+
const entsToUse = (reduxFormEntities || []).filter(e => {
|
|
7
|
+
if (!(e._isClean || isEntityClean(e))) return true;
|
|
8
|
+
else {
|
|
9
|
+
toFilterOut[getIdOrCodeOrIndex(e)] = true;
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const validationToUse = {};
|
|
15
|
+
Object.entries(reduxFormCellValidation || {}).forEach(([k, v]) => {
|
|
16
|
+
const [rowId] = k.split(":");
|
|
17
|
+
if (!toFilterOut[rowId]) {
|
|
18
|
+
validationToUse[k] = v;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return { entsToUse, validationToUse };
|
|
22
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isEmpty, forEach, range } from "lodash-es";
|
|
2
2
|
import { getSelectedRowsFromEntities } from "./selection";
|
|
3
|
-
import getIdOrCodeOrIndex from "./getIdOrCodeOrIndex";
|
|
3
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
4
4
|
import { getRecordsFromIdMap } from "./withSelectedEntities";
|
|
5
5
|
|
|
6
6
|
export default function rowClick(e, rowInfo, entities, props) {
|
|
@@ -124,8 +124,10 @@ export function changeSelectedEntities({ idMap, entities = [], change }) {
|
|
|
124
124
|
change("reduxFormSelectedEntityIdMap", newIdMap);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function finalizeSelection({
|
|
128
|
-
|
|
127
|
+
export function finalizeSelection({
|
|
128
|
+
idMap,
|
|
129
|
+
entities,
|
|
130
|
+
props: {
|
|
129
131
|
onDeselect,
|
|
130
132
|
onSingleRowSelect,
|
|
131
133
|
onMultiRowSelect,
|
|
@@ -133,7 +135,8 @@ export function finalizeSelection({ idMap, entities, props }) {
|
|
|
133
135
|
onRowSelect,
|
|
134
136
|
noSelect,
|
|
135
137
|
change
|
|
136
|
-
}
|
|
138
|
+
}
|
|
139
|
+
}) {
|
|
137
140
|
if (noSelect) return;
|
|
138
141
|
if (
|
|
139
142
|
noDeselectAll &&
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
|
|
2
|
+
|
|
3
|
+
export const getFieldPathToIndex = schema => {
|
|
4
|
+
const fieldToIndex = {};
|
|
5
|
+
schema.fields.forEach((f, i) => {
|
|
6
|
+
fieldToIndex[f.path] = i;
|
|
7
|
+
});
|
|
8
|
+
return fieldToIndex;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const defaultParsePaste = str => {
|
|
12
|
+
return str.split(/\r\n|\n|\r/).map(row => row.split("\t"));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const getEntityIdToEntity = entities => {
|
|
16
|
+
const entityIdToEntity = {};
|
|
17
|
+
entities.forEach((e, i) => {
|
|
18
|
+
entityIdToEntity[getIdOrCodeOrIndex(e, i)] = { e, i };
|
|
19
|
+
});
|
|
20
|
+
return entityIdToEntity;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const endsWithNumber = str => {
|
|
24
|
+
return /[0-9]+$/.test(str);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getNumberStrAtEnd = str => {
|
|
28
|
+
if (endsWithNumber(str)) {
|
|
29
|
+
return str.match(/[0-9]+$/)[0];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const stripNumberAtEnd = str => {
|
|
36
|
+
return str?.replace?.(getNumberStrAtEnd(str), "");
|
|
37
|
+
};
|
package/src/FillWindow.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { createPortal } from "react";
|
|
2
2
|
import { isFunction } from "lodash-es";
|
|
3
|
-
import reactDom from "react-dom";
|
|
4
3
|
import rerenderOnWindowResize from "./rerenderOnWindowResize";
|
|
5
4
|
import "./FillWindow.css";
|
|
6
5
|
|
|
@@ -63,7 +62,7 @@ export default class FillWindow extends React.Component {
|
|
|
63
62
|
: this.props.children}
|
|
64
63
|
</div>
|
|
65
64
|
);
|
|
66
|
-
if (asPortal) return
|
|
65
|
+
if (asPortal) return createPortal(inner, window.document.body);
|
|
67
66
|
return inner;
|
|
68
67
|
}
|
|
69
68
|
}
|