@patternfly/elements 2.2.2 → 2.3.1
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 +32 -45
- package/package.json +4 -3
- package/pf-accordion/BaseAccordion.d.ts +2 -1
- package/pf-accordion/BaseAccordion.js +239 -210
- package/pf-accordion/BaseAccordion.js.map +1 -1
- package/pf-accordion/BaseAccordionHeader.js +71 -69
- 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 +4 -9
- 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-button/BaseButton.js +16 -17
- 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.js +1 -1
- package/pf-card/BaseCard.js.map +1 -1
- package/pf-card/pf-card.js +1 -1
- 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 +33 -36
- 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 +11 -14
- package/pf-code-block/pf-code-block.js.map +1 -1
- package/pf-icon/BaseIcon.js +41 -39
- 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 +14 -17
- 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 +34 -37
- 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 +45 -46
- package/pf-modal/pf-modal.js.map +1 -1
- package/pf-panel/pf-panel.js +6 -7
- package/pf-panel/pf-panel.js.map +1 -1
- package/pf-popover/pf-popover.js +48 -51
- package/pf-popover/pf-popover.js.map +1 -1
- package/pf-progress-stepper/pf-progress-step.js +10 -11
- package/pf-progress-stepper/pf-progress-step.js.map +1 -1
- package/pf-progress-stepper/pf-progress-stepper.js +13 -16
- 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 +47 -44
- 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-tabs/BaseTab.js +31 -29
- package/pf-tabs/BaseTab.js.map +1 -1
- package/pf-tabs/BaseTabPanel.js +5 -11
- package/pf-tabs/BaseTabPanel.js.map +1 -1
- package/pf-tabs/BaseTabs.js +135 -116
- 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.js +1 -1
- package/pf-tabs/pf-tab.js.map +1 -1
- package/pf-tabs/pf-tabs.js +2 -2
- package/pf-tabs/pf-tabs.js.map +1 -1
- package/pf-tile/pf-tile.js +1 -1
- package/pf-tile/pf-tile.js.map +1 -1
- package/pf-timestamp/pf-timestamp.d.ts +8 -5
- package/pf-timestamp/pf-timestamp.js +21 -66
- package/pf-timestamp/pf-timestamp.js.map +1 -1
- package/pf-tooltip/BaseTooltip.js +7 -13
- package/pf-tooltip/BaseTooltip.js.map +1 -1
- package/pf-tooltip/pf-tooltip.js +1 -1
- package/pf-tooltip/pf-tooltip.js.map +1 -1
- package/pfe.min.js +120 -120
- package/pfe.min.js.map +4 -4
- package/react/pf-accordion/pf-accordion-header.d.ts +6 -0
- package/react/pf-accordion/pf-accordion-header.js +12 -0
- package/react/pf-accordion/pf-accordion-panel.d.ts +6 -0
- package/react/pf-accordion/pf-accordion-panel.js +10 -0
- package/react/pf-accordion/pf-accordion.d.ts +6 -0
- package/react/pf-accordion/pf-accordion.js +13 -0
- package/react/pf-avatar/pf-avatar.d.ts +6 -0
- package/react/pf-avatar/pf-avatar.js +10 -0
- package/react/pf-badge/pf-badge.d.ts +6 -0
- package/react/pf-badge/pf-badge.js +10 -0
- package/react/pf-button/pf-button.d.ts +6 -0
- package/react/pf-button/pf-button.js +10 -0
- package/react/pf-card/pf-card.d.ts +6 -0
- package/react/pf-card/pf-card.js +10 -0
- package/react/pf-clipboard-copy/pf-clipboard-copy.d.ts +6 -0
- package/react/pf-clipboard-copy/pf-clipboard-copy.js +10 -0
- package/react/pf-code-block/pf-code-block.d.ts +6 -0
- package/react/pf-code-block/pf-code-block.js +10 -0
- package/react/pf-icon/pf-icon.d.ts +6 -0
- package/react/pf-icon/pf-icon.js +13 -0
- package/react/pf-jump-links/pf-jump-links-item.d.ts +6 -0
- package/react/pf-jump-links/pf-jump-links-item.js +13 -0
- package/react/pf-jump-links/pf-jump-links-list.d.ts +6 -0
- package/react/pf-jump-links/pf-jump-links-list.js +10 -0
- package/react/pf-jump-links/pf-jump-links.d.ts +6 -0
- package/react/pf-jump-links/pf-jump-links.js +12 -0
- package/react/pf-label/pf-label.d.ts +6 -0
- package/react/pf-label/pf-label.js +12 -0
- package/react/pf-modal/pf-modal.d.ts +6 -0
- package/react/pf-modal/pf-modal.js +13 -0
- package/react/pf-panel/pf-panel.d.ts +6 -0
- package/react/pf-panel/pf-panel.js +10 -0
- package/react/pf-popover/pf-popover.d.ts +6 -0
- package/react/pf-popover/pf-popover.js +10 -0
- package/react/pf-progress-stepper/pf-progress-step.d.ts +6 -0
- package/react/pf-progress-stepper/pf-progress-step.js +10 -0
- package/react/pf-progress-stepper/pf-progress-stepper.d.ts +6 -0
- package/react/pf-progress-stepper/pf-progress-stepper.js +10 -0
- package/react/pf-spinner/pf-spinner.d.ts +6 -0
- package/react/pf-spinner/pf-spinner.js +10 -0
- package/react/pf-switch/pf-switch.d.ts +6 -0
- package/react/pf-switch/pf-switch.js +12 -0
- package/react/pf-tabs/pf-tab-panel.d.ts +6 -0
- package/react/pf-tabs/pf-tab-panel.js +10 -0
- package/react/pf-tabs/pf-tab.d.ts +6 -0
- package/react/pf-tabs/pf-tab.js +12 -0
- package/react/pf-tabs/pf-tabs.d.ts +6 -0
- package/react/pf-tabs/pf-tabs.js +10 -0
- package/react/pf-tile/pf-tile.d.ts +6 -0
- package/react/pf-tile/pf-tile.js +10 -0
- package/react/pf-timestamp/pf-timestamp.d.ts +6 -0
- package/react/pf-timestamp/pf-timestamp.js +10 -0
- package/react/pf-tooltip/pf-tooltip.d.ts +6 -0
- package/react/pf-tooltip/pf-tooltip.js +10 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate } from "tslib";
|
|
1
|
+
import { __decorate } from "tslib";
|
|
3
2
|
import { LitElement, html } from 'lit';
|
|
4
3
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
5
4
|
import { property } from 'lit/decorators/property.js';
|
|
5
|
+
import { TimestampController, } from '@patternfly/pfe-core/controllers/timestamp-controller.js';
|
|
6
6
|
import { css } from "lit";
|
|
7
7
|
const style = css `:host{display:inline}time{text-decoration:var(--_timestamp-text-decoration,none);text-underline-offset:var(--_timestamp-text-underline-offset,initial)}`;
|
|
8
8
|
const BooleanStringConverter = {
|
|
@@ -14,85 +14,37 @@ const BooleanStringConverter = {
|
|
|
14
14
|
* A **timestamp** provides consistent formats for displaying date and time values.
|
|
15
15
|
*/
|
|
16
16
|
let PfTimestamp = class PfTimestamp extends LitElement {
|
|
17
|
-
|
|
18
|
-
super(...arguments);
|
|
19
|
-
_PfTimestamp_instances.add(this);
|
|
20
|
-
_PfTimestamp_date.set(this, new Date());
|
|
21
|
-
_PfTimestamp_isoString.set(this, __classPrivateFieldGet(this, _PfTimestamp_date, "f").toISOString());
|
|
22
|
-
}
|
|
17
|
+
static { this.styles = [style]; }
|
|
23
18
|
get date() {
|
|
24
|
-
return
|
|
19
|
+
return this.#timestamp.localeString;
|
|
25
20
|
}
|
|
26
21
|
set date(string) {
|
|
27
|
-
|
|
28
|
-
__classPrivateFieldSet(this, _PfTimestamp_isoString, __classPrivateFieldGet(this, _PfTimestamp_date, "f").toISOString(), "f");
|
|
22
|
+
this.#timestamp.date = new Date(string);
|
|
29
23
|
}
|
|
30
24
|
get isoString() {
|
|
31
|
-
return
|
|
25
|
+
return this.#timestamp.isoString;
|
|
32
26
|
}
|
|
33
27
|
get time() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
return this.#timestamp.time;
|
|
29
|
+
}
|
|
30
|
+
#timestamp = new TimestampController(this);
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
if (this.hasAttribute('date')) {
|
|
34
|
+
this.#timestamp.date = new Date(this.getAttribute('date'));
|
|
35
|
+
}
|
|
39
36
|
}
|
|
40
|
-
willUpdate() {
|
|
41
|
-
|
|
42
|
-
this.
|
|
37
|
+
willUpdate(changedProperties) {
|
|
38
|
+
for (const [prop] of changedProperties) {
|
|
39
|
+
this.#timestamp.set(prop, this[prop]);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
render() {
|
|
46
43
|
return html `
|
|
47
|
-
<time datetime="${this.isoString}">${this.time}</time>
|
|
44
|
+
<time datetime="${this.#timestamp.isoString}">${this.#timestamp.time}</time>
|
|
48
45
|
`;
|
|
49
46
|
}
|
|
50
47
|
};
|
|
51
|
-
_PfTimestamp_date = new WeakMap();
|
|
52
|
-
_PfTimestamp_isoString = new WeakMap();
|
|
53
|
-
_PfTimestamp_instances = new WeakSet();
|
|
54
|
-
_PfTimestamp_getTimeRelative = function _PfTimestamp_getTimeRelative(date) {
|
|
55
|
-
const rtf = new Intl.RelativeTimeFormat(this.locale, { localeMatcher: 'best fit', numeric: 'auto', style: 'long' });
|
|
56
|
-
const ms = date.getTime() - Date.now();
|
|
57
|
-
const tense = ms > 0 ? 1 : -1;
|
|
58
|
-
let qty = 0;
|
|
59
|
-
let units;
|
|
60
|
-
const s = Math.round(Math.abs(ms) / 1000);
|
|
61
|
-
const min = Math.round(s / 60);
|
|
62
|
-
const h = Math.round(min / 60);
|
|
63
|
-
const d = Math.round(h / 24);
|
|
64
|
-
const m = Math.round(d / 30);
|
|
65
|
-
const y = Math.round(m / 12);
|
|
66
|
-
if (m >= 12) {
|
|
67
|
-
qty = y;
|
|
68
|
-
units = 'year';
|
|
69
|
-
}
|
|
70
|
-
else if (d >= 30) {
|
|
71
|
-
qty = m;
|
|
72
|
-
units = 'month';
|
|
73
|
-
}
|
|
74
|
-
else if (h >= 24) {
|
|
75
|
-
qty = d;
|
|
76
|
-
units = 'day';
|
|
77
|
-
}
|
|
78
|
-
else if (min >= 45) {
|
|
79
|
-
qty = h;
|
|
80
|
-
units = 'hour';
|
|
81
|
-
}
|
|
82
|
-
else if (s >= 45) {
|
|
83
|
-
qty = min;
|
|
84
|
-
units = 'minute';
|
|
85
|
-
}
|
|
86
|
-
else if (s >= 10) {
|
|
87
|
-
qty = s;
|
|
88
|
-
units = 'second';
|
|
89
|
-
}
|
|
90
|
-
return typeof (units) !== 'undefined' ? rtf.format(tense * qty, units) : 'just now';
|
|
91
|
-
};
|
|
92
|
-
PfTimestamp.styles = [style];
|
|
93
|
-
__decorate([
|
|
94
|
-
property({ reflect: true })
|
|
95
|
-
], PfTimestamp.prototype, "date", null);
|
|
96
48
|
__decorate([
|
|
97
49
|
property({ reflect: true, attribute: 'date-format' })
|
|
98
50
|
], PfTimestamp.prototype, "dateFormat", void 0);
|
|
@@ -117,6 +69,9 @@ __decorate([
|
|
|
117
69
|
__decorate([
|
|
118
70
|
property({ reflect: true, attribute: 'hour-12', converter: BooleanStringConverter })
|
|
119
71
|
], PfTimestamp.prototype, "hour12", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
property({ reflect: true })
|
|
74
|
+
], PfTimestamp.prototype, "date", null);
|
|
120
75
|
PfTimestamp = __decorate([
|
|
121
76
|
customElement('pf-timestamp')
|
|
122
77
|
], PfTimestamp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-timestamp.js","sourceRoot":"","sources":["pf-timestamp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pf-timestamp.js","sourceRoot":"","sources":["pf-timestamp.ts"],"names":[],"mappings":";AAEA,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;AAEtD,OAAO,EACL,mBAAmB,GAEpB,MAAM,0DAA0D,CAAC;;;AAIlE,MAAM,sBAAsB,GAA8B;IACxD,aAAa,CAAC,KAAK;QACjB,OAAO,CAAC,KAAK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B;IAAtD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;+CAA6B;AAEnD;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDAAuB;AAEI;IAAzD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;kDAAwB;AAEpD;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAiB;AAED;IAA3C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAoB;AAEnB;IAA3C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAe;AAE4B;IAArF,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;2CAAkB;AAGvG;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAG3B;AAtBU,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAwDvB;SAxDY,WAAW","sourcesContent":["import type { ComplexAttributeConverter, PropertyValues } from 'lit';\n\nimport { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\n\nimport {\n TimestampController,\n type DateTimeFormat,\n} from '@patternfly/pfe-core/controllers/timestamp-controller.js';\n\nimport style from './pf-timestamp.css';\n\nconst BooleanStringConverter: ComplexAttributeConverter = {\n fromAttribute(value) {\n return !value || value === 'true';\n },\n};\n\n/**\n * A **timestamp** provides consistent formats for displaying date and time values.\n */\n@customElement('pf-timestamp')\nexport class PfTimestamp extends LitElement {\n static readonly styles = [style];\n\n @property({ reflect: true, attribute: 'date-format' }) dateFormat?: DateTimeFormat;\n\n @property({ reflect: true, attribute: 'time-format' }) timeFormat?: DateTimeFormat;\n\n @property({ attribute: false }) customFormat?: object;\n\n @property({ reflect: true, attribute: 'display-suffix' }) displaySuffix?: string;\n\n @property({ reflect: true }) locale?: string;\n\n @property({ reflect: true, type: Boolean }) relative?: boolean;\n\n @property({ reflect: true, type: Boolean }) utc?: boolean;\n\n @property({ reflect: true, attribute: 'hour-12', converter: BooleanStringConverter }) hour12?: boolean;\n\n @property({ reflect: true })\n get date() {\n return this.#timestamp.localeString;\n }\n\n set date(string) {\n this.#timestamp.date = new Date(string);\n }\n\n get isoString() {\n return this.#timestamp.isoString;\n }\n\n get time() {\n return this.#timestamp.time;\n }\n\n #timestamp = new TimestampController(this);\n\n connectedCallback() {\n super.connectedCallback();\n if (this.hasAttribute('date')) {\n this.#timestamp.date = new Date(this.getAttribute('date')!);\n }\n }\n\n willUpdate(changedProperties: PropertyValues<this>) {\n for (const [prop] of changedProperties) {\n this.#timestamp.set(prop, this[prop as keyof this]);\n }\n }\n\n render() {\n return html`\n <time datetime=\"${this.#timestamp.isoString}\">${this.#timestamp.time}</time>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-timestamp': PfTimestamp;\n }\n}\n"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var _BaseTooltip_float;
|
|
2
|
-
import { __classPrivateFieldGet } from "tslib";
|
|
3
1
|
import { LitElement, html } from 'lit';
|
|
4
2
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
3
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
@@ -9,12 +7,10 @@ const style = css `:host{display:inline}#container{display:inline-flex;position:
|
|
|
9
7
|
const enterEvents = ['focusin', 'tap', 'click', 'mouseenter'];
|
|
10
8
|
const exitEvents = ['focusout', 'blur', 'mouseleave'];
|
|
11
9
|
class BaseTooltip extends LitElement {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
10
|
+
static { this.styles = [style]; }
|
|
11
|
+
#float = new FloatingDOMController(this, {
|
|
12
|
+
content: () => this.shadowRoot?.querySelector('#tooltip'),
|
|
13
|
+
});
|
|
18
14
|
connectedCallback() {
|
|
19
15
|
super.connectedCallback();
|
|
20
16
|
enterEvents.forEach(evt => this.addEventListener(evt, this.show));
|
|
@@ -25,13 +21,13 @@ class BaseTooltip extends LitElement {
|
|
|
25
21
|
const placement = this.position;
|
|
26
22
|
const offset = !placement?.match(/top|bottom/) ? 15
|
|
27
23
|
: { mainAxis: 15, alignmentAxis: -4 };
|
|
28
|
-
await
|
|
24
|
+
await this.#float.show({ offset, placement });
|
|
29
25
|
}
|
|
30
26
|
async hide() {
|
|
31
|
-
await
|
|
27
|
+
await this.#float.hide();
|
|
32
28
|
}
|
|
33
29
|
render() {
|
|
34
|
-
const { alignment, anchor, open, styles } =
|
|
30
|
+
const { alignment, anchor, open, styles } = this.#float;
|
|
35
31
|
return html `
|
|
36
32
|
<div id="container"
|
|
37
33
|
style="${styleMap(styles)}"
|
|
@@ -46,7 +42,5 @@ class BaseTooltip extends LitElement {
|
|
|
46
42
|
`;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
_BaseTooltip_float = new WeakMap();
|
|
50
|
-
BaseTooltip.styles = [style];
|
|
51
45
|
export { BaseTooltip };
|
|
52
46
|
//# sourceMappingURL=BaseTooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTooltip.js","sourceRoot":"","sources":["BaseTooltip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseTooltip.js","sourceRoot":"","sources":["BaseTooltip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAA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Q,MAAM;QACb,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAExD,OAAO,IAAI,CAAA;;oBAEK,QAAQ,CAAC,MAAM,CAAC;iBACnB,QAAQ,CAAC,EAAE,IAAI;YACJ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM;YAClB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;;;;6BAI1B,MAAM,CAAC,CAAC,IAAI,CAAqB,KAAK,IAAI,CAAC,OAAO;;KAE1E,CAAC;IACJ,CAAC;;SA9CmB,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\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"]}
|
package/pf-tooltip/pf-tooltip.js
CHANGED
|
@@ -96,8 +96,8 @@ let PfTooltip = class PfTooltip extends BaseTooltip {
|
|
|
96
96
|
super(...arguments);
|
|
97
97
|
this.position = 'top';
|
|
98
98
|
}
|
|
99
|
+
static { this.styles = [...BaseTooltip.styles, styles]; }
|
|
99
100
|
};
|
|
100
|
-
PfTooltip.styles = [...BaseTooltip.styles, styles];
|
|
101
101
|
__decorate([
|
|
102
102
|
property()
|
|
103
103
|
], PfTooltip.prototype, "position", void 0);
|
|
@@ -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
|
|
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"]}
|