@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
@@ -1,84 +1,36 @@
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
- exports.TrackingDrawer = void 0;
40
- var jsx_runtime_1 = require("preact/jsx-runtime");
41
- var hooks_1 = require("preact/hooks");
42
- var helper_1 = require("../../helper");
43
- var DrawerHeader_1 = require("../DrawerHeader");
44
- require("./index.css");
45
- var requests_1 = require("../../requests");
46
- var DrawerFooter_1 = require("../DrawerFooter");
47
- var TrackingShipment_1 = require("../TrackingShipment");
48
- var SelectTrackingShipment_1 = require("../SelectTrackingShipment");
49
- var TrackingDrawer = function (_a) {
50
- var shipmentIds = _a.shipmentIds, config = _a.config, onClose = _a.onClose;
51
- var position = config.style.position;
52
- var style = (0, helper_1.getTrackingStyle)(config);
53
- var _b = (0, hooks_1.useState)(null), shipments = _b[0], setShipments = _b[1];
54
- var _c = (0, hooks_1.useState)(null), selectedShipment = _c[0], setSelectedShipment = _c[1];
55
- (0, hooks_1.useEffect)(function () {
56
- (function () { return __awaiter(void 0, void 0, void 0, function () {
57
- var ships;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, Promise.all(shipmentIds.map(function (shipmentId) { return __awaiter(void 0, void 0, void 0, function () {
61
- return __generator(this, function (_a) {
62
- switch (_a.label) {
63
- case 0: return [4 /*yield*/, (0, requests_1.loadShipment)(config, shipmentId)];
64
- case 1: return [2 /*return*/, _a.sent()];
65
- }
66
- });
67
- }); }))];
68
- case 1:
69
- ships = _a.sent();
70
- setShipments(ships);
71
- return [2 /*return*/];
72
- }
73
- });
74
- }); })();
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('preact/jsx-runtime');
4
+ var hooks = require('preact/hooks');
5
+ var helper = require('../../helper.js');
6
+ var index$1 = require('../DrawerHeader/index.js');
7
+ var index = require('./index.css.js');
8
+ var requests = require('../../requests.js');
9
+ var index$4 = require('../DrawerFooter/index.js');
10
+ var index$2 = require('../TrackingShipment/index.js');
11
+ var index$3 = require('../SelectTrackingShipment/index.js');
12
+
13
+ const TrackingDrawer = ({ shipmentIds, config, onClose, }) => {
14
+ const position = config.style.position;
15
+ const style = helper.getTrackingStyle(config);
16
+ const [shipments, setShipments] = hooks.useState(null);
17
+ const [selectedShipment, setSelectedShipment] = hooks.useState(null);
18
+ hooks.useEffect(() => {
19
+ (async () => {
20
+ const ships = await Promise.all(shipmentIds.map(async (shipmentId) => {
21
+ return await requests.loadShipment(config, shipmentId);
22
+ }));
23
+ setShipments(ships);
24
+ //TODO should we ship.packages.filter(pkg => pkg.objects?.length)); ??
25
+ })();
75
26
  }, [shipmentIds]);
76
- return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs", children: [config.style.backdropEnabled && ((0, jsx_runtime_1.jsx)("div", { onClick: onClose, style: style, class: "artajs__drawer__backdrop" })), (0, jsx_runtime_1.jsx)("div", { style: style, class: "artajs__drawer ".concat(position === 'left'
77
- ? 'artajs__drawer__left'
78
- : 'artajs__drawer__right'), children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__out__wrapper", children: [(0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: selectedShipment
79
- ? config.text.header.titleShipmentDetail
80
- : shipments && shipments.length > 1
81
- ? config.text.header.titleShipmentList
82
- : config.text.header.title, onClose: onClose, setSelectedShipment: setSelectedShipment, multiple: !!selectedShipment, config: config }), (shipments === null || shipments === void 0 ? void 0 : shipments.length) ? (shipments.length === 1 || selectedShipment ? ((0, jsx_runtime_1.jsx)(TrackingShipment_1.TrackingShipment, { shipment: selectedShipment !== null && selectedShipment !== void 0 ? selectedShipment : shipments[0], config: config })) : ((0, jsx_runtime_1.jsx)(SelectTrackingShipment_1.SelectTrackingShipment, { shipments: shipments, config: config, setSelectedShipment: setSelectedShipment }))) : ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__body", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__drawer__loading" }), (0, jsx_runtime_1.jsx)(DrawerFooter_1.DrawerFooter, {})] }))] }) })] }) }));
27
+ return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("style", { children: index.default }), jsxRuntime.jsxs("div", { class: "artajs", children: [config.style.backdropEnabled && (jsxRuntime.jsx("div", { onClick: onClose, style: style, class: "artajs__drawer__backdrop" })), jsxRuntime.jsx("div", { style: style, class: `artajs__drawer ${position === 'left'
28
+ ? 'artajs__drawer__left'
29
+ : 'artajs__drawer__right'}`, children: jsxRuntime.jsxs("div", { class: "artajs__tracking__out__wrapper", children: [jsxRuntime.jsx(index$1.DrawerHeader, { title: selectedShipment
30
+ ? config.text.header.titleShipmentDetail
31
+ : shipments && shipments.length > 1
32
+ ? config.text.header.titleShipmentList
33
+ : config.text.header.title, onClose: onClose, setSelectedShipment: setSelectedShipment, multiple: !!selectedShipment, config: config }), shipments?.length ? (shipments.length === 1 || selectedShipment ? (jsxRuntime.jsx(index$2.TrackingShipment, { shipment: selectedShipment ?? shipments[0], config: config })) : (jsxRuntime.jsx(index$3.SelectTrackingShipment, { shipments: shipments, config: config, setSelectedShipment: setSelectedShipment }))) : (jsxRuntime.jsxs("div", { class: "artajs__tracking__body", children: [jsxRuntime.jsx("div", { class: "artajs__drawer__loading" }), jsxRuntime.jsx(index$4.DrawerFooter, {})] }))] }) })] })] }));
83
34
  };
