@getspot/spot-widget-react 3.0.2 → 3.1.1
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 +14 -0
- package/dist/ReactSpotWidget.d.ts +2 -2
- package/dist/ReactSpotWidget.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +14 -14
- package/dist/index.umd.js +1 -1
- package/package.json +12 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @getspot/spot-widget-react
|
|
2
2
|
|
|
3
|
+
## 3.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f3c5aed: fix rerender errors
|
|
8
|
+
- Updated dependencies [f3c5aed]
|
|
9
|
+
- @getspot/spot-widget@3.0.2
|
|
10
|
+
|
|
11
|
+
## 3.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 7b695ae: Fix re-rendering issues
|
|
16
|
+
|
|
3
17
|
## 3.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type SpotWidgetOptions, type SelectionData, type Quote } from "@getspot/spot-widget";
|
|
2
|
+
import { type SpotWidgetOptions, type SelectionData, type Quote, type QuoteUpdates } from "@getspot/spot-widget";
|
|
3
3
|
/**
|
|
4
4
|
* Props for the ReactSpotWidget component
|
|
5
5
|
*/
|
|
@@ -15,7 +15,7 @@ interface ReactSpotWidgetProps extends Omit<SpotWidgetOptions, 'location' | 'cal
|
|
|
15
15
|
/** Theme customization options for styling the widget */
|
|
16
16
|
theme?: SpotWidgetOptions['theme'];
|
|
17
17
|
/** Callback fired when a quote is successfully retrieved */
|
|
18
|
-
onQuoteRetrieved?: (quote: Quote) => void;
|
|
18
|
+
onQuoteRetrieved?: (quote: Quote) => QuoteUpdates | void;
|
|
19
19
|
/** Callback fired when user opts in to the refund guarantee */
|
|
20
20
|
onOptIn?: (data: SelectionData) => void;
|
|
21
21
|
/** Callback fired when user opts out of the refund guarantee */
|
|
@@ -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,MAAM,sBAAsB,CAAC;
|
|
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,MAAM,sBAAsB,CAAC;AAE7H;;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,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IACxD,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yDAAyD;IACzD,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,YAAY,GAAG,IAAI,CAAC;IACzD,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,iEAAiE;IACjE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IACpF,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAClE,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,gDAAgD;IAChD,SAAS,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,WAAW,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9F,qCAAqC;IACrC,YAAY,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IACzC,kDAAkD;IAClD,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,yDAAyD;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,eAAe,iGAoLnB,CAAC;AAIH,eAAe,eAAe,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type SpotWidgetOptions, type SelectionData, type Quote } from "@getspot/spot-widget";
|
|
2
|
+
import { type SpotWidgetOptions, type SelectionData, type Quote, type QuoteUpdates } from "@getspot/spot-widget";
|
|
3
3
|
/**
|
|
4
4
|
* Props for the ReactSpotWidget component
|
|
5
5
|
*/
|
|
@@ -15,7 +15,7 @@ interface ReactSpotWidgetProps extends Omit<SpotWidgetOptions, 'location' | 'cal
|
|
|
15
15
|
/** Theme customization options for styling the widget */
|
|
16
16
|
theme?: SpotWidgetOptions['theme'];
|
|
17
17
|
/** Callback fired when a quote is successfully retrieved */
|
|
18
|
-
onQuoteRetrieved?: (quote: Quote) => void;
|
|
18
|
+
onQuoteRetrieved?: (quote: Quote) => QuoteUpdates | void;
|
|
19
19
|
/** Callback fired when user opts in to the refund guarantee */
|
|
20
20
|
onOptIn?: (data: SelectionData) => void;
|
|
21
21
|
/** Callback fired when user opts out of the refund guarantee */
|
package/dist/index.es.js
CHANGED
|
@@ -11,7 +11,7 @@ function i(c, u) {
|
|
|
11
11
|
return !0;
|
|
12
12
|
}
|
|
13
13
|
function K(c, u) {
|
|
14
|
-
const s = p();
|
|
14
|
+
const s = p(void 0);
|
|
15
15
|
return (!s.current || !i(s.current.deps, u)) && (s.current = { deps: u, value: c() }), s.current.value;
|
|
16
16
|
}
|
|
17
17
|
const T = A(({
|
|
@@ -20,30 +20,30 @@ const T = A(({
|
|
|
20
20
|
showTable: s = !0,
|
|
21
21
|
optInSelected: d = !1,
|
|
22
22
|
theme: f,
|
|
23
|
-
callbacks:
|
|
24
|
-
onQuoteRetrieved:
|
|
25
|
-
onOptIn:
|
|
26
|
-
onOptOut:
|
|
23
|
+
callbacks: v = {},
|
|
24
|
+
onQuoteRetrieved: k,
|
|
25
|
+
onOptIn: R,
|
|
26
|
+
onOptOut: m,
|
|
27
27
|
onError: Q,
|
|
28
28
|
onNoMatchingQuote: h,
|
|
29
29
|
onSelectionChange: S
|
|
30
30
|
}, P) => {
|
|
31
31
|
const g = p(null), n = p(null), o = p({
|
|
32
|
-
onQuoteRetrieved:
|
|
33
|
-
onOptIn:
|
|
34
|
-
onOptOut:
|
|
32
|
+
onQuoteRetrieved: k,
|
|
33
|
+
onOptIn: R,
|
|
34
|
+
onOptOut: m,
|
|
35
35
|
onError: Q,
|
|
36
36
|
onNoMatchingQuote: h,
|
|
37
37
|
onSelectionChange: S
|
|
38
|
-
}), C = p(
|
|
38
|
+
}), C = p(v);
|
|
39
39
|
o.current = {
|
|
40
|
-
onQuoteRetrieved:
|
|
41
|
-
onOptIn:
|
|
42
|
-
onOptOut:
|
|
40
|
+
onQuoteRetrieved: k,
|
|
41
|
+
onOptIn: R,
|
|
42
|
+
onOptOut: m,
|
|
43
43
|
onError: Q,
|
|
44
44
|
onNoMatchingQuote: h,
|
|
45
45
|
onSelectionChange: S
|
|
46
|
-
}, C.current =
|
|
46
|
+
}, C.current = v;
|
|
47
47
|
const I = O((e) => {
|
|
48
48
|
var t, r;
|
|
49
49
|
return (r = (t = o.current).onQuoteRetrieved) == null ? void 0 : r.call(t, e);
|
|
@@ -106,7 +106,7 @@ const T = A(({
|
|
|
106
106
|
n.current && (n.current.destroy(), n.current = null);
|
|
107
107
|
}
|
|
108
108
|
}));
|
|
109
|
-
const y = p();
|
|
109
|
+
const y = p(void 0);
|
|
110
110
|
return W(() => (g.current && !n.current && (n.current = new N({
|
|
111
111
|
location: g.current,
|
|
112
112
|
...b
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("react/jsx-runtime"),require("react"),require("@getspot/spot-widget")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","@getspot/spot-widget"],n):(i=typeof globalThis<"u"?globalThis:i||self,i.ReactSpotWidget=n(i.React,i.React,i.SpotWidget))})(this,function(i,n,k){"use strict";function a(s,c){if(s===c)return!0;if(s==null||c==null||typeof s!="object"||typeof c!="object")return!1;const l=Object.keys(s),R=Object.keys(c);if(l.length!==R.length)return!1;for(let d of l)if(!R.includes(d)||!a(s[d],c[d]))return!1;return!0}function N(s,c){const l=n.useRef();return(!l.current||!a(l.current.deps,c))&&(l.current={deps:c,value:s()}),l.current.value}const y=n.forwardRef(({apiConfig:s,quoteRequestData:c,showTable:l=!0,optInSelected:R=!1,theme:d,callbacks:
|
|
1
|
+
(function(i,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("react/jsx-runtime"),require("react"),require("@getspot/spot-widget")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","@getspot/spot-widget"],n):(i=typeof globalThis<"u"?globalThis:i||self,i.ReactSpotWidget=n(i.React,i.React,i.SpotWidget))})(this,function(i,n,k){"use strict";function a(s,c){if(s===c)return!0;if(s==null||c==null||typeof s!="object"||typeof c!="object")return!1;const l=Object.keys(s),R=Object.keys(c);if(l.length!==R.length)return!1;for(let d of l)if(!R.includes(d)||!a(s[d],c[d]))return!1;return!0}function N(s,c){const l=n.useRef(void 0);return(!l.current||!a(l.current.deps,c))&&(l.current={deps:c,value:s()}),l.current.value}const y=n.forwardRef(({apiConfig:s,quoteRequestData:c,showTable:l=!0,optInSelected:R=!1,theme:d,callbacks:v={},onQuoteRetrieved:h,onOptIn:Q,onOptOut:m,onError:C,onNoMatchingQuote:S,onSelectionChange:j},P)=>{const O=n.useRef(null),u=n.useRef(null),o=n.useRef({onQuoteRetrieved:h,onOptIn:Q,onOptOut:m,onError:C,onNoMatchingQuote:S,onSelectionChange:j}),q=n.useRef(v);o.current={onQuoteRetrieved:h,onOptIn:Q,onOptOut:m,onError:C,onNoMatchingQuote:S,onSelectionChange:j},q.current=v;const w=n.useCallback(e=>{var t,r;return(r=(t=o.current).onQuoteRetrieved)==null?void 0:r.call(t,e)},[]),E=n.useCallback(e=>{var t,r,p,f;(r=(t=o.current).onOptIn)==null||r.call(t,e),(f=(p=o.current).onSelectionChange)==null||f.call(p,e)},[]),I=n.useCallback(e=>{var t,r,p,f;(r=(t=o.current).onOptOut)==null||r.call(t,e),(f=(p=o.current).onSelectionChange)==null||f.call(p,e)},[]),M=n.useCallback(e=>{var t,r;(r=(t=o.current).onError)==null||r.call(t,e)},[]),x=n.useCallback(e=>{var t,r;(r=(t=o.current).onNoMatchingQuote)==null||r.call(t,e)},[]),D=n.useMemo(()=>{const e={},t=["onQuoteRetrieved","onOptIn","onOptOut","onError","noMatchingQuote"];for(const r of t)e[r]=(...p)=>{var W;const f=(W=q.current)==null?void 0:W[r];if(f)return f(...p)};return{...e,...o.current.onQuoteRetrieved&&{onQuoteRetrieved:w},...o.current.onOptIn&&{onOptIn:E},...o.current.onOptOut&&{onOptOut:I},...o.current.onError&&{onError:M},...o.current.onNoMatchingQuote&&{noMatchingQuote:x}}},[w,E,I,M,x]),g=N(()=>({apiConfig:s,quoteRequestData:c,showTable:l,optInSelected:R,theme:d,callbacks:D}),[s,c,l,R,d,D]);n.useImperativeHandle(P,()=>({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 b=n.useRef(void 0);return n.useEffect(()=>(O.current&&!u.current&&(u.current=new k({location:O.current,...g}),b.current=g),()=>{u.current&&(u.current.destroy(),u.current=null)}),[]),n.useEffect(()=>{if(u.current&&b.current){const e=b.current,t=g;a(e.apiConfig,t.apiConfig)&&a(e.theme,t.theme)&&e.showTable===t.showTable&&e.optInSelected===t.optInSelected&&a(e.callbacks,t.callbacks)&&!a(e.quoteRequestData,t.quoteRequestData)?u.current.updateQuote(t.quoteRequestData):a(e,t)||(u.current.destroy(),u.current=new k({location:O.current,...t})),b.current=t}},[g]),i.jsx("div",{ref:O})});return y.displayName="ReactSpotWidget",y});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getspot/spot-widget-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -12,18 +12,8 @@
|
|
|
12
12
|
"README.md",
|
|
13
13
|
"CHANGELOG.md"
|
|
14
14
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "vite build && npx -p typescript tsc --emitDeclarationOnly && cp dist/ReactSpotWidget.d.ts dist/index.d.ts",
|
|
17
|
-
"docs": "npx -p typedoc -p typedoc-plugin-markdown typedoc --plugin typedoc-plugin-markdown --out docs src/ReactSpotWidget.tsx",
|
|
18
|
-
"docs:readme": "npm run docs && node scripts/generate-readme.js",
|
|
19
|
-
"test": "jest",
|
|
20
|
-
"test:watch": "jest --watch",
|
|
21
|
-
"test:coverage": "jest --coverage",
|
|
22
|
-
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
24
|
-
},
|
|
25
15
|
"dependencies": {
|
|
26
|
-
"@getspot/spot-widget": "
|
|
16
|
+
"@getspot/spot-widget": "3.0.2"
|
|
27
17
|
},
|
|
28
18
|
"peerDependencies": {
|
|
29
19
|
"react": ">=18.0.0",
|
|
@@ -48,5 +38,14 @@
|
|
|
48
38
|
"react": "^18.0.0",
|
|
49
39
|
"react-dom": "^18.0.0",
|
|
50
40
|
"ts-jest": "^29.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "vite build && npx -p typescript tsc --emitDeclarationOnly && cp dist/ReactSpotWidget.d.ts dist/index.d.ts",
|
|
44
|
+
"docs": "npx -p typedoc -p typedoc-plugin-markdown typedoc --plugin typedoc-plugin-markdown --out docs src/ReactSpotWidget.tsx",
|
|
45
|
+
"docs:readme": "npm run docs && node scripts/generate-readme.js",
|
|
46
|
+
"test": "jest",
|
|
47
|
+
"test:watch": "jest --watch",
|
|
48
|
+
"test:coverage": "jest --coverage",
|
|
49
|
+
"test:ci": "jest --ci --coverage --watchAll=false"
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|