@patternfly/elements 2.3.1 → 2.4.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/custom-elements.json +4399 -699
- package/package.json +11 -1
- package/pf-accordion/BaseAccordion.js +155 -220
- package/pf-accordion/BaseAccordion.js.map +1 -1
- package/pf-accordion/BaseAccordionHeader.d.ts +1 -0
- package/pf-accordion/BaseAccordionHeader.js +69 -71
- package/pf-accordion/BaseAccordionHeader.js.map +1 -1
- package/pf-accordion/BaseAccordionPanel.js +2 -2
- package/pf-accordion/BaseAccordionPanel.js.map +1 -1
- package/pf-accordion/pf-accordion-header.js +9 -4
- package/pf-accordion/pf-accordion-header.js.map +1 -1
- package/pf-accordion/pf-accordion-panel.js +1 -1
- package/pf-accordion/pf-accordion-panel.js.map +1 -1
- package/pf-accordion/pf-accordion.js +1 -1
- package/pf-accordion/pf-accordion.js.map +1 -1
- package/pf-avatar/BaseAvatar.js +1 -1
- package/pf-avatar/BaseAvatar.js.map +1 -1
- package/pf-avatar/pf-avatar.js +1 -1
- package/pf-avatar/pf-avatar.js.map +1 -1
- package/pf-badge/BaseBadge.js +1 -1
- package/pf-badge/BaseBadge.js.map +1 -1
- package/pf-badge/pf-badge.js +1 -1
- package/pf-badge/pf-badge.js.map +1 -1
- package/pf-banner/README.md +60 -0
- package/pf-banner/pf-banner.css +96 -0
- package/pf-banner/pf-banner.d.ts +52 -0
- package/pf-banner/pf-banner.js +85 -0
- package/pf-banner/pf-banner.js.map +1 -0
- package/pf-button/BaseButton.js +17 -16
- package/pf-button/BaseButton.js.map +1 -1
- package/pf-button/pf-button.js +1 -1
- package/pf-button/pf-button.js.map +1 -1
- package/pf-card/BaseCard.css +2 -2
- package/pf-card/BaseCard.js +2 -2
- package/pf-card/BaseCard.js.map +1 -1
- package/pf-card/pf-card.css +4 -4
- package/pf-card/pf-card.js +2 -2
- package/pf-card/pf-card.js.map +1 -1
- package/pf-clipboard-copy/BaseClipboardCopy.js +1 -1
- package/pf-clipboard-copy/BaseClipboardCopy.js.map +1 -1
- package/pf-clipboard-copy/pf-clipboard-copy.js +36 -33
- package/pf-clipboard-copy/pf-clipboard-copy.js.map +1 -1
- package/pf-code-block/BaseCodeBlock.js +1 -1
- package/pf-code-block/BaseCodeBlock.js.map +1 -1
- package/pf-code-block/pf-code-block.js +14 -11
- package/pf-code-block/pf-code-block.js.map +1 -1
- package/pf-icon/BaseIcon.js +39 -41
- package/pf-icon/BaseIcon.js.map +1 -1
- package/pf-icon/pf-icon.js +2 -2
- package/pf-icon/pf-icon.js.map +1 -1
- package/pf-jump-links/pf-jump-links-item.js +17 -14
- package/pf-jump-links/pf-jump-links-item.js.map +1 -1
- package/pf-jump-links/pf-jump-links-list.js +1 -1
- package/pf-jump-links/pf-jump-links-list.js.map +1 -1
- package/pf-jump-links/pf-jump-links.js +37 -34
- package/pf-jump-links/pf-jump-links.js.map +1 -1
- package/pf-label/BaseLabel.js +1 -1
- package/pf-label/BaseLabel.js.map +1 -1
- package/pf-label/pf-label.js +2 -2
- package/pf-label/pf-label.js.map +1 -1
- package/pf-modal/pf-modal.js +46 -45
- package/pf-modal/pf-modal.js.map +1 -1
- package/pf-panel/pf-panel.js +7 -6
- package/pf-panel/pf-panel.js.map +1 -1
- package/pf-popover/pf-popover.d.ts +2 -2
- package/pf-popover/pf-popover.js +67 -55
- package/pf-popover/pf-popover.js.map +1 -1
- package/pf-progress/README.md +33 -0
- package/pf-progress/pf-progress.css +210 -0
- package/pf-progress/pf-progress.d.ts +111 -0
- package/pf-progress/pf-progress.js +218 -0
- package/pf-progress/pf-progress.js.map +1 -0
- package/pf-progress-stepper/pf-progress-step.js +11 -10
- package/pf-progress-stepper/pf-progress-step.js.map +1 -1
- package/pf-progress-stepper/pf-progress-stepper.js +16 -13
- package/pf-progress-stepper/pf-progress-stepper.js.map +1 -1
- package/pf-spinner/BaseSpinner.js +1 -1
- package/pf-spinner/BaseSpinner.js.map +1 -1
- package/pf-spinner/pf-spinner.js +1 -1
- package/pf-spinner/pf-spinner.js.map +1 -1
- package/pf-switch/BaseSwitch.js +44 -47
- package/pf-switch/BaseSwitch.js.map +1 -1
- package/pf-switch/pf-switch.js +1 -1
- package/pf-switch/pf-switch.js.map +1 -1
- package/pf-table/README.md +43 -0
- package/pf-table/pf-caption.css +9 -0
- package/pf-table/pf-caption.d.ts +14 -0
- package/pf-table/pf-caption.js +22 -0
- package/pf-table/pf-caption.js.map +1 -0
- package/pf-table/pf-table.css +223 -0
- package/pf-table/pf-table.d.ts +663 -0
- package/pf-table/pf-table.js +767 -0
- package/pf-table/pf-table.js.map +1 -0
- package/pf-table/pf-tbody.css +16 -0
- package/pf-table/pf-tbody.d.ts +15 -0
- package/pf-table/pf-tbody.js +26 -0
- package/pf-table/pf-tbody.js.map +1 -0
- package/pf-table/pf-td.css +105 -0
- package/pf-table/pf-td.d.ts +18 -0
- package/pf-table/pf-td.js +52 -0
- package/pf-table/pf-td.js.map +1 -0
- package/pf-table/pf-th.css +93 -0
- package/pf-table/pf-th.d.ts +27 -0
- package/pf-table/pf-th.js +96 -0
- package/pf-table/pf-th.js.map +1 -0
- package/pf-table/pf-thead.css +19 -0
- package/pf-table/pf-thead.d.ts +16 -0
- package/pf-table/pf-thead.js +37 -0
- package/pf-table/pf-thead.js.map +1 -0
- package/pf-table/pf-tr.css +87 -0
- package/pf-table/pf-tr.d.ts +34 -0
- package/pf-table/pf-tr.js +164 -0
- package/pf-table/pf-tr.js.map +1 -0
- package/pf-tabs/BaseTab.d.ts +3 -0
- package/pf-tabs/BaseTab.js +32 -31
- package/pf-tabs/BaseTab.js.map +1 -1
- package/pf-tabs/BaseTabPanel.js +11 -5
- package/pf-tabs/BaseTabPanel.js.map +1 -1
- package/pf-tabs/BaseTabs.js +116 -135
- package/pf-tabs/BaseTabs.js.map +1 -1
- package/pf-tabs/pf-tab-panel.js +1 -1
- package/pf-tabs/pf-tab-panel.js.map +1 -1
- package/pf-tabs/pf-tab.d.ts +1 -1
- package/pf-tabs/pf-tab.js +2 -2
- package/pf-tabs/pf-tab.js.map +1 -1
- package/pf-tabs/pf-tabs.d.ts +2 -0
- package/pf-tabs/pf-tabs.js +6 -2
- package/pf-tabs/pf-tabs.js.map +1 -1
- package/pf-text-input/README.md +9 -0
- package/pf-text-input/pf-text-input.css +261 -0
- package/pf-text-input/pf-text-input.d.ts +174 -0
- package/pf-text-input/pf-text-input.js +262 -0
- package/pf-text-input/pf-text-input.js.map +1 -0
- package/pf-tile/pf-tile.js +1 -1
- package/pf-tile/pf-tile.js.map +1 -1
- package/pf-timestamp/pf-timestamp.js +15 -10
- package/pf-timestamp/pf-timestamp.js.map +1 -1
- package/pf-tooltip/BaseTooltip.css +1 -5
- package/pf-tooltip/BaseTooltip.d.ts +3 -0
- package/pf-tooltip/BaseTooltip.js +18 -9
- package/pf-tooltip/BaseTooltip.js.map +1 -1
- package/pf-tooltip/pf-tooltip.css +66 -4
- package/pf-tooltip/pf-tooltip.d.ts +25 -3
- package/pf-tooltip/pf-tooltip.js +144 -5
- package/pf-tooltip/pf-tooltip.js.map +1 -1
- package/pfe.min.js +257 -137
- package/pfe.min.js.map +4 -4
- package/react/pf-accordion/pf-accordion-header.d.ts +3 -5
- package/react/pf-accordion/pf-accordion-panel.d.ts +3 -5
- package/react/pf-accordion/pf-accordion.d.ts +3 -5
- package/react/pf-avatar/pf-avatar.d.ts +3 -5
- package/react/pf-badge/pf-badge.d.ts +3 -5
- package/react/pf-banner/pf-banner.d.ts +4 -0
- package/react/pf-banner/pf-banner.js +10 -0
- package/react/pf-button/pf-button.d.ts +3 -5
- package/react/pf-card/pf-card.d.ts +3 -5
- package/react/pf-clipboard-copy/pf-clipboard-copy.d.ts +3 -5
- package/react/pf-code-block/pf-code-block.d.ts +3 -5
- package/react/pf-icon/pf-icon.d.ts +3 -5
- package/react/pf-jump-links/pf-jump-links-item.d.ts +3 -5
- package/react/pf-jump-links/pf-jump-links-list.d.ts +3 -5
- package/react/pf-jump-links/pf-jump-links.d.ts +3 -5
- package/react/pf-label/pf-label.d.ts +3 -5
- package/react/pf-modal/pf-modal.d.ts +3 -5
- package/react/pf-panel/pf-panel.d.ts +3 -5
- package/react/pf-popover/pf-popover.d.ts +3 -5
- package/react/pf-progress/pf-progress.d.ts +4 -0
- package/react/pf-progress/pf-progress.js +10 -0
- package/react/pf-progress-stepper/pf-progress-step.d.ts +3 -5
- package/react/pf-progress-stepper/pf-progress-stepper.d.ts +3 -5
- package/react/pf-spinner/pf-spinner.d.ts +3 -5
- package/react/pf-switch/pf-switch.d.ts +3 -5
- package/react/pf-table/pf-caption.d.ts +4 -0
- package/react/pf-table/pf-caption.js +10 -0
- package/react/pf-table/pf-table.d.ts +4 -0
- package/react/pf-table/pf-table.js +10 -0
- package/react/pf-table/pf-tbody.d.ts +4 -0
- package/react/pf-table/pf-tbody.js +10 -0
- package/react/pf-table/pf-td.d.ts +4 -0
- package/react/pf-table/pf-td.js +10 -0
- package/react/pf-table/pf-th.d.ts +4 -0
- package/react/pf-table/pf-th.js +10 -0
- package/react/pf-table/pf-thead.d.ts +4 -0
- package/react/pf-table/pf-thead.js +10 -0
- package/react/pf-table/pf-tr.d.ts +4 -0
- package/react/pf-table/pf-tr.js +10 -0
- package/react/pf-tabs/pf-tab-panel.d.ts +3 -5
- package/react/pf-tabs/pf-tab.d.ts +3 -5
- package/react/pf-tabs/pf-tab.js +1 -1
- package/react/pf-tabs/pf-tabs.d.ts +3 -5
- package/react/pf-text-input/pf-text-input.d.ts +4 -0
- package/react/pf-text-input/pf-text-input.js +10 -0
- package/react/pf-tile/pf-tile.d.ts +3 -5
- package/react/pf-timestamp/pf-timestamp.d.ts +3 -5
- package/react/pf-tooltip/pf-tooltip.d.ts +3 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTooltip.js","sourceRoot":"","sources":["BaseTooltip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACv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O,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAChC,MAAM,MAAM,GACR,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;YACtC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,uBAAA,IAAI,0BAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,uBAAA,IAAI,0BAAO,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAA,IAAI,0BAAO,CAAC;QAExD,OAAO,IAAI,CAAA;;oBAEK,QAAQ,CAAC,MAAM,CAAC;oBAChB,QAAQ,CAAC,EAAE,IAAI;YACJ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM;YAClB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;;;;6BAI7B,MAAM,CAAC,CAAC,IAAI,CAAqB,KAAK,IAAI,CAAC,OAAO;;KAE1E,CAAC;IACJ,CAAC;;;AA7Ce,kBAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAW;SADb,WAAW","sourcesContent":["import type { Placement } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\n\nimport { LitElement, html } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport { FloatingDOMController } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\n\nimport style from './BaseTooltip.css';\n\nconst enterEvents = ['focusin', 'tap', 'click', 'mouseenter'];\nconst exitEvents = ['focusout', 'blur', 'mouseleave'];\n\n/**\n * @deprecated - Will be removed in the next major version. Use FloatingDOMController\n */\nexport abstract class BaseTooltip extends LitElement {\n static readonly styles = [style];\n\n abstract content?: string;\n\n /** The position of the tooltip, relative to the invoking content */\n abstract position?: Placement;\n\n #float = new FloatingDOMController(this, {\n content: (): HTMLElement | undefined | null => this.shadowRoot?.querySelector('#tooltip'),\n });\n\n override connectedCallback(): void {\n super.connectedCallback();\n enterEvents.forEach(evt => this.addEventListener(evt, this.show));\n exitEvents.forEach(evt => this.addEventListener(evt, this.hide));\n }\n\n async show() {\n await this.updateComplete;\n const placement = this.position;\n const offset =\n !placement?.match(/top|bottom/) ? 15\n : { mainAxis: 15, alignmentAxis: -4 };\n await this.#float.show({ offset, placement });\n }\n\n async hide() {\n await this.#float.hide();\n }\n\n override render() {\n const { alignment, anchor, open, styles } = this.#float;\n\n return html`\n <div id=\"container\"\n style=\"${styleMap(styles)}\"\n class=\"${classMap({ open,\n [anchor]: !!anchor,\n [alignment]: !!alignment })}\">\n <slot id=\"invoker\" role=\"tooltip\" aria-labelledby=\"tooltip\"></slot>\n <slot id=\"tooltip\"\n name=\"content\"\n aria-hidden=\"${String(!open) as 'true' | 'false'}\">${this.content}</slot>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
--_timestamp-text-decoration: underline dashed 1px;
|
|
3
3
|
--_timestamp-text-underline-offset: 4px;
|
|
4
|
+
display: inline;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
* { box-sizing: border-box; }
|
|
8
|
+
|
|
9
|
+
#container {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
position: relative;
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
--_floating-arrow-size: var(--pf-c-tooltip__arrow--Width, 0.5rem);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#invoker.block {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#tooltip,
|
|
21
|
+
#tooltip::after {
|
|
22
|
+
position: absolute;
|
|
4
23
|
}
|
|
5
24
|
|
|
6
25
|
#tooltip {
|
|
7
26
|
--_timestamp-text-decoration: none;
|
|
8
27
|
--_timestamp-text-underline-offset: initial;
|
|
28
|
+
display: block;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
z-index: 10000;
|
|
32
|
+
transition: opacity 300ms cubic-bezier(0.54, 1.5, 0.38, 1.11) 0s;
|
|
33
|
+
text-align: center;
|
|
34
|
+
word-break: break-word;
|
|
35
|
+
translate: var(--_floating-content-translate);
|
|
36
|
+
max-width: calc(100vw - 10px);
|
|
37
|
+
width: max-content;
|
|
38
|
+
top: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
will-change: opacity;
|
|
9
41
|
line-height: var(--pf-c-tooltip--line-height, 1.5);
|
|
10
42
|
max-width: var(--pf-c-tooltip--MaxWidth, 18.75rem);
|
|
11
43
|
box-shadow: var(--pf-c-tooltip--BoxShadow,
|
|
@@ -29,12 +61,42 @@
|
|
|
29
61
|
var(--pf-global--BackgroundColor--dark-100, #151515));
|
|
30
62
|
}
|
|
31
63
|
|
|
32
|
-
#container {
|
|
33
|
-
--_floating-arrow-size: var(--pf-c-tooltip__arrow--Width, 0.5rem);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
64
|
#tooltip::after {
|
|
65
|
+
display: block;
|
|
66
|
+
content: '';
|
|
67
|
+
rotate: 45deg;
|
|
68
|
+
width: var(--_floating-arrow-size);
|
|
69
|
+
height: var(--_floating-arrow-size);
|
|
70
|
+
will-change: left top right bottom;
|
|
37
71
|
background-color: var(--pf-c-tooltip__content--BackgroundColor,
|
|
38
72
|
var(--pf-global--BackgroundColor--dark-100, #151515));
|
|
39
73
|
}
|
|
40
74
|
|
|
75
|
+
.open #tooltip {
|
|
76
|
+
opacity: 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* LEFT */
|
|
80
|
+
.left #tooltip::after { right: calc(-0.5 * var(--_floating-arrow-size)); }
|
|
81
|
+
.left.center #tooltip::after { top: calc(50% - 0.5 * var(--_floating-arrow-size)); }
|
|
82
|
+
.left.start #tooltip::after { top: var(--_floating-arrow-size); }
|
|
83
|
+
.left.end #tooltip::after { bottom: var(--_floating-arrow-size); }
|
|
84
|
+
|
|
85
|
+
/* TOP */
|
|
86
|
+
.top #tooltip::after { top: calc(100% - 0.5 * var(--_floating-arrow-size)); }
|
|
87
|
+
.top.center #tooltip::after { right: calc(50% - 0.5 * var(--_floating-arrow-size)); }
|
|
88
|
+
.top.start #tooltip::after { left: var(--_floating-arrow-size); }
|
|
89
|
+
.top.end #tooltip::after { right: var(--_floating-arrow-size); }
|
|
90
|
+
|
|
91
|
+
/* RIGHT */
|
|
92
|
+
.right #tooltip::after { right: calc(100% - 0.5 * var(--_floating-arrow-size)); }
|
|
93
|
+
.right.center #tooltip::after { top: calc(50% - 0.5 * var(--_floating-arrow-size)); }
|
|
94
|
+
.right.start #tooltip::after { top: var(--_floating-arrow-size); }
|
|
95
|
+
.right.end #tooltip::after { bottom: var(--_floating-arrow-size); }
|
|
96
|
+
|
|
97
|
+
/* BOTTOM */
|
|
98
|
+
.bottom #tooltip::after { bottom: calc(100% - 0.5 * var(--_floating-arrow-size)); }
|
|
99
|
+
.bottom.center #tooltip::after { right: calc(50% - 0.5 * var(--_floating-arrow-size)); }
|
|
100
|
+
.bottom.start #tooltip::after { left: var(--_floating-arrow-size); }
|
|
101
|
+
.bottom.end #tooltip::after { right: var(--_floating-arrow-size); }
|
|
102
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { PropertyValues } from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { type Placement } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';
|
|
3
4
|
/**
|
|
4
5
|
* A **tooltip** is in-app messaging used to identify elements on a page with short,
|
|
5
6
|
* clarifying text.
|
|
@@ -87,11 +88,32 @@ import { BaseTooltip } from './BaseTooltip.js';
|
|
|
87
88
|
* Rotates the tooltip arrow based on degrees of movement for `left` positioned arrows.
|
|
88
89
|
* {@default `45deg`}
|
|
89
90
|
*/
|
|
90
|
-
export declare class PfTooltip extends
|
|
91
|
+
export declare class PfTooltip extends LitElement {
|
|
92
|
+
#private;
|
|
91
93
|
static readonly styles: import("lit").CSSResult[];
|
|
94
|
+
/** The position of the tooltip, relative to the invoking content */
|
|
92
95
|
position: Placement;
|
|
93
96
|
/** Tooltip content. Overridden by the content slot */
|
|
94
97
|
content?: string;
|
|
98
|
+
/** If false, prevents the tooltip from trying to remain in view by flipping itself when necessary */
|
|
99
|
+
noFlip: boolean;
|
|
100
|
+
trigger?: string | Element;
|
|
101
|
+
/**
|
|
102
|
+
* The flip order when flip is enabled and the initial position is not possible.
|
|
103
|
+
* There are 12 options: `top`, `bottom`, `left`, `right`, `top-start`, `top-end`,
|
|
104
|
+
* `bottom-start`, `bottom-end`, `left-start`, `left-end`,`right-start`, `right-end`.
|
|
105
|
+
* The default is [oppositePlacement], where only the opposite placement is tried.
|
|
106
|
+
*/
|
|
107
|
+
flipBehavior?: Placement[];
|
|
108
|
+
connectedCallback(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Removes event listeners from the old trigger element and attaches
|
|
111
|
+
* them to the new trigger element.
|
|
112
|
+
*/
|
|
113
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
114
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
115
|
+
show(): Promise<void>;
|
|
116
|
+
hide(): Promise<void>;
|
|
95
117
|
}
|
|
96
118
|
declare global {
|
|
97
119
|
interface HTMLElementTagNameMap {
|
package/pf-tooltip/pf-tooltip.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
var _PfTooltip_instances, _PfTooltip_invoker_get, _PfTooltip_content_get, _PfTooltip_blockInvoker, _PfTooltip_referenceTrigger, _PfTooltip_float, _PfTooltip_invokerChanged, _PfTooltip_getReferenceTrigger, _PfTooltip_updateTrigger;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate } from "tslib";
|
|
3
|
+
import { LitElement, html } from 'lit';
|
|
2
4
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
3
5
|
import { property } from 'lit/decorators/property.js';
|
|
4
|
-
import {
|
|
6
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
7
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
8
|
+
import { FloatingDOMController, } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';
|
|
9
|
+
import { bound } from '@patternfly/pfe-core/decorators/bound.js';
|
|
10
|
+
import { StringListConverter } from '@patternfly/pfe-core';
|
|
5
11
|
import { css } from "lit";
|
|
6
|
-
const styles = css `:host{--_timestamp-text-decoration:underline dashed 1px;--_timestamp-text-underline-offset:4px}#tooltip{--_timestamp-text-decoration:none;--_timestamp-text-underline-offset:initial;line-height:var(--pf-c-tooltip--line-height, 1.5);max-width:var(--pf-c-tooltip--MaxWidth,18.75rem);box-shadow:var(--pf-c-tooltip--BoxShadow,var(--pf-global--BoxShadow--md,0 .25rem .5rem 0 rgba(3,3,3,.12),0 0 .25rem 0 rgba(3,3,3,.06)));padding:var(--pf-c-tooltip__content--PaddingTop,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingRight,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingBottom,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingLeft,var(--pf-global--spacer--sm,.5rem));font-size:var(--pf-c-tooltip__content--FontSize,\n var(--pf-global--FontSize--sm, .875rem));color:var(--pf-c-tooltip__content--Color,var(--pf-global--Color--light-100,#fff));background-color:var(--pf-c-tooltip__content--BackgroundColor,var(--pf-global--BackgroundColor--dark-100,#151515))}#
|
|
12
|
+
const styles = css `:host{--_timestamp-text-decoration:underline dashed 1px;--_timestamp-text-underline-offset:4px;display:inline}*{box-sizing:border-box}#container{display:inline-flex;position:relative;max-width:100%;--_floating-arrow-size:var(--pf-c-tooltip__arrow--Width, 0.5rem)}#invoker.block{display:block}#tooltip,#tooltip::after{position:absolute}#tooltip{--_timestamp-text-decoration:none;--_timestamp-text-underline-offset:initial;display:block;opacity:0;pointer-events:none;z-index:10000;transition:opacity .3s cubic-bezier(.54, 1.5, .38, 1.11) 0s;text-align:center;word-break:break-word;translate:var(--_floating-content-translate);max-width:calc(100vw - 10px);width:max-content;top:0;left:0;will-change:opacity;line-height:var(--pf-c-tooltip--line-height, 1.5);max-width:var(--pf-c-tooltip--MaxWidth,18.75rem);box-shadow:var(--pf-c-tooltip--BoxShadow,var(--pf-global--BoxShadow--md,0 .25rem .5rem 0 rgba(3,3,3,.12),0 0 .25rem 0 rgba(3,3,3,.06)));padding:var(--pf-c-tooltip__content--PaddingTop,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingRight,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingBottom,var(--pf-global--spacer--sm,.5rem)) var(--pf-c-tooltip__content--PaddingLeft,var(--pf-global--spacer--sm,.5rem));font-size:var(--pf-c-tooltip__content--FontSize,\n var(--pf-global--FontSize--sm, .875rem));color:var(--pf-c-tooltip__content--Color,var(--pf-global--Color--light-100,#fff));background-color:var(--pf-c-tooltip__content--BackgroundColor,var(--pf-global--BackgroundColor--dark-100,#151515))}#tooltip::after{display:block;content:'';rotate:45deg;width:var(--_floating-arrow-size);height:var(--_floating-arrow-size);will-change:left top right bottom;background-color:var(--pf-c-tooltip__content--BackgroundColor,var(--pf-global--BackgroundColor--dark-100,#151515))}.open #tooltip{opacity:1}.left #tooltip::after{right:calc(-.5 * var(--_floating-arrow-size))}.left.center #tooltip::after{top:calc(50% - .5 * var(--_floating-arrow-size))}.left.start #tooltip::after{top:var(--_floating-arrow-size)}.left.end #tooltip::after{bottom:var(--_floating-arrow-size)}.top #tooltip::after{top:calc(100% - .5 * var(--_floating-arrow-size))}.top.center #tooltip::after{right:calc(50% - .5 * var(--_floating-arrow-size))}.top.start #tooltip::after{left:var(--_floating-arrow-size)}.top.end #tooltip::after{right:var(--_floating-arrow-size)}.right #tooltip::after{right:calc(100% - .5 * var(--_floating-arrow-size))}.right.center #tooltip::after{top:calc(50% - .5 * var(--_floating-arrow-size))}.right.start #tooltip::after{top:var(--_floating-arrow-size)}.right.end #tooltip::after{bottom:var(--_floating-arrow-size)}.bottom #tooltip::after{bottom:calc(100% - .5 * var(--_floating-arrow-size))}.bottom.center #tooltip::after{right:calc(50% - .5 * var(--_floating-arrow-size))}.bottom.start #tooltip::after{left:var(--_floating-arrow-size)}.bottom.end #tooltip::after{right:var(--_floating-arrow-size)}`;
|
|
13
|
+
const EnterEvents = ['focusin', 'tap', 'click', 'mouseenter'];
|
|
14
|
+
const ExitEvents = ['focusout', 'blur', 'mouseleave'];
|
|
7
15
|
/**
|
|
8
16
|
* A **tooltip** is in-app messaging used to identify elements on a page with short,
|
|
9
17
|
* clarifying text.
|
|
@@ -91,19 +99,150 @@ const styles = css `:host{--_timestamp-text-decoration:underline dashed 1px;--_t
|
|
|
91
99
|
* Rotates the tooltip arrow based on degrees of movement for `left` positioned arrows.
|
|
92
100
|
* {@default `45deg`}
|
|
93
101
|
*/
|
|
94
|
-
let PfTooltip = class PfTooltip extends
|
|
102
|
+
let PfTooltip = class PfTooltip extends LitElement {
|
|
95
103
|
constructor() {
|
|
96
104
|
super(...arguments);
|
|
105
|
+
_PfTooltip_instances.add(this);
|
|
106
|
+
/** The position of the tooltip, relative to the invoking content */
|
|
97
107
|
this.position = 'top';
|
|
108
|
+
/** If false, prevents the tooltip from trying to remain in view by flipping itself when necessary */
|
|
109
|
+
this.noFlip = false;
|
|
110
|
+
_PfTooltip_blockInvoker.set(this, false);
|
|
111
|
+
_PfTooltip_referenceTrigger.set(this, void 0);
|
|
112
|
+
_PfTooltip_float.set(this, new FloatingDOMController(this, {
|
|
113
|
+
content: () => __classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_content_get),
|
|
114
|
+
invoker: () => {
|
|
115
|
+
if (__classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f")) {
|
|
116
|
+
return __classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f");
|
|
117
|
+
}
|
|
118
|
+
else if (__classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get) instanceof HTMLSlotElement && __classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get).assignedElements().length > 0) {
|
|
119
|
+
return __classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get).assignedElements().at(0);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return __classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
}));
|
|
98
126
|
}
|
|
99
|
-
|
|
127
|
+
connectedCallback() {
|
|
128
|
+
super.connectedCallback();
|
|
129
|
+
__classPrivateFieldGet(this, _PfTooltip_instances, "m", _PfTooltip_invokerChanged).call(this);
|
|
130
|
+
__classPrivateFieldGet(this, _PfTooltip_instances, "m", _PfTooltip_updateTrigger).call(this);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes event listeners from the old trigger element and attaches
|
|
134
|
+
* them to the new trigger element.
|
|
135
|
+
*/
|
|
136
|
+
willUpdate(changed) {
|
|
137
|
+
if (changed.has('trigger')) {
|
|
138
|
+
__classPrivateFieldGet(this, _PfTooltip_instances, "m", _PfTooltip_updateTrigger).call(this);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
const { alignment, anchor, open, styles } = __classPrivateFieldGet(this, _PfTooltip_float, "f");
|
|
143
|
+
const block = __classPrivateFieldGet(this, _PfTooltip_blockInvoker, "f");
|
|
144
|
+
return html `
|
|
145
|
+
<div id="container"
|
|
146
|
+
style="${styleMap(styles)}"
|
|
147
|
+
class="${classMap({ open,
|
|
148
|
+
[anchor]: !!anchor,
|
|
149
|
+
[alignment]: !!alignment })}">
|
|
150
|
+
<slot id="invoker"
|
|
151
|
+
class="${classMap({ block })}"
|
|
152
|
+
@slotchange="${__classPrivateFieldGet(this, _PfTooltip_instances, "m", _PfTooltip_invokerChanged)}"
|
|
153
|
+
role="tooltip"
|
|
154
|
+
aria-labelledby="tooltip"></slot>
|
|
155
|
+
<slot id="tooltip"
|
|
156
|
+
name="content"
|
|
157
|
+
aria-hidden="${String(!open)}">${this.content}</slot>
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
async show() {
|
|
162
|
+
await this.updateComplete;
|
|
163
|
+
const placement = this.position;
|
|
164
|
+
const offset = !placement?.match(/top|bottom/) ? 15
|
|
165
|
+
: { mainAxis: 15, alignmentAxis: -4 };
|
|
166
|
+
await __classPrivateFieldGet(this, _PfTooltip_float, "f").show({
|
|
167
|
+
offset,
|
|
168
|
+
placement,
|
|
169
|
+
flip: !this.noFlip,
|
|
170
|
+
fallbackPlacements: this.flipBehavior,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async hide() {
|
|
174
|
+
await __classPrivateFieldGet(this, _PfTooltip_float, "f").hide();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
_PfTooltip_blockInvoker = new WeakMap();
|
|
178
|
+
_PfTooltip_referenceTrigger = new WeakMap();
|
|
179
|
+
_PfTooltip_float = new WeakMap();
|
|
180
|
+
_PfTooltip_instances = new WeakSet();
|
|
181
|
+
_PfTooltip_invoker_get = function _PfTooltip_invoker_get() {
|
|
182
|
+
return this.shadowRoot?.querySelector('#invoker') ?? null;
|
|
183
|
+
};
|
|
184
|
+
_PfTooltip_content_get = function _PfTooltip_content_get() {
|
|
185
|
+
return this.shadowRoot?.querySelector('#tooltip') ?? null;
|
|
186
|
+
};
|
|
187
|
+
_PfTooltip_invokerChanged = function _PfTooltip_invokerChanged() {
|
|
188
|
+
__classPrivateFieldSet(this, _PfTooltip_blockInvoker, __classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get)?.assignedElements().length === 0 &&
|
|
189
|
+
__classPrivateFieldGet(this, _PfTooltip_instances, "a", _PfTooltip_invoker_get)?.assignedNodes().length > 0, "f");
|
|
190
|
+
this.requestUpdate();
|
|
191
|
+
};
|
|
192
|
+
_PfTooltip_getReferenceTrigger = function _PfTooltip_getReferenceTrigger() {
|
|
193
|
+
return this.getRootNode().getElementById(this.trigger?.normalize() ?? '');
|
|
100
194
|
};
|
|
195
|
+
_PfTooltip_updateTrigger = function _PfTooltip_updateTrigger() {
|
|
196
|
+
const oldReferenceTrigger = __classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f");
|
|
197
|
+
__classPrivateFieldSet(this, _PfTooltip_referenceTrigger, this.trigger instanceof HTMLElement ? this.trigger
|
|
198
|
+
: typeof this.trigger === 'string' ? __classPrivateFieldGet(this, _PfTooltip_instances, "m", _PfTooltip_getReferenceTrigger).call(this)
|
|
199
|
+
: null, "f");
|
|
200
|
+
for (const evt of EnterEvents) {
|
|
201
|
+
if (__classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f")) {
|
|
202
|
+
this.removeEventListener(evt, this.show);
|
|
203
|
+
__classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f").addEventListener(evt, this.show);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
oldReferenceTrigger?.removeEventListener(evt, this.show);
|
|
207
|
+
this.addEventListener(evt, this.show);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const evt of ExitEvents) {
|
|
211
|
+
if (__classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f")) {
|
|
212
|
+
this.removeEventListener(evt, this.hide);
|
|
213
|
+
__classPrivateFieldGet(this, _PfTooltip_referenceTrigger, "f").addEventListener(evt, this.hide);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
oldReferenceTrigger?.removeEventListener(evt, this.hide);
|
|
217
|
+
this.addEventListener(evt, this.hide);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
PfTooltip.styles = [styles];
|
|
101
222
|
__decorate([
|
|
102
223
|
property()
|
|
103
224
|
], PfTooltip.prototype, "position", void 0);
|
|
104
225
|
__decorate([
|
|
105
226
|
property()
|
|
106
227
|
], PfTooltip.prototype, "content", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Boolean, attribute: 'no-flip' })
|
|
230
|
+
], PfTooltip.prototype, "noFlip", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property()
|
|
233
|
+
], PfTooltip.prototype, "trigger", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({
|
|
236
|
+
attribute: 'flip-behavior',
|
|
237
|
+
converter: StringListConverter,
|
|
238
|
+
})
|
|
239
|
+
], PfTooltip.prototype, "flipBehavior", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
bound
|
|
242
|
+
], PfTooltip.prototype, "show", null);
|
|
243
|
+
__decorate([
|
|
244
|
+
bound
|
|
245
|
+
], PfTooltip.prototype, "hide", null);
|
|
107
246
|
PfTooltip = __decorate([
|
|
108
247
|
customElement('pf-tooltip')
|
|
109
248
|
], PfTooltip);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-tooltip.js","sourceRoot":"","sources":["pf-tooltip.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;;;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,WAAW;IAA1C;;QAGc,aAAQ,GAAc,KAAK,CAAC;IAI1C,CAAC;aANiB,WAAM,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,AAAlC,CAAmC;;AAE7C;IAAX,QAAQ,EAAE;2CAA6B;AAG5B;IAAX,QAAQ,EAAE;0CAAkB;AANlB,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAOrB;SAPY,SAAS","sourcesContent":["import type { Placement } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\n\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { BaseTooltip } from './BaseTooltip.js';\n\nimport styles from './pf-tooltip.css';\n\n/**\n * A **tooltip** is in-app messaging used to identify elements on a page with short,\n * clarifying text.\n *\n * @summary Toggle the visibility of helpful or contextual information.\n *\n * @slot\n * This slot wraps around the element that should be used to invoke the tooltip content to display.\n * Typically this would be an icon, button, or other small sized element.\n * @slot content\n * This slot renders the content that will be displayed inside of the tooltip.\n * Typically this would include a string of text without any additional elements.\n * This element is wrapped with a div inside of the component to give it the stylings and background colors.\n *\n * @cssprop {<color>} --pf-c-tooltip__content--BackgroundColor\n * Sets the background color for the tooltip content.\n * {@default `#1b1d21`}\n * @cssprop {<color>} --pf-c-tooltip__content--Color\n * Sets the font color for the tooltip content.\n * {@default `#e0e0e0`}\n * @cssprop {<number>} --pf-c-tooltip--line-height\n * Sets the font color for the tooltip content.\n * {@default `1.5`}\n * @cssprop {<length>} --pf-c-tooltip--MaxWidth\n * Maximum width for the tooltip.\n * {@default `18.75rem`}\n * @cssprop --pf-c-tooltip--BoxShadow\n * Box shadow for the tooltip.\n * {@default `0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12), 0 0 0.25rem 0 rgba(3, 3, 3, 0.06)`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingTop\n * Top padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingRight\n * Right padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingBottom\n * Bottom padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingLeft\n * Left Padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop --pf-c-tooltip__content--FontSize\n * Font size for the tooltip content.\n * {@default `0.875rem`}\n * @cssprop {<length>} --pf-c-tooltip__arrow--Width\n * Tooltip arrow width.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__arrow--Height\n * Tooltip arrow height.\n * {@default `0.5rem`}\n * @cssprop --pf-c-tooltip__arrow--m-top--TranslateX\n * Positions the tooltip arrow along the x axis for `top` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-top--TranslateY\n * Positions the tooltip arrow along the y axis for `top` positioned arrows.\n * {@default `50%`}\n * @cssprop --pf-c-tooltip__arrow--m-top--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `top` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-right--TranslateX\n * Positions the tooltip arrow along the x axis for `right` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-right--TranslateY\n * Positions the tooltip arrow along the y axis for `right` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-right--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `right` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--TranslateX\n * Positions the tooltip arrow along the x axis for `bottom` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--TranslateY\n * Positions the tooltip arrow along the y axis for `bottom` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `bottom` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-left--TranslateX\n * Positions the tooltip arrow along the x axis for `left` positioned arrows.\n * {@default `50%`}\n * @cssprop --pf-c-tooltip__arrow--m-left--TranslateY\n * Positions the tooltip arrow along the y axis for `left` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-left--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `left` positioned arrows.\n * {@default `45deg`}\n */\n@customElement('pf-tooltip')\nexport class PfTooltip extends BaseTooltip {\n static readonly styles = [...BaseTooltip.styles, styles];\n\n @property() position: Placement = 'top';\n\n /** Tooltip content. Overridden by the content slot */\n @property() content?: string;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-tooltip': PfTooltip;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pf-tooltip.js","sourceRoot":"","sources":["pf-tooltip.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EACL,qBAAqB,GAEtB,MAAM,6DAA6D,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;;;AAK3D,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC9D,MAAM,UAAU,GAAG,CAAC,UAAU,E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C,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACzC,uBAAA,IAAI,mCAAkB,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SACzD;aAAM;YACL,mBAAmB,EAAE,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SACvC;KACF;AACH,CAAC;AA5He,gBAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAGtB;IAAX,QAAQ,EAAE;2CAA6B;AAG5B;IAAX,QAAQ,EAAE;0CAAkB;AAGsB;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;yCAAgB;AAEtD;IAAX,QAAQ,EAAE;0CAA4B;AAWpC;IAHF,QAAQ,CAAC;QACR,SAAS,EAAE,eAAe;QAC1B,SAAS,EAAE,mBAAmB;KAC/B,CAAC;+CAA4B;AAwGjB;IAAZ,KAAK;qCAYL;AAEY;IAAZ,KAAK;qCAEL;AA/IU,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAgJrB;SAhJY,SAAS","sourcesContent":["import type { PropertyValues } from 'lit';\nimport { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport {\n FloatingDOMController,\n type Placement,\n} from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\n\nimport { bound } from '@patternfly/pfe-core/decorators/bound.js';\n\nimport { StringListConverter } from '@patternfly/pfe-core';\n\n\nimport styles from './pf-tooltip.css';\n\nconst EnterEvents = ['focusin', 'tap', 'click', 'mouseenter'];\nconst ExitEvents = ['focusout', 'blur', 'mouseleave'];\n\n/**\n * A **tooltip** is in-app messaging used to identify elements on a page with short,\n * clarifying text.\n *\n * @summary Toggle the visibility of helpful or contextual information.\n *\n * @slot\n * This slot wraps around the element that should be used to invoke the tooltip content to display.\n * Typically this would be an icon, button, or other small sized element.\n * @slot content\n * This slot renders the content that will be displayed inside of the tooltip.\n * Typically this would include a string of text without any additional elements.\n * This element is wrapped with a div inside of the component to give it the stylings and background colors.\n *\n * @cssprop {<color>} --pf-c-tooltip__content--BackgroundColor\n * Sets the background color for the tooltip content.\n * {@default `#1b1d21`}\n * @cssprop {<color>} --pf-c-tooltip__content--Color\n * Sets the font color for the tooltip content.\n * {@default `#e0e0e0`}\n * @cssprop {<number>} --pf-c-tooltip--line-height\n * Sets the font color for the tooltip content.\n * {@default `1.5`}\n * @cssprop {<length>} --pf-c-tooltip--MaxWidth\n * Maximum width for the tooltip.\n * {@default `18.75rem`}\n * @cssprop --pf-c-tooltip--BoxShadow\n * Box shadow for the tooltip.\n * {@default `0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12), 0 0 0.25rem 0 rgba(3, 3, 3, 0.06)`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingTop\n * Top padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingRight\n * Right padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingBottom\n * Bottom padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingLeft\n * Left Padding for the tooltip.\n * {@default `0.5rem`}\n * @cssprop --pf-c-tooltip__content--FontSize\n * Font size for the tooltip content.\n * {@default `0.875rem`}\n * @cssprop {<length>} --pf-c-tooltip__arrow--Width\n * Tooltip arrow width.\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-tooltip__arrow--Height\n * Tooltip arrow height.\n * {@default `0.5rem`}\n * @cssprop --pf-c-tooltip__arrow--m-top--TranslateX\n * Positions the tooltip arrow along the x axis for `top` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-top--TranslateY\n * Positions the tooltip arrow along the y axis for `top` positioned arrows.\n * {@default `50%`}\n * @cssprop --pf-c-tooltip__arrow--m-top--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `top` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-right--TranslateX\n * Positions the tooltip arrow along the x axis for `right` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-right--TranslateY\n * Positions the tooltip arrow along the y axis for `right` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-right--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `right` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--TranslateX\n * Positions the tooltip arrow along the x axis for `bottom` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--TranslateY\n * Positions the tooltip arrow along the y axis for `bottom` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-bottom--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `bottom` positioned arrows.\n * {@default `45deg`}\n * @cssprop --pf-c-tooltip__arrow--m-left--TranslateX\n * Positions the tooltip arrow along the x axis for `left` positioned arrows.\n * {@default `50%`}\n * @cssprop --pf-c-tooltip__arrow--m-left--TranslateY\n * Positions the tooltip arrow along the y axis for `left` positioned arrows.\n * {@default `-50%`}\n * @cssprop --pf-c-tooltip__arrow--m-left--Rotate\n * Rotates the tooltip arrow based on degrees of movement for `left` positioned arrows.\n * {@default `45deg`}\n */\n@customElement('pf-tooltip')\nexport class PfTooltip extends LitElement {\n static readonly styles = [styles];\n\n /** The position of the tooltip, relative to the invoking content */\n @property() position: Placement = 'top';\n\n /** Tooltip content. Overridden by the content slot */\n @property() content?: string;\n\n /** If false, prevents the tooltip from trying to remain in view by flipping itself when necessary */\n @property({ type: Boolean, attribute: 'no-flip' }) noFlip = false;\n\n @property() trigger?: string | Element;\n\n /**\n * The flip order when flip is enabled and the initial position is not possible.\n * There are 12 options: `top`, `bottom`, `left`, `right`, `top-start`, `top-end`,\n * `bottom-start`, `bottom-end`, `left-start`, `left-end`,`right-start`, `right-end`.\n * The default is [oppositePlacement], where only the opposite placement is tried.\n */\n @property({\n attribute: 'flip-behavior',\n converter: StringListConverter,\n }) flipBehavior?: Placement[];\n\n get #invoker(): HTMLSlotElement | null {\n return this.shadowRoot?.querySelector('#invoker') ?? null;\n }\n\n get #content(): HTMLElement | null {\n return this.shadowRoot?.querySelector('#tooltip') ?? null;\n }\n\n #blockInvoker = false;\n\n #referenceTrigger?: HTMLElement | null;\n\n #float = new FloatingDOMController(this, {\n content: (): HTMLElement | null | undefined => this.#content,\n invoker: (): HTMLElement | null | undefined => {\n if (this.#referenceTrigger) {\n return this.#referenceTrigger;\n } else if (this.#invoker instanceof HTMLSlotElement && this.#invoker.assignedElements().length > 0) {\n return this.#invoker.assignedElements().at(0) as HTMLElement;\n } else {\n return this.#invoker;\n }\n },\n });\n\n override connectedCallback() {\n super.connectedCallback();\n this.#invokerChanged();\n this.#updateTrigger();\n }\n\n /**\n * Removes event listeners from the old trigger element and attaches\n * them to the new trigger element.\n */\n override willUpdate(changed: PropertyValues<this>) {\n if (changed.has('trigger')) {\n this.#updateTrigger();\n }\n }\n\n override render() {\n const { alignment, anchor, open, styles } = this.#float;\n\n const block = this.#blockInvoker;\n\n return html`\n <div id=\"container\"\n style=\"${styleMap(styles)}\"\n class=\"${classMap({ open,\n [anchor]: !!anchor,\n [alignment]: !!alignment })}\">\n <slot id=\"invoker\"\n class=\"${classMap({ block })}\"\n @slotchange=\"${this.#invokerChanged}\"\n role=\"tooltip\"\n aria-labelledby=\"tooltip\"></slot>\n <slot id=\"tooltip\"\n name=\"content\"\n aria-hidden=\"${String(!open) as 'true' | 'false'}\">${this.content}</slot>\n </div>\n `;\n }\n\n /** the invoker slot should render at block level if it only has text nodes */\n #invokerChanged() {\n this.#blockInvoker =\n this.#invoker?.assignedElements().length === 0 &&\n this.#invoker?.assignedNodes().length > 0;\n this.requestUpdate();\n }\n\n #getReferenceTrigger() {\n return (this.getRootNode() as Document | ShadowRoot).getElementById(this.trigger?.normalize() ?? '');\n }\n\n #updateTrigger() {\n const oldReferenceTrigger = this.#referenceTrigger;\n this.#referenceTrigger =\n this.trigger instanceof HTMLElement ? this.trigger\n : typeof this.trigger === 'string' ? this.#getReferenceTrigger()\n : null;\n for (const evt of EnterEvents) {\n if (this.#referenceTrigger) {\n this.removeEventListener(evt, this.show);\n this.#referenceTrigger.addEventListener(evt, this.show);\n } else {\n oldReferenceTrigger?.removeEventListener(evt, this.show);\n this.addEventListener(evt, this.show);\n }\n }\n for (const evt of ExitEvents) {\n if (this.#referenceTrigger) {\n this.removeEventListener(evt, this.hide);\n this.#referenceTrigger.addEventListener(evt, this.hide);\n } else {\n oldReferenceTrigger?.removeEventListener(evt, this.hide);\n this.addEventListener(evt, this.hide);\n }\n }\n }\n\n @bound async show() {\n await this.updateComplete;\n const placement = this.position;\n const offset =\n !placement?.match(/top|bottom/) ? 15\n : { mainAxis: 15, alignmentAxis: -4 };\n await this.#float.show({\n offset,\n placement,\n flip: !this.noFlip,\n fallbackPlacements: this.flipBehavior,\n });\n }\n\n @bound async hide() {\n await this.#float.hide();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-tooltip': PfTooltip;\n }\n}\n"]}
|