UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 12.7 kB
module.exports=function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}({0:function(e,t,o){o(1663),e.exports=o(1663)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},955:function(e,t){e.exports=require("../util/text-metrics")},970:function(e,t){e.exports=require("./range")},1641:function(e,t){e.exports=require("./sheet")},1656:function(e,t){e.exports=require("./references")},1663:function(e,t,o){var r,n,i;!function(a,define){n=[o(1664),o(1641),o(970),o(1656),o(1665),o(955)],r=a,i="function"==typeof r?r.apply(t,n):r,!(void 0!==i&&(e.exports=i))}(function(){"use strict";function e(e,t,o,r,n){var i=0,a=[],l=t,c=0;return t&&o&&(o*=t),e.forEach(function(e,d){null!=r&&d<r&&(c+=e),t&&i+e>l&&(l-i<o&&(i=t*Math.ceil(i/t)+c,c>0&&n.push(i-c)),l+=t*Math.ceil(e/t)),a.push(i),i+=e}),a.push(i),a}function t(t,r,d){var s,p,u,f,h,g,m,w,b,x,y,v,C,E,S,R,z,M,_=t._grid;return r=_.normalize(r),s=_.rectangle(r),p=[],t._drawings.forEach(function(e){var o=t.drawingBoundingBox(e);o.intersects(s)&&p.push({drawing:e,box:o.offset(-s.left,-s.top)})}),u=[],f=[],h=[],g=t._getMergedCells(r),m=-1,w=-1,t.forEach(r,function(e,o,n){var i,l,c,s=e-r.topLeft.row,b=o-r.topLeft.col,x=t.rowHeight(e),y=t.columnWidth(o);d.forScreen||(n.drawings=p.filter(function(r){var n=r.drawing.topLeftCell;if(n&&n.row==e&&n.col==o)return m=Math.max(m,t._rows.index(r.box.bottom)),w=Math.max(w,t._columns.index(r.box.right)),!0})),b||f.push(x),s||h.push(y),i=new k(e,o).print(),g.secondary[i]||(n.row=s,n.col=b,l=g.primary[i],l?(delete g.primary[i],n.merged=!0,n.rowspan=l.height(),n.colspan=l.width(),d.forScreen&&(n.width=t._columns.sum(l.topLeft.col,l.bottomRight.col),n.height=t._rows.sum(l.topLeft.row,l.bottomRight.row))):(n.rowspan=1,n.colspan=1),t._grid._columns.sum(o,o+n.colspan-1)&&t._grid._rows.sum(e,e+n.rowspan-1)&&(c=d.forScreen||a(n),(d.emptyCells||c)&&(c?(m=Math.max(m,s+n.rowspan-1),w=Math.max(w,b+n.colspan-1)):n.empty=!0,u.push(n))))}),d.forScreen||(f=f.slice(0,m+1),h=h.slice(0,w+1)),b=d.pageWidth,x=d.pageHeight,y=d.scale||1,d.fitWidth&&(v=h.reduce(n,0),v>b&&(y=b/v)),b=Math.ceil(b/y),x=Math.ceil(x/y),C=[],E=e(f,x||0,d.maxEmpty,d.headerRows,C),S=e(h,b||0,d.maxEmpty),R=0,z=0,M=[],u=u.filter(function(e){return(!e.empty||!(e.row>m||e.col>w))&&(d.headerRows&&e.row<d.headerRows&&M.push(e),e.left=S[e.col],e.top=E[e.row],e.merged?d.forScreen?(e.right=e.left+e.width,e.bottom=e.top+e.height):(e.right=i(S,e.col+e.colspan),e.bottom=i(E,e.row+e.rowspan),e.width=e.right-e.left,e.height=e.bottom-e.top):(e.width=h[e.col],e.height=f[e.row],e.bottom=e.top+e.height,e.right=e.left+e.width),d.forScreen||e.drawings.forEach(function(t){var o=t.box;o.left=e.left+t.drawing.offsetX,o.top=e.top+t.drawing.offsetY,o.right=o.left+o.width,o.bottom=o.top+o.height}),R=Math.max(R,e.right),z=Math.max(z,e.bottom),!0)}),Object.keys(g.primary).forEach(function(e){var o=g.primary[e];t.forEach(o.topLeft.toRangeRef(),function(e,n,i){var a=e-r.topLeft.row,l=n-r.topLeft.col;i.merged=!0,i.colspan=o.width(),i.rowspan=o.height(),i.top=a<0?-t._rows.sum(e,e-a-1):E[a],i.left=l<0?-t._columns.sum(n,n-l-1):S[l],i.height=t._rows.sum(o.topLeft.row,o.bottomRight.row),i.width=t._columns.sum(o.topLeft.col,o.bottomRight.col),i.height>0&&i.width>0&&(i.right=i.left+i.width,i.bottom=i.top+i.height,i.row=a,i.col=l,u.push(i))})}),d.headerRows&&(C.forEach(function(e){M.forEach(function(t){t=o(t),t.top+=e,t.bottom=t.top+t.height,u.push(t)}),E.push(e)}),E.sort(c)),{width:R,height:z,cells:u.sort(l),scale:y,xCoords:S,yCoords:E,drawings:p}}function o(e,t){return t||(t={}),Object.assign?Object.assign(t,e):Object.keys(e).reduce(function(t,o){return t[o]=e[o],t},t)}function r(e,t){return e.size===t.size&&e.color===t.color}function n(e,t){return e+t}function i(e,t){return t<e.length?e[t]:e[e.length-1]}function a(e){return null!=e.value||e.merged||null!=e.background||null!=e.borderRight||null!=e.borderBottom||null!=e.validation&&!e.validation.value||e.drawings&&e.drawings.length}function l(e,t){return e.top<t.top?-1:e.top==t.top?e.left<t.left?-1:e.left==t.left?0:1:1}function c(e,t){return e<t?-1:e>t?1:0}function d(e,t,o,r){function n(n,i){function a(e){return!(e.right<=w||e.left>=b||e.bottom<=x||e.top>=y)&&(v=Math.max(e.bottom,v),k=Math.max(e.right,k),!0)}var l,c,u,f,h,g,w=i*d,b=w+d,x=n*p,y=x+p,v=0,k=0,E=t.cells.filter(a),z=t.drawings.filter(function(e){return a(e.box)});v=Math.min(v,y),k=Math.min(k,b),(E.length||z.length)&&(l=new C.Group,o.append(l),c=new C.Group,l.append(c),c.clip(C.Path.fromRect(new S.Rect([w-1,x-1],[k+1,v+1]))),u=S.Matrix.scale(t.scale,t.scale).multiplyCopy(S.Matrix.translate(-w,-x)),(r.hCenter||r.vCenter)&&(u=u.multiplyCopy(S.Matrix.translate(r.hCenter?(b-k)/2:0,r.vCenter?(y-v)/2:0))),c.transform(u),r.guidelines&&(f=null,t.xCoords.forEach(function(e){e=Math.min(e,k),e!==f&&e>=w&&e<=b&&(f=e,c.append((new C.Path).moveTo(e,x).lineTo(e,v).close().stroke(r.guideColor,R)))}),f=null,t.yCoords.forEach(function(e){e=Math.min(e,v),e!==f&&e>=x&&e<=y&&(f=e,c.append((new C.Path).moveTo(w,e).lineTo(k,e).close().stroke(r.guideColor,R)))})),h=m(),E.forEach(function(t){s(t,c,r),h.add(t,e)}),g=new C.Group,h.vert.forEach(function(e){e.forEach(function(e){e.rendered||(e.rendered=!0,g.append((new C.Path).moveTo(e.x,e.top).lineTo(e.x,e.bottom).close().stroke(e.color,e.size)))})}),h.horiz.forEach(function(e){e.forEach(function(e){e.rendered||(e.rendered=!0,g.append((new C.Path).moveTo(e.left,e.y).lineTo(e.right,e.y).close().stroke(e.color,e.size)))})}),c.append(g),z.forEach(function(t){var o,r,n=t.drawing,i=n.image;null!=i&&(o=t.box,r=e._workbook.imageUrl(i),c.append(new C.Image(r,new S.Rect([o.left,o.top],[o.width,o.height])).opacity(n.opacity)))}))}var i,a,l=Math.ceil(t.width/r.pageWidth),c=Math.ceil(t.height/r.pageHeight),d=Math.ceil(r.pageWidth/t.scale),p=Math.ceil(r.pageHeight/t.scale);for(i=0;i<c;++i)for(a=0;a<l;++a)n(i,a)}function s(e,t,o){var r,n,i,a,l,c,d,s=new C.Group;if(t.append(s),r=new S.Rect([e.left,e.top],[e.width,e.height]),(e.background||e.merged)&&(n=r,o.guidelines&&(n=r.clone(),n.origin.x+=R/2+.1,n.origin.y+=R/2+.1,n.size.width-=R+.2,n.size.height-=R+.2),s.append(new C.Rect(n).fill(e.background||"#fff").stroke(null))),i=e.value,null!=i){if(a="number"==typeof i?"number":null,l=new C.Group,l.clip(C.Path.fromRect(r)),s.append(l),d=e.format,d||"number"!=a||i==Math.floor(i)||(d="0.##############"),d?(c=E.textAndColor(i,d),i=c.text,c.type&&(a=c.type)):i+="",!e.textAlign)switch(a){case"number":case"date":case"percent":case"currency":e.textAlign="right";break;case"boolean":e.textAlign="center"}u(i,c&&c.color||e.color||"#000",e,l)}}function p(e,t){if(e.indent){var o=1.4*e.indent;switch(t.textAlign){case null:case"left":t.paddingLeft=o+"ch";break;case"right":t.paddingRight=o+"ch";break;case"center":t.paddingLeft=o/2+"ch",t.paddingRight=o/2+"ch"}}}function u(e,t,o,r){var n,i;switch(b||(b=document.createElement("div"),b.style.position="fixed",b.style.left="0px",b.style.top="0px",b.style.visibility="hidden",b.style.overflow="hidden",b.style.boxSizing="border-box",b.style.lineHeight="normal",document.body.appendChild(b)),b.firstChild&&b.removeChild(b.firstChild),b.style.padding="2px 4px",b.style.color=t,b.style.font=f(o),b.style.width=o.width+"px",b.style.textAlign=o.textAlign||"left",b.style.textDecoration=o.underline?"underline":"none",p(o,b.style),o.wrap?(b.style.whiteSpace="pre-wrap",b.style.overflowWrap=b.style.wordWrap="break-word"):(b.style.whiteSpace="pre",b.style.overflowWrap=b.style.wordWrap="normal"),b.appendChild(document.createTextNode(e)),n=0,o.verticalAlign){case"center":n=o.height-b.offsetHeight>>1;break;case void 0:case null:case"bottom":n=o.height-b.offsetHeight}n<0&&(n=0),i=kendo.drawing.drawDOM.drawText(b),i.transform(S.Matrix.translate(o.left,o.top+n)),r.append(i)}function f(e){var t=[];return e.italic&&t.push("italic"),e.bold&&t.push("bold"),t.push((e.fontSize||12)+"px"),t.push(e.fontFamily||"Arial"),t.join(" ")}function h(e,o,r,n){var i,a,l,c,s;null==r&&null==n&&(n=o,r={},o=v.SHEETREF),null==n&&(n=r,o instanceof v.Range||o instanceof v.Ref||"string"==typeof o?r={}:(r=o,o=v.SHEETREF)),r=kendo.jQuery.extend({paperSize:"A4",landscape:!0,margin:"1cm",guidelines:!0,guideColor:"#aaa",emptyCells:!0,fitWidth:!1,center:!1,headerRows:null,maxEmpty:.2,scale:1},r),i=new C.Group,a=kendo.pdf.getPaperOptions(r),i.options.set("pdf",{author:r.author,creator:r.creator,date:r.date,keywords:r.keywords,margin:a.margin,multiPage:!0,paperSize:a.paperSize,subject:r.subject,title:r.title,autoPrint:r.autoPrint}),l=a.paperSize[0],c=a.paperSize[1],a.margin&&(l-=a.margin.left+a.margin.right+1,c-=a.margin.top+a.margin.bottom+1),r.pageWidth=l,r.pageHeight=c,s=t(e,e._ref(o),r),d(e,s,i,r),n(i)}function g(){}function m(){function e(e,r){var n,i;r&&(n=r._properties,i=r._grid,e.borderLeft=n.get("vBorders",i.index(e.row,e.col)),e.borderRight=n.get("vBorders",i.index(e.row,e.col+e.colspan)),e.borderTop=n.get("hBorders",i.index(e.row,e.col)),e.borderBottom=n.get("hBorders",i.index(e.row+e.rowspan,e.col))),e.borderLeft&&t(e.row,e.col,e.borderLeft,e.left,e.top,e.bottom),e.borderRight&&t(e.row,e.col+e.colspan,e.borderRight,e.right,e.top,e.bottom),e.borderTop&&o(e.row,e.col,e.borderTop,e.top,e.left,e.right),e.borderBottom&&o(e.row+e.rowspan,e.col,e.borderBottom,e.bottom,e.left,e.right)}function t(e,t,o,n,a,l){var c=i[t]||(i[t]=new g),d=e>0&&c[e-1];d&&r(d,o)?(c[e]=d,d.bottom=l):c[e]={size:o.size,color:o.color,x:n,top:a,bottom:l}}function o(e,t,o,i,a,l){var c=n[e]||(n[e]=new g),d=t>0&&c[t-1];d&&r(d,o)?(c[t]=d,d.right=l):c[t]={size:o.size,color:o.color,y:i,left:a,right:l}}var n=new g,i=new g;return{add:e,horiz:n,vert:i}}function w(e){function t(e){var t,o;if(null!=e){for(t=12,o=e.length;--o>=0;)t+=n(e.charAt(o));return t}return 0}function r(e){return i?o(e,{borderLeft:i,borderTop:i,borderRight:i,borderBottom:i}):e}var n,i,a=new $.Deferred,l=a.promise();return e=o(e,{dataSource:null,guidelines:!0,guideColor:"#000",columns:null,headerBackground:"#999",headerColor:"#000",oddBackground:null,evenBackground:null,fontFamily:"Arial",fontSize:12,paperSize:"A4",margin:"1cm",landscape:!0,fitWidth:!1,scale:1,rowHeight:20,maxEmpty:1,useGridFormat:!0}),kendo.drawing.pdf.defineFont(kendo.drawing.drawDOM.getFontFaces(document)),n=y(e.fontFamily,e.fontSize),i=e.guidelines?{size:1,color:e.guideColor}:null,e.dataSource.fetch(function(){var o,n,i,l,c,d=e.dataSource.data();return d.length?(o=e.columns.map(function(e){return"string"==typeof e?{title:e,field:e}:e}),n=o.map(function(e){return e.title||e.field}),i=n.map(t),l=d.map(function(n,a){return{cells:o.map(function(o,l){var c=n[o.field];return e.useGridFormat&&(null!=c&&(o.format?c=kendo.format(o.format,c):c+=""),i[l]=Math.max(t(c),i[l])),r({value:c,format:e.useGridFormat?null:o.format,background:a%2?e.evenBackground:e.oddBackground})})}}),l.unshift({cells:n.map(function(t){return r({value:t,background:e.headerBackground,color:e.headerColor})})}),c=new kendo.spreadsheet.Sheet(l.length+1,o.length+1,e.rowHeight,50,20,20,{fontFamily:e.fontFamily,fontSize:e.fontSize,verticalAlign:"center"}),c.fromJSON({name:"Sheet1",rows:l,columns:i.map(function(e,t){return{index:t,width:e}})}),void c.draw({paperSize:e.paperSize,landscape:e.landscape,margin:e.margin,guidelines:!1,scale:e.scale,fitWidth:e.fitWidth,maxEmpty:e.maxEmpty,headerRows:1},a.resolve.bind(a))):a.reject("Empty dataset")}),l}var b,x,y,v=kendo.spreadsheet,k=v.CellRef,C=kendo.drawing,E=v.formatting,S=kendo.geometry,R=.8;v.Sheet.prototype.draw=function(e,t,o){var r=this;r._workbook?r.recalc(r._workbook._context,function(){h(r,e,t,o)}):h(r,e,t,o)},g.prototype={forEach:function(e){Object.keys(this).forEach(function(t){e(this[t],t,this)},this)}},x={},y=function(e,t){var o,r,n,i,a=t+":"+e,l=x[a];if(!l){for(r=document.createElement("div"),r.style.position="fixed",r.style.left="-10000px",r.style.top="-10000px",r.style.fontFamily=e,r.style.fontSize=t+"px",r.style.whiteSpace="pre",n=32;n<128;++n)o=document.createElement("span"),o.appendChild(document.createTextNode(String.fromCharCode(n))),r.appendChild(o);for(document.body.appendChild(r),i={},n=32,o=r.firstChild;n<128&&o;++n,o=o.nextSibling)i[n]=o.offsetWidth;for(;o=r.firstChild;)r.removeChild(o);l=x[a]=function(e){var t=e.charCodeAt(0),n=i[t];return null==n&&(o=document.createElement("span"),o.appendChild(document.createTextNode(String.fromCharCode(t))),r.appendChild(o),n=i[t]=o.offsetWidth,r.removeChild(o)),n}}return l},v.draw={Borders:m,doLayout:t,applyIndent:p},v.drawTabularData=w},o(3))},1664:function(e,t){e.exports=require("../kendo.pdf")},1665:function(e,t){e.exports=require("./numformat")}});