revotech-ui-kit 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
package/dist/revotech-ui-kit.js
CHANGED
@@ -3138,7 +3138,7 @@ body {
|
|
3138
3138
|
</div>
|
3139
3139
|
<slot></slot>
|
3140
3140
|
</div>
|
3141
|
-
`}};be.styles=[l.css``,c],We([d.property({attribute:"data-state",type:String})],be.prototype,"state",2),We([d.state()],be.prototype,"isOpen",2),be=We([d.customElement("rtg-combo-box-list")],be);var In=Object.defineProperty,An=Object.getOwnPropertyDescriptor,U=(n,e,r,o)=>{for(var t=o>1?void 0:o?An(e,r):e,s=n.length-1,i;s>=0;s--)(i=n[s])&&(t=(o?i(e,r,t):i(t))||t);return o&&t&&In(e,r,t),t};a.ComboBox=class extends l.LitElement{constructor(){super(...arguments),this.isOpen=!1,this.selectedValue="",this.searchTerm="",this.focusedIndex=-1,this.filteredItems=[],this.label="Select an item",this.items=[]}firstUpdated(e){console.log("this. items",this.items),this.items&&this.items.length>0&&(this.filteredItems=this.items.filter(r=>r.toLowerCase().includes(this.searchTerm)))}toggleDropdown(){this.isOpen=!this.isOpen,this.focusedIndex=-1,this.requestUpdate(),console.log("toggleDropdown",this.isOpen)}selectItem(e){const r=e.target;if(r instanceof HTMLElement){const o=r.closest("rtg-combo-box-item");o?(this.selectedValue=o.getAttribute("data-hs-combo-box-value")||"",this.isOpen=!1):console.log("No valid rtg-combo-box-item found")}else console.log("Event target is not an HTMLElement")}handleInputClick(){console.log("-----handleInputClick------"),this.toggleDropdown()}handleSearch(e){const r=e.target;this.searchTerm=r.value,this.filteredItems=this.items.filter(o=>o.toLowerCase().includes(this.searchTerm.toLowerCase()))}handleKeyDown(e){const r=this.filteredItems.length;switch(e.key){case"ArrowDown":e.preventDefault(),this.focusedIndex=(this.focusedIndex+1)%r;break;case"ArrowUp":e.preventDefault(),this.focusedIndex=(this.focusedIndex-1+r)%r;break;case"Enter":this.focusedIndex>=0&&this.focusedIndex<r&&(this.selectedValue=this.filteredItems[this.focusedIndex],this.isOpen=!1);break}}handleMouseOver(e,r){e.preventDefault(),this.focusedIndex=r}connectedCallback(){var e,r,o,t;super.connectedCallback(),document.addEventListener("click",this.handleClickOutside.bind(this)),(r=(e=this.shadowRoot)==null?void 0:e.querySelector("input"))==null||r.addEventListener("focus",()=>{this.isOpen=!0}),(t=(o=this.shadowRoot)==null?void 0:o.querySelector("input"))==null||t.addEventListener("blur",()=>{this.isOpen&&(this.isOpen=!1)})}disconnectedCallback(){var e,r,o,t;super.disconnectedCallback(),document.removeEventListener("click",this.handleClickOutside),(r=(e=this.shadowRoot)==null?void 0:e.querySelector("input"))==null||r.removeEventListener("focus",()=>{}),(t=(o=this.shadowRoot)==null?void 0:o.querySelector("input"))==null||t.removeEventListener("blur",()=>{})}handleClickOutside(e){var s,i;const r=e.target,o=(s=this.shadowRoot)==null?void 0:s.querySelector("[data-hs-combo-box]");if(!this.shadowRoot||!(r instanceof HTMLElement)){console.log("Invalid target or shadow root");return}const t=(i=r.shadowRoot)==null?void 0:i.firstElementChild;if(!t){this.isOpen=!1;return}(!o||!o.contains(t))&&(this.isOpen=!1)}updateFocus(){if(!this.shadowRoot)return;this.shadowRoot.querySelectorAll("rtg-combo-box-item").forEach((r,o)=>{o===this.focusedIndex?r.classList.add("bg-gray-100"):r.classList.remove("bg-gray-100")})}render(){return console.log("render "),l.html`
|
3141
|
+
`}};be.styles=[l.css``,c],We([d.property({attribute:"data-state",type:String})],be.prototype,"state",2),We([d.state()],be.prototype,"isOpen",2),be=We([d.customElement("rtg-combo-box-list")],be);var In=Object.defineProperty,An=Object.getOwnPropertyDescriptor,U=(n,e,r,o)=>{for(var t=o>1?void 0:o?An(e,r):e,s=n.length-1,i;s>=0;s--)(i=n[s])&&(t=(o?i(e,r,t):i(t))||t);return o&&t&&In(e,r,t),t};a.ComboBox=class extends l.LitElement{constructor(){super(...arguments),this.isOpen=!1,this.selectedValue="",this.searchTerm="",this.focusedIndex=-1,this.filteredItems=[],this.label="Select an item",this.items=[]}firstUpdated(e){console.log("this. items",this.items),this.items&&this.items.length>0&&(this.filteredItems=this.items.filter(r=>r.toLowerCase().includes(this.searchTerm)))}toggleDropdown(){this.isOpen=!this.isOpen,this.focusedIndex=-1,this.requestUpdate(),console.log("toggleDropdown",this.isOpen)}selectItem(e){const r=e.target;if(r instanceof HTMLElement){const o=r.closest("rtg-combo-box-item");o?(this.selectedValue=o.getAttribute("data-hs-combo-box-value")||"",this.isOpen=!1):console.log("No valid rtg-combo-box-item found")}else console.log("Event target is not an HTMLElement")}handleInputClick(){console.log("-----handleInputClick------"),this.toggleDropdown()}handleSearch(e){const r=e.target;this.searchTerm=r.value,this.filteredItems=this.items.filter(o=>o.toLowerCase().includes(this.searchTerm.toLowerCase()))}handleKeyDown(e){const r=this.filteredItems.length;switch(e.key){case"ArrowDown":e.preventDefault(),this.focusedIndex=(this.focusedIndex+1)%r;break;case"ArrowUp":e.preventDefault(),this.focusedIndex=(this.focusedIndex-1+r)%r;break;case"Enter":this.focusedIndex>=0&&this.focusedIndex<r&&(this.selectedValue=this.filteredItems[this.focusedIndex],this.isOpen=!1);break}}handleMouseOver(e,r){e.preventDefault(),this.focusedIndex=r}connectedCallback(){var e,r,o,t;super.connectedCallback(),document.addEventListener("click",this.handleClickOutside.bind(this)),(r=(e=this.shadowRoot)==null?void 0:e.querySelector("input"))==null||r.addEventListener("focus",()=>{this.isOpen=!0}),(t=(o=this.shadowRoot)==null?void 0:o.querySelector("input"))==null||t.addEventListener("blur",()=>{this.isOpen&&(this.isOpen=!1)})}disconnectedCallback(){var e,r,o,t;super.disconnectedCallback(),document.removeEventListener("click",this.handleClickOutside),(r=(e=this.shadowRoot)==null?void 0:e.querySelector("input"))==null||r.removeEventListener("focus",()=>{}),(t=(o=this.shadowRoot)==null?void 0:o.querySelector("input"))==null||t.removeEventListener("blur",()=>{})}handleClickOutside(e){var s,i;const r=e.target,o=(s=this.shadowRoot)==null?void 0:s.querySelector("[data-hs-combo-box]");if(!this.shadowRoot||!(r instanceof HTMLElement)){console.log("Invalid target or shadow root");return}const t=(i=r.shadowRoot)==null?void 0:i.firstElementChild;if(!t){this.isOpen=!1;return}(!o||!o.contains(t))&&(this.isOpen=!1)}updateFocus(){if(!this.shadowRoot)return;this.shadowRoot.querySelectorAll("rtg-combo-box-item").forEach((r,o)=>{o===this.focusedIndex?r.classList.add("bg-gray-100"):r.classList.remove("bg-gray-100")})}render(){return console.log("render ",this.isOpen),l.html`
|
3142
3142
|
<div class="relative" data-hs-combo-box="">
|
3143
3143
|
isopen:${this.isOpen}
|
3144
3144
|
<div>
|
package/package.json
CHANGED