@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.
Files changed (66) hide show
  1. package/dist/ModalStatus.js +3 -4
  2. package/dist/arta.js +26 -39
  3. package/dist/bundle.js +1 -1
  4. package/dist/components/Date/SimpleDate.js +11 -11
  5. package/dist/components/Date/index.js +13 -13
  6. package/dist/components/Destination/countriesWithoutPostalCode.js +5 -4
  7. package/dist/components/Destination/index.js +20 -25
  8. package/dist/components/Disqualified/index.js +15 -14
  9. package/dist/components/DrawerFooter/index.js +7 -6
  10. package/dist/components/DrawerHeader/index.js +8 -8
  11. package/dist/components/DrawerInsurance/index.js +7 -6
  12. package/dist/components/Footer/index.js +7 -7
  13. package/dist/components/Header/index.js +7 -7
  14. package/dist/components/Invalidated/index.js +7 -7
  15. package/dist/components/Loading/index.js +7 -6
  16. package/dist/components/Modal/index.css.js +7 -0
  17. package/dist/components/Modal/index.d.ts +0 -1
  18. package/dist/components/Modal/index.js +67 -132
  19. package/dist/components/Package/index.js +24 -25
  20. package/dist/components/PackageEvents/index.js +43 -88
  21. package/dist/components/Pill/index.js +8 -8
  22. package/dist/components/Quotes/index.js +26 -25
  23. package/dist/components/SelectTrackingShipment/index.js +31 -35
  24. package/dist/components/ShipToFrom/index.js +13 -13
  25. package/dist/components/ShipmentException/icons/ExceptionIcon.js +12 -12
  26. package/dist/components/ShipmentException/icons/HexagonAlertBase.js +7 -7
  27. package/dist/components/ShipmentException/icons/HexagonPauseBase.js +7 -7
  28. package/dist/components/ShipmentException/icons/HexagonStopBase.js +7 -7
  29. package/dist/components/ShipmentException/index.js +25 -27
  30. package/dist/components/Summary/index.js +7 -7
  31. package/dist/components/Timeline/CheckedStep.js +12 -12
  32. package/dist/components/Timeline/CheckedSteps.js +7 -7
  33. package/dist/components/Timeline/EmptyStep.js +7 -7
  34. package/dist/components/Timeline/SecondaryStep.js +7 -7
  35. package/dist/components/Timeline/SecondarySteps.js +7 -7
  36. package/dist/components/Timeline/TimelineDefault.js +22 -22
  37. package/dist/components/Timeline/TimlineMinimal.js +24 -25
  38. package/dist/components/Timeline/defaultIcons/CancelledIcon.js +8 -8
  39. package/dist/components/Timeline/defaultIcons/CollectedIcon.js +9 -9
  40. package/dist/components/Timeline/defaultIcons/CompletedIcon.js +9 -9
  41. package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +9 -9
  42. package/dist/components/Timeline/defaultIcons/InTransitIcon.js +9 -9
  43. package/dist/components/Timeline/defaultIcons/PendingIcon.js +8 -8
  44. package/dist/components/Timeline/icons/CancelledIconBase.js +7 -7
  45. package/dist/components/Timeline/icons/CollectedIconBase.js +7 -7
  46. package/dist/components/Timeline/icons/CompletedIconBase.js +7 -7
  47. package/dist/components/Timeline/icons/ConfirmedIconBase.js +7 -7
  48. package/dist/components/Timeline/icons/InTransitIconBase.js +7 -7
  49. package/dist/components/Timeline/icons/PendingIconBase.js +7 -7
  50. package/dist/components/Timeline/index.js +9 -9
  51. package/dist/components/TrackingDrawer/index.css.js +7 -0
  52. package/dist/components/TrackingDrawer/index.d.ts +0 -1
  53. package/dist/components/TrackingDrawer/index.js +33 -81
  54. package/dist/components/TrackingShipment/index.js +27 -66
  55. package/dist/components/TrackingTop/index.js +14 -14
  56. package/dist/estimate.js +41 -83
  57. package/dist/estimateConfig.js +16 -14
  58. package/dist/fixtures/countries.js +5 -4
  59. package/dist/helper.js +61 -64
  60. package/dist/index.js +15 -34
  61. package/dist/requests.js +71 -191
  62. package/dist/tracking.js +77 -128
  63. package/dist/trackingConfig.js +11 -9
  64. package/package.json +8 -5
  65. package/dist/MetadataTypes.js +0 -2
  66. package/dist/typing.js +0 -1
