dromo-uploader-react 1.3.5 → 1.3.7

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 CHANGED
@@ -1,12 +1,18 @@
1
1
  import * as React from 'react';
2
- import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata, EStepHook, IStepHook, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback } from './interfaces';
3
- interface Props {
4
- style?: React.CSSProperties;
5
- className?: string;
6
- licenseKey: string;
2
+ import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata, EStepHook, IStepHook, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IImporterOptions } from './interfaces';
3
+ declare type VerboseRequiredProps = {
7
4
  user: IUser;
8
5
  fields: IDeveloperField[];
6
+ licenseKey: string;
9
7
  settings: IDeveloperSettings;
8
+ };
9
+ declare type SavedSchemaProps = {
10
+ schemaName: string;
11
+ licenseKey: string;
12
+ } & IImporterOptions;
13
+ declare type CommonOptionalProps = {
14
+ style?: React.CSSProperties;
15
+ className?: string;
10
16
  rowHooks?: IRowHook[];
11
17
  bulkRowHooks?: IBulkRowHook[];
12
18
  rowDeleteHooks?: IRowDeleteHook[];
@@ -16,7 +22,8 @@ interface Props {
16
22
  onResults?: (data: any, metadata: IResultMetadata) => void;
17
23
  onCancel?: () => void;
18
24
  children: React.ReactNode;
19
- }
25
+ };
26
+ declare type Props = (VerboseRequiredProps | SavedSchemaProps) & CommonOptionalProps;
20
27
  export default class DromoReactUploader extends React.Component<Props> {
21
28
  dromo: any;
22
29
  componentDidMount(): void;
package/dist/index.js CHANGED
@@ -41,7 +41,23 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
41
41
 
42
42
  _this.open = function () {
43
43
  if ('DromoUploader' in window) {
44
- _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
44
+ if ('fields' in _this.props && 'settings' in _this.props) {
45
+ _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
46
+ } else if ('schemaName' in _this.props) {
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
+ }
45
61
 
46
62
  if (_this.props.rowHooks) {
47
63
  _this.props.rowHooks.forEach(function (hook) {
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 ) => 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}\n\nexport type IPublicConnectionMethods = Pick<\n IConnectionMethods,\n | \"addField\"\n | \"updateInfoMessages\"\n | \"setHeaderRowOverride\"\n | \"setUser\"\n | \"removeField\"\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}\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 ISelectField extends IAbstractDeveloperField<\"select\"> {\n selectOptions: {\n label: string;\n value: string;\n alternateMatches?: string[];\n }[];\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}\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","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} from './interfaces'\n\ninterface Props {\n style?: React.CSSProperties\n className?: string\n licenseKey: string\n user: IUser\n fields: IDeveloperField[]\n settings: IDeveloperSettings\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\ndeclare var DromoUploader: any\n\nconst SCRIPT_SRC = 'https://unpkg.com/dromo-uploader-js/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 this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\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","dromo","DromoUploader","props","licenseKey","fields","settings","user","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":";;;;;;;;A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C,CAACC,GAAF,KAAUtC,UAAjB;AAAA,KAFe,CAAtB;;AAMA,QAAI,CAAC+B,aAAL,EAAoB;AAClB,UAAMQ,MAAM,GAAGL,QAAQ,CAACM,aAAT,CAAuB,QAAvB,CAAf;AACAD,MAAAA,MAAM,CAACD,GAAP,GAAatC,UAAb;AACAuC,MAAAA,MAAM,CAACE,KAAP,GAAe,IAAf;;AACAF,MAAAA,MAAM,CAACG,MAAP,GAAgB;AACd,YAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAU3C,mBAAV,CAAd;AACAE,QAAAA,MAAM,CAAC0C,aAAP,CAAqBF,KAArB;AACD,OAHD;;AAIAT,MAAAA,QAAQ,CAACY,IAAT,CAAcC,WAAd,CAA0BR,MAA1B;AACD,KATD,MASO;AACL,UAAI,mBAAmBpC,MAAvB,EAA+B;AAG7B,YAAMwC,KAAK,GAAG,IAAIC,KAAJ,CAAU3C,mBAAV,CAAd;AACAE,QAAAA,MAAM,CAAC0C,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAU3C,mBAAV,CAAd;AACAE,UAAAA,MAAM,CAAC0C,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAuDDK,SAAA;AACE,WACEC,mBAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAK5C,KAAL,CAAW4C;AAClBC,MAAAA,SAAS,EAAE,KAAK7C,KAAL,CAAW6C;AACtBC,MAAAA,OAAO,EAAE,KAAKvB;KAHhB,EAKG,KAAKvB,KAAL,CAAW+C,QALd,CADF;AASD;;;EAnG6CJ;;;;"}
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 = 'https://unpkg.com/dromo-uploader-js/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,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,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;;;;"}
@@ -43,7 +43,23 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
43
43
 
44
44
  _this.open = function () {
45
45
  if ('DromoUploader' in window) {
46
- _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
46
+ if ('fields' in _this.props && 'settings' in _this.props) {
47
+ _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
48
+ } else if ('schemaName' in _this.props) {
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
+ }
47
63
 
48
64
  if (_this.props.rowHooks) {
49
65
  _this.props.rowHooks.forEach(function (hook) {
@@ -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 ) => 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}\n\nexport type IPublicConnectionMethods = Pick<\n IConnectionMethods,\n | \"addField\"\n | \"updateInfoMessages\"\n | \"setHeaderRowOverride\"\n | \"setUser\"\n | \"removeField\"\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}\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 ISelectField extends IAbstractDeveloperField<\"select\"> {\n selectOptions: {\n label: string;\n value: string;\n alternateMatches?: string[];\n }[];\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}\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","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} from './interfaces'\n\ninterface Props {\n style?: React.CSSProperties\n className?: string\n licenseKey: string\n user: IUser\n fields: IDeveloperField[]\n settings: IDeveloperSettings\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\ndeclare var DromoUploader: any\n\nconst SCRIPT_SRC = 'https://unpkg.com/dromo-uploader-js/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 this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\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","dromo","DromoUploader","props","licenseKey","fields","settings","user","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":";;;;;;;;IA8aYA;;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;;ACjbA,IAAMC,UAAU,GAAG,2DAAnB;AACA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;;;;AAoCE,cAAA,GAAO;AACL,UAAI,mBAAmBC,MAAvB,EAA+B;AAC7B,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKC,KAAL,CAAWC,UADA,EAEX,MAAKD,KAAL,CAAWE,MAFA,EAGX,MAAKF,KAAL,CAAWG,QAHA,EAIX,MAAKH,KAAL,CAAWI,IAJA,CAAb;;AAOA,YAAI,MAAKJ,KAAL,CAAWK,QAAf,EAAyB;AACvB,gBAAKL,KAAL,CAAWK,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AAW4C;AAClBC,MAAAA,SAAS,EAAE,KAAK7C,KAAL,CAAW6C;AACtBC,MAAAA,OAAO,EAAE,KAAKvB;KAHhB,EAKG,KAAKvB,KAAL,CAAW+C,QALd,CADF;AASD;;;EAnG6CJ;;;;;"}
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 = 'https://unpkg.com/dromo-uploader-js/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,GAAG,2DAAnB;AACA,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,UAD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,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,7 +1,7 @@
1
1
  declare type MaybeAsync<T> = T | Promise<T>;
2
2
  export interface IConnectionMethods {
3
3
  init: (licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser, appHost?: string) => void;
4
- initFromSavedSchema: (licenseKey: string, schemaName: string, appHost: string) => void;
4
+ initFromSavedSchema: (licenseKey: string, schemaName: string, appHost: string, options?: IImporterOptions) => void;
5
5
  setHeaderRowOverride: (headerRowOverride: number | null) => void;
6
6
  setNumRegisteredColHooks: (numColHooks: number) => void;
7
7
  setNumRegisteredRowHooks: (numRowHooks: number) => void;
@@ -10,8 +10,9 @@ export interface IConnectionMethods {
10
10
  addField: (field: IDeveloperField, position?: IPositionSpec) => void;
11
11
  removeField: (fieldKey: string) => void;
12
12
  updateInfoMessages: (messages: IMessagesForCell[]) => void;
13
+ setDevelopmentMode: (developmentMode: boolean) => void;
13
14
  }
14
- export declare type IPublicConnectionMethods = Pick<IConnectionMethods, "addField" | "updateInfoMessages" | "setHeaderRowOverride" | "setUser" | "removeField">;
15
+ export declare type IPublicConnectionMethods = Pick<IConnectionMethods, "addField" | "updateInfoMessages" | "setHeaderRowOverride" | "setUser" | "removeField" | "setDevelopmentMode">;
15
16
  export declare type IDeveloperFieldType = "string" | "checkbox" | "select" | "number" | "date" | "datetime" | "time" | "email";
16
17
  export interface IAbstractDeveloperFieldUntyped {
17
18
  label: string;
@@ -23,18 +24,20 @@ export interface IAbstractDeveloperFieldUntyped {
23
24
  invalidValueMessage?: string;
24
25
  readOnly?: boolean;
25
26
  hidden?: boolean;
27
+ requireMapping?: boolean;
26
28
  }
27
29
  export interface IAbstractDeveloperField<FieldType extends IDeveloperFieldType, FieldOpts = Record<string, never>> extends Omit<IAbstractDeveloperFieldUntyped, "type"> {
28
30
  type: FieldType | [FieldType, FieldOpts];
29
31
  }
30
32
  declare type IStringField = IAbstractDeveloperFieldUntyped | IAbstractDeveloperField<"string">;
31
33
  declare type ICheckboxField = IAbstractDeveloperField<"checkbox">;
34
+ export interface IDeveloperSelectOption {
35
+ label: string;
36
+ value: string;
37
+ alternateMatches?: string[];
38
+ }
32
39
  export interface ISelectField extends IAbstractDeveloperField<"select"> {
33
- selectOptions: {
34
- label: string;
35
- value: string;
36
- alternateMatches?: string[];
37
- }[];
40
+ selectOptions: IDeveloperSelectOption[];
38
41
  }
39
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";
40
43
  interface INumbroFormat {
@@ -154,6 +157,7 @@ export interface IDeveloperSettings {
154
157
  locale?: TLocaleShorthand;
155
158
  templateDownloadFilename?: string;
156
159
  browserExcelParsing?: boolean;
160
+ redesign?: string;
157
161
  }
158
162
  export interface IDeveloperStyleOverrides {
159
163
  global?: {
@@ -333,4 +337,9 @@ export declare type IPositionSpec = {
333
337
  } | {
334
338
  after: string;
335
339
  };
340
+ export declare type IImporterOptions = {
341
+ user?: IUser;
342
+ developmentMode?: boolean;
343
+ headerRowOverride?: number | null;
344
+ };
336
345
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dromo-uploader-react",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Easy to use data (CSV, TSV, Excel) importer",
5
5
  "author": "ankitgoyal100",
6
6
  "license": "MIT",