@fluid-topics/ftds-popover 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +7 -0
- package/build/definitions.js +6 -0
- package/build/ftds-popover-section.d.ts +13 -0
- package/build/ftds-popover-section.js +61 -0
- package/build/ftds-popover-section.properties.d.ts +3 -0
- package/build/ftds-popover-section.properties.js +1 -0
- package/build/ftds-popover-section.styles.d.ts +1 -0
- package/build/ftds-popover-section.styles.js +22 -0
- package/build/ftds-popover.d.ts +53 -0
- package/build/ftds-popover.js +299 -0
- package/build/ftds-popover.light.js +1725 -0
- package/build/ftds-popover.min.js +1841 -0
- package/build/ftds-popover.properties.d.ts +14 -0
- package/build/ftds-popover.properties.js +5 -0
- package/build/ftds-popover.styles.d.ts +1 -0
- package/build/ftds-popover.styles.js +102 -0
- package/build/index.d.ts +7 -0
- package/build/index.js +7 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
The design system popover component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ftds-popover
|
|
7
|
+
yarn add @fluid-topics/ftds-popover
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import {html} from "lit"
|
|
14
|
+
import "@fluid-topics/ftds-link"
|
|
15
|
+
import "@fluid-topics/ft-popover"
|
|
16
|
+
|
|
17
|
+
function render() {
|
|
18
|
+
return html`
|
|
19
|
+
<ftds-popover heading="Popover heading">
|
|
20
|
+
Exemple popover content
|
|
21
|
+
<ftds-link slot="link" href="" variant="body-2-medium" family="brand" underlined>Example popover link</ftds-link>
|
|
22
|
+
</ftds-popover>
|
|
23
|
+
`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function render() {
|
|
27
|
+
return html`
|
|
28
|
+
<ftds-popover>
|
|
29
|
+
<ftds-popover-section slot="sections" heading="Popover section heading">
|
|
30
|
+
Example popover section content
|
|
31
|
+
<ftds-link slot="link">Example popover section link</ftds-link>
|
|
32
|
+
</ftds-popover-section>
|
|
33
|
+
<ftds-popover-section slot="sections">
|
|
34
|
+
Other example popover section content
|
|
35
|
+
</ftds-popover-section>
|
|
36
|
+
</ftds-popover>
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { nothing, PropertyValues } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsPopoverSectionProperties } from "./ftds-popover-section.properties";
|
|
4
|
+
export declare class FtdsPopoverSection extends FtLitElement implements FtdsPopoverSectionProperties {
|
|
5
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
heading: string;
|
|
8
|
+
private popoverSectionLinkTypography;
|
|
9
|
+
private popoverSectionLinkSlot;
|
|
10
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
renderHeading(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
12
|
+
protected updated(props: PropertyValues): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing, } from "lit";
|
|
8
|
+
import { property, query, } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement, unslotText, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
11
|
+
import { sectionStyles } from "./ftds-popover-section.styles";
|
|
12
|
+
export class FtdsPopoverSection extends FtLitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.heading = "";
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
return html `
|
|
19
|
+
<div class="ftds-popover-section--container">
|
|
20
|
+
<slot name="heading">
|
|
21
|
+
${this.renderHeading()}
|
|
22
|
+
</slot>
|
|
23
|
+
<div class="ftds-popover-section--content" part="content" id="ftds-popover-section-content">
|
|
24
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}">
|
|
25
|
+
<slot></slot>
|
|
26
|
+
</ftds-typography>
|
|
27
|
+
</div>
|
|
28
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}" part="popover-section-link-typography" class="ftds-popover-section--link">
|
|
29
|
+
<slot name="link"
|
|
30
|
+
part="popover-section-link"
|
|
31
|
+
@slotchange=${() => this.requestUpdate()}
|
|
32
|
+
></slot>
|
|
33
|
+
</ftds-typography>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
renderHeading() {
|
|
38
|
+
return this.heading ? html `
|
|
39
|
+
<div class="ftds-popover-section--heading" part="heading" id="ftds-popover-section-heading">
|
|
40
|
+
<ftds-typography element="span" variant="${FtdsTypographyVariants.body2semibold}">${this.heading}</ftds-typography>
|
|
41
|
+
</div>
|
|
42
|
+
` : nothing;
|
|
43
|
+
}
|
|
44
|
+
updated(props) {
|
|
45
|
+
super.updated(props);
|
|
46
|
+
this.popoverSectionLinkTypography.hidden = unslotText(this.popoverSectionLinkSlot).trim().length === 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
FtdsPopoverSection.elementDefinitions = {
|
|
50
|
+
"ftds-typography": FtdsTypography,
|
|
51
|
+
};
|
|
52
|
+
FtdsPopoverSection.styles = sectionStyles;
|
|
53
|
+
__decorate([
|
|
54
|
+
property()
|
|
55
|
+
], FtdsPopoverSection.prototype, "heading", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
query("[part=popover-section-link-typography]")
|
|
58
|
+
], FtdsPopoverSection.prototype, "popoverSectionLinkTypography", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
query("[part=popover-section-link]")
|
|
61
|
+
], FtdsPopoverSection.prototype, "popoverSectionLinkSlot", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sectionStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { popover } from "@fluid-topics/design-system-variables";
|
|
3
|
+
// language=css
|
|
4
|
+
export const sectionStyles = css `
|
|
5
|
+
.ftds-popover-section--heading ftds-typography {
|
|
6
|
+
flex-grow: 1;
|
|
7
|
+
flex-shrink: 1;
|
|
8
|
+
text-overflow: ellipsis;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ftds-popover-section--content {
|
|
14
|
+
color: ${popover.bodyColor};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ftds-popover-section--container {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: ${popover.contentSectionVerticalGap};
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { nothing, PropertyValues, TemplateResult } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsPopoverMargins, FtdsPopoverProperties } from "./ftds-popover.properties";
|
|
4
|
+
import { DesignSystemFamily, DesignSystemSize } from "@fluid-topics/design-system-variables";
|
|
5
|
+
import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
|
|
6
|
+
import { Position } from "@fluid-topics/ft-tooltip";
|
|
7
|
+
export declare class FtdsPopover extends FtLitElement implements FtdsPopoverProperties {
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
10
|
+
closeButtonLabel: string;
|
|
11
|
+
openButtonIcon: FtdsIcons;
|
|
12
|
+
openButtonIconVariant: FtdsIconVariants;
|
|
13
|
+
openButtonLabel: string;
|
|
14
|
+
openButtonTooltipPosition: Position;
|
|
15
|
+
opened: boolean;
|
|
16
|
+
hidden: boolean;
|
|
17
|
+
openButtonSize: DesignSystemSize;
|
|
18
|
+
openButtonFamily: DesignSystemFamily;
|
|
19
|
+
private isTriggerSlotAssigned;
|
|
20
|
+
heading: string;
|
|
21
|
+
margins: FtdsPopoverMargins;
|
|
22
|
+
private popoverWrapper?;
|
|
23
|
+
private triggerSlot?;
|
|
24
|
+
private openingButton?;
|
|
25
|
+
private closingButton?;
|
|
26
|
+
private popoverContentDiv?;
|
|
27
|
+
private popoverContentSlot?;
|
|
28
|
+
private slottedLinkContent?;
|
|
29
|
+
private popoverLinkTypography?;
|
|
30
|
+
private popoverSectionsDiv?;
|
|
31
|
+
private popoverSectionsSlot?;
|
|
32
|
+
private wrapperId;
|
|
33
|
+
private headingId;
|
|
34
|
+
private contentId;
|
|
35
|
+
private maxWidth;
|
|
36
|
+
get openingElement(): HTMLElement | undefined;
|
|
37
|
+
protected render(): typeof nothing | TemplateResult<1>;
|
|
38
|
+
private renderPopover;
|
|
39
|
+
private renderOpeningButton;
|
|
40
|
+
private renderClosingButton;
|
|
41
|
+
private renderFullContent;
|
|
42
|
+
private hideUnusedSlots;
|
|
43
|
+
private hasEmptySlot;
|
|
44
|
+
updated(properties: PropertyValues<FtdsPopover>): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
open(): void;
|
|
47
|
+
private closeAndFocusOpeningButton;
|
|
48
|
+
private onTriggerSlotChange;
|
|
49
|
+
private onTriggerKeydown;
|
|
50
|
+
private watchFocusIn;
|
|
51
|
+
private watchEscapeKey;
|
|
52
|
+
private positionWrapper;
|
|
53
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing, } from "lit";
|
|
8
|
+
import { property, query, state, } from "lit/decorators.js";
|
|
9
|
+
import { computeOffsetAutoPosition, FtLitElement, unslotText, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
11
|
+
import { FtdsButton } from "@fluid-topics/ftds-button";
|
|
12
|
+
import { FtdsPopoverMargins, } from "./ftds-popover.properties";
|
|
13
|
+
import { DesignSystemFamily, DesignSystemSize, popover, } from "@fluid-topics/design-system-variables";
|
|
14
|
+
import { FtdsIcons, FtdsIconVariants, } from "@fluid-topics/ftds-icon";
|
|
15
|
+
import { styles } from "./ftds-popover.styles";
|
|
16
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
17
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
18
|
+
export class FtdsPopover extends FtLitElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.closeButtonLabel = "close info";
|
|
22
|
+
this.openButtonIcon = FtdsIcons.CIRCLE_QUESTION;
|
|
23
|
+
this.openButtonIconVariant = FtdsIconVariants.regular;
|
|
24
|
+
this.openButtonLabel = "more info";
|
|
25
|
+
this.openButtonTooltipPosition = "bottom";
|
|
26
|
+
this.opened = false;
|
|
27
|
+
this.hidden = false;
|
|
28
|
+
this.openButtonSize = DesignSystemSize.medium;
|
|
29
|
+
this.openButtonFamily = DesignSystemFamily.info;
|
|
30
|
+
this.isTriggerSlotAssigned = false;
|
|
31
|
+
this.heading = "";
|
|
32
|
+
this.margins = FtdsPopoverMargins.default;
|
|
33
|
+
this.wrapperId = "ftds-popover-wrapper";
|
|
34
|
+
this.headingId = "ftds-popover-heading";
|
|
35
|
+
this.contentId = "ftds-popover-content";
|
|
36
|
+
this.maxWidth = popover.maxWidth;
|
|
37
|
+
this.onTriggerSlotChange = () => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const assignedTrigger = (_b = (_a = this.triggerSlot) === null || _a === void 0 ? void 0 : _a.assignedElements()) !== null && _b !== void 0 ? _b : [];
|
|
40
|
+
this.isTriggerSlotAssigned = assignedTrigger.length > 0;
|
|
41
|
+
};
|
|
42
|
+
this.onTriggerKeydown = (event) => {
|
|
43
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
this.open();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.watchFocusIn = (event) => {
|
|
49
|
+
if (this.popoverWrapper && !event.composedPath().includes(this.popoverWrapper)) {
|
|
50
|
+
this.close();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.watchEscapeKey = (event) => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (event.key === "Escape") {
|
|
56
|
+
this.close();
|
|
57
|
+
(_a = this.openingElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
get openingElement() {
|
|
62
|
+
var _a;
|
|
63
|
+
const assignedTrigger = (_a = this.triggerSlot) === null || _a === void 0 ? void 0 : _a.assignedElements();
|
|
64
|
+
if ((assignedTrigger === null || assignedTrigger === void 0 ? void 0 : assignedTrigger.length) && assignedTrigger[0] instanceof HTMLElement) {
|
|
65
|
+
return assignedTrigger[0];
|
|
66
|
+
}
|
|
67
|
+
return this.openingButton;
|
|
68
|
+
}
|
|
69
|
+
render() {
|
|
70
|
+
const classes = {
|
|
71
|
+
opened: this.opened,
|
|
72
|
+
};
|
|
73
|
+
return this.hidden ? nothing : html `
|
|
74
|
+
<div part="root-container" class="${classMap(classes)}">
|
|
75
|
+
<slot name="trigger"
|
|
76
|
+
@slotchange=${this.onTriggerSlotChange}
|
|
77
|
+
@click=${this.open}
|
|
78
|
+
@keydown=${this.onTriggerKeydown}
|
|
79
|
+
@focusin=${this.close}
|
|
80
|
+
></slot>
|
|
81
|
+
${this.isTriggerSlotAssigned ? nothing : this.renderOpeningButton()}
|
|
82
|
+
${this.renderPopover()}
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
renderPopover() {
|
|
87
|
+
const wrapperClasses = {
|
|
88
|
+
"ftds-popover--dense": this.margins === FtdsPopoverMargins.dense,
|
|
89
|
+
};
|
|
90
|
+
return this.opened ? html `
|
|
91
|
+
<div part="popover-container">
|
|
92
|
+
<div part="overlay" @click=${this.close}></div>
|
|
93
|
+
<div id="${this.wrapperId}" part="wrapper" role="dialog"
|
|
94
|
+
class="${classMap(wrapperClasses)}"
|
|
95
|
+
aria-labelledby="${ifDefined(this.heading ? `${this.headingId}` : undefined)}"
|
|
96
|
+
aria-describedby="${this.contentId}">
|
|
97
|
+
<div part="closing-button-container">
|
|
98
|
+
${this.renderClosingButton()}
|
|
99
|
+
</div>
|
|
100
|
+
${this.renderFullContent()}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
` : nothing;
|
|
104
|
+
}
|
|
105
|
+
renderOpeningButton() {
|
|
106
|
+
return html `
|
|
107
|
+
<ftds-button @focusin=${this.close}
|
|
108
|
+
part="opening-button"
|
|
109
|
+
icon="${this.openButtonIcon}"
|
|
110
|
+
variant="${this.openButtonIconVariant}"
|
|
111
|
+
size="${this.openButtonSize}" family="${this.openButtonFamily}"
|
|
112
|
+
label="${this.openButtonLabel}" tooltipposition="${this.openButtonTooltipPosition}"
|
|
113
|
+
aria-haspopup="true" aria-expanded="${this.opened}" aria-controls="${this.wrapperId}"
|
|
114
|
+
@click=${this.open}>
|
|
115
|
+
</ftds-button>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
renderClosingButton() {
|
|
119
|
+
return html `
|
|
120
|
+
<ftds-button part="closing-button"
|
|
121
|
+
icon="${FtdsIcons.XMARK}"
|
|
122
|
+
size="${DesignSystemSize.small}"
|
|
123
|
+
family="${DesignSystemFamily.neutral}"
|
|
124
|
+
label="${this.closeButtonLabel}"
|
|
125
|
+
@click=${this.closeAndFocusOpeningButton}>
|
|
126
|
+
</ftds-button>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
renderFullContent() {
|
|
130
|
+
return html `
|
|
131
|
+
<slot name="heading">
|
|
132
|
+
${this.heading ? html `
|
|
133
|
+
<div id="ftds-popover-heading" part="heading">
|
|
134
|
+
<ftds-typography element="span" variant="${FtdsTypographyVariants.body2semibold}">
|
|
135
|
+
${this.heading}
|
|
136
|
+
</ftds-typography>
|
|
137
|
+
</div>
|
|
138
|
+
` : nothing}
|
|
139
|
+
</slot>
|
|
140
|
+
<div id="ftds-popover-content" part="content">
|
|
141
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}">
|
|
142
|
+
<slot part="popover-content-slot"></slot>
|
|
143
|
+
</ftds-typography>
|
|
144
|
+
</div>
|
|
145
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}" part="popover-link-typography">
|
|
146
|
+
<slot name="link"
|
|
147
|
+
part="popover-link"
|
|
148
|
+
@slotchange=${() => this.requestUpdate()}
|
|
149
|
+
></slot>
|
|
150
|
+
</ftds-typography>
|
|
151
|
+
<div part="popover-sections">
|
|
152
|
+
<slot name="sections" part="popover-sections-slot"></slot>
|
|
153
|
+
</div>
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
hideUnusedSlots() {
|
|
157
|
+
var _a, _b, _c;
|
|
158
|
+
(_a = this.popoverLinkTypography) === null || _a === void 0 ? void 0 : _a.classList.toggle("hidden", this.hasEmptySlot(this.slottedLinkContent));
|
|
159
|
+
(_b = this.popoverContentDiv) === null || _b === void 0 ? void 0 : _b.classList.toggle("hidden", this.hasEmptySlot(this.popoverContentSlot));
|
|
160
|
+
(_c = this.popoverSectionsDiv) === null || _c === void 0 ? void 0 : _c.classList.toggle("hidden", this.hasEmptySlot(this.popoverSectionsSlot));
|
|
161
|
+
}
|
|
162
|
+
hasEmptySlot(slot) {
|
|
163
|
+
return unslotText(slot).trim().length === 0;
|
|
164
|
+
}
|
|
165
|
+
updated(properties) {
|
|
166
|
+
super.updated(properties);
|
|
167
|
+
if (properties.has("opened")) {
|
|
168
|
+
if (this.opened) {
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
this.positionWrapper();
|
|
171
|
+
document.addEventListener("keydown", this.watchEscapeKey);
|
|
172
|
+
document.addEventListener("focusin", this.watchFocusIn);
|
|
173
|
+
}, 0);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
document.removeEventListener("keydown", this.watchEscapeKey);
|
|
177
|
+
document.removeEventListener("focusin", this.watchFocusIn);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
close() {
|
|
182
|
+
this.opened = false;
|
|
183
|
+
this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: false } }));
|
|
184
|
+
}
|
|
185
|
+
open() {
|
|
186
|
+
this.opened = true;
|
|
187
|
+
this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: true } }));
|
|
188
|
+
}
|
|
189
|
+
closeAndFocusOpeningButton() {
|
|
190
|
+
var _a;
|
|
191
|
+
this.close();
|
|
192
|
+
(_a = this.openingElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
193
|
+
if (window.FluidTopicsA11yHints.isKeyboardNavigation && this.openingElement instanceof FtdsButton) {
|
|
194
|
+
this.openingElement.showTooltip();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async positionWrapper() {
|
|
198
|
+
var _a, _b;
|
|
199
|
+
if (this.popoverWrapper) {
|
|
200
|
+
this.popoverWrapper.classList.remove("positioned");
|
|
201
|
+
this.popoverWrapper.style.left = "";
|
|
202
|
+
this.popoverWrapper.style.top = "";
|
|
203
|
+
if (this.openingElement) {
|
|
204
|
+
const allowedPlacements = [
|
|
205
|
+
"bottom-start",
|
|
206
|
+
"right-start",
|
|
207
|
+
"bottom-end",
|
|
208
|
+
"right-end",
|
|
209
|
+
"left-start",
|
|
210
|
+
"left-end",
|
|
211
|
+
"top-start",
|
|
212
|
+
"top-end",
|
|
213
|
+
];
|
|
214
|
+
const defaultPlacement = "bottom-start";
|
|
215
|
+
const options = { placement: defaultPlacement, allowedPlacements: allowedPlacements, maxWidthCssVariable: this.maxWidth };
|
|
216
|
+
const { x, y } = await computeOffsetAutoPosition(this.openingElement, this.popoverWrapper, options);
|
|
217
|
+
this.popoverWrapper.style.left = `${x}px`;
|
|
218
|
+
this.popoverWrapper.style.top = `${y}px`;
|
|
219
|
+
}
|
|
220
|
+
this.popoverWrapper.classList.add("positioned");
|
|
221
|
+
}
|
|
222
|
+
this.hideUnusedSlots();
|
|
223
|
+
(_a = this.closingButton) === null || _a === void 0 ? void 0 : _a.focus();
|
|
224
|
+
if (window.FluidTopicsA11yHints.isKeyboardNavigation) {
|
|
225
|
+
(_b = this.closingButton) === null || _b === void 0 ? void 0 : _b.showTooltip();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
FtdsPopover.styles = styles;
|
|
230
|
+
FtdsPopover.elementDefinitions = {
|
|
231
|
+
"ftds-typography": FtdsTypography,
|
|
232
|
+
"ftds-button": FtdsButton,
|
|
233
|
+
};
|
|
234
|
+
__decorate([
|
|
235
|
+
property()
|
|
236
|
+
], FtdsPopover.prototype, "closeButtonLabel", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property()
|
|
239
|
+
], FtdsPopover.prototype, "openButtonIcon", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property()
|
|
242
|
+
], FtdsPopover.prototype, "openButtonIconVariant", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
property()
|
|
245
|
+
], FtdsPopover.prototype, "openButtonLabel", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
property()
|
|
248
|
+
], FtdsPopover.prototype, "openButtonTooltipPosition", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
property({ type: Boolean })
|
|
251
|
+
], FtdsPopover.prototype, "opened", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
property({ type: Boolean })
|
|
254
|
+
], FtdsPopover.prototype, "hidden", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
property({ type: DesignSystemSize })
|
|
257
|
+
], FtdsPopover.prototype, "openButtonSize", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
property({ type: DesignSystemFamily })
|
|
260
|
+
], FtdsPopover.prototype, "openButtonFamily", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
state()
|
|
263
|
+
], FtdsPopover.prototype, "isTriggerSlotAssigned", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
property()
|
|
266
|
+
], FtdsPopover.prototype, "heading", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
property()
|
|
269
|
+
], FtdsPopover.prototype, "margins", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
query(`[part="wrapper"]`)
|
|
272
|
+
], FtdsPopover.prototype, "popoverWrapper", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
query(`slot[name="trigger"]`)
|
|
275
|
+
], FtdsPopover.prototype, "triggerSlot", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
query(`[part="opening-button"]`)
|
|
278
|
+
], FtdsPopover.prototype, "openingButton", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
query(`[part="closing-button"]`)
|
|
281
|
+
], FtdsPopover.prototype, "closingButton", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
query(`[part="content"]`)
|
|
284
|
+
], FtdsPopover.prototype, "popoverContentDiv", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
query(`[part="popover-content-slot"]`)
|
|
287
|
+
], FtdsPopover.prototype, "popoverContentSlot", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
query(`[part="popover-link"]`)
|
|
290
|
+
], FtdsPopover.prototype, "slottedLinkContent", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
query(`[part="popover-link-typography"]`)
|
|
293
|
+
], FtdsPopover.prototype, "popoverLinkTypography", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
query(`[part="popover-sections"]`)
|
|
296
|
+
], FtdsPopover.prototype, "popoverSectionsDiv", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
query(`[part="popover-sections-slot"]`)
|
|
299
|
+
], FtdsPopover.prototype, "popoverSectionsSlot", void 0);
|