@sankhyalabs/ezui 5.22.0-dev.88 → 5.22.0-dev.89

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.
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as i,F as n,H as o,g as s}from"./p-23a36bb6.js";import{ArrayUtils as r}from"@sankhyalabs/core";var l;!function(t){t.DATASOURCE_RESULTS="DATASOURCE_RESULTS",t.DATASOURCE_RESULTS_EMPTY="DATASOURCE_RESULTS_EMPTY",t.DATASOURCE_INIT="DATASOURCE_INIT",t.OPTIONS_EMPTY="OPTIONS_EMPTY",t.OPTIONS="OPTIONS"}(l||(l={}));const a=class{constructor(i){t(this,i),this.changeFilteredOptions=e(this,"changeFilteredOptions",7),this.columnName=void 0,this.dataSource=void 0,this.useOptions=!1,this.options=void 0,this.isTextSearch=!1,this.filteredOptions=void 0,this.displayOptions=void 0,this.viewScenario=void 0,this.displayOptionToCheckAllItems=!0}async clearFilteredOptions(){this.setInitialScenario(),this.filteredOptions=[],this.searchInput&&(this.searchInput.value=""),this.filterInput&&(this.filterInput.value="")}onChangeUseOptions(){this.setInitialScenario()}onChangeOptions(){this.options&&(this.filteredOptions=this.ordenationByCheckStateAndAlphabetically(this.options)),this.checkInput&&this.changeCheckAllValeuFromFilteredOptions(),this.setInitialScenario()}onChangeFilteredOptions(t){this.displayOptions=this.filteredOptions,this.displayOptionToCheckAllItems=this.filteredOptions.length>1,this.checkInput&&this.changeCheckAllValeuFromFilteredOptions(),this.changeFilteredOptions.emit(t)}componentDidRender(){this.changeCheckAllValeuFromFilteredOptions()}ordenationByCheckStateAndAlphabetically(t){const e=[],i=[];let n;return t.forEach((t=>{null==t.value||""===t.label?n=Object.assign(Object.assign({},t),{label:"(Vazio)"}):t.check?e.push(t):i.push(t)})),(null==n?[]:[n]).concat(null==this.dataSource?r.sortAlphabetically(e):this.dataSource.sortItems(this.columnName,e)).concat(null==this.dataSource?r.sortAlphabetically(i):this.dataSource.sortItems(this.columnName,i))}changeCheckAllValeuFromFilteredOptions(){var t,e,i,n;const o=null===(t=this.filteredOptions)||void 0===t?void 0:t.every((t=>!0===t.check)),s=null===(e=this.filteredOptions)||void 0===e?void 0:e.every((t=>!1===t.check)),r=(null===(i=this.filteredOptions)||void 0===i?void 0:i.some((t=>!1===t.check)))&&(null===(n=this.filteredOptions)||void 0===n?void 0:n.some((t=>!0===t.check)))&&(!o||!s);return this.checkInput&&o?(this.checkInput.indeterminate=!1,void(this.checkInput.value=!0)):this.checkInput&&r?(this.checkInput.indeterminate=!0,void(this.checkInput.value=!1)):this.checkInput&&s?(this.checkInput.indeterminate=!1,void(this.checkInput.value=!1)):void 0}setInitialScenario(){if(this.useOptions)return this.viewScenario=l.OPTIONS,void this.changeCheckAllValeuFromFilteredOptions();this.viewScenario=this.options&&this.options.length>0?l.DATASOURCE_RESULTS:l.DATASOURCE_INIT}async searchWithDataSource(t,e){const{argument:i,mode:n}=t;if("PRELOAD"!==n&&e)return this.dataSource.fetchData(i,e)}handleSearchOnDataSource(t){var e;const i=null!==(e=this.filteredOptions)&&void 0!==e?e:[];t.detail&&!i.some((e=>e.value==t.detail.value))&&(this.filteredOptions=this.ordenationByCheckStateAndAlphabetically([...i,t.detail])),this.viewScenario=l.DATASOURCE_RESULTS,this.searchInput.value=""}handleRemoveItemFromOptions(t){this.filteredOptions=this.ordenationByCheckStateAndAlphabetically(this.filteredOptions.filter((e=>e.value!==t.value))),0===this.filteredOptions.length&&(this.viewScenario=l.DATASOURCE_INIT),this.searchInput&&(this.searchInput.value="")}handleSearchOnOption(t){if(t.detail)return this.displayOptions=r.applyStringFilter(t.detail,this.filteredOptions,!0),void(this.viewScenario=0===this.displayOptions.length?l.OPTIONS_EMPTY:l.OPTIONS);this.displayOptions=this.filteredOptions,this.viewScenario=l.OPTIONS}handleChangeSelectAllItems(t){this.filteredOptions=this.ordenationByCheckStateAndAlphabetically([...this.filteredOptions.map((e=>(e.check=!!t.detail,e)))])}handleChangeSelectedItem(t){const{detail:e}=t;this.filteredOptions.find((t=>t.label===e.label)).check=e.check}buildViewList(t){return i(n,null,this.displayOptionToCheckAllItems&&i("ez-check",{ref:t=>this.checkInput=t,label:"Selecionar todos",class:"multi-selection__select-all",onEzChange:this.handleChangeSelectAllItems.bind(this)}),i("ez-list",{class:"multi-selection__list",dataSource:this.displayOptions,listMode:"check",hoverFeedback:!0,onEzCheckChange:this.handleChangeSelectedItem.bind(this),itemSlotBuilder:t?this.buildDeleteIconSlot.bind(this):null}))}buildDeleteIconSlot(t){return i("ez-icon",{style:{cursor:"pointer"},iconName:"delete",onClick:()=>this.handleRemoveItemFromOptions(t)})}buildInitViewWithDataSource(){return i("multi-selection-box-message",{message:"Selecione os valores a serem filtrados através do campo de busca."})}buildViewEmptyResults(){return i("multi-selection-box-message",{message:"Nenhum resultado encontrado."})}scenarioToDisplay(t){const e={[l.DATASOURCE_INIT]:()=>this.buildInitViewWithDataSource(),[l.DATASOURCE_RESULTS]:()=>this.buildViewList(!0),[l.DATASOURCE_RESULTS_EMPTY]:()=>this.buildViewEmptyResults(),[l.OPTIONS_EMPTY]:()=>this.buildViewEmptyResults(),[l.OPTIONS]:()=>this.buildViewList(!1)}[t];return e?e():void 0}render(){return i(o,null,i("div",{class:"multi-selection"},this.useOptions?i("ez-filter-input",{ref:t=>this.filterInput=t,label:"Buscar..",onEzChange:this.handleSearchOnOption.bind(this)}):i("ez-search",{class:"multi-selection__input",label:"Buscar...",ref:t=>this.searchInput=t,suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,optionLoader:t=>this.searchWithDataSource(t,this.columnName),onEzChange:this.handleSearchOnDataSource.bind(this),isTextSearch:this.isTextSearch}),i("ez-scroll",{class:"multi-selection__content-options"},this.scenarioToDisplay(this.viewScenario))))}static get watchers(){return{useOptions:["onChangeUseOptions"],options:["onChangeOptions"],filteredOptions:["onChangeFilteredOptions"]}}};a.style=".sc-ez-multi-selection-list-h{--ez-check--outter-gap:0px;--ez-multi-selection-default-height:322px;display:block;width:304px;height:var(--ez-multi-selection-default-height);min-height:fit-content;max-height:calc(100vh - 350px)}.multi-selection__input.sc-ez-multi-selection-list{margin-bottom:var(--space--2xs, 8px)}.multi-selection__content-options.sc-ez-multi-selection-list{position:relative;left:-4px}.multi-selection__select-all.sc-ez-multi-selection-list{height:var(--space--xl);margin:0 var(--space--small, 6px)}.multi-selection__list.sc-ez-multi-selection-list{max-height:calc(100vh - 435px);overflow-y:auto;overflow-x:clip}.multi-selection__list.sc-ez-multi-selection-list::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";const c=Math.min,h=Math.max,u=Math.round,d=t=>({x:t,y:t}),f={left:"right",right:"left",bottom:"top",top:"bottom"},p={start:"end",end:"start"};function m(t,e,i){return h(t,c(e,i))}function v(t,e){return"function"==typeof t?t(e):t}function b(t){return t.split("-")[0]}function g(t){return t.split("-")[1]}function y(t){return"x"===t?"y":"x"}function x(t){return"y"===t?"height":"width"}function w(t){return["top","bottom"].includes(b(t))?"y":"x"}function _(t){return y(w(t))}function z(t){return t.replace(/start|end/g,(t=>p[t]))}function O(t){return t.replace(/left|right|bottom|top/g,(t=>f[t]))}function S(t){const{x:e,y:i,width:n,height:o}=t;return{width:n,height:o,top:i,left:e,right:e+n,bottom:i+o,x:e,y:i}}function k(t,e,i){let{reference:n,floating:o}=t;const s=w(e),r=_(e),l=x(r),a=b(e),c="y"===s,h=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,d=n[l]/2-o[l]/2;let f;switch(a){case"top":f={x:h,y:n.y-o.height};break;case"bottom":f={x:h,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:u};break;case"left":f={x:n.x-o.width,y:u};break;default:f={x:n.x,y:n.y}}switch(g(e)){case"start":f[r]-=d*(i&&c?-1:1);break;case"end":f[r]+=d*(i&&c?-1:1)}return f}async function C(t,e){var i;void 0===e&&(e={});const{x:n,y:o,platform:s,rects:r,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=v(e,t),p=function(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}(f),m=l[d?"floating"===u?"reference":"floating":u],b=S(await s.getClippingRect({element:null==(i=await(null==s.isElement?void 0:s.isElement(m)))||i?m:m.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:h,strategy:a})),g="floating"===u?{x:n,y:o,width:r.floating.width,height:r.floating.height}:r.reference,y=await(null==s.getOffsetParent?void 0:s.getOffsetParent(l.floating)),x=await(null==s.isElement?void 0:s.isElement(y))&&await(null==s.getScale?void 0:s.getScale(y))||{x:1,y:1},w=S(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:g,offsetParent:y,strategy:a}):g);return{top:(b.top-w.top+p.top)/x.y,bottom:(w.bottom-b.bottom+p.bottom)/x.y,left:(b.left-w.left+p.left)/x.x,right:(w.right-b.right+p.right)/x.x}}function A(){return"undefined"!=typeof window}function P(t){return E(t)?(t.nodeName||"").toLowerCase():"#document"}function R(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function T(t){var e;return null==(e=(E(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function E(t){return!!A()&&(t instanceof Node||t instanceof R(t).Node)}function D(t){return!!A()&&(t instanceof Element||t instanceof R(t).Element)}function F(t){return!!A()&&(t instanceof HTMLElement||t instanceof R(t).HTMLElement)}function L(t){return!(!A()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof R(t).ShadowRoot)}function I(t){const{overflow:e,overflowX:i,overflowY:n,display:o}=U(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&!["inline","contents"].includes(o)}function B(t){return["table","td","th"].includes(P(t))}function N(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function V(t){const e=j(),i=D(t)?U(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!i[t]&&"none"!==i[t]))||!!i.containerType&&"normal"!==i.containerType||!e&&!!i.backdropFilter&&"none"!==i.backdropFilter||!e&&!!i.filter&&"none"!==i.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(i.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(i.contain||"").includes(t)))}function j(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function M(t){return["html","body","#document"].includes(P(t))}function U(t){return R(t).getComputedStyle(t)}function $(t){return D(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function G(t){if("html"===P(t))return t;const e=t.assignedSlot||t.parentNode||L(t)&&t.host||T(t);return L(e)?e.host:e}function W(t){const e=G(t);return M(e)?t.ownerDocument?t.ownerDocument.body:t.body:F(e)&&I(e)?e:W(e)}function Y(t,e,i){var n;void 0===e&&(e=[]),void 0===i&&(i=!0);const o=W(t),s=o===(null==(n=t.ownerDocument)?void 0:n.body),r=R(o);if(s){const t=H(r);return e.concat(r,r.visualViewport||[],I(o)?o:[],t&&i?Y(t):[])}return e.concat(o,Y(o,[],i))}function H(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X(t){const e=U(t);let i=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const o=F(t),s=o?t.offsetWidth:i,r=o?t.offsetHeight:n,l=u(i)!==s||u(n)!==r;return l&&(i=s,n=r),{width:i,height:n,$:l}}function q(t){return D(t)?t:t.contextElement}function J(t){const e=q(t);if(!F(e))return d(1);const i=e.getBoundingClientRect(),{width:n,height:o,$:s}=X(e);let r=(s?u(i.width):i.width)/n,l=(s?u(i.height):i.height)/o;return r&&Number.isFinite(r)||(r=1),l&&Number.isFinite(l)||(l=1),{x:r,y:l}}const K=d(0);function Q(t){const e=R(t);return j()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:K}function Z(t,e,i,n){void 0===e&&(e=!1),void 0===i&&(i=!1);const o=t.getBoundingClientRect(),s=q(t);let r=d(1);e&&(n?D(n)&&(r=J(n)):r=J(t));const l=function(t,e,i){return void 0===e&&(e=!1),!(!i||e&&i!==R(t))&&e}(s,i,n)?Q(s):d(0);let a=(o.left+l.x)/r.x,c=(o.top+l.y)/r.y,h=o.width/r.x,u=o.height/r.y;if(s){const t=R(s),e=n&&D(n)?R(n):n;let i=t,o=H(i);for(;o&&n&&e!==i;){const t=J(o),e=o.getBoundingClientRect(),n=U(o),s=e.left+(o.clientLeft+parseFloat(n.paddingLeft))*t.x,r=e.top+(o.clientTop+parseFloat(n.paddingTop))*t.y;a*=t.x,c*=t.y,h*=t.x,u*=t.y,a+=s,c+=r,i=R(o),o=H(i)}}return S({width:h,height:u,x:a,y:c})}function tt(t,e){const i=$(t).scrollLeft;return e?e.left+i:Z(T(t)).left+i}function et(t,e,i){void 0===i&&(i=!1);const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-(i?0:tt(t,n)),y:n.top+e.scrollTop}}function it(t,e,i){let n;if("viewport"===e)n=function(t,e){const i=R(t),n=T(t),o=i.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,a=0;if(o){s=o.width,r=o.height;const t=j();(!t||t&&"fixed"===e)&&(l=o.offsetLeft,a=o.offsetTop)}return{width:s,height:r,x:l,y:a}}(t,i);else if("document"===e)n=function(t){const e=T(t),i=$(t),n=t.ownerDocument.body,o=h(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=h(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let r=-i.scrollLeft+tt(t);const l=-i.scrollTop;return"rtl"===U(n).direction&&(r+=h(e.clientWidth,n.clientWidth)-o),{width:o,height:s,x:r,y:l}}(T(t));else if(D(e))n=function(t,e){const i=Z(t,!0,"fixed"===e),n=i.top+t.clientTop,o=i.left+t.clientLeft,s=F(t)?J(t):d(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:o*s.x,y:n*s.y}}(e,i);else{const i=Q(t);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return S(n)}function nt(t,e){const i=G(t);return!(i===e||!D(i)||M(i))&&("fixed"===U(i).position||nt(i,e))}function ot(t,e,i){const n=F(e),o=T(e),s="fixed"===i,r=Z(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=d(0);if(n||!n&&!s)if(("body"!==P(e)||I(o))&&(l=$(e)),n){const t=Z(e,!0,s,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else o&&(a.x=tt(o));const c=!o||n||s?d(0):et(o,l);return{x:r.left+l.scrollLeft-a.x-c.x,y:r.top+l.scrollTop-a.y-c.y,width:r.width,height:r.height}}function st(t){return"static"===U(t).position}function rt(t,e){if(!F(t)||"fixed"===U(t).position)return null;if(e)return e(t);let i=t.offsetParent;return T(t)===i&&(i=i.ownerDocument.body),i}function lt(t,e){const i=R(t);if(N(t))return i;if(!F(t)){let e=G(t);for(;e&&!M(e);){if(D(e)&&!st(e))return e;e=G(e)}return i}let n=rt(t,e);for(;n&&B(n)&&st(n);)n=rt(n,e);return n&&M(n)&&st(n)&&!V(n)?i:n||function(t){let e=G(t);for(;F(e)&&!M(e);){if(V(e))return e;if(N(e))return null;e=G(e)}return null}(t)||i}const at={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:n,strategy:o}=t;const s="fixed"===o,r=T(n),l=!!e&&N(e.floating);if(n===r||l&&s)return i;let a={scrollLeft:0,scrollTop:0},c=d(1);const h=d(0),u=F(n);if((u||!u&&!s)&&(("body"!==P(n)||I(r))&&(a=$(n)),F(n))){const t=Z(n);c=J(n),h.x=t.x+n.clientLeft,h.y=t.y+n.clientTop}const f=!r||u||s?d(0):et(r,a,!0);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-a.scrollLeft*c.x+h.x+f.x,y:i.y*c.y-a.scrollTop*c.y+h.y+f.y}},getDocumentElement:T,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t;const s=[..."clippingAncestors"===i?N(e)?[]:function(t,e){const i=e.get(t);if(i)return i;let n=Y(t,[],!1).filter((t=>D(t)&&"body"!==P(t))),o=null;const s="fixed"===U(t).position;let r=s?G(t):t;for(;D(r)&&!M(r);){const e=U(r),i=V(r);i||"fixed"!==e.position||(o=null),(s?!i&&!o:!i&&"static"===e.position&&o&&["absolute","fixed"].includes(o.position)||I(r)&&!i&&nt(t,r))?n=n.filter((t=>t!==r)):o=e,r=G(r)}return e.set(t,n),n}(e,this._c):[].concat(i),n],r=s.reduce(((t,i)=>{const n=it(e,i,o);return t.top=h(n.top,t.top),t.right=c(n.right,t.right),t.bottom=c(n.bottom,t.bottom),t.left=h(n.left,t.left),t}),it(e,s[0],o));return{width:r.right-r.left,height:r.bottom-r.top,x:r.left,y:r.top}},getOffsetParent:lt,getElementRects:async function(t){const e=this.getOffsetParent||lt,i=this.getDimensions,n=await i(t.floating);return{reference:ot(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:i}=X(t);return{width:e,height:i}},getScale:J,isElement:D,isRTL:function(t){return"rtl"===U(t).direction}},ct=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:n,placement:o}=e,{mainAxis:s=!0,crossAxis:r=!1,limiter:l={fn:t=>{let{x:e,y:i}=t;return{x:e,y:i}}},...a}=v(t,e),c={x:i,y:n},h=await C(e,a),u=w(b(o)),d=y(u);let f=c[d],p=c[u];s&&(f=m(f+h["y"===d?"top":"left"],f,f-h["y"===d?"bottom":"right"])),r&&(p=m(p+h["y"===u?"top":"left"],p,p-h["y"===u?"bottom":"right"]));const g=l.fn({...e,[d]:f,[u]:p});return{...g,data:{x:g.x-i,y:g.y-n,enabled:{[d]:s,[u]:r}}}}}},ht=class{constructor(i){t(this,i),this.ezVisibilityChange=e(this,"ezVisibilityChange",7),this.TIME_DEBOUNCE=500,this.autoClose=!0,this.boxWidth="fit-content",this.opened=!1,this.overlayType="light",this.anchorElement=void 0,this.options={horizontalGap:0,verticalGap:0,fromRight:!1}}async observeOpened(t,e){if(t!==e)return t?this.openPopover():this.hidePopover(),void this.ezVisibilityChange.emit(t)}async updatePosition(t,e){this.updateOptionPosition(t,e),await this.updatePositionPopover()}async show(t,e){this.updateOptionPosition(t,e),this.opened=!0}async showUnder(t,e){e&&(this.options=e),this.anchorElement=t,this.opened=!0}async hide(){this.opened=!1}async setOptions(t){Object.assign(this.options,t)}async setAnchorElement(t){this.anchorElement=t}parseSizePixel(t,e){return t?"string"==typeof t?Number(t.replace("px","")):null!=t?t:0:null!=e?e:0}updateOptionPosition(t,e){Object.assign(this.options,{horizontalGap:this.parseSizePixel(e,this.options.horizontalGap),verticalGap:this.parseSizePixel(t,this.options.verticalGap)})}async updatePositionPopover(){var t;this._box&&this.opened&&(this.anchorElement||(this.anchorElement=this._host),"string"==typeof this.anchorElement&&(this.anchorElement=document.getElementById(this.anchorElement)),await((t,e,i)=>{const n=new Map,o={platform:at,...i},s={...o.platform,_c:n};return(async(t,e,i)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:r}=i,l=s.filter(Boolean),a=await(null==r.isRTL?void 0:r.isRTL(e));let c=await r.getElementRects({reference:t,floating:e,strategy:o}),{x:h,y:u}=k(c,n,a),d=n,f={},p=0;for(let i=0;i<l.length;i++){const{name:s,fn:m}=l[i],{x:v,y:b,data:g,reset:y}=await m({x:h,y:u,initialPlacement:n,placement:d,strategy:o,middlewareData:f,rects:c,platform:r,elements:{reference:t,floating:e}});h=null!=v?v:h,u=null!=b?b:u,f={...f,[s]:{...f[s],...g}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await r.getElementRects({reference:t,floating:e,strategy:o}):y.rects),({x:h,y:u}=k(c,d,a))),i=-1)}return{x:h,y:u,placement:d,strategy:o,middlewareData:f}})(t,e,{...o,platform:s})})(this.anchorElement,this._box,{placement:this.options.fromRight?"bottom-end":"bottom-start",middleware:[(void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var i,n;const{placement:o,middlewareData:s,rects:r,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...y}=v(t,e);if(null!=(i=s.arrow)&&i.alignmentOffset)return{};const S=b(o),k=w(l),A=b(l)===l,P=await(null==a.isRTL?void 0:a.isRTL(c.floating)),R=d||(A||!m?[O(l)]:function(t){const e=O(t);return[z(t),e,z(e)]}(l)),T="none"!==p;!d&&T&&R.push(...function(t,e,i,n){const o=g(t);let s=function(t,e,i){const n=["left","right"],o=["right","left"],s=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return i?e?o:n:e?n:o;case"left":case"right":return e?s:r;default:return[]}}(b(t),"start"===i,n);return o&&(s=s.map((t=>t+"-"+o)),e&&(s=s.concat(s.map(z)))),s}(l,m,p,P));const E=[l,...R],D=await C(e,y),F=[];let L=(null==(n=s.flip)?void 0:n.overflows)||[];if(h&&F.push(D[S]),u){const t=function(t,e,i){void 0===i&&(i=!1);const n=g(t),o=_(t),s=x(o);let r="x"===o?n===(i?"end":"start")?"right":"left":"start"===n?"bottom":"top";return e.reference[s]>e.floating[s]&&(r=O(r)),[r,O(r)]}(o,r,P);F.push(D[t[0]],D[t[1]])}if(L=[...L,{placement:o,overflows:F}],!F.every((t=>t<=0))){var I,B;const t=((null==(I=s.flip)?void 0:I.index)||0)+1,e=E[t];if(e)return{data:{index:t,overflows:L},reset:{placement:e}};let i=null==(B=L.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:B.placement;if(!i)switch(f){case"bestFit":{var N;const t=null==(N=L.filter((t=>{if(T){const e=w(t.placement);return e===k||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:N[0];t&&(i=t);break}case"initialPlacement":i=l}if(o!==i)return{reset:{placement:i}}}return{}}}),ct({padding:5})],strategy:"fixed"}).then((({x:t,y:e,placement:i})=>{const n=i.includes("bottom")?e+this.options.verticalGap:e-this.options.verticalGap,o=i.includes("start")?t+this.options.horizontalGap:t-this.options.horizontalGap;Object.assign(this._box.style,{top:`${n}px`,left:`${o}px`})})))}hidePopover(){this._box&&(this._box.style.display="",this.hideOverlay(),this.ezVisibilityChange.emit(!1))}async openPopover(){this._box&&(this._box.style.display="flex",this._box.style.visibility="hidden",await this.updatePositionPopover(),this.openOverlay(),this.ezVisibilityChange.emit(!0),this._box.style.visibility="visible")}openOverlay(){this._overlay&&this._overlayIsActive&&(this._overlay.style.display="block")}hideOverlay(){this._overlay&&(this._overlay.style.display="none")}checkStatusOverlay(){return"none"!==this.overlayType||!("none"!==this.overlayType||!this.autoClose)}updatePositionDebounce(){this.opened&&(clearTimeout(this._timeoutDebounce),this._timeoutDebounce=setTimeout((()=>{this.updatePositionPopover()}),this.TIME_DEBOUNCE))}componentWillLoad(){window.addEventListener("scroll",this.updatePositionDebounce.bind(this),!0),window.addEventListener("resize",this.updatePositionDebounce.bind(this),!0)}componentDidLoad(){this._overlayIsActive=this.checkStatusOverlay(),this._resizeObserver=new ResizeObserver(this.updatePositionPopover.bind(this)),this._resizeObserver.observe(this._box)}disconnectedCallback(){window.removeEventListener("scroll",this.updatePositionDebounce.bind(this),!0),window.removeEventListener("resize",this.updatePositionDebounce.bind(this),!0),this._resizeObserver.disconnect()}render(){return i(o,null,i("div",{ref:t=>this._overlay=t,onClick:()=>this.hide(),class:`popover__overlay popover__overlay--${this.overlayType}`}),i("section",{ref:t=>this._box=t,class:{popover__box:!0,"popover__box--fit-content":"fit-content"===this.boxWidth,"popover__box--full-width":"fit-content"!==this.boxWidth}},i("slot",null)))}get _host(){return s(this)}static get watchers(){return{opened:["observeOpened"]}}};ht.style=":host{--ez-popover__box--border-radius:var(--border--radius-medium, 12px);--ez-popover__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-popover__box--background-color:var(--background--xlight, #fff);--ez-popover__box--z-index:var(--most-visible, 4);position:relative;display:flex;user-select:none}.popover__overlay{display:none;position:fixed;padding:0;top:0px;left:0px;width:100%;height:100vh;box-sizing:border-box;z-index:var(--more-visible--2x, 3)}.popover__overlay--light{background-color:rgba(var(--rgb-background--overlay), var(--opacity--bright))}.popover__overlay--medium{background-color:rgba(var(--rgb-background--overlay), var(--opacity--soft));backdrop-filter:blur(var(--background-blur--medium))}.popover__box{display:none;position:fixed;top:0;left:0;z-index:var(--ez-popover__box--z-index);flex-direction:column;height:fit-content;background-color:var(--ez-popover__box--background-color);border-radius:var(--ez-popover__box--border-radius);box-shadow:var(--ez-popover__box--box-shadow)}.popover__box--fit-content{width:fit-content}.popover__box--full-width{width:calc(100% - 10px)}";export{a as ez_multi_selection_list,ht as ez_popover_plus}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/ezui",
3
- "version": "5.22.0-dev.88",
3
+ "version": "5.22.0-dev.89",
4
4
  "description": "Biblioteca de componentes Sankhya.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/custom-elements/index.js",
@@ -1 +0,0 @@
1
- import{r as t,c as e,h as i,F as n,H as o,g as s}from"./p-23a36bb6.js";import{ArrayUtils as r}from"@sankhyalabs/core";var l;!function(t){t.DATASOURCE_RESULTS="DATASOURCE_RESULTS",t.DATASOURCE_RESULTS_EMPTY="DATASOURCE_RESULTS_EMPTY",t.DATASOURCE_INIT="DATASOURCE_INIT",t.OPTIONS_EMPTY="OPTIONS_EMPTY",t.OPTIONS="OPTIONS"}(l||(l={}));const a=class{constructor(i){t(this,i),this.changeFilteredOptions=e(this,"changeFilteredOptions",7),this.columnName=void 0,this.dataSource=void 0,this.useOptions=!1,this.options=void 0,this.isTextSearch=!1,this.filteredOptions=void 0,this.displayOptions=void 0,this.viewScenario=void 0,this.displayOptionToCheckAllItems=!0}async clearFilteredOptions(){this.setInitialScenario(),this.filteredOptions=[],this.searchInput&&(this.searchInput.value=""),this.filterInput&&(this.filterInput.value="")}onChangeUseOptions(){this.setInitialScenario()}onChangeOptions(){this.options&&(this.filteredOptions=this.ordenationByCheckStateAndAlphabetically(this.options)),this.checkInput&&this.changeCheckAllValeuFromFilteredOptions(),this.setInitialScenario()}onChangeFilteredOptions(t){this.displayOptions=this.filteredOptions,this.displayOptionToCheckAllItems=this.filteredOptions.length>1,this.checkInput&&this.changeCheckAllValeuFromFilteredOptions(),this.changeFilteredOptions.emit(t)}componentDidRender(){this.changeCheckAllValeuFromFilteredOptions()}ordenationByCheckStateAndAlphabetically(t){const e=[],i=[];let n;return t.forEach((t=>{null==t.value||""===t.label?n=Object.assign(Object.assign({},t),{label:"(Vazio)"}):t.check?e.push(t):i.push(t)})),(null==n?[]:[n]).concat(null==this.dataSource?r.sortAlphabetically(e):this.dataSource.sortItems(this.columnName,e)).concat(null==this.dataSource?r.sortAlphabetically(i):this.dataSource.sortItems(this.columnName,i))}changeCheckAllValeuFromFilteredOptions(){var t,e,i,n;const o=null===(t=this.filteredOptions)||void 0===t?void 0:t.every((t=>!0===t.check)),s=null===(e=this.filteredOptions)||void 0===e?void 0:e.every((t=>!1===t.check)),r=(null===(i=this.filteredOptions)||void 0===i?void 0:i.some((t=>!1===t.check)))&&(null===(n=this.filteredOptions)||void 0===n?void 0:n.some((t=>!0===t.check)))&&(!o||!s);return this.checkInput&&o?(this.checkInput.indeterminate=!1,void(this.checkInput.value=!0)):this.checkInput&&r?(this.checkInput.indeterminate=!0,void(this.checkInput.value=!1)):this.checkInput&&s?(this.checkInput.indeterminate=!1,void(this.checkInput.value=!1)):void 0}setInitialScenario(){if(this.useOptions)return this.viewScenario=l.OPTIONS,void this.changeCheckAllValeuFromFilteredOptions();this.viewScenario=this.options&&this.options.length>0?l.DATASOURCE_RESULTS:l.DATASOURCE_INIT}async searchWithDataSource(t,e){const{argument:i,mode:n}=t;if("PRELOAD"!==n&&e)return this.dataSource.fetchData(i,e)}handleSearchOnDataSource(t){var e;const i=null!==(e=this.filteredOptions)&&void 0!==e?e:[];t.detail&&!i.some((e=>e.value==t.detail.value))&&(this.filteredOptions=this.ordenationByCheckStateAndAlphabetically([...i,t.detail])),this.viewScenario=l.DATASOURCE_RESULTS,this.searchInput.value=""}handleRemoveItemFromOptions(t){this.filteredOptions=this.ordenationByCheckStateAndAlphabetically(this.filteredOptions.filter((e=>e.value!==t.value))),0===this.filteredOptions.length&&(this.viewScenario=l.DATASOURCE_INIT),this.searchInput&&(this.searchInput.value="")}handleSearchOnOption(t){if(t.detail)return this.displayOptions=r.applyStringFilter(t.detail,this.filteredOptions,!0),void(this.viewScenario=0===this.displayOptions.length?l.OPTIONS_EMPTY:l.OPTIONS);this.displayOptions=this.filteredOptions,this.viewScenario=l.OPTIONS}handleChangeSelectAllItems(t){this.filteredOptions=this.ordenationByCheckStateAndAlphabetically([...this.filteredOptions.map((e=>(e.check=!!t.detail,e)))])}handleChangeSelectedItem(t){const{detail:e}=t;this.filteredOptions.find((t=>t.label===e.label)).check=e.check}buildViewList(t){return i(n,null,this.displayOptionToCheckAllItems&&i("ez-check",{ref:t=>this.checkInput=t,label:"Selecionar todos",class:"multi-selection__select-all",onEzChange:this.handleChangeSelectAllItems.bind(this)}),i("ez-list",{class:"multi-selection__list",dataSource:this.displayOptions,listMode:"check",hoverFeedback:!0,onEzCheckChange:this.handleChangeSelectedItem.bind(this),itemSlotBuilder:t?this.buildDeleteIconSlot.bind(this):null}))}buildDeleteIconSlot(t){return i("ez-icon",{style:{cursor:"pointer"},iconName:"delete",onClick:()=>this.handleRemoveItemFromOptions(t)})}buildInitViewWithDataSource(){return i("multi-selection-box-message",{message:"Selecione os valores a serem filtrados através do campo de busca."})}buildViewEmptyResults(){return i("multi-selection-box-message",{message:"Nenhum resultado encontrado."})}scenarioToDisplay(t){const e={[l.DATASOURCE_INIT]:()=>this.buildInitViewWithDataSource(),[l.DATASOURCE_RESULTS]:()=>this.buildViewList(!0),[l.DATASOURCE_RESULTS_EMPTY]:()=>this.buildViewEmptyResults(),[l.OPTIONS_EMPTY]:()=>this.buildViewEmptyResults(),[l.OPTIONS]:()=>this.buildViewList(!1)}[t];return e?e():void 0}render(){return i(o,null,i("div",{class:"multi-selection"},this.useOptions?i("ez-filter-input",{ref:t=>this.filterInput=t,label:"Buscar..",onEzChange:this.handleSearchOnOption.bind(this)}):i("ez-search",{class:"multi-selection__input",label:"Buscar...",ref:t=>this.searchInput=t,suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,optionLoader:t=>this.searchWithDataSource(t,this.columnName),onEzChange:this.handleSearchOnDataSource.bind(this),isTextSearch:this.isTextSearch}),i("ez-scroll",{class:"multi-selection__content-options"},this.scenarioToDisplay(this.viewScenario))))}static get watchers(){return{useOptions:["onChangeUseOptions"],options:["onChangeOptions"],filteredOptions:["onChangeFilteredOptions"]}}};a.style=".sc-ez-multi-selection-list-h{--ez-check--outter-gap:0px;--ez-multi-selection-default-height:322px;display:block;width:304px;height:var(--ez-multi-selection-default-height);min-height:fit-content;max-height:calc(100vh - 350px)}.multi-selection__input.sc-ez-multi-selection-list{margin-bottom:var(--space--2xs, 8px)}.multi-selection__content-options.sc-ez-multi-selection-list{position:relative;left:-4px}.multi-selection__select-all.sc-ez-multi-selection-list{height:var(--space--xl);margin:0 var(--space--small, 6px)}.multi-selection__list.sc-ez-multi-selection-list{max-height:calc(100vh - 435px);overflow-y:auto;overflow-x:clip}.multi-selection__list.sc-ez-multi-selection-list::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";const c=Math.min,h=Math.max,u=Math.round,d=t=>({x:t,y:t}),f={left:"right",right:"left",bottom:"top",top:"bottom"},p={start:"end",end:"start"};function m(t,e,i){return h(t,c(e,i))}function v(t,e){return"function"==typeof t?t(e):t}function b(t){return t.split("-")[0]}function g(t){return t.split("-")[1]}function y(t){return"x"===t?"y":"x"}function x(t){return"y"===t?"height":"width"}function w(t){return["top","bottom"].includes(b(t))?"y":"x"}function _(t){return y(w(t))}function z(t){return t.replace(/start|end/g,(t=>p[t]))}function O(t){return t.replace(/left|right|bottom|top/g,(t=>f[t]))}function S(t){const{x:e,y:i,width:n,height:o}=t;return{width:n,height:o,top:i,left:e,right:e+n,bottom:i+o,x:e,y:i}}function k(t,e,i){let{reference:n,floating:o}=t;const s=w(e),r=_(e),l=x(r),a=b(e),c="y"===s,h=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,d=n[l]/2-o[l]/2;let f;switch(a){case"top":f={x:h,y:n.y-o.height};break;case"bottom":f={x:h,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:u};break;case"left":f={x:n.x-o.width,y:u};break;default:f={x:n.x,y:n.y}}switch(g(e)){case"start":f[r]-=d*(i&&c?-1:1);break;case"end":f[r]+=d*(i&&c?-1:1)}return f}async function C(t,e){var i;void 0===e&&(e={});const{x:n,y:o,platform:s,rects:r,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=v(e,t),p=function(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}(f),m=l[d?"floating"===u?"reference":"floating":u],b=S(await s.getClippingRect({element:null==(i=await(null==s.isElement?void 0:s.isElement(m)))||i?m:m.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:h,strategy:a})),g="floating"===u?{x:n,y:o,width:r.floating.width,height:r.floating.height}:r.reference,y=await(null==s.getOffsetParent?void 0:s.getOffsetParent(l.floating)),x=await(null==s.isElement?void 0:s.isElement(y))&&await(null==s.getScale?void 0:s.getScale(y))||{x:1,y:1},w=S(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:g,offsetParent:y,strategy:a}):g);return{top:(b.top-w.top+p.top)/x.y,bottom:(w.bottom-b.bottom+p.bottom)/x.y,left:(b.left-w.left+p.left)/x.x,right:(w.right-b.right+p.right)/x.x}}function A(){return"undefined"!=typeof window}function P(t){return E(t)?(t.nodeName||"").toLowerCase():"#document"}function R(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function T(t){var e;return null==(e=(E(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function E(t){return!!A()&&(t instanceof Node||t instanceof R(t).Node)}function D(t){return!!A()&&(t instanceof Element||t instanceof R(t).Element)}function F(t){return!!A()&&(t instanceof HTMLElement||t instanceof R(t).HTMLElement)}function L(t){return!(!A()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof R(t).ShadowRoot)}function I(t){const{overflow:e,overflowX:i,overflowY:n,display:o}=U(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&!["inline","contents"].includes(o)}function B(t){return["table","td","th"].includes(P(t))}function N(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function V(t){const e=j(),i=D(t)?U(t):t;return"none"!==i.transform||"none"!==i.perspective||!!i.containerType&&"normal"!==i.containerType||!e&&!!i.backdropFilter&&"none"!==i.backdropFilter||!e&&!!i.filter&&"none"!==i.filter||["transform","perspective","filter"].some((t=>(i.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(i.contain||"").includes(t)))}function j(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function M(t){return["html","body","#document"].includes(P(t))}function U(t){return R(t).getComputedStyle(t)}function $(t){return D(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function G(t){if("html"===P(t))return t;const e=t.assignedSlot||t.parentNode||L(t)&&t.host||T(t);return L(e)?e.host:e}function W(t){const e=G(t);return M(e)?t.ownerDocument?t.ownerDocument.body:t.body:F(e)&&I(e)?e:W(e)}function Y(t,e,i){var n;void 0===e&&(e=[]),void 0===i&&(i=!0);const o=W(t),s=o===(null==(n=t.ownerDocument)?void 0:n.body),r=R(o);if(s){const t=H(r);return e.concat(r,r.visualViewport||[],I(o)?o:[],t&&i?Y(t):[])}return e.concat(o,Y(o,[],i))}function H(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X(t){const e=U(t);let i=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const o=F(t),s=o?t.offsetWidth:i,r=o?t.offsetHeight:n,l=u(i)!==s||u(n)!==r;return l&&(i=s,n=r),{width:i,height:n,$:l}}function q(t){return D(t)?t:t.contextElement}function J(t){const e=q(t);if(!F(e))return d(1);const i=e.getBoundingClientRect(),{width:n,height:o,$:s}=X(e);let r=(s?u(i.width):i.width)/n,l=(s?u(i.height):i.height)/o;return r&&Number.isFinite(r)||(r=1),l&&Number.isFinite(l)||(l=1),{x:r,y:l}}const K=d(0);function Q(t){const e=R(t);return j()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:K}function Z(t,e,i,n){void 0===e&&(e=!1),void 0===i&&(i=!1);const o=t.getBoundingClientRect(),s=q(t);let r=d(1);e&&(n?D(n)&&(r=J(n)):r=J(t));const l=function(t,e,i){return void 0===e&&(e=!1),!(!i||e&&i!==R(t))&&e}(s,i,n)?Q(s):d(0);let a=(o.left+l.x)/r.x,c=(o.top+l.y)/r.y,h=o.width/r.x,u=o.height/r.y;if(s){const t=R(s),e=n&&D(n)?R(n):n;let i=t,o=H(i);for(;o&&n&&e!==i;){const t=J(o),e=o.getBoundingClientRect(),n=U(o),s=e.left+(o.clientLeft+parseFloat(n.paddingLeft))*t.x,r=e.top+(o.clientTop+parseFloat(n.paddingTop))*t.y;a*=t.x,c*=t.y,h*=t.x,u*=t.y,a+=s,c+=r,i=R(o),o=H(i)}}return S({width:h,height:u,x:a,y:c})}function tt(t,e){const i=$(t).scrollLeft;return e?e.left+i:Z(T(t)).left+i}function et(t,e,i){void 0===i&&(i=!1);const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-(i?0:tt(t,n)),y:n.top+e.scrollTop}}function it(t,e,i){let n;if("viewport"===e)n=function(t,e){const i=R(t),n=T(t),o=i.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,a=0;if(o){s=o.width,r=o.height;const t=j();(!t||t&&"fixed"===e)&&(l=o.offsetLeft,a=o.offsetTop)}return{width:s,height:r,x:l,y:a}}(t,i);else if("document"===e)n=function(t){const e=T(t),i=$(t),n=t.ownerDocument.body,o=h(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=h(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let r=-i.scrollLeft+tt(t);const l=-i.scrollTop;return"rtl"===U(n).direction&&(r+=h(e.clientWidth,n.clientWidth)-o),{width:o,height:s,x:r,y:l}}(T(t));else if(D(e))n=function(t,e){const i=Z(t,!0,"fixed"===e),n=i.top+t.clientTop,o=i.left+t.clientLeft,s=F(t)?J(t):d(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:o*s.x,y:n*s.y}}(e,i);else{const i=Q(t);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return S(n)}function nt(t,e){const i=G(t);return!(i===e||!D(i)||M(i))&&("fixed"===U(i).position||nt(i,e))}function ot(t,e,i){const n=F(e),o=T(e),s="fixed"===i,r=Z(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=d(0);if(n||!n&&!s)if(("body"!==P(e)||I(o))&&(l=$(e)),n){const t=Z(e,!0,s,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else o&&(a.x=tt(o));const c=!o||n||s?d(0):et(o,l);return{x:r.left+l.scrollLeft-a.x-c.x,y:r.top+l.scrollTop-a.y-c.y,width:r.width,height:r.height}}function st(t){return"static"===U(t).position}function rt(t,e){if(!F(t)||"fixed"===U(t).position)return null;if(e)return e(t);let i=t.offsetParent;return T(t)===i&&(i=i.ownerDocument.body),i}function lt(t,e){const i=R(t);if(N(t))return i;if(!F(t)){let e=G(t);for(;e&&!M(e);){if(D(e)&&!st(e))return e;e=G(e)}return i}let n=rt(t,e);for(;n&&B(n)&&st(n);)n=rt(n,e);return n&&M(n)&&st(n)&&!V(n)?i:n||function(t){let e=G(t);for(;F(e)&&!M(e);){if(V(e))return e;if(N(e))return null;e=G(e)}return null}(t)||i}const at={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:n,strategy:o}=t;const s="fixed"===o,r=T(n),l=!!e&&N(e.floating);if(n===r||l&&s)return i;let a={scrollLeft:0,scrollTop:0},c=d(1);const h=d(0),u=F(n);if((u||!u&&!s)&&(("body"!==P(n)||I(r))&&(a=$(n)),F(n))){const t=Z(n);c=J(n),h.x=t.x+n.clientLeft,h.y=t.y+n.clientTop}const f=!r||u||s?d(0):et(r,a,!0);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-a.scrollLeft*c.x+h.x+f.x,y:i.y*c.y-a.scrollTop*c.y+h.y+f.y}},getDocumentElement:T,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t;const s=[..."clippingAncestors"===i?N(e)?[]:function(t,e){const i=e.get(t);if(i)return i;let n=Y(t,[],!1).filter((t=>D(t)&&"body"!==P(t))),o=null;const s="fixed"===U(t).position;let r=s?G(t):t;for(;D(r)&&!M(r);){const e=U(r),i=V(r);i||"fixed"!==e.position||(o=null),(s?!i&&!o:!i&&"static"===e.position&&o&&["absolute","fixed"].includes(o.position)||I(r)&&!i&&nt(t,r))?n=n.filter((t=>t!==r)):o=e,r=G(r)}return e.set(t,n),n}(e,this._c):[].concat(i),n],r=s.reduce(((t,i)=>{const n=it(e,i,o);return t.top=h(n.top,t.top),t.right=c(n.right,t.right),t.bottom=c(n.bottom,t.bottom),t.left=h(n.left,t.left),t}),it(e,s[0],o));return{width:r.right-r.left,height:r.bottom-r.top,x:r.left,y:r.top}},getOffsetParent:lt,getElementRects:async function(t){const e=this.getOffsetParent||lt,i=this.getDimensions,n=await i(t.floating);return{reference:ot(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:i}=X(t);return{width:e,height:i}},getScale:J,isElement:D,isRTL:function(t){return"rtl"===U(t).direction}},ct=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:n,placement:o}=e,{mainAxis:s=!0,crossAxis:r=!1,limiter:l={fn:t=>{let{x:e,y:i}=t;return{x:e,y:i}}},...a}=v(t,e),c={x:i,y:n},h=await C(e,a),u=w(b(o)),d=y(u);let f=c[d],p=c[u];s&&(f=m(f+h["y"===d?"top":"left"],f,f-h["y"===d?"bottom":"right"])),r&&(p=m(p+h["y"===u?"top":"left"],p,p-h["y"===u?"bottom":"right"]));const g=l.fn({...e,[d]:f,[u]:p});return{...g,data:{x:g.x-i,y:g.y-n,enabled:{[d]:s,[u]:r}}}}}},ht=class{constructor(i){t(this,i),this.ezVisibilityChange=e(this,"ezVisibilityChange",7),this.TIME_DEBOUNCE=500,this.autoClose=!0,this.boxWidth="fit-content",this.opened=!1,this.overlayType="light",this.anchorElement=void 0,this.options={horizontalGap:0,verticalGap:0,fromRight:!1}}async observeOpened(t,e){if(t!==e)return t?this.openPopover():this.hidePopover(),void this.ezVisibilityChange.emit(t)}async updatePosition(t,e){this.updateOptionPosition(t,e),await this.updatePositionPopover()}async show(t,e){this.updateOptionPosition(t,e),this.opened=!0}async showUnder(t,e){e&&(this.options=e),this.anchorElement=t,this.opened=!0}async hide(){this.opened=!1}async setOptions(t){Object.assign(this.options,t)}async setAnchorElement(t){this.anchorElement=t}parseSizePixel(t,e){return t?"string"==typeof t?Number(t.replace("px","")):null!=t?t:0:null!=e?e:0}updateOptionPosition(t,e){Object.assign(this.options,{horizontalGap:this.parseSizePixel(e,this.options.horizontalGap),verticalGap:this.parseSizePixel(t,this.options.verticalGap)})}async updatePositionPopover(){var t;this._box&&this.opened&&(this.anchorElement||(this.anchorElement=this._host),"string"==typeof this.anchorElement&&(this.anchorElement=document.getElementById(this.anchorElement)),await((t,e,i)=>{const n=new Map,o={platform:at,...i},s={...o.platform,_c:n};return(async(t,e,i)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:r}=i,l=s.filter(Boolean),a=await(null==r.isRTL?void 0:r.isRTL(e));let c=await r.getElementRects({reference:t,floating:e,strategy:o}),{x:h,y:u}=k(c,n,a),d=n,f={},p=0;for(let i=0;i<l.length;i++){const{name:s,fn:m}=l[i],{x:v,y:b,data:g,reset:y}=await m({x:h,y:u,initialPlacement:n,placement:d,strategy:o,middlewareData:f,rects:c,platform:r,elements:{reference:t,floating:e}});h=null!=v?v:h,u=null!=b?b:u,f={...f,[s]:{...f[s],...g}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await r.getElementRects({reference:t,floating:e,strategy:o}):y.rects),({x:h,y:u}=k(c,d,a))),i=-1)}return{x:h,y:u,placement:d,strategy:o,middlewareData:f}})(t,e,{...o,platform:s})})(this.anchorElement,this._box,{placement:this.options.fromRight?"bottom-end":"bottom-start",middleware:[(void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var i,n;const{placement:o,middlewareData:s,rects:r,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...y}=v(t,e);if(null!=(i=s.arrow)&&i.alignmentOffset)return{};const S=b(o),k=w(l),A=b(l)===l,P=await(null==a.isRTL?void 0:a.isRTL(c.floating)),R=d||(A||!m?[O(l)]:function(t){const e=O(t);return[z(t),e,z(e)]}(l)),T="none"!==p;!d&&T&&R.push(...function(t,e,i,n){const o=g(t);let s=function(t,e,i){const n=["left","right"],o=["right","left"],s=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return i?e?o:n:e?n:o;case"left":case"right":return e?s:r;default:return[]}}(b(t),"start"===i,n);return o&&(s=s.map((t=>t+"-"+o)),e&&(s=s.concat(s.map(z)))),s}(l,m,p,P));const E=[l,...R],D=await C(e,y),F=[];let L=(null==(n=s.flip)?void 0:n.overflows)||[];if(h&&F.push(D[S]),u){const t=function(t,e,i){void 0===i&&(i=!1);const n=g(t),o=_(t),s=x(o);let r="x"===o?n===(i?"end":"start")?"right":"left":"start"===n?"bottom":"top";return e.reference[s]>e.floating[s]&&(r=O(r)),[r,O(r)]}(o,r,P);F.push(D[t[0]],D[t[1]])}if(L=[...L,{placement:o,overflows:F}],!F.every((t=>t<=0))){var I,B;const t=((null==(I=s.flip)?void 0:I.index)||0)+1,e=E[t];if(e)return{data:{index:t,overflows:L},reset:{placement:e}};let i=null==(B=L.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:B.placement;if(!i)switch(f){case"bestFit":{var N;const t=null==(N=L.filter((t=>{if(T){const e=w(t.placement);return e===k||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:N[0];t&&(i=t);break}case"initialPlacement":i=l}if(o!==i)return{reset:{placement:i}}}return{}}}),ct({padding:5})],strategy:"fixed"}).then((({x:t,y:e,placement:i})=>{const n=i.includes("bottom")?e+this.options.verticalGap:e-this.options.verticalGap,o=i.includes("start")?t+this.options.horizontalGap:t-this.options.horizontalGap;Object.assign(this._box.style,{top:`${n}px`,left:`${o}px`})})))}hidePopover(){this._box&&(this._box.style.display="",this.hideOverlay(),this.ezVisibilityChange.emit(!1))}async openPopover(){this._box&&(this._box.style.display="flex",this._box.style.visibility="hidden",await this.updatePositionPopover(),this.openOverlay(),this.ezVisibilityChange.emit(!0),this._box.style.visibility="visible")}openOverlay(){this._overlay&&this._overlayIsActive&&(this._overlay.style.display="block")}hideOverlay(){this._overlay&&(this._overlay.style.display="none")}checkStatusOverlay(){return"none"!==this.overlayType||!("none"!==this.overlayType||!this.autoClose)}updatePositionDebounce(){this.opened&&(clearTimeout(this._timeoutDebounce),this._timeoutDebounce=setTimeout((()=>{this.updatePositionPopover()}),this.TIME_DEBOUNCE))}componentWillLoad(){window.addEventListener("scroll",this.updatePositionDebounce.bind(this),!0),window.addEventListener("resize",this.updatePositionDebounce.bind(this),!0)}componentDidLoad(){this._overlayIsActive=this.checkStatusOverlay(),this._resizeObserver=new ResizeObserver(this.updatePositionPopover.bind(this)),this._resizeObserver.observe(this._box)}disconnectedCallback(){window.removeEventListener("scroll",this.updatePositionDebounce.bind(this),!0),window.removeEventListener("resize",this.updatePositionDebounce.bind(this),!0),this._resizeObserver.disconnect()}render(){return i(o,null,i("div",{ref:t=>this._overlay=t,onClick:()=>this.hide(),class:`popover__overlay popover__overlay--${this.overlayType}`}),i("section",{ref:t=>this._box=t,class:{popover__box:!0,"popover__box--fit-content":"fit-content"===this.boxWidth,"popover__box--full-width":"fit-content"!==this.boxWidth}},i("slot",null)))}get _host(){return s(this)}static get watchers(){return{opened:["observeOpened"]}}};ht.style=":host{--ez-popover__box--border-radius:var(--border--radius-medium, 12px);--ez-popover__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-popover__box--background-color:var(--background--xlight, #fff);--ez-popover__box--z-index:var(--most-visible, 4);position:relative;display:flex;user-select:none}.popover__overlay{display:none;position:fixed;padding:0;top:0px;left:0px;width:100%;height:100vh;box-sizing:border-box;z-index:var(--more-visible--2x, 3)}.popover__overlay--light{background-color:rgba(var(--rgb-background--overlay), var(--opacity--bright))}.popover__overlay--medium{background-color:rgba(var(--rgb-background--overlay), var(--opacity--soft));backdrop-filter:blur(var(--background-blur--medium))}.popover__box{display:none;position:fixed;top:0;left:0;z-index:var(--ez-popover__box--z-index);flex-direction:column;height:fit-content;background-color:var(--ez-popover__box--background-color);border-radius:var(--ez-popover__box--border-radius);box-shadow:var(--ez-popover__box--box-shadow)}.popover__box--fit-content{width:fit-content}.popover__box--full-width{width:calc(100% - 10px)}";export{a as ez_multi_selection_list,ht as ez_popover_plus}