@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.
- package/package.json +12 -12
- package/src/csv-upload/CsvUpload.js +52 -32
- package/src/csv-upload/parse/csv-constants.js +2 -2
- package/src/csv-upload/parse/csv-errors.js +1 -0
- package/src/csv-upload/parse/csv-schema-validation.js +9 -0
- package/src/csv-upload/useCsvUpload.js +7 -5
- package/types/csv-upload/CsvUpload.d.ts +2 -1
- package/types/csv-upload/index.d.ts +1 -1
- package/types/csv-upload/parse/csv-constants.d.ts +2 -2
- package/types/csv-upload/parse/csv-errors.d.ts +2 -1
- package/types/csv-upload/parse/csv-schema-validation.d.ts +2 -0
- package/types/csv-upload/parse/index.d.ts +1 -1
- package/types/csv-upload/useCsvUpload.d.ts +3 -2
- package/types/src/calculated-column/CalculatedColumnPanel.d.ts +12 -0
- package/types/src/calculated-column/useCalculatedColumnPanel.d.ts +10 -0
- package/types/src/calculated-column/useEditCalculatedColumn.d.ts +13 -0
- package/types/src/cell-edit-validators/CaseValidator.d.ts +2 -0
- package/types/src/cell-edit-validators/PatternValidator.d.ts +2 -0
- package/types/src/cell-edit-validators/index.d.ts +2 -0
- package/types/src/cell-renderers/background-cell/BackgroundCell.d.ts +2 -0
- package/types/src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.d.ts +2 -0
- package/types/src/cell-renderers/background-cell/index.d.ts +2 -0
- package/types/src/cell-renderers/background-cell/useDirection.d.ts +3 -0
- package/types/src/cell-renderers/button-cell/IconButtonCell.d.ts +6 -0
- package/types/src/cell-renderers/dropdown-cell/DropdownCell.d.ts +2 -0
- package/types/src/cell-renderers/dropdown-cell/index.d.ts +1 -0
- package/types/src/cell-renderers/index.d.ts +6 -0
- package/types/src/cell-renderers/lookup-cell/LookupCell.d.ts +2 -0
- package/types/src/cell-renderers/lookup-cell/index.d.ts +1 -0
- package/types/src/cell-renderers/pct-progress-cell/PctProgressCell.d.ts +2 -0
- package/types/src/cell-renderers/pct-progress-cell/index.d.ts +1 -0
- package/types/src/cell-renderers/progress-cell/ProgressCell.d.ts +1 -0
- package/types/src/cell-renderers/progress-cell/index.d.ts +1 -0
- package/types/src/column-expression-input/ColumnExpressionInput.d.ts +10 -0
- package/types/src/column-expression-input/column-function-descriptors.d.ts +15 -0
- package/types/src/column-expression-input/column-language-parser/ColumnExpressionLanguage.d.ts +2 -0
- package/types/src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.d.ts +57 -0
- package/types/src/column-expression-input/column-language-parser/column-expression-parse-utils.d.ts +5 -0
- package/types/src/column-expression-input/column-language-parser/generated/column-parser.d.ts +2 -0
- package/types/src/column-expression-input/column-language-parser/generated/column-parser.terms.d.ts +1 -0
- package/types/src/column-expression-input/column-language-parser/index.d.ts +3 -0
- package/types/src/column-expression-input/column-language-parser/test.d.mts +1 -0
- package/types/src/column-expression-input/functionDocInfo.d.ts +2 -0
- package/types/src/column-expression-input/highlighting.d.ts +1 -0
- package/types/src/column-expression-input/index.d.ts +4 -0
- package/types/src/column-expression-input/theme.d.ts +1 -0
- package/types/src/column-expression-input/useColumnAutoComplete.d.ts +6 -0
- package/types/src/column-expression-input/useColumnExpressionEditor.d.ts +25 -0
- package/types/src/column-expression-input/useColumnExpressionSuggestionProvider.d.ts +8 -0
- package/types/src/column-formatting-settings/BaseNumericFormattingSettings.d.ts +2 -0
- package/types/src/column-formatting-settings/ColumnFormattingPanel.d.ts +9 -0
- package/types/src/column-formatting-settings/DateTimeFormattingSettings.d.ts +3 -0
- package/types/src/column-formatting-settings/LongTypeFormattingSettings.d.ts +3 -0
- package/types/src/column-formatting-settings/index.d.ts +3 -0
- package/types/src/column-menu/ColumnMenu.d.ts +10 -0
- package/types/src/column-menu/column-action-types.d.ts +11 -0
- package/types/src/column-menu/column-menu-utils.d.ts +19 -0
- package/types/src/column-menu/useColumnActions.d.ts +16 -0
- package/types/src/column-picker/ColumnModel.d.ts +81 -0
- package/types/src/column-picker/ColumnPicker.d.ts +10 -0
- package/types/src/column-picker/ColumnPickerAction.d.ts +5 -0
- package/types/src/column-picker/useColumnPicker.d.ts +16 -0
- package/types/src/column-picker/useTableColumnPicker.d.ts +7 -0
- package/types/src/column-picker/useTableColumnPickerDeprecated.d.ts +14 -0
- package/types/src/column-settings-panel/ColumnNameLabel.d.ts +7 -0
- package/types/src/column-settings-panel/ColumnSettingsPanel.d.ts +5 -0
- package/types/src/column-settings-panel/useColumnSettings.d.ts +30 -0
- package/types/src/csv-export/export-utils.d.ts +42 -0
- package/types/src/csv-export/index.d.ts +2 -0
- package/types/src/csv-export/useCsvExport.d.ts +14 -0
- package/types/src/csv-upload/CsvUpload.d.ts +69 -0
- package/types/src/csv-upload/data-upload-preview/DataUploadPreview.d.ts +10 -0
- package/types/src/csv-upload/data-upload-preview/useDataUploadPreview.d.ts +17 -0
- package/types/src/csv-upload/index.d.ts +7 -0
- package/types/src/csv-upload/parse/csv-constants.d.ts +3 -0
- package/types/src/csv-upload/parse/csv-errors.d.ts +47 -0
- package/types/src/csv-upload/parse/csv-parse.d.ts +11 -0
- package/types/src/csv-upload/parse/csv-schema-validation.d.ts +18 -0
- package/types/src/csv-upload/parse/csv-upload-utils.d.ts +21 -0
- package/types/src/csv-upload/parse/index.d.ts +5 -0
- package/types/src/csv-upload/useCsvUpload.d.ts +43 -0
- package/types/src/datasource-stats/DatasourceStats.d.ts +17 -0
- package/types/src/datasource-stats/useDatasourceStats.d.ts +15 -0
- package/types/src/freeze-control/FreezeControl.d.ts +15 -0
- package/types/src/freeze-control/FrozenBanner.d.ts +6 -0
- package/types/src/freeze-control/freezeControlBadge.d.ts +11 -0
- package/types/src/freeze-control/useFreezeControl.d.ts +10 -0
- package/types/src/index.d.ts +26 -0
- package/types/src/inline-add-row/InlineAddRow.d.ts +3 -0
- package/types/src/inline-add-row/index.d.ts +2 -0
- package/types/src/inline-add-row/useInlineAddRow.d.ts +59 -0
- package/types/src/tabbed-table-config-panel/TabbedTableConfigPanel.d.ts +17 -0
- package/types/src/tabbed-table-config-panel/TabbedTableSettingsAction.d.ts +7 -0
- package/types/src/tabbed-table-config-panel/useTabbedTableConfigPanel.d.ts +13 -0
- package/types/src/table-footer/TableFooter.d.ts +10 -0
- package/types/src/table-provider/TableProvider.d.ts +18 -0
- package/types/src/table-settings-panel/TableSettingsPanel.d.ts +22 -0
- package/types/src/table-settings-panel/useTableSettings.d.ts +14 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Completion } from "@vuu-ui/vuu-codemirror";
|
|
2
|
+
import { FocusEventHandler } from "react";
|
|
3
|
+
import { ColumnExpressionInputProps } from "./ColumnExpressionInput";
|
|
4
|
+
export type ColumnExpressionOperator = "Times" | "Divide" | "Minus" | "Plus";
|
|
5
|
+
export type ColumnExpressionSuggestionType = "column" | "columnValue" | "expression" | "condition-operator" | "operator" | "relational-operator";
|
|
6
|
+
export type ColumnExpressionSuggestionOptions = {
|
|
7
|
+
columnName?: string;
|
|
8
|
+
functionName?: string;
|
|
9
|
+
operator?: ColumnExpressionOperator;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
startsWith?: string;
|
|
12
|
+
selection?: string[];
|
|
13
|
+
};
|
|
14
|
+
export interface IExpressionSuggestionProvider {
|
|
15
|
+
getSuggestions: (valueType: ColumnExpressionSuggestionType, options?: ColumnExpressionSuggestionOptions) => Promise<Completion[]>;
|
|
16
|
+
isPartialMatch: (valueType: ColumnExpressionSuggestionType, columnName?: string, text?: string | undefined) => Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export interface ExpressionSuggestionConsumer {
|
|
19
|
+
suggestionProvider: IExpressionSuggestionProvider;
|
|
20
|
+
}
|
|
21
|
+
export declare const useColumnExpressionEditor: ({ onChange, onSubmitExpression, source, suggestionProvider, }: ColumnExpressionInputProps) => {
|
|
22
|
+
editorRef: import("react").RefObject<HTMLDivElement | null>;
|
|
23
|
+
clearInput: () => void;
|
|
24
|
+
onBlur: FocusEventHandler;
|
|
25
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { IExpressionSuggestionProvider } from "./useColumnExpressionEditor";
|
|
4
|
+
export interface SuggestionProviderHookProps {
|
|
5
|
+
columns: readonly ColumnDescriptor[];
|
|
6
|
+
table: VuuTable;
|
|
7
|
+
}
|
|
8
|
+
export declare const useColumnExpressionSuggestionProvider: ({ columns, table, }: SuggestionProviderHookProps) => IExpressionSuggestionProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnDescriptor, ColumnTypeRendering, FormattingSettingsProps } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { CellRendererDescriptor } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
export interface ColumnFormattingPanelProps extends HTMLAttributes<HTMLDivElement>, FormattingSettingsProps {
|
|
5
|
+
availableRenderers: CellRendererDescriptor[];
|
|
6
|
+
column: ColumnDescriptor;
|
|
7
|
+
onChangeRendering: (renderProps: ColumnTypeRendering) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ColumnFormattingPanel: ({ availableRenderers, className, column, onChangeFormatting, onChangeColumnType, onChangeRendering, ...htmlAttributes }: ColumnFormattingPanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MenuActionHandler } from "@vuu-ui/vuu-context-menu";
|
|
2
|
+
import { ColumnDescriptor, ColumnMenuPermissions } from "@vuu-ui/vuu-table-types";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
import { ColumnMenuActionType } from "./column-menu-utils";
|
|
5
|
+
export interface ColumnMenuProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
column: ColumnDescriptor;
|
|
7
|
+
menuActionHandler?: MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;
|
|
8
|
+
menuPermissions?: ColumnMenuPermissions;
|
|
9
|
+
}
|
|
10
|
+
export declare const ColumnMenu: ({ className, column, menuActionHandler: menuActionHandlerProp, menuPermissions: { allowSort, allowGroup, allowAggregation, allowHide, allowRemove, allowPin, }, }: ColumnMenuProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import { ColumnDescriptor, ColumnDisplayAction } from "@vuu-ui/vuu-table-types";
|
|
3
|
+
export type ColumnDisplayActionHandler = (action: ColumnDisplayAction) => void;
|
|
4
|
+
export type DisplayColumnSettingsAction = {
|
|
5
|
+
type: "column-settings";
|
|
6
|
+
column: ColumnDescriptor;
|
|
7
|
+
/** only for calculated columnn */
|
|
8
|
+
vuuTable?: VuuTable;
|
|
9
|
+
};
|
|
10
|
+
export type DisplaySettingsAction = DisplayColumnSettingsAction;
|
|
11
|
+
export type TableSettingsActionHandler = (action: DisplaySettingsAction) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Menu, MenuItem, MenuItemProps, MenuProps } from "@salt-ds/core";
|
|
2
|
+
import { DataSource } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
4
|
+
import { MouseEventHandler, ReactElement } from "react";
|
|
5
|
+
type MenuElement = ReactElement<MenuProps, typeof Menu>;
|
|
6
|
+
type MenuItemElement = ReactElement<MenuItemProps, typeof MenuItem>;
|
|
7
|
+
type MenuElements = Array<MenuElement | MenuItemElement>;
|
|
8
|
+
export type MenuItemClickHandler = MouseEventHandler<HTMLDivElement>;
|
|
9
|
+
export type DataSourceColumnMenuActionType = "agg-count" | "agg-distinct" | "agg-sum" | "agg-avg" | "agg-high" | "agg-low" | "sort-asc" | "sort-dsc" | "sort-add-asc" | "sort-add-dsc" | "remove-sort" | "group-column" | "remove-group" | "add-to-group" | "remove-from-group" | "remove-column";
|
|
10
|
+
export type ColumnDisplayColumnMenuActionType = "pin-column-left" | "pin-column-right" | "unpin-column" | "hide-column";
|
|
11
|
+
export type ColumnMenuActionType = DataSourceColumnMenuActionType | ColumnDisplayColumnMenuActionType;
|
|
12
|
+
export declare const isColumnMenuActionType: (value?: string) => value is ColumnMenuActionType;
|
|
13
|
+
export declare const getColumnMenuActionType: (target: EventTarget | HTMLElement) => ColumnMenuActionType;
|
|
14
|
+
export declare function buildSortMenu(column: ColumnDescriptor, dataSource: DataSource, menuActionClickHandler: MenuItemClickHandler, isAllowed?: boolean): MenuElement | null;
|
|
15
|
+
export declare function buildGroupMenu(column: ColumnDescriptor, dataSource: DataSource, menuActionClickHandler: MenuItemClickHandler, isAllowed?: boolean): MenuElement | null;
|
|
16
|
+
export declare const buildVisibilityMenuItems: (column: ColumnDescriptor, menuActionClickHandler: MenuItemClickHandler, allowHide?: boolean, allowRemove?: boolean) => MenuElements | null;
|
|
17
|
+
export declare const buildPinMenuItems: (column: ColumnDescriptor, menuActionClickHandler: MenuItemClickHandler, isAllowed?: boolean) => MenuElements;
|
|
18
|
+
export declare function buildAggregationMenuItems(column: ColumnDescriptor, dataSource: DataSource, menuActionClickHandler: MenuItemClickHandler, isAllowed?: boolean): MenuElements | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MenuActionHandler } from "@vuu-ui/vuu-context-menu";
|
|
2
|
+
import { Filter } from "@vuu-ui/vuu-filter-types";
|
|
3
|
+
import { VuuFilter } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { ColumnDescriptor, ColumnDisplayAction, RuntimeColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
5
|
+
import { ColumnMenuActionType } from "./column-menu-utils";
|
|
6
|
+
import { DataSource } from "@vuu-ui/vuu-data-types";
|
|
7
|
+
export interface ContextMenuOptions {
|
|
8
|
+
column?: RuntimeColumnDescriptor;
|
|
9
|
+
filter?: Filter;
|
|
10
|
+
sort?: VuuFilter;
|
|
11
|
+
}
|
|
12
|
+
export interface ContextMenuHookProps {
|
|
13
|
+
dataSource: DataSource;
|
|
14
|
+
onColumnDisplayAction?: (action: ColumnDisplayAction) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useColumnActions: ({ dataSource, onColumnDisplayAction, }: ContextMenuHookProps) => MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { EventEmitter, ValueOf } from "@vuu-ui/vuu-utils";
|
|
3
|
+
export declare const ColumnChangeSource: {
|
|
4
|
+
readonly ColumnPicker: "column-picker";
|
|
5
|
+
readonly ColumnSettings: "column-settings";
|
|
6
|
+
readonly Table: "table";
|
|
7
|
+
};
|
|
8
|
+
export type ColumnChangeSource = ValueOf<typeof ColumnChangeSource>;
|
|
9
|
+
export declare const SelectedColumnChangeType: {
|
|
10
|
+
readonly CalculatedColumnAdded: "calculated-column-added";
|
|
11
|
+
readonly ColumnAdded: "column-added";
|
|
12
|
+
readonly ColumnRemoved: "column-removed";
|
|
13
|
+
readonly ColumnUpdated: "column-updated";
|
|
14
|
+
readonly ColumnsReordered: "columns-reordered";
|
|
15
|
+
};
|
|
16
|
+
export type SelectedColumnChangeType = ValueOf<typeof SelectedColumnChangeType>;
|
|
17
|
+
export interface SelectedColumnChangeColumnAdded {
|
|
18
|
+
type: Extract<SelectedColumnChangeType, "column-added">;
|
|
19
|
+
column: ColumnDescriptor;
|
|
20
|
+
}
|
|
21
|
+
export interface SelectedColumnChangeCalculatedColumnAdded {
|
|
22
|
+
type: Extract<SelectedColumnChangeType, "calculated-column-added">;
|
|
23
|
+
column: ColumnDescriptor;
|
|
24
|
+
}
|
|
25
|
+
export interface SelectedColumnChangeColumnUpdated {
|
|
26
|
+
type: Extract<SelectedColumnChangeType, "column-updated">;
|
|
27
|
+
column: ColumnDescriptor;
|
|
28
|
+
}
|
|
29
|
+
export interface SelectedColumnChangeColumnRemoved {
|
|
30
|
+
type: Extract<SelectedColumnChangeType, "column-removed">;
|
|
31
|
+
column: ColumnDescriptor;
|
|
32
|
+
}
|
|
33
|
+
export interface SelectedColumnChangeColumnsReordered {
|
|
34
|
+
type: Extract<SelectedColumnChangeType, "columns-reordered">;
|
|
35
|
+
}
|
|
36
|
+
export type SelectedColumnChangeDescriptor = SelectedColumnChangeCalculatedColumnAdded | SelectedColumnChangeColumnAdded | SelectedColumnChangeColumnRemoved | SelectedColumnChangeColumnUpdated | SelectedColumnChangeColumnsReordered;
|
|
37
|
+
export declare const isColumnAdded: (change?: SelectedColumnChangeDescriptor) => change is SelectedColumnChangeColumnAdded;
|
|
38
|
+
export declare const isColumnRemoved: (change?: SelectedColumnChangeDescriptor) => change is SelectedColumnChangeColumnRemoved;
|
|
39
|
+
export declare const isColumnUpdated: (change?: SelectedColumnChangeDescriptor) => change is SelectedColumnChangeColumnUpdated;
|
|
40
|
+
export declare const isColumnsReordered: (change?: SelectedColumnChangeDescriptor) => change is SelectedColumnChangeColumnsReordered;
|
|
41
|
+
export type ColumnsChangeHandler = (columns: readonly ColumnDescriptor[], changeSource: ColumnChangeSource, changeDescriptor?: SelectedColumnChangeDescriptor) => void;
|
|
42
|
+
export type ColumnEvents = {
|
|
43
|
+
change: ColumnsChangeHandler;
|
|
44
|
+
render: (o: object) => void;
|
|
45
|
+
};
|
|
46
|
+
export declare class ColumnModel extends EventEmitter<ColumnEvents> {
|
|
47
|
+
#private;
|
|
48
|
+
/**
|
|
49
|
+
* All available columns, including selected columns.
|
|
50
|
+
*/
|
|
51
|
+
allColumns: readonly ColumnDescriptor[];
|
|
52
|
+
constructor(
|
|
53
|
+
/**
|
|
54
|
+
* All available columns, including selected columns.
|
|
55
|
+
*/
|
|
56
|
+
allColumns: readonly ColumnDescriptor[],
|
|
57
|
+
/**
|
|
58
|
+
* Columns already selected and rendered in Table.
|
|
59
|
+
*/
|
|
60
|
+
selectedColumns: readonly ColumnDescriptor[]);
|
|
61
|
+
get availableColumns(): ColumnDescriptor[];
|
|
62
|
+
set searchPattern(pattern: string);
|
|
63
|
+
get searchPattern(): string;
|
|
64
|
+
get selectedColumns(): readonly ColumnDescriptor[];
|
|
65
|
+
setSelectedColumns(selectedColumns: readonly ColumnDescriptor[], source: ColumnChangeSource, changeDescriptor?: SelectedColumnChangeDescriptor): void;
|
|
66
|
+
getColumn(name: string): ColumnDescriptor;
|
|
67
|
+
addItemToSelectedColumns(name: string, source: ColumnChangeSource): void;
|
|
68
|
+
removeItemFromSelectedColumns(name: string, source: ColumnChangeSource): void;
|
|
69
|
+
reorderSelectedColumns(orderedColumnNames: string[], source: ColumnChangeSource): void;
|
|
70
|
+
updateColumn(currentColumn: ColumnDescriptor, newColumn: ColumnDescriptor): void;
|
|
71
|
+
updateColumn(column: ColumnDescriptor): void;
|
|
72
|
+
/**
|
|
73
|
+
* Used when adding a calculated column
|
|
74
|
+
*
|
|
75
|
+
* @param column
|
|
76
|
+
*
|
|
77
|
+
* @param addToSelectedColumns
|
|
78
|
+
*/
|
|
79
|
+
addColumn(column: ColumnDescriptor, addToSelectedColumns?: boolean): void;
|
|
80
|
+
private notifyListeners;
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { HTMLAttributes, MouseEventHandler } from "react";
|
|
3
|
+
import { ListBoxProps } from "@salt-ds/core";
|
|
4
|
+
import { ColumnPickerHookProps } from "./useColumnPicker";
|
|
5
|
+
export declare const classBaseListItem = "vuuColumnPickerListItem";
|
|
6
|
+
export interface ColumnPickerProps extends ColumnPickerHookProps, Pick<ListBoxProps<ColumnDescriptor>, "selected" | "onSelectionChange">, HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
allowCreateCalculatedColumn?: boolean;
|
|
8
|
+
onClickCreateCalculatedColumn?: MouseEventHandler<HTMLButtonElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare const ColumnPicker: import("react").ForwardRefExoticComponent<ColumnPickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IconButtonProps } from "@vuu-ui/vuu-ui-controls";
|
|
2
|
+
import { ColumnPickerHookProps } from "./useColumnPicker";
|
|
3
|
+
export interface ColumnPickerActionProps extends Partial<IconButtonProps>, ColumnPickerHookProps {
|
|
4
|
+
}
|
|
5
|
+
export declare const ColumnPickerAction: ({ appearance, columnModel, icon, sentiment, ...IconButtonProps }: ColumnPickerActionProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColumnDescriptor, TableSelectionModel } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { FormEventHandler, MouseEventHandler } from "react";
|
|
3
|
+
import { ColumnModel, SelectedColumnChangeType } from "./ColumnModel";
|
|
4
|
+
export type ColumnSelectionModel = Extract<TableSelectionModel, "none" | "single">;
|
|
5
|
+
export type SelectedColumnsChangeHandler = (columns: ColumnDescriptor[], changeType: SelectedColumnChangeType) => void;
|
|
6
|
+
export interface ColumnPickerHookProps {
|
|
7
|
+
columnModel: ColumnModel;
|
|
8
|
+
}
|
|
9
|
+
export declare const useColumnPicker: ({ columnModel: model, }: ColumnPickerHookProps) => {
|
|
10
|
+
availableColumns: ColumnDescriptor[];
|
|
11
|
+
onAddItemToSelectedList: MouseEventHandler<HTMLButtonElement>;
|
|
12
|
+
onRemoveItemFromSelectedList: MouseEventHandler<HTMLButtonElement>;
|
|
13
|
+
onChangeSearchInput: FormEventHandler;
|
|
14
|
+
searchText: string;
|
|
15
|
+
selectedColumns: readonly ColumnDescriptor[];
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnModel } from "./ColumnModel";
|
|
2
|
+
export interface TableColumnPickerHookProps {
|
|
3
|
+
columnModel: ColumnModel;
|
|
4
|
+
}
|
|
5
|
+
export declare const useTableColumnPicker: ({ columnModel, }: TableColumnPickerHookProps) => {
|
|
6
|
+
showColumnPicker: (title?: string) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DataSource } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { ColumnDescriptor, TableConfigChangeHandler } from "@vuu-ui/vuu-table-types";
|
|
3
|
+
export type TableColumnChangeHandler = (columns: ColumnDescriptor[], change: unknown) => void;
|
|
4
|
+
export interface ColumnPickerHookProps {
|
|
5
|
+
readonly availableColumns: ColumnDescriptor[];
|
|
6
|
+
dataSource: DataSource;
|
|
7
|
+
readonly selectedColumns: ColumnDescriptor[];
|
|
8
|
+
onTableColumnChange?: TableColumnChangeHandler;
|
|
9
|
+
}
|
|
10
|
+
export declare const useTableColumnPickerDeprecated: ({ availableColumns, dataSource, onTableColumnChange, selectedColumns: initialSelectedColumns, }: ColumnPickerHookProps) => {
|
|
11
|
+
onTableConfigChange: TableConfigChangeHandler;
|
|
12
|
+
showColumnPicker: (title?: string) => void;
|
|
13
|
+
selectedColumns: ColumnDescriptor[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { MouseEventHandler } from "react";
|
|
3
|
+
export interface ColumnNameLabelProps {
|
|
4
|
+
column: ColumnDescriptor;
|
|
5
|
+
onClick?: MouseEventHandler;
|
|
6
|
+
}
|
|
7
|
+
export declare const ColumnNameLabel: ({ column, onClick }: ColumnNameLabelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ColumnSettingsProps } from "./useColumnSettings";
|
|
2
|
+
export interface ColumnSettinsPanelProps extends ColumnSettingsProps {
|
|
3
|
+
onClickEditCalculatedColumn?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const ColumnSettingsPanel: ({ column: columnProp, columnModel, onClickEditCalculatedColumn, onConfigChange, }: ColumnSettinsPanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ColumnDescriptor, TableConfig, ColumnTypeFormatting } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
import { CellRendererDescriptor, ColumnRenderPropsChangeHandler } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { VuuColumnDataType, VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { FormEventHandler } from "react";
|
|
5
|
+
import { DataValueTypeSimple } from "@vuu-ui/vuu-data-types";
|
|
6
|
+
import { ColumnModel } from "../column-picker/ColumnModel";
|
|
7
|
+
/**
|
|
8
|
+
* Describes the props for a Column Configuration Editor, for which
|
|
9
|
+
* an implementation is provided in vuu-table-extras
|
|
10
|
+
*/
|
|
11
|
+
export interface ColumnSettingsProps {
|
|
12
|
+
column: ColumnDescriptor;
|
|
13
|
+
columnModel: ColumnModel;
|
|
14
|
+
onConfigChange?: (config: TableConfig) => void;
|
|
15
|
+
vuuTable?: VuuTable;
|
|
16
|
+
}
|
|
17
|
+
export declare const useColumnSettings: ({ column: columnProp, columnModel, }: Omit<ColumnSettingsProps, "vuuTable">) => {
|
|
18
|
+
availableRenderers: CellRendererDescriptor[];
|
|
19
|
+
column: ColumnDescriptor;
|
|
20
|
+
navigateNextColumn: () => void;
|
|
21
|
+
navigatePrevColumn: () => void;
|
|
22
|
+
onChange: FormEventHandler;
|
|
23
|
+
onChangeCalculatedColumnName: (name: string) => void;
|
|
24
|
+
onChangeFormatting: (formatting: ColumnTypeFormatting) => void;
|
|
25
|
+
onChangeRendering: ColumnRenderPropsChangeHandler;
|
|
26
|
+
onChangeServerDataType: (serverDataType: VuuColumnDataType) => void;
|
|
27
|
+
onChangeToggleButton: FormEventHandler;
|
|
28
|
+
onChangeType: (type: DataValueTypeSimple) => void;
|
|
29
|
+
onInputCommit: () => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CopyOption, DataSource, SessionDataSourceOverrides } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
export type ExportColumnDescriptor<TName extends string = string> = {
|
|
3
|
+
name: TName;
|
|
4
|
+
/** Override the column name used as the CSV header label. */
|
|
5
|
+
label?: string;
|
|
6
|
+
exportFormatter?: (value: unknown) => string;
|
|
7
|
+
};
|
|
8
|
+
export interface ExportToCsvOptions<TName extends string = string> {
|
|
9
|
+
filename?: string;
|
|
10
|
+
copyOption?: CopyOption;
|
|
11
|
+
excludeColumns?: string[];
|
|
12
|
+
maxRows?: number;
|
|
13
|
+
columnDescriptors?: ExportColumnDescriptor<TName>[];
|
|
14
|
+
overrides?: SessionDataSourceOverrides;
|
|
15
|
+
/** Timeout in milliseconds before the export times out. Default: 30_000ms (0 to disable). */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
onSuccess?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ExportCsvTemplateOptions {
|
|
21
|
+
filename?: string;
|
|
22
|
+
excludeColumns?: string[];
|
|
23
|
+
columns?: string[];
|
|
24
|
+
overrides?: SessionDataSourceOverrides;
|
|
25
|
+
/** Timeout in milliseconds before template generation times out. Default: 10_000ms (0 to disable). */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
onError?: (error: Error) => void;
|
|
28
|
+
onSuccess?: () => void;
|
|
29
|
+
}
|
|
30
|
+
/** Downloads a single-row CSV containing only the column headers, for use as an import template. */
|
|
31
|
+
export declare const exportCsvTemplate: (dataSource: DataSource, options?: ExportCsvTemplateOptions) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Subscribes to `dataSource` (creating an export session data source if a view data source is passed),
|
|
34
|
+
* collects all rows in memory in index order, serialises them to CSV (excluding internal session columns),
|
|
35
|
+
* then triggers a browser download. The session data source is unsubscribed automatically once the download
|
|
36
|
+
* is initiated.
|
|
37
|
+
*/
|
|
38
|
+
export declare const exportSessionTableToCsv: <TName extends string = string>(dataSource: DataSource, options?: ExportToCsvOptions<TName>) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates an export session table from `dataSource`, collects all rows in memory, then triggers a CSV download.
|
|
41
|
+
*/
|
|
42
|
+
export declare const exportToCsv: <TName extends string = string>(dataSource: DataSource, options?: ExportToCsvOptions<TName>) => Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DataSource } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { type ExportCsvTemplateOptions, type ExportToCsvOptions } from "./export-utils";
|
|
3
|
+
export interface UseCsvExportProps {
|
|
4
|
+
dataSource?: DataSource;
|
|
5
|
+
onError?: (error: Error) => void;
|
|
6
|
+
onSuccess?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface UseCsvExportResult {
|
|
9
|
+
isExporting: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
exportCsv: <TName extends string = string>(options?: ExportToCsvOptions<TName>, overrideDataSource?: DataSource) => Promise<void>;
|
|
12
|
+
exportTemplate: (options?: ExportCsvTemplateOptions, overrideDataSource?: DataSource) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function useCsvExport(propsOrDataSource?: DataSource | UseCsvExportProps): UseCsvExportResult;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { RowDefaultDataItemValues, EditSession } from "@vuu-ui/vuu-data-editing";
|
|
3
|
+
import type { CsvParseError, CsvParseOptions } from "./parse/csv-parse";
|
|
4
|
+
import type { CsvValidationStructuredError, CsvColumnValidator } from "./parse/csv-schema-validation";
|
|
5
|
+
import type { DataSource, TableSchema } from "@vuu-ui/vuu-data-types";
|
|
6
|
+
import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
7
|
+
import type { CsvUploadTableData } from "./parse/csv-upload-utils";
|
|
8
|
+
export type CsvUploadImportedResult = {
|
|
9
|
+
tableData: CsvUploadTableData;
|
|
10
|
+
};
|
|
11
|
+
export type CsvUploadPreviewResult = {
|
|
12
|
+
dataSource: DataSource;
|
|
13
|
+
editSession: EditSession;
|
|
14
|
+
tableData: CsvUploadTableData;
|
|
15
|
+
};
|
|
16
|
+
export type CsvUploadErrors = {
|
|
17
|
+
schemaError?: CsvUploadError;
|
|
18
|
+
validationError?: CsvUploadError;
|
|
19
|
+
importError?: CsvUploadError;
|
|
20
|
+
};
|
|
21
|
+
export type CsvUploadError = {
|
|
22
|
+
message: string;
|
|
23
|
+
parseError?: CsvParseError;
|
|
24
|
+
validationError?: CsvValidationStructuredError;
|
|
25
|
+
source: "schema" | "validation" | "import";
|
|
26
|
+
};
|
|
27
|
+
export type CsvUploadErrorResult = {
|
|
28
|
+
errors: CsvUploadErrors;
|
|
29
|
+
};
|
|
30
|
+
export type CsvUploadSessionTable = VuuTable;
|
|
31
|
+
export type CsvUploadSessionEndReason = "saved" | "discarded" | "failed";
|
|
32
|
+
export type CsvUploadSessionEndResult = {
|
|
33
|
+
reason: CsvUploadSessionEndReason;
|
|
34
|
+
sessionTable?: CsvUploadSessionTable;
|
|
35
|
+
};
|
|
36
|
+
export type CsvUploadPhase = "idle" | "processing" | "preview-ready" | "importing" | "imported" | "failed";
|
|
37
|
+
export interface CsvUploadProps {
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
dataSource: DataSource;
|
|
40
|
+
embedded?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Schema of the import table, where it differs from the target table. Used to validate
|
|
43
|
+
* the CSV and to determine the session datasource columns. If omitted and importTable is
|
|
44
|
+
* provided, the schema is fetched via getTableSchema. Pass a stable reference.
|
|
45
|
+
*/
|
|
46
|
+
importSchema?: TableSchema;
|
|
47
|
+
/** Expected import table, used to validate the session table returned by the server. */
|
|
48
|
+
importTable?: VuuTable;
|
|
49
|
+
onImportSessionStarted?: (dataSource: DataSource) => void;
|
|
50
|
+
onImportSessionEnded?: (result: CsvUploadSessionEndResult) => void;
|
|
51
|
+
onError?: (result: CsvUploadErrorResult | undefined) => void;
|
|
52
|
+
onImported?: (result: CsvUploadImportedResult) => void;
|
|
53
|
+
onPreview?: (result: CsvUploadPreviewResult) => void;
|
|
54
|
+
onProcessingStarted?: () => void;
|
|
55
|
+
dialogTitle?: string;
|
|
56
|
+
maxRows?: number;
|
|
57
|
+
onCancel?: () => void;
|
|
58
|
+
onClose?: () => void;
|
|
59
|
+
open?: boolean;
|
|
60
|
+
parseOptions?: CsvParseOptions;
|
|
61
|
+
importMode?: "direct" | "preview";
|
|
62
|
+
rowDefaults?: RowDefaultDataItemValues;
|
|
63
|
+
validators?: Record<string, CsvColumnValidator>;
|
|
64
|
+
/**
|
|
65
|
+
* Custom renderer for the error panel.
|
|
66
|
+
*/
|
|
67
|
+
renderError?: (error: CsvUploadErrorResult) => ReactNode;
|
|
68
|
+
}
|
|
69
|
+
export declare const CsvUpload: (props: CsvUploadProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { type EditSession } from "@vuu-ui/vuu-data-editing";
|
|
3
|
+
import type { HTMLAttributes } from "react";
|
|
4
|
+
export interface DataUploadPreviewProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
|
|
5
|
+
editSession: EditSession;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
saveLabel?: string;
|
|
8
|
+
tableSchema: TableSchema;
|
|
9
|
+
}
|
|
10
|
+
export declare const DataUploadPreview: ({ className, editSession, onClose, saveLabel, tableSchema, ...htmlAttributes }: DataUploadPreviewProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DataSource } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { EditSession } from "@vuu-ui/vuu-data-editing";
|
|
3
|
+
export interface UseDataUploadPreviewProps {
|
|
4
|
+
dataSource: DataSource;
|
|
5
|
+
editSession: EditSession;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const getSessionDataSource: (editSession: EditSession) => DataSource;
|
|
9
|
+
export declare const useDataUploadPreview: ({ dataSource, editSession, onClose, }: UseDataUploadPreviewProps) => {
|
|
10
|
+
canCancel: boolean;
|
|
11
|
+
canSave: boolean;
|
|
12
|
+
hasSelection: boolean;
|
|
13
|
+
onCancel: () => Promise<void>;
|
|
14
|
+
onDelete: () => Promise<import("@vuu-ui/vuu-protocol-types").RpcResult>;
|
|
15
|
+
onSave: (force?: boolean) => Promise<void>;
|
|
16
|
+
sessionError: string | undefined;
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
export { useCsvUpload, type CsvUploadHookProps, type UseCsvUploadReturn, } from "./useCsvUpload";
|
|
3
|
+
export { DataUploadPreview, type DataUploadPreviewProps, } from "./data-upload-preview/DataUploadPreview";
|
|
4
|
+
export { validateCsvAgainstSchema, type CsvColumnValidator, type CsvValidationOptions, type CsvValidationResult, } from "./parse/csv-schema-validation";
|
|
5
|
+
export { parseCsv, type CsvParseOptions, type CsvParseResult, } from "./parse/csv-parse";
|
|
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
|
+
export { CSV_FIRST_DATA_ROW_NUMBER, CSV_HEADER_ROW_NUMBER, } from "./parse/csv-constants";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare enum CsvParseErrorEnum {
|
|
2
|
+
EMPTY_FILE = "EMPTY_FILE",
|
|
3
|
+
INVALID_SEPARATOR = "INVALID_SEPARATOR",
|
|
4
|
+
INVALID_FORMAT = "INVALID_FORMAT",
|
|
5
|
+
UNQUOTED_VALUE = "UNQUOTED_VALUE",
|
|
6
|
+
EMPTY_HEADER_COLUMN = "EMPTY_HEADER_COLUMN",
|
|
7
|
+
DUPLICATE_HEADER_COLUMN = "DUPLICATE_HEADER_COLUMN",
|
|
8
|
+
ROW_COLUMN_COUNT_MISMATCH = "ROW_COLUMN_COUNT_MISMATCH"
|
|
9
|
+
}
|
|
10
|
+
export declare enum CsvValidationErrorEnum {
|
|
11
|
+
MISSING_KEY_COLUMN = "MISSING_KEY_COLUMN",
|
|
12
|
+
UNKNOWN_COLUMN = "UNKNOWN_COLUMN",
|
|
13
|
+
MAX_ROWS_EXCEEDED = "MAX_ROWS_EXCEEDED",
|
|
14
|
+
EMPTY_NON_STRING_VALUE = "EMPTY_NON_STRING_VALUE",
|
|
15
|
+
TYPE_MISMATCH = "TYPE_MISMATCH",
|
|
16
|
+
CUSTOM_VALIDATION = "CUSTOM_VALIDATION"
|
|
17
|
+
}
|
|
18
|
+
export type CsvErrorMap<TError extends string> = {
|
|
19
|
+
rowErrors: Record<number, Record<string, TError[]>>;
|
|
20
|
+
fileErrors: Record<string, TError[]>;
|
|
21
|
+
};
|
|
22
|
+
export type CsvStructuredError<TError extends string> = {
|
|
23
|
+
rowNum: number;
|
|
24
|
+
column: string;
|
|
25
|
+
value: string;
|
|
26
|
+
message: string;
|
|
27
|
+
errorEnum: TError;
|
|
28
|
+
};
|
|
29
|
+
export type CsvError<TError extends string> = {
|
|
30
|
+
errorMap: CsvErrorMap<TError>;
|
|
31
|
+
errors: CsvStructuredError<TError>[];
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
export type CsvErrorState<TError extends string> = {
|
|
35
|
+
errorMap: CsvErrorMap<TError>;
|
|
36
|
+
errors: CsvStructuredError<TError>[];
|
|
37
|
+
};
|
|
38
|
+
export declare const createCsvErrorState: <TError extends string>() => CsvErrorState<TError>;
|
|
39
|
+
export declare const addCsvFileError: <TError extends string>(state: CsvErrorState<TError>, columnName: string, error: TError, message: string, value?: string) => void;
|
|
40
|
+
export declare const addCsvRowError: <TError extends string>(state: CsvErrorState<TError>, rowNum: number, columnName: string, error: TError, message: string, value?: string) => void;
|
|
41
|
+
export declare const hasCsvErrors: <TError extends string>(errorMap: CsvErrorMap<TError>) => boolean;
|
|
42
|
+
export type CsvParseErrorMap = CsvErrorMap<CsvParseErrorEnum>;
|
|
43
|
+
export type CsvParseError = CsvError<CsvParseErrorEnum>;
|
|
44
|
+
export type CsvValidationErrorType = CsvValidationErrorEnum | CsvParseErrorEnum;
|
|
45
|
+
export type CsvValidationErrorMap = CsvErrorMap<CsvValidationErrorEnum>;
|
|
46
|
+
export type CsvValidationStructuredError = CsvError<CsvValidationErrorType>;
|
|
47
|
+
export type CsvValidationError = CsvStructuredError<CsvValidationErrorType>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CsvParseError } from "./csv-errors";
|
|
2
|
+
export { CsvParseErrorEnum, type CsvError, type CsvErrorMap, type CsvStructuredError, type CsvParseError, type CsvParseErrorMap, } from "./csv-errors";
|
|
3
|
+
export type CsvParseResult = {
|
|
4
|
+
error?: CsvParseError;
|
|
5
|
+
header: string[];
|
|
6
|
+
rows: string[][];
|
|
7
|
+
};
|
|
8
|
+
export type CsvParseOptions = {
|
|
9
|
+
requireQuotedValues?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const parseCsv: (csvText: string, options?: CsvParseOptions) => CsvParseResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import type { CsvValidationError, CsvValidationErrorMap, CsvParseError } from "./csv-errors";
|
|
4
|
+
import type { CsvParseResult } from "./csv-parse";
|
|
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;
|
|
7
|
+
export type CsvValidationResult = {
|
|
8
|
+
columns: string[];
|
|
9
|
+
errorMap: CsvValidationErrorMap;
|
|
10
|
+
errors: CsvValidationError[];
|
|
11
|
+
parseRowError?: CsvParseError;
|
|
12
|
+
rows: Record<string, VuuRowDataItemType>[];
|
|
13
|
+
};
|
|
14
|
+
export type CsvValidationOptions = {
|
|
15
|
+
maxRows?: number;
|
|
16
|
+
validators?: Record<string, CsvColumnValidator>;
|
|
17
|
+
};
|
|
18
|
+
export declare const validateCsvAgainstSchema: (parsed: CsvParseResult, tableSchema: TableSchema, options?: CsvValidationOptions) => CsvValidationResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import type { CsvUploadError } from "../CsvUpload";
|
|
3
|
+
import type { CsvParseError } from "./csv-parse";
|
|
4
|
+
import type { CsvValidationError, CsvValidationResult } from "./csv-schema-validation";
|
|
5
|
+
export type CsvUploadTableData = {
|
|
6
|
+
columns: string[];
|
|
7
|
+
rows: VuuRowDataItemType[][];
|
|
8
|
+
};
|
|
9
|
+
export declare const toErrorMessage: (error: unknown) => string;
|
|
10
|
+
export declare const isCsvParseError: (value: unknown) => value is CsvParseError;
|
|
11
|
+
export declare const hasFileParseErrors: (parseError: CsvParseError) => boolean;
|
|
12
|
+
export declare const createUploadError: (source: CsvUploadError["source"], message: string, parseError?: CsvParseError, validationError?: CsvUploadError["validationError"]) => CsvUploadError;
|
|
13
|
+
export declare const mergeValidationWithParseErrors: (schemaValidation: CsvValidationResult, parseError: CsvParseError | undefined) => CsvValidationResult;
|
|
14
|
+
export declare const buildRowErrorMessage: (prefix: string, rowErrors: string[]) => string;
|
|
15
|
+
export declare const toValidationErrorsFromParseRowErrors: (parseError: CsvParseError) => CsvValidationError[];
|
|
16
|
+
export declare const normalizeTableData: (value: unknown, fallback: CsvUploadTableData) => CsvUploadTableData;
|
|
17
|
+
export type RpcBatchResult = {
|
|
18
|
+
errors: string[];
|
|
19
|
+
results: unknown[];
|
|
20
|
+
};
|
|
21
|
+
export declare const executeBatchRpcCalls: <T>(items: T[], executor: (item: T) => Promise<unknown>, errorFormatter: (item: T, error: string) => string) => Promise<RpcBatchResult>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CSV_FIRST_DATA_ROW_NUMBER, CSV_HEADER_ROW_NUMBER, } from "./csv-constants";
|
|
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
|
+
export { parseCsv, type CsvParseOptions, type CsvParseResult, } from "./csv-parse";
|
|
4
|
+
export { validateCsvAgainstSchema, type CsvColumnValidator, type CsvValidationOptions, type CsvValidationResult, } from "./csv-schema-validation";
|
|
5
|
+
export { buildRowErrorMessage, executeBatchRpcCalls, hasFileParseErrors, isCsvParseError, mergeValidationWithParseErrors, normalizeTableData, toErrorMessage, toValidationErrorsFromParseRowErrors, type CsvUploadTableData, type RpcBatchResult, } from "./csv-upload-utils";
|