@vuu-ui/vuu-table-extras 3.3.9 → 3.3.11

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 (98) hide show
  1. package/package.json +12 -12
  2. package/src/csv-upload/CsvUpload.js +52 -32
  3. package/src/csv-upload/parse/csv-constants.js +2 -2
  4. package/src/csv-upload/parse/csv-errors.js +1 -0
  5. package/src/csv-upload/parse/csv-schema-validation.js +9 -0
  6. package/src/csv-upload/useCsvUpload.js +7 -5
  7. package/types/csv-upload/CsvUpload.d.ts +2 -1
  8. package/types/csv-upload/index.d.ts +1 -1
  9. package/types/csv-upload/parse/csv-constants.d.ts +2 -2
  10. package/types/csv-upload/parse/csv-errors.d.ts +2 -1
  11. package/types/csv-upload/parse/csv-schema-validation.d.ts +2 -0
  12. package/types/csv-upload/parse/index.d.ts +1 -1
  13. package/types/csv-upload/useCsvUpload.d.ts +3 -2
  14. package/types/src/calculated-column/CalculatedColumnPanel.d.ts +12 -0
  15. package/types/src/calculated-column/useCalculatedColumnPanel.d.ts +10 -0
  16. package/types/src/calculated-column/useEditCalculatedColumn.d.ts +13 -0
  17. package/types/src/cell-edit-validators/CaseValidator.d.ts +2 -0
  18. package/types/src/cell-edit-validators/PatternValidator.d.ts +2 -0
  19. package/types/src/cell-edit-validators/index.d.ts +2 -0
  20. package/types/src/cell-renderers/background-cell/BackgroundCell.d.ts +2 -0
  21. package/types/src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.d.ts +2 -0
  22. package/types/src/cell-renderers/background-cell/index.d.ts +2 -0
  23. package/types/src/cell-renderers/background-cell/useDirection.d.ts +3 -0
  24. package/types/src/cell-renderers/button-cell/IconButtonCell.d.ts +6 -0
  25. package/types/src/cell-renderers/dropdown-cell/DropdownCell.d.ts +2 -0
  26. package/types/src/cell-renderers/dropdown-cell/index.d.ts +1 -0
  27. package/types/src/cell-renderers/index.d.ts +6 -0
  28. package/types/src/cell-renderers/lookup-cell/LookupCell.d.ts +2 -0
  29. package/types/src/cell-renderers/lookup-cell/index.d.ts +1 -0
  30. package/types/src/cell-renderers/pct-progress-cell/PctProgressCell.d.ts +2 -0
  31. package/types/src/cell-renderers/pct-progress-cell/index.d.ts +1 -0
  32. package/types/src/cell-renderers/progress-cell/ProgressCell.d.ts +1 -0
  33. package/types/src/cell-renderers/progress-cell/index.d.ts +1 -0
  34. package/types/src/column-expression-input/ColumnExpressionInput.d.ts +10 -0
  35. package/types/src/column-expression-input/column-function-descriptors.d.ts +15 -0
  36. package/types/src/column-expression-input/column-language-parser/ColumnExpressionLanguage.d.ts +2 -0
  37. package/types/src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.d.ts +57 -0
  38. package/types/src/column-expression-input/column-language-parser/column-expression-parse-utils.d.ts +5 -0
  39. package/types/src/column-expression-input/column-language-parser/generated/column-parser.d.ts +2 -0
  40. package/types/src/column-expression-input/column-language-parser/generated/column-parser.terms.d.ts +1 -0
  41. package/types/src/column-expression-input/column-language-parser/index.d.ts +3 -0
  42. package/types/src/column-expression-input/column-language-parser/test.d.mts +1 -0
  43. package/types/src/column-expression-input/functionDocInfo.d.ts +2 -0
  44. package/types/src/column-expression-input/highlighting.d.ts +1 -0
  45. package/types/src/column-expression-input/index.d.ts +4 -0
  46. package/types/src/column-expression-input/theme.d.ts +1 -0
  47. package/types/src/column-expression-input/useColumnAutoComplete.d.ts +6 -0
  48. package/types/src/column-expression-input/useColumnExpressionEditor.d.ts +25 -0
  49. package/types/src/column-expression-input/useColumnExpressionSuggestionProvider.d.ts +8 -0
  50. package/types/src/column-formatting-settings/BaseNumericFormattingSettings.d.ts +2 -0
  51. package/types/src/column-formatting-settings/ColumnFormattingPanel.d.ts +9 -0
  52. package/types/src/column-formatting-settings/DateTimeFormattingSettings.d.ts +3 -0
  53. package/types/src/column-formatting-settings/LongTypeFormattingSettings.d.ts +3 -0
  54. package/types/src/column-formatting-settings/index.d.ts +3 -0
  55. package/types/src/column-menu/ColumnMenu.d.ts +10 -0
  56. package/types/src/column-menu/column-action-types.d.ts +11 -0
  57. package/types/src/column-menu/column-menu-utils.d.ts +19 -0
  58. package/types/src/column-menu/useColumnActions.d.ts +16 -0
  59. package/types/src/column-picker/ColumnModel.d.ts +81 -0
  60. package/types/src/column-picker/ColumnPicker.d.ts +10 -0
  61. package/types/src/column-picker/ColumnPickerAction.d.ts +5 -0
  62. package/types/src/column-picker/useColumnPicker.d.ts +16 -0
  63. package/types/src/column-picker/useTableColumnPicker.d.ts +7 -0
  64. package/types/src/column-picker/useTableColumnPickerDeprecated.d.ts +14 -0
  65. package/types/src/column-settings-panel/ColumnNameLabel.d.ts +7 -0
  66. package/types/src/column-settings-panel/ColumnSettingsPanel.d.ts +5 -0
  67. package/types/src/column-settings-panel/useColumnSettings.d.ts +30 -0
  68. package/types/src/csv-export/export-utils.d.ts +42 -0
  69. package/types/src/csv-export/index.d.ts +2 -0
  70. package/types/src/csv-export/useCsvExport.d.ts +14 -0
  71. package/types/src/csv-upload/CsvUpload.d.ts +69 -0
  72. package/types/src/csv-upload/data-upload-preview/DataUploadPreview.d.ts +10 -0
  73. package/types/src/csv-upload/data-upload-preview/useDataUploadPreview.d.ts +17 -0
  74. package/types/src/csv-upload/index.d.ts +7 -0
  75. package/types/src/csv-upload/parse/csv-constants.d.ts +3 -0
  76. package/types/src/csv-upload/parse/csv-errors.d.ts +47 -0
  77. package/types/src/csv-upload/parse/csv-parse.d.ts +11 -0
  78. package/types/src/csv-upload/parse/csv-schema-validation.d.ts +18 -0
  79. package/types/src/csv-upload/parse/csv-upload-utils.d.ts +21 -0
  80. package/types/src/csv-upload/parse/index.d.ts +5 -0
  81. package/types/src/csv-upload/useCsvUpload.d.ts +43 -0
  82. package/types/src/datasource-stats/DatasourceStats.d.ts +17 -0
  83. package/types/src/datasource-stats/useDatasourceStats.d.ts +15 -0
  84. package/types/src/freeze-control/FreezeControl.d.ts +15 -0
  85. package/types/src/freeze-control/FrozenBanner.d.ts +6 -0
  86. package/types/src/freeze-control/freezeControlBadge.d.ts +11 -0
  87. package/types/src/freeze-control/useFreezeControl.d.ts +10 -0
  88. package/types/src/index.d.ts +26 -0
  89. package/types/src/inline-add-row/InlineAddRow.d.ts +3 -0
  90. package/types/src/inline-add-row/index.d.ts +2 -0
  91. package/types/src/inline-add-row/useInlineAddRow.d.ts +59 -0
  92. package/types/src/tabbed-table-config-panel/TabbedTableConfigPanel.d.ts +17 -0
  93. package/types/src/tabbed-table-config-panel/TabbedTableSettingsAction.d.ts +7 -0
  94. package/types/src/tabbed-table-config-panel/useTabbedTableConfigPanel.d.ts +13 -0
  95. package/types/src/table-footer/TableFooter.d.ts +10 -0
  96. package/types/src/table-provider/TableProvider.d.ts +18 -0
  97. package/types/src/table-settings-panel/TableSettingsPanel.d.ts +22 -0
  98. package/types/src/table-settings-panel/useTableSettings.d.ts +14 -0
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.3.9",
2
+ "version": "3.3.11",
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.3.9",
15
- "@vuu-ui/vuu-protocol-types": "3.3.9"
14
+ "@vuu-ui/vuu-filter-types": "3.3.11",
15
+ "@vuu-ui/vuu-protocol-types": "3.3.11"
16
16
  },
