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
patternPhonepatternPhoneMobilepatternEmail
Utils / Analytics
getGaAccount(): stringgetGoogleAnalyticsId(): stringtrackConversion(id: string): void
Utils / DataLayer
initDataLayer(customMethods: KeyedObject<Function> = {}): voidgetDataLayer(): DataLayerdataLayerMiddleware: Middleware({ getState }: MiddlewareAPI)
Utils / Dates
parseDate(date: string): moment.MomentgetCurrentDate(): moment.MomentgetDifferenceInYears( firstDate: moment.Moment, secondDate: moment.Moment ): numbergetIsAdult(dob: string): boolean
Utils / Display
scrollTo(speed = 100, scrollTargetY = 0): voidshouldShowIf(condition: boolean): { "hidden"?: boolean }
Utils / FieldFormatters
priceFormatter(value: string): stringpriceNormalizerFactory(digitsCount?: number, decimalCount?: number): FunctionpriceNormalizer(value: string): string
Utils / GlobalVars
appGlobalVarInit(name: string, prefix: string): voidsetAppStoreVar(store: any): voidgetAppStore(): anygetAppGlobalVar(): KeyedObjectgetAppPrefix(): string
Utils / Performance
throttle(fn: Function, threshhold: number, scope: any): FunctionrequestAnimFrame(): Function
Utils / State
getInitialState(): KeyedObjectgetEndPoints(): KeyedObjectgetWhatsappPhone(): KeyedObjectwrapMapStateToProps( state: KeyedObject, commonItems: KeyedObject, appItems: KeyedObject ): KeyedObject
Utils / Steps
initSteps(steps: Steps): voidgetStepByIndex(index: number): StepgetStepById(id: string): Step | undefinedgetNextStep(step: Step): Step | nullgetPreviousStep(step: Step): Step | nullgetLastStep(): StepgetStepInNumberFormat(stepString: string): string
Utils / Strings
PHONE_FIXEDPHONE_MOBILEparseStringTemplate( str: string, replacements: KeyedObject<string> ): stringcapitalizeFirstLetter(s: string): stringcomposeStreetAddress( street: string, streetNr: string, postalBoxText = "", boxNr = "" ): stringcomposeCityAddress(postalCode: number | string, city: string): stringcomposeFullAddress( street: string, streetNr: string, postalBoxText = "", boxNr = "", postalCode: number | string, city: string, oneLine: boolean ): stringcomposeGmapsAddress( street = "", streetNumber = "", postalCode = "", city = "" ): stringformatPrice(price: string, lang = "fr"): stringformatPercentage(num: number): stringnormalizeCountryPrefixTo00(prefix: string): stringnormalizeCountryPrefixToPlus(prefix: string): stringnormalizeAreaPrefix(prefix: string): stringconstructPhoneNumber(prefix: string, phoneNumber: string): stringgetPhoneType(phone: string): stringphoneTransform(phone: string): string | nullgetOptionLabelFromValue( options: Array<KeyedObject<string>>, value: string ): stringgetGuid(): string
Utils / URL
getHistoryLocation(): string
Utils / Validation
required(value: any): undefined | JSX.ElementisValidDate(value: string): booleandateAfterToday(value: string): boolean | undefined | JSX.ElementdateWithinYear(value: string): boolean | undefined | JSX.ElementvalidDate(value: string): boolean | undefined | JSX.ElementdateNotBefore1900(value: string): undefined | JSX.ElementdateNotInFuture(value: string): undefined | JSX.ElementvalidEmail(value: string): undefined | JSX.ElementvalidPhoneLogic(phoneNumber: string): booleanvalidPhone(value: string): undefined | JSX.Element
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago