@artaio/arta-browser 2.0.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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/dist/MetadataTypes.d.ts +110 -0
  3. package/dist/MetadataTypes.js +2 -0
  4. package/dist/ModalStatus.d.ts +7 -0
  5. package/dist/ModalStatus.js +11 -0
  6. package/dist/arta.d.ts +14 -0
  7. package/dist/arta.js +45 -0
  8. package/dist/bundle.js +1 -0
  9. package/dist/components/Destination/countriesWithoutPostalCode.d.ts +1 -0
  10. package/dist/components/Destination/countriesWithoutPostalCode.js +64 -0
  11. package/dist/components/Destination/index.d.ts +26 -0
  12. package/dist/components/Destination/index.js +59 -0
  13. package/dist/components/Disqualified/index.d.ts +28 -0
  14. package/dist/components/Disqualified/index.js +35 -0
  15. package/dist/components/Footer/index.d.ts +6 -0
  16. package/dist/components/Footer/index.js +20 -0
  17. package/dist/components/Header/index.d.ts +6 -0
  18. package/dist/components/Header/index.js +20 -0
  19. package/dist/components/Loading/index.d.ts +5 -0
  20. package/dist/components/Loading/index.js +20 -0
  21. package/dist/components/Modal/index.css +738 -0
  22. package/dist/components/Modal/index.d.ts +9 -0
  23. package/dist/components/Modal/index.js +133 -0
  24. package/dist/components/Quotes/currencies.d.ts +6 -0
  25. package/dist/components/Quotes/currencies.js +25 -0
  26. package/dist/components/Quotes/index.d.ts +33 -0
  27. package/dist/components/Quotes/index.js +51 -0
  28. package/dist/estimate.d.ts +11 -0
  29. package/dist/estimate.js +72 -0
  30. package/dist/estimateConfig.d.ts +52 -0
  31. package/dist/estimateConfig.js +77 -0
  32. package/dist/fixtures/countries.d.ts +6 -0
  33. package/dist/fixtures/countries.js +250 -0
  34. package/dist/helper.d.ts +23 -0
  35. package/dist/helper.js +71 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +28 -0
  38. package/dist/requests.d.ts +25 -0
  39. package/dist/requests.js +152 -0
  40. package/dist/typing.d.ts +1 -0
  41. package/dist/typing.js +1 -0
  42. package/package.json +49 -0
