@getspot/spot-widget-react 4.1.1 → 4.3.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.3.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.2.0...@getspot/spot-widget-react@4.3.0) (2026-06-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * **core:** publish 13 currencies for Competition Corner [ST-5242] ([c700cc6](https://gitlab.com/getspot/spot-widget/commit/c700cc6557c66a4b9d24e799fdbe3b9f24f342eb))
7
+
8
+ # [4.2.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.1.1...@getspot/spot-widget-react@4.2.0) (2026-05-12)
9
+
10
+
11
+ ### Features
12
+
13
+ * **core:** allow user to select state in widget and make selection available ([d5758ba](https://gitlab.com/getspot/spot-widget/commit/d5758baa147cb31e018e15ef1280a7599c3b515b))
14
+
1
15
  ## [4.1.1](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-react@4.1.0...@getspot/spot-widget-react@4.1.1) (2026-03-06)
2
16
 
3
17
 
@@ -82,4 +82,5 @@ declare const ReactSpotWidget: React.ForwardRefExoticComponent<ReactSpotWidgetPr
82
82
  export default ReactSpotWidget;
83
83
  export type { Quote, QuoteUpdates, SelectionData, SpotWidgetOptions, QuoteRequestData, ApiConfig };
84
84
  export { SelectionEnum };
85
+ export { NON_US_RESIDENT_VALUE } from "@getspot/spot-widget";
85
86
  //# sourceMappingURL=ReactSpotWidget.d.ts.map
@@ -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,gB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AAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -82,4 +82,5 @@ declare const ReactSpotWidget: React.ForwardRefExoticComponent<ReactSpotWidgetPr
82
82
  export default ReactSpotWidget;
83
83
  export type { Quote, QuoteUpdates, SelectionData, SpotWidgetOptions, QuoteRequestData, ApiConfig };
84
84
  export { SelectionEnum };
85
+ export { NON_US_RESIDENT_VALUE } from "@getspot/spot-widget";
85
86
  //# sourceMappingURL=ReactSpotWidget.d.ts.map
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as B } from "react/jsx-runtime";
2
- import { forwardRef as H, useRef as p, useCallback as O, useMemo as K, useImperativeHandle as L, useEffect as P } from "react";
3
- import T, { SelectionEnum as U } from "@getspot/spot-widget";
4
- import { SelectionEnum as Z } from "@getspot/spot-widget";
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";
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,59 +11,60 @@ 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 z(c, u) {
14
+ function V(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 F = H(({
18
+ const z = P(({
19
19
  apiConfig: c,
20
20
  quoteRequestData: u,
21
21
  showTable: s = !0,
22
- selection: d = U.UNSELECTED,
22
+ selection: d = K.UNSELECTED,
23
23
  theme: f,
24
24
  callbacks: m = {},
25
25
  useMockData: v,
26
26
  mockData: R,
27
- logoPosition: Q,
28
- onQuoteRetrieved: k,
29
- onOptIn: h,
30
- onOptOut: E,
31
- onError: S,
32
- onNoMatchingQuote: C,
33
- onSelectionChange: w
27
+ logoPosition: E,
28
+ state: Q,
29
+ onQuoteRetrieved: S,
30
+ onOptIn: k,
31
+ onOptOut: h,
32
+ onError: C,
33
+ onNoMatchingQuote: I,
34
+ onSelectionChange: N
34
35
  }, A) => {
35
36
  const g = p(null), n = p(null), o = p({
36
- onQuoteRetrieved: k,
37
- onOptIn: h,
38
- onOptOut: E,
39
- onError: S,
40
- onNoMatchingQuote: C,
41
- onSelectionChange: w
42
- }), I = p(m);
37
+ onQuoteRetrieved: S,
38
+ onOptIn: k,
39
+ onOptOut: h,
40
+ onError: C,
41
+ onNoMatchingQuote: I,
42
+ onSelectionChange: N
43
+ }), w = p(m);
43
44
  o.current = {
44
- onQuoteRetrieved: k,
45
- onOptIn: h,
46
- onOptOut: E,
47
- onError: S,
48
- onNoMatchingQuote: C,
49
- onSelectionChange: w
50
- }, I.current = m;
45
+ onQuoteRetrieved: S,
46
+ onOptIn: k,
47
+ onOptOut: h,
48
+ onError: C,
49
+ onNoMatchingQuote: I,
50
+ onSelectionChange: N
51
+ }, w.current = m;
51
52
  const j = O((e) => {
52
53
  var t, r;
53
54
  return (r = (t = o.current).onQuoteRetrieved) == null ? void 0 : r.call(t, e);
54
55
  }, []), q = O((e) => {
55
56
  var t, r, a, l;
56
57
  (r = (t = o.current).onOptIn) == null || r.call(t, e), (l = (a = o.current).onSelectionChange) == null || l.call(a, e);
57
- }, []), M = O((e) => {
58
+ }, []), D = O((e) => {
58
59
  var t, r, a, l;
59
60
  (r = (t = o.current).onOptOut) == null || r.call(t, e), (l = (a = o.current).onSelectionChange) == null || l.call(a, e);
60
- }, []), D = O((e) => {
61
+ }, []), M = O((e) => {
61
62
  var t, r;
62
63
  (r = (t = o.current).onError) == null || r.call(t, e);
63
- }, []), N = O((e) => {
64
+ }, []), W = O((e) => {
64
65
  var t, r;
65
66
  (r = (t = o.current).onNoMatchingQuote) == null || r.call(t, e);
66
- }, []), W = K(() => {
67
+ }, []), x = B(() => {
67
68
  const e = {}, t = [
68
69
  "onQuoteRetrieved",
69
70
  "onOptIn",
@@ -73,30 +74,31 @@ const F = H(({
73
74
  ];
74
75
  for (const r of t)
75
76
  e[r] = (...a) => {
76
- var x;
77
- const l = (x = I.current) == null ? void 0 : x[r];
77
+ var T;
78
+ const l = (T = w.current) == null ? void 0 : T[r];
78
79
  if (l) return l(...a);
79
80
  };
80
81
  return {
81
82
  ...e,
82
83
  ...o.current.onQuoteRetrieved && { onQuoteRetrieved: j },
83
84
  ...o.current.onOptIn && { onOptIn: q },
84
- ...o.current.onOptOut && { onOptOut: M },
85
- ...o.current.onError && { onError: D },
86
- ...o.current.onNoMatchingQuote && { noMatchingQuote: N }
85
+ ...o.current.onOptOut && { onOptOut: D },
86
+ ...o.current.onError && { onError: M },
87
+ ...o.current.onNoMatchingQuote && { noMatchingQuote: W }
87
88
  };
88
- }, [j, q, M, D, N]), b = z(() => ({
89
+ }, [j, q, D, M, W]), b = V(() => ({
89
90
  apiConfig: c,
90
91
  quoteRequestData: u,
91
92
  showTable: s,
92
93
  selection: d,
93
94
  theme: f,
94
- callbacks: W,
95
+ callbacks: x,
95
96
  useMockData: v,
96
97
  mockData: R,
97
- logoPosition: Q
98
- }), [c, u, s, d, f, W, v, R, Q]);
99
- L(A, () => ({
98
+ logoPosition: E,
99
+ state: Q
100
+ }), [c, u, s, d, f, x, v, R, E, Q]);
101
+ H(A, () => ({
100
102
  updateQuote: (e) => {
101
103
  var t;
102
104
  return ((t = n.current) == null ? void 0 : t.updateQuote(e)) ?? Promise.resolve(!1);
@@ -114,23 +116,24 @@ const F = H(({
114
116
  }
115
117
  }));
116
118
  const y = p(void 0);
117
- return P(() => (g.current && !n.current && (n.current = new T({
119
+ return U(() => (g.current && !n.current && (n.current = new _({
118
120
  location: g.current,
119
121
  ...b
120
122
  }), y.current = b), () => {
121
123
  n.current && (n.current.destroy(), n.current = null);
122
- }), []), P(() => {
124
+ }), []), U(() => {
123
125
  if (n.current && y.current) {
124
126
  const e = y.current, t = b;
125
- i(e.apiConfig, t.apiConfig) && i(e.theme, t.theme) && e.showTable === t.showTable && e.selection === t.selection && i(e.callbacks, t.callbacks) && !i(e.quoteRequestData, t.quoteRequestData) ? n.current.updateQuote(t.quoteRequestData) : i(e, t) || (n.current.destroy(), n.current = new T({
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 _({
126
128
  location: g.current,
127
129
  ...t
128
130
  })), y.current = t;
129
131
  }
130
- }, [b]), /* @__PURE__ */ B("div", { ref: g });
132
+ }, [b]), /* @__PURE__ */ L("div", { ref: g });
131
133
  });
132
- F.displayName = "ReactSpotWidget";
134
+ z.displayName = "ReactSpotWidget";
133
135
  export {
134
- Z as SelectionEnum,
135
- F as default
136
+ Z as NON_US_RESIDENT_VALUE,
137
+ $ as SelectionEnum,
138
+ z as default
136
139
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(s,b){typeof exports=="object"&&typeof module<"u"?b(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"],b):(s=typeof globalThis<"u"?globalThis:s||self,b(s.ReactSpotWidget={},s.React,s.React,s.SpotWidget))})(this,function(s,b,r,R){"use strict";function a(l,c){if(l===c)return!0;if(l==null||c==null||typeof l!="object"||typeof c!="object")return!1;const i=Object.keys(l),O=Object.keys(c);if(i.length!==O.length)return!1;for(let p of i)if(!O.includes(p)||!a(l[p],c[p]))return!1;return!0}function A(l,c){const i=r.useRef(void 0);return(!i.current||!a(i.current.deps,c))&&(i.current={deps:c,value:l()}),i.current.value}const k=r.forwardRef(({apiConfig:l,quoteRequestData:c,showTable:i=!0,selection:O=R.SelectionEnum.UNSELECTED,theme:p,callbacks:m={},useMockData:h,mockData:C,logoPosition:E,onQuoteRetrieved:Q,onOptIn:S,onOptOut:j,onError:q,onNoMatchingQuote:w,onSelectionChange:M},B)=>{const y=r.useRef(null),u=r.useRef(null),o=r.useRef({onQuoteRetrieved:Q,onOptIn:S,onOptOut:j,onError:q,onNoMatchingQuote:w,onSelectionChange:M}),I=r.useRef(m);o.current={onQuoteRetrieved:Q,onOptIn:S,onOptOut:j,onError:q,onNoMatchingQuote:w,onSelectionChange:M},I.current=m;const T=r.useCallback(e=>{var t,n;return(n=(t=o.current).onQuoteRetrieved)==null?void 0:n.call(t,e)},[]),x=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)},[]),N=r.useCallback(e=>{var t,n;(n=(t=o.current).onError)==null||n.call(t,e)},[]),P=r.useCallback(e=>{var t,n;(n=(t=o.current).onNoMatchingQuote)==null||n.call(t,e)},[]),W=r.useMemo(()=>{const e={},t=["onQuoteRetrieved","onOptIn","onOptOut","onError","noMatchingQuote"];for(const n of t)e[n]=(...d)=>{var _;const f=(_=I.current)==null?void 0:_[n];if(f)return f(...d)};return{...e,...o.current.onQuoteRetrieved&&{onQuoteRetrieved:T},...o.current.onOptIn&&{onOptIn:x},...o.current.onOptOut&&{onOptOut:D},...o.current.onError&&{onError:N},...o.current.onNoMatchingQuote&&{noMatchingQuote:P}}},[T,x,D,N,P]),g=A(()=>({apiConfig:l,quoteRequestData:c,showTable:i,selection:O,theme:p,callbacks:W,useMockData:h,mockData:C,logoPosition:E}),[l,c,i,O,p,W,h,C,E]);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 v=r.useRef(void 0);return r.useEffect(()=>(y.current&&!u.current&&(u.current=new R({location:y.current,...g}),v.current=g),()=>{u.current&&(u.current.destroy(),u.current=null)}),[]),r.useEffect(()=>{if(u.current&&v.current){const e=v.current,t=g;a(e.apiConfig,t.apiConfig)&&a(e.theme,t.theme)&&e.showTable===t.showTable&&e.selection===t.selection&&a(e.callbacks,t.callbacks)&&!a(e.quoteRequestData,t.quoteRequestData)?u.current.updateQuote(t.quoteRequestData):a(e,t)||(u.current.destroy(),u.current=new R({location:y.current,...t})),v.current=t}},[g]),b.jsx("div",{ref:y})});k.displayName="ReactSpotWidget",Object.defineProperty(s,"SelectionEnum",{enumerable:!0,get:()=>R.SelectionEnum}),s.default=k,Object.defineProperties(s,{__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 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"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget-react",
3
- "version": "4.1.1",
3
+ "version": "4.3.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.1.1"
17
+ "@getspot/spot-widget": "^4.3.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@types/react": ">=18.0.0",