@everymatrix/general-slider-navigation 1.36.0 → 1.37.0

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.
Files changed (30) hide show
  1. package/dist/cjs/carousel-component_2.cjs.entry.js +442 -0
  2. package/dist/cjs/general-slider-navigation.cjs.js +2 -2
  3. package/dist/cjs/{index-3420513e.js → index-d69ac031.js} +0 -13
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +1 -0
  6. package/dist/collection/components/carousel-component/carousel-component.css +167 -0
  7. package/dist/collection/components/carousel-component/carousel-component.js +379 -0
  8. package/dist/collection/components/general-slider-navigation/general-slider-navigation.css +0 -282
  9. package/dist/collection/components/general-slider-navigation/general-slider-navigation.js +34 -307
  10. package/dist/collection/utils/locale.utils.js +24 -2
  11. package/dist/components/carousel-component.d.ts +11 -0
  12. package/dist/components/carousel-component.js +6 -0
  13. package/dist/components/carousel-component2.js +374 -0
  14. package/dist/components/general-slider-navigation.js +25 -294
  15. package/dist/esm/carousel-component_2.entry.js +437 -0
  16. package/dist/esm/general-slider-navigation.js +2 -2
  17. package/dist/esm/{index-22e4ccbc.js → index-a33109c0.js} +0 -13
  18. package/dist/esm/loader.js +2 -2
  19. package/dist/general-slider-navigation/general-slider-navigation.esm.js +1 -1
  20. package/dist/general-slider-navigation/p-734ecc50.js +1 -0
  21. package/dist/general-slider-navigation/p-88323bff.entry.js +1 -0
  22. package/dist/types/components/carousel-component/carousel-component.d.ts +70 -0
  23. package/dist/types/components/general-slider-navigation/general-slider-navigation.d.ts +7 -51
  24. package/dist/types/components.d.ts +77 -40
  25. package/dist/types/utils/locale.utils.d.ts +1 -0
  26. package/package.json +1 -1
  27. package/dist/cjs/general-slider-navigation.cjs.entry.js +0 -369
  28. package/dist/esm/general-slider-navigation.entry.js +0 -365
  29. package/dist/general-slider-navigation/p-2f9afaa5.entry.js +0 -1
  30. package/dist/general-slider-navigation/p-b72fe935.js +0 -1
@@ -24,69 +24,25 @@ export declare class GeneralSliderNavigation {
24
24
  */
25
25
  userRoles: string;
26
26
  /**
27
- * Show slider navigate arrows
27
+ * Show bullet navigation under slides
28
28
  */
29
- showSliderArrows: boolean;
29
+ bulletNavigation: boolean;
30
30
  /**
31
- * Show slider navigate arrows on mobile
31
+ * Timer for auto sliding
32
32
  */
33
- showSliderArrowsMobile: boolean;
33
+ slideTimer: number;
34
34
  /**
35
- * You will see a fixed grid without a slider when using a mobile device.
36
- */
37
- showMobileGrid: boolean;
38
- /**
39
- * Set if you want to have a slider on mobile device.
40
- */
41
- showNavigationSliderMobile: boolean;
42
- /**
43
- * Set if you want to have a slider on desktop.
44
- */
45
- showNavigationSliderDesktop: boolean;
46
- /**
47
- * Specify the number of items you would like to be displayed on desktop.
48
- */
49
- itemsPerPageDesktop: number;
50
- /**
51
- * Specify the number of items you would like to be displayed on mobile devices.
35
+ * Translation via url
52
36
  */
53
- itemsPerPageMobile: number;
54
- el: HTMLElement;
37
+ translationUrl: string;
55
38
  private isLoading;
56
- private limitStylingAppends;
57
39
  hasErrors: boolean;
58
40
  device: string;
59
- activeIndex: number;
60
- sliderMenuElementWidth: number;
61
- private userAgent;
62
41
  private sliderData;
63
- private stylingContainer;
64
- isMobile: boolean;
65
- allElementsWidth: number;
66
- sliderMenuElement: HTMLElement;
67
42
  slider: HTMLElement;
68
- xDown: number;
69
- yDown: number;
43
+ handleNewTranslations(): void;
70
44
  watchEndpoint(newValue: string, oldValue: string): void;
71
- connectedCallback(): void;
72
45
  componentWillLoad(): Promise<void>;
73
- componentDidLoad(): void;
74
- componentDidRender(): void;
75
- componentDidUpdate(): void;
76
- disconnectedCallback(): void;
77
46
  getGeneralSliderNavigation(): Promise<any>;
78
- handleTouchStart(evt: any): void;
79
- resizeHandler: () => void;
80
- orientationChangeHandler: () => void;
81
- handleTouchMove(evt: any): void;
82
- navigationTo: (url: string, target: string, isExternal: boolean) => void;
83
- calculateSliderWidth(): void;
84
- getTouches(evt: any): void;
85
- setActive(index: number): void;
86
- move(direction: any): void;
87
- goTo(index: number): void;
88
- setImage: (image: any) => string;
89
- setClientStyling: () => void;
90
- setClientStylingURL: () => void;
91
47
  render(): any;
92
48
  }
