dromo-uploader-react 1.2.9 → 1.2.13

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.js CHANGED
@@ -9,6 +9,7 @@ function _inheritsLoose(subClass, superClass) {
9
9
  (function (EStepHook) {
10
10
  EStepHook["UPLOAD_STEP"] = "UPLOAD_STEP";
11
11
  EStepHook["REVIEW_STEP"] = "REVIEW_STEP";
12
+ EStepHook["REVIEW_STEP_POST_HOOKS"] = "REVIEW_STEP_POST_HOOKS";
12
13
  })(exports.EStepHook || (exports.EStepHook = {}));
13
14
 
14
15
  var SCRIPT_SRC = 'https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["export interface IDeveloperField {\n label: string\n key: string\n type?: 'string' | 'checkbox' | 'select'\n description?: string\n alternateMatches?: string[]\n validators?: IValidatorField[]\n selectOptions?: {\n label: string\n value: string\n }[]\n}\n\nexport interface IValidatorField {\n validate:\n | 'required'\n | 'unique'\n | 'regex_match'\n | 'regex_exclude'\n | 'require_with'\n | 'require_without'\n | 'require_with_all'\n | 'require_without_all'\n | 'require_with_values'\n | 'require_without_values'\n | 'require_with_all_values'\n | 'require_without_all_values'\n errorMessage?: string\n fields?: string[]\n fieldValues?: { [key: string]: any }\n regex?: string\n regexOptions?: {\n ignoreCase?: boolean\n dotAll?: boolean\n multiline?: boolean\n unicode?: boolean\n }\n}\n\nexport interface IDeveloperSettings {\n importIdentifier: string\n title?: string\n allowInvalidSubmit?: boolean\n backendSync?: boolean\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?: any[] | null\n autoMapHeaders?: boolean\n delimiter?: string\n backendOverride?: {\n url: string\n type: 'AWS' | 'AZURE'\n } | null\n locale?: TLocaleShorthand\n templateDownloadFilename?: 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 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 ITableMessage {\n message: string\n level: 'info' | 'warning' | 'error'\n}\n\nexport interface IColumnHook {\n fieldName: string\n callback: (\n values: IColumnHookInput[]\n ) => IColumnHookOutput[] | Promise<IColumnHookOutput[]>\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: 'init' | 'update'):\n | IRowHookOutput\n | Promise<IRowHookOutput>\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 }\n }\n index: number\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any\n info?: ITableMessage[]\n }\n }\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number\n}\n\nexport interface IResultMetadata {\n id: string | null\n importIdentifier: string\n user: IUser\n rowsWithError: number[]\n}\n\nexport type TLocaleShorthand = 'en'\n\nexport enum EStepHook {\n // eslint-disable-next-line no-unused-vars\n UPLOAD_STEP = 'UPLOAD_STEP',\n // eslint-disable-next-line no-unused-vars\n REVIEW_STEP = 'REVIEW_STEP'\n}\n\nexport interface IUploadStepData {\n dataPreview: any[][]\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IStepHook {\n type: EStepHook\n callback: (\n uploader: any,\n data: IUploadStepData | IReviewStepData\n ) => void | Promise<void>\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} 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 columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\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 // Add event listener post load to set up Dromo\n window.addEventListener(SCRIPT_LOADED_EVENT, this.scriptLoaded.bind(this))\n\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 componentWillUnmount() {\n window.removeEventListener(\n SCRIPT_LOADED_EVENT,\n this.scriptLoaded.bind(this)\n )\n }\n\n scriptLoaded = () => {\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.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\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\n open = () => {\n if (this.dromo) 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 EStepHook,\n IStepHook\n}\n"],"names":["EStepHook","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","dromo","DromoUploader","props","licenseKey","fields","settings","user","rowHooks","forEach","hook","registerRowHook","columnHooks","registerColumnHook","fieldName","callback","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","window","addEventListener","scriptLoaded","bind","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","componentWillUnmount","removeEventListener","render","React","style","className","onClick","children"],"mappings":";;;;;;;;AAyLA,WAAYA;AAEVA,EAAAA,wBAAA,gBAAA;AAEAA,EAAAA,wBAAA,gBAAA;AACD,CALD,EAAYA,iBAAS,KAATA,iBAAS,KAAA,CAArB;;ACvJA,IAAMC,UAAU,GAAG,2DAAnB;AACA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;;;;AA8CE,sBAAA,GAAe;AACb,YAAKC,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,UAAI,MAAKJ,KAAL,CAAWK,QAAf,EAAyB;AACvB,cAAKL,KAAL,CAAWK,QAAX,CAAoBC,OAApB,CAA4B,UAACC,IAAD;AAAA,iBAAU,MAAKT,KAAL,CAAWU,eAAX,CAA2BD,IAA3B,CAAV;AAAA,SAA5B;AACD;;AAED,UAAI,MAAKP,KAAL,CAAWS,WAAf,EAA4B;AAC1B,cAAKT,KAAL,CAAWS,WAAX,CAAuBH,OAAvB,CAA+B,UAACC,IAAD;AAC7B,gBAAKT,KAAL,CAAWY,kBAAX,CAA8BH,IAAI,CAACI,SAAnC,EAA8CJ,IAAI,CAACK,QAAnD;AACD,SAFD;AAGD;;AAED,UAAI,MAAKZ,KAAL,CAAWa,SAAf,EAA0B;AACxB,cAAKf,KAAL,CAAWe,SAAX,CAAqB,MAAKb,KAAL,CAAWa,SAAhC;AACD;;AAED,UAAI,MAAKb,KAAL,CAAWc,QAAf,EAAyB;AACvB,cAAKhB,KAAL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,CAAd;AACAwB,QAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,UAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAEDK,uBAAA;AACErB,IAAAA,MAAM,CAACsB,mBAAP,CACE9C,mBADF,EAEE,KAAK0B,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAFF;AAID;;SAuCDoB,SAAA;AACE,WACEC,mBAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAK7C,KAAL,CAAW6C;AAClBC,MAAAA,SAAS,EAAE,KAAK9C,KAAL,CAAW8C;AACtBC,MAAAA,OAAO,EAAE,KAAK7B;KAHhB,EAKG,KAAKlB,KAAL,CAAWgD,QALd,CADF;AASD;;;EA7F6CJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["export interface IDeveloperField {\n label: string\n key: string\n type?: 'string' | 'checkbox' | 'select'\n description?: string\n alternateMatches?: string[]\n validators?: IValidatorField[]\n selectOptions?: {\n label: string\n value: string\n }[]\n}\n\nexport interface IValidatorField {\n validate:\n | 'required'\n | 'unique'\n | 'unique_case_insensitive'\n | 'regex_match'\n | 'regex_exclude'\n | 'require_with'\n | 'require_without'\n | 'require_with_all'\n | 'require_without_all'\n | 'require_with_values'\n | 'require_without_values'\n | 'require_with_all_values'\n | 'require_without_all_values'\n errorMessage?: string\n fields?: string[]\n fieldValues?: { [key: string]: any }\n regex?: string\n regexOptions?: {\n ignoreCase?: boolean\n dotAll?: boolean\n multiline?: boolean\n unicode?: boolean\n }\n}\n\nexport interface IDeveloperSettings {\n importIdentifier: string\n title?: string\n allowInvalidSubmit?: boolean\n backendSync?: boolean\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?: any[] | null\n matchingStep?: {\n headerRowOverride?: number | null\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}\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 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 column: string\n}\n\nexport interface ITableMessage {\n message: string\n level: 'info' | 'warning' | 'error'\n}\n\nexport type ITableMessageWithRef = ITableMessage & ICellRef\n\nexport interface IColumnHook {\n fieldName: string\n callback: (\n values: IColumnHookInput[]\n ) => IColumnHookOutput[] | Promise<IColumnHookOutput[]>\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: 'init' | 'update'):\n | IRowHookOutput\n | Promise<IRowHookOutput>\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 info?: ITableMessage[]\n }\n }\n index: number\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any\n info?: ITableMessage[]\n }\n }\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number\n}\n\nexport interface IResultMetadata {\n id: string | null\n importIdentifier: string\n user: IUser\n rowsWithError: number[]\n}\n\nexport type TLocaleShorthand = 'en'\n\n/* eslint-disable no-unused-vars */\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 dataPreview: any[][]\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IReviewStepPostHooksData {\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IStepHook {\n type: EStepHook\n callback: (\n uploader: any,\n data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData\n ) => void | Promise<void>\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} 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 columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\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 // Add event listener post load to set up Dromo\n window.addEventListener(SCRIPT_LOADED_EVENT, this.scriptLoaded.bind(this))\n\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 componentWillUnmount() {\n window.removeEventListener(\n SCRIPT_LOADED_EVENT,\n this.scriptLoaded.bind(this)\n )\n }\n\n scriptLoaded = () => {\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.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\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\n open = () => {\n if (this.dromo) 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 EStepHook,\n IStepHook\n}\n"],"names":["EStepHook","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","dromo","DromoUploader","props","licenseKey","fields","settings","user","rowHooks","forEach","hook","registerRowHook","columnHooks","registerColumnHook","fieldName","callback","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","window","addEventListener","scriptLoaded","bind","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","componentWillUnmount","removeEventListener","render","React","style","className","onClick","children"],"mappings":";;;;;;;;AAsMA,WAAYA;AACVA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,mCAAA,2BAAA;AACD,CAJD,EAAYA,iBAAS,KAATA,iBAAS,KAAA,CAArB;;ACpKA,IAAMC,UAAU,GAAG,2DAAnB;AACA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;;;;AA8CE,sBAAA,GAAe;AACb,YAAKC,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,UAAI,MAAKJ,KAAL,CAAWK,QAAf,EAAyB;AACvB,cAAKL,KAAL,CAAWK,QAAX,CAAoBC,OAApB,CAA4B,UAACC,IAAD;AAAA,iBAAU,MAAKT,KAAL,CAAWU,eAAX,CAA2BD,IAA3B,CAAV;AAAA,SAA5B;AACD;;AAED,UAAI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ACD,GAAP,GAAapC,UAAb;AACAqC,MAAAA,MAAM,CAACE,KAAP,GAAe,IAAf;;AACAF,MAAAA,MAAM,CAACG,MAAP,GAAgB;AACd,YAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,QAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,OAHD;;AAIAT,MAAAA,QAAQ,CAACY,IAAT,CAAcC,WAAd,CAA0BR,MAA1B;AACD,KATD,MASO;AACL,UAAI,mBAAmBZ,MAAvB,EAA+B;AAG7B,YAAMgB,KAAK,GAAG,IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,QAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,UAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAEDK,uBAAA;AACErB,IAAAA,MAAM,CAACsB,mBAAP,CACE9C,mBADF,EAEE,KAAK0B,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAFF;AAID;;SAuCDoB,SAAA;AACE,WACEC,mBAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAK7C,KAAL,CAAW6C;AAClBC,MAAAA,SAAS,EAAE,KAAK9C,KAAL,CAAW8C;AACtBC,MAAAA,OAAO,EAAE,KAAK7B;KAHhB,EAKG,KAAKlB,KAAL,CAAWgD,QALd,CADF;AASD;;;EA7F6CJ;;;;"}
@@ -11,6 +11,7 @@ var EStepHook;
11
11
  (function (EStepHook) {
12
12
  EStepHook["UPLOAD_STEP"] = "UPLOAD_STEP";
13
13
  EStepHook["REVIEW_STEP"] = "REVIEW_STEP";
14
+ EStepHook["REVIEW_STEP_POST_HOOKS"] = "REVIEW_STEP_POST_HOOKS";
14
15
  })(EStepHook || (EStepHook = {}));
15
16
 
16
17
  var SCRIPT_SRC = 'https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["export interface IDeveloperField {\n label: string\n key: string\n type?: 'string' | 'checkbox' | 'select'\n description?: string\n alternateMatches?: string[]\n validators?: IValidatorField[]\n selectOptions?: {\n label: string\n value: string\n }[]\n}\n\nexport interface IValidatorField {\n validate:\n | 'required'\n | 'unique'\n | 'regex_match'\n | 'regex_exclude'\n | 'require_with'\n | 'require_without'\n | 'require_with_all'\n | 'require_without_all'\n | 'require_with_values'\n | 'require_without_values'\n | 'require_with_all_values'\n | 'require_without_all_values'\n errorMessage?: string\n fields?: string[]\n fieldValues?: { [key: string]: any }\n regex?: string\n regexOptions?: {\n ignoreCase?: boolean\n dotAll?: boolean\n multiline?: boolean\n unicode?: boolean\n }\n}\n\nexport interface IDeveloperSettings {\n importIdentifier: string\n title?: string\n allowInvalidSubmit?: boolean\n backendSync?: boolean\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?: any[] | null\n autoMapHeaders?: boolean\n delimiter?: string\n backendOverride?: {\n url: string\n type: 'AWS' | 'AZURE'\n } | null\n locale?: TLocaleShorthand\n templateDownloadFilename?: 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 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 ITableMessage {\n message: string\n level: 'info' | 'warning' | 'error'\n}\n\nexport interface IColumnHook {\n fieldName: string\n callback: (\n values: IColumnHookInput[]\n ) => IColumnHookOutput[] | Promise<IColumnHookOutput[]>\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: 'init' | 'update'):\n | IRowHookOutput\n | Promise<IRowHookOutput>\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 }\n }\n index: number\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any\n info?: ITableMessage[]\n }\n }\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number\n}\n\nexport interface IResultMetadata {\n id: string | null\n importIdentifier: string\n user: IUser\n rowsWithError: number[]\n}\n\nexport type TLocaleShorthand = 'en'\n\nexport enum EStepHook {\n // eslint-disable-next-line no-unused-vars\n UPLOAD_STEP = 'UPLOAD_STEP',\n // eslint-disable-next-line no-unused-vars\n REVIEW_STEP = 'REVIEW_STEP'\n}\n\nexport interface IUploadStepData {\n dataPreview: any[][]\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IStepHook {\n type: EStepHook\n callback: (\n uploader: any,\n data: IUploadStepData | IReviewStepData\n ) => void | Promise<void>\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} 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 columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\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 // Add event listener post load to set up Dromo\n window.addEventListener(SCRIPT_LOADED_EVENT, this.scriptLoaded.bind(this))\n\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 componentWillUnmount() {\n window.removeEventListener(\n SCRIPT_LOADED_EVENT,\n this.scriptLoaded.bind(this)\n )\n }\n\n scriptLoaded = () => {\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.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\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\n open = () => {\n if (this.dromo) 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 EStepHook,\n IStepHook\n}\n"],"names":["EStepHook","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","dromo","DromoUploader","props","licenseKey","fields","settings","user","rowHooks","forEach","hook","registerRowHook","columnHooks","registerColumnHook","fieldName","callback","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","window","addEventListener","scriptLoaded","bind","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","componentWillUnmount","removeEventListener","render","React","style","className","onClick","children"],"mappings":";;;;;;;;IAyLYA;;AAAZ,WAAYA;AAEVA,EAAAA,wBAAA,gBAAA;AAEAA,EAAAA,wBAAA,gBAAA;AACD,CALD,EAAYA,SAAS,KAATA,SAAS,KAAA,CAArB;;ACvJA,IAAMC,UAAU,GAAG,2DAAnB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B,SAAA;AACE,WACEC,aAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAK7C,KAAL,CAAW6C;AAClBC,MAAAA,SAAS,EAAE,KAAK9C,KAAL,CAAW8C;AACtBC,MAAAA,OAAO,EAAE,KAAK7B;KAHhB,EAKG,KAAKlB,KAAL,CAAWgD,QALd,CADF;AASD;;;EA7F6CJ;;;;;"}
1
+ {"version":3,"file":"index.modern.js","sources":["../src/interfaces.ts","../src/index.tsx"],"sourcesContent":["export interface IDeveloperField {\n label: string\n key: string\n type?: 'string' | 'checkbox' | 'select'\n description?: string\n alternateMatches?: string[]\n validators?: IValidatorField[]\n selectOptions?: {\n label: string\n value: string\n }[]\n}\n\nexport interface IValidatorField {\n validate:\n | 'required'\n | 'unique'\n | 'unique_case_insensitive'\n | 'regex_match'\n | 'regex_exclude'\n | 'require_with'\n | 'require_without'\n | 'require_with_all'\n | 'require_without_all'\n | 'require_with_values'\n | 'require_without_values'\n | 'require_with_all_values'\n | 'require_without_all_values'\n errorMessage?: string\n fields?: string[]\n fieldValues?: { [key: string]: any }\n regex?: string\n regexOptions?: {\n ignoreCase?: boolean\n dotAll?: boolean\n multiline?: boolean\n unicode?: boolean\n }\n}\n\nexport interface IDeveloperSettings {\n importIdentifier: string\n title?: string\n allowInvalidSubmit?: boolean\n backendSync?: boolean\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?: any[] | null\n matchingStep?: {\n headerRowOverride?: number | null\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}\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 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 column: string\n}\n\nexport interface ITableMessage {\n message: string\n level: 'info' | 'warning' | 'error'\n}\n\nexport type ITableMessageWithRef = ITableMessage & ICellRef\n\nexport interface IColumnHook {\n fieldName: string\n callback: (\n values: IColumnHookInput[]\n ) => IColumnHookOutput[] | Promise<IColumnHookOutput[]>\n}\n\nexport interface IRowHook {\n (data: IRowHookInput, mode: 'init' | 'update'):\n | IRowHookOutput\n | Promise<IRowHookOutput>\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 info?: ITableMessage[]\n }\n }\n index: number\n}\n\nexport interface IRowHookOutput {\n row: {\n [key: string]: {\n value?: any\n info?: ITableMessage[]\n }\n }\n}\n\nexport interface IRowHookOutputInternal extends IRowHookOutput {\n index: number\n}\n\nexport interface IResultMetadata {\n id: string | null\n importIdentifier: string\n user: IUser\n rowsWithError: number[]\n}\n\nexport type TLocaleShorthand = 'en'\n\n/* eslint-disable no-unused-vars */\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 dataPreview: any[][]\n}\n\nexport interface IReviewStepData {\n rawHeaders: string[] | null\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IReviewStepPostHooksData {\n headerMapping: { [header: string]: string | undefined }\n}\n\nexport interface IStepHook {\n type: EStepHook\n callback: (\n uploader: any,\n data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData\n ) => void | Promise<void>\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} 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 columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\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 // Add event listener post load to set up Dromo\n window.addEventListener(SCRIPT_LOADED_EVENT, this.scriptLoaded.bind(this))\n\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 componentWillUnmount() {\n window.removeEventListener(\n SCRIPT_LOADED_EVENT,\n this.scriptLoaded.bind(this)\n )\n }\n\n scriptLoaded = () => {\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.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\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\n open = () => {\n if (this.dromo) 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 EStepHook,\n IStepHook\n}\n"],"names":["EStepHook","SCRIPT_SRC","SCRIPT_LOADED_EVENT","DromoReactUploader","dromo","DromoUploader","props","licenseKey","fields","settings","user","rowHooks","forEach","hook","registerRowHook","columnHooks","registerColumnHook","fieldName","callback","onResults","onCancel","stepHooks","registerStepHook","type","open","componentDidMount","window","addEventListener","scriptLoaded","bind","loadingScript","Array","from","document","getElementsByTagName","find","s","src","script","createElement","async","onload","event","Event","dispatchEvent","body","appendChild","componentWillUnmount","removeEventListener","render","React","style","className","onClick","children"],"mappings":";;;;;;;;IAsMYA;;AAAZ,WAAYA;AACVA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,wBAAA,gBAAA;AACAA,EAAAA,mCAAA,2BAAA;AACD,CAJD,EAAYA,SAAS,KAATA,SAAS,KAAA,CAArB;;ACpKA,IAAMC,UAAU,GAAG,2DAAnB;AACA,IAAMC,mBAAmB,GAAG,qBAA5B;;IAEqBC;;;AAArB;;;;;AA8CE,sBAAA,GAAe;AACb,YAAKC,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,UAAI,MAAKJ,KAAL,CAAWK,QAAf,EAAyB;AACvB,cAAKL,KAAL,CAAWK,QAAX,CAAoBC,OAApB,CAA4B,UAACC,IAAD;AAAA,iBAAU,MAAKT,KAAL,CAAWU,eAAX,CAA2BD,IAA3B,CAAV;AAAA,SAA5B;AACD;;AAED,UAAI,MAAKP,KAAL,CAAWS,WAAf,EAA4B;AAC1B,cAAKT,KAAL,CAAWS,WAAX,CAAuBH,OAAvB,CAA+B,UAACC,IAAD;AAC7B,gBAAKT,KAAL,CAAWY,kBAAX,CAA8BH,IAAI,CAACI,SAAnC,EAA8CJ,IAAI,CAACK,QAAnD;AACD,SAFD;AAGD;;AAED,UAAI,MAAKZ,KAAL,CAAWa,SAAf,EAA0B;AACxB,cAAKf,KAAL,CAAWe,SAAX,CAAqB,MAAKb,KAAL,CAAWa,SAAhC;AACD;;AAED,UAAI,MAAKb,KAAL,CAAWc,QAA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IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,QAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,OALD,MAKO;AAGLZ,QAAAA,aAAa,CAACW,MAAd,GAAuB;AACrB,cAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAUzC,mBAAV,CAAd;AACAwB,UAAAA,MAAM,CAACkB,aAAP,CAAqBF,KAArB;AACD,SAHD;AAID;AACF;AACF;;SAEDK,uBAAA;AACErB,IAAAA,MAAM,CAACsB,mBAAP,CACE9C,mBADF,EAEE,KAAK0B,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAFF;AAID;;SAuCDoB,SAAA;AACE,WACEC,aAAA,SAAA;AACEC,MAAAA,KAAK,EAAE,KAAK7C,KAAL,CAAW6C;AAClBC,MAAAA,SAAS,EAAE,KAAK9C,KAAL,CAAW8C;AACtBC,MAAAA,OAAO,EAAE,KAAK7B;KAHhB,EAKG,KAAKlB,KAAL,CAAWgD,QALd,CADF;AASD;;;EA7F6CJ;;;;;"}
@@ -11,7 +11,7 @@ export interface IDeveloperField {
11
11
  }[];
12
12
  }
