@fluid-topics/ft-floating-menu 0.3.45 → 0.3.47

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.
@@ -12,20 +12,27 @@ export const itemStyles = css `
12
12
  align-items: center;
13
13
  justify-content: flex-start;
14
14
  overflow: hidden;
15
- padding: 0 16px;
15
+ padding: 4px 16px;
16
16
  outline: none;
17
- height: 48px;
18
- }
19
-
20
- ft-typography {
21
- white-space: nowrap;
17
+ min-height: 48px;
18
+ gap: 16px;
22
19
  }
23
20
 
24
21
  .ft-floating-menu-item ft-icon {
25
- --ft-icon-font-size: 24px;
26
22
  color: ${FtFloatingMenuItemCssVariables.iconColor};
27
23
  margin-left: 0;
28
- margin-right: 32px;
24
+ flex-shrink: 0;
25
+ flex-grow: 0;
26
+ }
27
+
28
+ .ft-floating-menu-item ft-typography {
29
+ flex-shrink: 1;
30
+ flex-grow: 1;
31
+ width: max-content;
32
+ text-overflow: ellipsis;
33
+ overflow: hidden;
34
+ word-break: break-word;
35
+ hyphens: auto;
29
36
  }
30
37
  `;
31
38
  //# sourceMappingURL=ft-floating-menu-item.css.js.map
@@ -1,11 +1,13 @@
1
1
  import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtFloatingMenuItemProperties } from "./ft-floating-menu-item.properties";
3
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
3
4
  export declare class FtFloatingMenuItemSelect extends CustomEvent<string> {
4
5
  constructor(value: string);
5
6
  }
