@ptcwebops/ptcw-design 0.1.2 → 0.1.3
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/dist/cjs/icon-asset_5.cjs.entry.js +1 -1
- package/dist/cjs/interfaces-0ecd8027.js +15 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/ptc-avatar.cjs.entry.js +19 -0
- package/dist/cjs/ptc-card.cjs.entry.js +2 -2
- package/dist/cjs/ptc-img.cjs.entry.js +7 -12
- package/dist/cjs/ptc-picture.cjs.entry.js +145 -4
- package/dist/cjs/ptcw-design.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ptc-avatar/ptc-avatar.css +3 -0
- package/dist/collection/components/ptc-avatar/ptc-avatar.js +15 -0
- package/dist/collection/components/ptc-card/ptc-card.css +26 -3
- package/dist/collection/components/ptc-card/ptc-card.js +1 -1
- package/dist/collection/components/ptc-img/ptc-img.js +4 -10
- package/dist/collection/components/ptc-para/ptc-para.css +24 -0
- package/dist/collection/components/ptc-para/ptc-para.js +2 -2
- package/dist/collection/components/ptc-picture/ptc-picture.css +29 -0
- package/dist/collection/components/ptc-picture/ptc-picture.js +325 -13
- package/dist/collection/utils/interfaces.js +6 -1
- package/dist/custom-elements/index.d.ts +6 -6
- package/dist/custom-elements/index.js +174 -67
- package/dist/esm/icon-asset_5.entry.js +1 -1
- package/dist/esm/interfaces-3cb94654.js +12 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/ptc-avatar.entry.js +15 -0
- package/dist/esm/ptc-card.entry.js +2 -2
- package/dist/esm/ptc-img.entry.js +4 -9
- package/dist/esm/ptc-picture.entry.js +146 -5
- package/dist/esm/ptcw-design.js +1 -1
- package/dist/ptcw-design/{p-dddd4d6e.entry.js → p-18092cf1.entry.js} +1 -1
- package/dist/ptcw-design/p-240733ce.js +1 -0
- package/dist/ptcw-design/p-73e2418e.entry.js +1 -0
- package/dist/ptcw-design/p-78a47bf1.entry.js +1 -0
- package/dist/ptcw-design/{p-1df1006b.entry.js → p-bff9c1f2.entry.js} +1 -1
- package/dist/ptcw-design/p-f694e46a.entry.js +1 -0
- package/dist/ptcw-design/ptcw-design.css +1 -1
- package/dist/ptcw-design/ptcw-design.esm.js +1 -1
- package/dist/types/components/ptc-avatar/ptc-avatar.d.ts +3 -0
- package/dist/types/components/ptc-para/ptc-para.d.ts +1 -1
- package/dist/types/components/ptc-picture/ptc-picture.d.ts +60 -1
- package/dist/types/components.d.ts +95 -33
- package/dist/types/utils/interfaces.d.ts +6 -1
- package/package.json +1 -1
- package/dist/cjs/ptc-image.cjs.entry.js +0 -58
- package/dist/collection/components/ptc-image/ptc-image.css +0 -4
- package/dist/collection/components/ptc-image/ptc-image.js +0 -92
- package/dist/esm/ptc-image.entry.js +0 -54
- package/dist/ptcw-design/p-4586b0f5.entry.js +0 -1
- package/dist/ptcw-design/p-56f6f900.entry.js +0 -1
- package/dist/ptcw-design/p-97a61538.entry.js +0 -1
- package/dist/types/components/ptc-image/ptc-image.d.ts +0 -18
|
@@ -68,6 +68,8 @@ export namespace Components {
|
|
|
68
68
|
*/
|
|
69
69
|
"visible": boolean;
|
|
70
70
|
}
|
|
71
|
+
interface PtcAvatar {
|
|
72
|
+
}
|
|
71
73
|
interface PtcButton {
|
|
72
74
|
/**
|
|
73
75
|
* Button theme color
|
|
@@ -172,16 +174,6 @@ export namespace Components {
|
|
|
172
174
|
}
|
|
173
175
|
interface PtcFooter {
|
|
174
176
|
}
|
|
175
|
-
interface PtcImage {
|
|
176
|
-
/**
|
|
177
|
-
* Image alt
|
|
178
|
-
*/
|
|
179
|
-
"alt": string;
|
|
180
|
-
/**
|
|
181
|
-
* Image Render Src
|
|
182
|
-
*/
|
|
183
|
-
"src": string;
|
|
184
|
-
}
|
|
185
177
|
interface PtcImg {
|
|
186
178
|
/**
|
|
187
179
|
* Image border shape
|
|
@@ -310,14 +302,53 @@ export namespace Components {
|
|
|
310
302
|
/**
|
|
311
303
|
* Paragraph Margin
|
|
312
304
|
*/
|
|
313
|
-
"paraMargin"?: 'margin-flush';
|
|
305
|
+
"paraMargin"?: 'margin-flush' | 'margin-top-3' | 'margin-top-4' | 'margin-top-5' | 'margin-top-6' | 'margin-bottom-3' | 'margin-bottom-4' | 'margin-bottom-5' | 'margin-bottom-6';
|
|
314
306
|
/**
|
|
315
307
|
* Paragraph Style
|
|
316
308
|
*/
|
|
317
309
|
"paraStyle": 'default' | 'intro' | 'small' | 'announcement';
|
|
318
310
|
}
|
|
319
311
|
interface PtcPicture {
|
|
320
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Image alt
|
|
314
|
+
*/
|
|
315
|
+
"alt": string;
|
|
316
|
+
/**
|
|
317
|
+
* Image border shape
|
|
318
|
+
*/
|
|
319
|
+
"borderRadius": 'radius-sm' | 'radius-md' | 'radius-lg' | '';
|
|
320
|
+
/**
|
|
321
|
+
* Set height Width will be auto by default
|
|
322
|
+
*/
|
|
323
|
+
"height": string;
|
|
324
|
+
/**
|
|
325
|
+
* Object Fit Default: cover
|
|
326
|
+
*/
|
|
327
|
+
"objectFit": 'cover' | 'fill' | 'contain' | 'scale-down' | 'none' | 'initial' | 'inherit';
|
|
328
|
+
/**
|
|
329
|
+
* Image solution for large screen >=1200px
|
|
330
|
+
*/
|
|
331
|
+
"sizeLg": string;
|
|
332
|
+
/**
|
|
333
|
+
* Image size for medium screen >=992px and <=1199px
|
|
334
|
+
*/
|
|
335
|
+
"sizeMd": string;
|
|
336
|
+
/**
|
|
337
|
+
* Image size for small screen >=768px and <=991px
|
|
338
|
+
*/
|
|
339
|
+
"sizeSm": string;
|
|
340
|
+
/**
|
|
341
|
+
* Image size for smallest screen <=767px
|
|
342
|
+
*/
|
|
343
|
+
"sizeXs": string;
|
|
344
|
+
/**
|
|
345
|
+
* Image Render Src
|
|
346
|
+
*/
|
|
347
|
+
"src": string;
|
|
348
|
+
/**
|
|
349
|
+
* Set Width height will be 100% by default
|
|
350
|
+
*/
|
|
351
|
+
"width": string;
|
|
321
352
|
}
|
|
322
353
|
interface PtcSpacer {
|
|
323
354
|
/**
|
|
@@ -387,6 +418,12 @@ declare global {
|
|
|
387
418
|
prototype: HTMLPtcAnnouncementElement;
|
|
388
419
|
new (): HTMLPtcAnnouncementElement;
|
|
389
420
|
};
|
|
421
|
+
interface HTMLPtcAvatarElement extends Components.PtcAvatar, HTMLStencilElement {
|
|
422
|
+
}
|
|
423
|
+
var HTMLPtcAvatarElement: {
|
|
424
|
+
prototype: HTMLPtcAvatarElement;
|
|
425
|
+
new (): HTMLPtcAvatarElement;
|
|
426
|
+
};
|
|
390
427
|
interface HTMLPtcButtonElement extends Components.PtcButton, HTMLStencilElement {
|
|
391
428
|
}
|
|
392
429
|
var HTMLPtcButtonElement: {
|
|
@@ -411,12 +448,6 @@ declare global {
|
|
|
411
448
|
prototype: HTMLPtcFooterElement;
|
|
412
449
|
new (): HTMLPtcFooterElement;
|
|
413
450
|
};
|
|
414
|
-
interface HTMLPtcImageElement extends Components.PtcImage, HTMLStencilElement {
|
|
415
|
-
}
|
|
416
|
-
var HTMLPtcImageElement: {
|
|
417
|
-
prototype: HTMLPtcImageElement;
|
|
418
|
-
new (): HTMLPtcImageElement;
|
|
419
|
-
};
|
|
420
451
|
interface HTMLPtcImgElement extends Components.PtcImg, HTMLStencilElement {
|
|
421
452
|
}
|
|
422
453
|
var HTMLPtcImgElement: {
|
|
@@ -500,11 +531,11 @@ declare global {
|
|
|
500
531
|
"list-item": HTMLListItemElement;
|
|
501
532
|
"my-component": HTMLMyComponentElement;
|
|
502
533
|
"ptc-announcement": HTMLPtcAnnouncementElement;
|
|
534
|
+
"ptc-avatar": HTMLPtcAvatarElement;
|
|
503
535
|
"ptc-button": HTMLPtcButtonElement;
|
|
504
536
|
"ptc-card": HTMLPtcCardElement;
|
|
505
537
|
"ptc-date": HTMLPtcDateElement;
|
|
506
538
|
"ptc-footer": HTMLPtcFooterElement;
|
|
507
|
-
"ptc-image": HTMLPtcImageElement;
|
|
508
539
|
"ptc-img": HTMLPtcImgElement;
|
|
509
540
|
"ptc-link": HTMLPtcLinkElement;
|
|
510
541
|
"ptc-list": HTMLPtcListElement;
|
|
@@ -587,6 +618,8 @@ declare namespace LocalJSX {
|
|
|
587
618
|
*/
|
|
588
619
|
"visible"?: boolean;
|
|
589
620
|
}
|
|
621
|
+
interface PtcAvatar {
|
|
622
|
+
}
|
|
590
623
|
interface PtcButton {
|
|
591
624
|
/**
|
|
592
625
|
* Button theme color
|
|
@@ -695,16 +728,6 @@ declare namespace LocalJSX {
|
|
|
695
728
|
}
|
|
696
729
|
interface PtcFooter {
|
|
697
730
|
}
|
|
698
|
-
interface PtcImage {
|
|
699
|
-
/**
|
|
700
|
-
* Image alt
|
|
701
|
-
*/
|
|
702
|
-
"alt"?: string;
|
|
703
|
-
/**
|
|
704
|
-
* Image Render Src
|
|
705
|
-
*/
|
|
706
|
-
"src"?: string;
|
|
707
|
-
}
|
|
708
731
|
interface PtcImg {
|
|
709
732
|
/**
|
|
710
733
|
* Image border shape
|
|
@@ -837,14 +860,53 @@ declare namespace LocalJSX {
|
|
|
837
860
|
/**
|
|
838
861
|
* Paragraph Margin
|
|
839
862
|
*/
|
|
840
|
-
"paraMargin"?: 'margin-flush';
|
|
863
|
+
"paraMargin"?: 'margin-flush' | 'margin-top-3' | 'margin-top-4' | 'margin-top-5' | 'margin-top-6' | 'margin-bottom-3' | 'margin-bottom-4' | 'margin-bottom-5' | 'margin-bottom-6';
|
|
841
864
|
/**
|
|
842
865
|
* Paragraph Style
|
|
843
866
|
*/
|
|
844
867
|
"paraStyle"?: 'default' | 'intro' | 'small' | 'announcement';
|
|
845
868
|
}
|
|
846
869
|
interface PtcPicture {
|
|
847
|
-
|
|
870
|
+
/**
|
|
871
|
+
* Image alt
|
|
872
|
+
*/
|
|
873
|
+
"alt"?: string;
|
|
874
|
+
/**
|
|
875
|
+
* Image border shape
|
|
876
|
+
*/
|
|
877
|
+
"borderRadius"?: 'radius-sm' | 'radius-md' | 'radius-lg' | '';
|
|
878
|
+
/**
|
|
879
|
+
* Set height Width will be auto by default
|
|
880
|
+
*/
|
|
881
|
+
"height"?: string;
|
|
882
|
+
/**
|
|
883
|
+
* Object Fit Default: cover
|
|
884
|
+
*/
|
|
885
|
+
"objectFit"?: 'cover' | 'fill' | 'contain' | 'scale-down' | 'none' | 'initial' | 'inherit';
|
|
886
|
+
/**
|
|
887
|
+
* Image solution for large screen >=1200px
|
|
888
|
+
*/
|
|
889
|
+
"sizeLg"?: string;
|
|
890
|
+
/**
|
|
891
|
+
* Image size for medium screen >=992px and <=1199px
|
|
892
|
+
*/
|
|
893
|
+
"sizeMd"?: string;
|
|
894
|
+
/**
|
|
895
|
+
* Image size for small screen >=768px and <=991px
|
|
896
|
+
*/
|
|
897
|
+
"sizeSm"?: string;
|
|
898
|
+
/**
|
|
899
|
+
* Image size for smallest screen <=767px
|
|
900
|
+
*/
|
|
901
|
+
"sizeXs"?: string;
|
|
902
|
+
/**
|
|
903
|
+
* Image Render Src
|
|
904
|
+
*/
|
|
905
|
+
"src"?: string;
|
|
906
|
+
/**
|
|
907
|
+
* Set Width height will be 100% by default
|
|
908
|
+
*/
|
|
909
|
+
"width"?: string;
|
|
848
910
|
}
|
|
849
911
|
interface PtcSpacer {
|
|
850
912
|
/**
|
|
@@ -893,11 +955,11 @@ declare namespace LocalJSX {
|
|
|
893
955
|
"list-item": ListItem;
|
|
894
956
|
"my-component": MyComponent;
|
|
895
957
|
"ptc-announcement": PtcAnnouncement;
|
|
958
|
+
"ptc-avatar": PtcAvatar;
|
|
896
959
|
"ptc-button": PtcButton;
|
|
897
960
|
"ptc-card": PtcCard;
|
|
898
961
|
"ptc-date": PtcDate;
|
|
899
962
|
"ptc-footer": PtcFooter;
|
|
900
|
-
"ptc-image": PtcImage;
|
|
901
963
|
"ptc-img": PtcImg;
|
|
902
964
|
"ptc-link": PtcLink;
|
|
903
965
|
"ptc-list": PtcList;
|
|
@@ -921,11 +983,11 @@ declare module "@stencil/core" {
|
|
|
921
983
|
"list-item": LocalJSX.ListItem & JSXBase.HTMLAttributes<HTMLListItemElement>;
|
|
922
984
|
"my-component": LocalJSX.MyComponent & JSXBase.HTMLAttributes<HTMLMyComponentElement>;
|
|
923
985
|
"ptc-announcement": LocalJSX.PtcAnnouncement & JSXBase.HTMLAttributes<HTMLPtcAnnouncementElement>;
|
|
986
|
+
"ptc-avatar": LocalJSX.PtcAvatar & JSXBase.HTMLAttributes<HTMLPtcAvatarElement>;
|
|
924
987
|
"ptc-button": LocalJSX.PtcButton & JSXBase.HTMLAttributes<HTMLPtcButtonElement>;
|
|
925
988
|
"ptc-card": LocalJSX.PtcCard & JSXBase.HTMLAttributes<HTMLPtcCardElement>;
|
|
926
989
|
"ptc-date": LocalJSX.PtcDate & JSXBase.HTMLAttributes<HTMLPtcDateElement>;
|
|
927
990
|
"ptc-footer": LocalJSX.PtcFooter & JSXBase.HTMLAttributes<HTMLPtcFooterElement>;
|
|
928
|
-
"ptc-image": LocalJSX.PtcImage & JSXBase.HTMLAttributes<HTMLPtcImageElement>;
|
|
929
991
|
"ptc-img": LocalJSX.PtcImg & JSXBase.HTMLAttributes<HTMLPtcImgElement>;
|
|
930
992
|
"ptc-link": LocalJSX.PtcLink & JSXBase.HTMLAttributes<HTMLPtcLinkElement>;
|
|
931
993
|
"ptc-list": LocalJSX.PtcList & JSXBase.HTMLAttributes<HTMLPtcListElement>;
|
|
@@ -6,4 +6,9 @@ declare let ResponsiveBgVariables: {
|
|
|
6
6
|
selector: string;
|
|
7
7
|
interval: number;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
declare let ResponsivePictureVariables: {
|
|
10
|
+
envs: string[];
|
|
11
|
+
selector: string;
|
|
12
|
+
interval: number;
|
|
13
|
+
};
|
|
14
|
+
export { CssClassMap, ResponsiveBgVariables, ResponsivePictureVariables };
|
package/package.json
CHANGED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-ac192914.js');
|
|
6
|
-
|
|
7
|
-
const ptcImageCss = "img{width:100%;height:auto}";
|
|
8
|
-
|
|
9
|
-
const PtcImage = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
}
|
|
13
|
-
componentDidLoad() {
|
|
14
|
-
this.addIntersectionObserver();
|
|
15
|
-
}
|
|
16
|
-
componentWillUpdate() {
|
|
17
|
-
if (this.src !== this.oldSrc) {
|
|
18
|
-
this.addIntersectionObserver();
|
|
19
|
-
}
|
|
20
|
-
this.oldSrc = this.src;
|
|
21
|
-
}
|
|
22
|
-
addIntersectionObserver() {
|
|
23
|
-
if (!this.src) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if ('IntersectionObserver' in window) {
|
|
27
|
-
let lazyLoadImages = new IntersectionObserver((entries) => {
|
|
28
|
-
entries.forEach(entry => {
|
|
29
|
-
if (entry.isIntersecting) {
|
|
30
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
31
|
-
image.src = image.dataset.src;
|
|
32
|
-
console.log('loaded');
|
|
33
|
-
lazyLoadImages.unobserve(image);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
lazyLoadImages.observe(this.el.shadowRoot.querySelector('img'));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// fall back to setTimeout for Safari and IE
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
43
|
-
image.src = image.dataset.src;
|
|
44
|
-
image.onload = () => {
|
|
45
|
-
image.removeAttribute('data-src');
|
|
46
|
-
console.log('loaded fallback');
|
|
47
|
-
};
|
|
48
|
-
}, 5000);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
render() {
|
|
52
|
-
return index.h("img", { "data-src": this.src, alt: this.alt });
|
|
53
|
-
}
|
|
54
|
-
get el() { return index.getElement(this); }
|
|
55
|
-
};
|
|
56
|
-
PtcImage.style = ptcImageCss;
|
|
57
|
-
|
|
58
|
-
exports.ptc_image = PtcImage;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Component, Prop, h, Element, State } from '@stencil/core';
|
|
2
|
-
export class PtcImage {
|
|
3
|
-
componentDidLoad() {
|
|
4
|
-
this.addIntersectionObserver();
|
|
5
|
-
}
|
|
6
|
-
componentWillUpdate() {
|
|
7
|
-
if (this.src !== this.oldSrc) {
|
|
8
|
-
this.addIntersectionObserver();
|
|
9
|
-
}
|
|
10
|
-
this.oldSrc = this.src;
|
|
11
|
-
}
|
|
12
|
-
addIntersectionObserver() {
|
|
13
|
-
if (!this.src) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if ('IntersectionObserver' in window) {
|
|
17
|
-
let lazyLoadImages = new IntersectionObserver((entries) => {
|
|
18
|
-
entries.forEach(entry => {
|
|
19
|
-
if (entry.isIntersecting) {
|
|
20
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
21
|
-
image.src = image.dataset.src;
|
|
22
|
-
console.log('loaded');
|
|
23
|
-
lazyLoadImages.unobserve(image);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
lazyLoadImages.observe(this.el.shadowRoot.querySelector('img'));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// fall back to setTimeout for Safari and IE
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
33
|
-
image.src = image.dataset.src;
|
|
34
|
-
image.onload = () => {
|
|
35
|
-
image.removeAttribute('data-src');
|
|
36
|
-
console.log('loaded fallback');
|
|
37
|
-
};
|
|
38
|
-
}, 5000);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
render() {
|
|
42
|
-
return h("img", { "data-src": this.src, alt: this.alt });
|
|
43
|
-
}
|
|
44
|
-
static get is() { return "ptc-image"; }
|
|
45
|
-
static get encapsulation() { return "shadow"; }
|
|
46
|
-
static get originalStyleUrls() { return {
|
|
47
|
-
"$": ["ptc-image.scss"]
|
|
48
|
-
}; }
|
|
49
|
-
static get styleUrls() { return {
|
|
50
|
-
"$": ["ptc-image.css"]
|
|
51
|
-
}; }
|
|
52
|
-
static get properties() { return {
|
|
53
|
-
"src": {
|
|
54
|
-
"type": "string",
|
|
55
|
-
"mutable": false,
|
|
56
|
-
"complexType": {
|
|
57
|
-
"original": "string",
|
|
58
|
-
"resolved": "string",
|
|
59
|
-
"references": {}
|
|
60
|
-
},
|
|
61
|
-
"required": false,
|
|
62
|
-
"optional": false,
|
|
63
|
-
"docs": {
|
|
64
|
-
"tags": [],
|
|
65
|
-
"text": "Image Render Src"
|
|
66
|
-
},
|
|
67
|
-
"attribute": "src",
|
|
68
|
-
"reflect": false
|
|
69
|
-
},
|
|
70
|
-
"alt": {
|
|
71
|
-
"type": "string",
|
|
72
|
-
"mutable": false,
|
|
73
|
-
"complexType": {
|
|
74
|
-
"original": "string",
|
|
75
|
-
"resolved": "string",
|
|
76
|
-
"references": {}
|
|
77
|
-
},
|
|
78
|
-
"required": false,
|
|
79
|
-
"optional": false,
|
|
80
|
-
"docs": {
|
|
81
|
-
"tags": [],
|
|
82
|
-
"text": "Image alt"
|
|
83
|
-
},
|
|
84
|
-
"attribute": "alt",
|
|
85
|
-
"reflect": false
|
|
86
|
-
}
|
|
87
|
-
}; }
|
|
88
|
-
static get states() { return {
|
|
89
|
-
"oldSrc": {}
|
|
90
|
-
}; }
|
|
91
|
-
static get elementRef() { return "el"; }
|
|
92
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, a as getElement } from './index-7a3883ee.js';
|
|
2
|
-
|
|
3
|
-
const ptcImageCss = "img{width:100%;height:auto}";
|
|
4
|
-
|
|
5
|
-
const PtcImage = class {
|
|
6
|
-
constructor(hostRef) {
|
|
7
|
-
registerInstance(this, hostRef);
|
|
8
|
-
}
|
|
9
|
-
componentDidLoad() {
|
|
10
|
-
this.addIntersectionObserver();
|
|
11
|
-
}
|
|
12
|
-
componentWillUpdate() {
|
|
13
|
-
if (this.src !== this.oldSrc) {
|
|
14
|
-
this.addIntersectionObserver();
|
|
15
|
-
}
|
|
16
|
-
this.oldSrc = this.src;
|
|
17
|
-
}
|
|
18
|
-
addIntersectionObserver() {
|
|
19
|
-
if (!this.src) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if ('IntersectionObserver' in window) {
|
|
23
|
-
let lazyLoadImages = new IntersectionObserver((entries) => {
|
|
24
|
-
entries.forEach(entry => {
|
|
25
|
-
if (entry.isIntersecting) {
|
|
26
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
27
|
-
image.src = image.dataset.src;
|
|
28
|
-
console.log('loaded');
|
|
29
|
-
lazyLoadImages.unobserve(image);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
lazyLoadImages.observe(this.el.shadowRoot.querySelector('img'));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// fall back to setTimeout for Safari and IE
|
|
37
|
-
setTimeout(() => {
|
|
38
|
-
const image = this.el.shadowRoot.querySelector('img');
|
|
39
|
-
image.src = image.dataset.src;
|
|
40
|
-
image.onload = () => {
|
|
41
|
-
image.removeAttribute('data-src');
|
|
42
|
-
console.log('loaded fallback');
|
|
43
|
-
};
|
|
44
|
-
}, 5000);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
render() {
|
|
48
|
-
return h("img", { "data-src": this.src, alt: this.alt });
|
|
49
|
-
}
|
|
50
|
-
get el() { return getElement(this); }
|
|
51
|
-
};
|
|
52
|
-
PtcImage.style = ptcImageCss;
|
|
53
|
-
|
|
54
|
-
export { PtcImage as ptc_image };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as s,a as e}from"./p-50923c9a.js";const i=class{constructor(s){t(this,s)}componentDidLoad(){this.addIntersectionObserver()}componentWillUpdate(){this.src!==this.oldSrc&&this.addIntersectionObserver(),this.oldSrc=this.src}addIntersectionObserver(){if(this.src)if("IntersectionObserver"in window){let t=new IntersectionObserver((s=>{s.forEach((s=>{if(s.isIntersecting){const s=this.el.shadowRoot.querySelector("img");s.src=s.dataset.src,console.log("loaded"),t.unobserve(s)}}))}));t.observe(this.el.shadowRoot.querySelector("img"))}else setTimeout((()=>{const t=this.el.shadowRoot.querySelector("img");t.src=t.dataset.src,t.onload=()=>{t.removeAttribute("data-src"),console.log("loaded fallback")}}),5e3)}render(){return s("img",{"data-src":this.src,alt:this.alt})}get el(){return e(this)}};i.style="img{width:100%;height:auto}";export{i as ptc_image}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as i,H as e,a as n}from"./p-50923c9a.js";let s={envs:["xs","sm","md","lg"],selector:".ptc-img",interval:250};const o=class{constructor(i){t(this,i),this.sizeXs="510x340",this.sizeSm="1240x496",this.sizeMd="1366x500",this.sizeLg="1920x1080",this.imageType="smart-bg",this.borderRadius="",this.loadMode="lazy-bg"}WindowResize(){this.setResponsiveBg()}render(){const t=this.getCssClassMap();return i(e,null,i("div",{class:t,"data-xs":`${this.imgUrl}:${this.sizeXs}`,"data-sm":`${this.imgUrl}:${this.sizeSm}`,"data-md":`${this.imgUrl}:${this.sizeMd}`,"data-lg":`${this.imgUrl}:${this.sizeLg}`}))}componentDidLoad(){this.addIntersectionObserver(),this.setResponsiveBg()}componentWillUpdate(){console.log("componentWillUpdate!"),this.addIntersectionObserver(),this.setResponsiveBg()}setResponsiveBg(){let t,i,e=(this.el||document).querySelectorAll(s.selector),n=this.getCurrentBreakPoints();console.log("current breakpoint: "+n);for(var o=0,r=e.length;o<r;o++)t=e[o],i=t.getAttribute("data-"+n),null!==i?t.style.backgroundImage="url('"+i+"')":"object"==typeof console&&console.warn("Data attribute: data-"+n+" not found on element:\n\n"+t.outerHTML+"\n\n\n")}addIntersectionObserver(){if(this.imgUrl){if("IntersectionObserver"in window){let t=(this.el||document).querySelectorAll(".lazy-bg"),i=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting){const e=t.target;e.classList.remove("lazy-bg"),console.log("loaded"),i.unobserve(e)}}))}));t.forEach((t=>{i.observe(t)}))}}else console.log("no image!")}getCssClassMap(){return{[this.imageType]:!0,"ptc-img":!0,[this.borderRadius]:!0,[this.loadMode]:!0}}getCurrentBreakPoints(){let t,i=window.document,e=i.createElement("div");i.body.appendChild(e);for(let n=s.envs.length-1;n>=0;n--)if(t=s.envs[n],e.className="hidden-"+t,null===e.offsetParent)return i.body.removeChild(e),console.log("remove test node"),t;return i.body.removeChild(e),this.getFallbackBreakpoint()}getFallbackBreakpoint(){return window.matchMedia("(min-width: 992px)").matches?"lg":window.matchMedia("(min-width: 768px)").matches?"md":window.matchMedia("(min-width: 576px)").matches?"sm":"xs"}get el(){return n(this)}};o.style=".smart-bg{width:100%;height:100%;background-size:cover;background-repeat:no-repeat;background-position:50% 50%}.smart-img{position:absolute;display:block;width:100%;height:100%;top:0;left:0;background-size:cover;background-repeat:no-repeat;background-position:50% 50%}.radius-sm{border-radius:var(--ptc-border-radius-small)}.radius-md{border-radius:var(--ptc-border-radius-medium)}.radius-lg{border-radius:var(--ptc-border-radius-large)}.lazy-bg{background-image:none !important;background-color:var(--color-primary-lightgrey)}@media (max-width: 767px){.hidden-xs{display:none !important}}@media (min-width: 768px) and (max-width: 991px){.hidden-sm{display:none !important}}@media (min-width: 992px) and (max-width: 1199px){.hidden-md{display:none !important}}@media (min-width: 1200px){.hidden-lg{display:none !important}}";export{o as ptc_img}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as t,H as r}from"./p-50923c9a.js";const c=class{constructor(t){s(this,t),this.lazy="lazy"}render(){const s=this.getCssClassMap();return t(r,{class:s},t("picture",null,t("slot",null)))}getCssClassMap(){return{[this.lazy]:!0}}};c.style=":host{display:block}";export{c as ptc_picture}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare class PtcImage {
|
|
2
|
-
el: HTMLElement;
|
|
3
|
-
/**
|
|
4
|
-
* Image Render Src
|
|
5
|
-
*/
|
|
6
|
-
src: string;
|
|
7
|
-
/**
|
|
8
|
-
* Image alt
|
|
9
|
-
*/
|
|
10
|
-
alt: string;
|
|
11
|
-
/**Image Src */
|
|
12
|
-
oldSrc: string;
|
|
13
|
-
io: IntersectionObserver;
|
|
14
|
-
componentDidLoad(): void;
|
|
15
|
-
componentWillUpdate(): void;
|
|
16
|
-
addIntersectionObserver(): void;
|
|
17
|
-
render(): any;
|
|
18
|
-
}
|