eszutils v1.1.60
esUtils
:link: See documentation
Update & publish
- Setup NPM token in ~/.profile or ~/.bash_profile :
export NPM_TOKEN="0000-00000-00000-00000-00000"
- before each git commit, run
yarn build
- before deploy, run
yarn build
, increase version in package.json, git commit andnpm publish
Project init
Some methods need to be called to bootstrap the project. These methods should be called in the js file that is first executed.
- appGlobalVarInit(name: string, prefix: string) to give access to the global variable containing app data
- initDataLayer(customMethods: KeyedObject = {}) to get the dataLayer ready and set custom methods
- initSteps(steps: Steps) to define the steps list for the app
- initIcons(icons: KeyedObject<JSX.Element>) to append icons to the default set
- initModal(modalContainers: KeyedObject, prefix: string) to provide modal containers and app prefix
- setAppStoreVar(store: any) to provide access to the appStore
Endpoints list
The initial state should provide a few endpoints for some modules:
window.appName = {
"endpoints": {
"getLanguages": "/api/lang%%lang%%.json?1=1",
"saveState": "/api/saveState.json?1=1",
"getCountries": "/api/countries%%lang%%.json",
"GetCityProposals": "/api/GetCityProposals.json",
"GetPostalAddressProposals": "/api/GetPostalAddressProposals.json",
"getIBPBrokers" : "/api/getIBPBrokers.json?1=1",
"getAgentData": "/api/getAgentData.json?1=1",
"saveBlockedInFlowReason": "/api/submitStep.json?1=1",
}
}
API
Types
KeyedObject<T = any> = {[k: string]: T}
Step = { "index": number, "ID": string, "number": number, "pageTitle": string, "chapter": string }
Steps = Step[]
Data
phoneCountriesList: { "name": { "FR": string, "NL": string }, "dial_code": string, "code": string, "flag": string }[]
RegExp
patternPhone
patternPhoneMobile
patternEmail
Utils / Analytics
getGaAccount(): string
getGoogleAnalyticsId(): string
trackConversion(id: string): void
Utils / DataLayer
initDataLayer(customMethods: KeyedObject<Function> = {}): void
getDataLayer(): DataLayer
dataLayerMiddleware: Middleware({ getState }: MiddlewareAPI)
Utils / Dates
parseDate(date: string): moment.Moment
getCurrentDate(): moment.Moment
getDifferenceInYears( firstDate: moment.Moment, secondDate: moment.Moment ): number
getIsAdult(dob: string): boolean
Utils / Display
scrollTo(speed = 100, scrollTargetY = 0): void
shouldShowIf(condition: boolean): { "hidden"?: boolean }
Utils / FieldFormatters
priceFormatter(value: string): string
priceNormalizerFactory(digitsCount?: number, decimalCount?: number): Function
priceNormalizer(value: string): string
Utils / GlobalVars
appGlobalVarInit(name: string, prefix: string): void
setAppStoreVar(store: any): void
getAppStore(): any
getAppGlobalVar(): KeyedObject
getAppPrefix(): string
Utils / Performance
throttle(fn: Function, threshhold: number, scope: any): Function
requestAnimFrame(): Function
Utils / State
getInitialState(): KeyedObject
getEndPoints(): KeyedObject
getWhatsappPhone(): KeyedObject
wrapMapStateToProps( state: KeyedObject, commonItems: KeyedObject, appItems: KeyedObject ): KeyedObject
Utils / Steps
initSteps(steps: Steps): void
getStepByIndex(index: number): Step
getStepById(id: string): Step | undefined
getNextStep(step: Step): Step | null
getPreviousStep(step: Step): Step | null
getLastStep(): Step
getStepInNumberFormat(stepString: string): string
Utils / Strings
PHONE_FIXED
PHONE_MOBILE
parseStringTemplate( str: string, replacements: KeyedObject<string> ): string
capitalizeFirstLetter(s: string): string
composeStreetAddress( street: string, streetNr: string, postalBoxText = "", boxNr = "" ): string
composeCityAddress(postalCode: number | string, city: string): string
composeFullAddress( street: string, streetNr: string, postalBoxText = "", boxNr = "", postalCode: number | string, city: string, oneLine: boolean ): string
composeGmapsAddress( street = "", streetNumber = "", postalCode = "", city = "" ): string
formatPrice(price: string, lang = "fr"): string
formatPercentage(num: number): string
normalizeCountryPrefixTo00(prefix: string): string
normalizeCountryPrefixToPlus(prefix: string): string
normalizeAreaPrefix(prefix: string): string
constructPhoneNumber(prefix: string, phoneNumber: string): string
getPhoneType(phone: string): string
phoneTransform(phone: string): string | null
getOptionLabelFromValue( options: Array<KeyedObject<string>>, value: string ): string
getGuid(): string
Utils / URL
getHistoryLocation(): string
Utils / Validation
required(value: any): undefined | JSX.Element
isValidDate(value: string): boolean
dateAfterToday(value: string): boolean | undefined | JSX.Element
dateWithinYear(value: string): boolean | undefined | JSX.Element
validDate(value: string): boolean | undefined | JSX.Element
dateNotBefore1900(value: string): undefined | JSX.Element
dateNotInFuture(value: string): undefined | JSX.Element
validEmail(value: string): undefined | JSX.Element
validPhoneLogic(phoneNumber: string): boolean
validPhone(value: string): undefined | JSX.Element
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago