@swisspost/design-system-components 10.0.0-next.46 → 10.0.0-next.48
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/{event-from-AKK8RQrn.js → event-from-C6kpQwhw.js} +2 -2
- package/dist/cjs/index-CpDyH7Ww.js +8 -8
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{package-Din0le0Q.js → package-CZyXYkIN.js} +1 -1
- package/dist/cjs/post-accordion_2.cjs.entry.js +4 -4
- package/dist/cjs/post-avatar.cjs.entry.js +91 -54
- package/dist/cjs/post-back-to-top.cjs.entry.js +32 -7
- package/dist/cjs/post-banner.cjs.entry.js +31 -35
- package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +1 -1
- package/dist/cjs/post-breadcrumbs.cjs.entry.js +1 -1
- package/dist/cjs/post-card-control.cjs.entry.js +3 -3
- package/dist/cjs/post-closebutton_15.cjs.entry.js +39 -8
- package/dist/cjs/post-collapsible_2.cjs.entry.js +2 -2
- package/dist/cjs/post-components.cjs.js +1 -1
- package/dist/cjs/post-footer.cjs.entry.js +1 -1
- package/dist/cjs/post-linkarea.cjs.entry.js +1 -1
- package/dist/cjs/post-popover.cjs.entry.js +1 -1
- package/dist/cjs/post-rating.cjs.entry.js +1 -1
- package/dist/cjs/post-tab-header.cjs.entry.js +1 -1
- package/dist/cjs/post-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/post-tabs.cjs.entry.js +2 -2
- package/dist/cjs/post-tooltip-trigger.cjs.entry.js +1 -1
- package/dist/cjs/post-tooltip.cjs.entry.js +1 -1
- package/dist/collection/animations/slide-and-fade.js +25 -0
- package/dist/collection/components/post-accordion-item/post-accordion-item.js +5 -5
- package/dist/collection/components/post-avatar/avatar-utils.js +16 -0
- package/dist/collection/components/post-avatar/post-avatar.js +91 -58
- package/dist/collection/components/post-back-to-top/post-back-to-top.css +1 -1
- package/dist/collection/components/post-back-to-top/post-back-to-top.js +5 -5
- package/dist/collection/components/post-banner/post-banner.css +1 -1
- package/dist/collection/components/post-banner/post-banner.js +41 -81
- package/dist/collection/components/post-card-control/post-card-control.js +8 -8
- package/dist/collection/components/post-closebutton/post-closebutton.js +9 -1
- package/dist/collection/components/post-menu/post-menu.js +4 -1
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +1 -1
- package/dist/collection/components/post-tabs/post-tabs.js +3 -3
- package/dist/collection/utils/event-from.js +2 -2
- package/dist/components/{p-8U5GFtQP.js → event-from.js} +2 -2
- package/dist/components/get-root.js +15 -0
- package/dist/components/index.d.ts +73 -0
- package/dist/components/index.js +36 -2315
- package/dist/components/package.js +3 -0
- package/dist/components/post-accordion-item.js +1 -1
- package/dist/components/post-accordion-item2.js +113 -0
- package/dist/components/post-accordion.js +1 -1
- package/dist/components/post-accordion2.js +138 -0
- package/dist/components/post-avatar.js +99 -62
- package/dist/components/post-back-to-top.js +37 -13
- package/dist/components/post-banner.js +39 -51
- package/dist/components/post-breadcrumb-item.js +1 -1
- package/dist/components/post-breadcrumb-item2.js +79 -0
- package/dist/components/post-breadcrumbs.js +13 -14
- package/dist/components/post-card-control.js +10 -11
- package/dist/components/post-closebutton.js +13 -6
- package/dist/components/post-collapsible-trigger.js +1 -1
- package/dist/components/post-collapsible-trigger2.js +135 -0
- package/dist/components/post-collapsible.js +1 -1
- package/dist/components/post-collapsible2.js +110 -0
- package/dist/components/post-footer.js +10 -11
- package/dist/components/post-header.js +30 -8
- package/dist/components/post-icon.js +1 -1
- package/dist/components/post-icon2.js +153 -0
- package/dist/components/post-language-option.js +8 -9
- package/dist/components/post-language-switch.js +12 -13
- package/dist/components/post-linkarea.js +3 -4
- package/dist/components/post-list-item.js +3 -4
- package/dist/components/post-list.js +4 -5
- package/dist/components/post-logo.js +5 -6
- package/dist/components/post-mainnavigation.js +4 -5
- package/dist/components/post-megadropdown-trigger.js +6 -7
- package/dist/components/post-megadropdown.js +7 -8
- package/dist/components/post-menu-item.js +1 -1
- package/dist/components/post-menu-item2.js +30 -0
- package/dist/components/post-menu-trigger.js +1 -1
- package/dist/components/post-menu-trigger2.js +110 -0
- package/dist/components/post-menu.js +1 -1
- package/dist/components/post-menu2.js +222 -0
- package/dist/components/post-popover.js +6 -7
- package/dist/components/post-popovercontainer.js +1 -1
- package/dist/components/post-popovercontainer2.js +3018 -0
- package/dist/components/post-rating.js +8 -9
- package/dist/components/post-tab-header.js +6 -7
- package/dist/components/post-tab-panel.js +6 -7
- package/dist/components/post-tabs.js +7 -8
- package/dist/components/post-togglebutton.js +3 -4
- package/dist/components/post-tooltip-trigger.js +6 -7
- package/dist/components/post-tooltip.js +6 -7
- package/dist/components/react/index.d.ts +33 -0
- package/dist/components/react/index.js +2315 -0
- package/dist/components/react/p-0Ltezq5O.js +3 -0
- package/dist/components/{p-C8YtuR96.js → react/p-38PqL5iD.js} +1 -1
- package/dist/components/react/p-BLchVpF6.js +14 -0
- package/dist/components/react/p-C35MCWIp.js +35 -0
- package/dist/components/{p-Dg6sSnLv.js → react/p-CGsAj6ij.js} +1 -1
- package/dist/components/react/p-CJ80BZ06.js +178 -0
- package/dist/{esm/index-BWC0gtGU.js → components/react/p-CV7fm1rW.js} +1 -1
- package/dist/components/react/p-C_2k3G1c.js +264 -0
- package/dist/components/{p-D1Ldeko3.js → react/p-Ce7jgYmK.js} +2 -2
- package/dist/components/{p-DNnYEFO6.js → react/p-CiYSngKM.js} +7 -7
- package/dist/components/{p-Cpy7mEQb.js → react/p-Da5wbVP8.js} +1 -1
- package/dist/components/{p-9rHPmDn6.js → react/p-Dq9F2i7n.js} +2 -2
- package/dist/components/{p-jLh9Y0sO.js → react/p-DzYquz3e.js} +2 -2
- package/dist/components/{p-C1i4rB_c.js → react/p-JHuJA2Lv.js} +4 -4
- package/dist/components/react/p-SbIC4aZX.js +11 -0
- package/dist/components/{p-Cd5RHPSU.js → react/p-Tg0GNTZM.js} +2 -2
- package/dist/{esm/event-from-8U5GFtQP.js → components/react/p-kraHE1r3.js} +2 -2
- package/dist/components/{p-DQE6fqIb.js → react/p-q8Fvf8A0.js} +1 -1
- package/dist/components/react/p-r4txK0AC.js +3 -0
- package/dist/components/react/post-accordion-item.d.ts +11 -0
- package/dist/components/react/post-accordion-item.js +6 -0
- package/dist/components/react/post-accordion.d.ts +11 -0
- package/dist/components/react/post-accordion.js +6 -0
- package/dist/components/react/post-avatar.d.ts +11 -0
- package/dist/components/react/post-avatar.js +226 -0
- package/dist/components/react/post-back-to-top.d.ts +11 -0
- package/dist/components/react/post-back-to-top.js +145 -0
- package/dist/components/react/post-banner.d.ts +11 -0
- package/dist/components/react/post-banner.js +99 -0
- package/dist/components/react/post-breadcrumb-item.d.ts +11 -0
- package/dist/components/react/post-breadcrumb-item.js +6 -0
- package/dist/components/react/post-breadcrumbs.d.ts +11 -0
- package/dist/components/react/post-breadcrumbs.js +187 -0
- package/dist/components/react/post-card-control.d.ts +11 -0
- package/dist/components/react/post-card-control.js +327 -0
- package/dist/components/react/post-closebutton.d.ts +11 -0
- package/dist/components/react/post-closebutton.js +50 -0
- package/dist/components/react/post-collapsible-trigger.d.ts +11 -0
- package/dist/components/react/post-collapsible-trigger.js +6 -0
- package/dist/components/react/post-collapsible.d.ts +11 -0
- package/dist/components/react/post-collapsible.js +6 -0
- package/dist/components/react/post-footer.d.ts +11 -0
- package/dist/components/react/post-footer.js +117 -0
- package/dist/components/react/post-header.d.ts +11 -0
- package/dist/components/react/post-header.js +333 -0
- package/dist/components/react/post-icon.d.ts +11 -0
- package/dist/components/react/post-icon.js +6 -0
- package/dist/components/react/post-language-option.d.ts +11 -0
- package/dist/components/react/post-language-option.js +101 -0
- package/dist/components/react/post-language-switch.d.ts +11 -0
- package/dist/components/react/post-language-switch.js +159 -0
- package/dist/components/react/post-linkarea.d.ts +11 -0
- package/dist/components/react/post-linkarea.js +46 -0
- package/dist/components/react/post-list-item.d.ts +11 -0
- package/dist/components/react/post-list-item.js +39 -0
- package/dist/components/react/post-list.d.ts +11 -0
- package/dist/components/react/post-list.js +62 -0
- package/dist/components/react/post-logo.d.ts +11 -0
- package/dist/components/react/post-logo.js +59 -0
- package/dist/components/react/post-mainnavigation.d.ts +11 -0
- package/dist/components/react/post-mainnavigation.js +181 -0
- package/dist/components/react/post-megadropdown-trigger.d.ts +11 -0
- package/dist/components/react/post-megadropdown-trigger.js +137 -0
- package/dist/components/react/post-megadropdown.d.ts +11 -0
- package/dist/components/react/post-megadropdown.js +197 -0
- package/dist/components/react/post-menu-item.d.ts +11 -0
- package/dist/components/react/post-menu-item.js +6 -0
- package/dist/components/react/post-menu-trigger.d.ts +11 -0
- package/dist/components/react/post-menu-trigger.js +6 -0
- package/dist/components/react/post-menu.d.ts +11 -0
- package/dist/components/react/post-menu.js +6 -0
- package/dist/components/react/post-popover.d.ts +11 -0
- package/dist/components/react/post-popover.js +189 -0
- package/dist/components/react/post-popovercontainer.d.ts +11 -0
- package/dist/components/react/post-popovercontainer.js +6 -0
- package/dist/components/react/post-rating.d.ts +11 -0
- package/dist/components/react/post-rating.js +153 -0
- package/dist/components/react/post-tab-header.d.ts +11 -0
- package/dist/components/react/post-tab-header.js +53 -0
- package/dist/components/react/post-tab-panel.d.ts +11 -0
- package/dist/components/react/post-tab-panel.js +55 -0
- package/dist/components/react/post-tabs.d.ts +11 -0
- package/dist/components/react/post-tabs.js +197 -0
- package/dist/components/react/post-togglebutton.d.ts +11 -0
- package/dist/components/react/post-togglebutton.js +57 -0
- package/dist/components/react/post-tooltip-trigger.d.ts +11 -0
- package/dist/components/react/post-tooltip-trigger.js +5223 -0
- package/dist/components/react/post-tooltip.d.ts +11 -0
- package/dist/components/react/post-tooltip.js +115 -0
- package/dist/components/switch-variants.js +3 -0
- package/dist/docs.json +43 -76
- package/dist/esm/event-from-kraHE1r3.js +105 -0
- package/dist/esm/index-C8a0ddDa.js +8 -8
- package/dist/esm/index-VmK3ABCB.js +88 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/package-0Ltezq5O.js +3 -0
- package/dist/esm/post-accordion_2.entry.js +5 -5
- package/dist/esm/post-avatar.entry.js +92 -55
- package/dist/esm/post-back-to-top.entry.js +33 -8
- package/dist/esm/post-banner.entry.js +32 -36
- package/dist/esm/post-breadcrumb-item_2.entry.js +2 -2
- package/dist/esm/post-breadcrumbs.entry.js +2 -2
- package/dist/esm/post-card-control.entry.js +4 -4
- package/dist/esm/post-closebutton_15.entry.js +38 -7
- package/dist/esm/post-collapsible_2.entry.js +3 -3
- package/dist/esm/post-components.js +1 -1
- package/dist/esm/post-footer.entry.js +2 -2
- package/dist/esm/post-linkarea.entry.js +1 -1
- package/dist/esm/post-popover.entry.js +2 -2
- package/dist/esm/post-rating.entry.js +2 -2
- package/dist/esm/post-tab-header.entry.js +2 -2
- package/dist/esm/post-tab-panel.entry.js +2 -2
- package/dist/esm/post-tabs.entry.js +2 -2
- package/dist/esm/post-tooltip-trigger.entry.js +2 -2
- package/dist/esm/post-tooltip.entry.js +2 -2
- package/dist/loader/cdn.js +1 -0
- package/dist/loader/index.cjs.js +1 -0
- package/{loader → dist/loader}/index.d.ts +1 -1
- package/dist/loader/index.es2017.js +1 -0
- package/{loader → dist/loader}/index.js +1 -1
- package/dist/post-components/p-0Ltezq5O.js +1 -0
- package/dist/post-components/{p-eddb07df.entry.js → p-16772417.entry.js} +1 -1
- package/dist/post-components/{p-1dee733a.entry.js → p-38d3d441.entry.js} +1 -1
- package/dist/post-components/{p-470750be.entry.js → p-3c71f590.entry.js} +1 -1
- package/dist/post-components/p-40f21542.entry.js +1 -0
- package/dist/post-components/{p-30f12b7c.entry.js → p-4243cdd1.entry.js} +1 -1
- package/dist/post-components/p-4c18cb8c.entry.js +1 -0
- package/dist/post-components/{p-7819009b.entry.js → p-51dc7647.entry.js} +1 -1
- package/dist/post-components/{p-80bad606.entry.js → p-6777e505.entry.js} +1 -1
- package/dist/post-components/{p-7689015e.entry.js → p-6add880f.entry.js} +1 -1
- package/dist/post-components/{p-74a9aafc.entry.js → p-8363fedb.entry.js} +1 -1
- package/dist/post-components/p-83998038.entry.js +1 -0
- package/dist/post-components/{p-cb937e6b.entry.js → p-85bb1b5e.entry.js} +1 -1
- package/dist/post-components/{p-a0a1cab6.entry.js → p-8f4d8685.entry.js} +1 -1
- package/dist/post-components/{p-a69c874a.entry.js → p-95ad536d.entry.js} +1 -1
- package/dist/post-components/{p-3789cf50.entry.js → p-9d806e89.entry.js} +1 -1
- package/dist/post-components/{p-BWC0gtGU.js → p-VmK3ABCB.js} +1 -1
- package/dist/post-components/p-aad86320.entry.js +1 -0
- package/dist/post-components/p-c3e38acf.entry.js +1 -0
- package/dist/post-components/{p-ba13450e.entry.js → p-d61bb2ff.entry.js} +1 -1
- package/dist/post-components/p-kraHE1r3.js +1 -0
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/types/animations/slide-and-fade.d.ts +2 -0
- package/dist/types/components/post-accordion-item/post-accordion-item.d.ts +3 -3
- package/dist/types/components/post-avatar/avatar-utils.d.ts +3 -0
- package/dist/types/components/post-avatar/post-avatar.d.ts +14 -11
- package/dist/types/components/post-banner/post-banner.d.ts +6 -14
- package/dist/types/components/post-card-control/post-card-control.d.ts +7 -7
- package/dist/types/components/post-closebutton/post-closebutton.d.ts +2 -0
- package/dist/types/components/post-menu/post-menu.d.ts +3 -0
- package/dist/types/components/post-tabs/post-tabs.d.ts +2 -2
- package/dist/types/components.d.ts +9 -27
- package/dist/types/utils/component-on-ready.d.ts +2 -2
- package/hydrate/index.js +208 -142
- package/hydrate/index.mjs +208 -142
- package/package.json +20 -10
- package/dist/cjs/slide-CbBL7A8w.js +0 -28
- package/dist/components/p-7hVD-I9l.js +0 -3
- package/dist/components/p-BuLMaH5t.js +0 -25
- package/dist/esm/package-7hVD-I9l.js +0 -3
- package/dist/esm/slide-BuLMaH5t.js +0 -25
- package/dist/post-components/p-26730afe.entry.js +0 -1
- package/dist/post-components/p-2d3fb75c.entry.js +0 -1
- package/dist/post-components/p-2ed74834.entry.js +0 -1
- package/dist/post-components/p-7hVD-I9l.js +0 -1
- package/dist/post-components/p-8U5GFtQP.js +0 -1
- package/dist/post-components/p-BuLMaH5t.js +0 -1
- package/dist/post-components/p-cb5af9d8.entry.js +0 -1
- package/dist/post-components/p-ea9ae6b7.entry.js +0 -1
- package/loader/cdn.js +0 -1
- package/loader/index.cjs.js +0 -1
- package/loader/index.es2017.js +0 -1
- /package/dist/components/{p-CJ80BZ06.js → breakpoints.js} +0 -0
- /package/dist/components/{p-SbIC4aZX.js → fade.js} +0 -0
- /package/dist/components/{p-C35MCWIp.js → get-focusable-children.js} +0 -0
- /package/dist/components/{p-r4txK0AC.js → heading-levels.js} +0 -0
- /package/dist/components/{p-BLchVpF6.js → index.browser.js} +0 -0
- /package/dist/components/{p-CV7fm1rW.js → index2.js} +0 -0
- /package/dist/components/{p-C_2k3G1c.js → long-press-event.js} +0 -0
- /package/dist/components/{p-CBFgkSgY.js → react/p-CBFgkSgY.js} +0 -0
- /package/dist/components/{p-DjIHLduJ.js → react/p-DjIHLduJ.js} +0 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import { version } from "../../../../package";
|
|
3
3
|
import { checkRequiredAndType, checkEmptyOrPattern, checkEmptyOrType } from "../../utils/index";
|
|
4
|
-
|
|
5
|
-
const GRAVATAR_DEFAULT = '404';
|
|
6
|
-
const GRAVATAR_RATING = 'g';
|
|
7
|
-
const GRAVATAR_SIZE = 80;
|
|
8
|
-
const GRAVATAR_BASE_URL = `https://www.gravatar.com/avatar/{email}?s=${GRAVATAR_SIZE}&d=${GRAVATAR_DEFAULT}&r=${GRAVATAR_RATING}`;
|
|
4
|
+
import { GRAVATAR_BASE_URL } from "./avatar-utils";
|
|
9
5
|
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
10
6
|
var AvatarType;
|
|
11
7
|
(function (AvatarType) {
|
|
@@ -23,6 +19,8 @@ export class PostAvatar {
|
|
|
23
19
|
this.imageUrl = '';
|
|
24
20
|
this.imageAlt = '';
|
|
25
21
|
this.initials = '';
|
|
22
|
+
// To handle email or userid updates and reset the storage item
|
|
23
|
+
this.storageKey = '';
|
|
26
24
|
}
|
|
27
25
|
validateFirstname() {
|
|
28
26
|
checkRequiredAndType(this, 'firstname', 'string');
|
|
@@ -30,47 +28,67 @@ export class PostAvatar {
|
|
|
30
28
|
validateLastname() {
|
|
31
29
|
checkEmptyOrType(this, 'lastname', 'string');
|
|
32
30
|
}
|
|
33
|
-
|
|
31
|
+
updateUserid() {
|
|
32
|
+
this.validateUserId();
|
|
33
|
+
this.getAvatarImage();
|
|
34
|
+
}
|
|
35
|
+
updateEmail() {
|
|
36
|
+
this.validateEmail();
|
|
37
|
+
this.getAvatarImage();
|
|
38
|
+
}
|
|
39
|
+
validateUserId() {
|
|
34
40
|
checkEmptyOrType(this, 'userid', 'string');
|
|
35
41
|
}
|
|
36
42
|
validateEmail() {
|
|
37
43
|
if (this.email)
|
|
38
44
|
checkEmptyOrPattern(this, 'email', emailPattern);
|
|
39
45
|
}
|
|
40
|
-
async
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!imageLoaded && this.userid)
|
|
46
|
+
async getAvatarImage() {
|
|
47
|
+
let imageLoaded = false;
|
|
48
|
+
this.slottedImage = this.host.querySelector('img');
|
|
49
|
+
const imageUrl = this.slottedImage?.getAttribute('src');
|
|
50
|
+
if (!imageUrl) {
|
|
51
|
+
if (this.userid) {
|
|
47
52
|
imageLoaded = await this.getImageByProp(this.userid, this.fetchImageByUserId.bind(this));
|
|
48
|
-
|
|
53
|
+
}
|
|
54
|
+
if (!imageLoaded && this.email?.match(emailPattern)) {
|
|
49
55
|
imageLoaded = await this.getImageByProp(this.email, this.fetchImageByEmail.bind(this));
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
}
|
|
57
|
+
if (!imageLoaded) {
|
|
58
|
+
this.getAvatarInitials();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const slottedImageLoaded = await this.getImageByProp(imageUrl, this.fetchSlottedImage.bind(this));
|
|
63
|
+
if (!slottedImageLoaded) {
|
|
64
|
+
this.slottedImage.style.display = 'none';
|
|
65
|
+
this.getAvatarInitials();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.slottedImage.style.display = 'block';
|
|
69
|
+
}
|
|
52
70
|
}
|
|
53
71
|
}
|
|
54
72
|
async getImageByProp(prop, fetchImage) {
|
|
55
73
|
if (!prop)
|
|
56
74
|
return false;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
let imageResponse;
|
|
76
|
+
try {
|
|
77
|
+
imageResponse = await fetchImage(prop);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.info('Loading avatar image failed.', error);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!imageResponse?.ok) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.imageUrl = imageResponse.url;
|
|
88
|
+
this.imageAlt = `${this.firstname} ${this.lastname} avatar`;
|
|
89
|
+
this.avatarType = AvatarType.Image;
|
|
90
|
+
return true;
|
|
72
91
|
}
|
|
73
|
-
return imageResponse.ok;
|
|
74
92
|
}
|
|
75
93
|
async fetchImageByUserId() {
|
|
76
94
|
return await fetch(PostAvatar.INTERNAL_USERID_IMAGE_SRC.replace('{userid}', encodeURIComponent(this.userid)));
|
|
@@ -80,7 +98,10 @@ export class PostAvatar {
|
|
|
80
98
|
const imageUrl = GRAVATAR_BASE_URL.replace('{email}', email);
|
|
81
99
|
return await fetch(imageUrl);
|
|
82
100
|
}
|
|
83
|
-
|
|
101
|
+
async fetchSlottedImage(imageUrl) {
|
|
102
|
+
return await fetch(imageUrl, { method: 'HEAD' });
|
|
103
|
+
}
|
|
104
|
+
getAvatarInitials() {
|
|
84
105
|
this.initials = this.getInitials();
|
|
85
106
|
this.avatarType = AvatarType.Initials;
|
|
86
107
|
}
|
|
@@ -93,19 +114,6 @@ export class PostAvatar {
|
|
|
93
114
|
.join('')
|
|
94
115
|
.trim();
|
|
95
116
|
}
|
|
96
|
-
async getStorageItem(keyToken) {
|
|
97
|
-
const key = await this.cryptify(keyToken);
|
|
98
|
-
const value = window?.sessionStorage?.getItem(key);
|
|
99
|
-
return value ? JSON.parse(value) : null;
|
|
100
|
-
}
|
|
101
|
-
async setStorageItem(keyToken, value) {
|
|
102
|
-
const key = await this.cryptify(keyToken);
|
|
103
|
-
window?.sessionStorage?.setItem(key, value);
|
|
104
|
-
}
|
|
105
|
-
async removeStorageItem(keyToken) {
|
|
106
|
-
const key = await this.cryptify(keyToken);
|
|
107
|
-
window?.sessionStorage?.removeItem(key);
|
|
108
|
-
}
|
|
109
117
|
async cryptify(key) {
|
|
110
118
|
return await crypto.subtle.digest('SHA-256', new TextEncoder().encode(key)).then(buffer => {
|
|
111
119
|
return Array.from(new Uint8Array(buffer))
|
|
@@ -113,18 +121,42 @@ export class PostAvatar {
|
|
|
113
121
|
.join('');
|
|
114
122
|
});
|
|
115
123
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
slotChanged() {
|
|
125
|
+
const slot = this.host.shadowRoot.querySelector('slot');
|
|
126
|
+
const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
127
|
+
assignedNodes.forEach(node => {
|
|
128
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
129
|
+
const el = node;
|
|
130
|
+
if (el.tagName === 'IMG') {
|
|
131
|
+
this.observeImageSrcChanges(el);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
this.getAvatarImage();
|
|
119
136
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
137
|
+
// Observe the Slotted image src attribute and update the image
|
|
138
|
+
observeImageSrcChanges(img) {
|
|
139
|
+
if (this.slottedImageObserver) {
|
|
140
|
+
this.slottedImageObserver.disconnect();
|
|
141
|
+
}
|
|
142
|
+
this.slottedImageObserver = new MutationObserver(mutations => {
|
|
143
|
+
mutations.forEach(mutation => {
|
|
144
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
|
|
145
|
+
this.getAvatarImage();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
this.slottedImageObserver.observe(img, { attributes: true, attributeFilter: ['src'] });
|
|
150
|
+
}
|
|
151
|
+
connectedCallback() {
|
|
152
|
+
//This provides a fallback by showing the initials while the image is still loading or delayed.
|
|
153
|
+
this.getAvatarInitials();
|
|
154
|
+
this.getAvatarImage();
|
|
123
155
|
}
|
|
124
156
|
componentDidLoad() {
|
|
125
157
|
this.validateFirstname();
|
|
126
158
|
this.validateLastname();
|
|
127
|
-
this.
|
|
159
|
+
this.validateUserId();
|
|
128
160
|
this.validateEmail();
|
|
129
161
|
}
|
|
130
162
|
render() {
|
|
@@ -136,7 +168,7 @@ export class PostAvatar {
|
|
|
136
168
|
// eslint-disable-next-line @stencil-community/render-returns-host
|
|
137
169
|
return acc;
|
|
138
170
|
}, []);
|
|
139
|
-
return (h(Host, { "data-version": version }, h("slot", { onSlotchange: this.
|
|
171
|
+
return (h(Host, { "data-version": version }, h("span", { class: this.avatarType === 'slotted' ? '' : 'd-none' }, h("slot", { onSlotchange: this.slotChanged.bind(this) })), this.avatarType === 'image' && h("img", { src: this.imageUrl, alt: this.imageAlt }), this.avatarType === 'initials' && h("div", { class: "initials" }, initials)));
|
|
140
172
|
}
|
|
141
173
|
static get is() { return "post-avatar"; }
|
|
142
174
|
static get encapsulation() { return "shadow"; }
|
|
@@ -203,7 +235,7 @@ export class PostAvatar {
|
|
|
203
235
|
"optional": true,
|
|
204
236
|
"docs": {
|
|
205
237
|
"tags": [],
|
|
206
|
-
"text": "Defines the company internal userId.<
|
|
238
|
+
"text": "Defines the company internal userId.<post-banner type=\"warning\" data-size=\"sm\"><p>Can only be used on post.ch domains!</p></post-banner>"
|
|
207
239
|
},
|
|
208
240
|
"getter": false,
|
|
209
241
|
"setter": false,
|
|
@@ -236,7 +268,8 @@ export class PostAvatar {
|
|
|
236
268
|
"avatarType": {},
|
|
237
269
|
"imageUrl": {},
|
|
238
270
|
"imageAlt": {},
|
|
239
|
-
"initials": {}
|
|
271
|
+
"initials": {},
|
|
272
|
+
"storageKey": {}
|
|
240
273
|
};
|
|
241
274
|
}
|
|
242
275
|
static get elementRef() { return "host"; }
|
|
@@ -249,10 +282,10 @@ export class PostAvatar {
|
|
|
249
282
|
"methodName": "validateLastname"
|
|
250
283
|
}, {
|
|
251
284
|
"propName": "userid",
|
|
252
|
-
"methodName": "
|
|
285
|
+
"methodName": "updateUserid"
|
|
253
286
|
}, {
|
|
254
287
|
"propName": "email",
|
|
255
|
-
"methodName": "
|
|
288
|
+
"methodName": "updateEmail"
|
|
256
289
|
}];
|
|
257
290
|
}
|
|
258
291
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host{
|
|
1
|
+
:host{opacity:0;--post-floating-button-position-top: var(--post-device-position-4);--post-back-to-top-position-top: calc( var(--post-header-height) + var(--post-floating-button-position-top) );--post-back-to-top-elevation: var(--post-device-elevation-300);position:fixed;inset-block-start:var(--post-back-to-top-position-top);inset-inline-end:var(--post-device-position-1)}:host .back-to-top{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;box-shadow:var(--post-back-to-top-elevation);cursor:pointer;border-radius:var(--post-device-border-radius-round);width:var(--post-device-sizing-interactive-button-height-2);height:var(--post-device-sizing-interactive-button-height-2);border:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-button-secondary-enabled-stroke);color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);background-color:var(--post-scheme-color-interactive-button-secondary-enabled-bg);display:flex;align-items:center;justify-content:center}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top{background-color:ButtonFace !important}:host .back-to-top:hover{background-color:Highlight !important}}:host .back-to-top{outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}:host .back-to-top:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){:host .back-to-top:is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}:host .back-to-top:hover{border-color:var(--post-scheme-color-interactive-button-secondary-hover-stroke);color:var(--post-scheme-color-interactive-button-secondary-hover-fg);background-color:var(--post-scheme-color-interactive-button-secondary-hover-bg)}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top:hover{color:HighlightText !important}}:host .back-to-top post-icon{height:var(--post-device-sizing-interactive-button-icon-3);width:var(--post-device-sizing-interactive-button-icon-3)}:host .visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import {
|
|
2
|
+
import { slideUpAndFadeOut, slideDownAndFadeIn } from "../../animations/slide-and-fade";
|
|
3
3
|
import { version } from "../../../../package";
|
|
4
4
|
import { checkRequiredAndType } from "../../utils/index";
|
|
5
5
|
export class PostBackToTop {
|
|
@@ -18,10 +18,10 @@ export class PostBackToTop {
|
|
|
18
18
|
/*Watch for changes in belowFold to show/hide the back to top button*/
|
|
19
19
|
watchBelowFold(newValue) {
|
|
20
20
|
if (newValue) {
|
|
21
|
-
|
|
21
|
+
slideDownAndFadeIn(this.host, this.translateY);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
|
|
24
|
+
slideUpAndFadeOut(this.host, this.translateY);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
scrollToTop() {
|
|
@@ -52,7 +52,7 @@ export class PostBackToTop {
|
|
|
52
52
|
parseFloat(positionTop.replace('px', '')) -
|
|
53
53
|
parseFloat(elevationHeight.replace('px', ''))) + 'px';
|
|
54
54
|
if (this.belowFold) {
|
|
55
|
-
|
|
55
|
+
slideDownAndFadeIn(this.host, this.translateY);
|
|
56
56
|
}
|
|
57
57
|
if (!this.belowFold) {
|
|
58
58
|
this.host.style.transform = `translateY(${this.translateY})`;
|
|
@@ -71,7 +71,7 @@ export class PostBackToTop {
|
|
|
71
71
|
window.removeEventListener('scroll', this.handleScroll);
|
|
72
72
|
}
|
|
73
73
|
render() {
|
|
74
|
-
return (h(Host, { key: '
|
|
74
|
+
return (h(Host, { key: '820244e9c039304895d78887000ed986707bf3b1', "data-version": version }, h("button", { key: 'c1d38883fbf31c50b2b00e08e6b22cbc6be37adb', class: "back-to-top", "aria-hidden": this.belowFold ? 'false' : 'true', tabindex: this.belowFold ? '0' : '-1', onClick: this.scrollToTop }, h("post-icon", { key: '3cc57c355a12bf500f368e906d147be10f9014e7', "aria-hidden": "true", name: "3026" }), h("span", { key: '134e5c579e2d99d64c25ce21ab538e51520a6dd6', class: "visually-hidden" }, this.label))));
|
|
75
75
|
}
|
|
76
76
|
static get is() { return "post-back-to-top"; }
|
|
77
77
|
static get encapsulation() { return "shadow"; }
|