@vuu-ui/vuu-table-extras 3.2.0 → 3.3.0
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/package.json +12 -12
- package/src/csv-upload/CsvUpload.js +8 -1
- package/src/csv-upload/data-upload-preview/DataUploadPreview.js +2 -2
- package/src/csv-upload/parse/csv-constants.js +2 -1
- package/src/csv-upload/parse/csv-schema-validation.js +2 -3
- package/src/csv-upload/useCsvUpload.js +6 -3
- package/types/csv-upload/parse/csv-constants.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.
|
|
2
|
+
"version": "3.3.0",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
"lezer-generate:column": "lezer-generator --output ./src/column-expression-input/column-language-parser/generated/column-parser.js ./src/column-expression-input/column-language-parser/grammar/column.grammar"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-filter-types": "3.
|
|
15
|
-
"@vuu-ui/vuu-protocol-types": "3.
|
|
14
|
+
"@vuu-ui/vuu-filter-types": "3.3.0",
|
|
15
|
+
"@vuu-ui/vuu-protocol-types": "3.3.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@vuu-ui/vuu-codemirror": "3.
|
|
19
|
-
"@vuu-ui/vuu-data-editing": "3.
|
|
20
|
-
"@vuu-ui/vuu-data-react": "3.
|
|
21
|
-
"@vuu-ui/vuu-data-types": "3.
|
|
22
|
-
"@vuu-ui/vuu-table-types": "3.
|
|
23
|
-
"@vuu-ui/vuu-popups": "3.
|
|
24
|
-
"@vuu-ui/vuu-table": "3.
|
|
25
|
-
"@vuu-ui/vuu-utils": "3.
|
|
26
|
-
"@vuu-ui/vuu-ui-controls": "3.
|
|
18
|
+
"@vuu-ui/vuu-codemirror": "3.3.0",
|
|
19
|
+
"@vuu-ui/vuu-data-editing": "3.3.0",
|
|
20
|
+
"@vuu-ui/vuu-data-react": "3.3.0",
|
|
21
|
+
"@vuu-ui/vuu-data-types": "3.3.0",
|
|
22
|
+
"@vuu-ui/vuu-table-types": "3.3.0",
|
|
23
|
+
"@vuu-ui/vuu-popups": "3.3.0",
|
|
24
|
+
"@vuu-ui/vuu-table": "3.3.0",
|
|
25
|
+
"@vuu-ui/vuu-utils": "3.3.0",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "3.3.0",
|
|
27
27
|
"@lezer/lr": "1.4.2",
|
|
28
28
|
"@salt-ds/core": "1.54.1",
|
|
29
29
|
"@salt-ds/lab": "1.0.0-alpha.83",
|
|
@@ -48,8 +48,15 @@ const CsvUpload_CsvUpload = (props)=>{
|
|
|
48
48
|
/*#__PURE__*/ jsx("div", {
|
|
49
49
|
children: "Your file contains errors"
|
|
50
50
|
}),
|
|
51
|
+
/*#__PURE__*/ jsx("ul", {
|
|
52
|
+
className: `${classBase}-errorList`,
|
|
53
|
+
children: validation.errors.filter((e)=>e.column in validation.errorMap.fileErrors).map((error, i)=>/*#__PURE__*/ jsx("li", {
|
|
54
|
+
className: `${classBase}-errorItem`,
|
|
55
|
+
children: error.message
|
|
56
|
+
}, i))
|
|
57
|
+
}),
|
|
51
58
|
/*#__PURE__*/ jsx("div", {
|
|
52
|
-
children: "
|
|
59
|
+
children: "Please rectify and reupload"
|
|
53
60
|
})
|
|
54
61
|
]
|
|
55
62
|
}) : /*#__PURE__*/ jsx("div", {
|
|
@@ -38,7 +38,7 @@ const DataUploadPreview_DataUploadPreview = ({ className, editSession, onClose,
|
|
|
38
38
|
editSession,
|
|
39
39
|
onClose
|
|
40
40
|
});
|
|
41
|
-
const isRowSelectable = useCallback((dataRow)=>"deleteRow" !== dataRow.
|
|
41
|
+
const isRowSelectable = useCallback((dataRow)=>"deleteRow" !== dataRow.vuuAction, []);
|
|
42
42
|
const config = useMemo(()=>{
|
|
43
43
|
const columns = tableSchema.columns.map((column)=>"vuuMsg" === column.name ? {
|
|
44
44
|
...column,
|
|
@@ -60,7 +60,7 @@ const DataUploadPreview_DataUploadPreview = ({ className, editSession, onClose,
|
|
|
60
60
|
return {
|
|
61
61
|
columns: columns.concat({
|
|
62
62
|
hidden: true,
|
|
63
|
-
name: "
|
|
63
|
+
name: "vuuAction"
|
|
64
64
|
}, undoColumn),
|
|
65
65
|
columnDefaultWidth: 150,
|
|
66
66
|
rowClassNameGenerators: rowClassNameGenerators,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getTypedValue } from "@vuu-ui/vuu-utils";
|
|
2
2
|
import { CsvValidationErrorEnum, addCsvFileError, addCsvRowError, createCsvErrorState } from "./csv-errors.js";
|
|
3
|
-
import { CSV_FIRST_DATA_ROW_NUMBER } from "./csv-constants.js";
|
|
4
|
-
const MAX_ROWS_IN_CSV = 25000;
|
|
3
|
+
import { CSV_FIRST_DATA_ROW_NUMBER, MAX_ROWS_IN_CSV } from "./csv-constants.js";
|
|
5
4
|
const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
|
|
6
5
|
const schemaColumns = new Map(tableSchema.columns.map((col)=>[
|
|
7
6
|
col.name,
|
|
@@ -11,7 +10,7 @@ const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
|
|
|
11
10
|
const errorState = createCsvErrorState();
|
|
12
11
|
if (!parsed.header.includes(tableSchema.key)) addCsvFileError(errorState, tableSchema.key, CsvValidationErrorEnum.MISSING_KEY_COLUMN, `CSV must include key column '${tableSchema.key}'.`);
|
|
13
12
|
parsed.header.forEach((column)=>{
|
|
14
|
-
if (!schemaColumns.has(column)) addCsvFileError(errorState, column, CsvValidationErrorEnum.UNKNOWN_COLUMN,
|
|
13
|
+
if (!schemaColumns.has(column)) addCsvFileError(errorState, column, CsvValidationErrorEnum.UNKNOWN_COLUMN, `Column ${column} is not present in table schema.`, column);
|
|
15
14
|
});
|
|
16
15
|
if (parsed.rows.length > maxRows) addCsvFileError(errorState, "*", CsvValidationErrorEnum.MAX_ROWS_EXCEEDED, `CSV row count ${parsed.rows.length} exceeds maxRows ${maxRows}.`, String(parsed.rows.length));
|
|
17
16
|
const typedRows = [];
|
|
@@ -85,9 +85,12 @@ const useCsvUpload = ({ dataSource, importMode = "direct", onImportSessionEnded,
|
|
|
85
85
|
for (const { rowNum, rowData, vuuMsg } of allRows){
|
|
86
86
|
if (operationId !== operationIdRef.current) return false;
|
|
87
87
|
try {
|
|
88
|
-
const payload = {
|
|
88
|
+
const payload = vuuMsg ? {
|
|
89
|
+
vuuRowNum: rowNum,
|
|
90
|
+
vuuMsg
|
|
91
|
+
} : {
|
|
89
92
|
...rowData,
|
|
90
|
-
rowNum,
|
|
93
|
+
vuuRowNum: rowNum,
|
|
91
94
|
vuuMsg
|
|
92
95
|
};
|
|
93
96
|
const result = await editSession.addRow(payload);
|
|
@@ -103,7 +106,7 @@ const useCsvUpload = ({ dataSource, importMode = "direct", onImportSessionEnded,
|
|
|
103
106
|
editSession
|
|
104
107
|
]);
|
|
105
108
|
const beginEditSession = useCallback(async ()=>{
|
|
106
|
-
const sessionDataSource = await editSession.begin("Empty");
|
|
109
|
+
const sessionDataSource = await editSession.begin("Empty", "import");
|
|
107
110
|
const sessionVuuTable = sessionDataSource?.table;
|
|
108
111
|
if (void 0 === sessionDataSource || void 0 === sessionVuuTable || !isSessionTable(sessionVuuTable)) throw Error("CsvUpload createSessionDataSource returned no session datasource.");
|
|
109
112
|
if (!sessionDataSource.columns.includes("vuuMsg")) sessionDataSource.columns = sessionDataSource.columns.concat("vuuMsg");
|