@ikas/storefront-providers 4.0.0-alpha.78 → 4.0.0-alpha.8
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 +12 -13
- package/{build/index.d.ts → src/index.ts} +22 -20
- package/src/models/prop-value/attribute-list.ts +8 -0
- package/src/models/prop-value/attribute.ts +8 -0
- package/src/models/prop-value/blog-category-list.ts +9 -0
- package/src/models/prop-value/blog-category.ts +6 -0
- package/src/models/prop-value/blog-list.ts +13 -0
- package/src/models/prop-value/blog.ts +6 -0
- package/src/models/prop-value/brand-list.ts +11 -0
- package/src/models/prop-value/brand.ts +6 -0
- package/src/models/prop-value/category-list.ts +11 -0
- package/src/models/prop-value/category.ts +6 -0
- package/src/models/prop-value/link.ts +22 -0
- package/src/models/prop-value/product-list.ts +29 -0
- package/src/models/prop-value/product.ts +7 -0
- package/src/models/prop-value/raffle-list.ts +6 -0
- package/src/models/prop-value/raffle.ts +6 -0
- package/src/models/ui/blog-category-list/index.ts +19 -0
- package/src/models/ui/blog-category-list/init.ts +54 -0
- package/src/models/ui/blog-list/index.ts +21 -0
- package/src/models/ui/blog-list/init.ts +49 -0
- package/src/models/ui/brand-list/index.ts +25 -0
- package/src/models/ui/brand-list/init.ts +47 -0
- package/src/models/ui/category-list/index.ts +25 -0
- package/src/models/ui/category-list/init.ts +50 -0
- package/src/models/ui/component-renderer/index.ts +5 -0
- package/src/models/ui/customer-review-list/index.ts +12 -0
- package/src/models/ui/customer-review-list/init.ts +33 -0
- package/src/models/ui/customer-review-summary-list/index.ts +12 -0
- package/src/models/ui/customer-review-summary-list/init.ts +33 -0
- package/{build/models/ui/index.d.ts → src/models/ui/index.ts} +12 -12
- package/src/models/ui/navigation-link/index.ts +7 -0
- package/src/models/ui/product-attribute-detail/index.ts +7 -0
- package/src/models/ui/product-attribute-list/index.ts +7 -0
- package/src/models/ui/product-list/index.ts +80 -0
- package/src/models/ui/product-list/init.ts +407 -0
- package/src/models/ui/raffle-list/index.ts +17 -0
- package/src/models/ui/raffle-list/init.ts +44 -0
- package/src/providers/helpers/raffle.ts +69 -0
- package/src/providers/page-data-get.ts +708 -0
- package/src/providers/placeholders.ts +138 -0
- package/src/providers/prop-value/attribute-list.ts +75 -0
- package/src/providers/prop-value/attribute.ts +77 -0
- package/src/providers/prop-value/blog-category-list.ts +29 -0
- package/src/providers/prop-value/blog-category.ts +49 -0
- package/src/providers/prop-value/blog-list.ts +61 -0
- package/src/providers/prop-value/blog.ts +41 -0
- package/src/providers/prop-value/boolean.ts +14 -0
- package/src/providers/prop-value/brand-list.ts +30 -0
- package/src/providers/prop-value/brand.ts +46 -0
- package/src/providers/prop-value/category-list.ts +31 -0
- package/src/providers/prop-value/category.ts +45 -0
- package/src/providers/prop-value/color.ts +14 -0
- package/src/providers/prop-value/custom.ts +560 -0
- package/src/providers/prop-value/image-list.ts +16 -0
- package/src/providers/prop-value/image.ts +16 -0
- package/{build/providers/prop-value/index.d.ts → src/providers/prop-value/index.ts} +3 -3
- package/src/providers/prop-value/link.ts +259 -0
- package/src/providers/prop-value/product-detail.ts +92 -0
- package/src/providers/prop-value/product-list.ts +124 -0
- package/src/providers/prop-value/raffle-list.ts +20 -0
- package/src/providers/prop-value/raffle.ts +41 -0
- package/src/providers/prop-value/rich-text.ts +14 -0
- package/src/providers/prop-value/slider.ts +19 -0
- package/src/providers/prop-value/text.ts +14 -0
- package/src/providers/types.ts +88 -0
- package/build/ext/tslib/tslib.es6.js +0 -1
- package/build/index.js +0 -1
- package/build/models/prop-value/attribute-list.d.ts +0 -6
- package/build/models/prop-value/attribute.d.ts +0 -6
- package/build/models/prop-value/blog-category-list.d.ts +0 -6
- package/build/models/prop-value/blog-category.d.ts +0 -4
- package/build/models/prop-value/blog-list.d.ts +0 -8
- package/build/models/prop-value/blog.d.ts +0 -4
- package/build/models/prop-value/brand-list.d.ts +0 -8
- package/build/models/prop-value/brand.d.ts +0 -4
- package/build/models/prop-value/brand.js +0 -1
- package/build/models/prop-value/category-list.d.ts +0 -8
- package/build/models/prop-value/category.d.ts +0 -4
- package/build/models/prop-value/link.d.ts +0 -18
- package/build/models/prop-value/link.js +0 -1
- package/build/models/prop-value/product-list.d.ts +0 -17
- package/build/models/prop-value/product.d.ts +0 -5
- package/build/models/prop-value/raffle-list.d.ts +0 -4
- package/build/models/prop-value/raffle.d.ts +0 -4
- package/build/models/ui/blog-category-list/index.d.ts +0 -17
- package/build/models/ui/blog-category-list/index.js +0 -1
- package/build/models/ui/blog-category-list/init.d.ts +0 -2
- package/build/models/ui/blog-category-list/init.js +0 -1
- package/build/models/ui/blog-list/index.d.ts +0 -19
- package/build/models/ui/blog-list/index.js +0 -1
- package/build/models/ui/blog-list/init.d.ts +0 -2
- package/build/models/ui/blog-list/init.js +0 -1
- package/build/models/ui/brand-list/index.d.ts +0 -22
- package/build/models/ui/brand-list/index.js +0 -1
- package/build/models/ui/brand-list/init.d.ts +0 -2
- package/build/models/ui/brand-list/init.js +0 -1
- package/build/models/ui/category-list/index.d.ts +0 -22
- package/build/models/ui/category-list/index.js +0 -1
- package/build/models/ui/category-list/init.d.ts +0 -2
- package/build/models/ui/category-list/init.js +0 -1
- package/build/models/ui/component-renderer/index.d.ts +0 -6
- package/build/models/ui/customer-review-list/index.d.ts +0 -11
- package/build/models/ui/customer-review-list/init.d.ts +0 -2
- package/build/models/ui/customer-review-summary-list/index.d.ts +0 -11
- package/build/models/ui/customer-review-summary-list/init.d.ts +0 -2
- package/build/models/ui/navigation-link/index.d.ts +0 -7
- package/build/models/ui/product-attribute-detail/index.d.ts +0 -6
- package/build/models/ui/product-attribute-list/index.d.ts +0 -6
- package/build/models/ui/product-list/index.d.ts +0 -64
- package/build/models/ui/product-list/index.js +0 -1
- package/build/models/ui/product-list/init.d.ts +0 -2
- package/build/models/ui/product-list/init.js +0 -1
- package/build/models/ui/raffle-list/index.d.ts +0 -16
- package/build/models/ui/raffle-list/init.d.ts +0 -2
- package/build/models/ui/raffle-list/init.js +0 -1
- package/build/providers/helpers/raffle.d.ts +0 -3
- package/build/providers/helpers/raffle.js +0 -1
- package/build/providers/page-data-get.d.ts +0 -31
- package/build/providers/page-data-get.js +0 -1
- package/build/providers/placeholders.d.ts +0 -7
- package/build/providers/placeholders.js +0 -1
- package/build/providers/prop-value/attribute-list.d.ts +0 -8
- package/build/providers/prop-value/attribute-list.js +0 -1
- package/build/providers/prop-value/attribute.d.ts +0 -8
- package/build/providers/prop-value/attribute.js +0 -1
- package/build/providers/prop-value/blog-category-list.d.ts +0 -8
- package/build/providers/prop-value/blog-category-list.js +0 -1
- package/build/providers/prop-value/blog-category.d.ts +0 -8
- package/build/providers/prop-value/blog-category.js +0 -1
- package/build/providers/prop-value/blog-list.d.ts +0 -11
- package/build/providers/prop-value/blog-list.js +0 -1
- package/build/providers/prop-value/blog.d.ts +0 -8
- package/build/providers/prop-value/blog.js +0 -1
- package/build/providers/prop-value/boolean.d.ts +0 -6
- package/build/providers/prop-value/boolean.js +0 -1
- package/build/providers/prop-value/brand-list.d.ts +0 -8
- package/build/providers/prop-value/brand-list.js +0 -1
- package/build/providers/prop-value/brand.d.ts +0 -8
- package/build/providers/prop-value/brand.js +0 -1
- package/build/providers/prop-value/category-list.d.ts +0 -8
- package/build/providers/prop-value/category-list.js +0 -1
- package/build/providers/prop-value/category.d.ts +0 -8
- package/build/providers/prop-value/category.js +0 -1
- package/build/providers/prop-value/color.d.ts +0 -6
- package/build/providers/prop-value/color.js +0 -1
- package/build/providers/prop-value/custom.d.ts +0 -42
- package/build/providers/prop-value/custom.js +0 -1
- package/build/providers/prop-value/image-list.d.ts +0 -7
- package/build/providers/prop-value/image-list.js +0 -1
- package/build/providers/prop-value/image.d.ts +0 -7
- package/build/providers/prop-value/image.js +0 -1
- package/build/providers/prop-value/link.d.ts +0 -26
- package/build/providers/prop-value/link.js +0 -1
- package/build/providers/prop-value/product-detail.d.ts +0 -8
- package/build/providers/prop-value/product-detail.js +0 -1
- package/build/providers/prop-value/product-list.d.ts +0 -17
- package/build/providers/prop-value/product-list.js +0 -1
- package/build/providers/prop-value/raffle-list.d.ts +0 -5
- package/build/providers/prop-value/raffle-list.js +0 -1
- package/build/providers/prop-value/raffle.d.ts +0 -8
- package/build/providers/prop-value/raffle.js +0 -1
- package/build/providers/prop-value/rich-text.d.ts +0 -6
- package/build/providers/prop-value/rich-text.js +0 -1
- package/build/providers/prop-value/slider.d.ts +0 -7
- package/build/providers/prop-value/slider.js +0 -1
- package/build/providers/prop-value/text.d.ts +0 -6
- package/build/providers/prop-value/text.js +0 -1
- package/build/providers/types.d.ts +0 -66
- package/build/providers/types.js +0 -1
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import _cloneDeep from "lodash/cloneDeep";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
import { IkasBrandListPropValueProvider } from "./brand-list";
|
|
4
|
+
import { IkasBrandPropValueProvider } from "./brand";
|
|
5
|
+
import { IkasCategoryListPropValueProvider } from "./category-list";
|
|
6
|
+
import { IkasCategoryPropValueProvider } from "./category";
|
|
7
|
+
import { IkasColorPropValueProvider } from "./color";
|
|
8
|
+
import { IkasBooleanPropValueProvider } from "./boolean";
|
|
9
|
+
import { IkasTextPropValueProvider } from "./text";
|
|
10
|
+
import { IkasImageListPropValueProvider } from "./image-list";
|
|
11
|
+
import { IkasImagePropValueProvider } from "./image";
|
|
12
|
+
import { IkasLinkPropValueProvider } from "./link";
|
|
13
|
+
import { IkasProductPropValueProvider } from "./product-detail";
|
|
14
|
+
import { IkasProductListPropValueProvider } from "./product-list";
|
|
15
|
+
import { IkasPageDataProvider } from "../page-data-get";
|
|
16
|
+
import { IkasRichTextPropValueProvider } from "./rich-text";
|
|
17
|
+
import { IkasBlogPropValueProvider } from "./blog";
|
|
18
|
+
import { IkasBlogListPropValueProvider } from "./blog-list";
|
|
19
|
+
import { IkasAttributePropValueProvider } from "./attribute";
|
|
20
|
+
import { IkasAttributeListPropValueProvider } from "./attribute-list";
|
|
21
|
+
import { IkasBlogCategoryPropValueProvider } from "./blog-category";
|
|
22
|
+
import { IkasBlogCategoryListPropValueProvider } from "./blog-category-list";
|
|
23
|
+
import { IkasRaffleListPropValueProvider } from "./raffle-list";
|
|
24
|
+
import { IkasRafflePropValueProvider } from "./raffle";
|
|
25
|
+
import { IkasSliderPropValueProvider } from "./slider";
|
|
26
|
+
import {
|
|
27
|
+
IkasThemeJson,
|
|
28
|
+
IkasThemeJsonComponentPropType,
|
|
29
|
+
IkasThemeJsonCustomData,
|
|
30
|
+
IkasThemeJsonPageComponent,
|
|
31
|
+
IkasThemeJsonPageType,
|
|
32
|
+
} from "@ikas/storefront-models";
|
|
33
|
+
import { IkasCustomDataPropValueData } from "../types";
|
|
34
|
+
|
|
35
|
+
export class IkasCustomPropValueProvider
|
|
36
|
+
implements IkasPropValueProvider<IkasCustomDataPropValueData | undefined>
|
|
37
|
+
{
|
|
38
|
+
private value: any;
|
|
39
|
+
private customData: IkasThemeJsonCustomData;
|
|
40
|
+
private theme: IkasThemeJson;
|
|
41
|
+
private pageType: IkasThemeJsonPageType;
|
|
42
|
+
private pageSpecificData?: any;
|
|
43
|
+
private pageParams?: Record<string, any>;
|
|
44
|
+
private pageDataProvider: IkasPageDataProvider;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
value: any,
|
|
48
|
+
customData: IkasThemeJsonCustomData,
|
|
49
|
+
theme: IkasThemeJson,
|
|
50
|
+
pageType: IkasThemeJsonPageType,
|
|
51
|
+
pageDataProvider: IkasPageDataProvider,
|
|
52
|
+
pageSpecificData?: any,
|
|
53
|
+
pageParams?: Record<string, any>
|
|
54
|
+
) {
|
|
55
|
+
this.value = value;
|
|
56
|
+
this.customData = customData;
|
|
57
|
+
this.theme = theme;
|
|
58
|
+
this.pageType = pageType;
|
|
59
|
+
this.pageDataProvider = pageDataProvider;
|
|
60
|
+
this.pageSpecificData = pageSpecificData;
|
|
61
|
+
this.pageParams = pageParams;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async getValue(): Promise<IkasCustomDataPropValueData | undefined> {
|
|
65
|
+
if (
|
|
66
|
+
(this.value === undefined || this.value === null) &&
|
|
67
|
+
this.customData.type !== IkasThemeJsonComponentPropType.RAFFLE_LIST
|
|
68
|
+
)
|
|
69
|
+
return { value: null, customData: this.customData };
|
|
70
|
+
|
|
71
|
+
let customDataValue: IkasCustomDataPropValueData | undefined;
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
switch (this.customData.type) {
|
|
75
|
+
case IkasThemeJsonComponentPropType.TEXT:
|
|
76
|
+
customDataValue = await this.getTextValue();
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case IkasThemeJsonComponentPropType.RICH_TEXT:
|
|
80
|
+
customDataValue = await this.getRichTextPropValue();
|
|
81
|
+
break;
|
|
82
|
+
|
|
83
|
+
case IkasThemeJsonComponentPropType.BOOLEAN:
|
|
84
|
+
customDataValue = await this.getBooleanValue();
|
|
85
|
+
break;
|
|
86
|
+
|
|
87
|
+
case IkasThemeJsonComponentPropType.BRAND_LIST:
|
|
88
|
+
customDataValue = await this.getBrandListPropValue();
|
|
89
|
+
break;
|
|
90
|
+
|
|
91
|
+
case IkasThemeJsonComponentPropType.BRAND:
|
|
92
|
+
customDataValue = await this.getBrandPropValue();
|
|
93
|
+
break;
|
|
94
|
+
|
|
95
|
+
case IkasThemeJsonComponentPropType.CATEGORY_LIST:
|
|
96
|
+
customDataValue = await this.getCategoryListPropValue();
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case IkasThemeJsonComponentPropType.CATEGORY:
|
|
100
|
+
customDataValue = await this.getCategoryPropValue();
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case IkasThemeJsonComponentPropType.COLOR:
|
|
104
|
+
customDataValue = await this.getColorPropValue();
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case IkasThemeJsonComponentPropType.IMAGE_LIST:
|
|
108
|
+
customDataValue = await this.getImageListPropValue();
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case IkasThemeJsonComponentPropType.IMAGE:
|
|
112
|
+
customDataValue = await this.getImagePropValue();
|
|
113
|
+
break;
|
|
114
|
+
|
|
115
|
+
case IkasThemeJsonComponentPropType.LINK:
|
|
116
|
+
case IkasThemeJsonComponentPropType.LIST_OF_LINK:
|
|
117
|
+
customDataValue = await this.getLinkPropValue();
|
|
118
|
+
break;
|
|
119
|
+
|
|
120
|
+
case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
|
|
121
|
+
customDataValue = await this.getProductDetailPropValue();
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
case IkasThemeJsonComponentPropType.PRODUCT_LIST:
|
|
125
|
+
customDataValue = await this.getProductListPropValue();
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
|
|
129
|
+
customDataValue = await this.getProductAttributePropValue();
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
|
|
133
|
+
customDataValue = await this.getProductAttributeListPropValue();
|
|
134
|
+
break;
|
|
135
|
+
|
|
136
|
+
case IkasThemeJsonComponentPropType.OBJECT:
|
|
137
|
+
customDataValue = await this.getObjectValue();
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case IkasThemeJsonComponentPropType.DYNAMIC_LIST:
|
|
141
|
+
case IkasThemeJsonComponentPropType.STATIC_LIST:
|
|
142
|
+
customDataValue = await this.getArrayValue();
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case IkasThemeJsonComponentPropType.ENUM:
|
|
146
|
+
customDataValue = await this.getEnumValue();
|
|
147
|
+
break;
|
|
148
|
+
|
|
149
|
+
case IkasThemeJsonComponentPropType.CUSTOM:
|
|
150
|
+
customDataValue = await this.getCustomDataValue();
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case IkasThemeJsonComponentPropType.COMPONENT:
|
|
154
|
+
case IkasThemeJsonComponentPropType.COMPONENT_LIST:
|
|
155
|
+
customDataValue = await this.getComponentListValue();
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case IkasThemeJsonComponentPropType.BLOG:
|
|
159
|
+
customDataValue = await this.getBlogValue();
|
|
160
|
+
break;
|
|
161
|
+
|
|
162
|
+
case IkasThemeJsonComponentPropType.BLOG_LIST:
|
|
163
|
+
customDataValue = await this.getBlogListValue();
|
|
164
|
+
break;
|
|
165
|
+
|
|
166
|
+
case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
|
|
167
|
+
customDataValue = await this.getBlogCategoryValue();
|
|
168
|
+
break;
|
|
169
|
+
|
|
170
|
+
case IkasThemeJsonComponentPropType.BLOG_CATEGORY_LIST:
|
|
171
|
+
customDataValue = await this.getBlogCategoryListValue();
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case IkasThemeJsonComponentPropType.RAFFLE:
|
|
175
|
+
customDataValue = await this.getRaffleValue();
|
|
176
|
+
break;
|
|
177
|
+
|
|
178
|
+
case IkasThemeJsonComponentPropType.RAFFLE_LIST:
|
|
179
|
+
customDataValue = await this.getRaffleListValue();
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case IkasThemeJsonComponentPropType.SLIDER:
|
|
183
|
+
customDataValue = await this.getSliderValue();
|
|
184
|
+
break;
|
|
185
|
+
|
|
186
|
+
default:
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
} catch (err) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (
|
|
194
|
+
this.customData.isRequired &&
|
|
195
|
+
(customDataValue?.value === undefined || customDataValue?.value === null)
|
|
196
|
+
)
|
|
197
|
+
return;
|
|
198
|
+
|
|
199
|
+
return customDataValue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private async getBooleanValue() {
|
|
203
|
+
const provider = new IkasBooleanPropValueProvider(this.value);
|
|
204
|
+
const value = await provider.getValue();
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
value,
|
|
208
|
+
customData: this.customData,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private async getBrandListPropValue() {
|
|
213
|
+
const provider = new IkasBrandListPropValueProvider(this.value);
|
|
214
|
+
const value = await provider.getValue();
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
value,
|
|
218
|
+
customData: this.customData,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private async getBrandPropValue() {
|
|
223
|
+
const provider = new IkasBrandPropValueProvider(this.value);
|
|
224
|
+
const value = await provider.getValue();
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
value,
|
|
228
|
+
customData: this.customData,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private async getCategoryListPropValue() {
|
|
233
|
+
const provider = new IkasCategoryListPropValueProvider(this.value);
|
|
234
|
+
const value = await provider.getValue();
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
value,
|
|
238
|
+
customData: this.customData,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private async getCategoryPropValue() {
|
|
243
|
+
const provider = new IkasCategoryPropValueProvider(this.value);
|
|
244
|
+
const value = await provider.getValue();
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
value,
|
|
248
|
+
customData: this.customData,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private async getColorPropValue() {
|
|
253
|
+
const provider = new IkasColorPropValueProvider(this.value);
|
|
254
|
+
const value = await provider.getValue();
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
value,
|
|
258
|
+
customData: this.customData,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private async getRichTextPropValue() {
|
|
263
|
+
const provider = new IkasRichTextPropValueProvider(this.value);
|
|
264
|
+
const value = await provider.getValue();
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
value,
|
|
268
|
+
customData: this.customData,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private async getImageListPropValue() {
|
|
273
|
+
const provider = new IkasImageListPropValueProvider(this.value);
|
|
274
|
+
const value = await provider.getValue();
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
value,
|
|
278
|
+
customData: this.customData,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private async getImagePropValue() {
|
|
283
|
+
const provider = new IkasImagePropValueProvider(this.value);
|
|
284
|
+
const value = await provider.getValue();
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
value,
|
|
288
|
+
customData: this.customData,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private async getLinkPropValue() {
|
|
293
|
+
const provider = new IkasLinkPropValueProvider(
|
|
294
|
+
this.value,
|
|
295
|
+
this.theme,
|
|
296
|
+
this.pageDataProvider.linkMetaDataTargetIds
|
|
297
|
+
);
|
|
298
|
+
const value = await provider.getValue();
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
value,
|
|
302
|
+
customData: this.customData,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private async getProductDetailPropValue() {
|
|
307
|
+
const provider = new IkasProductPropValueProvider(this.value);
|
|
308
|
+
const value = await provider.getValue();
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
value,
|
|
312
|
+
customData: this.customData,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private async getProductListPropValue() {
|
|
317
|
+
const provider = new IkasProductListPropValueProvider(
|
|
318
|
+
this.pageType,
|
|
319
|
+
this.value,
|
|
320
|
+
this.pageSpecificData
|
|
321
|
+
);
|
|
322
|
+
const value = await provider.getValue();
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
value,
|
|
326
|
+
customData: this.customData,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private async getProductAttributePropValue() {
|
|
331
|
+
const provider = new IkasAttributePropValueProvider(this.value);
|
|
332
|
+
const value = await provider.getValue();
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
value,
|
|
336
|
+
customData: this.customData,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private async getProductAttributeListPropValue() {
|
|
341
|
+
const provider = new IkasAttributeListPropValueProvider(this.value);
|
|
342
|
+
const value = await provider.getValue();
|
|
343
|
+
|
|
344
|
+
return {
|
|
345
|
+
value,
|
|
346
|
+
customData: this.customData,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
private async getTextValue() {
|
|
351
|
+
const provider = new IkasTextPropValueProvider(this.value);
|
|
352
|
+
const value = await provider.getValue();
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
value,
|
|
356
|
+
customData: this.customData,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private async getObjectValue() {
|
|
361
|
+
const objectValue: Record<string, any> = {};
|
|
362
|
+
|
|
363
|
+
for (const nestedData of this.customData.nestedData || []) {
|
|
364
|
+
if (!nestedData.key) continue;
|
|
365
|
+
const nestedValue = this.value[nestedData.key];
|
|
366
|
+
|
|
367
|
+
if (
|
|
368
|
+
nestedData.isRequired &&
|
|
369
|
+
nestedData.type !== IkasThemeJsonComponentPropType.RAFFLE_LIST &&
|
|
370
|
+
(nestedValue === undefined || nestedValue === null)
|
|
371
|
+
)
|
|
372
|
+
throw new Error("Required data is missing");
|
|
373
|
+
|
|
374
|
+
const nestedProvider = new IkasCustomPropValueProvider(
|
|
375
|
+
nestedValue,
|
|
376
|
+
nestedData,
|
|
377
|
+
this.theme,
|
|
378
|
+
this.pageType,
|
|
379
|
+
this.pageDataProvider,
|
|
380
|
+
this.pageSpecificData
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const _itemValue = await nestedProvider.getValue();
|
|
384
|
+
|
|
385
|
+
if (
|
|
386
|
+
nestedData.isRequired &&
|
|
387
|
+
(_itemValue === null || _itemValue === undefined)
|
|
388
|
+
)
|
|
389
|
+
throw new Error("Required data is missing");
|
|
390
|
+
|
|
391
|
+
objectValue[nestedData.key] = _itemValue;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return {
|
|
395
|
+
value: objectValue,
|
|
396
|
+
customData: this.customData,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private async getArrayValue() {
|
|
401
|
+
if (!this.value || !Array.isArray(this.value))
|
|
402
|
+
throw new Error("Incorrect data!");
|
|
403
|
+
|
|
404
|
+
const value: any[] = [];
|
|
405
|
+
const nestedData = this.customData.nestedData![0];
|
|
406
|
+
|
|
407
|
+
for (const itemValue of this.value) {
|
|
408
|
+
if (
|
|
409
|
+
nestedData.isRequired &&
|
|
410
|
+
nestedData.type !== IkasThemeJsonComponentPropType.RAFFLE_LIST &&
|
|
411
|
+
(itemValue === undefined || itemValue === null)
|
|
412
|
+
)
|
|
413
|
+
throw new Error("Required data is missing");
|
|
414
|
+
|
|
415
|
+
const provider = new IkasCustomPropValueProvider(
|
|
416
|
+
itemValue,
|
|
417
|
+
nestedData,
|
|
418
|
+
this.theme,
|
|
419
|
+
this.pageType,
|
|
420
|
+
this.pageDataProvider,
|
|
421
|
+
this.pageSpecificData
|
|
422
|
+
);
|
|
423
|
+
const _itemValue = await provider.getValue();
|
|
424
|
+
|
|
425
|
+
if (
|
|
426
|
+
nestedData.isRequired &&
|
|
427
|
+
(_itemValue === null || _itemValue === undefined)
|
|
428
|
+
) {
|
|
429
|
+
throw new Error("Required data is missing");
|
|
430
|
+
} else value.push(_itemValue);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return {
|
|
434
|
+
value,
|
|
435
|
+
customData: this.customData,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private async getEnumValue() {
|
|
440
|
+
return {
|
|
441
|
+
value: this.value,
|
|
442
|
+
customData: this.customData,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
private async getCustomDataValue() {
|
|
447
|
+
let selectedCustomData = this.theme.customData.find(
|
|
448
|
+
(c) => c.id === this.customData.customDataId
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
if (!selectedCustomData)
|
|
452
|
+
return {
|
|
453
|
+
value: null,
|
|
454
|
+
customData: this.customData,
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
selectedCustomData = _cloneDeep(selectedCustomData);
|
|
458
|
+
selectedCustomData.isRequired = this.customData.isRequired;
|
|
459
|
+
|
|
460
|
+
const nestedProvider = new IkasCustomPropValueProvider(
|
|
461
|
+
this.value,
|
|
462
|
+
selectedCustomData,
|
|
463
|
+
this.theme,
|
|
464
|
+
this.pageType,
|
|
465
|
+
this.pageDataProvider,
|
|
466
|
+
this.pageSpecificData
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
return await nestedProvider.getValue();
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
private async getComponentListValue() {
|
|
473
|
+
const pageComponents: IkasThemeJsonPageComponent[] = this.value
|
|
474
|
+
? this.value.map((v: IkasThemeJsonPageComponent) => ({ ...v }))
|
|
475
|
+
: [];
|
|
476
|
+
|
|
477
|
+
return {
|
|
478
|
+
value: await Promise.all(
|
|
479
|
+
pageComponents.map((tp) =>
|
|
480
|
+
this.pageDataProvider.getPageComponentPropValues(tp)
|
|
481
|
+
)
|
|
482
|
+
),
|
|
483
|
+
customData: this.customData,
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
private async getBlogValue() {
|
|
488
|
+
const provider = new IkasBlogPropValueProvider(this.value);
|
|
489
|
+
const value = await provider.getValue();
|
|
490
|
+
|
|
491
|
+
return {
|
|
492
|
+
value,
|
|
493
|
+
customData: this.customData,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
private async getBlogListValue() {
|
|
498
|
+
const provider = new IkasBlogListPropValueProvider(
|
|
499
|
+
this.pageType,
|
|
500
|
+
this.value,
|
|
501
|
+
this.pageSpecificData
|
|
502
|
+
);
|
|
503
|
+
const value = await provider.getValue();
|
|
504
|
+
|
|
505
|
+
return {
|
|
506
|
+
value,
|
|
507
|
+
customData: this.customData,
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
private async getBlogCategoryValue() {
|
|
512
|
+
const provider = new IkasBlogCategoryPropValueProvider(this.value);
|
|
513
|
+
const value = await provider.getValue();
|
|
514
|
+
|
|
515
|
+
return {
|
|
516
|
+
value,
|
|
517
|
+
customData: this.customData,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
private async getBlogCategoryListValue() {
|
|
522
|
+
const provider = new IkasBlogCategoryListPropValueProvider(this.value);
|
|
523
|
+
const value = await provider.getValue();
|
|
524
|
+
|
|
525
|
+
return {
|
|
526
|
+
value,
|
|
527
|
+
customData: this.customData,
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
private async getRaffleValue() {
|
|
532
|
+
const provider = new IkasRafflePropValueProvider(this.value);
|
|
533
|
+
const value = await provider.getValue();
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
value,
|
|
537
|
+
customData: this.customData,
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
private async getRaffleListValue() {
|
|
542
|
+
const provider = new IkasRaffleListPropValueProvider();
|
|
543
|
+
const value = await provider.getValue();
|
|
544
|
+
|
|
545
|
+
return {
|
|
546
|
+
value,
|
|
547
|
+
customData: this.customData,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
private async getSliderValue() {
|
|
552
|
+
const provider = new IkasSliderPropValueProvider(this.value);
|
|
553
|
+
const value = await provider.getValue();
|
|
554
|
+
|
|
555
|
+
return {
|
|
556
|
+
value,
|
|
557
|
+
customData: this.customData,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IkasImage } from "@ikas/storefront-models";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
|
|
4
|
+
export class IkasImageListPropValueProvider
|
|
5
|
+
implements IkasPropValueProvider<IkasImage[]>
|
|
6
|
+
{
|
|
7
|
+
private imageListPropValue: string[];
|
|
8
|
+
|
|
9
|
+
constructor(imageListPropValue: string[]) {
|
|
10
|
+
this.imageListPropValue = imageListPropValue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getValue(): Promise<IkasImage[]> {
|
|
14
|
+
return this.imageListPropValue.map((i) => ({ id: i, isVideo: false }));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IkasImage } from "@ikas/storefront-models";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
|
|
4
|
+
export class IkasImagePropValueProvider
|
|
5
|
+
implements IkasPropValueProvider<IkasImage>
|
|
6
|
+
{
|
|
7
|
+
private imagePropValue: string;
|
|
8
|
+
|
|
9
|
+
constructor(imagePropValue: string) {
|
|
10
|
+
this.imagePropValue = imagePropValue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getValue(): Promise<IkasImage> {
|
|
14
|
+
return { id: this.imagePropValue, isVideo: false };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default interface IkasPropValueProvider<T> {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export default interface IkasPropValueProvider<T> {
|
|
2
|
+
getValue: () => Promise<T>;
|
|
3
|
+
}
|