UNPKG

@progress/kendo-vue-grid

Version:
9 lines (8 loc) 3.91 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),o=require("@progress/kendo-vue-common"),c=require("@progress/kendo-vue-data-tools"),b=require("@progress/kendo-vue-intl"),T=require("../rows/GridRow.js"),I=require("../getRowContents.js"),l=require("../messages/main.js"),C=t.defineComponent({name:"PinnedRowsTable",props:{size:String,cols:Array,dataRowContext:Object,position:String,pinnedItems:Array,rowHeight:Number,rows:Object,selectable:Object},inject:{gridContext:{default:()=>({})},kendoLocalizationService:{default:null}},mounted(){this.tableRef=o.getRef(this,"table"),this.colGroupRefEl=o.getRef(this,"colGroup")},updated(){this.tableRef=o.getRef(this,"table"),this.colGroupRefEl=o.getRef(this,"colGroup")},methods:{setWidth(e){const a=o.getRef(this,"table");a&&(a.style.width=e?e+"px":"")},setScrollLeft(e){const a=o.getRef(this,"pinnedRef");a&&a.scrollLeft!==e&&(a.scrollLeft=e)}},setup(e){const a=t.inject("gridContext",{}),d=t.computed(()=>e.position==="top"),m=t.computed(()=>d.value?a.pinnedTopRef:a.pinnedBottomRef),w=t.ref(!1),g=i=>{const n=a.containerElementRef;if(!n||w.value)return;const s=i.currentTarget.scrollLeft;n.scrollLeft!==s&&(n.scrollLeft=s)},h=t.computed(()=>{if(!e.rows)return;const{pinnedData:i,...n}=e.rows;return i?{...n,data:i}:e.rows}),p=t.computed(()=>!e.pinnedItems||!e.dataRowContext?[]:e.pinnedItems.map((i,n)=>{var R;const s={dataItem:i,rowType:"data",level:0,expanded:!1,dataIndex:n},r=e.dataRowContext.dataItemKey,u="pinned_"+((r?o.getter(r)(i):void 0)||"ai"+n),f=I.getRowContents(e.dataRowContext,s,u,n);return(R=e.rows)!=null&&R.pinnedData?{...e.rows,data:e.rows.pinnedData}:e.rows,t.createVNode(T.GridRow,{key:u,rowType:"data",isPinned:!0,item:s,dataIndex:n,ariaRowIndex:n+1,absoluteRowIndex:n,isAltRow:n%2!==0,isHidden:!1,rowHeight:e.rowHeight,isSelected:f.isSelected,rows:h.value},{default:()=>[f.row]})})),S=t.computed(()=>o.classNames("k-grid-pinned-container",{"k-pos-bottom":!d.value})),y=t.computed(()=>o.classNames(o.uGrid.table({size:e.size}))),N=i=>{var s,r;const n=(s=e.pinnedItems)==null?void 0:s[i.startRowIndex];n&&((r=a.pinnedSelectionRelease)==null||r.call(a,i,n))},v=t.computed(()=>e.selectable?{...typeof e.selectable=="object"?e.selectable:{},enabled:!0,drag:!1}:e.selectable),L=t.computed(()=>d.value?c.tableKeyboardNavigationTopPinnedAttributes:c.tableKeyboardNavigationBottomPinnedAttributes);return{isTop:d,pinnedRef:m,handlePinnedScroll:g,pinnedRows:p,containerClassName:S,tableClassName:y,handleSelectionRelease:N,pinnedSelectable:v,pinnedBodyAttributes:L}},render(){return t.createVNode("div",{class:this.containerClassName,role:"presentation",style:this.pinnedRows.length?void 0:{display:"none"}},[t.createVNode("div",{class:"k-grid-pinned-wrap",ref:o.setRef(this,"pinnedRef"),onScroll:this.handlePinnedScroll},[t.createVNode(c.TableSelection,{selectable:this.pinnedSelectable,onRelease:this.handleSelectionRelease},{default:()=>[t.createVNode("table",{ref:o.setRef(this,"table"),class:this.tableClassName,"aria-label":this.isTop?b.provideLocalizationService(this).toLanguageString(l.pinnedTopRowsAriaLabel,l.messages[l.pinnedTopRowsAriaLabel]):b.provideLocalizationService(this).toLanguageString(l.pinnedBottomRowsAriaLabel,l.messages[l.pinnedBottomRowsAriaLabel])},[t.createVNode("colgroup",{ref:o.setRef(this,"colGroup")},[this.$props.cols]),t.createVNode("tbody",t.mergeProps({class:o.classNames(o.uGrid.tbody({}))},this.pinnedBodyAttributes),[this.pinnedRows])])]})])])}});exports.PinnedRowsTable=C;