@nuralyui/dropdown 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/hy-dropdowns-demo.d.ts +19 -0
- package/demo/hy-dropdowns-demo.d.ts.map +1 -0
- package/demo/hy-dropdowns-demo.js +205 -0
- package/demo/hy-dropdowns-demo.js.map +1 -0
- package/dropdown.types.d.ts +16 -0
- package/dropdown.types.d.ts.map +1 -0
- package/dropdown.types.js +2 -0
- package/dropdown.types.js.map +1 -0
- package/hy-dropdown.component.d.ts +29 -0
- package/hy-dropdown.component.d.ts.map +1 -0
- package/hy-dropdown.component.js +182 -0
- package/hy-dropdown.component.js.map +1 -0
- package/hy-dropdown.style.d.ts +2 -0
- package/hy-dropdown.style.d.ts.map +1 -0
- package/hy-dropdown.style.js +42 -0
- package/hy-dropdown.style.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/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-dropdown-item.d.ts +11 -0
- package/templates/hy-dropdown-item.d.ts.map +1 -0
- package/templates/hy-dropdown-item.js +41 -0
- package/templates/hy-dropdown-item.js.map +1 -0
- package/templates/hy-dropdown-item.style.d.ts +2 -0
- package/templates/hy-dropdown-item.style.d.ts.map +1 -0
- package/templates/hy-dropdown-item.style.js +31 -0
- package/templates/hy-dropdown-item.style.js.map +1 -0
- package/templates/hy-dropdown-menu.d.ts +18 -0
- package/templates/hy-dropdown-menu.d.ts.map +1 -0
- package/templates/hy-dropdown-menu.js +70 -0
- package/templates/hy-dropdown-menu.js.map +1 -0
- package/templates/hy-dropdown-menu.style.d.ts +2 -0
- package/templates/hy-dropdown-menu.style.d.ts.map +1 -0
- package/templates/hy-dropdown-menu.style.js +49 -0
- package/templates/hy-dropdown-menu.style.js.map +1 -0
- package/test/hy-dropdown_test.d.ts +4 -0
- package/test/hy-dropdown_test.d.ts.map +1 -0
- package/test/hy-dropdown_test.js +132 -0
- package/test/hy-dropdown_test.js.map +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import '../hy-dropdown.component';
|
|
8
|
+
import { IOption } from '../dropdown.types';
|
|
9
|
+
export declare class ElButtonDemoElement extends LitElement {
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
options: IOption[];
|
|
12
|
+
render(): import("lit").TemplateResult<1>;
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'hy-dropdwon-demo': ElButtonDemoElement;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=hy-dropdowns-demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdowns-demo.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/demo/hy-dropdowns-demo.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAY,MAAM,KAAK,CAAC;AAG1C,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE1C,qBACa,mBAAoB,SAAQ,UAAU;IACjD,OAAgB,MAAM,4BAuBpB;IAEF,OAAO,EAAE,OAAO,EAAE,CAyChB;IACO,MAAM;CA+GhB;AACD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,mBAAmB,CAAC;KACzC;CACF"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google Laabidi Aymen
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
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;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
};
|
|
13
|
+
import { LitElement, css, html } from 'lit';
|
|
14
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
15
|
+
import '../hy-dropdown.component';
|
|
16
|
+
let ElButtonDemoElement = class ElButtonDemoElement extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.options = [
|
|
20
|
+
{ label: 'option1', value: 'value1', icon: 'bomb' },
|
|
21
|
+
{
|
|
22
|
+
label: 'option2',
|
|
23
|
+
value: 'value2',
|
|
24
|
+
children: [
|
|
25
|
+
{ label: 'option3', value: 'value3', icon: 'car' },
|
|
26
|
+
{ label: 'option13', value: 'value13', icon: 'car' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{ label: 'option4', value: 'value4', icon: 'bomb', disabled: true },
|
|
30
|
+
{
|
|
31
|
+
label: 'option5',
|
|
32
|
+
value: 'value5',
|
|
33
|
+
children: [
|
|
34
|
+
{
|
|
35
|
+
label: 'option6',
|
|
36
|
+
value: 'value6',
|
|
37
|
+
icon: 'car',
|
|
38
|
+
disabled: true,
|
|
39
|
+
children: [{ label: 'option7', value: 'value7', icon: 'cog' }],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'option8',
|
|
45
|
+
value: 'value8',
|
|
46
|
+
icon: 'book',
|
|
47
|
+
children: [
|
|
48
|
+
{
|
|
49
|
+
label: 'option9',
|
|
50
|
+
value: 'value9',
|
|
51
|
+
icon: 'bolt',
|
|
52
|
+
children: [
|
|
53
|
+
{ label: 'option10', value: 'value10', icon: 'bell', disabled: true },
|
|
54
|
+
{ label: 'option11', value: 'value11', icon: 'bell' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{ label: 'option12', value: 'value12', disabled: true },
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
return html `
|
|
64
|
+
<h3>With template</h3>
|
|
65
|
+
<hy-dropdown .template=${html `<div style='color:red;'>hello</div>`}>
|
|
66
|
+
<span>click me</span>
|
|
67
|
+
</hy-dropdown>
|
|
68
|
+
<div id="centered">
|
|
69
|
+
<h3>Centered trigger</h3>
|
|
70
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
71
|
+
<div style="overflow-y:scroll;max-height:100px;width:100px"> hover meee, hover meeehover meeehover meeehover meeehover meeehover meeehover meee</div>
|
|
72
|
+
</hy-dropdown>
|
|
73
|
+
|
|
74
|
+
<br /><br />
|
|
75
|
+
|
|
76
|
+
<hy-dropdown
|
|
77
|
+
trigger="click"
|
|
78
|
+
.options=${this.options}
|
|
79
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
80
|
+
>
|
|
81
|
+
<span> click me</span>
|
|
82
|
+
</hy-dropdown>
|
|
83
|
+
<br /><br />
|
|
84
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
85
|
+
<span> hover me</span>
|
|
86
|
+
</hy-dropdown>
|
|
87
|
+
|
|
88
|
+
<br /><br />
|
|
89
|
+
|
|
90
|
+
<hy-dropdown
|
|
91
|
+
trigger="click"
|
|
92
|
+
.options=${this.options}
|
|
93
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
94
|
+
>
|
|
95
|
+
<span> click me</span>
|
|
96
|
+
</hy-dropdown>
|
|
97
|
+
<br /><br />
|
|
98
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
99
|
+
<span> hover me</span>
|
|
100
|
+
</hy-dropdown>
|
|
101
|
+
</div>
|
|
102
|
+
<div id="left">
|
|
103
|
+
<h3>Left trigger</h3>
|
|
104
|
+
|
|
105
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
106
|
+
<span> hover me</span>
|
|
107
|
+
</hy-dropdown>
|
|
108
|
+
|
|
109
|
+
<br /><br />
|
|
110
|
+
|
|
111
|
+
<hy-dropdown
|
|
112
|
+
trigger="click"
|
|
113
|
+
.options=${this.options}
|
|
114
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
115
|
+
>
|
|
116
|
+
<span> click me</span>
|
|
117
|
+
</hy-dropdown>
|
|
118
|
+
<br /><br />
|
|
119
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
120
|
+
<span> hover me</span>
|
|
121
|
+
</hy-dropdown>
|
|
122
|
+
|
|
123
|
+
<br /><br />
|
|
124
|
+
|
|
125
|
+
<hy-dropdown
|
|
126
|
+
trigger="click"
|
|
127
|
+
.options=${this.options}
|
|
128
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
129
|
+
>
|
|
130
|
+
<span> click me</span>
|
|
131
|
+
</hy-dropdown>
|
|
132
|
+
<br /><br />
|
|
133
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
134
|
+
<span> hover me</span>
|
|
135
|
+
</hy-dropdown>
|
|
136
|
+
</div>
|
|
137
|
+
<div id="right">
|
|
138
|
+
<h3>Right trigger</h3>
|
|
139
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
140
|
+
<span> hover me</span>
|
|
141
|
+
</hy-dropdown>
|
|
142
|
+
|
|
143
|
+
<br /><br />
|
|
144
|
+
|
|
145
|
+
<hy-dropdown
|
|
146
|
+
trigger="click"
|
|
147
|
+
.options=${this.options}
|
|
148
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
149
|
+
>
|
|
150
|
+
<span> click me</span>
|
|
151
|
+
</hy-dropdown>
|
|
152
|
+
<br /><br />
|
|
153
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
154
|
+
<span> hover me</span>
|
|
155
|
+
</hy-dropdown>
|
|
156
|
+
|
|
157
|
+
<br /><br />
|
|
158
|
+
|
|
159
|
+
<hy-dropdown
|
|
160
|
+
trigger="click"
|
|
161
|
+
.options=${this.options}
|
|
162
|
+
@click-item=${(e) => console.log('value clicked', e.detail)}
|
|
163
|
+
>
|
|
164
|
+
<span> click me</span>
|
|
165
|
+
</hy-dropdown>
|
|
166
|
+
<br /><br />
|
|
167
|
+
<hy-dropdown .options=${this.options} @click-item=${(e) => console.log('value clicked', e.detail)}>
|
|
168
|
+
<span> hover me</span>
|
|
169
|
+
</hy-dropdown>
|
|
170
|
+
</div>
|
|
171
|
+
`;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
ElButtonDemoElement.styles = [
|
|
175
|
+
css `
|
|
176
|
+
#centered {
|
|
177
|
+
display: flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
gap: 30px;
|
|
181
|
+
}
|
|
182
|
+
#left {
|
|
183
|
+
display: flex;
|
|
184
|
+
align-items: start;
|
|
185
|
+
flex-direction: column;
|
|
186
|
+
gap: 10px;
|
|
187
|
+
margin-left: 50px;
|
|
188
|
+
}
|
|
189
|
+
#right {
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: end;
|
|
192
|
+
flex-direction: column;
|
|
193
|
+
gap: 10px;
|
|
194
|
+
margin-right: 50px;
|
|
195
|
+
}
|
|
196
|
+
`,
|
|
197
|
+
];
|
|
198
|
+
__decorate([
|
|
199
|
+
state()
|
|
200
|
+
], ElButtonDemoElement.prototype, "options", void 0);
|
|
201
|
+
ElButtonDemoElement = __decorate([
|
|
202
|
+
customElement('hy-dropdwon-demo')
|
|
203
|
+
], ElButtonDemoElement);
|
|
204
|
+
export { ElButtonDemoElement };
|
|
205
|
+
//# sourceMappingURL=hy-dropdowns-demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdowns-demo.js","sourceRoot":"","sources":["../../../../src/components/dropdown/demo/hy-dropdowns-demo.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;GAIG;;;;;;;AAEH,OAAO,EAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAEvD,OAAO,0BAA0B,CAAC;AAIlC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAAnD;;QA0BE,YAAO,GAAc;YACnB,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAC;YACjD;gBACE,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,QAAQ;gBACf,QAAQ,EAAE;oBACR,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC;oBAChD,EAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAC;iBACnD;aACF;YACD,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC;YACjE;gBACE,KAAK,EAAE,SAAS;g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CAAC,OAAO,gBAAgB,CAAC,CAAc,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC;;;;;;;;qBAQjG,IAAI,CAAC,OAAO;wBACT,CAAC,CAAc,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC;;;;;gCAKlD,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAc,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC;;;;KAIjH,CAAC;IACJ,CAAC;CACF,CAAA;AAlLiB,0BAAM,GAAG;IACvB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACD,CAAA;AAEF;IADC,KAAK,EAAE;oDA0CN;AAnES,mBAAmB;IAD/B,aAAa,CAAC,kBAAkB,CAAC;GACrB,mBAAmB,CAmL/B;SAnLY,mBAAmB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport {LitElement, css, html} from 'lit';\nimport {customElement, state} from 'lit/decorators.js';\n\nimport '../hy-dropdown.component';\nimport {IOption} from '../dropdown.types';\n\n@customElement('hy-dropdwon-demo')\nexport class ElButtonDemoElement extends LitElement {\n static override styles = [\n css`\n #centered {\n display: flex;\n align-items: center;\n flex-direction: column;\n gap: 30px;\n }\n #left {\n display: flex;\n align-items: start;\n flex-direction: column;\n gap: 10px;\n margin-left: 50px;\n }\n #right {\n display: flex;\n align-items: end;\n flex-direction: column;\n gap: 10px;\n margin-right: 50px;\n }\n `,\n ];\n @state()\n options: IOption[] = [\n {label: 'option1', value: 'value1', icon: 'bomb'},\n {\n label: 'option2',\n value: 'value2',\n children: [\n {label: 'option3', value: 'value3', icon: 'car'},\n {label: 'option13', value: 'value13', icon: 'car'},\n ],\n },\n {label: 'option4', value: 'value4', icon: 'bomb', disabled: true},\n {\n label: 'option5',\n value: 'value5',\n children: [\n {\n label: 'option6',\n value: 'value6',\n icon: 'car',\n disabled: true,\n children: [{label: 'option7', value: 'value7', icon: 'cog'}],\n },\n ],\n },\n {\n label: 'option8',\n value: 'value8',\n icon: 'book',\n children: [\n {\n label: 'option9',\n value: 'value9',\n icon: 'bolt',\n children: [\n {label: 'option10', value: 'value10', icon: 'bell', disabled: true},\n {label: 'option11', value: 'value11', icon: 'bell'},\n ],\n },\n ],\n },\n {label: 'option12', value: 'value12', disabled: true},\n ];\n override render() {\n return html` \n <h3>With template</h3>\n <hy-dropdown .template=${html`<div style='color:red;'>hello</div>`}>\n <span>click me</span>\n </hy-dropdown>\n <div id=\"centered\">\n <h3>Centered trigger</h3>\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <div style=\"overflow-y:scroll;max-height:100px;width:100px\"> hover meee, hover meeehover meeehover meeehover meeehover meeehover meeehover meee</div>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n </div>\n <div id=\"left\">\n <h3>Left trigger</h3>\n\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n </div>\n <div id=\"right\">\n <h3>Right trigger</h3>\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n\n <br /><br />\n\n <hy-dropdown\n trigger=\"click\"\n .options=${this.options}\n @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}\n >\n <span> click me</span>\n </hy-dropdown>\n <br /><br />\n <hy-dropdown .options=${this.options} @click-item=${(e: CustomEvent) => console.log('value clicked', e.detail)}>\n <span> hover me</span>\n </hy-dropdown>\n </div>\n `;\n }\n}\ndeclare global {\n interface HTMLElementTagNameMap {\n 'hy-dropdwon-demo': ElButtonDemoElement;\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
icon?: string;
|
|
6
|
+
children?: IOption[];
|
|
7
|
+
}
|
|
8
|
+
export declare const enum TriggerMode {
|
|
9
|
+
Click = "click",
|
|
10
|
+
Hover = "hover"
|
|
11
|
+
}
|
|
12
|
+
export declare const enum DropDownDirection {
|
|
13
|
+
Right = "right",
|
|
14
|
+
Left = "left"
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dropdown.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/dropdown.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,0BAAkB,WAAW;IAC3B,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AACD,0BAAkB,iBAAiB;IACjC,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.types.js","sourceRoot":"","sources":["../../../src/components/dropdown/dropdown.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface IOption {\n label: string;\n value?: string;\n disabled?: boolean;\n icon?: string;\n children?: IOption[];\n}\n\nexport const enum TriggerMode {\n Click = 'click',\n Hover = 'hover',\n}\nexport const enum DropDownDirection {\n Right = 'right',\n Left = 'left',\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { DropDownDirection, IOption, TriggerMode } from './dropdown.types';
|
|
3
|
+
import './templates/hy-dropdown-item.js';
|
|
4
|
+
import './templates/hy-dropdown-menu.js';
|
|
5
|
+
export declare class HyDropdownComponent extends LitElement {
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
triggerElement: HTMLElement;
|
|
8
|
+
dropDownContainer: HTMLElement;
|
|
9
|
+
options: IOption[];
|
|
10
|
+
show: boolean;
|
|
11
|
+
trigger: TriggerMode;
|
|
12
|
+
template: TemplateResult<1>;
|
|
13
|
+
isDropDownVisited: boolean;
|
|
14
|
+
dropDownDirection: DropDownDirection;
|
|
15
|
+
firstUpdated(): void;
|
|
16
|
+
onTriggerClick: () => Promise<void>;
|
|
17
|
+
calculatePosition: () => void;
|
|
18
|
+
initPosition(): void;
|
|
19
|
+
onClickOutside: (onClickEvent: Event) => void;
|
|
20
|
+
onMouseEnterTriggerElement: () => Promise<void>;
|
|
21
|
+
onMouseLeaveTriggerElement: () => void;
|
|
22
|
+
onMouseEnterDropDown: () => void;
|
|
23
|
+
onMouseLeaveDropDown: () => void;
|
|
24
|
+
onOptionClick(): void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
display(options: IOption[]): any;
|
|
27
|
+
render(): TemplateResult<1>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=hy-dropdown.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown.component.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAO,MAAM,KAAK,CAAC;AAGrD,OAAO,EAAC,iBAAiB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AACzE,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AAEzC,qBACa,mBAAoB,SAAQ,UAAU;IACjD,OAAgB,MAAM,0BAAU;IAEhC,cAAc,EAAG,WAAW,CAAC;IAE7B,iBAAiB,EAAG,WAAW,CAAC;IAEhC,OAAO,EAAG,OAAO,EAAE,CAAC;IAEpB,IAAI,UAAS;IAEb,OAAO,cAAqB;IAE5B,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAI5B,iBAAiB,UAAS;IAE1B,iBAAiB,oBAA2B;IAEnC,YAAY,IAAI,IAAI;IAa7B,cAAc,sBAIZ;IACF,iBAAiB,aAoBf;IACF,YAAY;IAKZ,cAAc,iBAAiB,KAAK,UAMlC;IACF,0BAA0B,sBAIxB;IACF,0BAA0B,aAKxB;IACF,oBAAoB,aAElB;IACF,oBAAoB,aAIlB;IACF,aAAa;IAIJ,oBAAoB;IAc7B,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG;IAsBvB,MAAM;CAQhB"}
|
|
@@ -0,0 +1,182 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
+
import { LitElement, html } from 'lit';
|
|
18
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
19
|
+
import { styles } from './hy-dropdown.style.js';
|
|
20
|
+
import './templates/hy-dropdown-item.js';
|
|
21
|
+
import './templates/hy-dropdown-menu.js';
|
|
22
|
+
let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.show = false;
|
|
26
|
+
this.trigger = "click" /* TriggerMode.Click */;
|
|
27
|
+
this.isDropDownVisited = false;
|
|
28
|
+
this.dropDownDirection = "right" /* DropDownDirection.Right */;
|
|
29
|
+
this.onTriggerClick = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
this.show = !this.show;
|
|
31
|
+
yield this.updateComplete;
|
|
32
|
+
this.calculatePosition();
|
|
33
|
+
});
|
|
34
|
+
this.calculatePosition = () => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const triggerClientRect = this.shadowRoot.querySelector('slot').assignedElements()[0].getBoundingClientRect();
|
|
37
|
+
const dropDownWidth = (_a = this.dropDownContainer) === null || _a === void 0 ? void 0 : _a.clientWidth;
|
|
38
|
+
const dropDownHeight = (_b = this.dropDownContainer) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
39
|
+
const availableBottomSpace = window.visualViewport.height - triggerClientRect.bottom;
|
|
40
|
+
const availableRightSpace = window.visualViewport.width - triggerClientRect.left;
|
|
41
|
+
const availableLeftSpace = triggerClientRect.right;
|
|
42
|
+
this.dropDownContainer.style.position = 'fixed';
|
|
43
|
+
if (dropDownHeight > availableBottomSpace) {
|
|
44
|
+
this.dropDownContainer.style.top = `${triggerClientRect.top - dropDownHeight}px`;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.dropDownContainer.style.top = `${triggerClientRect.top + triggerClientRect.height}px`;
|
|
48
|
+
}
|
|
49
|
+
if (dropDownWidth > availableRightSpace && dropDownWidth < availableLeftSpace) {
|
|
50
|
+
this.dropDownContainer.style.right = `${availableRightSpace}px`;
|
|
51
|
+
this.dropDownDirection = "left" /* DropDownDirection.Left */;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.dropDownDirection = "right" /* DropDownDirection.Right */;
|
|
55
|
+
this.dropDownContainer.style.removeProperty('right');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.onClickOutside = (onClickEvent) => {
|
|
59
|
+
const outsideClick = !onClickEvent.composedPath().includes(this);
|
|
60
|
+
if (outsideClick && this.show) {
|
|
61
|
+
this.show = false;
|
|
62
|
+
this.initPosition();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
this.onMouseEnterTriggerElement = () => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
this.show = true;
|
|
67
|
+
yield this.updateComplete;
|
|
68
|
+
this.calculatePosition();
|
|
69
|
+
});
|
|
70
|
+
this.onMouseLeaveTriggerElement = () => {
|
|
71
|
+
const waitIsDropDownVisited = 50;
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (!this.isDropDownVisited)
|
|
74
|
+
this.show = false;
|
|
75
|
+
}, waitIsDropDownVisited);
|
|
76
|
+
};
|
|
77
|
+
this.onMouseEnterDropDown = () => {
|
|
78
|
+
this.isDropDownVisited = true;
|
|
79
|
+
};
|
|
80
|
+
this.onMouseLeaveDropDown = () => {
|
|
81
|
+
this.isDropDownVisited = false;
|
|
82
|
+
this.show = false;
|
|
83
|
+
this.initPosition();
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
firstUpdated() {
|
|
87
|
+
document.addEventListener('scroll', this.calculatePosition);
|
|
88
|
+
window.addEventListener('resize', this.calculatePosition);
|
|
89
|
+
if (this.trigger == "hover" /* TriggerMode.Hover */) {
|
|
90
|
+
this.triggerElement.addEventListener('mouseenter', this.onMouseEnterTriggerElement);
|
|
91
|
+
this.triggerElement.addEventListener('mouseleave', this.onMouseLeaveTriggerElement);
|
|
92
|
+
this.dropDownContainer.addEventListener('mouseenter', this.onMouseEnterDropDown);
|
|
93
|
+
this.dropDownContainer.addEventListener('mouseleave', this.onMouseLeaveDropDown);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.triggerElement.addEventListener('click', this.onTriggerClick);
|
|
97
|
+
window.addEventListener('click', this.onClickOutside);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
initPosition() {
|
|
101
|
+
this.dropDownContainer.style.removeProperty('top');
|
|
102
|
+
this.dropDownContainer.style.removeProperty('position');
|
|
103
|
+
this.dropDownContainer.style.removeProperty('right');
|
|
104
|
+
}
|
|
105
|
+
onOptionClick() {
|
|
106
|
+
this.show = false;
|
|
107
|
+
}
|
|
108
|
+
disconnectedCallback() {
|
|
109
|
+
document.removeEventListener('scroll', this.calculatePosition);
|
|
110
|
+
window.removeEventListener('resize', this.calculatePosition);
|
|
111
|
+
if (this.trigger == "hover" /* TriggerMode.Hover */) {
|
|
112
|
+
this.triggerElement.removeEventListener('mouseenter', this.onMouseEnterTriggerElement);
|
|
113
|
+
this.triggerElement.removeEventListener('mouseleave', this.onMouseLeaveTriggerElement);
|
|
114
|
+
this.dropDownContainer.removeEventListener('mouseenter', this.onMouseEnterDropDown);
|
|
115
|
+
this.dropDownContainer.removeEventListener('mouseleave', this.onMouseLeaveDropDown);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.triggerElement.removeEventListener('click', this.onTriggerClick);
|
|
119
|
+
window.removeEventListener('click', this.onClickOutside);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
display(options) {
|
|
123
|
+
return options.map((option) => {
|
|
124
|
+
if (option.children) {
|
|
125
|
+
return html `<hy-dropdown-menu
|
|
126
|
+
.direction=${this.dropDownDirection}
|
|
127
|
+
.disabled=${option.disabled}
|
|
128
|
+
.icon=${option.icon}
|
|
129
|
+
.label=${option.label}
|
|
130
|
+
>
|
|
131
|
+
<div class="dropdown-container">${this.display(option.children)}</div>
|
|
132
|
+
</hy-dropdown-menu>`;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return html `<hy-dropdown-item
|
|
136
|
+
.disabled=${option.disabled}
|
|
137
|
+
.icon=${option.icon}
|
|
138
|
+
.label=${option.label}
|
|
139
|
+
.value=${option.value}
|
|
140
|
+
></hy-dropdown-item>`;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
return html `
|
|
146
|
+
<slot></slot>
|
|
147
|
+
<div class="dropdown-container" @click-item=${this.onOptionClick}>
|
|
148
|
+
${this.template ? html `${this.template}` : this.display(this.options)}
|
|
149
|
+
</div>
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
HyDropdownComponent.styles = styles;
|
|
154
|
+
__decorate([
|
|
155
|
+
query('slot')
|
|
156
|
+
], HyDropdownComponent.prototype, "triggerElement", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
query('.dropdown-container')
|
|
159
|
+
], HyDropdownComponent.prototype, "dropDownContainer", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
property()
|
|
162
|
+
], HyDropdownComponent.prototype, "options", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: Boolean, reflect: true })
|
|
165
|
+
], HyDropdownComponent.prototype, "show", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
property()
|
|
168
|
+
], HyDropdownComponent.prototype, "trigger", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
property()
|
|
171
|
+
], HyDropdownComponent.prototype, "template", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
state()
|
|
174
|
+
], HyDropdownComponent.prototype, "isDropDownVisited", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
state()
|
|
177
|
+
], HyDropdownComponent.prototype, "dropDownDirection", void 0);
|
|
178
|
+
HyDropdownComponent = __decorate([
|
|
179
|
+
customElement('hy-dropdown')
|
|
180
|
+
], HyDropdownComponent);
|
|
181
|
+
export { HyDropdownComponent };
|
|
182
|
+
//# sourceMappingURL=hy-dropdown.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown.component.js","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,OAAO,EAAC,UAAU,EAAkB,IAAI,EAAC,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAE9C,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AAGzC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAAnD;;QASE,SAAI,GAAG,KAAK,CAAC;QAEb,YAAO,mCAAqB;QAM5B,sBAAiB,GAAG,KAAK,CAAC;QAE1B,sBAAiB,yCAA2B;QAe5C,mBAAc,GAAG,GAAS,EAAE;YAC1B,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,MAAM,IAAI,CAAC,cAAc,CAAC;YAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC,CAAA,CAAC;QACF,sBAAiB,GAAG,GAAG,EAAE;;YACvB,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,qBAAqB,EAAG,CAAC;YACjH,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,iBAAiB,0CAAE,WAAW,CAAC;YAC1D,MAAM,cAAc,GAAG,MAAA,IAAI,CAAC,iBAAiB,0CAAE,YAAY,CAAC;YAC5D,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAe,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;YACtF,MAAM,mBAAmB,GAAG,MAAM,C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TemplateResult, html} from 'lit';\nimport {customElement, property, query, state} from 'lit/decorators.js';\nimport {styles} from './hy-dropdown.style.js';\nimport {DropDownDirection, IOption, TriggerMode} from './dropdown.types';\nimport './templates/hy-dropdown-item.js';\nimport './templates/hy-dropdown-menu.js';\n\n@customElement('hy-dropdown')\nexport class HyDropdownComponent extends LitElement {\n static override styles = styles;\n @query('slot')\n triggerElement!: HTMLElement;\n @query('.dropdown-container')\n dropDownContainer!: HTMLElement;\n @property()\n options!: IOption[];\n @property({type: Boolean, reflect: true})\n show = false;\n @property()\n trigger = TriggerMode.Click;\n @property()\n template!:TemplateResult<1>;\n\n\n @state()\n isDropDownVisited = false;\n @state()\n dropDownDirection = DropDownDirection.Right;\n\n override firstUpdated(): void {\n document.addEventListener('scroll', this.calculatePosition);\n window.addEventListener('resize', this.calculatePosition);\n if (this.trigger == TriggerMode.Hover) {\n this.triggerElement.addEventListener('mouseenter', this.onMouseEnterTriggerElement);\n this.triggerElement.addEventListener('mouseleave', this.onMouseLeaveTriggerElement);\n this.dropDownContainer.addEventListener('mouseenter', this.onMouseEnterDropDown);\n this.dropDownContainer.addEventListener('mouseleave', this.onMouseLeaveDropDown);\n } else {\n this.triggerElement.addEventListener('click', this.onTriggerClick);\n window.addEventListener('click', this.onClickOutside);\n }\n }\n onTriggerClick = async () => {\n this.show = !this.show;\n await this.updateComplete;\n this.calculatePosition();\n };\n calculatePosition = () => {\n const triggerClientRect = this.shadowRoot!.querySelector('slot')!.assignedElements()[0].getBoundingClientRect()!;\n const dropDownWidth = this.dropDownContainer?.clientWidth;\n const dropDownHeight = this.dropDownContainer?.clientHeight;\n const availableBottomSpace = window.visualViewport!.height - triggerClientRect.bottom;\n const availableRightSpace = window.visualViewport!.width - triggerClientRect.left;\n const availableLeftSpace = triggerClientRect.right;\n this.dropDownContainer.style.position = 'fixed';\n if (dropDownHeight > availableBottomSpace) {\n this.dropDownContainer.style.top = `${triggerClientRect.top - dropDownHeight}px`;\n } else {\n this.dropDownContainer.style.top = `${triggerClientRect.top +triggerClientRect.height}px`;\n }\n if (dropDownWidth > availableRightSpace && dropDownWidth < availableLeftSpace) {\n this.dropDownContainer.style.right = `${availableRightSpace}px`;\n this.dropDownDirection = DropDownDirection.Left;\n } else {\n this.dropDownDirection = DropDownDirection.Right;\n this.dropDownContainer.style.removeProperty('right');\n }\n };\n initPosition() {\n this.dropDownContainer.style.removeProperty('top');\n this.dropDownContainer.style.removeProperty('position');\n this.dropDownContainer.style.removeProperty('right');\n }\n onClickOutside = (onClickEvent:Event) => {\n const outsideClick = !onClickEvent.composedPath().includes(this)\n if (outsideClick && this.show){\n this.show = false;\n this.initPosition();\n }\n };\n onMouseEnterTriggerElement = async () => {\n this.show = true;\n await this.updateComplete;\n this.calculatePosition();\n };\n onMouseLeaveTriggerElement = () => {\n const waitIsDropDownVisited = 50;\n setTimeout(() => {\n if (!this.isDropDownVisited) this.show = false;\n }, waitIsDropDownVisited);\n };\n onMouseEnterDropDown = () => {\n this.isDropDownVisited = true;\n };\n onMouseLeaveDropDown = () => {\n this.isDropDownVisited = false;\n this.show = false;\n this.initPosition();\n };\n onOptionClick() {\n this.show = false;\n }\n\n override disconnectedCallback() {\n document.removeEventListener('scroll', this.calculatePosition);\n window.removeEventListener('resize', this.calculatePosition);\n if (this.trigger == TriggerMode.Hover) {\n this.triggerElement.removeEventListener('mouseenter', this.onMouseEnterTriggerElement);\n this.triggerElement.removeEventListener('mouseleave', this.onMouseLeaveTriggerElement);\n this.dropDownContainer.removeEventListener('mouseenter', this.onMouseEnterDropDown);\n this.dropDownContainer.removeEventListener('mouseleave', this.onMouseLeaveDropDown);\n } else {\n this.triggerElement.removeEventListener('click', this.onTriggerClick);\n window.removeEventListener('click', this.onClickOutside);\n }\n }\n\n display(options: IOption[]): any {\n return options.map((option) => {\n if (option.children) {\n return html`<hy-dropdown-menu\n .direction=${this.dropDownDirection}\n .disabled=${option.disabled}\n .icon=${option.icon}\n .label=${option.label}\n >\n <div class=\"dropdown-container\">${this.display(option.children)}</div>\n </hy-dropdown-menu>`;\n } else {\n return html`<hy-dropdown-item\n .disabled=${option.disabled}\n .icon=${option.icon}\n .label=${option.label}\n .value=${option.value}\n ></hy-dropdown-item>`;\n }\n });\n }\n\n override render() {\n return html`\n <slot></slot>\n <div class=\"dropdown-container\" @click-item=${this.onOptionClick}>\n ${this.template?html`${this.template}`: this.display(this.options)}\n </div>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown.style.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.style.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,MAAM,yBAAgB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const dropdownStyle = css `
|
|
3
|
+
.dropdown-container {
|
|
4
|
+
display: none;
|
|
5
|
+
z-index:1;
|
|
6
|
+
}
|
|
7
|
+
:host {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host([show]) .dropdown-container {
|
|
12
|
+
display: block;
|
|
13
|
+
position: absolute;
|
|
14
|
+
width: var(--hybrid-dropdown-width);
|
|
15
|
+
box-shadow: var(--hybrid-dropdown-box-shadow);
|
|
16
|
+
}
|
|
17
|
+
:host {
|
|
18
|
+
--hybrid-dropdown-width: 150px;
|
|
19
|
+
--hybrid-dropdown-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.1);
|
|
20
|
+
--hybrid-dropdown-padding: 10px;
|
|
21
|
+
--hybrid-dropdown-background-color: #e0e0e0;
|
|
22
|
+
--hybrid-dropdown-hovered-background-color: #8d8d8d;
|
|
23
|
+
--hybrid-dropdown-text-color: #000000;
|
|
24
|
+
--hybrid-dropdown-disabled-background-color: #f4f4f4;
|
|
25
|
+
--hybrid-dropdown-disabled-text-color: rgba(0, 0, 0, 0.5);
|
|
26
|
+
--hybrid-dropdown-only-text-padding-left: 18px;
|
|
27
|
+
--hybrid-dropdown-icon-and-text-padding-left: 4px;
|
|
28
|
+
--hybrid-dropdown-menu-children-top: 10px;
|
|
29
|
+
--hybrid-dropdown-menu-children-offset: 5px;
|
|
30
|
+
--hybrid-dropdown-menu-children-z-index: 2;
|
|
31
|
+
}
|
|
32
|
+
@media (prefers-color-scheme: dark) {
|
|
33
|
+
:host {
|
|
34
|
+
--hybrid-dropdown-background-color: #393939;
|
|
35
|
+
--hybrid-dropdown-hovered-background-color: #4c4c4c;
|
|
36
|
+
--hybrid-dropdown-disabled-background-color: #6f6f6f;
|
|
37
|
+
--hybrid-dropdown-text-color: #f4f4f4;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
export const styles = dropdownStyle;
|
|
42
|
+
//# sourceMappingURL=hy-dropdown.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown.style.js","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCxB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC","sourcesContent":["import {css} from 'lit';\n\nconst dropdownStyle = css`\n .dropdown-container {\n display: none;\n z-index:1;\n }\n :host {\n cursor: pointer;\n }\n\n :host([show]) .dropdown-container {\n display: block;\n position: absolute;\n width: var(--hybrid-dropdown-width);\n box-shadow: var(--hybrid-dropdown-box-shadow);\n }\n :host {\n --hybrid-dropdown-width: 150px;\n --hybrid-dropdown-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.1);\n --hybrid-dropdown-padding: 10px;\n --hybrid-dropdown-background-color: #e0e0e0;\n --hybrid-dropdown-hovered-background-color: #8d8d8d;\n --hybrid-dropdown-text-color: #000000;\n --hybrid-dropdown-disabled-background-color: #f4f4f4;\n --hybrid-dropdown-disabled-text-color: rgba(0, 0, 0, 0.5);\n --hybrid-dropdown-only-text-padding-left: 18px;\n --hybrid-dropdown-icon-and-text-padding-left: 4px;\n --hybrid-dropdown-menu-children-top: 10px;\n --hybrid-dropdown-menu-children-offset: 5px;\n --hybrid-dropdown-menu-children-z-index: 2;\n }\n @media (prefers-color-scheme: dark) {\n :host {\n --hybrid-dropdown-background-color: #393939;\n --hybrid-dropdown-hovered-background-color: #4c4c4c;\n --hybrid-dropdown-disabled-background-color: #6f6f6f;\n --hybrid-dropdown-text-color: #f4f4f4;\n }\n }\n`;\nexport const styles = dropdownStyle;\n"]}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/dropdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './hy-dropdown.component.js';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuralyui/dropdown",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"dayjs": "^1.11.7"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"author": "Labidi Aymen",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
package/react.d.ts
ADDED
package/react.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAC/D,eAAO,MAAM,UAAU,sEAKrB,CAAC"}
|
package/react.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createComponent } from '@lit-labs/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { HyDropdownComponent } from './hy-dropdown.component.js';
|
|
4
|
+
export const HyDropdown = createComponent({
|
|
5
|
+
tagName: 'hy-dropdown',
|
|
6
|
+
elementClass: HyDropdownComponent,
|
|
7
|
+
react: React,
|
|
8
|
+
events: {},
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=react.js.map
|
package/react.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/components/dropdown/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAC/D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,mBAAmB;IACjC,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,EAAE;CACX,CAAC,CAAC","sourcesContent":["import {createComponent} from '@lit-labs/react';\nimport * as React from 'react';\nimport {HyDropdownComponent} from './hy-dropdown.component.js';\nexport const HyDropdown = createComponent({\n tagName: 'hy-dropdown',\n elementClass: HyDropdownComponent,\n react: React,\n events: {},\n});\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class HyDropdownItem extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
icon: string;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
onClick(clickItemEvent: Event): void;
|
|
9
|
+
render(): import("lit").TemplateResult<1>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hy-dropdown-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,KAAK,CAAC;AAI9C,qBACa,cAAe,SAAQ,UAAU;IAC5C,OAAgB,MAAM,4BAAU;IAEhC,IAAI,EAAG,MAAM,CAAC;IAEd,QAAQ,UAAS;IAEjB,KAAK,EAAG,MAAM,CAAC;IAEf,KAAK,EAAG,MAAM,CAAC;IAEf,OAAO,CAAC,cAAc,EAAE,KAAK;IAMpB,MAAM;CAKhB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 } from 'lit/decorators.js';
|
|
9
|
+
import { styles } from './hy-dropdown-item.style.js';
|
|
10
|
+
let HyDropdownItem = class HyDropdownItem extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.disabled = false;
|
|
14
|
+
}
|
|
15
|
+
onClick(clickItemEvent) {
|
|
16
|
+
clickItemEvent.stopPropagation();
|
|
17
|
+
if (!this.disabled)
|
|
18
|
+
this.dispatchEvent(new CustomEvent('click-item', { detail: { value: this.value }, composed: true, bubbles: true }));
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `<div @click=${this.onClick}>${this.icon ? html `<hy-icon name=${this.icon}></hy-icon>` : nothing}<span class="option-label">${this.label}<span></li>`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
HyDropdownItem.styles = styles;
|
|
25
|
+
__decorate([
|
|
26
|
+
property({ reflect: true, type: String })
|
|
27
|
+
], HyDropdownItem.prototype, "icon", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
property({ reflect: true, type: Boolean })
|
|
30
|
+
], HyDropdownItem.prototype, "disabled", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
property()
|
|
33
|
+
], HyDropdownItem.prototype, "label", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
property()
|
|
36
|
+
], HyDropdownItem.prototype, "value", void 0);
|
|
37
|
+
HyDropdownItem = __decorate([
|
|
38
|
+
customElement('hy-dropdown-item')
|
|
39
|
+
], HyDropdownItem);
|
|
40
|
+
export { HyDropdownItem };
|
|
41
|
+
//# sourceMappingURL=hy-dropdown-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,6BAA6B,CAAC;AAGnD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAA9C;;QAKE,aAAQ,GAAG,KAAK,CAAC;IAiBnB,CAAC;IAXC,OAAO,CAAC,cAAqB;QAC3B,cAAc,CAAC,eAAe,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAC,MAAM,EAAE,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IACpH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,IAAI,CAAC,OAAO,IACpC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,iBAAiB,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,OAC5D,8BAA8B,IAAI,CAAC,KAAK,aAAa,CAAC;IACxD,CAAC;CACF,CAAA;AArBiB,qBAAM,GAAG,MAAO,CAAA;AAEhC;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC;4CAC1B;AAEd;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;gDACxB;AAEjB;IADC,QAAQ,EAAE;6CACI;AAEf;IADC,QAAQ,EAAE;6CACI;AATJ,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAsB1B;SAtBY,cAAc","sourcesContent":["import {LitElement, html, nothing} from 'lit';\nimport {customElement, property} from 'lit/decorators.js';\nimport {styles} from './hy-dropdown-item.style.js';\n\n@customElement('hy-dropdown-item')\nexport class HyDropdownItem extends LitElement {\n static override styles = styles;\n @property({reflect: true, type: String})\n icon!: string;\n @property({reflect: true, type: Boolean})\n disabled = false;\n @property()\n label!: string;\n @property()\n value!: string;\n\n onClick(clickItemEvent: Event) {\n clickItemEvent.stopPropagation();\n if (!this.disabled)\n this.dispatchEvent(new CustomEvent('click-item', {detail: {value: this.value}, composed: true, bubbles: true}));\n }\n\n override render() {\n return html`<div @click=${this.onClick}>${\n this.icon ? html`<hy-icon name=${this.icon}></hy-icon>` : nothing\n }<span class=\"option-label\">${this.label}<span></li>`;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.style.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.style.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,MAAM,2BAAsB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const dropdownItemStyle = css `
|
|
3
|
+
div {
|
|
4
|
+
padding: var(--hybrid-dropdown-padding);
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
background-color: var(--hybrid-dropdown-background-color);
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
color: var(--hybrid-dropdown-text-color);
|
|
10
|
+
}
|
|
11
|
+
hy-icon {
|
|
12
|
+
display: flex;
|
|
13
|
+
}
|
|
14
|
+
:host(:not([disabled])) div:hover {
|
|
15
|
+
background-color: var(--hybrid-dropdown-hovered-background-color);
|
|
16
|
+
}
|
|
17
|
+
:host([disabled]) div {
|
|
18
|
+
background-color: var(--hybrid-dropdown-disabled-background-color);
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
color: var(--hybrid-dropdown-disabled-text-color);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host(:not([icon])) .option-label {
|
|
24
|
+
padding-left: var(--hybrid-dropdown-only-text-padding-left);
|
|
25
|
+
}
|
|
26
|
+
:host([icon]) .option-label {
|
|
27
|
+
padding-left: var(--hybrid-dropdown-icon-and-text-padding-left);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
export const styles = [dropdownItemStyle];
|
|
31
|
+
//# sourceMappingURL=hy-dropdown-item.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.style.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B5B,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import {css} from 'lit';\n\nconst dropdownItemStyle = css`\n div {\n padding: var(--hybrid-dropdown-padding);\n cursor: pointer;\n background-color: var(--hybrid-dropdown-background-color);\n display: flex;\n align-items: center;\n color: var(--hybrid-dropdown-text-color);\n }\n hy-icon {\n display: flex;\n }\n :host(:not([disabled])) div:hover {\n background-color: var(--hybrid-dropdown-hovered-background-color);\n }\n :host([disabled]) div {\n background-color: var(--hybrid-dropdown-disabled-background-color);\n cursor: not-allowed;\n color: var(--hybrid-dropdown-disabled-text-color);\n }\n\n :host(:not([icon])) .option-label {\n padding-left: var(--hybrid-dropdown-only-text-padding-left);\n }\n :host([icon]) .option-label {\n padding-left: var(--hybrid-dropdown-icon-and-text-padding-left);\n }\n`;\n\nexport const styles = [dropdownItemStyle];\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { DropDownDirection } from '../dropdown.types';
|
|
3
|
+
export declare class HyDropdownMenu extends LitElement {
|
|
4
|
+
static styles: import("lit").CSSResult[];
|
|
5
|
+
menuOption: HTMLElement;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
icon: string;
|
|
8
|
+
label: string;
|
|
9
|
+
direction: DropDownDirection;
|
|
10
|
+
showChildren: boolean;
|
|
11
|
+
firstUpdated(): void;
|
|
12
|
+
onMouseEnterMenu: () => void;
|
|
13
|
+
onMouseLeaveMenu: () => void;
|
|
14
|
+
onClickMenu(menuClickEvent: Event): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
render(): import("lit").TemplateResult<1>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=hy-dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,KAAK,CAAC;AAG9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,qBACa,cAAe,SAAQ,UAAU;IAC5C,OAAgB,MAAM,4BAAU;IAEhC,UAAU,EAAG,WAAW,CAAC;IAEzB,QAAQ,UAAS;IAEjB,IAAI,EAAG,MAAM,CAAC;IAEd,KAAK,EAAG,MAAM,CAAC;IAEf,SAAS,EAAG,iBAAiB,CAAC;IAE9B,YAAY,UAAS;IAEZ,YAAY,IAAI,IAAI;IAK7B,gBAAgB,aAEd;IACF,gBAAgB,aAEd;IACF,WAAW,CAAC,cAAc,EAAE,KAAK;IAIxB,oBAAoB,IAAI,IAAI;IAK5B,MAAM;CAWhB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { styles } from './hy-dropdown-menu.style.js';
|
|
10
|
+
let HyDropdownMenu = class HyDropdownMenu extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.disabled = false;
|
|
14
|
+
this.showChildren = false;
|
|
15
|
+
this.onMouseEnterMenu = () => {
|
|
16
|
+
if (!this.disabled)
|
|
17
|
+
this.showChildren = true;
|
|
18
|
+
};
|
|
19
|
+
this.onMouseLeaveMenu = () => {
|
|
20
|
+
if (!this.disabled)
|
|
21
|
+
this.showChildren = false;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
firstUpdated() {
|
|
25
|
+
this.menuOption.addEventListener('mouseenter', this.onMouseEnterMenu);
|
|
26
|
+
this.menuOption.addEventListener('mouseleave', this.onMouseLeaveMenu);
|
|
27
|
+
}
|
|
28
|
+
onClickMenu(menuClickEvent) {
|
|
29
|
+
menuClickEvent.stopPropagation();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
this.menuOption.removeEventListener('mouseenter', this.onMouseEnterMenu);
|
|
33
|
+
this.menuOption.removeEventListener('mouseleave', this.onMouseLeaveMenu);
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
return html `<div @click=${this.onClickMenu}>
|
|
37
|
+
${this.icon ? html `<hy-icon name=${this.icon}></hy-icon>` : nothing}
|
|
38
|
+
<span class="menu-label"> ${this.label}</span>
|
|
39
|
+
<hy-icon
|
|
40
|
+
name="${this.direction == "right" /* DropDownDirection.Right */ ? 'caret-right' : 'caret-left'}"
|
|
41
|
+
id="caret-icon"
|
|
42
|
+
></hy-icon>
|
|
43
|
+
<slot style="display:${this.showChildren ? 'block' : 'none'}"></slot>
|
|
44
|
+
</div>`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
HyDropdownMenu.styles = styles;
|
|
48
|
+
__decorate([
|
|
49
|
+
query('div')
|
|
50
|
+
], HyDropdownMenu.prototype, "menuOption", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ reflect: true, type: Boolean })
|
|
53
|
+
], HyDropdownMenu.prototype, "disabled", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
property({ reflect: true, type: String })
|
|
56
|
+
], HyDropdownMenu.prototype, "icon", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
property()
|
|
59
|
+
], HyDropdownMenu.prototype, "label", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
property({ reflect: true })
|
|
62
|
+
], HyDropdownMenu.prototype, "direction", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
state()
|
|
65
|
+
], HyDropdownMenu.prototype, "showChildren", void 0);
|
|
66
|
+
HyDropdownMenu = __decorate([
|
|
67
|
+
customElement('hy-dropdown-menu')
|
|
68
|
+
], HyDropdownMenu);
|
|
69
|
+
export { HyDropdownMenu };
|
|
70
|
+
//# sourceMappingURL=hy-dropdown-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-menu.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-menu.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAC,MAAM,EAAC,MAAM,6BAA6B,CAAC;AAGnD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAA9C;;QAKE,aAAQ,GAAG,KAAK,CAAC;QAQjB,iBAAY,GAAG,KAAK,CAAC;QAOrB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC/C,CAAC,CAAC;QACF,qB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EAAE,IAAI,EAAE,MAAM,EAAC,CAAC;4CAC1B;AAEd;IADC,QAAQ,EAAE;6CACI;AAEf;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;iDACI;AAE9B;IADC,KAAK,EAAE;oDACa;AAbV,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA8C1B;SA9CY,cAAc","sourcesContent":["import {LitElement, html, nothing} from 'lit';\nimport {customElement, property, query, state} from 'lit/decorators.js';\nimport {styles} from './hy-dropdown-menu.style.js';\nimport {DropDownDirection} from '../dropdown.types';\n@customElement('hy-dropdown-menu')\nexport class HyDropdownMenu extends LitElement {\n static override styles = styles;\n @query('div')\n menuOption!: HTMLElement;\n @property({reflect: true, type: Boolean})\n disabled = false;\n @property({reflect: true, type: String})\n icon!: string;\n @property()\n label!: string;\n @property({reflect: true})\n direction!: DropDownDirection;\n @state()\n showChildren = false;\n\n override firstUpdated(): void {\n this.menuOption.addEventListener('mouseenter', this.onMouseEnterMenu);\n this.menuOption.addEventListener('mouseleave', this.onMouseLeaveMenu);\n }\n\n onMouseEnterMenu = () => {\n if (!this.disabled) this.showChildren = true;\n };\n onMouseLeaveMenu = () => {\n if (!this.disabled) this.showChildren = false;\n };\n onClickMenu(menuClickEvent: Event) {\n menuClickEvent.stopPropagation();\n }\n\n override disconnectedCallback(): void {\n this.menuOption.removeEventListener('mouseenter', this.onMouseEnterMenu);\n this.menuOption.removeEventListener('mouseleave', this.onMouseLeaveMenu);\n }\n\n override render() {\n return html`<div @click=${this.onClickMenu}>\n ${this.icon ? html`<hy-icon name=${this.icon}></hy-icon>` : nothing}\n <span class=\"menu-label\"> ${this.label}</span>\n <hy-icon\n name=\"${this.direction == DropDownDirection.Right ? 'caret-right' : 'caret-left'}\"\n id=\"caret-icon\"\n ></hy-icon>\n <slot style=\"display:${this.showChildren ? 'block' : 'none'}\"></slot>\n </div>`;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-menu.style.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-menu.style.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,MAAM,2BAAsB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const dropdownMenuStyle = css `
|
|
3
|
+
div {
|
|
4
|
+
padding: var(--hybrid-dropdown-padding);
|
|
5
|
+
position: relative;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
background-color: var(--hybrid-dropdown-background-color);
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
}
|
|
11
|
+
hy-icon {
|
|
12
|
+
display: flex;
|
|
13
|
+
}
|
|
14
|
+
#caret-icon {
|
|
15
|
+
flex-grow: 1;
|
|
16
|
+
justify-content: flex-end;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host(:not([disabled])) div:hover {
|
|
20
|
+
background-color: var(--hybrid-dropdown-hovered-background-color);
|
|
21
|
+
}
|
|
22
|
+
:host([disabled]) div {
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
background-color: var(--hybrid-dropdown-disabled-background-color);
|
|
25
|
+
color: var(--hybrid-dropdown-disabled-text-color);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
::slotted(*) {
|
|
29
|
+
z-index: var(--hybrid-dropdown-menu-children-z-index);
|
|
30
|
+
top: var(--hybrid-dropdown-menu-children-top);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
:host([direction='left']) ::slotted(*) {
|
|
34
|
+
right: calc(var(--hybrid-dropdown-width) - var(--hybrid-dropdown-menu-children-offset));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([direction='right']) ::slotted(*) {
|
|
38
|
+
left: calc(var(--hybrid-dropdown-width) - var(--hybrid-dropdown-menu-children-offset));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host(:not([icon])) .menu-label {
|
|
42
|
+
padding-left: var(--hybrid-dropdown-only-text-padding-left);
|
|
43
|
+
}
|
|
44
|
+
:host([icon]) .menu-label {
|
|
45
|
+
padding-left: var(--hybrid-dropdown-icon-and-text-padding-left);
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const styles = [dropdownMenuStyle];
|
|
49
|
+
//# sourceMappingURL=hy-dropdown-menu.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown-menu.style.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-menu.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C5B,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import {css} from 'lit';\n\nconst dropdownMenuStyle = css`\n div {\n padding: var(--hybrid-dropdown-padding);\n position: relative;\n cursor: pointer;\n background-color: var(--hybrid-dropdown-background-color);\n display: flex;\n align-items: center;\n }\n hy-icon {\n display: flex;\n }\n #caret-icon {\n flex-grow: 1;\n justify-content: flex-end;\n }\n\n :host(:not([disabled])) div:hover {\n background-color: var(--hybrid-dropdown-hovered-background-color);\n }\n :host([disabled]) div {\n cursor: not-allowed;\n background-color: var(--hybrid-dropdown-disabled-background-color);\n color: var(--hybrid-dropdown-disabled-text-color);\n }\n\n ::slotted(*) {\n z-index: var(--hybrid-dropdown-menu-children-z-index);\n top: var(--hybrid-dropdown-menu-children-top);\n cursor: pointer;\n }\n :host([direction='left']) ::slotted(*) {\n right: calc(var(--hybrid-dropdown-width) - var(--hybrid-dropdown-menu-children-offset));\n }\n\n :host([direction='right']) ::slotted(*) {\n left: calc(var(--hybrid-dropdown-width) - var(--hybrid-dropdown-menu-children-offset));\n }\n\n :host(:not([icon])) .menu-label {\n padding-left: var(--hybrid-dropdown-only-text-padding-left);\n }\n :host([icon]) .menu-label {\n padding-left: var(--hybrid-dropdown-icon-and-text-padding-left);\n }\n`;\n\nexport const styles = [dropdownMenuStyle];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown_test.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/test/hy-dropdown_test.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAIlC,OAAO,+BAA+B,CAAC;AAEvC,OAAO,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
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 '../hy-dropdown.component';
|
|
12
|
+
import '../templates/hy-dropdown-item';
|
|
13
|
+
import '../templates/hy-dropdown-menu';
|
|
14
|
+
const options = [
|
|
15
|
+
{ label: 'option1', value: 'value1' },
|
|
16
|
+
{ label: 'option4', value: 'value4', icon: 'bomb', disabled: true },
|
|
17
|
+
{
|
|
18
|
+
label: 'option8',
|
|
19
|
+
value: 'value8',
|
|
20
|
+
children: [
|
|
21
|
+
{
|
|
22
|
+
label: 'option9',
|
|
23
|
+
value: 'value9',
|
|
24
|
+
icon: 'bolt',
|
|
25
|
+
children: [{ label: 'option10', value: 'value10' }],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
suite('HyDropdownComponent', () => {
|
|
31
|
+
test('should show dropdown on click when trigger is click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const el = yield fixture(html `<hy-dropdown .trigger=${"click" /* TriggerMode.Click */} .options=${options}></hy-dropdown>`);
|
|
33
|
+
const slot = el.shadowRoot.querySelector('slot');
|
|
34
|
+
slot.click();
|
|
35
|
+
expect(el.show).to.be.true;
|
|
36
|
+
slot.click();
|
|
37
|
+
expect(el.show).to.be.false;
|
|
38
|
+
}));
|
|
39
|
+
test('should show dropdown on hover when trigger is hover', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const el = yield fixture(html `<hy-dropdown .trigger=${"hover" /* TriggerMode.Hover */} .options=${options}></hy-dropdown>`);
|
|
41
|
+
const slot = el.shadowRoot.querySelector('slot');
|
|
42
|
+
expect(el.show).to.be.false;
|
|
43
|
+
slot.dispatchEvent(new Event('mouseenter'));
|
|
44
|
+
expect(el.show).to.be.true;
|
|
45
|
+
}));
|
|
46
|
+
test('should hide dropdown on click outside when trigger is click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const el = yield fixture(html `<hy-dropdown .show=${true} .trigger=${"click" /* TriggerMode.Click */} .options=${options}></hy-dropdown>`);
|
|
48
|
+
expect(el.show).to.be.true;
|
|
49
|
+
window.dispatchEvent(new Event('click'));
|
|
50
|
+
expect(el.show).to.be.false;
|
|
51
|
+
}));
|
|
52
|
+
test('should hide dropdown on mouseleave dropdown', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const el = yield fixture(html `<hy-dropdown .show=${true} .options=${options}></hy-dropdown>`);
|
|
54
|
+
const dropDownContainer = el.shadowRoot.querySelector('.dropdown-container');
|
|
55
|
+
expect(el.show).to.be.true;
|
|
56
|
+
dropDownContainer.dispatchEvent(new Event('mouseleave'));
|
|
57
|
+
expect(el.show).to.be.false;
|
|
58
|
+
}));
|
|
59
|
+
test('should hide dropdown on option click event', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const el = yield fixture(html `
|
|
61
|
+
<hy-dropdown .show=${true} .options=${options}></hy-dropdown>
|
|
62
|
+
`);
|
|
63
|
+
const dropDownContainer = el.shadowRoot.querySelector('.dropdown-container');
|
|
64
|
+
expect(el.show).to.be.true;
|
|
65
|
+
dropDownContainer.dispatchEvent(new Event('click-item'));
|
|
66
|
+
expect(el.show).to.be.false;
|
|
67
|
+
}));
|
|
68
|
+
suite('hy-dropdown-item', () => {
|
|
69
|
+
test('dropdown item with icon and label', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
const iconName = 'bomb';
|
|
71
|
+
const labelText = 'label';
|
|
72
|
+
const el = yield fixture(html `<hy-dropdown-item icon="${iconName}" label="${labelText}"></hy-dropdown-item>`);
|
|
73
|
+
const icon = el.shadowRoot.querySelector('hy-icon');
|
|
74
|
+
const label = el.shadowRoot.querySelector('.option-label');
|
|
75
|
+
expect(icon).to.exist;
|
|
76
|
+
expect(icon.getAttribute('name')).to.equal(iconName);
|
|
77
|
+
expect(label).to.exist;
|
|
78
|
+
expect(label.textContent).to.equal(labelText);
|
|
79
|
+
}));
|
|
80
|
+
test('should dispatch click-item ', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
const el = yield fixture(html `<hy-dropdown-item label="Test Label" value="test-value"></hy-dropdown-item>`);
|
|
82
|
+
let clickItemDispatched = false;
|
|
83
|
+
el.addEventListener('click-item', () => {
|
|
84
|
+
clickItemDispatched = true;
|
|
85
|
+
});
|
|
86
|
+
el.shadowRoot.querySelector('div').click();
|
|
87
|
+
expect(clickItemDispatched).to.be.true;
|
|
88
|
+
}));
|
|
89
|
+
test('should not dispatch click-item event when disabled', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const el = yield fixture(html `<hy-dropdown-item label="Test Label" value="test-value" disabled></hy-dropdown-item>`);
|
|
91
|
+
let clickItemDispatched = false;
|
|
92
|
+
el.addEventListener('click-item', () => {
|
|
93
|
+
clickItemDispatched = true;
|
|
94
|
+
});
|
|
95
|
+
el.shadowRoot.querySelector('div').click();
|
|
96
|
+
expect(clickItemDispatched).to.be.false;
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
suite('hy-dropdown-menu', () => {
|
|
100
|
+
test('should show menu children on mouse enter and hide on mouse leave', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
const el = yield fixture(html `<hy-dropdown-menu label="Test Label"><div>Child Item</div></hy-dropdown-menu>`);
|
|
102
|
+
const div = el.shadowRoot.querySelector('div');
|
|
103
|
+
expect(el.showChildren).to.be.false;
|
|
104
|
+
expect(el.shadowRoot.querySelector('slot')).to.have.style('display', 'none');
|
|
105
|
+
div.dispatchEvent(new Event('mouseenter'));
|
|
106
|
+
yield el.updateComplete;
|
|
107
|
+
expect(el.showChildren).to.be.true;
|
|
108
|
+
expect(el.shadowRoot.querySelector('slot')).to.have.style('display', 'block');
|
|
109
|
+
div.dispatchEvent(new Event('mouseleave'));
|
|
110
|
+
expect(el.showChildren).to.be.false;
|
|
111
|
+
}));
|
|
112
|
+
test('should not show children if disabled', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
const el = yield fixture(html `<hy-dropdown-menu label="Test Label" disabled></hy-dropdown-menu>`);
|
|
114
|
+
const div = el.shadowRoot.querySelector('div');
|
|
115
|
+
expect(el.shadowRoot.querySelector('slot')).to.have.style('display', 'none');
|
|
116
|
+
div.dispatchEvent(new Event('mouseenter'));
|
|
117
|
+
expect(el.showChildren).to.be.false;
|
|
118
|
+
expect(el.shadowRoot.querySelector('slot')).to.not.have.style('display', 'block');
|
|
119
|
+
}));
|
|
120
|
+
test('should stop event propagation on click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
const el = yield fixture(html `<hy-dropdown-menu label="Test Label"></hy-dropdown-menu>`);
|
|
122
|
+
const div = el.shadowRoot.querySelector('div');
|
|
123
|
+
let eventStopped = true;
|
|
124
|
+
window.addEventListener('click', () => {
|
|
125
|
+
eventStopped = false;
|
|
126
|
+
});
|
|
127
|
+
div.click();
|
|
128
|
+
expect(eventStopped).to.be.true;
|
|
129
|
+
}));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=hy-dropdown_test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hy-dropdown_test.js","sourceRoot":"","sources":["../../../../src/components/dropdown/test/hy-dropdown_test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,0BAA0B,CAAC;AAIlC,OAAO,+BAA+B,CAAC;AAEvC,OAAO,+BAA+B,CAAC;AAEvC,MAAM,OAAO,GAAG;IACd,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAC;IACnC,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC;IACjE;QACE,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE;YACR;gBACE,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,QAAQ;gBACf,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC;aAClD;SACF;KACF;CACF,CAAC;AACF,KAAK,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,qDAAqD,EAAE,GAAS,EAAE;QACrE,MAAM,EAAE,GAAwB,MAAM,OAAO,CAC3C,IAAI,CAAA,yBAAyB,+BAAiB,aAAa,OAAO,iBAAiB,CACpF,CAAC;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,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AC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {html, fixture, expect} from '@open-wc/testing';\nimport '../hy-dropdown.component';\nimport {HyDropdownComponent} from '../hy-dropdown.component';\nimport {TriggerMode} from '../dropdown.types';\nimport {HyDropdownItem} from '../templates/hy-dropdown-item';\nimport '../templates/hy-dropdown-item';\nimport {HyDropdownMenu} from '../templates/hy-dropdown-menu';\nimport '../templates/hy-dropdown-menu';\n\nconst options = [\n {label: 'option1', value: 'value1'},\n {label: 'option4', value: 'value4', icon: 'bomb', disabled: true},\n {\n label: 'option8',\n value: 'value8',\n children: [\n {\n label: 'option9',\n value: 'value9',\n icon: 'bolt',\n children: [{label: 'option10', value: 'value10'}],\n },\n ],\n },\n];\nsuite('HyDropdownComponent', () => {\n test('should show dropdown on click when trigger is click', async () => {\n const el: HyDropdownComponent = await fixture(\n html`<hy-dropdown .trigger=${TriggerMode.Click} .options=${options}></hy-dropdown>`\n );\n const slot = el.shadowRoot!.querySelector('slot')!;\n slot.click();\n expect(el.show).to.be.true;\n slot.click();\n expect(el.show).to.be.false;\n });\n\n test('should show dropdown on hover when trigger is hover', async () => {\n const el: HyDropdownComponent = await fixture(\n html`<hy-dropdown .trigger=${TriggerMode.Hover} .options=${options}></hy-dropdown>`\n );\n const slot = el.shadowRoot!.querySelector('slot')!;\n expect(el.show).to.be.false;\n slot.dispatchEvent(new Event('mouseenter'));\n expect(el.show).to.be.true;\n });\n\n test('should hide dropdown on click outside when trigger is click', async () => {\n const el: HyDropdownComponent = await fixture(\n html`<hy-dropdown .show=${true} .trigger=${TriggerMode.Click} .options=${options}></hy-dropdown>`\n );\n expect(el.show).to.be.true;\n window.dispatchEvent(new Event('click'));\n expect(el.show).to.be.false;\n });\n test('should hide dropdown on mouseleave dropdown', async () => {\n const el: HyDropdownComponent = await fixture(html`<hy-dropdown .show=${true} .options=${options}></hy-dropdown>`);\n const dropDownContainer = el.shadowRoot!.querySelector('.dropdown-container') as HTMLElement;\n expect(el.show).to.be.true;\n dropDownContainer.dispatchEvent(new Event('mouseleave'));\n expect(el.show).to.be.false;\n });\n\n test('should hide dropdown on option click event', async () => {\n const el: HyDropdownComponent = await fixture(html`\n <hy-dropdown .show=${true} .options=${options}></hy-dropdown>\n `);\n const dropDownContainer: HTMLElement = el.shadowRoot!.querySelector('.dropdown-container')!;\n expect(el.show).to.be.true;\n dropDownContainer.dispatchEvent(new Event('click-item'));\n expect(el.show).to.be.false;\n });\n\n suite('hy-dropdown-item', () => {\n test('dropdown item with icon and label', async () => {\n const iconName = 'bomb';\n const labelText = 'label';\n const el: HyDropdownItem = await fixture(\n html`<hy-dropdown-item icon=\"${iconName}\" label=\"${labelText}\"></hy-dropdown-item>`\n );\n const icon = el.shadowRoot!.querySelector('hy-icon');\n const label = el.shadowRoot!.querySelector('.option-label');\n expect(icon).to.exist;\n expect(icon!.getAttribute('name')).to.equal(iconName);\n expect(label).to.exist;\n expect(label!.textContent).to.equal(labelText);\n });\n\n test('should dispatch click-item ', async () => {\n const el: HyDropdownItem = await fixture(\n html`<hy-dropdown-item label=\"Test Label\" value=\"test-value\"></hy-dropdown-item>`\n );\n let clickItemDispatched = false;\n el.addEventListener('click-item', () => {\n clickItemDispatched = true;\n });\n el.shadowRoot!.querySelector('div')!.click();\n expect(clickItemDispatched).to.be.true;\n });\n test('should not dispatch click-item event when disabled', async () => {\n const el: HyDropdownItem = await fixture(\n html`<hy-dropdown-item label=\"Test Label\" value=\"test-value\" disabled></hy-dropdown-item>`\n );\n let clickItemDispatched = false;\n el.addEventListener('click-item', () => {\n clickItemDispatched = true;\n });\n el.shadowRoot!.querySelector('div')!.click();\n expect(clickItemDispatched).to.be.false;\n });\n });\n suite('hy-dropdown-menu', () => {\n test('should show menu children on mouse enter and hide on mouse leave', async () => {\n const el: HyDropdownMenu = await fixture(\n html`<hy-dropdown-menu label=\"Test Label\"><div>Child Item</div></hy-dropdown-menu>`\n );\n const div = el.shadowRoot!.querySelector('div')!;\n expect(el.showChildren).to.be.false;\n expect(el.shadowRoot!.querySelector('slot')).to.have.style('display', 'none');\n div.dispatchEvent(new Event('mouseenter'));\n await el.updateComplete;\n expect(el.showChildren).to.be.true;\n expect(el.shadowRoot!.querySelector('slot')).to.have.style('display', 'block');\n div.dispatchEvent(new Event('mouseleave'));\n expect(el.showChildren).to.be.false;\n });\n\n test('should not show children if disabled', async () => {\n const el: HyDropdownMenu = await fixture(html`<hy-dropdown-menu label=\"Test Label\" disabled></hy-dropdown-menu>`);\n const div = el.shadowRoot!.querySelector('div')!;\n expect(el.shadowRoot!.querySelector('slot')).to.have.style('display', 'none');\n div.dispatchEvent(new Event('mouseenter'));\n expect(el.showChildren).to.be.false;\n expect(el.shadowRoot!.querySelector('slot')).to.not.have.style('display', 'block');\n });\n\n test('should stop event propagation on click', async () => {\n const el: HyDropdownMenu = await fixture(html`<hy-dropdown-menu label=\"Test Label\"></hy-dropdown-menu>`);\n const div = el.shadowRoot!.querySelector('div')!;\n let eventStopped = true;\n window.addEventListener('click', () => {\n eventStopped = false;\n });\n div.click();\n expect(eventStopped).to.be.true;\n });\n });\n});\n"]}
|