@fw-components/formula-editor 2.0.3-formula-editor.1

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.
@@ -0,0 +1,61 @@
1
+ import { css, html, LitElement } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+
4
+ @customElement("suggestion-menu")
5
+ export class SuggestionMenu extends LitElement {
6
+ @property()
7
+ recommendations: string[] = [];
8
+
9
+ @property()
10
+ onClickRecommendation: Function = (recommendation: string) => {};
11
+
12
+ static styles = css`
13
+ ul {
14
+ border: 1px solid var(--fe-suggestion-color, white);
15
+ color: var(--fe-suggestion-color, #bab6c0);
16
+ background-color: var(--fe-suggestion-background-color, #363537);
17
+ box-sizing: border-box;
18
+ width: fit-content;
19
+ list-style-type: none;
20
+ padding: 4px 0px;
21
+ margin: 2px;
22
+ }
23
+
24
+ li {
25
+ margin: 0px;
26
+ padding: 2px 6px;
27
+ cursor: pointer;
28
+ }
29
+
30
+ li:focus-visible {
31
+ /* outline: 1px solid red; */
32
+ outline: 0px;
33
+ color: var(--fe-suggestion-focus-color, #fce566);
34
+ background-color: var(--fe-suggestion-focus-background-color, #69676c);
35
+ }
36
+ `;
37
+
38
+ handleKeydown(event: KeyboardEvent, recommendation: string) {
39
+ if (event.code == "Enter") {
40
+ event.preventDefault();
41
+ event.stopPropagation();
42
+ this.onClickRecommendation(recommendation);
43
+ }
44
+ }
45
+
46
+ render() {
47
+ return html`
48
+ <ul class="wysiwyg-suggestion-menu">
49
+ ${this.recommendations.map((recommendation) => {
50
+ return html`<li
51
+ tabindex="0"
52
+ @click=${(e: any) => this.onClickRecommendation(recommendation)}
53
+ @keydown=${(e: any) => this.handleKeydown(e, recommendation)}
54
+ >
55
+ ${recommendation}
56
+ </li>`;
57
+ })}
58
+ </ul>
59
+ `;
60
+ }
61
+ }