@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
package/pf-modal/pf-modal.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
var _PfModal_headerId, _PfModal_triggerElement, _PfModal_header, _PfModal_body, _PfModal_headings, _PfModal_cancelling, _PfModal_slots;
|
|
2
1
|
var PfModal_1;
|
|
3
|
-
import {
|
|
2
|
+
import { __decorate } from "tslib";
|
|
4
3
|
import { LitElement, html } from 'lit';
|
|
5
4
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
6
5
|
import { property } from 'lit/decorators/property.js';
|
|
@@ -73,25 +72,36 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
73
72
|
this.open = false;
|
|
74
73
|
/** @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue */
|
|
75
74
|
this.returnValue = '';
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
this.#headerId = getRandomId();
|
|
76
|
+
this.#triggerElement = null;
|
|
77
|
+
this.#header = null;
|
|
78
|
+
this.#body = [];
|
|
79
|
+
this.#headings = [];
|
|
80
|
+
this.#cancelling = false;
|
|
81
|
+
this.#slots = new SlotController(this, null, 'header', 'description', 'footer');
|
|
83
82
|
}
|
|
83
|
+
static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; }
|
|
84
|
+
static { this.styles = [style]; }
|
|
85
|
+
/** Should the dialog close when user clicks outside the dialog? */
|
|
86
|
+
static { this.closeOnOutsideClick = false; }
|
|
87
|
+
#headerId;
|
|
88
|
+
#triggerElement;
|
|
89
|
+
#header;
|
|
90
|
+
#body;
|
|
91
|
+
#headings;
|
|
92
|
+
#cancelling;
|
|
93
|
+
#slots;
|
|
84
94
|
connectedCallback() {
|
|
85
95
|
super.connectedCallback();
|
|
86
96
|
this.addEventListener('keydown', this.onKeydown);
|
|
87
97
|
this.addEventListener('click', this.onClick);
|
|
88
98
|
}
|
|
89
99
|
render() {
|
|
90
|
-
const headerId = (
|
|
91
|
-
const headerLabel =
|
|
92
|
-
const hasHeader =
|
|
93
|
-
const hasDescription =
|
|
94
|
-
const hasFooter =
|
|
100
|
+
const headerId = (this.#header || this.#headings.length) ? this.#headerId : undefined;
|
|
101
|
+
const headerLabel = this.#triggerElement ? this.#triggerElement.innerText : undefined;
|
|
102
|
+
const hasHeader = this.#slots.hasSlotted('header');
|
|
103
|
+
const hasDescription = this.#slots.hasSlotted('description');
|
|
104
|
+
const hasFooter = this.#slots.hasSlotted('footer');
|
|
95
105
|
return html `
|
|
96
106
|
<section ?hidden=${!this.open}>
|
|
97
107
|
<div id="overlay" part="overlay" ?hidden=${!this.open}></div>
|
|
@@ -132,23 +142,23 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
132
142
|
disconnectedCallback() {
|
|
133
143
|
super.disconnectedCallback();
|
|
134
144
|
this.removeEventListener('keydown', this.onKeydown);
|
|
135
|
-
|
|
145
|
+
this.#triggerElement?.removeEventListener('click', this.onTriggerClick);
|
|
136
146
|
}
|
|
137
147
|
async _init() {
|
|
138
148
|
await this.updateComplete;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
|
|
149
|
+
this.#header = this.querySelector(`[slot$="header"]`);
|
|
150
|
+
this.#body = [...this.querySelectorAll(`*:not([slot])`)];
|
|
151
|
+
this.#headings = this.#body.filter(el => el.tagName.slice(0, 1) === 'H');
|
|
152
|
+
if (this.#triggerElement) {
|
|
153
|
+
this.#triggerElement.addEventListener('click', this.onTriggerClick);
|
|
144
154
|
this.removeAttribute('hidden');
|
|
145
155
|
}
|
|
146
|
-
if (
|
|
147
|
-
|
|
156
|
+
if (this.#header) {
|
|
157
|
+
this.#header.id = this.#headerId;
|
|
148
158
|
}
|
|
149
|
-
else if (
|
|
159
|
+
else if (this.#headings.length > 0) {
|
|
150
160
|
// Get the first heading in the modal if it exists
|
|
151
|
-
|
|
161
|
+
this.#headings[0].id = this.#headerId;
|
|
152
162
|
}
|
|
153
163
|
}
|
|
154
164
|
async _openChanged(oldValue, newValue) {
|
|
@@ -163,22 +173,22 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
163
173
|
await this.updateComplete;
|
|
164
174
|
// Set the focus to the container
|
|
165
175
|
this.dialog?.focus();
|
|
166
|
-
this.dispatchEvent(new ModalOpenEvent(
|
|
176
|
+
this.dispatchEvent(new ModalOpenEvent(this.#triggerElement));
|
|
167
177
|
}
|
|
168
178
|
else {
|
|
169
179
|
// Return scrollability
|
|
170
180
|
document.body.style.overflow = 'auto';
|
|
171
181
|
await this.updateComplete;
|
|
172
|
-
if (
|
|
173
|
-
|
|
182
|
+
if (this.#triggerElement) {
|
|
183
|
+
this.#triggerElement.focus();
|
|
174
184
|
}
|
|
175
|
-
this.dispatchEvent(
|
|
185
|
+
this.dispatchEvent(this.#cancelling ? new ModalCancelEvent() : new ModalCloseEvent());
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
188
|
_triggerChanged() {
|
|
179
189
|
if (this.trigger) {
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
this.#triggerElement = this.getRootNode().getElementById(this.trigger);
|
|
191
|
+
this.#triggerElement?.addEventListener('click', this.onTriggerClick);
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
onTriggerClick(event) {
|
|
@@ -212,7 +222,7 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
212
222
|
this.cancel();
|
|
213
223
|
return;
|
|
214
224
|
case 'Enter':
|
|
215
|
-
if (event.target ===
|
|
225
|
+
if (event.target === this.#triggerElement) {
|
|
216
226
|
event.preventDefault();
|
|
217
227
|
this.showModal();
|
|
218
228
|
}
|
|
@@ -220,14 +230,14 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
220
230
|
}
|
|
221
231
|
}
|
|
222
232
|
async cancel() {
|
|
223
|
-
|
|
233
|
+
this.#cancelling = true;
|
|
224
234
|
this.open = false;
|
|
225
235
|
await this.updateComplete;
|
|
226
|
-
|
|
236
|
+
this.#cancelling = false;
|
|
227
237
|
}
|
|
228
238
|
setTrigger(element) {
|
|
229
|
-
|
|
230
|
-
|
|
239
|
+
this.#triggerElement = element;
|
|
240
|
+
this.#triggerElement.addEventListener('click', this.onTriggerClick);
|
|
231
241
|
}
|
|
232
242
|
/**
|
|
233
243
|
* Manually toggles the modal.
|
|
@@ -264,17 +274,6 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
264
274
|
this.open = false;
|
|
265
275
|
}
|
|
266
276
|
};
|
|
267
|
-
_PfModal_headerId = new WeakMap();
|
|
268
|
-
_PfModal_triggerElement = new WeakMap();
|
|
269
|
-
_PfModal_header = new WeakMap();
|
|
270
|
-
_PfModal_body = new WeakMap();
|
|
271
|
-
_PfModal_headings = new WeakMap();
|
|
272
|
-
_PfModal_cancelling = new WeakMap();
|
|
273
|
-
_PfModal_slots = new WeakMap();
|
|
274
|
-
PfModal.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
275
|
-
PfModal.styles = [style];
|
|
276
|
-
/** Should the dialog close when user clicks outside the dialog? */
|
|
277
|
-
PfModal.closeOnOutsideClick = false;
|
|
278
277
|
__decorate([
|
|
279
278
|
property({ reflect: true })
|
|
280
279
|
], PfModal.prototype, "variant", void 0);
|
package/pf-modal/pf-modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-modal.js","sourceRoot":"","sources":["pf-modal.ts"],"names":[],"mappings":";;;AAAA,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,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QA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;SAvPY,OAAO","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\nimport { bound, deprecation, initializer, observed } from '@patternfly/pfe-core/decorators.js';\nimport { getRandomId } from '@patternfly/pfe-core/functions/random.js';\n\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\n\nimport style from './pf-modal.css';\n\nexport class ModalCancelEvent extends ComposedEvent {\n constructor() {\n super('cancel');\n }\n}\n\nexport class ModalCloseEvent extends ComposedEvent {\n constructor() {\n super('close');\n }\n}\n\nexport class ModalOpenEvent extends ComposedEvent {\n constructor(\n /** The trigger element which triggered the modal to open */\n public trigger: HTMLElement | null\n ) {\n super('open');\n }\n}\n\n/**\n * A **modal** displays important information to a user without requiring them to navigate\n * to a new page.\n *\n * @summary Displays information or helps a user focus on a task\n *\n * @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.\n * @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).\n * @slot footer - Optional footer content. Good place to put action buttons.\n *\n * @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.\n * @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.\n *\n * @csspart overlay - The modal overlay which lies under the dialog and above the page body\n * @csspart dialog - The dialog element\n * @csspart content - The container for the dialog content\n * @csspart header - The container for the optional dialog header\n * @csspart description - The container for the optional dialog description in the header\n * @csspart close-button - The modal's close button\n * @csspart footer - Actions footer container\n *\n * @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}\n * @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--m-sm--sm--MaxWidth - Max width of the small variant modal {@default 35rem}\n * @cssprop {<length>} --pf-c-modal-box--m-md--MaxWidth - Max width of the small variant modal {@default 52.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-lg--lg--MaxWidth - Max width of the large variant modal {@default 70rem}\n * @cssprop {<length>} --pf-c-modal-box--MaxHeight - Max height of the modal {@default calc(100% - 3rem)}\n * @cssprop {<length>} --pf-c-modal-box--BoxShadow - {@default var(--pf-global--BoxShadow--xl)}\n * @cssprop {<length>} --pf-c-modal-box__title--FontSize - {@default 1.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MarginTop - {@default 2rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxWidth\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxHeight\n * @cssprop {<color>} --pf-c-modal-box--BackgroundColor - {@default #fff}\n * @cssprop --pf-c-modal-box__title--FontFamily - default font family for header-slotted headings\n */\n@customElement('pf-modal')\nexport class PfModal extends LitElement implements HTMLDialogElement {\n static readonly shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static readonly styles = [style];\n\n /** Should the dialog close when user clicks outside the dialog? */\n protected static closeOnOutsideClick = false;\n\n /**\n * The `variant` controls the width of the modal.\n * There are three options: `small`, `medium` and `large`. The default is `large`.\n */\n @property({ reflect: true }) variant?: 'small' | 'medium' | 'large';\n\n @deprecation({ alias: 'variant', attribute: 'width' }) width?: 'small' | 'medium' | 'large';\n\n /**\n * `position=\"top\"` aligns the dialog with the top of the page\n */\n @property({ reflect: true }) position?: 'top';\n\n @observed\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\n @observed\n @property() trigger?: string;\n\n /** @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue */\n public returnValue = '';\n\n @query('#overlay') private overlay?: HTMLElement | null;\n @query('#dialog') private dialog?: HTMLElement | null;\n @query('#close-button') private closeButton?: HTMLElement | null;\n\n #headerId = getRandomId();\n #triggerElement: HTMLElement | null = null;\n #header: HTMLElement | null = null;\n #body: Element[] = [];\n #headings: Element[] = [];\n #cancelling = false;\n\n #slots = new SlotController(this, null, 'header', 'description', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render() {\n const headerId = (this.#header || this.#headings.length) ? this.#headerId : undefined;\n const headerLabel = this.#triggerElement ? this.#triggerElement.innerText : undefined;\n const hasHeader = this.#slots.hasSlotted('header');\n const hasDescription = this.#slots.hasSlotted('description');\n const hasFooter = this.#slots.hasSlotted('footer');\n\n return html`\n <section ?hidden=${!this.open}>\n <div id=\"overlay\" part=\"overlay\" ?hidden=${!this.open}></div>\n <div id=\"dialog\"\n part=\"dialog\"\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=${ifDefined(headerId)}\n aria-label=${ifDefined(headerLabel)}\n ?hidden=\"${!this.open}\">\n <div id=\"container\">\n <div id=\"content\" part=\"content\" class=${classMap({ hasHeader, hasDescription, hasFooter })}>\n <header part=\"header\">\n <slot name=\"header\"></slot>\n <div part=\"description\" ?hidden=${!hasDescription}>\n <slot name=\"description\"></slot>\n </div>\n </header>\n <slot></slot>\n <footer ?hidden=${!hasFooter} part=\"footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n <button id=\"close-button\"\n part=\"close-button\"\n aria-label=\"Close dialog\"\n @keydown=${this.onKeydown}\n @click=${this.close}>\n <svg fill=\"currentColor\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"></path>\n </svg>\n </button>\n </div>\n </div>\n </section>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n this.removeEventListener('keydown', this.onKeydown);\n\n this.#triggerElement?.removeEventListener('click', this.onTriggerClick);\n }\n\n @initializer()\n protected async _init() {\n await this.updateComplete;\n this.#header = this.querySelector(`[slot$=\"header\"]`);\n this.#body = [...this.querySelectorAll(`*:not([slot])`)];\n this.#headings = this.#body.filter(el => el.tagName.slice(0, 1) === 'H');\n\n if (this.#triggerElement) {\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n this.removeAttribute('hidden');\n }\n\n if (this.#header) {\n this.#header.id = this.#headerId;\n } else if (this.#headings.length > 0) {\n // Get the first heading in the modal if it exists\n this.#headings[0].id = this.#headerId;\n }\n }\n\n protected async _openChanged(oldValue?: boolean, newValue?: boolean) {\n // loosening types to prevent running these effects in unexpected circumstances\n // eslint-disable-next-line eqeqeq\n if (oldValue == null || newValue == null || oldValue == newValue) {\n return;\n } else if (this.open) {\n // This prevents background scroll\n document.body.style.overflow = 'hidden';\n await this.updateComplete;\n // Set the focus to the container\n this.dialog?.focus();\n this.dispatchEvent(new ModalOpenEvent(this.#triggerElement));\n } else {\n // Return scrollability\n document.body.style.overflow = 'auto';\n\n await this.updateComplete;\n\n if (this.#triggerElement) {\n this.#triggerElement.focus();\n }\n\n this.dispatchEvent(this.#cancelling ? new ModalCancelEvent() : new ModalCloseEvent());\n }\n }\n\n protected _triggerChanged() {\n if (this.trigger) {\n this.#triggerElement = (this.getRootNode() as Document | ShadowRoot).getElementById(this.trigger);\n this.#triggerElement?.addEventListener('click', this.onTriggerClick);\n }\n }\n\n @bound private onTriggerClick(event: MouseEvent) {\n event.preventDefault();\n // TODO: in non-modal case, toggle the dialog\n this.showModal();\n }\n\n @bound private onClick(event: MouseEvent) {\n const { open, overlay, dialog } = this;\n if (open) {\n const path = event.composedPath();\n const { closeOnOutsideClick } = this.constructor as typeof PfModal;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (closeOnOutsideClick && path.includes(overlay!) && !path.includes(dialog!)) {\n event.preventDefault();\n this.cancel();\n }\n }\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Tab':\n if (event.target === this.closeButton) {\n event.preventDefault();\n this.dialog?.focus();\n }\n return;\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.cancel();\n return;\n case 'Enter':\n if (event.target === this.#triggerElement) {\n event.preventDefault();\n this.showModal();\n }\n return;\n }\n }\n\n private async cancel() {\n this.#cancelling = true;\n this.open = false;\n await this.updateComplete;\n this.#cancelling = false;\n }\n\n setTrigger(element: HTMLElement) {\n this.#triggerElement = element;\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n }\n\n /**\n * Manually toggles the modal.\n * ```js\n * modal.toggle();\n * ```\n */\n @bound toggle() {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show() {\n this.open = true;\n }\n\n @bound showModal() {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n */\n @bound close(returnValue?: string) {\n if (typeof returnValue === 'string') {\n this.returnValue = returnValue;\n }\n\n this.open = false;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-modal': PfModal;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pf-modal.js","sourceRoot":"","sources":["pf-modal.ts"],"names":[],"mappings":";;AAAA,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,E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;AACtB;IAA/B,KAAK,CAAC,eAAe,CAAC;4CAA0C;AAuEjD;IADf,WAAW,EAAE;oCAkBb;AAmCc;IAAd,KAAK;6CAIL;AAEc;IAAd,KAAK;sCAWL;AAEc;IAAd,KAAK;wCAoBL;AAoBM;IAAN,KAAK;qCAEL;AAQM;IAAN,KAAK;mCAEL;AAEM;IAAN,KAAK;wCAGL;AAQM;IAAN,KAAK;oCAML;AAtPU,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAuPnB;SAvPY,OAAO","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\nimport { bound, deprecation, initializer, observed } from '@patternfly/pfe-core/decorators.js';\nimport { getRandomId } from '@patternfly/pfe-core/functions/random.js';\n\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\n\nimport style from './pf-modal.css';\n\nexport class ModalCancelEvent extends ComposedEvent {\n constructor() {\n super('cancel');\n }\n}\n\nexport class ModalCloseEvent extends ComposedEvent {\n constructor() {\n super('close');\n }\n}\n\nexport class ModalOpenEvent extends ComposedEvent {\n constructor(\n /** The trigger element which triggered the modal to open */\n public trigger: HTMLElement | null\n ) {\n super('open');\n }\n}\n\n/**\n * A **modal** displays important information to a user without requiring them to navigate\n * to a new page.\n *\n * @summary Displays information or helps a user focus on a task\n *\n * @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.\n * @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).\n * @slot footer - Optional footer content. Good place to put action buttons.\n *\n * @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.\n * @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.\n *\n * @csspart overlay - The modal overlay which lies under the dialog and above the page body\n * @csspart dialog - The dialog element\n * @csspart content - The container for the dialog content\n * @csspart header - The container for the optional dialog header\n * @csspart description - The container for the optional dialog description in the header\n * @csspart close-button - The modal's close button\n * @csspart footer - Actions footer container\n *\n * @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}\n * @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--m-sm--sm--MaxWidth - Max width of the small variant modal {@default 35rem}\n * @cssprop {<length>} --pf-c-modal-box--m-md--MaxWidth - Max width of the small variant modal {@default 52.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-lg--lg--MaxWidth - Max width of the large variant modal {@default 70rem}\n * @cssprop {<length>} --pf-c-modal-box--MaxHeight - Max height of the modal {@default calc(100% - 3rem)}\n * @cssprop {<length>} --pf-c-modal-box--BoxShadow - {@default var(--pf-global--BoxShadow--xl)}\n * @cssprop {<length>} --pf-c-modal-box__title--FontSize - {@default 1.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MarginTop - {@default 2rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxWidth\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxHeight\n * @cssprop {<color>} --pf-c-modal-box--BackgroundColor - {@default #fff}\n * @cssprop --pf-c-modal-box__title--FontFamily - default font family for header-slotted headings\n */\n@customElement('pf-modal')\nexport class PfModal extends LitElement implements HTMLDialogElement {\n static readonly shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static readonly styles = [style];\n\n /** Should the dialog close when user clicks outside the dialog? */\n protected static closeOnOutsideClick = false;\n\n /**\n * The `variant` controls the width of the modal.\n * There are three options: `small`, `medium` and `large`. The default is `large`.\n */\n @property({ reflect: true }) variant?: 'small' | 'medium' | 'large';\n\n @deprecation({ alias: 'variant', attribute: 'width' }) width?: 'small' | 'medium' | 'large';\n\n /**\n * `position=\"top\"` aligns the dialog with the top of the page\n */\n @property({ reflect: true }) position?: 'top';\n\n @observed\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\n @observed\n @property() trigger?: string;\n\n /** @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue */\n public returnValue = '';\n\n @query('#overlay') private overlay?: HTMLElement | null;\n @query('#dialog') private dialog?: HTMLElement | null;\n @query('#close-button') private closeButton?: HTMLElement | null;\n\n #headerId = getRandomId();\n #triggerElement: HTMLElement | null = null;\n #header: HTMLElement | null = null;\n #body: Element[] = [];\n #headings: Element[] = [];\n #cancelling = false;\n\n #slots = new SlotController(this, null, 'header', 'description', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render() {\n const headerId = (this.#header || this.#headings.length) ? this.#headerId : undefined;\n const headerLabel = this.#triggerElement ? this.#triggerElement.innerText : undefined;\n const hasHeader = this.#slots.hasSlotted('header');\n const hasDescription = this.#slots.hasSlotted('description');\n const hasFooter = this.#slots.hasSlotted('footer');\n\n return html`\n <section ?hidden=${!this.open}>\n <div id=\"overlay\" part=\"overlay\" ?hidden=${!this.open}></div>\n <div id=\"dialog\"\n part=\"dialog\"\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=${ifDefined(headerId)}\n aria-label=${ifDefined(headerLabel)}\n ?hidden=\"${!this.open}\">\n <div id=\"container\">\n <div id=\"content\" part=\"content\" class=${classMap({ hasHeader, hasDescription, hasFooter })}>\n <header part=\"header\">\n <slot name=\"header\"></slot>\n <div part=\"description\" ?hidden=${!hasDescription}>\n <slot name=\"description\"></slot>\n </div>\n </header>\n <slot></slot>\n <footer ?hidden=${!hasFooter} part=\"footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n <button id=\"close-button\"\n part=\"close-button\"\n aria-label=\"Close dialog\"\n @keydown=${this.onKeydown}\n @click=${this.close}>\n <svg fill=\"currentColor\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"></path>\n </svg>\n </button>\n </div>\n </div>\n </section>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n this.removeEventListener('keydown', this.onKeydown);\n\n this.#triggerElement?.removeEventListener('click', this.onTriggerClick);\n }\n\n @initializer()\n protected async _init() {\n await this.updateComplete;\n this.#header = this.querySelector(`[slot$=\"header\"]`);\n this.#body = [...this.querySelectorAll(`*:not([slot])`)];\n this.#headings = this.#body.filter(el => el.tagName.slice(0, 1) === 'H');\n\n if (this.#triggerElement) {\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n this.removeAttribute('hidden');\n }\n\n if (this.#header) {\n this.#header.id = this.#headerId;\n } else if (this.#headings.length > 0) {\n // Get the first heading in the modal if it exists\n this.#headings[0].id = this.#headerId;\n }\n }\n\n protected async _openChanged(oldValue?: boolean, newValue?: boolean) {\n // loosening types to prevent running these effects in unexpected circumstances\n // eslint-disable-next-line eqeqeq\n if (oldValue == null || newValue == null || oldValue == newValue) {\n return;\n } else if (this.open) {\n // This prevents background scroll\n document.body.style.overflow = 'hidden';\n await this.updateComplete;\n // Set the focus to the container\n this.dialog?.focus();\n this.dispatchEvent(new ModalOpenEvent(this.#triggerElement));\n } else {\n // Return scrollability\n document.body.style.overflow = 'auto';\n\n await this.updateComplete;\n\n if (this.#triggerElement) {\n this.#triggerElement.focus();\n }\n\n this.dispatchEvent(this.#cancelling ? new ModalCancelEvent() : new ModalCloseEvent());\n }\n }\n\n protected _triggerChanged() {\n if (this.trigger) {\n this.#triggerElement = (this.getRootNode() as Document | ShadowRoot).getElementById(this.trigger);\n this.#triggerElement?.addEventListener('click', this.onTriggerClick);\n }\n }\n\n @bound private onTriggerClick(event: MouseEvent) {\n event.preventDefault();\n // TODO: in non-modal case, toggle the dialog\n this.showModal();\n }\n\n @bound private onClick(event: MouseEvent) {\n const { open, overlay, dialog } = this;\n if (open) {\n const path = event.composedPath();\n const { closeOnOutsideClick } = this.constructor as typeof PfModal;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (closeOnOutsideClick && path.includes(overlay!) && !path.includes(dialog!)) {\n event.preventDefault();\n this.cancel();\n }\n }\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Tab':\n if (event.target === this.closeButton) {\n event.preventDefault();\n this.dialog?.focus();\n }\n return;\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.cancel();\n return;\n case 'Enter':\n if (event.target === this.#triggerElement) {\n event.preventDefault();\n this.showModal();\n }\n return;\n }\n }\n\n private async cancel() {\n this.#cancelling = true;\n this.open = false;\n await this.updateComplete;\n this.#cancelling = false;\n }\n\n setTrigger(element: HTMLElement) {\n this.#triggerElement = element;\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n }\n\n /**\n * Manually toggles the modal.\n * ```js\n * modal.toggle();\n * ```\n */\n @bound toggle() {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show() {\n this.open = true;\n }\n\n @bound showModal() {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n */\n @bound close(returnValue?: string) {\n if (typeof returnValue === 'string') {\n this.returnValue = returnValue;\n }\n\n this.open = false;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-modal': PfModal;\n }\n}\n"]}
|
package/pf-panel/pf-panel.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { __classPrivateFieldGet, __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';
|
|
@@ -20,11 +19,13 @@ let PfPanel = class PfPanel extends LitElement {
|
|
|
20
19
|
constructor() {
|
|
21
20
|
super(...arguments);
|
|
22
21
|
this.scrollable = false;
|
|
23
|
-
|
|
22
|
+
this.#slots = new SlotController(this, 'header', null, 'footer');
|
|
24
23
|
}
|
|
24
|
+
static { this.styles = [styles]; }
|
|
25
|
+
#slots;
|
|
25
26
|
render() {
|
|
26
|
-
const hasHeader =
|
|
27
|
-
const hasFooter =
|
|
27
|
+
const hasHeader = this.#slots.hasSlotted('header');
|
|
28
|
+
const hasFooter = this.#slots.hasSlotted('footer');
|
|
28
29
|
return html `
|
|
29
30
|
<slot name="header" role="region" ?hidden="${!hasHeader}"></slot>
|
|
30
31
|
<hr role="presentation" ?hidden="${!hasHeader}">
|
|
@@ -33,8 +34,6 @@ let PfPanel = class PfPanel extends LitElement {
|
|
|
33
34
|
`;
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
_PfPanel_slots = new WeakMap();
|
|
37
|
-
PfPanel.styles = [styles];
|
|
38
37
|
__decorate([
|
|
39
38
|
property({ type: Boolean, reflect: true })
|
|
40
39
|
], PfPanel.prototype, "scrollable", void 0);
|
package/pf-panel/pf-panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-panel.js","sourceRoot":"","sources":["pf-panel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pf-panel.js","sourceRoot":"","sources":["pf-panel.ts"],"names":[],"mappings":";AAAA,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,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;;;AAIrF;;;;;;;;;GASG;AAEH,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,UAAU;IAAvC;;QAG8C,eAAU,GAAG,KAAK,CAAC;QAI/D,WAAM,GAAG,IAAI,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAY9D,CAAC;aAlBiB,WAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;IAMlC,MAAM,CAAsD;IAE5D,MAAM;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,IAAI,CAAA;mDACoC,CAAC,SAAS;yCACpB,CAAC,SAAS;;mDAEA,CAAC,SAAS;KACxD,CAAC;IACJ,CAAC;;AAf2C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAoB;AAElC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAiC;AALlD,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAmBnB;SAnBY,OAAO","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\n\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\n\nimport styles from './pf-panel.css';\n\n/**\n * The **panel** component is a container that supports flexible content layouts. It can\n * be used to house other components such as fields, forms, videos, buttons, and more.\n * The panel should not be confused with the [drawer](https://www.patternfly.org/v4/components/drawer/design-guidelines/)\n * component, which allows you to surface information via a collapsable container.\n *\n * @slot header - Place header content here\n * @slot - Place main content here\n * @slot footer - Place footer content here\n */\n@customElement('pf-panel')\nexport class PfPanel extends LitElement {\n static readonly styles = [styles];\n\n @property({ type: Boolean, reflect: true }) scrollable = false;\n\n @property({ reflect: true }) variant?: 'raised' | 'bordered';\n\n #slots = new SlotController(this, 'header', null, 'footer');\n\n render() {\n const hasHeader = this.#slots.hasSlotted('header');\n const hasFooter = this.#slots.hasSlotted('footer');\n return html`\n <slot name=\"header\" role=\"region\" ?hidden=\"${!hasHeader}\"></slot>\n <hr role=\"presentation\" ?hidden=\"${!hasHeader}\">\n <slot></slot>\n <slot name=\"footer\" role=\"region\" ?hidden=\"${!hasFooter}\"></slot>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-panel': PfPanel;\n }\n}\n"]}
|
package/pf-popover/pf-popover.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
var _PfPopover_instances, _PfPopover_referenceTrigger, _PfPopover_float, _PfPopover_slots, _PfPopover_outsideClick;
|
|
2
1
|
var PfPopover_1;
|
|
3
|
-
import {
|
|
2
|
+
import { __decorate } from "tslib";
|
|
4
3
|
import { LitElement, nothing, html } from 'lit';
|
|
5
4
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
6
5
|
import { property } from 'lit/decorators/property.js';
|
|
@@ -174,7 +173,6 @@ export class PopoverShownEvent extends ComposedEvent {
|
|
|
174
173
|
let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
175
174
|
constructor() {
|
|
176
175
|
super(...arguments);
|
|
177
|
-
_PfPopover_instances.add(this);
|
|
178
176
|
/**
|
|
179
177
|
* Indicates the initial popover position.
|
|
180
178
|
* There are 12 options: `top`, `bottom`, `left`, `right`, `top-start`, `top-end`,
|
|
@@ -186,23 +184,44 @@ let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
|
186
184
|
* Disable the flip behavior. The default is `false`.
|
|
187
185
|
*/
|
|
188
186
|
this.noFlip = false;
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
this.#referenceTrigger = null;
|
|
188
|
+
this.#float = new FloatingDOMController(this, {
|
|
191
189
|
content: () => this._popover,
|
|
192
190
|
arrow: () => this._arrow,
|
|
193
|
-
invoker: () =>
|
|
194
|
-
})
|
|
195
|
-
|
|
191
|
+
invoker: () => this.#referenceTrigger || this._slottedTrigger,
|
|
192
|
+
});
|
|
193
|
+
this.#slots = new SlotController(this, null, 'icon', 'heading', 'body', 'footer');
|
|
194
|
+
}
|
|
195
|
+
static { this.styles = [styles]; }
|
|
196
|
+
static { this.instances = new Set(); }
|
|
197
|
+
static { this.alertIcons = new Map(Object.entries({
|
|
198
|
+
default: 'bell',
|
|
199
|
+
info: 'circle-info',
|
|
200
|
+
success: 'circle-check',
|
|
201
|
+
warning: 'triangle-exclamation',
|
|
202
|
+
danger: 'circle-exclamation',
|
|
203
|
+
})); }
|
|
204
|
+
static {
|
|
205
|
+
document.addEventListener('click', function (event) {
|
|
206
|
+
for (const instance of PfPopover_1.instances) {
|
|
207
|
+
if (!instance.noOutsideClick) {
|
|
208
|
+
instance.#outsideClick(event);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
196
212
|
}
|
|
213
|
+
#referenceTrigger;
|
|
214
|
+
#float;
|
|
215
|
+
#slots;
|
|
197
216
|
connectedCallback() {
|
|
198
217
|
super.connectedCallback();
|
|
199
218
|
this.addEventListener('keydown', this.onKeydown);
|
|
200
219
|
}
|
|
201
220
|
render() {
|
|
202
|
-
const { alignment, anchor, styles } =
|
|
203
|
-
const hasFooter =
|
|
204
|
-
const hasHeading =
|
|
205
|
-
const hasIcon =
|
|
221
|
+
const { alignment, anchor, styles } = this.#float;
|
|
222
|
+
const hasFooter = this.#slots.hasSlotted('footer') || !!this.footer;
|
|
223
|
+
const hasHeading = this.#slots.hasSlotted('heading') || !!this.heading;
|
|
224
|
+
const hasIcon = this.#slots.hasSlotted('icon') || !!this.icon || !!this.alertSeverity;
|
|
206
225
|
// https://github.com/asyncLiz/minify-html-literals/issues/37
|
|
207
226
|
let headingContent = html `<h6>${this.heading ?? ''}</h6>`;
|
|
208
227
|
switch (this.headingLevel) {
|
|
@@ -267,8 +286,8 @@ let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
|
267
286
|
disconnectedCallback() {
|
|
268
287
|
super.disconnectedCallback();
|
|
269
288
|
PfPopover_1.instances.delete(this);
|
|
270
|
-
|
|
271
|
-
|
|
289
|
+
this.#referenceTrigger?.removeEventListener('click', this.show);
|
|
290
|
+
this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);
|
|
272
291
|
}
|
|
273
292
|
onKeydown(event) {
|
|
274
293
|
switch (event.key) {
|
|
@@ -278,33 +297,39 @@ let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
|
278
297
|
this.hide();
|
|
279
298
|
return;
|
|
280
299
|
case 'Enter':
|
|
281
|
-
if (event.target ===
|
|
300
|
+
if (event.target === this.#referenceTrigger || event.target === this._slottedTrigger) {
|
|
282
301
|
event.preventDefault();
|
|
283
302
|
this.show();
|
|
284
303
|
}
|
|
285
304
|
return;
|
|
286
305
|
}
|
|
287
306
|
}
|
|
307
|
+
#outsideClick(event) {
|
|
308
|
+
const path = event.composedPath();
|
|
309
|
+
if (!path.includes(this) && !path.includes(this.#referenceTrigger)) {
|
|
310
|
+
this.hide();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
288
313
|
/**
|
|
289
314
|
* Removes event listeners from the old trigger element and attaches
|
|
290
315
|
* them to the new trigger element.
|
|
291
316
|
*/
|
|
292
317
|
triggerChanged(oldValue, newValue) {
|
|
293
318
|
if (oldValue) {
|
|
294
|
-
|
|
295
|
-
|
|
319
|
+
this.#referenceTrigger?.removeEventListener('click', this.show);
|
|
320
|
+
this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);
|
|
296
321
|
}
|
|
297
322
|
if (newValue) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
323
|
+
this.#referenceTrigger = this.getRootNode().getElementById(newValue);
|
|
324
|
+
this.#referenceTrigger?.addEventListener('click', this.show);
|
|
325
|
+
this.#referenceTrigger?.addEventListener('keydown', this.onKeydown);
|
|
301
326
|
}
|
|
302
327
|
}
|
|
303
328
|
/**
|
|
304
329
|
* Toggle the popover
|
|
305
330
|
*/
|
|
306
331
|
async toggle() {
|
|
307
|
-
|
|
332
|
+
this.#float.open ? this.hide() : this.show();
|
|
308
333
|
}
|
|
309
334
|
/**
|
|
310
335
|
* Opens the popover
|
|
@@ -312,7 +337,7 @@ let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
|
312
337
|
async show() {
|
|
313
338
|
this.dispatchEvent(new PopoverShowEvent());
|
|
314
339
|
await this.updateComplete;
|
|
315
|
-
await
|
|
340
|
+
await this.#float.show({
|
|
316
341
|
offset: this.distance ?? 25,
|
|
317
342
|
placement: this.position,
|
|
318
343
|
flip: !this.noFlip,
|
|
@@ -327,40 +352,12 @@ let PfPopover = PfPopover_1 = class PfPopover extends LitElement {
|
|
|
327
352
|
*/
|
|
328
353
|
async hide() {
|
|
329
354
|
this.dispatchEvent(new PopoverHideEvent());
|
|
330
|
-
await
|
|
355
|
+
await this.#float.hide();
|
|
331
356
|
this._popover?.close();
|
|
332
357
|
this.dispatchEvent(new PopoverHiddenEvent());
|
|
333
358
|
PfPopover_1.instances.delete(this);
|
|
334
359
|
}
|
|
335
360
|
};
|
|
336
|
-
_PfPopover_referenceTrigger = new WeakMap();
|
|
337
|
-
_PfPopover_float = new WeakMap();
|
|
338
|
-
_PfPopover_slots = new WeakMap();
|
|
339
|
-
_PfPopover_instances = new WeakSet();
|
|
340
|
-
_PfPopover_outsideClick = function _PfPopover_outsideClick(event) {
|
|
341
|
-
const path = event.composedPath();
|
|
342
|
-
if (!path.includes(this) && !path.includes(__classPrivateFieldGet(this, _PfPopover_referenceTrigger, "f"))) {
|
|
343
|
-
this.hide();
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
PfPopover.styles = [styles];
|
|
347
|
-
PfPopover.instances = new Set();
|
|
348
|
-
PfPopover.alertIcons = new Map(Object.entries({
|
|
349
|
-
default: 'bell',
|
|
350
|
-
info: 'circle-info',
|
|
351
|
-
success: 'circle-check',
|
|
352
|
-
warning: 'triangle-exclamation',
|
|
353
|
-
danger: 'circle-exclamation',
|
|
354
|
-
}));
|
|
355
|
-
(() => {
|
|
356
|
-
document.addEventListener('click', function (event) {
|
|
357
|
-
for (const instance of PfPopover_1.instances) {
|
|
358
|
-
if (!instance.noOutsideClick) {
|
|
359
|
-
__classPrivateFieldGet(instance, _PfPopover_instances, "m", _PfPopover_outsideClick).call(instance, event);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
})();
|
|
364
361
|
__decorate([
|
|
365
362
|
property({ reflect: true })
|
|
366
363
|
], PfPopover.prototype, "position", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-popover.js","sourceRoot":"","sources":["pf-popover.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,cAA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AK,CAAC,UAAU,CAAC;2CAAsC;AAC7B;IAA1B,KAAK,CAAC,UAAU,CAAC;kDAA8C;AACvC;IAAxB,KAAK,CAAC,QAAQ,CAAC;yCAAiC;AAuFlC;IAAd,KAAK;0CAcL;AA4BY;IAAZ,KAAK;uCAEL;AAKY;IAAZ,KAAK;qCAYL;AAKY;IAAZ,KAAK;qCAML;AA9RU,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA+RrB;SA/RY,SAAS","sourcesContent":["import { LitElement, nothing, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { FloatingDOMController } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\nimport { bound } from '@patternfly/pfe-core/decorators/bound.js';\nimport { ComposedEvent, StringListConverter } from '@patternfly/pfe-core/core.js';\nimport { observed } from '@patternfly/pfe-core/decorators/observed.js';\nimport type { Placement } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\nimport '@patternfly/elements/pf-button/pf-button.js';\nimport styles from './pf-popover.css';\n\nconst headingLevels = [2, 3, 4, 5, 6] as const;\n\ntype HeadingLevel = (typeof headingLevels)[number];\n\ntype AlertSeverity = 'default' | 'info' | 'warning' | 'success' | 'danger';\n\nexport class PopoverHideEvent extends ComposedEvent {\n constructor() {\n super('hide');\n }\n}\n\nexport class PopoverHiddenEvent extends ComposedEvent {\n constructor() {\n super('hidden');\n }\n}\n\nexport class PopoverShowEvent extends ComposedEvent {\n constructor() {\n super('show');\n }\n}\n\nexport class PopoverShownEvent extends ComposedEvent {\n constructor() {\n super('shown');\n }\n}\n\n/**\n * A **Popover** displays content in a non-modal dialog and adds contextual information or provides resources via text and links.\n *\n * @summary Toggle the visibility of helpful or contextual information.\n *\n * @slot -\n * The default slot holds invoking element.\n * Typically this would be an icon, button, or other small sized element.\n * @slot heading\n * This slot renders the content that will be displayed inside of the header of the popover.\n * Typically this would be a heading element.\n * @slot icon\n * This slot renders the icon that will be displayed inside the header of the popover,\n * before the heading.\n * @slot body\n * This slot renders the content that will be displayed inside of the body of the popover.\n * @slot footer\n * This slot renders the content that will be displayed inside of the footer of the popover.\n *\n * @csspart container - The component wrapper\n * @csspart content - The content wrapper\n * @csspart header - The header element; only visible if both an icon annd heading are provided.\n * @csspart heading - The heading element\n * @csspart icon - The header icon\n * @csspart close-button - The close button\n * @csspart body - The container for the body content\n * @csspart footer - The container for the footer content\n *\n * @cssprop {<length>} --pf-c-popover__arrow--Height\n * Height of the arrow\n * {@default `1.5625rem`}\n * @cssprop {<length>} --pf-c-popover__arrow--Width\n * Width of the arrow\n * {@default `1.5625rem`}\n * @cssprop {<color>} --pf-c-popover__title-text--Color\n * Heading font color\n * {@default `inherit`}\n * @cssprop {<color>} --pf-c-popover__title-icon--Color\n * Heading icon font color\n * {@default `#151515`}\n * @cssprop {<color>} --pf-c-popover__arrow--BackgroundColor\n * Arrow background color\n * {@default `#fff`}\n * @cssprop --pf-c-popover__arrow--BoxShadow\n * Arrow box shadow\n * {@default `0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08)`}\n * @cssprop --pf-c-popover--BoxShadow\n * Popover box shadow\n * {@default `0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08)`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingTop\n * Popover top padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingRight\n * Popover right padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingBottom\n * Popover bottom padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingLeft\n * Popover left padding\n * {@default `1rem`}\n * @cssprop {<number>} --pf-c-popover--line-height\n * Popover line height\n * {@default `1.5`}\n * @cssprop {<length>} --pf-c-popover__content--FontSize\n * Popover font-size\n * {@default `0.875rem`}\n * @cssprop {<color>} --pf-c-popover__content--BackgroundColor\n * Popover background color\n * {@default `#fff`}\n * @cssprop {<length>} --pf-c-popover--MaxWidth\n * Popover max-width\n * {@default `20.75rem`}\n * @cssprop {<length>} --pf-c-popover--MinWidth\n * Popover min-width\n * {@default `20.75rem`}\n * @cssprop {<number>} --pf-c-popover--c-button--Right\n * Close button right position\n * {@default `0}\n * @cssprop {<number>} --pf-c-popover--c-button--Top\n * Close button top position\n * {@default `0`}\n * @cssprop {<length>} --pf-c-popover--c-button--sibling--PaddingRight\n * Padding between close button and its immediate sibling\n * {@default `3rem`}\n * @cssprop {<length>} --pf-c-popover__title-icon--MarginRight\n * Heading icon right margin\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-popover__title--FontSize\n * Header font-size\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-popover__title--MarginBottom\n * Header bottom margin\n * {@default `0.5rem`}\n * @cssprop {<number>} --pf-c-popover__title--LineHeight\n * Header line height\n * {@default `1.5`}\n * @cssprop {<string>} --pf-c-popover__title--FontFamily\n * Header font-family\n * {@default `'RedHatDisplay', 'Overpass', overpass, helvetica, arial, sans-serif`}\n * @cssprop {<length>} --pf-c-popover__footer--MarginTop\n * Footer top margin\n * {@default `1rem`}\n * @cssprop {<color>} --pf-c-popover--m-default__title-text--Color\n * Default alert heading color\n * {@default `#003737`}\n * @cssprop {<color>} --pf-c-popover--m-default__title-icon--Color\n * Default alert icon color\n * {@default `#009596`}\n * @cssprop {<color>} --pf-c-popover--m-info__title-text--Color\n * Default alert heading color\n * {@default `#002952`}\n * @cssprop {<color>} --pf-c-popover--m-info__title-icon--Color\n * Default alert icon color\n * {@default `#2b9af3`}\n * @cssprop {<color>} --pf-c-popover--m-warning__title-text--Color\n * Default alert heading color\n * {@default `#795600`}\n * @cssprop {<color>} --pf-c-popover--m-warning__title-icon--Color\n * Default alert icon color\n * {@default `#f0ab00`}\n * @cssprop {<color>} --pf-c-popover--m-success__title-text--Color\n * Default alert heading color\n * {@default `#1e4f18`}\n * @cssprop {<color>} --pf-c-popover--m-success__title-icon--Color\n * Default alert icon color\n * {@default `#3e8635`}\n * @cssprop {<color>} --pf-c-popover--m-danger__title-text--Color\n * Default alert heading color\n * {@default `#a30000`}\n * @cssprop {<color>} --pf-c-popover--m-danger__title-icon--Color\n * Default alert icon color\n * {@default `#c9190b`}\n */\n@customElement('pf-popover')\nexport class PfPopover extends LitElement {\n static readonly styles = [styles];\n\n private static instances = new Set<PfPopover>();\n\n private static alertIcons = new Map(Object.entries({\n default: 'bell',\n info: 'circle-info',\n success: 'circle-check',\n warning: 'triangle-exclamation',\n danger: 'circle-exclamation',\n } satisfies Record<AlertSeverity, string>) as [AlertSeverity, string][]);\n\n static {\n document.addEventListener('click', function(event) {\n for (const instance of PfPopover.instances) {\n if (!instance.noOutsideClick) {\n instance.#outsideClick(event);\n }\n }\n });\n }\n\n /**\n * Indicates the initial popover position.\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 `top`.\n */\n @property({ reflect: true }) position: Placement = 'top';\n\n /**\n * The content rendered in the popover's heading.\n */\n @property({ reflect: true }) heading?: string;\n\n /**\n * The content rendered in the popover's body.\n */\n @property({ reflect: true }) body?: string;\n\n /**\n * The content rendered in the popover's footer.\n */\n @property({ reflect: true }) footer?: string;\n\n /**\n * The icon placed before the popover's heading.\n */\n @property({ reflect: true }) icon?: string;\n\n /**\n * The accessible label for the popover. This is required if the no heading is set.\n */\n @property({ reflect: true }) label?: string;\n\n /**\n * The distance to set between the popover and its trigger element.\n */\n @property({ type: Number, reflect: true }) distance?: number;\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 /**\n * Disable the flip behavior. The default is `false`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'no-flip' }) noFlip = false;\n\n /**\n * The heading level to use for the popover's header. The default is `h6`.\n */\n @property({ type: Number, reflect: true, attribute: 'heading-level' }) headingLevel?: HeadingLevel;\n\n /**\n * Indicates which icon set to use for the header's icon.\n * The default is `fas` (Font Awesome Free Solid).\n */\n @property({ reflect: true, attribute: 'icon-set' }) iconSet?: string;\n\n /**\n * Hide the close button. The default is `false`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-close' }) hideClose?: boolean;\n\n /**\n * Indicates the severity variant to use for the alert popover.\n * There are five options: `default`, `info`, `warning`, `success`, and `danger`.\n */\n @property({ reflect: true, attribute: 'alert-severity' }) alertSeverity?: AlertSeverity;\n\n /**\n * The accessible label for the popover's close button. The default is `Close popover`.\n */\n @property({ reflect: true, attribute: 'close-label' }) closeButtonLabel?: string;\n\n /**\n * The text announced by the screen reader to indicate the popover's severity.\n * The default is `${alertSeverity} alert:`.\n */\n @property({ reflect: true, attribute: 'alert-severity-text' }) alertSeverityText?: string;\n\n /**\n * Don't hide the popover when clicking ouside of it.\n */\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'no-outside-click',\n }) noOutsideClick?: boolean;\n\n /**\n * The ID of the element to attach the popover to.\n */\n @observed('triggerChanged')\n @property({ reflect: true }) trigger?: string;\n\n @query('#popover') private _popover!: HTMLDialogElement;\n @query('#trigger') private _slottedTrigger?: HTMLElement | null;\n @query('#arrow') private _arrow!: HTMLDivElement;\n\n #referenceTrigger?: HTMLElement | null = null;\n\n #float = new FloatingDOMController(this, {\n content: () => this._popover,\n arrow: () => this._arrow,\n invoker: () => this.#referenceTrigger || this._slottedTrigger,\n });\n\n #slots = new SlotController(this, null, 'icon', 'heading', 'body', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n }\n\n render() {\n const { alignment, anchor, styles } = this.#float;\n const hasFooter = this.#slots.hasSlotted('footer') || !!this.footer;\n const hasHeading = this.#slots.hasSlotted('heading') || !!this.heading;\n const hasIcon = this.#slots.hasSlotted('icon') || !!this.icon || !!this.alertSeverity;\n\n // https://github.com/asyncLiz/minify-html-literals/issues/37\n let headingContent = html`<h6>${this.heading ?? ''}</h6>`;\n switch (this.headingLevel) {\n case 2: headingContent = html`<h2>${this.heading ?? ''}</h2>`; break;\n case 3: headingContent = html`<h3>${this.heading ?? ''}</h3>`; break;\n case 4: headingContent = html`<h4>${this.heading ?? ''}</h4>`; break;\n case 5: headingContent = html`<h5>${this.heading ?? ''}</h5>`; break;\n }\n\n const headingSlotWithFallback = html`\n <slot id=\"heading\" name=\"heading\" part=\"heading\" ?hidden=${!hasHeading}>${headingContent}</slot>\n `;\n\n const header = !(hasHeading && hasIcon) ? headingSlotWithFallback : html`\n <header part=\"header\">\n <span part=\"icon\">\n <slot name=\"icon\">\n <pf-icon icon=\"${this.icon ?? PfPopover.alertIcons.get(this.alertSeverity as AlertSeverity) ?? ''}\"\n set=\"${ifDefined(this.iconSet)}\"\n size=\"md\"></pf-icon>\n </slot>\n </span>${!this.alertSeverity ? nothing : html`\n <span class=\"visually-hidden\">${this.alertSeverityText ?? `${this.alertSeverity} alert:`}</span>`}\n ${headingSlotWithFallback}\n </header>\n `;\n\n return html`\n <div id=\"container\"\n style=\"${styleMap(styles)}\"\n class=\"${classMap({ [anchor]: !!anchor, [alignment]: !!alignment })}\">\n <slot id=\"trigger\" @keydown=${this.onKeydown} @click=${this.toggle}></slot>\n <dialog id=\"popover\" aria-labelledby=\"heading\" aria-describedby=\"body\" aria-label=${ifDefined(this.label)}>\n <div id=\"arrow\"></div>\n <div id=\"content\" part=\"content\">\n <pf-button id=\"close-button\"\n part=\"close-button\"\n plain\n label=\"${this.closeButtonLabel ?? 'Close popover'}\"\n @click=\"${this.hide}\"\n @keydown=\"${this.onKeydown}\"\n ?hidden=\"${this.hideClose}\">\n <svg fill=\"currentColor\" height=\"1em\" width=\"1em\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"/>\n </svg>\n </pf-button>\n ${header}\n <slot id=\"body\" part=\"body\" name=\"body\">${this.body ?? ''}</slot>\n <footer part=\"footer\" ?hidden=${!hasFooter}>\n <slot name=\"footer\">${this.footer}</slot>\n </footer>\n </div>\n </dialog>\n </div>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n PfPopover.instances.delete(this);\n this.#referenceTrigger?.removeEventListener('click', this.show);\n this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.hide();\n return;\n case 'Enter':\n if (event.target === this.#referenceTrigger || event.target === this._slottedTrigger) {\n event.preventDefault();\n this.show();\n }\n return;\n }\n }\n\n #outsideClick(event: MouseEvent) {\n const path = event.composedPath();\n if (!path.includes(this) && !path.includes(this.#referenceTrigger as HTMLElement)) {\n this.hide();\n }\n }\n\n /**\n * Removes event listeners from the old trigger element and attaches\n * them to the new trigger element.\n */\n triggerChanged(oldValue?: string, newValue?: string) {\n if (oldValue) {\n this.#referenceTrigger?.removeEventListener('click', this.show);\n this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);\n }\n if (newValue) {\n this.#referenceTrigger = (this.getRootNode() as Document | ShadowRoot).getElementById(newValue);\n this.#referenceTrigger?.addEventListener('click', this.show);\n this.#referenceTrigger?.addEventListener('keydown', this.onKeydown);\n }\n }\n\n /**\n * Toggle the popover\n */\n @bound async toggle() {\n this.#float.open ? this.hide() : this.show();\n }\n\n /**\n * Opens the popover\n */\n @bound async show() {\n this.dispatchEvent(new PopoverShowEvent());\n await this.updateComplete;\n await this.#float.show({\n offset: this.distance ?? 25,\n placement: this.position,\n flip: !this.noFlip,\n fallbackPlacements: this.flipBehavior,\n });\n this._popover?.show();\n this.dispatchEvent(new PopoverShownEvent());\n PfPopover.instances.add(this);\n }\n\n /**\n * Closes the popover\n */\n @bound async hide() {\n this.dispatchEvent(new PopoverHideEvent());\n await this.#float.hide();\n this._popover?.close();\n this.dispatchEvent(new PopoverHiddenEvent());\n PfPopover.instances.delete(this);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-popover': PfPopover;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pf-popover.js","sourceRoot":"","sources":["pf-popover.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,M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EnB;IAA1B,KAAK,CAAC,UAAU,CAAC;2CAAsC;AAC7B;IAA1B,KAAK,CAAC,UAAU,CAAC;kDAA8C;AACvC;IAAxB,KAAK,CAAC,QAAQ,CAAC;yCAAiC;AAuFlC;IAAd,KAAK;0CAcL;AA4BY;IAAZ,KAAK;uCAEL;AAKY;IAAZ,KAAK;qCAYL;AAKY;IAAZ,KAAK;qCAML;AA9RU,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA+RrB;SA/RY,SAAS","sourcesContent":["import { LitElement, nothing, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { FloatingDOMController } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\nimport { bound } from '@patternfly/pfe-core/decorators/bound.js';\nimport { ComposedEvent, StringListConverter } from '@patternfly/pfe-core/core.js';\nimport { observed } from '@patternfly/pfe-core/decorators/observed.js';\nimport type { Placement } from '@patternfly/pfe-core/controllers/floating-dom-controller.js';\nimport '@patternfly/elements/pf-button/pf-button.js';\nimport styles from './pf-popover.css';\n\nconst headingLevels = [2, 3, 4, 5, 6] as const;\n\ntype HeadingLevel = (typeof headingLevels)[number];\n\ntype AlertSeverity = 'default' | 'info' | 'warning' | 'success' | 'danger';\n\nexport class PopoverHideEvent extends ComposedEvent {\n constructor() {\n super('hide');\n }\n}\n\nexport class PopoverHiddenEvent extends ComposedEvent {\n constructor() {\n super('hidden');\n }\n}\n\nexport class PopoverShowEvent extends ComposedEvent {\n constructor() {\n super('show');\n }\n}\n\nexport class PopoverShownEvent extends ComposedEvent {\n constructor() {\n super('shown');\n }\n}\n\n/**\n * A **Popover** displays content in a non-modal dialog and adds contextual information or provides resources via text and links.\n *\n * @summary Toggle the visibility of helpful or contextual information.\n *\n * @slot -\n * The default slot holds invoking element.\n * Typically this would be an icon, button, or other small sized element.\n * @slot heading\n * This slot renders the content that will be displayed inside of the header of the popover.\n * Typically this would be a heading element.\n * @slot icon\n * This slot renders the icon that will be displayed inside the header of the popover,\n * before the heading.\n * @slot body\n * This slot renders the content that will be displayed inside of the body of the popover.\n * @slot footer\n * This slot renders the content that will be displayed inside of the footer of the popover.\n *\n * @csspart container - The component wrapper\n * @csspart content - The content wrapper\n * @csspart header - The header element; only visible if both an icon annd heading are provided.\n * @csspart heading - The heading element\n * @csspart icon - The header icon\n * @csspart close-button - The close button\n * @csspart body - The container for the body content\n * @csspart footer - The container for the footer content\n *\n * @cssprop {<length>} --pf-c-popover__arrow--Height\n * Height of the arrow\n * {@default `1.5625rem`}\n * @cssprop {<length>} --pf-c-popover__arrow--Width\n * Width of the arrow\n * {@default `1.5625rem`}\n * @cssprop {<color>} --pf-c-popover__title-text--Color\n * Heading font color\n * {@default `inherit`}\n * @cssprop {<color>} --pf-c-popover__title-icon--Color\n * Heading icon font color\n * {@default `#151515`}\n * @cssprop {<color>} --pf-c-popover__arrow--BackgroundColor\n * Arrow background color\n * {@default `#fff`}\n * @cssprop --pf-c-popover__arrow--BoxShadow\n * Arrow box shadow\n * {@default `0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08)`}\n * @cssprop --pf-c-popover--BoxShadow\n * Popover box shadow\n * {@default `0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08)`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingTop\n * Popover top padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingRight\n * Popover right padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingBottom\n * Popover bottom padding\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-tooltip__content--PaddingLeft\n * Popover left padding\n * {@default `1rem`}\n * @cssprop {<number>} --pf-c-popover--line-height\n * Popover line height\n * {@default `1.5`}\n * @cssprop {<length>} --pf-c-popover__content--FontSize\n * Popover font-size\n * {@default `0.875rem`}\n * @cssprop {<color>} --pf-c-popover__content--BackgroundColor\n * Popover background color\n * {@default `#fff`}\n * @cssprop {<length>} --pf-c-popover--MaxWidth\n * Popover max-width\n * {@default `20.75rem`}\n * @cssprop {<length>} --pf-c-popover--MinWidth\n * Popover min-width\n * {@default `20.75rem`}\n * @cssprop {<number>} --pf-c-popover--c-button--Right\n * Close button right position\n * {@default `0}\n * @cssprop {<number>} --pf-c-popover--c-button--Top\n * Close button top position\n * {@default `0`}\n * @cssprop {<length>} --pf-c-popover--c-button--sibling--PaddingRight\n * Padding between close button and its immediate sibling\n * {@default `3rem`}\n * @cssprop {<length>} --pf-c-popover__title-icon--MarginRight\n * Heading icon right margin\n * {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-popover__title--FontSize\n * Header font-size\n * {@default `1rem`}\n * @cssprop {<length>} --pf-c-popover__title--MarginBottom\n * Header bottom margin\n * {@default `0.5rem`}\n * @cssprop {<number>} --pf-c-popover__title--LineHeight\n * Header line height\n * {@default `1.5`}\n * @cssprop {<string>} --pf-c-popover__title--FontFamily\n * Header font-family\n * {@default `'RedHatDisplay', 'Overpass', overpass, helvetica, arial, sans-serif`}\n * @cssprop {<length>} --pf-c-popover__footer--MarginTop\n * Footer top margin\n * {@default `1rem`}\n * @cssprop {<color>} --pf-c-popover--m-default__title-text--Color\n * Default alert heading color\n * {@default `#003737`}\n * @cssprop {<color>} --pf-c-popover--m-default__title-icon--Color\n * Default alert icon color\n * {@default `#009596`}\n * @cssprop {<color>} --pf-c-popover--m-info__title-text--Color\n * Default alert heading color\n * {@default `#002952`}\n * @cssprop {<color>} --pf-c-popover--m-info__title-icon--Color\n * Default alert icon color\n * {@default `#2b9af3`}\n * @cssprop {<color>} --pf-c-popover--m-warning__title-text--Color\n * Default alert heading color\n * {@default `#795600`}\n * @cssprop {<color>} --pf-c-popover--m-warning__title-icon--Color\n * Default alert icon color\n * {@default `#f0ab00`}\n * @cssprop {<color>} --pf-c-popover--m-success__title-text--Color\n * Default alert heading color\n * {@default `#1e4f18`}\n * @cssprop {<color>} --pf-c-popover--m-success__title-icon--Color\n * Default alert icon color\n * {@default `#3e8635`}\n * @cssprop {<color>} --pf-c-popover--m-danger__title-text--Color\n * Default alert heading color\n * {@default `#a30000`}\n * @cssprop {<color>} --pf-c-popover--m-danger__title-icon--Color\n * Default alert icon color\n * {@default `#c9190b`}\n */\n@customElement('pf-popover')\nexport class PfPopover extends LitElement {\n static readonly styles = [styles];\n\n private static instances = new Set<PfPopover>();\n\n private static alertIcons = new Map(Object.entries({\n default: 'bell',\n info: 'circle-info',\n success: 'circle-check',\n warning: 'triangle-exclamation',\n danger: 'circle-exclamation',\n } satisfies Record<AlertSeverity, string>) as [AlertSeverity, string][]);\n\n static {\n document.addEventListener('click', function(event) {\n for (const instance of PfPopover.instances) {\n if (!instance.noOutsideClick) {\n instance.#outsideClick(event);\n }\n }\n });\n }\n\n /**\n * Indicates the initial popover position.\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 `top`.\n */\n @property({ reflect: true }) position: Placement = 'top';\n\n /**\n * The content rendered in the popover's heading.\n */\n @property({ reflect: true }) heading?: string;\n\n /**\n * The content rendered in the popover's body.\n */\n @property({ reflect: true }) body?: string;\n\n /**\n * The content rendered in the popover's footer.\n */\n @property({ reflect: true }) footer?: string;\n\n /**\n * The icon placed before the popover's heading.\n */\n @property({ reflect: true }) icon?: string;\n\n /**\n * The accessible label for the popover. This is required if the no heading is set.\n */\n @property({ reflect: true }) label?: string;\n\n /**\n * The distance to set between the popover and its trigger element.\n */\n @property({ type: Number, reflect: true }) distance?: number;\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 /**\n * Disable the flip behavior. The default is `false`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'no-flip' }) noFlip = false;\n\n /**\n * The heading level to use for the popover's header. The default is `h6`.\n */\n @property({ type: Number, reflect: true, attribute: 'heading-level' }) headingLevel?: HeadingLevel;\n\n /**\n * Indicates which icon set to use for the header's icon.\n * The default is `fas` (Font Awesome Free Solid).\n */\n @property({ reflect: true, attribute: 'icon-set' }) iconSet?: string;\n\n /**\n * Hide the close button. The default is `false`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-close' }) hideClose?: boolean;\n\n /**\n * Indicates the severity variant to use for the alert popover.\n * There are five options: `default`, `info`, `warning`, `success`, and `danger`.\n */\n @property({ reflect: true, attribute: 'alert-severity' }) alertSeverity?: AlertSeverity;\n\n /**\n * The accessible label for the popover's close button. The default is `Close popover`.\n */\n @property({ reflect: true, attribute: 'close-label' }) closeButtonLabel?: string;\n\n /**\n * The text announced by the screen reader to indicate the popover's severity.\n * The default is `${alertSeverity} alert:`.\n */\n @property({ reflect: true, attribute: 'alert-severity-text' }) alertSeverityText?: string;\n\n /**\n * Don't hide the popover when clicking ouside of it.\n */\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'no-outside-click',\n }) noOutsideClick?: boolean;\n\n /**\n * The ID of the element to attach the popover to.\n */\n @observed('triggerChanged')\n @property({ reflect: true }) trigger?: string;\n\n @query('#popover') private _popover!: HTMLDialogElement;\n @query('#trigger') private _slottedTrigger?: HTMLElement | null;\n @query('#arrow') private _arrow!: HTMLDivElement;\n\n #referenceTrigger?: HTMLElement | null = null;\n\n #float = new FloatingDOMController(this, {\n content: () => this._popover,\n arrow: () => this._arrow,\n invoker: () => this.#referenceTrigger || this._slottedTrigger,\n });\n\n #slots = new SlotController(this, null, 'icon', 'heading', 'body', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n }\n\n render() {\n const { alignment, anchor, styles } = this.#float;\n const hasFooter = this.#slots.hasSlotted('footer') || !!this.footer;\n const hasHeading = this.#slots.hasSlotted('heading') || !!this.heading;\n const hasIcon = this.#slots.hasSlotted('icon') || !!this.icon || !!this.alertSeverity;\n\n // https://github.com/asyncLiz/minify-html-literals/issues/37\n let headingContent = html`<h6>${this.heading ?? ''}</h6>`;\n switch (this.headingLevel) {\n case 2: headingContent = html`<h2>${this.heading ?? ''}</h2>`; break;\n case 3: headingContent = html`<h3>${this.heading ?? ''}</h3>`; break;\n case 4: headingContent = html`<h4>${this.heading ?? ''}</h4>`; break;\n case 5: headingContent = html`<h5>${this.heading ?? ''}</h5>`; break;\n }\n\n const headingSlotWithFallback = html`\n <slot id=\"heading\" name=\"heading\" part=\"heading\" ?hidden=${!hasHeading}>${headingContent}</slot>\n `;\n\n const header = !(hasHeading && hasIcon) ? headingSlotWithFallback : html`\n <header part=\"header\">\n <span part=\"icon\">\n <slot name=\"icon\">\n <pf-icon icon=\"${this.icon ?? PfPopover.alertIcons.get(this.alertSeverity as AlertSeverity) ?? ''}\"\n set=\"${ifDefined(this.iconSet)}\"\n size=\"md\"></pf-icon>\n </slot>\n </span>${!this.alertSeverity ? nothing : html`\n <span class=\"visually-hidden\">${this.alertSeverityText ?? `${this.alertSeverity} alert:`}</span>`}\n ${headingSlotWithFallback}\n </header>\n `;\n\n return html`\n <div id=\"container\"\n style=\"${styleMap(styles)}\"\n class=\"${classMap({ [anchor]: !!anchor, [alignment]: !!alignment })}\">\n <slot id=\"trigger\" @keydown=${this.onKeydown} @click=${this.toggle}></slot>\n <dialog id=\"popover\" aria-labelledby=\"heading\" aria-describedby=\"body\" aria-label=${ifDefined(this.label)}>\n <div id=\"arrow\"></div>\n <div id=\"content\" part=\"content\">\n <pf-button id=\"close-button\"\n part=\"close-button\"\n plain\n label=\"${this.closeButtonLabel ?? 'Close popover'}\"\n @click=\"${this.hide}\"\n @keydown=\"${this.onKeydown}\"\n ?hidden=\"${this.hideClose}\">\n <svg fill=\"currentColor\" height=\"1em\" width=\"1em\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"/>\n </svg>\n </pf-button>\n ${header}\n <slot id=\"body\" part=\"body\" name=\"body\">${this.body ?? ''}</slot>\n <footer part=\"footer\" ?hidden=${!hasFooter}>\n <slot name=\"footer\">${this.footer}</slot>\n </footer>\n </div>\n </dialog>\n </div>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n PfPopover.instances.delete(this);\n this.#referenceTrigger?.removeEventListener('click', this.show);\n this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.hide();\n return;\n case 'Enter':\n if (event.target === this.#referenceTrigger || event.target === this._slottedTrigger) {\n event.preventDefault();\n this.show();\n }\n return;\n }\n }\n\n #outsideClick(event: MouseEvent) {\n const path = event.composedPath();\n if (!path.includes(this) && !path.includes(this.#referenceTrigger as HTMLElement)) {\n this.hide();\n }\n }\n\n /**\n * Removes event listeners from the old trigger element and attaches\n * them to the new trigger element.\n */\n triggerChanged(oldValue?: string, newValue?: string) {\n if (oldValue) {\n this.#referenceTrigger?.removeEventListener('click', this.show);\n this.#referenceTrigger?.removeEventListener('keydown', this.onKeydown);\n }\n if (newValue) {\n this.#referenceTrigger = (this.getRootNode() as Document | ShadowRoot).getElementById(newValue);\n this.#referenceTrigger?.addEventListener('click', this.show);\n this.#referenceTrigger?.addEventListener('keydown', this.onKeydown);\n }\n }\n\n /**\n * Toggle the popover\n */\n @bound async toggle() {\n this.#float.open ? this.hide() : this.show();\n }\n\n /**\n * Opens the popover\n */\n @bound async show() {\n this.dispatchEvent(new PopoverShowEvent());\n await this.updateComplete;\n await this.#float.show({\n offset: this.distance ?? 25,\n placement: this.position,\n flip: !this.noFlip,\n fallbackPlacements: this.flipBehavior,\n });\n this._popover?.show();\n this.dispatchEvent(new PopoverShownEvent());\n PfPopover.instances.add(this);\n }\n\n /**\n * Closes the popover\n */\n @bound async hide() {\n this.dispatchEvent(new PopoverHideEvent());\n await this.#float.hide();\n this._popover?.close();\n this.dispatchEvent(new PopoverHiddenEvent());\n PfPopover.instances.delete(this);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-popover': PfPopover;\n }\n}\n"]}
|