@crystaldesign/widget-image-carousel 25.11.0-beta.30 → 25.11.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/index.js +52 -18
- package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts +2 -1
- package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-prod.stories.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/types/index.d.ts +8 -0
- package/build/types/widget-image-carousel/src/types/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/useImageCarousel.d.ts.map +1 -1
- package/build/umd/report.html +1 -1
- package/build/umd/widget-image-carousel.umd.min.js +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
-
import { useCss, useProductData, ActionGroup, Action, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
|
|
3
|
+
import { useCss, useProductData, replaceTemplatesInObject, ActionGroup, Action, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
|
|
4
4
|
import { useDivaCore, useTranslation } from '@crystaldesign/diva-core';
|
|
5
5
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
6
6
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
7
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
8
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
8
9
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
9
10
|
import { Navigation } from 'swiper/modules';
|
|
10
11
|
import classNames from 'classnames';
|
|
@@ -44,6 +45,8 @@ function useImageCarousel(_ref) {
|
|
|
44
45
|
setError = _useState6[1];
|
|
45
46
|
var _useDivaCore = useDivaCore(),
|
|
46
47
|
openComponent = _useDivaCore.actions.openComponent;
|
|
48
|
+
var _useTranslation = useTranslation(),
|
|
49
|
+
i18n = _useTranslation.i18n;
|
|
47
50
|
useCss(settings);
|
|
48
51
|
var _useProductData = useProductData({
|
|
49
52
|
productIds: productIds,
|
|
@@ -55,11 +58,18 @@ function useImageCarousel(_ref) {
|
|
|
55
58
|
setSelectedProductId = _useProductData.setSelectedProductId,
|
|
56
59
|
selectedProduct = _useProductData.selectedProduct,
|
|
57
60
|
setProductCache = _useProductData.setProductCache,
|
|
58
|
-
getSimpleProductListByIds = _useProductData.getSimpleProductListByIds
|
|
61
|
+
getSimpleProductListByIds = _useProductData.getSimpleProductListByIds,
|
|
62
|
+
productVariants = _useProductData.productVariants;
|
|
59
63
|
var onClickProduct = useCallback(function (productId) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if (settings.openComponent) {
|
|
65
|
+
var clonedSettings = cloneDeep(settings);
|
|
66
|
+
var product = productVariants.find(function (p) {
|
|
67
|
+
return p._id === productId;
|
|
68
|
+
});
|
|
69
|
+
if (product) {
|
|
70
|
+
var action = replaceTemplatesInObject(clonedSettings.openComponent, product, i18n.language);
|
|
71
|
+
openComponent(action);
|
|
72
|
+
}
|
|
63
73
|
} else {
|
|
64
74
|
setSelectedProductId(productId);
|
|
65
75
|
if (!settings.disableScrollToTop) {
|
|
@@ -69,17 +79,7 @@ function useImageCarousel(_ref) {
|
|
|
69
79
|
});
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
|
-
}, [setSelectedProductId, settings.
|
|
73
|
-
var openConfigurator = function openConfigurator(productId) {
|
|
74
|
-
openComponent({
|
|
75
|
-
type: 'DIVA_WEBPLANNER',
|
|
76
|
-
parameters: {
|
|
77
|
-
productId: productId
|
|
78
|
-
},
|
|
79
|
-
openInFullscreen: true,
|
|
80
|
-
absoluteFullscreen: true
|
|
81
|
-
});
|
|
82
|
-
};
|
|
82
|
+
}, [setSelectedProductId, settings.openComponent, productVariants]);
|
|
83
83
|
useEffect(function () {
|
|
84
84
|
var loadMockups = /*#__PURE__*/function () {
|
|
85
85
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -536,7 +536,7 @@ var InfoElementComponent = function InfoElementComponent(_ref) {
|
|
|
536
536
|
media = _ref.media;
|
|
537
537
|
switch (infoElement.type) {
|
|
538
538
|
case 'text':
|
|
539
|
-
return /*#__PURE__*/jsx("
|
|
539
|
+
return /*#__PURE__*/jsx("span", {
|
|
540
540
|
className: infoElement.className,
|
|
541
541
|
children: (_media$infoElements = media.infoElements) === null || _media$infoElements === void 0 ? void 0 : _media$infoElements[(_infoElement$text = infoElement.text) !== null && _infoElement$text !== void 0 ? _infoElement$text : '']
|
|
542
542
|
});
|
|
@@ -564,6 +564,37 @@ function CallToAction(_ref2) {
|
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
+
function styleInject(css, ref) {
|
|
568
|
+
if ( ref === void 0 ) ref = {};
|
|
569
|
+
var insertAt = ref.insertAt;
|
|
570
|
+
|
|
571
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
572
|
+
|
|
573
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
574
|
+
var style = document.createElement('style');
|
|
575
|
+
style.type = 'text/css';
|
|
576
|
+
|
|
577
|
+
if (insertAt === 'top') {
|
|
578
|
+
if (head.firstChild) {
|
|
579
|
+
head.insertBefore(style, head.firstChild);
|
|
580
|
+
} else {
|
|
581
|
+
head.appendChild(style);
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
head.appendChild(style);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (style.styleSheet) {
|
|
588
|
+
style.styleSheet.cssText = css;
|
|
589
|
+
} else {
|
|
590
|
+
style.appendChild(document.createTextNode(css));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var slideInfoElement = "slideInfoElement-hvOw3";
|
|
595
|
+
var css_248z = ".imageCarouselContainer-5xR1Z {\n width: 100%;\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 20px;\n}\n\n.imageCarousel-doGe7 {\n height: 100%;\n width: 100%;\n}\n\n.slide-kzTjO {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n}\n\n.slideImage-25uCG {\n max-height: 100%;\n max-width: 100%;\n -o-object-fit: contain;\n object-fit: contain;\n cursor: pointer;\n}\n\n.slideDescriptionImage-qebF3 {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 100%;\n}\n\n.slideDescriptionImage-qebF3 img {\n cursor: pointer;\n display: block;\n width: 100%;\n max-height: 75%;\n height: auto;\n -o-object-fit: contain;\n object-fit: contain;\n}\n\n.slideDescription-UOsb1 {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 25%;\n background: lightgrey;\n color: black;\n text-align: center;\n}\n\n.slideDescription-UOsb1 span {\n font-size: 26px;\n}\n\n.slideInfoElement-hvOw3 {\n display: flex;\n flex-direction: column;\n}\n";
|
|
596
|
+
styleInject(css_248z);
|
|
597
|
+
|
|
567
598
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
568
599
|
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
569
600
|
var SwiperComponent = function SwiperComponent(_ref) {
|
|
@@ -584,6 +615,9 @@ var SwiperComponent = function SwiperComponent(_ref) {
|
|
|
584
615
|
var _settings$infoElement, _settings$openConfigu, _settings$openConfigu2, _settings$infoElement2, _settings$openConfigu3, _settings$openConfigu4;
|
|
585
616
|
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
586
617
|
className: classNames(['diva-widget-image-carousel-slide']),
|
|
618
|
+
onClick: function onClick() {
|
|
619
|
+
return onClickProduct(m.productId);
|
|
620
|
+
},
|
|
587
621
|
children: (_settings$infoElement = settings.infoElements) !== null && _settings$infoElement !== void 0 && _settings$infoElement.length ? /*#__PURE__*/jsxs("div", {
|
|
588
622
|
className: classNames(['diva-widget-image-carousel-slide-description-image']),
|
|
589
623
|
onClick: function onClick() {
|
|
@@ -608,7 +642,7 @@ var SwiperComponent = function SwiperComponent(_ref) {
|
|
|
608
642
|
return onClickProduct(m.productId);
|
|
609
643
|
}
|
|
610
644
|
}), /*#__PURE__*/jsx("div", {
|
|
611
|
-
className: classNames(['diva-widget-image-carousel-slide-info']),
|
|
645
|
+
className: classNames([slideInfoElement, 'diva-widget-image-carousel-slide-info']),
|
|
612
646
|
children: (_settings$infoElement2 = settings.infoElements) === null || _settings$infoElement2 === void 0 ? void 0 : _settings$infoElement2.map(function (infoElement) {
|
|
613
647
|
return /*#__PURE__*/jsx(InfoElementComponent, {
|
|
614
648
|
infoElement: infoElement,
|
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import 'swiper/css';
|
|
3
3
|
import 'swiper/css/navigation';
|
|
4
4
|
import { Configuration, Media } from '@crystaldesign/widget-image-carousel/types';
|
|
5
|
+
import { Action } from '@crystaldesign/diva-core';
|
|
5
6
|
interface SwiperComponentProps {
|
|
6
7
|
media: Media[];
|
|
7
8
|
settings: Configuration;
|
|
8
|
-
onClickProduct: (id: string) => void;
|
|
9
|
+
onClickProduct: (id: string, openComponent?: Action) => void;
|
|
9
10
|
isMobile: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare const SwiperComponent: React.FC<SwiperComponentProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Swiper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,YAAY,CAAC;AACpB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAe,KAAK,EAAE,MAAM,4CAA4C,CAAC;AAI/F,UAAU,oBAAoB;IAC5B,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Swiper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,YAAY,CAAC;AACpB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAe,KAAK,EAAE,MAAM,4CAA4C,CAAC;AAI/F,OAAO,EAAE,MAAM,EAAe,MAAM,0BAA0B,CAAC;AAE/D,UAAU,oBAAoB;IAC5B,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAuD1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kirchner-prod.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/stories/SimpleProductList/kirchner-prod.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAmBhD,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"kirchner-prod.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/stories/SimpleProductList/kirchner-prod.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAmBhD,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAuFxD,eAAO,MAAM,aAAa,EAAE,KAE3B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Action } from '@crystaldesign/diva-core';
|
|
1
2
|
import { ActionConfig, ActionGroupConfig, BaseConfiguration } from '@crystaldesign/widget-library';
|
|
2
3
|
import { SwiperProps } from 'swiper/react';
|
|
3
4
|
export interface ImageCarouselProps {
|
|
@@ -20,6 +21,13 @@ export interface Configuration extends BaseConfiguration {
|
|
|
20
21
|
ctaText?: string;
|
|
21
22
|
ctaIcon?: string;
|
|
22
23
|
};
|
|
24
|
+
openComponent?: Action;
|
|
25
|
+
}
|
|
26
|
+
export interface InfoElement {
|
|
27
|
+
type: 'text' | 'cta';
|
|
28
|
+
text?: string;
|
|
29
|
+
className: string;
|
|
30
|
+
action?: ActionConfig | ActionGroupConfig;
|
|
23
31
|
}
|
|
24
32
|
export interface InfoElement {
|
|
25
33
|
type: 'text' | 'cta';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,IAAI,EAAE,cAAc,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,mBAAmB,CAAC,EAAE;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,c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IACzC,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageCarousel.d.ts","sourceRoot":"","sources":["../../../../src/useImageCarousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useImageCarousel.d.ts","sourceRoot":"","sources":["../../../../src/useImageCarousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAMjE,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,kBAAkB;;;;gCA2B7D,MAAM;EA+MrB"}
|