@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
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(1567),e.exports=o(1567)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},925:function(e,t){e.exports=require("../util/text-metrics")},940:function(e,t){e.exports=require("./range")},1545:function(e,t){e.exports=require("./sheet")},1560:function(e,t){e.exports=require("./references")},1567:function(e,t,o){var r,n,i;!function(a,define){n=[o(1568),o(1545),o(940),o(1560),o(1569),o(925)],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 s,p,u,f,h,g,m,w,b,y,v,k,C,E,S,R,z,M,T=t._grid;return r=T.normalize(r),s=T.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,d,s=e-r.topLeft.row,b=o-r.topLeft.col,y=t.rowHeight(e),v=t.columnWidth(o);c.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(y),s||h.push(v),!t.isHiddenColumn(o)&&!t.isHiddenRow(e)&&y&&v&&(i=c.forScreen||a(n),(c.emptyCells||i)&&(l=new x(e,o).print(),g.secondary[l]||(i?(m=Math.max(m,s),w=Math.max(w,b)):n.empty=!0,n.row=s,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),u.push(n))))}),f=f.slice(0,m+1),h=h.slice(0,w+1),b=c.pageWidth,y=c.pageHeight,v=c.scale||1,c.fitWidth&&(k=h.reduce(n,0),k>b&&(v=b/k)),b=Math.ceil(b/v),y=Math.ceil(y/v),C=[],E=e(f,y||0,c.maxEmpty,c.headerRows,C),S=e(h,b||0,c.maxEmpty),R=0,z=0,M=[],u=u.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,u.push(i))})}),c.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(d)),{width:R,height:z,cells:u.sort(l),scale:v,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 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>=v)&&(E=Math.max(e.bottom,E),S=Math.max(e.right,S),!0)}var l,d,u,f,h,g,w=i*c,b=w+c,x=n*p,v=x+p,E=0,S=0,R=t.cells.filter(a),z=t.drawings.filter(function(e){return a(e.box)});E=Math.min(E,v),S=Math.min(S,b),(R.length||z.length)&&(l=new y.Group,o.append(l),d=new y.Group,l.append(d),d.clip(y.Path.fromRect(new k.Rect([w-1,x-1],[S+1,E+1]))),u=k.Matrix.scale(t.scale,t.scale).multiplyCopy(k.Matrix.translate(-w,-x)),(r.hCenter||r.vCenter)&&(u=u.multiplyCopy(k.Matrix.translate(r.hCenter?(b-S)/2:0,r.vCenter?(v-E)/2:0))),d.transform(u),r.guidelines&&(f=null,t.xCoords.forEach(function(e){e=Math.min(e,S),e!==f&&e>=w&&e<=b&&(f=e,d.append((new y.Path).moveTo(e,x).lineTo(e,E).close().stroke(r.guideColor,C)))}),f=null,t.yCoords.forEach(function(e){e=Math.min(e,E),e!==f&&e>=x&&e<=v&&(f=e,d.append((new y.Path).moveTo(w,e).lineTo(S,e).close().stroke(r.guideColor,C)))})),h=m(),R.forEach(function(t){s(t,d,r),h.add(t,e)}),g=new y.Group,h.vert.forEach(function(e){e.forEach(function(e){e.rendered||(e.rendered=!0,g.append((new y.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 y.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 y.Image(r,new k.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),p=Math.ceil(r.pageHeight/t.scale);for(i=0;i<d;++i)for(a=0;a<l;++a)n(i,a)}function s(e,t,o){var r,n,i,a,l,d,c,s=new y.Group;if(t.append(s),r=new k.Rect([e.left,e.top],[e.width,e.height]),(e.background||e.merged)&&(n=r,o.guidelines&&(n=r.clone(),n.origin.x+=C/2+.1,n.origin.y+=C/2+.1,n.size.width-=C+.2,n.size.height-=C+.2),s.append(new y.Rect(n).fill(e.background||"#fff").stroke(null))),i=e.value,null!=i){if(a="number"==typeof i?"number":null,l=new y.Group,l.clip(y.Path.fromRect(r)),s.append(l),c=e.format,c||"number"!=a||i==Math.floor(i)||(c="0.##############"),c?(d=v.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"}u(i,d&&d.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(E||(E=document.createElement("div"),E.style.position="fixed",E.style.left="0px",E.style.top="0px",E.style.visibility="hidden",E.style.overflow="hidden",E.style.boxSizing="border-box",E.style.lineHeight="normal",document.body.appendChild(E)),E.firstChild&&E.removeChild(E.firstChild),E.style.padding="2px 4px",E.style.color=t,E.style.font=f(o),E.style.width=o.width+"px",E.style.textAlign=o.textAlign||"left",E.style.textDecoration=o.underline?"underline":"none",p(o,E.style),o.wrap?(E.style.whiteSpace="pre-wrap",E.style.overflowWrap=E.style.wordWrap="break-word"):(E.style.whiteSpace="pre",E.style.overflowWrap=E.style.wordWrap="normal"),E.appendChild(document.createTextNode(e)),n=0,o.verticalAlign){case"center":n=o.height-E.offsetHeight>>1;break;case void 0:case null:case"bottom":n=o.height-E.offsetHeight}n<0&&(n=0),i=kendo.drawing.drawDOM.drawText(E),i.transform(k.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,s;null==r&&null==n&&(n=o,r={},o=b.SHEETREF),null==n&&(n=r,o instanceof b.Range||o instanceof b.Ref||"string"==typeof o?r={}:(r=o,o=b.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 y.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}),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,s=t(e,e._ref(o),r),c(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 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=R(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,k,C,E,S,R;kendo.support.browser.msie&&kendo.support.browser.version<9||(b=kendo.spreadsheet,x=b.CellRef,y=kendo.drawing,v=b.formatting,k=kendo.geometry,C=.8,b.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)}},S={},R=function(e,t){var o,r,n,i,a=t+":"+e,l=S[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=S[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},b.draw={Borders:m,doLayout:t,applyIndent:p},b.drawTabularData=w)},o(3))},1568:function(e,t){e.exports=require("../kendo.pdf")},1569:function(e,t){e.exports=require("./numformat")}});