@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../../types/components";
|
|
2
|
+
|
|
3
|
+
interface PostTooltip extends Components.PostTooltip, HTMLElement {}
|
|
4
|
+
export const PostTooltip: {
|
|
5
|
+
prototype: PostTooltip;
|
|
6
|
+
new (): PostTooltip;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, h, a as Host } from './index.js';
|
|
2
|
+
import { v as version } from './p-0Ltezq5O.js';
|
|
3
|
+
import { d as checkEmptyOrOneOf } from './p-CV7fm1rW.js';
|
|
4
|
+
import './p-CJ80BZ06.js';
|
|
5
|
+
import { d as defineCustomElement$2, a as PLACEMENT_TYPES } from './p-Ce7jgYmK.js';
|
|
6
|
+
|
|
7
|
+
const postTooltipCss = ":host{display:none}:host([open]){display:contents}post-popovercontainer[arrow]::after{position:absolute;content:\"\";inset:-13px;z-index:-1}post-popovercontainer>div{color:var(--post-current-fg);background-color:var(--post-current-bg);padding:var(--post-core-dimension-4) var(--post-core-dimension-8);max-width:280px;min-height:32px;word-wrap:break-word;white-space:normal}";
|
|
8
|
+
|
|
9
|
+
const PostTooltip$1 = /*@__PURE__*/ proxyCustomElement(class PostTooltip extends H {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.__registerHost();
|
|
13
|
+
this.__attachShadow();
|
|
14
|
+
/**
|
|
15
|
+
* Defines the position of the tooltip relative to its trigger.
|
|
16
|
+
* Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted towards the viewport if they would overlap edge boundaries.
|
|
17
|
+
* For supported values and behavior details, see the [Floating UI placement documentation](https://floating-ui.com/docs/computePosition#placement).
|
|
18
|
+
*/
|
|
19
|
+
this.placement = 'top';
|
|
20
|
+
/**
|
|
21
|
+
* Whether or not to display a little pointer arrow
|
|
22
|
+
*/
|
|
23
|
+
this.arrow = false;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates the open state of the tooltip
|
|
26
|
+
*/
|
|
27
|
+
this.open = false;
|
|
28
|
+
}
|
|
29
|
+
validatePlacement() {
|
|
30
|
+
checkEmptyOrOneOf(this, 'placement', PLACEMENT_TYPES);
|
|
31
|
+
}
|
|
32
|
+
componentWillLoad() {
|
|
33
|
+
this.validatePlacement();
|
|
34
|
+
}
|
|
35
|
+
componentDidLoad() {
|
|
36
|
+
if (!this.host.id) {
|
|
37
|
+
console.error(
|
|
38
|
+
/*prettier-ignore*/
|
|
39
|
+
'No id set: <post-tooltip> must have an id, linking it to it\'s target element with a <post-tooltip-trigger> element.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Programmatically display the tooltip.
|
|
44
|
+
* @param target An element where the tooltip should be shown
|
|
45
|
+
*/
|
|
46
|
+
async show(target) {
|
|
47
|
+
if (this.open)
|
|
48
|
+
return;
|
|
49
|
+
this.popoverRef.show(target);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Programmatically hide this tooltip.
|
|
53
|
+
*/
|
|
54
|
+
async hide() {
|
|
55
|
+
this.popoverRef.hide();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Toggle tooltip display.
|
|
59
|
+
* @param target An element where the tooltip should be shown
|
|
60
|
+
* @param [force] Pass true to always show or false to always hide
|
|
61
|
+
*/
|
|
62
|
+
async toggle(target, force) {
|
|
63
|
+
this.popoverRef.toggle(target, force);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Set the open state based on the toggle event.
|
|
67
|
+
* @param e Popovercontainer toggle event
|
|
68
|
+
*/
|
|
69
|
+
handleToggle(e) {
|
|
70
|
+
this.open = e.detail;
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const popoverClass = `${this.arrow ? 'has-arrow' : ''}`;
|
|
74
|
+
return (h(Host, { key: 'c5f293812e33520ea5a2c9224e93fe5e5e41cbe0', "data-version": version }, h("post-popovercontainer", { key: '7ec57e1a2315d95e7cb696cf6d2d1a1d8ae77257', safeSpace: "trapezoid", class: popoverClass, role: "tooltip", arrow: this.arrow, animation: this.animation, placement: this.placement, onPostToggle: e => this.handleToggle(e), ref: (el) => (this.popoverRef = el) }, h("slot", { key: '79c91307707c56345acb136a45acdae859d54c2b' }))));
|
|
75
|
+
}
|
|
76
|
+
get host() { return this; }
|
|
77
|
+
static get watchers() { return {
|
|
78
|
+
"placement": ["validatePlacement"]
|
|
79
|
+
}; }
|
|
80
|
+
static get style() { return postTooltipCss; }
|
|
81
|
+
}, [1, "post-tooltip", {
|
|
82
|
+
"placement": [1],
|
|
83
|
+
"arrow": [4],
|
|
84
|
+
"animation": [1],
|
|
85
|
+
"open": [1540],
|
|
86
|
+
"show": [64],
|
|
87
|
+
"hide": [64],
|
|
88
|
+
"toggle": [64]
|
|
89
|
+
}, undefined, {
|
|
90
|
+
"placement": ["validatePlacement"]
|
|
91
|
+
}]);
|
|
92
|
+
function defineCustomElement$1() {
|
|
93
|
+
if (typeof customElements === "undefined") {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const components = ["post-tooltip", "post-popovercontainer"];
|
|
97
|
+
components.forEach(tagName => { switch (tagName) {
|
|
98
|
+
case "post-tooltip":
|
|
99
|
+
if (!customElements.get(tagName)) {
|
|
100
|
+
customElements.define(tagName, PostTooltip$1);
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case "post-popovercontainer":
|
|
104
|
+
if (!customElements.get(tagName)) {
|
|
105
|
+
defineCustomElement$2();
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
} });
|
|
109
|
+
}
|
|
110
|
+
defineCustomElement$1();
|
|
111
|
+
|
|
112
|
+
const PostTooltip = PostTooltip$1;
|
|
113
|
+
const defineCustomElement = defineCustomElement$1;
|
|
114
|
+
|
|
115
|
+
export { PostTooltip, defineCustomElement };
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-
|
|
2
|
+
"timestamp": "2025-09-15T11:02:00",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.35.0",
|
|
@@ -215,15 +215,15 @@
|
|
|
215
215
|
"docsTags": [
|
|
216
216
|
{
|
|
217
217
|
"name": "part",
|
|
218
|
-
"text": "button - The
|
|
218
|
+
"text": "button - The element that toggles the accordion item (header button)."
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
"name": "part",
|
|
222
|
-
"text": "body - The
|
|
222
|
+
"text": "body - The container element that holds the accordion item's content."
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
"name": "slot",
|
|
226
|
-
"text": "logo - Slot for
|
|
226
|
+
"text": "logo - Slot for placing a logo in the accordion item’s header, before the content."
|
|
227
227
|
},
|
|
228
228
|
{
|
|
229
229
|
"name": "slot",
|
|
@@ -378,7 +378,7 @@
|
|
|
378
378
|
},
|
|
379
379
|
{
|
|
380
380
|
"name": "logo",
|
|
381
|
-
"docs": "Slot for
|
|
381
|
+
"docs": "Slot for placing a logo in the accordion item’s header, before the content."
|
|
382
382
|
}
|
|
383
383
|
],
|
|
384
384
|
"parts": [
|
|
@@ -388,11 +388,11 @@
|
|
|
388
388
|
},
|
|
389
389
|
{
|
|
390
390
|
"name": "body",
|
|
391
|
-
"docs": "The
|
|
391
|
+
"docs": "The container element that holds the accordion item's content."
|
|
392
392
|
},
|
|
393
393
|
{
|
|
394
394
|
"name": "button",
|
|
395
|
-
"docs": "The
|
|
395
|
+
"docs": "The element that toggles the accordion item (header button)."
|
|
396
396
|
}
|
|
397
397
|
],
|
|
398
398
|
"dependents": [
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
"mutable": false,
|
|
509
509
|
"attr": "userid",
|
|
510
510
|
"reflectToAttr": false,
|
|
511
|
-
"docs": "Defines the company internal userId.<
|
|
511
|
+
"docs": "Defines the company internal userId.<post-banner type=\"warning\" data-size=\"sm\"><p>Can only be used on post.ch domains!</p></post-banner>",
|
|
512
512
|
"docsTags": [],
|
|
513
513
|
"values": [
|
|
514
514
|
{
|
|
@@ -600,6 +600,10 @@
|
|
|
600
600
|
"name": "slot",
|
|
601
601
|
"text": "actions - Slot for placing custom actions (buttons, links, etc.) within the banner."
|
|
602
602
|
},
|
|
603
|
+
{
|
|
604
|
+
"name": "slot",
|
|
605
|
+
"text": "close-button - Slot for placing a `post-closebutton` component to make the banner dismissible."
|
|
606
|
+
},
|
|
603
607
|
{
|
|
604
608
|
"name": "slot",
|
|
605
609
|
"text": "default - Slot for placing the main content/message of the banner."
|
|
@@ -607,58 +611,6 @@
|
|
|
607
611
|
],
|
|
608
612
|
"usage": {},
|
|
609
613
|
"props": [
|
|
610
|
-
{
|
|
611
|
-
"name": "dismissLabel",
|
|
612
|
-
"type": "string",
|
|
613
|
-
"complexType": {
|
|
614
|
-
"original": "string",
|
|
615
|
-
"resolved": "string",
|
|
616
|
-
"references": {}
|
|
617
|
-
},
|
|
618
|
-
"mutable": false,
|
|
619
|
-
"attr": "dismiss-label",
|
|
620
|
-
"reflectToAttr": false,
|
|
621
|
-
"docs": "The label to use for the close button of a dismissible banner.",
|
|
622
|
-
"docsTags": [],
|
|
623
|
-
"values": [
|
|
624
|
-
{
|
|
625
|
-
"type": "string"
|
|
626
|
-
}
|
|
627
|
-
],
|
|
628
|
-
"optional": true,
|
|
629
|
-
"required": false,
|
|
630
|
-
"getter": false,
|
|
631
|
-
"setter": false
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
"name": "dismissible",
|
|
635
|
-
"type": "boolean",
|
|
636
|
-
"complexType": {
|
|
637
|
-
"original": "boolean",
|
|
638
|
-
"resolved": "boolean",
|
|
639
|
-
"references": {}
|
|
640
|
-
},
|
|
641
|
-
"mutable": false,
|
|
642
|
-
"attr": "dismissible",
|
|
643
|
-
"reflectToAttr": false,
|
|
644
|
-
"docs": "If `true`, a close button (×) is displayed and the banner can be dismissed by the user.",
|
|
645
|
-
"docsTags": [
|
|
646
|
-
{
|
|
647
|
-
"name": "default",
|
|
648
|
-
"text": "false"
|
|
649
|
-
}
|
|
650
|
-
],
|
|
651
|
-
"default": "false",
|
|
652
|
-
"values": [
|
|
653
|
-
{
|
|
654
|
-
"type": "boolean"
|
|
655
|
-
}
|
|
656
|
-
],
|
|
657
|
-
"optional": false,
|
|
658
|
-
"required": false,
|
|
659
|
-
"getter": false,
|
|
660
|
-
"setter": false
|
|
661
|
-
},
|
|
662
614
|
{
|
|
663
615
|
"name": "type",
|
|
664
616
|
"type": "\"error\" | \"info\" | \"success\" | \"warning\"",
|
|
@@ -675,7 +627,7 @@
|
|
|
675
627
|
},
|
|
676
628
|
"mutable": false,
|
|
677
629
|
"attr": "type",
|
|
678
|
-
"reflectToAttr":
|
|
630
|
+
"reflectToAttr": true,
|
|
679
631
|
"docs": "The type of the banner.",
|
|
680
632
|
"docsTags": [
|
|
681
633
|
{
|
|
@@ -748,13 +700,23 @@
|
|
|
748
700
|
"docsTags": []
|
|
749
701
|
}
|
|
750
702
|
],
|
|
751
|
-
"listeners": [
|
|
703
|
+
"listeners": [
|
|
704
|
+
{
|
|
705
|
+
"event": "click",
|
|
706
|
+
"capture": false,
|
|
707
|
+
"passive": false
|
|
708
|
+
}
|
|
709
|
+
],
|
|
752
710
|
"styles": [],
|
|
753
711
|
"slots": [
|
|
754
712
|
{
|
|
755
713
|
"name": "actions",
|
|
756
714
|
"docs": "Slot for placing custom actions (buttons, links, etc.) within the banner."
|
|
757
715
|
},
|
|
716
|
+
{
|
|
717
|
+
"name": "close-button",
|
|
718
|
+
"docs": "Slot for placing a `post-closebutton` component to make the banner dismissible."
|
|
719
|
+
},
|
|
758
720
|
{
|
|
759
721
|
"name": "default",
|
|
760
722
|
"docs": "Slot for placing the main content/message of the banner."
|
|
@@ -946,11 +908,11 @@
|
|
|
946
908
|
},
|
|
947
909
|
{
|
|
948
910
|
"name": "slot",
|
|
949
|
-
"text": "default - Content to place into the `default` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Block-level_contentt\">block content</a>.<
|
|
911
|
+
"text": "default - Content to place into the `default` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Block-level_contentt\">block content</a>.<post-banner type=\"warning\" data-size=\"sm\"><p>Even if it is generally possible, we do not recommend using interactive elements in this slot because the background of the card control is clickable.<br/>This can lead to confusion when the hit box of nested interactive controls is not clearly separated from the background, is invalid HTML and click events bubbling up to the card control will unexpectedly toggle it if they're not captured.<br/>More info: <a href=\"https://accessibilityinsights.io/info-examples/web/nested-interactive/\">https://accessibilityinsights.io/info-examples/web/nested-interactive/</a></p></post-banner>"
|
|
950
912
|
},
|
|
951
913
|
{
|
|
952
914
|
"name": "slot",
|
|
953
|
-
"text": "icon - To insert a custom icon into the named `icon` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content\">inline content</a>.<
|
|
915
|
+
"text": "icon - To insert a custom icon into the named `icon` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content\">inline content</a>.<post-banner data-size=\"sm\"><p>It is only meant for <code>img</code> or <code>svg</code> elements and overrides the `icon` property.</p></post-banner>"
|
|
954
916
|
}
|
|
955
917
|
],
|
|
956
918
|
"usage": {},
|
|
@@ -1047,7 +1009,7 @@
|
|
|
1047
1009
|
"mutable": false,
|
|
1048
1010
|
"attr": "icon",
|
|
1049
1011
|
"reflectToAttr": false,
|
|
1050
|
-
"docs": "Defines the icon `name` inside the card.\n<
|
|
1012
|
+
"docs": "Defines the icon `name` inside the card.\n<post-banner data-size=\"sm\"><p>If not set the icon will not show up.</p></post-banner>",
|
|
1051
1013
|
"docsTags": [],
|
|
1052
1014
|
"values": [
|
|
1053
1015
|
{
|
|
@@ -1093,7 +1055,7 @@
|
|
|
1093
1055
|
"mutable": false,
|
|
1094
1056
|
"attr": "name",
|
|
1095
1057
|
"reflectToAttr": false,
|
|
1096
|
-
"docs": "Defines the `name` attribute of the control.\n<
|
|
1058
|
+
"docs": "Defines the `name` attribute of the control.\n<post-banner data-size=\"sm\"><p>This is a required property, when the control should participate in a native `form`. If not specified, a native `form` will never contain this controls value.</p></post-banner>\n<post-banner data-size=\"sm\"><p>This is a required property, when the control is used with type `radio`.</p></post-banner>",
|
|
1097
1059
|
"docsTags": [],
|
|
1098
1060
|
"values": [
|
|
1099
1061
|
{
|
|
@@ -1167,7 +1129,7 @@
|
|
|
1167
1129
|
"mutable": false,
|
|
1168
1130
|
"attr": "value",
|
|
1169
1131
|
"reflectToAttr": false,
|
|
1170
|
-
"docs": "Defines the `value` attribute of the control. <
|
|
1132
|
+
"docs": "Defines the `value` attribute of the control. <post-banner data-size=\"sm\"><p>This is a required property, when the control is used with type `radio`.</p></post-banner>",
|
|
1171
1133
|
"docsTags": [],
|
|
1172
1134
|
"values": [
|
|
1173
1135
|
{
|
|
@@ -1238,7 +1200,7 @@
|
|
|
1238
1200
|
},
|
|
1239
1201
|
"cancelable": true,
|
|
1240
1202
|
"composed": true,
|
|
1241
|
-
"docs": "An event emitted whenever the components checked state is toggled.\nThe event payload (emitted under `event.detail.state`) is a boolean: `true` if the component is checked, `false` if it is unchecked.\n<
|
|
1203
|
+
"docs": "An event emitted whenever the components checked state is toggled.\nThe event payload (emitted under `event.detail.state`) is a boolean: `true` if the component is checked, `false` if it is unchecked.\n<post-banner data-size=\"sm\"><p>If the component is used with type `radio`, it will only emit this event, when the checked state is changing to `true`.</p></post-banner>",
|
|
1242
1204
|
"docsTags": []
|
|
1243
1205
|
},
|
|
1244
1206
|
{
|
|
@@ -1261,11 +1223,11 @@
|
|
|
1261
1223
|
"slots": [
|
|
1262
1224
|
{
|
|
1263
1225
|
"name": "default",
|
|
1264
|
-
"docs": "Content to place into the `default` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Block-level_contentt\">block content</a>.<
|
|
1226
|
+
"docs": "Content to place into the `default` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Block-level_contentt\">block content</a>.<post-banner type=\"warning\" data-size=\"sm\"><p>Even if it is generally possible, we do not recommend using interactive elements in this slot because the background of the card control is clickable.<br/>This can lead to confusion when the hit box of nested interactive controls is not clearly separated from the background, is invalid HTML and click events bubbling up to the card control will unexpectedly toggle it if they're not captured.<br/>More info: <a href=\"https://accessibilityinsights.io/info-examples/web/nested-interactive/\">https://accessibilityinsights.io/info-examples/web/nested-interactive/</a></p></post-banner>"
|
|
1265
1227
|
},
|
|
1266
1228
|
{
|
|
1267
1229
|
"name": "icon",
|
|
1268
|
-
"docs": "To insert a custom icon into the named `icon` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content\">inline content</a>.<
|
|
1230
|
+
"docs": "To insert a custom icon into the named `icon` slot.<p>Markup accepted: <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content\">inline content</a>.<post-banner data-size=\"sm\"><p>It is only meant for <code>img</code> or <code>svg</code> elements and overrides the `icon` property.</p></post-banner>"
|
|
1269
1231
|
}
|
|
1270
1232
|
],
|
|
1271
1233
|
"parts": [],
|
|
@@ -2776,7 +2738,12 @@
|
|
|
2776
2738
|
"tag": "post-menu",
|
|
2777
2739
|
"readme": "# post-menu\n\n\n",
|
|
2778
2740
|
"docs": "",
|
|
2779
|
-
"docsTags": [
|
|
2741
|
+
"docsTags": [
|
|
2742
|
+
{
|
|
2743
|
+
"name": "part",
|
|
2744
|
+
"text": "menu - The container element that holds the list of menu items."
|
|
2745
|
+
}
|
|
2746
|
+
],
|
|
2780
2747
|
"usage": {},
|
|
2781
2748
|
"props": [
|
|
2782
2749
|
{
|
|
@@ -2987,7 +2954,7 @@
|
|
|
2987
2954
|
"parts": [
|
|
2988
2955
|
{
|
|
2989
2956
|
"name": "menu",
|
|
2990
|
-
"docs": ""
|
|
2957
|
+
"docs": "The container element that holds the list of menu items."
|
|
2991
2958
|
}
|
|
2992
2959
|
],
|
|
2993
2960
|
"dependents": [
|
|
@@ -4069,11 +4036,11 @@
|
|
|
4069
4036
|
},
|
|
4070
4037
|
{
|
|
4071
4038
|
"name": "part",
|
|
4072
|
-
"text": "tabs -
|
|
4039
|
+
"text": "tabs - The container element that holds the set of tabs."
|
|
4073
4040
|
},
|
|
4074
4041
|
{
|
|
4075
4042
|
"name": "part",
|
|
4076
|
-
"text": "content -
|
|
4043
|
+
"text": "content - The container element that displays the content of the currently active tab."
|
|
4077
4044
|
}
|
|
4078
4045
|
],
|
|
4079
4046
|
"usage": {},
|
|
@@ -4207,11 +4174,11 @@
|
|
|
4207
4174
|
"parts": [
|
|
4208
4175
|
{
|
|
4209
4176
|
"name": "content",
|
|
4210
|
-
"docs": "
|
|
4177
|
+
"docs": "The container element that displays the content of the currently active tab."
|
|
4211
4178
|
},
|
|
4212
4179
|
{
|
|
4213
4180
|
"name": "tabs",
|
|
4214
|
-
"docs": "
|
|
4181
|
+
"docs": "The container element that holds the set of tabs."
|
|
4215
4182
|
}
|
|
4216
4183
|
],
|
|
4217
4184
|
"dependents": [],
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates if an event should be processed based on target and nesting criteria
|
|
3
|
+
* @param event - The event to validate
|
|
4
|
+
* @param tag - The expected local name of the event target
|
|
5
|
+
* @param host - The host element for nested component checking
|
|
6
|
+
* @param ignoreNestedComponents - Whether to ignore events from nested components
|
|
7
|
+
* @returns true if the event should be processed, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
function shouldProcessEvent(event, tag, host, ignoreNestedComponents) {
|
|
10
|
+
if (!(event instanceof Event && event.target instanceof HTMLElement))
|
|
11
|
+
return false;
|
|
12
|
+
const eventTarget = event.target;
|
|
13
|
+
if (eventTarget.localName !== tag)
|
|
14
|
+
return false;
|
|
15
|
+
if (ignoreNestedComponents) {
|
|
16
|
+
// Find the closest parent with the same tag as the host
|
|
17
|
+
const closestParentWithSameTag = findClosestParentWithTag(eventTarget, host.localName);
|
|
18
|
+
if (closestParentWithSameTag !== host)
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decorator that guards event handlers to only execute when the event meets certain criteria.
|
|
25
|
+
* @param tag - The local name of the element that should be the target of the event
|
|
26
|
+
* @param option - Configuration options for the event guard
|
|
27
|
+
* @param option.ignoreNestedComponents - Whether to ignore events from nested components
|
|
28
|
+
*/
|
|
29
|
+
function EventFrom(tag, option = { ignoreNestedComponents: true }) {
|
|
30
|
+
return function (target, propertyKey, descriptor) {
|
|
31
|
+
if (descriptor) {
|
|
32
|
+
const originalMethod = descriptor.value;
|
|
33
|
+
descriptor.value = function (event) {
|
|
34
|
+
if (!shouldProcessEvent(event, tag, this.host, option.ignoreNestedComponents)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return originalMethod.call(this, event);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Creates a hidden storage property for the original method using a
|
|
42
|
+
// modified key format (__[property]_original) to avoid naming conflicts
|
|
43
|
+
const privateKey = `__${propertyKey}_original`;
|
|
44
|
+
// Create hidden storage for original method
|
|
45
|
+
Object.defineProperty(target, privateKey, {
|
|
46
|
+
writable: true,
|
|
47
|
+
configurable: true
|
|
48
|
+
});
|
|
49
|
+
// Replace property with getter/setter
|
|
50
|
+
Object.defineProperty(target, propertyKey, {
|
|
51
|
+
// Getter returns original method
|
|
52
|
+
get() {
|
|
53
|
+
return this[privateKey];
|
|
54
|
+
},
|
|
55
|
+
// Setter wraps original method with extra code
|
|
56
|
+
set(originalFunction) {
|
|
57
|
+
if (typeof originalFunction === 'function') {
|
|
58
|
+
// Store original and add new behavior
|
|
59
|
+
this[privateKey] = (event) => {
|
|
60
|
+
if (!shouldProcessEvent(event, tag, this.host, option.ignoreNestedComponents)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
return originalFunction.call(this, event);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this[privateKey] = originalFunction;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
configurable: true,
|
|
71
|
+
enumerable: true
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Traverses up the DOM (including crossing shadow DOM boundaries) to find the closest ancestor
|
|
78
|
+
* that matches the specified tag name.
|
|
79
|
+
* @param element - The starting element
|
|
80
|
+
* @param tagName - The tag name to match (e.g., 'post-accordion')
|
|
81
|
+
* @returns The closest matching ancestor or null if none found
|
|
82
|
+
*/
|
|
83
|
+
function findClosestParentWithTag(element, tagName) {
|
|
84
|
+
let current = element;
|
|
85
|
+
while (current) {
|
|
86
|
+
if (current.localName === tagName) {
|
|
87
|
+
return current;
|
|
88
|
+
}
|
|
89
|
+
// Check regular parent first
|
|
90
|
+
if (current.parentElement) {
|
|
91
|
+
current = current.parentElement;
|
|
92
|
+
}
|
|
93
|
+
// If no parentElement, check if we're in a shadow root
|
|
94
|
+
else if (current.parentNode instanceof ShadowRoot) {
|
|
95
|
+
current = current.parentNode.host;
|
|
96
|
+
}
|
|
97
|
+
// No more parents to check
|
|
98
|
+
else {
|
|
99
|
+
current = null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { EventFrom as E };
|
|
@@ -94,14 +94,6 @@ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
94
94
|
}
|
|
95
95
|
switch(bundleId) {
|
|
96
96
|
|
|
97
|
-
case 'post-avatar':
|
|
98
|
-
return import(
|
|
99
|
-
/* webpackMode: "lazy" */
|
|
100
|
-
'./post-avatar.entry.js').then(processMod, consoleError);
|
|
101
|
-
case 'post-back-to-top':
|
|
102
|
-
return import(
|
|
103
|
-
/* webpackMode: "lazy" */
|
|
104
|
-
'./post-back-to-top.entry.js').then(processMod, consoleError);
|
|
105
97
|
case 'post-card-control':
|
|
106
98
|
return import(
|
|
107
99
|
/* webpackMode: "lazy" */
|
|
@@ -130,6 +122,14 @@ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
130
122
|
return import(
|
|
131
123
|
/* webpackMode: "lazy" */
|
|
132
124
|
'./post-tooltip.entry.js').then(processMod, consoleError);
|
|
125
|
+
case 'post-avatar':
|
|
126
|
+
return import(
|
|
127
|
+
/* webpackMode: "lazy" */
|
|
128
|
+
'./post-avatar.entry.js').then(processMod, consoleError);
|
|
129
|
+
case 'post-back-to-top':
|
|
130
|
+
return import(
|
|
131
|
+
/* webpackMode: "lazy" */
|
|
132
|
+
'./post-back-to-top.entry.js').then(processMod, consoleError);
|
|
133
133
|
case 'post-banner':
|
|
134
134
|
return import(
|
|
135
135
|
/* webpackMode: "lazy" */
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const EMPTY_VALUES = [undefined, null, '', NaN];
|
|
2
|
+
|
|
3
|
+
function isValueEmpty(value) {
|
|
4
|
+
return EMPTY_VALUES.some(v => v === value);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function requiredAnd(check) {
|
|
8
|
+
return (component, prop, ...extraArgs) => {
|
|
9
|
+
const componentName = component.host.localName;
|
|
10
|
+
const value = component[prop];
|
|
11
|
+
const message = `The prop \`${String(prop)}\` of the \`${componentName}\` component is not defined.`;
|
|
12
|
+
if (isValueEmpty(value)) {
|
|
13
|
+
throw new Error(message);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
check(component, prop, ...extraArgs);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function checkOneOf(component, prop, possibleValues) {
|
|
22
|
+
const componentName = component.host.localName;
|
|
23
|
+
const value = component[prop];
|
|
24
|
+
const message = `The prop \`${String(prop)}\` of the \`${componentName}\` component must be one of the following values: ${possibleValues.join(', ')}.`;
|
|
25
|
+
if (!possibleValues.includes(value)) {
|
|
26
|
+
console.error(message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function checkPattern(component, prop, pattern) {
|
|
31
|
+
const componentName = component.host.localName;
|
|
32
|
+
const value = component[prop];
|
|
33
|
+
const message = `The prop \`${String(prop)}\` of the \`${componentName}\` component must follow the format \`${pattern}\`.`;
|
|
34
|
+
if (typeof value !== 'string' || !pattern.test(value)) {
|
|
35
|
+
console.error(message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function checkType(component, prop, type) {
|
|
40
|
+
const componentName = component.host.localName;
|
|
41
|
+
const value = component[prop];
|
|
42
|
+
const typeIsArray = type === 'array';
|
|
43
|
+
const valueIsArray = Array.isArray(value);
|
|
44
|
+
const message = `The prop \`${String(prop)}\` of the \`${componentName}\` component must be of type \`${type}\`.`;
|
|
45
|
+
if (typeIsArray || valueIsArray) {
|
|
46
|
+
if (valueIsArray !== typeIsArray) {
|
|
47
|
+
console.error(message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (typeof value !== type) {
|
|
51
|
+
console.error(message);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function checkUrl(component, prop) {
|
|
56
|
+
const componentName = component.host.localName;
|
|
57
|
+
const value = component[prop];
|
|
58
|
+
const message = `The prop \`${String(prop)}\` of the \`${componentName}\` component is invalid.`;
|
|
59
|
+
if (typeof value !== 'string' && !(value instanceof URL)) {
|
|
60
|
+
console.error(message);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
new URL(value, 'https://www.post.ch');
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
console.error(message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function emptyOr(check) {
|
|
72
|
+
return (component, prop, ...extraArgs) => {
|
|
73
|
+
const value = component[prop];
|
|
74
|
+
if (!isValueEmpty(value)) {
|
|
75
|
+
check(component, prop, ...extraArgs);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const checkEmptyOrOneOf = emptyOr(checkOneOf);
|
|
81
|
+
const checkEmptyOrPattern = emptyOr(checkPattern);
|
|
82
|
+
const checkEmptyOrType = emptyOr(checkType);
|
|
83
|
+
const checkEmptyOrUrl = emptyOr(checkUrl);
|
|
84
|
+
const checkRequiredAndOneOf = requiredAnd(checkOneOf);
|
|
85
|
+
const checkRequiredAndType = requiredAnd(checkType);
|
|
86
|
+
const checkRequiredAndUrl = requiredAnd(checkUrl);
|
|
87
|
+
|
|
88
|
+
export { checkEmptyOrType as a, checkRequiredAndOneOf as b, checkRequiredAndType as c, checkEmptyOrOneOf as d, checkEmptyOrPattern as e, checkRequiredAndUrl as f, checkEmptyOrUrl as g };
|