@nuralyui/dropdown 0.0.5 → 0.0.7
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/dropdown.types.d.ts +1 -0
- package/dropdown.types.d.ts.map +1 -1
- package/dropdown.types.js.map +1 -1
- package/hy-dropdown.component.d.ts +2 -2
- package/hy-dropdown.component.d.ts.map +1 -1
- package/hy-dropdown.component.js +25 -28
- package/hy-dropdown.component.js.map +1 -1
- package/hy-dropdown.style.js +1 -1
- package/hy-dropdown.style.js.map +1 -1
- package/package.json +1 -1
- package/templates/hy-dropdown-item.d.ts +1 -0
- package/templates/hy-dropdown-item.d.ts.map +1 -1
- package/templates/hy-dropdown-item.js +17 -3
- package/templates/hy-dropdown-item.js.map +1 -1
package/dropdown.types.d.ts
CHANGED
package/dropdown.types.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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;IACrB,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB;AAED,0BAAkB,WAAW;IAC3B,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AACD,0BAAkB,iBAAiB;IACjC,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
|
package/dropdown.types.js.map
CHANGED
|
@@ -1 +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"]}
|
|
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 additionalData?: any;\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"]}
|
|
@@ -17,14 +17,14 @@ export declare class HyDropdownComponent extends LitElement {
|
|
|
17
17
|
onTriggerClick: () => Promise<void>;
|
|
18
18
|
calculatePosition: () => void;
|
|
19
19
|
initPosition(): void;
|
|
20
|
-
onClickOutside: (
|
|
20
|
+
onClickOutside: (event: Event) => void;
|
|
21
21
|
onMouseEnterTriggerElement: () => Promise<void>;
|
|
22
22
|
onMouseLeaveTriggerElement: () => void;
|
|
23
23
|
onMouseEnterDropDown: () => void;
|
|
24
24
|
onMouseLeaveDropDown: () => void;
|
|
25
25
|
onOptionClick(): void;
|
|
26
26
|
disconnectedCallback(): void;
|
|
27
|
-
display(options: IOption[]):
|
|
27
|
+
display(options: IOption[]): TemplateResult[];
|
|
28
28
|
render(): TemplateResult<1>;
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=hy-dropdown.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hy-dropdown.component.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.component.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"hy-dropdown.component.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAiB,MAAM,KAAK,CAAC;AAGhE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AAEzC,qBACa,mBAAoB,SAAQ,UAAU;IACjD,OAAgB,MAAM,0BAAU;IAEjB,cAAc,EAAG,WAAW,CAAC;IACd,iBAAiB,EAAG,WAAW,CAAC;IAEnC,OAAO,EAAG,OAAO,EAAE,CAAC;IACH,IAAI,UAAS;IAC7C,OAAO,cAAqB;IACZ,QAAQ,EAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IACb,MAAM,UAAS;IAElD,iBAAiB,UAAS;IAC1B,iBAAiB,oBAA2B;IAE5C,YAAY,IAAI,IAAI;IAe7B,cAAc,sBAIZ;IAEF,iBAAiB,aAqBf;IAEF,YAAY;IAMZ,cAAc,UAAW,KAAK,UAM5B;IAEF,0BAA0B,sBAIxB;IAEF,0BAA0B,aAKxB;IAEF,oBAAoB,aAElB;IAEF,oBAAoB,aAIlB;IAEF,aAAa;IAIJ,oBAAoB;IAe7B,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE;IAyBpC,MAAM;CAQhB"}
|
package/hy-dropdown.component.js
CHANGED
|
@@ -44,9 +44,6 @@ let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
|
44
44
|
if (dropDownHeight > availableBottomSpace) {
|
|
45
45
|
this.dropDownContainer.style.top = `${triggerClientRect.top - dropDownHeight}px`;
|
|
46
46
|
}
|
|
47
|
-
else {
|
|
48
|
-
//this.dropDownContainer.style.top = `${triggerClientRect.top +triggerClientRect.height+8}px`;
|
|
49
|
-
}
|
|
50
47
|
if (dropDownWidth > availableRightSpace && dropDownWidth < availableLeftSpace) {
|
|
51
48
|
this.dropDownContainer.style.right = `${availableRightSpace}px`;
|
|
52
49
|
this.dropDownDirection = "left" /* DropDownDirection.Left */;
|
|
@@ -56,8 +53,8 @@ let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
|
56
53
|
this.dropDownContainer.style.removeProperty('right');
|
|
57
54
|
}
|
|
58
55
|
};
|
|
59
|
-
this.onClickOutside = (
|
|
60
|
-
const outsideClick = !
|
|
56
|
+
this.onClickOutside = (event) => {
|
|
57
|
+
const outsideClick = !event.composedPath().includes(this);
|
|
61
58
|
if (outsideClick && this.show && !this.always) {
|
|
62
59
|
this.show = false;
|
|
63
60
|
this.initPosition();
|
|
@@ -87,7 +84,7 @@ let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
|
87
84
|
firstUpdated() {
|
|
88
85
|
document.addEventListener('scroll', this.calculatePosition);
|
|
89
86
|
window.addEventListener('resize', this.calculatePosition);
|
|
90
|
-
if (this.trigger
|
|
87
|
+
if (this.trigger === "hover" /* TriggerMode.Hover */) {
|
|
91
88
|
this.triggerElement.addEventListener('mouseenter', this.onMouseEnterTriggerElement);
|
|
92
89
|
this.triggerElement.addEventListener('mouseleave', this.onMouseLeaveTriggerElement);
|
|
93
90
|
this.dropDownContainer.addEventListener('mouseenter', this.onMouseEnterDropDown);
|
|
@@ -109,7 +106,7 @@ let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
|
109
106
|
disconnectedCallback() {
|
|
110
107
|
document.removeEventListener('scroll', this.calculatePosition);
|
|
111
108
|
window.removeEventListener('resize', this.calculatePosition);
|
|
112
|
-
if (this.trigger
|
|
109
|
+
if (this.trigger === "hover" /* TriggerMode.Hover */) {
|
|
113
110
|
this.triggerElement.removeEventListener('mouseenter', this.onMouseEnterTriggerElement);
|
|
114
111
|
this.triggerElement.removeEventListener('mouseleave', this.onMouseLeaveTriggerElement);
|
|
115
112
|
this.dropDownContainer.removeEventListener('mouseenter', this.onMouseEnterDropDown);
|
|
@@ -121,32 +118,32 @@ let HyDropdownComponent = class HyDropdownComponent extends LitElement {
|
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
display(options) {
|
|
124
|
-
return options.map((option) =>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
121
|
+
return options.map((option) => option.children
|
|
122
|
+
? html `
|
|
123
|
+
<hy-dropdown-menu
|
|
124
|
+
.direction=${this.dropDownDirection}
|
|
125
|
+
.disabled=${option.disabled}
|
|
126
|
+
.icon=${option.icon}
|
|
127
|
+
.label=${option.label}
|
|
128
|
+
>
|
|
129
|
+
<div class="dropdown-container">${this.display(option.children)}</div>
|
|
130
|
+
</hy-dropdown-menu>
|
|
131
|
+
`
|
|
132
|
+
: html `
|
|
133
|
+
<hy-dropdown-item
|
|
134
|
+
.disabled=${option.disabled}
|
|
135
|
+
.icon=${option.icon}
|
|
136
|
+
.label=${option.label}
|
|
137
|
+
.value=${option.value}
|
|
138
|
+
.additionalData=${option.additionalData}
|
|
139
|
+
></hy-dropdown-item>
|
|
140
|
+
`);
|
|
144
141
|
}
|
|
145
142
|
render() {
|
|
146
143
|
return html `
|
|
147
144
|
<slot></slot>
|
|
148
145
|
<div class="dropdown-container" @click-item=${this.onOptionClick}>
|
|
149
|
-
|
|
146
|
+
${this.template ? html `${this.show ? this.template : nothing}` : this.display(this.options)}
|
|
150
147
|
</div>
|
|
151
148
|
`;
|
|
152
149
|
}
|
|
@@ -1 +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,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9D,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;QAK5B,WAAM,GAAG,KAAK,CAAC;QAIf,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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AAG5B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;mDAC1B;AAIf;IADC,KAAK,EAAE;8DACkB;AAE1B;IADC,KAAK,EAAE;8DACoC;AAtBjC,mBAAmB;IAD/B,aAAa,CAAC,aAAa,CAAC;GAChB,mBAAmB,CA8I/B;SA9IY,mBAAmB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {LitElement, TemplateResult, html, nothing} 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({type: Array})\n options!: IOption[];\n @property({type: Boolean, reflect: true})\n show = false;\n @property()\n trigger = TriggerMode.Click;\n @property({type: Object})\n template!:TemplateResult<1>;\n\n @property({type: Boolean, reflect: true})\n always = false;\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 - triggerClientRect.width;\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+8}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 && !this.always){\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.show ? this.template : nothing}`: this.display(this.options)}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hy-dropdown.component.js","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AAGzC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAAnD;;QAO8C,SAAI,GAAG,KAAK,CAAC;QAC7C,YAAO,mCAAqB;QAEI,WAAM,GAAG,KAAK,CAAC;QAElD,sBAAiB,GAAG,KAAK,CAAC;QAC1B,sBAAiB,yC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AAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;;KAE9F,CAAC;IACJ,CAAC;CACF,CAAA;AAnJiB,0BAAM,GAAG,MAAO,CAAA;AAEjB;IAAd,KAAK,CAAC,MAAM,CAAC;2DAA8B;AACd;IAA7B,KAAK,CAAC,qBAAqB,CAAC;8DAAiC;AAEnC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAqB;AACH;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAc;AAC7C;IAAX,QAAQ,EAAE;oDAA6B;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA8B;AACb;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAgB;AAElD;IAAR,KAAK,EAAE;8DAA2B;AAC1B;IAAR,KAAK,EAAE;8DAA6C;AAb1C,mBAAmB;IAD/B,aAAa,CAAC,aAAa,CAAC;GAChB,mBAAmB,CAoJ/B;SApJY,mBAAmB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { LitElement, TemplateResult, html, nothing } 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\n @query('slot') triggerElement!: HTMLElement;\n @query('.dropdown-container') dropDownContainer!: HTMLElement;\n\n @property({ type: Array }) options!: IOption[];\n @property({ type: Boolean, reflect: true }) show = false;\n @property() trigger = TriggerMode.Click;\n @property({ type: Object }) template!: TemplateResult<1>;\n @property({ type: Boolean, reflect: true }) always = false;\n\n @state() isDropDownVisited = false;\n @state() dropDownDirection = DropDownDirection.Right;\n\n override firstUpdated(): void {\n document.addEventListener('scroll', this.calculatePosition);\n window.addEventListener('resize', this.calculatePosition);\n\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\n onTriggerClick = async () => {\n this.show = !this.show;\n await this.updateComplete;\n this.calculatePosition();\n };\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 - triggerClientRect.width;\n const availableLeftSpace = triggerClientRect.right;\n\n this.dropDownContainer.style.position = 'fixed';\n\n if (dropDownHeight > availableBottomSpace) {\n this.dropDownContainer.style.top = `${triggerClientRect.top - dropDownHeight}px`;\n }\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\n initPosition() {\n this.dropDownContainer.style.removeProperty('top');\n this.dropDownContainer.style.removeProperty('position');\n this.dropDownContainer.style.removeProperty('right');\n }\n\n onClickOutside = (event: Event) => {\n const outsideClick = !event.composedPath().includes(this);\n if (outsideClick && this.show && !this.always) {\n this.show = false;\n this.initPosition();\n }\n };\n\n onMouseEnterTriggerElement = async () => {\n this.show = true;\n await this.updateComplete;\n this.calculatePosition();\n };\n\n onMouseLeaveTriggerElement = () => {\n const waitIsDropDownVisited = 50;\n setTimeout(() => {\n if (!this.isDropDownVisited) this.show = false;\n }, waitIsDropDownVisited);\n };\n\n onMouseEnterDropDown = () => {\n this.isDropDownVisited = true;\n };\n\n onMouseLeaveDropDown = () => {\n this.isDropDownVisited = false;\n this.show = false;\n this.initPosition();\n };\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\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[]): TemplateResult[] {\n return options.map((option) =>\n option.children\n ? html`\n <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 `\n : html`\n <hy-dropdown-item\n .disabled=${option.disabled}\n .icon=${option.icon}\n .label=${option.label}\n .value=${option.value}\n .additionalData=${option.additionalData}\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.show ? this.template : nothing}` : this.display(this.options)}\n </div>\n `;\n }\n}"]}
|
package/hy-dropdown.style.js
CHANGED
|
@@ -28,7 +28,7 @@ const dropdownStyle = css `
|
|
|
28
28
|
--hybrid-dropdown-disabled-text-color: rgba(0, 0, 0, 0.5);
|
|
29
29
|
--hybrid-dropdown-only-text-padding-left: 18px;
|
|
30
30
|
--hybrid-dropdown-icon-and-text-padding-left: 4px;
|
|
31
|
-
--hybrid-dropdown-menu-children-top:
|
|
31
|
+
--hybrid-dropdown-menu-children-top: 0px;
|
|
32
32
|
--hybrid-dropdown-menu-children-offset: -2px;
|
|
33
33
|
--hybrid-dropdown-menu-children-z-index: 2;
|
|
34
34
|
--hybrid-dropdown-font-size-local: 13px;
|
package/hy-dropdown.style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hy-dropdown.style.js","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.style.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"hy-dropdown.style.js","sourceRoot":"","sources":["../../../src/components/dropdown/hy-dropdown.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxB,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 border-radius: var(--hybrid-dropdown-border-radius, var(--hybrid-dropdown-border-radius));\n font-family: var(--hybrid-dropdown-font-family, Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, Ubuntu, Cantarell, \"Noto Sans\", sans-serif, \"system-ui\", \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, SFProLocalRange;);\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-icon-color: #5d5d5d;\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: #f4f4f4;\n --hybrid-dropdown-hovered-background-color: #e4e3e3;\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: 0px;\n --hybrid-dropdown-menu-children-offset: -2px;\n --hybrid-dropdown-menu-children-z-index: 2;\n --hybrid-dropdown-font-size-local: 13px;\n --hybrid-dropdown-border-radius : 0px;\n }\n @media (prefers-color-scheme: dark) {\n :host {\n --hybrid-dropdown-background-color: #232323;\n --hybrid-dropdown-hovered-background-color: #2b2b2b;\n --hybrid-dropdown-disabled-background-color: #6f6f6f;\n --hybrid-dropdown-text-color: #f4f4f4;\n }\n }\n`;\nexport const styles = dropdownStyle;\n"]}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hy-dropdown-item.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAIhD,qBACa,cAAe,SAAQ,UAAU;IAC5C,OAAgB,MAAM,4BAAU;IAGhC,IAAI,EAAG,MAAM,CAAC;IAGd,QAAQ,UAAS;IAGjB,KAAK,EAAG,MAAM,CAAC;IAGf,KAAK,EAAG,MAAM,CAAC;IAGf,cAAc,EAAG,GAAG,CAAC;IAErB,OAAO,CAAC,cAAc,EAAE,KAAK;IAepB,MAAM;CAQhB"}
|
|
@@ -13,12 +13,23 @@ let HyDropdownItem = class HyDropdownItem extends LitElement {
|
|
|
13
13
|
this.disabled = false;
|
|
14
14
|
}
|
|
15
15
|
onClick(clickItemEvent) {
|
|
16
|
+
console.log(this.additionalData, 'clickItemEvent');
|
|
16
17
|
clickItemEvent.stopPropagation();
|
|
17
|
-
if (!this.disabled)
|
|
18
|
-
this.dispatchEvent(new CustomEvent('click-item', {
|
|
18
|
+
if (!this.disabled) {
|
|
19
|
+
this.dispatchEvent(new CustomEvent('click-item', {
|
|
20
|
+
detail: { value: this.value, additionalData: this.additionalData },
|
|
21
|
+
composed: true,
|
|
22
|
+
bubbles: true,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
render() {
|
|
21
|
-
return html
|
|
27
|
+
return html `
|
|
28
|
+
<div @click=${this.onClick}>
|
|
29
|
+
${this.icon ? html `<hy-icon name=${this.icon}></hy-icon>` : nothing}
|
|
30
|
+
<hy-label class="option-label">${this.label}</hy-label>
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
22
33
|
}
|
|
23
34
|
};
|
|
24
35
|
HyDropdownItem.styles = styles;
|
|
@@ -34,6 +45,9 @@ __decorate([
|
|
|
34
45
|
__decorate([
|
|
35
46
|
property()
|
|
36
47
|
], HyDropdownItem.prototype, "value", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property()
|
|
50
|
+
], HyDropdownItem.prototype, "additionalData", void 0);
|
|
37
51
|
HyDropdownItem = __decorate([
|
|
38
52
|
customElement('hy-dropdown-item')
|
|
39
53
|
], HyDropdownItem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hy-dropdown-item.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-dropdown-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"hy-dropdown-item.js","sourceRoot":"","sources":["../../../../src/components/dropdown/templates/hy-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E;6CACI;AAGf;IADC,QAAQ,EAAE;6CACI;AAGf;IADC,QAAQ,EAAE;sDACU;AAhBV,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAyC1B;SAzCY,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\n @property({ reflect: true, type: String })\n icon!: string;\n\n @property({ reflect: true, type: Boolean })\n disabled = false;\n\n @property()\n label!: string;\n\n @property()\n value!: string;\n\n @property()\n additionalData!: any;\n\n onClick(clickItemEvent: Event) {\n console.log(this.additionalData, 'clickItemEvent');\n clickItemEvent.stopPropagation();\n\n if (!this.disabled) {\n this.dispatchEvent(\n new CustomEvent('click-item', {\n detail: { value: this.value, additionalData: this.additionalData },\n composed: true,\n bubbles: true,\n })\n );\n }\n }\n\n override render() {\n return html`\n <div @click=${this.onClick}>\n ${this.icon ? html`<hy-icon name=${this.icon}></hy-icon>` : nothing}\n <hy-label class=\"option-label\">${this.label}</hy-label>\n </div>\n `;\n }\n}"]}
|