@artaio/arta-browser 2.19.0 → 2.19.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/dist/ModalStatus.js +3 -4
- package/dist/arta.js +26 -39
- package/dist/bundle.js +1 -1
- package/dist/components/Date/SimpleDate.js +11 -11
- package/dist/components/Date/index.js +13 -13
- package/dist/components/Destination/countriesWithoutPostalCode.js +5 -4
- package/dist/components/Destination/index.js +20 -25
- package/dist/components/Disqualified/index.js +15 -14
- package/dist/components/DrawerFooter/index.js +7 -6
- package/dist/components/DrawerHeader/index.js +8 -8
- package/dist/components/DrawerInsurance/index.js +7 -6
- package/dist/components/Footer/index.js +7 -7
- package/dist/components/Header/index.js +7 -7
- package/dist/components/Invalidated/index.js +7 -7
- package/dist/components/Loading/index.js +7 -6
- package/dist/components/Modal/index.css.js +7 -0
- package/dist/components/Modal/index.d.ts +0 -1
- package/dist/components/Modal/index.js +67 -132
- package/dist/components/Package/index.js +24 -25
- package/dist/components/PackageEvents/index.js +43 -88
- package/dist/components/Pill/index.js +8 -8
- package/dist/components/Quotes/index.js +26 -25
- package/dist/components/SelectTrackingShipment/index.js +31 -35
- package/dist/components/ShipToFrom/index.js +13 -13
- package/dist/components/ShipmentException/icons/ExceptionIcon.js +12 -12
- package/dist/components/ShipmentException/icons/HexagonAlertBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonPauseBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonStopBase.js +7 -7
- package/dist/components/ShipmentException/index.js +25 -27
- package/dist/components/Summary/index.js +7 -7
- package/dist/components/Timeline/CheckedStep.js +12 -12
- package/dist/components/Timeline/CheckedSteps.js +7 -7
- package/dist/components/Timeline/EmptyStep.js +7 -7
- package/dist/components/Timeline/SecondaryStep.js +7 -7
- package/dist/components/Timeline/SecondarySteps.js +7 -7
- package/dist/components/Timeline/TimelineDefault.js +22 -22
- package/dist/components/Timeline/TimlineMinimal.js +24 -25
- package/dist/components/Timeline/defaultIcons/CancelledIcon.js +8 -8
- package/dist/components/Timeline/defaultIcons/CollectedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/CompletedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/InTransitIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/PendingIcon.js +8 -8
- package/dist/components/Timeline/icons/CancelledIconBase.js +7 -7
- package/dist/components/Timeline/icons/CollectedIconBase.js +7 -7
- package/dist/components/Timeline/icons/CompletedIconBase.js +7 -7
- package/dist/components/Timeline/icons/ConfirmedIconBase.js +7 -7
- package/dist/components/Timeline/icons/InTransitIconBase.js +7 -7
- package/dist/components/Timeline/icons/PendingIconBase.js +7 -7
- package/dist/components/Timeline/index.js +9 -9
- package/dist/components/TrackingDrawer/index.css.js +7 -0
- package/dist/components/TrackingDrawer/index.d.ts +0 -1
- package/dist/components/TrackingDrawer/index.js +33 -81
- package/dist/components/TrackingShipment/index.js +27 -66
- package/dist/components/TrackingTop/index.js +14 -14
- package/dist/estimate.js +41 -83
- package/dist/estimateConfig.js +16 -14
- package/dist/fixtures/countries.js +5 -4
- package/dist/helper.js +61 -64
- package/dist/index.js +15 -34
- package/dist/requests.js +71 -191
- package/dist/tracking.js +77 -128
- package/dist/trackingConfig.js +11 -9
- package/package.json +8 -5
- package/dist/MetadataTypes.js +0 -2
- package/dist/typing.js +0 -1
package/dist/tracking.js
CHANGED
|
@@ -1,163 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
40
|
-
var preact_1 = require("preact");
|
|
41
|
-
var TrackingDrawer_1 = require("./components/TrackingDrawer");
|
|
42
|
-
var requests_1 = require("./requests");
|
|
43
|
-
var SHIPMENT_LIMIT_IDX = 100;
|
|
44
|
-
var Tracking = /** @class */ (function () {
|
|
45
|
-
function Tracking(shipmentIdOrIds, config, el) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
6
|
+
var preact = require('preact');
|
|
7
|
+
var index = require('./components/TrackingDrawer/index.js');
|
|
8
|
+
var requests = require('./requests.js');
|
|
9
|
+
|
|
10
|
+
const SHIPMENT_LIMIT_IDX = 100;
|
|
11
|
+
class Tracking {
|
|
12
|
+
shipmentIdOrIds;
|
|
13
|
+
config;
|
|
14
|
+
el;
|
|
15
|
+
isReady = false;
|
|
16
|
+
isOpen = false;
|
|
17
|
+
shipmentIds = [];
|
|
18
|
+
fadeOut = {
|
|
19
|
+
fade: {
|
|
20
|
+
left: [{ opacity: 1 }, { opacity: 0 }],
|
|
21
|
+
right: [{ opacity: 1 }, { opacity: 0 }],
|
|
22
|
+
},
|
|
23
|
+
slide: {
|
|
24
|
+
left: [
|
|
25
|
+
{ transform: 'translateX(0)' },
|
|
26
|
+
{ transform: 'translateX(-100%)' },
|
|
27
|
+
],
|
|
28
|
+
right: [
|
|
29
|
+
{ transform: 'translateX(0)' },
|
|
30
|
+
{ transform: 'translateX(100%)' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
constructor(shipmentIdOrIds, config, el) {
|
|
46
35
|
this.shipmentIdOrIds = shipmentIdOrIds;
|
|
47
36
|
this.config = config;
|
|
48
37
|
this.el = el;
|
|
49
|
-
this.isReady = false;
|
|
50
|
-
this.isOpen = false;
|
|
51
|
-
this.shipmentIds = [];
|
|
52
|
-
this.fadeOut = {
|
|
53
|
-
fade: {
|
|
54
|
-
left: [{ opacity: 1 }, { opacity: 0 }],
|
|
55
|
-
right: [{ opacity: 1 }, { opacity: 0 }],
|
|
56
|
-
},
|
|
57
|
-
slide: {
|
|
58
|
-
left: [
|
|
59
|
-
{ transform: 'translateX(0)' },
|
|
60
|
-
{ transform: 'translateX(-100%)' },
|
|
61
|
-
],
|
|
62
|
-
right: [
|
|
63
|
-
{ transform: 'translateX(0)' },
|
|
64
|
-
{ transform: 'translateX(100%)' },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
38
|
if (Array.isArray(this.shipmentIdOrIds)) {
|
|
69
39
|
if (this.shipmentIdOrIds.length === 0) {
|
|
70
40
|
throw new Error('Shipment id array is empty');
|
|
71
41
|
}
|
|
72
|
-
if (this.shipmentIdOrIds.some(
|
|
42
|
+
if (this.shipmentIdOrIds.some((shipmentId) => typeof shipmentId !== 'string')) {
|
|
73
43
|
throw new Error('Shipment id array contains non-string values');
|
|
74
44
|
}
|
|
75
|
-
if (this.shipmentIdOrIds.some(
|
|
45
|
+
if (this.shipmentIdOrIds.some((shipmentId) => shipmentId.length === 0)) {
|
|
76
46
|
throw new Error('Shipment id array contains empty strings');
|
|
77
47
|
}
|
|
78
48
|
if (this.shipmentIdOrIds.length > SHIPMENT_LIMIT_IDX) {
|
|
79
|
-
throw new Error(
|
|
49
|
+
throw new Error(`Shipment id array contains more than ${SHIPMENT_LIMIT_IDX} shipment ids`);
|
|
80
50
|
}
|
|
81
51
|
}
|
|
82
52
|
this.shipmentIds = Array.isArray(this.shipmentIdOrIds)
|
|
83
53
|
? this.shipmentIdOrIds
|
|
84
54
|
: [this.shipmentIdOrIds];
|
|
85
55
|
}
|
|
86
|
-
|
|
56
|
+
open() {
|
|
87
57
|
this.render();
|
|
88
58
|
this.isOpen = true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Tracking.prototype.close = function () {
|
|
95
|
-
var _this = this;
|
|
96
|
-
var _a, _b, _c;
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
preact.render(jsxRuntime.jsx(index.TrackingDrawer, { shipmentIds: this.shipmentIds, config: this.config, onClose: this.config.onClose ?? this.onClose.bind(this) }), this.el);
|
|
62
|
+
}
|
|
63
|
+
close() {
|
|
97
64
|
if (this.isOpen) {
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
.getElementsByClassName(
|
|
65
|
+
if (this.config.animation?.out?.type != null) {
|
|
66
|
+
const animation = document
|
|
67
|
+
.getElementsByClassName(`artajs__drawer`)[0]
|
|
68
|
+
?.animate(this.fadeOut[this.config.animation.out.type][this.config.style.position], {
|
|
101
69
|
duration: this.config.animation.out.duration,
|
|
102
70
|
easing: this.config.animation.out.easing,
|
|
103
71
|
});
|
|
104
|
-
animation.onfinish =
|
|
72
|
+
animation.onfinish = (e) => {
|
|
105
73
|
e.preventDefault();
|
|
106
|
-
|
|
74
|
+
preact.render(jsxRuntime.jsx("div", {}), this.el);
|
|
107
75
|
};
|
|
108
76
|
}
|
|
109
77
|
else {
|
|
110
|
-
|
|
78
|
+
preact.render(jsxRuntime.jsx("div", {}), this.el);
|
|
111
79
|
}
|
|
112
80
|
}
|
|
113
81
|
this.isOpen = false;
|
|
114
|
-
}
|
|
115
|
-
|
|
82
|
+
}
|
|
83
|
+
onClose(e) {
|
|
116
84
|
e.preventDefault();
|
|
117
85
|
this.close();
|
|
118
86
|
this.isOpen = false;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
shipmentIdOrError = shipmentIdsOrErrors_1[_i];
|
|
145
|
-
if (typeof shipmentIdOrError === 'object') {
|
|
146
|
-
console.error('Shipment validation failed', shipmentIdOrError);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
newShipmentIds.push(shipmentIdOrError);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (newShipmentIds.length === 0) {
|
|
153
|
-
return [2 /*return*/, Promise.reject('No valid shipment ids')];
|
|
154
|
-
}
|
|
155
|
-
this.isReady = true;
|
|
156
|
-
return [2 /*return*/];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
return Tracking;
|
|
162
|
-
}());
|
|
87
|
+
}
|
|
88
|
+
async validate() {
|
|
89
|
+
const shipmentIdsOrErrors = await Promise.all(this.shipmentIds.map(async (shipmentId) => {
|
|
90
|
+
const errors = await requests.validateShipment(this.config, shipmentId);
|
|
91
|
+
if (errors && Object.keys(errors).length > 0) {
|
|
92
|
+
return errors;
|
|
93
|
+
}
|
|
94
|
+
return shipmentId;
|
|
95
|
+
}));
|
|
96
|
+
const newShipmentIds = [];
|
|
97
|
+
for (const shipmentIdOrError of shipmentIdsOrErrors) {
|
|
98
|
+
if (typeof shipmentIdOrError === 'object') {
|
|
99
|
+
console.error('Shipment validation failed', shipmentIdOrError);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
newShipmentIds.push(shipmentIdOrError);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (newShipmentIds.length === 0) {
|
|
106
|
+
return Promise.reject('No valid shipment ids');
|
|
107
|
+
}
|
|
108
|
+
this.isReady = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
163
112
|
exports.default = Tracking;
|
package/dist/trackingConfig.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var helper = require('./helper.js');
|
|
4
|
+
|
|
5
|
+
const defaultTrackingConfig = {
|
|
6
6
|
navigation: {
|
|
7
7
|
shipmentExceptionMailTo: 'hello@arta.io',
|
|
8
8
|
},
|
|
@@ -173,13 +173,15 @@ exports.defaultTrackingConfig = {
|
|
|
173
173
|
},
|
|
174
174
|
},
|
|
175
175
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var merged = (0, helper_1.nestedObjectAssign)((0, helper_1.deepClone)(exports.defaultTrackingConfig), artaConfig, (0, helper_1.deepClean)(trackingConfig));
|
|
176
|
+
const getFullTrackingConfig = (artaConfig, trackingConfig) => {
|
|
177
|
+
const merged = helper.nestedObjectAssign(helper.deepClone(defaultTrackingConfig), artaConfig, helper.deepClean(trackingConfig));
|
|
179
178
|
// Do not merge the default formatOptions: { dateStyle: 'medium' }, as it will override
|
|
180
179
|
// the object property if none is passed which can lead to formatLocaleString to throw
|
|
181
180
|
merged.text.dates.formatOptions =
|
|
182
|
-
|
|
181
|
+
trackingConfig?.text?.dates?.formatOptions ??
|
|
182
|
+
defaultTrackingConfig.text.dates.formatOptions;
|
|
183
183
|
return merged;
|
|
184
184
|
};
|
|
185
|
+
|
|
186
|
+
exports.defaultTrackingConfig = defaultTrackingConfig;
|
|
185
187
|
exports.getFullTrackingConfig = getFullTrackingConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artaio/arta-browser",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "lib/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "npm run lint",
|
|
12
|
-
"build": "
|
|
13
|
-
"build:npm": "./build-npm.sh && copyfiles -u 1 \"./lib/**/*.css\" \"./dist/\"",
|
|
14
|
-
"build:cdn": "microbundle -i lib/index.ts -o dist/bundle.js --external none --no-pkg-main -f umd --no-sourcemap --css inline",
|
|
12
|
+
"build": "rollup -c && copyfiles -u 1 \"./lib/**/*.css\" \"./dist/\"",
|
|
15
13
|
"lint": "eslint .",
|
|
16
14
|
"lint:fix": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|tsx|jsx|json)\""
|
|
17
15
|
},
|
|
18
16
|
"devDependencies": {
|
|
17
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
18
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
19
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
20
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
19
21
|
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
20
22
|
"@typescript-eslint/parser": "^5.40.1",
|
|
21
23
|
"copyfiles": "^2.4.1",
|
|
@@ -25,8 +27,9 @@
|
|
|
25
27
|
"eslint-plugin-import": "^2.26.0",
|
|
26
28
|
"eslint-plugin-n": "^15.3.0",
|
|
27
29
|
"eslint-plugin-promise": "^6.0.1",
|
|
28
|
-
"microbundle": "^0.15.1",
|
|
29
30
|
"prettier": "2.7.1",
|
|
31
|
+
"rollup": "^4.60.3",
|
|
32
|
+
"tslib": "^2.8.1",
|
|
30
33
|
"typescript": "^5.7.2",
|
|
31
34
|
"typescript-plugin-css-modules": "^4.1.1"
|
|
32
35
|
},
|
package/dist/MetadataTypes.js
DELETED
package/dist/typing.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|