17
17
  "dependencies": {
18
- "@vuu-ui/vuu-codemirror": "3.3.9",
19
- "@vuu-ui/vuu-data-editing": "3.3.9",
20
- "@vuu-ui/vuu-data-react": "3.3.9",
21
- "@vuu-ui/vuu-data-types": "3.3.9",
22
- "@vuu-ui/vuu-table-types": "3.3.9",
23
- "@vuu-ui/vuu-popups": "3.3.9",
24
- "@vuu-ui/vuu-table": "3.3.9",
25
- "@vuu-ui/vuu-utils": "3.3.9",
26
- "@vuu-ui/vuu-ui-controls": "3.3.9",
18
+ "@vuu-ui/vuu-codemirror": "3.3.11",
19
+ "@vuu-ui/vuu-data-editing": "3.3.11",
20
+ "@vuu-ui/vuu-data-react": "3.3.11",
21
+ "@vuu-ui/vuu-data-types": "3.3.11",
22
+ "@vuu-ui/vuu-table-types": "3.3.11",
23
+ "@vuu-ui/vuu-popups": "3.3.11",
24
+ "@vuu-ui/vuu-table": "3.3.11",
25
+ "@vuu-ui/vuu-utils": "3.3.11",
26
+ "@vuu-ui/vuu-ui-controls": "3.3.11",
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",
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Button, Dialog, DialogActions, DialogContent, DialogHeader, FileDropZone, FileDropZoneIcon, FileDropZoneTrigger } from "@salt-ds/core";
2
+ import { Button, Dialog, DialogActions, DialogContent, DialogHeader, FileDropZone, FileDropZoneIcon, FileDropZoneTrigger, Text } from "@salt-ds/core";
3
3
  import { useComponentCssInjection } from "@salt-ds/styles";
4
4
  import { useWindow } from "@salt-ds/window";
