UNPKG

@progress/kendo-ui

Version:

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

1 lines 13.9 kB
module.exports=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){r(1527),e.exports=r(1527)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},19:function(e,t){e.exports=require("../kendo.core")},924:function(e,t){e.exports=require("../util/text-metrics")},1522:function(e,t){e.exports=require("../util/main")},1527:function(e,t,r){var n,i,o;!function(s,define){i=[r(19),r(924),r(1522)],n=s,o="function"==typeof n?n.apply(t,i):n,!(void 0!==o&&(e.exports=o))}(function(){!function(e){function t(e,r,n){for(;e<=r&&n(e);)e++;if(e>r)return[];for(var i=e+1;i<=r;++i)if(n(i))return[{begin:e,end:i-1}].concat(t(i+1,r,n));return[{begin:e,end:r}]}function r(e){return e.replace(/M/g,"m").replace(/'/g,'"').replace(/tt/,"am/pm")}function n(t){return!/^=/.test(t)&&/number|percent/.test(e.spreadsheet.calc.parse(null,0,0,t).type)}function i(t,r,n,i,o){var s={baselineMarkerSize:0,width:o===!0?r+"px":"auto","font-size":(i||12)+"px","font-family":n||"Arial","white-space":o===!0?"pre-wrap":"pre","overflow-wrap":o===!0?"break-word":"normal","word-wrap":o===!0?"break-word":"normal"};return e.util.measureText(t,s,{box:l,normalizeText:!1}).height}var o,s,a,f,h,u,l;e.support.browser.msie&&e.support.browser.version<9||(o=e.jQuery,s=e.spreadsheet.UnionRef,a=e.spreadsheet.CellRef,f=e.spreadsheet.RangeRef,h=["color","fontFamily","underline","italic","bold","textAlign","indent","verticalAlign","background","format","link","editor","borderTop","borderRight","borderBottom","borderLeft","comment"],u=e.Class.extend({init:function(e,t){this._sheet=t,this._ref=e},clone:function(){return new u(this._ref.clone(),this._sheet)},skipHiddenCells:function(){var e=[],r=this,n=r._sheet,i=n.isHiddenRow.bind(n),o=n.isHiddenColumn.bind(n);return r._ref.forEach(function(n){var s,h,u,l,c,d;for(n=r._normalize(n.toRangeRef()),s=n.topLeft,h=n.bottomRight,u=t(s.row,h.row,i),l=t(s.col,h.col,o),c=0;c<u.length;++c)for(d=0;d<l.length;++d)e.push(new f(new a(u[c].begin,l[d].begin),new a(u[c].end,l[d].end)))}),n.range(e.length>1?new s(e):e[0])},_normalize:function(e){return this._sheet._grid.normalize(e)},_set:function(e,t,r){var n=this,i=n._sheet;return n._ref.forEach(function(r){i._set(r.toRangeRef(),e,t)}),r||i.triggerChange({recalc:"formula"==e||"value"==e||"validation"==e,value:t,range:n,ref:n._ref}),n},_get:function(e){return this._sheet._get(this._ref.toRangeRef(),e)},_property:function(e,t){return void 0===t?this._get(e):this._set(e,t)},value:function(e){return void 0!==e&&this._set("formula",null,!0),this._property("value",e)},resize:function(e){var t=this._resizedRef(e);return new u(t,this._sheet)},_resizedRef:function(e){return this._ref.map(function(t){return t.toRangeRef().resize(e)})},input:function(t,i){var s,a,f,h,u,l,c;return i=o.extend({arrayFormula:!1},i),s=this._get("format"),void 0!==t?(f=this._ref.toRangeRef().topLeft,a=e.spreadsheet.calc.parse(this._sheet.name(),f.row,f.col,t,s),this._sheet.batch(function(){var n,o=null;"exp"==a.type?o=e.spreadsheet.calc.compile(a):"@"!=s?(n=s&&e.spreadsheet.formatting.type(a.value,s),"date"==a.type&&"date"!=n?this.format(a.format||r(e.culture().calendar.patterns.d)):"percent"==a.type&&"percent"!=n?this.format(100*a.value==(100*a.value|0)?"0%":"0.00%"):a.format&&(!s||a.currency||"number"==n&&"number"==a.type&&a.format.length>s.length)&&this.format(a.format)):"string"!=a.type&&(a.value=t),this.formula(o,i.arrayFormula),o||this.value(a.value)}.bind(this),{recalc:!0,value:t,ref:this._ref,editorChange:this._sheet.isInEditMode()}),this):(t=this._get("value"),h=this._get("formula"),u=s&&!h&&e.spreadsheet.formatting.type(t,s),h?t="="+h:s&&"date"==u&&(l=e.spreadsheet.formatting.text(t,s),a=e.spreadsheet.calc.parse(null,null,null,l,s),c=e.spreadsheet.formatting.text(a.value,s),l==c)?t=l:"date"===u?t=e.toString(e.spreadsheet.numberToDate(t),e.culture().calendar.patterns.d):"percent"===u?t=e.spreadsheet.calc.runtime.limitPrecision(100*t)+"%":"string"==typeof t&&(/^[=']/.test(t)||/^(?:true|false)$/i.test(t)||n(t))?t="'"+t:this._sheet._useCultureDecimals()&&"number"==typeof t&&t!=Math.floor(t)&&(t=(t+"").replace(".",e.culture().numberFormat["."])),t)},enable:function(t){return void 0===t?!e.util.withExit(function(e){this._sheet.forEach(this._ref,function(t,r,n){n.enable===!1&&e(!0)})},this):this._property("enable",t)},formula:function(e,t){var r,n,i=this;return void 0===e?(r=i._get("formula"),r?""+r:null):(t?(n=this._ref.toRangeRef(),e=i._sheet.range(n.topLeft)._set("formula",e)._get("formula"),e&&e.setArrayFormulaRange(n)):i._set("formula",e),i)},intersectingArrayFormula:function(){var t=this._ref.clone().simplify().setSheet(this._sheet.name());return e.util.withExit(function(r){this._sheet._forFormulas(function(n){var i=n.arrayFormulaRange;i&&(i=t.intersect(i))!==e.spreadsheet.NULLREF&&r({formula:n,intersection:i})})},this)},canEditArrayFormula:function(){var e=this.intersectingArrayFormula();return!e||e.formula.arrayFormulaRange.eq(e.intersection)},validation:function(e){if(void 0===e){var t=this._get("validation");return t?t.toJSON():null}return this._property("validation",e)},_getValidationState:function(){var e,t,r,n=this._ref.toRangeRef(),i=n.topLeft.row,o=n.topLeft.col,s=n.bottomRight.row,a=n.bottomRight.col;for(e=o;e<=a;e++)for(t=i;t<=s;t++)if(r=this._sheet._validation(t,e),r&&"reject"===r.type&&r.value===!1)return r;return!1},merge:function(){return this._ref=this._sheet._merge(this._ref),this},unmerge:function(){var e=this._sheet._mergedCells;return this._ref.forEach(function(t){t.toRangeRef().intersecting(e).forEach(function(t){e.splice(e.indexOf(t),1)})}),this._sheet.triggerChange({}),this},select:function(){return this._sheet.select(this._ref),this},values:function(t){var r,n,i,o,a,f,h,u,l,c;if(this._ref instanceof s)throw Error("Unsupported for multiple ranges.");if(this._ref===e.spreadsheet.NULLREF){if(void 0!==t)throw Error("Unsupported for NULLREF.");return[]}if(r=this._ref.toRangeRef(),n=r.topLeft.row,i=r.topLeft.col,o=r.bottomRight.row,a=r.bottomRight.col,void 0===t){for(t=Array(r.height()),u=0;u<t.length;u++)t[u]=Array(r.width());for(f=i;f<=a;f++)for(h=n;h<=o;h++)t[h-n][f-i]=this._sheet._value(h,f);return t}for(this._sheet._set(r,"formula",null),f=i;f<=a;f++)for(h=n;h<=o;h++)l=t[h-n],l&&(c=l[f-i],void 0!==c&&this._sheet._value(h,f,c));return this._sheet.triggerChange({recalc:!0,ref:r}),this},_properties:function(t,r){var n,i,o,a,f,h,u,l,c,d,p;if(this._ref instanceof s)throw Error("Unsupported for multiple ranges.");if(this._ref===e.spreadsheet.NULLREF){if(void 0!==t)throw Error("Unsupported for NULLREF.");return[]}if(n=this._ref.toRangeRef(),i=n.topLeft.row,o=n.topLeft.col,a=n.bottomRight.row,f=n.bottomRight.col,l=this._sheet,void 0===t)return t=Array(n.height()),l.forEach(n,function(e,r,n){e-=i,r-=o;var s=t[e]||(t[e]=[]);s[r]=n}),t;for(n=n.clone(),d=function(e){var t=c[e];n.topLeft.row=n.bottomRight.row=u,n.topLeft.col=n.bottomRight.col=h,"value"==e&&l._set(n,"formula",null),l._set(n,e,t)},h=o;h<=f;h++)if(r||!l.isHiddenColumn(h))for(u=i;u<=a;u++)!r&&l.isHiddenRow(u)||r&&l.isFilteredRow(u)||(p=t[u-i],p&&(c=p[h-o],c&&Object.keys(c).forEach(d)));return l.triggerChange({recalc:!0,ref:this._ref}),this},clear:function(e){var t,r,n;return e=e||{},t=e.clearAll||!Object.keys(e).length,r=this._sheet,n={recalc:t||e.contentsOnly,ref:this._ref},r.batch(function(){n.recalc&&this.formula(null),t&&this.validation(null),(t||e.formatOnly)&&(h.forEach(function(t){e.keepBorders&&/^border/i.test(t)||this[t](null)}.bind(this)),this.fontSize(null),this.wrap(null),this.unmerge())}.bind(this),n),this},clearContent:function(){return this.clear({contentsOnly:!0})},clearFormat:function(){return this.clear({formatOnly:!0})},isSortable:function(){return!this.cantSort()},cantSort:function(){var t,r,n,i,o,f;if(this._ref instanceof s)return{code:"cantSortMultipleSelection",message:"Unsupported for multiple ranges."};if(this._ref===e.spreadsheet.NULLREF)return{code:"cantSortNullRef",message:"Unsupported for NULLREF."};t=this._sheet._getMergedCells(this._ref.toRangeRef()),r=t.primary,n=t.secondary,i=null,o=null,f={};try{this._sheet.forEach(this,function(e,s){var h=new a(e,s).print(),u=r[h];if(u){if(null===i)i=u.width(),o=u.height();else if(i!=u.width()||o!=u.height())throw f}else if(!n[h]&&t.hasMerged)throw f})}catch(h){if(h!==f)throw h;return{code:"cantSortMixedCells",message:"Unsupported for range containing cells of different shapes."}}return!1},sort:function(e){var t=this.cantSort();if(t)throw Error(t.message);return void 0===e&&(e={column:0}),e=e instanceof Array?e:[e],this._sheet._sortBy(this._ref.toRangeRef(),e.map(function(e,t){return"number"==typeof e&&(e={column:e}),{index:void 0===e.column?t:e.column,ascending:void 0===e.ascending||e.ascending}})),this},isFilterable:function(){return!(this._ref instanceof s)},filter:function(e){if(this._ref instanceof s)throw Error("Unsupported for multiple ranges.");return e===!1?this.clearFilters():(e=e===!0?[]:e instanceof Array?e:[e],this._sheet._filterBy(this._ref.toRangeRef(),e.map(function(e,t){return{index:void 0===e.column?t:e.column,filter:e.filter}}))),this},clearFilter:function(e){this._sheet.clearFilter(e)},clearFilters:function(){var e,t=this._sheet.filter(),r=[];if(t){for(e=0;e<t.columns.length;e++)r.push(t.columns[e].index);this._sheet.batch(function(){this.clearFilter(r),this._filter=null},{layout:!0,filter:!0})}},hasFilter:function(){var e=this._sheet.filter();return!!e},leftColumn:function(){return new u(this._ref.leftColumn(),this._sheet)},rightColumn:function(){return new u(this._ref.rightColumn(),this._sheet)},topRow:function(){return new u(this._ref.topRow(),this._sheet)},bottomRow:function(){return new u(this._ref.bottomRow(),this._sheet)},column:function(e){return new u(this._ref.toColumn(e),this._sheet)},row:function(e){return new u(this._ref.toRow(e),this._sheet)},forEachRow:function(e){this._ref.forEachRow(function(t){e(new u(t,this._sheet))}.bind(this))},forEachColumn:function(e){this._ref.forEachColumn(function(t){e(new u(t,this._sheet))}.bind(this))},sheet:function(){return this._sheet},topLeft:function(){return this._ref.toRangeRef().topLeft},intersectingMerged:function(){var e=this._sheet,t=[];return e._mergedCells.forEach(function(e){e.intersects(this._ref)&&t.push(""+e)}.bind(this)),t},getState:function(t){var r,n,i=this._ref.first(),o={ref:i,data:[],origRef:this._ref,rows:this._sheet._rows.getState()};return t?r="input"===t?["value","formula"]:"border"===t?["borderLeft","borderTop","borderRight","borderBottom"]:[t]:(r=e.spreadsheet.ALL_PROPERTIES,o.mergedCells=this.intersectingMerged()),n=o.data,this.forEachCell(function(t,o,s){var a={},f=t-i.row,h=o-i.col;n[f]||(n[f]=[]),n[f][h]=a,r.forEach(function(t){var r=void 0===s[t]?null:s[t];(r instanceof e.spreadsheet.calc.runtime.Formula||r instanceof e.spreadsheet.validation.Validation)&&(r=r.deepClone()),a[t]=r})}),o},setState:function(e,t){var r=this._sheet,n=this._ref.first(),i=e.ref.row-n.row,o=e.ref.col-n.col,s=t&&!t.isExternal(),a=t&&!s;r.batch(function(){var f,h;e.mergedCells&&this.unmerge(),t||this._sheet._rows.setState(e.rows),f=n.row,h=this.hasFilter(),e.data.forEach(function(i,o){if(!(h&&s&&r.isHiddenRow(e.ref.row+o))){var u=n.col;i.forEach(function(i,l){var c,d;if(!(h&&s&&r.isHiddenColumn(e.ref.col+l))){if(c=t?r.range(f,u):r.range(n.row+o,n.col+l),c.enable()){for(d in i)"value"!=d&&(t&&"enable"==d||c._set(d,i[d]));if(!i.formula)if(a)try{null==i.value?c._set("value",null):c.input(i.value)}catch(p){c._set("value",i.value)}else c._set("value",i.value)}u++}}),f++}}),e.mergedCells&&e.mergedCells.forEach(function(e){e=r._ref(e).relative(i,o,3),r.range(e).merge()},this)}.bind(this),{recalc:!0,ref:this._ref})},_adjustRowHeight:function(){var t=this,r=t._sheet,n=r._getMergedCells(t._ref.toRangeRef()),i=n.primary,o=n.secondary;r.batch(function(){t.forEachRow(function(t){var n=t._ref.topLeft.row,s=r.rowHeight(n);t.forEachCell(function(t,n,f){var h,u,l,c,d=new a(t,n).print();o[d]||(h=i[d],u=h?r._columns.sum(h.topLeft.col,h.bottomRight.col):r.columnWidth(n),l=f.value,f.format&&null!=l&&(l=e.spreadsheet.formatting.format(l,f.format)),c=e.spreadsheet.util.getTextHeight(l,u,f.fontFamily,f.fontSize,f.wrap),s=Math.max(s,c))}),r.rowHeight(n,s)})},{layout:!0})},forEachCell:function(e){this._ref.forEach(function(t){this._sheet.forEach(t.toRangeRef(),e.bind(this))}.bind(this))},hasValue:function(){var t=this._sheet._defaultCellStyle;return e.util.withExit(function(e){this.forEachCell(function(r,n,i){var o,s;for(o in i)s=i[o],void 0!==s&&null!==s&&s!==t[o]&&e(!0)})},this)},wrap:function(e){return void 0===e?!!this._property("wrap"):(this._property("wrap",e),null!==e&&this._adjustRowHeight(),this)},fontSize:function(e){return void 0===e?this._property("fontSize"):(this._property("fontSize",e),null!==e&&this._adjustRowHeight(),this)},draw:function(e,t){this._sheet.draw(this,e,t)},insideBorders:function(e){return this.insideVerticalBorders(e).insideHorizontalBorders(e)},insideVerticalBorders:function(e){return this._ref.forEach(function(t){t instanceof f&&t.width()>1&&(t=t.clone(),t.topLeft.col++,this._sheet.range(t)._set("vBorders",e))},this),this},insideHorizontalBorders:function(e){return this._ref.forEach(function(t){t instanceof f&&t.height()>1&&(t=t.clone(),t.topLeft.row++,this._sheet.range(t)._set("hBorders",e))},this),this}}),o.each(h,function(e,t){u.prototype[t]=function(e){return this._property(t,e)}}),l=o('<div style="position: absolute !important; top: -4000px !important; height: auto !important;padding: 1px 3px !important; box-sizing: border-box; margin: 0 !important; border: 1px solid black !important;line-height: normal !important; visibility: hidden !important;white-space: pre-wrap;" />')[0],e.spreadsheet.util={getTextHeight:i},e.spreadsheet.Range=u)}(window.kendo)},r(3))}});