UNPKG

@revolist/revogrid

Version:

Virtual reactive data grid spreadsheet component - RevoGrid.

4 lines 2.37 kB
/*! * Built by Revolist OU ❤️ */ import{proxyCustomElement as t,HTMLElement as s,createEvent as e,h as o,Host as i,transformTag as n}from"@stencil/core/internal/client";import{F as r}from"./consts.js";import{a as l,s as c}from"./selection.utils.js";import{b as u}from"./data.store.js";import"./platform.js";const d=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.beforeFocusRender=e(this,"beforefocusrender",7),this.beforeScrollIntoView=e(this,"beforescrollintoview",7),this.afterFocus=e(this,"afterfocus",7),this.focusTemplate=null,this.activeFocus=null}componentDidRender(){var t,s;const e=this.selectionStore.get("focus");if(((null===(t=this.activeFocus)||void 0===t?void 0:t.x)!==(null==e?void 0:e.x)||(null===(s=this.activeFocus)||void 0===s?void 0:s.y)!==(null==e?void 0:e.y))&&(this.activeFocus=e,e&&this.el)){this.beforeScrollIntoView.emit({el:this.el}).defaultPrevented||this.el.scrollIntoView({block:"nearest",inline:"nearest"});const t=u(this.dataStore,e.y),s=u(this.colData,e.x);this.afterFocus.emit({model:t,column:s,rowType:this.rowType,colType:this.colType,rowIndex:e.y,colIndex:e.x})}}render(){var t;if(this.selectionStore.get("edit"))return;const s=this.selectionStore.get("focus");if(!s)return;const e=this.beforeFocusRender.emit({range:Object.assign(Object.assign({},s),{x1:s.x,y1:s.y}),rowType:this.rowType,colType:this.colType,rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)});if(e.defaultPrevented)return o("slot",null);const{detail:n}=e,u=l(n.range,e.detail.rowDimension,e.detail.colDimension),d=c(u),h=null===(t=this.focusTemplate)||void 0===t?void 0:t.call(this,o,n);return o(i,Object.assign({},{class:{[r]:!0},style:d}),o("slot",null),h)}get el(){return this}static get style(){return"revogr-focus.focused-cell{box-shadow:-1px 0 0 #0d63e8 inset, 1px 0 0 #0d63e8 inset, 0 -1px 0 #0d63e8 inset, 0 1px 0 #0d63e8 inset;position:absolute;pointer-events:none;z-index:9;display:block !important}"}},[260,"revogr-focus",{colType:[1,"col-type"],rowType:[1,"row-type"],selectionStore:[16],dimensionRow:[16],dimensionCol:[16],dataStore:[16],colData:[16],focusTemplate:[16]}]);function h(){"undefined"!=typeof customElements&&["revogr-focus"].forEach((t=>{"revogr-focus"===t&&(customElements.get(n(t))||customElements.define(n(t),d))}))}export{d as R,h as d}