@fluid-topics/ftds-floating-menu 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 +19 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +9 -0
- package/build/definitions.js +8 -0
- package/build/ftds-floating-menu-item.d.ts +20 -0
- package/build/ftds-floating-menu-item.js +90 -0
- package/build/ftds-floating-menu-item.properties.d.ts +7 -0
- package/build/ftds-floating-menu-item.properties.js +1 -0
- package/build/ftds-floating-menu-item.styles.d.ts +4 -0
- package/build/ftds-floating-menu-item.styles.js +42 -0
- package/build/ftds-floating-menu-label.d.ts +7 -0
- package/build/ftds-floating-menu-label.js +19 -0
- package/build/ftds-floating-menu-label.properties.d.ts +2 -0
- package/build/ftds-floating-menu-label.properties.js +1 -0
- package/build/ftds-floating-menu-label.styles.d.ts +4 -0
- package/build/ftds-floating-menu-label.styles.js +20 -0
- package/build/ftds-floating-menu.d.ts +55 -0
- package/build/ftds-floating-menu.js +232 -0
- package/build/ftds-floating-menu.light.js +1659 -0
- package/build/ftds-floating-menu.min.js +1775 -0
- package/build/ftds-floating-menu.properties.d.ts +21 -0
- package/build/ftds-floating-menu.properties.js +1 -0
- package/build/ftds-floating-menu.styles.d.ts +10 -0
- package/build/ftds-floating-menu.styles.js +45 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +11 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The design system floating menu component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ftds-floating-menu
|
|
7
|
+
yarn add @fluid-topics/ftds-floating-menu
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ftds-floating-menu"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ftds-floating-menu foo="bar"></ftds-floating-menu> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FtdsFloatingMenu } from "./ftds-floating-menu";
|
|
2
|
+
import { FtdsFloatingMenuItem } from "./ftds-floating-menu-item";
|
|
3
|
+
import { FtdsFloatingMenuLabel } from "./ftds-floating-menu-label";
|
|
4
|
+
declare const _default: {
|
|
5
|
+
"ftds-floating-menu": typeof FtdsFloatingMenu;
|
|
6
|
+
"ftds-floating-menu-item": typeof FtdsFloatingMenuItem;
|
|
7
|
+
"ftds-floating-menu-label": typeof FtdsFloatingMenuLabel;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FtdsFloatingMenu } from "./ftds-floating-menu";
|
|
2
|
+
import { FtdsFloatingMenuItem } from "./ftds-floating-menu-item";
|
|
3
|
+
import { FtdsFloatingMenuLabel } from "./ftds-floating-menu-label";
|
|
4
|
+
export default {
|
|
5
|
+
"ftds-floating-menu": FtdsFloatingMenu,
|
|
6
|
+
"ftds-floating-menu-item": FtdsFloatingMenuItem,
|
|
7
|
+
"ftds-floating-menu-label": FtdsFloatingMenuLabel,
|
|
8
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtdsFloatingMenuItemProperties } from "./ftds-floating-menu-item.properties";
|
|
3
|
+
import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
|
|
4
|
+
import { ClassInfo } from "lit/directives/class-map.js";
|
|
5
|
+
export declare class FtdsFloatingMenuItemSelectEvent extends CustomEvent<string> {
|
|
6
|
+
constructor(value: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class FtdsFloatingMenuItem extends FtLitElement implements FtdsFloatingMenuItemProperties {
|
|
9
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
10
|
+
static styles: import("lit").CSSResult;
|
|
11
|
+
iconVariant?: FtdsIconVariants;
|
|
12
|
+
icon?: FtdsIcons;
|
|
13
|
+
value: string;
|
|
14
|
+
notFocusable: boolean;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
get floatingClasses(): ClassInfo;
|
|
17
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
private onClick;
|
|
19
|
+
private onKeyDown;
|
|
20
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { itemStyles } from "./ftds-floating-menu-item.styles";
|
|
11
|
+
import { FtdsIcon, } from "@fluid-topics/ftds-icon";
|
|
12
|
+
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
13
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
14
|
+
import { classMap, } from "lit/directives/class-map.js";
|
|
15
|
+
export class FtdsFloatingMenuItemSelectEvent extends CustomEvent {
|
|
16
|
+
constructor(value) {
|
|
17
|
+
super("ftds-floating-menu-item-select", { detail: value, bubbles: true, composed: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class FtdsFloatingMenuItem extends FtLitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.value = "";
|
|
24
|
+
this.notFocusable = false;
|
|
25
|
+
this.disabled = false;
|
|
26
|
+
}
|
|
27
|
+
get floatingClasses() {
|
|
28
|
+
return {
|
|
29
|
+
"ftds-floating-menu-item": true,
|
|
30
|
+
"ftds-floating-menu-item--disabled": this.disabled,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return html `
|
|
35
|
+
<div class="${classMap(this.floatingClasses)}"
|
|
36
|
+
tabindex="${(this.notFocusable || this.disabled) ? "-1" : "0"}"
|
|
37
|
+
aria-disabled="${this.disabled}"
|
|
38
|
+
@keydown=${(e) => this.onKeyDown(e)}
|
|
39
|
+
@click=${this.onClick}>
|
|
40
|
+
<ft-ripple
|
|
41
|
+
?disabled=${this.disabled}
|
|
42
|
+
></ft-ripple>
|
|
43
|
+
${this.icon ? html `
|
|
44
|
+
<ftds-icon .variant=${this.iconVariant} .icon=${this.icon}></ftds-icon>
|
|
45
|
+
` : nothing}
|
|
46
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2regular}">
|
|
47
|
+
<slot></slot>
|
|
48
|
+
</ftds-typography>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
onClick(event) {
|
|
53
|
+
if (this.disabled) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
event.stopImmediatePropagation();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.dispatchEvent(new FtdsFloatingMenuItemSelectEvent(this.value));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
onKeyDown(event) {
|
|
63
|
+
if (event.key == "Enter" || event.key == " ") {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
this.dispatchEvent(new FtdsFloatingMenuItemSelectEvent(this.value));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
FtdsFloatingMenuItem.elementDefinitions = {
|
|
70
|
+
"ftds-icon": FtdsIcon,
|
|
71
|
+
"ft-ripple": FtRipple,
|
|
72
|
+
"ftds-typography": FtdsTypography,
|
|
73
|
+
};
|
|
74
|
+
// language=CSS
|
|
75
|
+
FtdsFloatingMenuItem.styles = itemStyles;
|
|
76
|
+
__decorate([
|
|
77
|
+
property()
|
|
78
|
+
], FtdsFloatingMenuItem.prototype, "iconVariant", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
property()
|
|
81
|
+
], FtdsFloatingMenuItem.prototype, "icon", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
property()
|
|
84
|
+
], FtdsFloatingMenuItem.prototype, "value", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
property({ type: Boolean })
|
|
87
|
+
], FtdsFloatingMenuItem.prototype, "notFocusable", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
property({ type: Boolean })
|
|
90
|
+
], FtdsFloatingMenuItem.prototype, "disabled", void 0);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FtdsIconVariants } from "@fluid-topics/ftds-icon/build/ftds-icon.properties";
|
|
2
|
+
import { FtdsIcons } from "@fluid-topics/ftds-icon";
|
|
3
|
+
export interface FtdsFloatingMenuItemProperties {
|
|
4
|
+
iconVariant?: FtdsIconVariants;
|
|
5
|
+
icon?: FtdsIcons;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { designSystemVariables, FtCssVariableFactory, } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
export const FtdsFloatingMenuItemCssVariables = {
|
|
4
|
+
iconColor: FtCssVariableFactory.extend("--ftds-floating-menu-icon-color", "", designSystemVariables.colorOnSurfaceMedium),
|
|
5
|
+
};
|
|
6
|
+
// language=CSS
|
|
7
|
+
export const itemStyles = css `
|
|
8
|
+
.ftds-floating-menu-item {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
display: flex;
|
|
11
|
+
position: relative;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: flex-start;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
padding: 4px 16px;
|
|
16
|
+
outline: none;
|
|
17
|
+
min-height: 48px;
|
|
18
|
+
gap: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ftds-floating-menu-item--disabled {
|
|
22
|
+
cursor: default;
|
|
23
|
+
opacity: 0.4;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ftds-floating-menu-item ftds-icon {
|
|
27
|
+
color: ${FtdsFloatingMenuItemCssVariables.iconColor};
|
|
28
|
+
margin-left: 0;
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
flex-grow: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ftds-floating-menu-item ft-typography {
|
|
34
|
+
flex-shrink: 1;
|
|
35
|
+
flex-grow: 1;
|
|
36
|
+
width: max-content;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
word-break: break-word;
|
|
40
|
+
hyphens: auto;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtdsFloatingMenuLabelProperties } from "./ftds-floating-menu-label.properties";
|
|
3
|
+
export declare class FtdsFloatingMenuLabel extends FtLitElement implements FtdsFloatingMenuLabelProperties {
|
|
4
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { FtLitElement, } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
4
|
+
import { labelStyles } from "./ftds-floating-menu-label.styles";
|
|
5
|
+
export class FtdsFloatingMenuLabel extends FtLitElement {
|
|
6
|
+
render() {
|
|
7
|
+
return html `
|
|
8
|
+
<div class="ft-floating-menu-label">
|
|
9
|
+
<ftds-typography variant="${FtdsTypographyVariants.caption1medium}">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</ftds-typography>
|
|
12
|
+
</div>
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
FtdsFloatingMenuLabel.elementDefinitions = {
|
|
17
|
+
"ftds-typography": FtdsTypography,
|
|
18
|
+
};
|
|
19
|
+
FtdsFloatingMenuLabel.styles = labelStyles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { designSystemVariables, FtCssVariableFactory, } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
export const FtdsFloatingMenuLabelCssVariables = {
|
|
4
|
+
color: FtCssVariableFactory.extend("--ftds-floating-menu-label-color", "", designSystemVariables.colorOnSurfaceMedium),
|
|
5
|
+
};
|
|
6
|
+
// language=CSS
|
|
7
|
+
export const labelStyles = css `
|
|
8
|
+
.ftds-floating-menu-label {
|
|
9
|
+
padding: 4px 8px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.ftds-floating-menu-label ft-typography {
|
|
13
|
+
flex-shrink: 1;
|
|
14
|
+
flex-grow: 1;
|
|
15
|
+
width: max-content;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
color: ${FtdsFloatingMenuLabelCssVariables.color}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsIconVariants } from "@fluid-topics/ftds-icon/build/ftds-icon.properties";
|
|
4
|
+
import { Position } from "@fluid-topics/ft-tooltip/build/ft-tooltip.properties";
|
|
5
|
+
import { FtdsFloatingMenuProperties, FtdsHorizontalAlignment, FtdsVerticalAlignment } from "./ftds-floating-menu.properties";
|
|
6
|
+
import { FtdsIcons } from "@fluid-topics/ftds-icon";
|
|
7
|
+
export declare class FtdsFloatingMenuStatusChangeEvent extends CustomEvent<{
|
|
8
|
+
open: boolean;
|
|
9
|
+
}> {
|
|
10
|
+
constructor(open: boolean);
|
|
11
|
+
}
|
|
12
|
+
export declare class FloatingMenuCloseEvent extends CustomEvent<void> {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare class FtdsFloatingMenuSelectEvent extends CustomEvent<string> {
|
|
16
|
+
constructor(detail: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class FtdsFloatingMenu extends FtLitElement implements FtdsFloatingMenuProperties {
|
|
19
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
20
|
+
static styles: import("lit").CSSResult[];
|
|
21
|
+
private menuOpen;
|
|
22
|
+
forceMenuOpen: boolean;
|
|
23
|
+
private container;
|
|
24
|
+
private menuWrapper;
|
|
25
|
+
private actionButton?;
|
|
26
|
+
private customToggle;
|
|
27
|
+
primary: boolean;
|
|
28
|
+
secondary: boolean;
|
|
29
|
+
tertiary: boolean;
|
|
30
|
+
neutral: boolean;
|
|
31
|
+
small: boolean;
|
|
32
|
+
label?: string;
|
|
33
|
+
tooltipPosition?: Position;
|
|
34
|
+
iconVariant: FtdsIconVariants;
|
|
35
|
+
icon: FtdsIcons;
|
|
36
|
+
text?: string;
|
|
37
|
+
horizontalAlignment: FtdsHorizontalAlignment;
|
|
38
|
+
verticalAlignment: FtdsVerticalAlignment;
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
closeMenuMatchers: string[];
|
|
41
|
+
protected updated(props: PropertyValues): void;
|
|
42
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
toggleMenu(): void;
|
|
44
|
+
openMenu(): void;
|
|
45
|
+
closeMenu(): void;
|
|
46
|
+
private hideOptionsOnClickOutside;
|
|
47
|
+
private onCloseEvent;
|
|
48
|
+
private onItemSelect;
|
|
49
|
+
private onContentClick;
|
|
50
|
+
disconnectedCallback(): void;
|
|
51
|
+
protected contentAvailableCallback(props: PropertyValues): void;
|
|
52
|
+
private positionMenuWrapper;
|
|
53
|
+
private convertPlacement;
|
|
54
|
+
private onKeyDown;
|
|
55
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
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, } from "lit";
|
|
8
|
+
import { property, query, queryAssignedElements, state, } from "lit/decorators.js";
|
|
9
|
+
import { eventPathContainsMatchingElement, FtLitElement, jsonProperty, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { FtdsButton } from "@fluid-topics/ftds-button";
|
|
11
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
12
|
+
import { FtdsFloatingMenuItem, } from "./ftds-floating-menu-item";
|
|
13
|
+
import { FtdsIconVariants } from "@fluid-topics/ftds-icon/build/ftds-icon.properties";
|
|
14
|
+
import { computeOffsetPosition } from "@fluid-topics/ft-wc-utils/build/floating";
|
|
15
|
+
import { styles } from "./ftds-floating-menu.styles";
|
|
16
|
+
import { FtdsIcons } from "@fluid-topics/ftds-icon";
|
|
17
|
+
export class FtdsFloatingMenuStatusChangeEvent extends CustomEvent {
|
|
18
|
+
constructor(open) {
|
|
19
|
+
super("change", { detail: { open } });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class FloatingMenuCloseEvent extends CustomEvent {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("close-ftds-floating-menu");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class FtdsFloatingMenuSelectEvent extends CustomEvent {
|
|
28
|
+
constructor(detail) {
|
|
29
|
+
super("select", { detail });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class FtdsFloatingMenu extends FtLitElement {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.menuOpen = false;
|
|
36
|
+
this.forceMenuOpen = false;
|
|
37
|
+
this.primary = false;
|
|
38
|
+
this.secondary = false;
|
|
39
|
+
this.tertiary = false;
|
|
40
|
+
this.neutral = false;
|
|
41
|
+
this.small = false;
|
|
42
|
+
this.iconVariant = FtdsIconVariants.regular;
|
|
43
|
+
this.icon = FtdsIcons.ELLIPSIS_VERTICAL;
|
|
44
|
+
this.horizontalAlignment = "left";
|
|
45
|
+
this.verticalAlignment = "bottom";
|
|
46
|
+
this.disabled = false;
|
|
47
|
+
this.closeMenuMatchers = [];
|
|
48
|
+
this.hideOptionsOnClickOutside = (e) => {
|
|
49
|
+
this.menuOpen = this.menuOpen && e.composedPath().includes(this.container);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
updated(props) {
|
|
53
|
+
super.updated(props);
|
|
54
|
+
if (props.has("menuOpen")) {
|
|
55
|
+
this.dispatchEvent(new FtdsFloatingMenuStatusChangeEvent(this.menuOpen));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const classes = {
|
|
60
|
+
"ftds-floating-menu": true,
|
|
61
|
+
"ftds-floating-menu--open": this.forceMenuOpen || this.menuOpen,
|
|
62
|
+
["ftds-floating-menu--" + this.horizontalAlignment.toLowerCase()]: true,
|
|
63
|
+
["ftds-floating-menu--" + this.verticalAlignment.toLowerCase()]: true,
|
|
64
|
+
};
|
|
65
|
+
return html `
|
|
66
|
+
<div part="container" class="${classMap(classes)}" @keydown=${this.onKeyDown}>
|
|
67
|
+
<slot name="toggle"
|
|
68
|
+
part="toggle"
|
|
69
|
+
@click=${this.toggleMenu}
|
|
70
|
+
aria-controls="ftds-floating-menu-options"
|
|
71
|
+
aria-expanded="${this.forceMenuOpen || this.menuOpen}">
|
|
72
|
+
<ftds-button id="actions-button"
|
|
73
|
+
part="button"
|
|
74
|
+
?primary=${this.primary}
|
|
75
|
+
?secondary=${this.secondary}
|
|
76
|
+
?tertiary=${this.tertiary}
|
|
77
|
+
?neutral=${this.neutral}
|
|
78
|
+
?small=${this.small}
|
|
79
|
+
dense round
|
|
80
|
+
icon="${this.icon}"
|
|
81
|
+
.iconVariant=${this.iconVariant}
|
|
82
|
+
.label=${this.label}
|
|
83
|
+
.tooltipPosition=${this.tooltipPosition}
|
|
84
|
+
?disabled=${this.disabled}>
|
|
85
|
+
${this.text}
|
|
86
|
+
</ftds-button>
|
|
87
|
+
</slot>
|
|
88
|
+
<div part="options-wrapper" class="ftds-floating-menu--wrapper">
|
|
89
|
+
<div id="ftds-floating-menu-options"
|
|
90
|
+
class="ftds-floating-menu--options"
|
|
91
|
+
part="options"
|
|
92
|
+
@ftds-floating-menu-item-select=${this.onItemSelect}>
|
|
93
|
+
<slot id="ftds-floating-menu-content"
|
|
94
|
+
@click=${this.onContentClick}
|
|
95
|
+
@close-ftds-floating-menu=${this.onCloseEvent}
|
|
96
|
+
></slot>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
toggleMenu() {
|
|
103
|
+
this.menuOpen = !this.menuOpen;
|
|
104
|
+
}
|
|
105
|
+
openMenu() {
|
|
106
|
+
this.menuOpen = true;
|
|
107
|
+
}
|
|
108
|
+
closeMenu() {
|
|
109
|
+
this.menuOpen = false;
|
|
110
|
+
}
|
|
111
|
+
onCloseEvent(e) {
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
this.closeMenu();
|
|
114
|
+
}
|
|
115
|
+
onItemSelect(e) {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
this.dispatchEvent(new FtdsFloatingMenuSelectEvent(e.detail));
|
|
118
|
+
this.closeMenu();
|
|
119
|
+
}
|
|
120
|
+
onContentClick(e) {
|
|
121
|
+
if (eventPathContainsMatchingElement(e, this.closeMenuMatchers, this)) {
|
|
122
|
+
this.closeMenu();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
disconnectedCallback() {
|
|
126
|
+
super.disconnectedCallback();
|
|
127
|
+
document.removeEventListener("click", this.hideOptionsOnClickOutside);
|
|
128
|
+
}
|
|
129
|
+
contentAvailableCallback(props) {
|
|
130
|
+
super.contentAvailableCallback(props);
|
|
131
|
+
if (props.has("menuOpen")) {
|
|
132
|
+
if (this.menuOpen) {
|
|
133
|
+
this.menuWrapper.classList.remove("ftds-floating-menu--wrapper-positioned");
|
|
134
|
+
this.positionMenuWrapper();
|
|
135
|
+
document.addEventListener("click", this.hideOptionsOnClickOutside);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
document.removeEventListener("click", this.hideOptionsOnClickOutside);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async positionMenuWrapper() {
|
|
143
|
+
this.menuWrapper.style.left = "";
|
|
144
|
+
this.menuWrapper.style.top = "";
|
|
145
|
+
const reference = this.customToggle.length > 0 ? this.customToggle[0] : this.actionButton;
|
|
146
|
+
const { x, y } = await computeOffsetPosition(reference, this.menuWrapper, this.convertPlacement());
|
|
147
|
+
this.menuWrapper.style.left = `${x}px`;
|
|
148
|
+
this.menuWrapper.style.top = `${y}px`;
|
|
149
|
+
this.menuWrapper.classList.add("ftds-floating-menu--wrapper-positioned");
|
|
150
|
+
}
|
|
151
|
+
convertPlacement() {
|
|
152
|
+
switch (this.horizontalAlignment) {
|
|
153
|
+
case "left":
|
|
154
|
+
return this.verticalAlignment + "-start";
|
|
155
|
+
case "right":
|
|
156
|
+
return this.verticalAlignment + "-end";
|
|
157
|
+
case "center":
|
|
158
|
+
return this.verticalAlignment + "-center";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
onKeyDown(e) {
|
|
162
|
+
if (e.code == "Escape") {
|
|
163
|
+
this.closeMenu();
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
FtdsFloatingMenu.elementDefinitions = {
|
|
169
|
+
"ftds-floating-menu-item": FtdsFloatingMenuItem,
|
|
170
|
+
"ftds-button": FtdsButton,
|
|
171
|
+
};
|
|
172
|
+
FtdsFloatingMenu.styles = [styles];
|
|
173
|
+
__decorate([
|
|
174
|
+
state()
|
|
175
|
+
], FtdsFloatingMenu.prototype, "menuOpen", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
state()
|
|
178
|
+
], FtdsFloatingMenu.prototype, "forceMenuOpen", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
query(".ftds-floating-menu")
|
|
181
|
+
], FtdsFloatingMenu.prototype, "container", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
query(".ftds-floating-menu--wrapper")
|
|
184
|
+
], FtdsFloatingMenu.prototype, "menuWrapper", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
query("#actions-button")
|
|
187
|
+
], FtdsFloatingMenu.prototype, "actionButton", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
queryAssignedElements({ slot: "toggle" })
|
|
190
|
+
], FtdsFloatingMenu.prototype, "customToggle", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
property({ type: Boolean })
|
|
193
|
+
], FtdsFloatingMenu.prototype, "primary", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
property({ type: Boolean })
|
|
196
|
+
], FtdsFloatingMenu.prototype, "secondary", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
property({ type: Boolean })
|
|
199
|
+
], FtdsFloatingMenu.prototype, "tertiary", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
property({ type: Boolean })
|
|
202
|
+
], FtdsFloatingMenu.prototype, "neutral", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
property({ type: Boolean })
|
|
205
|
+
], FtdsFloatingMenu.prototype, "small", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
property()
|
|
208
|
+
], FtdsFloatingMenu.prototype, "label", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
property()
|
|
211
|
+
], FtdsFloatingMenu.prototype, "tooltipPosition", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
property()
|
|
214
|
+
], FtdsFloatingMenu.prototype, "iconVariant", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
property()
|
|
217
|
+
], FtdsFloatingMenu.prototype, "icon", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property()
|
|
220
|
+
], FtdsFloatingMenu.prototype, "text", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property()
|
|
223
|
+
], FtdsFloatingMenu.prototype, "horizontalAlignment", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
property()
|
|
226
|
+
], FtdsFloatingMenu.prototype, "verticalAlignment", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property({ type: Boolean })
|
|
229
|
+
], FtdsFloatingMenu.prototype, "disabled", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
jsonProperty([])
|
|
232
|
+
], FtdsFloatingMenu.prototype, "closeMenuMatchers", void 0);
|