@vuu-ui/vuu-table-extras 4.1.1 → 4.1.2
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.1.
|
|
2
|
+
"version": "4.1.2",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"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"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@vuu-ui/vuu-filter-types": "4.1.
|
|
14
|
-
"@vuu-ui/vuu-protocol-types": "4.1.
|
|
13
|
+
"@vuu-ui/vuu-filter-types": "4.1.2",
|
|
14
|
+
"@vuu-ui/vuu-protocol-types": "4.1.2"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vuu-ui/vuu-codemirror": "4.1.
|
|
18
|
-
"@vuu-ui/vuu-data-editing": "4.1.
|
|
19
|
-
"@vuu-ui/vuu-data-react": "4.1.
|
|
20
|
-
"@vuu-ui/vuu-data-types": "4.1.
|
|
21
|
-
"@vuu-ui/vuu-table-types": "4.1.
|
|
22
|
-
"@vuu-ui/vuu-popups": "4.1.
|
|
23
|
-
"@vuu-ui/vuu-table": "4.1.
|
|
24
|
-
"@vuu-ui/vuu-utils": "4.1.
|
|
25
|
-
"@vuu-ui/vuu-ui-controls": "4.1.
|
|
17
|
+
"@vuu-ui/vuu-codemirror": "4.1.2",
|
|
18
|
+
"@vuu-ui/vuu-data-editing": "4.1.2",
|
|
19
|
+
"@vuu-ui/vuu-data-react": "4.1.2",
|
|
20
|
+
"@vuu-ui/vuu-data-types": "4.1.2",
|
|
21
|
+
"@vuu-ui/vuu-table-types": "4.1.2",
|
|
22
|
+
"@vuu-ui/vuu-popups": "4.1.2",
|
|
23
|
+
"@vuu-ui/vuu-table": "4.1.2",
|
|
24
|
+
"@vuu-ui/vuu-utils": "4.1.2",
|
|
25
|
+
"@vuu-ui/vuu-ui-controls": "4.1.2",
|
|
26
26
|
"@lezer/lr": "1.4.2",
|
|
27
27
|
"@salt-ds/core": "1.74.0",
|
|
28
28
|
"@salt-ds/styles": "0.4.2",
|
|
@@ -47,8 +47,8 @@ const parseCsv = (csvText, options)=>{
|
|
|
47
47
|
relax_column_count: true,
|
|
48
48
|
skip_empty_lines: true
|
|
49
49
|
});
|
|
50
|
-
} catch
|
|
51
|
-
addCsvFileError(errorState, "*", CsvParseErrorEnum.INVALID_FORMAT,
|
|
50
|
+
} catch {
|
|
51
|
+
addCsvFileError(errorState, "*", CsvParseErrorEnum.INVALID_FORMAT, "Invalid CSV format.");
|
|
52
52
|
return withError("Invalid CSV format.", errorState.errorMap, errorState.errors);
|
|
53
53
|
}
|
|
54
54
|
if (0 === records.length) {
|
|
@@ -75,6 +75,10 @@ const parseCsv = (csvText, options)=>{
|
|
|
75
75
|
addCsvFileError(errorState, duplicateHeader, CsvParseErrorEnum.DUPLICATE_HEADER_COLUMN, `CSV header contains duplicate column '${duplicateHeader}'.`, duplicateHeader);
|
|
76
76
|
return withError(`CSV header contains duplicate column '${duplicateHeader}'.`, errorState.errorMap, errorState.errors, header, []);
|
|
77
77
|
}
|
|
78
|
+
if (0 === rows.length) {
|
|
79
|
+
addCsvFileError(errorState, "*", CsvParseErrorEnum.EMPTY_FILE, "CSV file is empty.");
|
|
80
|
+
return withError("CSV file is empty.", errorState.errorMap, errorState.errors, header, []);
|
|
81
|
+
}
|
|
78
82
|
const firstDataRowNumber = options?.customHeaders && false === options.hasHeaderRow ? 1 : CSV_FIRST_DATA_ROW_NUMBER;
|
|
79
83
|
rows.forEach((row, rowIndex)=>{
|
|
80
84
|
if (row.length !== header.length) addCsvRowError(errorState, rowIndex + firstDataRowNumber, "*", CsvParseErrorEnum.ROW_COLUMN_COUNT_MISMATCH, "This row has too many or too few columns compared to the header line. Check for extra or missing commas.", row.join(","));
|
|
@@ -5,6 +5,14 @@ import { CsvValidationErrorEnum, validateCsvAgainstSchema } from "./parse/csv-sc
|
|
|
5
5
|
import { createUploadError, hasFileParseErrors, isCsvParseError, mapCsvHeaders, mergeValidationWithParseErrors, toErrorMessage } from "./parse/csv-upload-utils.js";
|
|
6
6
|
import { useImportSchema } from "./session/useImportSchema.js";
|
|
7
7
|
import { useImportSession } from "./session/useImportSession.js";
|
|
8
|
+
const CSV_MIME_TYPES = new Set([
|
|
9
|
+
"",
|
|
10
|
+
"text/csv",
|
|
11
|
+
"text/plain",
|
|
12
|
+
"application/csv",
|
|
13
|
+
"application/vnd.ms-excel"
|
|
14
|
+
]);
|
|
15
|
+
const isCsvFile = (file)=>file.name.toLowerCase().endsWith(".csv") && CSV_MIME_TYPES.has(file.type.toLowerCase());
|
|
8
16
|
const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importTable, onImportSessionEnded, onImportSessionReady, onError, onImported, onPreview, onProcessingStarted, maxRows, parseOptions, customHeaders, hasHeaderRow, headerMapping, rowDefaults, validators })=>{
|
|
9
17
|
const [validation, setValidation] = useState();
|
|
10
18
|
const [isProcessingFile, setIsProcessingFile] = useState(false);
|
|
@@ -58,6 +66,15 @@ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importT
|
|
|
58
66
|
}
|
|
59
67
|
if (void 0 === schema) throw Error("Table schema is not yet available.");
|
|
60
68
|
if (void 0 === table) throw Error("CsvUpload requires dataSource.table to be defined.");
|
|
69
|
+
if (!isCsvFile(file)) {
|
|
70
|
+
const errorMessage = "Invalid file type. Only .csv files are supported.";
|
|
71
|
+
handleError({
|
|
72
|
+
errors: {
|
|
73
|
+
validationError: createUploadError("validation", errorMessage)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
61
78
|
const effectiveParseOptions = {
|
|
62
79
|
...parseOptions,
|
|
63
80
|
...void 0 !== customHeaders ? {
|
|
@@ -66,14 +66,6 @@ const useInlineAddRow = ({ columns })=>{
|
|
|
66
66
|
newRowState.values,
|
|
67
67
|
visibleInsertColumns
|
|
68
68
|
]);
|
|
69
|
-
useEffect(()=>{
|
|
70
|
-
const firstInvalidIndex = visibleColumns.findIndex(({ name })=>void 0 !== newRowState.errors[name]);
|
|
71
|
-
if (-1 !== firstInvalidIndex) focusEditor(firstInvalidIndex);
|
|
72
|
-
}, [
|
|
73
|
-
focusEditor,
|
|
74
|
-
newRowState.errors,
|
|
75
|
-
visibleColumns
|
|
76
|
-
]);
|
|
77
69
|
useEffect(()=>{
|
|
78
70
|
const previousValues = previousValuesRef.current;
|
|
79
71
|
previousValuesRef.current = newRowState.values;
|