@getspot/spot-widget 3.3.3 → 3.3.4
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/CHANGELOG.md +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.es.js +7 -9
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.3.4](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.3.3...@getspot/spot-widget@3.3.4) (2026-02-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **core:** spread batchData to forward all fields including metadata ([9b8f76d](https://gitlab.com/getspot/spot-widget/commit/9b8f76d8c42482b3b64152c69eb0da9267fcddf8))
|
|
7
|
+
|
|
1
8
|
## [3.3.3](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.3.2...@getspot/spot-widget@3.3.3) (2026-01-21)
|
|
2
9
|
|
|
3
10
|
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAEnI;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,CAwBtB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,oBAAoB,GACjC,OAAO,CAAC,WAAW,CAAC,CAyBtB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAEnI;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,CAwBtB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,oBAAoB,GACjC,OAAO,CAAC,WAAW,CAAC,CAyBtB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAsEtB"}
|
package/dist/index.es.js
CHANGED
|
@@ -40,9 +40,7 @@ async function I(m, t, o) {
|
|
|
40
40
|
var s;
|
|
41
41
|
try {
|
|
42
42
|
const n = {
|
|
43
|
-
|
|
44
|
-
cartName: o.cartInfo.cartName,
|
|
45
|
-
currencyCode: o.cartInfo.currencyCode,
|
|
43
|
+
...o.cartInfo,
|
|
46
44
|
isPartialPayment: o.cartInfo.isPartialPayment || !1,
|
|
47
45
|
roundTo: o.cartInfo.roundTo || void 0,
|
|
48
46
|
items: o.items.map((p, u) => ({
|
|
@@ -90,7 +88,7 @@ const M = {
|
|
|
90
88
|
production: "https://api.getspot.com/v1/quote",
|
|
91
89
|
local: "http://localhost:3999/api/v1/quote"
|
|
92
90
|
};
|
|
93
|
-
function
|
|
91
|
+
function D(m) {
|
|
94
92
|
const {
|
|
95
93
|
apiConfig: t = {},
|
|
96
94
|
quoteRequestData: o,
|
|
@@ -423,7 +421,7 @@ function R(m, t, o) {
|
|
|
423
421
|
}), e = a("input", { parent: i });
|
|
424
422
|
return e.type = "radio", e.name = "selection", e.value = "no", a("span", { text: o.noOptionText, parent: i }), s;
|
|
425
423
|
}
|
|
426
|
-
function
|
|
424
|
+
function T(m, t) {
|
|
427
425
|
var n;
|
|
428
426
|
const o = (n = t.communication) == null ? void 0 : n.paymentTerms, s = a("div", {
|
|
429
427
|
className: "spot-payment-terms",
|
|
@@ -527,7 +525,7 @@ class A {
|
|
|
527
525
|
async _init() {
|
|
528
526
|
var t, o, s, n, r;
|
|
529
527
|
try {
|
|
530
|
-
|
|
528
|
+
D(this.options);
|
|
531
529
|
let i;
|
|
532
530
|
if (this.options.useMockData && this.options.mockData)
|
|
533
531
|
i = this.options.mockData;
|
|
@@ -609,7 +607,7 @@ class A {
|
|
|
609
607
|
t.appendChild(o), this.paymentTermsEl = a("div", {
|
|
610
608
|
className: "spot-payment-terms__wrapper",
|
|
611
609
|
parent: t
|
|
612
|
-
}), this.currentSelection === "yes" &&
|
|
610
|
+
}), this.currentSelection === "yes" && T(this.paymentTermsEl, this.quote), V(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(o);
|
|
613
611
|
}
|
|
614
612
|
_updateLayout() {
|
|
615
613
|
if (!this.container || !this.quote) return;
|
|
@@ -664,7 +662,7 @@ class A {
|
|
|
664
662
|
n.addEventListener("change", (r) => {
|
|
665
663
|
var p, u, f, h;
|
|
666
664
|
const i = r.target, e = i.value;
|
|
667
|
-
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((y) => y.classList.remove("selected")), (p = i.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === "yes" && ((u = this.quote) != null && u.communication.paymentTerms &&
|
|
665
|
+
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((y) => y.classList.remove("selected")), (p = i.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === "yes" && ((u = this.quote) != null && u.communication.paymentTerms && T(this.paymentTermsEl, this.quote), (f = this.options.callbacks) != null && f.onOptIn)) {
|
|
668
666
|
const y = {
|
|
669
667
|
status: "QUOTE_ACCEPTED",
|
|
670
668
|
spotPrice: this.quote.spotPrice,
|
|
@@ -742,7 +740,7 @@ class A {
|
|
|
742
740
|
...this.options,
|
|
743
741
|
quoteRequestData: t
|
|
744
742
|
};
|
|
745
|
-
|
|
743
|
+
D(i);
|
|
746
744
|
const { environment: e, partnerId: p, customEndpoint: u } = this.options.apiConfig, f = u || H[e], y = "cartInfo" in i.quoteRequestData && "items" in i.quoteRequestData ? await I(
|
|
747
745
|
f,
|
|
748
746
|
p,
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,q){typeof exports=="object"&&typeof module<"u"?module.exports=q():typeof define=="function"&&define.amd?define(q):(C=typeof globalThis<"u"?globalThis:C||self,C.SpotWidget=q())})(this,function(){"use strict";async function C(m,t,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),n=await s.json();if(!s.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=n,r}return n}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function q(m,t,o){try{const s=m.replace("/quote","/quote/batch"),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await n.json();if(!n.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=n.status,i.responseBody=r,i}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function E(m,t,o){var s;try{const n={
|
|
1
|
+
(function(C,q){typeof exports=="object"&&typeof module<"u"?module.exports=q():typeof define=="function"&&define.amd?define(q):(C=typeof globalThis<"u"?globalThis:C||self,C.SpotWidget=q())})(this,function(){"use strict";async function C(m,t,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),n=await s.json();if(!s.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=n,r}return n}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function q(m,t,o){try{const s=m.replace("/quote","/quote/batch"),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await n.json();if(!n.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=n.status,i.responseBody=r,i}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function E(m,t,o){var s;try{const n={...o.cartInfo,isPartialPayment:o.cartInfo.isPartialPayment||!1,roundTo:o.cartInfo.roundTo||void 0,items:o.items.map((p,u)=>({...p,cartItemId:p.cartItemId||`item-${u+1}`}))},r=await q(m,t,n);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(p=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===p.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${p.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(p=>p.id).join(","):((s=r.data)==null?void 0:s.id)||"",spotPrice:e,currencyCode:r.currencyCode||"",communication:{...r.communication,yesOptionText:r.communication.yesOptionText.replace(String(r.totalSpotPrice),String(e))},payoutSchedule:r.payoutSchedule.map(p=>({...p,amount:p.amount!==void 0?p.amount:0})),coveredItems:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching multiple quotes")}}const M={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function x(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:n,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:p}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(p||M[i]))throw new Error(`Invalid environment in apiConfig: ${i}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function h(c,d=null){const l=d!==null?`quoteRequestData[${d}]`:"quoteRequestData";f.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(c,v)||c[v]===void 0||c[v]===null)throw new Error(`Missing required ${l} field: '${v}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(c.startDate))throw new Error(`${l}.startDate must be a valid ISO8601 string`);if(!w.test(c.endDate))throw new Error(`${l}.endDate must be a valid ISO8601 string`);if(typeof c.currencyCode!="string")throw new Error(`${l}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(c.currencyCode))throw new Error(`Invalid ${l}.currencyCode: ${c.currencyCode}`);if(typeof c.eventType!="string")throw new Error(`${l}.eventType must be a string`);if(typeof c.productType!="string")throw new Error(`${l}.productType must be a string`);const g=["Pass","Trip","Registration"];if(!g.includes(c.productType))throw new Error(`${l}.productType must be one of ${g.join(", ")}`);if(typeof c.productDuration!="string")throw new Error(`${l}.productDuration must be a string`);const _=["Daily","Seasonal","Trip","Event"];if(!_.includes(c.productDuration))throw new Error(`${l}.productDuration must be one of ${_.join(", ")}`);if(typeof c.productPrice!="number"||isNaN(c.productPrice))throw new Error(`${l}.productPrice must be a valid number`);if(typeof c.productId!="string")throw new Error(`${l}.productId must be a string`);if(typeof c.cartId!="string")throw new Error(`${l}.cartId must be a string`);if(typeof c.productName!="string")throw new Error(`${l}.productName must be a string`)}if("cartInfo"in o&&"items"in o){const c=o,{cartInfo:d,items:l}=c;if(!d||typeof d!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!d.cartId||typeof d.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!d.cartName||typeof d.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!d.currencyCode||typeof d.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(d.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${d.currencyCode}`);if(!Array.isArray(l)||l.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const b=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];l.forEach((g,_)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);const v=`quoteRequestData.items[${_}]`;b.forEach(k=>{if(!Object.prototype.hasOwnProperty.call(g,k)||g[k]===void 0||g[k]===null)throw new Error(`Missing required ${v} field: '${k}'`)});const D=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!D.test(g.startDate))throw new Error(`${v}.startDate must be a valid ISO8601 string`);if(!D.test(g.endDate))throw new Error(`${v}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${v}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${v}.productType must be a string`);const H=["Pass","Trip","Registration"];if(!H.includes(g.productType))throw new Error(`${v}.productType must be one of ${H.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${v}.productDuration must be a string`);const z=["Daily","Seasonal","Trip","Event"];if(!z.includes(g.productDuration))throw new Error(`${v}.productDuration must be one of ${z.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${v}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${v}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${v}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((c,d)=>{if(!c||typeof c!="object")throw new Error(`quoteRequestData[${d}] must be a non-null object`);h(c,d)})}else h(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const d=s[c];if(d&&typeof d!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof n=="string"&&!document.querySelector(n))throw new Error(`Invalid location selector: '${n}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function a(m,{text:t,className:o,parent:s,innerHTML:n,href:r,target:i}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),n!=null&&(e.innerHTML=n),r&&"href"in e&&(e.href=r),i&&"target"in e&&(e.target=i),s&&s.appendChild(e),e}function N(m,{name:t,description:o}){a("div",{className:"spot-header__title",text:t,parent:m}),a("div",{className:"spot-header__description",text:o,parent:m})}function L(m,t=[]){const o=a("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const n=a("li",{parent:o});n.innerHTML=`
|
|
2
2
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
|
|
3
3
|
<path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
|
|
4
4
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|