UNPKG

@protobi/exceljs

Version:

Excel Workbook Manager - Temporary fork with pivot table enhancements and bug fixes pending upstream merge

113 lines (111 loc) 8.24 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } var BaseXform = require('../../base-xform'); var CompositeXform = require('../../composite-xform'); var ColorXform = require('../../style/color-xform'); var CfvoExtXform = require('./cfvo-ext-xform'); var DatabarExtXform = /*#__PURE__*/function (_CompositeXform) { _inherits(DatabarExtXform, _CompositeXform); var _super = _createSuper(DatabarExtXform); function DatabarExtXform() { var _this; _classCallCheck(this, DatabarExtXform); _this = _super.call(this); _this.map = { 'x14:cfvo': _this.cfvoXform = new CfvoExtXform(), 'x14:borderColor': _this.borderColorXform = new ColorXform('x14:borderColor'), 'x14:negativeBorderColor': _this.negativeBorderColorXform = new ColorXform('x14:negativeBorderColor'), 'x14:negativeFillColor': _this.negativeFillColorXform = new ColorXform('x14:negativeFillColor'), 'x14:axisColor': _this.axisColorXform = new ColorXform('x14:axisColor') }; return _this; } _createClass(DatabarExtXform, [{ key: "tag", get: function get() { return 'x14:dataBar'; } }, { key: "render", value: function render(xmlStream, model) { var _this2 = this; xmlStream.openNode(this.tag, { minLength: BaseXform.toIntAttribute(model.minLength, 0, true), maxLength: BaseXform.toIntAttribute(model.maxLength, 100, true), border: BaseXform.toBoolAttribute(model.border, false), gradient: BaseXform.toBoolAttribute(model.gradient, true), negativeBarColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarColorSameAsPositive, true), negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarBorderColorSameAsPositive, true), axisPosition: BaseXform.toAttribute(model.axisPosition, 'auto'), direction: BaseXform.toAttribute(model.direction, 'leftToRight') }); model.cfvo.forEach(function (cfvo) { _this2.cfvoXform.render(xmlStream, cfvo); }); this.borderColorXform.render(xmlStream, model.borderColor); this.negativeBorderColorXform.render(xmlStream, model.negativeBorderColor); this.negativeFillColorXform.render(xmlStream, model.negativeFillColor); this.axisColorXform.render(xmlStream, model.axisColor); xmlStream.closeNode(); } }, { key: "createNewModel", value: function createNewModel(_ref) { var attributes = _ref.attributes; return { cfvo: [], minLength: BaseXform.toIntValue(attributes.minLength, 0), maxLength: BaseXform.toIntValue(attributes.maxLength, 100), border: BaseXform.toBoolValue(attributes.border, false), gradient: BaseXform.toBoolValue(attributes.gradient, true), negativeBarColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarColorSameAsPositive, true), negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarBorderColorSameAsPositive, true), axisPosition: BaseXform.toStringValue(attributes.axisPosition, 'auto'), direction: BaseXform.toStringValue(attributes.direction, 'leftToRight') }; } }, { key: "onParserClose", value: function onParserClose(name, parser) { var _name$split = name.split(':'), _name$split2 = _slicedToArray(_name$split, 2), prop = _name$split2[1]; switch (prop) { case 'cfvo': this.model.cfvo.push(parser.model); break; default: this.model[prop] = parser.model; break; } } }], [{ key: "isExt", value: function isExt(rule) { // not all databars need ext // TODO: refine this return !rule.gradient; } }]); return DatabarExtXform; }(CompositeXform); module.exports = DatabarExtXform; //# sourceMappingURL=databar-ext-xform.js.map