@fluid-topics/ft-popover 2.0.5 → 2.0.7
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 +21 -2
- package/build/define.js +2 -0
- package/build/ft-base-popover.d.ts +44 -0
- package/build/ft-base-popover.js +157 -0
- package/build/ft-popover.d.ts +18 -0
- package/build/ft-popover.js +67 -0
- package/build/ft-popover.light.js +326 -234
- package/build/ft-popover.min.js +352 -260
- package/build/ft-popover.properties.d.ts +3 -0
- package/build/ft-popover.properties.js +1 -0
- package/build/ft-popover.styles.d.ts +1 -0
- package/build/ft-popover.styles.js +65 -0
- package/build/ftds-popover.d.ts +17 -29
- package/build/ftds-popover.js +61 -166
- package/build/ftds-popover.properties.d.ts +2 -7
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ftPopoverStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
// language=css
|
|
3
|
+
export const ftPopoverStyles = css `
|
|
4
|
+
:host {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[part="root-container"] {
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[part="popover-container"] {
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 100;
|
|
16
|
+
display: block;
|
|
17
|
+
margin: auto;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part="closing-button-container"] {
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 8px;
|
|
23
|
+
right: 8px;
|
|
24
|
+
|
|
25
|
+
ft-button {
|
|
26
|
+
--ft-button-icon-size: 12px;
|
|
27
|
+
--ft-button-background-color: #fff;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part="overlay"] {
|
|
32
|
+
position: fixed;
|
|
33
|
+
top: 0;
|
|
34
|
+
right: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
height: 100%;
|
|
38
|
+
width: 100%;
|
|
39
|
+
opacity: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[part="wrapper"] {
|
|
43
|
+
visibility: hidden;
|
|
44
|
+
position: fixed;
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
|
|
48
|
+
max-width: 464px;
|
|
49
|
+
width: max-content;
|
|
50
|
+
|
|
51
|
+
padding: 24px;
|
|
52
|
+
|
|
53
|
+
background-color: #fff;
|
|
54
|
+
border-radius: 8px;
|
|
55
|
+
box-shadow: 0 0 1px 0 #0000000F, 0 2px 5px 0 #00000024, 0 4px 10px 0 #0000000F;;
|
|
56
|
+
|
|
57
|
+
&.positioned {
|
|
58
|
+
visibility: visible;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hidden {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
`;
|
package/build/ftds-popover.d.ts
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ElementDefinitionsMap
|
|
1
|
+
import { TemplateResult } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsButton } from "@fluid-topics/ft-button";
|
|
3
4
|
import { FtdsPopoverProperties } from "./ftds-popover.properties";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
7
|
-
export declare class FtdsPopover extends FtLitElement implements FtdsPopoverProperties {
|
|
8
|
-
static elementDefinitions: ElementDefinitionsMap;
|
|
5
|
+
import { FtBasePopover } from "./ft-base-popover";
|
|
6
|
+
export declare class FtdsPopover extends FtBasePopover implements FtdsPopoverProperties {
|
|
9
7
|
static styles: import("lit").CSSResult;
|
|
8
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
10
9
|
heading: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
openButtonLabel: string;
|
|
14
|
-
openButtonTooltipPosition: Position;
|
|
15
|
-
opened: boolean;
|
|
16
|
-
hidden: boolean;
|
|
17
|
-
openButtonSize: DesignSystemSize;
|
|
18
|
-
openButtonFamily: DesignSystemFamily;
|
|
19
|
-
private openingButton?;
|
|
20
|
-
private closingButton?;
|
|
21
|
-
private popoverWrapper?;
|
|
10
|
+
protected openingButton?: FtdsButton;
|
|
11
|
+
protected closingButton?: FtdsButton;
|
|
22
12
|
private popoverContentDiv?;
|
|
23
13
|
private popoverContentSlot?;
|
|
24
14
|
private slottedLinkContent?;
|
|
25
15
|
private popoverLinkTypography?;
|
|
26
16
|
private popoverSectionsDiv?;
|
|
27
17
|
private popoverSectionsSlot?;
|
|
28
|
-
protected
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
private positionWrapper;
|
|
38
|
-
private hideUnusedSlots;
|
|
18
|
+
protected wrapperId: string;
|
|
19
|
+
protected headingId: string;
|
|
20
|
+
protected contentId: string;
|
|
21
|
+
maxWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
22
|
+
protected renderOpeningButton(): TemplateResult;
|
|
23
|
+
protected renderClosingButton(): TemplateResult;
|
|
24
|
+
protected renderFullContent(): TemplateResult;
|
|
25
|
+
protected hideUnusedSlots(): void;
|
|
26
|
+
private hasEmptySlot;
|
|
39
27
|
}
|
package/build/ftds-popover.js
CHANGED
|
@@ -5,154 +5,73 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing } from "lit";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { computeOffsetAutoPosition, FtLitElement, unslotText } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { query } from "lit/decorators.js";
|
|
9
|
+
import { unslotText } from "@fluid-topics/ft-wc-utils";
|
|
11
10
|
import { FtdsTypography, FtdsTypographyVariants } from "@fluid-topics/ft-typography";
|
|
12
11
|
import { FtdsButton } from "@fluid-topics/ft-button";
|
|
13
|
-
import {
|
|
14
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
15
|
-
import { DesignSystemFamily, DesignSystemSize } from "@fluid-topics/design-system-variables";
|
|
12
|
+
import { DesignSystemFamily, DesignSystemSize, popover } from "@fluid-topics/design-system-variables";
|
|
16
13
|
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
17
|
-
|
|
14
|
+
import { FtBasePopover } from "./ft-base-popover";
|
|
15
|
+
import { property } from "lit/decorators.js";
|
|
16
|
+
import { styles } from "./ftds-popover.styles";
|
|
17
|
+
class FtdsPopover extends FtBasePopover {
|
|
18
18
|
constructor() {
|
|
19
19
|
super(...arguments);
|
|
20
20
|
this.heading = "";
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.opened = false;
|
|
26
|
-
this.hidden = false;
|
|
27
|
-
this.openButtonSize = DesignSystemSize.medium;
|
|
28
|
-
this.openButtonFamily = DesignSystemFamily.info;
|
|
29
|
-
this.watchFocusIn = (event) => {
|
|
30
|
-
if (this.popoverWrapper && !event.composedPath().includes(this.popoverWrapper)) {
|
|
31
|
-
this.close();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
this.watchEscapeKey = (event) => {
|
|
35
|
-
var _a;
|
|
36
|
-
if (event.key === "Escape") {
|
|
37
|
-
this.close();
|
|
38
|
-
(_a = this.openingButton) === null || _a === void 0 ? void 0 : _a.focus();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
21
|
+
this.wrapperId = "ftds-popover-wrapper";
|
|
22
|
+
this.headingId = "ftds-popover-heading";
|
|
23
|
+
this.contentId = "ftds-popover-content";
|
|
24
|
+
this.maxWidth = popover.maxWidth;
|
|
41
25
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
label="${this.openButtonLabel}" tooltipposition="${this.openButtonTooltipPosition}"
|
|
53
|
-
aria-haspopup="true" aria-expanded="${this.opened}" aria-controls="ftds-popover-wrapper"
|
|
54
|
-
@click=${this.open}>
|
|
55
|
-
</ftds-button>
|
|
56
|
-
${this.renderPopover()}
|
|
57
|
-
</div>
|
|
26
|
+
renderOpeningButton() {
|
|
27
|
+
return html `
|
|
28
|
+
<ftds-button @focusin=${this.close}
|
|
29
|
+
part="opening-button"
|
|
30
|
+
icon="${this.openButtonIcon}"
|
|
31
|
+
size="${this.openButtonSize}" family="${this.openButtonFamily}"
|
|
32
|
+
label="${this.openButtonLabel}" tooltipposition="${this.openButtonTooltipPosition}"
|
|
33
|
+
aria-haspopup="true" aria-expanded="${this.opened}" aria-controls="${this.wrapperId}"
|
|
34
|
+
@click=${this.open}>
|
|
35
|
+
</ftds-button>
|
|
58
36
|
`;
|
|
59
37
|
}
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
size="${DesignSystemSize.small}"
|
|
71
|
-
family="${DesignSystemFamily.neutral}"
|
|
72
|
-
label="${this.closeButtonLabel}"
|
|
73
|
-
@click=${this.closeAndFocusOpeningButton}></ftds-button>
|
|
74
|
-
</div>
|
|
75
|
-
<slot name="heading">
|
|
76
|
-
${this.heading ? html `
|
|
77
|
-
<div id="ftds-popover-heading" part="heading">
|
|
78
|
-
<ftds-typography element="span" variant="${FtdsTypographyVariants.body2semibold}">
|
|
79
|
-
${this.heading}
|
|
80
|
-
</ftds-typography>
|
|
81
|
-
</div>
|
|
82
|
-
` : nothing}
|
|
83
|
-
</slot>
|
|
84
|
-
<div id="ftds-popover-content" part="content">
|
|
85
|
-
<ftds-typography variant="${FtdsTypographyVariants.body2medium}">
|
|
86
|
-
<slot part="popover-content-slot"></slot>
|
|
87
|
-
</ftds-typography>
|
|
88
|
-
</div>
|
|
89
|
-
<ftds-typography variant="${FtdsTypographyVariants.body2medium}" part="popover-link-typography">
|
|
90
|
-
<slot name="link"
|
|
91
|
-
part="popover-link"
|
|
92
|
-
@slotchange=${() => this.requestUpdate()}
|
|
93
|
-
></slot>
|
|
94
|
-
</ftds-typography>
|
|
95
|
-
<div part="popover-sections">
|
|
96
|
-
<slot name="sections" part="popover-sections-slot"></slot>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
` : nothing;
|
|
101
|
-
}
|
|
102
|
-
updated(properties) {
|
|
103
|
-
super.updated(properties);
|
|
104
|
-
if (properties.has("opened")) {
|
|
105
|
-
if (this.opened) {
|
|
106
|
-
setTimeout(() => {
|
|
107
|
-
this.positionWrapper();
|
|
108
|
-
document.addEventListener("keydown", this.watchEscapeKey);
|
|
109
|
-
document.addEventListener("focusin", this.watchFocusIn);
|
|
110
|
-
}, 0);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
document.removeEventListener("keydown", this.watchEscapeKey);
|
|
114
|
-
document.removeEventListener("focusin", this.watchFocusIn);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
close() {
|
|
119
|
-
this.opened = false;
|
|
120
|
-
this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: false } }));
|
|
121
|
-
}
|
|
122
|
-
open() {
|
|
123
|
-
this.opened = true;
|
|
124
|
-
this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: true } }));
|
|
125
|
-
}
|
|
126
|
-
hasEmptySlot(slot) {
|
|
127
|
-
return unslotText(slot).trim().length === 0;
|
|
128
|
-
}
|
|
129
|
-
closeAndFocusOpeningButton() {
|
|
130
|
-
var _a, _b;
|
|
131
|
-
this.close();
|
|
132
|
-
(_a = this.openingButton) === null || _a === void 0 ? void 0 : _a.focus();
|
|
133
|
-
if (window.FluidTopicsA11yHints.isKeyboardNavigation) {
|
|
134
|
-
(_b = this.openingButton) === null || _b === void 0 ? void 0 : _b.showTooltip();
|
|
135
|
-
}
|
|
38
|
+
renderClosingButton() {
|
|
39
|
+
return html `
|
|
40
|
+
<ftds-button part="closing-button"
|
|
41
|
+
icon="${FtIcons.CLOSE}"
|
|
42
|
+
size="${DesignSystemSize.small}"
|
|
43
|
+
family="${DesignSystemFamily.neutral}"
|
|
44
|
+
label="${this.closeButtonLabel}"
|
|
45
|
+
@click=${this.closeAndFocusOpeningButton}>
|
|
46
|
+
</ftds-button>
|
|
47
|
+
`;
|
|
136
48
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
49
|
+
renderFullContent() {
|
|
50
|
+
return html `
|
|
51
|
+
<slot name="heading">
|
|
52
|
+
${this.heading ? html `
|
|
53
|
+
<div id="ftds-popover-heading" part="heading">
|
|
54
|
+
<ftds-typography element="span" variant="${FtdsTypographyVariants.body2semibold}">
|
|
55
|
+
${this.heading}
|
|
56
|
+
</ftds-typography>
|
|
57
|
+
</div>
|
|
58
|
+
` : nothing}
|
|
59
|
+
</slot>
|
|
60
|
+
<div id="ftds-popover-content" part="content">
|
|
61
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}">
|
|
62
|
+
<slot part="popover-content-slot"></slot>
|
|
63
|
+
</ftds-typography>
|
|
64
|
+
</div>
|
|
65
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2medium}" part="popover-link-typography">
|
|
66
|
+
<slot name="link"
|
|
67
|
+
part="popover-link"
|
|
68
|
+
@slotchange=${() => this.requestUpdate()}
|
|
69
|
+
></slot>
|
|
70
|
+
</ftds-typography>
|
|
71
|
+
<div part="popover-sections">
|
|
72
|
+
<slot name="sections" part="popover-sections-slot"></slot>
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
156
75
|
}
|
|
157
76
|
hideUnusedSlots() {
|
|
158
77
|
var _a, _b, _c;
|
|
@@ -160,48 +79,24 @@ class FtdsPopover extends FtLitElement {
|
|
|
160
79
|
(_b = this.popoverContentDiv) === null || _b === void 0 ? void 0 : _b.classList.toggle("hidden", this.hasEmptySlot(this.popoverContentSlot));
|
|
161
80
|
(_c = this.popoverSectionsDiv) === null || _c === void 0 ? void 0 : _c.classList.toggle("hidden", this.hasEmptySlot(this.popoverSectionsSlot));
|
|
162
81
|
}
|
|
82
|
+
hasEmptySlot(slot) {
|
|
83
|
+
return unslotText(slot).trim().length === 0;
|
|
84
|
+
}
|
|
163
85
|
}
|
|
86
|
+
FtdsPopover.styles = styles;
|
|
164
87
|
FtdsPopover.elementDefinitions = {
|
|
165
88
|
"ftds-typography": FtdsTypography,
|
|
166
89
|
"ftds-button": FtdsButton,
|
|
167
90
|
};
|
|
168
|
-
FtdsPopover.styles = styles;
|
|
169
91
|
__decorate([
|
|
170
92
|
property()
|
|
171
93
|
], FtdsPopover.prototype, "heading", void 0);
|
|
172
|
-
__decorate([
|
|
173
|
-
property()
|
|
174
|
-
], FtdsPopover.prototype, "closeButtonLabel", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
property()
|
|
177
|
-
], FtdsPopover.prototype, "openButtonIcon", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
property()
|
|
180
|
-
], FtdsPopover.prototype, "openButtonLabel", void 0);
|
|
181
|
-
__decorate([
|
|
182
|
-
property()
|
|
183
|
-
], FtdsPopover.prototype, "openButtonTooltipPosition", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
property({ type: Boolean })
|
|
186
|
-
], FtdsPopover.prototype, "opened", void 0);
|
|
187
|
-
__decorate([
|
|
188
|
-
property({ type: Boolean })
|
|
189
|
-
], FtdsPopover.prototype, "hidden", void 0);
|
|
190
|
-
__decorate([
|
|
191
|
-
property({ type: DesignSystemSize })
|
|
192
|
-
], FtdsPopover.prototype, "openButtonSize", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
property({ type: DesignSystemFamily })
|
|
195
|
-
], FtdsPopover.prototype, "openButtonFamily", void 0);
|
|
196
94
|
__decorate([
|
|
197
95
|
query(`[part="opening-button"]`)
|
|
198
96
|
], FtdsPopover.prototype, "openingButton", void 0);
|
|
199
97
|
__decorate([
|
|
200
98
|
query(`[part="closing-button"]`)
|
|
201
99
|
], FtdsPopover.prototype, "closingButton", void 0);
|
|
202
|
-
__decorate([
|
|
203
|
-
query(`[part="wrapper"]`)
|
|
204
|
-
], FtdsPopover.prototype, "popoverWrapper", void 0);
|
|
205
100
|
__decorate([
|
|
206
101
|
query(`[part="content"]`)
|
|
207
102
|
], FtdsPopover.prototype, "popoverContentDiv", void 0);
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface FtdsPopoverProperties {
|
|
3
|
-
opened?: boolean;
|
|
4
|
-
hidden?: boolean;
|
|
1
|
+
import { FtBasePopoverProperties } from "./ft-base-popover";
|
|
2
|
+
export interface FtdsPopoverProperties extends FtBasePopoverProperties {
|
|
5
3
|
heading?: string;
|
|
6
|
-
closeButtonLabel?: string;
|
|
7
|
-
openButtonLabel?: string;
|
|
8
|
-
openButtonTooltipPosition?: Position;
|
|
9
4
|
}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-popover",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "A simple popover component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fluid-topics/design-system-variables": "3.1.0",
|
|
23
|
-
"@fluid-topics/ft-button": "2.0.
|
|
24
|
-
"@fluid-topics/ft-icon": "2.0.
|
|
25
|
-
"@fluid-topics/ft-link": "2.0.
|
|
26
|
-
"@fluid-topics/ft-typography": "2.0.
|
|
27
|
-
"@fluid-topics/ft-wc-utils": "2.0.
|
|
23
|
+
"@fluid-topics/ft-button": "2.0.7",
|
|
24
|
+
"@fluid-topics/ft-icon": "2.0.7",
|
|
25
|
+
"@fluid-topics/ft-link": "2.0.7",
|
|
26
|
+
"@fluid-topics/ft-typography": "2.0.7",
|
|
27
|
+
"@fluid-topics/ft-wc-utils": "2.0.7",
|
|
28
28
|
"lit": "3.1.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "8555f88ae4858c380daee8311a887142043c46a9"
|
|
31
31
|
}
|