ng-easycommerce-v18 0.3.22-beta.1 → 0.3.22-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/README.md +3 -1
- package/esm2022/lib/classes/filters/filter.mjs +27 -2
- package/esm2022/lib/ec-components/blocks-ec/block-products-ec/block-products-ec.component.mjs +5 -3
- package/esm2022/lib/ec-components/header-ec/header-ec.component.mjs +32 -23
- package/esm2022/lib/ec-components/related-products-ec/related-products-ec.component.mjs +6 -4
- package/esm2022/lib/ec-components/widgets-ec/magnizoom-ec/magnizoom-ec.component.mjs +4 -2
- package/esm2022/lib/ec-services/analytics/facebook-pixel.service.mjs +4 -2
- package/esm2022/lib/ec-services/analytics/google-analytics.service.mjs +4 -2
- package/esm2022/lib/ec-services/options.service.mjs +27 -3
- package/fesm2022/ng-easycommerce-v18.mjs +97 -29
- package/fesm2022/ng-easycommerce-v18.mjs.map +1 -1
- package/lib/ec-services/options.service.d.ts +4 -0
- package/package.json +1 -1
|
@@ -539,6 +539,10 @@ class OptionsService {
|
|
|
539
539
|
* Maneja las peticiones a la API
|
|
540
540
|
*/
|
|
541
541
|
connection = inject(ConnectionService);
|
|
542
|
+
/**
|
|
543
|
+
* Platform ID para verificar si estamos en el navegador
|
|
544
|
+
*/
|
|
545
|
+
platformId = inject(PLATFORM_ID);
|
|
542
546
|
/**
|
|
543
547
|
* Constantes del core
|
|
544
548
|
*/
|
|
@@ -649,7 +653,26 @@ class OptionsService {
|
|
|
649
653
|
* @returns
|
|
650
654
|
*/
|
|
651
655
|
removeAccents(str) {
|
|
652
|
-
|
|
656
|
+
if (isPlatformBrowser(this.platformId) && typeof String.prototype.normalize === 'function') {
|
|
657
|
+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
658
|
+
}
|
|
659
|
+
// Fallback para SSR - remover acentos manualmente
|
|
660
|
+
return str.replace(/[àáâãäå]/g, 'a')
|
|
661
|
+
.replace(/[èéêë]/g, 'e')
|
|
662
|
+
.replace(/[ìíîï]/g, 'i')
|
|
663
|
+
.replace(/[òóôõö]/g, 'o')
|
|
664
|
+
.replace(/[ùúûü]/g, 'u')
|
|
665
|
+
.replace(/[ýÿ]/g, 'y')
|
|
666
|
+
.replace(/[ñ]/g, 'n')
|
|
667
|
+
.replace(/[ç]/g, 'c')
|
|
668
|
+
.replace(/[ÀÁÂÃÄÅ]/g, 'A')
|
|
669
|
+
.replace(/[ÈÉÊË]/g, 'E')
|
|
670
|
+
.replace(/[ÌÍÎÏ]/g, 'I')
|
|
671
|
+
.replace(/[ÒÓÔÕÖ]/g, 'O')
|
|
672
|
+
.replace(/[ÙÚÛÜ]/g, 'U')
|
|
673
|
+
.replace(/[ÝŸ]/g, 'Y')
|
|
674
|
+
.replace(/[Ñ]/g, 'N')
|
|
675
|
+
.replace(/[Ç]/g, 'C');
|
|
653
676
|
}
|
|
654
677
|
/**
|
|
655
678
|
* Realiza un mapeo de los datos para darle un formato mas entendible a la
|
|
@@ -866,7 +889,9 @@ class FacebookPixelService {
|
|
|
866
889
|
this.renderer.appendChild(this.document?.body, new_analityc_script);
|
|
867
890
|
this.enabled = true;
|
|
868
891
|
}
|
|
869
|
-
|
|
892
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
893
|
+
setTimeout(() => this.callEvent('initialize'), 1000);
|
|
894
|
+
}
|
|
870
895
|
}
|
|
871
896
|
/**
|
|
872
897
|
* Ejecuta el evento pasado por parametro.
|
|
@@ -1083,7 +1108,9 @@ class GoogleAnalyticsService {
|
|
|
1083
1108
|
this.renderer.appendChild(this.document?.head, declaration);
|
|
1084
1109
|
this.enabled = true;
|
|
1085
1110
|
}
|
|
1086
|
-
|
|
1111
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
1112
|
+
setTimeout(() => this.startListeningPageViews(gtm_id), 1000);
|
|
1113
|
+
}
|
|
1087
1114
|
}
|
|
1088
1115
|
/**
|
|
1089
1116
|
*
|
|
@@ -2748,6 +2775,31 @@ class User {
|
|
|
2748
2775
|
}
|
|
2749
2776
|
}
|
|
2750
2777
|
|
|
2778
|
+
/**
|
|
2779
|
+
* Función auxiliar para remover acentos de forma segura para SSR
|
|
2780
|
+
*/
|
|
2781
|
+
function safeRemoveAccents(str) {
|
|
2782
|
+
if (typeof window !== 'undefined' && typeof String.prototype.normalize === 'function') {
|
|
2783
|
+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
2784
|
+
}
|
|
2785
|
+
// Fallback para SSR - remover acentos manualmente
|
|
2786
|
+
return str.replace(/[àáâãäå]/g, 'a')
|
|
2787
|
+
.replace(/[èéêë]/g, 'e')
|
|
2788
|
+
.replace(/[ìíîï]/g, 'i')
|
|
2789
|
+
.replace(/[òóôõö]/g, 'o')
|
|
2790
|
+
.replace(/[ùúûü]/g, 'u')
|
|
2791
|
+
.replace(/[ýÿ]/g, 'y')
|
|
2792
|
+
.replace(/[ñ]/g, 'n')
|
|
2793
|
+
.replace(/[ç]/g, 'c')
|
|
2794
|
+
.replace(/[ÀÁÂÃÄÅ]/g, 'A')
|
|
2795
|
+
.replace(/[ÈÉÊË]/g, 'E')
|
|
2796
|
+
.replace(/[ÌÍÎÏ]/g, 'I')
|
|
2797
|
+
.replace(/[ÒÓÔÕÖ]/g, 'O')
|
|
2798
|
+
.replace(/[ÙÚÛÜ]/g, 'U')
|
|
2799
|
+
.replace(/[ÝŸ]/g, 'Y')
|
|
2800
|
+
.replace(/[Ñ]/g, 'N')
|
|
2801
|
+
.replace(/[Ç]/g, 'C');
|
|
2802
|
+
}
|
|
2751
2803
|
class Filter {
|
|
2752
2804
|
data = [];
|
|
2753
2805
|
multi = false;
|
|
@@ -2767,7 +2819,7 @@ class Filter {
|
|
|
2767
2819
|
throw new Error("Method not implemented.");
|
|
2768
2820
|
}
|
|
2769
2821
|
removeAccents = (str) => {
|
|
2770
|
-
return str
|
|
2822
|
+
return safeRemoveAccents(str);
|
|
2771
2823
|
};
|
|
2772
2824
|
setSelected(element, value) {
|
|
2773
2825
|
//console.log(element, value);
|
|
@@ -6322,17 +6374,21 @@ class HeaderEcComponent extends MenuEcComponent {
|
|
|
6322
6374
|
});
|
|
6323
6375
|
}
|
|
6324
6376
|
onWindowScroll() {
|
|
6325
|
-
|
|
6326
|
-
|
|
6377
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
6378
|
+
const scrollTop = window.scrollY;
|
|
6379
|
+
this.isScrolled = scrollTop > 80;
|
|
6380
|
+
}
|
|
6327
6381
|
}
|
|
6328
6382
|
isHomeFunction() {
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
if (
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6383
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
6384
|
+
const headerElement = document.querySelector('header');
|
|
6385
|
+
if (headerElement) {
|
|
6386
|
+
if (this.router.url !== '/home') {
|
|
6387
|
+
headerElement.classList.add('show-menu');
|
|
6388
|
+
}
|
|
6389
|
+
else {
|
|
6390
|
+
headerElement.classList.remove('show-menu');
|
|
6391
|
+
}
|
|
6336
6392
|
}
|
|
6337
6393
|
}
|
|
6338
6394
|
}
|
|
@@ -6356,26 +6412,30 @@ class HeaderEcComponent extends MenuEcComponent {
|
|
|
6356
6412
|
}
|
|
6357
6413
|
};
|
|
6358
6414
|
borrarInput(inputId) {
|
|
6359
|
-
if (
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
input.value = '';
|
|
6363
|
-
}
|
|
6364
|
-
}
|
|
6365
|
-
else {
|
|
6366
|
-
const inputs = ['searchInput1'];
|
|
6367
|
-
inputs.forEach((id) => {
|
|
6368
|
-
const input = document.getElementById(id);
|
|
6415
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
6416
|
+
if (inputId) {
|
|
6417
|
+
const input = document.getElementById(inputId);
|
|
6369
6418
|
if (input) {
|
|
6370
6419
|
input.value = '';
|
|
6371
6420
|
}
|
|
6372
|
-
}
|
|
6421
|
+
}
|
|
6422
|
+
else {
|
|
6423
|
+
const inputs = ['searchInput1'];
|
|
6424
|
+
inputs.forEach((id) => {
|
|
6425
|
+
const input = document.getElementById(id);
|
|
6426
|
+
if (input) {
|
|
6427
|
+
input.value = '';
|
|
6428
|
+
}
|
|
6429
|
+
});
|
|
6430
|
+
}
|
|
6373
6431
|
}
|
|
6374
6432
|
this.searchValue = '';
|
|
6375
6433
|
this.coreConstantsService.searchValue = '';
|
|
6376
6434
|
this.getCollectionSearch();
|
|
6377
6435
|
}
|
|
6378
6436
|
setupMobileMenu() {
|
|
6437
|
+
if (!isPlatformBrowser(this.platformId))
|
|
6438
|
+
return;
|
|
6379
6439
|
// console.log('setupMobileMenu called');
|
|
6380
6440
|
const menuMobile = document.querySelector('.menuMobile');
|
|
6381
6441
|
if (!(menuMobile instanceof HTMLElement))
|
|
@@ -6411,6 +6471,8 @@ class HeaderEcComponent extends MenuEcComponent {
|
|
|
6411
6471
|
});
|
|
6412
6472
|
}
|
|
6413
6473
|
setupSearchInputs() {
|
|
6474
|
+
if (!isPlatformBrowser(this.platformId))
|
|
6475
|
+
return;
|
|
6414
6476
|
const inputs = ['searchInput1', 'searchInput2'];
|
|
6415
6477
|
inputs.forEach(id => {
|
|
6416
6478
|
const input = document.getElementById(id);
|
|
@@ -7273,7 +7335,7 @@ class BlockProductsEcComponent extends BlockEcComponent {
|
|
|
7273
7335
|
* Permite personalización de las imágenes de las flechas mediante @Input.
|
|
7274
7336
|
*/
|
|
7275
7337
|
setupSwiperNavigation() {
|
|
7276
|
-
if (this.meta?.styles?.carrousel !== false) {
|
|
7338
|
+
if (this.meta?.styles?.carrousel !== false && isPlatformBrowser(this.platformId)) {
|
|
7277
7339
|
// Usar setTimeout para asegurar que el swiper esté inicializado
|
|
7278
7340
|
setTimeout(() => {
|
|
7279
7341
|
this.initializeSwiperWithCustomNavigation();
|
|
@@ -7285,6 +7347,8 @@ class BlockProductsEcComponent extends BlockEcComponent {
|
|
|
7285
7347
|
* Esta función puede ser movida al componente base para reutilización.
|
|
7286
7348
|
*/
|
|
7287
7349
|
initializeSwiperWithCustomNavigation() {
|
|
7350
|
+
if (!isPlatformBrowser(this.platformId))
|
|
7351
|
+
return;
|
|
7288
7352
|
const prevButton = document.getElementById(`${this.meta?.code}-prev`);
|
|
7289
7353
|
const nextButton = document.getElementById(`${this.meta?.code}-next`);
|
|
7290
7354
|
const swiperElement = document.getElementById(this.meta?.code);
|
|
@@ -7650,7 +7714,9 @@ class MagnizoomEcComponent {
|
|
|
7650
7714
|
this.image = this.document.createElement('img');
|
|
7651
7715
|
this.image.onload = () => {
|
|
7652
7716
|
this.lensSize = { width: this.image.width / 2, height: this.image.height / 2 };
|
|
7653
|
-
|
|
7717
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
7718
|
+
setTimeout(() => this.render());
|
|
7719
|
+
}
|
|
7654
7720
|
};
|
|
7655
7721
|
this.image.src = src;
|
|
7656
7722
|
}
|
|
@@ -10957,9 +11023,11 @@ class RelatedProductsEcComponent extends BlockEcComponent {
|
|
|
10957
11023
|
this._relatedProductsSubject.next(relatedProducts);
|
|
10958
11024
|
res.map((products) => this._analyticsService.callEvent('view_item_list', { products: products.items, item_list_name: products.title || 'Related Products', item_list_id: products.id || 'related-products' }));
|
|
10959
11025
|
// Inicializar swiper después de que los datos estén disponibles
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
11026
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
11027
|
+
setTimeout(() => {
|
|
11028
|
+
this.initSwiper();
|
|
11029
|
+
}, 100);
|
|
11030
|
+
}
|
|
10963
11031
|
});
|
|
10964
11032
|
}
|
|
10965
11033
|
initSwiper() {
|