35
+
84
36
  exports.TrackingDrawer = TrackingDrawer;
@@ -1,73 +1,34 @@
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
- exports.TrackingShipment = exports.hasActiveException = void 0;
40
- var jsx_runtime_1 = require("preact/jsx-runtime");
41
- var hooks_1 = require("preact/hooks");
42
- var ShipToFrom_1 = require("../ShipToFrom");
43
- var Package_1 = require("../Package");
44
- var Timeline_1 = require("../Timeline");
45
- var TrackingTop_1 = require("../TrackingTop");
46
- var DrawerFooter_1 = require("../DrawerFooter");
47
- var DrawerInsurance_1 = require("../DrawerInsurance");
48
- var Summary_1 = require("../Summary");
49
- var ShipmentException_1 = require("../ShipmentException");
50
- var PackageEvents_1 = require("../PackageEvents");
51
- var hasActiveException = function (shipment) {
52
- return (shipment.shipment_exceptions.some(function (ex) { return ex.status !== 'resolved'; }) &&
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('preact/jsx-runtime');
4
+ var hooks = require('preact/hooks');
5
+ var index$4 = require('../ShipToFrom/index.js');
6
+ var index$5 = require('../Package/index.js');
7
+ var index$1 = require('../Timeline/index.js');
8
+ var index$3 = require('../TrackingTop/index.js');
9
+ var index$8 = require('../DrawerFooter/index.js');
10
+ var index$6 = require('../DrawerInsurance/index.js');
11
+ var index$7 = require('../Summary/index.js');
12
+ var index$2 = require('../ShipmentException/index.js');
13
+ var index = require('../PackageEvents/index.js');
14
+
15
+ const hasActiveException = (shipment) => {
16
+ return (shipment.shipment_exceptions.some((ex) => ex.status !== 'resolved') &&
53
17
  shipment.status !== 'completed');
54
18
  };
55
- exports.hasActiveException = hasActiveException;
56
- var TrackingShipment = function (_a) {
57
- var shipment = _a.shipment, config = _a.config;
58
- var _b = (0, hooks_1.useState)([]), packagesWithObjects = _b[0], setPackagesWithObjects = _b[1];
59
- var _c = (0, hooks_1.useState)(null), packageId = _c[0], setPackageId = _c[1];
60
- (0, hooks_1.useEffect)(function () {
61
- (function () { return __awaiter(void 0, void 0, void 0, function () {
62
- return __generator(this, function (_a) {
63
- setPackagesWithObjects(shipment.packages);
64
- return [2 /*return*/];
65
- });
66
- }); })();
19
+ const TrackingShipment = ({ shipment, config, }) => {
20
+ const [packagesWithObjects, setPackagesWithObjects] = hooks.useState([]);
21
+ const [packageId, setPackageId] = hooks.useState(null);
22
+ hooks.useEffect(() => {
23
+ (async () => {
24
+ setPackagesWithObjects(shipment.packages);
25
+ })();
67
26
  }, [shipment]);
68
27
  if (packageId != null) {
69
- return ((0, jsx_runtime_1.jsx)(PackageEvents_1.PackageEvents, { packageId: packageId, shipment: shipment, config: config, setPackageId: setPackageId }));
28
+ return (jsxRuntime.jsx(index.PackageEvents, { packageId: packageId, shipment: shipment, config: config, setPackageId: setPackageId }));
70
29
  }
71
- return ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__body", children: [(0, jsx_runtime_1.jsx)(Timeline_1.Timeline, { shipment: shipment, config: config }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__timeline__divider" }), (0, exports.hasActiveException)(shipment) && ((0, jsx_runtime_1.jsx)(ShipmentException_1.ShipmentException, { shipment: shipment, config: config })), (0, jsx_runtime_1.jsx)(TrackingTop_1.TrackingTop, { config: config, shipment: shipment }), (0, jsx_runtime_1.jsx)(ShipToFrom_1.ShipToFrom, { config: config, shipment: shipment }), packagesWithObjects.map(function (pkg, index) { return ((0, jsx_runtime_1.jsx)(Package_1.Package, { title: "#".concat(index + 1), pkg: pkg, shipment: shipment, config: config, setPackageId: setPackageId })); }), shipment.insurance_policy != null && (0, jsx_runtime_1.jsx)(DrawerInsurance_1.DrawerInsurance, {}), (0, jsx_runtime_1.jsx)(Summary_1.Summary, { config: config, shipment: shipment }), (0, jsx_runtime_1.jsx)(DrawerFooter_1.DrawerFooter, {})] }));
30
+ return (jsxRuntime.jsxs("div", { class: "artajs__tracking__body", children: [jsxRuntime.jsx(index$1.Timeline, { shipment: shipment, config: config }), jsxRuntime.jsx("div", { class: "artajs__tracking__timeline__divider" }), hasActiveException(shipment) && (jsxRuntime.jsx(index$2.ShipmentException, { shipment: shipment, config: config })), jsxRuntime.jsx(index$3.TrackingTop, { config: config, shipment: shipment }), jsxRuntime.jsx(index$4.ShipToFrom, { config: config, shipment: shipment }), packagesWithObjects.map((pkg, index) => (jsxRuntime.jsx(index$5.Package, { title: `#${index + 1}`, pkg: pkg, shipment: shipment, config: config, setPackageId: setPackageId }))), shipment.insurance_policy != null && jsxRuntime.jsx(index$6.DrawerInsurance, {}), jsxRuntime.jsx(index$7.Summary, { config: config, shipment: shipment }), jsxRuntime.jsx(index$8.DrawerFooter, {})] }));
72
31
  };