6
7
  export declare class FtFloatingMenuItem extends FtLitElement implements FtFloatingMenuItemProperties {
7
8
  static elementDefinitions: ElementDefinitionsMap;
8
9
  static styles: import("lit").CSSResult;
10
+ iconVariant?: FtIconVariants;
9
11
  icon?: string;
10
12
  value: string;
11
13
  protected render(): import("lit-html").TemplateResult<1>;
@@ -22,11 +22,14 @@ export class FtFloatingMenuItem extends FtLitElement {
22
22
  this.value = "";
23
23
  }
24
24
  render() {
25
+ var _a;
25
26
  return html `
26
27
  <div class="ft-floating-menu-item"
27
28
  @click=${this.onClick}>
28
29
  <ft-ripple></ft-ripple>
29
- ${this.icon ? html `<ft-icon variant="material">${this.icon}</ft-icon>` : nothing}
30
+ ${this.icon ? html `
31
+ <ft-icon variant="${(_a = this.iconVariant) !== null && _a !== void 0 ? _a : "material"}">${this.icon}</ft-icon>
32
+ ` : nothing}
30
33
  <ft-typography variant="body2">
31
34
  <slot></slot>
32
35
  </ft-typography>
@@ -45,9 +48,12 @@ FtFloatingMenuItem.elementDefinitions = {
45
48
  // language=CSS
46
49
  FtFloatingMenuItem.styles = itemStyles;
47
50
  __decorate([
48
- property({ type: String })
51
+ property()
52
+ ], FtFloatingMenuItem.prototype, "iconVariant", void 0);
53
+ __decorate([
54
+ property()
49
55
  ], FtFloatingMenuItem.prototype, "icon", void 0);
50
56
  __decorate([
51
- property({ type: String })
57
+ property()
52
58
  ], FtFloatingMenuItem.prototype, "value", void 0);
53
59
  //# sourceMappingURL=ft-floating-menu-item.js.map
@@ -1,4 +1,6 @@
1
+ import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
1
2
  export interface FtFloatingMenuItemProperties {
3
+ iconVariant?: FtIconVariants;
2
4
  icon?: string;
3
5
  value: string;
4
6
  }
@@ -1,4 +1,7 @@
1
1
  export declare const FtFloatingMenuCssVariables: {
2
+ zIndex: import("@fluid-topics/ft-wc-utils").FtCssVariable;
3
+ maxWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
4
+ maxHeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
2
5
  textColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
3
6
  colorSurface: import("@fluid-topics/ft-wc-utils").FtCssVariable;
4
7
  menuElevation: import("@fluid-topics/ft-wc-utils").FtCssVariable;
@@ -1,6 +1,9 @@
1
1
  import { css } from "lit";
2
2
  import { designSystemVariables, FtCssVariableFactory } from "@fluid-topics/ft-wc-utils";
3
3
  export const FtFloatingMenuCssVariables = {
4
+ zIndex: FtCssVariableFactory.create("--ft-floating-menu-z-index", "NUMBER", "8"),
5
+ maxWidth: FtCssVariableFactory.create("--ft-floating-menu-max-width", "SIZE", "300px"),
6
+ maxHeight: FtCssVariableFactory.create("--ft-floating-menu-max-height", "SIZE", "500px"),
4
7
  textColor: FtCssVariableFactory.extend("--ft-floating-menu-text-color", designSystemVariables.colorOnSurfaceHigh),
5
8
  colorSurface: FtCssVariableFactory.external(designSystemVariables.colorSurface, "Design system"),
6
9
  menuElevation: FtCssVariableFactory.external(designSystemVariables.elevation02, "Design system"),
@@ -15,32 +18,22 @@ export const styles = css `
15
18
  }
16
19
 
17
20
  .ft-floating-menu--options {
21
+ display: none;
22
+ position: absolute;
23
+ overflow: auto;
24
+ max-width: ${FtFloatingMenuCssVariables.maxWidth};
25
+ max-height: ${FtFloatingMenuCssVariables.maxHeight};
18
26
  box-shadow: ${FtFloatingMenuCssVariables.menuElevation};
19
27
  background-color: ${FtFloatingMenuCssVariables.colorSurface};
20
28
  border-radius: ${FtFloatingMenuCssVariables.borderRadiusS};
21
29
  color: ${FtFloatingMenuCssVariables.textColor};
22
- display: none;
23
- list-style: none;
24
- max-width: calc(100vw - 32px);
25
- max-height: calc(100vh - 32px);
26
- margin: 0;
27
- padding-left: 0;
28
- position: absolute;
29
- transform: scale(1);
30
- transform-origin: left top;
31
- overflow: auto;
32
- top: 0;
33
- transition: opacity 0.03s linear 0s, transform 0.12s cubic-bezier(0, 0, 0.2, 1) 0s, height 250ms cubic-bezier(0, 0, 0.2, 1) 0s;
34
- opacity: 0;
35
- will-change: transform, opacity;
36
- z-index: 8;
30
+ z-index: ${FtFloatingMenuCssVariables.zIndex};
37
31
  }
38
32
 
39
33
  .ft-floating-menu--open .ft-floating-menu--options {
40
- display: inline-block;
41
- opacity: 1;
34
+ display: block;
42
35
  }
43
-
36
+
44
37
  .ft-floating-menu--left .ft-floating-menu--options {
45
38
  left: 0;
46
39
  }
@@ -49,8 +42,17 @@ export const styles = css `
49
42
  right: 0;
50
43
  }
51
44
 
45
+ .ft-floating-menu--center .ft-floating-menu--options {
46
+ left: 50%;
47
+ transform: translateX(-50%);
48
+ }
49
+
50
+ .ft-floating-menu--top .ft-floating-menu--options {
51
+ bottom: calc(100% + 4px);
52
+ }
53
+
52
54
  .ft-floating-menu--bottom .ft-floating-menu--options {
53
- top: 100%;
55
+ top: calc(100% + 4px);
54
56
  }
55
57
  `;
56
58
  //# sourceMappingURL=ft-floating-menu.css.js.map
@@ -1,6 +1,7 @@
1
- import { PropertyValues } from "lit";
2
1
  import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
2
  import { FtFloatingMenuProperties, FtHorizontalAlignment, FtVerticalAlignment } from "./ft-floating-menu.properties";
3
+ import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
4
+ import { Position } from "@fluid-topics/ft-tooltip/build/ft-tooltip.properties";
4
5
  export declare class FtFloatingMenu extends FtLitElement implements FtFloatingMenuProperties {
5
6
  static elementDefinitions: ElementDefinitionsMap;
6
7
  static styles: import("lit").CSSResult;
@@ -8,17 +9,18 @@ export declare class FtFloatingMenu extends FtLitElement implements FtFloatingMe
8
9
  private container;
9
10
  private menuContainer;
10
11
  private button;
11
- label: string;
12
+ label?: string;
13
+ tooltipPosition?: Position;
14
+ iconVariant?: FtIconVariants;
12
15
  icon: string;
13
16
  text?: string;
14
- horizontalAlignment: FtHorizontalAlignment;
15
- verticalAlignment: FtVerticalAlignment;
17
+ horizontalAlignment?: FtHorizontalAlignment;
18
+ verticalAlignment?: FtVerticalAlignment;
16
19
  disabled: boolean;
17
20
  protected render(): import("lit-html").TemplateResult<1>;
18
21
  private onClick;
19
22
  private onClickItem;
20
23
  private hideOptions;
21
24
  disconnectedCallback(): void;
22
- protected contentAvailableCallback(props: PropertyValues): void;
23
25
  }
24
26
  //# sourceMappingURL=ft-floating-menu.d.ts.map
@@ -4,9 +4,9 @@ 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 { html, nothing } from "lit";
7
+ import { html } from "lit";
8
8
  import { property, query, state } from "lit/decorators.js";
9
- import { Aligner, FtLitElement, } from "@fluid-topics/ft-wc-utils";
9
+ import { FtLitElement, } from "@fluid-topics/ft-wc-utils";
10
10
  import { styles } from "./ft-floating-menu.css";
11
11
  import { FtButton } from "@fluid-topics/ft-button";
12
12
  import { classMap } from "lit/directives/class-map.js";
@@ -15,11 +15,7 @@ export class FtFloatingMenu extends FtLitElement {
15
15
  constructor() {
16
16
  super(...arguments);
17
17
  this.menuOpen = false;
18
- this.label = "";
19
- this.icon = "more_vert";
20
- this.text = undefined;
21
- this.horizontalAlignment = "left";
22
- this.verticalAlignment = "bottom";
18
+ this.icon = "SHORTCUT_MENU";
23
19
  this.disabled = false;
24
20
  this.hideOptions = (e) => {
25
21
  this.menuOpen = this.menuOpen && e.composedPath().includes(this.container);
@@ -29,25 +25,28 @@ export class FtFloatingMenu extends FtLitElement {
29
25
  };
30
26
  }
31
27
  render() {
28
+ var _a, _b;
32
29
  const classes = {
33
30
  "ft-floating-menu": true,
34
31
  "ft-floating-menu--open": this.menuOpen,
35
- "ft-floating-menu--right": this.horizontalAlignment == "right",
36
- "ft-floating-menu--left": this.horizontalAlignment == "left",
37
- "ft-floating-menu--bottom": this.verticalAlignment == "bottom"
32
+ ["ft-floating-menu--" + ((_a = this.horizontalAlignment) !== null && _a !== void 0 ? _a : "left").toLowerCase()]: true,
33
+ ["ft-floating-menu--" + ((_b = this.verticalAlignment) !== null && _b !== void 0 ? _b : "bottom").toLowerCase()]: true,
38
34
  };
39
35
  return html `
40
36
  <div class="${classMap(classes)}">
41
- <ft-button part="button"
37
+ <ft-button id="actions-button"
38
+ part="button"
42
39
  dense round
43
40
  icon="${this.icon}"
44
- id="actions-button"
45
- @click=${this.onClick}
41
+ .iconVariant=${this.iconVariant}
46
42
  .label=${this.label}
47
- ?disabled=${this.disabled}>
48
- ${this.text ? html `<span>${this.text}</span>` : nothing}
43
+ .tooltipPosition=${this.tooltipPosition}
44
+ ?disabled=${this.disabled}
45
+ @click=${this.onClick}>
46
+ ${this.text}
49
47
  </ft-button>
50
48
  <div class="ft-floating-menu--options"
49
+ part="options"
51
50
  @select="${this.onClickItem}">
52
51
  <slot></slot>
53
52
  </div>
@@ -65,24 +64,6 @@ export class FtFloatingMenu extends FtLitElement {
65
64
  super.disconnectedCallback();
66
65
  document.removeEventListener("click", this.hideOptions);
67
66
  }
68
- contentAvailableCallback(props) {
69
- super.contentAvailableCallback(props);
70
- if (this.menuOpen) {
71
- if (this.horizontalAlignment == "center") {
72
- const offset = Aligner.computeCenterLeftOffset(this.button, this.menuContainer);
73
- this.menuContainer.style.left = `${offset}px`;
74
- }
75
- else {
76
- this.menuContainer.style.removeProperty("left");
77
- }
78
- if (this.verticalAlignment == "top") {
79
- this.menuContainer.style.top = `-${this.menuContainer.getBoundingClientRect().height}px`;
80
- }
81
- else {
82
- this.menuContainer.style.removeProperty("top");
83
- }
84
- }
85
- }
86
67
  }
87
68
  FtFloatingMenu.elementDefinitions = {
88
69
  "ft-button": FtButton,
@@ -105,6 +86,12 @@ __decorate([
105
86
  __decorate([
106
87
  property()
107
88
  ], FtFloatingMenu.prototype, "label", void 0);
89
+ __decorate([
90
+ property()
91
+ ], FtFloatingMenu.prototype, "tooltipPosition", void 0);
92
+ __decorate([
93
+ property()
94
+ ], FtFloatingMenu.prototype, "iconVariant", void 0);
108
95
  __decorate([
109
96
  property()
110
97
  ], FtFloatingMenu.prototype, "icon", void 0);