@ikas/storefront 4.0.0-alpha.31 → 4.0.0-alpha.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.0.0-alpha.31",
3
+ "version": "4.0.0-alpha.32",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "Umut Ozan Yıldırım",
6
6
  "license": "ISC",
@@ -24,11 +24,11 @@
24
24
  "libphonenumber-js": "^1.10.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@ikas/storefront-api": "^4.0.0-alpha.31",
28
- "@ikas/storefront-config": "^4.0.0-alpha.31",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.31",
30
- "@ikas/storefront-models": "^4.0.0-alpha.31",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.31",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.32",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.32",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.32",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.32",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.32",
32
32
  "@rollup/plugin-commonjs": "^22.0.0",
33
33
  "@rollup/plugin-json": "^4.1.0",
34
34
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "html-react-parser": "^1.4.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.0.0-alpha.31",
56
- "@ikas/storefront-config": "^4.0.0-alpha.31",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.31",
58
- "@ikas/storefront-models": "^4.0.0-alpha.31",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.31",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.32",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.32",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.32",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.32",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.32",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -622,87 +622,16 @@ export default class IkasPageEditorViewModel {
622
622
  prop
623
623
  );
624
624
 
625
- await this.pageDataProvider.setLinkSlugs();
625
+ if (propValue.linkType || JSON.stringify(propValue)?.includes("linkType"))
626
+ await this.pageDataProvider.setLinkSlugs();
626
627
 
627
628
  if (pageComponentPropValues) {
628
- if (prop.type === IkasThemeJsonComponentPropType.CUSTOM) {
629
- IkasPageDataInit.initCustomDataPropValue(
630
- prop,
631
- propValue,
632
- pageComponentPropValues,
633
- this.theme!.settings,
634
- true
635
- );
636
- } else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT) {
637
- IkasPageDataInit.initComponentPropValue(
638
- prop,
639
- propValue,
640
- pageComponentPropValues,
641
- this.theme!.settings,
642
- true
643
- );
644
- } else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT_LIST) {
645
- IkasPageDataInit.initComponentListPropValue(
646
- prop,
647
- propValue,
648
- pageComponentPropValues,
649
- this.theme!.settings,
650
- true
651
- );
652
- } else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_DETAIL) {
653
- IkasPageDataInit.initProductPropValue(
654
- prop,
655
- propValue,
656
- pageComponentPropValues
657
- );
658
- } else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_LIST) {
659
- IkasPageDataInit.initProductListPropValue(
660
- prop,
661
- propValue,
662
- pageComponentPropValues
663
- );
664
- } else if (prop.type === IkasThemeJsonComponentPropType.CATEGORY) {
665
- IkasPageDataInit.initCategoryPropValue(
666
- prop,
667
- propValue,
668
- pageComponentPropValues
669
- );
670
- } else if (prop.type === IkasThemeJsonComponentPropType.BRAND) {
671
- IkasPageDataInit.initBrandPropValue(
672
- prop,
673
- propValue,
674
- pageComponentPropValues
675
- );
676
- } else if (prop.type === IkasThemeJsonComponentPropType.BLOG) {
677
- IkasPageDataInit.initBlogPropValue(
678
- prop,
679
- propValue,
680
- pageComponentPropValues
681
- );
682
- } else if (prop.type === IkasThemeJsonComponentPropType.BLOG_CATEGORY) {
683
- IkasPageDataInit.initBlogCategoryPropValue(
684
- prop,
685
- propValue,
686
- pageComponentPropValues
687
- );
688
- } else if (prop.type === IkasThemeJsonComponentPropType.RAFFLE) {
689
- IkasPageDataInit.initRafflePropValue(
690
- prop,
691
- propValue,
692
- pageComponentPropValues
693
- );
694
- } else if (
695
- prop.type === IkasThemeJsonComponentPropType.LINK ||
696
- prop.type === IkasThemeJsonComponentPropType.LIST_OF_LINK
697
- ) {
698
- IkasPageDataInit.initLinkPropValue(
699
- prop,
700
- propValue,
701
- pageComponentPropValues
702
- );
703
- } else {
704
- pageComponentPropValues.propValues[propName] = propValue;
705
- }
629
+ pageComponentPropValues.propValues[propName] = propValue;
630
+ IkasPageDataInit.initPropValue(
631
+ pageComponentPropValues,
632
+ this.theme!.settings,
633
+ true
634
+ );
706
635
  }