32
+
73
33
  exports.TrackingShipment = TrackingShipment;
34
+ exports.hasActiveException = hasActiveException;
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TrackingTop = exports.getLabelAndDates = void 0;
4
- var jsx_runtime_1 = require("preact/jsx-runtime");
5
- var Date_1 = require("../Date");
6
- var getLabelAndDates = function (shipment, config) {
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('preact/jsx-runtime');
4
+ var index = require('../Date/index.js');
5
+
6
+ const getLabelAndDates = (shipment, config) => {
7
7
  if (shipment.status === 'completed') {
8
8
  return {
9
9
  label: config.text.completedCTA,
@@ -17,8 +17,8 @@ var getLabelAndDates = function (shipment, config) {
17
17
  dates: null,
18
18
  };
19
19
  }
20
- var start = shipment.delivery_start != null ? new Date(shipment.delivery_start) : null;
21
- var end = shipment.delivery_end != null ? new Date(shipment.delivery_end) : null;
20
+ const start = shipment.delivery_start != null ? new Date(shipment.delivery_start) : null;
21
+ const end = shipment.delivery_end != null ? new Date(shipment.delivery_end) : null;
22
22
  if (start == null && end == null) {
23
23
  return {
24
24
  label: config.text.checkBackLater,
@@ -54,11 +54,11 @@ var getLabelAndDates = function (shipment, config) {
54
54
  dates: null,
55
55
  };
56
56
  };
57
- exports.getLabelAndDates = getLabelAndDates;
58
- var TrackingTop = function (_a) {
59
- var shipment = _a.shipment, config = _a.config;
60
- var _b = (0, exports.getLabelAndDates)(shipment, config), label = _b.label, dates = _b.dates;
61
- var parsedDates = dates === null || dates === void 0 ? void 0 : dates.map(Date_1.parseStringDate);
62
- return ((0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__wrapper", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__divider", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__cta", children: (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__text", children: label }) }), parsedDates != null && parsedDates.length === 1 && ((0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__wrapper", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[0].weekday], ", ").concat(config.text.dates.months[parsedDates[0].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[0].day).padStart(2, '0') })] }) })), parsedDates != null && parsedDates.length === 2 && ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__wrapper", children: [(0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[0].weekday], ", ").concat(config.text.dates.months[parsedDates[0].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[0].day).padStart(2, '0') })] }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__aligner", children: (0, jsx_runtime_1.jsx)("div", { class: "artajas__tracking__top__date__and", children: config.text.inTransitCTAAndLabel }) }), (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[1].weekday], ", ").concat(config.text.dates.months[parsedDates[1].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[1].day).padStart(2, '0') })] })] }))] }) }));
57
+ const TrackingTop = ({ shipment, config }) => {
58
+ const { label, dates } = getLabelAndDates(shipment, config);
59
+ const parsedDates = dates?.map(index.parseStringDate);
60
+ return (jsxRuntime.jsx("div", { class: "artajs__tracking__top__wrapper", children: jsxRuntime.jsxs("div", { class: "artajs__tracking__top__divider", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__top__cta", children: jsxRuntime.jsx("div", { class: "artajs__tracking__top__text", children: label }) }), parsedDates != null && parsedDates.length === 1 && (jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__wrapper", children: jsxRuntime.jsxs("div", { class: "artajs__tracking__top__date__aligner", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day", children: `${config.text.dates.weekdays[parsedDates[0].weekday]}, ${config.text.dates.months[parsedDates[0].month]}` }), jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day__numeric", children: `${parsedDates[0].day}`.padStart(2, '0') })] }) })), parsedDates != null && parsedDates.length === 2 && (jsxRuntime.jsxs("div", { class: "artajs__tracking__top__date__wrapper", children: [jsxRuntime.jsxs("div", { class: "artajs__tracking__top__date__aligner", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day", children: `${config.text.dates.weekdays[parsedDates[0].weekday]}, ${config.text.dates.months[parsedDates[0].month]}` }), jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day__numeric", children: `${parsedDates[0].day}`.padStart(2, '0') })] }), jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__aligner", children: jsxRuntime.jsx("div", { class: "artajas__tracking__top__date__and", children: config.text.inTransitCTAAndLabel }) }), jsxRuntime.jsxs("div", { class: "artajs__tracking__top__date__aligner", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day", children: `${config.text.dates.weekdays[parsedDates[1].weekday]}, ${config.text.dates.months[parsedDates[1].month]}` }), jsxRuntime.jsx("div", { class: "artajs__tracking__top__date__day__numeric", children: `${parsedDates[1].day}`.padStart(2, '0') })] })] }))] }) }));
63
61
  };
