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