707
636
  };
708
637
 
@@ -771,24 +700,16 @@ export default class IkasPageEditorViewModel {
771
700
  const pageComponentPropValues =
772
701
  await this.pageDataProvider!.getPageComponentPropValues(pageComponent);
773
702
 
774
- const customDataProps = pageComponentPropValues.component.props.filter(
775
- (p) => p.type === IkasThemeJsonComponentPropType.CUSTOM
703
+ IkasPageDataInit.initPropValue(
704
+ pageComponentPropValues,
705
+ this.theme!.settings,
706
+ true
776
707
  );
777
708
 
778
- customDataProps.forEach((customDataProp) => {
779
- IkasPageDataInit.initCustomDataPropValue(
780
- customDataProp,
781
- pageComponentPropValues.propValues[customDataProp.name],
782
- pageComponentPropValues,
783
- this.theme!.settings,
784
- true
785
- );
786
-
787
- this.pageDataProvider!.pageComponentPropValues.push(
788
- pageComponentPropValues
789
- );
790
- this.pageComponents.push(pageComponent);
791
- });
709
+ this.pageDataProvider!.pageComponentPropValues.push(
710
+ pageComponentPropValues
711
+ );
712
+ this.pageComponents.push(pageComponent);
792
713
  };
793
714
 
794
715
  handleDeletePageComponent = (data: any) => {
@@ -3,7 +3,6 @@ import { IkasCategoryListParams } from "../models/ui/category-list";
3
3
  import { IkasAttributeList } from "../models/ui/product-attribute-list";
4
4
  import { IkasProductListParams } from "../models/ui/product-list";
5
5
  import { IkasRaffleListParams } from "../models/ui/raffle-list";
6
- import { observable } from "mobx";
7
6
 
8
7
  import {
9
8
  IkasThemeJsonSettings,
@@ -54,7 +53,7 @@ import {
54
53
  import _cloneDeep from "lodash/cloneDeep";
55
54
 
56
55
  export class IkasPageDataInit {
57
- static pageSpecificData: any = observable({});
56
+ static pageSpecificData: any = {};
58
57
 
59
58
  static setPageSpecificData(
60
59
  pageSpecificData: any,
@@ -71,7 +70,8 @@ export class IkasPageDataInit {
71
70
  const product = pageSpecificData as IkasProduct;
72
71
  IkasPageDataInit.pageSpecificData = new IkasProduct({
73
72
  ...product,
74
- selectedVariantValues: product.selectedVariantValues,
73
+ selectedVariantValues:
74
+ product.selectedVariantValues || product.variants[0].variantValues,
75
75
  });
76
76
  if (isBrowser) {
77
77
  this._initProductOnBrowser(IkasPageDataInit.pageSpecificData);
@@ -113,202 +113,212 @@ export class IkasPageDataInit {
113
113
  }
114
114
 
115
115
  static initPropValues(
116
- _pageComponentPropValues: IkasPageComponentPropValue[],
116
+ pageComponentPropValues: IkasPageComponentPropValue[],
117
117
  settings: IkasThemeJsonSettings,
118
118
  isBrowser?: boolean
119
119
  ) {
120
- const pageComponentPropValues = _cloneDeep(_pageComponentPropValues);
121
-
122
120
  pageComponentPropValues.forEach((pageComponentPropValue) => {
123
- const props = pageComponentPropValue.component.props;
124
-
125
- props.forEach((prop) => {
126
- const propValue = pageComponentPropValue.propValues[prop.name];
127
- if (propValue === null || propValue === undefined) return;
128
-
129
- switch (prop.type) {
130
- case IkasThemeJsonComponentPropType.IMAGE:
131
- IkasPageDataInit.initImagePropValue(
132
- prop,
133
- propValue,
134
- pageComponentPropValue
135
- );
136
- break;
121
+ IkasPageDataInit.initPropValue(
122
+ pageComponentPropValue,
123
+ settings,
124
+ isBrowser
125
+ );
126
+ });
137
127
 
138
- case IkasThemeJsonComponentPropType.IMAGE_LIST:
139
- IkasPageDataInit.initImageListPropValue(
140
- prop,
141
- propValue,
142
- pageComponentPropValue
143
- );
144
- break;
128
+ return pageComponentPropValues;
129
+ }
145
130
 
146
- case IkasThemeJsonComponentPropType.BRAND:
147
- IkasPageDataInit.initBrandPropValue(
148
- prop,
149
- propValue,
150
- pageComponentPropValue
151
- );
152
- break;
131
+ static initPropValue(
132
+ pageComponentPropValue: IkasPageComponentPropValue,
133
+ settings: IkasThemeJsonSettings,
134
+ isBrowser?: boolean
135
+ ) {
136
+ const props = pageComponentPropValue.component.props;
137
+
138
+ props.forEach((prop) => {
139
+ const propValue = pageComponentPropValue.propValues[prop.name];
140
+ if (propValue === null || propValue === undefined) return;
141
+
142
+ switch (prop.type) {
143
+ case IkasThemeJsonComponentPropType.IMAGE:
144
+ IkasPageDataInit.initImagePropValue(
145
+ prop,
146
+ propValue,
147
+ pageComponentPropValue
148
+ );
149
+ break;
153
150
 
154
- case IkasThemeJsonComponentPropType.BRAND_LIST:
155
- IkasPageDataInit.initBrandListPropValue(
156
- prop,
157
- propValue,
158
- pageComponentPropValue
159
- );
160
- break;
151
+ case IkasThemeJsonComponentPropType.IMAGE_LIST:
152
+ IkasPageDataInit.initImageListPropValue(
153
+ prop,
154
+ propValue,
155
+ pageComponentPropValue
156
+ );
157
+ break;
161
158
 
162
- case IkasThemeJsonComponentPropType.CATEGORY:
163
- IkasPageDataInit.initCategoryPropValue(
164
- prop,
165
- propValue,
166
- pageComponentPropValue
167
- );
168
- break;
159
+ case IkasThemeJsonComponentPropType.BRAND:
160
+ IkasPageDataInit.initBrandPropValue(
161
+ prop,
162
+ propValue,
163
+ pageComponentPropValue
164
+ );
165
+ break;
169
166
 
170
- case IkasThemeJsonComponentPropType.CATEGORY_LIST:
171
- IkasPageDataInit.initCategoryListPropValue(
172
- prop,
173
- propValue,
174
- pageComponentPropValue
175
- );
176
- break;
167
+ case IkasThemeJsonComponentPropType.BRAND_LIST:
168
+ IkasPageDataInit.initBrandListPropValue(
169
+ prop,
170
+ propValue,
171
+ pageComponentPropValue
172
+ );
173
+ break;
177
174
 
178
- case IkasThemeJsonComponentPropType.PRODUCT_LIST:
179
- IkasPageDataInit.initProductListPropValue(
180
- prop,
181
- propValue,
182
- pageComponentPropValue
183
- );
184
- break;
175
+ case IkasThemeJsonComponentPropType.CATEGORY:
176
+ IkasPageDataInit.initCategoryPropValue(
177
+ prop,
178
+ propValue,
179
+ pageComponentPropValue
180
+ );
181
+ break;
185
182
 
186
- case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
187
- IkasPageDataInit.initProductPropValue(
188
- prop,
189
- propValue,
190
- pageComponentPropValue
191
- );
192
- break;
183
+ case IkasThemeJsonComponentPropType.CATEGORY_LIST:
184
+ IkasPageDataInit.initCategoryListPropValue(
185
+ prop,
186
+ propValue,
187
+ pageComponentPropValue
188
+ );
189
+ break;
193
190
 
194
- case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
195
- IkasPageDataInit.initAttributePropValue(
196
- prop,
197
- propValue,
198
- pageComponentPropValue
199
- );
200
- break;
191
+ case IkasThemeJsonComponentPropType.PRODUCT_LIST:
192
+ IkasPageDataInit.initProductListPropValue(
193
+ prop,
194
+ propValue,
195
+ pageComponentPropValue
196
+ );
197
+ break;
201
198
 
202
- case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
203
- IkasPageDataInit.initAttributeListPropValue(
204
- prop,
205
- propValue,
206
- pageComponentPropValue
207
- );
208
- break;
209
-
210
- case IkasThemeJsonComponentPropType.LINK:
211
- case IkasThemeJsonComponentPropType.LIST_OF_LINK:
212
- IkasPageDataInit.initLinkPropValue(
213
- prop,
214
- propValue,
215
- pageComponentPropValue
216
- );
217
- break;
218
-
219
- case IkasThemeJsonComponentPropType.COMPONENT:
220
- IkasPageDataInit.initComponentPropValue(
221
- prop,
222
- propValue,
223
- pageComponentPropValue,
224
- settings,
225
- isBrowser
226
- );
227
- break;
228
-
229
- case IkasThemeJsonComponentPropType.COMPONENT_LIST:
230
- IkasPageDataInit.initComponentListPropValue(
231
- prop,
232
- propValue,
233
- pageComponentPropValue,
234
- settings,
235
- isBrowser
236
- );
237
- break;
238
-
239
- case IkasThemeJsonComponentPropType.CUSTOM:
240
- IkasPageDataInit.initCustomDataPropValue(
241
- prop,
242
- propValue,
243
- pageComponentPropValue,
244
- settings,
245
- isBrowser
246
- );
247
- break;
199
+ case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
200
+ IkasPageDataInit.initProductPropValue(
201
+ prop,
202
+ propValue,
203
+ pageComponentPropValue
204
+ );
205
+ break;
248
206
 
249
- case IkasThemeJsonComponentPropType.BLOG:
250
- IkasPageDataInit.initBlogPropValue(
251
- prop,
252
- propValue,
253
- pageComponentPropValue
254
- );
255
- break;
207
+ case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
208
+ IkasPageDataInit.initAttributePropValue(
209
+ prop,
210
+ propValue,
211
+ pageComponentPropValue
212
+ );
213
+ break;
256
214
 
257
- case IkasThemeJsonComponentPropType.BLOG_LIST:
258
- IkasPageDataInit.initBlogListPropValue(
259
- prop,
260
- propValue,
261
- pageComponentPropValue
262
- );
263
- break;
215
+ case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
216
+ IkasPageDataInit.initAttributeListPropValue(
217
+ prop,
218
+ propValue,
219
+ pageComponentPropValue
220
+ );
221
+ break;
222
+
223
+ case IkasThemeJsonComponentPropType.LINK:
224
+ case IkasThemeJsonComponentPropType.LIST_OF_LINK:
225
+ IkasPageDataInit.initLinkPropValue(
226
+ prop,
227
+ propValue,
228
+ pageComponentPropValue
229
+ );
230
+ break;
264
231
 
265
- case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
266
- IkasPageDataInit.initBlogCategoryPropValue(
267
- prop,
268
- propValue,
269
- pageComponentPropValue
270
- );
271
- break;
232
+ case IkasThemeJsonComponentPropType.COMPONENT:
233
+ IkasPageDataInit.initComponentPropValue(
234
+ prop,
235
+ propValue,
236
+ pageComponentPropValue,
237
+ settings,
238
+ isBrowser
239
+ );
240
+ break;
272
241
 
273
- case IkasThemeJsonComponentPropType.BLOG_LIST:
274
- IkasPageDataInit.initBlogCategoryListPropValue(
275
- prop,
276
- propValue,
277
- pageComponentPropValue
278
- );
279
- break;
242
+ case IkasThemeJsonComponentPropType.COMPONENT_LIST:
243
+ IkasPageDataInit.initComponentListPropValue(
244
+ prop,
245
+ propValue,
246
+ pageComponentPropValue,
247
+ settings,
248
+ isBrowser
249
+ );
250
+ break;
280
251
 
281
- case IkasThemeJsonComponentPropType.RAFFLE:
282
- IkasPageDataInit.initRafflePropValue(
283
- prop,
284
- propValue,
285
- pageComponentPropValue
286
- );
287
- break;
252
+ case IkasThemeJsonComponentPropType.CUSTOM:
253
+ IkasPageDataInit.initCustomDataPropValue(
254
+ prop,
255
+ propValue,
256
+ pageComponentPropValue,
257
+ settings,
258
+ isBrowser
259
+ );
260
+ break;
288
261
 
289
- case IkasThemeJsonComponentPropType.RAFFLE_LIST:
290
- IkasPageDataInit.initRaffleListPropValue(
291
- prop,
292
- propValue,
293
- pageComponentPropValue
294
- );
295
- break;
262
+ case IkasThemeJsonComponentPropType.BLOG:
263
+ IkasPageDataInit.initBlogPropValue(
264
+ prop,
265
+ propValue,
266
+ pageComponentPropValue
267
+ );
268
+ break;
296
269
 
297
- case IkasThemeJsonComponentPropType.SLIDER:
298
- IkasPageDataInit.initSliderPropValue(
299
- prop,
300
- propValue,
301
- pageComponentPropValue
302
- );
303
- break;
270
+ case IkasThemeJsonComponentPropType.BLOG_LIST:
271
+ IkasPageDataInit.initBlogListPropValue(
272
+ prop,
273
+ propValue,
274
+ pageComponentPropValue
275
+ );
276
+ break;
304
277
 
305
- default:
306
- break;
307
- }
308
- });
309
- });
278
+ case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
279
+ IkasPageDataInit.initBlogCategoryPropValue(
280
+ prop,
281
+ propValue,
282
+ pageComponentPropValue
283
+ );
284
+ break;
310
285
 
311
- return pageComponentPropValues;
286
+ case IkasThemeJsonComponentPropType.BLOG_LIST:
287
+ IkasPageDataInit.initBlogCategoryListPropValue(
288
+ prop,
289
+ propValue,
290
+ pageComponentPropValue
291
+ );
292
+ break;
293
+
294
+ case IkasThemeJsonComponentPropType.RAFFLE:
295
+ IkasPageDataInit.initRafflePropValue(
296
+ prop,
297
+ propValue,
298
+ pageComponentPropValue
299
+ );
300
+ break;
301
+
302
+ case IkasThemeJsonComponentPropType.RAFFLE_LIST:
303
+ IkasPageDataInit.initRaffleListPropValue(
304
+ prop,
305
+ propValue,
306
+ pageComponentPropValue
307
+ );
308
+ break;
309
+
310
+ case IkasThemeJsonComponentPropType.SLIDER:
311
+ IkasPageDataInit.initSliderPropValue(
312
+ prop,
313
+ propValue,
314
+ pageComponentPropValue
315
+ );
316
+ break;
317
+
318
+ default:
319
+ break;
320
+ }
321
+ });
312
322
  }
313
323
 
314
324
  static initBrandPropValue(