62
+
64
63
  exports.TrackingTop = TrackingTop;
64
+ exports.getLabelAndDates = getLabelAndDates;
package/dist/estimate.js CHANGED
@@ -1,99 +1,57 @@
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 Modal_1 = require("./components/Modal");
42
- var requests_1 = require("./requests");
43
- var helper_1 = require("./helper");
44
- var Estimate = /** @class */ (function () {
45
- function Estimate(estimateBody, 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/Modal/index.js');
8
+ var requests = require('./requests.js');
9
+ var helper = require('./helper.js');
10
+
11
+ class Estimate {
12
+ estimateBody;
13
+ config;
14
+ el;
15
+ isReady = false;
16
+ isOpen = false;
17
+ addedOrientationChangeListener = false;
18
+ constructor(estimateBody, config, el) {
46
19
  this.estimateBody = estimateBody;
47
20
  this.config = config;
48
21
  this.el = el;
49
- this.isReady = false;
50
- this.isOpen = false;
51
- this.addedOrientationChangeListener = false;
52
22
  }
53
- Estimate.prototype.open = function () {
54
- var _this = this;
23
+ open() {
55
24
  if (!this.addedOrientationChangeListener) {
56
- window.screen.orientation.addEventListener('change', function () {
57
- (0, helper_1.applySmallMobileStyling)(_this.config);
58
- if (_this.isOpen) {
59
- _this.render();
25
+ window.screen.orientation.addEventListener('change', () => {
26
+ helper.applySmallMobileStyling(this.config);
27
+ if (this.isOpen) {
28
+ this.render();
60
29
  }
61
30
  });
62
31
  this.addedOrientationChangeListener = true;
63
32
  }
64
33
  this.render();
65
34
  this.isOpen = true;
66
- };
67
- Estimate.prototype.render = function () {
68
- var _a;
69
- (0, preact_1.render)((0, jsx_runtime_1.jsx)(Modal_1.Modal, { onClose: (_a = this.config.onClose) !== null && _a !== void 0 ? _a : this.onClose.bind(this), estimateBody: this.estimateBody, config: this.config }), this.el);
70
- };
71
- Estimate.prototype.close = function () {
72
- (0, preact_1.render)((0, jsx_runtime_1.jsx)("div", {}), this.el);
35
+ }
36
+ render() {
37
+ preact.render(jsxRuntime.jsx(index.Modal, { onClose: this.config.onClose ?? this.onClose.bind(this), estimateBody: this.estimateBody, config: this.config }), this.el);
38
+ }
39
+ close() {
40
+ preact.render(jsxRuntime.jsx("div", {}), this.el);
73
41
  this.isOpen = false;
74
- };
75
- Estimate.prototype.onClose = function (e) {
42
+ }
43
+ onClose(e) {
76
44
  e.preventDefault();
77
45
  this.close();
78
46
  this.isOpen = false;
79
- };
80
- Estimate.prototype.validate = function () {
81
- return __awaiter(this, void 0, void 0, function () {
82
- var errors;
83
- return __generator(this, function (_a) {
84
- switch (_a.label) {
85
- case 0: return [4 /*yield*/, (0, requests_1.validateEstimateBody)(this.config, this.estimateBody)];
86
- case 1:
87
- errors = _a.sent();
88
- if (errors && Object.keys(errors).length > 0) {
89
- return [2 /*return*/, Promise.reject(errors)];
90
- }
91
- this.isReady = true;
92
- return [2 /*return*/];
93
- }
94
- });
95
- });
96
- };
97
- return Estimate;
98
- }());
47
+ }
48
+ async validate() {
49
+ const errors = await requests.validateEstimateBody(this.config, this.estimateBody);
50
+ if (errors && Object.keys(errors).length > 0) {
51
+ return Promise.reject(errors);
52
+ }
53
+ this.isReady = true;
54
+ }
55
+ }
56
+
99
57
  exports.default = Estimate;
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFullEstimateConfig = exports.defaultEstimateConfig = void 0;
4
- var Destination_1 = require("./components/Destination");
5
- var Disqualified_1 = require("./components/Disqualified");
6
- var Quotes_1 = require("./components/Quotes");
7
- var helper_1 = require("./helper");
8
- exports.defaultEstimateConfig = {
1
+ 'use strict';
2
+
3
+ var index$2 = require('./components/Destination/index.js');
4
+ var index = require('./components/Disqualified/index.js');
5
+ var index$1 = require('./components/Quotes/index.js');
6
+ var helper = require('./helper.js');
7
+
8
+ const defaultEstimateConfig = {
9
9
  style: {
10
10
  color: {
11
11
  background: '#FFFFFF',
@@ -38,18 +38,20 @@ exports.defaultEstimateConfig = {
38
38
  header: {
39
39
  title: 'Estimate Shipping Costs',
40
40
  },
41
- destination: Destination_1.defaultDestinationConfig,
42
- quoted: Quotes_1.defaultQuoteConfig,
43
- disqualified: Disqualified_1.defaultDisqualifiedConfig,
41
+ destination: index$2.defaultDestinationConfig,
42
+ quoted: index$1.defaultQuoteConfig,
43
+ disqualified: index.defaultDisqualifiedConfig,
44
44
  invalidated: {
45
45
  message: 'Unfortunately we could not successfully geocode the origin location to provide a shipping estimate.',
46
46
  detail: 'The address may be missing components or invalid.',
47
47
  },
48
48
  },
49
49
  };
50
- var getFullEstimateConfig = function (artaConfig, estimateConfig) {
51
- var finalConfig = (0, helper_1.nestedObjectAssign)((0, helper_1.deepClone)(exports.defaultEstimateConfig), artaConfig, (0, helper_1.deepClean)(estimateConfig));
52
- (0, helper_1.applySmallMobileStyling)(finalConfig);
50
+ const getFullEstimateConfig = (artaConfig, estimateConfig) => {
51
+ const finalConfig = helper.nestedObjectAssign(helper.deepClone(defaultEstimateConfig), artaConfig, helper.deepClean(estimateConfig));
52
+ helper.applySmallMobileStyling(finalConfig);
53
53
  return finalConfig;
54
54
  };
55
+
56
+ exports.defaultEstimateConfig = defaultEstimateConfig;
55
57
  exports.getFullEstimateConfig = getFullEstimateConfig;
@@ -1,7 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.countries = void 0;
4
- exports.countries = [
1
+ 'use strict';
2
+
3
+ const countries = [
5
4
  { code: 'AF', name: 'Afghanistan' },
6
5
  { code: 'AX', name: 'Aland Islands' },
7
6
  { code: 'AL', name: 'Albania' },
@@ -248,3 +247,5 @@ exports.countries = [
248
247
  { code: 'ZM', name: 'Zambia' },
249
248
  { code: 'ZW', name: 'Zimbabwe' },
250
249
  ];
250
+
251
+ exports.countries = countries;