@@ -6,7 +6,11 @@
6
6
  */
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
8
  export namespace Components {
9
- interface GeneralSliderNavigation {
9
+ interface CarouselComponent {
10
+ /**
11
+ * Show bullet navigation under slides
12
+ */
13
+ "bulletNavigation": boolean;
10
14
  /**
11
15
  * Client custom styling via inline style
12
16
  */
@@ -15,46 +19,56 @@ export namespace Components {
15
19
  * Client custom styling via url
16
20
  */
17
21
  "clientStylingUrl": string;
22
+ /**
23
+ * Language of the widget
24
+ */
25
+ "language": string;
26
+ /**
27
+ * Timer for auto sliding
28
+ */
29
+ "slideTimer": number;
18
30
  /**
19
31
  * Endpoint URL for the source of data
20
32
  */
21
- "cmsEndpoint": string;
33
+ "sliderData": Array<any>;
22
34
  /**
23
- * CMS Endpoint stage
35
+ * Translation via url
24
36
  */
25
- "cmsEnv": string;
37
+ "translationUrl": string;
38
+ }
39
+ interface GeneralSliderNavigation {
26
40
  /**
27
- * Specify the number of items you would like to be displayed on desktop.
41
+ * Show bullet navigation under slides
28
42
  */
29
- "itemsPerPageDesktop": number;
43
+ "bulletNavigation": boolean;
30
44
  /**
31
- * Specify the number of items you would like to be displayed on mobile devices.
45
+ * Client custom styling via inline style
32
46
  */
33
- "itemsPerPageMobile": number;
47
+ "clientStyling": string;
34
48
  /**
35
- * Language of the widget
49
+ * Client custom styling via url
36
50
  */
37
- "language": string;
51
+ "clientStylingUrl": string;
38
52
  /**
39
- * You will see a fixed grid without a slider when using a mobile device.
53
+ * Endpoint URL for the source of data
40
54
  */
41
- "showMobileGrid": boolean;
55
+ "cmsEndpoint": string;
42
56
  /**
43
- * Set if you want to have a slider on desktop.
57
+ * CMS Endpoint stage
44
58
  */
45
- "showNavigationSliderDesktop": boolean;
59
+ "cmsEnv": string;
46
60
  /**
47
- * Set if you want to have a slider on mobile device.
61
+ * Language of the widget
48
62
  */
49
- "showNavigationSliderMobile": boolean;
63
+ "language": string;
50
64
  /**
51
- * Show slider navigate arrows
65
+ * Timer for auto sliding
52
66
  */
53
- "showSliderArrows": boolean;
67
+ "slideTimer": number;
54
68
  /**
55
- * Show slider navigate arrows on mobile
69
+ * Translation via url
56
70
  */
57
- "showSliderArrowsMobile": boolean;
71
+ "translationUrl": string;
58
72
  /**
59
73
  * User roles
60
74
  */
@@ -62,6 +76,12 @@ export namespace Components {
62
76
  }
63
77
  }
64
78
  declare global {
79
+ interface HTMLCarouselComponentElement extends Components.CarouselComponent, HTMLStencilElement {
80
+ }
81
+ var HTMLCarouselComponentElement: {
82
+ prototype: HTMLCarouselComponentElement;
83
+ new (): HTMLCarouselComponentElement;
84
+ };
65
85
  interface HTMLGeneralSliderNavigationElement extends Components.GeneralSliderNavigation, HTMLStencilElement {
66
86
  }
67
87
  var HTMLGeneralSliderNavigationElement: {
@@ -69,11 +89,16 @@ declare global {
69
89
  new (): HTMLGeneralSliderNavigationElement;
70
90
  };
71
91
  interface HTMLElementTagNameMap {
92
+ "carousel-component": HTMLCarouselComponentElement;
72
93
  "general-slider-navigation": HTMLGeneralSliderNavigationElement;
73
94
  }
74
95
  }
75
96
  declare namespace LocalJSX {
76
- interface GeneralSliderNavigation {
97
+ interface CarouselComponent {
98
+ /**
99
+ * Show bullet navigation under slides
100
+ */
101
+ "bulletNavigation"?: boolean;
77
102
  /**
78
103
  * Client custom styling via inline style
79
104
  */
@@ -82,52 +107,63 @@ declare namespace LocalJSX {
82
107
  * Client custom styling via url
83
108
  */
84
109
  "clientStylingUrl"?: string;
110
+ /**
111
+ * Language of the widget
112
+ */
113
+ "language"?: string;
114
+ /**
115
+ * Timer for auto sliding
116
+ */
117
+ "slideTimer"?: number;
85
118
  /**
86
119
  * Endpoint URL for the source of data
87
120
  */
88
- "cmsEndpoint": string;
121
+ "sliderData"?: Array<any>;
89
122
  /**
90
- * CMS Endpoint stage
123
+ * Translation via url
91
124
  */
92
- "cmsEnv"?: string;
125
+ "translationUrl"?: string;
126
+ }
127
+ interface GeneralSliderNavigation {
93
128
  /**
94
- * Specify the number of items you would like to be displayed on desktop.
129
+ * Show bullet navigation under slides
95
130
  */
96
- "itemsPerPageDesktop"?: number;
131
+ "bulletNavigation"?: boolean;
97
132
  /**
98
- * Specify the number of items you would like to be displayed on mobile devices.
133
+ * Client custom styling via inline style
99
134
  */
100
- "itemsPerPageMobile"?: number;
135
+ "clientStyling"?: string;
101
136
  /**
102
- * Language of the widget
137
+ * Client custom styling via url
103
138
  */
104
- "language"?: string;
139
+ "clientStylingUrl"?: string;
105
140
  /**
106
- * You will see a fixed grid without a slider when using a mobile device.
141
+ * Endpoint URL for the source of data
107
142
  */
108
- "showMobileGrid"?: boolean;
143
+ "cmsEndpoint": string;
109
144
  /**
110
- * Set if you want to have a slider on desktop.
145
+ * CMS Endpoint stage
111
146
  */
112
- "showNavigationSliderDesktop"?: boolean;
147
+ "cmsEnv"?: string;
113
148
  /**
114
- * Set if you want to have a slider on mobile device.
149
+ * Language of the widget
115
150
  */
116
- "showNavigationSliderMobile"?: boolean;
151
+ "language"?: string;
117
152
  /**
118
- * Show slider navigate arrows
153
+ * Timer for auto sliding
119
154
  */
120
- "showSliderArrows"?: boolean;
155
+ "slideTimer"?: number;
121
156
  /**
122
- * Show slider navigate arrows on mobile
157
+ * Translation via url
123
158
  */
124
- "showSliderArrowsMobile"?: boolean;
159
+ "translationUrl"?: string;
125
160
  /**
126
161
  * User roles
127
162
  */
128
163
  "userRoles"?: string;
129
164
  }
130
165
  interface IntrinsicElements {
166
+ "carousel-component": CarouselComponent;
131
167
  "general-slider-navigation": GeneralSliderNavigation;
132
168
  }
133
169
  }
@@ -135,6 +171,7 @@ export { LocalJSX as JSX };
135
171
  declare module "@stencil/core" {
136
172
  export namespace JSX {
137
173
  interface IntrinsicElements {
174
+ "carousel-component": LocalJSX.CarouselComponent & JSXBase.HTMLAttributes<HTMLCarouselComponentElement>;
138
175
  "general-slider-navigation": LocalJSX.GeneralSliderNavigation & JSXBase.HTMLAttributes<HTMLGeneralSliderNavigationElement>;
139
176
  }
140
177
  }
@@ -1 +1,2 @@
1
+ export declare const getTranslations: (url: string) => Promise<unknown>;
1
2
  export declare const translate: (key: string, customLang?: any) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/general-slider-navigation",
3
- "version": "1.36.0",
3
+ "version": "1.37.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1,369 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-3420513e.js');
6
-
7
- const DEFAULT_LANGUAGE = 'en';
8
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hu', 'hr'];
9
- const TRANSLATIONS = {
10
- en: {
11
- error: 'Error',
12
- noResults: 'Loading, please wait ...',
13
- },
14
- hu: {
15
- error: 'Error',
16
- noResults: 'Loading, please wait ...',
17
- },
18
- ro: {
19
- error: 'Eroare',
20
- noResults: 'Loading, please wait ...',
21
- },
22
- fr: {
23
- error: 'Error',
24
- noResults: 'Loading, please wait ...',
25
- },
26
- ar: {
27
- error: 'خطأ',
28
- noResults: 'Loading, please wait ...',
29
- },
30
- hr: {
31
- error: 'Greška',
32
- noResults: 'Učitavanje, molimo pričekajte ...',
33
- },
34
- 'pt-br': {
35
- 'error': 'Erro',
36
- 'noResults': 'Carregando, espere por favor…'
37
- },
38
- 'es-mx': {
39
- 'error': 'Error',
40
- 'noResults': 'Cargando, espere por favor…'
41
- }
42
- };
43
- const translate = (key, customLang) => {
44
- const lang = customLang;
45
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
46
- };
47
-
48
- /**
49
- * @name isMobile
50
- * @description A method that returns if the browser used to access the app is from a mobile device or not
51
- * @param {String} userAgent window.navigator.userAgent
52
- * @returns {Boolean} true or false
53
- */
54
- const isMobile = (userAgent) => {
55
- return !!(userAgent.toLowerCase().match(/android/i) ||
56
- userAgent.toLowerCase().match(/blackberry|bb/i) ||
57
- userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
58
- userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
59
- };
60
- const getDevice = () => {
61
- let userAgent = window.navigator.userAgent;
62
- if (userAgent.toLowerCase().match(/android/i)) {
63
- return 'Android';
64
- }
65
- if (userAgent.toLowerCase().match(/iphone/i)) {
66
- return 'iPhone';
67
- }
68
- if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
69
- return 'iPad';
70
- }
71
- return 'PC';
72
- };
73
- const getDevicePlatform = () => {
74
- const device = getDevice();
75
- if (device) {
76
- if (device === 'PC') {
77
- return 'dk';
78
- }
79
- else if (device === 'iPad' || device === 'iPhone') {
80
- return 'ios';
81
- }
82
- else {
83
- return 'mtWeb';
84
- }
85
- }
86
- };
87
- function checkDeviceType() {
88
- const userAgent = navigator.userAgent.toLowerCase();
89
- const width = screen.availWidth;
90
- const height = screen.availHeight;
91
- if (userAgent.includes('iphone')) {
92
- return 'mobile';
93
- }
94
- if (userAgent.includes('android')) {
95
- if (height > width && width < 800) {
96
- return 'mobile';
97
- }
98
- if (width > height && height < 800) {
99
- return 'tablet';
100
- }
101
- }
102
- return 'desktop';
103
- }
104
-
105
- const generalSliderNavigationCss = ":host {\n display: block;\n}\n\n.PageError {\n display: flex;\n justify-content: center;\n flex-direction: column;\n}\n.PageError.TitleError {\n color: red;\n}\n\nmain {\n width: 100%;\n overflow: hidden;\n}\n\n.SliderItemsWrapper {\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n\n.SliderWrapperContent {\n display: flex;\n justify-content: center;\n flex-direction: row;\n width: 100%;\n}\n\n.SliderItems {\n display: flex;\n transition: transform 0.4s ease-in-out;\n transform: translateX(0px);\n}\n\n.SliderItem {\n flex: 0 0 auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n border-radius: 5px;\n user-select: none;\n}\n\n.GridContainer {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n width: 220px;\n height: 320px;\n border-radius: 5px;\n margin-bottom: 20px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n}\n.GridContainer .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainer .SliderImage img {\n object-fit: cover;\n height: 320px;\n width: 220px;\n border-radius: 5px;\n}\n.GridContainer .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n}\n.GridContainer .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n}\n.GridContainer .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n}\n\n.GridItems {\n display: grid;\n grid-template-columns: 49vw 49vw;\n grid-template-rows: auto auto;\n place-content: unset;\n gap: 2vw;\n margin: 0;\n width: 100vw;\n}\n\n.GridContainerMobile {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n width: 49vw;\n height: 240px;\n border-radius: 15px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n}\n.GridContainerMobile .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainerMobile .SliderImage img {\n width: 49vw;\n object-fit: cover;\n height: 240px;\n border-radius: 5px;\n}\n.GridContainerMobile .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-flow: column;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n}\n.GridContainerMobile .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n}\n.GridContainerMobile .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n}\n\n.GridContainerMobile:nth-last-child(1):nth-child(odd) {\n display: grid;\n gap: 0px 0px;\n margin: auto;\n width: 100vw;\n}\n.GridContainerMobile:nth-last-child(1):nth-child(odd) .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainerMobile:nth-last-child(1):nth-child(odd) .SliderImage img {\n width: 100vw;\n object-fit: cover;\n height: 240px;\n border-radius: 5px;\n}\n\n.SliderNavButton {\n border: 0px;\n width: 45px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.SliderNavButton svg {\n width: 40px;\n stroke: var(--emfe-w-color-secondary, #FD2839);\n}\n\n.DisabledArrow svg {\n opacity: 0.2;\n stroke: var(--emfe-w-color-secondary, #FD2839);\n pointer-events: none;\n}\n\n@container (max-width: 475px) {\n .SliderItem {\n display: grid;\n grid-template-columns: repeat(auto-fill, max(250px, 1fr));\n color: var(--emfe-w-color-secondary, #FD2839);\n border-radius: 5px;\n user-select: none;\n }\n\n .GridContainer {\n display: grid;\n grid-template-columns: repeat(auto-fill, max(250px, 1fr));\n gap: 10px;\n margin: auto;\n width: 90%;\n height: 220px;\n border-radius: 5px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n }\n .GridContainer .SliderImage {\n grid-area: 1/1/2/2;\n }\n .GridContainer .SliderImage img {\n object-fit: cover;\n height: 220px;\n width: 100%;\n border-radius: 5px;\n }\n .GridContainer .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 40px;\n }\n .GridContainer .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n }\n .GridContainer .SliderContent .Title {\n font-size: 16px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n }\n\n .GridItems {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-template-rows: auto auto auto auto;\n gap: 2cqw;\n width: 100cqw;\n justify-items: stretch;\n }\n\n .GridContainerMobile {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n height: 200px;\n border-radius: 15px;\n background: white;\n cursor: pointer;\n }\n .GridContainerMobile .SliderImage {\n grid-area: 1/1/2/2;\n }\n .GridContainerMobile .SliderImage img {\n object-fit: cover;\n height: 200px;\n border-radius: 5px;\n }\n .GridContainerMobile .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-flow: column;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n }\n .GridContainerMobile .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n }\n .GridContainerMobile .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n }\n}";
106
-
107
- const GeneralSliderNavigation = class {
108
- constructor(hostRef) {
109
- index.registerInstance(this, hostRef);
110
- /**
111
- * Client custom styling via inline style
112
- */
113
- this.clientStyling = '';
114
- /**
115
- * Client custom styling via url
116
- */
117
- this.clientStylingUrl = '';
118
- /**
119
- * CMS Endpoint stage
120
- */
121
- this.cmsEnv = 'stage';
122
- /**
123
- * Language of the widget
124
- */
125
- this.language = 'en';
126
- /**
127
- * User roles
128
- */
129
- this.userRoles = 'everyone';
130
- /**
131
- * Show slider navigate arrows
132
- */
133
- this.showSliderArrows = true;
134
- /**
135
- * Show slider navigate arrows on mobile
136
- */
137
- this.showSliderArrowsMobile = true;
138
- /**
139
- * You will see a fixed grid without a slider when using a mobile device.
140
- */
141
- this.showMobileGrid = false;
142
- /**
143
- * Set if you want to have a slider on mobile device.
144
- */
145
- this.showNavigationSliderMobile = true;
146
- /**
147
- * Set if you want to have a slider on desktop.
148
- */
149
- this.showNavigationSliderDesktop = true;
150
- /**
151
- * Specify the number of items you would like to be displayed on desktop.
152
- */
153
- this.itemsPerPageDesktop = 3;
154
- /**
155
- * Specify the number of items you would like to be displayed on mobile devices.
156
- */
157
- this.itemsPerPageMobile = 2;
158
- this.isLoading = true;
159
- this.limitStylingAppends = false;
160
- this.hasErrors = false;
161
- this.device = '';
162
- this.activeIndex = 0;
163
- this.sliderMenuElementWidth = 0;
164
- this.userAgent = window.navigator.userAgent;
165
- this.isMobile = isMobile(this.userAgent);
166
- this.allElementsWidth = 0;
167
- this.xDown = null;
168
- this.yDown = null;
169
- this.resizeHandler = () => {
170
- this.calculateSliderWidth();
171
- };
172
- this.orientationChangeHandler = () => {
173
- setTimeout(() => {
174
- this.calculateSliderWidth();
175
- }, 10);
176
- };
177
- this.navigationTo = (url, target, isExternal) => {
178
- window.postMessage({ type: 'NavigateTo', path: url, target: target || null, externalLink: isExternal || false }, window.location.href);
179
- };
180
- this.setImage = (image) => {
181
- let source = '';
182
- this.device = checkDeviceType();
183
- switch (this.device) {
184
- case 'mobile':
185
- source = image.srcMobile;
186
- break;
187
- case 'tablet':
188
- source = image.srcTablet;
189
- break;
190
- case 'desktop':
191
- source = image.srcDesktop;
192
- break;
193
- }
194
- return source;
195
- };
196
- this.setClientStyling = () => {
197
- let sheet = document.createElement('style');
198
- sheet.innerHTML = this.clientStyling;
199
- this.stylingContainer.prepend(sheet);
200
- };
201
- this.setClientStylingURL = () => {
202
- let url = new URL(this.clientStylingUrl);
203
- let cssFile = document.createElement('style');
204
- fetch(url.href)
205
- .then((res) => res.text())
206
- .then((data) => {
207
- cssFile.innerHTML = data;
208
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
209
- })
210
- .catch((err) => {
211
- console.log('error ', err);
212
- });
213
- };
214
- }
215
- watchEndpoint(newValue, oldValue) {
216
- if (newValue && newValue != oldValue && this.cmsEndpoint) {
217
- this.getGeneralSliderNavigation().then((GeneralSliderNavigation) => {
218
- this.sliderData = GeneralSliderNavigation;
219
- });
220
- }
221
- }
222
- connectedCallback() {
223
- window.screen.orientation.addEventListener('change', this.orientationChangeHandler);
224
- }
225
- componentWillLoad() {
226
- if (this.cmsEndpoint && this.language) {
227
- return this.getGeneralSliderNavigation().then((GeneralSliderNavigation) => {
228
- this.sliderData = GeneralSliderNavigation;
229
- });
230
- }
231
- }
232
- componentDidLoad() {
233
- window.addEventListener('resize', this.resizeHandler);
234
- }
235
- componentDidRender() {
236
- this.el.addEventListener('touchstart', this.handleTouchStart.bind(this), { passive: true });
237
- this.el.addEventListener('touchmove', this.handleTouchMove.bind(this), { passive: true });
238
- // start custom styling area
239
- if (!this.limitStylingAppends && this.stylingContainer) {
240
- if (this.clientStyling)
241
- this.setClientStyling();
242
- this.limitStylingAppends = true;
243
- }
244
- // end custom styling area
245
- }
246
- componentDidUpdate() {
247
- this.calculateSliderWidth();
248
- }
249
- disconnectedCallback() {
250
- this.el.removeEventListener('touchstart', this.handleTouchStart);
251
- this.el.removeEventListener('touchmove', this.handleTouchMove);
252
- window.screen.orientation.removeEventListener('change', this.orientationChangeHandler);
253
- window.removeEventListener('resize', this.resizeHandler);
254
- }
255
- getGeneralSliderNavigation() {
256
- let url = new URL(`${this.cmsEndpoint}/${this.language}/homepage`);
257
- url.searchParams.append('env', this.cmsEnv);
258
- url.searchParams.append('userRoles', this.userRoles);
259
- url.searchParams.append('device', getDevicePlatform());
260
- return new Promise((resolve, reject) => {
261
- this.isLoading = true;
262
- fetch(url.href)
263
- .then((res) => res.json())
264
- .then((menuSliderData) => {
265
- resolve(menuSliderData.banners);
266
- })
267
- .catch((err) => {
268
- console.error(err);
269
- this.hasErrors = true;
270
- reject(err);
271
- }).finally(() => {
272
- this.isLoading = false;
273
- });
274
- });
275
- }
276
- handleTouchStart(evt) {
277
- const firstTouch = this.getTouches(evt)[0];
278
- this.xDown = firstTouch.clientX;
279
- this.yDown = firstTouch.clientY;
280
- }
281
- handleTouchMove(evt) {
282
- if (!this.xDown || !this.yDown)
283
- return;
284
- let xUp = evt.touches[0].clientX;
285
- let yUp = evt.touches[0].clientY;
286
- let xDiff = this.xDown - xUp;
287
- let yDiff = this.yDown - yUp;
288
- if (Math.abs(xDiff) > Math.abs(yDiff)) {
289
- if (xDiff > 0) {
290
- this.move(1);
291
- }
292
- else {
293
- this.move(-1);
294
- }
295
- }
296
- this.xDown = null;
297
- this.yDown = null;
298
- }
299
- ;
300
- calculateSliderWidth() {
301
- if (!this.sliderMenuElement)
302
- return;
303
- this.sliderMenuElementWidth = this.sliderMenuElement.clientWidth;
304
- }
305
- ;
306
- getTouches(evt) {
307
- return evt.touches || evt.originalEvent.touches;
308
- }
309
- setActive(index) {
310
- const maxLength = Math.ceil(this.sliderData.length / (!this.isMobile ? this.itemsPerPageDesktop : this.itemsPerPageMobile));
311
- if (index >= 0) {
312
- if (index >= maxLength - 1) {
313
- this.activeIndex = maxLength - 1;
314
- }
315
- else {
316
- this.activeIndex = index;
317
- }
318
- }
319
- else {
320
- this.activeIndex = 0;
321
- }
322
- }
323
- move(direction) {
324
- this.setActive(this.activeIndex + direction);
325
- }
326
- ;
327
- goTo(index) {
328
- let diff = this.activeIndex - index;
329
- if (diff > 0) {
330
- for (let i = 0; i < diff; i++) {
331
- this.move(-1);
332
- }
333
- }
334
- else {
335
- for (let i = 0; i > diff; i--) {
336
- this.move(1);
337
- }
338
- }
339
- }
340
- render() {
341
- const styles = {
342
- transform: `translate(${(+this.sliderMenuElementWidth * this.activeIndex) * -1}px, 0px)`
343
- };
344
- const itemStyleDesktop = {
345
- width: `${this.sliderMenuElementWidth / Math.ceil(this.itemsPerPageDesktop)}px`
346
- };
347
- const itemStyleMobile = {
348
- width: `${this.sliderMenuElementWidth / this.itemsPerPageMobile}px`
349
- };
350
- if (this.hasErrors) {
351
- return (index.h("div", { class: "PageError" }, index.h("div", { class: "TitleError" }, translate('error', this.language))));
352
- }
353
- if (!this.isLoading) {
354
- return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "SliderWrapper" }, index.h("div", { class: "SliderWrapperContent", ref: (el) => this.slider = el }, ((this.showSliderArrows && !this.isMobile) || (this.showSliderArrowsMobile && this.isMobile)) &&
355
- index.h("div", { class: this.activeIndex === 0 ? 'SliderNavButton DisabledArrow' : 'SliderNavButton', onClick: () => this.move(-1) }, index.h("svg", { fill: "none", stroke: "var(--emfe-w-color-secondary, #FD2839)", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))), this.showNavigationSliderMobile && this.isMobile ? (index.h("main", null, index.h("div", { style: styles, ref: (el) => this.sliderMenuElement = el, class: "SliderItems" }, this.sliderData.map((data) => index.h("div", { class: "SliderItem", style: itemStyleMobile }, index.h("div", { class: "GridContainer", onClick: () => data.externalLink ? this.navigationTo(data.url, data.targetType, data.externalLink) : this.navigationTo(data.url, data.targetType, false) }, index.h("div", { class: "SliderImage" }, index.h("img", { src: this.setImage(data.image), alt: data.title })), index.h("div", { class: "SliderContent" }, index.h("div", { class: "DividerElement" }), index.h("div", { class: "Title" }, data.title)))))))) : (this.showNavigationSliderDesktop && !this.isMobile &&
356
- index.h("main", null, index.h("div", { class: "SliderItems", style: styles, ref: (el) => this.sliderMenuElement = el }, index.h("div", { class: "SliderItemsWrapper" }, this.sliderData.map((data) => index.h("div", { class: "SliderItem", style: itemStyleDesktop }, index.h("div", { class: "GridContainer", onClick: () => data.externalLink ? this.navigationTo(data.url, data.targetType, data.externalLink) : this.navigationTo(data.url, data.targetType, false) }, index.h("div", { class: "SliderImage" }, index.h("img", { src: this.setImage(data.image), alt: data.title })), index.h("div", { class: "SliderContent" }, index.h("div", { class: "DividerElement" }), index.h("div", { class: "Title" }, data.title))))))))), ((this.showSliderArrows && !this.isMobile) || (this.showSliderArrowsMobile && this.isMobile)) &&
357
- index.h("div", { class: this.activeIndex === Math.ceil(this.sliderData.length / (!this.isMobile ? this.itemsPerPageDesktop : this.itemsPerPageMobile)) - 1 ? ' SliderNavButton DisabledArrow disabled' : 'SliderNavButton', onClick: () => this.move(1) }, index.h("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" }))))), (this.showMobileGrid && this.isMobile) &&
358
- index.h("main", { class: "GridItems GridMobile" }, this.sliderData.map((dataMobile) => index.h("div", { class: "GridContainerMobile", onClick: () => dataMobile.externalLink ? this.navigationTo(dataMobile.url, dataMobile.targetType, dataMobile.externalLink) : this.navigationTo(dataMobile.url, dataMobile.targetType, false) }, index.h("div", { class: "SliderImage" }, index.h("img", { src: this.setImage(dataMobile.image), alt: dataMobile.title })), index.h("div", { class: "SliderContent" }, index.h("div", { class: "DividerElement" }), index.h("div", { class: "Title" }, dataMobile.title)))))));
359
- }
360
- }
361
- get el() { return index.getElement(this); }
362
- static get watchers() { return {
363
- "cmsEndpoint": ["watchEndpoint"],
364
- "language": ["watchEndpoint"]
365
- }; }
366
- };
367
- GeneralSliderNavigation.style = generalSliderNavigationCss;
368
-
369
- exports.general_slider_navigation = GeneralSliderNavigation;