@covet-pics/covet-pics-widget 0.125.2 → 0.125.3

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.
@@ -93,12 +93,19 @@ const CovetPicsDirectBuy = class {
93
93
  }
94
94
  componentWillLoad() {
95
95
  this.initStore();
96
+ this.setSingleSelectedValues();
96
97
  }
97
98
  componentDidLoad() {
98
99
  this.initSwiper();
99
100
  const closeBtn = this.el.shadowRoot.querySelector(".close");
100
101
  closeBtn.focus();
101
102
  }
103
+ componentDidUpdate() {
104
+ // TODO check do we need this update in componentDidUpdate
105
+ if (this.mainGallery) {
106
+ this.mainGallery.update();
107
+ }
108
+ }
102
109
  disconnectedCallback() {
103
110
  this.unsubscribe();
104
111
  }
@@ -110,6 +117,11 @@ const CovetPicsDirectBuy = class {
110
117
  this.settings = this.appState.settings;
111
118
  });
112
119
  }
120
+ setSingleSelectedValues() {
121
+ if (this.product.options && this.product.options.length > 0) {
122
+ this.product.options.forEach((option, index) => this.updateSelectedOptions(`option${index + 1}`, option.values[0]));
123
+ }
124
+ }
113
125
  get productId() {
114
126
  if (typeof this.product !== "undefined") {
115
127
  return this.product.id.toString();
@@ -163,9 +175,6 @@ const CovetPicsDirectBuy = class {
163
175
  });
164
176
  }
165
177
  renderOptions(optionData, optionNumber) {
166
- if (optionData && optionData.values.length === 1) {
167
- this.updateSelectedOptions(`option${optionNumber}`, optionData.values[0]);
168
- }
169
178
  if (optionData && optionData.values.length > 1) {
170
179
  return (
171
180
  // TODO switch to native html select
@@ -193,12 +202,6 @@ const CovetPicsDirectBuy = class {
193
202
  });
194
203
  }
195
204
  }
196
- componentDidUpdate() {
197
- // TODO check do we need this update in componentDidUpdate
198
- if (this.mainGallery) {
199
- this.mainGallery.update();
200
- }
201
- }
202
205
  imgAltTag(caption, idx, itemsLength) {
203
206
  return caption && caption.length > 0
204
207
  ? `${caption} product slide ${idx} of ${itemsLength}`