5
5
  import { useCallback, useState } from "react";
@@ -18,6 +18,10 @@ const CsvUpload_CsvUpload = (props)=>{
18
18
  window: targetWindow
19
19
  });
20
20
  const { canImport, cancelImport, isProcessingFile, isImporting, importData, onDrop, onTriggerChange, schema, validation, error } = useCsvUpload(props);
21
+ const fileErrors = validation?.errors.filter((e)=>e.column in validation.errorMap.fileErrors) ?? [];
22
+ const hasErrors = !!error || validation && validation.errors.length > 0;
23
+ const isUploaded = canImport || isImporting;
24
+ const status = hasErrors ? "error" : isUploaded ? "success" : void 0;
21
25
  const handleCancel = useCallback(async ()=>{
22
26
  await cancelImport();
23
27
  if (!isControlledOpen) setInternalOpen(false);
@@ -36,38 +40,55 @@ const CsvUpload_CsvUpload = (props)=>{
36
40
  const content = /*#__PURE__*/ jsxs("div", {
37
41
  className: classBase,
38
42
  children: [
39
- /*#__PURE__*/ jsxs(FileDropZone, {
43
+ /*#__PURE__*/ jsx(FileDropZone, {
40
44
  className: `${classBase}-dropZone`,
41
45
  disabled: void 0 === schema || isProcessingFile || isImporting,
42
46
  onDrop: onDrop,
43
- status: validation && validation.errors.length > 0 || error ? "error" : void 0,
44
- children: [
45
- /*#__PURE__*/ jsx(FileDropZoneIcon, {}),
46
- validation && validation.errors.length > 0 ? /*#__PURE__*/ jsxs(Fragment, {
47
- children: [
48
- /*#__PURE__*/ jsx("div", {
49
- children: "Your file contains errors"
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
- }, `${error.column}-${error.message}-${i}`))
57
- }),
58
- /*#__PURE__*/ jsx("div", {
59
- children: "Please rectify and reupload"
60
- })
61
- ]
62
- }) : /*#__PURE__*/ jsx("div", {
63
- children: "Drop a file here or"
64
- }),
65
- /*#__PURE__*/ jsx(FileDropZoneTrigger, {
66
- accept: ".csv,text/csv",
67
- onChange: onTriggerChange,
68
- children: "BROWSE FILES"
69
- })
70
- ]
47
+ status: status,
48
+ children: isUploaded ? /*#__PURE__*/ jsxs(Fragment, {
49
+ children: [
50
+ /*#__PURE__*/ jsx(FileDropZoneIcon, {
51
+ status: "success"
52
+ }),
53
+ /*#__PURE__*/ jsx("strong", {
54
+ children: "Upload completed"
55
+ })
56
+ ]
57
+ }) : /*#__PURE__*/ jsxs(Fragment, {
58
+ children: [
59
+ /*#__PURE__*/ jsx(FileDropZoneIcon, {
60
+ status: hasErrors ? "error" : void 0
61
+ }),
62
+ validation && validation.errors.length > 0 ? /*#__PURE__*/ jsxs(Fragment, {
63
+ children: [
64
+ /*#__PURE__*/ jsx("div", {
65
+ children: "Your file contains errors"
66
+ }),
67
+ fileErrors.length > 0 && /*#__PURE__*/ jsx("ul", {
68
+ className: `${classBase}-errorList`,
69
+ children: fileErrors.map((error, i)=>/*#__PURE__*/ jsx("li", {
70
+ className: `${classBase}-errorItem`,
71
+ children: error.message
72
+ }, `${error.column}-${error.message}-${i}`))
73
+ }),
74
+ /*#__PURE__*/ jsx("div", {
75
+ children: "Please rectify and reupload"
76
+ })
77
+ ]
78
+ }) : /*#__PURE__*/ jsx("div", {
79
+ children: "Drop a file here or"
80
+ }),
81
+ /*#__PURE__*/ jsx(FileDropZoneTrigger, {
82
+ accept: ".csv,text/csv",
83
+ onChange: onTriggerChange,
84
+ children: "BROWSE FILES"
85
+ }),
86
+ /*#__PURE__*/ jsx(Text, {
87
+ children: "Only .csv files"
88
+ }),
89
+ children
90
+ ]
91
+ })
71
92
  }),
72
93
  error && (renderError ? renderError(error) : /*#__PURE__*/ jsxs("div", {
73
94
  className: `${classBase}-errors`,
@@ -81,8 +102,7 @@ const CsvUpload_CsvUpload = (props)=>{
81
102
  children: error.errors.importError?.message || error.errors.schemaError?.message || error.errors.validationError?.message || "An unexpected error occurred during import."
82
103
  })
83
104
  ]
84
- })),
85
- children
105
+ }))
86
106
  ]
87
107
  });
