@artaio/arta-browser 2.15.1 → 2.16.0
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 +1 -1
- package/dist/bundle.js +1 -1
- package/dist/components/Date/SimpleDate.js +1 -12
- package/dist/components/Destination/index.js +3 -14
- package/dist/components/Disqualified/index.js +1 -12
- package/dist/components/DrawerFooter/index.js +1 -12
- package/dist/components/DrawerHeader/index.d.ts +6 -1
- package/dist/components/DrawerHeader/index.js +5 -13
- package/dist/components/DrawerInsurance/index.js +1 -12
- package/dist/components/Footer/index.d.ts +1 -1
- package/dist/components/Footer/index.js +1 -12
- package/dist/components/Header/index.js +1 -12
- package/dist/components/Modal/index.js +4 -4
- package/dist/components/Package/index.d.ts +2 -1
- package/dist/components/Package/index.js +28 -38
- package/dist/components/PackageEvents/index.js +13 -24
- package/dist/components/Pill/index.d.ts +3 -3
- package/dist/components/Pill/index.js +3 -13
- package/dist/components/Quotes/index.js +3 -14
- package/dist/components/SelectTrackingShipment/index.d.ts +9 -0
- package/dist/components/SelectTrackingShipment/index.js +42 -0
- package/dist/components/ShipToFrom/index.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonAlertBase.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonPauseBase.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonStopBase.js +1 -12
- package/dist/components/ShipmentException/index.d.ts +4 -1
- package/dist/components/ShipmentException/index.js +4 -12
- package/dist/components/Summary/index.js +1 -12
- package/dist/components/Timeline/CheckedStep.js +1 -12
- package/dist/components/Timeline/CheckedSteps.js +1 -12
- package/dist/components/Timeline/EmptyStep.js +1 -12
- package/dist/components/Timeline/SecondaryStep.js +1 -12
- package/dist/components/Timeline/SecondarySteps.js +1 -12
- package/dist/components/Timeline/TimelineDefault.js +2 -13
- package/dist/components/Timeline/TimlineMinimal.js +1 -12
- package/dist/components/Timeline/defaultIcons/CancelledIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/CollectedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/CompletedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/InTransitIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/PendingIcon.js +1 -12
- package/dist/components/Timeline/icons/CancelledIconBase.js +1 -12
- package/dist/components/Timeline/icons/CollectedIconBase.js +1 -12
- package/dist/components/Timeline/icons/CompletedIconBase.js +1 -12
- package/dist/components/Timeline/icons/ConfirmedIconBase.js +1 -12
- package/dist/components/Timeline/icons/InTransitIconBase.js +1 -12
- package/dist/components/Timeline/icons/PendingIconBase.js +1 -12
- package/dist/components/Timeline/index.js +1 -12
- package/dist/components/TrackingDrawer/index.css +115 -0
- package/dist/components/TrackingDrawer/index.d.ts +2 -2
- package/dist/components/TrackingDrawer/index.js +25 -39
- package/dist/components/TrackingShipment/index.d.ts +9 -0
- package/dist/components/TrackingShipment/index.js +73 -0
- package/dist/components/TrackingTop/index.d.ts +4 -0
- package/dist/components/TrackingTop/index.js +50 -62
- package/dist/estimate.js +2 -2
- package/dist/helper.d.ts +6 -0
- package/dist/helper.js +11 -5
- package/dist/requests.js +18 -5
- package/dist/tracking.d.ts +3 -2
- package/dist/tracking.js +53 -10
- package/dist/trackingConfig.d.ts +16 -0
- package/dist/trackingConfig.js +39 -1
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TrackingFullConfig } from '../../trackingConfig';
|
|
2
|
+
import type { Shipment } from '../TrackingDrawer';
|
|
3
|
+
interface TrackingShipmentsProps {
|
|
4
|
+
shipment: Shipment;
|
|
5
|
+
config: TrackingFullConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare const hasActiveException: (shipment: Shipment) => boolean;
|
|
8
|
+
export declare const TrackingShipment: ({ shipment, config, }: TrackingShipmentsProps) => import("preact").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
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'; }) &&
|
|
53
|
+
shipment.status !== 'completed');
|
|
54
|
+
};
|
|
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
|
+
}); })();
|
|
67
|
+
}, [shipment]);
|
|
68
|
+
if (packageId != null) {
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(PackageEvents_1.PackageEvents, { packageId: packageId, shipment: shipment, config: config, setPackageId: setPackageId }));
|
|
70
|
+
}
|
|
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, {})] }));
|
|
72
|
+
};
|
|
73
|
+
exports.TrackingShipment = TrackingShipment;
|
|
@@ -4,4 +4,8 @@ export interface TrackingTopProps {
|
|
|
4
4
|
shipment: Shipment;
|
|
5
5
|
config: TrackingConfig;
|
|
6
6
|
}
|
|
7
|
+
export declare const getLabelAndDates: (shipment: Shipment, config: TrackingConfig) => {
|
|
8
|
+
label: string;
|
|
9
|
+
dates: Date[] | null;
|
|
10
|
+
};
|
|
7
11
|
export declare const TrackingTop: ({ shipment, config }: TrackingTopProps) => import("preact").JSX.Element;
|
|
@@ -1,76 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TrackingTop = void 0;
|
|
3
|
+
exports.TrackingTop = exports.getLabelAndDates = void 0;
|
|
15
4
|
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
16
5
|
var Date_1 = require("../Date");
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (start != null && end != null) {
|
|
44
|
-
if (start.toDateString() === end.toDateString()) {
|
|
45
|
-
return {
|
|
46
|
-
label: config.text.inTransitCTAOnLabel,
|
|
47
|
-
dates: [start],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
label: config.text.inTransitCTABetweenLabel,
|
|
52
|
-
dates: [start, end],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (start == null && end != null) {
|
|
56
|
-
return {
|
|
57
|
-
label: config.text.inTransitCTABeforeLabel,
|
|
58
|
-
dates: [end],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (start != null && end == null) {
|
|
6
|
+
var getLabelAndDates = function (shipment, config) {
|
|
7
|
+
if (shipment.status === 'completed') {
|
|
8
|
+
return {
|
|
9
|
+
label: config.text.completedCTA,
|
|
10
|
+
dates: shipment.completed_at ? [new Date(shipment.completed_at)] : null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (shipment.status === 'cancelled') {
|
|
14
|
+
return {
|
|
15
|
+
label: config.text.cancelledMessage,
|
|
16
|
+
// TODO: maybe we want to check for cancelled_at here?
|
|
17
|
+
dates: null,
|
|
18
|
+
};
|
|
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;
|
|
22
|
+
if (start == null && end == null) {
|
|
23
|
+
return {
|
|
24
|
+
label: config.text.checkBackLater,
|
|
25
|
+
dates: null,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (start != null && end != null) {
|
|
29
|
+
if (start.toDateString() === end.toDateString()) {
|
|
62
30
|
return {
|
|
63
|
-
label: config.text.
|
|
31
|
+
label: config.text.inTransitCTAOnLabel,
|
|
64
32
|
dates: [start],
|
|
65
33
|
};
|
|
66
34
|
}
|
|
67
35
|
return {
|
|
68
|
-
label: config.text.
|
|
69
|
-
dates:
|
|
36
|
+
label: config.text.inTransitCTABetweenLabel,
|
|
37
|
+
dates: [start, end],
|
|
70
38
|
};
|
|
39
|
+
}
|
|
40
|
+
if (start == null && end != null) {
|
|
41
|
+
return {
|
|
42
|
+
label: config.text.inTransitCTABeforeLabel,
|
|
43
|
+
dates: [end],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (start != null && end == null) {
|
|
47
|
+
return {
|
|
48
|
+
label: config.text.inTransitCTAAfterLabel,
|
|
49
|
+
dates: [start],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
label: config.text.checkBackLater,
|
|
54
|
+
dates: null,
|
|
71
55
|
};
|
|
72
|
-
|
|
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;
|
|
73
61
|
var parsedDates = dates === null || dates === void 0 ? void 0 : dates.map(Date_1.parseStringDate);
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
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') })] })] }))] }) }));
|
|
75
63
|
};
|
|
76
64
|
exports.TrackingTop = TrackingTop;
|
package/dist/estimate.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
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;
|
|
13
|
-
return g =
|
|
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
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
package/dist/helper.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ export declare const getTrackingStyle: (config: TrackingFullConfig) => {
|
|
|
48
48
|
'--location-flex': string;
|
|
49
49
|
'--backdrop-color': string;
|
|
50
50
|
'--animationIn': string;
|
|
51
|
+
'--button-background': string;
|
|
52
|
+
'--button-background-hover': string;
|
|
53
|
+
'--button-border': string;
|
|
54
|
+
'--button-text': string;
|
|
55
|
+
'--button-text-hover': string;
|
|
56
|
+
'--button-border-hover': string;
|
|
51
57
|
};
|
|
52
58
|
export declare function isSmallMobile(): boolean;
|
|
53
59
|
export declare function applySmallMobileStyling(finalConfig: EstimateFullConfig): void;
|
package/dist/helper.js
CHANGED
|
@@ -11,7 +11,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.getTrackingStyle = exports.getEstimateStyle = exports.getDestinationConfig = exports.getDisqualifiedConfig = exports.getQuoteConfig = exports.parseErrors = exports.parseEstimatedLocation = void 0;
|
|
15
|
+
exports.isSmallMobile = isSmallMobile;
|
|
16
|
+
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
17
|
+
exports.nestedObjectAssign = nestedObjectAssign;
|
|
18
|
+
exports.deepClone = deepClone;
|
|
15
19
|
var parseEstimatedLocation = function (loc) {
|
|
16
20
|
if (!loc) {
|
|
17
21
|
return '';
|
|
@@ -96,6 +100,12 @@ var getTrackingStyle = function (config) {
|
|
|
96
100
|
'--location-flex': config.style.variant === 'default' ? '1 0 0' : '0 1 auto',
|
|
97
101
|
'--backdrop-color': config.style.backdropColor,
|
|
98
102
|
'--animationIn': getAnimationStyleIn(config.animation.in, config),
|
|
103
|
+
'--button-background': config.style.color.buttonBackground,
|
|
104
|
+
'--button-background-hover': config.style.color.buttonBackgroundHover,
|
|
105
|
+
'--button-border': config.style.color.buttonBorder,
|
|
106
|
+
'--button-text': config.style.color.buttonText,
|
|
107
|
+
'--button-text-hover': config.style.color.buttonTextHover,
|
|
108
|
+
'--button-border-hover': config.style.color.buttonBorderHover,
|
|
99
109
|
};
|
|
100
110
|
};
|
|
101
111
|
exports.getTrackingStyle = getTrackingStyle;
|
|
@@ -115,7 +125,6 @@ var MINIMUM_RENDERING_HEIGHT = 467;
|
|
|
115
125
|
function isSmallMobile() {
|
|
116
126
|
return window.innerWidth <= 800 && window.innerHeight <= 600;
|
|
117
127
|
}
|
|
118
|
-
exports.isSmallMobile = isSmallMobile;
|
|
119
128
|
function applySmallMobileStyling(finalConfig) {
|
|
120
129
|
if (isSmallMobile()) {
|
|
121
130
|
finalConfig.style.position = 'center';
|
|
@@ -123,7 +132,6 @@ function applySmallMobileStyling(finalConfig) {
|
|
|
123
132
|
finalConfig.style.height = Math.max(window.screen.availHeight, MINIMUM_RENDERING_HEIGHT);
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
|
-
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
127
135
|
function nestedObjectAssign(target) {
|
|
128
136
|
var sources = [];
|
|
129
137
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -146,8 +154,6 @@ function nestedObjectAssign(target) {
|
|
|
146
154
|
});
|
|
147
155
|
return target;
|
|
148
156
|
}
|
|
149
|
-
exports.nestedObjectAssign = nestedObjectAssign;
|
|
150
157
|
function deepClone(obj) {
|
|
151
158
|
return JSON.parse(JSON.stringify(obj));
|
|
152
159
|
}
|
|
153
|
-
exports.deepClone = deepClone;
|
package/dist/requests.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -46,6 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.loadPackageEvents = exports.validateShipment = exports.loadShipment = exports.validateEstimateBody = exports.loadQuoteRequests = exports.loadHostedSessions = void 0;
|
|
51
60
|
var AUTH_KEY = 'ARTA_APIKey';
|
|
@@ -73,10 +82,14 @@ var logError = function (_a) {
|
|
|
73
82
|
console.error('Unkonwn error', status, errors);
|
|
74
83
|
}
|
|
75
84
|
};
|
|
76
|
-
var artaRequest = function (
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
var artaRequest = function (path_1, config_1, body_1, headers_1) {
|
|
86
|
+
var args_1 = [];
|
|
87
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
88
|
+
args_1[_i - 4] = arguments[_i];
|
|
89
|
+
}
|
|
90
|
+
return __awaiter(void 0, __spreadArray([path_1, config_1, body_1, headers_1], args_1, true), void 0, function (path, config, body, headers, method) {
|
|
79
91
|
var schema, res, resBody, err;
|
|
92
|
+
if (method === void 0) { method = 'POST'; }
|
|
80
93
|
return __generator(this, function (_a) {
|
|
81
94
|
switch (_a.label) {
|
|
82
95
|
case 0:
|
package/dist/tracking.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { TrackingFullConfig } from './trackingConfig';
|
|
2
2
|
export default class Tracking {
|
|
3
|
-
private readonly
|
|
3
|
+
private readonly shipmentIdOrIds;
|
|
4
4
|
private readonly config;
|
|
5
5
|
private readonly el;
|
|
6
6
|
isReady: boolean;
|
|
7
7
|
isOpen: boolean;
|
|
8
|
+
private shipmentIds;
|
|
8
9
|
private fadeOut;
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(shipmentIdOrIds: string | string[], config: TrackingFullConfig, el: HTMLDivElement);
|
|
10
11
|
open(): void;
|
|
11
12
|
private render;
|
|
12
13
|
close(): void;
|
package/dist/tracking.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
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;
|
|
13
|
-
return g =
|
|
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
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -40,13 +40,15 @@ var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
|
40
40
|
var preact_1 = require("preact");
|
|
41
41
|
var TrackingDrawer_1 = require("./components/TrackingDrawer");
|
|
42
42
|
var requests_1 = require("./requests");
|
|
43
|
+
var SHIPMENT_LIMIT_IDX = 100;
|
|
43
44
|
var Tracking = /** @class */ (function () {
|
|
44
|
-
function Tracking(
|
|
45
|
-
this.
|
|
45
|
+
function Tracking(shipmentIdOrIds, config, el) {
|
|
46
|
+
this.shipmentIdOrIds = shipmentIdOrIds;
|
|
46
47
|
this.config = config;
|
|
47
48
|
this.el = el;
|
|
48
49
|
this.isReady = false;
|
|
49
50
|
this.isOpen = false;
|
|
51
|
+
this.shipmentIds = [];
|
|
50
52
|
this.fadeOut = {
|
|
51
53
|
fade: {
|
|
52
54
|
left: [{ opacity: 1 }, { opacity: 0 }],
|
|
@@ -63,6 +65,23 @@ var Tracking = /** @class */ (function () {
|
|
|
63
65
|
],
|
|
64
66
|
},
|
|
65
67
|
};
|
|
68
|
+
if (Array.isArray(this.shipmentIdOrIds)) {
|
|
69
|
+
if (this.shipmentIdOrIds.length === 0) {
|
|
70
|
+
throw new Error('Shipment id array is empty');
|
|
71
|
+
}
|
|
72
|
+
if (this.shipmentIdOrIds.some(function (shipmentId) { return typeof shipmentId !== 'string'; })) {
|
|
73
|
+
throw new Error('Shipment id array contains non-string values');
|
|
74
|
+
}
|
|
75
|
+
if (this.shipmentIdOrIds.some(function (shipmentId) { return shipmentId.length === 0; })) {
|
|
76
|
+
throw new Error('Shipment id array contains empty strings');
|
|
77
|
+
}
|
|
78
|
+
if (this.shipmentIdOrIds.length > SHIPMENT_LIMIT_IDX) {
|
|
79
|
+
throw new Error("Shipment id array contains more than ".concat(SHIPMENT_LIMIT_IDX, " shipment ids"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.shipmentIds = Array.isArray(this.shipmentIdOrIds)
|
|
83
|
+
? this.shipmentIdOrIds
|
|
84
|
+
: [this.shipmentIdOrIds];
|
|
66
85
|
}
|
|
67
86
|
Tracking.prototype.open = function () {
|
|
68
87
|
this.render();
|
|
@@ -70,7 +89,7 @@ var Tracking = /** @class */ (function () {
|
|
|
70
89
|
};
|
|
71
90
|
Tracking.prototype.render = function () {
|
|
72
91
|
var _a;
|
|
73
|
-
(0, preact_1.render)((0, jsx_runtime_1.jsx)(TrackingDrawer_1.TrackingDrawer, {
|
|
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);
|
|
74
93
|
};
|
|
75
94
|
Tracking.prototype.close = function () {
|
|
76
95
|
var _this = this;
|
|
@@ -100,14 +119,38 @@ var Tracking = /** @class */ (function () {
|
|
|
100
119
|
};
|
|
101
120
|
Tracking.prototype.validate = function () {
|
|
102
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var
|
|
122
|
+
var shipmentIdsOrErrors, newShipmentIds, _i, shipmentIdsOrErrors_1, shipmentIdOrError;
|
|
123
|
+
var _this = this;
|
|
104
124
|
return __generator(this, function (_a) {
|
|
105
125
|
switch (_a.label) {
|
|
106
|
-
case 0: return [4 /*yield*/,
|
|
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
|
+
}); }))];
|
|
107
140
|
case 1:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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')];
|
|
111
154
|
}
|
|
112
155
|
this.isReady = true;
|
|
113
156
|
return [2 /*return*/];
|
package/dist/trackingConfig.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ArtaJsFullConfig } from './arta';
|
|
2
2
|
import { DeepPartial } from './helper';
|
|
3
3
|
export interface DateConfig {
|
|
4
|
+
locale: Intl.LocalesArgument;
|
|
5
|
+
formatOptions: Intl.DateTimeFormatOptions;
|
|
4
6
|
weekdays: {
|
|
5
7
|
sunday: string;
|
|
6
8
|
monday: string;
|
|
@@ -52,6 +54,12 @@ export interface TrackingConfig {
|
|
|
52
54
|
iconSecondary: string;
|
|
53
55
|
iconTertiary: string;
|
|
54
56
|
exceptionIcon: string;
|
|
57
|
+
buttonBackground: string;
|
|
58
|
+
buttonBackgroundHover: string;
|
|
59
|
+
buttonBorder: string;
|
|
60
|
+
buttonText: string;
|
|
61
|
+
buttonTextHover: string;
|
|
62
|
+
buttonBorderHover: string;
|
|
55
63
|
};
|
|
56
64
|
variant: 'default' | 'minimal';
|
|
57
65
|
position: 'left' | 'right';
|
|
@@ -63,6 +71,8 @@ export interface TrackingConfig {
|
|
|
63
71
|
text: {
|
|
64
72
|
header: {
|
|
65
73
|
title: string;
|
|
74
|
+
titleShipmentList: string;
|
|
75
|
+
titleShipmentDetail: string;
|
|
66
76
|
};
|
|
67
77
|
pendingLabel: string;
|
|
68
78
|
completedLabel: string;
|
|
@@ -95,6 +105,8 @@ export interface TrackingConfig {
|
|
|
95
105
|
singleShipmentHeldAtCustomsLabel: string;
|
|
96
106
|
changeOfAddressRequestLabel: string;
|
|
97
107
|
shipmentExceptionDefaultLabel: string;
|
|
108
|
+
viewShipmentDetailLabel: string;
|
|
109
|
+
viewShipmentsListLabel: string;
|
|
98
110
|
};
|
|
99
111
|
pill: {
|
|
100
112
|
unknown: PillConfig;
|
|
@@ -106,6 +118,10 @@ export interface TrackingConfig {
|
|
|
106
118
|
undelivered: PillConfig;
|
|
107
119
|
exception: PillConfig;
|
|
108
120
|
expired: PillConfig;
|
|
121
|
+
cancelled: PillConfig;
|
|
122
|
+
collected: PillConfig;
|
|
123
|
+
completed: PillConfig;
|
|
124
|
+
confirmed: PillConfig;
|
|
109
125
|
};
|
|
110
126
|
animation: {
|
|
111
127
|
in: AnimationConfig;
|
package/dist/trackingConfig.js
CHANGED
|
@@ -16,6 +16,12 @@ exports.defaultTrackingConfig = {
|
|
|
16
16
|
iconSecondary: 'white',
|
|
17
17
|
iconTertiary: '#8C8984',
|
|
18
18
|
exceptionIcon: '#F59E0B',
|
|
19
|
+
buttonBackground: '#110F10',
|
|
20
|
+
buttonBackgroundHover: '#6F6C65',
|
|
21
|
+
buttonBorder: '#110F10',
|
|
22
|
+
buttonText: '#FFFFFF',
|
|
23
|
+
buttonTextHover: '#FFFFFF',
|
|
24
|
+
buttonBorderHover: '#110F10',
|
|
19
25
|
},
|
|
20
26
|
variant: 'default',
|
|
21
27
|
position: 'right',
|
|
@@ -27,6 +33,8 @@ exports.defaultTrackingConfig = {
|
|
|
27
33
|
text: {
|
|
28
34
|
header: {
|
|
29
35
|
title: 'Track Shipment',
|
|
36
|
+
titleShipmentList: 'Shipments List',
|
|
37
|
+
titleShipmentDetail: 'Shipment Detail',
|
|
30
38
|
},
|
|
31
39
|
pendingLabel: 'Pending',
|
|
32
40
|
completedLabel: 'Completed',
|
|
@@ -58,7 +66,11 @@ exports.defaultTrackingConfig = {
|
|
|
58
66
|
multipleShipmentsHeldAtCustomsLabel: 'One or more packages are being held by Customs',
|
|
59
67
|
changeOfAddressRequestLabel: 'A change of address was requested which may impact delivery timelines.',
|
|
60
68
|
shipmentExceptionDefaultLabel: 'There is an exception with this shipment.',
|
|
69
|
+
viewShipmentDetailLabel: 'View Details',
|
|
70
|
+
viewShipmentsListLabel: '< All Shipments',
|
|
61
71
|
dates: {
|
|
72
|
+
locale: navigator.language,
|
|
73
|
+
formatOptions: { dateStyle: 'medium' },
|
|
62
74
|
weekdays: {
|
|
63
75
|
sunday: 'Sun',
|
|
64
76
|
monday: 'Mon',
|
|
@@ -130,6 +142,26 @@ exports.defaultTrackingConfig = {
|
|
|
130
142
|
backgroundColor: '#E7E7E7',
|
|
131
143
|
text: 'Expired',
|
|
132
144
|
},
|
|
145
|
+
cancelled: {
|
|
146
|
+
textColor: '#772424',
|
|
147
|
+
backgroundColor: '#FEF9F9',
|
|
148
|
+
text: 'Cancelled',
|
|
149
|
+
},
|
|
150
|
+
collected: {
|
|
151
|
+
textColor: '#173E2A',
|
|
152
|
+
backgroundColor: '#D6EDE1',
|
|
153
|
+
text: 'Collected',
|
|
154
|
+
},
|
|
155
|
+
completed: {
|
|
156
|
+
textColor: '#173E2A',
|
|
157
|
+
backgroundColor: '#D6EDE1',
|
|
158
|
+
text: 'Completed',
|
|
159
|
+
},
|
|
160
|
+
confirmed: {
|
|
161
|
+
textColor: '#173E2A',
|
|
162
|
+
backgroundColor: '#D6EDE1',
|
|
163
|
+
text: 'Confirmed',
|
|
164
|
+
},
|
|
133
165
|
},
|
|
134
166
|
animation: {
|
|
135
167
|
in: {
|
|
@@ -141,6 +173,12 @@ exports.defaultTrackingConfig = {
|
|
|
141
173
|
},
|
|
142
174
|
};
|
|
143
175
|
var getFullTrackingConfig = function (artaConfig, trackingConfig) {
|
|
144
|
-
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
var merged = (0, helper_1.nestedObjectAssign)((0, helper_1.deepClone)(exports.defaultTrackingConfig), artaConfig, trackingConfig);
|
|
178
|
+
// Do not merge the default formatOptions: { dateStyle: 'medium' }, as it will override
|
|
179
|
+
// the object property if none is passed which can lead to formatLocaleString to throw
|
|
180
|
+
merged.text.dates.formatOptions =
|
|
181
|
+
(_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;
|
|
182
|
+
return merged;
|
|
145
183
|
};
|
|
146
184
|
exports.getFullTrackingConfig = getFullTrackingConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artaio/arta-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "lib/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"eslint-plugin-promise": "^6.0.1",
|
|
28
28
|
"microbundle": "^0.15.1",
|
|
29
29
|
"prettier": "2.7.1",
|
|
30
|
-
"typescript": "^
|
|
30
|
+
"typescript": "^5.7.2",
|
|
31
31
|
"typescript-plugin-css-modules": "^4.1.1"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|