@liquidcommercedev/rmn-sdk 1.4.6-beta.2 → 1.4.6-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +567 -471
- package/dist/index.esm.js +567 -472
- package/dist/types/index.umd.d.ts +2 -2
- package/dist/types/modules/element/component/carousel/carousel.component.d.ts +3 -58
- package/dist/types/modules/element/component/carousel/carousel.interface.d.ts +31 -0
- package/dist/types/modules/element/component/carousel/carousel.style.d.ts +2 -1
- package/dist/types/modules/element/component/carousel/index.d.ts +1 -0
- package/dist/types/modules/element/component/spot/index.d.ts +2 -0
- package/dist/types/modules/element/component/spot/spot.component.d.ts +3 -0
- package/dist/types/modules/element/component/spot/spot.interface.d.ts +10 -0
- package/dist/types/modules/element/element.constant.d.ts +2 -1
- package/dist/types/modules/element/element.interface.d.ts +16 -18
- package/dist/types/modules/element/{spot.element.service.d.ts → element.service.d.ts} +15 -3
- package/dist/types/modules/element/index.d.ts +1 -1
- package/dist/types/modules/element/template/helper.d.ts +1 -0
- package/dist/types/modules/element/template/template.service.d.ts +1 -1
- package/dist/types/modules/event/helpers/resize.service.d.ts +1 -1
- package/dist/types/rmn-client.d.ts +21 -8
- package/dist/types/static.constant.d.ts +3 -0
- package/dist/types/types.d.ts +3 -3
- package/package.json +2 -2
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
- package/dist/types/modules/element/spot.element.d.ts +0 -2
package/dist/index.esm.js
CHANGED
@@ -15148,7 +15148,8 @@ class AuthService extends BaseApi {
|
|
15148
15148
|
}
|
15149
15149
|
}
|
15150
15150
|
|
15151
|
-
const
|
15151
|
+
const SPOT_ELEMENT_TAG = 'spot-element';
|
15152
|
+
const CAROUSEL_ELEMENT_TAG = 'spot-carousel-element';
|
15152
15153
|
const GFONT_PRECONNECT = `
|
15153
15154
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
15154
15155
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
@@ -15161,7 +15162,7 @@ const GFONT_CORMORANT = `
|
|
15161
15162
|
`;
|
15162
15163
|
|
15163
15164
|
class ResizeObserverService {
|
15164
|
-
constructor({ element, maxSize, minScale
|
15165
|
+
constructor({ element, maxSize, minScale }) {
|
15165
15166
|
this.element = element;
|
15166
15167
|
if (!element.parentElement) {
|
15167
15168
|
throw new Error('RmnSdk: Spot element must have a parent container.');
|
@@ -15228,6 +15229,431 @@ class ResizeObserverService {
|
|
15228
15229
|
}
|
15229
15230
|
}
|
15230
15231
|
|
15232
|
+
const CAROUSEL_COMPONENT_STYLE = ({ width, height, fluid }) => `
|
15233
|
+
:host {
|
15234
|
+
position: relative;
|
15235
|
+
display: inline-block;
|
15236
|
+
margin: 0;
|
15237
|
+
overflow: hidden;
|
15238
|
+
width: ${fluid ? '100%' : `${width}px`};
|
15239
|
+
height: ${fluid ? '100%' : `${height}px`};
|
15240
|
+
}
|
15241
|
+
|
15242
|
+
.slides {
|
15243
|
+
position: relative;
|
15244
|
+
height: 100%;
|
15245
|
+
width: 100%;
|
15246
|
+
}
|
15247
|
+
|
15248
|
+
.slide {
|
15249
|
+
display: none;
|
15250
|
+
|
15251
|
+
justify-content: center;
|
15252
|
+
align-items: center;
|
15253
|
+
height: 100%;
|
15254
|
+
width: 100%;
|
15255
|
+
}
|
15256
|
+
|
15257
|
+
.slide.active {
|
15258
|
+
display: flex;
|
15259
|
+
}
|
15260
|
+
|
15261
|
+
.dots {
|
15262
|
+
position: absolute;
|
15263
|
+
display: flex;
|
15264
|
+
align-items: center;
|
15265
|
+
gap: 8px;
|
15266
|
+
}
|
15267
|
+
|
15268
|
+
.dots .dot {
|
15269
|
+
width: 12px;
|
15270
|
+
height: 12px;
|
15271
|
+
border-radius: 50%;
|
15272
|
+
cursor: pointer;
|
15273
|
+
transition: all 0.3s ease;
|
15274
|
+
}
|
15275
|
+
|
15276
|
+
.dots.top-left,
|
15277
|
+
.dots.bottom-left {
|
15278
|
+
left: 10px;
|
15279
|
+
}
|
15280
|
+
|
15281
|
+
.dots.top-center,
|
15282
|
+
.dots.bottom-center {
|
15283
|
+
left: 50%;
|
15284
|
+
transform: translateX(-50%);
|
15285
|
+
}
|
15286
|
+
|
15287
|
+
.dots.top-right,
|
15288
|
+
.dots.bottom-right {
|
15289
|
+
right: 10px;
|
15290
|
+
}
|
15291
|
+
|
15292
|
+
.dots.top-left,
|
15293
|
+
.dots.top-center,
|
15294
|
+
.dots.top-right {
|
15295
|
+
top: 10px;
|
15296
|
+
}
|
15297
|
+
|
15298
|
+
.dots.bottom-left,
|
15299
|
+
.dots.bottom-center,
|
15300
|
+
.dots.bottom-right {
|
15301
|
+
bottom: 10px;
|
15302
|
+
}
|
15303
|
+
|
15304
|
+
.dots.middle-left {
|
15305
|
+
left: 10px;
|
15306
|
+
top: 50%;
|
15307
|
+
transform: translateY(-50%);
|
15308
|
+
flex-direction: column;
|
15309
|
+
}
|
15310
|
+
|
15311
|
+
.dots.middle-right {
|
15312
|
+
right: 10px;
|
15313
|
+
top: 50%;
|
15314
|
+
transform: translateY(-50%);
|
15315
|
+
flex-direction: column;
|
15316
|
+
}
|
15317
|
+
|
15318
|
+
.buttons button {
|
15319
|
+
background-color: #00000080;
|
15320
|
+
color: #fff;
|
15321
|
+
border: none;
|
15322
|
+
padding: 10px;
|
15323
|
+
cursor: pointer;
|
15324
|
+
transition: background-color 0.3s ease;
|
15325
|
+
}
|
15326
|
+
|
15327
|
+
.buttons button:hover {
|
15328
|
+
background-color: #000000b3;
|
15329
|
+
}
|
15330
|
+
|
15331
|
+
.buttons.buttons-separate button {
|
15332
|
+
position: absolute;
|
15333
|
+
top: 50%;
|
15334
|
+
transform: translateY(-50%);
|
15335
|
+
}
|
15336
|
+
|
15337
|
+
.buttons.buttons-separate .prev-button {
|
15338
|
+
left: 10px;
|
15339
|
+
}
|
15340
|
+
|
15341
|
+
.buttons.buttons-separate .next-button {
|
15342
|
+
right: 10px;
|
15343
|
+
}
|
15344
|
+
|
15345
|
+
.buttons.buttons-together {
|
15346
|
+
position: absolute;
|
15347
|
+
display: flex;
|
15348
|
+
gap: 10px;
|
15349
|
+
}
|
15350
|
+
|
15351
|
+
.buttons.buttons-together.top-left,
|
15352
|
+
.buttons.buttons-together.bottom-left {
|
15353
|
+
left: 10px;
|
15354
|
+
}
|
15355
|
+
|
15356
|
+
.buttons.buttons-together.top-center,
|
15357
|
+
.buttons.buttons-together.bottom-center {
|
15358
|
+
left: 50%;
|
15359
|
+
transform: translateX(-50%);
|
15360
|
+
}
|
15361
|
+
|
15362
|
+
.buttons.buttons-together.top-right,
|
15363
|
+
.buttons.buttons-together.bottom-right {
|
15364
|
+
right: 10px;
|
15365
|
+
}
|
15366
|
+
|
15367
|
+
.buttons.buttons-together.top-left,
|
15368
|
+
.buttons.buttons-together.top-center,
|
15369
|
+
.buttons.buttons-together.top-right {
|
15370
|
+
top: 10px;
|
15371
|
+
}
|
15372
|
+
|
15373
|
+
.buttons.buttons-together.bottom-left,
|
15374
|
+
.buttons.buttons-together.bottom-center,
|
15375
|
+
.buttons.buttons-together.bottom-right {
|
15376
|
+
bottom: 10px;
|
15377
|
+
}
|
15378
|
+
|
15379
|
+
.buttons.buttons-together.middle-left,
|
15380
|
+
.buttons.buttons-together.middle-right {
|
15381
|
+
top: 50%;
|
15382
|
+
transform: translateY(-50%);
|
15383
|
+
flex-direction: column;
|
15384
|
+
}
|
15385
|
+
|
15386
|
+
.buttons.buttons-together.middle-left {
|
15387
|
+
left: 10px;
|
15388
|
+
}
|
15389
|
+
|
15390
|
+
.buttons.buttons-together.middle-right {
|
15391
|
+
right: 10px;
|
15392
|
+
}
|
15393
|
+
|
15394
|
+
@media (max-width: 768px) {
|
15395
|
+
.buttons button {
|
15396
|
+
padding: 8px 12px;
|
15397
|
+
font-size: 14px;
|
15398
|
+
}
|
15399
|
+
|
15400
|
+
.dots .dot {
|
15401
|
+
width: 8px;
|
15402
|
+
height: 8px;
|
15403
|
+
}
|
15404
|
+
}
|
15405
|
+
`;
|
15406
|
+
|
15407
|
+
let CarouselElement;
|
15408
|
+
if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined') {
|
15409
|
+
class CustomCarouselElement extends HTMLElement {
|
15410
|
+
constructor() {
|
15411
|
+
super();
|
15412
|
+
this.currentSlide = 0;
|
15413
|
+
this.dotElements = [];
|
15414
|
+
this.prevButton = null;
|
15415
|
+
this.nextButton = null;
|
15416
|
+
this.autoplayInterval = null;
|
15417
|
+
this.useDots = false;
|
15418
|
+
this.useButtons = false;
|
15419
|
+
this.attachShadow({ mode: 'open' });
|
15420
|
+
}
|
15421
|
+
connectedCallback() {
|
15422
|
+
this.initializeOptions();
|
15423
|
+
this.setupResizeObserver();
|
15424
|
+
this.render();
|
15425
|
+
this.setupCarousel();
|
15426
|
+
}
|
15427
|
+
disconnectedCallback() {
|
15428
|
+
var _a;
|
15429
|
+
this.stopAutoplay();
|
15430
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
15431
|
+
}
|
15432
|
+
initializeOptions() {
|
15433
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
15434
|
+
this.useDots = ((_a = this.data) === null || _a === void 0 ? void 0 : _a.useDots) === true || typeof ((_b = this.data) === null || _b === void 0 ? void 0 : _b.useDots) === 'object';
|
15435
|
+
this.useButtons = ((_c = this.data) === null || _c === void 0 ? void 0 : _c.useButtons) === true || typeof ((_d = this.data) === null || _d === void 0 ? void 0 : _d.useButtons) === 'object';
|
15436
|
+
this.autoplay = (_f = (_e = this.data) === null || _e === void 0 ? void 0 : _e.autoplay) !== null && _f !== void 0 ? _f : true;
|
15437
|
+
this.interval = (_h = (_g = this.data) === null || _g === void 0 ? void 0 : _g.interval) !== null && _h !== void 0 ? _h : CustomCarouselElement.defaultInterval;
|
15438
|
+
this.dotsOptions = {
|
15439
|
+
position: 'bottom-center',
|
15440
|
+
color: '#d9d9d9',
|
15441
|
+
activeColor: '#b5914a',
|
15442
|
+
...(typeof ((_j = this.data) === null || _j === void 0 ? void 0 : _j.useDots) === 'object' ? this.data.useDots : {}),
|
15443
|
+
};
|
15444
|
+
this.buttonsOptions = {
|
15445
|
+
together: false,
|
15446
|
+
position: 'middle-sides',
|
15447
|
+
textColor: '#000000',
|
15448
|
+
backgroundColor: '#ffffff',
|
15449
|
+
borderRadius: '50%',
|
15450
|
+
prev: 'Prev',
|
15451
|
+
next: 'Next',
|
15452
|
+
...(typeof ((_k = this.data) === null || _k === void 0 ? void 0 : _k.useButtons) === 'object' ? this.data.useButtons : {}),
|
15453
|
+
};
|
15454
|
+
this.validateOptions();
|
15455
|
+
}
|
15456
|
+
setupResizeObserver() {
|
15457
|
+
if (this.data) {
|
15458
|
+
this.resizeObserver = new ResizeObserverService({
|
15459
|
+
element: this,
|
15460
|
+
maxSize: {
|
15461
|
+
width: this.data.width,
|
15462
|
+
height: this.data.height,
|
15463
|
+
},
|
15464
|
+
minScale: this.data.minScale,
|
15465
|
+
});
|
15466
|
+
this.addEventListener('spotSizeChanged', this.handleCarouselSizeChanged.bind(this));
|
15467
|
+
}
|
15468
|
+
}
|
15469
|
+
handleCarouselSizeChanged(event) {
|
15470
|
+
console.info('Carousel Size Changed', event);
|
15471
|
+
}
|
15472
|
+
render() {
|
15473
|
+
var _a;
|
15474
|
+
if (!this.shadowRoot)
|
15475
|
+
return;
|
15476
|
+
const style = document.createElement('style');
|
15477
|
+
style.textContent = CAROUSEL_COMPONENT_STYLE(this.data);
|
15478
|
+
this.shadowRoot.appendChild(style);
|
15479
|
+
const slides = this.renderSlides();
|
15480
|
+
this.shadowRoot.appendChild(slides);
|
15481
|
+
this.slidesContainer = (_a = this.shadowRoot.querySelector('.slides')) !== null && _a !== void 0 ? _a : undefined;
|
15482
|
+
if (this.useDots) {
|
15483
|
+
const dots = this.renderDots();
|
15484
|
+
if (dots)
|
15485
|
+
this.shadowRoot.appendChild(dots);
|
15486
|
+
}
|
15487
|
+
if (this.useButtons) {
|
15488
|
+
const buttons = this.renderButtons();
|
15489
|
+
if (buttons)
|
15490
|
+
this.shadowRoot.appendChild(buttons);
|
15491
|
+
}
|
15492
|
+
}
|
15493
|
+
setupCarousel() {
|
15494
|
+
this.setupDots();
|
15495
|
+
this.setupButtons();
|
15496
|
+
if (this.autoplay) {
|
15497
|
+
this.startAutoplay();
|
15498
|
+
}
|
15499
|
+
this.updateCarousel();
|
15500
|
+
}
|
15501
|
+
renderSlides() {
|
15502
|
+
const slidesContainer = document.createElement('div');
|
15503
|
+
slidesContainer.className = 'slides';
|
15504
|
+
this.slides.forEach((slide, index) => {
|
15505
|
+
const slideElement = document.createElement('div');
|
15506
|
+
slideElement.className = `slide ${index === this.currentSlide ? 'active' : ''}`;
|
15507
|
+
if (slide instanceof HTMLElement) {
|
15508
|
+
slideElement.appendChild(slide);
|
15509
|
+
}
|
15510
|
+
slidesContainer.appendChild(slideElement);
|
15511
|
+
});
|
15512
|
+
return slidesContainer;
|
15513
|
+
}
|
15514
|
+
renderDots() {
|
15515
|
+
const dotsContainer = document.createElement('div');
|
15516
|
+
dotsContainer.className = `dots ${this.dotsOptions.position}`;
|
15517
|
+
this.slides.forEach((_, index) => {
|
15518
|
+
const dot = document.createElement('span');
|
15519
|
+
dot.className = `dot ${index === this.currentSlide ? 'active' : ''}`;
|
15520
|
+
dot.style.backgroundColor = this.dotsOptions.color;
|
15521
|
+
dotsContainer.appendChild(dot);
|
15522
|
+
});
|
15523
|
+
return dotsContainer;
|
15524
|
+
}
|
15525
|
+
renderButtons() {
|
15526
|
+
const buttonsContainer = document.createElement('div');
|
15527
|
+
const buttonsClass = this.buttonsOptions.together
|
15528
|
+
? `buttons-together ${this.buttonsOptions.position}`
|
15529
|
+
: 'buttons-separate';
|
15530
|
+
buttonsContainer.className = `buttons ${buttonsClass}`;
|
15531
|
+
this.prevButton = this.createButton('prev-button', this.buttonsOptions.prev);
|
15532
|
+
this.nextButton = this.createButton('next-button', this.buttonsOptions.next);
|
15533
|
+
buttonsContainer.appendChild(this.prevButton);
|
15534
|
+
buttonsContainer.appendChild(this.nextButton);
|
15535
|
+
return buttonsContainer;
|
15536
|
+
}
|
15537
|
+
createButton(className, text) {
|
15538
|
+
const button = document.createElement('button');
|
15539
|
+
button.className = className;
|
15540
|
+
button.textContent = text;
|
15541
|
+
button.style.color = this.buttonsOptions.textColor;
|
15542
|
+
button.style.backgroundColor = this.buttonsOptions.backgroundColor;
|
15543
|
+
button.style.borderRadius = this.buttonsOptions.borderRadius;
|
15544
|
+
return button;
|
15545
|
+
}
|
15546
|
+
setupDots() {
|
15547
|
+
if (!this.shadowRoot || !this.useDots)
|
15548
|
+
return;
|
15549
|
+
this.dotElements = Array.from(this.shadowRoot.querySelectorAll('.dot'));
|
15550
|
+
this.dotElements.forEach((dot, index) => {
|
15551
|
+
dot.addEventListener('click', () => {
|
15552
|
+
this.goToSlide(index);
|
15553
|
+
this.resetAutoplay();
|
15554
|
+
});
|
15555
|
+
});
|
15556
|
+
}
|
15557
|
+
setupButtons() {
|
15558
|
+
var _a, _b;
|
15559
|
+
if (!this.useButtons)
|
15560
|
+
return;
|
15561
|
+
(_a = this.prevButton) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
|
15562
|
+
this.prevSlide();
|
15563
|
+
this.resetAutoplay();
|
15564
|
+
});
|
15565
|
+
(_b = this.nextButton) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
|
15566
|
+
this.nextSlide();
|
15567
|
+
this.resetAutoplay();
|
15568
|
+
});
|
15569
|
+
}
|
15570
|
+
nextSlide() {
|
15571
|
+
this.goToSlide((this.currentSlide + 1) % this.slides.length);
|
15572
|
+
}
|
15573
|
+
prevSlide() {
|
15574
|
+
this.goToSlide((this.currentSlide - 1 + this.slides.length) % this.slides.length);
|
15575
|
+
}
|
15576
|
+
goToSlide(index) {
|
15577
|
+
this.currentSlide = index;
|
15578
|
+
this.updateCarousel();
|
15579
|
+
}
|
15580
|
+
updateCarousel() {
|
15581
|
+
if (!this.slidesContainer)
|
15582
|
+
return;
|
15583
|
+
const slides = Array.from(this.slidesContainer.children);
|
15584
|
+
slides.forEach((slide, index) => {
|
15585
|
+
slide.classList.toggle('active', index === this.currentSlide);
|
15586
|
+
});
|
15587
|
+
this.updateDots();
|
15588
|
+
}
|
15589
|
+
updateDots() {
|
15590
|
+
if (!this.useDots)
|
15591
|
+
return;
|
15592
|
+
this.dotElements.forEach((dot, index) => {
|
15593
|
+
const isActive = index === this.currentSlide;
|
15594
|
+
dot.classList.toggle('active', isActive);
|
15595
|
+
dot.style.backgroundColor = isActive
|
15596
|
+
? this.dotsOptions.activeColor
|
15597
|
+
: this.dotsOptions.color;
|
15598
|
+
});
|
15599
|
+
}
|
15600
|
+
startAutoplay() {
|
15601
|
+
this.autoplayInterval = window.setInterval(() => this.nextSlide(), this.interval);
|
15602
|
+
}
|
15603
|
+
stopAutoplay() {
|
15604
|
+
if (this.autoplayInterval !== null) {
|
15605
|
+
window.clearInterval(this.autoplayInterval);
|
15606
|
+
this.autoplayInterval = null;
|
15607
|
+
}
|
15608
|
+
}
|
15609
|
+
resetAutoplay() {
|
15610
|
+
if (this.autoplay) {
|
15611
|
+
this.stopAutoplay();
|
15612
|
+
this.startAutoplay();
|
15613
|
+
}
|
15614
|
+
}
|
15615
|
+
validateOptions() {
|
15616
|
+
this.validatePosition(this.dotsOptions.position, 'dotsPosition', 'bottom-center');
|
15617
|
+
this.validateButtonsPosition();
|
15618
|
+
}
|
15619
|
+
validatePosition(position, optionName, defaultValue) {
|
15620
|
+
if (!CustomCarouselElement.validPositions.includes(position)) {
|
15621
|
+
console.warn(`Invalid ${optionName}: ${position}. Defaulting to '${defaultValue}'.`);
|
15622
|
+
if (optionName === 'dotsPosition') {
|
15623
|
+
this.dotsOptions.position = defaultValue;
|
15624
|
+
}
|
15625
|
+
else if (optionName === 'buttonsPosition') {
|
15626
|
+
this.buttonsOptions.position = defaultValue;
|
15627
|
+
}
|
15628
|
+
}
|
15629
|
+
}
|
15630
|
+
validateButtonsPosition() {
|
15631
|
+
if (this.useButtons) {
|
15632
|
+
if (this.buttonsOptions.together) {
|
15633
|
+
this.validatePosition(this.buttonsOptions.position, 'buttonsPosition', 'bottom-center');
|
15634
|
+
}
|
15635
|
+
else if (this.buttonsOptions.position !== 'middle-sides') {
|
15636
|
+
console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. When buttons are not together, only 'middle-sides' is allowed. Defaulting to 'middle-sides'.`);
|
15637
|
+
this.buttonsOptions.position = 'middle-sides';
|
15638
|
+
}
|
15639
|
+
}
|
15640
|
+
}
|
15641
|
+
}
|
15642
|
+
CustomCarouselElement.defaultInterval = 5000;
|
15643
|
+
CustomCarouselElement.validPositions = [
|
15644
|
+
'top-left',
|
15645
|
+
'top-center',
|
15646
|
+
'top-right',
|
15647
|
+
'bottom-left',
|
15648
|
+
'bottom-center',
|
15649
|
+
'bottom-right',
|
15650
|
+
'middle-left',
|
15651
|
+
'middle-right',
|
15652
|
+
'middle-sides',
|
15653
|
+
];
|
15654
|
+
CarouselElement = CustomCarouselElement;
|
15655
|
+
}
|
15656
|
+
|
15231
15657
|
let SpotElement;
|
15232
15658
|
if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined') {
|
15233
15659
|
class CustomSpotElement extends HTMLElement {
|
@@ -15267,6 +15693,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15267
15693
|
* #########################################################
|
15268
15694
|
*/
|
15269
15695
|
handleSpotSizeChanged(event) {
|
15696
|
+
console.info('Spot Size Changed', event);
|
15270
15697
|
// Adjust text elements font size based on the scale factor
|
15271
15698
|
this.adjustFontSize(event.detail.scale);
|
15272
15699
|
}
|
@@ -15309,8 +15736,8 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15309
15736
|
const scaleFactor = 1 + (baseFactor - 1) * dampening;
|
15310
15737
|
// Step 3: Define the allowed range for the scale factor
|
15311
15738
|
// This ensures that the font size never changes too drastically
|
15312
|
-
const minScale = 0.
|
15313
|
-
const maxScale = 1.
|
15739
|
+
const minScale = 0.5; // Font will never be smaller than 90% of original
|
15740
|
+
const maxScale = 1.5; // Font will never be larger than 110% of original
|
15314
15741
|
// Step 4: Clamp the scale factor to the defined range
|
15315
15742
|
// Math.min ensures the value doesn't exceed maxScale
|
15316
15743
|
// Math.max ensures the value isn't less than minScale
|
@@ -15324,15 +15751,9 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15324
15751
|
if (!this.shadowRoot || !this.data || !this.content)
|
15325
15752
|
return;
|
15326
15753
|
const style = this.getTemplateStyle(this.data.width, this.data.height);
|
15327
|
-
const spot = document.createElement('div');
|
15328
|
-
spot.className = 'spot';
|
15329
|
-
if (typeof this.content === 'string') {
|
15330
|
-
spot.innerHTML = this.content;
|
15331
|
-
}
|
15332
15754
|
if (this.content instanceof HTMLElement) {
|
15333
|
-
|
15755
|
+
this.shadowRoot.replaceChildren(style, this.content);
|
15334
15756
|
}
|
15335
|
-
this.shadowRoot.replaceChildren(style, spot);
|
15336
15757
|
}
|
15337
15758
|
getTemplateStyle(width, height) {
|
15338
15759
|
const style = document.createElement('style');
|
@@ -15345,12 +15766,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15345
15766
|
width: ${this.data.fluid ? '100%' : `${width}px`};
|
15346
15767
|
height: ${this.data.fluid ? '100%' : `${height}px`};
|
15347
15768
|
}
|
15348
|
-
|
15349
|
-
:host .spot {
|
15350
|
-
width: 100%;
|
15351
|
-
height: 100%;
|
15352
|
-
display: block;
|
15353
|
-
}
|
15354
15769
|
`;
|
15355
15770
|
return style;
|
15356
15771
|
}
|
@@ -15367,24 +15782,43 @@ class ElementService {
|
|
15367
15782
|
*
|
15368
15783
|
* This method is only available in browser environments.
|
15369
15784
|
*
|
15370
|
-
* @param {
|
15785
|
+
* @param {ICreateSpotElementParams} params - The parameters to create the final element.
|
15371
15786
|
*
|
15372
15787
|
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
15373
15788
|
*/
|
15374
|
-
|
15789
|
+
createSpotElement({ content, config }) {
|
15375
15790
|
var _a;
|
15376
15791
|
if (!this.ensureBrowserEnvironmentAndDefineElement()) {
|
15377
15792
|
return null;
|
15378
15793
|
}
|
15379
|
-
const
|
15380
|
-
|
15381
|
-
width: config.width,
|
15382
|
-
height: config.height,
|
15383
|
-
minScale: config === null || config === void 0 ? void 0 : config.minScale,
|
15794
|
+
const spot = document.createElement(SPOT_ELEMENT_TAG);
|
15795
|
+
spot.data = {
|
15384
15796
|
fluid: (_a = config === null || config === void 0 ? void 0 : config.fluid) !== null && _a !== void 0 ? _a : false,
|
15797
|
+
...config,
|
15385
15798
|
};
|
15386
|
-
|
15387
|
-
return
|
15799
|
+
spot.content = content;
|
15800
|
+
return spot;
|
15801
|
+
}
|
15802
|
+
/**
|
15803
|
+
* Creates the carousel html element based on the provided slides and configs using shadow dom.
|
15804
|
+
*
|
15805
|
+
* This method is only available in browser environments.
|
15806
|
+
*
|
15807
|
+
* @param {ICreateCarouselElementParams} params - The parameters to create the final element.
|
15808
|
+
*
|
15809
|
+
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
15810
|
+
*/
|
15811
|
+
createCarouselElement({ slides, config, }) {
|
15812
|
+
if (!this.ensureBrowserEnvironmentAndDefineElement()) {
|
15813
|
+
return null;
|
15814
|
+
}
|
15815
|
+
const carousel = document.createElement(CAROUSEL_ELEMENT_TAG);
|
15816
|
+
carousel.data = {
|
15817
|
+
fluid: false,
|
15818
|
+
...config,
|
15819
|
+
};
|
15820
|
+
carousel.slides = slides;
|
15821
|
+
return carousel;
|
15388
15822
|
}
|
15389
15823
|
/**
|
15390
15824
|
* Overrides the spot colors with the provided colors.
|
@@ -15414,428 +15848,35 @@ class ElementService {
|
|
15414
15848
|
console.warn('LiquidCommerce Rmn Sdk: Methods which create elements are only available in browser environments.');
|
15415
15849
|
return false;
|
15416
15850
|
}
|
15417
|
-
if (!window.customElements.get(
|
15418
|
-
window.customElements.define(
|
15851
|
+
if (!window.customElements.get(SPOT_ELEMENT_TAG)) {
|
15852
|
+
window.customElements.define(SPOT_ELEMENT_TAG, SpotElement);
|
15853
|
+
}
|
15854
|
+
if (!window.customElements.get(CAROUSEL_ELEMENT_TAG)) {
|
15855
|
+
window.customElements.define(CAROUSEL_ELEMENT_TAG, CarouselElement);
|
15419
15856
|
}
|
15420
15857
|
return true;
|
15421
15858
|
}
|
15422
15859
|
}
|
15423
15860
|
|
15424
|
-
|
15425
|
-
|
15426
|
-
|
15427
|
-
display: inline-block;
|
15428
|
-
margin: 0;
|
15429
|
-
overflow: hidden;
|
15430
|
-
height: 100%;
|
15431
|
-
width: 100%;
|
15432
|
-
}
|
15433
|
-
|
15434
|
-
.carousel-slides {
|
15435
|
-
position: relative;
|
15436
|
-
height: 100%;
|
15437
|
-
width: 100%;
|
15438
|
-
}
|
15439
|
-
|
15440
|
-
.carousel-slide {
|
15441
|
-
display: none;
|
15442
|
-
|
15443
|
-
justify-content: center;
|
15444
|
-
align-items: center;
|
15445
|
-
height: 100%;
|
15446
|
-
width: 100%;
|
15447
|
-
}
|
15448
|
-
|
15449
|
-
.carousel-slide.active {
|
15450
|
-
display: flex;
|
15451
|
-
}
|
15452
|
-
|
15453
|
-
.carousel-dots {
|
15454
|
-
position: absolute;
|
15455
|
-
display: flex;
|
15456
|
-
align-items: center;
|
15457
|
-
gap: 8px;
|
15458
|
-
}
|
15459
|
-
|
15460
|
-
.carousel-dots .dot {
|
15461
|
-
width: 12px;
|
15462
|
-
height: 12px;
|
15463
|
-
border-radius: 50%;
|
15464
|
-
cursor: pointer;
|
15465
|
-
transition: all 0.3s ease;
|
15466
|
-
}
|
15467
|
-
|
15468
|
-
.carousel-dots.top-left,
|
15469
|
-
.carousel-dots.bottom-left {
|
15470
|
-
left: 10px;
|
15471
|
-
}
|
15472
|
-
|
15473
|
-
.carousel-dots.top-center,
|
15474
|
-
.carousel-dots.bottom-center {
|
15475
|
-
left: 50%;
|
15476
|
-
transform: translateX(-50%);
|
15477
|
-
}
|
15478
|
-
|
15479
|
-
.carousel-dots.top-right,
|
15480
|
-
.carousel-dots.bottom-right {
|
15481
|
-
right: 10px;
|
15482
|
-
}
|
15483
|
-
|
15484
|
-
.carousel-dots.top-left,
|
15485
|
-
.carousel-dots.top-center,
|
15486
|
-
.carousel-dots.top-right {
|
15487
|
-
top: 10px;
|
15488
|
-
}
|
15489
|
-
|
15490
|
-
.carousel-dots.bottom-left,
|
15491
|
-
.carousel-dots.bottom-center,
|
15492
|
-
.carousel-dots.bottom-right {
|
15493
|
-
bottom: 10px;
|
15494
|
-
}
|
15495
|
-
|
15496
|
-
.carousel-dots.middle-left {
|
15497
|
-
left: 10px;
|
15498
|
-
top: 50%;
|
15499
|
-
transform: translateY(-50%);
|
15500
|
-
flex-direction: column;
|
15501
|
-
}
|
15502
|
-
|
15503
|
-
.carousel-dots.middle-right {
|
15504
|
-
right: 10px;
|
15505
|
-
top: 50%;
|
15506
|
-
transform: translateY(-50%);
|
15507
|
-
flex-direction: column;
|
15508
|
-
}
|
15509
|
-
|
15510
|
-
.carousel-buttons button {
|
15511
|
-
background-color: #00000080;
|
15512
|
-
color: #fff;
|
15513
|
-
border: none;
|
15514
|
-
padding: 10px;
|
15515
|
-
cursor: pointer;
|
15516
|
-
transition: background-color 0.3s ease;
|
15517
|
-
}
|
15518
|
-
|
15519
|
-
.carousel-buttons button:hover {
|
15520
|
-
background-color: #000000b3;
|
15521
|
-
}
|
15522
|
-
|
15523
|
-
.carousel-buttons.buttons-separate button {
|
15524
|
-
position: absolute;
|
15525
|
-
top: 50%;
|
15526
|
-
transform: translateY(-50%);
|
15527
|
-
}
|
15528
|
-
|
15529
|
-
.carousel-buttons.buttons-separate .prev-button {
|
15530
|
-
left: 10px;
|
15531
|
-
}
|
15532
|
-
|
15533
|
-
.carousel-buttons.buttons-separate .next-button {
|
15534
|
-
right: 10px;
|
15535
|
-
}
|
15536
|
-
|
15537
|
-
.carousel-buttons.buttons-together {
|
15538
|
-
position: absolute;
|
15539
|
-
display: flex;
|
15540
|
-
gap: 10px;
|
15541
|
-
}
|
15542
|
-
|
15543
|
-
.carousel-buttons.buttons-together.top-left,
|
15544
|
-
.carousel-buttons.buttons-together.bottom-left {
|
15545
|
-
left: 10px;
|
15546
|
-
}
|
15547
|
-
|
15548
|
-
.carousel-buttons.buttons-together.top-center,
|
15549
|
-
.carousel-buttons.buttons-together.bottom-center {
|
15550
|
-
left: 50%;
|
15551
|
-
transform: translateX(-50%);
|
15552
|
-
}
|
15553
|
-
|
15554
|
-
.carousel-buttons.buttons-together.top-right,
|
15555
|
-
.carousel-buttons.buttons-together.bottom-right {
|
15556
|
-
right: 10px;
|
15557
|
-
}
|
15558
|
-
|
15559
|
-
.carousel-buttons.buttons-together.top-left,
|
15560
|
-
.carousel-buttons.buttons-together.top-center,
|
15561
|
-
.carousel-buttons.buttons-together.top-right {
|
15562
|
-
top: 10px;
|
15563
|
-
}
|
15564
|
-
|
15565
|
-
.carousel-buttons.buttons-together.bottom-left,
|
15566
|
-
.carousel-buttons.buttons-together.bottom-center,
|
15567
|
-
.carousel-buttons.buttons-together.bottom-right {
|
15568
|
-
bottom: 10px;
|
15569
|
-
}
|
15570
|
-
|
15571
|
-
.carousel-buttons.buttons-together.middle-left,
|
15572
|
-
.carousel-buttons.buttons-together.middle-right {
|
15573
|
-
top: 50%;
|
15574
|
-
transform: translateY(-50%);
|
15575
|
-
flex-direction: column;
|
15576
|
-
}
|
15577
|
-
|
15578
|
-
.carousel-buttons.buttons-together.middle-left {
|
15579
|
-
left: 10px;
|
15580
|
-
}
|
15581
|
-
|
15582
|
-
.carousel-buttons.buttons-together.middle-right {
|
15583
|
-
right: 10px;
|
15584
|
-
}
|
15585
|
-
|
15586
|
-
@media (max-width: 768px) {
|
15587
|
-
.carousel-buttons button {
|
15588
|
-
padding: 8px 12px;
|
15589
|
-
font-size: 14px;
|
15590
|
-
}
|
15591
|
-
|
15592
|
-
.carousel-dots .dot {
|
15593
|
-
width: 8px;
|
15594
|
-
height: 8px;
|
15595
|
-
}
|
15596
|
-
}
|
15597
|
-
`;
|
15598
|
-
|
15599
|
-
class CarouselComponent {
|
15600
|
-
constructor(slides, options = {}) {
|
15601
|
-
var _a, _b;
|
15602
|
-
this.currentSlide = 0;
|
15603
|
-
this.dotElements = [];
|
15604
|
-
this.prevButton = null;
|
15605
|
-
this.nextButton = null;
|
15606
|
-
this.autoplayInterval = null;
|
15607
|
-
this.slides = slides;
|
15608
|
-
this.autoplay = (_a = options.autoplay) !== null && _a !== void 0 ? _a : true;
|
15609
|
-
this.interval = (_b = options.interval) !== null && _b !== void 0 ? _b : 10000;
|
15610
|
-
this.dotsOptions = this.initializeDotOptions(options.useDots);
|
15611
|
-
this.buttonsOptions = this.initializeButtonOptions(options.useButtons);
|
15612
|
-
this.validateOptions();
|
15613
|
-
this.carousel = document.createElement('div');
|
15614
|
-
this.carousel.className = 'carousel';
|
15615
|
-
this.shadowRoot = this.carousel.attachShadow({ mode: 'open' });
|
15616
|
-
this.render();
|
15617
|
-
this.slidesContainer = this.shadowRoot.querySelector('.carousel-slides');
|
15618
|
-
this.setupCarousel();
|
15619
|
-
}
|
15620
|
-
// Public method to get the carousel element
|
15621
|
-
getElement() {
|
15622
|
-
return this.carousel;
|
15623
|
-
}
|
15624
|
-
// Main setup methods
|
15625
|
-
render() {
|
15626
|
-
const style = document.createElement('style');
|
15627
|
-
style.textContent = CAROUSEL_COMPONENT_STYLE;
|
15628
|
-
this.shadowRoot.appendChild(style);
|
15629
|
-
this.shadowRoot.appendChild(this.renderSlides());
|
15630
|
-
if (this.dotsOptions) {
|
15631
|
-
const dots = this.renderDots();
|
15632
|
-
if (dots)
|
15633
|
-
this.shadowRoot.appendChild(dots);
|
15634
|
-
}
|
15635
|
-
if (this.buttonsOptions) {
|
15636
|
-
const buttons = this.renderButtons();
|
15637
|
-
if (buttons)
|
15638
|
-
this.shadowRoot.appendChild(buttons);
|
15639
|
-
}
|
15640
|
-
}
|
15641
|
-
setupCarousel() {
|
15642
|
-
this.setupDots();
|
15643
|
-
this.setupButtons();
|
15644
|
-
if (this.autoplay) {
|
15645
|
-
this.startAutoplay();
|
15646
|
-
}
|
15647
|
-
this.updateCarousel();
|
15648
|
-
}
|
15649
|
-
// Rendering methods
|
15650
|
-
renderSlides() {
|
15651
|
-
const slidesContainer = document.createElement('div');
|
15652
|
-
slidesContainer.className = 'carousel-slides';
|
15653
|
-
this.slides.forEach((slide, index) => {
|
15654
|
-
const slideElement = document.createElement('div');
|
15655
|
-
slideElement.className = `carousel-slide ${index === this.currentSlide ? 'active' : ''}`;
|
15656
|
-
if (typeof slide === 'string') {
|
15657
|
-
slideElement.innerHTML = slide;
|
15658
|
-
}
|
15659
|
-
else if (slide instanceof HTMLElement) {
|
15660
|
-
slideElement.appendChild(slide);
|
15661
|
-
}
|
15662
|
-
slidesContainer.appendChild(slideElement);
|
15663
|
-
});
|
15664
|
-
return slidesContainer;
|
15665
|
-
}
|
15666
|
-
renderDots() {
|
15667
|
-
if (!this.dotsOptions)
|
15668
|
-
return null;
|
15669
|
-
const dotsContainer = document.createElement('div');
|
15670
|
-
dotsContainer.className = `carousel-dots ${this.dotsOptions.position}`;
|
15671
|
-
this.slides.forEach((_, index) => {
|
15672
|
-
if (!this.dotsOptions)
|
15673
|
-
return;
|
15674
|
-
const dot = document.createElement('span');
|
15675
|
-
dot.className = `dot ${index === this.currentSlide ? 'active' : ''}`;
|
15676
|
-
dot.style.backgroundColor = this.dotsOptions.color;
|
15677
|
-
dotsContainer.appendChild(dot);
|
15678
|
-
});
|
15679
|
-
return dotsContainer;
|
15680
|
-
}
|
15681
|
-
renderButtons() {
|
15682
|
-
if (!this.buttonsOptions)
|
15683
|
-
return null;
|
15684
|
-
const buttonsContainer = document.createElement('div');
|
15685
|
-
const buttonsClass = this.buttonsOptions.together
|
15686
|
-
? `buttons-together ${this.buttonsOptions.position}`
|
15687
|
-
: 'buttons-separate';
|
15688
|
-
buttonsContainer.className = `carousel-buttons ${buttonsClass}`;
|
15689
|
-
this.prevButton = document.createElement('button');
|
15690
|
-
this.prevButton.className = 'prev-button';
|
15691
|
-
this.prevButton.textContent = this.buttonsOptions.prev;
|
15692
|
-
this.prevButton.style.color = this.buttonsOptions.textColor;
|
15693
|
-
this.prevButton.style.backgroundColor = this.buttonsOptions.backgroundColor;
|
15694
|
-
this.prevButton.style.borderRadius = this.buttonsOptions.borderRadius;
|
15695
|
-
buttonsContainer.appendChild(this.prevButton);
|
15696
|
-
this.nextButton = document.createElement('button');
|
15697
|
-
this.nextButton.className = 'next-button';
|
15698
|
-
this.nextButton.textContent = this.buttonsOptions.next;
|
15699
|
-
this.nextButton.style.color = this.buttonsOptions.textColor;
|
15700
|
-
this.nextButton.style.backgroundColor = this.buttonsOptions.backgroundColor;
|
15701
|
-
this.nextButton.style.borderRadius = this.buttonsOptions.borderRadius;
|
15702
|
-
buttonsContainer.appendChild(this.nextButton);
|
15703
|
-
return buttonsContainer;
|
15704
|
-
}
|
15705
|
-
// Setup methods
|
15706
|
-
setupDots() {
|
15707
|
-
if (this.dotsOptions) {
|
15708
|
-
this.dotElements = Array.from(this.shadowRoot.querySelectorAll('.dot'));
|
15709
|
-
this.dotElements.forEach((dot, index) => {
|
15710
|
-
dot.addEventListener('click', () => {
|
15711
|
-
this.goToSlide(index);
|
15712
|
-
this.resetAutoplay();
|
15713
|
-
});
|
15714
|
-
});
|
15715
|
-
}
|
15716
|
-
}
|
15717
|
-
setupButtons() {
|
15718
|
-
var _a, _b;
|
15719
|
-
if (this.buttonsOptions) {
|
15720
|
-
(_a = this.prevButton) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
|
15721
|
-
this.prevSlide();
|
15722
|
-
this.resetAutoplay();
|
15723
|
-
});
|
15724
|
-
(_b = this.nextButton) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
|
15725
|
-
this.nextSlide();
|
15726
|
-
this.resetAutoplay();
|
15727
|
-
});
|
15728
|
-
}
|
15729
|
-
}
|
15730
|
-
// Navigation methods
|
15731
|
-
nextSlide() {
|
15732
|
-
this.goToSlide((this.currentSlide + 1) % this.slides.length);
|
15733
|
-
}
|
15734
|
-
prevSlide() {
|
15735
|
-
this.goToSlide((this.currentSlide - 1 + this.slides.length) % this.slides.length);
|
15736
|
-
}
|
15737
|
-
goToSlide(index) {
|
15738
|
-
this.currentSlide = index;
|
15739
|
-
this.updateCarousel();
|
15740
|
-
}
|
15741
|
-
// Update methods
|
15742
|
-
updateCarousel() {
|
15743
|
-
const slides = Array.from(this.slidesContainer.children);
|
15744
|
-
slides.forEach((slide, index) => {
|
15745
|
-
if (index === this.currentSlide) {
|
15746
|
-
slide.classList.add('active');
|
15747
|
-
}
|
15748
|
-
else {
|
15749
|
-
slide.classList.remove('active');
|
15750
|
-
}
|
15751
|
-
});
|
15752
|
-
this.updateDots();
|
15753
|
-
}
|
15754
|
-
updateDots() {
|
15755
|
-
this.dotElements.forEach((dot, index) => {
|
15756
|
-
const isActive = index === this.currentSlide;
|
15757
|
-
dot.classList.toggle('active', isActive);
|
15758
|
-
if (!this.dotsOptions)
|
15759
|
-
return;
|
15760
|
-
dot.style.backgroundColor = isActive ? this.dotsOptions.activeColor : this.dotsOptions.color;
|
15761
|
-
});
|
15762
|
-
}
|
15763
|
-
// Autoplay methods
|
15764
|
-
startAutoplay() {
|
15765
|
-
this.autoplayInterval = window.setInterval(() => this.nextSlide(), this.interval);
|
15766
|
-
}
|
15767
|
-
stopAutoplay() {
|
15768
|
-
if (this.autoplayInterval !== null) {
|
15769
|
-
window.clearInterval(this.autoplayInterval);
|
15770
|
-
this.autoplayInterval = null;
|
15771
|
-
}
|
15772
|
-
}
|
15773
|
-
resetAutoplay() {
|
15774
|
-
if (this.autoplay) {
|
15775
|
-
this.stopAutoplay();
|
15776
|
-
this.startAutoplay();
|
15777
|
-
}
|
15778
|
-
}
|
15779
|
-
// Initialization and validation methods
|
15780
|
-
initializeDotOptions(useDots) {
|
15781
|
-
var _a, _b, _c;
|
15782
|
-
return !useDots
|
15783
|
-
? false
|
15784
|
-
: {
|
15785
|
-
position: (_a = useDots === null || useDots === void 0 ? void 0 : useDots.position) !== null && _a !== void 0 ? _a : 'bottom-center',
|
15786
|
-
color: (_b = useDots === null || useDots === void 0 ? void 0 : useDots.color) !== null && _b !== void 0 ? _b : '#d9d9d9',
|
15787
|
-
activeColor: (_c = useDots === null || useDots === void 0 ? void 0 : useDots.activeColor) !== null && _c !== void 0 ? _c : '#b5914a',
|
15788
|
-
};
|
15789
|
-
}
|
15790
|
-
initializeButtonOptions(useButtons) {
|
15791
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
15792
|
-
return !useButtons
|
15793
|
-
? false
|
15794
|
-
: {
|
15795
|
-
position: (_a = useButtons === null || useButtons === void 0 ? void 0 : useButtons.position) !== null && _a !== void 0 ? _a : 'middle-sides',
|
15796
|
-
together: (_b = useButtons === null || useButtons === void 0 ? void 0 : useButtons.together) !== null && _b !== void 0 ? _b : false,
|
15797
|
-
textColor: (_c = useButtons === null || useButtons === void 0 ? void 0 : useButtons.textColor) !== null && _c !== void 0 ? _c : '#000000',
|
15798
|
-
backgroundColor: (_d = useButtons === null || useButtons === void 0 ? void 0 : useButtons.backgroundColor) !== null && _d !== void 0 ? _d : '#ffffff',
|
15799
|
-
borderRadius: (_e = useButtons === null || useButtons === void 0 ? void 0 : useButtons.borderRadius) !== null && _e !== void 0 ? _e : '50%',
|
15800
|
-
prev: (_f = useButtons === null || useButtons === void 0 ? void 0 : useButtons.prev) !== null && _f !== void 0 ? _f : 'Prev',
|
15801
|
-
next: (_g = useButtons === null || useButtons === void 0 ? void 0 : useButtons.next) !== null && _g !== void 0 ? _g : 'Next',
|
15802
|
-
};
|
15803
|
-
}
|
15804
|
-
validateOptions() {
|
15805
|
-
const validPositions = [
|
15806
|
-
'top-left',
|
15807
|
-
'top-center',
|
15808
|
-
'top-right',
|
15809
|
-
'bottom-left',
|
15810
|
-
'bottom-center',
|
15811
|
-
'bottom-right',
|
15812
|
-
'middle-left',
|
15813
|
-
'middle-right',
|
15814
|
-
'middle-sides',
|
15815
|
-
];
|
15816
|
-
this.validateDotsPosition(validPositions);
|
15817
|
-
this.validateButtonsPosition(validPositions);
|
15818
|
-
}
|
15819
|
-
validateDotsPosition(validPositions) {
|
15820
|
-
if (this.dotsOptions && !validPositions.includes(this.dotsOptions.position)) {
|
15821
|
-
console.warn(`Invalid dotsPosition: ${this.dotsOptions.position}. Defaulting to 'bottom-center'.`);
|
15822
|
-
this.dotsOptions.position = 'bottom-center';
|
15823
|
-
}
|
15824
|
-
}
|
15825
|
-
validateButtonsPosition(validPositions) {
|
15826
|
-
if (this.buttonsOptions) {
|
15827
|
-
if (this.buttonsOptions.together) {
|
15828
|
-
if (!validPositions.includes(this.buttonsOptions.position)) {
|
15829
|
-
console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. Defaulting to 'bottom-center'.`);
|
15830
|
-
this.buttonsOptions.position = 'bottom-center';
|
15831
|
-
}
|
15832
|
-
}
|
15833
|
-
else if (this.buttonsOptions.position !== 'middle-sides') {
|
15834
|
-
console.warn(`Invalid buttonsPosition: ${this.buttonsOptions.position}. When buttons are not together, only 'middle-sides' is allowed. Defaulting to 'middle-sides'.`);
|
15835
|
-
this.buttonsOptions.position = 'middle-sides';
|
15836
|
-
}
|
15837
|
-
}
|
15861
|
+
function linearGradientColorStop(overlay, fallback) {
|
15862
|
+
if (!overlay || overlay.length === 0) {
|
15863
|
+
return fallback;
|
15838
15864
|
}
|
15865
|
+
return overlay.map(({ color, colorStop }) => `${color} ${colorStop}`).join(', ');
|
15866
|
+
}
|
15867
|
+
function spotHtmlStringToElement(htmlString) {
|
15868
|
+
const spot = document.createElement('div');
|
15869
|
+
spot.className = 'spot';
|
15870
|
+
spot.innerHTML = htmlString;
|
15871
|
+
Object.assign(spot.style, {
|
15872
|
+
position: 'relative',
|
15873
|
+
display: 'block',
|
15874
|
+
width: '100%',
|
15875
|
+
height: '100%',
|
15876
|
+
margin: '0',
|
15877
|
+
padding: '0',
|
15878
|
+
});
|
15879
|
+
return spot;
|
15839
15880
|
}
|
15840
15881
|
|
15841
15882
|
const STYLES$i = ({ primaryImage, secondaryImage }) => `
|
@@ -16688,13 +16729,6 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot, config) {
|
|
16688
16729
|
`;
|
16689
16730
|
}
|
16690
16731
|
|
16691
|
-
function linearGradientColorStop(overlay, fallback) {
|
16692
|
-
if (!overlay || overlay.length === 0) {
|
16693
|
-
return fallback;
|
16694
|
-
}
|
16695
|
-
return overlay.map(({ color, colorStop }) => `${color} ${colorStop}`).join(', ');
|
16696
|
-
}
|
16697
|
-
|
16698
16732
|
const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }, { prefix, overlay }) => {
|
16699
16733
|
const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 40%');
|
16700
16734
|
return `
|
@@ -17289,7 +17323,9 @@ function rbLargeCategoryImageToutTemplate(spot, config) {
|
|
17289
17323
|
`;
|
17290
17324
|
}
|
17291
17325
|
|
17292
|
-
const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage }, { prefix }) =>
|
17326
|
+
const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage }, { prefix, overlay }) => {
|
17327
|
+
const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
|
17328
|
+
return `
|
17293
17329
|
<style>
|
17294
17330
|
:host {
|
17295
17331
|
min-width: 320px;
|
@@ -17305,10 +17341,9 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17305
17341
|
border-radius: 5px;
|
17306
17342
|
overflow: hidden;
|
17307
17343
|
cursor: pointer;
|
17308
|
-
background-image: url("${mobilePrimaryImage}");
|
17344
|
+
background-image: linear-gradient(to top, ${linearGradient}), url("${mobilePrimaryImage}");
|
17309
17345
|
background-size: cover;
|
17310
17346
|
background-position: center;
|
17311
|
-
background-blend-mode: overlay;
|
17312
17347
|
background-repeat: no-repeat;
|
17313
17348
|
}
|
17314
17349
|
|
@@ -17329,7 +17364,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17329
17364
|
|
17330
17365
|
@media (min-width: 640px) {
|
17331
17366
|
.${prefix}__content {
|
17332
|
-
background-image: url("${primaryImage}");
|
17367
|
+
background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
|
17333
17368
|
}
|
17334
17369
|
}
|
17335
17370
|
|
@@ -17352,6 +17387,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17352
17387
|
}
|
17353
17388
|
</style>
|
17354
17389
|
`;
|
17390
|
+
};
|
17355
17391
|
function rbNavigationBannerTemplate(spot, config) {
|
17356
17392
|
const { prefix = '' } = config;
|
17357
17393
|
return `
|
@@ -17507,7 +17543,7 @@ function rbSmallDiscoverToutTemplate(spot, config) {
|
|
17507
17543
|
*
|
17508
17544
|
* @return {string} - The spot html string.
|
17509
17545
|
*/
|
17510
|
-
const
|
17546
|
+
const SPOT_TEMPLATE_HTML_ELEMENT = (spot, config) => {
|
17511
17547
|
const templates = {
|
17512
17548
|
// Reserve Bar Spot Templates
|
17513
17549
|
[RMN_SPOT_TYPE.RB_HOMEPAGE_HERO_THREE_TILE]: {
|
@@ -17566,15 +17602,16 @@ const GET_SPOT_TEMPLATE_HTML_STRING = (spot, config) => {
|
|
17566
17602
|
};
|
17567
17603
|
const spotVariants = templates[spot.spot];
|
17568
17604
|
if (!spotVariants) {
|
17569
|
-
return
|
17605
|
+
return null;
|
17570
17606
|
}
|
17571
17607
|
const variantTemplate = spotVariants[spot.variant];
|
17572
17608
|
if (!variantTemplate) {
|
17573
|
-
return
|
17609
|
+
return null;
|
17574
17610
|
}
|
17575
17611
|
// Generate a random prefix to avoid conflicts with other elements.
|
17576
17612
|
const prefix = 's' + Math.random().toString(36).substring(6);
|
17577
|
-
|
17613
|
+
const spotHtmlString = variantTemplate(spot, { ...config, prefix });
|
17614
|
+
return spotHtmlStringToElement(spotHtmlString);
|
17578
17615
|
};
|
17579
17616
|
|
17580
17617
|
const SELECTION_API_PATH = '/spots/selection';
|
@@ -17627,8 +17664,8 @@ class LiquidCommerceRmnClient {
|
|
17627
17664
|
/**
|
17628
17665
|
* Injects the spot elements into their provided placement.
|
17629
17666
|
*
|
17630
|
-
* @param {IInjectSpotElement[]} data - The spot
|
17631
|
-
* @param {
|
17667
|
+
* @param {IInjectSpotElement[]} data - The spot element's data.
|
17668
|
+
* @param {IInjectSpotElementConfig} config - The configuration object.
|
17632
17669
|
*
|
17633
17670
|
* @return {Promise<void>} - A promise that resolves when the spot elements are injected.
|
17634
17671
|
*/
|
@@ -17644,7 +17681,10 @@ class LiquidCommerceRmnClient {
|
|
17644
17681
|
count: (_a = item === null || item === void 0 ? void 0 : item.count) !== null && _a !== void 0 ? _a : 1,
|
17645
17682
|
});
|
17646
17683
|
});
|
17647
|
-
const response = await this.spotSelection({
|
17684
|
+
const response = await this.spotSelection({
|
17685
|
+
spots: spotSelectionRequest,
|
17686
|
+
url: config === null || config === void 0 ? void 0 : config.url,
|
17687
|
+
});
|
17648
17688
|
const normalizedData = this.normalizeDataSpotType(data);
|
17649
17689
|
for (const item of normalizedData) {
|
17650
17690
|
const spots = response[item.spotType];
|
@@ -17671,20 +17711,40 @@ class LiquidCommerceRmnClient {
|
|
17671
17711
|
*
|
17672
17712
|
* @param {HTMLElement} placement - The placement element.
|
17673
17713
|
* @param {ISpot[]} spots - The spot data.
|
17674
|
-
* @param {
|
17714
|
+
* @param {IInjectSpotElementConfig} config - The configuration object.
|
17675
17715
|
*
|
17676
17716
|
* @return {void}
|
17677
17717
|
*/
|
17678
17718
|
injectCarouselSpotElement(placement, spots, config) {
|
17719
|
+
var _a;
|
17679
17720
|
const carouselSlides = [];
|
17680
17721
|
for (const spotItem of spots) {
|
17681
17722
|
const spot = this.elementService.overrideSpotColors(spotItem, config === null || config === void 0 ? void 0 : config.colors);
|
17682
|
-
const content =
|
17723
|
+
const content = SPOT_TEMPLATE_HTML_ELEMENT(spot, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
|
17724
|
+
if (!content) {
|
17725
|
+
console.warn(`RmnSdk: Failed to inject carousel spot element. Could not create element for type "${spot.spot}".`);
|
17726
|
+
return;
|
17727
|
+
}
|
17683
17728
|
carouselSlides.push(content);
|
17684
17729
|
}
|
17685
|
-
const
|
17686
|
-
|
17687
|
-
|
17730
|
+
const { maxWidth, maxHeight } = spots.reduce((max, spot) => ({
|
17731
|
+
maxWidth: Math.max(max.maxWidth, spot.width),
|
17732
|
+
maxHeight: Math.max(max.maxHeight, spot.height),
|
17733
|
+
}), { maxWidth: 0, maxHeight: 0 });
|
17734
|
+
const carouselElement = this.elementService.createCarouselElement({
|
17735
|
+
slides: carouselSlides,
|
17736
|
+
config: {
|
17737
|
+
width: maxWidth,
|
17738
|
+
height: maxHeight,
|
17739
|
+
minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
|
17740
|
+
...config === null || config === void 0 ? void 0 : config.carousel,
|
17741
|
+
},
|
17742
|
+
});
|
17743
|
+
if (!carouselElement) {
|
17744
|
+
console.warn(`RmnSdk: Failed to inject spot carousel element. Could not create spot carousel element.`);
|
17745
|
+
return;
|
17746
|
+
}
|
17747
|
+
placement.replaceChildren(carouselElement);
|
17688
17748
|
}
|
17689
17749
|
/**
|
17690
17750
|
* Injects a single spot element into the provided placement.
|
@@ -17692,27 +17752,31 @@ class LiquidCommerceRmnClient {
|
|
17692
17752
|
* @param {IInjectSpotElement} injectItem - The inject item data.
|
17693
17753
|
* @param {HTMLElement} placement - The placement element.
|
17694
17754
|
* @param {ISpot} spot - The spot data.
|
17695
|
-
* @param {
|
17755
|
+
* @param {IInjectSpotElementConfig} config - The configuration object.
|
17696
17756
|
*
|
17697
17757
|
* @return {void}
|
17698
17758
|
*/
|
17699
17759
|
injectOneSpotElement(injectItem, placement, spot, config) {
|
17760
|
+
var _a;
|
17700
17761
|
const spotData = this.elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
|
17701
|
-
const content =
|
17702
|
-
|
17762
|
+
const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
|
17763
|
+
if (!content) {
|
17764
|
+
console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
|
17765
|
+
return;
|
17766
|
+
}
|
17767
|
+
const spotElement = this.elementService.createSpotElement({
|
17703
17768
|
content,
|
17704
17769
|
config: {
|
17705
|
-
fluid: true,
|
17706
17770
|
width: spot.width,
|
17707
17771
|
height: spot.height,
|
17708
|
-
minScale: config === null || config === void 0 ? void 0 : config.minScale,
|
17772
|
+
minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
|
17709
17773
|
},
|
17710
17774
|
});
|
17711
17775
|
if (!spotElement) {
|
17712
17776
|
console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
|
17713
17777
|
return;
|
17714
17778
|
}
|
17715
|
-
placement.
|
17779
|
+
placement.replaceChildren(spotElement);
|
17716
17780
|
}
|
17717
17781
|
/**
|
17718
17782
|
* Normalizes the spot type data by adding a number suffix to the spot type.
|
@@ -17749,5 +17813,36 @@ async function RmnClient(apiKey, config) {
|
|
17749
17813
|
const credentials = await authService.initialize();
|
17750
17814
|
return new LiquidCommerceRmnClient(credentials);
|
17751
17815
|
}
|
17816
|
+
/**
|
17817
|
+
* Creates the spot html element based on the provided data using shadow dom.
|
17818
|
+
*
|
17819
|
+
* This method is useful when you are initializing the client in a non-browser environment.
|
17820
|
+
* When you request a spot selection, you will receive the spot data in server-side and return them to the client.
|
17821
|
+
* Then you can use this function to create the spot html element based on the provided data without the need of the RmnClient instance.
|
17822
|
+
*
|
17823
|
+
* @param {ISpot} spot - The spot data.
|
17824
|
+
* @param {IRmnCreateSpotElementConfig} config - The configuration object.
|
17825
|
+
*
|
17826
|
+
* @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
|
17827
|
+
*/
|
17828
|
+
function RmnCreateSpotElement(spot, config) {
|
17829
|
+
var _a;
|
17830
|
+
const elementService = ElementService.getInstance();
|
17831
|
+
const spotData = elementService.overrideSpotColors(spot, config === null || config === void 0 ? void 0 : config.colors);
|
17832
|
+
const content = SPOT_TEMPLATE_HTML_ELEMENT(spotData, { overlay: config === null || config === void 0 ? void 0 : config.overlay });
|
17833
|
+
if (!content) {
|
17834
|
+
console.warn(`RmnSdk: Failed to create spot element for type "${spotData.spot}".`);
|
17835
|
+
return null;
|
17836
|
+
}
|
17837
|
+
return elementService.createSpotElement({
|
17838
|
+
content,
|
17839
|
+
config: {
|
17840
|
+
fluid: true,
|
17841
|
+
width: spot.width,
|
17842
|
+
height: spot.height,
|
17843
|
+
minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
|
17844
|
+
},
|
17845
|
+
});
|
17846
|
+
}
|
17752
17847
|
|
17753
|
-
export { LiquidCommerceRmnClient, RMN_ENV, RMN_FILTER_PROPERTIES, RMN_SPOT_EVENT, RMN_SPOT_TYPE, RmnClient };
|
17848
|
+
export { LiquidCommerceRmnClient, RMN_ENV, RMN_FILTER_PROPERTIES, RMN_SPOT_EVENT, RMN_SPOT_TYPE, RmnClient, RmnCreateSpotElement };
|