dromo-uploader-react 1.3.8 → 1.4.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/dist/index.d.ts +2 -3
- package/dist/index.js +52 -105
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +49 -107
- package/dist/index.modern.js.map +1 -1
- package/package.json +5 -2
- package/dist/interfaces.d.ts +0 -345
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata,
|
|
2
|
+
import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions } from 'dromo-uploader-js';
|
|
3
3
|
declare type VerboseRequiredProps = {
|
|
4
4
|
user: IUser;
|
|
5
5
|
fields: IDeveloperField[];
|
|
@@ -26,8 +26,7 @@ declare type CommonOptionalProps = {
|
|
|
26
26
|
declare type Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps;
|
|
27
27
|
export default class DromoReactUploader extends React.Component<Props> {
|
|
28
28
|
dromo: any;
|
|
29
|
-
componentDidMount(): void;
|
|
30
29
|
open: () => void;
|
|
31
30
|
render(): JSX.Element;
|
|
32
31
|
}
|
|
33
|
-
export { IDeveloperField, IDeveloperSettings, IUser, IColumnHookInput, IColumnHookOutput, IColumnHook, IRowHookInput, IRowHookOutput, IRowHook, IValidatorField, IDeveloperStyleOverrides, IResultMetadata,
|
|
32
|
+
export { IDeveloperField, IDeveloperSettings, IUser, IColumnHookInput, IColumnHookOutput, IColumnHook, IRowHookInput, IRowHookOutput, IRowHook, IValidatorField, IDeveloperStyleOverrides, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
2
|
+
|
|
1
3
|
var React = require('react');
|
|
4
|
+
var DromoUploader = _interopDefault(require('dromo-uploader-js'));
|
|
2
5
|
|
|
3
6
|
function _inheritsLoose(subClass, superClass) {
|
|
4
7
|
subClass.prototype = Object.create(superClass.prototype);
|
|
@@ -6,31 +9,6 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
6
9
|
subClass.__proto__ = superClass;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
|
-
(function (EStepHook) {
|
|
10
|
-
EStepHook["UPLOAD_STEP"] = "UPLOAD_STEP";
|
|
11
|
-
EStepHook["REVIEW_STEP"] = "REVIEW_STEP";
|
|
12
|
-
EStepHook["REVIEW_STEP_POST_HOOKS"] = "REVIEW_STEP_POST_HOOKS";
|
|
13
|
-
})(exports.EStepHook || (exports.EStepHook = {}));
|
|
14
|
-
|
|
15
|
-
var EInvalidDataBehavior;
|
|
16
|
-
|
|
17
|
-
(function (EInvalidDataBehavior) {
|
|
18
|
-
EInvalidDataBehavior["BLOCK_SUBMIT"] = "BLOCK_SUBMIT";
|
|
19
|
-
EInvalidDataBehavior["REMOVE_INVALID_ROWS"] = "REMOVE_INVALID_ROWS";
|
|
20
|
-
EInvalidDataBehavior["INCLUDE_INVALID_ROWS"] = "INCLUDE_INVALID_ROWS";
|
|
21
|
-
})(EInvalidDataBehavior || (EInvalidDataBehavior = {}));
|
|
22
|
-
|
|
23
|
-
var EBackendSyncMode;
|
|
24
|
-
|
|
25
|
-
(function (EBackendSyncMode) {
|
|
26
|
-
EBackendSyncMode["DISABLED"] = "DISABLED";
|
|
27
|
-
EBackendSyncMode["MAPPINGS_ONLY"] = "MAPPINGS_ONLY";
|
|
28
|
-
EBackendSyncMode["FULL_DATA"] = "FULL_DATA";
|
|
29
|
-
})(EBackendSyncMode || (EBackendSyncMode = {}));
|
|
30
|
-
|
|
31
|
-
var SCRIPT_SRC = 'https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js';
|
|
32
|
-
var SCRIPT_LOADED_EVENT = 'DROMO_SCRIPT_LOADED';
|
|
33
|
-
|
|
34
12
|
var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
35
13
|
_inheritsLoose(DromoReactUploader, _React$Component);
|
|
36
14
|
|
|
@@ -40,69 +18,67 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
40
18
|
_this = _React$Component.apply(this, arguments) || this;
|
|
41
19
|
|
|
42
20
|
_this.open = function () {
|
|
43
|
-
if ('
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.schemaName);
|
|
48
|
-
|
|
49
|
-
if ('developmentMode' in _this.props) {
|
|
50
|
-
_this.dromo.setDevelopmentMode(_this.props.developmentMode);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if ('user' in _this.props) {
|
|
54
|
-
_this.dromo.setUser(_this.props.user);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if ('headerRowOverride' in _this.props) {
|
|
58
|
-
_this.dromo.setHeaderRowOverride(_this.props.headerRowOverride);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
21
|
+
if ('fields' in _this.props && 'settings' in _this.props) {
|
|
22
|
+
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
|
|
23
|
+
} else if ('schemaName' in _this.props) {
|
|
24
|
+
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.schemaName);
|
|
61
25
|
|
|
62
|
-
if (_this.props
|
|
63
|
-
_this.props.
|
|
64
|
-
return _this.dromo.registerRowHook(hook);
|
|
65
|
-
});
|
|
26
|
+
if ('developmentMode' in _this.props) {
|
|
27
|
+
_this.dromo.setDevelopmentMode(_this.props.developmentMode);
|
|
66
28
|
}
|
|
67
29
|
|
|
68
|
-
if (_this.props
|
|
69
|
-
_this.props.
|
|
70
|
-
return _this.dromo.registerBulkRowHook(hook);
|
|
71
|
-
});
|
|
30
|
+
if ('user' in _this.props) {
|
|
31
|
+
_this.dromo.setUser(_this.props.user);
|
|
72
32
|
}
|
|
73
33
|
|
|
74
|
-
if (_this.props
|
|
75
|
-
_this.props.
|
|
76
|
-
_this.dromo.registerColumnHook(hook.fieldName, hook.callback);
|
|
77
|
-
});
|
|
34
|
+
if ('headerRowOverride' in _this.props) {
|
|
35
|
+
_this.dromo.setHeaderRowOverride(_this.props.headerRowOverride);
|
|
78
36
|
}
|
|
37
|
+
}
|
|
79
38
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
39
|
+
if (_this.props.rowHooks) {
|
|
40
|
+
_this.props.rowHooks.forEach(function (hook) {
|
|
41
|
+
return _this.dromo.registerRowHook(hook);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
85
44
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
45
|
+
if (_this.props.bulkRowHooks) {
|
|
46
|
+
_this.props.bulkRowHooks.forEach(function (hook) {
|
|
47
|
+
return _this.dromo.registerBulkRowHook(hook);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
89
50
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
51
|
+
if (_this.props.columnHooks) {
|
|
52
|
+
_this.props.columnHooks.forEach(function (hook) {
|
|
53
|
+
_this.dromo.registerColumnHook(hook.fieldName, hook.callback);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
93
56
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
57
|
+
if (_this.props.rowDeleteHooks) {
|
|
58
|
+
_this.props.rowDeleteHooks.forEach(function (hook) {
|
|
59
|
+
return _this.dromo.registerRowDeleteHook(hook);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
97
62
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
63
|
+
if (_this.props.beforeFinish) {
|
|
64
|
+
_this.dromo.beforeFinish(_this.props.beforeFinish);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (_this.props.onResults) {
|
|
68
|
+
_this.dromo.onResults(_this.props.onResults);
|
|
69
|
+
}
|
|
103
70
|
|
|
104
|
-
|
|
71
|
+
if (_this.props.onCancel) {
|
|
72
|
+
_this.dromo.onCancel(_this.props.onCancel);
|
|
105
73
|
}
|
|
74
|
+
|
|
75
|
+
if (_this.props.stepHooks) {
|
|
76
|
+
_this.props.stepHooks.forEach(function (hook) {
|
|
77
|
+
_this.dromo.registerStepHook(hook.type, hook.callback);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_this.dromo.open();
|
|
106
82
|
};
|
|
107
83
|
|
|
108
84
|
return _this;
|
|
@@ -110,35 +86,6 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
110
86
|
|
|
111
87
|
var _proto = DromoReactUploader.prototype;
|
|
112
88
|
|
|
113
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
114
|
-
var loadingScript = Array.from(document.getElementsByTagName('script')).find(function (s) {
|
|
115
|
-
return s.src === SCRIPT_SRC;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (!loadingScript) {
|
|
119
|
-
var script = document.createElement('script');
|
|
120
|
-
script.src = SCRIPT_SRC;
|
|
121
|
-
script.async = true;
|
|
122
|
-
|
|
123
|
-
script.onload = function () {
|
|
124
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
125
|
-
window.dispatchEvent(event);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
document.body.appendChild(script);
|
|
129
|
-
} else {
|
|
130
|
-
if ('DromoUploader' in window) {
|
|
131
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
132
|
-
window.dispatchEvent(event);
|
|
133
|
-
} else {
|
|
134
|
-
loadingScript.onload = function () {
|
|
135
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
136
|
-
window.dispatchEvent(event);
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
89
|
_proto.render = function render() {
|
|
143
90
|
return React.createElement("button", {
|
|
144
91
|
style: this.props.style,
|
|
@@ -150,5 +97,5 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
150
97
|
return DromoReactUploader;
|
|
151
98
|
}(React.Component);
|
|
152
99
|
|
|
153
|
-
exports
|
|
100
|
+
module.exports = DromoReactUploader;
|
|
154
101
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["type MaybeAsync<T> = T | Promise<T>;\n\nexport interface IConnectionMethods {\n init: (\n licenseKey: string,\n fields: IDeveloperField[],\n settings: IDeveloperSettings,\n user: IUser,\n appHost?: string\n ) => void;\n initFromSavedSchema: (\n licenseKey: string,\n schemaName: string,\n appHost: string,\n options?: IImporterOptions\n ) => void;\n setHeaderRowOverride: (headerRowOverride: number | null) => void;\n setNumRegisteredColHooks: (numColHooks: number) => void;\n setNumRegisteredRowHooks: (numRowHooks: number) => void;\n setNumRegisteredRowDeleteHooks: (numRowDeleteHooks: number) => void;\n setUser: (user: IUser) => void;\n addField: (field: IDeveloperField, position?: IPositionSpec) => void;\n removeField: (fieldKey: string) => void;\n updateInfoMessages: (messages: IMessagesForCell[]) => void;\n setDevelopmentMode: (developmentMode: boolean) => void;\n}\n\nexport type IPublicConnectionMethods = Pick<\n IConnectionMethods,\n | \"addField\"\n | \"updateInfoMessages\"\n | \"setHeaderRowOverride\"\n | \"setUser\"\n | \"removeField\"\n | \"setDevelopmentMode\"\n>;\n\nexport type IDeveloperFieldType =\n | \"string\"\n | \"checkbox\"\n | \"select\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"time\"\n | \"email\";\n\nexport interface IAbstractDeveloperFieldUntyped {\n label: string;\n key: string;\n type?: never;\n description?: string;\n alternateMatches?: string[];\n validators?: IValidatorField[];\n invalidValueMessage?: string;\n readOnly?: boolean;\n hidden?: boolean;\n requireMapping?: boolean;\n}\n\nexport interface IAbstractDeveloperField<\n FieldType extends IDeveloperFieldType,\n FieldOpts = Record<string, never>\n> extends Omit<IAbstractDeveloperFieldUntyped, \"type\"> {\n type: FieldType | [FieldType, FieldOpts];\n}\n\ntype IStringField =\n | IAbstractDeveloperFieldUntyped\n | IAbstractDeveloperField<\"string\">;\n\ntype ICheckboxField = IAbstractDeveloperField<\"checkbox\">;\n\nexport interface IDeveloperSelectOption {\n label: string;\n value: string;\n alternateMatches?: string[];\n}\n\nexport interface ISelectField extends IAbstractDeveloperField<\"select\"> {\n selectOptions: IDeveloperSelectOption[];\n}\n\ntype INumberPreset =\n | \"default\"\n | \"percent\"\n | \"percent_0\"\n | \"percent_1\"\n | \"percent_2\"\n | \"percent_3\"\n | \"percent_4\"\n | \"decimal_0\"\n | \"decimal_1\"\n | \"decimal_2\"\n | \"decimal_3\"\n | \"decimal_4\"\n | \"integer\"\n | \"plain\"\n | \"usd\"\n | \"usd_accounting\"\n | \"eur\"\n | \"gbp\";\n\n// copy-pasta'd from numbro.Format\ninterface INumbroFormat {\n output?: \"currency\" | \"percent\" | \"byte\" | \"time\" | \"ordinal\" | \"number\";\n base?: \"decimal\" | \"binary\" | \"general\";\n characteristic?: number;\n prefix?: string;\n postfix?: string;\n forceAverage?: \"trillion\" | \"billion\" | \"million\" | \"thousand\";\n average?: boolean;\n currencyPosition?: \"prefix\" | \"infix\" | \"postfix\";\n currencySymbol?: string;\n totalLength?: number;\n mantissa?: number;\n optionalMantissa?: boolean;\n trimMantissa?: boolean;\n optionalCharacteristic?: boolean;\n thousandSeparated?: boolean;\n abbreviations?: {\n thousand?: string;\n million?: string;\n billion?: string;\n trillion?: string;\n };\n negative?: \"sign\" | \"parenthesis\";\n forceSign?: boolean;\n spaceSeparated?: boolean;\n spaceSeparatedCurrency?: boolean;\n spaceSeparatedAbbreviation?: boolean;\n exponential?: boolean;\n prefixSymbol?: boolean;\n lowPrecision?: boolean;\n roundingFunction?: (num: number) => number;\n}\n\ninterface INumberOpts {\n preset?: INumberPreset;\n round?: number;\n displayFormat?: INumbroFormat;\n outputFormat?: INumbroFormat;\n}\n\ntype INumberField = IAbstractDeveloperField<\n \"number\",\n INumberPreset | INumberOpts\n>;\n\ninterface IDateTimeOpts {\n displayFormat?: string;\n outputFormat?: string;\n locale?: string;\n withSeconds?: boolean;\n}\n\ntype IDateTimeField = IAbstractDeveloperField<\n \"date\" | \"time\" | \"datetime\",\n IDateTimeOpts\n>;\n\ntype IEmailField = IAbstractDeveloperField<\"email\">;\n\nexport type IDeveloperField =\n | IStringField\n | ICheckboxField\n | ISelectField\n | INumberField\n | IDateTimeField\n | IEmailField;\n\ninterface IAbstractValidator<ValidateKey> {\n validate: ValidateKey;\n errorMessage?: string;\n level?: \"info\" | \"warning\" | \"error\";\n}\n\nexport type IRequiredValidator = IAbstractValidator<\"required\">;\n\nexport type IUniqueValidator = IAbstractValidator<\n \"unique\" | \"unique_case_insensitive\"\n>;\n\nexport interface IUniqueWithValidator\n extends IAbstractValidator<\"unique_with\"> {\n uniqueKey: string;\n}\n\nexport interface IRegexValidator\n extends IAbstractValidator<\"regex_match\" | \"regex_exclude\"> {\n regex: string | RegExp;\n regexOptions?: {\n ignoreCase?: boolean;\n dotAll?: boolean;\n multiline?: boolean;\n unicode?: boolean;\n };\n}\n\nexport interface IRequireWithValidator\n extends IAbstractValidator<\n | \"require_with\"\n | \"require_without\"\n | \"require_with_all\"\n | \"require_without_all\"\n > {\n fields: string[];\n}\n\nexport interface IRequireWithValuesValidator\n extends IAbstractValidator<\n | \"require_with_values\"\n | \"require_without_values\"\n | \"require_with_all_values\"\n | \"require_without_all_values\"\n > {\n fieldValues: { [key: string]: string };\n}\n\nexport type IValidatorField =\n | IRequiredValidator\n | IUniqueValidator\n | IUniqueWithValidator\n | IRegexValidator\n | IRequireWithValidator\n | IRequireWithValuesValidator;\n\nexport interface IDeveloperSettings {\n importIdentifier: string;\n title?: string;\n allowInvalidSubmit?: boolean;\n invalidDataBehavior?: keyof typeof EInvalidDataBehavior;\n backendSync?: boolean;\n backendSyncMode?: keyof typeof EBackendSyncMode;\n manualInputDisabled?: boolean;\n manualInputOnly?: boolean;\n allowCustomFields?: boolean;\n maxRecords?: number | null;\n developmentMode?: boolean;\n displayEncoding?: boolean;\n styleOverrides?: IDeveloperStyleOverrides;\n webhookUrl?: string;\n initialData?: { [key: string]: string }[] | any[][] | null;\n uploadStep?: {\n helpText?: string;\n };\n matchingStep?: {\n helpText?: string;\n headerRowOverride?: number | null;\n fuzzyMatchHeaders?: boolean;\n alwaysMatchSelectFields?: boolean;\n };\n reviewStep?: {\n helpText?: string;\n processingText?: string;\n saveForLater?: boolean;\n };\n autoMapHeaders?: boolean;\n delimiter?: string;\n backendOverride?: {\n url: string;\n type: \"AWS\" | \"AZURE\";\n } | null;\n locale?: TLocaleShorthand;\n templateDownloadFilename?: string;\n browserExcelParsing?: boolean;\n redesign?: string;\n}\n\n// If you update this, also update IDeveloperStylesOverridesStrict\n// in interfaces.tsx\nexport interface IDeveloperStyleOverrides {\n global?: {\n textColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n successColor?: string;\n warningColor?: string;\n customFontURL?: string | null;\n customFontFamily?: string | null;\n };\n primaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n secondaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n tertiaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n dropzone?: {\n borderWidth?: number;\n borderRadius?: number;\n borderColor?: string;\n borderStyle?: string;\n color?: string;\n outline?: string;\n };\n helpText?: {\n textColor?: string;\n backgroundColor?: string;\n };\n stepperBar?: {\n completeColor?: string;\n incompleteColor?: string;\n currentColor?: string;\n };\n}\n\nexport interface IUser {\n id: string;\n name?: string;\n email?: string;\n companyId?: string;\n companyName?: string;\n}\n\nexport interface ICellRef {\n rowIndex: number;\n fieldKey: string;\n}\n\nexport interface ITableMessage {\n message: string;\n level: \"info\" | \"warning\" | \"error\";\n}\n\nexport interface IMessagesForCell extends ICellRef {\n messages: ITableMessage[];\n}\n\nexport interface IColumnHook {\n fieldName: string;\n callback: (values: IColumnHookInput[]) => MaybeAsync<IColumnHookOutput[]>;\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: \"init\" | \"update\"): MaybeAsync<IRowHookOutput>;\n}\n\nexport type IBulkRowHook = (\n data: IRowHookInput[],\n mode: \"init\" | \"update\"\n) => IRowHookOutputInternal[] | Promise<IRowHookOutputInternal[]>;\n\nexport interface IRowDeleteHook {\n (data: IRowHookInput): MaybeAsync<void>;\n}\n\nexport interface IColumnHookInput {\n index: number;\n value: any;\n}\n\nexport interface IColumnHookOutput {\n index: number;\n value?: any;\n info?: ITableMessage[];\n}\n\nexport interface IRowHookInput {\n row: {\n [key: string]: {\n value: any;\n resultValue: any;\n info?: ITableMessage[];\n selectOptions?: ISelectField[\"selectOptions\"];\n };\n };\n index: number;\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any;\n info?: ITableMessage[];\n selectOptions?: ISelectField[\"selectOptions\"];\n };\n };\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number;\n}\n\nexport type IFieldMetadata = Record<\n string,\n {\n fileHeader: string | null;\n fileHeaderIndex: number | null;\n isCustom: boolean;\n }\n>;\n\nexport interface IResultMetadata {\n id: string | null;\n filename: string | null;\n importIdentifier: string;\n user: IUser;\n rowsWithError: number[];\n rawHeaders: string[] | null;\n fields: IFieldMetadata;\n saveForLater?: boolean;\n}\n\nexport type TLocaleShorthand =\n | \"de\"\n | \"en\"\n | \"es\"\n | \"fr\"\n | \"in\"\n | \"ja\"\n | \"ko\"\n | \"th\"\n | \"vi\"\n | \"zh_CN\"\n | \"zh_TW\";\n\nexport enum EStepHook {\n UPLOAD_STEP = \"UPLOAD_STEP\",\n REVIEW_STEP = \"REVIEW_STEP\",\n REVIEW_STEP_POST_HOOKS = \"REVIEW_STEP_POST_HOOKS\",\n}\n\nexport interface IUploadStepData {\n filename: string | null;\n dataPreview: any[][];\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null;\n headerMapping: { [header: string]: string | undefined };\n fields: IFieldMetadata;\n}\n\nexport interface IReviewStepPostHooksData {\n headerMapping: { [header: string]: string | undefined };\n fields: IFieldMetadata;\n}\n\nexport interface IStepHook {\n type: keyof typeof EStepHook;\n callback: (\n uploader: IPublicConnectionMethods,\n data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData\n ) => MaybeAsync<void>;\n}\n\nexport type IBeforeFinishCallback = (\n data: Record<string, any>[],\n metadata: IResultMetadata,\n instance: IPublicConnectionMethods\n) => MaybeAsync<IBeforeFinishOutput>;\n\nexport type IBeforeFinishOutput = void | { cancel: true; message: string };\n\nexport enum EInvalidDataBehavior {\n BLOCK_SUBMIT = \"BLOCK_SUBMIT\",\n REMOVE_INVALID_ROWS = \"REMOVE_INVALID_ROWS\",\n INCLUDE_INVALID_ROWS = \"INCLUDE_INVALID_ROWS\",\n}\n\nexport enum EBackendSyncMode {\n DISABLED = \"DISABLED\",\n MAPPINGS_ONLY = \"MAPPINGS_ONLY\",\n FULL_DATA = \"FULL_DATA\",\n}\n\nexport type IPositionSpec = { before: string } | { after: string };\n\nexport type IImporterOptions = {\n user?: IUser;\n developmentMode?: boolean;\n headerRowOverride?: number | null;\n};\n","import * as React from 'react'\nimport {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n EStepHook,\n IStepHook,\n IRowDeleteHook,\n IBulkRowHook,\n IBeforeFinishCallback,\n IImporterOptions\n} from './interfaces'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n schemaName: string\n licenseKey: string\n} & IImporterOptions\n\ntype CommonOptionalProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children: React.ReactNode\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps\n\ndeclare var DromoUploader: any\n\nconst SCRIPT_SRC =\n 'https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js'\nconst SCRIPT_LOADED_EVENT = 'DROMO_SCRIPT_LOADED'\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n componentDidMount() {\n const loadingScript = Array.from(\n document.getElementsByTagName('script')\n ).find((s) => s.src === SCRIPT_SRC)\n\n // If there is no script tag added to HTML then we add. Prevents multiple\n // adds if there are multiple components\n if (!loadingScript) {\n const script = document.createElement('script')\n script.src = SCRIPT_SRC\n script.async = true\n script.onload = () => {\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n }\n document.body.appendChild(script)\n } else {\n if ('DromoUploader' in window) {\n // If the script has been injected and has been loaded we can call\n // scriptLoaded\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n } else {\n // If the script has been injected but hasn't been loaded, we wait\n // for load\n loadingScript.onload = () => {\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n }\n }\n }\n }\n\n open = () => {\n if ('DromoUploader' in window) {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaName' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.schemaName\n )\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n this.dromo.open()\n }\n }\n\n render() {\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n EStepHook,\n IStepHook,\n IRowDeleteHook\n}\n"],"names":["EStepHook","EInvalidDataBehavior","EBackendSyncMode","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","window","props","dromo","DromoUploader","licenseKey","fields","settings","user","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","render","React","style","className","onClick","children"],"mappings":";;;;;;;;AAqbA,WAAYA;AACVA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,mCAAA,2BAAA;AACD,CAJD,EAAYA,iBAAS,KAATA,iBAAS,KAAA,CAArB;;AAsCA,IAAYC,oBAAZ;;AAAA,WAAYA;AACVA,EAAAA,oCAAA,iBAAA;AACAA,EAAAA,2CAAA,wBAAA;AACAA,EAAAA,4CAAA,yBAAA;AACD,CAJD,EAAYA,oBAAoB,KAApBA,oBAAoB,KAAA,CAAhC;;AAMA,IAAYC,gBAAZ;;AAAA,WAAYA;AACVA,EAAAA,4BAAA,aAAA;AACAA,EAAAA,iCAAA,kBAAA;AACAA,EAAAA,6BAAA,cAAA;AACD,CAJD,EAAYA,gBAAgB,KAAhBA,gBAAgB,KAAA,CAA5B;;AC7aA,IAAMC,UAAU,GACd,6EADF;AAEA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;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,aAAOA,CAAC,CAACC,GAAF,KAAU5C,UAAjB;AAAA,KAFe,CAAtB;;AAMA,QAAI,CAACqC,aAAL,EAAoB;AAClB,UAAMQ,MAAM,GAAGL,QAAQ,CAACM,aAAT,CAAuB,QAAvB,CAAf;AACAD,MAAAA,MAAM,CAACD,GAAP,GAAa5C,UAAb;AACA6C,MAAAA,MAAM,CAACE,KAAP,GAAe,IAAf;;AACAF,MAAAA,MAAM,CAACG,MAAP,GAAgB;AACd,YAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUjD,mBAAV,CAAd;AACAE,QAAAA,MAAM,CAACgD,aAAP,CAAqBF,KAArB;AACD,OAHD;;AAIAT,MAAAA,QAAQ,CAACY,IAAT,CAAcC,WAAd,CAA0BR,MAA1B;AACD,KATD,MASO;AACL,UAAI,mBAAmB1C,MAAvB,EAA+B;AAG7B,YAAM8C,KAAK,GAAG,IAAIC,KAAJ,CAAUjD,mBAAV,CAAd;AACAE,QAAAA,MAAM,CAACgD,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUjD,mBAAV,CAAd;AACAE,UAAAA,MAAM,CAACgD,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAuEDK,SAAA;AACE,WACEC,mBAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAKpD,KAAL,CAAWoD;AAClBC,MAAAA,SAAS,EAAE,KAAKrD,KAAL,CAAWqD;AACtBC,MAAAA,OAAO,EAAE,KAAKvB;KAHhB,EAKG,KAAK/B,KAAL,CAAWuD,QALd,CADF;AASD;;;EAnH6CJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n schemaName: string\n licenseKey: string\n} & IImporterOptions\n\ntype CommonOptionalProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children: React.ReactNode\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n open = () => {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaName' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.schemaName\n )\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n this.dromo.open()\n }\n\n render() {\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n}\n"],"names":["DromoReactUploader","props","dromo","DromoUploader","licenseKey","fields","settings","user","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","open","render","React","style","className","onClick","children"],"mappings":";;;;;;;;;;;IAiDqBA;;;AAArB;;;;;AAGE,cAAA,GAAO;AACL,UAAI,YAAY,MAAKC,KAAjB,IAA0B,cAAc,MAAKA,KAAjD,EAAwD;AACtD,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWI,MAFA,EAGX,MAAKJ,KAAL,CAAWK,QAHA,EAIX,MAAKL,KAAL,CAAWM,IAJA,CAAb;AAMD,OAPD,MAOO,IAAI,gBAAgB,MAAKN,K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AAKd,KAAL,CAAWuB,qBAAX,CAAiCT,IAAjC,CAAP;AACD,SAFD;AAGD;;AAED,UAAI,MAAKf,KAAL,CAAWyB,YAAf,EAA6B;AAC3B,cAAKxB,KAAL,CAAWwB,YAAX,CAAwB,MAAKzB,KAAL,CAAWyB,YAAnC;AACD;;AAED,UAAI,MAAKzB,KAAL,CAAW0B,SAAf,EAA0B;AACxB,cAAKzB,KAAL,CAAWyB,SAAX,CAAqB,MAAK1B,KAAL,CAAW0B,SAAhC;AACD;;AAED,UAAI,MAAK1B,KAAL,CAAW2B,QAAf,EAAyB;AACvB,cAAK1B,KAAL,CAAW0B,QAAX,CAAoB,MAAK3B,KAAL,CAAW2B,QAA/B;AACD;;AAED,UAAI,MAAK3B,KAAL,CAAW4B,SAAf,EAA0B;AACxB,cAAK5B,KAAL,CAAW4B,SAAX,CAAqBd,OAArB,CAA6B,UAACC,IAAD;AAC3B,gBAAKd,KAAL,CAAW4B,gBAAX,CAA4Bd,IAAI,CAACe,IAAjC,EAAuCf,IAAI,CAACO,QAA5C;AACD,SAFD;AAGD;;AAED,YAAKrB,KAAL,CAAW8B,IAAX;AACD,KAjED;;;AA8ED;;;;SAXCC,SAAA;AACE,WACEC,mBAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAKlC,KAAL,CAAWkC;AAClBC,MAAAA,SAAS,EAAE,KAAKnC,KAAL,CAAWmC;AACtBC,MAAAA,OAAO,EAAE,KAAKL;KAHhB,EAKG,KAAK/B,KAAL,CAAWqC,QALd,CADF;AASD;;;EAhF6CJ;;;;"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createElement, Component } from 'react';
|
|
2
|
+
import DromoUploader from 'dromo-uploader-js';
|
|
2
3
|
|
|
3
4
|
function _inheritsLoose(subClass, superClass) {
|
|
4
5
|
subClass.prototype = Object.create(superClass.prototype);
|
|
@@ -6,33 +7,6 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
6
7
|
subClass.__proto__ = superClass;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
var EStepHook;
|
|
10
|
-
|
|
11
|
-
(function (EStepHook) {
|
|
12
|
-
EStepHook["UPLOAD_STEP"] = "UPLOAD_STEP";
|
|
13
|
-
EStepHook["REVIEW_STEP"] = "REVIEW_STEP";
|
|
14
|
-
EStepHook["REVIEW_STEP_POST_HOOKS"] = "REVIEW_STEP_POST_HOOKS";
|
|
15
|
-
})(EStepHook || (EStepHook = {}));
|
|
16
|
-
|
|
17
|
-
var EInvalidDataBehavior;
|
|
18
|
-
|
|
19
|
-
(function (EInvalidDataBehavior) {
|
|
20
|
-
EInvalidDataBehavior["BLOCK_SUBMIT"] = "BLOCK_SUBMIT";
|
|
21
|
-
EInvalidDataBehavior["REMOVE_INVALID_ROWS"] = "REMOVE_INVALID_ROWS";
|
|
22
|
-
EInvalidDataBehavior["INCLUDE_INVALID_ROWS"] = "INCLUDE_INVALID_ROWS";
|
|
23
|
-
})(EInvalidDataBehavior || (EInvalidDataBehavior = {}));
|
|
24
|
-
|
|
25
|
-
var EBackendSyncMode;
|
|
26
|
-
|
|
27
|
-
(function (EBackendSyncMode) {
|
|
28
|
-
EBackendSyncMode["DISABLED"] = "DISABLED";
|
|
29
|
-
EBackendSyncMode["MAPPINGS_ONLY"] = "MAPPINGS_ONLY";
|
|
30
|
-
EBackendSyncMode["FULL_DATA"] = "FULL_DATA";
|
|
31
|
-
})(EBackendSyncMode || (EBackendSyncMode = {}));
|
|
32
|
-
|
|
33
|
-
var SCRIPT_SRC = 'https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js';
|
|
34
|
-
var SCRIPT_LOADED_EVENT = 'DROMO_SCRIPT_LOADED';
|
|
35
|
-
|
|
36
10
|
var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
37
11
|
_inheritsLoose(DromoReactUploader, _React$Component);
|
|
38
12
|
|
|
@@ -42,69 +16,67 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
42
16
|
_this = _React$Component.apply(this, arguments) || this;
|
|
43
17
|
|
|
44
18
|
_this.open = function () {
|
|
45
|
-
if ('
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.schemaName);
|
|
50
|
-
|
|
51
|
-
if ('developmentMode' in _this.props) {
|
|
52
|
-
_this.dromo.setDevelopmentMode(_this.props.developmentMode);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if ('user' in _this.props) {
|
|
56
|
-
_this.dromo.setUser(_this.props.user);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if ('headerRowOverride' in _this.props) {
|
|
60
|
-
_this.dromo.setHeaderRowOverride(_this.props.headerRowOverride);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
19
|
+
if ('fields' in _this.props && 'settings' in _this.props) {
|
|
20
|
+
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
|
|
21
|
+
} else if ('schemaName' in _this.props) {
|
|
22
|
+
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.schemaName);
|
|
63
23
|
|
|
64
|
-
if (_this.props
|
|
65
|
-
_this.props.
|
|
66
|
-
return _this.dromo.registerRowHook(hook);
|
|
67
|
-
});
|
|
24
|
+
if ('developmentMode' in _this.props) {
|
|
25
|
+
_this.dromo.setDevelopmentMode(_this.props.developmentMode);
|
|
68
26
|
}
|
|
69
27
|
|
|
70
|
-
if (_this.props
|
|
71
|
-
_this.props.
|
|
72
|
-
return _this.dromo.registerBulkRowHook(hook);
|
|
73
|
-
});
|
|
28
|
+
if ('user' in _this.props) {
|
|
29
|
+
_this.dromo.setUser(_this.props.user);
|
|
74
30
|
}
|
|
75
31
|
|
|
76
|
-
if (_this.props
|
|
77
|
-
_this.props.
|
|
78
|
-
_this.dromo.registerColumnHook(hook.fieldName, hook.callback);
|
|
79
|
-
});
|
|
32
|
+
if ('headerRowOverride' in _this.props) {
|
|
33
|
+
_this.dromo.setHeaderRowOverride(_this.props.headerRowOverride);
|
|
80
34
|
}
|
|
35
|
+
}
|
|
81
36
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
37
|
+
if (_this.props.rowHooks) {
|
|
38
|
+
_this.props.rowHooks.forEach(function (hook) {
|
|
39
|
+
return _this.dromo.registerRowHook(hook);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
87
42
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
43
|
+
if (_this.props.bulkRowHooks) {
|
|
44
|
+
_this.props.bulkRowHooks.forEach(function (hook) {
|
|
45
|
+
return _this.dromo.registerBulkRowHook(hook);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
91
48
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
49
|
+
if (_this.props.columnHooks) {
|
|
50
|
+
_this.props.columnHooks.forEach(function (hook) {
|
|
51
|
+
_this.dromo.registerColumnHook(hook.fieldName, hook.callback);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
95
54
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
55
|
+
if (_this.props.rowDeleteHooks) {
|
|
56
|
+
_this.props.rowDeleteHooks.forEach(function (hook) {
|
|
57
|
+
return _this.dromo.registerRowDeleteHook(hook);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
99
60
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
61
|
+
if (_this.props.beforeFinish) {
|
|
62
|
+
_this.dromo.beforeFinish(_this.props.beforeFinish);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (_this.props.onResults) {
|
|
66
|
+
_this.dromo.onResults(_this.props.onResults);
|
|
67
|
+
}
|
|
105
68
|
|
|
106
|
-
|
|
69
|
+
if (_this.props.onCancel) {
|
|
70
|
+
_this.dromo.onCancel(_this.props.onCancel);
|
|
107
71
|
}
|
|
72
|
+
|
|
73
|
+
if (_this.props.stepHooks) {
|
|
74
|
+
_this.props.stepHooks.forEach(function (hook) {
|
|
75
|
+
_this.dromo.registerStepHook(hook.type, hook.callback);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_this.dromo.open();
|
|
108
80
|
};
|
|
109
81
|
|
|
110
82
|
return _this;
|
|
@@ -112,35 +84,6 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
112
84
|
|
|
113
85
|
var _proto = DromoReactUploader.prototype;
|
|
114
86
|
|
|
115
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
116
|
-
var loadingScript = Array.from(document.getElementsByTagName('script')).find(function (s) {
|
|
117
|
-
return s.src === SCRIPT_SRC;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
if (!loadingScript) {
|
|
121
|
-
var script = document.createElement('script');
|
|
122
|
-
script.src = SCRIPT_SRC;
|
|
123
|
-
script.async = true;
|
|
124
|
-
|
|
125
|
-
script.onload = function () {
|
|
126
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
127
|
-
window.dispatchEvent(event);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
document.body.appendChild(script);
|
|
131
|
-
} else {
|
|
132
|
-
if ('DromoUploader' in window) {
|
|
133
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
134
|
-
window.dispatchEvent(event);
|
|
135
|
-
} else {
|
|
136
|
-
loadingScript.onload = function () {
|
|
137
|
-
var event = new Event(SCRIPT_LOADED_EVENT);
|
|
138
|
-
window.dispatchEvent(event);
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
87
|
_proto.render = function render() {
|
|
145
88
|
return createElement("button", {
|
|
146
89
|
style: this.props.style,
|
|
@@ -153,5 +96,4 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
153
96
|
}(Component);
|
|
154
97
|
|
|
155
98
|
export default DromoReactUploader;
|
|
156
|
-
export { EStepHook };
|
|
157
99
|
//# sourceMappingURL=index.modern.js.map
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["type MaybeAsync<T> = T | Promise<T>;\n\nexport interface IConnectionMethods {\n init: (\n licenseKey: string,\n fields: IDeveloperField[],\n settings: IDeveloperSettings,\n user: IUser,\n appHost?: string\n ) => void;\n initFromSavedSchema: (\n licenseKey: string,\n schemaName: string,\n appHost: string,\n options?: IImporterOptions\n ) => void;\n setHeaderRowOverride: (headerRowOverride: number | null) => void;\n setNumRegisteredColHooks: (numColHooks: number) => void;\n setNumRegisteredRowHooks: (numRowHooks: number) => void;\n setNumRegisteredRowDeleteHooks: (numRowDeleteHooks: number) => void;\n setUser: (user: IUser) => void;\n addField: (field: IDeveloperField, position?: IPositionSpec) => void;\n removeField: (fieldKey: string) => void;\n updateInfoMessages: (messages: IMessagesForCell[]) => void;\n setDevelopmentMode: (developmentMode: boolean) => void;\n}\n\nexport type IPublicConnectionMethods = Pick<\n IConnectionMethods,\n | \"addField\"\n | \"updateInfoMessages\"\n | \"setHeaderRowOverride\"\n | \"setUser\"\n | \"removeField\"\n | \"setDevelopmentMode\"\n>;\n\nexport type IDeveloperFieldType =\n | \"string\"\n | \"checkbox\"\n | \"select\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"time\"\n | \"email\";\n\nexport interface IAbstractDeveloperFieldUntyped {\n label: string;\n key: string;\n type?: never;\n description?: string;\n alternateMatches?: string[];\n validators?: IValidatorField[];\n invalidValueMessage?: string;\n readOnly?: boolean;\n hidden?: boolean;\n requireMapping?: boolean;\n}\n\nexport interface IAbstractDeveloperField<\n FieldType extends IDeveloperFieldType,\n FieldOpts = Record<string, never>\n> extends Omit<IAbstractDeveloperFieldUntyped, \"type\"> {\n type: FieldType | [FieldType, FieldOpts];\n}\n\ntype IStringField =\n | IAbstractDeveloperFieldUntyped\n | IAbstractDeveloperField<\"string\">;\n\ntype ICheckboxField = IAbstractDeveloperField<\"checkbox\">;\n\nexport interface IDeveloperSelectOption {\n label: string;\n value: string;\n alternateMatches?: string[];\n}\n\nexport interface ISelectField extends IAbstractDeveloperField<\"select\"> {\n selectOptions: IDeveloperSelectOption[];\n}\n\ntype INumberPreset =\n | \"default\"\n | \"percent\"\n | \"percent_0\"\n | \"percent_1\"\n | \"percent_2\"\n | \"percent_3\"\n | \"percent_4\"\n | \"decimal_0\"\n | \"decimal_1\"\n | \"decimal_2\"\n | \"decimal_3\"\n | \"decimal_4\"\n | \"integer\"\n | \"plain\"\n | \"usd\"\n | \"usd_accounting\"\n | \"eur\"\n | \"gbp\";\n\n// copy-pasta'd from numbro.Format\ninterface INumbroFormat {\n output?: \"currency\" | \"percent\" | \"byte\" | \"time\" | \"ordinal\" | \"number\";\n base?: \"decimal\" | \"binary\" | \"general\";\n characteristic?: number;\n prefix?: string;\n postfix?: string;\n forceAverage?: \"trillion\" | \"billion\" | \"million\" | \"thousand\";\n average?: boolean;\n currencyPosition?: \"prefix\" | \"infix\" | \"postfix\";\n currencySymbol?: string;\n totalLength?: number;\n mantissa?: number;\n optionalMantissa?: boolean;\n trimMantissa?: boolean;\n optionalCharacteristic?: boolean;\n thousandSeparated?: boolean;\n abbreviations?: {\n thousand?: string;\n million?: string;\n billion?: string;\n trillion?: string;\n };\n negative?: \"sign\" | \"parenthesis\";\n forceSign?: boolean;\n spaceSeparated?: boolean;\n spaceSeparatedCurrency?: boolean;\n spaceSeparatedAbbreviation?: boolean;\n exponential?: boolean;\n prefixSymbol?: boolean;\n lowPrecision?: boolean;\n roundingFunction?: (num: number) => number;\n}\n\ninterface INumberOpts {\n preset?: INumberPreset;\n round?: number;\n displayFormat?: INumbroFormat;\n outputFormat?: INumbroFormat;\n}\n\ntype INumberField = IAbstractDeveloperField<\n \"number\",\n INumberPreset | INumberOpts\n>;\n\ninterface IDateTimeOpts {\n displayFormat?: string;\n outputFormat?: string;\n locale?: string;\n withSeconds?: boolean;\n}\n\ntype IDateTimeField = IAbstractDeveloperField<\n \"date\" | \"time\" | \"datetime\",\n IDateTimeOpts\n>;\n\ntype IEmailField = IAbstractDeveloperField<\"email\">;\n\nexport type IDeveloperField =\n | IStringField\n | ICheckboxField\n | ISelectField\n | INumberField\n | IDateTimeField\n | IEmailField;\n\ninterface IAbstractValidator<ValidateKey> {\n validate: ValidateKey;\n errorMessage?: string;\n level?: \"info\" | \"warning\" | \"error\";\n}\n\nexport type IRequiredValidator = IAbstractValidator<\"required\">;\n\nexport type IUniqueValidator = IAbstractValidator<\n \"unique\" | \"unique_case_insensitive\"\n>;\n\nexport interface IUniqueWithValidator\n extends IAbstractValidator<\"unique_with\"> {\n uniqueKey: string;\n}\n\nexport interface IRegexValidator\n extends IAbstractValidator<\"regex_match\" | \"regex_exclude\"> {\n regex: string | RegExp;\n regexOptions?: {\n ignoreCase?: boolean;\n dotAll?: boolean;\n multiline?: boolean;\n unicode?: boolean;\n };\n}\n\nexport interface IRequireWithValidator\n extends IAbstractValidator<\n | \"require_with\"\n | \"require_without\"\n | \"require_with_all\"\n | \"require_without_all\"\n > {\n fields: string[];\n}\n\nexport interface IRequireWithValuesValidator\n extends IAbstractValidator<\n | \"require_with_values\"\n | \"require_without_values\"\n | \"require_with_all_values\"\n | \"require_without_all_values\"\n > {\n fieldValues: { [key: string]: string };\n}\n\nexport type IValidatorField =\n | IRequiredValidator\n | IUniqueValidator\n | IUniqueWithValidator\n | IRegexValidator\n | IRequireWithValidator\n | IRequireWithValuesValidator;\n\nexport interface IDeveloperSettings {\n importIdentifier: string;\n title?: string;\n allowInvalidSubmit?: boolean;\n invalidDataBehavior?: keyof typeof EInvalidDataBehavior;\n backendSync?: boolean;\n backendSyncMode?: keyof typeof EBackendSyncMode;\n manualInputDisabled?: boolean;\n manualInputOnly?: boolean;\n allowCustomFields?: boolean;\n maxRecords?: number | null;\n developmentMode?: boolean;\n displayEncoding?: boolean;\n styleOverrides?: IDeveloperStyleOverrides;\n webhookUrl?: string;\n initialData?: { [key: string]: string }[] | any[][] | null;\n uploadStep?: {\n helpText?: string;\n };\n matchingStep?: {\n helpText?: string;\n headerRowOverride?: number | null;\n fuzzyMatchHeaders?: boolean;\n alwaysMatchSelectFields?: boolean;\n };\n reviewStep?: {\n helpText?: string;\n processingText?: string;\n saveForLater?: boolean;\n };\n autoMapHeaders?: boolean;\n delimiter?: string;\n backendOverride?: {\n url: string;\n type: \"AWS\" | \"AZURE\";\n } | null;\n locale?: TLocaleShorthand;\n templateDownloadFilename?: string;\n browserExcelParsing?: boolean;\n redesign?: string;\n}\n\n// If you update this, also update IDeveloperStylesOverridesStrict\n// in interfaces.tsx\nexport interface IDeveloperStyleOverrides {\n global?: {\n textColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n successColor?: string;\n warningColor?: string;\n customFontURL?: string | null;\n customFontFamily?: string | null;\n };\n primaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n secondaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n tertiaryButton?: {\n borderRadius?: string;\n backgroundColor?: string;\n textColor?: string;\n border?: string;\n hoverBackgroundColor?: string;\n hoverTextColor?: string;\n hoverBorder?: string;\n };\n dropzone?: {\n borderWidth?: number;\n borderRadius?: number;\n borderColor?: string;\n borderStyle?: string;\n color?: string;\n outline?: string;\n };\n helpText?: {\n textColor?: string;\n backgroundColor?: string;\n };\n stepperBar?: {\n completeColor?: string;\n incompleteColor?: string;\n currentColor?: string;\n };\n}\n\nexport interface IUser {\n id: string;\n name?: string;\n email?: string;\n companyId?: string;\n companyName?: string;\n}\n\nexport interface ICellRef {\n rowIndex: number;\n fieldKey: string;\n}\n\nexport interface ITableMessage {\n message: string;\n level: \"info\" | \"warning\" | \"error\";\n}\n\nexport interface IMessagesForCell extends ICellRef {\n messages: ITableMessage[];\n}\n\nexport interface IColumnHook {\n fieldName: string;\n callback: (values: IColumnHookInput[]) => MaybeAsync<IColumnHookOutput[]>;\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: \"init\" | \"update\"): MaybeAsync<IRowHookOutput>;\n}\n\nexport type IBulkRowHook = (\n data: IRowHookInput[],\n mode: \"init\" | \"update\"\n) => IRowHookOutputInternal[] | Promise<IRowHookOutputInternal[]>;\n\nexport interface IRowDeleteHook {\n (data: IRowHookInput): MaybeAsync<void>;\n}\n\nexport interface IColumnHookInput {\n index: number;\n value: any;\n}\n\nexport interface IColumnHookOutput {\n index: number;\n value?: any;\n info?: ITableMessage[];\n}\n\nexport interface IRowHookInput {\n row: {\n [key: string]: {\n value: any;\n resultValue: any;\n info?: ITableMessage[];\n selectOptions?: ISelectField[\"selectOptions\"];\n };\n };\n index: number;\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any;\n info?: ITableMessage[];\n selectOptions?: ISelectField[\"selectOptions\"];\n };\n };\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number;\n}\n\nexport type IFieldMetadata = Record<\n string,\n {\n fileHeader: string | null;\n fileHeaderIndex: number | null;\n isCustom: boolean;\n }\n>;\n\nexport interface IResultMetadata {\n id: string | null;\n filename: string | null;\n importIdentifier: string;\n user: IUser;\n rowsWithError: number[];\n rawHeaders: string[] | null;\n fields: IFieldMetadata;\n saveForLater?: boolean;\n}\n\nexport type TLocaleShorthand =\n | \"de\"\n | \"en\"\n | \"es\"\n | \"fr\"\n | \"in\"\n | \"ja\"\n | \"ko\"\n | \"th\"\n | \"vi\"\n | \"zh_CN\"\n | \"zh_TW\";\n\nexport enum EStepHook {\n UPLOAD_STEP = \"UPLOAD_STEP\",\n REVIEW_STEP = \"REVIEW_STEP\",\n REVIEW_STEP_POST_HOOKS = \"REVIEW_STEP_POST_HOOKS\",\n}\n\nexport interface IUploadStepData {\n filename: string | null;\n dataPreview: any[][];\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null;\n headerMapping: { [header: string]: string | undefined };\n fields: IFieldMetadata;\n}\n\nexport interface IReviewStepPostHooksData {\n headerMapping: { [header: string]: string | undefined };\n fields: IFieldMetadata;\n}\n\nexport interface IStepHook {\n type: keyof typeof EStepHook;\n callback: (\n uploader: IPublicConnectionMethods,\n data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData\n ) => MaybeAsync<void>;\n}\n\nexport type IBeforeFinishCallback = (\n data: Record<string, any>[],\n metadata: IResultMetadata,\n instance: IPublicConnectionMethods\n) => MaybeAsync<IBeforeFinishOutput>;\n\nexport type IBeforeFinishOutput = void | { cancel: true; message: string };\n\nexport enum EInvalidDataBehavior {\n BLOCK_SUBMIT = \"BLOCK_SUBMIT\",\n REMOVE_INVALID_ROWS = \"REMOVE_INVALID_ROWS\",\n INCLUDE_INVALID_ROWS = \"INCLUDE_INVALID_ROWS\",\n}\n\nexport enum EBackendSyncMode {\n DISABLED = \"DISABLED\",\n MAPPINGS_ONLY = \"MAPPINGS_ONLY\",\n FULL_DATA = \"FULL_DATA\",\n}\n\nexport type IPositionSpec = { before: string } | { after: string };\n\nexport type IImporterOptions = {\n user?: IUser;\n developmentMode?: boolean;\n headerRowOverride?: number | null;\n};\n","import * as React from 'react'\nimport {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n EStepHook,\n IStepHook,\n IRowDeleteHook,\n IBulkRowHook,\n IBeforeFinishCallback,\n IImporterOptions\n} from './interfaces'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n schemaName: string\n licenseKey: string\n} & IImporterOptions\n\ntype CommonOptionalProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children: React.ReactNode\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps\n\ndeclare var DromoUploader: any\n\nconst SCRIPT_SRC =\n 'https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js'\nconst SCRIPT_LOADED_EVENT = 'DROMO_SCRIPT_LOADED'\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n componentDidMount() {\n const loadingScript = Array.from(\n document.getElementsByTagName('script')\n ).find((s) => s.src === SCRIPT_SRC)\n\n // If there is no script tag added to HTML then we add. Prevents multiple\n // adds if there are multiple components\n if (!loadingScript) {\n const script = document.createElement('script')\n script.src = SCRIPT_SRC\n script.async = true\n script.onload = () => {\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n }\n document.body.appendChild(script)\n } else {\n if ('DromoUploader' in window) {\n // If the script has been injected and has been loaded we can call\n // scriptLoaded\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n } else {\n // If the script has been injected but hasn't been loaded, we wait\n // for load\n loadingScript.onload = () => {\n const event = new Event(SCRIPT_LOADED_EVENT)\n window.dispatchEvent(event)\n }\n }\n }\n }\n\n open = () => {\n if ('DromoUploader' in window) {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaName' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.schemaName\n )\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n this.dromo.open()\n }\n }\n\n render() {\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n EStepHook,\n IStepHook,\n IRowDeleteHook\n}\n"],"names":["EStepHook","EInvalidDataBehavior","EBackendSyncMode","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","window","props","dromo","DromoUploader","licenseKey","fields","settings","user","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","render","React","style","className","onClick","children"],"mappings":";;;;;;;;IAqbYA;;AAAZ,WAAYA;AACVA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,mCAAA,2BAAA;AACD,CAJD,EAAYA,SAAS,KAATA,SAAS,KAAA,CAArB;;AAsCA,IAAYC,oBAAZ;;AAAA,WAAYA;AACVA,EAAAA,oCAAA,iBAAA;AACAA,EAAAA,2CAAA,wBAAA;AACAA,EAAAA,4CAAA,yBAAA;AACD,CAJD,EAAYA,oBAAoB,KAApBA,oBAAoB,KAAA,CAAhC;;AAMA,IAAYC,gBAAZ;;AAAA,WAAYA;AACVA,EAAAA,4BAAA,aAAA;AACAA,EAAAA,iCAAA,kBAAA;AACAA,EAAAA,6BAAA,cAAA;AACD,CAJD,EAAYA,gBAAgB,KAAhBA,gBAAgB,KAAA,CAA5B;;AC7aA,IAAMC,UAAU,GACd,6EADF;AAEA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;;;;AAoCE,cAAA,GAAO;AACL,UAAI,mBAAmBC,MAAvB,EAA+B;AAC7B,YAAI,YAAY,MAAKC,KAAjB,IAA0B,cAAc,MAAKA,KAAjD,EAAwD;AACtD,gBAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWI,MAFA,EAGX,MAAKJ,KAAL,CAAWK,QAHA,EAIX,MAAKL,KAAL,CAAWM,IAJA,CAAb;AAMD,SAPD,MAOO,IAAI,gBAAgB,MAAKN,KAAzB,EAAgC;AACrC,gBAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,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AA,QAAQ,CAACY,IAAT,CAAcC,WAAd,CAA0BR,MAA1B;AACD,KATD,MASO;AACL,UAAI,mBAAmB1C,MAAvB,EAA+B;AAG7B,YAAM8C,KAAK,GAAG,IAAIC,KAAJ,CAAUjD,mBAAV,CAAd;AACAE,QAAAA,MAAM,CAACgD,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUjD,mBAAV,CAAd;AACAE,UAAAA,MAAM,CAACgD,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAuEDK,SAAA;AACE,WACEC,aAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAKpD,KAAL,CAAWoD;AAClBC,MAAAA,SAAS,EAAE,KAAKrD,KAAL,CAAWqD;AACtBC,MAAAA,OAAO,EAAE,KAAKvB;KAHhB,EAKG,KAAK/B,KAAL,CAAWuD,QALd,CADF;AASD;;;EAnH6CJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n schemaName: string\n licenseKey: string\n} & IImporterOptions\n\ntype CommonOptionalProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children: React.ReactNode\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n open = () => {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaName' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.schemaName\n )\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n this.dromo.open()\n }\n\n render() {\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n}\n"],"names":["DromoReactUploader","props","dromo","DromoUploader","licenseKey","fields","settings","user","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","open","render","React","style","className","onClick","children"],"mappings":";;;;;;;;;IAiDqBA;;;AAArB;;;;;AAGE,cAAA,GAAO;AACL,UAAI,YAAY,MAAKC,KAAjB,IAA0B,cAAc,MAAKA,KAAjD,EAAwD;AACtD,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWI,MAFA,EAGX,MAAKJ,KAAL,CAAWK,QAHA,EAIX,MAAKL,KAAL,CAAWM,IAJA,CAAb;AAMD,OAPD,MAOO,IAAI,gBAAgB,MAAKN,KAAzB,EAAgC;AACrC,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWO,UAFA,CAAb;;AAIA,YAAI,qBAAqB,MAAKP,KAA9B,EAAqC;AACnC,gBAAKC,KAAL,CAAWO,kBAAX,CAA8B,MAAKR,KAAL,CAAWS,eAAzC;AACD;;AACD,YAAI,UAAU,MAAKT,KAAnB,EAA0B;AACxB,gBAAKC,KAAL,CAAWS,OAAX,CAAmB,MAAKV,KAAL,CAAWM,IAA9B;AACD;;AACD,YAAI,uBAAuB,MAAKN,KAAhC,EAAuC;AACrC,gBAAKC,KAAL,CAAWU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CAAW2B,QAA/B;AACD;;AAED,UAAI,MAAK3B,KAAL,CAAW4B,SAAf,EAA0B;AACxB,cAAK5B,KAAL,CAAW4B,SAAX,CAAqBd,OAArB,CAA6B,UAACC,IAAD;AAC3B,gBAAKd,KAAL,CAAW4B,gBAAX,CAA4Bd,IAAI,CAACe,IAAjC,EAAuCf,IAAI,CAACO,QAA5C;AACD,SAFD;AAGD;;AAED,YAAKrB,KAAL,CAAW8B,IAAX;AACD,KAjED;;;AA8ED;;;;SAXCC,SAAA;AACE,WACEC,aAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAKlC,KAAL,CAAWkC;AAClBC,MAAAA,SAAS,EAAE,KAAKnC,KAAL,CAAWmC;AACtBC,MAAAA,OAAO,EAAE,KAAKL;KAHhB,EAKG,KAAK/B,KAAL,CAAWqC,QALd,CADF;AASD;;;EAhF6CJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dromo-uploader-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Easy to use data (CSV, TSV, Excel) importer",
|
|
5
5
|
"author": "ankitgoyal100",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,5 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist"
|
|
62
|
-
]
|
|
62
|
+
],
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"dromo-uploader-js": "^1.3.16"
|
|
65
|
+
}
|
|
63
66
|
}
|
package/dist/interfaces.d.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
declare type MaybeAsync<T> = T | Promise<T>;
|
|
2
|
-
export interface IConnectionMethods {
|
|
3
|
-
init: (licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser, appHost?: string) => void;
|
|
4
|
-
initFromSavedSchema: (licenseKey: string, schemaName: string, appHost: string, options?: IImporterOptions) => void;
|
|
5
|
-
setHeaderRowOverride: (headerRowOverride: number | null) => void;
|
|
6
|
-
setNumRegisteredColHooks: (numColHooks: number) => void;
|
|
7
|
-
setNumRegisteredRowHooks: (numRowHooks: number) => void;
|
|
8
|
-
setNumRegisteredRowDeleteHooks: (numRowDeleteHooks: number) => void;
|
|
9
|
-
setUser: (user: IUser) => void;
|
|
10
|
-
addField: (field: IDeveloperField, position?: IPositionSpec) => void;
|
|
11
|
-
removeField: (fieldKey: string) => void;
|
|
12
|
-
updateInfoMessages: (messages: IMessagesForCell[]) => void;
|
|
13
|
-
setDevelopmentMode: (developmentMode: boolean) => void;
|
|
14
|
-
}
|
|
15
|
-
export declare type IPublicConnectionMethods = Pick<IConnectionMethods, "addField" | "updateInfoMessages" | "setHeaderRowOverride" | "setUser" | "removeField" | "setDevelopmentMode">;
|
|
16
|
-
export declare type IDeveloperFieldType = "string" | "checkbox" | "select" | "number" | "date" | "datetime" | "time" | "email";
|
|
17
|
-
export interface IAbstractDeveloperFieldUntyped {
|
|
18
|
-
label: string;
|
|
19
|
-
key: string;
|
|
20
|
-
type?: never;
|
|
21
|
-
description?: string;
|
|
22
|
-
alternateMatches?: string[];
|
|
23
|
-
validators?: IValidatorField[];
|
|
24
|
-
invalidValueMessage?: string;
|
|
25
|
-
readOnly?: boolean;
|
|
26
|
-
hidden?: boolean;
|
|
27
|
-
requireMapping?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface IAbstractDeveloperField<FieldType extends IDeveloperFieldType, FieldOpts = Record<string, never>> extends Omit<IAbstractDeveloperFieldUntyped, "type"> {
|
|
30
|
-
type: FieldType | [FieldType, FieldOpts];
|
|
31
|
-
}
|
|
32
|
-
declare type IStringField = IAbstractDeveloperFieldUntyped | IAbstractDeveloperField<"string">;
|
|
33
|
-
declare type ICheckboxField = IAbstractDeveloperField<"checkbox">;
|
|
34
|
-
export interface IDeveloperSelectOption {
|
|
35
|
-
label: string;
|
|
36
|
-
value: string;
|
|
37
|
-
alternateMatches?: string[];
|
|
38
|
-
}
|
|
39
|
-
export interface ISelectField extends IAbstractDeveloperField<"select"> {
|
|
40
|
-
selectOptions: IDeveloperSelectOption[];
|
|
41
|
-
}
|
|
42
|
-
declare type INumberPreset = "default" | "percent" | "percent_0" | "percent_1" | "percent_2" | "percent_3" | "percent_4" | "decimal_0" | "decimal_1" | "decimal_2" | "decimal_3" | "decimal_4" | "integer" | "plain" | "usd" | "usd_accounting" | "eur" | "gbp";
|
|
43
|
-
interface INumbroFormat {
|
|
44
|
-
output?: "currency" | "percent" | "byte" | "time" | "ordinal" | "number";
|
|
45
|
-
base?: "decimal" | "binary" | "general";
|
|
46
|
-
characteristic?: number;
|
|
47
|
-
prefix?: string;
|
|
48
|
-
postfix?: string;
|
|
49
|
-
forceAverage?: "trillion" | "billion" | "million" | "thousand";
|
|
50
|
-
average?: boolean;
|
|
51
|
-
currencyPosition?: "prefix" | "infix" | "postfix";
|
|
52
|
-
currencySymbol?: string;
|
|
53
|
-
totalLength?: number;
|
|
54
|
-
mantissa?: number;
|
|
55
|
-
optionalMantissa?: boolean;
|
|
56
|
-
trimMantissa?: boolean;
|
|
57
|
-
optionalCharacteristic?: boolean;
|
|
58
|
-
thousandSeparated?: boolean;
|
|
59
|
-
abbreviations?: {
|
|
60
|
-
thousand?: string;
|
|
61
|
-
million?: string;
|
|
62
|
-
billion?: string;
|
|
63
|
-
trillion?: string;
|
|
64
|
-
};
|
|
65
|
-
negative?: "sign" | "parenthesis";
|
|
66
|
-
forceSign?: boolean;
|
|
67
|
-
spaceSeparated?: boolean;
|
|
68
|
-
spaceSeparatedCurrency?: boolean;
|
|
69
|
-
spaceSeparatedAbbreviation?: boolean;
|
|
70
|
-
exponential?: boolean;
|
|
71
|
-
prefixSymbol?: boolean;
|
|
72
|
-
lowPrecision?: boolean;
|
|
73
|
-
roundingFunction?: (num: number) => number;
|
|
74
|
-
}
|
|
75
|
-
interface INumberOpts {
|
|
76
|
-
preset?: INumberPreset;
|
|
77
|
-
round?: number;
|
|
78
|
-
displayFormat?: INumbroFormat;
|
|
79
|
-
outputFormat?: INumbroFormat;
|
|
80
|
-
}
|
|
81
|
-
declare type INumberField = IAbstractDeveloperField<"number", INumberPreset | INumberOpts>;
|
|
82
|
-
interface IDateTimeOpts {
|
|
83
|
-
displayFormat?: string;
|
|
84
|
-
outputFormat?: string;
|
|
85
|
-
locale?: string;
|
|
86
|
-
withSeconds?: boolean;
|
|
87
|
-
}
|
|
88
|
-
declare type IDateTimeField = IAbstractDeveloperField<"date" | "time" | "datetime", IDateTimeOpts>;
|
|
89
|
-
declare type IEmailField = IAbstractDeveloperField<"email">;
|
|
90
|
-
export declare type IDeveloperField = IStringField | ICheckboxField | ISelectField | INumberField | IDateTimeField | IEmailField;
|
|
91
|
-
interface IAbstractValidator<ValidateKey> {
|
|
92
|
-
validate: ValidateKey;
|
|
93
|
-
errorMessage?: string;
|
|
94
|
-
level?: "info" | "warning" | "error";
|
|
95
|
-
}
|
|
96
|
-
export declare type IRequiredValidator = IAbstractValidator<"required">;
|
|
97
|
-
export declare type IUniqueValidator = IAbstractValidator<"unique" | "unique_case_insensitive">;
|
|
98
|
-
export interface IUniqueWithValidator extends IAbstractValidator<"unique_with"> {
|
|
99
|
-
uniqueKey: string;
|
|
100
|
-
}
|
|
101
|
-
export interface IRegexValidator extends IAbstractValidator<"regex_match" | "regex_exclude"> {
|
|
102
|
-
regex: string | RegExp;
|
|
103
|
-
regexOptions?: {
|
|
104
|
-
ignoreCase?: boolean;
|
|
105
|
-
dotAll?: boolean;
|
|
106
|
-
multiline?: boolean;
|
|
107
|
-
unicode?: boolean;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
export interface IRequireWithValidator extends IAbstractValidator<"require_with" | "require_without" | "require_with_all" | "require_without_all"> {
|
|
111
|
-
fields: string[];
|
|
112
|
-
}
|
|
113
|
-
export interface IRequireWithValuesValidator extends IAbstractValidator<"require_with_values" | "require_without_values" | "require_with_all_values" | "require_without_all_values"> {
|
|
114
|
-
fieldValues: {
|
|
115
|
-
[key: string]: string;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export declare type IValidatorField = IRequiredValidator | IUniqueValidator | IUniqueWithValidator | IRegexValidator | IRequireWithValidator | IRequireWithValuesValidator;
|
|
119
|
-
export interface IDeveloperSettings {
|
|
120
|
-
importIdentifier: string;
|
|
121
|
-
title?: string;
|
|
122
|
-
allowInvalidSubmit?: boolean;
|
|
123
|
-
invalidDataBehavior?: keyof typeof EInvalidDataBehavior;
|
|
124
|
-
backendSync?: boolean;
|
|
125
|
-
backendSyncMode?: keyof typeof EBackendSyncMode;
|
|
126
|
-
manualInputDisabled?: boolean;
|
|
127
|
-
manualInputOnly?: boolean;
|
|
128
|
-
allowCustomFields?: boolean;
|
|
129
|
-
maxRecords?: number | null;
|
|
130
|
-
developmentMode?: boolean;
|
|
131
|
-
displayEncoding?: boolean;
|
|
132
|
-
styleOverrides?: IDeveloperStyleOverrides;
|
|
133
|
-
webhookUrl?: string;
|
|
134
|
-
initialData?: {
|
|
135
|
-
[key: string]: string;
|
|
136
|
-
}[] | any[][] | null;
|
|
137
|
-
uploadStep?: {
|
|
138
|
-
helpText?: string;
|
|
139
|
-
};
|
|
140
|
-
matchingStep?: {
|
|
141
|
-
helpText?: string;
|
|
142
|
-
headerRowOverride?: number | null;
|
|
143
|
-
fuzzyMatchHeaders?: boolean;
|
|
144
|
-
alwaysMatchSelectFields?: boolean;
|
|
145
|
-
};
|
|
146
|
-
reviewStep?: {
|
|
147
|
-
helpText?: string;
|
|
148
|
-
processingText?: string;
|
|
149
|
-
saveForLater?: boolean;
|
|
150
|
-
};
|
|
151
|
-
autoMapHeaders?: boolean;
|
|
152
|
-
delimiter?: string;
|
|
153
|
-
backendOverride?: {
|
|
154
|
-
url: string;
|
|
155
|
-
type: "AWS" | "AZURE";
|
|
156
|
-
} | null;
|
|
157
|
-
locale?: TLocaleShorthand;
|
|
158
|
-
templateDownloadFilename?: string;
|
|
159
|
-
browserExcelParsing?: boolean;
|
|
160
|
-
redesign?: string;
|
|
161
|
-
}
|
|
162
|
-
export interface IDeveloperStyleOverrides {
|
|
163
|
-
global?: {
|
|
164
|
-
textColor?: string;
|
|
165
|
-
primaryTextColor?: string;
|
|
166
|
-
secondaryTextColor?: string;
|
|
167
|
-
successColor?: string;
|
|
168
|
-
warningColor?: string;
|
|
169
|
-
customFontURL?: string | null;
|
|
170
|
-
customFontFamily?: string | null;
|
|
171
|
-
};
|
|
172
|
-
primaryButton?: {
|
|
173
|
-
borderRadius?: string;
|
|
174
|
-
backgroundColor?: string;
|
|
175
|
-
textColor?: string;
|
|
176
|
-
border?: string;
|
|
177
|
-
hoverBackgroundColor?: string;
|
|
178
|
-
hoverTextColor?: string;
|
|
179
|
-
hoverBorder?: string;
|
|
180
|
-
};
|
|
181
|
-
secondaryButton?: {
|
|
182
|
-
borderRadius?: string;
|
|
183
|
-
backgroundColor?: string;
|
|
184
|
-
textColor?: string;
|
|
185
|
-
border?: string;
|
|
186
|
-
hoverBackgroundColor?: string;
|
|
187
|
-
hoverTextColor?: string;
|
|
188
|
-
hoverBorder?: string;
|
|
189
|
-
};
|
|
190
|
-
tertiaryButton?: {
|
|
191
|
-
borderRadius?: string;
|
|
192
|
-
backgroundColor?: string;
|
|
193
|
-
textColor?: string;
|
|
194
|
-
border?: string;
|
|
195
|
-
hoverBackgroundColor?: string;
|
|
196
|
-
hoverTextColor?: string;
|
|
197
|
-
hoverBorder?: string;
|
|
198
|
-
};
|
|
199
|
-
dropzone?: {
|
|
200
|
-
borderWidth?: number;
|
|
201
|
-
borderRadius?: number;
|
|
202
|
-
borderColor?: string;
|
|
203
|
-
borderStyle?: string;
|
|
204
|
-
color?: string;
|
|
205
|
-
outline?: string;
|
|
206
|
-
};
|
|
207
|
-
helpText?: {
|
|
208
|
-
textColor?: string;
|
|
209
|
-
backgroundColor?: string;
|
|
210
|
-
};
|
|
211
|
-
stepperBar?: {
|
|
212
|
-
completeColor?: string;
|
|
213
|
-
incompleteColor?: string;
|
|
214
|
-
currentColor?: string;
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
export interface IUser {
|
|
218
|
-
id: string;
|
|
219
|
-
name?: string;
|
|
220
|
-
email?: string;
|
|
221
|
-
companyId?: string;
|
|
222
|
-
companyName?: string;
|
|
223
|
-
}
|
|
224
|
-
export interface ICellRef {
|
|
225
|
-
rowIndex: number;
|
|
226
|
-
fieldKey: string;
|
|
227
|
-
}
|
|
228
|
-
export interface ITableMessage {
|
|
229
|
-
message: string;
|
|
230
|
-
level: "info" | "warning" | "error";
|
|
231
|
-
}
|
|
232
|
-
export interface IMessagesForCell extends ICellRef {
|
|
233
|
-
messages: ITableMessage[];
|
|
234
|
-
}
|
|
235
|
-
export interface IColumnHook {
|
|
236
|
-
fieldName: string;
|
|
237
|
-
callback: (values: IColumnHookInput[]) => MaybeAsync<IColumnHookOutput[]>;
|
|
238
|
-
}
|
|
239
|
-
export interface IRowHook {
|
|
240
|
-
(data: IRowHookInput, mode: "init" | "update"): MaybeAsync<IRowHookOutput>;
|
|
241
|
-
}
|
|
242
|
-
export declare type IBulkRowHook = (data: IRowHookInput[], mode: "init" | "update") => IRowHookOutputInternal[] | Promise<IRowHookOutputInternal[]>;
|
|
243
|
-
export interface IRowDeleteHook {
|
|
244
|
-
(data: IRowHookInput): MaybeAsync<void>;
|
|
245
|
-
}
|
|
246
|
-
export interface IColumnHookInput {
|
|
247
|
-
index: number;
|
|
248
|
-
value: any;
|
|
249
|
-
}
|
|
250
|
-
export interface IColumnHookOutput {
|
|
251
|
-
index: number;
|
|
252
|
-
value?: any;
|
|
253
|
-
info?: ITableMessage[];
|
|
254
|
-
}
|
|
255
|
-
export interface IRowHookInput {
|
|
256
|
-
row: {
|
|
257
|
-
[key: string]: {
|
|
258
|
-
value: any;
|
|
259
|
-
resultValue: any;
|
|
260
|
-
info?: ITableMessage[];
|
|
261
|
-
selectOptions?: ISelectField["selectOptions"];
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
index: number;
|
|
265
|
-
}
|
|
266
|
-
export interface IRowHookOutput {
|
|
267
|
-
row: {
|
|
268
|
-
[key: string]: {
|
|
269
|
-
value?: any;
|
|
270
|
-
info?: ITableMessage[];
|
|
271
|
-
selectOptions?: ISelectField["selectOptions"];
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
export interface IRowHookOutputInternal extends IRowHookOutput {
|
|
276
|
-
index: number;
|
|
277
|
-
}
|
|
278
|
-
export declare type IFieldMetadata = Record<string, {
|
|
279
|
-
fileHeader: string | null;
|
|
280
|
-
fileHeaderIndex: number | null;
|
|
281
|
-
isCustom: boolean;
|
|
282
|
-
}>;
|
|
283
|
-
export interface IResultMetadata {
|
|
284
|
-
id: string | null;
|
|
285
|
-
filename: string | null;
|
|
286
|
-
importIdentifier: string;
|
|
287
|
-
user: IUser;
|
|
288
|
-
rowsWithError: number[];
|
|
289
|
-
rawHeaders: string[] | null;
|
|
290
|
-
fields: IFieldMetadata;
|
|
291
|
-
saveForLater?: boolean;
|
|
292
|
-
}
|
|
293
|
-
export declare type TLocaleShorthand = "de" | "en" | "es" | "fr" | "in" | "ja" | "ko" | "th" | "vi" | "zh_CN" | "zh_TW";
|
|
294
|
-
export declare enum EStepHook {
|
|
295
|
-
UPLOAD_STEP = "UPLOAD_STEP",
|
|
296
|
-
REVIEW_STEP = "REVIEW_STEP",
|
|
297
|
-
REVIEW_STEP_POST_HOOKS = "REVIEW_STEP_POST_HOOKS"
|
|
298
|
-
}
|
|
299
|
-
export interface IUploadStepData {
|
|
300
|
-
filename: string | null;
|
|
301
|
-
dataPreview: any[][];
|
|
302
|
-
}
|
|
303
|
-
export interface IReviewStepData {
|
|
304
|
-
rawHeaders: string[] | null;
|
|
305
|
-
headerMapping: {
|
|
306
|
-
[header: string]: string | undefined;
|
|
307
|
-
};
|
|
308
|
-
fields: IFieldMetadata;
|
|
309
|
-
}
|
|
310
|
-
export interface IReviewStepPostHooksData {
|
|
311
|
-
headerMapping: {
|
|
312
|
-
[header: string]: string | undefined;
|
|
313
|
-
};
|
|
314
|
-
fields: IFieldMetadata;
|
|
315
|
-
}
|
|
316
|
-
export interface IStepHook {
|
|
317
|
-
type: keyof typeof EStepHook;
|
|
318
|
-
callback: (uploader: IPublicConnectionMethods, data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData) => MaybeAsync<void>;
|
|
319
|
-
}
|
|
320
|
-
export declare type IBeforeFinishCallback = (data: Record<string, any>[], metadata: IResultMetadata, instance: IPublicConnectionMethods) => MaybeAsync<IBeforeFinishOutput>;
|
|
321
|
-
export declare type IBeforeFinishOutput = void | {
|
|
322
|
-
cancel: true;
|
|
323
|
-
message: string;
|
|
324
|
-
};
|
|
325
|
-
export declare enum EInvalidDataBehavior {
|
|
326
|
-
BLOCK_SUBMIT = "BLOCK_SUBMIT",
|
|
327
|
-
REMOVE_INVALID_ROWS = "REMOVE_INVALID_ROWS",
|
|
328
|
-
INCLUDE_INVALID_ROWS = "INCLUDE_INVALID_ROWS"
|
|
329
|
-
}
|
|
330
|
-
export declare enum EBackendSyncMode {
|
|
331
|
-
DISABLED = "DISABLED",
|
|
332
|
-
MAPPINGS_ONLY = "MAPPINGS_ONLY",
|
|
333
|
-
FULL_DATA = "FULL_DATA"
|
|
334
|
-
}
|
|
335
|
-
export declare type IPositionSpec = {
|
|
336
|
-
before: string;
|
|
337
|
-
} | {
|
|
338
|
-
after: string;
|
|
339
|
-
};
|
|
340
|
-
export declare type IImporterOptions = {
|
|
341
|
-
user?: IUser;
|
|
342
|
-
developmentMode?: boolean;
|
|
343
|
-
headerRowOverride?: number | null;
|
|
344
|
-
};
|
|
345
|
-
export {};
|