@crystaldesign/product-detail-page 24.10.0-alpha.6
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/build/esm/index.js +1542 -0
- package/build/types/product-detail-page/src/components/UiElement/index.d.ts +11 -0
- package/build/types/product-detail-page/src/components/UiElement/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/index.d.ts +10 -0
- package/build/types/product-detail-page/src/components/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/ArActionIcon/index.d.ts +10 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/ArActionIcon/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/ArItem/index.d.ts +15 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/ArItem/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/SirvItem/index.d.ts +9 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/SirvItem/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/index.d.ts +12 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/MediaItem/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/PageNumber/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/PageNumber/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/Thumb/index.d.ts +8 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/Thumb/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/index.d.ts +9 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/useGallery.d.ts +12 -0
- package/build/types/product-detail-page/src/components/mainComponents/Gallery/useGallery.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/TabsInfo/Tab/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/TabsInfo/Tab/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/TabsInfo/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/TabsInfo/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/Info/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Price/index.d.ts +9 -0
- package/build/types/product-detail-page/src/components/mainComponents/Price/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Text/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/Text/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/Group/index.d.ts +21 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/Group/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/index.d.ts +11 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/useVariants.d.ts +20 -0
- package/build/types/product-detail-page/src/components/mainComponents/Variants/useVariants.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/ActionGroup/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/ActionGroup/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/ActionIcon/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/ActionIcon/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/PdpAction/index.d.ts +7 -0
- package/build/types/product-detail-page/src/components/mainComponents/actions/PdpAction/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/index.d.ts +12 -0
- package/build/types/product-detail-page/src/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/stories/boho/boho.stories.d.ts +8 -0
- package/build/types/product-detail-page/src/stories/boho/boho.stories.d.ts.map +1 -0
- package/build/types/product-detail-page/src/stories/boho/testdata/product-RORO.d.ts +3 -0
- package/build/types/product-detail-page/src/stories/boho/testdata/product-RORO.d.ts.map +1 -0
- package/build/types/product-detail-page/src/types/index.d.ts +114 -0
- package/build/types/product-detail-page/src/types/index.d.ts.map +1 -0
- package/build/types/product-detail-page/src/useDetailPage.d.ts +14 -0
- package/build/types/product-detail-page/src/useDetailPage.d.ts.map +1 -0
- package/build/types/product-detail-page/src/utils/filterContent.d.ts +10 -0
- package/build/types/product-detail-page/src/utils/filterContent.d.ts.map +1 -0
- package/build/types/product-detail-page/src/utils/replaceActions.d.ts +19 -0
- package/build/types/product-detail-page/src/utils/replaceActions.d.ts.map +1 -0
- package/build/types/product-detail-page/src/utils/replaceTemplateStrings.d.ts +20 -0
- package/build/types/product-detail-page/src/utils/replaceTemplateStrings.d.ts.map +1 -0
- package/build/types/product-detail-page/src/utils/resolveReferences.d.ts +8 -0
- package/build/types/product-detail-page/src/utils/resolveReferences.d.ts.map +1 -0
- package/build/types/product-detail-page/src/utils/updateCssInDom.d.ts +8 -0
- package/build/types/product-detail-page/src/utils/updateCssInDom.d.ts.map +1 -0
- package/build/umd/549.product-detail-page.umd.min.js +408 -0
- package/build/umd/549.product-detail-page.umd.min.js.LICENSE.txt +101 -0
- package/build/umd/product-detail-page.umd.min.js +2 -0
- package/build/umd/product-detail-page.umd.min.js.LICENSE.txt +40 -0
- package/build/umd/report.html +38 -0
- package/package.json +47 -0
|
@@ -0,0 +1,1542 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import React, { useState, useEffect, forwardRef, useRef, useCallback } from 'react';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import { Navigation, Thumbs } from 'swiper/modules';
|
|
5
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
6
|
+
import { useLayer, Arrow } from 'react-laag';
|
|
7
|
+
import QRCode from 'react-qr-code';
|
|
8
|
+
import { useDivaCore, useTranslation, DivaUtils, getLogger, DivaError } from '@crystaldesign/diva-core';
|
|
9
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
10
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
13
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
14
|
+
import { cloneDeep } from 'lodash';
|
|
15
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
16
|
+
import flatten$1, { flatten } from 'flat';
|
|
17
|
+
|
|
18
|
+
(function() {
|
|
19
|
+
const env = {"STAGE":"production"};
|
|
20
|
+
try {
|
|
21
|
+
if (process) {
|
|
22
|
+
process.env = Object.assign({}, process.env);
|
|
23
|
+
Object.assign(process.env, env);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
27
|
+
globalThis.process = { env:env };
|
|
28
|
+
})();
|
|
29
|
+
|
|
30
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
34
|
+
var ArActionIcon = function ArActionIcon(_ref) {
|
|
35
|
+
var _config$className;
|
|
36
|
+
|
|
37
|
+
var config = _ref.config,
|
|
38
|
+
url = _ref.url,
|
|
39
|
+
htmlArElement = _ref.htmlArElement;
|
|
40
|
+
|
|
41
|
+
var _useDivaCore = useDivaCore(),
|
|
42
|
+
isMobile = _useDivaCore.state.dimensions.isMobile;
|
|
43
|
+
|
|
44
|
+
var _useState = useState(false),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
isOpen = _useState2[0],
|
|
47
|
+
setOpen = _useState2[1];
|
|
48
|
+
|
|
49
|
+
var _useLayer = useLayer({
|
|
50
|
+
isOpen: isOpen && !isMobile,
|
|
51
|
+
auto: true,
|
|
52
|
+
onOutsideClick: function onOutsideClick() {
|
|
53
|
+
return setOpen(false);
|
|
54
|
+
},
|
|
55
|
+
placement: 'top-start',
|
|
56
|
+
triggerOffset: 10
|
|
57
|
+
}),
|
|
58
|
+
arrowProps = _useLayer.arrowProps,
|
|
59
|
+
layerProps = _useLayer.layerProps,
|
|
60
|
+
renderLayer = _useLayer.renderLayer,
|
|
61
|
+
triggerProps = _useLayer.triggerProps;
|
|
62
|
+
_useLayer.layerSide;
|
|
63
|
+
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
if (isOpen && isMobile) {
|
|
66
|
+
htmlArElement.activateAR();
|
|
67
|
+
}
|
|
68
|
+
}, [isOpen]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
var _htmlArElement$shadow;
|
|
71
|
+
|
|
72
|
+
var element = (_htmlArElement$shadow = htmlArElement.shadowRoot) === null || _htmlArElement$shadow === void 0 ? void 0 : _htmlArElement$shadow.getElementById('default-ar-button');
|
|
73
|
+
if (element !== null && element !== void 0 && element.style) element.style.display = 'none';
|
|
74
|
+
}, []);
|
|
75
|
+
if (!url) return /*#__PURE__*/jsx(Fragment, {});
|
|
76
|
+
return /*#__PURE__*/jsx("div", _objectSpread$7(_objectSpread$7({}, triggerProps), {}, {
|
|
77
|
+
onClick: function onClick() {
|
|
78
|
+
return setOpen(!isOpen);
|
|
79
|
+
},
|
|
80
|
+
className: 'diva-pdp-ar-action-icon ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
81
|
+
children: isOpen && !isMobile && renderLayer( /*#__PURE__*/jsxs("div", _objectSpread$7(_objectSpread$7({}, layerProps), {}, {
|
|
82
|
+
className: "ar-tooltip",
|
|
83
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
84
|
+
className: "ar-tooltip-container",
|
|
85
|
+
onClick: function onClick(e) {
|
|
86
|
+
return e.stopPropagation();
|
|
87
|
+
},
|
|
88
|
+
children: [/*#__PURE__*/jsx(QRCode, {
|
|
89
|
+
value: url,
|
|
90
|
+
className: "qr-code",
|
|
91
|
+
onClick: function onClick() {
|
|
92
|
+
return window.open(url, '_blank');
|
|
93
|
+
}
|
|
94
|
+
}), /*#__PURE__*/jsx("div", {
|
|
95
|
+
className: "text",
|
|
96
|
+
children: !!config.text && config.text
|
|
97
|
+
}), /*#__PURE__*/jsx("div", {
|
|
98
|
+
className: "close",
|
|
99
|
+
onClick: function onClick() {
|
|
100
|
+
return setOpen(false);
|
|
101
|
+
}
|
|
102
|
+
})]
|
|
103
|
+
}), /*#__PURE__*/jsx(Arrow, _objectSpread$7({}, arrowProps))]
|
|
104
|
+
})))
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
function useGallery (_ref) {
|
|
109
|
+
var product = _ref.product,
|
|
110
|
+
_ref$config = _ref.config,
|
|
111
|
+
functionTypes = _ref$config.functionTypes,
|
|
112
|
+
mediaTypes = _ref$config.mediaTypes,
|
|
113
|
+
add2DImage = _ref$config.add2DImage;
|
|
114
|
+
|
|
115
|
+
var _useState = useState([]),
|
|
116
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
117
|
+
medias = _useState2[0],
|
|
118
|
+
setMedias = _useState2[1];
|
|
119
|
+
|
|
120
|
+
var _useState3 = useState(false),
|
|
121
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
122
|
+
sirvLoaded = _useState4[0],
|
|
123
|
+
setSirvLoaded = _useState4[1];
|
|
124
|
+
|
|
125
|
+
var _useDivaCore = useDivaCore(),
|
|
126
|
+
baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
|
|
127
|
+
|
|
128
|
+
useEffect(function () {
|
|
129
|
+
var newMedias = [];
|
|
130
|
+
|
|
131
|
+
var _loop = function _loop(i) {
|
|
132
|
+
var _product$media$filter, _product$media;
|
|
133
|
+
|
|
134
|
+
var functionType = functionTypes[i];
|
|
135
|
+
var filteredMedias = (_product$media$filter = (_product$media = product.media) === null || _product$media === void 0 ? void 0 : _product$media.filter(function (m, i) {
|
|
136
|
+
return m.functionType === functionType;
|
|
137
|
+
})) !== null && _product$media$filter !== void 0 ? _product$media$filter : [];
|
|
138
|
+
|
|
139
|
+
if (filteredMedias !== null && filteredMedias !== void 0 && filteredMedias.length) {
|
|
140
|
+
if (mediaTypes) {
|
|
141
|
+
var _loop2 = function _loop2(j) {
|
|
142
|
+
newMedias = [].concat(_toConsumableArray(newMedias), _toConsumableArray(filteredMedias.filter(function (m) {
|
|
143
|
+
return m.mediaType === mediaTypes[j];
|
|
144
|
+
})));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
for (var j = 0; j < mediaTypes.length; j++) {
|
|
148
|
+
_loop2(j);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var _loop3 = function _loop3(_j) {
|
|
152
|
+
newMedias = [].concat(_toConsumableArray(newMedias), _toConsumableArray(filteredMedias.filter(function (m) {
|
|
153
|
+
return !newMedias.find(function (m) {
|
|
154
|
+
return m.url == filteredMedias[_j].url;
|
|
155
|
+
});
|
|
156
|
+
})));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
for (var _j = 0; _j < filteredMedias.length; _j++) {
|
|
160
|
+
_loop3(_j);
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
newMedias = [].concat(_toConsumableArray(newMedias), _toConsumableArray(filteredMedias));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
for (var i = 0; i < functionTypes.length; i++) {
|
|
169
|
+
_loop(i);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (add2DImage && product.image2D) newMedias.push({
|
|
173
|
+
url: product.image2D
|
|
174
|
+
});
|
|
175
|
+
setMedias(newMedias);
|
|
176
|
+
}, [product]);
|
|
177
|
+
useEffect(function () {
|
|
178
|
+
var hasSirvMedia = false;
|
|
179
|
+
|
|
180
|
+
var _loop4 = function _loop4(i) {
|
|
181
|
+
if (medias.find(function (m) {
|
|
182
|
+
var _m$url;
|
|
183
|
+
|
|
184
|
+
return (_m$url = m.url) === null || _m$url === void 0 ? void 0 : _m$url.includes(baseSirvUrls[i]);
|
|
185
|
+
})) hasSirvMedia = true;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
for (var i = 0; i < (baseSirvUrls !== null && baseSirvUrls !== void 0 ? baseSirvUrls : []).length && !hasSirvMedia; i++) {
|
|
189
|
+
_loop4(i);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!hasSirvMedia) return;
|
|
193
|
+
|
|
194
|
+
var loadSirv = function loadSirv() {
|
|
195
|
+
return new Promise(function (resolve) {
|
|
196
|
+
var script = document.createElement('script');
|
|
197
|
+
script.src = 'https://scripts.sirv.com/sirvjs/v3/sirv.js?modules=lazyimage,zoom,spin';
|
|
198
|
+
script.type = 'text/javascript';
|
|
199
|
+
script.async = true;
|
|
200
|
+
script.onload = resolve;
|
|
201
|
+
document.body.appendChild(script);
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
loadSirv().then(function () {
|
|
206
|
+
setSirvLoaded(true);
|
|
207
|
+
});
|
|
208
|
+
}, [medias]);
|
|
209
|
+
return {
|
|
210
|
+
medias: medias,
|
|
211
|
+
sirvLoaded: sirvLoaded
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
216
|
+
|
|
217
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
218
|
+
|
|
219
|
+
var SirvMediaItem = function SirvMediaItem(_ref) {
|
|
220
|
+
var _ref$media = _ref.media,
|
|
221
|
+
url = _ref$media.url,
|
|
222
|
+
functionType = _ref$media.functionType,
|
|
223
|
+
_ref$config = _ref.config,
|
|
224
|
+
sirvProps = _ref$config.sirvProps,
|
|
225
|
+
specificSirvProps = _ref$config.specificSirvProps,
|
|
226
|
+
sirvWrapperProps = _ref$config.sirvWrapperProps;
|
|
227
|
+
var props = functionType && specificSirvProps !== null && specificSirvProps !== void 0 && specificSirvProps[functionType] ? specificSirvProps[functionType] : sirvProps;
|
|
228
|
+
return /*#__PURE__*/jsx("div", _objectSpread$6(_objectSpread$6({
|
|
229
|
+
className: "Sirv custom"
|
|
230
|
+
}, sirvWrapperProps), {}, {
|
|
231
|
+
children: /*#__PURE__*/jsx("div", _objectSpread$6(_objectSpread$6({
|
|
232
|
+
"data-src": url
|
|
233
|
+
}, props), {}, {
|
|
234
|
+
className: 'diva-sirv-img'
|
|
235
|
+
}))
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
function styleInject(css, ref) {
|
|
240
|
+
if ( ref === void 0 ) ref = {};
|
|
241
|
+
var insertAt = ref.insertAt;
|
|
242
|
+
|
|
243
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
244
|
+
|
|
245
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
246
|
+
var style = document.createElement('style');
|
|
247
|
+
style.type = 'text/css';
|
|
248
|
+
|
|
249
|
+
if (insertAt === 'top') {
|
|
250
|
+
if (head.firstChild) {
|
|
251
|
+
head.insertBefore(style, head.firstChild);
|
|
252
|
+
} else {
|
|
253
|
+
head.appendChild(style);
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
head.appendChild(style);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (style.styleSheet) {
|
|
260
|
+
style.styleSheet.cssText = css;
|
|
261
|
+
} else {
|
|
262
|
+
style.appendChild(document.createTextNode(css));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
var divaAr = "diva-ar-msJ2C";
|
|
267
|
+
var css_248z$2 = "/* This keeps child nodes hidden while the element loads */\r\n.diva-ar-msJ2C :not(:defined) > * {\r\n display: none;\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C {\r\n overflow-x: hidden;\r\n}\r\n\r\n@-webkit-keyframes circle-qKefP {\r\n from {\r\n transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg);\r\n }\r\n to {\r\n transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg);\r\n }\r\n}\r\n\r\n@keyframes circle-qKefP {\r\n from {\r\n transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg);\r\n }\r\n to {\r\n transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg);\r\n }\r\n}\r\n\r\n@-webkit-keyframes elongate-EJuQ- {\r\n from {\r\n transform: translateX(100px);\r\n }\r\n to {\r\n transform: translateX(-100px);\r\n }\r\n}\r\n\r\n@keyframes elongate-EJuQ- {\r\n from {\r\n transform: translateX(100px);\r\n }\r\n to {\r\n transform: translateX(-100px);\r\n }\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C > #ar-prompt {\r\n position: absolute;\r\n left: 50%;\r\n bottom: 175px;\r\n -webkit-animation: elongate-EJuQ- 2s infinite ease-in-out alternate;\r\n animation: elongate-EJuQ- 2s infinite ease-in-out alternate;\r\n display: none;\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C[ar-status='session-started'] > #ar-prompt {\r\n display: block;\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C > #ar-prompt > img {\r\n -webkit-animation: circle-qKefP 4s linear infinite;\r\n animation: circle-qKefP 4s linear infinite;\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C > #ar-failure {\r\n position: absolute;\r\n left: 50%;\r\n transform: translateX(-50%);\r\n bottom: 175px;\r\n display: none;\r\n}\r\n\r\nmodel-viewer.diva-ar-msJ2C[ar-tracking='not-tracking'] > #ar-failure {\r\n display: block;\r\n}\r\n";
|
|
268
|
+
styleInject(css_248z$2);
|
|
269
|
+
|
|
270
|
+
if (!window.customElements.get('model-viewer')) {
|
|
271
|
+
import('@google/model-viewer');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var ArViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
275
|
+
_ref.cameraArButton;
|
|
276
|
+
var media = _ref.media;
|
|
277
|
+
|
|
278
|
+
var _useDivaCore = useDivaCore(),
|
|
279
|
+
baseCdnUrl = _useDivaCore.state.apiConfig.baseCdnUrl;
|
|
280
|
+
|
|
281
|
+
return /*#__PURE__*/jsxs("model-viewer", {
|
|
282
|
+
ref: ref,
|
|
283
|
+
src: media.url,
|
|
284
|
+
"environment-image": 'neutral',
|
|
285
|
+
shadowIntensity: 1,
|
|
286
|
+
shadowSoftness: 1,
|
|
287
|
+
exposure: 1,
|
|
288
|
+
"camera-controls": true,
|
|
289
|
+
ar: true,
|
|
290
|
+
"ar-modes": 'webxr quick-look',
|
|
291
|
+
"ar-scale": 'fixed',
|
|
292
|
+
style: {
|
|
293
|
+
overscrollBehavior: 'none',
|
|
294
|
+
width: '100%',
|
|
295
|
+
height: '100%',
|
|
296
|
+
touchAction: 'none'
|
|
297
|
+
},
|
|
298
|
+
"class": classNames(divaAr, 'diva-pdp-ar'),
|
|
299
|
+
"touch-action": "pan-y",
|
|
300
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
301
|
+
id: "ar-prompt",
|
|
302
|
+
children: /*#__PURE__*/jsx("img", {
|
|
303
|
+
src: baseCdnUrl + '/static/images/hand.png'
|
|
304
|
+
})
|
|
305
|
+
}), /*#__PURE__*/jsx("button", {
|
|
306
|
+
id: "ar-failure",
|
|
307
|
+
children: "AR is not tracking!"
|
|
308
|
+
})]
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
var MediaItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
313
|
+
var media = _ref.media,
|
|
314
|
+
config = _ref.config;
|
|
315
|
+
_ref.isCurrentlyVisible;
|
|
316
|
+
var useSirv = false;
|
|
317
|
+
|
|
318
|
+
var _useDivaCore = useDivaCore(),
|
|
319
|
+
baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
|
|
320
|
+
|
|
321
|
+
if (media.url && baseSirvUrls !== null && baseSirvUrls !== void 0 && baseSirvUrls.find(function (base) {
|
|
322
|
+
var _media$url;
|
|
323
|
+
|
|
324
|
+
return (_media$url = media.url) === null || _media$url === void 0 ? void 0 : _media$url.includes(base);
|
|
325
|
+
})) useSirv = true;
|
|
326
|
+
if (useSirv) return /*#__PURE__*/jsx(SirvMediaItem, {
|
|
327
|
+
media: media,
|
|
328
|
+
config: config
|
|
329
|
+
}, media.url);
|
|
330
|
+
if (media.mediaType == 'AR') return /*#__PURE__*/jsx(ArViewer, {
|
|
331
|
+
ref: ref,
|
|
332
|
+
media: media
|
|
333
|
+
});
|
|
334
|
+
return /*#__PURE__*/jsx("img", {
|
|
335
|
+
className: "gallery-image",
|
|
336
|
+
src: media.url
|
|
337
|
+
}, media.url);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
var Thumb = function Thumb(_ref) {
|
|
341
|
+
var media = _ref.media,
|
|
342
|
+
medias = _ref.medias;
|
|
343
|
+
|
|
344
|
+
if (media.mediaType == 'AR') {
|
|
345
|
+
var _medias$find$url, _medias$find;
|
|
346
|
+
|
|
347
|
+
var mainImageUrl = (_medias$find$url = (_medias$find = medias.find(function (m) {
|
|
348
|
+
return m.functionType == 'ART';
|
|
349
|
+
})) === null || _medias$find === void 0 ? void 0 : _medias$find.url) !== null && _medias$find$url !== void 0 ? _medias$find$url : medias[0].url;
|
|
350
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
351
|
+
children: [/*#__PURE__*/jsx("img", {
|
|
352
|
+
className: "gallery-image-thumb",
|
|
353
|
+
src: mainImageUrl
|
|
354
|
+
}), /*#__PURE__*/jsx("div", {
|
|
355
|
+
className: 'ar-icon-thumb'
|
|
356
|
+
})]
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return /*#__PURE__*/jsx("img", {
|
|
361
|
+
className: "gallery-image-thumb",
|
|
362
|
+
src: media.url
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
var gallery = "gallery-jOl8d";
|
|
367
|
+
var css_248z$1 = ".gallery-jOl8d .gallery-thumb .swiper-slide {\r\n opacity: 0.4;\r\n}\r\n.gallery-jOl8d .gallery-thumb .swiper-slide-thumb-active {\r\n opacity: 1;\r\n}\r\n\r\n/*navigation*/\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next {\r\n position: absolute;\r\n top: 50%;\r\n top: var(--swiper-navigation-top-offset, 50%);\r\n width: calc(var(--swiper-navigation-size) / 44 * 27);\r\n height: var(--swiper-navigation-size);\r\n margin-top: calc(0px - (var(--swiper-navigation-size) / 2));\r\n z-index: 10;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: var(--swiper-theme-color);\r\n color: var(--swiper-navigation-color, var(--swiper-theme-color));\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev.swiper-button-disabled,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next.swiper-button-disabled {\r\n opacity: 0.35;\r\n cursor: auto;\r\n pointer-events: none;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev.swiper-button-hidden,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next.swiper-button-hidden {\r\n opacity: 0;\r\n cursor: auto;\r\n pointer-events: none;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-navigation-disabled .swiper-button-prev,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-navigation-disabled .swiper-button-next {\r\n display: none !important;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev svg,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next svg {\r\n width: 100%;\r\n height: 100%;\r\n -o-object-fit: contain;\r\n object-fit: contain;\r\n transform-origin: center;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-prev svg,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-next svg {\r\n transform: rotate(180deg);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-next {\r\n left: 10px;\r\n left: var(--swiper-navigation-sides-offset, 10px);\r\n right: auto;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-prev {\r\n right: 10px;\r\n right: var(--swiper-navigation-sides-offset, 10px);\r\n left: auto;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-lock {\r\n display: none;\r\n}\r\n/* Navigation font start */\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev:after,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next:after {\r\n text-transform: none !important;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev:after,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next:after {\r\n font-family: swiper-icons;\r\n font-size: var(--swiper-navigation-size);\r\n letter-spacing: 0;\r\n font-feature-settings: ;\r\n font-variant: normal;\r\n font-variant: initial;\r\n line-height: 1;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-prev:after,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-next:after {\r\n content: 'prev';\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-prev {\r\n right: 10px;\r\n right: var(--swiper-navigation-sides-offset, 10px);\r\n left: auto;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-button-next:after,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-rtl .swiper-button-prev:after {\r\n content: 'next';\r\n}\r\n/* Navigation font end */\r\n\r\n/*swiper min css*/\r\n\r\n@font-face {\r\n font-family: swiper-icons;\r\n src: url('data:application/font-woff;charset=utf-8;base64, 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');\r\n font-weight: 400;\r\n font-style: normal;\r\n}\r\n\r\n.gallery-jOl8d.diva-pdp-gallery .swiper {\r\n margin-left: auto;\r\n margin-right: auto;\r\n position: relative;\r\n overflow: hidden;\r\n list-style: none;\r\n padding: 0;\r\n z-index: 1;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-vertical > .swiper-wrapper {\r\n flex-direction: column;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-wrapper {\r\n position: relative;\r\n width: 100%;\r\n height: 100%;\r\n z-index: 1;\r\n display: flex;\r\n transition-property: transform;\r\n box-sizing: content-box;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-android .swiper-slide,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-wrapper {\r\n transform: translate3d(0px, 0, 0);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-pointer-events {\r\n touch-action: pan-y;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-pointer-events.swiper-vertical {\r\n touch-action: pan-x;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-slide {\r\n flex-shrink: 0;\r\n width: 100%;\r\n height: 100%;\r\n position: relative;\r\n transition-property: transform;\r\n}\r\n\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-slide-invisible-blank {\r\n visibility: hidden;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-autoheight,\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-autoheight .swiper-slide {\r\n height: auto;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-autoheight .swiper-wrapper {\r\n align-items: flex-start;\r\n transition-property: transform, height;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-backface-hidden .swiper-slide {\r\n transform: translateZ(0);\r\n -webkit-backface-visibility: hidden;\r\n backface-visibility: hidden;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-horizontal.swiper-css-mode > .swiper-wrapper {\r\n scroll-snap-type: x mandatory;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-vertical.swiper-css-mode > .swiper-wrapper {\r\n scroll-snap-type: y mandatory;\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-centered > .swiper-wrapper::before {\r\n content: '';\r\n flex-shrink: 0;\r\n order: 9999;\r\n}\r\n[dir=\"ltr\"] .gallery-jOl8d.diva-pdp-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-left: var(--swiper-centered-offset-before);\r\n}\r\n[dir=\"rtl\"] .gallery-jOl8d.diva-pdp-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-right: var(--swiper-centered-offset-before);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper::before {\r\n height: 100%;\r\n min-height: 1px;\r\n width: var(--swiper-centered-offset-after);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-centered.swiper-vertical > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-top: var(--swiper-centered-offset-before);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-centered.swiper-vertical > .swiper-wrapper::before {\r\n width: 100%;\r\n min-width: 1px;\r\n height: var(--swiper-centered-offset-after);\r\n}\r\n.gallery-jOl8d.diva-pdp-gallery .swiper-centered > .swiper-wrapper > .swiper-slide {\r\n scroll-snap-align: center center;\r\n}\r\n";
|
|
368
|
+
styleInject(css_248z$1);
|
|
369
|
+
|
|
370
|
+
var PageNumber = function PageNumber(_ref) {
|
|
371
|
+
var index = _ref.index,
|
|
372
|
+
length = _ref.length;
|
|
373
|
+
return /*#__PURE__*/jsx("div", {
|
|
374
|
+
className: "gallery-page-number",
|
|
375
|
+
children: index + 1 + '/' + length
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
380
|
+
|
|
381
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
382
|
+
var focusable = '.smv-cursor-zoom-in, .sirv-zoom-wrapper, .sirv-zoom-map-lens ,.sirv-zoom-map, .sirv-deepzoom, .smv-icon, canvas, .diva-sirv-img, input, select, option, textarea, button, video, label';
|
|
383
|
+
var noSwiping = 'canvas, model-viewer, .sirv-zoom-map, .zoom-controls, .smv-icon';
|
|
384
|
+
|
|
385
|
+
var Gallery = function Gallery(_ref) {
|
|
386
|
+
var _medias$find;
|
|
387
|
+
|
|
388
|
+
var config = _ref.config,
|
|
389
|
+
product = _ref.product;
|
|
390
|
+
|
|
391
|
+
var _useState = useState(null),
|
|
392
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
393
|
+
thumbsSwiper = _useState2[0],
|
|
394
|
+
setThumbsSwiper = _useState2[1];
|
|
395
|
+
|
|
396
|
+
var _useState3 = useState(null),
|
|
397
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
398
|
+
swiper = _useState4[0],
|
|
399
|
+
setSwiper = _useState4[1];
|
|
400
|
+
|
|
401
|
+
var _useState5 = useState(0),
|
|
402
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
403
|
+
currentIndex = _useState6[0],
|
|
404
|
+
setCurrentIndex = _useState6[1];
|
|
405
|
+
|
|
406
|
+
var className = config.className;
|
|
407
|
+
|
|
408
|
+
var _useGallery = useGallery({
|
|
409
|
+
product: product,
|
|
410
|
+
config: config
|
|
411
|
+
}),
|
|
412
|
+
medias = _useGallery.medias;
|
|
413
|
+
|
|
414
|
+
var htmlArElement = useRef(null);
|
|
415
|
+
if (!medias.length) return /*#__PURE__*/jsx(Fragment, {});
|
|
416
|
+
var arUrl = (_medias$find = medias.find(function (m) {
|
|
417
|
+
return m.mediaType == 'AR';
|
|
418
|
+
})) === null || _medias$find === void 0 ? void 0 : _medias$find.url;
|
|
419
|
+
return /*#__PURE__*/jsxs("div", {
|
|
420
|
+
className: classNames(gallery, ' diva-pdp-gallery', className),
|
|
421
|
+
children: [config.arIconProps && (htmlArElement === null || htmlArElement === void 0 ? void 0 : htmlArElement.current) && arUrl && /*#__PURE__*/jsx(ArActionIcon, {
|
|
422
|
+
config: config.arIconProps,
|
|
423
|
+
url: arUrl,
|
|
424
|
+
htmlArElement: htmlArElement === null || htmlArElement === void 0 ? void 0 : htmlArElement.current
|
|
425
|
+
}), config.showPageNumber && swiper && /*#__PURE__*/jsx(PageNumber, {
|
|
426
|
+
index: currentIndex,
|
|
427
|
+
length: medias.length
|
|
428
|
+
}), /*#__PURE__*/jsx(Swiper, _objectSpread$5(_objectSpread$5({
|
|
429
|
+
onSwiper: setSwiper,
|
|
430
|
+
onSlideChange: function onSlideChange(swiper) {
|
|
431
|
+
setCurrentIndex(swiper.activeIndex);
|
|
432
|
+
},
|
|
433
|
+
focusableElements: focusable,
|
|
434
|
+
noSwipingSelector: noSwiping,
|
|
435
|
+
navigation: true,
|
|
436
|
+
thumbs: {
|
|
437
|
+
swiper: thumbsSwiper
|
|
438
|
+
},
|
|
439
|
+
modules: [Navigation, Thumbs],
|
|
440
|
+
className: "gallery-main"
|
|
441
|
+
}, config.sliderProp), {}, {
|
|
442
|
+
children: medias.map(function (media, i) {
|
|
443
|
+
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
444
|
+
children: /*#__PURE__*/jsx(MediaItem, {
|
|
445
|
+
media: media,
|
|
446
|
+
config: config,
|
|
447
|
+
isCurrentlyVisible: i === (swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex),
|
|
448
|
+
ref: htmlArElement
|
|
449
|
+
})
|
|
450
|
+
}, i);
|
|
451
|
+
})
|
|
452
|
+
})), /*#__PURE__*/jsx(Swiper, _objectSpread$5(_objectSpread$5({
|
|
453
|
+
onSwiper: setThumbsSwiper,
|
|
454
|
+
slidesPerView: medias.length < 5 ? medias.length : 6,
|
|
455
|
+
modules: [Navigation, Thumbs],
|
|
456
|
+
className: "gallery-thumb"
|
|
457
|
+
}, config.thumbSliderProp), {}, {
|
|
458
|
+
children: medias.map(function (media, i) {
|
|
459
|
+
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
460
|
+
children: /*#__PURE__*/jsx(Thumb, {
|
|
461
|
+
media: media,
|
|
462
|
+
medias: medias
|
|
463
|
+
}, i)
|
|
464
|
+
}, i + 't');
|
|
465
|
+
})
|
|
466
|
+
}))]
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
var Text = function Text(_ref) {
|
|
471
|
+
var _config$className;
|
|
472
|
+
|
|
473
|
+
var config = _ref.config;
|
|
474
|
+
return /*#__PURE__*/jsx("div", {
|
|
475
|
+
className: 'diva-pdp-text ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
476
|
+
dangerouslySetInnerHTML: {
|
|
477
|
+
__html: config.text
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
var Price = function Price(_ref) {
|
|
483
|
+
var _config$className;
|
|
484
|
+
|
|
485
|
+
var addedPrice = _ref.addedPrice,
|
|
486
|
+
discountedPrice = _ref.discountedPrice,
|
|
487
|
+
config = _ref.config;
|
|
488
|
+
|
|
489
|
+
var _useTranslation = useTranslation(),
|
|
490
|
+
t = _useTranslation.t;
|
|
491
|
+
|
|
492
|
+
var price_ending = '';
|
|
493
|
+
if (config.priceEnding) price_ending = t(config.priceEnding);
|
|
494
|
+
return /*#__PURE__*/jsxs("div", {
|
|
495
|
+
className: 'diva-pdp-price ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
496
|
+
children: [!!discountedPrice && /*#__PURE__*/jsxs("div", {
|
|
497
|
+
id: "discounted-price",
|
|
498
|
+
children: [DivaUtils.formatPrice(discountedPrice) + ' ' + price_ending, " "]
|
|
499
|
+
}), /*#__PURE__*/jsx("div", {
|
|
500
|
+
id: "added-price",
|
|
501
|
+
className: !!discountedPrice ? 'added-price-cancelled' : undefined,
|
|
502
|
+
children: !!addedPrice && DivaUtils.formatPrice(addedPrice) + ' ' + price_ending
|
|
503
|
+
})]
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var Tab = function Tab(props) {
|
|
508
|
+
//TODO implement Tab component
|
|
509
|
+
return /*#__PURE__*/jsx("div", {
|
|
510
|
+
children: "To be implemented"
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
var TabInfo = function TabInfo(_ref) {
|
|
515
|
+
var _config$className;
|
|
516
|
+
|
|
517
|
+
var config = _ref.config;
|
|
518
|
+
return /*#__PURE__*/jsx("div", {
|
|
519
|
+
className: 'diva-pdp-tabs ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
520
|
+
children: config.tabs.map(function (tab) {
|
|
521
|
+
return /*#__PURE__*/jsx(Tab, {
|
|
522
|
+
text: tab.title,
|
|
523
|
+
title: tab.text
|
|
524
|
+
});
|
|
525
|
+
})
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
var Info = function Info(_ref) {
|
|
530
|
+
var config = _ref.config;
|
|
531
|
+
if (config.type == 'TABS') return /*#__PURE__*/jsx(TabInfo, {
|
|
532
|
+
config: config
|
|
533
|
+
});
|
|
534
|
+
throw new Error('Info type ' + config.type + ' not implemented!');
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
var PdpAction = function PdpAction(_ref) {
|
|
538
|
+
var _ref$config = _ref.config,
|
|
539
|
+
icon = _ref$config.icon,
|
|
540
|
+
iconClass = _ref$config.iconClass,
|
|
541
|
+
textClass = _ref$config.textClass,
|
|
542
|
+
onClick = _ref$config.onClick,
|
|
543
|
+
onDoubleClick = _ref$config.onDoubleClick,
|
|
544
|
+
text = _ref$config.text,
|
|
545
|
+
className = _ref$config.className;
|
|
546
|
+
return /*#__PURE__*/jsxs("button", {
|
|
547
|
+
className: 'diva-pdp-action ' + (className !== null && className !== void 0 ? className : ''),
|
|
548
|
+
onDoubleClick: onDoubleClick ? onClick : undefined,
|
|
549
|
+
onClick: !onDoubleClick ? onClick : undefined,
|
|
550
|
+
children: [text !== undefined && /*#__PURE__*/jsx("div", {
|
|
551
|
+
className: textClass,
|
|
552
|
+
children: text
|
|
553
|
+
}), icon !== undefined && /*#__PURE__*/jsx("img", {
|
|
554
|
+
src: icon
|
|
555
|
+
}), iconClass !== undefined && /*#__PURE__*/jsx("div", {
|
|
556
|
+
className: iconClass
|
|
557
|
+
})]
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
var Actions = function Actions(_ref) {
|
|
562
|
+
var _config$className, _config$actions;
|
|
563
|
+
|
|
564
|
+
var config = _ref.config;
|
|
565
|
+
return /*#__PURE__*/jsx("div", {
|
|
566
|
+
className: 'diva-pdp-actions ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
567
|
+
children: (_config$actions = config.actions) === null || _config$actions === void 0 ? void 0 : _config$actions.map(function (a) {
|
|
568
|
+
return /*#__PURE__*/jsx(PdpAction, {
|
|
569
|
+
config: a
|
|
570
|
+
}, a.id);
|
|
571
|
+
})
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
var variants = "variants-HWTGr";
|
|
576
|
+
var css_248z = "/*navigation*/\r\n.variants-HWTGr.classification-group .swiper-button-prev,\r\n.variants-HWTGr.classification-group .swiper-button-next {\r\n position: absolute;\r\n top: 50%;\r\n top: var(--swiper-navigation-top-offset, 50%);\r\n width: calc(var(--swiper-navigation-size) / 44 * 27);\r\n height: var(--swiper-navigation-size);\r\n margin-top: calc(0px - (var(--swiper-navigation-size) / 2));\r\n z-index: 10;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: var(--swiper-theme-color);\r\n color: var(--swiper-navigation-color, var(--swiper-theme-color));\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev.swiper-button-disabled,\r\n.variants-HWTGr.classification-group .swiper-button-next.swiper-button-disabled {\r\n opacity: 0.35;\r\n cursor: auto;\r\n pointer-events: none;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev.swiper-button-hidden,\r\n.variants-HWTGr.classification-group .swiper-button-next.swiper-button-hidden {\r\n opacity: 0;\r\n cursor: auto;\r\n pointer-events: none;\r\n}\r\n.variants-HWTGr.classification-group .swiper-navigation-disabled .swiper-button-prev,\r\n.variants-HWTGr.classification-group .swiper-navigation-disabled .swiper-button-next {\r\n display: none !important;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev svg,\r\n.variants-HWTGr.classification-group .swiper-button-next svg {\r\n width: 100%;\r\n height: 100%;\r\n -o-object-fit: contain;\r\n object-fit: contain;\r\n transform-origin: center;\r\n}\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-prev svg,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-next svg {\r\n transform: rotate(180deg);\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-next {\r\n left: 10px;\r\n left: var(--swiper-navigation-sides-offset, 10px);\r\n right: auto;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-next,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-prev {\r\n right: 10px;\r\n right: var(--swiper-navigation-sides-offset, 10px);\r\n left: auto;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-lock {\r\n display: none;\r\n}\r\n/* Navigation font start */\r\n.variants-HWTGr.classification-group .swiper-button-prev:after,\r\n.variants-HWTGr.classification-group .swiper-button-next:after {\r\n text-transform: none !important;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev:after,\r\n.variants-HWTGr.classification-group .swiper-button-next:after {\r\n font-family: swiper-icons;\r\n font-size: var(--swiper-navigation-size);\r\n letter-spacing: 0;\r\n font-feature-settings: ;\r\n font-variant: normal;\r\n font-variant: initial;\r\n line-height: 1;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-prev:after,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-next:after {\r\n content: 'prev';\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-next,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-prev {\r\n right: 10px;\r\n right: var(--swiper-navigation-sides-offset, 10px);\r\n left: auto;\r\n}\r\n.variants-HWTGr.classification-group .swiper-button-next:after,\r\n.variants-HWTGr.classification-group .swiper-rtl .swiper-button-prev:after {\r\n content: 'next';\r\n}\r\n/* Navigation font end */\r\n\r\n/*swiper min css*/\r\n\r\n@font-face {\r\n font-family: swiper-icons;\r\n src: url('data:application/font-woff;charset=utf-8;base64, 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');\r\n font-weight: 400;\r\n font-style: normal;\r\n}\r\n\r\n.variants-HWTGr.classification-group .swiper {\r\n position: relative;\r\n overflow: hidden;\r\n list-style: none;\r\n padding: 0;\r\n z-index: 1;\r\n}\r\n.variants-HWTGr.classification-group .swiper-vertical > .swiper-wrapper {\r\n flex-direction: column;\r\n}\r\n.variants-HWTGr.classification-group .swiper-wrapper {\r\n position: relative;\r\n width: 100%;\r\n height: 100%;\r\n z-index: 1;\r\n display: flex;\r\n transition-property: transform;\r\n box-sizing: content-box;\r\n}\r\n.variants-HWTGr.classification-group .swiper-android .swiper-slide,\r\n.variants-HWTGr.classification-group .swiper-wrapper {\r\n transform: translate3d(0px, 0, 0);\r\n}\r\n.variants-HWTGr.classification-group .swiper-pointer-events {\r\n touch-action: pan-y;\r\n}\r\n.variants-HWTGr.classification-group .swiper-pointer-events.swiper-vertical {\r\n touch-action: pan-x;\r\n}\r\n.variants-HWTGr.classification-group .swiper-slide {\r\n flex-shrink: 0;\r\n width: 100%;\r\n height: 100%;\r\n position: relative;\r\n transition-property: transform;\r\n}\r\n\r\n.variants-HWTGr.classification-group .swiper-slide-invisible-blank {\r\n visibility: hidden;\r\n}\r\n.variants-HWTGr.classification-group .swiper-autoheight,\r\n.variants-HWTGr.classification-group .swiper-autoheight .swiper-slide {\r\n height: auto;\r\n}\r\n.variants-HWTGr.classification-group .swiper-autoheight .swiper-wrapper {\r\n align-items: flex-start;\r\n transition-property: transform, height;\r\n}\r\n.variants-HWTGr.classification-group .swiper-backface-hidden .swiper-slide {\r\n transform: translateZ(0);\r\n -webkit-backface-visibility: hidden;\r\n backface-visibility: hidden;\r\n}\r\n.variants-HWTGr.classification-group .swiper-horizontal.swiper-css-mode > .swiper-wrapper {\r\n scroll-snap-type: x mandatory;\r\n}\r\n.variants-HWTGr.classification-group .swiper-vertical.swiper-css-mode > .swiper-wrapper {\r\n scroll-snap-type: y mandatory;\r\n}\r\n.variants-HWTGr.classification-group .swiper-centered > .swiper-wrapper::before {\r\n content: '';\r\n flex-shrink: 0;\r\n order: 9999;\r\n}\r\n[dir=\"ltr\"] .variants-HWTGr.classification-group .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-left: var(--swiper-centered-offset-before);\r\n}\r\n[dir=\"rtl\"] .variants-HWTGr.classification-group .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-right: var(--swiper-centered-offset-before);\r\n}\r\n.variants-HWTGr.classification-group .swiper-centered.swiper-horizontal > .swiper-wrapper::before {\r\n height: 100%;\r\n min-height: 1px;\r\n width: var(--swiper-centered-offset-after);\r\n}\r\n.variants-HWTGr.classification-group .swiper-centered.swiper-vertical > .swiper-wrapper > .swiper-slide:first-child {\r\n margin-top: var(--swiper-centered-offset-before);\r\n}\r\n.variants-HWTGr.classification-group .swiper-centered.swiper-vertical > .swiper-wrapper::before {\r\n width: 100%;\r\n min-width: 1px;\r\n height: var(--swiper-centered-offset-after);\r\n}\r\n.variants-HWTGr.classification-group .swiper-centered > .swiper-wrapper > .swiper-slide {\r\n scroll-snap-align: center center;\r\n}\r\n";
|
|
577
|
+
styleInject(css_248z);
|
|
578
|
+
|
|
579
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
580
|
+
|
|
581
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
582
|
+
|
|
583
|
+
var Group = function Group(_ref) {
|
|
584
|
+
var _config$classificatio, _selectedClassificati;
|
|
585
|
+
|
|
586
|
+
var onChange = _ref.onChange,
|
|
587
|
+
groups = _ref.groups,
|
|
588
|
+
product = _ref.product,
|
|
589
|
+
groupKey = _ref.groupKey,
|
|
590
|
+
config = _ref.config,
|
|
591
|
+
products = _ref.products,
|
|
592
|
+
_ref$selectedClassifi = _ref.selectedClassification,
|
|
593
|
+
selectedClassification = _ref$selectedClassifi === void 0 ? product[groupKey] : _ref$selectedClassifi;
|
|
594
|
+
|
|
595
|
+
var _useState = useState(null),
|
|
596
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
597
|
+
swiperRef = _useState2[0],
|
|
598
|
+
setSwiperRef = _useState2[1];
|
|
599
|
+
|
|
600
|
+
if (!selectedClassification) return /*#__PURE__*/jsx(Fragment, {});
|
|
601
|
+
var classificationConfig = (_config$classificatio = config.classificationConfig) === null || _config$classificatio === void 0 ? void 0 : _config$classificatio[groupKey];
|
|
602
|
+
var classificationText = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.text;
|
|
603
|
+
var group = groups[groupKey];
|
|
604
|
+
|
|
605
|
+
var _onClick = function onClick(e, codex) {
|
|
606
|
+
var _classificationConfig3, _classificationConfig4;
|
|
607
|
+
|
|
608
|
+
var potentials = products.filter(function (variant) {
|
|
609
|
+
var _variant$groupKey$val, _variant$groupKey, _variant$groupKey2;
|
|
610
|
+
|
|
611
|
+
return compareCodexes((_variant$groupKey$val = (_variant$groupKey = variant[groupKey]) === null || _variant$groupKey === void 0 ? void 0 : _variant$groupKey.value) !== null && _variant$groupKey$val !== void 0 ? _variant$groupKey$val : (_variant$groupKey2 = variant[groupKey]) === null || _variant$groupKey2 === void 0 ? void 0 : _variant$groupKey2.opv, codex);
|
|
612
|
+
});
|
|
613
|
+
if (!potentials.length) return;
|
|
614
|
+
|
|
615
|
+
for (var i = 0; i < potentials.length; i++) {
|
|
616
|
+
var potential = potentials[i];
|
|
617
|
+
var perfectMatch = true;
|
|
618
|
+
|
|
619
|
+
for (var key in groups) {
|
|
620
|
+
var _potential$key$value, _potential$key, _potential$key2, _key$value, _key, _key2;
|
|
621
|
+
|
|
622
|
+
if (key === groupKey) continue;
|
|
623
|
+
var potentialCodex = (_potential$key$value = (_potential$key = potential[key]) === null || _potential$key === void 0 ? void 0 : _potential$key.value) !== null && _potential$key$value !== void 0 ? _potential$key$value : (_potential$key2 = potential[key]) === null || _potential$key2 === void 0 ? void 0 : _potential$key2.opv;
|
|
624
|
+
var currentCodex = (_key$value = (_key = product[key]) === null || _key === void 0 ? void 0 : _key.value) !== null && _key$value !== void 0 ? _key$value : (_key2 = product[key]) === null || _key2 === void 0 ? void 0 : _key2.opv;
|
|
625
|
+
|
|
626
|
+
if (!compareCodexes(potentialCodex, currentCodex)) {
|
|
627
|
+
perfectMatch = false;
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (perfectMatch) {
|
|
633
|
+
var _classificationConfig, _classificationConfig2;
|
|
634
|
+
|
|
635
|
+
onChange(potential._id);
|
|
636
|
+
classificationConfig === null || classificationConfig === void 0 ? void 0 : (_classificationConfig = classificationConfig.action) === null || _classificationConfig === void 0 ? void 0 : (_classificationConfig2 = _classificationConfig.onClick) === null || _classificationConfig2 === void 0 ? void 0 : _classificationConfig2.call(_classificationConfig, e, potential._id);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
onChange(potentials[0]._id);
|
|
642
|
+
classificationConfig === null || classificationConfig === void 0 ? void 0 : (_classificationConfig3 = classificationConfig.action) === null || _classificationConfig3 === void 0 ? void 0 : (_classificationConfig4 = _classificationConfig3.onClick) === null || _classificationConfig4 === void 0 ? void 0 : _classificationConfig4.call(_classificationConfig3, e, potentials[0]._id);
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
var selectedKey = (_selectedClassificati = selectedClassification === null || selectedClassification === void 0 ? void 0 : selectedClassification.opv) !== null && _selectedClassificati !== void 0 ? _selectedClassificati : selectedClassification === null || selectedClassification === void 0 ? void 0 : selectedClassification.value;
|
|
646
|
+
var elements = group.map(function (item, index) {
|
|
647
|
+
var _item$image, _item$variant$media, _item$variant$media$f;
|
|
648
|
+
|
|
649
|
+
var image = (_item$image = item.image) !== null && _item$image !== void 0 ? _item$image : (_item$variant$media = item.variant.media) === null || _item$variant$media === void 0 ? void 0 : (_item$variant$media$f = _item$variant$media.find(function (media) {
|
|
650
|
+
return media.functionType === 'OPV';
|
|
651
|
+
})) === null || _item$variant$media$f === void 0 ? void 0 : _item$variant$media$f.url;
|
|
652
|
+
|
|
653
|
+
if (image) {
|
|
654
|
+
//IMAGE AND TEXT
|
|
655
|
+
// if (imageAndText) {
|
|
656
|
+
// return <ImageAndText onClick={(e) => onClick(e, item.codex)} image={image} name={item.name} selected={selectedKey === item.codex} />;
|
|
657
|
+
// }
|
|
658
|
+
//IMAGE
|
|
659
|
+
return /*#__PURE__*/jsx("div", {
|
|
660
|
+
onClick: function onClick(e) {
|
|
661
|
+
return _onClick(e, item.codex);
|
|
662
|
+
},
|
|
663
|
+
style: {
|
|
664
|
+
backgroundImage: 'url(' + image + '?w=' + 64 + ')'
|
|
665
|
+
},
|
|
666
|
+
className: classNames('variant-item-image', selectedKey === item.codex ? 'sel' : undefined)
|
|
667
|
+
}, index);
|
|
668
|
+
} else {
|
|
669
|
+
//TEXT
|
|
670
|
+
return /*#__PURE__*/jsx("div", {
|
|
671
|
+
onClick: function onClick(e) {
|
|
672
|
+
return _onClick(e, item.codex);
|
|
673
|
+
},
|
|
674
|
+
className: classNames('variant-item-text', selectedKey === item.codex ? 'sel' : undefined)
|
|
675
|
+
}, index);
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
if (classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.maxCount) {
|
|
680
|
+
elements.length = classificationConfig.maxCount;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
var navigateToOnClick = function navigateToOnClick(index) {
|
|
684
|
+
swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.slideTo(index);
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
return /*#__PURE__*/jsxs("div", {
|
|
688
|
+
className: classNames(variants, 'classification-group'),
|
|
689
|
+
children: [!!classificationText && /*#__PURE__*/jsx("div", {
|
|
690
|
+
className: "classification-group-title",
|
|
691
|
+
children: classificationText
|
|
692
|
+
}), /*#__PURE__*/jsx(Swiper, _objectSpread$4(_objectSpread$4({
|
|
693
|
+
onSwiper: setSwiperRef,
|
|
694
|
+
className: "classification-variants-slider"
|
|
695
|
+
}, config.sliderProp), {}, {
|
|
696
|
+
children: elements.map(function (e, index) {
|
|
697
|
+
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
698
|
+
onClick: function onClick(e) {
|
|
699
|
+
navigateToOnClick(index - 1);
|
|
700
|
+
e.stopPropagation();
|
|
701
|
+
},
|
|
702
|
+
children: e
|
|
703
|
+
}, index);
|
|
704
|
+
})
|
|
705
|
+
})), config.moreIcon && /*#__PURE__*/jsx(PdpAction, {
|
|
706
|
+
config: config.moreIcon
|
|
707
|
+
})]
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
var compareCodexes = function compareCodexes(codex1, codex2) {
|
|
712
|
+
if (codex1 == codex2) return true;
|
|
713
|
+
|
|
714
|
+
if (codex1.startsWith('A') && codex2.startsWith('A')) {
|
|
715
|
+
var _codex1$match, _codex2$match;
|
|
716
|
+
|
|
717
|
+
var reg = new RegExp(/A\d*(.*)/);
|
|
718
|
+
var repairedCodex1 = (_codex1$match = codex1.match(reg)) === null || _codex1$match === void 0 ? void 0 : _codex1$match[1];
|
|
719
|
+
var repairedCodex2 = (_codex2$match = codex2.match(reg)) === null || _codex2$match === void 0 ? void 0 : _codex2$match[1];
|
|
720
|
+
|
|
721
|
+
if (repairedCodex1 && repairedCodex2 && repairedCodex1 == repairedCodex2) {
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return false;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
function useVariants (_ref) {
|
|
730
|
+
var products = _ref.products;
|
|
731
|
+
|
|
732
|
+
//const [posOfOptState, setPosOfOpt] = useState<{ [opt: string]: number }>({});
|
|
733
|
+
var _useState = useState({}),
|
|
734
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
735
|
+
groupsState = _useState2[0],
|
|
736
|
+
setGroups = _useState2[1];
|
|
737
|
+
|
|
738
|
+
useEffect(function () {
|
|
739
|
+
var groups = {};
|
|
740
|
+
var posOfOpt = {};
|
|
741
|
+
|
|
742
|
+
for (var i = 0; i < products.length; i++) {
|
|
743
|
+
for (var _key in products[i]) {
|
|
744
|
+
if (_key.startsWith('dc_')) {
|
|
745
|
+
var classification = products[i][_key];
|
|
746
|
+
if (!groups[_key]) groups[_key] = [];
|
|
747
|
+
|
|
748
|
+
if (posOfOpt[_key] === undefined) {
|
|
749
|
+
if (classification.optionPosition !== undefined) {
|
|
750
|
+
posOfOpt[_key] = classification.optionPosition;
|
|
751
|
+
} else if (classification.defaultOptionPosition !== undefined) {
|
|
752
|
+
posOfOpt[_key] = classification.defaultOptionPosition;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
} //sort options
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
if (Object.keys(posOfOpt).length) {
|
|
761
|
+
var positions = Object.assign({}, posOfOpt);
|
|
762
|
+
groups = {};
|
|
763
|
+
|
|
764
|
+
while (Object.keys(positions).length) {
|
|
765
|
+
var options = Object.keys(positions);
|
|
766
|
+
var nextOpt = options[0];
|
|
767
|
+
|
|
768
|
+
for (var _key2 in positions) {
|
|
769
|
+
if (positions[nextOpt] > positions[_key2]) nextOpt = _key2;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
delete positions[nextOpt];
|
|
773
|
+
groups[nextOpt] = [];
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
products.map(function (variant, index) {
|
|
778
|
+
var variantAny = variant;
|
|
779
|
+
|
|
780
|
+
var _loop = function _loop(_key3) {
|
|
781
|
+
var _variantAny$_key3$val, _variantAny$_key, _variantAny$_key2, _variantAny$_key3$nam, _variant$media, _variant$media$find;
|
|
782
|
+
|
|
783
|
+
var value = (_variantAny$_key3$val = (_variantAny$_key = variantAny[_key3]) === null || _variantAny$_key === void 0 ? void 0 : _variantAny$_key.value) !== null && _variantAny$_key3$val !== void 0 ? _variantAny$_key3$val : (_variantAny$_key2 = variantAny[_key3]) === null || _variantAny$_key2 === void 0 ? void 0 : _variantAny$_key2.opv;
|
|
784
|
+
if (!value) return "continue";
|
|
785
|
+
if (groups[_key3].find(function (group) {
|
|
786
|
+
return group.codex === value;
|
|
787
|
+
})) return "continue";
|
|
788
|
+
var position = variantAny[_key3].position;
|
|
789
|
+
|
|
790
|
+
groups[_key3].push({
|
|
791
|
+
codex: value,
|
|
792
|
+
position: variantAny[_key3].position !== undefined ? position : index,
|
|
793
|
+
name: (_variantAny$_key3$nam = variantAny[_key3].name) !== null && _variantAny$_key3$nam !== void 0 ? _variantAny$_key3$nam : variantAny[_key3].opvName,
|
|
794
|
+
image: (_variant$media = variant.media) === null || _variant$media === void 0 ? void 0 : (_variant$media$find = _variant$media.find(function (media) {
|
|
795
|
+
return media.functionType === 'OPV' && 'dc_' + media["class"] === _key3;
|
|
796
|
+
})) === null || _variant$media$find === void 0 ? void 0 : _variant$media$find.url,
|
|
797
|
+
variant: variant,
|
|
798
|
+
optName: variantAny[_key3].optName
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
for (var _key3 in groups) {
|
|
803
|
+
var _ret = _loop(_key3);
|
|
804
|
+
|
|
805
|
+
if (_ret === "continue") continue;
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
var irrelevantGroups = [];
|
|
809
|
+
|
|
810
|
+
for (var _key4 in groups) {
|
|
811
|
+
if (groups[_key4].length <= 1) {
|
|
812
|
+
irrelevantGroups.push(_key4);
|
|
813
|
+
} //sort the values of each group
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
groups[_key4] = groups[_key4].sort(function (o1, o2) {
|
|
817
|
+
if (o1.position < o2.position) return -1;
|
|
818
|
+
return 1;
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
irrelevantGroups.map(function (key) {
|
|
823
|
+
return delete groups[key];
|
|
824
|
+
});
|
|
825
|
+
setGroups(groups); //setPosOfOpt(posOfOpt);
|
|
826
|
+
}, [products]);
|
|
827
|
+
return {
|
|
828
|
+
groupsState: groupsState
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
var Variants = function Variants(_ref) {
|
|
833
|
+
var _config$className;
|
|
834
|
+
|
|
835
|
+
var products = _ref.products,
|
|
836
|
+
config = _ref.config,
|
|
837
|
+
product = _ref.product,
|
|
838
|
+
onChange = _ref.onChange;
|
|
839
|
+
|
|
840
|
+
var _useVariants = useVariants({
|
|
841
|
+
products: products
|
|
842
|
+
}),
|
|
843
|
+
groupsState = _useVariants.groupsState;
|
|
844
|
+
|
|
845
|
+
return /*#__PURE__*/jsx("div", {
|
|
846
|
+
className: 'diva-pdp-variants ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
847
|
+
children: Object.keys(groupsState).map(function (key) {
|
|
848
|
+
return /*#__PURE__*/jsx(Group, {
|
|
849
|
+
products: products,
|
|
850
|
+
groups: groupsState,
|
|
851
|
+
product: product,
|
|
852
|
+
groupKey: key,
|
|
853
|
+
onChange: onChange,
|
|
854
|
+
config: config,
|
|
855
|
+
selectedClassification: product[key]
|
|
856
|
+
}, key);
|
|
857
|
+
})
|
|
858
|
+
});
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
862
|
+
var _config$className;
|
|
863
|
+
|
|
864
|
+
var config = _ref.config;
|
|
865
|
+
return /*#__PURE__*/jsx("div", {
|
|
866
|
+
className: 'diva-pdp-action-icon ' + ((_config$className = config.className) !== null && _config$className !== void 0 ? _config$className : ''),
|
|
867
|
+
children: config.action && /*#__PURE__*/jsx(PdpAction, {
|
|
868
|
+
config: config.action
|
|
869
|
+
})
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
var UiElemet = function UiElemet(_ref) {
|
|
874
|
+
var _content$containers;
|
|
875
|
+
|
|
876
|
+
var content = _ref.content,
|
|
877
|
+
product = _ref.product,
|
|
878
|
+
productVariants = _ref.productVariants,
|
|
879
|
+
selectProduct = _ref.selectProduct;
|
|
880
|
+
|
|
881
|
+
switch (content.id) {
|
|
882
|
+
case 'GALLERY':
|
|
883
|
+
return /*#__PURE__*/jsx(Gallery, {
|
|
884
|
+
config: content,
|
|
885
|
+
product: product
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
case 'TEXT':
|
|
889
|
+
return /*#__PURE__*/jsx(Text, {
|
|
890
|
+
config: content
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
case 'PRICE':
|
|
894
|
+
return /*#__PURE__*/jsx(Price, {
|
|
895
|
+
config: content,
|
|
896
|
+
addedPrice: product.addedPrice,
|
|
897
|
+
discountedPrice: product.discountedPrice
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
case 'INFO':
|
|
901
|
+
return /*#__PURE__*/jsx(Info, {
|
|
902
|
+
config: content
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
case 'ACTIONS':
|
|
906
|
+
return /*#__PURE__*/jsx(Actions, {
|
|
907
|
+
config: content
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
case 'VARIANTS':
|
|
911
|
+
return /*#__PURE__*/jsx(Variants, {
|
|
912
|
+
config: content,
|
|
913
|
+
products: productVariants,
|
|
914
|
+
onChange: selectProduct,
|
|
915
|
+
product: product
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
case 'ACTIONICON':
|
|
919
|
+
return /*#__PURE__*/jsx(ActionIcon, {
|
|
920
|
+
config: content
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
default:
|
|
924
|
+
return /*#__PURE__*/jsx("div", {
|
|
925
|
+
id: content.id,
|
|
926
|
+
className: content.className,
|
|
927
|
+
children: !!('containers' in content) && ((_content$containers = content.containers) === null || _content$containers === void 0 ? void 0 : _content$containers.map(function (c, i) {
|
|
928
|
+
return /*#__PURE__*/jsx(UiElemet, {
|
|
929
|
+
content: c,
|
|
930
|
+
product: product,
|
|
931
|
+
productVariants: productVariants,
|
|
932
|
+
selectProduct: selectProduct
|
|
933
|
+
}, i);
|
|
934
|
+
}))
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
940
|
+
|
|
941
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Filters the content based on the current settings
|
|
945
|
+
*
|
|
946
|
+
* @param content the content to filter
|
|
947
|
+
* @param isMobile if the device is mobile
|
|
948
|
+
* @param isPortrait if the device is in portrait mode
|
|
949
|
+
*/
|
|
950
|
+
function filterContent(content, isMobile, isPortrait) {
|
|
951
|
+
if (typeof content !== 'string' && 'containers' in content) {
|
|
952
|
+
var filteredContainer = [];
|
|
953
|
+
|
|
954
|
+
for (var i = 0; content.containers && i < content.containers.length; i++) {
|
|
955
|
+
var innerContent = filterContent(content.containers[i], isMobile, isPortrait);
|
|
956
|
+
if (innerContent) filteredContainer.push(innerContent);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
if (filteredContainer.length === 0) return null;
|
|
960
|
+
return _objectSpread$3(_objectSpread$3({}, content), {}, {
|
|
961
|
+
containers: filteredContainer
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
if (isVisible(content, isMobile, isPortrait)) {
|
|
966
|
+
return content;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Checks if an element should be filtered out, based on the current settings
|
|
973
|
+
*
|
|
974
|
+
* @param content the content to check
|
|
975
|
+
* @param isMobile if the device is mobile
|
|
976
|
+
* @param isPortrait if the device is in portrait mode
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
function isVisible(content, isMobile, isPortrait) {
|
|
980
|
+
var _content$onlyFor, _content$onlyFor2, _content$onlyFor3, _content$onlyFor4;
|
|
981
|
+
|
|
982
|
+
if (typeof content == 'string') {
|
|
983
|
+
return true;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if ((_content$onlyFor = content.onlyFor) !== null && _content$onlyFor !== void 0 && _content$onlyFor.includes('DESKTOP') && isMobile) return false;
|
|
987
|
+
if ((_content$onlyFor2 = content.onlyFor) !== null && _content$onlyFor2 !== void 0 && _content$onlyFor2.includes('LANDSCAPE') && (!isMobile || !isPortrait)) return false;
|
|
988
|
+
if ((_content$onlyFor3 = content.onlyFor) !== null && _content$onlyFor3 !== void 0 && _content$onlyFor3.includes('MOBILE') && !isMobile) return false;
|
|
989
|
+
if ((_content$onlyFor4 = content.onlyFor) !== null && _content$onlyFor4 !== void 0 && _content$onlyFor4.includes('PORTRAIT') && !isPortrait) return false;
|
|
990
|
+
return true;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Replaces the template strings in the content with the actual product data
|
|
995
|
+
*
|
|
996
|
+
* @param content the content to parse
|
|
997
|
+
* @param product the product data to use
|
|
998
|
+
* @param language the language to use
|
|
999
|
+
*/
|
|
1000
|
+
function replaceTemplateStrings (content, product, language) {
|
|
1001
|
+
if (typeof content == 'string') return content;
|
|
1002
|
+
var flatProduct = flatten(product);
|
|
1003
|
+
return recursiveReplaceTemplates(content, flatProduct, language);
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Replaces the template string in all fields of the content object with the actual product data
|
|
1007
|
+
*
|
|
1008
|
+
* @param content the content to parse
|
|
1009
|
+
* @param product the flattend version of the product data
|
|
1010
|
+
*/
|
|
1011
|
+
|
|
1012
|
+
function recursiveReplaceTemplates(content, product, language) {
|
|
1013
|
+
for (var _i = 0, _Object$entries = Object.entries(content); _i < _Object$entries.length; _i++) {
|
|
1014
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
1015
|
+
_key = _Object$entries$_i[0],
|
|
1016
|
+
value = _Object$entries$_i[1];
|
|
1017
|
+
|
|
1018
|
+
if (typeof content[_key] === 'string') {
|
|
1019
|
+
content[_key] = replaceTemplateString(value, product, language);
|
|
1020
|
+
} else if (_typeof(content[_key]) === 'object') {
|
|
1021
|
+
//check if the object is a language dictionary, if so replace it with the value for the current language
|
|
1022
|
+
var keys = Object.keys(content[_key]);
|
|
1023
|
+
|
|
1024
|
+
if (keys.includes(language) || keys.includes('de')) {
|
|
1025
|
+
var _content$_key$languag;
|
|
1026
|
+
|
|
1027
|
+
content[_key] = replaceTemplateString((_content$_key$languag = content[_key][language]) !== null && _content$_key$languag !== void 0 ? _content$_key$languag : content[_key].de, product, language);
|
|
1028
|
+
} else {
|
|
1029
|
+
content[_key] = recursiveReplaceTemplates(content[_key], product, language);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
return content;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* replaces the templates in on string with the actual product data
|
|
1038
|
+
*
|
|
1039
|
+
* @param template the templatestring to parse
|
|
1040
|
+
* @param product the flattend version of the product data
|
|
1041
|
+
* @param locale the locale to use, if any
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
1044
|
+
function replaceTemplateString(template, product, locale) {
|
|
1045
|
+
var matches = checkForTemplateStrings(template);
|
|
1046
|
+
|
|
1047
|
+
for (var _i2 = 0, _matches = matches; _i2 < _matches.length; _i2++) {
|
|
1048
|
+
var _product$locale, _product, _product2;
|
|
1049
|
+
|
|
1050
|
+
var match = _matches[_i2];
|
|
1051
|
+
//if a locale is provided, check if there is a locale version of the field (fallback is 'de'), if not use the default
|
|
1052
|
+
var productField = match.replace('product.', '');
|
|
1053
|
+
var value = void 0;
|
|
1054
|
+
if (locale) value = (_product$locale = (_product = product[productField + '_locales']) === null || _product === void 0 ? void 0 : _product[locale]) !== null && _product$locale !== void 0 ? _product$locale : (_product2 = product[productField + '_locales']) === null || _product2 === void 0 ? void 0 : _product2.de;
|
|
1055
|
+
if (!value) value = product[productField];
|
|
1056
|
+
if (value) template = template.replace('${' + match + '}', value);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
return template;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Extracts all substrings that are inside ${...}
|
|
1063
|
+
*
|
|
1064
|
+
* @param input the template to parse
|
|
1065
|
+
* @returns a list of values extracted form the template
|
|
1066
|
+
*/
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
function checkForTemplateStrings(input) {
|
|
1070
|
+
// Regular expression to match ${...}
|
|
1071
|
+
var regex = /\$\{([^}]+)\}/g;
|
|
1072
|
+
var matches = [];
|
|
1073
|
+
var match; // Find all matches
|
|
1074
|
+
|
|
1075
|
+
while ((match = regex.exec(input)) !== null) {
|
|
1076
|
+
// Extract the content inside ${...}
|
|
1077
|
+
matches.push(match[1]);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
return matches;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1084
|
+
|
|
1085
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Replaces the references in the content with the actual content
|
|
1089
|
+
* @param content the current content to parse
|
|
1090
|
+
* @param fullContent the full content to look for references
|
|
1091
|
+
*/
|
|
1092
|
+
function resolveReferences(content, fullContent) {
|
|
1093
|
+
if (typeof content == 'string') {
|
|
1094
|
+
var ref = getContentById(content, fullContent);
|
|
1095
|
+
|
|
1096
|
+
if (!ref) {
|
|
1097
|
+
throw new Error("Reference ".concat(content, " not found"));
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
return ref;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if ('containers' in content) {
|
|
1104
|
+
var _content$containers;
|
|
1105
|
+
|
|
1106
|
+
//resolve references in containers
|
|
1107
|
+
var container = (_content$containers = content.containers) !== null && _content$containers !== void 0 ? _content$containers : [];
|
|
1108
|
+
var parsedContainer = [];
|
|
1109
|
+
|
|
1110
|
+
for (var i = 0; i < container.length; i++) {
|
|
1111
|
+
var element = resolveReferences(container[i], fullContent);
|
|
1112
|
+
parsedContainer.push(element);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
return _objectSpread$2(_objectSpread$2({}, content), {}, {
|
|
1116
|
+
containers: parsedContainer
|
|
1117
|
+
});
|
|
1118
|
+
} else if ('actions' in content) {
|
|
1119
|
+
var _content$actions;
|
|
1120
|
+
|
|
1121
|
+
//resolve references in actions arrays, i.e. ActionGroupConfig
|
|
1122
|
+
var actions = (_content$actions = content.actions) !== null && _content$actions !== void 0 ? _content$actions : [];
|
|
1123
|
+
|
|
1124
|
+
for (var _i = 0; _i < actions.length; _i++) {
|
|
1125
|
+
var openMenu = actions[_i].openMenu;
|
|
1126
|
+
|
|
1127
|
+
if (openMenu) {
|
|
1128
|
+
openMenu.content = resolveReferences(openMenu.content, fullContent);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
return content;
|
|
1133
|
+
} else if ('action' in content) {
|
|
1134
|
+
var _content$action;
|
|
1135
|
+
|
|
1136
|
+
//resolve references in single action, i.e. ActionIconConfig, VariantsConfig
|
|
1137
|
+
if ((_content$action = content.action) !== null && _content$action !== void 0 && _content$action.openMenu) {
|
|
1138
|
+
content.action.openMenu.content = resolveReferences(content.action.openMenu.content, fullContent);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
return content;
|
|
1142
|
+
} else {
|
|
1143
|
+
return content;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Recursive find a content element by id
|
|
1148
|
+
*
|
|
1149
|
+
* @param id the id of the element to find
|
|
1150
|
+
* @param content the root content element
|
|
1151
|
+
* @throws an error if the id is not found
|
|
1152
|
+
*/
|
|
1153
|
+
|
|
1154
|
+
function getContentById(id, content) {
|
|
1155
|
+
if (typeof content != 'string') {
|
|
1156
|
+
if (content.id === id) {
|
|
1157
|
+
return content;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if ('containers' in content && content.containers) {
|
|
1161
|
+
for (var i = 0; i < content.containers.length; i++) {
|
|
1162
|
+
var result = getContentById(id, content.containers[i]);
|
|
1163
|
+
if (result) return result;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Make sure that the CSS is in the dome and that it has the current content
|
|
1173
|
+
*
|
|
1174
|
+
* @param url an url to a css file
|
|
1175
|
+
* @param css the css content as text
|
|
1176
|
+
*/
|
|
1177
|
+
|
|
1178
|
+
function updateCssInDom (url, css) {
|
|
1179
|
+
if (url) {
|
|
1180
|
+
var element = document.getElementById('DIVA-PDP-STYLE-URL');
|
|
1181
|
+
|
|
1182
|
+
if (element) {
|
|
1183
|
+
var _element$parentNode;
|
|
1184
|
+
|
|
1185
|
+
(_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : _element$parentNode.removeChild(element);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
element = document.createElement('link');
|
|
1189
|
+
element.rel = 'stylesheet';
|
|
1190
|
+
element.type = 'text/css';
|
|
1191
|
+
element.id = 'DIVA-PDP-STYLE-URL';
|
|
1192
|
+
element.href = url;
|
|
1193
|
+
document.head.appendChild(element);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
if (css) {
|
|
1197
|
+
var finalCss = Array.isArray(css) ? css.join(' ') : css;
|
|
1198
|
+
|
|
1199
|
+
var _element = document.getElementById('DIVA-PDP-STYLE');
|
|
1200
|
+
|
|
1201
|
+
if (_element) {
|
|
1202
|
+
var _element$parentNode2;
|
|
1203
|
+
|
|
1204
|
+
(_element$parentNode2 = _element.parentNode) === null || _element$parentNode2 === void 0 ? void 0 : _element$parentNode2.removeChild(_element);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
_element = document.createElement('style');
|
|
1208
|
+
_element.type = 'text/css';
|
|
1209
|
+
_element.id = 'DIVA-PDP-STYLE';
|
|
1210
|
+
|
|
1211
|
+
_element.appendChild(document.createTextNode(finalCss));
|
|
1212
|
+
|
|
1213
|
+
document.head.appendChild(_element);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1218
|
+
|
|
1219
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1220
|
+
/**
|
|
1221
|
+
* Replace the configurated actions with an onClick function
|
|
1222
|
+
*
|
|
1223
|
+
* Needs to be called after the references are resolved, but before the templates are replaced.
|
|
1224
|
+
* The onClick function accepts a product id, which can differ from the current product, so the translation has to be done in the function
|
|
1225
|
+
*
|
|
1226
|
+
* @param content the content to replace the actions in
|
|
1227
|
+
* @param productVariants the current product variants, needed for the side menu renderer
|
|
1228
|
+
* @param product the current product, needed for the side menu renderer and the is also passed with the event
|
|
1229
|
+
* @param language the language to use, needed to translated the action
|
|
1230
|
+
* @param selectProduct the function to select a product, needed for the side menu renderer
|
|
1231
|
+
* @param openComponentFunction the function to open a component, called when an action with openComponent config is clicked
|
|
1232
|
+
* @param onEventFunction the function to handle an event, called when an action with onEvent config is clicked, the current product is passed with the event
|
|
1233
|
+
* @param openSideMenuFunction the function to open a side menu, called when an action with openMenu config is clicked, a side menu is opened with the rendered content
|
|
1234
|
+
*/
|
|
1235
|
+
|
|
1236
|
+
function replaceActions (content, productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction) {
|
|
1237
|
+
if (typeof content == 'string') return content;
|
|
1238
|
+
return recursiveReplaceActions(content, productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction);
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Recursively replace the actions in the content with an onClick function
|
|
1242
|
+
*
|
|
1243
|
+
* @param content the content to replace the actions in
|
|
1244
|
+
* @param productVariants the current product variants
|
|
1245
|
+
* @param product the current product
|
|
1246
|
+
* @param language the language to use
|
|
1247
|
+
* @param selectProduct the function to select a product
|
|
1248
|
+
* @param openComponentFunction the function to open a component
|
|
1249
|
+
* @param onEventFunction the function to handle an event
|
|
1250
|
+
* @param openSideMenuFunction the function to open a side menu
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
function recursiveReplaceActions(content, productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction) {
|
|
1254
|
+
var keys = Object.keys(content);
|
|
1255
|
+
var openComponent = undefined;
|
|
1256
|
+
var onEvent = undefined;
|
|
1257
|
+
var openMenu = undefined;
|
|
1258
|
+
|
|
1259
|
+
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
1260
|
+
var _key = _keys[_i];
|
|
1261
|
+
|
|
1262
|
+
if (_key === 'openComponent') {
|
|
1263
|
+
openComponent = content[_key];
|
|
1264
|
+
delete content[_key];
|
|
1265
|
+
} else if (_key === 'onEvent') {
|
|
1266
|
+
onEvent = content[_key];
|
|
1267
|
+
delete content[_key];
|
|
1268
|
+
} else if (_key === 'openMenu') {
|
|
1269
|
+
openMenu = content[_key];
|
|
1270
|
+
delete content[_key];
|
|
1271
|
+
} else if (_typeof(content[_key]) === 'object') {
|
|
1272
|
+
content[_key] = recursiveReplaceActions(content[_key], productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
if (openComponent || onEvent || openMenu) {
|
|
1277
|
+
content['onClick'] = function (e, productId) {
|
|
1278
|
+
var _productVariants$find;
|
|
1279
|
+
|
|
1280
|
+
var currentProduct = (_productVariants$find = productVariants.find(function (variant) {
|
|
1281
|
+
return variant._id === productId;
|
|
1282
|
+
})) !== null && _productVariants$find !== void 0 ? _productVariants$find : product;
|
|
1283
|
+
var flatProduct = flatten$1(currentProduct);
|
|
1284
|
+
|
|
1285
|
+
if (openComponent) {
|
|
1286
|
+
var translatedOpenComponent = recursiveReplaceTemplates(openComponent, flatProduct, language);
|
|
1287
|
+
openComponentFunction(translatedOpenComponent);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (onEvent) {
|
|
1291
|
+
onEventFunction({
|
|
1292
|
+
type: onEvent,
|
|
1293
|
+
data: currentProduct
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
if (openMenu) {
|
|
1298
|
+
var translatedOpenMenu = recursiveReplaceTemplates(openMenu, flatProduct, language);
|
|
1299
|
+
openSideMenuFunction(_objectSpread$1(_objectSpread$1({}, translatedOpenMenu), {}, {
|
|
1300
|
+
content: /*#__PURE__*/React.createElement(UiElemet, {
|
|
1301
|
+
content: translatedOpenMenu.content,
|
|
1302
|
+
product: currentProduct,
|
|
1303
|
+
productVariants: productVariants,
|
|
1304
|
+
selectProduct: selectProduct
|
|
1305
|
+
})
|
|
1306
|
+
}));
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
return content;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
var LOG = getLogger('PDP', 'useDetailPage');
|
|
1315
|
+
function useDetailPage(_ref) {
|
|
1316
|
+
var settings = _ref.settings,
|
|
1317
|
+
productData = _ref.productData,
|
|
1318
|
+
productId = _ref.productId;
|
|
1319
|
+
|
|
1320
|
+
var _useDivaCore = useDivaCore(),
|
|
1321
|
+
_useDivaCore$state$di = _useDivaCore.state.dimensions,
|
|
1322
|
+
isMobile = _useDivaCore$state$di.isMobile,
|
|
1323
|
+
isPortrait = _useDivaCore$state$di.isPortrait,
|
|
1324
|
+
_useDivaCore$actions = _useDivaCore.actions,
|
|
1325
|
+
onEvent = _useDivaCore$actions.onEvent,
|
|
1326
|
+
openComponent = _useDivaCore$actions.openComponent,
|
|
1327
|
+
openSideMenu = _useDivaCore$actions.openSideMenu,
|
|
1328
|
+
handler = _useDivaCore.handler;
|
|
1329
|
+
|
|
1330
|
+
var _useTranslation = useTranslation(),
|
|
1331
|
+
i18n = _useTranslation.i18n;
|
|
1332
|
+
|
|
1333
|
+
var _useState = useState(true),
|
|
1334
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1335
|
+
loading = _useState2[0],
|
|
1336
|
+
setLoading = _useState2[1];
|
|
1337
|
+
|
|
1338
|
+
var _useState3 = useState(false),
|
|
1339
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1340
|
+
error = _useState4[0],
|
|
1341
|
+
setError = _useState4[1];
|
|
1342
|
+
|
|
1343
|
+
var _useState5 = useState(undefined),
|
|
1344
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1345
|
+
currentProduct = _useState6[0],
|
|
1346
|
+
setCurrentProduct = _useState6[1];
|
|
1347
|
+
|
|
1348
|
+
var _useState7 = useState([]),
|
|
1349
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1350
|
+
productVariants = _useState8[0],
|
|
1351
|
+
setProductVariants = _useState8[1];
|
|
1352
|
+
|
|
1353
|
+
var _useState9 = useState(null),
|
|
1354
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
1355
|
+
parsedContent = _useState10[0],
|
|
1356
|
+
setParsedContent = _useState10[1];
|
|
1357
|
+
|
|
1358
|
+
useEffect(function () {
|
|
1359
|
+
updateCssInDom(settings.cssUrl, settings.css);
|
|
1360
|
+
}, [settings.cssUrl, settings.css]);
|
|
1361
|
+
useEffect(function () {
|
|
1362
|
+
if (!productId) throw new Error('productId is required');
|
|
1363
|
+
(function () {
|
|
1364
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(productId) {
|
|
1365
|
+
var newVariants, products;
|
|
1366
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1367
|
+
while (1) {
|
|
1368
|
+
switch (_context.prev = _context.next) {
|
|
1369
|
+
case 0:
|
|
1370
|
+
setError(false);
|
|
1371
|
+
setLoading(true);
|
|
1372
|
+
_context.prev = 2;
|
|
1373
|
+
|
|
1374
|
+
if (!productData) {
|
|
1375
|
+
_context.next = 8;
|
|
1376
|
+
break;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
setProductVariants(productData);
|
|
1380
|
+
newVariants = productData;
|
|
1381
|
+
_context.next = 13;
|
|
1382
|
+
break;
|
|
1383
|
+
|
|
1384
|
+
case 8:
|
|
1385
|
+
_context.next = 10;
|
|
1386
|
+
return handler.productHandler.apiGetProductVariants(productId, true);
|
|
1387
|
+
|
|
1388
|
+
case 10:
|
|
1389
|
+
products = _context.sent;
|
|
1390
|
+
setProductVariants(products);
|
|
1391
|
+
newVariants = products;
|
|
1392
|
+
|
|
1393
|
+
case 13:
|
|
1394
|
+
selectProduct(productId, newVariants);
|
|
1395
|
+
_context.next = 20;
|
|
1396
|
+
break;
|
|
1397
|
+
|
|
1398
|
+
case 16:
|
|
1399
|
+
_context.prev = 16;
|
|
1400
|
+
_context.t0 = _context["catch"](2);
|
|
1401
|
+
//TODO: show the diva error page?
|
|
1402
|
+
LOG.error(new DivaError('Error loading products', {
|
|
1403
|
+
cause: _context.t0
|
|
1404
|
+
}));
|
|
1405
|
+
setError(true);
|
|
1406
|
+
|
|
1407
|
+
case 20:
|
|
1408
|
+
_context.prev = 20;
|
|
1409
|
+
setLoading(false);
|
|
1410
|
+
return _context.finish(20);
|
|
1411
|
+
|
|
1412
|
+
case 23:
|
|
1413
|
+
case "end":
|
|
1414
|
+
return _context.stop();
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}, _callee, null, [[2, 16, 20, 23]]);
|
|
1418
|
+
}));
|
|
1419
|
+
|
|
1420
|
+
return function (_x) {
|
|
1421
|
+
return _ref2.apply(this, arguments);
|
|
1422
|
+
};
|
|
1423
|
+
})()(productId);
|
|
1424
|
+
}, [productData, productId]);
|
|
1425
|
+
useEffect(function () {
|
|
1426
|
+
if (!currentProduct) return;
|
|
1427
|
+
|
|
1428
|
+
try {
|
|
1429
|
+
var _parsedContent = parseContent(isMobile, isPortrait, productVariants, currentProduct, i18n.language, selectProduct, openComponent, onEvent, openSideMenu, settings.content);
|
|
1430
|
+
|
|
1431
|
+
if (!_parsedContent) {
|
|
1432
|
+
LOG.warn('No content to render, check the configuration');
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
setParsedContent(_parsedContent);
|
|
1436
|
+
} catch (e) {
|
|
1437
|
+
LOG.error(new DivaError('Error parsing content', {
|
|
1438
|
+
cause: e
|
|
1439
|
+
}));
|
|
1440
|
+
setError(true);
|
|
1441
|
+
}
|
|
1442
|
+
}, [settings.content, isMobile, isPortrait, currentProduct, i18n.language]);
|
|
1443
|
+
var selectProduct = useCallback(function (productId, newVariants) {
|
|
1444
|
+
var currentProduct = (newVariants !== null && newVariants !== void 0 ? newVariants : productVariants).find(function (p) {
|
|
1445
|
+
return p._id === productId;
|
|
1446
|
+
});
|
|
1447
|
+
|
|
1448
|
+
if (!currentProduct) {
|
|
1449
|
+
LOG.error(new DivaError('Product not found', {
|
|
1450
|
+
cause: error
|
|
1451
|
+
}));
|
|
1452
|
+
setError(true);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
setCurrentProduct(currentProduct);
|
|
1456
|
+
}, [productVariants]);
|
|
1457
|
+
return {
|
|
1458
|
+
loading: loading,
|
|
1459
|
+
error: error,
|
|
1460
|
+
content: parsedContent,
|
|
1461
|
+
productVariants: productVariants,
|
|
1462
|
+
product: currentProduct,
|
|
1463
|
+
selectProduct: selectProduct,
|
|
1464
|
+
isMobile: isMobile,
|
|
1465
|
+
isPortrait: isPortrait
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Takes the content from the configuration and processes it to render in the ui.
|
|
1470
|
+
* This includes replacing references and filtering out elements that should not be rendered
|
|
1471
|
+
*
|
|
1472
|
+
* @param content the content to parse
|
|
1473
|
+
* @param isMobile if the device is mobile
|
|
1474
|
+
* @param isPortrait if the device is in portrait mode
|
|
1475
|
+
* @param product the product data to use
|
|
1476
|
+
* @param language the language to use
|
|
1477
|
+
*/
|
|
1478
|
+
|
|
1479
|
+
function parseContent(isMobile, isPortrait, productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction, content) {
|
|
1480
|
+
var finalContent = null;
|
|
1481
|
+
|
|
1482
|
+
if (content) {
|
|
1483
|
+
var clonedContent = cloneDeep(content);
|
|
1484
|
+
var pureContent = resolveReferences(clonedContent, content);
|
|
1485
|
+
var filteredContent = filterContent(pureContent, isMobile, isPortrait);
|
|
1486
|
+
if (!filteredContent) return null;
|
|
1487
|
+
var withActionsContent = replaceActions(filteredContent, productVariants, product, language, selectProduct, openComponentFunction, onEventFunction, openSideMenuFunction);
|
|
1488
|
+
finalContent = replaceTemplateStrings(withActionsContent, product, language);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
return finalContent;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
var MainComponent = function MainComponent(props) {
|
|
1495
|
+
var _useDetailPage = useDetailPage(props),
|
|
1496
|
+
product = _useDetailPage.product,
|
|
1497
|
+
productVariants = _useDetailPage.productVariants,
|
|
1498
|
+
loading = _useDetailPage.loading,
|
|
1499
|
+
error = _useDetailPage.error,
|
|
1500
|
+
content = _useDetailPage.content,
|
|
1501
|
+
selectProduct = _useDetailPage.selectProduct;
|
|
1502
|
+
|
|
1503
|
+
if (error) return /*#__PURE__*/jsx("div", {
|
|
1504
|
+
children: "error"
|
|
1505
|
+
});
|
|
1506
|
+
if (loading || !product || !content) return /*#__PURE__*/jsx(Fragment, {});
|
|
1507
|
+
return /*#__PURE__*/jsx("div", {
|
|
1508
|
+
id: 'DIVA-PDP-' + (product === null || product === void 0 ? void 0 : product._id),
|
|
1509
|
+
className: 'diva-pdp',
|
|
1510
|
+
children: /*#__PURE__*/jsx(UiElemet, {
|
|
1511
|
+
content: content,
|
|
1512
|
+
product: product,
|
|
1513
|
+
productVariants: productVariants,
|
|
1514
|
+
selectProduct: selectProduct
|
|
1515
|
+
})
|
|
1516
|
+
});
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1520
|
+
|
|
1521
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1522
|
+
|
|
1523
|
+
var Main = function Main(_ref) {
|
|
1524
|
+
var settings = _ref.settings,
|
|
1525
|
+
parameters = _ref.parameters,
|
|
1526
|
+
internal = _ref.internal;
|
|
1527
|
+
return /*#__PURE__*/jsx(MainComponent, {
|
|
1528
|
+
settings: settings,
|
|
1529
|
+
productData: internal === null || internal === void 0 ? void 0 : internal.productData,
|
|
1530
|
+
productId: parameters === null || parameters === void 0 ? void 0 : parameters.id
|
|
1531
|
+
});
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
var ProductDetailPageComponent = function ProductDetailPageComponent(props) {
|
|
1535
|
+
return /*#__PURE__*/jsx(MainComponent, _objectSpread({}, props));
|
|
1536
|
+
};
|
|
1537
|
+
var ProductDetailPage = {
|
|
1538
|
+
name: 'PRODUCTDETAILPAGE',
|
|
1539
|
+
renderFunction: Main
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
export { ProductDetailPageComponent, ProductDetailPage as default };
|