0.2.2 • Published 6 years ago

@dhl-parcel/dhl-parcel-data-importer v0.2.2

Weekly downloads
1
License
UNLICENSED
Repository
github
Last release
6 years ago

dhl-upload-form

This module exposes a simple form component that handles the upload and parsing of CSV files, with the option to map the parsed data to a predefined structure.

Install

npm i --save dhl-parcel-upload-form

Impression

UploadSchema
npm.ionpm.io

Available Scripts

In the project directory, you can run:

npm run build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

npm run flow

Check all flow types in the application for possible errors.

npm run lint

Perform a linting operation to check for possible errors.

npm run watch

Run continuous iterations of the build process for development.

API

Schema props

namedescriptiontypedefault
typea unique name for the component, allows for multiple instances of the componentstring'import'
categoryused to name and filter schema types, can differ from type, see according parameter in postSchemasstring'import'
fields(optional) names of the fieldsArray\<string>[]
mandatoryFieldsrequired names of the fields, the component will validate on thisArray\<string>[]
dependsfields with names that equal to a key of this prop will be disabled unless first the field that corresponds to the value of this prop is selected{string: string}{}
setMappingfunction that will be called with the result of the parsed and mapped file(result: {string: any}) => void
normalizefunction that will be used to properly format/ trim a value before persisting.(string, string, string) => string(field: string, depends: string, val: string) => val
getRegexForFieldfunction that will be called to return the regex rules for validation of a field name, the second parameter is usally used to pass a countryCode on wich the regex rule should be based(string, string) => RegExp() => null
showToastMessagefunction that will be called to display a message and action string(string, string) => void
getSchemasPromise that will resolve to a schema array used for presets, see the mapping param in postSchemas for details on this arrayPromise
postSchemasPromise that wil resolve to a Response, it should be used to post 'preset schemes' that need to be persisted, type and category are used to filter and tag the preset(schemes: Array\< {id: string, category: string, name: string, matches: {string: string}}>, mapping: Array\<any>, name: string, category: string)=> PromisePromise.resolve
trfunction that will be called to display a translated value. It will be passed a translation key that can to be mapped to a value, locale is not passed.str => str
getTranslationMappingfunction that will be called by tr callback to allow for for the translation key used in the component to be mapped, this is usefull if you can't modify your translation file, or if it has prefixed keys.string => string(str: string) => str