package/dist/tracking.js CHANGED
@@ -1,163 +1,112 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
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(function (shipmentId) { return typeof shipmentId !== 'string'; })) {
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(function (shipmentId) { return shipmentId.length === 0; })) {
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("Shipment id array contains more than ".concat(SHIPMENT_LIMIT_IDX, " shipment ids"));
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
- Tracking.prototype.open = function () {
56
+ open() {
87
57
  this.render();
88
58
  this.isOpen = true;
89
- };
90
- Tracking.prototype.render = function () {
91
- var _a;
92
- (0, preact_1.render)((0, jsx_runtime_1.jsx)(TrackingDrawer_1.TrackingDrawer, { shipmentIds: this.shipmentIds, config: this.config, onClose: (_a = this.config.onClose) !== null && _a !== void 0 ? _a : this.onClose.bind(this) }), this.el);
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 (((_b = (_a = this.config.animation) === null || _a === void 0 ? void 0 : _a.out) === null || _b === void 0 ? void 0 : _b.type) != null) {
99
- var animation = (_c = document
100
- .getElementsByClassName("artajs__drawer")[0]) === null || _c === void 0 ? void 0 : _c.animate(this.fadeOut[this.config.animation.out.type][this.config.style.position], {
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 = function (e) {
72
+ animation.onfinish = (e) => {
105
73
  e.preventDefault();
106
- (0, preact_1.render)((0, jsx_runtime_1.jsx)("div", {}), _this.el);
74
+ preact.render(jsxRuntime.jsx("div", {}), this.el);
107
75
  };
108
76
  }
109
77
  else {
110
- (0, preact_1.render)((0, jsx_runtime_1.jsx)("div", {}), this.el);
78
+ preact.render(jsxRuntime.jsx("div", {}), this.el);
111
79
  }
112
80
  }
113
81
  this.isOpen = false;
114
- };
115
- Tracking.prototype.onClose = function (e) {
82
+ }
83
+ onClose(e) {
116
84
  e.preventDefault();
117
85
  this.close();
118
86
  this.isOpen = false;
119
- };
120
- Tracking.prototype.validate = function () {
121
- return __awaiter(this, void 0, void 0, function () {
122
- var shipmentIdsOrErrors, newShipmentIds, _i, shipmentIdsOrErrors_1, shipmentIdOrError;
123
- var _this = this;
124
- return __generator(this, function (_a) {
125
- switch (_a.label) {
126
- case 0: return [4 /*yield*/, Promise.all(this.shipmentIds.map(function (shipmentId) { return __awaiter(_this, void 0, void 0, function () {
127
- var errors;
128
- return __generator(this, function (_a) {
129
- switch (_a.label) {
130
- case 0: return [4 /*yield*/, (0, requests_1.validateShipment)(this.config, shipmentId)];
131
- case 1:
132
- errors = _a.sent();
133
- if (errors && Object.keys(errors).length > 0) {
134
- return [2 /*return*/, errors];
135
- }
136
- return [2 /*return*/, shipmentId];
137
- }
138
- });
139
- }); }))];
140
- case 1:
141
- shipmentIdsOrErrors = _a.sent();
142
- newShipmentIds = [];
143
- for (_i = 0, shipmentIdsOrErrors_1 = shipmentIdsOrErrors; _i < shipmentIdsOrErrors_1.length; _i++) {
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;
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFullTrackingConfig = exports.defaultTrackingConfig = void 0;
4
- var helper_1 = require("./helper");
5
- exports.defaultTrackingConfig = {
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
- var getFullTrackingConfig = function (artaConfig, trackingConfig) {
177
- var _a, _b, _c;
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
- (_c = (_b = (_a = trackingConfig === null || trackingConfig === void 0 ? void 0 : trackingConfig.text) === null || _a === void 0 ? void 0 : _a.dates) === null || _b === void 0 ? void 0 : _b.formatOptions) !== null && _c !== void 0 ? _c : exports.defaultTrackingConfig.text.dates.formatOptions;
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.0",
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": "npm run build:cdn && npm run build:npm",
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
  },
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/typing.js DELETED
@@ -1 +0,0 @@
1
- "use strict";