UNPKG

@kelvininc/ui-components

Version:
1 lines 2.08 kB
import{r as t,c as s,h as e,H as i,g as a}from"./p-WTwLUJcM.js";import{o,f as r}from"./p-CJTtq_QG.js";import{d}from"./p-BzJpag4J.js";import{a as n}from"./p-B4OowdnI.js";import"./p-COrzvkrr.js";import"./p-DjSNdVAB.js";const h={placement:"bottom",middleware:[o(8),r({padding:16,fallbackPlacements:["top-end","bottom-end","top-start","bottom-start"]})]},c=class{constructor(e){t(this,e),this.openStateChange=s(this,"openStateChange",7),this.clickOutside=s(this,"clickOutside",7),this.isOpen=!1,this.options=h,this.actionElement=null,this.listElement=null,this.clickOutsideClose=!0,this.zIndex=n,this.getActionElement=()=>{var t;return null!==(t=this.actionElement)&&void 0!==t?t:this.action},this.getListElement=()=>{var t;return null!==(t=this.listElement)&&void 0!==t?t:this.portal},this.didClickOnDropdownAction=t=>{const s=this.getActionElement();return d(s,t)},this.didClickOnDropdownList=t=>{const s=this.getListElement();return d(s,t)}}checkForClickOutside(t){this.didClickOnDropdownAction(t)||this.didClickOnDropdownList(t)||(this.isOpen&&this.clickOutsideClose&&this.openStateChange.emit(!this.isOpen),this.clickOutside.emit(t))}disconnectedCallback(){var t;null===(t=this.portal)||void 0===t||t.remove()}render(){return e(i,{key:"4e4c7a224c21ed840cda7b25bcdf5291a011b5c0"},e("div",{key:"3f34c6190639bbcd5a4764ee05938dfd01099428",id:"dropdown-action",ref:t=>this.action=t},e("slot",{key:"1a69edda08f5e8925edd72e46b33baacc6dbe0e5",name:"action"})),e("kv-portal",{key:"76662b19361907772abd2c5a112146b22367a5f2",animated:!0,ref:t=>this.portal=t,show:this.isOpen,reference:this.getActionElement(),options:this.options,zIndex:this.zIndex},e("div",{key:"3a2cf570844afd3b1e9b650308c8ea4c70c50fe6",class:"dropdown-base-list"},e("slot",{key:"5150c2a047b5482c38a0904916859572d8021644",name:"list"}))))}get element(){return a(this)}};c.style='@property --rotation{syntax:"<angle>";initial-value:0deg;inherits:false}@keyframes rotate-border{to{--rotation:360deg}}kv-dropdown-base:not(.hydrated)>[slot=list]{display:none}.dropdown-base-list{width:100%}';export{c as kv_dropdown_base}