1.1.60 • Published 4 years ago

eszutils v1.1.60

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

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 and npm 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
1.1.60

4 years ago

1.1.59

4 years ago

1.1.58

4 years ago

1.1.56

4 years ago

1.1.55

4 years ago

1.1.32

4 years ago

1.1.52

4 years ago

1.1.54

4 years ago

1.1.53

4 years ago

1.1.51

4 years ago

1.1.50

4 years ago

1.1.49

4 years ago

1.1.48

4 years ago

1.1.47

4 years ago

1.1.46

4 years ago

1.1.45

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.41

4 years ago

1.1.42

4 years ago

1.1.40

4 years ago

1.1.31

4 years ago

1.1.29

4 years ago

1.1.30

4 years ago

1.1.28

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.23

5 years ago

1.1.22

5 years ago

1.1.21

5 years ago

1.1.20

5 years ago

1.1.19

5 years ago

1.1.18

5 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.97

5 years ago

1.0.96

5 years ago

1.0.95

5 years ago

1.0.94

5 years ago

1.0.93

5 years ago

1.0.92

5 years ago

1.0.91

5 years ago

1.0.90

5 years ago

1.0.89

5 years ago

1.0.88

5 years ago

1.0.87

5 years ago

1.0.86

5 years ago

1.0.85

5 years ago

1.0.84

5 years ago

1.0.83

5 years ago

1.0.82

5 years ago

1.0.81

5 years ago

1.0.80

5 years ago

1.0.79

5 years ago

1.0.78

5 years ago

1.0.77

5 years ago

1.0.76

5 years ago

1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

5 years ago

1.0.72

5 years ago

1.0.71

5 years ago

1.0.70

5 years ago

1.0.69

5 years ago

1.0.68

5 years ago

1.0.67

5 years ago

1.0.66

5 years ago

1.0.65

5 years ago

1.0.64

5 years ago

1.0.63

5 years ago

1.0.62

5 years ago

1.0.61

5 years ago

1.0.60

5 years ago

1.0.59

5 years ago

1.0.58

5 years ago

1.0.57

5 years ago

1.0.56

5 years ago

1.0.55

5 years ago

1.0.54

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago