@ptcwebops/ptcw-design 0.4.9 → 0.5.1

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 (213) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/icon-asset.cjs.entry.js +53 -53
  3. package/dist/cjs/{interfaces-574e6df7.js → interfaces-0ecd8027.js} +9 -9
  4. package/dist/cjs/list-item.cjs.entry.js +19 -19
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/lottie-player.cjs.entry.js +354 -354
  7. package/dist/cjs/my-component.cjs.entry.js +13 -13
  8. package/dist/cjs/ptc-announcement_2.cjs.entry.js +113 -112
  9. package/dist/cjs/ptc-breadcrumb.cjs.entry.js +12 -12
  10. package/dist/cjs/ptc-button.cjs.entry.js +65 -65
  11. package/dist/cjs/ptc-card-bottom.cjs.entry.js +31 -31
  12. package/dist/cjs/ptc-card-content.cjs.entry.js +31 -31
  13. package/dist/cjs/ptc-card-plm.cjs.entry.js +16 -16
  14. package/dist/cjs/ptc-card.cjs.entry.js +68 -68
  15. package/dist/cjs/ptc-countdown.cjs.entry.js +8 -8
  16. package/dist/cjs/ptc-date.cjs.entry.js +48 -48
  17. package/dist/cjs/ptc-footer.cjs.entry.js +8 -8
  18. package/dist/cjs/ptc-form.cjs.entry.js +104 -104
  19. package/dist/cjs/ptc-hero-footer-cta.cjs.entry.js +8 -8
  20. package/dist/cjs/ptc-hero.cjs.entry.js +18 -18
  21. package/dist/cjs/ptc-icon-list.cjs.entry.js +32 -32
  22. package/dist/cjs/ptc-img_2.cjs.entry.js +169 -169
  23. package/dist/cjs/ptc-input.cjs.entry.js +20 -20
  24. package/dist/cjs/ptc-link.cjs.entry.js +42 -42
  25. package/dist/cjs/ptc-list.cjs.entry.js +20 -20
  26. package/dist/cjs/ptc-lottie.cjs.entry.js +12 -12
  27. package/dist/cjs/ptc-minimized-footer.cjs.entry.js +8 -8
  28. package/dist/cjs/ptc-minimized-header.cjs.entry.js +11 -11
  29. package/dist/cjs/ptc-mobile-select.cjs.entry.js +69 -69
  30. package/dist/cjs/ptc-modal.cjs.entry.js +103 -103
  31. package/dist/cjs/ptc-nav-item.cjs.entry.js +83 -83
  32. package/dist/cjs/ptc-nav.cjs.entry.js +8 -8
  33. package/dist/cjs/ptc-para.cjs.entry.js +39 -39
  34. package/dist/cjs/ptc-picture.cjs.entry.js +169 -169
  35. package/dist/cjs/ptc-previous-url.cjs.entry.js +8 -8
  36. package/dist/cjs/ptc-quote.cjs.entry.js +25 -25
  37. package/dist/cjs/ptc-responsive-wrapper.cjs.entry.js +54 -54
  38. package/dist/cjs/ptc-select.cjs.entry.js +24 -24
  39. package/dist/cjs/ptc-social-share.cjs.entry.js +64 -64
  40. package/dist/cjs/ptc-spacer.cjs.entry.js +35 -35
  41. package/dist/cjs/ptc-span.cjs.entry.js +23 -23
  42. package/dist/cjs/ptc-title.cjs.entry.js +44 -44
  43. package/dist/cjs/ptc-two-column-media.cjs.entry.js +14 -14
  44. package/dist/cjs/ptcw-design.cjs.js +1 -1
  45. package/dist/collection/components/icon-asset/icon-asset.css +4 -4
  46. package/dist/collection/components/icon-asset/icon-asset.js +199 -199
  47. package/dist/collection/components/icon-asset/media/brands.svg +1381 -1381
  48. package/dist/collection/components/icon-asset/media/designer.svg +327 -327
  49. package/dist/collection/components/icon-asset/media/regular.svg +463 -463
  50. package/dist/collection/components/icon-asset/media/solid.svg +3013 -3013
  51. package/dist/collection/components/icon-asset/media/svg-with-js.min.css +4 -4
  52. package/dist/collection/components/list-item/list-item.js +103 -103
  53. package/dist/collection/components/my-component/my-component.css +3 -3
  54. package/dist/collection/components/my-component/my-component.js +73 -73
  55. package/dist/collection/components/ptc-announcement/ptc-announcement.css +1 -0
  56. package/dist/collection/components/ptc-announcement/ptc-announcement.js +210 -192
  57. package/dist/collection/components/ptc-breadcrumb/ptc-breadcrumb.js +21 -21
  58. package/dist/collection/components/ptc-button/ptc-button.js +293 -293
  59. package/dist/collection/components/ptc-card/ptc-card.js +282 -282
  60. package/dist/collection/components/ptc-card-bottom/ptc-card-bottom.js +105 -105
  61. package/dist/collection/components/ptc-card-content/ptc-card-content.js +105 -105
  62. package/dist/collection/components/ptc-card-plm/ptc-card-plm.js +97 -97
  63. package/dist/collection/components/ptc-countdown/ptc-countdown.js +15 -15
  64. package/dist/collection/components/ptc-date/ptc-date.js +201 -201
  65. package/dist/collection/components/ptc-footer/ptc-footer.js +25 -25
  66. package/dist/collection/components/ptc-form/ptc-form.js +118 -118
  67. package/dist/collection/components/ptc-form/validation/FormValidation.js +4234 -4234
  68. package/dist/collection/components/ptc-hero/ptc-hero.js +67 -67
  69. package/dist/collection/components/ptc-hero-footer-cta/ptc-hero-footer-cta.js +77 -77
  70. package/dist/collection/components/ptc-icon-list/ptc-icon-list.js +145 -145
  71. package/dist/collection/components/ptc-img/ptc-img.js +314 -314
  72. package/dist/collection/components/ptc-input/ptc-input.js +133 -133
  73. package/dist/collection/components/ptc-link/ptc-link.js +198 -198
  74. package/dist/collection/components/ptc-list/ptc-list.js +63 -63
  75. package/dist/collection/components/ptc-lottie/ptc-lottie.css +5 -5
  76. package/dist/collection/components/ptc-lottie/ptc-lottie.js +58 -58
  77. package/dist/collection/components/ptc-minimized-footer/ptc-minimized-footer.js +17 -17
  78. package/dist/collection/components/ptc-minimized-header/ptc-minimized-header.js +80 -80
  79. package/dist/collection/components/ptc-mobile-select/ptc-mobile-select.js +221 -221
  80. package/dist/collection/components/ptc-modal/ptc-modal.js +252 -252
  81. package/dist/collection/components/ptc-nav/ptc-nav.js +21 -21
  82. package/dist/collection/components/ptc-nav-item/ptc-nav-item.js +252 -252
  83. package/dist/collection/components/ptc-overlay/ptc-overlay.js +99 -99
  84. package/dist/collection/components/ptc-para/ptc-para.js +157 -157
  85. package/dist/collection/components/ptc-picture/ptc-picture.js +474 -474
  86. package/dist/collection/components/ptc-previous-url/ptc-previous-url.js +54 -54
  87. package/dist/collection/components/ptc-quote/ptc-quote.js +154 -154
  88. package/dist/collection/components/ptc-responsive-wrapper/ptc-responsive-wrapper.css +3 -3
  89. package/dist/collection/components/ptc-responsive-wrapper/ptc-responsive-wrapper.js +62 -62
  90. package/dist/collection/components/ptc-select/ptc-select.js +105 -105
  91. package/dist/collection/components/ptc-social-share/ptc-social-share.js +206 -206
  92. package/dist/collection/components/ptc-spacer/ptc-spacer.css +322 -322
  93. package/dist/collection/components/ptc-spacer/ptc-spacer.js +99 -99
  94. package/dist/collection/components/ptc-span/ptc-span.js +89 -89
  95. package/dist/collection/components/ptc-svg-btn/ptc-svg-btn.js +71 -71
  96. package/dist/collection/components/ptc-title/ptc-title.js +231 -231
  97. package/dist/collection/components/ptc-two-column-media/ptc-two-column-media.js +40 -40
  98. package/dist/collection/index.js +1 -1
  99. package/dist/collection/media/svg-imgs/Back-arrow.svg +11 -11
  100. package/dist/collection/media/svg-imgs/close.svg +10 -10
  101. package/dist/collection/media/svg-imgs/slider-arrow-left.svg +18 -18
  102. package/dist/collection/media/svg-imgs/slider-arrow-right.svg +18 -18
  103. package/dist/collection/utils/interfaces.js +11 -11
  104. package/dist/collection/utils/utils.js +3 -3
  105. package/dist/custom-elements/index.js +2130 -2129
  106. package/dist/esm/icon-asset.entry.js +53 -53
  107. package/dist/esm/{interfaces-7c0243be.js → interfaces-c1c73092.js} +9 -9
  108. package/dist/esm/list-item.entry.js +19 -19
  109. package/dist/esm/loader.js +1 -1
  110. package/dist/esm/lottie-player.entry.js +354 -354
  111. package/dist/esm/my-component.entry.js +13 -13
  112. package/dist/esm/polyfills/core-js.js +0 -0
  113. package/dist/esm/polyfills/dom.js +0 -0
  114. package/dist/esm/polyfills/es5-html-element.js +0 -0
  115. package/dist/esm/polyfills/index.js +0 -0
  116. package/dist/esm/polyfills/system.js +0 -0
  117. package/dist/esm/ptc-announcement_2.entry.js +113 -112
  118. package/dist/esm/ptc-breadcrumb.entry.js +12 -12
  119. package/dist/esm/ptc-button.entry.js +65 -65
  120. package/dist/esm/ptc-card-bottom.entry.js +31 -31
  121. package/dist/esm/ptc-card-content.entry.js +31 -31
  122. package/dist/esm/ptc-card-plm.entry.js +16 -16
  123. package/dist/esm/ptc-card.entry.js +68 -68
  124. package/dist/esm/ptc-countdown.entry.js +8 -8
  125. package/dist/esm/ptc-date.entry.js +48 -48
  126. package/dist/esm/ptc-footer.entry.js +8 -8
  127. package/dist/esm/ptc-form.entry.js +104 -104
  128. package/dist/esm/ptc-hero-footer-cta.entry.js +8 -8
  129. package/dist/esm/ptc-hero.entry.js +18 -18
  130. package/dist/esm/ptc-icon-list.entry.js +32 -32
  131. package/dist/esm/ptc-img_2.entry.js +169 -169
  132. package/dist/esm/ptc-input.entry.js +20 -20
  133. package/dist/esm/ptc-link.entry.js +42 -42
  134. package/dist/esm/ptc-list.entry.js +20 -20
  135. package/dist/esm/ptc-lottie.entry.js +12 -12
  136. package/dist/esm/ptc-minimized-footer.entry.js +8 -8
  137. package/dist/esm/ptc-minimized-header.entry.js +11 -11
  138. package/dist/esm/ptc-mobile-select.entry.js +69 -69
  139. package/dist/esm/ptc-modal.entry.js +103 -103
  140. package/dist/esm/ptc-nav-item.entry.js +83 -83
  141. package/dist/esm/ptc-nav.entry.js +8 -8
  142. package/dist/esm/ptc-para.entry.js +39 -39
  143. package/dist/esm/ptc-picture.entry.js +169 -169
  144. package/dist/esm/ptc-previous-url.entry.js +8 -8
  145. package/dist/esm/ptc-quote.entry.js +25 -25
  146. package/dist/esm/ptc-responsive-wrapper.entry.js +54 -54
  147. package/dist/esm/ptc-select.entry.js +24 -24
  148. package/dist/esm/ptc-social-share.entry.js +64 -64
  149. package/dist/esm/ptc-spacer.entry.js +35 -35
  150. package/dist/esm/ptc-span.entry.js +23 -23
  151. package/dist/esm/ptc-title.entry.js +44 -44
  152. package/dist/esm/ptc-two-column-media.entry.js +14 -14
  153. package/dist/esm/ptcw-design.js +1 -1
  154. package/dist/ptcw-design/media/brands.svg +1381 -1381
  155. package/dist/ptcw-design/media/designer.svg +327 -327
  156. package/dist/ptcw-design/media/regular.svg +463 -463
  157. package/dist/ptcw-design/media/solid.svg +3013 -3013
  158. package/dist/ptcw-design/media/svg-with-js.min.css +4 -4
  159. package/dist/ptcw-design/p-58a9ce3c.entry.js +1 -0
  160. package/dist/ptcw-design/{p-e4102de2.entry.js → p-97edf10d.entry.js} +1 -1
  161. package/dist/ptcw-design/{p-da55b60e.entry.js → p-d97f4152.entry.js} +1 -1
  162. package/dist/ptcw-design/ptcw-design.esm.js +1 -1
  163. package/dist/ptcw-design/validation/FormValidation.js +4234 -4234
  164. package/dist/types/components/icon-asset/icon-asset.d.ts +36 -36
  165. package/dist/types/components/list-item/list-item.d.ts +8 -8
  166. package/dist/types/components/my-component/my-component.d.ts +16 -16
  167. package/dist/types/components/ptc-announcement/ptc-announcement.d.ts +43 -39
  168. package/dist/types/components/ptc-breadcrumb/ptc-breadcrumb.d.ts +4 -4
  169. package/dist/types/components/ptc-button/ptc-button.d.ts +56 -56
  170. package/dist/types/components/ptc-card/ptc-card.d.ts +50 -50
  171. package/dist/types/components/ptc-card-bottom/ptc-card-bottom.d.ts +15 -15
  172. package/dist/types/components/ptc-card-content/ptc-card-content.d.ts +15 -15
  173. package/dist/types/components/ptc-card-plm/ptc-card-plm.d.ts +8 -8
  174. package/dist/types/components/ptc-countdown/ptc-countdown.d.ts +3 -3
  175. package/dist/types/components/ptc-date/ptc-date.d.ts +41 -41
  176. package/dist/types/components/ptc-footer/ptc-footer.d.ts +3 -3
  177. package/dist/types/components/ptc-form/ptc-form.d.ts +11 -11
  178. package/dist/types/components/ptc-hero/ptc-hero.d.ts +12 -12
  179. package/dist/types/components/ptc-hero-footer-cta/ptc-hero-footer-cta.d.ts +6 -6
  180. package/dist/types/components/ptc-icon-list/ptc-icon-list.d.ts +21 -21
  181. package/dist/types/components/ptc-img/ptc-img.d.ts +51 -51
  182. package/dist/types/components/ptc-input/ptc-input.d.ts +19 -19
  183. package/dist/types/components/ptc-link/ptc-link.d.ts +36 -36
  184. package/dist/types/components/ptc-list/ptc-list.d.ts +6 -6
  185. package/dist/types/components/ptc-lottie/ptc-lottie.d.ts +12 -12
  186. package/dist/types/components/ptc-minimized-footer/ptc-minimized-footer.d.ts +3 -3
  187. package/dist/types/components/ptc-minimized-header/ptc-minimized-header.d.ts +6 -6
  188. package/dist/types/components/ptc-mobile-select/ptc-mobile-select.d.ts +40 -40
  189. package/dist/types/components/ptc-modal/ptc-modal.d.ts +46 -46
  190. package/dist/types/components/ptc-nav/ptc-nav.d.ts +3 -3
  191. package/dist/types/components/ptc-nav-item/ptc-nav-item.d.ts +53 -53
  192. package/dist/types/components/ptc-overlay/ptc-overlay.d.ts +20 -20
  193. package/dist/types/components/ptc-para/ptc-para.d.ts +28 -28
  194. package/dist/types/components/ptc-picture/ptc-picture.d.ts +93 -93
  195. package/dist/types/components/ptc-previous-url/ptc-previous-url.d.ts +5 -5
  196. package/dist/types/components/ptc-quote/ptc-quote.d.ts +29 -29
  197. package/dist/types/components/ptc-responsive-wrapper/ptc-responsive-wrapper.d.ts +8 -8
  198. package/dist/types/components/ptc-select/ptc-select.d.ts +9 -9
  199. package/dist/types/components/ptc-social-share/ptc-social-share.d.ts +25 -25
  200. package/dist/types/components/ptc-spacer/ptc-spacer.d.ts +16 -16
  201. package/dist/types/components/ptc-span/ptc-span.d.ts +16 -16
  202. package/dist/types/components/ptc-svg-btn/ptc-svg-btn.d.ts +12 -12
  203. package/dist/types/components/ptc-title/ptc-title.d.ts +41 -41
  204. package/dist/types/components/ptc-two-column-media/ptc-two-column-media.d.ts +9 -9
  205. package/dist/types/components.d.ts +32 -24
  206. package/dist/types/global.d.ts +1072 -1072
  207. package/dist/types/index.d.ts +1 -1
  208. package/dist/types/utils/interfaces.d.ts +14 -14
  209. package/dist/types/utils/utils.d.ts +1 -1
  210. package/package.json +59 -59
  211. package/readme.md +11 -11
  212. package/dist/ptcw-design/p-8dd0aef5.entry.js +0 -1
  213. /package/dist/ptcw-design/{p-ee1183b2.js → p-50e52c88.js} +0 -0
@@ -1,314 +1,314 @@
1
- import { Component, Host, h, Prop, Listen, Element } from '@stencil/core';
2
- import { ResponsiveBgVariables } from '../../utils/interfaces';
3
- export class PtcImg {
4
- constructor() {
5
- /**
6
- * Image size for smallest screen
7
- * <=767px
8
- */
9
- this.sizeXs = '510x340';
10
- /**
11
- * Image size for small screen
12
- * >=768px and <=991px
13
- */
14
- this.sizeSm = '1240x496';
15
- /**
16
- * Image size for medium screen
17
- * >=992px and <=1199px
18
- */
19
- this.sizeMd = '1366x500';
20
- /**
21
- * Image solution for large screen
22
- * >=1200px
23
- */
24
- this.sizeLg = '1920x1080';
25
- /**
26
- * Image type
27
- */
28
- this.imageType = 'smart-bg';
29
- /**
30
- * Image border shape
31
- */
32
- this.borderRadius = '';
33
- /**
34
- * Lazy loading option
35
- */
36
- this.loadMode = 'lazy-bg';
37
- }
38
- /**
39
- * Image Z Index
40
- */
41
- // @Prop() imageZIndex: 'z-index-auto' | 'z-index-n-2' | 'z-index-n-1' | 'z-index-p-1' | 'z-index-p-2' = 'z-index-auto';
42
- WindowResize() {
43
- this.setResponsiveBg();
44
- }
45
- render() {
46
- const classMap = this.getCssClassMap();
47
- return (h(Host, null,
48
- h("div", { class: classMap, "data-xs": `${this.imgUrl}:${this.sizeXs}`, "data-sm": `${this.imgUrl}:${this.sizeSm}`, "data-md": `${this.imgUrl}:${this.sizeMd}`, "data-lg": `${this.imgUrl}:${this.sizeLg}` }, this.imageType == 'smart-bg' ? h("slot", null) : null)));
49
- }
50
- componentDidLoad() {
51
- this.addIntersectionObserver();
52
- this.setResponsiveBg();
53
- }
54
- componentWillUpdate() {
55
- // console.log('componentWillUpdate!');
56
- this.addIntersectionObserver();
57
- this.setResponsiveBg();
58
- }
59
- //responsive image
60
- setResponsiveBg() {
61
- // Define local variables
62
- let backgrounds = (this.el || document).querySelectorAll(ResponsiveBgVariables.selector), el, elData, currentBreakpoint = this.getCurrentBreakPoints();
63
- // console.log('current breakpoint: ' + currentBreakpoint);
64
- // Loop through all target elements
65
- for (var i = 0, len = backgrounds.length; i < len; i++) {
66
- // Set current variables
67
- el = backgrounds[i];
68
- elData = el.getAttribute('data-' + currentBreakpoint);
69
- // If the data attribute exists, set the background
70
- if (elData !== null) {
71
- el.style.backgroundImage = "url('" + elData + "')";
72
- }
73
- else {
74
- if (typeof console == 'object') {
75
- console.warn('Data attribute: data-' + currentBreakpoint + ' not found on element:\n\n' + el.outerHTML + '\n\n\n');
76
- }
77
- }
78
- }
79
- }
80
- //lazy loading
81
- addIntersectionObserver() {
82
- if (!this.imgUrl) {
83
- console.log('no image!');
84
- return;
85
- }
86
- if ('IntersectionObserver' in window) {
87
- let lazyLoadBgs = (this.el || document).querySelectorAll('.lazy-bg');
88
- let bgObserver = new IntersectionObserver(entries => {
89
- entries.forEach(entry => {
90
- if (entry.isIntersecting) {
91
- const image = entry.target;
92
- image.classList.remove('lazy-bg');
93
- // console.log('loaded');
94
- bgObserver.unobserve(image);
95
- }
96
- });
97
- });
98
- lazyLoadBgs.forEach(image => {
99
- bgObserver.observe(image);
100
- });
101
- }
102
- else {
103
- // fall back to setTimeout for Safari and IE
104
- // setTimeout(() => {};
105
- // }, 5000);
106
- }
107
- }
108
- getCssClassMap() {
109
- return {
110
- [this.imageType]: true,
111
- 'ptc-img': true,
112
- [this.borderRadius]: true,
113
- [this.loadMode]: true,
114
- // [this.imageZIndex] : true
115
- };
116
- }
117
- getCurrentBreakPoints() {
118
- // Define local variables
119
- let doc = window.document, temp = doc.createElement('div'), env;
120
- // Append test node
121
- doc.body.appendChild(temp);
122
- // Loop through breakpoints
123
- for (let i = ResponsiveBgVariables.envs.length - 1; i >= 0; i--) {
124
- env = ResponsiveBgVariables.envs[i];
125
- // Add classes
126
- temp.className = 'hidden-' + env;
127
- // Found breakpoint
128
- if (temp.offsetParent === null) {
129
- // Remove our test node
130
- doc.body.removeChild(temp);
131
- console.log('remove test node');
132
- // Return current breakpoint
133
- return env;
134
- }
135
- }
136
- // Breakpoint not found, try fallback
137
- doc.body.removeChild(temp);
138
- return this.getFallbackBreakpoint();
139
- }
140
- getFallbackBreakpoint() {
141
- if (window.matchMedia('(min-width: 992px)').matches) {
142
- return 'lg';
143
- }
144
- else if (window.matchMedia('(min-width: 768px)').matches) {
145
- return 'md';
146
- }
147
- else if (window.matchMedia('(min-width: 576px)').matches) {
148
- return 'sm';
149
- }
150
- else {
151
- return 'xs';
152
- }
153
- }
154
- static get is() { return "ptc-img"; }
155
- static get originalStyleUrls() { return {
156
- "$": ["ptc-img.scss"]
157
- }; }
158
- static get styleUrls() { return {
159
- "$": ["ptc-img.css"]
160
- }; }
161
- static get properties() { return {
162
- "sizeXs": {
163
- "type": "string",
164
- "mutable": true,
165
- "complexType": {
166
- "original": "string",
167
- "resolved": "string",
168
- "references": {}
169
- },
170
- "required": false,
171
- "optional": false,
172
- "docs": {
173
- "tags": [],
174
- "text": "Image size for smallest screen\r\n<=767px"
175
- },
176
- "attribute": "size-xs",
177
- "reflect": false,
178
- "defaultValue": "'510x340'"
179
- },
180
- "sizeSm": {
181
- "type": "string",
182
- "mutable": true,
183
- "complexType": {
184
- "original": "string",
185
- "resolved": "string",
186
- "references": {}
187
- },
188
- "required": false,
189
- "optional": false,
190
- "docs": {
191
- "tags": [],
192
- "text": "Image size for small screen\r\n>=768px and <=991px"
193
- },
194
- "attribute": "size-sm",
195
- "reflect": false,
196
- "defaultValue": "'1240x496'"
197
- },
198
- "sizeMd": {
199
- "type": "string",
200
- "mutable": true,
201
- "complexType": {
202
- "original": "string",
203
- "resolved": "string",
204
- "references": {}
205
- },
206
- "required": false,
207
- "optional": false,
208
- "docs": {
209
- "tags": [],
210
- "text": "Image size for medium screen\r\n>=992px and <=1199px"
211
- },
212
- "attribute": "size-md",
213
- "reflect": false,
214
- "defaultValue": "'1366x500'"
215
- },
216
- "sizeLg": {
217
- "type": "string",
218
- "mutable": true,
219
- "complexType": {
220
- "original": "string",
221
- "resolved": "string",
222
- "references": {}
223
- },
224
- "required": false,
225
- "optional": false,
226
- "docs": {
227
- "tags": [],
228
- "text": "Image solution for large screen\r\n>=1200px"
229
- },
230
- "attribute": "size-lg",
231
- "reflect": false,
232
- "defaultValue": "'1920x1080'"
233
- },
234
- "imgUrl": {
235
- "type": "string",
236
- "mutable": false,
237
- "complexType": {
238
- "original": "string",
239
- "resolved": "string",
240
- "references": {}
241
- },
242
- "required": false,
243
- "optional": false,
244
- "docs": {
245
- "tags": [],
246
- "text": "Image Src"
247
- },
248
- "attribute": "img-url",
249
- "reflect": false
250
- },
251
- "imageType": {
252
- "type": "string",
253
- "mutable": false,
254
- "complexType": {
255
- "original": "'smart-bg' | 'smart-img'",
256
- "resolved": "\"smart-bg\" | \"smart-img\"",
257
- "references": {}
258
- },
259
- "required": false,
260
- "optional": false,
261
- "docs": {
262
- "tags": [],
263
- "text": "Image type"
264
- },
265
- "attribute": "image-type",
266
- "reflect": false,
267
- "defaultValue": "'smart-bg'"
268
- },
269
- "borderRadius": {
270
- "type": "string",
271
- "mutable": false,
272
- "complexType": {
273
- "original": "'radius-sm' | 'radius-md' | 'radius-lg' | ''",
274
- "resolved": "\"\" | \"radius-lg\" | \"radius-md\" | \"radius-sm\"",
275
- "references": {}
276
- },
277
- "required": false,
278
- "optional": false,
279
- "docs": {
280
- "tags": [],
281
- "text": "Image border shape"
282
- },
283
- "attribute": "border-radius",
284
- "reflect": false,
285
- "defaultValue": "''"
286
- },
287
- "loadMode": {
288
- "type": "string",
289
- "mutable": false,
290
- "complexType": {
291
- "original": "'lazy-bg' | 'eager-bg'",
292
- "resolved": "\"eager-bg\" | \"lazy-bg\"",
293
- "references": {}
294
- },
295
- "required": false,
296
- "optional": false,
297
- "docs": {
298
- "tags": [],
299
- "text": "Lazy loading option"
300
- },
301
- "attribute": "load-mode",
302
- "reflect": false,
303
- "defaultValue": "'lazy-bg'"
304
- }
305
- }; }
306
- static get elementRef() { return "el"; }
307
- static get listeners() { return [{
308
- "name": "resize",
309
- "method": "WindowResize",
310
- "target": "window",
311
- "capture": false,
312
- "passive": true
313
- }]; }
314
- }
1
+ import { Component, Host, h, Prop, Listen, Element } from '@stencil/core';
2
+ import { ResponsiveBgVariables } from '../../utils/interfaces';
3
+ export class PtcImg {
4
+ constructor() {
5
+ /**
6
+ * Image size for smallest screen
7
+ * <=767px
8
+ */
9
+ this.sizeXs = '510x340';
10
+ /**
11
+ * Image size for small screen
12
+ * >=768px and <=991px
13
+ */
14
+ this.sizeSm = '1240x496';
15
+ /**
16
+ * Image size for medium screen
17
+ * >=992px and <=1199px
18
+ */
19
+ this.sizeMd = '1366x500';
20
+ /**
21
+ * Image solution for large screen
22
+ * >=1200px
23
+ */
24
+ this.sizeLg = '1920x1080';
25
+ /**
26
+ * Image type
27
+ */
28
+ this.imageType = 'smart-bg';
29
+ /**
30
+ * Image border shape
31
+ */
32
+ this.borderRadius = '';
33
+ /**
34
+ * Lazy loading option
35
+ */
36
+ this.loadMode = 'lazy-bg';
37
+ }
38
+ /**
39
+ * Image Z Index
40
+ */
41
+ // @Prop() imageZIndex: 'z-index-auto' | 'z-index-n-2' | 'z-index-n-1' | 'z-index-p-1' | 'z-index-p-2' = 'z-index-auto';
42
+ WindowResize() {
43
+ this.setResponsiveBg();
44
+ }
45
+ render() {
46
+ const classMap = this.getCssClassMap();
47
+ return (h(Host, null,
48
+ h("div", { class: classMap, "data-xs": `${this.imgUrl}:${this.sizeXs}`, "data-sm": `${this.imgUrl}:${this.sizeSm}`, "data-md": `${this.imgUrl}:${this.sizeMd}`, "data-lg": `${this.imgUrl}:${this.sizeLg}` }, this.imageType == 'smart-bg' ? h("slot", null) : null)));
49
+ }
50
+ componentDidLoad() {
51
+ this.addIntersectionObserver();
52
+ this.setResponsiveBg();
53
+ }
54
+ componentWillUpdate() {
55
+ // console.log('componentWillUpdate!');
56
+ this.addIntersectionObserver();
57
+ this.setResponsiveBg();
58
+ }
59
+ //responsive image
60
+ setResponsiveBg() {
61
+ // Define local variables
62
+ let backgrounds = (this.el || document).querySelectorAll(ResponsiveBgVariables.selector), el, elData, currentBreakpoint = this.getCurrentBreakPoints();
63
+ // console.log('current breakpoint: ' + currentBreakpoint);
64
+ // Loop through all target elements
65
+ for (var i = 0, len = backgrounds.length; i < len; i++) {
66
+ // Set current variables
67
+ el = backgrounds[i];
68
+ elData = el.getAttribute('data-' + currentBreakpoint);
69
+ // If the data attribute exists, set the background
70
+ if (elData !== null) {
71
+ el.style.backgroundImage = "url('" + elData + "')";
72
+ }
73
+ else {
74
+ if (typeof console == 'object') {
75
+ console.warn('Data attribute: data-' + currentBreakpoint + ' not found on element:\n\n' + el.outerHTML + '\n\n\n');
76
+ }
77
+ }
78
+ }
79
+ }
80
+ //lazy loading
81
+ addIntersectionObserver() {
82
+ if (!this.imgUrl) {
83
+ console.log('no image!');
84
+ return;
85
+ }
86
+ if ('IntersectionObserver' in window) {
87
+ let lazyLoadBgs = (this.el || document).querySelectorAll('.lazy-bg');
88
+ let bgObserver = new IntersectionObserver(entries => {
89
+ entries.forEach(entry => {
90
+ if (entry.isIntersecting) {
91
+ const image = entry.target;
92
+ image.classList.remove('lazy-bg');
93
+ // console.log('loaded');
94
+ bgObserver.unobserve(image);
95
+ }
96
+ });
97
+ });
98
+ lazyLoadBgs.forEach(image => {
99
+ bgObserver.observe(image);
100
+ });
101
+ }
102
+ else {
103
+ // fall back to setTimeout for Safari and IE
104
+ // setTimeout(() => {};
105
+ // }, 5000);
106
+ }
107
+ }
108
+ getCssClassMap() {
109
+ return {
110
+ [this.imageType]: true,
111
+ 'ptc-img': true,
112
+ [this.borderRadius]: true,
113
+ [this.loadMode]: true,
114
+ // [this.imageZIndex] : true
115
+ };
116
+ }
117
+ getCurrentBreakPoints() {
118
+ // Define local variables
119
+ let doc = window.document, temp = doc.createElement('div'), env;
120
+ // Append test node
121
+ doc.body.appendChild(temp);
122
+ // Loop through breakpoints
123
+ for (let i = ResponsiveBgVariables.envs.length - 1; i >= 0; i--) {
124
+ env = ResponsiveBgVariables.envs[i];
125
+ // Add classes
126
+ temp.className = 'hidden-' + env;
127
+ // Found breakpoint
128
+ if (temp.offsetParent === null) {
129
+ // Remove our test node
130
+ doc.body.removeChild(temp);
131
+ console.log('remove test node');
132
+ // Return current breakpoint
133
+ return env;
134
+ }
135
+ }
136
+ // Breakpoint not found, try fallback
137
+ doc.body.removeChild(temp);
138
+ return this.getFallbackBreakpoint();
139
+ }
140
+ getFallbackBreakpoint() {
141
+ if (window.matchMedia('(min-width: 992px)').matches) {
142
+ return 'lg';
143
+ }
144
+ else if (window.matchMedia('(min-width: 768px)').matches) {
145
+ return 'md';
146
+ }
147
+ else if (window.matchMedia('(min-width: 576px)').matches) {
148
+ return 'sm';
149
+ }
150
+ else {
151
+ return 'xs';
152
+ }
153
+ }
154
+ static get is() { return "ptc-img"; }
155
+ static get originalStyleUrls() { return {
156
+ "$": ["ptc-img.scss"]
157
+ }; }
158
+ static get styleUrls() { return {
159
+ "$": ["ptc-img.css"]
160
+ }; }
161
+ static get properties() { return {
162
+ "sizeXs": {
163
+ "type": "string",
164
+ "mutable": true,
165
+ "complexType": {
166
+ "original": "string",
167
+ "resolved": "string",
168
+ "references": {}
169
+ },
170
+ "required": false,
171
+ "optional": false,
172
+ "docs": {
173
+ "tags": [],
174
+ "text": "Image size for smallest screen\n<=767px"
175
+ },
176
+ "attribute": "size-xs",
177
+ "reflect": false,
178
+ "defaultValue": "'510x340'"
179
+ },
180
+ "sizeSm": {
181
+ "type": "string",
182
+ "mutable": true,
183
+ "complexType": {
184
+ "original": "string",
185
+ "resolved": "string",
186
+ "references": {}
187
+ },
188
+ "required": false,
189
+ "optional": false,
190
+ "docs": {
191
+ "tags": [],
192
+ "text": "Image size for small screen\n>=768px and <=991px"
193
+ },
194
+ "attribute": "size-sm",
195
+ "reflect": false,
196
+ "defaultValue": "'1240x496'"
197
+ },
198
+ "sizeMd": {
199
+ "type": "string",
200
+ "mutable": true,
201
+ "complexType": {
202
+ "original": "string",
203
+ "resolved": "string",
204
+ "references": {}
205
+ },
206
+ "required": false,
207
+ "optional": false,
208
+ "docs": {
209
+ "tags": [],
210
+ "text": "Image size for medium screen\n>=992px and <=1199px"
211
+ },
212
+ "attribute": "size-md",
213
+ "reflect": false,
214
+ "defaultValue": "'1366x500'"
215
+ },
216
+ "sizeLg": {
217
+ "type": "string",
218
+ "mutable": true,
219
+ "complexType": {
220
+ "original": "string",
221
+ "resolved": "string",
222
+ "references": {}
223
+ },
224
+ "required": false,
225
+ "optional": false,
226
+ "docs": {
227
+ "tags": [],
228
+ "text": "Image solution for large screen\n>=1200px"
229
+ },
230
+ "attribute": "size-lg",
231
+ "reflect": false,
232
+ "defaultValue": "'1920x1080'"
233
+ },
234
+ "imgUrl": {
235
+ "type": "string",
236
+ "mutable": false,
237
+ "complexType": {
238
+ "original": "string",
239
+ "resolved": "string",
240
+ "references": {}
241
+ },
242
+ "required": false,
243
+ "optional": false,
244
+ "docs": {
245
+ "tags": [],
246
+ "text": "Image Src"
247
+ },
248
+ "attribute": "img-url",
249
+ "reflect": false
250
+ },
251
+ "imageType": {
252
+ "type": "string",
253
+ "mutable": false,
254
+ "complexType": {
255
+ "original": "'smart-bg' | 'smart-img'",
256
+ "resolved": "\"smart-bg\" | \"smart-img\"",
257
+ "references": {}
258
+ },
259
+ "required": false,
260
+ "optional": false,
261
+ "docs": {
262
+ "tags": [],
263
+ "text": "Image type"
264
+ },
265
+ "attribute": "image-type",
266
+ "reflect": false,
267
+ "defaultValue": "'smart-bg'"
268
+ },
269
+ "borderRadius": {
270
+ "type": "string",
271
+ "mutable": false,
272
+ "complexType": {
273
+ "original": "'radius-sm' | 'radius-md' | 'radius-lg' | ''",
274
+ "resolved": "\"\" | \"radius-lg\" | \"radius-md\" | \"radius-sm\"",
275
+ "references": {}
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": "Image border shape"
282
+ },
283
+ "attribute": "border-radius",
284
+ "reflect": false,
285
+ "defaultValue": "''"
286
+ },
287
+ "loadMode": {
288
+ "type": "string",
289
+ "mutable": false,
290
+ "complexType": {
291
+ "original": "'lazy-bg' | 'eager-bg'",
292
+ "resolved": "\"eager-bg\" | \"lazy-bg\"",
293
+ "references": {}
294
+ },
295
+ "required": false,
296
+ "optional": false,
297
+ "docs": {
298
+ "tags": [],
299
+ "text": "Lazy loading option"
300
+ },
301
+ "attribute": "load-mode",
302
+ "reflect": false,
303
+ "defaultValue": "'lazy-bg'"
304
+ }
305
+ }; }
306
+ static get elementRef() { return "el"; }
307
+ static get listeners() { return [{
308
+ "name": "resize",
309
+ "method": "WindowResize",
310
+ "target": "window",
311
+ "capture": false,
312
+ "passive": true
313
+ }]; }
314
+ }