react-dpd-pickup-map 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # react-dpd-pickup-map
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - cef9f5e: Init release
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Juliusz Kowalewski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # react-dpd-pickup-map
2
+
3
+ React component for implementing a DPD Pickup Map
4
+
5
+ ## Installation
6
+
7
+ Install react-dpd-pickup-map with npm
8
+
9
+ ```bash
10
+ npm install react-dpd-pickup-map
11
+ ```
12
+
13
+ ## Usage/Examples
14
+
15
+ ```typescript
16
+ import ReactDPDPickupMap from 'react-dpd-pickup-map'
17
+
18
+ function App() {
19
+ return <ReactDPDPickupMap
20
+ authKey='YOUR_AUTH_KEY' //<- Your own auth key for pudofinder.dpd.com.pl
21
+ lang='pl' //<- Defaults to: pl
22
+ country='PL' //<- Defaults to: PL
23
+ services={{
24
+ openSaturdays=true
25
+ openSundays=true
26
+ }}
27
+ />
28
+ }
29
+ ```
30
+
31
+ ## Available services
32
+
33
+ | Parameter | Type | Default | Description |
34
+ | :------------------- | :-------- | :------ | :--------------------------------------------- |
35
+ | `openLate` | `boolean` | `false` | Points open Late |
36
+ | `openSaturdays` | `boolean` | `false` | Points open in Saturdays |
37
+ | `openSundays` | `boolean` | `false` | Points open in Sundays |
38
+ | `disabledFriendly` | `boolean` | `false` | Points friendly for disabled people |
39
+ | `parking` | `boolean` | `false` | Points with parking |
40
+ | `directDelivery` | `boolean` | `false` | Direct delivery |
41
+ | `directDeliveryCOD` | `boolean` | `false` | Direct delivery with cash on delivery |
42
+ | `dropOffOnline` | `boolean` | `false` | Sending a paid shipment |
43
+ | `dropOffOffline` | `boolean` | `false` | Points with on-site shipping + payment and BOD |
44
+ | `swapParcel` | `boolean` | `false` | Points with return shipment |
45
+ | `dpdFood` | `boolean` | `false` | Points with DPD Food |
46
+ | `fittingRoom` | `boolean` | `false` | Points with fitting room |
47
+ | `cardPayment` | `boolean` | `false` | Points with card payment |
48
+ | `rod` | `boolean` | `false` | Point with return documents |
49
+ | `dpdLQ` | `boolean` | `false` | DPD LG |
50
+ | `digitalLabel` | `boolean` | `false` | Point with shipping without a label |
51
+ | `swipBox` | `boolean` | `false` | Parcela machines |
52
+ | `pointsWithServices` | `boolean` | `false` | Points with services |
53
+
54
+ ## Authors
55
+
56
+ - [@Imunal](https://github.com/Imunal)
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+
3
+ interface IReactDPDPickupMap {
4
+ authKey: string;
5
+ onPointSelect: (pointID: string) => void;
6
+ lang: "pl" | "de" | "se" | "fr";
7
+ country: "AT" | "BE" | "HR" | "CZ" | "DK" | "EE" | "FI" | "FR" | "ES" | "NL" | "LT" | "LV" | "DE" | "PT" | "SK" | "SE" | "HU" | "IT" | "PL";
8
+ services?: {
9
+ openLate?: boolean;
10
+ openSaturdays?: boolean;
11
+ openSundays?: boolean;
12
+ disabledFriendly?: boolean;
13
+ parking?: boolean;
14
+ directDelivery?: boolean;
15
+ directDeliveryCOD?: boolean;
16
+ dropOffOnline?: boolean;
17
+ dropOffOffline?: boolean;
18
+ swapParcel?: boolean;
19
+ dpdFood?: boolean;
20
+ fittingRoom?: boolean;
21
+ cardPayment?: boolean;
22
+ rod?: boolean;
23
+ dpdLQ?: boolean;
24
+ digitalLabel?: boolean;
25
+ swipBox?: boolean;
26
+ pointsWithServices?: boolean;
27
+ };
28
+ }
29
+ declare const ReactDPDPickupMap: ({ authKey, onPointSelect, lang, country, services, }: IReactDPDPickupMap) => React.JSX.Element;
30
+
31
+ export { ReactDPDPickupMap };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+
3
+ interface IReactDPDPickupMap {
4
+ authKey: string;
5
+ onPointSelect: (pointID: string) => void;
6
+ lang: "pl" | "de" | "se" | "fr";
7
+ country: "AT" | "BE" | "HR" | "CZ" | "DK" | "EE" | "FI" | "FR" | "ES" | "NL" | "LT" | "LV" | "DE" | "PT" | "SK" | "SE" | "HU" | "IT" | "PL";
8
+ services?: {
9
+ openLate?: boolean;
10
+ openSaturdays?: boolean;
11
+ openSundays?: boolean;
12
+ disabledFriendly?: boolean;
13
+ parking?: boolean;
14
+ directDelivery?: boolean;
15
+ directDeliveryCOD?: boolean;
16
+ dropOffOnline?: boolean;
17
+ dropOffOffline?: boolean;
18
+ swapParcel?: boolean;
19
+ dpdFood?: boolean;
20
+ fittingRoom?: boolean;
21
+ cardPayment?: boolean;
22
+ rod?: boolean;
23
+ dpdLQ?: boolean;
24
+ digitalLabel?: boolean;
25
+ swipBox?: boolean;
26
+ pointsWithServices?: boolean;
27
+ };
28
+ }
29
+ declare const ReactDPDPickupMap: ({ authKey, onPointSelect, lang, country, services, }: IReactDPDPickupMap) => React.JSX.Element;
30
+
31
+ export { ReactDPDPickupMap };
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.tsx
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ ReactDPDPickupMap: () => ReactDPDPickupMap
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_react = __toESM(require("react"));
38
+ var boolToInt = (value) => value ? "1" : "0";
39
+ var ReactDPDPickupMap = ({
40
+ authKey,
41
+ onPointSelect,
42
+ lang = "pl",
43
+ country = "PL",
44
+ services = {}
45
+ }) => {
46
+ (0, import_react.useEffect)(() => {
47
+ const container = document.getElementById("dpd-widget-container");
48
+ if (!container)
49
+ return;
50
+ window.pointSelected = (pointID) => onPointSelect(pointID);
51
+ const queryParams = new URLSearchParams({
52
+ key: authKey,
53
+ lang,
54
+ country,
55
+ //Map
56
+ open_late: boolToInt(services.openLate || false),
57
+ open_saturdays: boolToInt(services.openSaturdays || false),
58
+ open_sundays: boolToInt(services.openSundays || false),
59
+ disabled_friendly: boolToInt(services.disabledFriendly || false),
60
+ parking: boolToInt(services.parking || false),
61
+ direct_delivery: boolToInt(services.directDelivery || false),
62
+ direct_delivery_cod: boolToInt(services.directDeliveryCOD || false),
63
+ dropoff_online: boolToInt(services.dropOffOnline || false),
64
+ dropoff_offline: boolToInt(services.dropOffOffline || false),
65
+ swap_parcel: boolToInt(services.swapParcel || false),
66
+ d_fresh: boolToInt(services.dpdFood || false),
67
+ fitting_room: boolToInt(services.fittingRoom || false),
68
+ card_payment: boolToInt(services.cardPayment || false),
69
+ rod: boolToInt(services.rod || false),
70
+ dpd_lq: boolToInt(services.dpdLQ || false),
71
+ digital_label: boolToInt(services.digitalLabel || false),
72
+ swip_box: boolToInt(services.swipBox || false),
73
+ points_with_services: boolToInt(services.pointsWithServices || false)
74
+ });
75
+ const script = document.createElement("script");
76
+ script.id = "dpd-widget";
77
+ script.src = `//pudofinder.dpd.com.pl/source/dpd_widget.js?${queryParams}`;
78
+ script.async = true;
79
+ document.body.appendChild(script);
80
+ return () => {
81
+ document.body.removeChild(script);
82
+ delete window.pointSelected;
83
+ };
84
+ }, [authKey, onPointSelect, lang, country, services]);
85
+ return /* @__PURE__ */ import_react.default.createElement("div", { id: "dpd-widget-container" }, /* @__PURE__ */ import_react.default.createElement("script", { id: "dpd-widget" }));
86
+ };
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ ReactDPDPickupMap
90
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ // src/index.tsx
4
+ import React, { useEffect } from "react";
5
+ var boolToInt = (value) => value ? "1" : "0";
6
+ var ReactDPDPickupMap = ({
7
+ authKey,
8
+ onPointSelect,
9
+ lang = "pl",
10
+ country = "PL",
11
+ services = {}
12
+ }) => {
13
+ useEffect(() => {
14
+ const container = document.getElementById("dpd-widget-container");
15
+ if (!container)
16
+ return;
17
+ window.pointSelected = (pointID) => onPointSelect(pointID);
18
+ const queryParams = new URLSearchParams({
19
+ key: authKey,
20
+ lang,
21
+ country,
22
+ //Map
23
+ open_late: boolToInt(services.openLate || false),
24
+ open_saturdays: boolToInt(services.openSaturdays || false),
25
+ open_sundays: boolToInt(services.openSundays || false),
26
+ disabled_friendly: boolToInt(services.disabledFriendly || false),
27
+ parking: boolToInt(services.parking || false),
28
+ direct_delivery: boolToInt(services.directDelivery || false),
29
+ direct_delivery_cod: boolToInt(services.directDeliveryCOD || false),
30
+ dropoff_online: boolToInt(services.dropOffOnline || false),
31
+ dropoff_offline: boolToInt(services.dropOffOffline || false),
32
+ swap_parcel: boolToInt(services.swapParcel || false),
33
+ d_fresh: boolToInt(services.dpdFood || false),
34
+ fitting_room: boolToInt(services.fittingRoom || false),
35
+ card_payment: boolToInt(services.cardPayment || false),
36
+ rod: boolToInt(services.rod || false),
37
+ dpd_lq: boolToInt(services.dpdLQ || false),
38
+ digital_label: boolToInt(services.digitalLabel || false),
39
+ swip_box: boolToInt(services.swipBox || false),
40
+ points_with_services: boolToInt(services.pointsWithServices || false)
41
+ });
42
+ const script = document.createElement("script");
43
+ script.id = "dpd-widget";
44
+ script.src = `//pudofinder.dpd.com.pl/source/dpd_widget.js?${queryParams}`;
45
+ script.async = true;
46
+ document.body.appendChild(script);
47
+ return () => {
48
+ document.body.removeChild(script);
49
+ delete window.pointSelected;
50
+ };
51
+ }, [authKey, onPointSelect, lang, country, services]);
52
+ return /* @__PURE__ */ React.createElement("div", { id: "dpd-widget-container" }, /* @__PURE__ */ React.createElement("script", { id: "dpd-widget" }));
53
+ };
54
+ export {
55
+ ReactDPDPickupMap
56
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "react-dpd-pickup-map",
3
+ "version": "0.0.1",
4
+ "description": "React component for DPD Pickup Map",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "keywords": [
9
+ "dpd",
10
+ "react",
11
+ "dpd pickup",
12
+ "dpd pickup map",
13
+ "react dpd"
14
+ ],
15
+ "author": "Juliusz Kowalewski @Imunal",
16
+ "license": "MIT",
17
+ "bugs": {
18
+ "url": "https://github.com/Imunal/react-dpd-pickup-map/issues"
19
+ },
20
+ "homepage": "https://github.com/Imunal/react-dpd-pickup-map",
21
+ "repository": {
22
+ "type": "github",
23
+ "url": "https://github.com/Imunal/react-dpd-pickup-map"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^18.2.72",
27
+ "@types/react-dom": "^18.2.22",
28
+ "tsup": "^8.0.2",
29
+ "typescript": "^5.4.3"
30
+ },
31
+ "dependencies": {
32
+ "react": "^18.2.0",
33
+ "react-dom": "^18.2.0"
34
+ },
35
+ "scripts": {
36
+ "dev": "tsup src/index.tsx --watch",
37
+ "build": "tsup src/index.tsx --format cjs,esm --dts",
38
+ "lint": "tsc"
39
+ }
40
+ }