88
108
  const actions = /*#__PURE__*/ jsxs(DialogActions, {
@@ -1,4 +1,4 @@
1
- const CSV_HEADER_ROW_NUMBER = 1;
2
- const CSV_FIRST_DATA_ROW_NUMBER = 2;
1
+ const CSV_HEADER_ROW_NUMBER = 0;
2
+ const CSV_FIRST_DATA_ROW_NUMBER = 1;
3
3
  const MAX_ROWS_IN_CSV = 10000;
4
4
  export { CSV_FIRST_DATA_ROW_NUMBER, CSV_HEADER_ROW_NUMBER, MAX_ROWS_IN_CSV };
@@ -15,6 +15,7 @@ var csv_errors_CsvValidationErrorEnum = /*#__PURE__*/ function(CsvValidationErro
15
15
  CsvValidationErrorEnum["MAX_ROWS_EXCEEDED"] = "MAX_ROWS_EXCEEDED";
16
16
  CsvValidationErrorEnum["EMPTY_NON_STRING_VALUE"] = "EMPTY_NON_STRING_VALUE";
17
17
  CsvValidationErrorEnum["TYPE_MISMATCH"] = "TYPE_MISMATCH";
18
+ CsvValidationErrorEnum["CUSTOM_VALIDATION"] = "CUSTOM_VALIDATION";
18
19
  return CsvValidationErrorEnum;
19
20
  }({});
20
21
  const createCsvErrorState = ()=>({
@@ -20,6 +20,10 @@ const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
20
20
  parsed.rows.forEach((rowValues, rowIndex)=>{
21
21
  const rowNum = rowIndex + CSV_FIRST_DATA_ROW_NUMBER;
22
22
  const typedRow = {};
23
+ const rawRow = parsed.header.reduce((acc, headerCol, idx)=>{
24
+ acc[headerCol] = rowValues[idx];
25
+ return acc;
26
+ }, {});
23
27
  parsed.header.forEach((columnName, columnIndex)=>{
24
28
  const rawValue = rowValues[columnIndex];
25
29
  const schemaType = schemaColumns.get(columnName);
@@ -33,6 +37,11 @@ const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
33
37
  return;
34
38
  }
35
39
  if (void 0 === value) return void addCsvRowError(errorState, rowNum, columnName, CsvValidationErrorEnum.TYPE_MISMATCH, `Value '${rawValue}' is not a valid ${toType}`, rawValue);
40
+ const customValidator = options?.validators?.[columnName];
41
+ if (customValidator) {
42
+ const validationResult = customValidator(rawValue, columnName, rawRow);
43
+ if (true !== validationResult) return void addCsvRowError(errorState, rowNum, columnName, CsvValidationErrorEnum.CUSTOM_VALIDATION, "string" == typeof validationResult ? validationResult : `Value '${rawValue}' failed custom validation.`, rawValue);
44
+ }
36
45
  typedRow[columnName] = value;
37
46
  });
38
47
  typedRows.push(typedRow);
@@ -5,7 +5,7 @@ import { parseCsv } from "./parse/csv-parse.js";
5
5
  import { validateCsvAgainstSchema } from "./parse/csv-schema-validation.js";
6
6
  import { buildRowErrorMessage, createUploadError, hasFileParseErrors, isCsvParseError, mergeValidationWithParseErrors, toErrorMessage } from "./parse/csv-upload-utils.js";
7
7
  import { CSV_FIRST_DATA_ROW_NUMBER } from "./parse/csv-constants.js";
8
- const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importTable, onImportSessionEnded, onImportSessionStarted, onError, onImported, onPreview, onProcessingStarted, maxRows, parseOptions, rowDefaults })=>{
8
+ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importTable, onImportSessionEnded, onImportSessionStarted, onError, onImported, onPreview, onProcessingStarted, maxRows, parseOptions, rowDefaults, validators })=>{
9
9
  const { getServerAPI } = useData();
10
10
  const [validation, setValidation] = useState();
11
11
  const [sessionTable, setSessionTable] = useState();
@@ -140,7 +140,7 @@ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importT
140
140
  if (rowNum < CSV_FIRST_DATA_ROW_NUMBER) continue;
141
141
  const existing = vuuMsgByRow.get(rowNum);
142
142
  const columnError = `${column}: ${message}`;
143
- vuuMsgByRow.set(rowNum, existing ? `${existing}; ${columnError}` : `Row ${rowNum}: ${columnError}`);
143
+ vuuMsgByRow.set(rowNum, existing ? `${existing}; ${columnError}` : `${0 === rowNum ? "Header" : `Row ${rowNum}`}: ${columnError}`);
144
144
  }
145
145
  const parsedRowCount = mergedValidation.rows.length;
146
146
  const unparsedErrorRows = [
@@ -174,7 +174,7 @@ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importT
174
174
  if (isRpcError(result)) throw Error(result.errorMessage);
175
175
  if ("string" == typeof result) throw Error(result);
176
176
  } catch (error) {
177
- rpcErrors.push(`Row ${rowNum}: ${toErrorMessage(error)}`);
177
+ rpcErrors.push(`${0 === rowNum ? "Header" : `Row ${rowNum}`}: ${toErrorMessage(error)}`);
178
178
  }
179
179
  }
180
180
  if (rpcErrors.length > 0) throw Error(buildRowErrorMessage("Import failed", rpcErrors));
@@ -240,7 +240,8 @@ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importT
240
240
  return;
241
241
  }
242
242
  const schemaValidation = validateCsvAgainstSchema(parsedCsv, schema, {
243
- maxRows
243
+ maxRows,
244
+ validators
244
245
  });
