@fluid-topics/ft-popover 2.0.35 → 2.0.37
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/build/ft-base-popover.d.ts +7 -0
- package/build/ft-base-popover.js +51 -12
- package/build/ft-popover.light.js +327 -312
- package/build/ft-popover.min.js +429 -414
- package/build/ftds-popover.d.ts +4 -1
- package/build/ftds-popover.js +16 -6
- package/build/ftds-popover.properties.d.ts +5 -0
- package/build/ftds-popover.properties.js +5 -1
- package/build/ftds-popover.styles.js +13 -4
- package/package.json +8 -8
|
@@ -3,6 +3,7 @@ import { FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
|
3
3
|
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
4
4
|
import { DesignSystemFamily, DesignSystemSize } from "@fluid-topics/design-system-variables";
|
|
5
5
|
import { nothing, PropertyValues, TemplateResult } from "lit";
|
|
6
|
+
import { ClassInfo } from "lit/directives/class-map.js";
|
|
6
7
|
import { FtBaseButton } from "@fluid-topics/ft-button/build/ft-base-button";
|
|
7
8
|
export interface FtBasePopoverProperties {
|
|
8
9
|
opened?: boolean;
|
|
@@ -21,9 +22,11 @@ export declare abstract class FtBasePopover extends FtLitElement implements FtBa
|
|
|
21
22
|
hidden: boolean;
|
|
22
23
|
openButtonSize: DesignSystemSize;
|
|
23
24
|
openButtonFamily: DesignSystemFamily;
|
|
25
|
+
private isTriggerSlotAssigned;
|
|
24
26
|
protected abstract openingButton?: FtBaseButton;
|
|
25
27
|
protected abstract closingButton?: FtBaseButton;
|
|
26
28
|
private popoverWrapper?;
|
|
29
|
+
private triggerSlot?;
|
|
27
30
|
protected abstract wrapperId: string;
|
|
28
31
|
protected abstract headingId: string;
|
|
29
32
|
protected abstract contentId: string;
|
|
@@ -32,13 +35,17 @@ export declare abstract class FtBasePopover extends FtLitElement implements FtBa
|
|
|
32
35
|
protected abstract renderClosingButton(): TemplateResult;
|
|
33
36
|
protected abstract renderFullContent(): TemplateResult;
|
|
34
37
|
protected abstract hideUnusedSlots(): void;
|
|
38
|
+
get openingElement(): HTMLElement | undefined;
|
|
35
39
|
protected render(): typeof nothing | TemplateResult<1>;
|
|
36
40
|
protected renderPopover(): typeof nothing | TemplateResult<1>;
|
|
37
41
|
updated(properties: PropertyValues<FtBasePopover>): void;
|
|
38
42
|
close(): void;
|
|
39
43
|
open(): void;
|
|
40
44
|
protected closeAndFocusOpeningButton(): void;
|
|
45
|
+
private onTriggerSlotChange;
|
|
46
|
+
private onTriggerKeydown;
|
|
41
47
|
private watchFocusIn;
|
|
42
48
|
private watchEscapeKey;
|
|
43
49
|
private positionWrapper;
|
|
50
|
+
protected getPopoverWrapperClasses(): ClassInfo;
|
|
44
51
|
}
|
package/build/ft-base-popover.js
CHANGED
|
@@ -4,13 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { computeOffsetAutoPosition, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
8
|
-
import { property, query } from "lit/decorators.js";
|
|
7
|
+
import { computeOffsetAutoPosition, FtLitElement, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { property, query, state, } from "lit/decorators.js";
|
|
9
9
|
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
10
10
|
import { DesignSystemFamily, DesignSystemSize, } from "@fluid-topics/design-system-variables";
|
|
11
|
-
import { html, nothing } from "lit";
|
|
12
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
+
import { html, nothing, } from "lit";
|
|
12
|
+
import { classMap, } from "lit/directives/class-map.js";
|
|
13
13
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
14
|
+
import { FtBaseButton } from "@fluid-topics/ft-button/build/ft-base-button";
|
|
14
15
|
import { FtCssVariableFactory } from "@fluid-topics/design-system-variables/build/FtCssVariables";
|
|
15
16
|
export class FtBasePopover extends FtLitElement {
|
|
16
17
|
constructor() {
|
|
@@ -24,7 +25,19 @@ export class FtBasePopover extends FtLitElement {
|
|
|
24
25
|
this.hidden = false;
|
|
25
26
|
this.openButtonSize = DesignSystemSize.medium;
|
|
26
27
|
this.openButtonFamily = DesignSystemFamily.info;
|
|
28
|
+
this.isTriggerSlotAssigned = false;
|
|
27
29
|
this.maxWidth = FtCssVariableFactory.create("--ft-popover-max-width", "", "SIZE", "464px");
|
|
30
|
+
this.onTriggerSlotChange = () => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const assignedTrigger = (_b = (_a = this.triggerSlot) === null || _a === void 0 ? void 0 : _a.assignedElements()) !== null && _b !== void 0 ? _b : [];
|
|
33
|
+
this.isTriggerSlotAssigned = assignedTrigger.length > 0;
|
|
34
|
+
};
|
|
35
|
+
this.onTriggerKeydown = (event) => {
|
|
36
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
this.open();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
28
41
|
this.watchFocusIn = (event) => {
|
|
29
42
|
if (this.popoverWrapper && !event.composedPath().includes(this.popoverWrapper)) {
|
|
30
43
|
this.close();
|
|
@@ -34,17 +47,31 @@ export class FtBasePopover extends FtLitElement {
|
|
|
34
47
|
var _a;
|
|
35
48
|
if (event.key === "Escape") {
|
|
36
49
|
this.close();
|
|
37
|
-
(_a = this.
|
|
50
|
+
(_a = this.openingElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
38
51
|
}
|
|
39
52
|
};
|
|
40
53
|
}
|
|
54
|
+
get openingElement() {
|
|
55
|
+
var _a;
|
|
56
|
+
const assignedTrigger = (_a = this.triggerSlot) === null || _a === void 0 ? void 0 : _a.assignedElements();
|
|
57
|
+
if ((assignedTrigger === null || assignedTrigger === void 0 ? void 0 : assignedTrigger.length) && assignedTrigger[0] instanceof HTMLElement) {
|
|
58
|
+
return assignedTrigger[0];
|
|
59
|
+
}
|
|
60
|
+
return this.openingButton;
|
|
61
|
+
}
|
|
41
62
|
render() {
|
|
42
63
|
const classes = {
|
|
43
64
|
opened: this.opened,
|
|
44
65
|
};
|
|
45
66
|
return this.hidden ? nothing : html `
|
|
46
67
|
<div part="root-container" class="${classMap(classes)}">
|
|
47
|
-
|
|
68
|
+
<slot name="trigger"
|
|
69
|
+
@slotchange=${this.onTriggerSlotChange}
|
|
70
|
+
@click=${this.open}
|
|
71
|
+
@keydown=${this.onTriggerKeydown}
|
|
72
|
+
@focusin=${this.close}
|
|
73
|
+
></slot>
|
|
74
|
+
${this.isTriggerSlotAssigned ? nothing : this.renderOpeningButton()}
|
|
48
75
|
${this.renderPopover()}
|
|
49
76
|
</div>
|
|
50
77
|
`;
|
|
@@ -54,6 +81,7 @@ export class FtBasePopover extends FtLitElement {
|
|
|
54
81
|
<div part="popover-container">
|
|
55
82
|
<div part="overlay" @click=${this.close}></div>
|
|
56
83
|
<div id="${this.wrapperId}" part="wrapper" role="dialog"
|
|
84
|
+
class="${classMap(this.getPopoverWrapperClasses())}"
|
|
57
85
|
aria-labelledby="${ifDefined(this.heading ? `${this.headingId}` : undefined)}"
|
|
58
86
|
aria-describedby="${this.contentId}">
|
|
59
87
|
<div part="closing-button-container">
|
|
@@ -89,11 +117,13 @@ export class FtBasePopover extends FtLitElement {
|
|
|
89
117
|
this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: true } }));
|
|
90
118
|
}
|
|
91
119
|
closeAndFocusOpeningButton() {
|
|
92
|
-
var _a
|
|
120
|
+
var _a;
|
|
93
121
|
this.close();
|
|
94
|
-
(_a = this.
|
|
122
|
+
(_a = this.openingElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
95
123
|
if (window.FluidTopicsA11yHints.isKeyboardNavigation) {
|
|
96
|
-
(
|
|
124
|
+
if (this.openingElement instanceof FtBaseButton) {
|
|
125
|
+
this.openingElement.showTooltip();
|
|
126
|
+
}
|
|
97
127
|
}
|
|
98
128
|
}
|
|
99
129
|
async positionWrapper() {
|
|
@@ -102,7 +132,7 @@ export class FtBasePopover extends FtLitElement {
|
|
|
102
132
|
this.popoverWrapper.classList.remove("positioned");
|
|
103
133
|
this.popoverWrapper.style.left = "";
|
|
104
134
|
this.popoverWrapper.style.top = "";
|
|
105
|
-
if (this.
|
|
135
|
+
if (this.openingElement) {
|
|
106
136
|
const allowedPlacements = [
|
|
107
137
|
"bottom-start",
|
|
108
138
|
"right-start",
|
|
@@ -111,11 +141,11 @@ export class FtBasePopover extends FtLitElement {
|
|
|
111
141
|
"left-start",
|
|
112
142
|
"left-end",
|
|
113
143
|
"top-start",
|
|
114
|
-
"top-end"
|
|
144
|
+
"top-end",
|
|
115
145
|
];
|
|
116
146
|
const defaultPlacement = "bottom-start";
|
|
117
147
|
const options = { placement: defaultPlacement, allowedPlacements: allowedPlacements, maxWidthCssVariable: this.maxWidth };
|
|
118
|
-
const { x, y } = await computeOffsetAutoPosition(this.
|
|
148
|
+
const { x, y } = await computeOffsetAutoPosition(this.openingElement, this.popoverWrapper, options);
|
|
119
149
|
this.popoverWrapper.style.left = `${x}px`;
|
|
120
150
|
this.popoverWrapper.style.top = `${y}px`;
|
|
121
151
|
}
|
|
@@ -127,6 +157,9 @@ export class FtBasePopover extends FtLitElement {
|
|
|
127
157
|
(_b = this.closingButton) === null || _b === void 0 ? void 0 : _b.showTooltip();
|
|
128
158
|
}
|
|
129
159
|
}
|
|
160
|
+
getPopoverWrapperClasses() {
|
|
161
|
+
return {};
|
|
162
|
+
}
|
|
130
163
|
}
|
|
131
164
|
__decorate([
|
|
132
165
|
property()
|
|
@@ -152,6 +185,12 @@ __decorate([
|
|
|
152
185
|
__decorate([
|
|
153
186
|
property({ type: DesignSystemFamily })
|
|
154
187
|
], FtBasePopover.prototype, "openButtonFamily", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
state()
|
|
190
|
+
], FtBasePopover.prototype, "isTriggerSlotAssigned", void 0);
|
|
155
191
|
__decorate([
|
|
156
192
|
query(`[part="wrapper"]`)
|
|
157
193
|
], FtBasePopover.prototype, "popoverWrapper", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
query(`slot[name="trigger"]`)
|
|
196
|
+
], FtBasePopover.prototype, "triggerSlot", void 0);
|