@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 12.6 kB
JavaScript
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(1625),e.exports=o(1625)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},949:function(e,t){e.exports=require("../util/text-metrics")},964:function(e,t){e.exports=require("./range")},1603:function(e,t){e.exports=require("./sheet")},1618:function(e,t){e.exports=require("./references")},1625:function(e,t,o){var r,n,i;!function(a,define){n=[o(1626),o(1603),o(964),o(1618),o(1627),o(949)],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,d=0;return t&&o&&(o*=t),e.forEach(function(e,c){null!=r&&c<r&&(d+=e),t&&i+e>l&&(l-i<o&&(i=t*Math.ceil(i/t)+d,d>0&&n.push(i-d)),l+=t*Math.ceil(e/t)),a.push(i),i+=e}),a.push(i),a}function t(t,r,c){var p,u,s,f,h,g,m,w,b,x,y,v,C,E,S,R,z,M,T=t._grid;return r=T.normalize(r),p=T.rectangle(r),u=[],t._drawings.forEach(function(e){var o=t.drawingBoundingBox(e);o.intersects(p)&&u.push({drawing:e,box:o.offset(-p.left,-p.top)})}),s=[],f=[],h=[],g=t._getMergedCells(r),m=-1,w=-1,t.forEach(r,function(e,o,n){var i,l,d,p=e-r.topLeft.row,b=o-r.topLeft.col,x=t.rowHeight(e),y=t.columnWidth(o);c.forScreen||(n.drawings=u.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),p||h.push(y),!t.isHiddenColumn(o)&&!t.isHiddenRow(e)&&x&&y&&(i=c.forScreen||a(n),(c.emptyCells||i)&&(l=new k(e,o).print(),g.secondary[l]||(i?(m=Math.max(m,p),w=Math.max(w,b)):n.empty=!0,n.row=p,n.col=b,d=g.primary[l],d?(delete g.primary[l],n.merged=!0,n.rowspan=d.height(),n.colspan=d.width(),c.forScreen&&(n.width=t._columns.sum(d.topLeft.col,d.bottomRight.col),n.height=t._rows.sum(d.topLeft.row,d.bottomRight.row))):(n.rowspan=1,n.colspan=1),s.push(n))))}),f=f.slice(0,m+1),h=h.slice(0,w+1),b=c.pageWidth,x=c.pageHeight,y=c.scale||1,c.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,c.maxEmpty,c.headerRows,C),S=e(h,b||0,c.maxEmpty),R=0,z=0,M=[],s=s.filter(function(e){return(!e.empty||!(e.row>m||e.col>w))&&(c.headerRows&&e.row<c.headerRows&&M.push(e),e.left=S[e.col],e.top=E[e.row],e.merged?c.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),c.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,s.push(i))})}),c.headerRows&&(C.forEach(function(e){M.forEach(function(t){t=o(t),t.top+=e,t.bottom=t.top+t.height,s.push(t)}),E.push(e)}),E.sort(d)),{width:R,height:z,cells:s.sort(l),scale:y,xCoords:S,yCoords:E,drawings:u}}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 d(e,t){return e<t?-1:e>t?1:0}function c(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,d,s,f,h,g,w=i*c,b=w+c,x=n*u,y=x+u,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),d=new C.Group,l.append(d),d.clip(C.Path.fromRect(new S.Rect([w-1,x-1],[k+1,v+1]))),s=S.Matrix.scale(t.scale,t.scale).multiplyCopy(S.Matrix.translate(-w,-x)),(r.hCenter||r.vCenter)&&(s=s.multiplyCopy(S.Matrix.translate(r.hCenter?(b-k)/2:0,r.vCenter?(y-v)/2:0))),d.transform(s),r.guidelines&&(f=null,t.xCoords.forEach(function(e){e=Math.min(e,k),e!==f&&e>=w&&e<=b&&(f=e,d.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,d.append((new C.Path).moveTo(w,e).lineTo(k,e).close().stroke(r.guideColor,R)))})),h=m(),E.forEach(function(t){p(t,d,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)))})}),d.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),d.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),d=Math.ceil(t.height/r.pageHeight),c=Math.ceil(r.pageWidth/t.scale),u=Math.ceil(r.pageHeight/t.scale);for(i=0;i<d;++i)for(a=0;a<l;++a)n(i,a)}function p(e,t,o){var r,n,i,a,l,d,c,p=new C.Group;if(t.append(p),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),p.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)),p.append(l),c=e.format,c||"number"!=a||i==Math.floor(i)||(c="0.##############"),c?(d=E.textAndColor(i,c),i=d.text,d.type&&(a=d.type)):i+="",!e.textAlign)switch(a){case"number":case"date":case"percent":case"currency":e.textAlign="right";break;case"boolean":e.textAlign="center"}s(i,d&&d.color||e.color||"#000",e,l)}}function u(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 s(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",u(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,d,p;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],d=a.paperSize[1],a.margin&&(l-=a.margin.left+a.margin.right+1,d-=a.margin.top+a.margin.bottom+1),r.pageWidth=l,r.pageHeight=d,p=t(e,e._ref(o),r),c(e,p,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 d=i[t]||(i[t]=new g),c=e>0&&d[e-1];c&&r(c,o)?(d[e]=c,c.bottom=l):d[e]={size:o.size,color:o.color,x:n,top:a,bottom:l}}function o(e,t,o,i,a,l){var d=n[e]||(n[e]=new g),c=t>0&&d[t-1];c&&r(c,o)?(d[t]=c,c.right=l):d[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,d,c=e.dataSource.data();return c.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=c.map(function(n,a){return{cells:o.map(function(o,l){var d=n[o.field];return e.useGridFormat&&(null!=d&&(o.format?d=kendo.format(o.format,d):d+=""),i[l]=Math.max(t(d),i[l])),r({value:d,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})})}),d=new kendo.spreadsheet.Sheet(l.length+1,o.length+1,e.rowHeight,50,20,20,{fontFamily:e.fontFamily,fontSize:e.fontSize,verticalAlign:"center"}),d.fromJSON({name:"Sheet1",rows:l,columns:i.map(function(e,t){return{index:t,width:e}})}),void d.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:u},v.drawTabularData=w},o(3))},1626:function(e,t){e.exports=require("../kendo.pdf")},1627:function(e,t){e.exports=require("./numformat")}});