@getspot/spot-widget-vue 3.2.2 → 4.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [4.0.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-vue@3.2.2...@getspot/spot-widget-vue@4.0.0) (2026-01-12)
2
+
3
+
4
+ * feat!(core): replacing optInSelected prop with selection enum ([0d40913](https://gitlab.com/getspot/spot-widget/commit/0d409135aa50eaa98995b9c1e20ca05cc7e2b2fc))
5
+
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ * better preselection of widget optIn/optOut
10
+
1
11
  ## [3.2.2](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget-vue@3.2.1...@getspot/spot-widget-vue@3.2.2) (2026-01-09)
2
12
 
3
13
 
package/README.md CHANGED
@@ -30,7 +30,7 @@ npm install @getspot/spot-widget-vue
30
30
  }"
31
31
  :quote-request-data="quoteData"
32
32
  :show-table="true"
33
- :opt-in-selected="false"
33
+ :selection="'unselected'"
34
34
  @quote-retrieved="onQuoteRetrieved"
35
35
  @opt-in="onOptIn"
36
36
  @opt-out="onOptOut"
@@ -129,7 +129,7 @@ const onOptOut = (data: SelectionData) => {
129
129
  | Prop | Type | Default | Description |
130
130
  |------|------|---------|-------------|
131
131
  | `showTable` | `boolean` | `true` | Whether to show the payout table |
132
- | `optInSelected` | `boolean` | `false` | Whether the widget should be pre-selected for opt-in |
132
+ | `selection` | `SelectionEnum` | `'unselected'` | Initial selection state for the widget |
133
133
  | `theme` | `Theme` | `undefined` | Theme customization options for styling the widget |
134
134
 
135
135
  ## Events
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import s from "@getspot/spot-widget";
2
- import { createElementBlock as r, openBlock as d } from "vue";
3
- const a = (t, e) => {
1
+ import r, { SelectionEnum as s } from "@getspot/spot-widget";
2
+ import { createElementBlock as d, openBlock as a } from "vue";
3
+ const u = (t, e) => {
4
4
  const i = t.__vccOpts || t;
5
5
  for (const [n, o] of e)
6
6
  i[n] = o;
7
7
  return i;
8
- }, u = {
8
+ }, h = {
9
9
  name: "VueSpotWidget",
10
10
  props: {
11
11
  apiConfig: {
@@ -20,9 +20,10 @@ const a = (t, e) => {
20
20
  type: Boolean,
21
21
  default: !0
22
22
  },
23
- optInSelected: {
24
- type: Boolean,
25
- default: !1
23
+ selection: {
24
+ type: String,
25
+ default: s.UNSELECTED,
26
+ validator: (t) => Object.values(s).includes(t)
26
27
  },
27
28
  theme: {
28
29
  type: Object,
@@ -93,7 +94,7 @@ const a = (t, e) => {
93
94
  apiConfig: this.apiConfig,
94
95
  quoteRequestData: this.quoteRequestData,
95
96
  showTable: this.showTable,
96
- optInSelected: this.optInSelected,
97
+ selection: this.selection,
97
98
  theme: this.theme,
98
99
  callbacks: this.mergedCallbacks,
99
100
  ...this.options
@@ -126,7 +127,7 @@ const a = (t, e) => {
126
127
  showTable(t, e) {
127
128
  t !== e && this.reinitializeWidget();
128
129
  },
129
- optInSelected(t, e) {
130
+ selection(t, e) {
130
131
  t !== e && this.reinitializeWidget();
131
132
  },
132
133
  theme: {
@@ -147,7 +148,7 @@ const a = (t, e) => {
147
148
  this.widget && (this.widget.destroy(), this.widget = null), this.$refs.container && (this.$refs.container.innerHTML = ""), this.$nextTick(() => {
148
149
  var t;
149
150
  try {
150
- this.widget = new s({
151
+ this.widget = new r({
151
152
  ...this.widgetOptions,
152
153
  location: this.$refs.container
153
154
  });
@@ -187,11 +188,11 @@ const a = (t, e) => {
187
188
  beforeUnmount() {
188
189
  this.reinitTimeout && clearTimeout(this.reinitTimeout), this.widget && typeof this.widget.destroy == "function" && this.widget.destroy();
189
190
  }
190
- }, h = { ref: "container" };
191
- function l(t, e, i, n, o, c) {
192
- return d(), r("div", h, null, 512);
191
+ }, l = { ref: "container" };
192
+ function c(t, e, i, n, o, f) {
193
+ return a(), d("div", l, null, 512);
193
194
  }
194
- const p = /* @__PURE__ */ a(u, [["render", l]]);
195
+ const y = /* @__PURE__ */ u(h, [["render", c]]);
195
196
  export {
196
- p as default
197
+ y as default
197
198
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(n,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("@getspot/spot-widget"),require("vue")):typeof define=="function"&&define.amd?define(["@getspot/spot-widget","vue"],o):(n=typeof globalThis<"u"?globalThis:n||self,n.VueSpotWidget=o(n.SpotWidget,n.Vue))})(this,function(n,o){"use strict";const r=(t,e)=>{const i=t.__vccOpts||t;for(const[s,d]of e)i[s]=d;return i},u={name:"VueSpotWidget",props:{apiConfig:{type:Object,default:void 0},quoteRequestData:{type:[Object,Array],default:void 0},showTable:{type:Boolean,default:!0},optInSelected:{type:Boolean,default:!1},theme:{type:Object,default:void 0},callbacks:{type:Object,default:()=>({})},onQuoteRetrieved:{type:Function,default:void 0},onOptIn:{type:Function,default:void 0},onOptOut:{type:Function,default:void 0},onError:{type:Function,default:void 0},onNoMatchingQuote:{type:Function,default:void 0},onSelectionChange:{type:Function,default:void 0},options:{type:Object,default:()=>({})}},data(){return{widget:null,reinitTimeout:null}},computed:{mergedCallbacks(){return{...this.callbacks,...this.onQuoteRetrieved&&{onQuoteRetrieved:this.onQuoteRetrieved},...this.onOptIn&&{onOptIn:t=>{var e,i;(e=this.onOptIn)==null||e.call(this,t),(i=this.onSelectionChange)==null||i.call(this,t)}},...this.onOptOut&&{onOptOut:t=>{var e,i;(e=this.onOptOut)==null||e.call(this,t),(i=this.onSelectionChange)==null||i.call(this,t)}},...this.onError&&{onError:this.onError},...this.onNoMatchingQuote&&{onNoMatchingQuote:this.onNoMatchingQuote}}},widgetOptions(){return{apiConfig:this.apiConfig,quoteRequestData:this.quoteRequestData,showTable:this.showTable,optInSelected:this.optInSelected,theme:this.theme,callbacks:this.mergedCallbacks,...this.options}}},mounted(){this.initializeWidget()},watch:{quoteRequestData:{handler(t,e){this.widget&&t&&JSON.stringify(t)!==JSON.stringify(e)&&(this.reinitTimeout&&clearTimeout(this.reinitTimeout),this.reinitTimeout=setTimeout(async()=>{try{await this.widget.updateQuote(t)||this.reinitializeWidget()}catch{this.reinitializeWidget()}this.reinitTimeout=null},100))},deep:!0},apiConfig:{handler(){this.reinitializeWidget()},deep:!0},showTable(t,e){t!==e&&this.reinitializeWidget()},optInSelected(t,e){t!==e&&this.reinitializeWidget()},theme:{handler(t,e){this.widget&&JSON.stringify(t)!==JSON.stringify(e)&&this.updateTheme(t)},deep:!0},mergedCallbacks:{handler(t,e){this.widget&&JSON.stringify(t)!==JSON.stringify(e)&&this.updateCallbacks(t)},deep:!0}},methods:{initializeWidget(){this.widget&&(this.widget.destroy(),this.widget=null),this.$refs.container&&(this.$refs.container.innerHTML=""),this.$nextTick(()=>{var t;try{this.widget=new n({...this.widgetOptions,location:this.$refs.container})}catch(e){this.$emit("error",e),(t=this.onError)==null||t.call(this,e)}})},reinitializeWidget(){this.widget&&(this.widget.destroy(),this.widget=null),this.initializeWidget()},async updateQuote(t){var e;return(e=this.widget)==null?void 0:e.updateQuote(t)},getSelection(){var t;return(t=this.widget)==null?void 0:t.getSelection()},validateSelection(){var t;return(t=this.widget)==null?void 0:t.validateSelection()},updateTheme(t){!this.widget||!this.widget.container||Object.entries(t||{}).forEach(([e,i])=>{const s=`--${e}`;this.widget.container.style.setProperty(s,i)})},updateCallbacks(t){this.widget&&(this.widget.options.callbacks=t)},destroy(){this.widget&&typeof this.widget.destroy=="function"&&(this.widget.destroy(),this.widget=null)}},beforeUnmount(){this.reinitTimeout&&clearTimeout(this.reinitTimeout),this.widget&&typeof this.widget.destroy=="function"&&this.widget.destroy()}},a={ref:"container"};function h(t,e,i,s,d,l){return o.openBlock(),o.createElementBlock("div",a,null,512)}return r(u,[["render",h]])});
1
+ (function(n,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("@getspot/spot-widget"),require("vue")):typeof define=="function"&&define.amd?define(["@getspot/spot-widget","vue"],o):(n=typeof globalThis<"u"?globalThis:n||self,n.VueSpotWidget=o(n.SpotWidget,n.Vue))})(this,function(n,o){"use strict";const d=(t,e)=>{const i=t.__vccOpts||t;for(const[s,r]of e)i[s]=r;return i},u={name:"VueSpotWidget",props:{apiConfig:{type:Object,default:void 0},quoteRequestData:{type:[Object,Array],default:void 0},showTable:{type:Boolean,default:!0},selection:{type:String,default:n.SelectionEnum.UNSELECTED,validator:t=>Object.values(n.SelectionEnum).includes(t)},theme:{type:Object,default:void 0},callbacks:{type:Object,default:()=>({})},onQuoteRetrieved:{type:Function,default:void 0},onOptIn:{type:Function,default:void 0},onOptOut:{type:Function,default:void 0},onError:{type:Function,default:void 0},onNoMatchingQuote:{type:Function,default:void 0},onSelectionChange:{type:Function,default:void 0},options:{type:Object,default:()=>({})}},data(){return{widget:null,reinitTimeout:null}},computed:{mergedCallbacks(){return{...this.callbacks,...this.onQuoteRetrieved&&{onQuoteRetrieved:this.onQuoteRetrieved},...this.onOptIn&&{onOptIn:t=>{var e,i;(e=this.onOptIn)==null||e.call(this,t),(i=this.onSelectionChange)==null||i.call(this,t)}},...this.onOptOut&&{onOptOut:t=>{var e,i;(e=this.onOptOut)==null||e.call(this,t),(i=this.onSelectionChange)==null||i.call(this,t)}},...this.onError&&{onError:this.onError},...this.onNoMatchingQuote&&{onNoMatchingQuote:this.onNoMatchingQuote}}},widgetOptions(){return{apiConfig:this.apiConfig,quoteRequestData:this.quoteRequestData,showTable:this.showTable,selection:this.selection,theme:this.theme,callbacks:this.mergedCallbacks,...this.options}}},mounted(){this.initializeWidget()},watch:{quoteRequestData:{handler(t,e){this.widget&&t&&JSON.stringify(t)!==JSON.stringify(e)&&(this.reinitTimeout&&clearTimeout(this.reinitTimeout),this.reinitTimeout=setTimeout(async()=>{try{await this.widget.updateQuote(t)||this.reinitializeWidget()}catch{this.reinitializeWidget()}this.reinitTimeout=null},100))},deep:!0},apiConfig:{handler(){this.reinitializeWidget()},deep:!0},showTable(t,e){t!==e&&this.reinitializeWidget()},selection(t,e){t!==e&&this.reinitializeWidget()},theme:{handler(t,e){this.widget&&JSON.stringify(t)!==JSON.stringify(e)&&this.updateTheme(t)},deep:!0},mergedCallbacks:{handler(t,e){this.widget&&JSON.stringify(t)!==JSON.stringify(e)&&this.updateCallbacks(t)},deep:!0}},methods:{initializeWidget(){this.widget&&(this.widget.destroy(),this.widget=null),this.$refs.container&&(this.$refs.container.innerHTML=""),this.$nextTick(()=>{var t;try{this.widget=new n({...this.widgetOptions,location:this.$refs.container})}catch(e){this.$emit("error",e),(t=this.onError)==null||t.call(this,e)}})},reinitializeWidget(){this.widget&&(this.widget.destroy(),this.widget=null),this.initializeWidget()},async updateQuote(t){var e;return(e=this.widget)==null?void 0:e.updateQuote(t)},getSelection(){var t;return(t=this.widget)==null?void 0:t.getSelection()},validateSelection(){var t;return(t=this.widget)==null?void 0:t.validateSelection()},updateTheme(t){!this.widget||!this.widget.container||Object.entries(t||{}).forEach(([e,i])=>{const s=`--${e}`;this.widget.container.style.setProperty(s,i)})},updateCallbacks(t){this.widget&&(this.widget.options.callbacks=t)},destroy(){this.widget&&typeof this.widget.destroy=="function"&&(this.widget.destroy(),this.widget=null)}},beforeUnmount(){this.reinitTimeout&&clearTimeout(this.reinitTimeout),this.widget&&typeof this.widget.destroy=="function"&&this.widget.destroy()}},a={ref:"container"};function h(t,e,i,s,r,l){return o.openBlock(),o.createElementBlock("div",a,null,512)}return d(u,[["render",h]])});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget-vue",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "description": "Vue 3 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": "^3.3.2"
17
+ "@getspot/spot-widget": "^4.0.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "vue": "^3.0.0"