@@ -0,0 +1,9 @@
1
+ import './index.css';
2
+ import { EstimateBody, EstimateFullConfig } from '../../estimateConfig';
3
+ interface ModalOpts {
4
+ estimateBody: EstimateBody;
5
+ config: EstimateFullConfig;
6
+ onClose: (e: any) => void;
7
+ }
8
+ export declare const Modal: ({ estimateBody, onClose, config }: ModalOpts) => import("preact").JSX.Element;
9
+ export {};
@@ -0,0 +1,133 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
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 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.Modal = void 0;
51
+ var jsx_runtime_1 = require("preact/jsx-runtime");
52
+ var Header_1 = require("../Header");
53
+ var Destination_1 = require("../Destination");
54
+ var Footer_1 = require("../Footer");
55
+ var hooks_1 = require("preact/hooks");
56
+ require("./index.css");
57
+ var Loading_1 = require("../Loading");
58
+ var Quotes_1 = require("../Quotes");
59
+ var helper_1 = require("../../helper");
60
+ var requests_1 = require("../../requests");
61
+ var Disqualified_1 = require("../Disqualified");
62
+ var ModalStatus_1 = require("../../ModalStatus");
63
+ var Modal = function (_a) {
64
+ var estimateBody = _a.estimateBody, onClose = _a.onClose, config = _a.config;
65
+ var position = config.style.position;
66
+ var _b = (0, hooks_1.useState)(), destination = _b[0], setDestination = _b[1];
67
+ var _c = (0, hooks_1.useState)(''), parsedOrigin = _c[0], setParsedOrigin = _c[1];
68
+ var _d = (0, hooks_1.useState)(ModalStatus_1.ModalStatus.LOADING), status = _d[0], setStatus = _d[1];
69
+ var _e = (0, hooks_1.useState)(), hostedSession = _e[0], setHostedSession = _e[1];
70
+ var _f = (0, hooks_1.useState)(), quoteRequest = _f[0], setQuoteRequest = _f[1];
71
+ var _g = (0, hooks_1.useState)(), errors = _g[0], setErrors = _g[1];
72
+ var style = (0, helper_1.getStyle)(config);
73
+ (0, hooks_1.useEffect)(function () {
74
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
75
+ var session;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ setErrors([]);
80
+ setStatus(ModalStatus_1.ModalStatus.LOADING);
81
+ return [4 /*yield*/, (0, requests_1.loadHostedSessions)(config, estimateBody)];
82
+ case 1:
83
+ session = _a.sent();
84
+ setHostedSession(session);
85
+ setParsedOrigin((0, helper_1.parseEstimatedLocation)(session.origin));
86
+ setStatus(ModalStatus_1.ModalStatus.OPEN);
87
+ return [2 /*return*/];
88
+ }
89
+ });
90
+ }); })();
91
+ }, [estimateBody.origin, estimateBody.objects]);
92
+ (0, hooks_1.useEffect)(function () {
93
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
94
+ var esimate, sess, req, errorMessages;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ setErrors([]);
99
+ if (!destination) {
100
+ return [2 /*return*/];
101
+ }
102
+ setStatus(ModalStatus_1.ModalStatus.LOADING);
103
+ esimate = __assign(__assign({}, estimateBody), { destination: destination });
104
+ sess = hostedSession
105
+ ? hostedSession
106
+ : { id: '', private_token: '', origin: estimateBody.origin };
107
+ return [4 /*yield*/, (0, requests_1.loadQuoteRequests)(config, sess, esimate)];
108
+ case 1:
109
+ req = _a.sent();
110
+ if (req.err) {
111
+ errorMessages = (0, helper_1.parseErrors)(req.err.errors);
112
+ setErrors(errorMessages);
113
+ setStatus(ModalStatus_1.ModalStatus.OPEN);
114
+ }
115
+ else {
116
+ setQuoteRequest(req);
117
+ if (req.quotes && req.quotes.length > 0) {
118
+ setStatus(ModalStatus_1.ModalStatus.QUOTED);
119
+ }
120
+ else {
121
+ setStatus(ModalStatus_1.ModalStatus.DISQUALIFIED);
122
+ }
123
+ }
124
+ return [2 /*return*/];
125
+ }
126
+ });
127
+ }); })();
128
+ }, [destination]);
129
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs" }, { children: [position === 'center' && (0, jsx_runtime_1.jsx)("div", { class: "artajs__modal__backdrop" }), (0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal artajs__modal__".concat(position), style: style }, { children: [(0, jsx_runtime_1.jsx)(Header_1.Header, { onClose: onClose, title: config.text.header.title }), status === ModalStatus_1.ModalStatus.LOADING && ((0, jsx_runtime_1.jsx)(Loading_1.Loading, { message: config.text.loading.message })), status === ModalStatus_1.ModalStatus.OPEN && ((0, jsx_runtime_1.jsx)(Destination_1.Destination, { parsedOrigin: parsedOrigin, textConfig: (0, helper_1.getDestinationConfig)(config), setDestination: setDestination })), status === ModalStatus_1.ModalStatus.QUOTED && quoteRequest && ((0, jsx_runtime_1.jsx)(Quotes_1.Quotes, { quoteRequest: quoteRequest, showCostRange: config.style.pricingDisplay === 'range', textConfig: (0, helper_1.getQuoteConfig)(config), setStatus: setStatus })), status === ModalStatus_1.ModalStatus.DISQUALIFIED && quoteRequest && ((0, jsx_runtime_1.jsx)(Disqualified_1.Disqualified, { quoteRequest: quoteRequest, textConfig: (0, helper_1.getDisqualifiedConfig)(config), setStatus: setStatus })), (0, jsx_runtime_1.jsx)(Footer_1.Footer, { primaryColor: config.style.color.primaryColor, poweredByButtonColor: config.style.color.poweredByButtonColor }), errors && errors.length > 0 && ((0, jsx_runtime_1.jsx)("div", __assign({ class: "artajs__modal__error__container" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ class: "artajs__modal__error" }, { children: errors.map(function (error, i) {
130
+ return (0, jsx_runtime_1.jsx)("span", { children: error }, "arta-error-".concat(i));
131
+ }) })) })))] }))] })) }));
132
+ };
133
+ exports.Modal = Modal;
@@ -0,0 +1,6 @@
1
+ declare const currencies: {
2
+ id: string;
3
+ name: string;
4
+ symbol: string;
5
+ }[];
6
+ export default currencies;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var currencies = [
4
+ {
5
+ id: 'CAD',
6
+ name: 'Canadian Dollar',
7
+ symbol: '$',
8
+ },
9
+ {
10
+ id: 'EUR',
11
+ name: 'Euro',
12
+ symbol: '€',
13
+ },
14
+ {
15
+ id: 'GBP',
16
+ name: 'Pound Sterling',
17
+ symbol: '£',
18
+ },
19
+ {
20
+ id: 'USD',
21
+ name: 'US Dollar',
22
+ symbol: '$',
23
+ },
24
+ ];
25
+ exports.default = currencies;
@@ -0,0 +1,33 @@
1
+ import { QuoteRequest } from '../../requests';
2
+ import { ModalStatus } from '../../ModalStatus';
3
+ export declare const defaultQuoteConfig: {
4
+ shipFromLabel: string;
5
+ shipToLabel: string;
6
+ disclaimerLabel: string;
7
+ excludeDisclaimerLabel: string;
8
+ rangeLabel: string;
9
+ startsAtLabel: string;
10
+ artaInsuranceLabel: string;
11
+ };
12
+ export interface QuoteTextConfig {
13
+ shipFromLabel: string;
14
+ shipToLabel: string;
15
+ disclaimerLabel: string;
16
+ excludeDisclaimerLabel: string;
17
+ rangeLabel: string;
18
+ startsAtLabel: string;
19
+ artaInsuranceLabel: string;
20
+ }
21
+ export interface QuoteFullTextConfig extends QuoteTextConfig {
22
+ detailOriginLabel: string;
23
+ detailDestinationLabel: string;
24
+ returnLinkLabel: string;
25
+ }
26
+ interface QuotesOps {
27
+ quoteRequest: QuoteRequest;
28
+ showCostRange: boolean;
29
+ textConfig: QuoteFullTextConfig;
30
+ setStatus: (status: ModalStatus) => void;
31
+ }
32
+ export declare const Quotes: ({ quoteRequest, showCostRange, textConfig, setStatus, }: QuotesOps) => import("preact").JSX.Element;
33
+ export {};
@@ -0,0 +1,51 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Quotes = exports.defaultQuoteConfig = void 0;
18
+ var jsx_runtime_1 = require("preact/jsx-runtime");
19
+ var helper_1 = require("../../helper");
20
+ var currencies_1 = __importDefault(require("./currencies"));
21
+ var ModalStatus_1 = require("../../ModalStatus");
22
+ exports.defaultQuoteConfig = {
23
+ shipFromLabel: 'These goods ship from:',
24
+ shipToLabel: 'To:',
25
+ disclaimerLabel: 'Actual shipping costs will be provided at checkout.',
26
+ excludeDisclaimerLabel: 'Excludes duties & taxes',
27
+ rangeLabel: 'Shipping estimated between',
28
+ startsAtLabel: 'Shipping Starts at',
29
+ artaInsuranceLabel: 'This estimate includes ARTA Full Risk Insurance',
30
+ };
31
+ var Quotes = function (_a) {
32
+ var quoteRequest = _a.quoteRequest, showCostRange = _a.showCostRange, textConfig = _a.textConfig, setStatus = _a.setStatus;
33
+ var onChangeDestination = function (e) {
34
+ e.preventDefault();
35
+ setStatus(ModalStatus_1.ModalStatus.OPEN);
36
+ };
37
+ var quotes = quoteRequest.quotes;
38
+ if (quotes && quotes.length > 0) {
39
+ quotes.sort(function (a, b) {
40
+ return a.total - b.total;
41
+ });
42
+ }
43
+ var currencySymbol = currencies_1.default.filter(function (c) { return c.id === quoteRequest.currency; })[0].symbol;
44
+ var hasInsurance = quoteRequest.insurance === 'arta_transit_insurance';
45
+ var isInternational = quoteRequest.origin.estimated_country ===
46
+ quoteRequest.destination.estimated_country;
47
+ var parsedOrigin = (0, helper_1.parseEstimatedLocation)(quoteRequest.origin);
48
+ var parsedDestination = (0, helper_1.parseEstimatedLocation)(quoteRequest.destination);
49
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes" }, { children: [(0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__context" }, { children: textConfig.shipFromLabel })), (0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__origin" }, { children: (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("span", __assign({ class: "artajs__modal__capitalize" }, { children: parsedOrigin })), ' ', (0, jsx_runtime_1.jsx)("span", __assign({ class: "artajs__modal__quotes__light" }, { children: textConfig.detailOriginLabel }))] }) })), (0, jsx_runtime_1.jsxs)("p", __assign({ class: "artajs__modal__quotes__destination" }, { children: [(0, jsx_runtime_1.jsx)("span", __assign({ class: "artajs__modal__quotes__small" }, { children: textConfig.shipToLabel })), ' ', parsedDestination ? ((0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("strong", __assign({ class: "artajs__modal__capitalize" }, { children: parsedDestination })), ' ', (0, jsx_runtime_1.jsx)("span", __assign({ class: "artajs__modal__quotes__light" }, { children: textConfig.detailDestinationLabel }))] })) : ((0, jsx_runtime_1.jsx)("span", { children: "..." }))] })), showCostRange && quotes.length > 1 ? ((0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__box ".concat(!isInternational ? 'artajs__modal__quotes__box__padding__y' : '') }, { children: [(0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__context" }, { children: textConfig.rangeLabel })), (0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__price" }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__price__amount" }, { children: [currencySymbol, Math.round(quotes[0].total), " - ", currencySymbol, Math.round(quotes[quotes.length - 1].total)] })), (0, jsx_runtime_1.jsx)("div", __assign({ class: "artajs__modal__quotes__price__currency_code" }, { children: quoteRequest.currency }))] })), isInternational && ((0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__exclusions" }, { children: textConfig.excludeDisclaimerLabel }))), hasInsurance && ((0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__insurance" }, { children: [(0, jsx_runtime_1.jsx)("svg", __assign({ width: "11", height: "11", viewBox: "0 0 11 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M9.48465 2.79298C9.87517 3.1835 9.87518 3.81666 9.48465 4.20719L4.56126 9.13062C4.37166 9.32022 4.11386 9.42574 3.84574 9.42348C3.57761 9.42123 3.32163 9.31139 3.13525 9.11863L1.10866 7.02269C0.72476 6.62566 0.73541 5.99258 1.13245 5.60868C1.52948 5.22478 2.16256 5.23543 2.54646 5.63247L3.86614 6.99731L8.07043 2.79298C8.46096 2.40246 9.09412 2.40245 9.48465 2.79298Z", fill: "white" }) })), (0, jsx_runtime_1.jsx)("p", { children: textConfig.artaInsuranceLabel })] })))] }))) : ((0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__box ".concat(!isInternational ? 'artajs__modal__quotes__box__padding__y' : '') }, { children: [(0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__context" }, { children: textConfig.startsAtLabel })), (0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__price" }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__price__amount" }, { children: [currencySymbol, Math.round(quotes[0].total)] })), (0, jsx_runtime_1.jsx)("div", __assign({ class: "artajs__modal__quotes__price__currency_code" }, { children: quoteRequest.currency }))] })), isInternational && ((0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__exclusions" }, { children: textConfig.excludeDisclaimerLabel }))), hasInsurance && ((0, jsx_runtime_1.jsxs)("div", __assign({ class: "artajs__modal__quotes__insurance" }, { children: [(0, jsx_runtime_1.jsx)("svg", __assign({ width: "11", height: "11", viewBox: "0 0 11 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M9.48465 2.79298C9.87517 3.1835 9.87518 3.81666 9.48465 4.20719L4.56126 9.13062C4.37166 9.32022 4.11386 9.42574 3.84574 9.42348C3.57761 9.42123 3.32163 9.31139 3.13525 9.11863L1.10866 7.02269C0.72476 6.62566 0.73541 5.99258 1.13245 5.60868C1.52948 5.22478 2.16256 5.23543 2.54646 5.63247L3.86614 6.99731L8.07043 2.79298C8.46096 2.40246 9.09412 2.40245 9.48465 2.79298Z", fill: "white" }) })), (0, jsx_runtime_1.jsx)("p", { children: textConfig.artaInsuranceLabel })] })))] }))), (0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__checkout" }, { children: textConfig.disclaimerLabel })), (0, jsx_runtime_1.jsx)("p", __assign({ class: "artajs__modal__quotes__change" }, { children: (0, jsx_runtime_1.jsxs)("a", __assign({ onClick: onChangeDestination, href: "#" }, { children: [(0, jsx_runtime_1.jsx)("svg", __assign({ width: "20", height: "8", viewBox: "0 0 20 8", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.58562 7.46419C3.97614 7.85471 4.60931 7.85471 4.99983 7.46419C5.39036 7.07366 5.39036 6.4405 4.99983 6.04997L3.80697 4.85706L18.9999 4.85706C19.5522 4.85706 19.9999 4.40934 19.9999 3.85706C19.9999 3.30477 19.5522 2.85706 18.9999 2.85706L3.84988 2.85706L4.99993 1.70705C5.39045 1.31653 5.39045 0.683363 4.99993 0.292839C4.6094 -0.0976858 3.97624 -0.0976858 3.58571 0.292839L4.62519e-08 3.87847L3.58562 7.46419Z", fill: "#99A5B2" }) })), textConfig.returnLinkLabel] })) }))] })));
50
+ };
51
+ exports.Quotes = Quotes;
@@ -0,0 +1,11 @@
1
+ import { EstimateBody, EstimateFullConfig } from './estimateConfig';
2
+ export default class Estimate {
3
+ private readonly estimateBody;
4
+ private readonly config;
5
+ private readonly el;
6
+ ready: boolean;
7
+ constructor(estimateBody: EstimateBody, config: EstimateFullConfig, el: HTMLDivElement);
8
+ open(): void;
9
+ onClose(e: any): void;
10
+ validate(): Promise<void>;
11
+ }
@@ -0,0 +1,72 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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 Estimate = /** @class */ (function () {
44
+ function Estimate(estimateBody, config, el) {
45
+ this.estimateBody = estimateBody;
46
+ this.config = config;
47
+ this.el = el;
48
+ this.ready = false;
49
+ }
50
+ Estimate.prototype.open = function () {
51
+ (0, preact_1.render)((0, jsx_runtime_1.jsx)(Modal_1.Modal, { onClose: this.onClose.bind(this), estimateBody: this.estimateBody, config: this.config }), this.el);
52
+ };
53
+ Estimate.prototype.onClose = function (e) {
54
+ e.preventDefault();
55
+ (0, preact_1.render)((0, jsx_runtime_1.jsx)("div", {}), this.el);
56
+ };
57
+ Estimate.prototype.validate = function () {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, (0, requests_1.validateEstimateBody)(this.config, this.estimateBody)];
62
+ case 1:
63
+ _a.sent();
64
+ this.ready = true;
65
+ return [2 /*return*/];
66
+ }
67
+ });
68
+ });
69
+ };
70
+ return Estimate;
71
+ }());
72
+ exports.default = Estimate;
@@ -0,0 +1,52 @@
1
+ import { ArtaJsFullConfig } from './arta';
2
+ import { DestinationTextConfig } from './components/Destination';
3
+ import { DisqualifiedTextConfig } from './components/Disqualified';
4
+ import { QuoteTextConfig } from './components/Quotes';
5
+ import { AdditionalService, ArtaLocation, ArtaObject, Insurance, QuoteType, SupportedCurrency } from './MetadataTypes';
6
+ export interface EstimateBody {
7
+ origin: ArtaLocation;
8
+ objects: ArtaObject[];
9
+ additional_services?: AdditionalService[];
10
+ currency?: SupportedCurrency;
11
+ destination?: ArtaLocation;
12
+ insurance?: Insurance;
13
+ internal_reference?: string;
14
+ public_reference?: string;
15
+ preferred_quote_types?: QuoteType[];
16
+ }
17
+ export interface EstimateConfig {
18
+ style: {
19
+ color: {
20
+ primaryColor: string;
21
+ primaryUnfocusedColor: string;
22
+ secondaryColor: string;
23
+ errorColor: string;
24
+ backgroundColor: string;
25
+ poweredByButtonColor: string;
26
+ };
27
+ position: 'center' | 'left' | 'right';
28
+ pricingDisplay: 'starts_at' | 'range';
29
+ fontFamily: string;
30
+ fontSize: number;
31
+ width: number;
32
+ height: number;
33
+ };
34
+ text: {
35
+ detailOriginLabel: string;
36
+ detailDestinationLabel: string;
37
+ returnLinkLabel: string;
38
+ header: {
39
+ title: string;
40
+ };
41
+ loading: {
42
+ message: string;
43
+ };
44
+ destination: DestinationTextConfig;
45
+ quoted: QuoteTextConfig;
46
+ disqualified: DisqualifiedTextConfig;
47
+ };
48
+ }
49
+ export interface EstimateFullConfig extends EstimateConfig, ArtaJsFullConfig {
50
+ }
51
+ export declare const defaultEstimateConfig: EstimateConfig;
52
+ export declare const getFullConfig: (artaConfig: ArtaJsFullConfig, estimateConfig?: Partial<EstimateConfig>) => EstimateFullConfig;
@@ -0,0 +1,77 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getFullConfig = exports.defaultEstimateConfig = void 0;
15
+ var Destination_1 = require("./components/Destination");
16
+ var Disqualified_1 = require("./components/Disqualified");
17
+ var Quotes_1 = require("./components/Quotes");
18
+ exports.defaultEstimateConfig = {
19
+ style: {
20
+ color: {
21
+ primaryColor: '#001F3F',
22
+ primaryUnfocusedColor: '#4d6279',
23
+ secondaryColor: '#99A5B2',
24
+ errorColor: '#D84242',
25
+ backgroundColor: 'white',
26
+ poweredByButtonColor: '#F5F6F7',
27
+ },
28
+ position: 'right',
29
+ pricingDisplay: 'starts_at',
30
+ fontFamily: 'Arial, Helvetica, sans-serif',
31
+ fontSize: 12,
32
+ width: 300,
33
+ height: 432,
34
+ },
35
+ text: {
36
+ detailOriginLabel: '(origin)',
37
+ detailDestinationLabel: '(destination)',
38
+ returnLinkLabel: 'Change Destination',
39
+ loading: {
40
+ message: 'Retrieving shipping costs...',
41
+ },
42
+ header: {
43
+ title: 'Estimate Shipping Costs',
44
+ },
45
+ destination: Destination_1.defaultDestinationConfig,
46
+ quoted: Quotes_1.defaultQuoteConfig,
47
+ disqualified: Disqualified_1.defaultDisqualifiedConfig,
48
+ },
49
+ };
50
+ function nestedObjectAssign(target) {
51
+ var sources = [];
52
+ for (var _i = 1; _i < arguments.length; _i++) {
53
+ sources[_i - 1] = arguments[_i];
54
+ }
55
+ sources.forEach(function (source) {
56
+ if (source) {
57
+ Object.keys(source).forEach(function (key) {
58
+ var s_val = source[key];
59
+ var t_val = target[key];
60
+ target[key] =
61
+ t_val &&
62
+ s_val &&
63
+ typeof t_val === 'object' &&
64
+ typeof s_val === 'object'
65
+ ? nestedObjectAssign(t_val, s_val)
66
+ : s_val;
67
+ });
68
+ }
69
+ });
70
+ return target;
71
+ }
72
+ var getFullConfig = function (artaConfig, estimateConfig) {
73
+ var finalConfig = nestedObjectAssign(__assign(__assign({}, exports.defaultEstimateConfig), artaConfig), estimateConfig);
74
+ console.log('final config', finalConfig);
75
+ return finalConfig;
76
+ };
77
+ exports.getFullConfig = getFullConfig;
@@ -0,0 +1,6 @@
1
+ interface Country {
2
+ code: string;
3
+ name: string;
4
+ }
5
+ export declare const countries: Country[];
6
+ export {};