@swisspost/design-system-components 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/check-non-empty-ae713942.js +13 -0
- package/dist/cjs/check-non-empty-ae713942.js.map +1 -0
- package/dist/cjs/{check-one-of-4c2e8b2e.js → check-one-of-27ad3154.js} +1 -1
- package/dist/cjs/check-one-of-27ad3154.js.map +1 -0
- package/dist/cjs/constants-238701d3.js +7 -0
- package/dist/cjs/constants-238701d3.js.map +1 -0
- package/dist/cjs/fade-35a3633a.js +12 -0
- package/dist/cjs/fade-35a3633a.js.map +1 -0
- package/dist/cjs/index-b38a23e0.js +41 -0
- package/dist/cjs/index-b38a23e0.js.map +1 -0
- package/dist/cjs/{index-12cc37c9.js → index-b619e205.js} +245 -41
- package/dist/cjs/index-b619e205.js.map +1 -0
- package/dist/cjs/index.cjs.js +26 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +3 -12
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/package-7c4db872.js +7 -0
- package/dist/cjs/package-7c4db872.js.map +1 -0
- package/dist/cjs/post-accordion.cjs.entry.js +89 -0
- package/dist/cjs/post-accordion.cjs.entry.js.map +1 -0
- package/dist/cjs/post-alert-c037e6a3.js +101 -0
- package/dist/cjs/post-alert-c037e6a3.js.map +1 -0
- package/dist/cjs/post-alert.cjs.entry.js +9 -97
- package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/post-collapsible-7c9d23a2.js +93 -0
- package/dist/cjs/post-collapsible-7c9d23a2.js.map +1 -0
- package/dist/cjs/post-collapsible.cjs.entry.js +7 -119
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
- package/dist/cjs/post-components.cjs.js +3 -6
- package/dist/cjs/post-components.cjs.js.map +1 -1
- package/dist/cjs/post-icon-f418f76a.js +105 -0
- package/dist/cjs/post-icon-f418f76a.js.map +1 -0
- package/dist/cjs/post-icon.cjs.entry.js +8 -100
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-header-e08c2a42.js +33 -0
- package/dist/cjs/post-tab-header-e08c2a42.js.map +1 -0
- package/dist/cjs/post-tab-header.cjs.entry.js +6 -26
- package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-panel-721f7f32.js +27 -0
- package/dist/cjs/post-tab-panel-721f7f32.js.map +1 -0
- package/dist/cjs/post-tab-panel.cjs.entry.js +4 -20
- package/dist/cjs/post-tab-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tabs-4bcc867b.js +153 -0
- package/dist/cjs/post-tabs-4bcc867b.js.map +1 -0
- package/dist/cjs/post-tabs.cjs.entry.js +5 -127
- package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tooltip-261c5cda.js +5095 -0
- package/dist/cjs/post-tooltip-261c5cda.js.map +1 -0
- package/dist/cjs/post-tooltip.cjs.entry.js +5 -5088
- package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/animations/collapse.js +13 -0
- package/dist/collection/animations/collapse.js.map +1 -0
- package/dist/collection/animations/fade.js +4 -4
- package/dist/collection/animations/fade.js.map +1 -1
- package/dist/collection/collection-manifest.json +10 -9
- package/dist/collection/components/post-accordion/post-accordion.css +1 -0
- package/dist/collection/components/post-accordion/post-accordion.js +178 -0
- package/dist/collection/components/post-accordion/post-accordion.js.map +1 -0
- package/dist/collection/components/post-alert/post-alert.css +6 -534
- package/dist/collection/components/post-alert/post-alert.js +10 -9
- package/dist/collection/components/post-alert/post-alert.js.map +1 -1
- package/dist/collection/components/post-collapsible/heading-levels.js +2 -0
- package/dist/collection/components/post-collapsible/heading-levels.js.map +1 -0
- package/dist/collection/components/post-collapsible/post-collapsible.css +1 -261
- package/dist/collection/components/post-collapsible/post-collapsible.js +65 -63
- package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
- package/dist/collection/components/post-icon/post-icon.css +1 -102
- package/dist/collection/components/post-icon/post-icon.js +5 -4
- package/dist/collection/components/post-icon/post-icon.js.map +1 -1
- package/dist/collection/components/post-tab-header/post-tab-header.css +3 -337
- package/dist/collection/components/post-tab-header/post-tab-header.js +6 -5
- package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
- package/dist/collection/components/post-tab-panel/post-tab-panel.css +1 -3
- package/dist/collection/components/post-tab-panel/post-tab-panel.js +2 -2
- package/dist/collection/components/post-tabs/post-tabs.css +1 -148
- package/dist/collection/components/post-tabs/post-tabs.js +36 -13
- package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.css +1 -194
- package/dist/collection/components/post-tooltip/post-tooltip.js +22 -15
- package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -1
- package/dist/collection/index.js +8 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/utils/index.js +1 -3
- package/dist/collection/utils/index.js.map +1 -1
- package/dist/collection/utils/is-motion-reduced.js +4 -0
- package/dist/collection/utils/is-motion-reduced.js.map +1 -0
- package/dist/collection/utils/property-checkers/check-non-empty.js +1 -1
- package/dist/collection/utils/property-checkers/empty-or.js +1 -1
- package/dist/collection/utils/property-checkers/index.js +4 -4
- package/dist/components/check-non-empty.js +2 -2
- package/dist/components/check-non-empty.js.map +1 -1
- package/dist/components/check-one-of.js.map +1 -1
- package/dist/components/constants.js +5 -0
- package/dist/components/constants.js.map +1 -0
- package/dist/components/fade.js +4 -4
- package/dist/components/fade.js.map +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +8 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index2.js +36 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion.d.ts +11 -0
- package/dist/components/post-accordion.js +108 -0
- package/dist/components/post-accordion.js.map +1 -0
- package/dist/components/post-alert.js +1 -129
- package/dist/components/post-alert.js.map +1 -1
- package/dist/components/post-alert2.js +138 -0
- package/dist/components/post-alert2.js.map +1 -0
- package/dist/components/post-collapsible.js +1 -146
- package/dist/components/post-collapsible.js.map +1 -1
- package/dist/components/post-collapsible2.js +117 -0
- package/dist/components/post-collapsible2.js.map +1 -0
- package/dist/components/post-icon2.js +12 -22
- package/dist/components/post-icon2.js.map +1 -1
- package/dist/components/post-tab-header.js +1 -45
- package/dist/components/post-tab-header.js.map +1 -1
- package/dist/components/post-tab-header2.js +51 -0
- package/dist/components/post-tab-header2.js.map +1 -0
- package/dist/components/post-tab-panel.js +1 -39
- package/dist/components/post-tab-panel.js.map +1 -1
- package/dist/components/post-tab-panel2.js +43 -0
- package/dist/components/post-tab-panel2.js.map +1 -0
- package/dist/components/post-tabs.js +1 -146
- package/dist/components/post-tabs.js.map +1 -1
- package/dist/components/post-tabs2.js +169 -0
- package/dist/components/post-tabs2.js.map +1 -0
- package/dist/components/post-tooltip.js +1 -5111
- package/dist/components/post-tooltip.js.map +1 -1
- package/dist/components/post-tooltip2.js +5117 -0
- package/dist/components/post-tooltip2.js.map +1 -0
- package/dist/docs.d.ts +334 -235
- package/dist/docs.json +458 -14
- package/dist/esm/check-non-empty-09c39561.js +11 -0
- package/dist/esm/check-non-empty-09c39561.js.map +1 -0
- package/dist/esm/{check-one-of-ded5e15e.js → check-one-of-74750af9.js} +1 -1
- package/dist/esm/check-one-of-74750af9.js.map +1 -0
- package/dist/esm/constants-8d548297.js +5 -0
- package/dist/esm/constants-8d548297.js.map +1 -0
- package/dist/esm/fade-7fd71785.js +9 -0
- package/dist/esm/fade-7fd71785.js.map +1 -0
- package/dist/esm/index-35921354.js +36 -0
- package/dist/esm/index-35921354.js.map +1 -0
- package/dist/esm/{index-5611074b.js → index-4eff5fc5.js} +245 -41
- package/dist/esm/index-4eff5fc5.js.map +1 -0
- package/dist/esm/index.js +14 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +4 -13
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/package-3bbdb32c.js +5 -0
- package/dist/esm/package-3bbdb32c.js.map +1 -0
- package/dist/esm/post-accordion.entry.js +85 -0
- package/dist/esm/post-accordion.entry.js.map +1 -0
- package/dist/esm/post-alert-5dd43c8b.js +99 -0
- package/dist/esm/post-alert-5dd43c8b.js.map +1 -0
- package/dist/esm/post-alert.entry.js +8 -100
- package/dist/esm/post-alert.entry.js.map +1 -1
- package/dist/esm/post-collapsible-26dc2340.js +91 -0
- package/dist/esm/post-collapsible-26dc2340.js.map +1 -0
- package/dist/esm/post-collapsible.entry.js +6 -122
- package/dist/esm/post-collapsible.entry.js.map +1 -1
- package/dist/esm/post-components.js +4 -7
- package/dist/esm/post-components.js.map +1 -1
- package/dist/esm/post-icon-fb0eb8aa.js +103 -0
- package/dist/esm/post-icon-fb0eb8aa.js.map +1 -0
- package/dist/esm/post-icon.entry.js +7 -103
- package/dist/esm/post-icon.entry.js.map +1 -1
- package/dist/esm/post-tab-header-deebc551.js +31 -0
- package/dist/esm/post-tab-header-deebc551.js.map +1 -0
- package/dist/esm/post-tab-header.entry.js +5 -29
- package/dist/esm/post-tab-header.entry.js.map +1 -1
- package/dist/esm/post-tab-panel-4b820f71.js +25 -0
- package/dist/esm/post-tab-panel-4b820f71.js.map +1 -0
- package/dist/esm/post-tab-panel.entry.js +3 -23
- package/dist/esm/post-tab-panel.entry.js.map +1 -1
- package/dist/esm/post-tabs-2d8d6a33.js +151 -0
- package/dist/esm/post-tabs-2d8d6a33.js.map +1 -0
- package/dist/esm/post-tabs.entry.js +4 -130
- package/dist/esm/post-tabs.entry.js.map +1 -1
- package/dist/esm/post-tooltip-811309c5.js +5093 -0
- package/dist/esm/post-tooltip-811309c5.js.map +1 -0
- package/dist/esm/post-tooltip.entry.js +4 -5091
- package/dist/esm/post-tooltip.entry.js.map +1 -1
- package/dist/post-components/index.esm.js +1 -1
- package/dist/post-components/{p-2b6ab354.entry.js → p-01e8dfe6.js} +3 -3
- package/dist/post-components/p-01e8dfe6.js.map +1 -0
- package/dist/post-components/p-0a49c1a3.entry.js +2 -0
- package/dist/post-components/{p-bcc705f1.js → p-1339f8cd.js} +1 -1
- package/dist/post-components/p-1339f8cd.js.map +1 -0
- package/dist/post-components/p-1a8a8ef2.js +2 -0
- package/dist/post-components/p-1a8a8ef2.js.map +1 -0
- package/dist/post-components/p-27092ac3.entry.js +2 -0
- package/dist/post-components/p-27092ac3.entry.js.map +1 -0
- package/dist/post-components/{p-e5306504.js → p-2737eaf5.js} +1 -1
- package/dist/post-components/p-2737eaf5.js.map +1 -0
- package/dist/post-components/p-332eef46.js +2 -0
- package/dist/post-components/p-332eef46.js.map +1 -0
- package/dist/post-components/p-440193f4.js +2 -0
- package/dist/post-components/p-440193f4.js.map +1 -0
- package/dist/post-components/p-541142fd.js +2 -0
- package/dist/post-components/p-541142fd.js.map +1 -0
- package/dist/post-components/p-574acdb0.js +2 -0
- package/dist/post-components/p-574acdb0.js.map +1 -0
- package/dist/post-components/p-66460e3f.entry.js +2 -0
- package/dist/post-components/p-66460e3f.entry.js.map +1 -0
- package/dist/post-components/p-810ee105.entry.js +2 -0
- package/dist/post-components/p-810ee105.entry.js.map +1 -0
- package/dist/post-components/p-939df031.entry.js +2 -0
- package/dist/post-components/p-939df031.entry.js.map +1 -0
- package/dist/post-components/p-94b3f291.entry.js +2 -0
- package/dist/post-components/p-94b3f291.entry.js.map +1 -0
- package/dist/post-components/p-97000cb6.js +2 -0
- package/dist/post-components/p-97000cb6.js.map +1 -0
- package/dist/post-components/p-a7649277.js +3 -0
- package/dist/post-components/p-a7649277.js.map +1 -0
- package/dist/post-components/p-abd149b3.entry.js +2 -0
- package/dist/post-components/p-abd149b3.entry.js.map +1 -0
- package/dist/post-components/p-b531475e.js +2 -0
- package/dist/post-components/p-b531475e.js.map +1 -0
- package/dist/post-components/p-c6b73d6e.js +2 -0
- package/dist/post-components/p-c6b73d6e.js.map +1 -0
- package/dist/post-components/{p-29535fea.entry.js → p-d4fb9f16.js} +2 -2
- package/dist/post-components/p-d4fb9f16.js.map +1 -0
- package/dist/post-components/p-dfe29f7f.js +2 -0
- package/dist/post-components/p-dfe29f7f.js.map +1 -0
- package/dist/post-components/p-e9dc9039.entry.js +2 -0
- package/dist/post-components/p-e9dc9039.entry.js.map +1 -0
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/post-components/post-components.esm.js.map +1 -1
- package/dist/types/animations/collapse.d.ts +2 -0
- package/dist/types/components/post-accordion/post-accordion.d.ts +28 -0
- package/dist/types/components/post-alert/post-alert.d.ts +1 -1
- package/dist/types/components/post-collapsible/heading-levels.d.ts +2 -0
- package/dist/types/components/post-collapsible/post-collapsible.d.ts +16 -12
- package/dist/types/components/post-tabs/post-tabs.d.ts +1 -0
- package/dist/types/components.d.ts +79 -3
- package/dist/types/index.d.ts +7 -0
- package/dist/types/stencil-public-runtime.d.ts +38 -5
- package/dist/types/utils/index.d.ts +1 -3
- package/dist/types/utils/is-motion-reduced.d.ts +1 -0
- package/loader/index.d.ts +1 -1
- package/package.json +8 -8
- package/dist/cjs/check-non-empty-35b4d0b5.js +0 -14
- package/dist/cjs/check-non-empty-35b4d0b5.js.map +0 -1
- package/dist/cjs/check-one-of-4c2e8b2e.js.map +0 -1
- package/dist/cjs/check-type-508a21a5.js +0 -18
- package/dist/cjs/check-type-508a21a5.js.map +0 -1
- package/dist/cjs/fade-8c6d4fa7.js +0 -12
- package/dist/cjs/fade-8c6d4fa7.js.map +0 -1
- package/dist/cjs/index-12cc37c9.js.map +0 -1
- package/dist/cjs/index-f8f6f146.js +0 -28
- package/dist/cjs/index-f8f6f146.js.map +0 -1
- package/dist/cjs/package-67091813.js +0 -7
- package/dist/cjs/package-67091813.js.map +0 -1
- package/dist/collection/utils/get-element-height.js +0 -12
- package/dist/collection/utils/get-element-height.js.map +0 -1
- package/dist/collection/utils/on-transition-end.js +0 -15
- package/dist/collection/utils/on-transition-end.js.map +0 -1
- package/dist/collection/utils/should-reduce-motion.js +0 -4
- package/dist/collection/utils/should-reduce-motion.js.map +0 -1
- package/dist/components/check-type.js +0 -16
- package/dist/components/check-type.js.map +0 -1
- package/dist/esm/check-non-empty-554bdf88.js +0 -11
- package/dist/esm/check-non-empty-554bdf88.js.map +0 -1
- package/dist/esm/check-one-of-ded5e15e.js.map +0 -1
- package/dist/esm/check-type-18ebb4e7.js +0 -16
- package/dist/esm/check-type-18ebb4e7.js.map +0 -1
- package/dist/esm/fade-671f1489.js +0 -9
- package/dist/esm/fade-671f1489.js.map +0 -1
- package/dist/esm/index-5611074b.js.map +0 -1
- package/dist/esm/index-7f723686.js +0 -24
- package/dist/esm/index-7f723686.js.map +0 -1
- package/dist/esm/package-f5cb3167.js +0 -5
- package/dist/esm/package-f5cb3167.js.map +0 -1
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/post-components/p-12046db8.entry.js +0 -2
- package/dist/post-components/p-12046db8.entry.js.map +0 -1
- package/dist/post-components/p-15fc087f.js +0 -2
- package/dist/post-components/p-15fc087f.js.map +0 -1
- package/dist/post-components/p-24b07f64.js +0 -2
- package/dist/post-components/p-29535fea.entry.js.map +0 -1
- package/dist/post-components/p-296af738.entry.js +0 -2
- package/dist/post-components/p-296af738.entry.js.map +0 -1
- package/dist/post-components/p-2b6ab354.entry.js.map +0 -1
- package/dist/post-components/p-75a7b352.js +0 -2
- package/dist/post-components/p-75a7b352.js.map +0 -1
- package/dist/post-components/p-a14ec7bb.entry.js +0 -2
- package/dist/post-components/p-a14ec7bb.entry.js.map +0 -1
- package/dist/post-components/p-bcc705f1.js.map +0 -1
- package/dist/post-components/p-c7497ecb.entry.js +0 -2
- package/dist/post-components/p-c7497ecb.entry.js.map +0 -1
- package/dist/post-components/p-c8efe0ae.js +0 -2
- package/dist/post-components/p-c8efe0ae.js.map +0 -1
- package/dist/post-components/p-cc6e4eb8.entry.js +0 -2
- package/dist/post-components/p-cc6e4eb8.entry.js.map +0 -1
- package/dist/post-components/p-d94db268.js +0 -3
- package/dist/post-components/p-d94db268.js.map +0 -1
- package/dist/post-components/p-e5306504.js.map +0 -1
- package/dist/types/utils/get-element-height.d.ts +0 -3
- package/dist/types/utils/on-transition-end.d.ts +0 -1
- package/dist/types/utils/should-reduce-motion.d.ts +0 -1
- /package/dist/post-components/{p-24b07f64.js.map → p-0a49c1a3.entry.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { version } from
|
|
3
|
-
import { fadeIn, fadeOut } from
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { version } from "../../../package.json";
|
|
3
|
+
import { fadeIn, fadeOut } from "../../animations";
|
|
4
4
|
export class PostTabs {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.isLoaded = false;
|
|
@@ -13,7 +13,7 @@ export class PostTabs {
|
|
|
13
13
|
this.moveMisplacedTabs();
|
|
14
14
|
this.enableTabs();
|
|
15
15
|
const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
|
|
16
|
-
this.show(initiallyActivePanel);
|
|
16
|
+
void this.show(initiallyActivePanel);
|
|
17
17
|
this.isLoaded = true;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -70,24 +70,29 @@ export class PostTabs {
|
|
|
70
70
|
const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
|
|
71
71
|
tabTitle.setAttribute('aria-controls', tabPanel.id);
|
|
72
72
|
tabPanel.setAttribute('aria-labelledby', tabTitle.id);
|
|
73
|
-
tab.addEventListener('click',
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
tab.addEventListener('click', () => {
|
|
74
|
+
void this.show(tab.panel);
|
|
75
|
+
});
|
|
76
|
+
tab.addEventListener('keydown', ({ key }) => {
|
|
77
|
+
if (key === 'ArrowRight' || key === 'ArrowLeft')
|
|
78
|
+
this.navigateTabs(tab, key);
|
|
76
79
|
});
|
|
77
80
|
});
|
|
78
81
|
// if the currently active tab was removed from the DOM then select the first one
|
|
79
82
|
if (this.activeTab && !this.activeTab.isConnected) {
|
|
80
|
-
this.show(this.tabs.item(0).panel);
|
|
83
|
+
void this.show(this.tabs.item(0).panel);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
activateTab(tab) {
|
|
84
87
|
if (this.activeTab) {
|
|
85
88
|
const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
|
|
86
89
|
tabTitle.setAttribute('aria-selected', 'false');
|
|
90
|
+
tabTitle.setAttribute('tabindex', '-1');
|
|
87
91
|
tabTitle.classList.remove('active');
|
|
88
92
|
}
|
|
89
93
|
const tabTitle = tab.shadowRoot.querySelector('.tab-title');
|
|
90
94
|
tabTitle.setAttribute('aria-selected', 'true');
|
|
95
|
+
tabTitle.removeAttribute('tabindex');
|
|
91
96
|
tabTitle.classList.add('active');
|
|
92
97
|
this.activeTab = tab;
|
|
93
98
|
}
|
|
@@ -115,8 +120,22 @@ export class PostTabs {
|
|
|
115
120
|
getPanel(name) {
|
|
116
121
|
return this.host.querySelector(`post-tab-panel[name=${name}]`);
|
|
117
122
|
}
|
|
123
|
+
navigateTabs(tab, key) {
|
|
124
|
+
const activeTabIndex = Array.from(this.tabs).indexOf(tab);
|
|
125
|
+
let nextTab;
|
|
126
|
+
if (key === 'ArrowRight') {
|
|
127
|
+
nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];
|
|
131
|
+
}
|
|
132
|
+
if (!nextTab)
|
|
133
|
+
return;
|
|
134
|
+
const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title');
|
|
135
|
+
nextTabTitle.focus();
|
|
136
|
+
}
|
|
118
137
|
render() {
|
|
119
|
-
return (h(Host, { "data-version": version }, h("div", { class: "tabs-wrapper" }, h("
|
|
138
|
+
return (h(Host, { "data-version": version }, h("div", { class: "tabs-wrapper" }, h("div", { class: "tabs", role: "tablist" }, h("slot", { name: "tabs", onSlotchange: () => this.enableTabs() }))), h("div", { class: "tab-content" }, h("slot", { onSlotchange: () => this.moveMisplacedTabs() }))));
|
|
120
139
|
}
|
|
121
140
|
static get is() { return "post-tabs"; }
|
|
122
141
|
static get encapsulation() { return "shadow"; }
|
|
@@ -140,7 +159,8 @@ export class PostTabs {
|
|
|
140
159
|
"resolved": "string",
|
|
141
160
|
"references": {
|
|
142
161
|
"HTMLPostTabPanelElement": {
|
|
143
|
-
"location": "global"
|
|
162
|
+
"location": "global",
|
|
163
|
+
"id": "global::HTMLPostTabPanelElement"
|
|
144
164
|
}
|
|
145
165
|
}
|
|
146
166
|
},
|
|
@@ -171,7 +191,8 @@ export class PostTabs {
|
|
|
171
191
|
"resolved": "string",
|
|
172
192
|
"references": {
|
|
173
193
|
"HTMLPostTabPanelElement": {
|
|
174
|
-
"location": "global"
|
|
194
|
+
"location": "global",
|
|
195
|
+
"id": "global::HTMLPostTabPanelElement"
|
|
175
196
|
}
|
|
176
197
|
}
|
|
177
198
|
}
|
|
@@ -188,10 +209,12 @@ export class PostTabs {
|
|
|
188
209
|
}],
|
|
189
210
|
"references": {
|
|
190
211
|
"Promise": {
|
|
191
|
-
"location": "global"
|
|
212
|
+
"location": "global",
|
|
213
|
+
"id": "global::Promise"
|
|
192
214
|
},
|
|
193
215
|
"HTMLPostTabHeaderElement": {
|
|
194
|
-
"location": "global"
|
|
216
|
+
"location": "global",
|
|
217
|
+
"id": "global::HTMLPostTabHeaderElement"
|
|
195
218
|
}
|
|
196
219
|
},
|
|
197
220
|
"return": "Promise<void>"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-tabs.js","sourceRoot":"","sources":["../../../../src/components/post-tabs/post-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAA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prop } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeIn, fadeOut } from '../../animations';\n\n@Component({\n tag: 'post-tabs',\n styleUrl: 'post-tabs.scss',\n shadow: true,\n})\nexport class PostTabs {\n private activeTab: HTMLPostTabHeaderElement;\n private showing: Animation;\n private hiding: Animation;\n private isLoaded = false;\n\n private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {\n return this.host.querySelectorAll('post-tab-header');\n }\n\n @Element() host: HTMLPostTabsElement;\n\n /**\n * The name of the panel that is initially shown.\n * If not specified, it defaults to the panel associated with the first tab.\n *\n * **Changing this value after initialization has no effect.**\n */\n @Prop() readonly activePanel: HTMLPostTabPanelElement['name'];\n\n /**\n * An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\n * The payload is the name of the newly shown panel.\n */\n @Event() tabChange: EventEmitter<HTMLPostTabPanelElement['name']>;\n\n componentDidLoad() {\n this.moveMisplacedTabs();\n this.enableTabs();\n\n const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;\n this.show(initiallyActivePanel);\n\n this.isLoaded = true;\n }\n\n /**\n * Shows the panel with the given name and selects its associated tab.\n * Any other panel that was previously shown becomes hidden and its associated tab is unselected.\n */\n @Method()\n async show(panelName: string) {\n // do nothing if the tab is already active\n if (panelName === this.activeTab?.panel) {\n return;\n }\n\n const previousTab = this.activeTab;\n const newTab : HTMLPostTabHeaderElement = this.host.querySelector(`post-tab-header[panel=${panelName}]`);\n this.activateTab(newTab);\n\n // if a panel is currently being displayed, remove it from the view and complete the associated animation\n if (this.showing) {\n this.showing.effect['target'].style.display = 'none';\n this.showing.finish();\n }\n\n // hide the currently visible panel only if no other animation is running\n if (previousTab && !this.showing && !this.hiding) {\n this.hidePanel(previousTab.panel);\n }\n\n // wait for any hiding animation to complete before showing the selected tab\n if (this.hiding) {\n await this.hiding.finished;\n }\n\n this.showSelectedPanel();\n\n // wait for any display animation to complete for the returned promise to fully resolve\n if (this.showing) {\n await this.showing.finished;\n }\n\n this.tabChange.emit(this.activeTab.panel);\n }\n private moveMisplacedTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(tab => {\n if (tab.getAttribute('slot') === 'tabs') return;\n tab.setAttribute('slot', 'tabs');\n });\n }\n\n private enableTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(async tab => {\n await tab.componentOnReady();\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n\n // if the tab has an \"aria-controls\" attribute it was already linked to its panel: do nothing\n if (tabTitle.getAttribute('aria-controls')) return;\n\n const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');\n tabTitle.setAttribute('aria-controls', tabPanel.id);\n tabPanel.setAttribute('aria-labelledby', tabTitle.id);\n\n tab.addEventListener('click', e => {\n e.preventDefault();\n this.show(tab.panel);\n });\n });\n\n // if the currently active tab was removed from the DOM then select the first one\n if (this.activeTab && !this.activeTab.isConnected) {\n this.show(this.tabs.item(0).panel);\n }\n }\n\n private activateTab(tab: HTMLPostTabHeaderElement) {\n if (this.activeTab) {\n const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'false');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.classList.add('active');\n\n this.activeTab = tab;\n }\n\n private hidePanel(panelName: HTMLPostTabPanelElement['name']) {\n const previousPanel = this.getPanel(panelName);\n\n if (!previousPanel) return;\n\n this.hiding = fadeOut(previousPanel);\n this.hiding.onfinish = () => {\n previousPanel.style.display = 'none';\n this.hiding = null;\n };\n }\n\n private showSelectedPanel() {\n const panel = this.getPanel(this.activeTab.panel);\n panel.style.display = 'block';\n\n // prevent the initially selected panel from fading in\n if (!this.isLoaded) return;\n\n this.showing = fadeIn(panel);\n this.showing.onfinish = () => {\n this.showing = null;\n };\n }\n\n private getPanel(name: string): HTMLPostTabPanelElement {\n return this.host.querySelector(\n `post-tab-panel[name=${name}]`\n );\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <ul class=\"tabs nav\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </ul>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"post-tabs.js","sourceRoot":"","sources":["../../../../src/components/post-tabs/post-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOnD,MAAM,OAAO,QAAQ;;IAIX,aAAQ,GAAG,KAAK,CAAC;;;EAEzB,IAAY,IAAI;IACd,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;EACvD,CAAC;EAkBD,gBAAgB;IACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzB,IAAI,CAAC,UAAU,EAAE,CAAC;IAElB,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,KAAK,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAErC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;EACvB,CAAC;EAED;;;KAGG;EAEH,KAAK,CAAC,IAAI,CAAC,SAAiB;;IAC1B,0CAA0C;IAC1C,IAAI,SAAS,MAAK,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,CAAA,EAAE;MACvC,OAAO;KACR;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAA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iB,EAAE,GAAI,CAClD,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeIn, fadeOut } from '../../animations';\n\n@Component({\n tag: 'post-tabs',\n styleUrl: 'post-tabs.scss',\n shadow: true,\n})\nexport class PostTabs {\n private activeTab: HTMLPostTabHeaderElement;\n private showing: Animation;\n private hiding: Animation;\n private isLoaded = false;\n\n private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {\n return this.host.querySelectorAll('post-tab-header');\n }\n\n @Element() host: HTMLPostTabsElement;\n\n /**\n * The name of the panel that is initially shown.\n * If not specified, it defaults to the panel associated with the first tab.\n *\n * **Changing this value after initialization has no effect.**\n */\n @Prop() readonly activePanel: HTMLPostTabPanelElement['name'];\n\n /**\n * An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\n * The payload is the name of the newly shown panel.\n */\n @Event() tabChange: EventEmitter<HTMLPostTabPanelElement['name']>;\n\n componentDidLoad() {\n this.moveMisplacedTabs();\n this.enableTabs();\n\n const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;\n void this.show(initiallyActivePanel);\n\n this.isLoaded = true;\n }\n\n /**\n * Shows the panel with the given name and selects its associated tab.\n * Any other panel that was previously shown becomes hidden and its associated tab is unselected.\n */\n @Method()\n async show(panelName: string) {\n // do nothing if the tab is already active\n if (panelName === this.activeTab?.panel) {\n return;\n }\n\n const previousTab = this.activeTab;\n const newTab: HTMLPostTabHeaderElement = this.host.querySelector(\n `post-tab-header[panel=${panelName}]`,\n );\n this.activateTab(newTab);\n\n // if a panel is currently being displayed, remove it from the view and complete the associated animation\n if (this.showing) {\n this.showing.effect['target'].style.display = 'none';\n this.showing.finish();\n }\n\n // hide the currently visible panel only if no other animation is running\n if (previousTab && !this.showing && !this.hiding) {\n this.hidePanel(previousTab.panel);\n }\n\n // wait for any hiding animation to complete before showing the selected tab\n if (this.hiding) {\n await this.hiding.finished;\n }\n\n this.showSelectedPanel();\n\n // wait for any display animation to complete for the returned promise to fully resolve\n if (this.showing) {\n await this.showing.finished;\n }\n\n this.tabChange.emit(this.activeTab.panel);\n }\n\n private moveMisplacedTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(tab => {\n if (tab.getAttribute('slot') === 'tabs') return;\n tab.setAttribute('slot', 'tabs');\n });\n }\n\n private enableTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(async tab => {\n await tab.componentOnReady();\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n\n // if the tab has an \"aria-controls\" attribute it was already linked to its panel: do nothing\n if (tabTitle.getAttribute('aria-controls')) return;\n\n const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');\n tabTitle.setAttribute('aria-controls', tabPanel.id);\n tabPanel.setAttribute('aria-labelledby', tabTitle.id);\n\n tab.addEventListener('click', () => {\n void this.show(tab.panel);\n });\n\n tab.addEventListener('keydown', ({ key }) => {\n if (key === 'ArrowRight' || key === 'ArrowLeft') this.navigateTabs(tab, key);\n });\n });\n\n // if the currently active tab was removed from the DOM then select the first one\n if (this.activeTab && !this.activeTab.isConnected) {\n void this.show(this.tabs.item(0).panel);\n }\n }\n\n private activateTab(tab: HTMLPostTabHeaderElement) {\n if (this.activeTab) {\n const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'false');\n tabTitle.setAttribute('tabindex', '-1');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.removeAttribute('tabindex');\n tabTitle.classList.add('active');\n\n this.activeTab = tab;\n }\n\n private hidePanel(panelName: HTMLPostTabPanelElement['name']) {\n const previousPanel = this.getPanel(panelName);\n\n if (!previousPanel) return;\n\n this.hiding = fadeOut(previousPanel);\n this.hiding.onfinish = () => {\n previousPanel.style.display = 'none';\n this.hiding = null;\n };\n }\n\n private showSelectedPanel() {\n const panel = this.getPanel(this.activeTab.panel);\n panel.style.display = 'block';\n\n // prevent the initially selected panel from fading in\n if (!this.isLoaded) return;\n\n this.showing = fadeIn(panel);\n this.showing.onfinish = () => {\n this.showing = null;\n };\n }\n\n private getPanel(name: string): HTMLPostTabPanelElement {\n return this.host.querySelector(`post-tab-panel[name=${name}]`);\n }\n\n private navigateTabs(tab: HTMLPostTabHeaderElement, key: 'ArrowRight' | 'ArrowLeft') {\n const activeTabIndex = Array.from(this.tabs).indexOf(tab);\n\n let nextTab: HTMLPostTabHeaderElement;\n if (key === 'ArrowRight') {\n nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];\n } else {\n nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];\n }\n\n if (!nextTab) return;\n\n const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title') as HTMLAnchorElement;\n nextTabTitle.focus();\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <div class=\"tabs\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </div>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -1,194 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Colors used by the post style guide
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Maps. Allow maps to have custom colors from the project
|
|
6
|
-
* by always merging into a default empty map
|
|
7
|
-
*/
|
|
8
|
-
:host, .bg-yellow {
|
|
9
|
-
--post-bg-opacity: 1;
|
|
10
|
-
background-color: rgba(var(--post-bg-rgb), var(--post-bg-opacity)) !important;
|
|
11
|
-
color: var(--post-contrast-color) !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.bg-yellow {
|
|
15
|
-
--post-contrast-color: #000;
|
|
16
|
-
--post-contrast-color-inverted: #fff;
|
|
17
|
-
--post-gray-10: hsl(0, 0%, 90%);
|
|
18
|
-
--post-gray-20: hsl(0, 0%, 80%);
|
|
19
|
-
--post-gray-40: hsl(0, 0%, 60%);
|
|
20
|
-
--post-gray-60: hsl(0, 0%, 40%);
|
|
21
|
-
--post-gray-80: hsl(0, 0%, 20%);
|
|
22
|
-
--post-yellow: #fc0;
|
|
23
|
-
--post-light: #faf9f8;
|
|
24
|
-
--post-gray: #f4f3f1;
|
|
25
|
-
--post-dark: hsl(0, 0%, 20%);
|
|
26
|
-
--post-primary: hsl(0, 0%, 20%);
|
|
27
|
-
--post-white: #fff;
|
|
28
|
-
--post-black: #000;
|
|
29
|
-
--post-success: #2c911c;
|
|
30
|
-
--post-info: #cce4ee;
|
|
31
|
-
--post-warning: #f49e00;
|
|
32
|
-
--post-danger: #a51728;
|
|
33
|
-
--post-nightblue: #004976;
|
|
34
|
-
--post-nightblue-bright: #0076a8;
|
|
35
|
-
--post-petrol: #006d68;
|
|
36
|
-
--post-petrol-bright: #00968f;
|
|
37
|
-
--post-coral: #9e2a2f;
|
|
38
|
-
--post-coral-bright: #e03c31;
|
|
39
|
-
--post-olive: #716135;
|
|
40
|
-
--post-olive-bright: #aa9d2e;
|
|
41
|
-
--post-purple: #80276c;
|
|
42
|
-
--post-purple-bright: #c5299b;
|
|
43
|
-
--post-aubergine: #523178;
|
|
44
|
-
--post-aubergine-bright: #7566a0;
|
|
45
|
-
--post-contrast-color-rgb: 0, 0, 0;
|
|
46
|
-
--post-contrast-color-inverted-rgb: 255, 255, 255;
|
|
47
|
-
--post-gray-10-rgb: 230, 230, 230;
|
|
48
|
-
--post-gray-20-rgb: 204, 204, 204;
|
|
49
|
-
--post-gray-40-rgb: 153, 153, 153;
|
|
50
|
-
--post-gray-60-rgb: 102, 102, 102;
|
|
51
|
-
--post-gray-80-rgb: 51, 51, 51;
|
|
52
|
-
--post-yellow-rgb: 255, 204, 0;
|
|
53
|
-
--post-light-rgb: 250, 249, 248;
|
|
54
|
-
--post-gray-rgb: 244, 243, 241;
|
|
55
|
-
--post-dark-rgb: 51, 51, 51;
|
|
56
|
-
--post-primary-rgb: 51, 51, 51;
|
|
57
|
-
--post-white-rgb: 255, 255, 255;
|
|
58
|
-
--post-black-rgb: 0, 0, 0;
|
|
59
|
-
--post-success-rgb: 44, 145, 28;
|
|
60
|
-
--post-info-rgb: 204, 228, 238;
|
|
61
|
-
--post-warning-rgb: 244, 158, 0;
|
|
62
|
-
--post-danger-rgb: 165, 23, 40;
|
|
63
|
-
--post-nightblue-rgb: 0, 73, 118;
|
|
64
|
-
--post-nightblue-bright-rgb: 0, 118, 168;
|
|
65
|
-
--post-petrol-rgb: 0, 109, 104;
|
|
66
|
-
--post-petrol-bright-rgb: 0, 150, 143;
|
|
67
|
-
--post-coral-rgb: 158, 42, 47;
|
|
68
|
-
--post-coral-bright-rgb: 224, 60, 49;
|
|
69
|
-
--post-olive-rgb: 113, 97, 53;
|
|
70
|
-
--post-olive-bright-rgb: 170, 157, 46;
|
|
71
|
-
--post-purple-rgb: 128, 39, 108;
|
|
72
|
-
--post-purple-bright-rgb: 197, 41, 155;
|
|
73
|
-
--post-aubergine-rgb: 82, 49, 120;
|
|
74
|
-
--post-aubergine-bright-rgb: 117, 102, 160;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
:host {
|
|
78
|
-
--post-contrast-color: #fff;
|
|
79
|
-
--post-contrast-color-inverted: #000;
|
|
80
|
-
--post-dark: #faf9f8;
|
|
81
|
-
--post-light: hsl(0, 0%, 20%);
|
|
82
|
-
--post-gray-80: hsl(0, 0%, 90%);
|
|
83
|
-
--post-gray-60: hsl(0, 0%, 80%);
|
|
84
|
-
--post-gray-40: hsl(0, 0%, 60%);
|
|
85
|
-
--post-gray-20: hsl(0, 0%, 40%);
|
|
86
|
-
--post-gray-10: hsl(0, 0%, 20%);
|
|
87
|
-
--post-contrast-color-rgb: 255, 255, 255;
|
|
88
|
-
--post-contrast-color-inverted-rgb: 0, 0, 0;
|
|
89
|
-
--post-dark-rgb: 250, 249, 248;
|
|
90
|
-
--post-light-rgb: 51, 51, 51;
|
|
91
|
-
--post-gray-80-rgb: 230, 230, 230;
|
|
92
|
-
--post-gray-60-rgb: 204, 204, 204;
|
|
93
|
-
--post-gray-40-rgb: 153, 153, 153;
|
|
94
|
-
--post-gray-20-rgb: 102, 102, 102;
|
|
95
|
-
--post-gray-10-rgb: 51, 51, 51;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@layer polyfill {
|
|
99
|
-
[popover] {
|
|
100
|
-
position: fixed;
|
|
101
|
-
z-index: 2147483647;
|
|
102
|
-
inset: 0;
|
|
103
|
-
padding: 0.25em;
|
|
104
|
-
width: fit-content;
|
|
105
|
-
height: fit-content;
|
|
106
|
-
border-width: initial;
|
|
107
|
-
border-color: initial;
|
|
108
|
-
border-image: initial;
|
|
109
|
-
border-style: solid;
|
|
110
|
-
background-color: canvas;
|
|
111
|
-
color: canvastext;
|
|
112
|
-
overflow: auto;
|
|
113
|
-
margin: auto;
|
|
114
|
-
}
|
|
115
|
-
[popover]:not(.\:popover-open) {
|
|
116
|
-
display: none;
|
|
117
|
-
}
|
|
118
|
-
[popover]:is(dialog[open]) {
|
|
119
|
-
display: revert;
|
|
120
|
-
}
|
|
121
|
-
[anchor].\:popover-open {
|
|
122
|
-
inset: auto;
|
|
123
|
-
}
|
|
124
|
-
@supports selector([popover]:open) {
|
|
125
|
-
[popover]:not(.\:popover-open, dialog[open]) {
|
|
126
|
-
display: revert;
|
|
127
|
-
}
|
|
128
|
-
[anchor]:is(:open) {
|
|
129
|
-
inset: auto;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
@supports selector([popover]:popover-open) {
|
|
133
|
-
[popover]:not(.\:popover-open, dialog[open]) {
|
|
134
|
-
display: revert;
|
|
135
|
-
}
|
|
136
|
-
[anchor]:is(:popover-open) {
|
|
137
|
-
inset: auto;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
@supports not (background-color: canvas) {
|
|
141
|
-
[popover] {
|
|
142
|
-
background-color: white;
|
|
143
|
-
color: black;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
@supports (width: -moz-fit-content) {
|
|
147
|
-
[popover] {
|
|
148
|
-
width: -moz-fit-content;
|
|
149
|
-
height: -moz-fit-content;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
@supports not (inset: 0) {
|
|
153
|
-
[popover] {
|
|
154
|
-
top: 0;
|
|
155
|
-
left: 0;
|
|
156
|
-
right: 0;
|
|
157
|
-
bottom: 0;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
:host {
|
|
162
|
-
--post-bg-rgb: 51, 51, 51;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
div {
|
|
166
|
-
position: absolute;
|
|
167
|
-
z-index: 1070;
|
|
168
|
-
width: max-content;
|
|
169
|
-
max-width: 30ch;
|
|
170
|
-
margin: 0;
|
|
171
|
-
padding: 0.25rem 0.5rem;
|
|
172
|
-
color: inherit;
|
|
173
|
-
background-color: inherit;
|
|
174
|
-
border-color: transparent;
|
|
175
|
-
border-radius: 4px;
|
|
176
|
-
overflow: visible;
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.arrow {
|
|
181
|
-
position: absolute;
|
|
182
|
-
width: 0.7071067812rem;
|
|
183
|
-
aspect-ratio: 1/1;
|
|
184
|
-
background-color: inherit;
|
|
185
|
-
rotate: 45deg;
|
|
186
|
-
pointer-events: none;
|
|
187
|
-
z-index: -1;
|
|
188
|
-
border-right: 2px solid transparent;
|
|
189
|
-
border-bottom: 2px solid transparent;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.bg-yellow {
|
|
193
|
-
--post-bg-rgb: 255, 204, 0;
|
|
194
|
-
}
|
|
1
|
+
:host,.bg-yellow{--post-bg-opacity: 1;background-color:rgba(var(--post-bg-rgb), var(--post-bg-opacity)) !important;color:var(--post-contrast-color) !important}.bg-yellow{--post-contrast-color: #000;--post-contrast-color-inverted: #fff;--post-gray-10: hsl(0, 0%, 90%);--post-gray-20: hsl(0, 0%, 80%);--post-gray-40: hsl(0, 0%, 60%);--post-gray-60: hsl(0, 0%, 40%);--post-gray-80: hsl(0, 0%, 20%);--post-yellow: #fc0;--post-light: #faf9f8;--post-gray: #f4f3f1;--post-dark: hsl(0, 0%, 20%);--post-primary: hsl(0, 0%, 20%);--post-white: #fff;--post-black: #000;--post-success: #2c911c;--post-info: #cce4ee;--post-warning: #f49e00;--post-danger: #a51728;--post-nightblue: #004976;--post-nightblue-bright: #0076a8;--post-petrol: #006d68;--post-petrol-bright: #00968f;--post-coral: #9e2a2f;--post-coral-bright: #e03c31;--post-olive: #716135;--post-olive-bright: #aa9d2e;--post-purple: #80276c;--post-purple-bright: #c5299b;--post-aubergine: #523178;--post-aubergine-bright: #7566a0;--post-contrast-color-rgb: 0, 0, 0;--post-contrast-color-inverted-rgb: 255, 255, 255;--post-gray-10-rgb: 230, 230, 230;--post-gray-20-rgb: 204, 204, 204;--post-gray-40-rgb: 153, 153, 153;--post-gray-60-rgb: 102, 102, 102;--post-gray-80-rgb: 51, 51, 51;--post-yellow-rgb: 255, 204, 0;--post-light-rgb: 250, 249, 248;--post-gray-rgb: 244, 243, 241;--post-dark-rgb: 51, 51, 51;--post-primary-rgb: 51, 51, 51;--post-white-rgb: 255, 255, 255;--post-black-rgb: 0, 0, 0;--post-success-rgb: 44, 145, 28;--post-info-rgb: 204, 228, 238;--post-warning-rgb: 244, 158, 0;--post-danger-rgb: 165, 23, 40;--post-nightblue-rgb: 0, 73, 118;--post-nightblue-bright-rgb: 0, 118, 168;--post-petrol-rgb: 0, 109, 104;--post-petrol-bright-rgb: 0, 150, 143;--post-coral-rgb: 158, 42, 47;--post-coral-bright-rgb: 224, 60, 49;--post-olive-rgb: 113, 97, 53;--post-olive-bright-rgb: 170, 157, 46;--post-purple-rgb: 128, 39, 108;--post-purple-bright-rgb: 197, 41, 155;--post-aubergine-rgb: 82, 49, 120;--post-aubergine-bright-rgb: 117, 102, 160}:host{--post-contrast-color: #fff;--post-contrast-color-inverted: #000;--post-dark: #faf9f8;--post-light: hsl(0, 0%, 20%);--post-gray-80: hsl(0, 0%, 90%);--post-gray-60: hsl(0, 0%, 80%);--post-gray-40: hsl(0, 0%, 60%);--post-gray-20: hsl(0, 0%, 40%);--post-gray-10: hsl(0, 0%, 20%);--post-contrast-color-rgb: 255, 255, 255;--post-contrast-color-inverted-rgb: 0, 0, 0;--post-dark-rgb: 250, 249, 248;--post-light-rgb: 51, 51, 51;--post-gray-80-rgb: 230, 230, 230;--post-gray-60-rgb: 204, 204, 204;--post-gray-40-rgb: 153, 153, 153;--post-gray-20-rgb: 102, 102, 102;--post-gray-10-rgb: 51, 51, 51}@layer polyfill{[popover]{position:fixed;z-index:2147483647;inset:0;padding:.25em;width:fit-content;height:fit-content;border-width:initial;border-color:initial;border-image:initial;border-style:solid;background-color:canvas;color:canvastext;overflow:auto;margin:auto}[popover]:not(.\:popover-open){display:none}[popover]:is(dialog[open]){display:revert}[anchor].\:popover-open{inset:auto}@supports selector([popover]:open){[popover]:not(.\:popover-open,dialog[open]){display:revert}[anchor]:is(:open){inset:auto}}@supports selector([popover]:popover-open){[popover]:not(.\:popover-open,dialog[open]){display:revert}[anchor]:is(:popover-open){inset:auto}}@supports not (background-color: canvas){[popover]{background-color:white;color:black}}@supports(width: -moz-fit-content){[popover]{width:-moz-fit-content;height:-moz-fit-content}}@supports not (inset: 0){[popover]{top:0;left:0;right:0;bottom:0}}}:host{--post-bg-rgb: 51, 51, 51}div{position:absolute;z-index:1070;width:max-content;max-width:30ch;margin:0;padding:.25rem .5rem;color:inherit;background-color:inherit;border-color:rgba(0,0,0,0);border-radius:4px;overflow:visible;pointer-events:none}.arrow{position:absolute;width:.7071067812rem;aspect-ratio:1/1;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1;border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}.bg-yellow{--post-bg-rgb: 255, 204, 0}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { h, Host } from
|
|
2
|
-
import { arrow, autoUpdate, computePosition, flip, inline, offset, shift, } from
|
|
3
|
-
import isFocusable from
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { arrow, autoUpdate, computePosition, flip, inline, offset, shift, } from "@floating-ui/dom";
|
|
3
|
+
import isFocusable from "ally.js/esm/is/focusable";
|
|
4
4
|
// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green
|
|
5
|
-
import
|
|
5
|
+
import "@oddbird/popover-polyfill";
|
|
6
6
|
// Patch for long press on touch devices
|
|
7
|
-
import
|
|
8
|
-
import { version } from
|
|
9
|
-
import { checkOneOf } from
|
|
10
|
-
import { BACKGROUND_COLOR } from
|
|
7
|
+
import "long-press-event";
|
|
8
|
+
import { version } from "../../../package.json";
|
|
9
|
+
import { checkOneOf } from "../../utils";
|
|
10
|
+
import { BACKGROUND_COLOR } from "./types";
|
|
11
11
|
const SIDE_MAP = {
|
|
12
12
|
top: 'bottom',
|
|
13
13
|
right: 'left',
|
|
@@ -198,7 +198,8 @@ export class PostTooltip {
|
|
|
198
198
|
"references": {
|
|
199
199
|
"BackgroundColor": {
|
|
200
200
|
"location": "import",
|
|
201
|
-
"path": "./types"
|
|
201
|
+
"path": "./types",
|
|
202
|
+
"id": "src/components/post-tooltip/types.ts::BackgroundColor"
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
},
|
|
@@ -221,7 +222,8 @@ export class PostTooltip {
|
|
|
221
222
|
"references": {
|
|
222
223
|
"Placement": {
|
|
223
224
|
"location": "import",
|
|
224
|
-
"path": "@floating-ui/dom"
|
|
225
|
+
"path": "@floating-ui/dom",
|
|
226
|
+
"id": "../../node_modules/.pnpm/@floating-ui+dom@1.5.1/node_modules/@floating-ui/dom/src/types.d.ts::Placement"
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
229
|
},
|
|
@@ -256,10 +258,12 @@ export class PostTooltip {
|
|
|
256
258
|
}],
|
|
257
259
|
"references": {
|
|
258
260
|
"Promise": {
|
|
259
|
-
"location": "global"
|
|
261
|
+
"location": "global",
|
|
262
|
+
"id": "global::Promise"
|
|
260
263
|
},
|
|
261
264
|
"HTMLElement": {
|
|
262
|
-
"location": "global"
|
|
265
|
+
"location": "global",
|
|
266
|
+
"id": "global::HTMLElement"
|
|
263
267
|
}
|
|
264
268
|
},
|
|
265
269
|
"return": "Promise<void>"
|
|
@@ -278,7 +282,8 @@ export class PostTooltip {
|
|
|
278
282
|
"parameters": [],
|
|
279
283
|
"references": {
|
|
280
284
|
"Promise": {
|
|
281
|
-
"location": "global"
|
|
285
|
+
"location": "global",
|
|
286
|
+
"id": "global::Promise"
|
|
282
287
|
}
|
|
283
288
|
},
|
|
284
289
|
"return": "Promise<void>"
|
|
@@ -306,10 +311,12 @@ export class PostTooltip {
|
|
|
306
311
|
}],
|
|
307
312
|
"references": {
|
|
308
313
|
"Promise": {
|
|
309
|
-
"location": "global"
|
|
314
|
+
"location": "global",
|
|
315
|
+
"id": "global::Promise"
|
|
310
316
|
},
|
|
311
317
|
"HTMLElement": {
|
|
312
|
-
"location": "global"
|
|
318
|
+
"location": "global",
|
|
319
|
+
"id": "global::HTMLElement"
|
|
313
320
|
}
|
|
314
321
|
},
|
|
315
322
|
"return": "Promise<void>"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-tooltip.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/post-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,KAAK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,IAAI,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,IAAI;KACpD,CAAC,CAAC;EACL,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,oBAAe,OAAO;MACzB,WACE,IAAI,EAAC,SAAS,EACd,QAAQ,EAAC,IAAI,EACb,KAAK,EAAE,IAAI,CAAC,cAAc,EAC1B,GAAG,EAAE,CAAC,EAAmC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAEpE,YACE,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,EAAE,CAAC,EAAE;YACR,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;UACrB,CAAC,GACK;QACR,eAAa,CACT,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport isFocusable from 'ally.js/esm/is/focusable';\n\n// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green\nimport '@oddbird/popover-polyfill';\n\n// Patch for long press on touch devices\nimport 'long-press-event';\n\nimport { version } from '../../../package.json';\nimport { checkOneOf } from '../../utils';\nimport { BACKGROUND_COLOR, BackgroundColor } from './types';\n\nconst SIDE_MAP = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n};\n\ninterface PopoverElement {\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: (force?: boolean) => boolean;\n}\n\n@Component({\n tag: 'post-tooltip',\n styleUrl: 'post-tooltip.scss',\n shadow: true,\n})\nexport class PostTooltip {\n private tooltipRef: HTMLDivElement & PopoverElement;\n private arrowRef: HTMLElement;\n private clearAutoUpdate: () => void;\n private readonly localShowTooltip: (e: Event) => Promise<void>;\n private readonly localHideTooltip: () => Promise<void>;\n private readonly localToggleTooltip: () => Promise<void>;\n private eventTarget: Element;\n\n @Element() host: HTMLPostTooltipElement;\n\n @State() tooltipClasses: string;\n\n /**\n * Defines the background color of the tooltip.\n * Choose the one that provides the best contrast in your scenario.\n */\n @Prop() readonly backgroundColor?: BackgroundColor = 'primary';\n\n /**\n * Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\n * towards the viewport if they would overlap edge boundaries.\n */\n @Prop() readonly placement?: Placement = 'top';\n\n @Watch('backgroundColor')\n validateBackgroundColor(newValue = this.backgroundColor) {\n checkOneOf(\n newValue,\n BACKGROUND_COLOR,\n `The post-tooltip \"background-color\" prop should contain one of those values: ${BACKGROUND_COLOR.join(\n ', ',\n )}`,\n );\n\n if (newValue === 'yellow') {\n this.tooltipClasses = 'bg-yellow';\n } else {\n this.tooltipClasses = 'bg-primary';\n }\n }\n\n constructor() {\n // Create local versions of event handlers for de-registration\n // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class\n this.localShowTooltip = e => this.show(e.target as HTMLElement);\n this.localHideTooltip = this.hide.bind(this);\n this.localToggleTooltip = this.toggle.bind(this);\n }\n\n componentWillLoad() {\n this.validateBackgroundColor();\n\n // Append tooltip host to the end of the body to get around overflow: hidden restrictions\n // for browsers that don't support popover yet\n document.body.appendChild(this.host);\n }\n\n connectedCallback() {\n if (!this.host.id) {\n throw new Error(\n 'No id set: <post-tooltip> must have an id, linking it to it\\'s target element using the data-tooltip-target attribute.',\n );\n }\n\n if (!this.triggers) {\n throw new Error(\n `No trigger found for <post-tooltip id=\"${this.host.id}\">, please add the 'data-tooltip-target=\"${this.host.id}\" attribute to the trigger element.`,\n );\n }\n\n // Patch popovertargetaction=\"interest\" until it's implemented\n // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227\n this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));\n }\n\n /**\n * Remove a bunch of event listeners if the tooltip gets removed from the DOM\n */\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseenter', this.localShowTooltip);\n trigger.removeEventListener('mouseleave', this.localHideTooltip);\n trigger.removeEventListener('focus', this.localShowTooltip);\n trigger.removeEventListener('blur', this.localHideTooltip);\n trigger.removeEventListener('long-press', this.localShowTooltip);\n });\n if (this.tooltipRef)\n this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n\n componentDidLoad() {\n // Has the benefit of rendering the tooltip without the popover attribute which\n // causes the tooltip to show up on the page if it's not linked to a target. This makes\n // the error obvious.\n if (!this.host.id || !this.triggers) return false;\n\n this.tooltipRef.setAttribute('popover', '');\n this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));\n }\n\n /**\n * Programmatically display the tooltip\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.eventTarget = target;\n this.tooltipRef.showPopover();\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.eventTarget = null;\n this.tooltipRef.hidePopover();\n }\n\n /**\n * Toggle tooltip display\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n * @param force Pass true to always show or false to always hide\n */\n @Method()\n async toggle(target: HTMLElement, force?: boolean) {\n this.eventTarget = target;\n this.tooltipRef.togglePopover(force);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-tooltip-target=\"${this.host.id}\"]`);\n }\n\n private patchPopoverTargetActionInterest(trigger: Element) {\n trigger.addEventListener('mouseenter', this.localShowTooltip);\n trigger.addEventListener('mouseleave', this.localHideTooltip);\n trigger.addEventListener('focus', this.localShowTooltip);\n trigger.addEventListener('blur', this.localHideTooltip);\n trigger.addEventListener('long-press', this.localShowTooltip);\n\n // Patch missing aria-describedby attribute on the trigger without overriding existing values\n const describedBy = trigger.getAttribute('aria-describedby');\n if (!describedBy?.includes(this.host.id)) {\n const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;\n trigger.setAttribute('aria-describedby', newDescribedBy);\n }\n\n // Patch missing focus ability on the trigger element\n if (!isFocusable(trigger)) {\n trigger.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Start or stop auto updates based on tooltip events.\n * Tooltips can be closed or opened with other methods than class members,\n * therefore listening to the toggle event is safer for cleaning up.\n * @param e ToggleEvent\n */\n private handleToggle(e: ToggleEvent) {\n const isOpen = e.newState === 'open';\n if (isOpen) {\n this.startAutoupdates();\n } else {\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n }\n\n /**\n * Start listening for DOM updates, scroll events etc. that have\n * an influence on tooltip positioning\n */\n private startAutoupdates() {\n this.clearAutoUpdate = autoUpdate(\n this.eventTarget,\n this.tooltipRef,\n this.positionTooltip.bind(this),\n );\n }\n\n // Tooltip and arrow positioning with floating-ui\n // Docs: https://floating-ui.com/docs/computePosition\n private async positionTooltip() {\n const {\n x,\n y,\n middlewareData,\n placement: currentPlacement,\n } = await computePosition(this.eventTarget, this.tooltipRef, {\n placement: this.placement || 'top',\n middleware: [\n flip(),\n inline(),\n shift({ padding: 8 }),\n offset(12), // 4px outside of element to account for focus outline + ~arrow size\n arrow({ element: this.arrowRef, padding: 8 }),\n ],\n });\n\n // Tooltip\n this.tooltipRef.style.left = `${x}px`;\n this.tooltipRef.style.top = `${y}px`;\n\n // Arrow\n // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js\n const side = currentPlacement.split('-')[0];\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const staticSide = SIDE_MAP[side];\n\n Object.assign(this.arrowRef.style, {\n top: arrowY ? `${arrowY}px` : '',\n left: arrowX ? `${arrowX}px` : '',\n [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,\n });\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div\n role=\"tooltip\"\n tabindex=\"-1\"\n class={this.tooltipClasses}\n ref={(el: HTMLDivElement & PopoverElement) => (this.tooltipRef = el)}\n >\n <span\n class=\"arrow\"\n ref={el => {\n this.arrowRef = el;\n }}\n ></span>\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"post-tooltip.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/post-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,KAAK,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,MAAM,EAEN,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,0FAA0F;AAC1F,OAAO,2BAA2B,CAAC;AAEnC,wCAAwC;AACxC,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAE5D,MAAM,QAAQ,GAAG;EACf,GAAG,EAAE,QAAQ;EACb,KAAK,EAAE,MAAM;EACb,MAAM,EAAE,KAAK;EACb,IAAI,EAAE,OAAO;CACd,CAAC;AAaF,MAAM,OAAO,WAAW;EA2BtB,uBAAuB,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe;IACrD,UAAU,CACR,QAAQ,EACR,gBAAgB,EAChB,gFAAgF,gBAAgB,CAAC,IAAI,CACnG,IAAI,CACL,EAAE,CACJ,CAAC;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Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport isFocusable from 'ally.js/esm/is/focusable';\n\n// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green\nimport '@oddbird/popover-polyfill';\n\n// Patch for long press on touch devices\nimport 'long-press-event';\n\nimport { version } from '../../../package.json';\nimport { checkOneOf } from '../../utils';\nimport { BACKGROUND_COLOR, BackgroundColor } from './types';\n\nconst SIDE_MAP = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n};\n\ninterface PopoverElement {\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: (force?: boolean) => boolean;\n}\n\n@Component({\n tag: 'post-tooltip',\n styleUrl: 'post-tooltip.scss',\n shadow: true,\n})\nexport class PostTooltip {\n private tooltipRef: HTMLDivElement & PopoverElement;\n private arrowRef: HTMLElement;\n private clearAutoUpdate: () => void;\n private readonly localShowTooltip: (e: Event) => Promise<void>;\n private readonly localHideTooltip: () => Promise<void>;\n private readonly localToggleTooltip: () => Promise<void>;\n private eventTarget: Element;\n\n @Element() host: HTMLPostTooltipElement;\n\n @State() tooltipClasses: string;\n\n /**\n * Defines the background color of the tooltip.\n * Choose the one that provides the best contrast in your scenario.\n */\n @Prop() readonly backgroundColor?: BackgroundColor = 'primary';\n\n /**\n * Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\n * towards the viewport if they would overlap edge boundaries.\n */\n @Prop() readonly placement?: Placement = 'top';\n\n @Watch('backgroundColor')\n validateBackgroundColor(newValue = this.backgroundColor) {\n checkOneOf(\n newValue,\n BACKGROUND_COLOR,\n `The post-tooltip \"background-color\" prop should contain one of those values: ${BACKGROUND_COLOR.join(\n ', ',\n )}`,\n );\n\n if (newValue === 'yellow') {\n this.tooltipClasses = 'bg-yellow';\n } else {\n this.tooltipClasses = 'bg-primary';\n }\n }\n\n constructor() {\n // Create local versions of event handlers for de-registration\n // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class\n this.localShowTooltip = e => this.show(e.target as HTMLElement);\n this.localHideTooltip = this.hide.bind(this);\n this.localToggleTooltip = this.toggle.bind(this);\n }\n\n componentWillLoad() {\n this.validateBackgroundColor();\n\n // Append tooltip host to the end of the body to get around overflow: hidden restrictions\n // for browsers that don't support popover yet\n document.body.appendChild(this.host);\n }\n\n connectedCallback() {\n if (!this.host.id) {\n throw new Error(\n 'No id set: <post-tooltip> must have an id, linking it to it\\'s target element using the data-tooltip-target attribute.',\n );\n }\n\n if (!this.triggers) {\n throw new Error(\n `No trigger found for <post-tooltip id=\"${this.host.id}\">, please add the 'data-tooltip-target=\"${this.host.id}\" attribute to the trigger element.`,\n );\n }\n\n // Patch popovertargetaction=\"interest\" until it's implemented\n // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227\n this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));\n }\n\n /**\n * Remove a bunch of event listeners if the tooltip gets removed from the DOM\n */\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseenter', this.localShowTooltip);\n trigger.removeEventListener('mouseleave', this.localHideTooltip);\n trigger.removeEventListener('focus', this.localShowTooltip);\n trigger.removeEventListener('blur', this.localHideTooltip);\n trigger.removeEventListener('long-press', this.localShowTooltip);\n });\n if (this.tooltipRef)\n this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n\n componentDidLoad() {\n // Has the benefit of rendering the tooltip without the popover attribute which\n // causes the tooltip to show up on the page if it's not linked to a target. This makes\n // the error obvious.\n if (!this.host.id || !this.triggers) return false;\n\n this.tooltipRef.setAttribute('popover', '');\n this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));\n }\n\n /**\n * Programmatically display the tooltip\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.eventTarget = target;\n this.tooltipRef.showPopover();\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.eventTarget = null;\n this.tooltipRef.hidePopover();\n }\n\n /**\n * Toggle tooltip display\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n * @param force Pass true to always show or false to always hide\n */\n @Method()\n async toggle(target: HTMLElement, force?: boolean) {\n this.eventTarget = target;\n this.tooltipRef.togglePopover(force);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-tooltip-target=\"${this.host.id}\"]`);\n }\n\n private patchPopoverTargetActionInterest(trigger: Element) {\n trigger.addEventListener('mouseenter', this.localShowTooltip);\n trigger.addEventListener('mouseleave', this.localHideTooltip);\n trigger.addEventListener('focus', this.localShowTooltip);\n trigger.addEventListener('blur', this.localHideTooltip);\n trigger.addEventListener('long-press', this.localShowTooltip);\n\n // Patch missing aria-describedby attribute on the trigger without overriding existing values\n const describedBy = trigger.getAttribute('aria-describedby');\n if (!describedBy?.includes(this.host.id)) {\n const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;\n trigger.setAttribute('aria-describedby', newDescribedBy);\n }\n\n // Patch missing focus ability on the trigger element\n if (!isFocusable(trigger)) {\n trigger.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Start or stop auto updates based on tooltip events.\n * Tooltips can be closed or opened with other methods than class members,\n * therefore listening to the toggle event is safer for cleaning up.\n * @param e ToggleEvent\n */\n private handleToggle(e: ToggleEvent) {\n const isOpen = e.newState === 'open';\n if (isOpen) {\n this.startAutoupdates();\n } else {\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n }\n\n /**\n * Start listening for DOM updates, scroll events etc. that have\n * an influence on tooltip positioning\n */\n private startAutoupdates() {\n this.clearAutoUpdate = autoUpdate(\n this.eventTarget,\n this.tooltipRef,\n this.positionTooltip.bind(this),\n );\n }\n\n // Tooltip and arrow positioning with floating-ui\n // Docs: https://floating-ui.com/docs/computePosition\n private async positionTooltip() {\n const {\n x,\n y,\n middlewareData,\n placement: currentPlacement,\n } = await computePosition(this.eventTarget, this.tooltipRef, {\n placement: this.placement || 'top',\n middleware: [\n flip(),\n inline(),\n shift({ padding: 8 }),\n offset(12), // 4px outside of element to account for focus outline + ~arrow size\n arrow({ element: this.arrowRef, padding: 8 }),\n ],\n });\n\n // Tooltip\n this.tooltipRef.style.left = `${x}px`;\n this.tooltipRef.style.top = `${y}px`;\n\n // Arrow\n // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js\n const side = currentPlacement.split('-')[0];\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const staticSide = SIDE_MAP[side];\n\n Object.assign(this.arrowRef.style, {\n top: arrowY ? `${arrowY}px` : '',\n left: arrowX ? `${arrowX}px` : '',\n [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,\n });\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div\n role=\"tooltip\"\n tabindex=\"-1\"\n class={this.tooltipClasses}\n ref={(el: HTMLDivElement & PopoverElement) => (this.tooltipRef = el)}\n >\n <span\n class=\"arrow\"\n ref={el => {\n this.arrowRef = el;\n }}\n ></span>\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
|
package/dist/collection/index.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// Export every single component so it gets included in the dist output
|
|
2
|
+
export { PostAlert } from './components/post-alert/post-alert';
|
|
3
|
+
export { PostCollapsible } from './components/post-collapsible/post-collapsible';
|
|
4
|
+
export { PostIcon } from './components/post-icon/post-icon';
|
|
5
|
+
export { PostTabs } from './components/post-tabs/post-tabs';
|
|
6
|
+
export { PostTabHeader } from './components/post-tab-header/post-tab-header';
|
|
7
|
+
export { PostTabPanel } from './components/post-tab-panel/post-tab-panel';
|
|
8
|
+
export { PostTooltip } from './components/post-tooltip/post-tooltip';
|
|
2
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"","sourcesContent":["export { Components, JSX } from './components';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { Components, JSX } from './components';\n\n// Export every single component so it gets included in the dist output\nexport { PostAlert } from './components/post-alert/post-alert';\nexport { PostCollapsible } from './components/post-collapsible/post-collapsible';\nexport { PostIcon } from './components/post-icon/post-icon';\nexport { PostTabs } from './components/post-tabs/post-tabs';\nexport { PostTabHeader } from './components/post-tab-header/post-tab-header';\nexport { PostTabPanel } from './components/post-tab-panel/post-tab-panel';\nexport { PostTooltip } from './components/post-tooltip/post-tooltip';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './property-checkers';\nexport * from './is-motion-reduced';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-motion-reduced.js","sourceRoot":"","sources":["../../../src/utils/is-motion-reduced.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;EAC7B,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["export function isMotionReduced(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { emptyOr } from
|
|
2
|
-
import { checkOneOf } from
|
|
3
|
-
import { checkPattern } from
|
|
4
|
-
import { checkType } from
|
|
1
|
+
import { emptyOr } from "./empty-or";
|
|
2
|
+
import { checkOneOf } from "./check-one-of";
|
|
3
|
+
import { checkPattern } from "./check-pattern";
|
|
4
|
+
import { checkType } from "./check-type";
|
|
5
5
|
export const checkEmptyOrOneOf = emptyOr(checkOneOf);
|
|
6
6
|
export const checkEmptyOrPattern = emptyOr(checkPattern);
|
|
7
7
|
export const checkEmptyOrType = emptyOr(checkType);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { E as EMPTY_VALUES } from './constants.js';
|
|
2
2
|
|
|
3
3
|
function checkNonEmpty(value, error) {
|
|
4
4
|
if (EMPTY_VALUES.some(v => v === value)) {
|
|
@@ -6,6 +6,6 @@ function checkNonEmpty(value, error) {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { checkNonEmpty as c };
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=check-non-empty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"check-non-empty.js","mappings":"
|
|
1
|
+
{"file":"check-non-empty.js","mappings":";;SAEgB,aAAa,CAAC,KAAc,EAAE,KAAa;EACzD,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE;IACvC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACxB;AACH;;;;","names":[],"sources":["src/utils/property-checkers/check-non-empty.ts"],"sourcesContent":["import { EMPTY_VALUES } from './constants';\n\nexport function checkNonEmpty(value: unknown, error: string) {\n if (EMPTY_VALUES.some(v => v === value)) {\n throw new Error(error);\n }\n}\n"],"version":3}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"check-one-of.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAA4B,EAAE,KAAa;EACjF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;;;","names":[],"sources":["
|
|
1
|
+
{"file":"check-one-of.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAA4B,EAAE,KAAa;EACjF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;;;","names":[],"sources":["src/utils/property-checkers/check-one-of.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: readonly T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"],"version":3}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"constants.js","mappings":"MAAa,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;;;;","names":[],"sources":["src/utils/property-checkers/constants.ts"],"sourcesContent":["export const EMPTY_VALUES = [undefined, null, ''];\n"],"version":3}
|