ctt-babylon 0.11.4 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/core/babylon-booking-widget/babylon-booking-widget.component.mjs +100 -56
- package/esm2022/lib/services/mapper/mapper.service.mjs +43 -3
- package/fesm2022/ctt-babylon.mjs +141 -57
- package/fesm2022/ctt-babylon.mjs.map +1 -1
- package/lib/components/core/babylon-booking-widget/babylon-booking-widget.component.d.ts +10 -39
- package/package.json +1 -1
package/fesm2022/ctt-babylon.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i1$1 from '@angular/common';
|
|
2
2
|
import { isPlatformBrowser, CommonModule, DOCUMENT, NgClass } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, EventEmitter, inject, PLATFORM_ID, NgZone, HostListener, Output, Input, Directive, ChangeDetectionStrategy, Component, Inject, signal, Injectable, computed, Renderer2, effect, Pipe, ViewChild, ViewEncapsulation, HostBinding, ViewChildren, booleanAttribute, ChangeDetectorRef, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
4
|
+
import { InjectionToken, EventEmitter, inject, PLATFORM_ID, NgZone, HostListener, Output, Input, Directive, ChangeDetectionStrategy, Component, Inject, signal, Injectable, computed, Renderer2, effect, Pipe, afterNextRender, ViewChild, ViewEncapsulation, HostBinding, ViewChildren, booleanAttribute, ChangeDetectorRef, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
5
5
|
import * as i1 from '@angular/router';
|
|
6
6
|
import { RouterModule, NavigationEnd } from '@angular/router';
|
|
7
7
|
import { Observable, timer, map, filter, take, timeout, defer, of, switchMap, catchError, forkJoin, tap, takeWhile, fromEvent, debounceTime, distinctUntilChanged, startWith, Subject, takeUntil, BehaviorSubject } from 'rxjs';
|
|
@@ -4355,6 +4355,40 @@ class MapperService {
|
|
|
4355
4355
|
};
|
|
4356
4356
|
}
|
|
4357
4357
|
mapStaticFooter(props) {
|
|
4358
|
+
// Funcion temporal hasta que el back devuelva la lista de hoteles
|
|
4359
|
+
const dynamicHotelsAdresses = () => {
|
|
4360
|
+
const addressesMap = {};
|
|
4361
|
+
if (!props?.texts)
|
|
4362
|
+
return;
|
|
4363
|
+
Object.keys(props.texts).forEach((key) => {
|
|
4364
|
+
if (key.startsWith('addresslist')) {
|
|
4365
|
+
const match = key.match(/addresslist(\d+)(.*)/);
|
|
4366
|
+
if (match) {
|
|
4367
|
+
const index = match[1];
|
|
4368
|
+
const field = match[2];
|
|
4369
|
+
if (!addressesMap[index]) {
|
|
4370
|
+
addressesMap[index] = {
|
|
4371
|
+
id: parseInt(index, 10).toString(),
|
|
4372
|
+
};
|
|
4373
|
+
}
|
|
4374
|
+
const value = props.texts[key];
|
|
4375
|
+
switch (field) {
|
|
4376
|
+
case 'Title':
|
|
4377
|
+
addressesMap[index].name = value;
|
|
4378
|
+
break;
|
|
4379
|
+
case 'Address':
|
|
4380
|
+
addressesMap[index].address = value;
|
|
4381
|
+
addressesMap[index].full_address = value;
|
|
4382
|
+
break;
|
|
4383
|
+
case 'Telf':
|
|
4384
|
+
addressesMap[index].phone = value;
|
|
4385
|
+
break;
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
});
|
|
4390
|
+
return Object.values(addressesMap);
|
|
4391
|
+
};
|
|
4358
4392
|
return {
|
|
4359
4393
|
title: typeof props?.texts?.title === 'string'
|
|
4360
4394
|
? props?.texts?.title
|
|
@@ -4402,7 +4436,8 @@ class MapperService {
|
|
|
4402
4436
|
full_address: address.fullAddress,
|
|
4403
4437
|
}))
|
|
4404
4438
|
: [],
|
|
4405
|
-
addressHotels: Array.isArray(props?.addressHotels)
|
|
4439
|
+
addressHotels: Array.isArray(props?.addressHotels) &&
|
|
4440
|
+
props.addressHotels.length > 0
|
|
4406
4441
|
? props.addressHotels.map((address) => ({
|
|
4407
4442
|
id: address.id,
|
|
4408
4443
|
name: address.name,
|
|
@@ -4416,7 +4451,12 @@ class MapperService {
|
|
|
4416
4451
|
email: address.email,
|
|
4417
4452
|
full_address: address.fullAddress,
|
|
4418
4453
|
}))
|
|
4419
|
-
:
|
|
4454
|
+
: (() => {
|
|
4455
|
+
const dynamicAddresses = dynamicHotelsAdresses();
|
|
4456
|
+
return dynamicAddresses && dynamicAddresses.length > 0
|
|
4457
|
+
? dynamicAddresses
|
|
4458
|
+
: undefined;
|
|
4459
|
+
})(),
|
|
4420
4460
|
socialMedia: props?.socialMedia?.map((link) => ({
|
|
4421
4461
|
icon: `babylon-${link.name?.toLowerCase()}`,
|
|
4422
4462
|
url: link.url,
|
|
@@ -6032,16 +6072,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
6032
6072
|
type: Input
|
|
6033
6073
|
}] } });
|
|
6034
6074
|
|
|
6075
|
+
let widgetScriptPromise = null;
|
|
6076
|
+
function loadOnce(src) {
|
|
6077
|
+
if (widgetScriptPromise)
|
|
6078
|
+
return widgetScriptPromise;
|
|
6079
|
+
widgetScriptPromise = new Promise((resolve, reject) => {
|
|
6080
|
+
// Si ya existe, resolvemos
|
|
6081
|
+
if (window.WidgetSearch || window.initializeWidgetSearch) {
|
|
6082
|
+
resolve();
|
|
6083
|
+
return;
|
|
6084
|
+
}
|
|
6085
|
+
const s = document.createElement('script');
|
|
6086
|
+
s.src = src;
|
|
6087
|
+
s.async = true;
|
|
6088
|
+
s.onload = () => resolve();
|
|
6089
|
+
s.onerror = () => reject(new Error('No se pudo cargar el script del widget'));
|
|
6090
|
+
document.head.appendChild(s);
|
|
6091
|
+
});
|
|
6092
|
+
return widgetScriptPromise;
|
|
6093
|
+
}
|
|
6035
6094
|
class BabylonBookingWidgetComponent {
|
|
6036
6095
|
constructor(platformId, zone) {
|
|
6037
|
-
this.platformId = platformId;
|
|
6038
6096
|
this.zone = zone;
|
|
6039
|
-
// Base
|
|
6040
6097
|
this.widgetId = 'widget-search';
|
|
6041
|
-
this.hotelId = '
|
|
6098
|
+
this.hotelId = 'alecad';
|
|
6042
6099
|
this.type = 'chain';
|
|
6043
6100
|
this.theme = 'light';
|
|
6044
|
-
// Extra config (con defaults)
|
|
6045
6101
|
this.currency = 'EUR';
|
|
6046
6102
|
this.locale = 'es-ES';
|
|
6047
6103
|
this.layout = 'inline';
|
|
@@ -6052,63 +6108,96 @@ class BabylonBookingWidgetComponent {
|
|
|
6052
6108
|
this.showPromoCode = true;
|
|
6053
6109
|
this.showChildAges = true;
|
|
6054
6110
|
this.maxChildren = 2;
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
* <lib-babylon-booking-widget [configOverride]="{ currency:'USD', showPrice:true }" />
|
|
6058
|
-
*/
|
|
6059
|
-
this.configOverride = {};
|
|
6060
|
-
this.initialized = false;
|
|
6061
|
-
}
|
|
6062
|
-
ngAfterViewInit() {
|
|
6063
|
-
if (!isPlatformBrowser(this.platformId))
|
|
6111
|
+
this.mounted = false;
|
|
6112
|
+
if (!isPlatformBrowser(platformId))
|
|
6064
6113
|
return;
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6114
|
+
afterNextRender(() => {
|
|
6115
|
+
this.zone.runOutsideAngular(async () => {
|
|
6116
|
+
if (this.mounted)
|
|
6117
|
+
return;
|
|
6118
|
+
// ⬇️ PON AQUÍ la URL real del script de Witbooking
|
|
6119
|
+
await loadOnce('https://widget-engine.b-cdn.net/widget.min.js');
|
|
6120
|
+
this.mount();
|
|
6121
|
+
});
|
|
6122
|
+
});
|
|
6068
6123
|
}
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
if (!WidgetSearch)
|
|
6124
|
+
mount() {
|
|
6125
|
+
if (this.mounted)
|
|
6072
6126
|
return;
|
|
6127
|
+
this.mounted = true;
|
|
6073
6128
|
const el = this.widgetContainer.nativeElement;
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
showHotelSelector: this.showHotelSelector,
|
|
6085
|
-
showPromoCode: this.showPromoCode,
|
|
6086
|
-
showChildAges: this.showChildAges,
|
|
6087
|
-
maxChildren: this.maxChildren,
|
|
6088
|
-
baseUrl: this.baseUrl,
|
|
6089
|
-
urlChain: this.urlChain,
|
|
6090
|
-
urlHotel: this.urlHotel,
|
|
6091
|
-
buttonText: this.buttonText,
|
|
6092
|
-
...this.configOverride, // al final para que pise defaults
|
|
6093
|
-
};
|
|
6094
|
-
this.zone.runOutsideAngular(() => {
|
|
6095
|
-
this.initialized = true;
|
|
6096
|
-
new WidgetSearch(el, config);
|
|
6097
|
-
});
|
|
6098
|
-
}
|
|
6099
|
-
ngOnDestroy() {
|
|
6100
|
-
this.initialized = false;
|
|
6129
|
+
// Opción A (si existe): init global manual :contentReference[oaicite:1]{index=1}
|
|
6130
|
+
if (window.initializeWidgetSearch) {
|
|
6131
|
+
window.initializeWidgetSearch();
|
|
6132
|
+
return;
|
|
6133
|
+
}
|
|
6134
|
+
// Opción B: constructor :contentReference[oaicite:2]{index=2}
|
|
6135
|
+
if (window.WidgetSearch) {
|
|
6136
|
+
// Si tu WidgetSearch acepta (el, config), aquí puedes pasar config.
|
|
6137
|
+
new window.WidgetSearch(el, {});
|
|
6138
|
+
}
|
|
6101
6139
|
}
|
|
6102
6140
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BabylonBookingWidgetComponent, deps: [{ token: PLATFORM_ID }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6103
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: BabylonBookingWidgetComponent, isStandalone: true, selector: "lib-babylon-booking-widget", inputs: { widgetId: "widgetId", hotelId: "hotelId", type: "type", theme: "theme", currency: "currency", locale: "locale", layout: "layout", defaultAdults: "defaultAdults", defaultChildren: "defaultChildren", showPrice: "showPrice", showHotelSelector: "showHotelSelector", showPromoCode: "showPromoCode", showChildAges: "showChildAges", maxChildren: "maxChildren", baseUrl: "baseUrl", urlChain: "urlChain", urlHotel: "urlHotel", buttonText: "buttonText"
|
|
6141
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: BabylonBookingWidgetComponent, isStandalone: true, selector: "lib-babylon-booking-widget", inputs: { widgetId: "widgetId", hotelId: "hotelId", type: "type", theme: "theme", currency: "currency", locale: "locale", layout: "layout", defaultAdults: "defaultAdults", defaultChildren: "defaultChildren", showPrice: "showPrice", showHotelSelector: "showHotelSelector", showPromoCode: "showPromoCode", showChildAges: "showChildAges", maxChildren: "maxChildren", baseUrl: "baseUrl", urlChain: "urlChain", urlHotel: "urlHotel", buttonText: "buttonText" }, viewQueries: [{ propertyName: "widgetContainer", first: true, predicate: ["widgetContainer"], descendants: true, static: true }], ngImport: i0, template: `
|
|
6142
|
+
<div
|
|
6143
|
+
#widgetContainer
|
|
6144
|
+
[id]="widgetId"
|
|
6145
|
+
[attr.data-book-id]="hotelId"
|
|
6146
|
+
[attr.data-type]="type"
|
|
6147
|
+
[attr.data-theme]="theme"
|
|
6148
|
+
[attr.data-currency]="currency"
|
|
6149
|
+
[attr.data-locale]="locale"
|
|
6150
|
+
[attr.data-layout]="layout"
|
|
6151
|
+
[attr.data-default-adults]="defaultAdults"
|
|
6152
|
+
[attr.data-default-children]="defaultChildren"
|
|
6153
|
+
[attr.data-show-price]="showPrice"
|
|
6154
|
+
[attr.data-show-hotel-selector]="showHotelSelector"
|
|
6155
|
+
[attr.data-show-promo-code]="showPromoCode"
|
|
6156
|
+
[attr.data-show-child-ages]="showChildAges"
|
|
6157
|
+
[attr.data-max-children]="maxChildren"
|
|
6158
|
+
[attr.data-base-url]="baseUrl"
|
|
6159
|
+
[attr.data-url-chain]="urlChain"
|
|
6160
|
+
[attr.data-url-hotel]="urlHotel"
|
|
6161
|
+
[attr.data-button-text]="buttonText"
|
|
6162
|
+
></div>
|
|
6163
|
+
`, isInline: true }); }
|
|
6104
6164
|
}
|
|
6105
6165
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BabylonBookingWidgetComponent, decorators: [{
|
|
6106
6166
|
type: Component,
|
|
6107
|
-
args: [{
|
|
6167
|
+
args: [{
|
|
6168
|
+
selector: 'lib-babylon-booking-widget',
|
|
6169
|
+
standalone: true,
|
|
6170
|
+
template: `
|
|
6171
|
+
<div
|
|
6172
|
+
#widgetContainer
|
|
6173
|
+
[id]="widgetId"
|
|
6174
|
+
[attr.data-book-id]="hotelId"
|
|
6175
|
+
[attr.data-type]="type"
|
|
6176
|
+
[attr.data-theme]="theme"
|
|
6177
|
+
[attr.data-currency]="currency"
|
|
6178
|
+
[attr.data-locale]="locale"
|
|
6179
|
+
[attr.data-layout]="layout"
|
|
6180
|
+
[attr.data-default-adults]="defaultAdults"
|
|
6181
|
+
[attr.data-default-children]="defaultChildren"
|
|
6182
|
+
[attr.data-show-price]="showPrice"
|
|
6183
|
+
[attr.data-show-hotel-selector]="showHotelSelector"
|
|
6184
|
+
[attr.data-show-promo-code]="showPromoCode"
|
|
6185
|
+
[attr.data-show-child-ages]="showChildAges"
|
|
6186
|
+
[attr.data-max-children]="maxChildren"
|
|
6187
|
+
[attr.data-base-url]="baseUrl"
|
|
6188
|
+
[attr.data-url-chain]="urlChain"
|
|
6189
|
+
[attr.data-url-hotel]="urlHotel"
|
|
6190
|
+
[attr.data-button-text]="buttonText"
|
|
6191
|
+
></div>
|
|
6192
|
+
`,
|
|
6193
|
+
}]
|
|
6108
6194
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
6109
6195
|
type: Inject,
|
|
6110
6196
|
args: [PLATFORM_ID]
|
|
6111
|
-
}] }, { type: i0.NgZone }], propDecorators: {
|
|
6197
|
+
}] }, { type: i0.NgZone }], propDecorators: { widgetContainer: [{
|
|
6198
|
+
type: ViewChild,
|
|
6199
|
+
args: ['widgetContainer', { static: true }]
|
|
6200
|
+
}], widgetId: [{
|
|
6112
6201
|
type: Input
|
|
6113
6202
|
}], hotelId: [{
|
|
6114
6203
|
type: Input
|
|
@@ -6144,11 +6233,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
6144
6233
|
type: Input
|
|
6145
6234
|
}], buttonText: [{
|
|
6146
6235
|
type: Input
|
|
6147
|
-
}], configOverride: [{
|
|
6148
|
-
type: Input
|
|
6149
|
-
}], widgetContainer: [{
|
|
6150
|
-
type: ViewChild,
|
|
6151
|
-
args: ['widgetContainer', { static: true }]
|
|
6152
6236
|
}] } });
|
|
6153
6237
|
|
|
6154
6238
|
class BabylonBreadcrumbComponent {
|