0.0.68 • Published 4 years ago

@dhl-parcel/dhl-servicepoint-locator v0.0.68

Weekly downloads
41
License
UNLICENSED
Repository
github
Last release
4 years ago

dhl-servicepoint-locator

DHL Servicepoint Locator

NPM JavaScript Style Guide

Impression

DesktopMobile
npm.ionpm.io

Code example (with vanilla javascript)

https://codesandbox.io/s/wjox7zy1w

Install

npm install --save dhl-servicepoint-locator

Development environment

  • npm start Starts demo environment for local development
  • npm build Creates a distribution. We use rollup.
  • npm watch Continuously creates a distribution. Awesome in combination with npm link
  • npm publish --access public Publishes to npmjs

Docs

The component can be parameterized, either by passsing an options object ({}) to the callback specified under data-setup, or by specifying them as data- attributes on the DOM element the component will be mounted in, or in some cases by specifying them in the query string of the host URL, with the following properties:

PropertyDescription
host or data-hostAPI host to connect to for the API calls.
apiKey or data-api-keyGoogle Maps API key for showing the map.
postalCode or data-postal-code or ?pc=Postal code to perform a specific search with.
query or data-query or ?q=Query term to perform a generic search with.
limit or data-limit or ?l=Number to limit the amount of returned search results.
tr or data-trCallback that receives a translation key as the sole argument. Must return the translated value for that key.
locale or data-localeISO 639-1 value that determines the used locale (example: nl-NL).
countryCode or data-country-codeISO 639-1 value that which country the search should be performed in (example: BE).
selected or data-selectedValue that preselects a specific ServicePoint.
onChange or data-onchangeCallback that receives the selected ServicePoint when a user interacts with the component.
disableRefresh or data-disable-refreshDetermines whether the data should be refreshed automatically when the user pans on the map.
disableUrlSync or data-disable-url-syncDetermines whether the address bar should be synchronized to reflect the state of the component.
data-setupSpecifies a location on the window object where a callback that sets up the component can be stored to be invoked at a later time. Can be called multiple times with new properties to update the component and returns a callback that can be invoked to teardown the component.
toggleMap or data-toggle-mapDetermines whether the mobile viewport can toggle between the list and map view. If omitted, both are displayed.
mapWidth or data-map-widthIf toggleMap is used, can be used to set the map width.
mapHeight or data-map-heightIf toggleMap is used, can be used to set the map height.
mapPosition or data-map-positionIf toggleMap is used, can be used to set the map position.

Usage

import React, { Component } from 'react'
import { ParcelshopLocator } from 'dhl-servicepoint-locator'

class App extends React.Component {
  state = {
    selected: ''
  }

  render() {
    return (
      <div>
        <ParcelshopLocator
          host="https://api-gw.dhlparcel.nl"
          apiKey="<provide_api_key>"
          countryCode="<provide_country_code>"
          zipCode="<provide_postal_code>"
          query="<provide_search_query>"
          onChange={parcelshop =>
            this.setState({
              selected: parcelshop.id
            })
          }
          selected={this.state.selected}
          tr={value => value}
        />
      </div>
    )
  }
}

Remarks

Installing flow types with flow-typed install results in a bug in flow-typed.

UNCAUGHT ERROR: Error: Found react listed twice in package.json!

To fix it you have to temporary clean the peerDependencies befor you install flowtypes.

Interesting reads

Rollup vs webpack

Using npm link

Setup rollup/webpack

License

UNLICENSED © DHL

0.0.68

4 years ago

0.0.67

5 years ago

0.0.66

5 years ago

0.0.65

5 years ago

0.0.64

5 years ago

0.0.63

5 years ago

0.0.62

5 years ago

0.0.61

5 years ago

0.0.60

5 years ago

0.0.59

5 years ago

0.0.58

5 years ago

0.0.57

5 years ago

0.0.56

5 years ago

0.0.55

5 years ago

0.0.54

5 years ago

0.0.53

5 years ago

0.0.52

5 years ago

0.0.51

5 years ago

0.0.50

5 years ago

0.0.49

5 years ago

0.0.48

5 years ago

0.0.47

5 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.44

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.41

6 years ago

0.0.40

6 years ago

0.0.39

6 years ago

0.0.38

6 years ago

0.0.37

6 years ago

0.0.36

6 years ago

0.0.35

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago