@swisspost/design-system-components 2.0.2 → 2.1.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/attribute-observer-10f08c04.js +27 -0
- package/dist/cjs/index-f243643b.js +4 -0
- package/dist/cjs/index.cjs.js +15 -12
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{package-e8091039.js → package-96a46572.js} +1 -1
- package/dist/cjs/{post-accordion-eebf7827.js → post-accordion-9d27458a.js} +1 -1
- package/dist/cjs/{post-accordion-item-b2977ca5.js → post-accordion-item-61fb55fa.js} +2 -2
- package/dist/cjs/post-accordion-item.cjs.entry.js +2 -2
- package/dist/cjs/post-accordion.cjs.entry.js +2 -2
- package/dist/cjs/{post-alert-af7728e6.js → post-alert-a810f5b9.js} +2 -2
- package/dist/cjs/post-alert.cjs.entry.js +2 -2
- package/dist/cjs/{post-collapsible-15f79667.js → post-collapsible-1867015c.js} +1 -1
- package/dist/cjs/post-collapsible.cjs.entry.js +2 -2
- package/dist/cjs/post-components.cjs.js +1 -1
- package/dist/cjs/{post-icon-b80d7e24.js → post-icon-07a67b83.js} +1 -1
- package/dist/cjs/post-icon.cjs.entry.js +2 -2
- package/dist/cjs/post-popover-9610b64c.js +104 -0
- package/dist/cjs/post-popover.cjs.entry.js +3 -2
- package/dist/cjs/{post-popovercontainer-130193cf.js → post-popovercontainer-003c0819.js} +26 -13
- package/dist/cjs/post-popovercontainer.cjs.entry.js +2 -2
- package/dist/cjs/post-rating-75574abd.js +88 -0
- package/dist/cjs/post-rating.cjs.entry.js +11 -0
- package/dist/cjs/post-tab-header-85424e32.js +32 -0
- package/dist/cjs/post-tab-header.cjs.entry.js +2 -2
- package/dist/cjs/{post-tab-panel-fc0bfcbe.js → post-tab-panel-6a9c4a4f.js} +2 -2
- package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/{post-tabs-3f909e1c.js → post-tabs-2eb6f376.js} +3 -3
- package/dist/cjs/post-tabs.cjs.entry.js +2 -2
- package/dist/cjs/{post-tooltip-e5b22230.js → post-tooltip-260d0627.js} +10 -27
- package/dist/cjs/post-tooltip.cjs.entry.js +3 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/post-accordion-item/post-accordion-item.js +1 -1
- package/dist/collection/components/post-alert/post-alert.css +5 -5
- package/dist/collection/components/post-popover/post-popover.css +1 -1
- package/dist/collection/components/post-popover/post-popover.js +47 -63
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -1
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +25 -12
- package/dist/collection/components/post-rating/post-rating.css +3 -0
- package/dist/collection/components/post-rating/post-rating.js +202 -0
- package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
- package/dist/collection/components/post-tab-header/post-tab-header.js +1 -1
- package/dist/collection/components/post-tab-panel/post-tab-panel.js +1 -1
- package/dist/collection/components/post-tabs/post-tabs.css +1 -1
- package/dist/collection/components/post-tabs/post-tabs.js +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.js +9 -26
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/attribute-observer.js +23 -0
- package/dist/components/attribute-observer.js +25 -0
- package/dist/components/index.js +1 -0
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion-item2.js +1 -1
- package/dist/components/post-alert2.js +1 -1
- package/dist/components/post-popover2.js +51 -64
- package/dist/components/post-popovercontainer2.js +25 -12
- package/dist/components/post-rating.d.ts +11 -0
- package/dist/components/post-rating.js +6 -0
- package/dist/components/post-rating2.js +113 -0
- package/dist/components/post-tab-header2.js +2 -2
- package/dist/components/post-tab-panel2.js +1 -1
- package/dist/components/post-tabs2.js +2 -2
- package/dist/components/post-tooltip2.js +9 -26
- package/dist/docs.json +151 -14
- package/dist/esm/attribute-observer-37fa950a.js +25 -0
- package/dist/esm/index-1708db56.js +4 -0
- package/dist/esm/index.js +14 -12
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{package-aa903c40.js → package-50a9c0c3.js} +1 -1
- package/dist/esm/{post-accordion-82b49f7b.js → post-accordion-33fe4f0e.js} +1 -1
- package/dist/esm/{post-accordion-item-3deff76a.js → post-accordion-item-1fd95c9f.js} +2 -2
- package/dist/esm/post-accordion-item.entry.js +2 -2
- package/dist/esm/post-accordion.entry.js +2 -2
- package/dist/esm/{post-alert-c88451ba.js → post-alert-65d67f69.js} +2 -2
- package/dist/esm/post-alert.entry.js +2 -2
- package/dist/esm/{post-collapsible-87ce4e6e.js → post-collapsible-50dc361b.js} +1 -1
- package/dist/esm/post-collapsible.entry.js +2 -2
- package/dist/esm/post-components.js +1 -1
- package/dist/esm/{post-icon-e0536000.js → post-icon-00f314ae.js} +1 -1
- package/dist/esm/post-icon.entry.js +2 -2
- package/dist/esm/post-popover-40bfd1b7.js +102 -0
- package/dist/esm/post-popover.entry.js +3 -2
- package/dist/esm/{post-popovercontainer-6d1d7f76.js → post-popovercontainer-62e1fd82.js} +26 -13
- package/dist/esm/post-popovercontainer.entry.js +2 -2
- package/dist/esm/post-rating-f7a79ed4.js +86 -0
- package/dist/esm/post-rating.entry.js +3 -0
- package/dist/esm/post-tab-header-0683252a.js +30 -0
- package/dist/esm/post-tab-header.entry.js +2 -2
- package/dist/esm/{post-tab-panel-b41d5d0f.js → post-tab-panel-37a1331f.js} +2 -2
- package/dist/esm/post-tab-panel.entry.js +2 -2
- package/dist/esm/{post-tabs-97868e9c.js → post-tabs-c4e65a45.js} +3 -3
- package/dist/esm/post-tabs.entry.js +2 -2
- package/dist/esm/{post-tooltip-531b569d.js → post-tooltip-033f63fa.js} +10 -27
- package/dist/esm/post-tooltip.entry.js +3 -2
- package/dist/post-components/index.esm.js +1 -1
- package/dist/post-components/p-00dcad55.js +1 -0
- package/dist/post-components/p-01e57281.entry.js +1 -0
- package/dist/post-components/p-06c989fb.entry.js +1 -0
- package/dist/post-components/p-07ffb6de.entry.js +1 -0
- package/dist/post-components/p-26c658c1.entry.js +1 -0
- package/dist/post-components/p-2a964700.js +1 -0
- package/dist/post-components/{p-202a23d3.js → p-35f14000.js} +1 -1
- package/dist/post-components/{p-d8ac8ae9.js → p-3fb09ecd.js} +1 -1
- package/dist/post-components/p-4b0a45d8.entry.js +1 -0
- package/dist/post-components/p-53e8e4e7.entry.js +1 -0
- package/dist/post-components/{p-284ca5da.js → p-598b11b6.js} +1 -1
- package/dist/post-components/p-5b6ee52a.entry.js +1 -0
- package/dist/post-components/p-6adeaa6c.js +1 -0
- package/dist/post-components/p-7e7833f7.js +15 -0
- package/dist/post-components/p-8139faa4.entry.js +1 -0
- package/dist/post-components/p-8cd6d7c2.js +1 -0
- package/dist/post-components/{p-bf1293e1.js → p-99a9602e.js} +1 -1
- package/dist/post-components/p-a2775477.entry.js +1 -0
- package/dist/post-components/p-a905b16b.entry.js +1 -0
- package/dist/post-components/p-aa02111b.js +1 -0
- package/dist/post-components/{p-25766de1.js → p-b135d3e2.js} +1 -1
- package/dist/post-components/p-b81e61ed.entry.js +1 -0
- package/dist/post-components/p-d6bc34ff.js +1 -0
- package/dist/post-components/p-da2b8e26.entry.js +1 -0
- package/dist/post-components/p-f0476913.js +1 -0
- package/dist/post-components/p-ff0e1564.js +1 -0
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/types/components/post-popover/post-popover.d.ts +3 -17
- package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +1 -0
- package/dist/types/components/post-rating/post-rating.d.ts +43 -0
- package/dist/types/components.d.ts +69 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/attribute-observer.d.ts +1 -0
- package/package.json +4 -3
- package/dist/cjs/post-popover-392b0554.js +0 -117
- package/dist/cjs/post-tab-header-454cc178.js +0 -32
- package/dist/esm/post-popover-00b006b4.js +0 -115
- package/dist/esm/post-tab-header-0f7866f9.js +0 -30
- package/dist/post-components/p-0ef425cd.entry.js +0 -1
- package/dist/post-components/p-23d55894.entry.js +0 -1
- package/dist/post-components/p-2b5a940c.entry.js +0 -1
- package/dist/post-components/p-31c06741.entry.js +0 -1
- package/dist/post-components/p-320a90d8.entry.js +0 -1
- package/dist/post-components/p-3b8a1f9d.entry.js +0 -1
- package/dist/post-components/p-61ad6181.entry.js +0 -1
- package/dist/post-components/p-71a57911.js +0 -1
- package/dist/post-components/p-b111a381.js +0 -1
- package/dist/post-components/p-ba40e160.js +0 -1
- package/dist/post-components/p-be08f39f.entry.js +0 -1
- package/dist/post-components/p-c3dd84af.js +0 -1
- package/dist/post-components/p-c9ecada7.entry.js +0 -1
- package/dist/post-components/p-cdd7ad0a.js +0 -15
- package/dist/post-components/p-d7863a77.js +0 -1
- package/dist/post-components/p-dc9ffe1d.js +0 -1
- package/dist/post-components/p-fbf645c4.entry.js +0 -1
- package/dist/post-components/p-ff9016ce.entry.js +0 -1
|
@@ -1,54 +1,66 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import { version } from "../../../package.json";
|
|
3
|
+
import { getAttributeObserver } from "../../utils/attribute-observer";
|
|
3
4
|
/**
|
|
4
5
|
* @slot default - Slot for placing content inside the popover.
|
|
5
6
|
*/
|
|
7
|
+
let popoverInstances = 0;
|
|
8
|
+
const popoverTargetAttribute = 'data-popover-target';
|
|
9
|
+
const globalToggleHandler = (e) => {
|
|
10
|
+
const target = e.target;
|
|
11
|
+
if (!target || !('getAttribute' in target))
|
|
12
|
+
return;
|
|
13
|
+
const popoverTarget = target.getAttribute(popoverTargetAttribute);
|
|
14
|
+
if (!popoverTarget || ('key' in e && e.key !== 'Enter'))
|
|
15
|
+
return;
|
|
16
|
+
const popover = document.getElementById(popoverTarget);
|
|
17
|
+
popover === null || popover === void 0 ? void 0 : popover.toggle(target);
|
|
18
|
+
};
|
|
19
|
+
// Initialize a mutation observer for patching accessibility features
|
|
20
|
+
const triggerObserver = getAttributeObserver(popoverTargetAttribute, trigger => {
|
|
21
|
+
const force = trigger.hasAttribute(popoverTargetAttribute);
|
|
22
|
+
trigger.setAttribute('aria-expanded', force ? 'false' : null);
|
|
23
|
+
});
|
|
6
24
|
export class PostPopover {
|
|
7
25
|
constructor() {
|
|
8
26
|
this.placement = 'top';
|
|
9
27
|
this.closeButtonCaption = undefined;
|
|
10
28
|
this.arrow = true;
|
|
11
|
-
this.
|
|
12
|
-
this.localEnterTogglePopover = e => {
|
|
13
|
-
if (e.key === 'Enter')
|
|
14
|
-
this.toggle(e.target);
|
|
15
|
-
};
|
|
16
|
-
this.localTouchTogglePopover = e => {
|
|
17
|
-
e.preventDefault();
|
|
18
|
-
this.toggle(e.target);
|
|
19
|
-
};
|
|
29
|
+
this.localBeforeToggleHandler = this.beforeToggleHandler.bind(this);
|
|
20
30
|
}
|
|
21
31
|
connectedCallback() {
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
// Set up accessibility patcher and event listeners for the first component
|
|
33
|
+
if (popoverInstances === 0) {
|
|
34
|
+
window.addEventListener('pointerup', globalToggleHandler);
|
|
35
|
+
window.addEventListener('keydown', globalToggleHandler);
|
|
36
|
+
triggerObserver.observe(document.body, {
|
|
37
|
+
subtree: true,
|
|
38
|
+
childList: true,
|
|
39
|
+
attributeFilter: [popoverTargetAttribute],
|
|
40
|
+
});
|
|
24
41
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.triggers.forEach(trigger => {
|
|
31
|
-
// See this.onToggle for one time mouse event listener
|
|
32
|
-
trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });
|
|
33
|
-
trigger.addEventListener('keypress', this.localEnterTogglePopover);
|
|
34
|
-
trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });
|
|
35
|
-
trigger.setAttribute('aria-expanded', 'false');
|
|
36
|
-
});
|
|
42
|
+
popoverInstances++;
|
|
43
|
+
this.triggers.forEach(trigger => trigger.setAttribute('aria-expanded', 'false'));
|
|
44
|
+
}
|
|
45
|
+
componentDidLoad() {
|
|
46
|
+
this.popoverRef.addEventListener('beforetoggle', this.localBeforeToggleHandler);
|
|
37
47
|
}
|
|
38
48
|
disconnectedCallback() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
popoverInstances--;
|
|
50
|
+
// Remove listeners and observer after the last popover has been destructed
|
|
51
|
+
if (popoverInstances === 0) {
|
|
52
|
+
window.removeEventListener('click', globalToggleHandler);
|
|
53
|
+
window.removeEventListener('keydown', globalToggleHandler);
|
|
54
|
+
triggerObserver.disconnect();
|
|
55
|
+
}
|
|
56
|
+
this.popoverRef.removeEventListener('beforetoggle', this.localBeforeToggleHandler);
|
|
57
|
+
this.triggers.forEach(trigger => trigger.removeAttribute('aria-expanded'));
|
|
45
58
|
}
|
|
46
59
|
/**
|
|
47
60
|
* Programmatically display the popover
|
|
48
61
|
* @param target An element with [data-popover-target="id"] where the popover should be shown
|
|
49
62
|
*/
|
|
50
63
|
async show(target) {
|
|
51
|
-
this.currentTarget = target;
|
|
52
64
|
this.popoverRef.show(target);
|
|
53
65
|
target.setAttribute('aria-expanded', 'true');
|
|
54
66
|
}
|
|
@@ -65,46 +77,18 @@ export class PostPopover {
|
|
|
65
77
|
* @param force Pass true to always show or false to always hide
|
|
66
78
|
*/
|
|
67
79
|
async toggle(target, force) {
|
|
68
|
-
this.currentTarget = target;
|
|
69
80
|
const newState = await this.popoverRef.toggle(target, force);
|
|
81
|
+
this.triggers.forEach(trigger => trigger.setAttribute('aria-expanded', 'false'));
|
|
70
82
|
target.setAttribute('aria-expanded', `${newState}`);
|
|
71
83
|
}
|
|
72
84
|
get triggers() {
|
|
73
|
-
return document.querySelectorAll(`[
|
|
85
|
+
return document.querySelectorAll(`[${popoverTargetAttribute}="${this.host.id}"]`);
|
|
74
86
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* A permanent event listener would prevent a toggle button from working properly:
|
|
78
|
-
* A click opens the popover, a second click first closes it (due to light dismiss), then directly
|
|
79
|
-
* opens it again because of the click listener on the button. Registering a new
|
|
80
|
-
* one time listener after a small timeout solves this issue.
|
|
81
|
-
* @param e toggle event from post-popovercontainer
|
|
82
|
-
*/
|
|
83
|
-
onToggle(e) {
|
|
84
|
-
if (this.currentTarget) {
|
|
85
|
-
this.currentTarget.setAttribute('aria-expanded', `${e.detail}`);
|
|
86
|
-
}
|
|
87
|
-
if (!e.detail) {
|
|
88
|
-
window.requestAnimationFrame(() => {
|
|
89
|
-
this.triggers.forEach(trigger => {
|
|
90
|
-
trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });
|
|
91
|
-
trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
// Handle missing re-focusing logic after close. Can be removed as soon as popovertarget works correctly
|
|
95
|
-
if (this.currentTarget) {
|
|
96
|
-
this.currentTarget.focus();
|
|
97
|
-
this.currentTarget = null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Fix for firefox to prevent the following lines from triggering
|
|
102
|
-
// https://github.com/oddbird/popover-polyfill/blob/main/src/popover.ts#L338
|
|
103
|
-
stopImmediatePropagation(e) {
|
|
104
|
-
e.stopImmediatePropagation();
|
|
87
|
+
beforeToggleHandler() {
|
|
88
|
+
this.triggers.forEach(trigger => trigger.setAttribute('aria-expanded', 'false'));
|
|
105
89
|
}
|
|
106
90
|
render() {
|
|
107
|
-
return (h(Host, { key: '
|
|
91
|
+
return (h(Host, { key: '90cd97eedfdecb6666c5825cd09bb323cf857cbb', "data-version": version }, h("post-popovercontainer", { key: 'fe555322454124f4b9a618c634f2ae504ec89c07', arrow: this.arrow, placement: this.placement, ref: e => (this.popoverRef = e) }, h("div", { key: 'd6e30229dd8d38c95e165d1fc55b1c7af5c7b5e2', class: "popover-container" }, h("div", { key: 'c43c1347bb6bfe3532387693b1761b53533584ec', class: "popover-content" }, h("slot", { key: '24a4aa1df86497a4fe4b72adaac76f6e69db9d9e' })), h("button", { key: '3a5e52f480ddd1ef41d068e476d2a8c5f7d77c4a', class: "btn-close", onClick: () => this.hide() }, h("span", { key: '493310100d3f76dfe5bf6cf1d64250b7551be43c', class: "visually-hidden" }, this.closeButtonCaption))))));
|
|
108
92
|
}
|
|
109
93
|
static get is() { return "post-popover"; }
|
|
110
94
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer polyfill{@supports not selector(:popover-open){[popover]:not(.\:popover-open){display:none}}}.popover{box-shadow:.5px 3px 4px rgba(0,0,0,.1),2px 4px 10px 4px rgba(0,0,0,.12);position:fixed;z-index:1060;width:max-content;margin:0;padding:0;box-sizing:border-box;color:var(--post-contrast-color);background-color:rgb(var(--post-bg-rgb));border:
|
|
1
|
+
@layer polyfill{@supports not selector(:popover-open){[popover]:not(.\:popover-open){display:none}}}.popover{box-shadow:.5px 3px 4px rgba(0,0,0,.1),2px 4px 10px 4px rgba(0,0,0,.12);position:fixed;z-index:1060;width:max-content;margin:0;padding:0;box-sizing:border-box;color:var(--post-contrast-color);background-color:rgb(var(--post-bg-rgb));border:2px solid rgba(0,0,0,0);border-radius:4px;overflow:visible}.arrow{position:absolute;width:.7071067812rem;height:.7071067812rem;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1}.arrow.top{border-left:2px solid rgba(0,0,0,0);border-top:2px solid rgba(0,0,0,0)}.arrow.right{border-right:2px solid rgba(0,0,0,0);border-top:2px solid rgba(0,0,0,0)}.arrow.left{border-left:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}.arrow.bottom{border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
|
-
import { arrow, autoUpdate, computePosition, flip, inline, offset, shift,
|
|
2
|
+
import { arrow, autoUpdate, computePosition, flip, inline, limitShift, offset, shift, size, } from "@floating-ui/dom";
|
|
3
3
|
// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green
|
|
4
4
|
import "@oddbird/popover-polyfill";
|
|
5
5
|
import { version } from "../../../package.json";
|
|
@@ -32,16 +32,20 @@ export class PostPopovercontainer {
|
|
|
32
32
|
* @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
|
|
33
33
|
*/
|
|
34
34
|
async show(target) {
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (!this.toggleTimeoutId) {
|
|
36
|
+
this.eventTarget = target;
|
|
37
|
+
this.calculatePosition();
|
|
38
|
+
this.popoverRef.showPopover();
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Programmatically hide this tooltip
|
|
41
43
|
*/
|
|
42
44
|
async hide() {
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
+
if (!this.toggleTimeoutId) {
|
|
46
|
+
this.eventTarget = null;
|
|
47
|
+
this.popoverRef.hidePopover();
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Toggle tooltip display
|
|
@@ -49,9 +53,13 @@ export class PostPopovercontainer {
|
|
|
49
53
|
* @param force Pass true to always show or false to always hide
|
|
50
54
|
*/
|
|
51
55
|
async toggle(target, force) {
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
56
|
+
// Prevent instant double toggle
|
|
57
|
+
if (!this.toggleTimeoutId) {
|
|
58
|
+
this.eventTarget = target;
|
|
59
|
+
this.calculatePosition();
|
|
60
|
+
this.popoverRef.togglePopover(force);
|
|
61
|
+
this.toggleTimeoutId = null;
|
|
62
|
+
}
|
|
55
63
|
return this.popoverRef.matches(':popover-open');
|
|
56
64
|
}
|
|
57
65
|
/**
|
|
@@ -61,6 +69,7 @@ export class PostPopovercontainer {
|
|
|
61
69
|
* @param e ToggleEvent
|
|
62
70
|
*/
|
|
63
71
|
handleToggle(e) {
|
|
72
|
+
this.toggleTimeoutId = window.setTimeout(() => (this.toggleTimeoutId = null), 10);
|
|
64
73
|
const isOpen = e.newState === 'open';
|
|
65
74
|
if (isOpen) {
|
|
66
75
|
this.startAutoupdates();
|
|
@@ -116,17 +125,21 @@ export class PostPopovercontainer {
|
|
|
116
125
|
const side = currentPlacement.split('-')[0];
|
|
117
126
|
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
118
127
|
const staticSide = SIDE_MAP[side];
|
|
128
|
+
const offsetBorderLineJoin = 2;
|
|
119
129
|
Object.assign(this.arrowRef.style, {
|
|
120
130
|
top: arrowY ? `${arrowY}px` : '',
|
|
121
131
|
left: arrowX ? `${arrowX}px` : '',
|
|
122
|
-
[staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,
|
|
132
|
+
[staticSide]: `${-this.arrowRef.offsetWidth / 2 - offsetBorderLineJoin}px`,
|
|
123
133
|
});
|
|
134
|
+
// Add position as a class to be able to style arrow for HCM
|
|
135
|
+
this.arrowRef.classList.remove(...Object.values(SIDE_MAP));
|
|
136
|
+
this.arrowRef.classList.add(staticSide);
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
139
|
render() {
|
|
127
|
-
return (h(Host, { key: '
|
|
140
|
+
return (h(Host, { key: '8049387a5ba6eefb3165e84c098ba4ae5b8f443f', "data-version": version }, h("div", { key: '63d3095a7992baf46fbc74b5c595654cbdeaba66', class: "popover", part: "popover", ref: (el) => (this.popoverRef = el) }, this.arrow && (h("span", { class: "arrow", ref: el => {
|
|
128
141
|
this.arrowRef = el;
|
|
129
|
-
} })), h("slot", { key: '
|
|
142
|
+
} })), h("slot", { key: '74b1746bf48f8aa915c443721c1c2af1c1a3df5d' }))));
|
|
130
143
|
}
|
|
131
144
|
static get is() { return "post-popovercontainer"; }
|
|
132
145
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 by Swiss Post, Information Technology
|
|
3
|
+
*/:host{display:inline-block}.rating{display:flex;flex-wrap:wrap;overflow:hidden;margin:0 -0.25rem;border-radius:4px}.rating .star{--post-rating-star-stroke: hsl(0, 0%, 40%);--post-rating-star-fill: #fff;position:relative;width:2rem;height:2rem;cursor:pointer}.rating .star .stroke,.rating .star .fill{display:block;width:100%;height:100%;transition:all ease 100ms}.rating .star .stroke{position:absolute;inset:auto;z-index:1;color:var(--post-rating-star-stroke)}.rating .star .fill{margin:1px;width:calc(100% - 2px);height:calc(100% - 2px);color:var(--post-rating-star-fill)}.rating .star.before-hover{--post-rating-star-stroke: hsl(0, 0%, 40%);--post-rating-star-fill: #fc0}.rating .star.active{--post-rating-star-stroke: hsl(0, 0%, 20%);--post-rating-star-fill: #fc0}.rating .star.hover{--post-rating-star-stroke: hsl(0, 0%, 40%);--post-rating-star-fill: #fc0}.rating .star.after-active{--post-rating-star-stroke: hsl(0, 0%, 40%);--post-rating-star-fill: hsl(0, 0%, 80%)}.rating :focus{outline:none}.rating:focus-visible{outline-offset:2px;outline:2px solid #1976c8}.rating[aria-readonly=true] .star,.rating[aria-disabled=true] .star{cursor:default}.rating[aria-disabled=true] .star{--post-rating-star-stroke: hsl(0, 0%, 60%);--post-rating-star-fill: #fff}.rating[aria-disabled=true] .star.active{cursor:default;--post-rating-star-stroke: hsl(0, 0%, 60%);--post-rating-star-fill: hsl(0, 0%, 90%)}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { version } from "../../../package.json";
|
|
3
|
+
export class PostRating {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.hasChanged = false;
|
|
6
|
+
this.hoveredIndex = undefined;
|
|
7
|
+
this.label = 'Rating';
|
|
8
|
+
this.stars = 5;
|
|
9
|
+
this.currentRating = 0;
|
|
10
|
+
this.readonly = false;
|
|
11
|
+
this.keydownHandler = this.keydownHandler.bind(this);
|
|
12
|
+
this.blurHandler = this.blurHandler.bind(this);
|
|
13
|
+
this.hoverHandler = this.hoverHandler.bind(this);
|
|
14
|
+
}
|
|
15
|
+
update(value) {
|
|
16
|
+
if (this.readonly || value < 0 || value > this.stars)
|
|
17
|
+
return;
|
|
18
|
+
this.currentRating = this.currentRating !== value ? value : 0; // If a star is clicked the second time, the rating gets set to 0.
|
|
19
|
+
this.input.emit({ value: this.currentRating });
|
|
20
|
+
this.hasChanged = true;
|
|
21
|
+
}
|
|
22
|
+
keydownHandler(e) {
|
|
23
|
+
switch (e.key) {
|
|
24
|
+
case 'ArrowDown':
|
|
25
|
+
case 'ArrowLeft':
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
this.update(this.currentRating - 1);
|
|
28
|
+
break;
|
|
29
|
+
case 'ArrowUp':
|
|
30
|
+
case 'ArrowRight':
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
this.update(this.currentRating + 1);
|
|
33
|
+
break;
|
|
34
|
+
case 'Home':
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
this.update(0);
|
|
37
|
+
break;
|
|
38
|
+
case 'End':
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
this.update(this.stars);
|
|
41
|
+
break;
|
|
42
|
+
case 'Enter':
|
|
43
|
+
case ' ':
|
|
44
|
+
this.blurHandler();
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
blurHandler() {
|
|
51
|
+
if (this.hasChanged) {
|
|
52
|
+
this.change.emit({ value: this.currentRating });
|
|
53
|
+
this.hasChanged = false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
hoverHandler(index, e) {
|
|
57
|
+
if (this.readonly)
|
|
58
|
+
return;
|
|
59
|
+
if (e.type === 'mouseenter') {
|
|
60
|
+
this.hoveredIndex = index;
|
|
61
|
+
}
|
|
62
|
+
else if (e.type === 'mouseleave') {
|
|
63
|
+
this.hoveredIndex = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
return (h(Host, { key: '024062262951980933a54144b7ed00fead499f07', "data-version": version }, h("div", { key: '1be8030d6d4d5d25010a0df6823da0fe72e7e682', role: "slider", class: "rating", tabindex: "0", "aria-label": this.label, "aria-valuemin": "0", "aria-valuemax": this.stars, "aria-valuenow": this.currentRating, "aria-valuetext": `${this.currentRating} out of ${this.stars}`, "aria-readonly": this.readonly ? 'true' : 'false', onKeyDown: this.keydownHandler, onBlur: this.blurHandler }, Array.from({ length: this.stars }).map((v, i) => (h("div", { key: `star-${v}`, "aria-hidden": "true", class: {
|
|
68
|
+
'star': true,
|
|
69
|
+
'before-hover': i < this.hoveredIndex,
|
|
70
|
+
'active': i < Math.round(this.currentRating),
|
|
71
|
+
'hover': i === this.hoveredIndex,
|
|
72
|
+
'after-active': i > this.hoveredIndex && i < this.currentRating,
|
|
73
|
+
}, onClick: () => this.update(i + 1), onMouseEnter: e => this.hoverHandler(i, e), onMouseLeave: e => this.hoverHandler(i, e) }, h("post-icon", { name: "2062", class: "stroke" }), h("post-icon", { name: "2574", class: "fill" })))))));
|
|
74
|
+
}
|
|
75
|
+
static get is() { return "post-rating"; }
|
|
76
|
+
static get encapsulation() { return "shadow"; }
|
|
77
|
+
static get originalStyleUrls() {
|
|
78
|
+
return {
|
|
79
|
+
"$": ["post-rating.scss"]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static get styleUrls() {
|
|
83
|
+
return {
|
|
84
|
+
"$": ["post-rating.css"]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static get properties() {
|
|
88
|
+
return {
|
|
89
|
+
"label": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"mutable": false,
|
|
92
|
+
"complexType": {
|
|
93
|
+
"original": "string",
|
|
94
|
+
"resolved": "string",
|
|
95
|
+
"references": {}
|
|
96
|
+
},
|
|
97
|
+
"required": false,
|
|
98
|
+
"optional": false,
|
|
99
|
+
"docs": {
|
|
100
|
+
"tags": [],
|
|
101
|
+
"text": "Defines a hidden label for the component."
|
|
102
|
+
},
|
|
103
|
+
"attribute": "label",
|
|
104
|
+
"reflect": false,
|
|
105
|
+
"defaultValue": "'Rating'"
|
|
106
|
+
},
|
|
107
|
+
"stars": {
|
|
108
|
+
"type": "number",
|
|
109
|
+
"mutable": false,
|
|
110
|
+
"complexType": {
|
|
111
|
+
"original": "number",
|
|
112
|
+
"resolved": "number",
|
|
113
|
+
"references": {}
|
|
114
|
+
},
|
|
115
|
+
"required": false,
|
|
116
|
+
"optional": false,
|
|
117
|
+
"docs": {
|
|
118
|
+
"tags": [],
|
|
119
|
+
"text": "Defines the total amount of stars rendered in the component."
|
|
120
|
+
},
|
|
121
|
+
"attribute": "stars",
|
|
122
|
+
"reflect": false,
|
|
123
|
+
"defaultValue": "5"
|
|
124
|
+
},
|
|
125
|
+
"currentRating": {
|
|
126
|
+
"type": "number",
|
|
127
|
+
"mutable": true,
|
|
128
|
+
"complexType": {
|
|
129
|
+
"original": "number",
|
|
130
|
+
"resolved": "number",
|
|
131
|
+
"references": {}
|
|
132
|
+
},
|
|
133
|
+
"required": false,
|
|
134
|
+
"optional": false,
|
|
135
|
+
"docs": {
|
|
136
|
+
"tags": [],
|
|
137
|
+
"text": "Defines the rating that the component should show."
|
|
138
|
+
},
|
|
139
|
+
"attribute": "current-rating",
|
|
140
|
+
"reflect": false,
|
|
141
|
+
"defaultValue": "0"
|
|
142
|
+
},
|
|
143
|
+
"readonly": {
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"mutable": false,
|
|
146
|
+
"complexType": {
|
|
147
|
+
"original": "boolean",
|
|
148
|
+
"resolved": "boolean",
|
|
149
|
+
"references": {}
|
|
150
|
+
},
|
|
151
|
+
"required": false,
|
|
152
|
+
"optional": false,
|
|
153
|
+
"docs": {
|
|
154
|
+
"tags": [],
|
|
155
|
+
"text": "Defines if the component is readonly or not.\nThis usually should be used together with the `currentRating` property."
|
|
156
|
+
},
|
|
157
|
+
"attribute": "readonly",
|
|
158
|
+
"reflect": false,
|
|
159
|
+
"defaultValue": "false"
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
static get states() {
|
|
164
|
+
return {
|
|
165
|
+
"hoveredIndex": {}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
static get events() {
|
|
169
|
+
return [{
|
|
170
|
+
"method": "input",
|
|
171
|
+
"name": "input",
|
|
172
|
+
"bubbles": true,
|
|
173
|
+
"cancelable": true,
|
|
174
|
+
"composed": true,
|
|
175
|
+
"docs": {
|
|
176
|
+
"tags": [],
|
|
177
|
+
"text": "An event emitted whenever the component's value has changed (on input).\nThe event payload can be used like so: `event.detail.value`."
|
|
178
|
+
},
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "{ value: number }",
|
|
181
|
+
"resolved": "{ value: number; }",
|
|
182
|
+
"references": {}
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
185
|
+
"method": "change",
|
|
186
|
+
"name": "change",
|
|
187
|
+
"bubbles": true,
|
|
188
|
+
"cancelable": true,
|
|
189
|
+
"composed": true,
|
|
190
|
+
"docs": {
|
|
191
|
+
"tags": [],
|
|
192
|
+
"text": "An event emitted whenever the component's value has changed (on blur).\nThe event payload can be used like so: `event.detail.value`."
|
|
193
|
+
},
|
|
194
|
+
"complexType": {
|
|
195
|
+
"original": "{ value: number }",
|
|
196
|
+
"resolved": "{ value: number; }",
|
|
197
|
+
"references": {}
|
|
198
|
+
}
|
|
199
|
+
}];
|
|
200
|
+
}
|
|
201
|
+
static get elementRef() { return "host"; }
|
|
202
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.tab-title[role=tab]{display:inline-block;position:relative;box-sizing:border-box;padding:1rem;transition:background-color 100ms;border-right:1px solid rgba(0,0,0,0);border-left:1px solid rgba(0,0,0,0);outline-color:currentColor;opacity:.7;color:var(--post-contrast-color);text-decoration:none}.tab-title[role=tab]:focus{background-color:unset;color:var(--post-contrast-color)}.tab-title[role=tab]:hover{opacity:1;background-color
|
|
1
|
+
.tab-title[role=tab]{display:inline-block;cursor:pointer;position:relative;box-sizing:border-box;padding:1rem;transition:background-color 100ms;border-right:1px solid rgba(0,0,0,0);border-left:1px solid rgba(0,0,0,0);outline-color:currentColor;opacity:.7;color:var(--post-contrast-color);text-decoration:none;background-color:var(--post-contrast-color-inverted)}.tab-title[role=tab]:focus{background-color:unset;color:var(--post-contrast-color)}.tab-title[role=tab]:hover{opacity:1;background-color:rgba(var(--post-contrast-color-rgb), 0.6);color:var(--post-contrast-color-inverted)}.tab-title[role=tab]:focus-visible{outline:rgba(0,0,0,0);opacity:1;background-color:rgba(var(--post-contrast-color-rgb), 0.6);color:var(--post-contrast-color-inverted);box-shadow:none}.tab-title[role=tab]:focus-visible::after{content:"";display:block;position:absolute;top:2px;right:1px;bottom:0;left:1px;box-shadow:0 0 0 1px #fff,0 0 0 2px #333}.tab-title[role=tab].active{z-index:1;border-right-color:#ccc;border-left-color:#ccc;opacity:1;background-color:var(--post-contrast-color-inverted);color:var(--post-contrast-color);font-weight:700}.tab-title[role=tab].active::before{content:"";display:block;position:absolute;top:0;right:-1px;left:-1px;height:.25rem;background-color:#fc0}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright,.bg-success-green,.bg-error-red) .tab-title[role=tab]:hover{background-color:rgba(255,255,255,.2)}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright,.bg-success-green,.bg-error-red) .tab-title[role=tab]:focus-visible{background-color:rgba(255,255,255,.2)}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.tab-title[role=tab]{opacity:1;border-left-color:Canvas;border-right-color:Canvas;color:LinkText}.tab-title[role=tab]:hover,.tab-title[role=tab]:focus,.tab-title[role=tab]:focus-within,.tab-title[role=tab]:focus-visible{outline:2px solid Highlight;outline-offset:-0.25rem}.tab-title[role=tab].active{border-left-color:ButtonText;border-right-color:ButtonText;color:Highlight}.tab-title[role=tab].active::before{background-color:Highlight}}.bg-yellow .tab-title{background-color:#fc0}.bg-yellow .tab-title.active{background-color:#fc0}.bg-yellow .nav-item{background-color:#fc0}.bg-light .tab-title{background-color:#faf9f8}.bg-light .tab-title.active{background-color:#faf9f8}.bg-light .nav-item{background-color:#faf9f8}.bg-gray .tab-title{background-color:#f4f3f1}.bg-gray .tab-title.active{background-color:#f4f3f1}.bg-gray .nav-item{background-color:#f4f3f1}.bg-dark .tab-title{background-color:#333}.bg-dark .tab-title.active{background-color:#333}.bg-dark .nav-item{background-color:#333}.bg-primary .tab-title{background-color:#333}.bg-primary .tab-title.active{background-color:#333}.bg-primary .nav-item{background-color:#333}.bg-white .tab-title{background-color:#fff}.bg-white .tab-title.active{background-color:#fff}.bg-white .nav-item{background-color:#fff}.bg-black .tab-title{background-color:#000}.bg-black .tab-title.active{background-color:#000}.bg-black .nav-item{background-color:#000}.bg-info .tab-title{background-color:#cce4ee}.bg-info .tab-title.active{background-color:#cce4ee}.bg-info .nav-item{background-color:#cce4ee}.bg-success .tab-title{background-color:#2c911c}.bg-success .tab-title.active{background-color:#2c911c}.bg-success .nav-item{background-color:#2c911c}.bg-warning .tab-title{background-color:#f49e00}.bg-warning .tab-title.active{background-color:#f49e00}.bg-warning .nav-item{background-color:#f49e00}.bg-danger .tab-title{background-color:#a51728}.bg-danger .tab-title.active{background-color:#a51728}.bg-danger .nav-item{background-color:#a51728}.bg-nightblue .tab-title{background-color:#004976}.bg-nightblue .tab-title.active{background-color:#004976}.bg-nightblue .nav-item{background-color:#004976}.bg-nightblue-bright .tab-title{background-color:#0076a8}.bg-nightblue-bright .tab-title.active{background-color:#0076a8}.bg-nightblue-bright .nav-item{background-color:#0076a8}.bg-petrol .tab-title{background-color:#006d68}.bg-petrol .tab-title.active{background-color:#006d68}.bg-petrol .nav-item{background-color:#006d68}.bg-petrol-bright .tab-title{background-color:#00968f}.bg-petrol-bright .tab-title.active{background-color:#00968f}.bg-petrol-bright .nav-item{background-color:#00968f}.bg-coral .tab-title{background-color:#9e2a2f}.bg-coral .tab-title.active{background-color:#9e2a2f}.bg-coral .nav-item{background-color:#9e2a2f}.bg-coral-bright .tab-title{background-color:#e03c31}.bg-coral-bright .tab-title.active{background-color:#e03c31}.bg-coral-bright .nav-item{background-color:#e03c31}.bg-olive .tab-title{background-color:#716135}.bg-olive .tab-title.active{background-color:#716135}.bg-olive .nav-item{background-color:#716135}.bg-olive-bright .tab-title{background-color:#aa9d2e}.bg-olive-bright .tab-title.active{background-color:#aa9d2e}.bg-olive-bright .nav-item{background-color:#aa9d2e}.bg-purple .tab-title{background-color:#80276c}.bg-purple .tab-title.active{background-color:#80276c}.bg-purple .nav-item{background-color:#80276c}.bg-purple-bright .tab-title{background-color:#c5299b}.bg-purple-bright .tab-title.active{background-color:#c5299b}.bg-purple-bright .nav-item{background-color:#c5299b}.bg-aubergine .tab-title{background-color:#523178}.bg-aubergine .tab-title.active{background-color:#523178}.bg-aubergine .nav-item{background-color:#523178}.bg-aubergine-bright .tab-title{background-color:#7566a0}.bg-aubergine-bright .tab-title.active{background-color:#7566a0}.bg-aubergine-bright .nav-item{background-color:#7566a0}.bg-success-green .tab-title{background-color:#2c871d}.bg-success-green .tab-title.active{background-color:#2c871d}.bg-success-green .nav-item{background-color:#2c871d}.bg-error-red .tab-title{background-color:#a51728}.bg-error-red .tab-title.active{background-color:#a51728}.bg-error-red .nav-item{background-color:#a51728}.bg-warning-orange .tab-title{background-color:#f49e00}.bg-warning-orange .tab-title.active{background-color:#f49e00}.bg-warning-orange .nav-item{background-color:#f49e00}.bg-success-background .tab-title{background-color:#c0debb}.bg-success-background .tab-title.active{background-color:#c0debb}.bg-success-background .nav-item{background-color:#c0debb}.bg-error-background .tab-title{background-color:#ffdade}.bg-error-background .tab-title.active{background-color:#ffdade}.bg-error-background .nav-item{background-color:#ffdade}.bg-warning-background .tab-title{background-color:#fce2b2}.bg-warning-background .tab-title.active{background-color:#fce2b2}.bg-warning-background .nav-item{background-color:#fce2b2}[class*=bg-] .tab-title.active:focus::after{background-color:rgba(255,255,255,.2)}@supports selector(*:focus-visible){[class*=bg-] .tab-title.active:focus::after{background-color:unset}[class*=bg-] .tab-title.active:focus-visible::after{background-color:rgba(255,255,255,.2)}}/*!
|
|
2
2
|
* Copyright 2021 by Swiss Post, Information Technology
|
|
3
3
|
*/:host{display:block}.tab-title{padding:0;overflow:visible;border:0;background:none;color:inherit;font:inherit;-webkit-user-select:none;user-select:none;-webkit-appearance:button;appearance:button}
|
|
@@ -16,7 +16,7 @@ export class PostTabHeader {
|
|
|
16
16
|
this.tabId = `tab-${this.host.id || crypto.randomUUID()}`;
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
return (h(Host, { key: '
|
|
19
|
+
return (h(Host, { key: '999ab8056178562bbcf615b03787451a946f8929', "data-version": version }, h("button", { key: '9795891344158c294f6d77a2245200108f1fe737', "aria-selected": "false", class: "tab-title", id: this.tabId, role: "tab", tabindex: "-1", type: "button" }, h("slot", { key: 'd62f2894e9bf89c00a9d5673cd47507ef7b26359' }))));
|
|
20
20
|
}
|
|
21
21
|
static get is() { return "post-tab-header"; }
|
|
22
22
|
static get encapsulation() { return "shadow"; }
|
|
@@ -13,7 +13,7 @@ export class PostTabPanel {
|
|
|
13
13
|
this.panelId = `panel-${this.host.id || crypto.randomUUID()}`;
|
|
14
14
|
}
|
|
15
15
|
render() {
|
|
16
|
-
return (h(Host, { key: '
|
|
16
|
+
return (h(Host, { key: '08148fe9b221905fbeab99bdb14f4d040deda959', "data-version": version }, h("div", { key: '04ad9fba5b296902fc75e0e36f7cefd91d0b6948', class: "tab-pane", id: this.panelId, role: "tabpanel" }, h("slot", { key: '840a5242e071f47b102340738f31b3f8b3c10052' }))));
|
|
17
17
|
}
|
|
18
18
|
static get is() { return "post-tab-panel"; }
|
|
19
19
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.tabs-wrapper{position:relative;padding-top:1rem;border:0;background-color
|
|
1
|
+
.tabs-wrapper{position:relative;padding-top:1rem;border:0;background-color:rgba(var(--post-contrast-color-rgb), 0.02)}.tabs-wrapper::after{content:"";position:absolute;bottom:0;width:100%;height:1px;background-color:#ccc}.tabs-wrapper .tabs{background-color:rgba(0,0,0,0) !important}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.tabs-wrapper::after{background-color:ButtonBorder}}.tabs{margin:0;padding:0;list-style:none;display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;white-space:nowrap}.tabs::after{content:"";display:block;flex:1 0 auto;width:1rem}.tab-content{padding-top:1rem}.bg-yellow .tabs-wrapper{background-color:#fc0}.bg-light .tabs-wrapper{background-color:#faf9f8}.bg-gray .tabs-wrapper{background-color:#f4f3f1}.bg-dark .tabs-wrapper{background-color:#333}.bg-primary .tabs-wrapper{background-color:#333}.bg-white .tabs-wrapper{background-color:#fff}.bg-black .tabs-wrapper{background-color:#000}.bg-info .tabs-wrapper{background-color:#cce4ee}.bg-success .tabs-wrapper{background-color:#2c911c}.bg-warning .tabs-wrapper{background-color:#f49e00}.bg-danger .tabs-wrapper{background-color:#a51728}.bg-nightblue .tabs-wrapper{background-color:#004976}.bg-nightblue-bright .tabs-wrapper{background-color:#0076a8}.bg-petrol .tabs-wrapper{background-color:#006d68}.bg-petrol-bright .tabs-wrapper{background-color:#00968f}.bg-coral .tabs-wrapper{background-color:#9e2a2f}.bg-coral-bright .tabs-wrapper{background-color:#e03c31}.bg-olive .tabs-wrapper{background-color:#716135}.bg-olive-bright .tabs-wrapper{background-color:#aa9d2e}.bg-purple .tabs-wrapper{background-color:#80276c}.bg-purple-bright .tabs-wrapper{background-color:#c5299b}.bg-aubergine .tabs-wrapper{background-color:#523178}.bg-aubergine-bright .tabs-wrapper{background-color:#7566a0}.bg-success-green .tabs-wrapper{background-color:#2c871d}.bg-error-red .tabs-wrapper{background-color:#a51728}.bg-warning-orange .tabs-wrapper{background-color:#f49e00}.bg-success-background .tabs-wrapper{background-color:#c0debb}.bg-error-background .tabs-wrapper{background-color:#ffdade}.bg-warning-background .tabs-wrapper{background-color:#fce2b2}:host{display:block}
|
|
@@ -139,7 +139,7 @@ export class PostTabs {
|
|
|
139
139
|
nextTabTitle.focus();
|
|
140
140
|
}
|
|
141
141
|
render() {
|
|
142
|
-
return (h(Host, { key: '
|
|
142
|
+
return (h(Host, { key: '474b7d00c23aec2a44a202c09b8a75a9dc12b4a8', "data-version": version }, h("div", { key: '2fe1b6cad96fd868cbaa7e775d185537a37228fd', class: "tabs-wrapper" }, h("div", { key: 'ef70af3ddd337cefb719d183d603eb93fb033e25', class: "tabs", role: "tablist" }, h("slot", { key: '360909ea07bbbca523cb21b71daa8b4b02f60bed', name: "tabs", onSlotchange: () => this.enableTabs() }))), h("div", { key: 'ba44b0e8484e63d9b48f66933f37d854eb648854', class: "tab-content" }, h("slot", { key: 'cd22488448be508393fcb9f9428d3f712c9b659b', onSlotchange: () => this.moveMisplacedTabs() }))));
|
|
143
143
|
}
|
|
144
144
|
static get is() { return "post-tabs"; }
|
|
145
145
|
static get encapsulation() { return "shadow"; }
|
|
@@ -2,6 +2,7 @@ import { h, Host } from "@stencil/core";
|
|
|
2
2
|
import { version } from "../../../package.json";
|
|
3
3
|
import isFocusable from "ally.js/is/focusable";
|
|
4
4
|
import "long-press-event";
|
|
5
|
+
import { getAttributeObserver } from "../../utils/attribute-observer";
|
|
5
6
|
/**
|
|
6
7
|
* @slot default - Slot for the content of the tooltip.
|
|
7
8
|
*/
|
|
@@ -10,6 +11,7 @@ import "long-press-event";
|
|
|
10
11
|
*/
|
|
11
12
|
let tooltipInstances = 0;
|
|
12
13
|
let hideTooltipTimeout = null;
|
|
14
|
+
const tooltipTargetAttribute = 'data-tooltip-target';
|
|
13
15
|
/**
|
|
14
16
|
* Global event listener to show tooltips. This is globalized so that triggers that are rendered
|
|
15
17
|
* async will still work without the need to set listeners on the element itself
|
|
@@ -18,9 +20,9 @@ let hideTooltipTimeout = null;
|
|
|
18
20
|
*/
|
|
19
21
|
const globalInterestHandler = (e) => {
|
|
20
22
|
const target = e.target;
|
|
21
|
-
if (!
|
|
23
|
+
if (!target || !('getAttribute' in target))
|
|
22
24
|
return;
|
|
23
|
-
const tooltipTarget = target.getAttribute(
|
|
25
|
+
const tooltipTarget = target.getAttribute(tooltipTargetAttribute);
|
|
24
26
|
if (!tooltipTarget || tooltipTarget === '')
|
|
25
27
|
return;
|
|
26
28
|
const tooltip = document.getElementById(tooltipTarget);
|
|
@@ -38,7 +40,7 @@ const globalInterestHandler = (e) => {
|
|
|
38
40
|
*/
|
|
39
41
|
const globalInterestLostHandler = (e) => {
|
|
40
42
|
const target = e.target;
|
|
41
|
-
const tooltipTarget = target.getAttribute(
|
|
43
|
+
const tooltipTarget = target.getAttribute(tooltipTargetAttribute);
|
|
42
44
|
if (!tooltipTarget || tooltipTarget === '')
|
|
43
45
|
return;
|
|
44
46
|
const tooltip = document.getElementById(tooltipTarget);
|
|
@@ -61,7 +63,7 @@ const globalHideTooltip = (tooltip) => {
|
|
|
61
63
|
*/
|
|
62
64
|
const patchAccessibilityFeatures = (trigger) => {
|
|
63
65
|
const describedBy = trigger.getAttribute('aria-describedby');
|
|
64
|
-
const id = trigger.getAttribute(
|
|
66
|
+
const id = trigger.getAttribute(tooltipTargetAttribute);
|
|
65
67
|
// Add tooltip to aria-describedby
|
|
66
68
|
if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(id))) {
|
|
67
69
|
const newDescribedBy = describedBy ? `${describedBy} ${id}` : id;
|
|
@@ -72,27 +74,8 @@ const patchAccessibilityFeatures = (trigger) => {
|
|
|
72
74
|
trigger.setAttribute('tabindex', '0');
|
|
73
75
|
}
|
|
74
76
|
};
|
|
75
|
-
/**
|
|
76
|
-
* Handle attribute changes and childList changes from the observer
|
|
77
|
-
* @param {MutationRecord[]} mutationList
|
|
78
|
-
*/
|
|
79
|
-
const triggerObserverHandler = mutationList => {
|
|
80
|
-
mutationList.forEach(mutation => {
|
|
81
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'data-tooltip-target') {
|
|
82
|
-
patchAccessibilityFeatures(mutation.target);
|
|
83
|
-
}
|
|
84
|
-
if (mutation.type === 'childList') {
|
|
85
|
-
mutation.addedNodes.forEach(node => {
|
|
86
|
-
if (node.nodeType === Node.ELEMENT_NODE &&
|
|
87
|
-
node.hasAttribute('data-tooltip-target')) {
|
|
88
|
-
patchAccessibilityFeatures(node);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
77
|
// Initialize a mutation observer for patching accessibility features
|
|
95
|
-
const triggerObserver =
|
|
78
|
+
const triggerObserver = getAttributeObserver(tooltipTargetAttribute, patchAccessibilityFeatures);
|
|
96
79
|
export class PostTooltip {
|
|
97
80
|
constructor() {
|
|
98
81
|
this.placement = 'top';
|
|
@@ -123,7 +106,7 @@ export class PostTooltip {
|
|
|
123
106
|
triggerObserver.observe(document.body, {
|
|
124
107
|
subtree: true,
|
|
125
108
|
childList: true,
|
|
126
|
-
attributeFilter: [
|
|
109
|
+
attributeFilter: [tooltipTargetAttribute],
|
|
127
110
|
});
|
|
128
111
|
}
|
|
129
112
|
tooltipInstances++;
|
|
@@ -182,7 +165,7 @@ export class PostTooltip {
|
|
|
182
165
|
}
|
|
183
166
|
render() {
|
|
184
167
|
const popoverClass = `${this.arrow ? ' has-arrow' : ''}`;
|
|
185
|
-
return (h(Host, { key: '
|
|
168
|
+
return (h(Host, { key: '63124ebabffbe5fe857bcc61eecf4133f2952e85', "data-version": version, role: "tooltip", onPointerOver: this.handleInterest, onPointerOut: this.handleInterestLost, onFocusIn: this.handleInterest, onFocusOut: this.handleInterestLost }, h("post-popovercontainer", { key: '42e1b5e0ab8cbb3a1b805ccf5b40232b071cf5ad', class: popoverClass, arrow: this.arrow, placement: this.placement, ref: (el) => (this.popoverRef = el) }, h("slot", { key: 'bf414a19c044f3c608ab3141bb93736dd7dea723' }))));
|
|
186
169
|
}
|
|
187
170
|
static get is() { return "post-tooltip"; }
|
|
188
171
|
static get encapsulation() { return "shadow"; }
|
package/dist/collection/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { PostCollapsible } from './components/post-collapsible/post-collapsible'
|
|
|
6
6
|
export { PostIcon } from './components/post-icon/post-icon';
|
|
7
7
|
export { PostPopover } from './components/post-popover/post-popover';
|
|
8
8
|
export { PostPopovercontainer } from './components/post-popovercontainer/post-popovercontainer';
|
|
9
|
+
export { PostRating } from './components/post-rating/post-rating';
|
|
9
10
|
export { PostTabs } from './components/post-tabs/post-tabs';
|
|
10
11
|
export { PostTabHeader } from './components/post-tab-header/post-tab-header';
|
|
11
12
|
export { PostTabPanel } from './components/post-tab-panel/post-tab-panel';
|