13
13
  export interface IValidatorField {
14
- validate: 'required' | 'unique' | 'regex_match' | 'regex_exclude' | 'require_with' | 'require_without' | 'require_with_all' | 'require_without_all' | 'require_with_values' | 'require_without_values' | 'require_with_all_values' | 'require_without_all_values';
14
+ validate: 'required' | 'unique' | 'unique_case_insensitive' | 'regex_match' | 'regex_exclude' | 'require_with' | 'require_without' | 'require_with_all' | 'require_without_all' | 'require_with_values' | 'require_without_values' | 'require_with_all_values' | 'require_without_all_values';
15
15
  errorMessage?: string;
16
16
  fields?: string[];
17
17
  fieldValues?: {
@@ -39,6 +39,9 @@ export interface IDeveloperSettings {
39
39
  styleOverrides?: IDeveloperStyleOverrides;
40
40
  webhookUrl?: string;
41
41
  initialData?: any[] | null;
42
+ matchingStep?: {
43
+ headerRowOverride?: number | null;
44
+ };
42
45
  autoMapHeaders?: boolean;
43
46
  delimiter?: string;
44
47
  backendOverride?: {
@@ -106,10 +109,15 @@ export interface IUser {
106
109
  companyId?: string;
107
110
  companyName?: string;
108
111
  }
112
+ export interface ICellRef {
113
+ rowIndex: number;
114
+ column: string;
115
+ }
109
116
  export interface ITableMessage {
110
117
  message: string;
111
118
  level: 'info' | 'warning' | 'error';
112
119
  }
120
+ export declare type ITableMessageWithRef = ITableMessage & ICellRef;
113
121
  export interface IColumnHook {
114
122
  fieldName: string;
115
123
  callback: (values: IColumnHookInput[]) => IColumnHookOutput[] | Promise<IColumnHookOutput[]>;
@@ -130,6 +138,7 @@ export interface IRowHookInput {
130
138
  row: {
131
139
  [key: string]: {
132
140
  value: any;
141
+ info?: ITableMessage[];
133
142
  };
134
143
  };
135
144
  index: number;
@@ -154,7 +163,8 @@ export interface IResultMetadata {
154
163
  export declare type TLocaleShorthand = 'en';
155
164
  export declare enum EStepHook {
156
165
  UPLOAD_STEP = "UPLOAD_STEP",
157
- REVIEW_STEP = "REVIEW_STEP"
166
+ REVIEW_STEP = "REVIEW_STEP",
167
+ REVIEW_STEP_POST_HOOKS = "REVIEW_STEP_POST_HOOKS"
158
168
  }
159
169
  export interface IUploadStepData {
160
170
  dataPreview: any[][];
@@ -165,7 +175,12 @@ export interface IReviewStepData {
165
175
  [header: string]: string | undefined;
166
176
  };
167
177
  }
178
+ export interface IReviewStepPostHooksData {
179
+ headerMapping: {
180
+ [header: string]: string | undefined;
181
+ };
182
+ }
168
183
  export interface IStepHook {
169
184
  type: EStepHook;
170
- callback: (uploader: any, data: IUploadStepData | IReviewStepData) => void | Promise<void>;
185
+ callback: (uploader: any, data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData) => void | Promise<void>;
171
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dromo-uploader-react",
3
- "version": "1.2.9",
3
+ "version": "1.2.13",
4
4
  "description": "Easy to use data (CSV, TSV, Excel) importer",
5
5
  "author": "ankitgoyal100",
6
6
  "license": "MIT",