@getflip/swirl-components 0.391.0 → 0.392.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/components.json +30 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{media-query.service-BcAHijM-.js → media-query.service-B8u-DqoO.js} +1 -1
- package/dist/cjs/swirl-action-list_2.cjs.entry.js +2 -2
- package/dist/cjs/swirl-app-layout_5.cjs.entry.js +2 -2
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
- package/dist/cjs/swirl-banner.cjs.entry.js +2 -2
- package/dist/cjs/swirl-button.cjs.entry.js +2 -2
- package/dist/cjs/swirl-carousel.cjs.entry.js +1 -1
- package/dist/cjs/swirl-chip.cjs.entry.js +2 -2
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-console-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-date-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-date-picker_2.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-chip.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-viewer_8.cjs.entry.js +1 -1
- package/dist/cjs/swirl-form-control.cjs.entry.js +1 -1
- package/dist/cjs/swirl-icon-error_3.cjs.entry.js +2 -2
- package/dist/cjs/swirl-image-grid-item.cjs.entry.js +1 -1
- package/dist/cjs/swirl-inline-status.cjs.entry.js +2 -2
- package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
- package/dist/cjs/swirl-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/swirl-menu.cjs.entry.js +1 -1
- package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
- package/dist/cjs/swirl-option-list_2.cjs.entry.js +2 -2
- package/dist/cjs/swirl-pagination.cjs.entry.js +1 -1
- package/dist/cjs/swirl-pdf-reader.cjs.entry.js +1 -1
- package/dist/cjs/swirl-popover_2.cjs.entry.js +1 -1
- package/dist/cjs/swirl-resource-list-file-item.cjs.entry.js +2 -2
- package/dist/cjs/swirl-search.cjs.entry.js +2 -2
- package/dist/cjs/swirl-select.cjs.entry.js +1 -1
- package/dist/cjs/swirl-shell-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tab-bar.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-column.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-row.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tabs.cjs.entry.js +1 -1
- package/dist/cjs/swirl-text-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-time-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-toast.cjs.entry.js +2 -2
- package/dist/cjs/swirl-toolbar.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tooltip.cjs.entry.js +36 -10
- package/dist/cjs/{utils-CllbYlRY.js → utils-UfZG-xPD.js} +6 -0
- package/dist/collection/components/swirl-tooltip/swirl-tooltip.css +5 -0
- package/dist/collection/components/swirl-tooltip/swirl-tooltip.js +57 -10
- package/dist/collection/utils.js +5 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.mjs +4 -1
- package/dist/components/media-query.service.js +1 -1
- package/dist/components/swirl-tooltip2.js +39 -11
- package/dist/components/utils.js +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{media-query.service-CpP-qu5C.js → media-query.service-BZg4zbFx.js} +1 -1
- package/dist/esm/swirl-action-list_2.entry.js +2 -2
- package/dist/esm/swirl-app-layout_5.entry.js +2 -2
- package/dist/esm/swirl-autocomplete.entry.js +1 -1
- package/dist/esm/swirl-banner.entry.js +2 -2
- package/dist/esm/swirl-button.entry.js +2 -2
- package/dist/esm/swirl-carousel.entry.js +1 -1
- package/dist/esm/swirl-chip.entry.js +2 -2
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-console-layout.entry.js +1 -1
- package/dist/esm/swirl-date-input.entry.js +2 -2
- package/dist/esm/swirl-date-picker_2.entry.js +1 -1
- package/dist/esm/swirl-file-chip.entry.js +1 -1
- package/dist/esm/swirl-file-viewer_8.entry.js +1 -1
- package/dist/esm/swirl-form-control.entry.js +1 -1
- package/dist/esm/swirl-icon-error_3.entry.js +2 -2
- package/dist/esm/swirl-image-grid-item.entry.js +1 -1
- package/dist/esm/swirl-inline-status.entry.js +2 -2
- package/dist/esm/swirl-lightbox.entry.js +1 -1
- package/dist/esm/swirl-menu-item.entry.js +1 -1
- package/dist/esm/swirl-menu.entry.js +1 -1
- package/dist/esm/swirl-modal.entry.js +1 -1
- package/dist/esm/swirl-option-list_2.entry.js +2 -2
- package/dist/esm/swirl-pagination.entry.js +1 -1
- package/dist/esm/swirl-pdf-reader.entry.js +1 -1
- package/dist/esm/swirl-popover_2.entry.js +1 -1
- package/dist/esm/swirl-resource-list-file-item.entry.js +2 -2
- package/dist/esm/swirl-search.entry.js +2 -2
- package/dist/esm/swirl-select.entry.js +1 -1
- package/dist/esm/swirl-shell-layout.entry.js +1 -1
- package/dist/esm/swirl-tab-bar.entry.js +1 -1
- package/dist/esm/swirl-table-column.entry.js +1 -1
- package/dist/esm/swirl-table-row.entry.js +1 -1
- package/dist/esm/swirl-table.entry.js +1 -1
- package/dist/esm/swirl-tabs.entry.js +1 -1
- package/dist/esm/swirl-text-input.entry.js +2 -2
- package/dist/esm/swirl-time-input.entry.js +2 -2
- package/dist/esm/swirl-toast.entry.js +2 -2
- package/dist/esm/swirl-toolbar.entry.js +1 -1
- package/dist/esm/swirl-tooltip.entry.js +36 -10
- package/dist/esm/{utils-DytJsmhr.js → utils-wi_3Z3FQ.js} +6 -1
- package/dist/swirl-components/{p-84522af5.entry.js → p-08096eb7.entry.js} +1 -1
- package/dist/swirl-components/{p-7eaa0fa6.entry.js → p-0f996944.entry.js} +1 -1
- package/dist/swirl-components/{p-d9d2d3cd.entry.js → p-19dadeeb.entry.js} +1 -1
- package/dist/swirl-components/{p-27a2334e.entry.js → p-1a298d4a.entry.js} +1 -1
- package/dist/swirl-components/{p-2fae365b.entry.js → p-1b8edbad.entry.js} +1 -1
- package/dist/swirl-components/{p-744bb10c.entry.js → p-2ba77bbd.entry.js} +1 -1
- package/dist/swirl-components/{p-41514546.entry.js → p-3a51cd1d.entry.js} +1 -1
- package/dist/swirl-components/{p-81b2e380.entry.js → p-3cb860e0.entry.js} +1 -1
- package/dist/swirl-components/{p-0da2362d.entry.js → p-3ff37617.entry.js} +1 -1
- package/dist/swirl-components/{p-922134b6.entry.js → p-40d6a295.entry.js} +1 -1
- package/dist/swirl-components/{p-2a61a410.entry.js → p-488cfc82.entry.js} +1 -1
- package/dist/swirl-components/{p-81ee71b8.entry.js → p-492d52f6.entry.js} +1 -1
- package/dist/swirl-components/{p-bfa2491e.entry.js → p-59116473.entry.js} +1 -1
- package/dist/swirl-components/{p-2a285267.entry.js → p-5b34a195.entry.js} +1 -1
- package/dist/swirl-components/{p-1182eb75.entry.js → p-5c5c2a10.entry.js} +1 -1
- package/dist/swirl-components/{p-fc502f05.entry.js → p-5d81e853.entry.js} +1 -1
- package/dist/swirl-components/{p-b9a299b9.entry.js → p-6d325fa7.entry.js} +1 -1
- package/dist/swirl-components/{p-192e260b.entry.js → p-6e55cabe.entry.js} +1 -1
- package/dist/swirl-components/{p-f28a4f8e.entry.js → p-74aa7188.entry.js} +1 -1
- package/dist/swirl-components/{p-042ee5d4.entry.js → p-7bc63fc2.entry.js} +1 -1
- package/dist/swirl-components/{p-8acdbcb3.entry.js → p-7f4e05df.entry.js} +1 -1
- package/dist/swirl-components/{p-1531276b.entry.js → p-92fb5c55.entry.js} +1 -1
- package/dist/swirl-components/{p-180ed63e.entry.js → p-971f8aa4.entry.js} +1 -1
- package/dist/swirl-components/{p-fb5079da.entry.js → p-9b0a52d8.entry.js} +1 -1
- package/dist/swirl-components/{p-7a9af724.entry.js → p-9d829bc6.entry.js} +1 -1
- package/dist/swirl-components/{p-DJ2FyZeW.js → p-BKpD2IO9.js} +1 -1
- package/dist/swirl-components/{p-64e4d854.entry.js → p-ab26446b.entry.js} +1 -1
- package/dist/swirl-components/{p-350a5b37.entry.js → p-acf964f6.entry.js} +1 -1
- package/dist/swirl-components/{p-6a4c15e4.entry.js → p-b1926a98.entry.js} +1 -1
- package/dist/swirl-components/{p-84535964.entry.js → p-b674e398.entry.js} +1 -1
- package/dist/swirl-components/{p-c8e30ded.entry.js → p-b80acce3.entry.js} +1 -1
- package/dist/swirl-components/{p-6f8ef29e.entry.js → p-bf1ed31d.entry.js} +1 -1
- package/dist/swirl-components/{p-0d5171f8.entry.js → p-bf4d2ac3.entry.js} +1 -1
- package/dist/swirl-components/{p-e872b698.entry.js → p-c31d13e2.entry.js} +1 -1
- package/dist/swirl-components/{p-441c94ba.entry.js → p-d92888a6.entry.js} +1 -1
- package/dist/swirl-components/{p-57dfce0c.entry.js → p-eaa660fd.entry.js} +1 -1
- package/dist/swirl-components/{p-157e2343.entry.js → p-ebac4d1b.entry.js} +1 -1
- package/dist/swirl-components/{p-750914d8.entry.js → p-f1b42a86.entry.js} +1 -1
- package/dist/swirl-components/p-f38f71c9.entry.js +1 -0
- package/dist/swirl-components/{p-DytJsmhr.js → p-wi_3Z3FQ.js} +1 -1
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-tooltip/swirl-tooltip.d.ts +7 -0
- package/dist/types/components.d.ts +10 -0
- package/dist/types/utils.d.ts +1 -0
- package/package.json +1 -1
- package/vscode-data.json +4 -0
- package/dist/swirl-components/p-eef34c13.entry.js +0 -1
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
var index = require('./index-DM-IG6w2.js');
|
|
4
4
|
var floatingUi_dom_browser_min = require('./floating-ui.dom.browser.min-PA1q-Uql.js');
|
|
5
5
|
var index$1 = require('./index-DcAhLZUH.js');
|
|
6
|
+
var utils = require('./utils-UfZG-xPD.js');
|
|
6
7
|
|
|
7
|
-
const swirlTooltipCss = ":host{display:contents;font-weight:var(--s-font-weight-normal)}:host *{box-sizing:border-box}.tooltip{display:contents}.tooltip--active .tooltip__popper{display:block}.tooltip--visible .tooltip__popper{animation:tooltip-fade-in 0.15s;animation-delay:0.1s;animation-fill-mode:forwards;opacity:0}.tooltip--actual-placement-top .tooltip__arrow{top:calc(100% - 0.0625rem);transform:translate3d(0, -50%, 0) rotate(45deg)}.tooltip--actual-placement-bottom .tooltip__arrow{bottom:calc(100% - 0.0625rem);transform:translate3d(0, 50%, 0) rotate(45deg)}.tooltip--actual-placement-left .tooltip__arrow{left:calc(100% - 0.0625rem);transform:translate3d(-50%, 0, 0) rotate(45deg)}.tooltip--actual-placement-right .tooltip__arrow{right:calc(100% - 0.0625rem);transform:translate3d(50%, 0, 0) rotate(45deg)}.tooltip .tooltip__reference{display:contents}.tooltip__popper{position:absolute;z-index:var(--s-z-40);display:none;max-width:17.5rem;opacity:0}.tooltip__bubble{position:relative;display:block;padding-top:var(--s-space-8);padding-right:var(--s-space-12);padding-bottom:calc(var(--s-space-8) + 0.0625rem);padding-left:var(--s-space-12);border-radius:var(--s-border-radius-sm);color:var(--s-text-on-status);background-color:var(--s-surface-neutral-default);line-height:var(--s-line-height-base);box-shadow:var(--s-shadow-level-2)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.tooltip__bubble{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.tooltip__content{white-space:normal}.tooltip__arrow{position:absolute;width:0.6875rem;height:0.6875rem;border-radius:0.125rem;background-color:var(--s-surface-neutral-default)}@keyframes tooltip-fade-in{from{opacity:0}to{opacity:1}}";
|
|
8
|
+
const swirlTooltipCss = ":host{display:contents;font-weight:var(--s-font-weight-normal)}:host *{box-sizing:border-box}.tooltip{display:contents}.tooltip--active .tooltip__popper{display:block}.tooltip--visible .tooltip__popper{animation:tooltip-fade-in 0.15s;animation-delay:0.1s;animation-fill-mode:forwards;opacity:0}.tooltip--actual-placement-top .tooltip__arrow{top:calc(100% - 0.0625rem);transform:translate3d(0, -50%, 0) rotate(45deg)}.tooltip--actual-placement-bottom .tooltip__arrow{bottom:calc(100% - 0.0625rem);transform:translate3d(0, 50%, 0) rotate(45deg)}.tooltip--actual-placement-left .tooltip__arrow{left:calc(100% - 0.0625rem);transform:translate3d(-50%, 0, 0) rotate(45deg)}.tooltip--actual-placement-right .tooltip__arrow{right:calc(100% - 0.0625rem);transform:translate3d(50%, 0, 0) rotate(45deg)}.tooltip .tooltip__reference{display:contents}.tooltip__popper{position:absolute;z-index:var(--s-z-40);display:none;max-width:17.5rem;opacity:0}.tooltip__bubble{position:relative;display:block;padding-top:var(--s-space-8);padding-right:var(--s-space-12);padding-bottom:calc(var(--s-space-8) + 0.0625rem);padding-left:var(--s-space-12);border-radius:var(--s-border-radius-sm);color:var(--s-text-on-status);background-color:var(--s-surface-neutral-default);line-height:var(--s-line-height-base);box-shadow:var(--s-shadow-level-2)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.tooltip__bubble{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.tooltip__content{white-space:normal}.tooltip__arrow{position:absolute;width:0.6875rem;height:0.6875rem;border-radius:0.125rem;background-color:var(--s-surface-neutral-default)}.tooltip--promo .tooltip__bubble,.tooltip--promo .tooltip__arrow{background-color:var(--s-surface-info-default)}@keyframes tooltip-fade-in{from{opacity:0}to{opacity:1}}";
|
|
8
9
|
|
|
9
10
|
const SwirlTooltip = class {
|
|
10
11
|
constructor(hostRef) {
|
|
@@ -13,9 +14,16 @@ const SwirlTooltip = class {
|
|
|
13
14
|
this.delay = 200;
|
|
14
15
|
this.position = "top";
|
|
15
16
|
this.positioning = "absolute";
|
|
17
|
+
/**
|
|
18
|
+
* If set to true, tooltip will be initially visible.
|
|
19
|
+
* It will only be dismissible via a click and will not reappear.
|
|
20
|
+
* Tooltip will have a blue background color.
|
|
21
|
+
*/
|
|
22
|
+
this.isPromo = false;
|
|
16
23
|
this.visible = false;
|
|
24
|
+
this.isPromoShown = false;
|
|
17
25
|
this.onKeydown = (event) => {
|
|
18
|
-
if (event.code === "Escape") {
|
|
26
|
+
if (event.code === "Escape" && !this.isPromo) {
|
|
19
27
|
this.hide();
|
|
20
28
|
}
|
|
21
29
|
};
|
|
@@ -37,7 +45,7 @@ const SwirlTooltip = class {
|
|
|
37
45
|
};
|
|
38
46
|
};
|
|
39
47
|
this.show = () => {
|
|
40
|
-
if (!this.active) {
|
|
48
|
+
if (!this.active || (this.isPromo && this.isPromoShown)) {
|
|
41
49
|
return;
|
|
42
50
|
}
|
|
43
51
|
this.visible = true;
|
|
@@ -71,11 +79,22 @@ const SwirlTooltip = class {
|
|
|
71
79
|
this.disableAutoUpdate?.();
|
|
72
80
|
};
|
|
73
81
|
this.updateOptions = () => {
|
|
74
|
-
const margin =
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
const margin = utils.getPixelsFromRemToken("--s-space-12");
|
|
83
|
+
const shiftPaddingY = utils.getPixelsFromRemToken("--s-space-8");
|
|
84
|
+
const shiftPaddingX = utils.getPixelsFromRemToken("--s-space-16");
|
|
77
85
|
this.options = {
|
|
78
|
-
middleware: [
|
|
86
|
+
middleware: [
|
|
87
|
+
floatingUi_dom_browser_min.D(margin),
|
|
88
|
+
floatingUi_dom_browser_min.k({
|
|
89
|
+
padding: {
|
|
90
|
+
top: shiftPaddingY,
|
|
91
|
+
bottom: shiftPaddingY,
|
|
92
|
+
left: shiftPaddingX,
|
|
93
|
+
right: shiftPaddingX,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
floatingUi_dom_browser_min.b(),
|
|
97
|
+
],
|
|
79
98
|
placement: this.position,
|
|
80
99
|
strategy: this.positioning,
|
|
81
100
|
};
|
|
@@ -88,7 +107,9 @@ const SwirlTooltip = class {
|
|
|
88
107
|
this.showWithDelay();
|
|
89
108
|
}
|
|
90
109
|
onMouseLeave() {
|
|
91
|
-
this.
|
|
110
|
+
if (!this.isPromo) {
|
|
111
|
+
this.hide();
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
onWindowResize() {
|
|
94
115
|
if (!this.active) {
|
|
@@ -107,13 +128,18 @@ const SwirlTooltip = class {
|
|
|
107
128
|
}
|
|
108
129
|
componentDidLoad() {
|
|
109
130
|
this.updateOptions();
|
|
131
|
+
if (this.isPromo) {
|
|
132
|
+
this.show();
|
|
133
|
+
this.isPromoShown = true;
|
|
134
|
+
}
|
|
110
135
|
}
|
|
111
136
|
render() {
|
|
112
137
|
const className = index$1.classnames("tooltip", `tooltip--actual-placement-${this.actualPosition?.placement}`, {
|
|
113
138
|
"tooltip--active": this.active,
|
|
114
139
|
"tooltip--visible": this.visible,
|
|
140
|
+
"tooltip--promo": this.isPromo,
|
|
115
141
|
});
|
|
116
|
-
return (index.h(index.Host, { key: '
|
|
142
|
+
return (index.h(index.Host, { key: '0fa9404559103428ce19831a0b45a5330d00c9fa', onKeydown: this.onKeydown }, index.h("span", { key: '3602318c40723c65c318cef0254dab0161439cc6', class: className }, index.h("span", { key: 'a9aaf081590bcf01ad2c82c99b8ea10bc9b8f8a5', class: "tooltip__reference", "aria-describedby": "tooltip", onFocusout: !this.isPromo && this.hide, onClick: this.hide, onFocusin: this.show }, index.h("slot", { key: '73ad565e8b91925bba6fcb490b542d74890926c1' })), index.h("span", { key: 'bd84b556b64f4d24f2064d00556070af818524f5', class: "tooltip__popper", ref: (el) => (this.popperEl = el), style: {
|
|
117
143
|
top: Boolean(this.actualPosition)
|
|
118
144
|
? `${this.actualPosition?.y}px`
|
|
119
145
|
: "",
|
|
@@ -121,7 +147,7 @@ const SwirlTooltip = class {
|
|
|
121
147
|
? `${this.actualPosition?.x}px`
|
|
122
148
|
: "",
|
|
123
149
|
position: this.positioning,
|
|
124
|
-
} }, this.visible && (index.h("span", { key: '
|
|
150
|
+
} }, this.visible && (index.h("span", { key: '41fb5ef06491bfaf355d3fd5a98e00a92cd75a92', class: "tooltip__bubble", id: "tooltip", part: "tooltip__bubble", role: "tooltip" }, index.h("span", { key: 'a6a22b0bc86e87f2c7728fc3888ef109a8b9be8c', class: "tooltip__content", innerHTML: this.content }))), index.h("span", { key: 'b036d30ba31fbf5b4c8519b229aed70f20509874', class: "tooltip__arrow", ref: (el) => (this.arrowElement = el), style: {
|
|
125
151
|
...this.arrowStyles,
|
|
126
152
|
visibility: this.visible ? "visible" : "hidden",
|
|
127
153
|
} })))));
|
|
@@ -184,6 +184,11 @@ function isDocumentMimeType(mimeType) {
|
|
|
184
184
|
mimeType.startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.document") ||
|
|
185
185
|
mimeType.startsWith("application/vnd.apple.pages"));
|
|
186
186
|
}
|
|
187
|
+
function getPixelsFromRemToken(token) {
|
|
188
|
+
return (+getComputedStyle(document.documentElement)
|
|
189
|
+
.getPropertyValue(token)
|
|
190
|
+
.replace("rem", "") * 16);
|
|
191
|
+
}
|
|
187
192
|
|
|
188
193
|
exports.closestPassShadow = closestPassShadow;
|
|
189
194
|
exports.debounce = debounce;
|
|
@@ -191,6 +196,7 @@ exports.getActiveElement = getActiveElement;
|
|
|
191
196
|
exports.getCircularArrayIndex = getCircularArrayIndex;
|
|
192
197
|
exports.getDesktopMediaQuery = getDesktopMediaQuery;
|
|
193
198
|
exports.getISODateString = getISODateString;
|
|
199
|
+
exports.getPixelsFromRemToken = getPixelsFromRemToken;
|
|
194
200
|
exports.getVisibleHeight = getVisibleHeight;
|
|
195
201
|
exports.isAudioMimeType = isAudioMimeType;
|
|
196
202
|
exports.isCompressedArchiveMimeType = isCompressedArchiveMimeType;
|
|
@@ -88,6 +88,11 @@
|
|
|
88
88
|
background-color: var(--s-surface-neutral-default);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
.tooltip--promo .tooltip__bubble,
|
|
92
|
+
.tooltip--promo .tooltip__arrow {
|
|
93
|
+
background-color: var(--s-surface-info-default);
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
@keyframes tooltip-fade-in {
|
|
92
97
|
from {
|
|
93
98
|
opacity: 0;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { arrow, autoUpdate, computePosition, flip, offset, shift, } from "@floating-ui/dom";
|
|
2
2
|
import { h, Host, } from "@stencil/core";
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
+
import { getPixelsFromRemToken } from "../../utils";
|
|
4
5
|
export class SwirlTooltip {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.active = true;
|
|
7
8
|
this.delay = 200;
|
|
8
9
|
this.position = "top";
|
|
9
10
|
this.positioning = "absolute";
|
|
11
|
+
/**
|
|
12
|
+
* If set to true, tooltip will be initially visible.
|
|
13
|
+
* It will only be dismissible via a click and will not reappear.
|
|
14
|
+
* Tooltip will have a blue background color.
|
|
15
|
+
*/
|
|
16
|
+
this.isPromo = false;
|
|
10
17
|
this.visible = false;
|
|
18
|
+
this.isPromoShown = false;
|
|
11
19
|
this.onKeydown = (event) => {
|
|
12
|
-
if (event.code === "Escape") {
|
|
20
|
+
if (event.code === "Escape" && !this.isPromo) {
|
|
13
21
|
this.hide();
|
|
14
22
|
}
|
|
15
23
|
};
|
|
@@ -31,7 +39,7 @@ export class SwirlTooltip {
|
|
|
31
39
|
};
|
|
32
40
|
};
|
|
33
41
|
this.show = () => {
|
|
34
|
-
if (!this.active) {
|
|
42
|
+
if (!this.active || (this.isPromo && this.isPromoShown)) {
|
|
35
43
|
return;
|
|
36
44
|
}
|
|
37
45
|
this.visible = true;
|
|
@@ -65,11 +73,22 @@ export class SwirlTooltip {
|
|
|
65
73
|
this.disableAutoUpdate?.();
|
|
66
74
|
};
|
|
67
75
|
this.updateOptions = () => {
|
|
68
|
-
const margin =
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
const margin = getPixelsFromRemToken("--s-space-12");
|
|
77
|
+
const shiftPaddingY = getPixelsFromRemToken("--s-space-8");
|
|
78
|
+
const shiftPaddingX = getPixelsFromRemToken("--s-space-16");
|
|
71
79
|
this.options = {
|
|
72
|
-
middleware: [
|
|
80
|
+
middleware: [
|
|
81
|
+
offset(margin),
|
|
82
|
+
shift({
|
|
83
|
+
padding: {
|
|
84
|
+
top: shiftPaddingY,
|
|
85
|
+
bottom: shiftPaddingY,
|
|
86
|
+
left: shiftPaddingX,
|
|
87
|
+
right: shiftPaddingX,
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
flip(),
|
|
91
|
+
],
|
|
73
92
|
placement: this.position,
|
|
74
93
|
strategy: this.positioning,
|
|
75
94
|
};
|
|
@@ -82,7 +101,9 @@ export class SwirlTooltip {
|
|
|
82
101
|
this.showWithDelay();
|
|
83
102
|
}
|
|
84
103
|
onMouseLeave() {
|
|
85
|
-
this.
|
|
104
|
+
if (!this.isPromo) {
|
|
105
|
+
this.hide();
|
|
106
|
+
}
|
|
86
107
|
}
|
|
87
108
|
onWindowResize() {
|
|
88
109
|
if (!this.active) {
|
|
@@ -101,13 +122,18 @@ export class SwirlTooltip {
|
|
|
101
122
|
}
|
|
102
123
|
componentDidLoad() {
|
|
103
124
|
this.updateOptions();
|
|
125
|
+
if (this.isPromo) {
|
|
126
|
+
this.show();
|
|
127
|
+
this.isPromoShown = true;
|
|
128
|
+
}
|
|
104
129
|
}
|
|
105
130
|
render() {
|
|
106
131
|
const className = classnames("tooltip", `tooltip--actual-placement-${this.actualPosition?.placement}`, {
|
|
107
132
|
"tooltip--active": this.active,
|
|
108
133
|
"tooltip--visible": this.visible,
|
|
134
|
+
"tooltip--promo": this.isPromo,
|
|
109
135
|
});
|
|
110
|
-
return (h(Host, { key: '
|
|
136
|
+
return (h(Host, { key: '0fa9404559103428ce19831a0b45a5330d00c9fa', onKeydown: this.onKeydown }, h("span", { key: '3602318c40723c65c318cef0254dab0161439cc6', class: className }, h("span", { key: 'a9aaf081590bcf01ad2c82c99b8ea10bc9b8f8a5', class: "tooltip__reference", "aria-describedby": "tooltip", onFocusout: !this.isPromo && this.hide, onClick: this.hide, onFocusin: this.show }, h("slot", { key: '73ad565e8b91925bba6fcb490b542d74890926c1' })), h("span", { key: 'bd84b556b64f4d24f2064d00556070af818524f5', class: "tooltip__popper", ref: (el) => (this.popperEl = el), style: {
|
|
111
137
|
top: Boolean(this.actualPosition)
|
|
112
138
|
? `${this.actualPosition?.y}px`
|
|
113
139
|
: "",
|
|
@@ -115,7 +141,7 @@ export class SwirlTooltip {
|
|
|
115
141
|
? `${this.actualPosition?.x}px`
|
|
116
142
|
: "",
|
|
117
143
|
position: this.positioning,
|
|
118
|
-
} }, this.visible && (h("span", { key: '
|
|
144
|
+
} }, this.visible && (h("span", { key: '41fb5ef06491bfaf355d3fd5a98e00a92cd75a92', class: "tooltip__bubble", id: "tooltip", part: "tooltip__bubble", role: "tooltip" }, h("span", { key: 'a6a22b0bc86e87f2c7728fc3888ef109a8b9be8c', class: "tooltip__content", innerHTML: this.content }))), h("span", { key: 'b036d30ba31fbf5b4c8519b229aed70f20509874', class: "tooltip__arrow", ref: (el) => (this.arrowElement = el), style: {
|
|
119
145
|
...this.arrowStyles,
|
|
120
146
|
visibility: this.visible ? "visible" : "hidden",
|
|
121
147
|
} })))));
|
|
@@ -244,6 +270,26 @@ export class SwirlTooltip {
|
|
|
244
270
|
"setter": false,
|
|
245
271
|
"reflect": false,
|
|
246
272
|
"defaultValue": "\"absolute\""
|
|
273
|
+
},
|
|
274
|
+
"isPromo": {
|
|
275
|
+
"type": "boolean",
|
|
276
|
+
"attribute": "is-promo",
|
|
277
|
+
"mutable": false,
|
|
278
|
+
"complexType": {
|
|
279
|
+
"original": "boolean",
|
|
280
|
+
"resolved": "boolean",
|
|
281
|
+
"references": {}
|
|
282
|
+
},
|
|
283
|
+
"required": false,
|
|
284
|
+
"optional": false,
|
|
285
|
+
"docs": {
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": "If set to true, tooltip will be initially visible.\nIt will only be dismissible via a click and will not reappear.\nTooltip will have a blue background color."
|
|
288
|
+
},
|
|
289
|
+
"getter": false,
|
|
290
|
+
"setter": false,
|
|
291
|
+
"reflect": false,
|
|
292
|
+
"defaultValue": "false"
|
|
247
293
|
}
|
|
248
294
|
};
|
|
249
295
|
}
|
|
@@ -251,7 +297,8 @@ export class SwirlTooltip {
|
|
|
251
297
|
return {
|
|
252
298
|
"actualPosition": {},
|
|
253
299
|
"arrowStyles": {},
|
|
254
|
-
"visible": {}
|
|
300
|
+
"visible": {},
|
|
301
|
+
"isPromoShown": {}
|
|
255
302
|
};
|
|
256
303
|
}
|
|
257
304
|
static get elementRef() { return "el"; }
|
package/dist/collection/utils.js
CHANGED
|
@@ -240,3 +240,8 @@ export function isDocumentMimeType(mimeType) {
|
|
|
240
240
|
mimeType.startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.document") ||
|
|
241
241
|
mimeType.startsWith("application/vnd.apple.pages"));
|
|
242
242
|
}
|
|
243
|
+
export function getPixelsFromRemToken(token) {
|
|
244
|
+
return (+getComputedStyle(document.documentElement)
|
|
245
|
+
.getPropertyValue(token)
|
|
246
|
+
.replace("rem", "") * 16);
|
|
247
|
+
}
|