@revolist/revogrid
Version:
Virtual reactive data grid spreadsheet component - RevoGrid.
4 lines • 1.79 kB
JavaScript
/*!
* Built by Revolist OU ❤️
*/
import{proxyCustomElement as t,HTMLElement as e,h as n,Host as s,transformTag as o}from"@stencil/core/internal/client";import{t as r}from"./throttle.js";import{T as i}from"./consts.js";import{a as p,s as a}from"./selection.utils.js";const g=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.onChange=r((t=>this.doChange(t)),300)}doChange(t){null==t||t.scrollIntoView({block:"nearest",inline:"nearest"})}componentDidRender(){this.el&&this.onChange(this.el)}render(){const t=this.selectionStore.get("tempRange"),e=this.selectionStore.get("tempRangeType");if(!t)return;let o="bottom",r="right";const g=this.getRange();if(!g)return;t.y<g.y&&(o="top"),t.x<g.x&&(r="left");const m=`${r} ${o}`,l=p(t,this.dimensionRow.state,this.dimensionCol.state),c=a(l);return n(s,Object.assign({},{class:{[i]:!0,[e||""]:!0},style:c,hidden:!1}),n("div",{class:m,ref:t=>this.el=t}))}getRange(){const t=this.selectionStore.get("range");if(t)return t;const e=this.selectionStore.get("focus");return e?Object.assign(Object.assign({},e),{x1:e.x,y1:e.y}):null}static get style(){return".temp-bg-range{display:block !important;position:absolute;pointer-events:none;z-index:9;border:1px solid rgb(255, 94, 0);box-sizing:border-box}.temp-bg-range.Selection{border:1px dashed gray}.temp-bg-range>div{width:1px;height:1px;position:absolute}.temp-bg-range>div.top{top:-1px}.temp-bg-range>div.bottom{bottom:-1px}.temp-bg-range>div.left{left:-1px}.temp-bg-range>div.right{right:-1px}"}},[0,"revogr-temp-range",{selectionStore:[16],dimensionRow:[16],dimensionCol:[16]}]);function m(){"undefined"!=typeof customElements&&["revogr-temp-range"].forEach((t=>{"revogr-temp-range"===t&&(customElements.get(o(t))||customElements.define(o(t),g))}))}export{g as R,m as d}