@nuralyui/menu 0.0.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.
- package/demo/menus-demo.d.ts +22 -0
- package/demo/menus-demo.d.ts.map +1 -0
- package/demo/menus-demo.js +147 -0
- package/demo/menus-demo.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +2 -0
- package/index.js.map +1 -0
- package/menu.component.d.ts +19 -0
- package/menu.component.d.ts.map +1 -0
- package/menu.component.js +109 -0
- package/menu.component.js.map +1 -0
- package/menu.constants.d.ts +12 -0
- package/menu.constants.d.ts.map +1 -0
- package/menu.constants.js +14 -0
- package/menu.constants.js.map +1 -0
- package/menu.style.d.ts +2 -0
- package/menu.style.d.ts.map +1 -0
- package/menu.style.js +86 -0
- package/menu.style.js.map +1 -0
- package/menu.types.d.ts +22 -0
- package/menu.types.d.ts.map +1 -0
- package/menu.types.js +2 -0
- package/menu.types.js.map +1 -0
- package/package.json +15 -0
- package/react.d.ts +3 -0
- package/react.d.ts.map +1 -0
- package/react.js +10 -0
- package/react.js.map +1 -0
- package/templates/hy-menu-link.d.ts +30 -0
- package/templates/hy-menu-link.d.ts.map +1 -0
- package/templates/hy-menu-link.js +123 -0
- package/templates/hy-menu-link.js.map +1 -0
- package/templates/hy-sub-menu.d.ts +26 -0
- package/templates/hy-sub-menu.d.ts.map +1 -0
- package/templates/hy-sub-menu.js +96 -0
- package/templates/hy-sub-menu.js.map +1 -0
- package/templates/menu-link.contants.d.ts +5 -0
- package/templates/menu-link.contants.d.ts.map +1 -0
- package/templates/menu-link.contants.js +6 -0
- package/templates/menu-link.contants.js.map +1 -0
- package/templates/menu-link.style.d.ts +2 -0
- package/templates/menu-link.style.d.ts.map +1 -0
- package/templates/menu-link.style.js +96 -0
- package/templates/menu-link.style.js.map +1 -0
- package/templates/sub-menu.style.d.ts +2 -0
- package/templates/sub-menu.style.d.ts.map +1 -0
- package/templates/sub-menu.style.js +81 -0
- package/templates/sub-menu.style.js.map +1 -0
- package/test/menu-link_test.d.ts +2 -0
- package/test/menu-link_test.d.ts.map +1 -0
- package/test/menu-link_test.js +85 -0
- package/test/menu-link_test.js.map +1 -0
- package/test/menu_test.d.ts +2 -0
- package/test/menu_test.d.ts.map +1 -0
- package/test/menu_test.js +81 -0
- package/test/menu_test.js.map +1 -0
- package/test/sub-menu_test.d.ts +2 -0
- package/test/sub-menu_test.d.ts.map +1 -0
- package/test/sub-menu_test.js +72 -0
- package/test/sub-menu_test.js.map +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
var HyMenuLink_1;
|
|
8
|
+
import { LitElement, html, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { styles } from './menu-link.style.js';
|
|
11
|
+
import { EMPTY_STRING } from '../menu.constants.js';
|
|
12
|
+
import { ICON_POSITION } from './menu-link.contants.js';
|
|
13
|
+
import '../../dropdown/hy-dropdown.component.js';
|
|
14
|
+
let HyMenuLink = HyMenuLink_1 = class HyMenuLink extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.text = EMPTY_STRING;
|
|
18
|
+
this.disabled = false;
|
|
19
|
+
this.icon = EMPTY_STRING;
|
|
20
|
+
this.iconPosition = ICON_POSITION.LEFT;
|
|
21
|
+
this.selected = false;
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.optionPath = this.getAttribute('data-path').split('-').map((stringValue) => +stringValue);
|
|
26
|
+
const isTheFirstOption = this.optionPath.filter((path) => path != 0).length == 0;
|
|
27
|
+
if (isTheFirstOption) {
|
|
28
|
+
HyMenuLink_1.index = 0;
|
|
29
|
+
}
|
|
30
|
+
this.linkPosition = HyMenuLink_1.index;
|
|
31
|
+
HyMenuLink_1.index++;
|
|
32
|
+
}
|
|
33
|
+
firstUpdated() {
|
|
34
|
+
if (this.selected) {
|
|
35
|
+
this._clickLink();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_clickLink(event) {
|
|
39
|
+
var _a;
|
|
40
|
+
if (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.id) != 'action-icon') {
|
|
41
|
+
this.dispatchEvent(new CustomEvent('selected-link', {
|
|
42
|
+
detail: { index: this.linkPosition, value: this.text },
|
|
43
|
+
bubbles: true,
|
|
44
|
+
composed: true,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onActionClick(e) {
|
|
49
|
+
this.dispatchEvent(new CustomEvent('action-click', { detail: { value: e.detail.value, path: this.optionPath }, composed: true, bubbles: true }));
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return html `
|
|
54
|
+
<li tabindex="0" @click=${!this.disabled ? this._clickLink : nothing}>
|
|
55
|
+
<div class="icon-container" >
|
|
56
|
+
${this.icon
|
|
57
|
+
? html `${!this.text
|
|
58
|
+
? html `
|
|
59
|
+
<div id="icon-only">
|
|
60
|
+
<hy-icon name="${this.icon}"></hy-icon>
|
|
61
|
+
</div>
|
|
62
|
+
`
|
|
63
|
+
: html `<hy-icon name="${this.icon}"></hy-icon>`} `
|
|
64
|
+
: nothing}
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
${this.text
|
|
68
|
+
? html `
|
|
69
|
+
<div class="action-text-container">
|
|
70
|
+
<div id="text-container">
|
|
71
|
+
<span>${this.text}</span>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="icon-container" >
|
|
74
|
+
${((_a = this.status) === null || _a === void 0 ? void 0 : _a.icon) ? html `
|
|
75
|
+
<hy-icon name=${this.status.icon} class="status-icon"></hy-icon>
|
|
76
|
+
` : nothing}
|
|
77
|
+
${((_b = this.menu) === null || _b === void 0 ? void 0 : _b.actions) ? html `
|
|
78
|
+
<hy-dropdown .options=${this.menu.actions} .trigger=${'hover'} @click-item=${this.onActionClick}>
|
|
79
|
+
<hy-icon name="${this.menu.icon}" id="action-icon" ></hy-icon>
|
|
80
|
+
</hy-dropdown>
|
|
81
|
+
` : nothing}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
`
|
|
86
|
+
: nothing}
|
|
87
|
+
</li>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
HyMenuLink.styles = styles;
|
|
92
|
+
__decorate([
|
|
93
|
+
state()
|
|
94
|
+
], HyMenuLink.prototype, "linkPosition", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ reflect: true })
|
|
97
|
+
], HyMenuLink.prototype, "text", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property()
|
|
100
|
+
], HyMenuLink.prototype, "link", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: Boolean, reflect: true })
|
|
103
|
+
], HyMenuLink.prototype, "disabled", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ reflect: true })
|
|
106
|
+
], HyMenuLink.prototype, "icon", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ reflect: true })
|
|
109
|
+
], HyMenuLink.prototype, "iconPosition", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Boolean, reflect: true })
|
|
112
|
+
], HyMenuLink.prototype, "selected", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property()
|
|
115
|
+
], HyMenuLink.prototype, "menu", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property()
|
|
118
|
+
], HyMenuLink.prototype, "status", void 0);
|
|
119
|
+
HyMenuLink = HyMenuLink_1 = __decorate([
|
|
120
|
+
customElement('hy-menu-link')
|
|
121
|
+
], HyMenuLink);
|
|
122
|
+
export { HyMenuLink };
|
|
123
|
+
//# sourceMappingURL=hy-menu-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-menu-link.js","sourceRoot":"","sources":["../../../../src/components/menu/templates/hy-menu-link.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAEtD,OAAO,yCAAyC,CAAA;AAGhD,IAAa,UAAU,kBAAvB,MAAa,UAAW,SAAQ,UAAU;IAA1C;;QAOE,SAAI,GAAG,YAAY,CAAC;QAMpB,aAAQ,GAAG,KAAK,CAAC;QAGjB,SAAI,GAAG,YAAY,CAAC;QAGpB,iBAAY,GAAG,aAAa,CAAC,IAAI,CAAC;QAGlC,aAAQ,GAAG,KAAK,CAAC;IAoFnB,CAAC;IAzEU,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAC,EAAE,CAAA,CAAC,WAAW,CAAC,CA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B;AAGjB;IADC,QAAQ,EAAE;wCAC0B;AAGrC;IADC,QAAQ,EAAE;0CACuB;AA5BvB,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CA0GtB;SA1GY,UAAU","sourcesContent":["import {LitElement, html, nothing} from 'lit';\nimport {customElement, property, state} from 'lit/decorators.js';\nimport {styles} from './menu-link.style.js';\nimport {EMPTY_STRING} from '../menu.constants.js';\nimport {ICON_POSITION} from './menu-link.contants.js';\nimport { IAction } from '../menu.types.js';\nimport '../../dropdown/hy-dropdown.component.js'\n\n@customElement('hy-menu-link')\nexport class HyMenuLink extends LitElement {\n static index: number;\n\n @state()\n private linkPosition!: number;\n\n @property({reflect: true})\n text = EMPTY_STRING;\n\n @property()\n link!: string;\n\n @property({type: Boolean, reflect: true})\n disabled = false;\n\n @property({reflect: true})\n icon = EMPTY_STRING;\n\n @property({reflect: true})\n iconPosition = ICON_POSITION.LEFT;\n\n @property({type: Boolean, reflect: true})\n selected = false;\n\n @property()\n menu!:{icon:string,actions:IAction[]}\n\n @property()\n status!:{icon:string,label:string}\n\n optionPath!:number[];\n\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.optionPath=this.getAttribute('data-path')!.split('-').map((stringValue)=>+stringValue);\n\n const isTheFirstOption=this.optionPath.filter((path)=>path!=0).length==0\n if (isTheFirstOption) {\n HyMenuLink.index = 0;\n }\n this.linkPosition = HyMenuLink.index;\n HyMenuLink.index++;\n }\n\n override firstUpdated(): void {\n if (this.selected) {\n this._clickLink();\n }\n }\n\n _clickLink(event?:Event) {\n if((event?.target as HTMLElement)?.id !='action-icon'){\n this.dispatchEvent(\n new CustomEvent('selected-link', {\n detail: {index: this.linkPosition, value: this.text},\n bubbles: true,\n composed: true,\n })\n );\n }\n }\n\n onActionClick(e:CustomEvent){\n this.dispatchEvent(new CustomEvent('action-click',{detail:{value:e.detail.value,path:this.optionPath},composed:true,bubbles:true}))\n }\n\n override render() {\n return html`\n <li tabindex=\"0\" @click=${!this.disabled ? this._clickLink : nothing}>\n <div class=\"icon-container\" >\n ${this.icon\n ? html`${!this.text\n ? html`\n <div id=\"icon-only\">\n <hy-icon name=\"${this.icon}\"></hy-icon>\n </div>\n `\n : html`<hy-icon name=\"${this.icon}\"></hy-icon>`} `\n : nothing}\n \n </div>\n ${this.text\n ? html`\n <div class=\"action-text-container\">\n <div id=\"text-container\">\n <span>${this.text}</span>\n </div>\n <div class=\"icon-container\" >\n ${this.status?.icon?html`\n <hy-icon name=${this.status.icon} class=\"status-icon\"></hy-icon>\n `:nothing}\n ${this.menu?.actions?html`\n <hy-dropdown .options=${this.menu.actions} .trigger=${'hover'} @click-item=${this.onActionClick}>\n <hy-icon name=\"${this.menu.icon}\" id=\"action-icon\" ></hy-icon>\n </hy-dropdown>\n `:nothing}\n </div>\n \n </div>\n `\n : nothing}\n </li>\n `;\n }\n static override styles = styles;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { IAction } from '../menu.types.js';
|
|
3
|
+
export declare class HySubMenu extends LitElement {
|
|
4
|
+
text: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
highlighted: boolean;
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
menu: {
|
|
10
|
+
icon: string;
|
|
11
|
+
actions: IAction[];
|
|
12
|
+
};
|
|
13
|
+
status: {
|
|
14
|
+
icon: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
optionPath: number[];
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
_toggleMenu(event: Event): void;
|
|
20
|
+
toggleIcon(): void;
|
|
21
|
+
_handleSelectedChild(): void;
|
|
22
|
+
onActionClick(e: CustomEvent): void;
|
|
23
|
+
render(): import("lit").TemplateResult<1>;
|
|
24
|
+
static styles: import("lit").CSSResult;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=hy-sub-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-sub-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/templates/hy-sub-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,KAAK,CAAC;AAI9C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBACa,SAAU,SAAQ,UAAU;IAEvC,IAAI,EAAG,MAAM,CAAC;IAGd,IAAI,SAAgB;IAGpB,QAAQ,UAAS;IAGjB,WAAW,UAAS;IAGpB,MAAM,UAAS;IAGf,IAAI,EAAE;QAAC,IAAI,EAAC,MAAM,CAAC;QAAA,OAAO,EAAC,OAAO,EAAE,CAAA;KAAC,CAAA;IAGrC,MAAM,EAAE;QAAC,IAAI,EAAC,MAAM,CAAC;QAAA,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAEnC,UAAU,EAAE,MAAM,EAAE,CAAC;IAEZ,iBAAiB,IAAI,IAAI;IAKlC,WAAW,CAAC,KAAK,EAAC,KAAK;IAcvB,UAAU;IAIV,oBAAoB;IAIpB,aAAa,CAAC,CAAC,EAAC,WAAW;IAIlB,MAAM;IAsBf,OAAgB,MAAM,0BAAU;CACjC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 { LitElement, html, nothing } from 'lit';
|
|
8
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
|
+
import { styles } from './sub-menu.style.js';
|
|
10
|
+
import { EMPTY_STRING } from '../menu.constants.js';
|
|
11
|
+
let HySubMenu = class HySubMenu extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.icon = EMPTY_STRING;
|
|
15
|
+
this.disabled = false;
|
|
16
|
+
this.highlighted = false;
|
|
17
|
+
this.isOpen = false;
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback();
|
|
21
|
+
this.optionPath = this.getAttribute('data-path').split('-').map((stringValue) => +stringValue);
|
|
22
|
+
}
|
|
23
|
+
_toggleMenu(event) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if ((((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.className) != 'action-icon') && (((_b = event === null || event === void 0 ? void 0 : event.target) === null || _b === void 0 ? void 0 : _b.id) != 'toggle-icon')) {
|
|
26
|
+
if (!this.isOpen) {
|
|
27
|
+
this.isOpen = !this.isOpen;
|
|
28
|
+
}
|
|
29
|
+
this.dispatchEvent(new CustomEvent('select-menu', {
|
|
30
|
+
bubbles: true,
|
|
31
|
+
composed: true,
|
|
32
|
+
detail: { value: this.text, path: this.optionPath },
|
|
33
|
+
}));
|
|
34
|
+
this.highlighted = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
toggleIcon() {
|
|
38
|
+
this.isOpen = !this.isOpen;
|
|
39
|
+
}
|
|
40
|
+
_handleSelectedChild() {
|
|
41
|
+
this.highlighted = true;
|
|
42
|
+
}
|
|
43
|
+
onActionClick(e) {
|
|
44
|
+
this.dispatchEvent(new CustomEvent('action-click', { detail: { value: e.detail.value, path: this.optionPath }, composed: true, bubbles: true }));
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
return html `
|
|
49
|
+
<ul tabindex="0">
|
|
50
|
+
<div @click=${!this.disabled ? this._toggleMenu : nothing}>
|
|
51
|
+
${this.icon ? html `<hy-icon id="text-icon" name="${this.icon}"></hy-icon>` : nothing}
|
|
52
|
+
<span>${this.text}</span>
|
|
53
|
+
<div class="icons-container">
|
|
54
|
+
${((_a = this.status) === null || _a === void 0 ? void 0 : _a.icon) ? html `
|
|
55
|
+
<hy-icon name=${this.status.icon} class="status-icon" ></hy-icon>
|
|
56
|
+
` : nothing}
|
|
57
|
+
${((_b = this.menu) === null || _b === void 0 ? void 0 : _b.actions) ? html `
|
|
58
|
+
<hy-dropdown .options=${this.menu.actions} @click-item=${this.onActionClick} .trigger=${"hover"}>
|
|
59
|
+
<hy-icon name="${this.menu.icon}" class="action-icon"></hy-icon>
|
|
60
|
+
</hy-dropdown>
|
|
61
|
+
` : nothing}
|
|
62
|
+
<hy-icon id="toggle-icon" name="${this.isOpen ? 'angle-up' : 'angle-down'}" @click=${!this.disabled ? this.toggleIcon : nothing}></hy-icon>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<slot @select-menu=${this._handleSelectedChild} @selected-link=${this._handleSelectedChild} style="display:${this.isOpen ? nothing : 'none'};"></slot>
|
|
66
|
+
</ul>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
HySubMenu.styles = styles;
|
|
71
|
+
__decorate([
|
|
72
|
+
property()
|
|
73
|
+
], HySubMenu.prototype, "text", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
property({ reflect: true })
|
|
76
|
+
], HySubMenu.prototype, "icon", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
property({ type: Boolean, reflect: true })
|
|
79
|
+
], HySubMenu.prototype, "disabled", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
property({ type: Boolean, reflect: true })
|
|
82
|
+
], HySubMenu.prototype, "highlighted", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
state()
|
|
85
|
+
], HySubMenu.prototype, "isOpen", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
property()
|
|
88
|
+
], HySubMenu.prototype, "menu", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property()
|
|
91
|
+
], HySubMenu.prototype, "status", void 0);
|
|
92
|
+
HySubMenu = __decorate([
|
|
93
|
+
customElement('hy-sub-menu')
|
|
94
|
+
], HySubMenu);
|
|
95
|
+
export { HySubMenu };
|
|
96
|
+
//# sourceMappingURL=hy-sub-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-sub-menu.js","sourceRoot":"","sources":["../../../../src/components/menu/templates/hy-sub-menu.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAIlD,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAAzC;;QAKE,SAAI,GAAG,YAAY,CAAC;QAGpB,aAAQ,GAAG,KAAK,CAAC;QAGjB,gBAAW,GAAG,KAAK,CAAC;QAGpB,WAAM,GAAG,KAAK,CAAC;IAgEjB,CAAC;IAtDU,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAC,EAAE,CAAA,CAAC,WAAW,CAAC,CAAC;IAC9F,CAAC;IAED,WAAW,CAAC,KAAW;;QACrB,IAAG,CAAC,CAAA,MAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAsB,0CAAE,SAAS,KAAG,aAAa,CAAC,IAAG,CAAC,CAAA,MAAC,K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,CAAC,CAAA,IAAI,CAAA;8BACJ,IAAI,CAAC,MAAM,CAAC,IAAI;aACjC,CAAA,CAAC,CAAA,OAAO;YACT,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,EAAA,CAAC,CAAA,IAAI,CAAA;oCACC,IAAI,CAAC,IAAI,CAAC,OAAO,gBAAgB,IAAI,CAAC,aAAa,aAAa,OAAO;+BAC5E,IAAI,CAAC,IAAI,CAAC,IAAI;;aAEhC,CAAA,CAAC,CAAA,OAAO;8CACyB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO;;;6BAG9G,IAAI,CAAC,oBAAoB,mBAAmB,IAAI,CAAC,oBAAoB,mBAAmB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;;KAE9I,CAAC;IACJ,CAAC;CAEF,CAAA;AADiB,gBAAM,GAAG,MAAO,CAAA;AA3EhC;IADC,QAAQ,EAAE;uCACG;AAGd;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;uCACN;AAGpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;2CACxB;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;8CACrB;AAGpB;IADC,KAAK,EAAE;yCACO;AAGf;IADC,QAAQ,EAAE;uCAC0B;AAGrC;IADC,QAAQ,EAAE;yCACwB;AApBxB,SAAS;IADrB,aAAa,CAAC,aAAa,CAAC;GAChB,SAAS,CA8ErB;SA9EY,SAAS","sourcesContent":["import {LitElement, html, nothing} from 'lit';\nimport {customElement, property, state} from 'lit/decorators.js';\nimport {styles} from './sub-menu.style.js';\nimport {EMPTY_STRING} from '../menu.constants.js';\nimport { IAction } from '../menu.types.js';\n\n@customElement('hy-sub-menu')\nexport class HySubMenu extends LitElement {\n @property()\n text!: string;\n\n @property({reflect: true})\n icon = EMPTY_STRING;\n\n @property({type: Boolean, reflect: true})\n disabled = false;\n\n @property({type: Boolean, reflect: true})\n highlighted = false;\n\n @state()\n isOpen = false;\n\n @property()\n menu!:{icon:string,actions:IAction[]}\n\n @property()\n status!:{icon:string,label:string};\n \n optionPath!:number[];\n \n override connectedCallback(): void {\n super.connectedCallback();\n this.optionPath=this.getAttribute('data-path')!.split('-').map((stringValue)=>+stringValue);\n }\n\n _toggleMenu(event:Event) {\n if(((event?.target as HTMLElement)?.className !='action-icon') &&((event?.target as HTMLElement)?.id !='toggle-icon')){\n if(!this.isOpen){\n this.isOpen = !this.isOpen;\n }\n this.dispatchEvent(new CustomEvent('select-menu', {\n bubbles: true,\n composed: true,\n detail: {value:this.text,path:this.optionPath},\n }));\n this.highlighted = true\n }\n }\n\n toggleIcon(){\n this.isOpen = !this.isOpen\n }\n\n _handleSelectedChild() {\n this.highlighted = true;\n }\n \n onActionClick(e:CustomEvent){\n this.dispatchEvent(new CustomEvent('action-click',{detail:{value:e.detail.value,path:this.optionPath},composed:true,bubbles:true}))\n }\n\n override render() {\n return html`\n <ul tabindex=\"0\">\n <div @click=${!this.disabled ? this._toggleMenu : nothing}>\n ${this.icon ? html`<hy-icon id=\"text-icon\" name=\"${this.icon}\"></hy-icon>` : nothing}\n <span>${this.text}</span>\n <div class=\"icons-container\">\n ${this.status?.icon?html`\n <hy-icon name=${this.status.icon} class=\"status-icon\" ></hy-icon>\n `:nothing}\n ${this.menu?.actions?html`\n <hy-dropdown .options=${this.menu.actions} @click-item=${this.onActionClick} .trigger=${\"hover\"}>\n <hy-icon name=\"${this.menu.icon}\" class=\"action-icon\"></hy-icon>\n </hy-dropdown>\n `:nothing}\n <hy-icon id=\"toggle-icon\" name=\"${this.isOpen ? 'angle-up' : 'angle-down'}\" @click=${!this.disabled ? this.toggleIcon : nothing}></hy-icon>\n </div>\n </div>\n <slot @select-menu=${this._handleSelectedChild} @selected-link=${this._handleSelectedChild} style=\"display:${this.isOpen ? nothing : 'none'};\"></slot>\n </ul>\n `;\n }\n static override styles = styles;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link.contants.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/templates/menu-link.contants.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link.contants.js","sourceRoot":"","sources":["../../../../src/components/menu/templates/menu-link.contants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB","sourcesContent":["export enum ICON_POSITION {\n LEFT = 'left',\n RIGHT = 'right',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link.style.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/templates/menu-link.style.ts"],"names":[],"mappings":"AA8FA,eAAO,MAAM,MAAM,yBAAgB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const menuLinkStyle = css `
|
|
3
|
+
:host([disabled]) li {
|
|
4
|
+
color: var(--hybrid-menu-disabled-link-color);
|
|
5
|
+
cursor: not-allowed;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
:host(:not([disabled]):not([selected])) li {
|
|
9
|
+
background-color: var(--hybrid-menu-link-background-color);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host(:not([disabled]):not([selected])) li:hover {
|
|
13
|
+
background-color: var(--hybrid-menu-hover-link-background-color);
|
|
14
|
+
color: var(--hybrid-menu-hover-link-color);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([selected]) li:not(:focus) {
|
|
18
|
+
background-color: var(--hybrid-menu-selected-link-background-color);
|
|
19
|
+
color: var(--hybrid-menu-selected-color);
|
|
20
|
+
border-left: var(--hybrid-menu-selected-link-border);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host(:not([disabled])) li {
|
|
24
|
+
color: var(--hybrid-menu-link-color);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([text='']) li {
|
|
28
|
+
width: var(--hybrid-menu-link-icon-only-width);
|
|
29
|
+
}
|
|
30
|
+
hy-icon {
|
|
31
|
+
--hybrid-icon-color: var(--hybrid-menu-link-icon-color);
|
|
32
|
+
}
|
|
33
|
+
.icon-container{
|
|
34
|
+
display:flex;
|
|
35
|
+
align-items:center;
|
|
36
|
+
position:relative;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.status-icon{
|
|
40
|
+
padding-right:0px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
li {
|
|
44
|
+
list-style: none;
|
|
45
|
+
display: flex;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
padding-bottom: var(--hybrid-menu-link-padding-y);
|
|
48
|
+
padding-top: var(--hybrid-menu-link-padding-y);
|
|
49
|
+
}
|
|
50
|
+
.action-text-container{
|
|
51
|
+
width:100%;
|
|
52
|
+
display:flex;
|
|
53
|
+
justify-content:space-between;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([iconPosition='right']) li {
|
|
57
|
+
flex-direction: row-reverse;
|
|
58
|
+
justify-content: space-between;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host(:not([disabled])) li:focus {
|
|
62
|
+
border: var(--hybrid-menu-focus-border);
|
|
63
|
+
color: var(--hybrid-menu-focus-color);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host(:not([disabled]):not([selected])) li:active {
|
|
67
|
+
color: var(--hybrid-menu-active-color);
|
|
68
|
+
background-color: var(--hybrid-menu-active-background-color);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([icon='']) #text-container {
|
|
72
|
+
padding-left: var(--hybrid-menu-link-empty-icon-padding-left);
|
|
73
|
+
}
|
|
74
|
+
:host([icon=''][iconPosition='right']) #text-container {
|
|
75
|
+
margin-right: auto;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:host([iconPosition='right']) #text-container,
|
|
79
|
+
:host([iconPosition='right']) #icon-only {
|
|
80
|
+
padding-left: var(--hybrid-menu-link-icon-right-padding-left);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#link-icon {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
88
|
+
hy-icon {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
padding-right: var(--hybrid-menu-link-icon-padding-right);
|
|
92
|
+
padding-left: var(--hybrid-menu-link-icon-padding-left);
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
export const styles = menuLinkStyle;
|
|
96
|
+
//# sourceMappingURL=menu-link.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link.style.js","sourceRoot":"","sources":["../../../../src/components/menu/templates/menu-link.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FxB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC","sourcesContent":["import {css} from 'lit';\nconst menuLinkStyle = css`\n :host([disabled]) li {\n color: var(--hybrid-menu-disabled-link-color);\n cursor: not-allowed;\n }\n\n :host(:not([disabled]):not([selected])) li {\n background-color: var(--hybrid-menu-link-background-color);\n }\n\n :host(:not([disabled]):not([selected])) li:hover {\n background-color: var(--hybrid-menu-hover-link-background-color);\n color: var(--hybrid-menu-hover-link-color);\n }\n\n :host([selected]) li:not(:focus) {\n background-color: var(--hybrid-menu-selected-link-background-color);\n color: var(--hybrid-menu-selected-color);\n border-left: var(--hybrid-menu-selected-link-border);\n }\n\n :host(:not([disabled])) li {\n color: var(--hybrid-menu-link-color);\n }\n\n :host([text='']) li {\n width: var(--hybrid-menu-link-icon-only-width);\n }\n hy-icon {\n --hybrid-icon-color: var(--hybrid-menu-link-icon-color);\n }\n .icon-container{\n display:flex;\n align-items:center;\n position:relative;\n }\n \n .status-icon{\n padding-right:0px;\n }\n\n li {\n list-style: none;\n display: flex;\n cursor: pointer;\n padding-bottom: var(--hybrid-menu-link-padding-y);\n padding-top: var(--hybrid-menu-link-padding-y);\n }\n .action-text-container{\n width:100%;\n display:flex;\n justify-content:space-between;\n }\n\n :host([iconPosition='right']) li {\n flex-direction: row-reverse;\n justify-content: space-between;\n }\n\n :host(:not([disabled])) li:focus {\n border: var(--hybrid-menu-focus-border);\n color: var(--hybrid-menu-focus-color);\n }\n\n :host(:not([disabled]):not([selected])) li:active {\n color: var(--hybrid-menu-active-color);\n background-color: var(--hybrid-menu-active-background-color);\n }\n\n :host([icon='']) #text-container {\n padding-left: var(--hybrid-menu-link-empty-icon-padding-left);\n }\n :host([icon=''][iconPosition='right']) #text-container {\n margin-right: auto;\n }\n\n :host([iconPosition='right']) #text-container,\n :host([iconPosition='right']) #icon-only {\n padding-left: var(--hybrid-menu-link-icon-right-padding-left);\n }\n\n #link-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n hy-icon {\n display: flex;\n align-items: center;\n padding-right: var(--hybrid-menu-link-icon-padding-right);\n padding-left: var(--hybrid-menu-link-icon-padding-left);\n }\n`;\nexport const styles = menuLinkStyle;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-menu.style.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/templates/sub-menu.style.ts"],"names":[],"mappings":"AAgFA,eAAO,MAAM,MAAM,yBAAe,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const subMenuStyle = css `
|
|
3
|
+
:host([disabled]) ul > div {
|
|
4
|
+
color: var(--hybrid-sub-menu-disabled-color);
|
|
5
|
+
cursor: not-allowed;
|
|
6
|
+
}
|
|
7
|
+
:host(:not([disabled])[highlighted]) ul > div {
|
|
8
|
+
background: var(--hybrid-sub-menu-highlighted-background-color);
|
|
9
|
+
color: var(--hybrid-sub-menu-highlighted-color);
|
|
10
|
+
}
|
|
11
|
+
:host(:not([disabled])) {
|
|
12
|
+
color: var(--hybrid-sub-menu-color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([icon]) span {
|
|
16
|
+
margin-right: auto;
|
|
17
|
+
padding-left: var(--hybrid-sub-menu-padding-left-text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.icons-container{
|
|
21
|
+
display:flex;
|
|
22
|
+
align-items:center;
|
|
23
|
+
position:relative;
|
|
24
|
+
}
|
|
25
|
+
.action-icon{
|
|
26
|
+
margin-right:1px;
|
|
27
|
+
--hybrid-icon-color: var(--hybrid-sub-menu-action-icon-color);
|
|
28
|
+
}
|
|
29
|
+
.status-icon{
|
|
30
|
+
margin-right:10px;
|
|
31
|
+
--hybrid-icon-color: var(--hybrid-sub-menu-status-icon-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#text-icon {
|
|
35
|
+
--hybrid-icon-color: var(--hybrid-sub-menu-text-icon-color);
|
|
36
|
+
}
|
|
37
|
+
#toggle-icon {
|
|
38
|
+
--hybrid-icon-color: var(--hybrid-sub-menu-toggle-icon-color);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ul {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
margin-bottom: var(--hybrid-sub-menu-margin-y);
|
|
45
|
+
margin-top: var(--hybrid-sub-menu-margin-y);
|
|
46
|
+
padding-left: 0px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([icon]) ::slotted(*) {
|
|
50
|
+
padding-left: var(--hybrid-sub-menu-children-padding-left);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([icon='']) span {
|
|
54
|
+
padding-left: var(--hybrid-sub-menu-empty-icon-padding-left-text);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ul > div {
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
padding-top: var(--hybrid-sub-menu-padding-y);
|
|
62
|
+
padding-bottom: var(--hybrid-sub-menu-padding-y);
|
|
63
|
+
padding-left: var(--hybrid-sub-menu-padding-left);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host(:not([disabled])) ul > div:focus {
|
|
67
|
+
border: var(--hybrid-sub-menu-focus-border);
|
|
68
|
+
color: var(--hybrid-sub-menu-focus-color);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host(:not([disabled])) ul > div:hover {
|
|
72
|
+
background-color: var(--hybrid-sub-menu-hover-background-color);
|
|
73
|
+
color: var(--hybrid-sub-menu-hover-color);
|
|
74
|
+
}
|
|
75
|
+
:host(:not([disabled])) ul > div:active {
|
|
76
|
+
background-color: var(--hybrid-sub-menu-active-background-color);
|
|
77
|
+
color: var(--hybrid-sub-menu-active-color);
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
export const styles = subMenuStyle;
|
|
81
|
+
//# sourceMappingURL=sub-menu.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-menu.style.js","sourceRoot":"","sources":["../../../../src/components/menu/templates/sub-menu.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EvB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC","sourcesContent":["import {css} from 'lit';\n\nconst subMenuStyle = css`\n :host([disabled]) ul > div {\n color: var(--hybrid-sub-menu-disabled-color);\n cursor: not-allowed;\n }\n :host(:not([disabled])[highlighted]) ul > div {\n background: var(--hybrid-sub-menu-highlighted-background-color);\n color: var(--hybrid-sub-menu-highlighted-color);\n }\n :host(:not([disabled])) {\n color: var(--hybrid-sub-menu-color);\n }\n\n :host([icon]) span {\n margin-right: auto;\n padding-left: var(--hybrid-sub-menu-padding-left-text);\n }\n\n .icons-container{\n display:flex;\n align-items:center;\n position:relative;\n }\n .action-icon{\n margin-right:1px;\n --hybrid-icon-color: var(--hybrid-sub-menu-action-icon-color);\n }\n .status-icon{\n margin-right:10px;\n --hybrid-icon-color: var(--hybrid-sub-menu-status-icon-color);\n }\n\n #text-icon {\n --hybrid-icon-color: var(--hybrid-sub-menu-text-icon-color);\n }\n #toggle-icon {\n --hybrid-icon-color: var(--hybrid-sub-menu-toggle-icon-color);\n }\n\n ul {\n display: flex;\n flex-direction: column;\n margin-bottom: var(--hybrid-sub-menu-margin-y);\n margin-top: var(--hybrid-sub-menu-margin-y);\n padding-left: 0px;\n }\n\n :host([icon]) ::slotted(*) {\n padding-left: var(--hybrid-sub-menu-children-padding-left);\n }\n\n :host([icon='']) span {\n padding-left: var(--hybrid-sub-menu-empty-icon-padding-left-text);\n }\n\n ul > div {\n display: flex;\n justify-content: space-between;\n cursor: pointer;\n padding-top: var(--hybrid-sub-menu-padding-y);\n padding-bottom: var(--hybrid-sub-menu-padding-y);\n padding-left: var(--hybrid-sub-menu-padding-left);\n }\n\n :host(:not([disabled])) ul > div:focus {\n border: var(--hybrid-sub-menu-focus-border);\n color: var(--hybrid-sub-menu-focus-color);\n }\n\n :host(:not([disabled])) ul > div:hover {\n background-color: var(--hybrid-sub-menu-hover-background-color);\n color: var(--hybrid-sub-menu-hover-color);\n }\n :host(:not([disabled])) ul > div:active {\n background-color: var(--hybrid-sub-menu-active-background-color);\n color: var(--hybrid-sub-menu-active-color);\n }\n`;\nexport const styles = subMenuStyle;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link_test.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/test/menu-link_test.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
11
|
+
import '../templates/hy-menu-link';
|
|
12
|
+
import { ICON_POSITION } from '../templates/menu-link.contants';
|
|
13
|
+
suite('HyMenuLinkComponent', () => {
|
|
14
|
+
test('init menu link', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
const text = 'link text';
|
|
17
|
+
const link = 'url';
|
|
18
|
+
const icon = 'pencil';
|
|
19
|
+
const el = yield fixture(html `<hy-menu-link text="${text}" link=${link} icon=${icon}></hy-menu-link>`);
|
|
20
|
+
const templateIcon = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('hy-icon');
|
|
21
|
+
const templateLink = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('a');
|
|
22
|
+
const templateText = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('span');
|
|
23
|
+
const templateLinkIcon = (_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('#link-icon');
|
|
24
|
+
expect(el.text).to.equal(text);
|
|
25
|
+
expect(el.link).to.equal(link);
|
|
26
|
+
expect(el.icon).to.equal(icon);
|
|
27
|
+
expect(el.iconPosition).to.equal(ICON_POSITION.LEFT);
|
|
28
|
+
expect(el.disabled).to.be.false;
|
|
29
|
+
expect(el.selected).to.be.false;
|
|
30
|
+
expect(templateIcon).to.have.attribute('name', icon);
|
|
31
|
+
expect(templateLink).to.have.attribute('href', link);
|
|
32
|
+
expect(templateText === null || templateText === void 0 ? void 0 : templateText.textContent).to.equal(text);
|
|
33
|
+
expect(templateLinkIcon).to.not.exist;
|
|
34
|
+
}));
|
|
35
|
+
test('icon only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
var _e, _f, _g;
|
|
37
|
+
const link = 'url';
|
|
38
|
+
const icon = 'pencil';
|
|
39
|
+
const el = yield fixture(html `<hy-menu-link link=${link} icon=${icon}></hy-menu-link>`);
|
|
40
|
+
const templateText = (_e = el.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('span');
|
|
41
|
+
const templateLinkIcon = (_f = el.shadowRoot) === null || _f === void 0 ? void 0 : _f.querySelector('#link-icon');
|
|
42
|
+
const anchors = (_g = el.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelectorAll('a');
|
|
43
|
+
expect(templateText).not.exist;
|
|
44
|
+
expect(templateLinkIcon).to.exist;
|
|
45
|
+
expect(templateLinkIcon).to.have.attribute('href', link);
|
|
46
|
+
expect(templateLinkIcon === null || templateLinkIcon === void 0 ? void 0 : templateLinkIcon.children[0]).to.have.attribute('name', icon);
|
|
47
|
+
expect(anchors).to.have.length(1);
|
|
48
|
+
}));
|
|
49
|
+
test('text only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
var _h, _j;
|
|
51
|
+
const link = 'url';
|
|
52
|
+
const text = 'this is a text';
|
|
53
|
+
const el = yield fixture(html `<hy-menu-link link=${link} text=${text}></hy-menu-link>`);
|
|
54
|
+
const templateText = (_h = el.shadowRoot) === null || _h === void 0 ? void 0 : _h.querySelector('span');
|
|
55
|
+
const templateLinkIcon = (_j = el.shadowRoot) === null || _j === void 0 ? void 0 : _j.querySelector('#link-icon');
|
|
56
|
+
const templateAnchor = el.shadowRoot.querySelectorAll('a');
|
|
57
|
+
expect(templateText).exist;
|
|
58
|
+
expect(templateLinkIcon).not.to.exist;
|
|
59
|
+
expect(templateAnchor).to.exist;
|
|
60
|
+
expect(templateAnchor).to.have.length(1);
|
|
61
|
+
expect(templateAnchor[0]).to.have.attribute('href', link);
|
|
62
|
+
expect(templateAnchor[0].children[0].textContent).to.equal(text);
|
|
63
|
+
}));
|
|
64
|
+
test('enabled link', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const el = yield fixture(html `<hy-menu-link> </hy-menu-link>`);
|
|
66
|
+
const container = el.shadowRoot.querySelector('li');
|
|
67
|
+
let selectedLinkDispatch = false;
|
|
68
|
+
el.addEventListener('selected-link', () => {
|
|
69
|
+
selectedLinkDispatch = true;
|
|
70
|
+
});
|
|
71
|
+
container.click();
|
|
72
|
+
expect(selectedLinkDispatch).to.be.true;
|
|
73
|
+
}));
|
|
74
|
+
test('disabled link', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const el = yield fixture(html `<hy-menu-link disabled=${true}> </hy-menu-link>`);
|
|
76
|
+
const container = el.shadowRoot.querySelector('li');
|
|
77
|
+
let selectedLinkDispatch = false;
|
|
78
|
+
el.addEventListener('selected-link', () => {
|
|
79
|
+
selectedLinkDispatch = true;
|
|
80
|
+
});
|
|
81
|
+
container.click();
|
|
82
|
+
expect(selectedLinkDispatch).to.be.false;
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=menu-link_test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-link_test.js","sourceRoot":"","sources":["../../../../src/components/menu/test/menu-link_test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAEvD,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,KAAK,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,gBAAgB,EAAE,GAAS,EAAE;;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC;QACnB,MAAM,IAAI,GAAG,QAAQ,CAAC;QACtB,MAAM,EAAE,GAAe,MAAM,OAAO,CAAC,IAAI,CAAA,uBAAuB,IAAI,UAAU,IAAI,SAAS,IAAI,kBAAkB,CAAC,CAAC;QACnH,MAAM,YAAY,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,YAAY,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,gBAAgB,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QACpE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B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C,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC3C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {html, fixture, expect} from '@open-wc/testing';\nimport {HyMenuLink} from '../templates/hy-menu-link';\nimport '../templates/hy-menu-link';\nimport {ICON_POSITION} from '../templates/menu-link.contants';\n\nsuite('HyMenuLinkComponent', () => {\n test('init menu link', async () => {\n const text = 'link text';\n const link = 'url';\n const icon = 'pencil';\n const el: HyMenuLink = await fixture(html`<hy-menu-link text=\"${text}\" link=${link} icon=${icon}></hy-menu-link>`);\n const templateIcon = el.shadowRoot?.querySelector('hy-icon');\n const templateLink = el.shadowRoot?.querySelector('a');\n const templateText = el.shadowRoot?.querySelector('span');\n const templateLinkIcon = el.shadowRoot?.querySelector('#link-icon');\n expect(el.text).to.equal(text);\n expect(el.link).to.equal(link);\n expect(el.icon).to.equal(icon);\n expect(el.iconPosition).to.equal(ICON_POSITION.LEFT);\n expect(el.disabled).to.be.false;\n expect(el.selected).to.be.false;\n expect(templateIcon).to.have.attribute('name', icon);\n expect(templateLink).to.have.attribute('href', link);\n expect(templateText?.textContent).to.equal(text);\n expect(templateLinkIcon).to.not.exist;\n });\n\n test('icon only', async () => {\n const link = 'url';\n const icon = 'pencil';\n const el: HyMenuLink = await fixture(html`<hy-menu-link link=${link} icon=${icon}></hy-menu-link>`);\n const templateText = el.shadowRoot?.querySelector('span');\n const templateLinkIcon = el.shadowRoot?.querySelector('#link-icon');\n const anchors = el.shadowRoot?.querySelectorAll('a');\n expect(templateText).not.exist;\n expect(templateLinkIcon).to.exist;\n expect(templateLinkIcon).to.have.attribute('href', link);\n expect(templateLinkIcon?.children[0]).to.have.attribute('name', icon);\n expect(anchors).to.have.length(1);\n });\n test('text only', async () => {\n const link = 'url';\n const text = 'this is a text';\n const el: HyMenuLink = await fixture(html`<hy-menu-link link=${link} text=${text}></hy-menu-link>`);\n const templateText = el.shadowRoot?.querySelector('span');\n const templateLinkIcon = el.shadowRoot?.querySelector('#link-icon');\n const templateAnchor = el.shadowRoot!.querySelectorAll('a')!;\n expect(templateText).exist;\n expect(templateLinkIcon).not.to.exist;\n expect(templateAnchor).to.exist;\n expect(templateAnchor).to.have.length(1);\n expect(templateAnchor[0]).to.have.attribute('href', link);\n expect(templateAnchor[0].children[0].textContent).to.equal(text);\n });\n\n test('enabled link', async () => {\n const el: HyMenuLink = await fixture(html`<hy-menu-link> </hy-menu-link>`);\n const container = el.shadowRoot!.querySelector('li')!;\n let selectedLinkDispatch = false;\n el.addEventListener('selected-link', () => {\n selectedLinkDispatch = true;\n });\n container.click();\n expect(selectedLinkDispatch).to.be.true;\n });\n test('disabled link', async () => {\n const el: HyMenuLink = await fixture(html`<hy-menu-link disabled=${true}> </hy-menu-link>`);\n const container = el.shadowRoot!.querySelector('li')!;\n let selectedLinkDispatch = false;\n el.addEventListener('selected-link', () => {\n selectedLinkDispatch = true;\n });\n container.click();\n expect(selectedLinkDispatch).to.be.false;\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu_test.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/test/menu_test.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,CAAC"}
|