@getspot/spot-widget-react 4.6.0 → 4.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [4.8.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.7.0...@getspot/spot-widget-react@4.8.0) (2026-10-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * **core:** add isUSResident residency signal and re-fetch on dropdown change (ST-5408) ([4ba1587](https://gitlab.com/getspot/spot-widget/commit/4ba1587ebba7ebb12a900ab1a8b1bc8758ef4346))
7
+
8
+ # [4.7.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.6.0...@getspot/spot-widget-react@4.7.0) (2026-09-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * **core:** expose theme variables for widget spacing (ST-5451) ([db0179b](https://gitlab.com/getspot/spot-widget/commit/db0179b824c8add61d4ae754090401eefe6a2871))
14
+
1
15
  # [4.6.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.5.0...@getspot/spot-widget-react@4.6.0) (2026-08-11)
2
16
 
3
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"ReactSpotWidget.d.ts","sourceRoot":"","sources":["../src/ReactSpotWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmF,MAAM,OAAO,CAAC;AA+BxG,OAAmB,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnL;;GAEG;AACH,UAAU,oBAAqB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,CAAC;IACtF,0EAA0E;IAC1E,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC1C,iEAAiE;IACjE,gBAAgB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+1,7 @@
1
- import { jsx as L } from "react/jsx-runtime";
2
- import { forwardRef as P, useRef as p, useCallback as O, useMemo as B, useImperativeHandle as H, useEffect as U } from "react";
3
- import _, { SelectionEnum as K } from "@getspot/spot-widget";
4
- import { NON_US_RESIDENT_VALUE as Z, SelectionEnum as $ } from "@getspot/spot-widget";
1
+ import { jsx as P } from "react/jsx-runtime";
2
+ import { forwardRef as B, useRef as p, useCallback as O, useMemo as H, useImperativeHandle as K, useEffect as _ } from "react";
3
+ import A, { SelectionEnum as V } from "@getspot/spot-widget";
4
+ import { NON_US_RESIDENT_VALUE as $, SelectionEnum as ee } from "@getspot/spot-widget";
5
5
  function i(c, u) {
6
6
  if (c === u) return !0;
7
7
  if (c == null || u == null || typeof c != "object" || typeof u != "object") return !1;
@@ -11,60 +11,61 @@ function i(c, u) {
11
11
  if (!d.includes(f) || !i(c[f], u[f])) return !1;
12
12
  return !0;
13
13
  }
14
- function V(c, u) {
14
+ function z(c, u) {
15
15
  const s = p(void 0);
16
16
  return (!s.current || !i(s.current.deps, u)) && (s.current = { deps: u, value: c() }), s.current.value;
17
17
  }
18
- const z = P(({
18
+ const F = B(({
19
19
  apiConfig: c,
20
20
  quoteRequestData: u,
21
21
  showTable: s = !0,
22
- selection: d = K.UNSELECTED,
22
+ selection: d = V.UNSELECTED,
23
23
  theme: f,
24
- callbacks: m = {},
25
- useMockData: v,
26
- mockData: R,
27
- logoPosition: E,
28
- state: Q,
29
- onQuoteRetrieved: S,
30
- onOptIn: k,
31
- onOptOut: h,
32
- onError: C,
33
- onNoMatchingQuote: I,
34
- onSelectionChange: N
35
- }, A) => {
24
+ callbacks: v = {},
25
+ useMockData: m,
26
+ mockData: E,
27
+ mockRefetchData: R,
28
+ logoPosition: Q,
29
+ state: S,
30
+ onQuoteRetrieved: k,
31
+ onOptIn: h,
32
+ onOptOut: C,
33
+ onError: I,
34
+ onNoMatchingQuote: N,
35
+ onSelectionChange: w
36
+ }, L) => {
36
37
  const g = p(null), n = p(null), o = p({
37
- onQuoteRetrieved: S,
38
- onOptIn: k,
39
- onOptOut: h,
40
- onError: C,
41
- onNoMatchingQuote: I,
42
- onSelectionChange: N
43
- }), w = p(m);
38
+ onQuoteRetrieved: k,
39
+ onOptIn: h,
40
+ onOptOut: C,
41
+ onError: I,
42
+ onNoMatchingQuote: N,
43
+ onSelectionChange: w
44
+ }), j = p(v);
44
45
  o.current = {
45
- onQuoteRetrieved: S,
46
- onOptIn: k,
47
- onOptOut: h,
48
- onError: C,
49
- onNoMatchingQuote: I,
50
- onSelectionChange: N
51
- }, w.current = m;
52
- const j = O((e) => {
46
+ onQuoteRetrieved: k,
47
+ onOptIn: h,
48
+ onOptOut: C,
49
+ onError: I,
50
+ onNoMatchingQuote: N,
51
+ onSelectionChange: w
52
+ }, j.current = v;
53
+ const q = O((e) => {
53
54
  var t, r;
54
55
  return (r = (t = o.current).onQuoteRetrieved) == null ? void 0 : r.call(t, e);
55
- }, []), q = O((e) => {
56
+ }, []), M = O((e) => {
56
57
  var t, r, a, l;
57
58
  (r = (t = o.current).onOptIn) == null || r.call(t, e), (l = (a = o.current).onSelectionChange) == null || l.call(a, e);
58
59
  }, []), D = O((e) => {
59
60
  var t, r, a, l;
60
61
  (r = (t = o.current).onOptOut) == null || r.call(t, e), (l = (a = o.current).onSelectionChange) == null || l.call(a, e);
61
- }, []), M = O((e) => {
62
+ }, []), W = O((e) => {
62
63
  var t, r;
63
64
  (r = (t = o.current).onError) == null || r.call(t, e);
64
- }, []), W = O((e) => {
65
+ }, []), x = O((e) => {
65
66
  var t, r;
66
67
  (r = (t = o.current).onNoMatchingQuote) == null || r.call(t, e);
67
- }, []), x = B(() => {
68
+ }, []), T = H(() => {
68
69
  const e = {}, t = [
69
70
  "onQuoteRetrieved",
70
71
  "onOptIn",
@@ -74,31 +75,32 @@ const z = P(({
74
75
  ];
75
76
  for (const r of t)
76
77
  e[r] = (...a) => {
77
- var T;
78
- const l = (T = w.current) == null ? void 0 : T[r];
78
+ var U;
79
+ const l = (U = j.current) == null ? void 0 : U[r];
79
80
  if (l) return l(...a);
80
81
  };
81
82
  return {
82
83
  ...e,
83
- ...o.current.onQuoteRetrieved && { onQuoteRetrieved: j },
84
- ...o.current.onOptIn && { onOptIn: q },
84
+ ...o.current.onQuoteRetrieved && { onQuoteRetrieved: q },
85
+ ...o.current.onOptIn && { onOptIn: M },
85
86
  ...o.current.onOptOut && { onOptOut: D },
86
- ...o.current.onError && { onError: M },
87
- ...o.current.onNoMatchingQuote && { noMatchingQuote: W }
87
+ ...o.current.onError && { onError: W },
88
+ ...o.current.onNoMatchingQuote && { noMatchingQuote: x }
88
89
  };
89
- }, [j, q, D, M, W]), b = V(() => ({
90
+ }, [q, M, D, W, x]), b = z(() => ({
90
91
  apiConfig: c,
91
92
  quoteRequestData: u,
92
93
  showTable: s,
93
94
  selection: d,
94
95
  theme: f,
95
- callbacks: x,
96
- useMockData: v,
97
- mockData: R,
98
- logoPosition: E,
99
- state: Q
100
- }), [c, u, s, d, f, x, v, R, E, Q]);
101
- H(A, () => ({
96
+ callbacks: T,
97
+ useMockData: m,
98
+ mockData: E,
99
+ mockRefetchData: R,
100
+ logoPosition: Q,
101
+ state: S
102
+ }), [c, u, s, d, f, T, m, E, R, Q, S]);
103
+ K(L, () => ({
102
104
  updateQuote: (e) => {
103
105
  var t;
104
106
  return ((t = n.current) == null ? void 0 : t.updateQuote(e)) ?? Promise.resolve(!1);
@@ -116,24 +118,24 @@ const z = P(({
116
118
  }
117
119
  }));
118
120
  const y = p(void 0);
119
- return U(() => (g.current && !n.current && (n.current = new _({
121
+ return _(() => (g.current && !n.current && (n.current = new A({
120
122
  location: g.current,
121
123
  ...b
122
124
  }), y.current = b), () => {
123
125
  n.current && (n.current.destroy(), n.current = null);
124
- }), []), U(() => {
126
+ }), []), _(() => {
125
127
  if (n.current && y.current) {
126
128
  const e = y.current, t = b;
127
- i(e.apiConfig, t.apiConfig) && i(e.theme, t.theme) && e.showTable === t.showTable && e.selection === t.selection && e.state === t.state && i(e.callbacks, t.callbacks) && !i(e.quoteRequestData, t.quoteRequestData) ? n.current.updateQuote(t.quoteRequestData) : i(e, t) || (n.current.destroy(), n.current = new _({
129
+ i(e.apiConfig, t.apiConfig) && i(e.theme, t.theme) && e.showTable === t.showTable && e.selection === t.selection && e.state === t.state && i(e.callbacks, t.callbacks) && !i(e.quoteRequestData, t.quoteRequestData) ? n.current.updateQuote(t.quoteRequestData) : i(e, t) || (n.current.destroy(), n.current = new A({
128
130
  location: g.current,
129
131
  ...t
130
132
  })), y.current = t;
131
133
  }
132
- }, [b]), /* @__PURE__ */ L("div", { ref: g });
134
+ }, [b]), /* @__PURE__ */ P("div", { ref: g });
133
135
  });
134
- z.displayName = "ReactSpotWidget";
136
+ F.displayName = "ReactSpotWidget";
135
137
  export {
136
- Z as NON_US_RESIDENT_VALUE,
137
- $ as SelectionEnum,
138
- z as default
138
+ $ as NON_US_RESIDENT_VALUE,
139
+ ee as SelectionEnum,
140
+ F as default
139
141
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(c,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("react/jsx-runtime"),require("react"),require("@getspot/spot-widget")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@getspot/spot-widget"],O):(c=typeof globalThis<"u"?globalThis:c||self,O(c.ReactSpotWidget={},c.React,c.React,c.SpotWidget))})(this,function(c,O,r,b){"use strict";function a(l,s){if(l===s)return!0;if(l==null||s==null||typeof l!="object"||typeof s!="object")return!1;const i=Object.keys(l),R=Object.keys(s);if(i.length!==R.length)return!1;for(let p of i)if(!R.includes(p)||!a(l[p],s[p]))return!1;return!0}function L(l,s){const i=r.useRef(void 0);return(!i.current||!a(i.current.deps,s))&&(i.current={deps:s,value:l()}),i.current.value}const v=r.forwardRef(({apiConfig:l,quoteRequestData:s,showTable:i=!0,selection:R=b.SelectionEnum.UNSELECTED,theme:p,callbacks:k={},useMockData:m,mockData:S,logoPosition:h,state:C,onQuoteRetrieved:Q,onOptIn:j,onOptOut:N,onError:q,onNoMatchingQuote:w,onSelectionChange:I},V)=>{const y=r.useRef(null),u=r.useRef(null),o=r.useRef({onQuoteRetrieved:Q,onOptIn:j,onOptOut:N,onError:q,onNoMatchingQuote:w,onSelectionChange:I}),_=r.useRef(k);o.current={onQuoteRetrieved:Q,onOptIn:j,onOptOut:N,onError:q,onNoMatchingQuote:w,onSelectionChange:I},_.current=k;const M=r.useCallback(e=>{var t,n;return(n=(t=o.current).onQuoteRetrieved)==null?void 0:n.call(t,e)},[]),T=r.useCallback(e=>{var t,n,d,f;(n=(t=o.current).onOptIn)==null||n.call(t,e),(f=(d=o.current).onSelectionChange)==null||f.call(d,e)},[]),D=r.useCallback(e=>{var t,n,d,f;(n=(t=o.current).onOptOut)==null||n.call(t,e),(f=(d=o.current).onSelectionChange)==null||f.call(d,e)},[]),P=r.useCallback(e=>{var t,n;(n=(t=o.current).onError)==null||n.call(t,e)},[]),U=r.useCallback(e=>{var t,n;(n=(t=o.current).onNoMatchingQuote)==null||n.call(t,e)},[]),x=r.useMemo(()=>{const e={},t=["onQuoteRetrieved","onOptIn","onOptOut","onError","noMatchingQuote"];for(const n of t)e[n]=(...d)=>{var A;const f=(A=_.current)==null?void 0:A[n];if(f)return f(...d)};return{...e,...o.current.onQuoteRetrieved&&{onQuoteRetrieved:M},...o.current.onOptIn&&{onOptIn:T},...o.current.onOptOut&&{onOptOut:D},...o.current.onError&&{onError:P},...o.current.onNoMatchingQuote&&{noMatchingQuote:U}}},[M,T,D,P,U]),g=L(()=>({apiConfig:l,quoteRequestData:s,showTable:i,selection:R,theme:p,callbacks:x,useMockData:m,mockData:S,logoPosition:h,state:C}),[l,s,i,R,p,x,m,S,h,C]);r.useImperativeHandle(V,()=>({updateQuote:e=>{var t;return((t=u.current)==null?void 0:t.updateQuote(e))??Promise.resolve(!1)},getSelection:()=>{var e;return((e=u.current)==null?void 0:e.getSelection())??null},validateSelection:()=>{var e;return((e=u.current)==null?void 0:e.validateSelection())??!1},destroy:()=>{u.current&&(u.current.destroy(),u.current=null)}}));const E=r.useRef(void 0);return r.useEffect(()=>(y.current&&!u.current&&(u.current=new b({location:y.current,...g}),E.current=g),()=>{u.current&&(u.current.destroy(),u.current=null)}),[]),r.useEffect(()=>{if(u.current&&E.current){const e=E.current,t=g;a(e.apiConfig,t.apiConfig)&&a(e.theme,t.theme)&&e.showTable===t.showTable&&e.selection===t.selection&&e.state===t.state&&a(e.callbacks,t.callbacks)&&!a(e.quoteRequestData,t.quoteRequestData)?u.current.updateQuote(t.quoteRequestData):a(e,t)||(u.current.destroy(),u.current=new b({location:y.current,...t})),E.current=t}},[g]),O.jsx("div",{ref:y})});v.displayName="ReactSpotWidget",Object.defineProperty(c,"NON_US_RESIDENT_VALUE",{enumerable:!0,get:()=>b.NON_US_RESIDENT_VALUE}),Object.defineProperty(c,"SelectionEnum",{enumerable:!0,get:()=>b.SelectionEnum}),c.default=v,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(c,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("react/jsx-runtime"),require("react"),require("@getspot/spot-widget")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@getspot/spot-widget"],O):(c=typeof globalThis<"u"?globalThis:c||self,O(c.ReactSpotWidget={},c.React,c.React,c.SpotWidget))})(this,function(c,O,r,b){"use strict";function a(l,s){if(l===s)return!0;if(l==null||s==null||typeof l!="object"||typeof s!="object")return!1;const i=Object.keys(l),R=Object.keys(s);if(i.length!==R.length)return!1;for(let p of i)if(!R.includes(p)||!a(l[p],s[p]))return!1;return!0}function V(l,s){const i=r.useRef(void 0);return(!i.current||!a(i.current.deps,s))&&(i.current={deps:s,value:l()}),i.current.value}const v=r.forwardRef(({apiConfig:l,quoteRequestData:s,showTable:i=!0,selection:R=b.SelectionEnum.UNSELECTED,theme:p,callbacks:k={},useMockData:m,mockData:S,mockRefetchData:h,logoPosition:C,state:Q,onQuoteRetrieved:j,onOptIn:N,onOptOut:q,onError:w,onNoMatchingQuote:I,onSelectionChange:_},B)=>{const y=r.useRef(null),u=r.useRef(null),o=r.useRef({onQuoteRetrieved:j,onOptIn:N,onOptOut:q,onError:w,onNoMatchingQuote:I,onSelectionChange:_}),M=r.useRef(k);o.current={onQuoteRetrieved:j,onOptIn:N,onOptOut:q,onError:w,onNoMatchingQuote:I,onSelectionChange:_},M.current=k;const T=r.useCallback(e=>{var t,n;return(n=(t=o.current).onQuoteRetrieved)==null?void 0:n.call(t,e)},[]),D=r.useCallback(e=>{var t,n,d,f;(n=(t=o.current).onOptIn)==null||n.call(t,e),(f=(d=o.current).onSelectionChange)==null||f.call(d,e)},[]),P=r.useCallback(e=>{var t,n,d,f;(n=(t=o.current).onOptOut)==null||n.call(t,e),(f=(d=o.current).onSelectionChange)==null||f.call(d,e)},[]),U=r.useCallback(e=>{var t,n;(n=(t=o.current).onError)==null||n.call(t,e)},[]),x=r.useCallback(e=>{var t,n;(n=(t=o.current).onNoMatchingQuote)==null||n.call(t,e)},[]),A=r.useMemo(()=>{const e={},t=["onQuoteRetrieved","onOptIn","onOptOut","onError","noMatchingQuote"];for(const n of t)e[n]=(...d)=>{var L;const f=(L=M.current)==null?void 0:L[n];if(f)return f(...d)};return{...e,...o.current.onQuoteRetrieved&&{onQuoteRetrieved:T},...o.current.onOptIn&&{onOptIn:D},...o.current.onOptOut&&{onOptOut:P},...o.current.onError&&{onError:U},...o.current.onNoMatchingQuote&&{noMatchingQuote:x}}},[T,D,P,U,x]),g=V(()=>({apiConfig:l,quoteRequestData:s,showTable:i,selection:R,theme:p,callbacks:A,useMockData:m,mockData:S,mockRefetchData:h,logoPosition:C,state:Q}),[l,s,i,R,p,A,m,S,h,C,Q]);r.useImperativeHandle(B,()=>({updateQuote:e=>{var t;return((t=u.current)==null?void 0:t.updateQuote(e))??Promise.resolve(!1)},getSelection:()=>{var e;return((e=u.current)==null?void 0:e.getSelection())??null},validateSelection:()=>{var e;return((e=u.current)==null?void 0:e.validateSelection())??!1},destroy:()=>{u.current&&(u.current.destroy(),u.current=null)}}));const E=r.useRef(void 0);return r.useEffect(()=>(y.current&&!u.current&&(u.current=new b({location:y.current,...g}),E.current=g),()=>{u.current&&(u.current.destroy(),u.current=null)}),[]),r.useEffect(()=>{if(u.current&&E.current){const e=E.current,t=g;a(e.apiConfig,t.apiConfig)&&a(e.theme,t.theme)&&e.showTable===t.showTable&&e.selection===t.selection&&e.state===t.state&&a(e.callbacks,t.callbacks)&&!a(e.quoteRequestData,t.quoteRequestData)?u.current.updateQuote(t.quoteRequestData):a(e,t)||(u.current.destroy(),u.current=new b({location:y.current,...t})),E.current=t}},[g]),O.jsx("div",{ref:y})});v.displayName="ReactSpotWidget",Object.defineProperty(c,"NON_US_RESIDENT_VALUE",{enumerable:!0,get:()=>b.NON_US_RESIDENT_VALUE}),Object.defineProperty(c,"SelectionEnum",{enumerable:!0,get:()=>b.SelectionEnum}),c.default=v,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget-react",
3
- "version": "4.6.0",
3
+ "version": "4.8.0",
4
4
  "description": "React wrapper for Spot Widget",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,7 +14,7 @@
14
14
  "CHANGELOG.md"
15
15
  ],
16
16
  "dependencies": {
17
- "@getspot/spot-widget": "^4.6.0"
17
+ "@getspot/spot-widget": "^4.8.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@types/react": ">=18.0.0",