@fluid-topics/ft-floating-menu 2.0.10 → 2.0.12

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.
@@ -1,6 +1,7 @@
1
1
  import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtFloatingMenuItemProperties } from "./ft-floating-menu-item.properties";
3
3
  import { FtIconVariants } from "@fluid-topics/ft-icon";
4
+ import { ClassInfo } from "lit/directives/class-map.js";
4
5
  export declare class FtFloatingMenuItemSelectEvent extends CustomEvent<string> {
5
6
  constructor(value: string);
6
7
  }
@@ -11,6 +12,8 @@ export declare class FtFloatingMenuItem extends FtLitElement implements FtFloati
11
12
  icon?: string;
12
13
  value: string;
13
14
  notFocusable: boolean;
15
+ disabled: boolean;
16
+ get floatingClasses(): ClassInfo;
14
17
  protected render(): import("lit-html").TemplateResult<1>;
15
18
  private onClick;
16
19
  private onKeyDown;
@@ -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 { html, nothing } from "lit";
7
+ import { html, nothing, } from "lit";
8
8
  import { property } from "lit/decorators.js";
9
- import { FtLitElement } from "@fluid-topics/ft-wc-utils";
9
+ import { FtLitElement, } from "@fluid-topics/ft-wc-utils";
10
10
  import { itemStyles } from "./ft-floating-menu-item.styles";
11
- import { FtIcon } from "@fluid-topics/ft-icon";
11
+ import { FtIcon, } from "@fluid-topics/ft-icon";
12
12
  import { FtRipple } from "@fluid-topics/ft-ripple";
13
13
  import { FtTypography } from "@fluid-topics/ft-typography";
14
+ import { classMap, } from "lit/directives/class-map.js";
14
15
  export class FtFloatingMenuItemSelectEvent extends CustomEvent {
15
16
  constructor(value) {
16
17
  super("ft-floating-menu-item-select", { detail: value, bubbles: true, composed: true });
@@ -21,17 +22,27 @@ class FtFloatingMenuItem extends FtLitElement {
21
22
  super(...arguments);
22
23
  this.value = "";
23
24
  this.notFocusable = false;
25
+ this.disabled = false;
26
+ }
27
+ get floatingClasses() {
28
+ return {
29
+ "ft-floating-menu-item": true,
30
+ "ft-floating-menu-item--disabled": this.disabled,
31
+ };
24
32
  }
25
33
  render() {
26
34
  return html `
27
- <div class="ft-floating-menu-item"
28
- tabindex=${this.notFocusable ? "-1" : "0"}
35
+ <div class="${classMap(this.floatingClasses)}"
36
+ tabindex="${(this.notFocusable || this.disabled) ? "-1" : "0"}"
37
+ aria-disabled="${this.disabled}"
29
38
  @keydown=${(e) => this.onKeyDown(e)}
30
39
  @click=${this.onClick}>
31
- <ft-ripple></ft-ripple>
40
+ <ft-ripple
41
+ ?disabled=${this.disabled}
42
+ ></ft-ripple>
32
43
  ${this.icon ? html `
33
- <ft-icon .variant="${this.iconVariant}" .value="${this.icon}"></ft-icon>
34
- ` : nothing}
44
+ <ft-icon .variant=${this.iconVariant} .value=${this.icon}></ft-icon>
45
+ ` : nothing}
35
46
  <ft-typography variant="body2">
36
47
  <slot></slot>
37
48
  </ft-typography>
@@ -39,7 +50,14 @@ class FtFloatingMenuItem extends FtLitElement {
39
50
  `;
40
51
  }
41
52
  onClick(event) {
42
- this.dispatchEvent(new FtFloatingMenuItemSelectEvent(this.value));
53
+ if (this.disabled) {
54
+ event.preventDefault();
55
+ event.stopPropagation();
56
+ event.stopImmediatePropagation();
57
+ }
58
+ else {
59
+ this.dispatchEvent(new FtFloatingMenuItemSelectEvent(this.value));
60
+ }
43
61
  }
44
62
  onKeyDown(event) {
45
63
  if (event.key == "Enter" || event.key == " ") {
@@ -67,4 +85,7 @@ __decorate([
67
85
  __decorate([
68
86
  property({ type: Boolean })
69
87
  ], FtFloatingMenuItem.prototype, "notFocusable", void 0);
88
+ __decorate([
89
+ property({ type: Boolean })
90
+ ], FtFloatingMenuItem.prototype, "disabled", void 0);
70
91
  export { FtFloatingMenuItem };
@@ -1,7 +1,7 @@
1
1
  import { css } from "lit";
2
- import { designSystemVariables, FtCssVariableFactory } from "@fluid-topics/ft-wc-utils";
2
+ import { designSystemVariables, FtCssVariableFactory, } from "@fluid-topics/ft-wc-utils";
3
3
  export const FtFloatingMenuItemCssVariables = {
4
- iconColor: FtCssVariableFactory.extend("--ft-floating-menu-icon-color", "", designSystemVariables.colorOnSurfaceMedium)
4
+ iconColor: FtCssVariableFactory.extend("--ft-floating-menu-icon-color", "", designSystemVariables.colorOnSurfaceMedium),
5
5
  };
6
6
  // language=CSS
7
7
  export const itemStyles = css `
@@ -18,6 +18,11 @@ export const itemStyles = css `
18
18
  gap: 16px;
19
19
  }
20
20
 
21
+ .ft-floating-menu-item--disabled {
22
+ cursor: default;
23
+ opacity: 0.4;
24
+ }
25
+
21
26
  .ft-floating-menu-item ft-icon {
22
27
  color: ${FtFloatingMenuItemCssVariables.iconColor};
23
28
  margin-left: 0;