@liquidcommercedev/rmn-sdk 1.4.4 → 1.4.5-beta.2

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/dist/index.esm.js CHANGED
@@ -15150,60 +15150,56 @@ class AuthService extends BaseApi {
15150
15150
  }
15151
15151
 
15152
15152
  const SPOT_ELEMENT_TAG = 'spot-element';
15153
+ const SPOT_ELEMENT_SLOT_NAME = `${SPOT_ELEMENT_TAG}-custom-content`;
15153
15154
  const SPOTS_SELECTION_API_PATH = '/spots/selection';
15154
- const SPOT_EVENT_API_PATH = '/spots/event';
15155
15155
 
15156
- const SPOT_ELEMENT_SHADOW_ROOT = (width, height, hasCustomHtmlElement) => {
15156
+ const GFONT_PRECONNECT = `
15157
+ <link rel="preconnect" href="https://fonts.googleapis.com">
15158
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
15159
+ `;
15160
+ const GFONT_SOURCE_SANS_3 = `
15161
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
15162
+ `;
15163
+ const GFONT_CORMORANT = `
15164
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
15165
+ `;
15166
+ const SPOT_ELEMENT_TEMPLATE = (width, height, hasCustomContent) => {
15157
15167
  const style = document.createElement('style');
15168
+ style.textContent = `
15169
+ :host {
15170
+ display: block;
15171
+ position: relative;
15172
+ container-type: inline-size;
15173
+ overflow: hidden;
15174
+ }
15175
+ :host([fluid="true"]) {
15176
+ width: 100%;
15177
+ height: 100%;
15178
+ }
15179
+ :host([fluid="false"]) {
15180
+ width: ${width}px;
15181
+ height: ${height}px;
15182
+ }
15183
+ `;
15158
15184
  const wrapper = document.createElement('div');
15159
15185
  wrapper.className = 'wrapper';
15160
- style.textContent = `
15161
- :host {
15162
- display: block;
15163
- position: relative;
15164
- container-type: inline-size;
15165
- overflow: hidden;
15166
- }
15167
- :host([fluid="true"]) {
15168
- width: 100%;
15169
- height: 100%;
15170
- }
15171
- :host([fluid="false"]) {
15172
- width: ${width}px;
15173
- height: ${height}px;
15174
- }
15186
+ const slot = document.createElement('slot');
15187
+ slot.name = SPOT_ELEMENT_SLOT_NAME;
15188
+ if (!hasCustomContent) {
15189
+ style.textContent += `
15190
+ :host .wrapper {
15191
+ position: absolute;
15192
+ top: 0;
15193
+ left: 0;
15194
+ width: 100%;
15195
+ height: 100%;
15196
+ overflow: hidden;
15197
+ }
15175
15198
  `;
15176
- if (hasCustomHtmlElement) {
15177
- return { style, wrapper };
15178
15199
  }
15179
- style.textContent += `
15180
- .wrapper {
15181
- position: absolute;
15182
- top: 0;
15183
- left: 0;
15184
- width: 100%;
15185
- height: 100%;
15186
- overflow: hidden;
15187
- }
15188
- `;
15189
- return { style, wrapper };
15200
+ return { style, wrapper, slot };
15190
15201
  };
15191
15202
 
15192
- const GFONT_PRECONNECT = () => `
15193
- <link rel="preconnect" href="https://fonts.googleapis.com">
15194
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
15195
- `;
15196
- const GFONT_SOURCE_SANS_3 = () => `
15197
- <link rel="stylesheet"
15198
- href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
15199
- >
15200
- `;
15201
- const GFONT_CORMORANT = () => `
15202
- <link rel="stylesheet"
15203
- href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
15204
- >
15205
- `;
15206
-
15207
15203
  const STYLES$i = ({ primaryImage, secondaryImage }) => `
15208
15204
  <style>
15209
15205
  .content {
@@ -15299,9 +15295,9 @@ const STYLES$i = ({ primaryImage, secondaryImage }) => `
15299
15295
  `;
15300
15296
  function billboardV1Template(spot) {
15301
15297
  return `
15302
- ${GFONT_PRECONNECT()}
15303
- ${GFONT_SOURCE_SANS_3()}
15304
- ${GFONT_CORMORANT()}
15298
+ ${GFONT_PRECONNECT}
15299
+ ${GFONT_SOURCE_SANS_3}
15300
+ ${GFONT_CORMORANT}
15305
15301
  ${STYLES$i(spot)}
15306
15302
  <div class="content">
15307
15303
  <div class="big-image"></div>
@@ -15388,9 +15384,9 @@ const STYLES$h = ({ primaryImage }) => `
15388
15384
  `;
15389
15385
  function billboardV2Template(spot) {
15390
15386
  return `
15391
- ${GFONT_PRECONNECT()}
15392
- ${GFONT_SOURCE_SANS_3()}
15393
- ${GFONT_CORMORANT()}
15387
+ ${GFONT_PRECONNECT}
15388
+ ${GFONT_SOURCE_SANS_3}
15389
+ ${GFONT_CORMORANT}
15394
15390
  ${STYLES$h(spot)}
15395
15391
  <div class="content">
15396
15392
  <div class="text-container">
@@ -15489,9 +15485,9 @@ const STYLES$g = ({ primaryImage }) => `
15489
15485
  `;
15490
15486
  function billboardV3Template(spot) {
15491
15487
  return `
15492
- ${GFONT_PRECONNECT()}
15493
- ${GFONT_SOURCE_SANS_3()}
15494
- ${GFONT_CORMORANT()}
15488
+ ${GFONT_PRECONNECT}
15489
+ ${GFONT_SOURCE_SANS_3}
15490
+ ${GFONT_CORMORANT}
15495
15491
  ${STYLES$g(spot)}
15496
15492
  <div class="content">
15497
15493
  <div class="text">
@@ -15533,9 +15529,9 @@ const STYLES$f = () => `
15533
15529
  `;
15534
15530
  function inTextV1Template(spot) {
15535
15531
  return `
15536
- ${GFONT_PRECONNECT()}
15537
- ${GFONT_SOURCE_SANS_3()}
15538
- ${GFONT_CORMORANT()}
15532
+ ${GFONT_PRECONNECT}
15533
+ ${GFONT_SOURCE_SANS_3}
15534
+ ${GFONT_CORMORANT}
15539
15535
  ${STYLES$f()}
15540
15536
  <div class="content">
15541
15537
  <span class="header">${spot.header}</span>
@@ -15623,9 +15619,9 @@ const STYLES$e = ({ primaryImage }) => `
15623
15619
  `;
15624
15620
  function largeLeaderboardV1Template(spot) {
15625
15621
  return `
15626
- ${GFONT_PRECONNECT()}
15627
- ${GFONT_SOURCE_SANS_3()}
15628
- ${GFONT_CORMORANT()}
15622
+ ${GFONT_PRECONNECT}
15623
+ ${GFONT_SOURCE_SANS_3}
15624
+ ${GFONT_CORMORANT}
15629
15625
  ${STYLES$e(spot)}
15630
15626
  <div class="content">
15631
15627
  <div class="text">
@@ -15710,9 +15706,9 @@ const STYLES$d = ({ primaryImage }) => `
15710
15706
  `;
15711
15707
  function largeLeaderboardV2Template(spot) {
15712
15708
  return `
15713
- ${GFONT_PRECONNECT()}
15714
- ${GFONT_SOURCE_SANS_3()}
15715
- ${GFONT_CORMORANT()}
15709
+ ${GFONT_PRECONNECT}
15710
+ ${GFONT_SOURCE_SANS_3}
15711
+ ${GFONT_CORMORANT}
15716
15712
  ${STYLES$d(spot)}
15717
15713
  <div class="content">
15718
15714
  <div class="text">
@@ -15769,9 +15765,9 @@ const STYLES$c = ({ primaryImage }) => `
15769
15765
  `;
15770
15766
  function largeRectangleV1Template(spot) {
15771
15767
  return `
15772
- ${GFONT_PRECONNECT()}
15773
- ${GFONT_SOURCE_SANS_3()}
15774
- ${GFONT_CORMORANT()}
15768
+ ${GFONT_PRECONNECT}
15769
+ ${GFONT_SOURCE_SANS_3}
15770
+ ${GFONT_CORMORANT}
15775
15771
  ${STYLES$c(spot)}
15776
15772
  <div class="content">
15777
15773
  <div class="image"></div>
@@ -15867,9 +15863,9 @@ const STYLES$b = ({ primaryImage }) => `
15867
15863
  `;
15868
15864
  function squareV1Template(spot) {
15869
15865
  return `
15870
- ${GFONT_PRECONNECT()}
15871
- ${GFONT_SOURCE_SANS_3()}
15872
- ${GFONT_CORMORANT()}
15866
+ ${GFONT_PRECONNECT}
15867
+ ${GFONT_SOURCE_SANS_3}
15868
+ ${GFONT_CORMORANT}
15873
15869
  ${STYLES$b(spot)}
15874
15870
  <div class="content">
15875
15871
  <div class="text">
@@ -15922,9 +15918,9 @@ const STYLES$a = ({ primaryImage }) => `
15922
15918
  `;
15923
15919
  function squareV2Template(spot) {
15924
15920
  return `
15925
- ${GFONT_PRECONNECT()}
15926
- ${GFONT_SOURCE_SANS_3()}
15927
- ${GFONT_CORMORANT()}
15921
+ ${GFONT_PRECONNECT}
15922
+ ${GFONT_SOURCE_SANS_3}
15923
+ ${GFONT_CORMORANT}
15928
15924
  ${STYLES$a(spot)}
15929
15925
  <div class="content">
15930
15926
  <span class="header">${spot.header}</span>
@@ -15987,9 +15983,9 @@ const STYLES$9 = ({ primaryImage }) => `
15987
15983
  `;
15988
15984
  function verticalRectangleV1Template(spot) {
15989
15985
  return `
15990
- ${GFONT_PRECONNECT()}
15991
- ${GFONT_SOURCE_SANS_3()}
15992
- ${GFONT_CORMORANT()}
15986
+ ${GFONT_PRECONNECT}
15987
+ ${GFONT_SOURCE_SANS_3}
15988
+ ${GFONT_CORMORANT}
15993
15989
  ${STYLES$9(spot)}
15994
15990
  <div class="content">
15995
15991
  <div class="text">
@@ -16051,7 +16047,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot) {
16051
16047
  `;
16052
16048
  }
16053
16049
 
16054
- const STYLES$6 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16050
+ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16055
16051
  <style>
16056
16052
  :host {
16057
16053
  min-width: 320px;
@@ -16169,9 +16165,9 @@ const STYLES$6 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor
16169
16165
  `;
16170
16166
  function rbHomepageHeroFullImageTemplate(spot) {
16171
16167
  return `
16172
- ${GFONT_PRECONNECT()}
16173
- ${GFONT_SOURCE_SANS_3()}
16174
- ${GFONT_CORMORANT()}
16168
+ ${GFONT_PRECONNECT}
16169
+ ${GFONT_SOURCE_SANS_3}
16170
+ ${GFONT_CORMORANT}
16175
16171
  ${STYLES$6(spot)}
16176
16172
  <div class="content">
16177
16173
  <div class="text">
@@ -16336,9 +16332,9 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
16336
16332
  `;
16337
16333
  function rbHomepageHeroThreeTileTemplate(spot) {
16338
16334
  return `
16339
- ${GFONT_PRECONNECT()}
16340
- ${GFONT_SOURCE_SANS_3()}
16341
- ${GFONT_CORMORANT()}
16335
+ ${GFONT_PRECONNECT}
16336
+ ${GFONT_SOURCE_SANS_3}
16337
+ ${GFONT_CORMORANT}
16342
16338
  ${STYLES$5(spot)}
16343
16339
  <div class="content">
16344
16340
  <div class="primary-image"></div>
@@ -16479,9 +16475,9 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
16479
16475
  `;
16480
16476
  function rbHomepageHeroTwoTileTemplate(spot) {
16481
16477
  return `
16482
- ${GFONT_PRECONNECT()}
16483
- ${GFONT_SOURCE_SANS_3()}
16484
- ${GFONT_CORMORANT()}
16478
+ ${GFONT_PRECONNECT}
16479
+ ${GFONT_SOURCE_SANS_3}
16480
+ ${GFONT_CORMORANT}
16485
16481
  ${STYLES$4(spot)}
16486
16482
  <div class="content">
16487
16483
  <div class="text">
@@ -16494,7 +16490,7 @@ function rbHomepageHeroTwoTileTemplate(spot) {
16494
16490
  `;
16495
16491
  }
16496
16492
 
16497
- const STYLES$3 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16493
+ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16498
16494
  <style>
16499
16495
  :host {
16500
16496
  min-width: 320px;
@@ -16601,9 +16597,9 @@ const STYLES$3 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor
16601
16597
  `;
16602
16598
  function rbLargeCategoryImageToutTemplate(spot) {
16603
16599
  return `
16604
- ${GFONT_PRECONNECT()}
16605
- ${GFONT_SOURCE_SANS_3()}
16606
- ${GFONT_CORMORANT()}
16600
+ ${GFONT_PRECONNECT}
16601
+ ${GFONT_SOURCE_SANS_3}
16602
+ ${GFONT_CORMORANT}
16607
16603
  ${STYLES$3(spot)}
16608
16604
  <div class="content">
16609
16605
  <div class="text">
@@ -16615,7 +16611,7 @@ function rbLargeCategoryImageToutTemplate(spot) {
16615
16611
  `;
16616
16612
  }
16617
16613
 
16618
- const STYLES$2 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16614
+ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16619
16615
  <style>
16620
16616
  :host {
16621
16617
  min-width: 320px;
@@ -16673,8 +16669,8 @@ const STYLES$2 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
16673
16669
  `;
16674
16670
  function rbNavigationBannerTemplate(spot) {
16675
16671
  return `
16676
- ${GFONT_PRECONNECT()}
16677
- ${GFONT_SOURCE_SANS_3()}
16672
+ ${GFONT_PRECONNECT}
16673
+ ${GFONT_SOURCE_SANS_3}
16678
16674
  ${STYLES$2(spot)}
16679
16675
  <div class="content">
16680
16676
  <div class="text">
@@ -16684,7 +16680,7 @@ function rbNavigationBannerTemplate(spot) {
16684
16680
  `;
16685
16681
  }
16686
16682
 
16687
- const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16683
+ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16688
16684
  <style>
16689
16685
  :host {
16690
16686
  min-width: 165px;
@@ -16716,6 +16712,7 @@ const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
16716
16712
  font-style: normal;
16717
16713
  font-weight: 400;
16718
16714
  line-height: normal;
16715
+ margin: 0;
16719
16716
  }
16720
16717
  @media (min-width: 640px) {
16721
16718
  .content {
@@ -16726,8 +16723,8 @@ const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
16726
16723
  `;
16727
16724
  function rbSmallCategoryImageToutTemplate(spot) {
16728
16725
  return `
16729
- ${GFONT_PRECONNECT()}
16730
- ${GFONT_CORMORANT()}
16726
+ ${GFONT_PRECONNECT}
16727
+ ${GFONT_CORMORANT}
16731
16728
  ${STYLES$1(spot)}
16732
16729
  <div class="content">
16733
16730
  <div class="text">
@@ -16737,7 +16734,7 @@ function rbSmallCategoryImageToutTemplate(spot) {
16737
16734
  `;
16738
16735
  }
16739
16736
 
16740
- const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16737
+ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16741
16738
  <style>
16742
16739
  :host {
16743
16740
  min-width: 165px;
@@ -16780,6 +16777,7 @@ const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryIm
16780
16777
  font-style: normal;
16781
16778
  font-weight: 400;
16782
16779
  line-height: normal;
16780
+ margin: 0;
16783
16781
  }
16784
16782
  @media (min-width: 640px) {
16785
16783
  .image {
@@ -16790,8 +16788,8 @@ const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryIm
16790
16788
  `;
16791
16789
  function rbSmallDiscoverToutTemplate(spot) {
16792
16790
  return `
16793
- ${GFONT_PRECONNECT()}
16794
- ${GFONT_CORMORANT()}
16791
+ ${GFONT_PRECONNECT}
16792
+ ${GFONT_CORMORANT}
16795
16793
  ${STYLES(spot)}
16796
16794
  <div class="content">
16797
16795
  <div class="image"></div>
@@ -16887,16 +16885,20 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16887
16885
  class CustomSpotElement extends HTMLElement {
16888
16886
  constructor() {
16889
16887
  super();
16888
+ this.hasCustomContent = false;
16889
+ this.handleClick = this.handleClick.bind(this);
16890
16890
  this.attachShadow({ mode: 'open' });
16891
16891
  }
16892
16892
  connectedCallback() {
16893
- this.addEventListener('click', () => this.registerEvent(RMN_SPOT_EVENT.CLICK));
16893
+ this.hasCustomContent = Boolean(this.customContent);
16894
+ this.addEventListener('click', this.handleClick);
16894
16895
  this.setupIntersectionObserver();
16895
16896
  this.render();
16896
16897
  }
16897
16898
  disconnectedCallback() {
16898
16899
  var _a;
16899
16900
  (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
16901
+ this.removeEventListener('click', this.handleClick);
16900
16902
  }
16901
16903
  attributeChangedCallback(_name, oldValue, newValue) {
16902
16904
  if (oldValue !== newValue) {
@@ -16906,14 +16908,26 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16906
16908
  render() {
16907
16909
  if (!this.shadowRoot || !this.data)
16908
16910
  return;
16909
- const { style, wrapper } = SPOT_ELEMENT_SHADOW_ROOT(this.data.width, this.data.height, Boolean(this.customHtmlElement));
16910
- if (this.customHtmlElement) {
16911
- wrapper.innerHTML = this.customHtmlElement.outerHTML;
16911
+ const { style, wrapper, slot } = SPOT_ELEMENT_TEMPLATE(this.data.width, this.data.height, this.hasCustomContent);
16912
+ this.shadowRoot.replaceChildren(style, slot);
16913
+ if (this.hasCustomContent) {
16914
+ this.setCustomContent();
16912
16915
  }
16913
- else {
16916
+ if (!this.hasCustomContent) {
16914
16917
  wrapper.innerHTML = GET_SPOT_TEMPLATE_HTML_STRING(this.data);
16918
+ this.shadowRoot.appendChild(wrapper);
16915
16919
  }
16916
- this.shadowRoot.replaceChildren(style, wrapper);
16920
+ }
16921
+ setCustomContent() {
16922
+ const wrapper = document.createElement('div');
16923
+ wrapper.setAttribute('slot', SPOT_ELEMENT_SLOT_NAME);
16924
+ if (typeof this.customContent === 'string') {
16925
+ wrapper.innerHTML = this.customContent;
16926
+ }
16927
+ if (this.customContent instanceof HTMLElement) {
16928
+ wrapper.appendChild(this.customContent);
16929
+ }
16930
+ this.appendChild(wrapper);
16917
16931
  }
16918
16932
  setupIntersectionObserver() {
16919
16933
  const options = {
@@ -16930,47 +16944,37 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16930
16944
  }, options);
16931
16945
  this.observer.observe(this);
16932
16946
  }
16947
+ handleClick() {
16948
+ this.registerEvent(RMN_SPOT_EVENT.CLICK);
16949
+ }
16933
16950
  async registerEvent(event) {
16934
16951
  var _a, _b;
16935
16952
  if (!this.data)
16936
16953
  return;
16937
16954
  const shouldRedirectOnClick = this.getAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK) === 'true';
16938
- const url = (_b = (_a = this.data.events.find((e) => e.event === event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
16955
+ const eventUrl = (_b = (_a = this.data.events.find((e) => e.event === event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
16939
16956
  try {
16940
16957
  const options = {
16941
16958
  method: 'POST',
16942
- redirect: 'manual',
16959
+ redirect: event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick ? 'follow' : 'manual',
16943
16960
  };
16944
- if (event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16945
- options.redirect = 'follow';
16946
- }
16947
- const normalizedUrl = this.normalizeUrl(url);
16948
- const response = await fetch(normalizedUrl, options);
16961
+ const response = await fetch(eventUrl, options);
16949
16962
  if (response.ok && event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16950
- window.location.href = this.getRedirectUrlFromPayload(normalizedUrl);
16963
+ window.location.href = this.getRedirectUrlFromPayload(eventUrl);
16951
16964
  }
16952
16965
  }
16953
16966
  catch (error) {
16954
16967
  console.error(`Rmn error sending ${event} event:`, error);
16955
16968
  }
16956
16969
  }
16957
- normalizeUrl(url) {
16958
- if (!this.data)
16959
- return url;
16960
- const rmnUrl = `${SDK_CONFIG.url[this.data.env]}/api${SPOT_EVENT_API_PATH}`;
16961
- return url.replace(/https?:\/\/[^/]+\/[^?]+/, `${rmnUrl}`);
16962
- }
16963
16970
  getRedirectUrlFromPayload(url) {
16964
- var _a;
16971
+ var _a, _b;
16965
16972
  const base64String = (_a = new URL(url).searchParams.get('e')) !== null && _a !== void 0 ? _a : '';
16966
16973
  try {
16967
- const obj = JSON.parse(atob(base64String));
16968
- if (obj.ur) {
16969
- return obj.ur;
16970
- }
16971
- return '';
16974
+ const data = JSON.parse(atob(base64String));
16975
+ return (_b = data.ur) !== null && _b !== void 0 ? _b : '';
16972
16976
  }
16973
- catch (_b) {
16977
+ catch (_c) {
16974
16978
  return '';
16975
16979
  }
16976
16980
  }
@@ -16991,7 +16995,7 @@ class SpotHtmlService {
16991
16995
  * @param {ISpot} spot - The spot data.
16992
16996
  * @param {ICreateSpotElementConfig} config - The configuration object.
16993
16997
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
16994
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
16998
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
16995
16999
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
16996
17000
  *
16997
17001
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17010,8 +17014,9 @@ class SpotHtmlService {
17010
17014
  element.setAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK, shouldRedirectOnClick.toString());
17011
17015
  // Share the spot data with the element
17012
17016
  element.data = spot;
17013
- if (config === null || config === void 0 ? void 0 : config.customHtmlElement) {
17014
- element.customHtmlElement = config.customHtmlElement;
17017
+ // Set custom content
17018
+ if (config === null || config === void 0 ? void 0 : config.customContent) {
17019
+ element.customContent = config.customContent;
17015
17020
  }
17016
17021
  return element;
17017
17022
  }
@@ -17052,22 +17057,10 @@ class SpotSelectionService extends BaseApi {
17052
17057
  if (isOk && val && val.data && (val === null || val === void 0 ? void 0 : val.refresh.token)) {
17053
17058
  this.authInfo.authenticated = true;
17054
17059
  this.authInfo.token = val.refresh.token;
17055
- let spots = val.data.spots;
17056
- spots = this.addEnvToSpotData(spots, this.authInfo.env);
17057
- return spots;
17060
+ return val.data.spots;
17058
17061
  }
17059
17062
  throw new Error('Spot selection response was not successful');
17060
17063
  }
17061
- addEnvToSpotData(spots, env) {
17062
- for (const key in spots) {
17063
- if (spots[key]) {
17064
- spots[key].forEach((spot) => {
17065
- spot.env = env;
17066
- });
17067
- }
17068
- }
17069
- return spots;
17070
- }
17071
17064
  }
17072
17065
 
17073
17066
  class LiquidCommerceRmnClient {
@@ -17095,7 +17088,7 @@ class LiquidCommerceRmnClient {
17095
17088
  * @param {ISpot} spot - The spot data.
17096
17089
  * @param {ICreateSpotElementConfig} config - The configuration object.
17097
17090
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17098
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17091
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17099
17092
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17100
17093
  *
17101
17094
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17127,7 +17120,7 @@ async function RmnClient(apiKey, config) {
17127
17120
  * @param {ISpot} spot - The spot data.
17128
17121
  * @param {ICreateSpotElementConfig} config - The configuration object.
17129
17122
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17130
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17123
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17131
17124
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17132
17125
  *
17133
17126
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -0,0 +1,8 @@
1
+ export declare const GFONT_PRECONNECT = "\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n";
2
+ export declare const GFONT_SOURCE_SANS_3 = "\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap\">\n";
3
+ export declare const GFONT_CORMORANT = "\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap\">\n";
4
+ export declare const SPOT_ELEMENT_TEMPLATE: (width: number, height: number, hasCustomContent: boolean) => {
5
+ style: HTMLStyleElement;
6
+ wrapper: HTMLDivElement;
7
+ slot: HTMLSlotElement;
8
+ };
@@ -0,0 +1 @@
1
+ export * from './html.constant';
@@ -1,7 +1,7 @@
1
1
  import type { ISpot } from 'types';
2
2
  export interface ICustomSpotElement extends HTMLElement {
3
3
  data?: ISpot;
4
- customHtmlElement?: HTMLElement;
4
+ customContent?: HTMLElement | string;
5
5
  }
6
6
  declare let SpotElement: new () => HTMLElement;
7
7
  export { SpotElement };
@@ -1,3 +1,4 @@
1
1
  export declare const SPOT_ELEMENT_TAG = "spot-element";
2
+ export declare const SPOT_ELEMENT_SLOT_NAME = "spot-element-custom-content";
2
3
  export declare const SPOTS_SELECTION_API_PATH = "/spots/selection";
3
4
  export declare const SPOT_EVENT_API_PATH = "/spots/event";
@@ -9,7 +9,7 @@ export declare class SpotHtmlService implements ISpotHtmlService {
9
9
  * @param {ISpot} spot - The spot data.
10
10
  * @param {ICreateSpotElementConfig} config - The configuration object.
11
11
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
12
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
12
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
13
13
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
14
14
  *
15
15
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -1,4 +1,3 @@
1
- import type { RMN_ENV } from './../../enums';
2
1
  import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from './spot.enum';
3
2
  import type { RmnFilterType, RmnSpotType, SpotIdentifierType, SpotVariantType } from './spot.type';
4
3
  export interface ISpotSelectionParams {
@@ -29,11 +28,10 @@ export interface ISpot {
29
28
  mobilePrimaryImage?: string;
30
29
  mobileSecondaryImage?: string;
31
30
  productUpcs?: string[];
32
- env: RMN_ENV;
33
31
  }
34
32
  export interface ICreateSpotElementConfig {
35
33
  fluid?: boolean;
36
- customHtmlElement?: HTMLElement;
34
+ customContent?: HTMLElement | string;
37
35
  redirectOnClick?: boolean;
38
36
  }
39
37
  export type ISpots = Record<SpotIdentifierType, ISpot[]>;
@@ -12,5 +12,4 @@ export declare class SpotSelectionService extends BaseApi implements ISpotSelect
12
12
  * @return {Promise<ISpots>} - The spots response object.
13
13
  */
14
14
  spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
15
- private addEnvToSpotData;
16
15
  }
@@ -23,7 +23,7 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
23
23
  * @param {ISpot} spot - The spot data.
24
24
  * @param {ICreateSpotElementConfig} config - The configuration object.
25
25
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
26
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
26
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
27
27
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
28
28
  *
29
29
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -49,7 +49,7 @@ declare function RmnClient(apiKey: string, config: IRmnConfig): Promise<IRmnClie
49
49
  * @param {ISpot} spot - The spot data.
50
50
  * @param {ICreateSpotElementConfig} config - The configuration object.
51
51
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
52
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
52
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
53
53
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
54
54
  *
55
55
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@liquidcommercedev/rmn-sdk",
3
3
  "description": "LiquidCommerce RMN SDK",
4
4
  "author": "LiquidCommerce Tech",
5
- "version": "1.4.4",
5
+ "version": "1.4.5-beta.2",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",