@liquidcommercedev/rmn-sdk 1.5.0-beta.6 → 1.5.0-beta.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +104 -43
- package/dist/index.esm.js +104 -43
- package/dist/types/modules/event/event.service.d.ts +1 -0
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/dist/index.cjs
CHANGED
@@ -15560,11 +15560,13 @@ const CAROUSEL_COMPONENT_STYLE = ({ width, height, fluid }) => `
|
|
15560
15560
|
position: relative;
|
15561
15561
|
height: 100%;
|
15562
15562
|
width: 100%;
|
15563
|
+
display: flex;
|
15564
|
+
transition: transform 0.5s ease-in-out;
|
15563
15565
|
}
|
15564
15566
|
|
15565
15567
|
.slide {
|
15566
|
-
|
15567
|
-
|
15568
|
+
flex: 0 0 100%;
|
15569
|
+
display: flex;
|
15568
15570
|
justify-content: center;
|
15569
15571
|
align-items: center;
|
15570
15572
|
height: 100%;
|
@@ -15869,9 +15871,9 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15869
15871
|
renderSlides() {
|
15870
15872
|
const slidesContainer = document.createElement('div');
|
15871
15873
|
slidesContainer.className = 'slides';
|
15872
|
-
this.slides.forEach((slide
|
15874
|
+
this.slides.forEach((slide) => {
|
15873
15875
|
const slideElement = document.createElement('div');
|
15874
|
-
slideElement.className =
|
15876
|
+
slideElement.className = 'slide';
|
15875
15877
|
if (slide instanceof HTMLElement) {
|
15876
15878
|
slideElement.appendChild(slide);
|
15877
15879
|
}
|
@@ -15950,10 +15952,9 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15950
15952
|
updateCarousel() {
|
15951
15953
|
if (!this.slidesContainer)
|
15952
15954
|
return;
|
15953
|
-
|
15954
|
-
|
15955
|
-
|
15956
|
-
});
|
15955
|
+
// Calculate the translation distance based on current slide
|
15956
|
+
const translateX = -this.currentSlide * 100;
|
15957
|
+
this.slidesContainer.style.transform = `translateX(${translateX}%)`;
|
15957
15958
|
this.updateDots();
|
15958
15959
|
}
|
15959
15960
|
updateDots() {
|
@@ -16377,12 +16378,13 @@ function spotHtmlStringToElement(htmlString) {
|
|
16377
16378
|
spot.className = 'spot';
|
16378
16379
|
spot.innerHTML = htmlString;
|
16379
16380
|
Object.assign(spot.style, {
|
16380
|
-
position: 'relative',
|
16381
16381
|
display: 'block',
|
16382
16382
|
width: '100%',
|
16383
16383
|
height: '100%',
|
16384
16384
|
margin: '0',
|
16385
16385
|
padding: '0',
|
16386
|
+
containerType: 'inline-size',
|
16387
|
+
position: 'relative',
|
16386
16388
|
});
|
16387
16389
|
return spot;
|
16388
16390
|
}
|
@@ -17252,7 +17254,6 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17252
17254
|
box-sizing: border-box;
|
17253
17255
|
color: ${textColor};
|
17254
17256
|
cursor: pointer;
|
17255
|
-
container-type: inline-size;
|
17256
17257
|
}
|
17257
17258
|
|
17258
17259
|
.${prefix}__text {
|
@@ -17268,7 +17269,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17268
17269
|
.${prefix}__header {
|
17269
17270
|
font-size: 24px;
|
17270
17271
|
margin: 0;
|
17271
|
-
font-family: "Cormorant";
|
17272
|
+
font-family: "Cormorant", system-ui;
|
17272
17273
|
font-style: normal;
|
17273
17274
|
font-weight: 300;
|
17274
17275
|
line-height: normal;
|
@@ -17387,7 +17388,6 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17387
17388
|
height: 100%;
|
17388
17389
|
display: block;
|
17389
17390
|
position: relative;
|
17390
|
-
container-type: inline-size;
|
17391
17391
|
}
|
17392
17392
|
|
17393
17393
|
.${prefix}__content {
|
@@ -17578,15 +17578,20 @@ function rbHomepageHeroThreeTileTemplate(spot, config) {
|
|
17578
17578
|
const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextColor = textColor, primaryImage, mobilePrimaryImage = primaryImage, }, { prefix }) => `
|
17579
17579
|
<style>
|
17580
17580
|
.${prefix} {
|
17581
|
+
width: 100%;
|
17582
|
+
height: 100%;
|
17583
|
+
background-color: transparent;
|
17584
|
+
cursor: pointer;
|
17585
|
+
position: relative;
|
17586
|
+
}
|
17587
|
+
|
17588
|
+
.${prefix}__content {
|
17581
17589
|
width: 100%;
|
17582
17590
|
height: 100%;
|
17583
17591
|
display: flex;
|
17584
17592
|
flex-direction: column-reverse;
|
17585
17593
|
background-color: transparent;
|
17586
17594
|
gap: 6px;
|
17587
|
-
cursor: pointer;
|
17588
|
-
container-type: inline-size;
|
17589
|
-
position: relative;
|
17590
17595
|
}
|
17591
17596
|
|
17592
17597
|
.${prefix}__image {
|
@@ -17617,7 +17622,7 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17617
17622
|
font-size: 18px;
|
17618
17623
|
margin: 0;
|
17619
17624
|
color: inherit;
|
17620
|
-
font-family: "Cormorant";
|
17625
|
+
font-family: "Cormorant", system-ui;
|
17621
17626
|
font-style: normal;
|
17622
17627
|
font-weight: 700;
|
17623
17628
|
line-height: normal;
|
@@ -17659,7 +17664,7 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17659
17664
|
}
|
17660
17665
|
|
17661
17666
|
@container (min-width: 768px) {
|
17662
|
-
.${prefix} {
|
17667
|
+
.${prefix}__content {
|
17663
17668
|
flex-direction: row;
|
17664
17669
|
}
|
17665
17670
|
.${prefix}__image {
|
@@ -17714,12 +17719,14 @@ function rbHomepageHeroTwoTileTemplate(spot, config) {
|
|
17714
17719
|
${GFONT_CORMORANT}
|
17715
17720
|
${STYLES$4(spot, config)}
|
17716
17721
|
<div class="${prefix}">
|
17717
|
-
|
17718
|
-
|
17719
|
-
|
17720
|
-
|
17721
|
-
|
17722
|
-
|
17722
|
+
<div class="${prefix}__content">
|
17723
|
+
<div class="${prefix}__text">
|
17724
|
+
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17725
|
+
${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
|
17726
|
+
${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
|
17727
|
+
</div>
|
17728
|
+
<div class="${prefix}__image"></div>
|
17729
|
+
</div>
|
17723
17730
|
</div>
|
17724
17731
|
`;
|
17725
17732
|
}
|
@@ -17742,12 +17749,10 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17742
17749
|
overflow: hidden;
|
17743
17750
|
cursor: pointer;
|
17744
17751
|
color: ${textColor};
|
17745
|
-
container-type: inline-size;
|
17746
17752
|
}
|
17747
17753
|
|
17748
17754
|
.${prefix}__text {
|
17749
17755
|
padding: 20px;
|
17750
|
-
width: 70%;
|
17751
17756
|
display: flex;
|
17752
17757
|
flex-direction: column;
|
17753
17758
|
justify-content: center;
|
@@ -17759,7 +17764,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17759
17764
|
color: inherit;
|
17760
17765
|
margin: 0;
|
17761
17766
|
font-size: 20px;
|
17762
|
-
font-family: "Cormorant";
|
17767
|
+
font-family: "Cormorant", system-ui;
|
17763
17768
|
font-style: normal;
|
17764
17769
|
font-weight: 300;
|
17765
17770
|
line-height: normal;
|
@@ -17878,7 +17883,6 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17878
17883
|
background-size: cover;
|
17879
17884
|
background-position: center;
|
17880
17885
|
background-repeat: no-repeat;
|
17881
|
-
container-type: inline-size;
|
17882
17886
|
position: relative;
|
17883
17887
|
}
|
17884
17888
|
|
@@ -17948,12 +17952,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17948
17952
|
border-radius: 5px;
|
17949
17953
|
overflow: hidden;
|
17950
17954
|
cursor: pointer;
|
17951
|
-
|
17952
|
-
}
|
17953
|
-
|
17954
|
-
.${prefix}__text {
|
17955
|
-
padding: 10px;
|
17956
|
-
width: 70%;
|
17955
|
+
position: relative;
|
17957
17956
|
}
|
17958
17957
|
|
17959
17958
|
.${prefix}__header {
|
@@ -17964,6 +17963,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17964
17963
|
font-style: normal;
|
17965
17964
|
font-weight: 400;
|
17966
17965
|
margin: 0;
|
17966
|
+
padding: 10px;
|
17967
17967
|
}
|
17968
17968
|
|
17969
17969
|
@container (min-width: 640px) {
|
@@ -17981,9 +17981,7 @@ function rbSmallCategoryImageToutTemplate(spot, config) {
|
|
17981
17981
|
${GFONT_CORMORANT}
|
17982
17982
|
${STYLES$1(spot, config)}
|
17983
17983
|
<div class="${prefix}">
|
17984
|
-
|
17985
|
-
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17986
|
-
</div>
|
17984
|
+
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17987
17985
|
</div>
|
17988
17986
|
`;
|
17989
17987
|
}
|
@@ -17998,7 +17996,6 @@ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primar
|
|
17998
17996
|
display: flex;
|
17999
17997
|
flex-direction: column;
|
18000
17998
|
border-radius: 5px;
|
18001
|
-
container-type: inline-size;
|
18002
17999
|
}
|
18003
18000
|
|
18004
18001
|
.${prefix}__image {
|
@@ -18388,11 +18385,38 @@ class EventService {
|
|
18388
18385
|
},
|
18389
18386
|
};
|
18390
18387
|
}
|
18391
|
-
this.
|
18388
|
+
const merged = this.deepMerge(currentState, updates);
|
18389
|
+
this.spotStates.set(placementId, merged);
|
18392
18390
|
if (publish) {
|
18393
18391
|
this.pubSub.publish(exports.RMN_SPOT_EVENT.LIFECYCLE_STATE, this.spotStates.get(placementId));
|
18394
18392
|
}
|
18395
18393
|
}
|
18394
|
+
deepMerge(current, updates) {
|
18395
|
+
return {
|
18396
|
+
identifier: {
|
18397
|
+
...current.identifier,
|
18398
|
+
...updates.identifier,
|
18399
|
+
},
|
18400
|
+
dom: updates.dom
|
18401
|
+
? {
|
18402
|
+
...current.dom,
|
18403
|
+
...updates.dom,
|
18404
|
+
}
|
18405
|
+
: current.dom,
|
18406
|
+
state: updates.state
|
18407
|
+
? {
|
18408
|
+
...current.state,
|
18409
|
+
...updates.state,
|
18410
|
+
}
|
18411
|
+
: current.state,
|
18412
|
+
displayConfig: updates.displayConfig
|
18413
|
+
? {
|
18414
|
+
...current.displayConfig,
|
18415
|
+
...updates.displayConfig,
|
18416
|
+
}
|
18417
|
+
: current.displayConfig,
|
18418
|
+
};
|
18419
|
+
}
|
18396
18420
|
async handleClick({ placementId, spot, spotElement, }) {
|
18397
18421
|
var _a, _b, _c;
|
18398
18422
|
// Publish click event
|
@@ -18747,10 +18771,12 @@ class LiquidCommerceRmnClient {
|
|
18747
18771
|
const config = params.config;
|
18748
18772
|
let inject = params.inject;
|
18749
18773
|
if (!inject.length) {
|
18774
|
+
// Handle no spots error state
|
18750
18775
|
this.eventService.handleSpotState('all', {
|
18751
18776
|
state: {
|
18752
18777
|
error: 'No spot elements provided for injection.',
|
18753
18778
|
loading: false,
|
18779
|
+
mounted: false,
|
18754
18780
|
},
|
18755
18781
|
});
|
18756
18782
|
return;
|
@@ -18769,9 +18795,12 @@ class LiquidCommerceRmnClient {
|
|
18769
18795
|
// const response = await this.useSpotSelectionExample(inject);
|
18770
18796
|
// Handle the response
|
18771
18797
|
if (typeof response === 'object' && 'error' in response) {
|
18798
|
+
// Handle request error state
|
18772
18799
|
this.eventService.handleSpotState('all', {
|
18773
18800
|
state: {
|
18774
18801
|
error: response.error,
|
18802
|
+
mounted: false,
|
18803
|
+
loading: false,
|
18775
18804
|
},
|
18776
18805
|
});
|
18777
18806
|
return;
|
@@ -18780,9 +18809,11 @@ class LiquidCommerceRmnClient {
|
|
18780
18809
|
const itemConfig = (_a = item.config) !== null && _a !== void 0 ? _a : config;
|
18781
18810
|
const spots = response[item.placementId];
|
18782
18811
|
if (!(spots === null || spots === void 0 ? void 0 : spots.length)) {
|
18812
|
+
// Handle no spots found error state
|
18783
18813
|
this.eventService.handleSpotState(item.placementId, {
|
18784
18814
|
state: {
|
18785
18815
|
error: `No spots found for type "${item.spotType}".`,
|
18816
|
+
mounted: false,
|
18786
18817
|
loading: false,
|
18787
18818
|
},
|
18788
18819
|
});
|
@@ -18791,9 +18822,11 @@ class LiquidCommerceRmnClient {
|
|
18791
18822
|
const placementId = item.placementId.replace('#', '');
|
18792
18823
|
const placement = document.getElementById(placementId);
|
18793
18824
|
if (!placement) {
|
18825
|
+
// Handle placement not found error state
|
18794
18826
|
this.eventService.handleSpotState(item.placementId, {
|
18795
18827
|
state: {
|
18796
18828
|
error: `Placement not found for id "${placementId}".`,
|
18829
|
+
mounted: false,
|
18797
18830
|
loading: false,
|
18798
18831
|
},
|
18799
18832
|
});
|
@@ -18808,12 +18841,14 @@ class LiquidCommerceRmnClient {
|
|
18808
18841
|
display: 'flex',
|
18809
18842
|
justifyContent: 'center',
|
18810
18843
|
});
|
18844
|
+
// Handle single spot
|
18811
18845
|
if (spots.length === 1) {
|
18812
18846
|
const isInjected = this.injectOneSpotElement(item, placement, spots[0], itemConfig);
|
18813
18847
|
if (!isInjected) {
|
18814
18848
|
continue;
|
18815
18849
|
}
|
18816
18850
|
}
|
18851
|
+
// Handle multiple spots (carousel)
|
18817
18852
|
if (spots.length > 1) {
|
18818
18853
|
const isInjected = this.injectCarouselSpotElement(placement, spots, itemConfig);
|
18819
18854
|
if (!isInjected) {
|
@@ -18857,18 +18892,24 @@ class LiquidCommerceRmnClient {
|
|
18857
18892
|
const carouselSlides = [];
|
18858
18893
|
for (const spotItem of spots) {
|
18859
18894
|
this.eventService.handleSpotState(placement.id, {
|
18895
|
+
identifier: {
|
18896
|
+
placementId: placement.id,
|
18897
|
+
spotType: spotItem.spot,
|
18898
|
+
spotId: spotItem.id,
|
18899
|
+
},
|
18860
18900
|
displayConfig: {
|
18901
|
+
isSingleItem: false,
|
18861
18902
|
isCarousel: true,
|
18862
18903
|
isCarouselItem: true,
|
18863
|
-
isSingleItem: false,
|
18864
18904
|
},
|
18865
|
-
}
|
18905
|
+
});
|
18866
18906
|
const spot = this.elementService.overrideSpotColors(spotItem, config === null || config === void 0 ? void 0 : config.colors);
|
18867
18907
|
const content = SPOT_TEMPLATE_HTML_ELEMENT(spot, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
|
18868
18908
|
if (!content) {
|
18869
18909
|
this.eventService.handleSpotState(placement.id, {
|
18870
18910
|
state: {
|
18871
18911
|
error: `Failed to inject carousel spot item element. Could not create element for type "${spot.spot}".`,
|
18912
|
+
mounted: false,
|
18872
18913
|
loading: false,
|
18873
18914
|
},
|
18874
18915
|
});
|
@@ -18901,6 +18942,7 @@ class LiquidCommerceRmnClient {
|
|
18901
18942
|
this.eventService.handleSpotState(placement.id, {
|
18902
18943
|
state: {
|
18903
18944
|
error: `Failed to inject spot carousel element. Could not create spot carousel element.`,
|
18945
|
+
mounted: false,
|
18904
18946
|
loading: false,
|
18905
18947
|
},
|
18906
18948
|
});
|
@@ -18910,10 +18952,12 @@ class LiquidCommerceRmnClient {
|
|
18910
18952
|
this.eventService.handleSpotState(placement.id, {
|
18911
18953
|
dom: {
|
18912
18954
|
spotElement: carouselElement,
|
18955
|
+
visibleOnViewport: false,
|
18913
18956
|
},
|
18914
18957
|
state: {
|
18915
18958
|
mounted: true,
|
18916
18959
|
loading: false,
|
18960
|
+
error: undefined,
|
18917
18961
|
},
|
18918
18962
|
});
|
18919
18963
|
return true;
|
@@ -18930,18 +18974,25 @@ class LiquidCommerceRmnClient {
|
|
18930
18974
|
*/
|
18931
18975
|
injectOneSpotElement(injectItem, placement, spot, config) {
|
18932
18976
|
var _a;
|
18933
|
-
const spotData = this.elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
|
18934
18977
|
this.eventService.handleSpotState(injectItem.placementId, {
|
18978
|
+
identifier: {
|
18979
|
+
placementId: injectItem.placementId,
|
18980
|
+
spotType: injectItem.spotType,
|
18981
|
+
spotId: spot.id,
|
18982
|
+
},
|
18935
18983
|
displayConfig: {
|
18936
18984
|
isSingleItem: true,
|
18985
|
+
isCarousel: false,
|
18986
|
+
isCarouselItem: false,
|
18937
18987
|
},
|
18938
|
-
}
|
18939
|
-
|
18988
|
+
});
|
18989
|
+
const spotData = this.elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
|
18940
18990
|
const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
|
18941
18991
|
if (!content) {
|
18942
18992
|
this.eventService.handleSpotState(injectItem.placementId, {
|
18943
18993
|
state: {
|
18944
18994
|
error: `Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`,
|
18995
|
+
mounted: false,
|
18945
18996
|
loading: false,
|
18946
18997
|
},
|
18947
18998
|
});
|
@@ -18962,6 +19013,7 @@ class LiquidCommerceRmnClient {
|
|
18962
19013
|
this.eventService.handleSpotState(injectItem.placementId, {
|
18963
19014
|
state: {
|
18964
19015
|
error: `Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`,
|
19016
|
+
mounted: false,
|
18965
19017
|
loading: false,
|
18966
19018
|
},
|
18967
19019
|
});
|
@@ -18976,10 +19028,12 @@ class LiquidCommerceRmnClient {
|
|
18976
19028
|
this.eventService.handleSpotState(injectItem.placementId, {
|
18977
19029
|
dom: {
|
18978
19030
|
spotElement,
|
19031
|
+
visibleOnViewport: false,
|
18979
19032
|
},
|
18980
19033
|
state: {
|
18981
19034
|
mounted: true,
|
18982
19035
|
loading: false,
|
19036
|
+
error: undefined,
|
18983
19037
|
},
|
18984
19038
|
});
|
18985
19039
|
return true;
|
@@ -19000,6 +19054,8 @@ class LiquidCommerceRmnClient {
|
|
19000
19054
|
this.eventService.handleSpotState(item.placementId, {
|
19001
19055
|
state: {
|
19002
19056
|
error: `Duplicate placement id (${item.placementId}) found. Please provide a unique placement id for each spot element.`,
|
19057
|
+
mounted: false,
|
19058
|
+
loading: false,
|
19003
19059
|
},
|
19004
19060
|
});
|
19005
19061
|
return false;
|
@@ -19015,6 +19071,8 @@ class LiquidCommerceRmnClient {
|
|
19015
19071
|
this.eventService.handleSpotState(item.placementId, {
|
19016
19072
|
state: {
|
19017
19073
|
error: `Invalid spot type (${item.spotType}) found. Please provide a valid spot type for each spot element.`,
|
19074
|
+
mounted: false,
|
19075
|
+
loading: false,
|
19018
19076
|
},
|
19019
19077
|
});
|
19020
19078
|
continue;
|
@@ -19023,6 +19081,7 @@ class LiquidCommerceRmnClient {
|
|
19023
19081
|
}
|
19024
19082
|
return newInject;
|
19025
19083
|
}
|
19084
|
+
// Initialize spots with loading state and identifiers
|
19026
19085
|
updateSpotsState(inject) {
|
19027
19086
|
for (const item of inject) {
|
19028
19087
|
this.eventService.handleSpotState(item.placementId, {
|
@@ -19032,6 +19091,8 @@ class LiquidCommerceRmnClient {
|
|
19032
19091
|
},
|
19033
19092
|
state: {
|
19034
19093
|
loading: true,
|
19094
|
+
mounted: false,
|
19095
|
+
error: undefined,
|
19035
19096
|
},
|
19036
19097
|
});
|
19037
19098
|
}
|