245
246
  if (Object.keys(schemaValidation.errorMap.fileErrors).length > 0) {
246
247
  setValidation(schemaValidation);
@@ -288,7 +289,8 @@ const useCsvUpload = ({ dataSource, importMode = "direct", importSchema, importT
288
289
  dataSource.table,
289
290
  table,
290
291
  endEditSessionAndNotify,
291
- schema
292
+ schema,
293
+ validators
292
294
  ]);
293
295
  const handleFiles = useCallback(async (files)=>{
294
296
  const file = files[0];
@@ -1,7 +1,7 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { RowDefaultDataItemValues, EditSession } from "@vuu-ui/vuu-data-editing";
3
3
  import type { CsvParseError, CsvParseOptions } from "./parse/csv-parse";
4
- import type { CsvValidationStructuredError } from "./parse/csv-schema-validation";
4
+ import type { CsvValidationStructuredError, CsvColumnValidator } from "./parse/csv-schema-validation";
5
5
  import type { DataSource, TableSchema } from "@vuu-ui/vuu-data-types";
6
6
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
7
7
  import type { CsvUploadTableData } from "./parse/csv-upload-utils";
@@ -60,6 +60,7 @@ export interface CsvUploadProps {
60
60
  parseOptions?: CsvParseOptions;
61
61
  importMode?: "direct" | "preview";
62
62
  rowDefaults?: RowDefaultDataItemValues;
63
+ validators?: Record<string, CsvColumnValidator>;
63
64
  /**
64
65
  * Custom renderer for the error panel.
65
66
  */
@@ -1,7 +1,7 @@
1
1
  export { CsvUpload, type CsvUploadError, type CsvUploadProps, type CsvUploadErrorResult, type CsvUploadErrors, type CsvUploadPhase, type CsvUploadImportedResult, type CsvUploadPreviewResult, type CsvUploadSessionEndReason, type CsvUploadSessionEndResult, type CsvUploadSessionTable, } from "./CsvUpload";
2
2
  export { useCsvUpload, type CsvUploadHookProps, type UseCsvUploadReturn, } from "./useCsvUpload";
3
3
  export { DataUploadPreview, type DataUploadPreviewProps, } from "./data-upload-preview/DataUploadPreview";
4
- export { validateCsvAgainstSchema, type CsvValidationOptions, type CsvValidationResult, } from "./parse/csv-schema-validation";
4
+ export { validateCsvAgainstSchema, type CsvColumnValidator, type CsvValidationOptions, type CsvValidationResult, } from "./parse/csv-schema-validation";
5
5
  export { parseCsv, type CsvParseOptions, type CsvParseResult, } from "./parse/csv-parse";
6
6
  export { CsvValidationErrorEnum, CsvParseErrorEnum, type CsvError, type CsvErrorMap, type CsvStructuredError, type CsvValidationError, type CsvValidationErrorMap, type CsvValidationErrorType, type CsvValidationStructuredError, type CsvParseError, type CsvParseErrorMap, } from "./parse/csv-errors";
7
7
  export { CSV_FIRST_DATA_ROW_NUMBER, CSV_HEADER_ROW_NUMBER, } from "./parse/csv-constants";
@@ -1,3 +1,3 @@
1
- export declare const CSV_HEADER_ROW_NUMBER = 1;
2
- export declare const CSV_FIRST_DATA_ROW_NUMBER = 2;
1
+ export declare const CSV_HEADER_ROW_NUMBER = 0;
2
+ export declare const CSV_FIRST_DATA_ROW_NUMBER = 1;
3
3
  export declare const MAX_ROWS_IN_CSV = 10000;
@@ -12,7 +12,8 @@ export declare enum CsvValidationErrorEnum {
12
12
  UNKNOWN_COLUMN = "UNKNOWN_COLUMN",
13
13
  MAX_ROWS_EXCEEDED = "MAX_ROWS_EXCEEDED",
14
14
  EMPTY_NON_STRING_VALUE = "EMPTY_NON_STRING_VALUE",
15
- TYPE_MISMATCH = "TYPE_MISMATCH"
15
+ TYPE_MISMATCH = "TYPE_MISMATCH",
16
+ CUSTOM_VALIDATION = "CUSTOM_VALIDATION"
16
17
  }
17
18
  export type CsvErrorMap<TError extends string> = {
18
19
  rowErrors: Record<number, Record<string, TError[]>>;
@@ -3,6 +3,7 @@ import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
3
  import type { CsvValidationError, CsvValidationErrorMap, CsvParseError } from "./csv-errors";
4
4
  import type { CsvParseResult } from "./csv-parse";
5
5
  export { CsvValidationErrorEnum, type CsvValidationError, type CsvValidationErrorMap, type CsvValidationErrorType, type CsvValidationStructuredError, } from "./csv-errors";
6
+ export type CsvColumnValidator = (value: string, columnName: string, row: Record<string, string>) => boolean | string;
6
7
  export type CsvValidationResult = {
7
8
  columns: string[];
8
9
  errorMap: CsvValidationErrorMap;
@@ -12,5 +13,6 @@ export type CsvValidationResult = {
12
13
  };
13
14
  export type CsvValidationOptions = {
14
15
  maxRows?: number;
16
+ validators?: Record<string, CsvColumnValidator>;
15
17
  };
16
18
  export declare const validateCsvAgainstSchema: (parsed: CsvParseResult, tableSchema: TableSchema, options?: CsvValidationOptions) => CsvValidationResult;
@@ -1,5 +1,5 @@
1
1
  export { CSV_FIRST_DATA_ROW_NUMBER, CSV_HEADER_ROW_NUMBER, } from "./csv-constants";
2
2
  export { CsvParseErrorEnum, CsvValidationErrorEnum, type CsvError, type CsvErrorMap, type CsvErrorState, type CsvParseError, type CsvParseErrorMap, type CsvStructuredError, type CsvValidationError, type CsvValidationErrorMap, type CsvValidationErrorType, type CsvValidationStructuredError, addCsvFileError, addCsvRowError, createCsvErrorState, hasCsvErrors, } from "./csv-errors";
3
3
  export { parseCsv, type CsvParseOptions, type CsvParseResult, } from "./csv-parse";
4
- export { validateCsvAgainstSchema, type CsvValidationOptions, type CsvValidationResult, } from "./csv-schema-validation";
4
+ export { validateCsvAgainstSchema, type CsvColumnValidator, type CsvValidationOptions, type CsvValidationResult, } from "./csv-schema-validation";
5
5
  export { buildRowErrorMessage, executeBatchRpcCalls, hasFileParseErrors, isCsvParseError, mergeValidationWithParseErrors, normalizeTableData, toErrorMessage, toValidationErrorsFromParseRowErrors, type CsvUploadTableData, type RpcBatchResult, } from "./csv-upload-utils";
@@ -2,7 +2,7 @@ import type { DataSource, TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import { type RowDefaultDataItemValues } from "@vuu-ui/vuu-data-editing";
3
3
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
4
4
  import { type CsvParseOptions } from "./parse/csv-parse";
5
- import { type CsvValidationResult } from "./parse/csv-schema-validation";
5
+ import { type CsvValidationResult, type CsvColumnValidator } from "./parse/csv-schema-validation";
6
6
  import type { CsvUploadErrorResult, CsvUploadImportedResult, CsvUploadPreviewResult, CsvUploadSessionEndResult, CsvUploadSessionTable } from "./CsvUpload";
7
7
  export interface CsvUploadHookProps {
8
8
  dataSource: DataSource;
@@ -25,6 +25,7 @@ export interface CsvUploadHookProps {
25
25
  parseOptions?: CsvParseOptions;
26
26
  /** Default column values applied to every addRow call. Pass a stable reference — a new object triggers EditSession recreation. */
27
27
  rowDefaults?: RowDefaultDataItemValues;
28
+ validators?: Record<string, CsvColumnValidator>;
28
29
  }
29
30
  export type UseCsvUploadReturn = {
30
31
  canImport: boolean;
@@ -39,4 +40,4 @@ export type UseCsvUploadReturn = {
39
40
  validation: CsvValidationResult | undefined;
40
41
  error: CsvUploadErrorResult | undefined;
41
42
  };
42
- export declare const useCsvUpload: ({ dataSource, importMode, importSchema, importTable, onImportSessionEnded, onImportSessionStarted, onError, onImported, onPreview, onProcessingStarted, maxRows, parseOptions, rowDefaults, }: CsvUploadHookProps) => UseCsvUploadReturn;
43
+ export declare const useCsvUpload: ({ dataSource, importMode, importSchema, importTable, onImportSessionEnded, onImportSessionStarted, onError, onImported, onPreview, onProcessingStarted, maxRows, parseOptions, rowDefaults, validators, }: CsvUploadHookProps) => UseCsvUploadReturn;
@@ -0,0 +1,12 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
3
+ import { VuuColumnDataType, VuuTable } from "@vuu-ui/vuu-protocol-types";
4
+ import { ColumnModel } from "../column-picker/ColumnModel";
5
+ export interface CalculatedColumnPanelProps extends HTMLAttributes<HTMLDivElement> {
6
+ column: ColumnDescriptor;
7
+ columnModel: ColumnModel;
8
+ onChangeColumn: (column: ColumnDescriptor) => void;
9
+ onChangeServerDataType?: (name: VuuColumnDataType) => void;
10
+ vuuTable: VuuTable;
11
+ }
12
+ export declare const CalculatedColumnPanel: ({ column: columnProp, columnModel, onChangeColumn, onChangeServerDataType: onChangeServerDataTypeProp, vuuTable, }: CalculatedColumnPanelProps) => import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
+ import { FormEventHandler, SyntheticEvent } from "react";
3
+ import { CalculatedColumnPanelProps } from "./CalculatedColumnPanel";
4
+ export type ColumnExpressionHookProps = Pick<CalculatedColumnPanelProps, "column" | "onChangeColumn" | "onChangeServerDataType">;
5
+ export declare const useCalculatedColumnPanel: ({ column: columnProp, onChangeColumn, onChangeServerDataType: onChangeServerDataTypeProp, }: ColumnExpressionHookProps) => {
6
+ column: ColumnDescriptor;
7
+ onChangeExpression: (value: string) => void;
8
+ onChangeName: FormEventHandler;
9
+ onChangeServerDataType: (_e: SyntheticEvent, [serverDataType]: string[]) => void;
10
+ };
@@ -0,0 +1,13 @@
1
+ import { VuuTable } from "@vuu-ui/vuu-protocol-types";
2
+ import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
3
+ import { ColumnModel } from "../column-picker/ColumnModel";
4
+ export interface EditCalculatedColumnProps {
5
+ calculatedColumn?: ColumnDescriptor;
6
+ columnModel: ColumnModel;
7
+ onSaveColumn?: (caclulatedColumn: ColumnDescriptor) => void;
8
+ vuuTable?: VuuTable;
9
+ }
10
+ export declare const useEditCalculatedColumn: ({ calculatedColumn, columnModel, onSaveColumn, vuuTable, }: EditCalculatedColumnProps) => {
11
+ onCreateCalculatedColumn: () => void;
12
+ onEditCalculatedColumn: () => void;
13
+ };
@@ -0,0 +1,2 @@
1
+ import { EditRuleValidator } from "@vuu-ui/vuu-data-types";
2
+ export declare const CaseValidator: EditRuleValidator;
@@ -0,0 +1,2 @@
1
+ import { EditRuleValidator } from "@vuu-ui/vuu-data-types";
2
+ export declare const PatternValidator: EditRuleValidator;
@@ -0,0 +1,2 @@
1
+ export * from "./CaseValidator";
2
+ export * from "./PatternValidator";
@@ -0,0 +1,2 @@
1
+ import { TableCellRendererProps } from "@vuu-ui/vuu-table-types";
2
+ export declare const BackgroundCell: import("react").MemoExoticComponent<({ column, dataRow, }: TableCellRendererProps) => import("react").JSX.Element>;
@@ -0,0 +1,2 @@
1
+ import { ConfigurationEditorProps } from "@vuu-ui/vuu-utils";
2
+ export declare const BackgroundCellConfigurationEditor: ({ column, onChangeRendering, }: ConfigurationEditorProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from "./BackgroundCell";
2
+ export * from "./BackgroundCellConfigurationEditor";
@@ -0,0 +1,3 @@
1
+ import { RuntimeColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
+ import { valueChangeDirection } from "@vuu-ui/vuu-utils";
3
+ export declare function useDirection(key: string, value: unknown, column: RuntimeColumnDescriptor): valueChangeDirection;
@@ -0,0 +1,6 @@
1
+ import { TableCellRendererProps } from "@vuu-ui/vuu-table-types";
2
+ /**
3
+ * To assign an icon to the cell, give the columndescriptor
4
+ * a className. In css, assign an icon variable to --vuu-svg-icon.
5
+ */
6
+ export declare const IconButtonCell: ({ column, dataRow }: TableCellRendererProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { TableCellRendererProps } from "@vuu-ui/vuu-table-types";
2
+ export declare const DropdownCell: import("react").MemoExoticComponent<({ column, dataRow, editedDuringCurrentSession, onEdit, }: TableCellRendererProps) => import("react").JSX.Element>;
@@ -0,0 +1 @@
1
+ export * from "./DropdownCell";
@@ -0,0 +1,6 @@
1
+ export * from "./background-cell";
2
+ export * from "./dropdown-cell";
3
+ export * from "./lookup-cell";
4
+ export * from "./pct-progress-cell";
5
+ export * from "./progress-cell";
6
+ export { IconButtonCell } from "./button-cell/IconButtonCell";
@@ -0,0 +1,2 @@
1
+ import { TableCellRendererProps } from "@vuu-ui/vuu-table-types";
2
+ export declare const LookupCell: import("react").MemoExoticComponent<({ column, dataRow, }: TableCellRendererProps) => import("react").JSX.Element>;
@@ -0,0 +1 @@
1
+ export * from "./LookupCell";
@@ -0,0 +1,2 @@
1
+ import { TableCellProps } from "@vuu-ui/vuu-table-types";
2
+ export declare const PctProgressCell: ({ column, dataRow }: TableCellProps) => import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./PctProgressCell";
@@ -0,0 +1 @@
1
+ export * from "./ProgressCell";
@@ -0,0 +1,10 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { ColumnDefinitionExpression } from "./column-language-parser";
3
+ import { ExpressionSuggestionConsumer } from "./useColumnExpressionEditor";
4
+ export type ColumnExpressionSubmitHandler = (source: string, expression: ColumnDefinitionExpression | undefined) => void;
5
+ export interface ColumnExpressionInputProps extends ExpressionSuggestionConsumer, Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
6
+ onChange?: (source: string) => void;
7
+ onSubmitExpression?: ColumnExpressionSubmitHandler;
8
+ source?: string;
9
+ }
10
+ export declare const ColumnExpressionInput: import("react").MemoExoticComponent<({ onChange, onSubmitExpression, source, suggestionProvider, }: ColumnExpressionInputProps) => import("react").JSX.Element>;
@@ -0,0 +1,15 @@
1
+ export type ColumnFunctionDescriptor = {
2
+ accepts: "string" | "number" | "boolean" | "any" | Array<"string" | "number" | "boolean">;
3
+ description: string;
4
+ example: {
5
+ expression: string;
6
+ result: string;
7
+ };
8
+ name: string;
9
+ params: {
10
+ count?: number;
11
+ description: string;
12
+ };
13
+ type: "string" | "number" | "boolean" | "variable";
14
+ };
15
+ export declare const columnFunctionDescriptors: ColumnFunctionDescriptor[];
@@ -0,0 +1,2 @@
1
+ import { LanguageSupport } from "@vuu-ui/vuu-codemirror";
2
+ export declare const columnExpressionLanguageSupport: () => LanguageSupport;
@@ -0,0 +1,57 @@
1
+ import type { Tree } from "@vuu-ui/vuu-codemirror";
2
+ type expressionType = "arithmeticExpression" | "booleanCondition" | "booleanLiteralExpression" | "callExpression" | "colExpression" | "conditionalExpression" | "numericLiteralExpression" | "relationalExpression" | "stringLiteralExpression" | "unknown";
3
+ type arithmeticOp = "*" | "/" | "+" | "-" | "unknown";
4
+ type booleanOp = "and" | "or";
5
+ type relationalOp = "=" | "!=" | ">" | ">=" | "<" | "<=" | "unknown";
6
+ export interface Expression {
7
+ type: expressionType;
8
+ expressions?: Expression[];
9
+ toJSON?: () => unknown;
10
+ value?: string | number | boolean;
11
+ }
12
+ interface BooleanLiteralExpression {
13
+ type: "booleanLiteralExpression";
14
+ value: boolean;
15
+ }
16
+ interface NumericLiteralExpression {
17
+ type: "numericLiteralExpression";
18
+ value: number;
19
+ }
20
+ interface StringLiteralExpression {
21
+ type: "stringLiteralExpression";
22
+ value: string;
23
+ }
24
+ interface ArithmeticExpression extends Expression {
25
+ expressions: [Expression, Expression];
26
+ op: arithmeticOp;
27
+ type: "arithmeticExpression";
28
+ }
29
+ interface BooleanCondition extends Expression {
30
+ expressions: Expression[];
31
+ op: booleanOp;
32
+ type: "booleanCondition";
33
+ }
34
+ interface RelationalExpression extends Expression {
35
+ expressions: Expression[];
36
+ op: relationalOp;
37
+ type: "relationalExpression";
38
+ }
39
+ interface ColExpression extends Expression {
40
+ column?: string;
41
+ type: "colExpression";
42
+ }
43
+ interface CallExpression extends Expression {
44
+ arguments: Expression[];
45
+ functionName?: string;
46
+ type: "callExpression";
47
+ }
48
+ type ConditionExpression = RelationalExpression | BooleanCondition;
49
+ interface ConditionalExpression extends Expression {
50
+ type: "conditionalExpression";
51
+ condition: ConditionExpression;
52
+ truthyExpression: Expression;
53
+ falsyExpression: Expression;
54
+ }
55
+ export type ColumnDefinitionExpression = ArithmeticExpression | BooleanLiteralExpression | CallExpression | ColExpression | ConditionalExpression | NumericLiteralExpression | StringLiteralExpression;
56
+ export declare const walkTree: (tree: Tree, source: string) => ColumnDefinitionExpression;
57
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { SyntaxNode } from "@vuu-ui/vuu-codemirror";
2
+ export declare const ColumnNamedTerms: readonly string[];
3
+ export declare const isCompleteExpression: (src: string) => boolean;
4
+ export declare const lastNamedChild: (node: SyntaxNode) => SyntaxNode | null;
5
+ export declare const isCompleteRelationalExpression: (node?: SyntaxNode) => boolean;
@@ -0,0 +1,2 @@
1
+ import { LRParser } from "@lezer/lr";
2
+ export declare const parser: LRParser;
@@ -0,0 +1 @@
1
+ export declare const ColumnDefinitionExpression = 1, Column = 2, Number = 3, String = 4, True = 5, False = 6, ParenthesizedExpression = 7, OpenBrace = 8, CloseBrace = 9, ArithmeticExpression = 10, Divide = 11, Times = 12, Plus = 13, Minus = 14, ConditionalExpression = 15, If = 16, RelationalExpression = 17, RelationalOperator = 18, AndCondition = 19, OrCondition = 20, Comma = 21, CallExpression = 22, Function = 23, ArgList = 24;
@@ -0,0 +1,3 @@
1
+ export * from "./ColumnExpressionLanguage";
2
+ export * from "./ColumnExpressionTreeWalker";
3
+ export * from "./column-expression-parse-utils";
@@ -0,0 +1 @@
1
+ export declare const walkTree: (tree: any, source: any) => void;
@@ -0,0 +1,2 @@
1
+ import { ColumnFunctionDescriptor } from "./column-function-descriptors";
2
+ export declare const functionDocInfo: ({ name, description, example, params, type, }: ColumnFunctionDescriptor) => HTMLElement;
@@ -0,0 +1 @@
1
+ export declare const vuuHighlighting: import("@codemirror/state").Extension;
@@ -0,0 +1,4 @@
1
+ export * from "./ColumnExpressionInput";
2
+ export * from "./column-language-parser";
3
+ export * from "./useColumnExpressionEditor";
4
+ export * from "./useColumnExpressionSuggestionProvider";
@@ -0,0 +1 @@
1
+ export declare const vuuTheme: import("@codemirror/state").Extension;
@@ -0,0 +1,6 @@
1
+ import { type CompletionSource } from "@vuu-ui/vuu-codemirror";
2
+ import { type RefObject } from "react";
3
+ import type { IExpressionSuggestionProvider } from "./useColumnExpressionEditor";
4
+ export type ApplyCompletion = (mode?: "add" | "replace") => void;
5
+ export type Operator = "";
6
+ export declare const useColumnAutoComplete: (suggestionProvider: IExpressionSuggestionProvider, onSubmit: RefObject<ApplyCompletion>) => CompletionSource;