123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219 |
- /*!
- * jsPDF AutoTable plugin v2.3.4
- * Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
- *
- * * /if (typeof window === 'object') window.jspdfAutoTableVersion = '2.3.4';/*
- */
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("jspdf"));
- else if(typeof define === 'function' && define.amd)
- define(["jspdf"], factory);
- else {
- var a = typeof exports === 'object' ? factory(require("jspdf")) : factory(root["jsPDF"]);
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
- }
- })(window, function(__WEBPACK_EXTERNAL_MODULE__19__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 18);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- /**
- * Ratio between font size and font height. The number comes from jspdf's source code
- */
- exports.FONT_ROW_RATIO = 1.15;
- var models_1 = __webpack_require__(5);
- var table = null;
- var assign = __webpack_require__(6);
- var entries = __webpack_require__(20);
- /**
- * Styles for the themes (overriding the default styles)
- */
- exports.getTheme = function (name) {
- var themes = {
- 'striped': {
- table: { fillColor: 255, textColor: 80, fontStyle: 'normal' },
- header: { textColor: 255, fillColor: [41, 128, 185], fontStyle: 'bold' },
- body: {},
- alternateRow: { fillColor: 245 }
- },
- 'grid': {
- table: { fillColor: 255, textColor: 80, fontStyle: 'normal', lineWidth: 0.1 },
- header: { textColor: 255, fillColor: [26, 188, 156], fontStyle: 'bold', lineWidth: 0 },
- body: {},
- alternateRow: {}
- },
- 'plain': {
- header: { fontStyle: 'bold' }
- }
- };
- return themes[name];
- };
- function getDefaults() {
- var scaleFactor = Config.scaleFactor();
- return {
- // Styling
- theme: 'striped',
- styles: {},
- headerStyles: {},
- bodyStyles: {},
- alternateRowStyles: {},
- columnStyles: {},
- // Properties
- startY: false,
- margin: 40 / scaleFactor,
- pageBreak: 'auto',
- tableWidth: 'auto',
- showHeader: 'everyPage',
- tableLineWidth: 0,
- tableLineColor: 200,
- // Hooks
- createdHeaderCell: function (cell, data) { },
- createdCell: function (cell, data) { },
- drawHeaderRow: function (row, data) { },
- drawRow: function (row, data) { },
- drawHeaderCell: function (cell, data) { },
- drawCell: function (cell, data) { },
- addPageContent: function (data) { }
- };
- }
- exports.getDefaults = getDefaults;
- // Base style for all themes
- function defaultStyles() {
- var scaleFactor = Config.scaleFactor();
- return {
- font: "helvetica",
- fontStyle: 'normal',
- overflow: 'ellipsize',
- fillColor: false,
- textColor: 20,
- halign: 'left',
- valign: 'top',
- fontSize: 10,
- cellPadding: 5 / scaleFactor,
- lineColor: 200,
- lineWidth: 0 / scaleFactor,
- columnWidth: 'auto'
- };
- }
- var Config = /** @class */ (function () {
- function Config() {
- }
- Config.pageSize = function () {
- var pageSize = table.doc.internal.pageSize;
- // JSPDF 1.4 uses get functions instead of properties on pageSize
- if (pageSize.width == null) {
- pageSize = {
- width: pageSize.getWidth(),
- height: pageSize.getHeight()
- };
- }
- return pageSize;
- };
- Config.applyUserStyles = function () {
- Config.applyStyles(table.userStyles);
- };
- Config.createTable = function (doc) {
- table = new models_1.Table(doc);
- return table;
- };
- Config.tableInstance = function () {
- return table;
- };
- Config.scaleFactor = function () {
- return table.doc.internal.scaleFactor;
- };
- Config.hooksData = function (additionalData) {
- if (additionalData === void 0) { additionalData = {}; }
- return assign({
- pageCount: table.pageCount,
- settings: table.settings,
- table: table,
- doc: table.doc,
- cursor: table.cursor
- }, additionalData || {});
- };
- Config.initSettings = function (table, allOptions) {
- var _loop_1 = function (styleProp) {
- var styles = allOptions.map(function (opts) { return opts[styleProp] || {}; });
- table.styles[styleProp] = assign.apply(void 0, [{}].concat(styles));
- };
- // Merge styles one level deeper
- for (var _i = 0, _a = Object.keys(table.styles); _i < _a.length; _i++) {
- var styleProp = _a[_i];
- _loop_1(styleProp);
- }
- // Append event handlers instead of replacing them
- for (var _b = 0, _c = entries(table.hooks); _b < _c.length; _b++) {
- var _d = _c[_b], hookName = _d[0], list = _d[1];
- for (var _e = 0, allOptions_1 = allOptions; _e < allOptions_1.length; _e++) {
- var opts = allOptions_1[_e];
- if (opts && opts[hookName]) {
- list.push(opts[hookName]);
- }
- }
- }
- // Merge all other options one level
- table.settings = assign.apply(void 0, [getDefaults()].concat(allOptions));
- };
- // This is messy, only keep array and number format the next major version
- Config.marginOrPadding = function (value, defaultValue) {
- var newValue = {};
- if (Array.isArray(value)) {
- if (value.length >= 4) {
- newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[3] };
- }
- else if (value.length === 3) {
- newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[1] };
- }
- else if (value.length === 2) {
- newValue = { 'top': value[0], 'right': value[1], 'bottom': value[0], 'left': value[1] };
- }
- else if (value.length === 1) {
- value = value[0];
- }
- else {
- value = defaultValue;
- }
- }
- else if (typeof value === 'object') {
- if (value['vertical']) {
- value['top'] = value['vertical'];
- value['bottom'] = value['vertical'];
- }
- else if (value['horizontal']) {
- value['right'] = value['horizontal'];
- value['left'] = value['horizontal'];
- }
- for (var _i = 0, _a = ['top', 'right', 'bottom', 'left']; _i < _a.length; _i++) {
- var side = _a[_i];
- newValue[side] = value[side] || value[side] === 0 ? value[side] : defaultValue;
- }
- }
- if (typeof value === 'number') {
- newValue = { 'top': value, 'right': value, 'bottom': value, 'left': value };
- }
- return newValue;
- };
- Config.styles = function (styles) {
- styles = Array.isArray(styles) ? styles : [styles];
- return assign.apply(void 0, [defaultStyles()].concat(styles));
- };
- Config.applyStyles = function (styles) {
- var doc = table.doc;
- var styleModifiers = {
- fillColor: doc.setFillColor,
- textColor: doc.setTextColor,
- fontStyle: doc.setFontStyle,
- lineColor: doc.setDrawColor,
- lineWidth: doc.setLineWidth,
- font: doc.setFont,
- fontSize: doc.setFontSize
- };
- Object.keys(styleModifiers).forEach(function (name) {
- var style = styles[name];
- var modifier = styleModifiers[name];
- if (typeof style !== 'undefined') {
- if (Array.isArray(style)) {
- modifier.apply(this, style);
- }
- else {
- modifier(style);
- }
- }
- });
- };
- return Config;
- }());
- exports.Config = Config;
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var bind = __webpack_require__(2);
- module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var implementation = __webpack_require__(27);
- module.exports = Function.prototype.bind || implementation;
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var fnToStr = Function.prototype.toString;
- var constructorRegex = /^\s*class\b/;
- var isES6ClassFn = function isES6ClassFunction(value) {
- try {
- var fnStr = fnToStr.call(value);
- return constructorRegex.test(fnStr);
- } catch (e) {
- return false; // not a function
- }
- };
- var tryFunctionObject = function tryFunctionToStr(value) {
- try {
- if (isES6ClassFn(value)) { return false; }
- fnToStr.call(value);
- return true;
- } catch (e) {
- return false;
- }
- };
- var toStr = Object.prototype.toString;
- var fnClass = '[object Function]';
- var genClass = '[object GeneratorFunction]';
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
- module.exports = function isCallable(value) {
- if (!value) { return false; }
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
- if (typeof value === 'function' && !value.prototype) { return true; }
- if (hasToStringTag) { return tryFunctionObject(value); }
- if (isES6ClassFn(value)) { return false; }
- var strClass = toStr.call(value);
- return strClass === fnClass || strClass === genClass;
- };
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var config_1 = __webpack_require__(0);
- var painter_1 = __webpack_require__(17);
- function getStringWidth(text, styles) {
- var k = config_1.Config.scaleFactor();
- var fontSize = styles.fontSize / k;
- config_1.Config.applyStyles(styles);
- text = Array.isArray(text) ? text : [text];
- var maxWidth = 0;
- text.forEach(function (line) {
- var width = config_1.Config.tableInstance().doc.getStringUnitWidth(line);
- if (width > maxWidth) {
- maxWidth = width;
- }
- });
- var precision = 10000 * k;
- maxWidth = Math.floor(maxWidth * precision) / precision;
- return maxWidth * fontSize;
- }
- exports.getStringWidth = getStringWidth;
- /**
- * Ellipsize the text to fit in the width
- */
- function ellipsize(text, width, styles, ellipsizeStr) {
- if (ellipsizeStr === void 0) { ellipsizeStr = '...'; }
- if (Array.isArray(text)) {
- var value_1 = [];
- text.forEach(function (str, i) {
- value_1[i] = ellipsize(str, width, styles, ellipsizeStr);
- });
- return value_1;
- }
- var precision = 10000 * config_1.Config.scaleFactor();
- width = Math.ceil(width * precision) / precision;
- if (width >= getStringWidth(text, styles)) {
- return text;
- }
- while (width < getStringWidth(text + ellipsizeStr, styles)) {
- if (text.length <= 1) {
- break;
- }
- text = text.substring(0, text.length - 1);
- }
- return text.trim() + ellipsizeStr;
- }
- exports.ellipsize = ellipsize;
- function addTableBorder() {
- var table = config_1.Config.tableInstance();
- var styles = { lineWidth: table.settings.tableLineWidth, lineColor: table.settings.tableLineColor };
- config_1.Config.applyStyles(styles);
- var fs = getFillStyle(styles);
- if (fs) {
- table.doc.rect(table.pageStartX, table.pageStartY, table.width, table.cursor.y - table.pageStartY, fs);
- }
- }
- exports.addTableBorder = addTableBorder;
- function addPage() {
- var table = config_1.Config.tableInstance();
- table.finalY = table.cursor.y;
- // Add user content just before adding new page ensure it will
- // be drawn above other things on the page
- addContentHooks();
- addTableBorder();
- nextPage(table.doc);
- table.pageCount++;
- table.cursor = { x: table.margin('left'), y: table.margin('top') };
- table.pageStartX = table.cursor.x;
- table.pageStartY = table.cursor.y;
- if (table.settings.showHeader === true || table.settings.showHeader === 'everyPage') {
- painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
- }
- }
- exports.addPage = addPage;
- function addContentHooks() {
- for (var _i = 0, _a = config_1.Config.tableInstance().hooks.addPageContent; _i < _a.length; _i++) {
- var hook = _a[_i];
- config_1.Config.applyUserStyles();
- hook(config_1.Config.hooksData());
- }
- config_1.Config.applyUserStyles();
- }
- exports.addContentHooks = addContentHooks;
- function getFillStyle(styles) {
- var drawLine = styles.lineWidth > 0;
- var drawBackground = styles.fillColor || styles.fillColor === 0;
- if (drawLine && drawBackground) {
- return 'DF'; // Fill then stroke
- }
- else if (drawLine) {
- return 'S'; // Only stroke (transparent background)
- }
- else if (drawBackground) {
- return 'F'; // Only fill, no stroke
- }
- else {
- return false;
- }
- }
- exports.getFillStyle = getFillStyle;
- function nextPage(doc) {
- var current = doc.internal.getCurrentPageInfo().pageNumber;
- doc.setPage(current + 1);
- var newCurrent = doc.internal.getCurrentPageInfo().pageNumber;
- if (newCurrent === current) {
- doc.addPage();
- }
- }
- exports.nextPage = nextPage;
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var config_1 = __webpack_require__(0);
- exports.table = {};
- var Table = /** @class */ (function () {
- function Table(doc) {
- this.height = 0;
- this.width = 0;
- this.contentWidth = 0;
- this.preferredWidth = 0;
- this.rows = [];
- this.columns = [];
- this.headerRow = null;
- this.pageCount = 1;
- this.hooks = {
- createdHeaderCell: [],
- createdCell: [],
- drawHeaderRow: [],
- drawRow: [],
- drawHeaderCell: [],
- drawCell: [],
- addPageContent: []
- };
- this.styles = {
- styles: {},
- headerStyles: {},
- bodyStyles: {},
- alternateRowStyles: {},
- columnStyles: {}
- };
- this.doc = doc;
- this.userStyles = {
- textColor: 30,
- fontSize: doc.internal.getFontSize(),
- fontStyle: doc.internal.getFont().fontStyle
- };
- }
- Table.prototype.margin = function (side) {
- return config_1.Config.marginOrPadding(this.settings.margin, config_1.getDefaults().margin)[side];
- };
- return Table;
- }());
- exports.Table = Table;
- var Row = /** @class */ (function () {
- function Row(raw, index) {
- this.cells = {};
- this.spansMultiplePages = false;
- this.pageCount = 1;
- this.height = 0;
- this.y = 0;
- this.maxLineCount = 1;
- this.raw = raw;
- this.index = index;
- }
- return Row;
- }());
- exports.Row = Row;
- var Cell = /** @class */ (function () {
- function Cell(raw) {
- this.styles = {};
- this.text = '';
- this.contentWidth = 0;
- this.textPos = {};
- this.height = 0;
- this.width = 0;
- this.x = 0;
- this.y = 0;
- this.raw = raw;
- }
- Cell.prototype.padding = function (name) {
- var padding = config_1.Config.marginOrPadding(this.styles.cellPadding, config_1.Config.styles([]).cellPadding);
- if (name === 'vertical') {
- return padding.top + padding.bottom;
- }
- else if (name === 'horizontal') {
- return padding.left + padding.right;
- }
- else {
- return padding[name];
- }
- };
- return Cell;
- }());
- exports.Cell = Cell;
- var Column = /** @class */ (function () {
- function Column(dataKey, index) {
- this.options = {};
- this.contentWidth = 0;
- this.preferredWidth = 0;
- this.widthStyle = 'auto';
- this.width = 0;
- this.x = 0;
- this.dataKey = dataKey;
- this.index = index;
- }
- return Column;
- }());
- exports.Column = Column;
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
- return Object(val);
- }
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
- // Detect buggy property enumeration order in older V8 versions.
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
- module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
- return to;
- };
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var keys = __webpack_require__(21);
- var foreach = __webpack_require__(23);
- var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
- var toStr = Object.prototype.toString;
- var isFunction = function (fn) {
- return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
- };
- var arePropertyDescriptorsSupported = function () {
- var obj = {};
- try {
- Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
- /* eslint-disable no-unused-vars, no-restricted-syntax */
- for (var _ in obj) { return false; }
- /* eslint-enable no-unused-vars, no-restricted-syntax */
- return obj.x === obj;
- } catch (e) { /* this is IE 8. */
- return false;
- }
- };
- var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
- var defineProperty = function (object, name, value, predicate) {
- if (name in object && (!isFunction(predicate) || !predicate())) {
- return;
- }
- if (supportsDescriptors) {
- Object.defineProperty(object, name, {
- configurable: true,
- enumerable: false,
- value: value,
- writable: true
- });
- } else {
- object[name] = value;
- }
- };
- var defineProperties = function (object, map) {
- var predicates = arguments.length > 2 ? arguments[2] : {};
- var props = keys(map);
- if (hasSymbols) {
- props = props.concat(Object.getOwnPropertySymbols(map));
- }
- foreach(props, function (name) {
- defineProperty(object, name, map[name], predicates[name]);
- });
- };
- defineProperties.supportsDescriptors = !!supportsDescriptors;
- module.exports = defineProperties;
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var ES = __webpack_require__(24);
- var has = __webpack_require__(1);
- var bind = __webpack_require__(2);
- var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
- module.exports = function entries(O) {
- var obj = ES.RequireObjectCoercible(O);
- var entrys = [];
- for (var key in obj) {
- if (has(obj, key) && isEnumerable(obj, key)) {
- entrys.push([key, obj[key]]);
- }
- }
- return entrys;
- };
- /***/ }),
- /* 9 */
- /***/ (function(module, exports) {
- module.exports = function isPrimitive(value) {
- return value === null || (typeof value !== 'function' && typeof value !== 'object');
- };
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /* globals
- Set,
- Map,
- WeakSet,
- WeakMap,
- Promise,
- Symbol,
- Proxy,
- Atomics,
- SharedArrayBuffer,
- ArrayBuffer,
- DataView,
- Uint8Array,
- Float32Array,
- Float64Array,
- Int8Array,
- Int16Array,
- Int32Array,
- Uint8ClampedArray,
- Uint16Array,
- Uint32Array,
- */
- var undefined; // eslint-disable-line no-shadow-restricted-names
- var ThrowTypeError = Object.getOwnPropertyDescriptor
- ? (function () { return Object.getOwnPropertyDescriptor(arguments, 'callee').get; }())
- : function () { throw new TypeError(); };
- var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
- var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
- var generator; // = function * () {};
- var generatorFunction = generator ? getProto(generator) : undefined;
- var asyncFn; // async function() {};
- var asyncFunction = asyncFn ? asyncFn.constructor : undefined;
- var asyncGen; // async function * () {};
- var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
- var asyncGenIterator = asyncGen ? asyncGen() : undefined;
- var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
- var INTRINSICS = {
- '$ %Array%': Array,
- '$ %ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
- '$ %ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype,
- '$ %ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
- '$ %ArrayPrototype%': Array.prototype,
- '$ %ArrayProto_entries%': Array.prototype.entries,
- '$ %ArrayProto_forEach%': Array.prototype.forEach,
- '$ %ArrayProto_keys%': Array.prototype.keys,
- '$ %ArrayProto_values%': Array.prototype.values,
- '$ %AsyncFromSyncIteratorPrototype%': undefined,
- '$ %AsyncFunction%': asyncFunction,
- '$ %AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined,
- '$ %AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined,
- '$ %AsyncGeneratorFunction%': asyncGenFunction,
- '$ %AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined,
- '$ %AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined,
- '$ %Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
- '$ %Boolean%': Boolean,
- '$ %BooleanPrototype%': Boolean.prototype,
- '$ %DataView%': typeof DataView === 'undefined' ? undefined : DataView,
- '$ %DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype,
- '$ %Date%': Date,
- '$ %DatePrototype%': Date.prototype,
- '$ %decodeURI%': decodeURI,
- '$ %decodeURIComponent%': decodeURIComponent,
- '$ %encodeURI%': encodeURI,
- '$ %encodeURIComponent%': encodeURIComponent,
- '$ %Error%': Error,
- '$ %ErrorPrototype%': Error.prototype,
- '$ %eval%': eval, // eslint-disable-line no-eval
- '$ %EvalError%': EvalError,
- '$ %EvalErrorPrototype%': EvalError.prototype,
- '$ %Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
- '$ %Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype,
- '$ %Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
- '$ %Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype,
- '$ %Function%': Function,
- '$ %FunctionPrototype%': Function.prototype,
- '$ %Generator%': generator ? getProto(generator()) : undefined,
- '$ %GeneratorFunction%': generatorFunction,
- '$ %GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined,
- '$ %Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
- '$ %Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype,
- '$ %Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
- '$ %Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype,
- '$ %Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
- '$ %Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype,
- '$ %isFinite%': isFinite,
- '$ %isNaN%': isNaN,
- '$ %IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
- '$ %JSON%': JSON,
- '$ %JSONParse%': JSON.parse,
- '$ %Map%': typeof Map === 'undefined' ? undefined : Map,
- '$ %MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
- '$ %MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype,
- '$ %Math%': Math,
- '$ %Number%': Number,
- '$ %NumberPrototype%': Number.prototype,
- '$ %Object%': Object,
- '$ %ObjectPrototype%': Object.prototype,
- '$ %ObjProto_toString%': Object.prototype.toString,
- '$ %ObjProto_valueOf%': Object.prototype.valueOf,
- '$ %parseFloat%': parseFloat,
- '$ %parseInt%': parseInt,
- '$ %Promise%': typeof Promise === 'undefined' ? undefined : Promise,
- '$ %PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype,
- '$ %PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then,
- '$ %Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all,
- '$ %Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject,
- '$ %Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve,
- '$ %Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
- '$ %RangeError%': RangeError,
- '$ %RangeErrorPrototype%': RangeError.prototype,
- '$ %ReferenceError%': ReferenceError,
- '$ %ReferenceErrorPrototype%': ReferenceError.prototype,
- '$ %Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
- '$ %RegExp%': RegExp,
- '$ %RegExpPrototype%': RegExp.prototype,
- '$ %Set%': typeof Set === 'undefined' ? undefined : Set,
- '$ %SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
- '$ %SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype,
- '$ %SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
- '$ %SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype,
- '$ %String%': String,
- '$ %StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
- '$ %StringPrototype%': String.prototype,
- '$ %Symbol%': hasSymbols ? Symbol : undefined,
- '$ %SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined,
- '$ %SyntaxError%': SyntaxError,
- '$ %SyntaxErrorPrototype%': SyntaxError.prototype,
- '$ %ThrowTypeError%': ThrowTypeError,
- '$ %TypedArray%': TypedArray,
- '$ %TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined,
- '$ %TypeError%': TypeError,
- '$ %TypeErrorPrototype%': TypeError.prototype,
- '$ %Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
- '$ %Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype,
- '$ %Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
- '$ %Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype,
- '$ %Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
- '$ %Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype,
- '$ %Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
- '$ %Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype,
- '$ %URIError%': URIError,
- '$ %URIErrorPrototype%': URIError.prototype,
- '$ %WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
- '$ %WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype,
- '$ %WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
- '$ %WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype
- };
- module.exports = function GetIntrinsic(name, allowMissing) {
- if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
- throw new TypeError('"allowMissing" argument must be a boolean');
- }
- var key = '$ ' + name;
- if (!(key in INTRINSICS)) {
- throw new SyntaxError('intrinsic ' + name + ' does not exist!');
- }
- // istanbul ignore if // hopefully this is impossible to test :-)
- if (typeof INTRINSICS[key] === 'undefined' && !allowMissing) {
- throw new TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
- }
- return INTRINSICS[key];
- };
- /***/ }),
- /* 11 */
- /***/ (function(module, exports) {
- module.exports = Number.isNaN || function isNaN(a) {
- return a !== a;
- };
- /***/ }),
- /* 12 */
- /***/ (function(module, exports) {
- var $isNaN = Number.isNaN || function (a) { return a !== a; };
- module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- var bind = __webpack_require__(2);
- var has = bind.call(Function.call, Object.prototype.hasOwnProperty);
- var $assign = Object.assign;
- module.exports = function assign(target, source) {
- if ($assign) {
- return $assign(target, source);
- }
- for (var key in source) {
- if (has(source, key)) {
- target[key] = source[key];
- }
- }
- return target;
- };
- /***/ }),
- /* 14 */
- /***/ (function(module, exports) {
- module.exports = function sign(number) {
- return number >= 0 ? 1 : -1;
- };
- /***/ }),
- /* 15 */
- /***/ (function(module, exports) {
- module.exports = function mod(number, modulo) {
- var remain = number % modulo;
- return Math.floor(remain >= 0 ? remain : remain + modulo);
- };
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var implementation = __webpack_require__(8);
- module.exports = function getPolyfill() {
- return typeof Object.entries === 'function' ? Object.entries : implementation;
- };
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var config_1 = __webpack_require__(0);
- var common_1 = __webpack_require__(4);
- function printFullRow(row, drawRowHooks, drawCellHooks) {
- var remainingRowHeight = 0;
- var remainingTexts = {};
- var table = config_1.Config.tableInstance();
- if (!canFitOnPage(row.height)) {
- if (row.maxLineCount <= 1) {
- common_1.addPage();
- }
- else {
- // Modify the row to fit the current page and calculate text and height of partial row
- row.spansMultiplePages = true;
- var pageHeight = config_1.Config.pageSize().height;
- var maxCellHeight = 0;
- for (var j = 0; j < table.columns.length; j++) {
- var col = table.columns[j];
- var cell = row.cells[col.dataKey];
- var fontHeight = cell.styles.fontSize / config_1.Config.scaleFactor() * config_1.FONT_ROW_RATIO;
- var vPadding = cell.padding('vertical');
- var remainingPageSpace = pageHeight - table.cursor.y - table.margin('bottom');
- var remainingLineCount = Math.floor((remainingPageSpace - vPadding) / fontHeight);
- // Splice with negative values results in unexpected results, therefore eliminate
- // scenarios where less than one line is remaining, but are shown
- if (remainingLineCount < 0) {
- remainingLineCount = 0;
- }
- if (Array.isArray(cell.text) && cell.text.length > remainingLineCount) {
- var remainingLines = cell.text.splice(remainingLineCount, cell.text.length);
- remainingTexts[col.dataKey] = remainingLines;
- var cellHeight = cell.text.length * fontHeight + vPadding;
- if (cellHeight > maxCellHeight) {
- maxCellHeight = cellHeight;
- }
- var rCellHeight = remainingLines.length * fontHeight + vPadding;
- if (rCellHeight > remainingRowHeight) {
- remainingRowHeight = rCellHeight;
- }
- }
- }
- // Reset row height since text are now removed
- row.height = maxCellHeight;
- }
- }
- printRow(row, drawRowHooks, drawCellHooks);
- // Parts of the row is now printed. Time for adding a new page, prune
- // the text and start over
- if (Object.keys(remainingTexts).length > 0) {
- for (var j = 0; j < table.columns.length; j++) {
- var col = table.columns[j];
- var cell = row.cells[col.dataKey];
- cell.text = remainingTexts[col.dataKey] || '';
- }
- common_1.addPage();
- row.pageCount++;
- row.height = remainingRowHeight;
- printFullRow(row, drawRowHooks, drawCellHooks);
- }
- }
- exports.printFullRow = printFullRow;
- function printRow(row, drawRowHooks, drawCellHooks) {
- var table = config_1.Config.tableInstance();
- row.y = table.cursor.y;
- for (var _i = 0, drawRowHooks_1 = drawRowHooks; _i < drawRowHooks_1.length; _i++) {
- var hook = drawRowHooks_1[_i];
- if (hook(row, config_1.Config.hooksData({ row: row, addPage: common_1.addPage })) === false) {
- return;
- }
- }
- table.cursor.x = table.margin('left');
- for (var i = 0; i < table.columns.length; i++) {
- var column = table.columns[i];
- var cell = row.cells[column.dataKey];
- if (!cell) {
- continue;
- }
- config_1.Config.applyStyles(cell.styles);
- cell.x = table.cursor.x;
- cell.y = table.cursor.y;
- cell.height = row.height;
- cell.width = column.width;
- if (cell.styles.valign === 'top') {
- cell.textPos.y = table.cursor.y + cell.padding('top');
- }
- else if (cell.styles.valign === 'bottom') {
- cell.textPos.y = table.cursor.y + row.height - cell.padding('bottom');
- }
- else {
- cell.textPos.y = table.cursor.y + row.height / 2;
- }
- if (cell.styles.halign === 'right') {
- cell.textPos.x = cell.x + cell.width - cell.padding('right');
- }
- else if (cell.styles.halign === 'center') {
- cell.textPos.x = cell.x + cell.width / 2;
- }
- else {
- cell.textPos.x = cell.x + cell.padding('left');
- }
- var shouldDrawCell = true;
- var data = config_1.Config.hooksData({ column: column, row: row, addPage: common_1.addPage });
- for (var _a = 0, drawCellHooks_1 = drawCellHooks; _a < drawCellHooks_1.length; _a++) {
- var hook = drawCellHooks_1[_a];
- if (hook(cell, data) === false) {
- shouldDrawCell = false;
- }
- }
- if (shouldDrawCell) {
- var fillStyle = common_1.getFillStyle(cell.styles);
- if (fillStyle) {
- table.doc.rect(cell.x, cell.y, cell.width, cell.height, fillStyle);
- }
- table.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, {
- halign: cell.styles.halign,
- valign: cell.styles.valign
- });
- }
- table.cursor.x += cell.width;
- }
- table.cursor.y += row.height;
- }
- exports.printRow = printRow;
- function canFitOnPage(rowHeight) {
- var table = config_1.Config.tableInstance();
- var pos = rowHeight + table.cursor.y + table.margin('bottom');
- return pos < config_1.Config.pageSize().height;
- }
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var jsPDF = __webpack_require__(19);
- var config_1 = __webpack_require__(0);
- var common_1 = __webpack_require__(4);
- var painter_1 = __webpack_require__(17);
- var calculator_1 = __webpack_require__(36);
- var creator_1 = __webpack_require__(37);
- /**
- * Create a table from a set of rows and columns.
- *
- * @param {Object[]|String[]} headers Either as an array of objects or array of strings
- * @param {Object[][]|String[][]} data Either as an array of objects or array of strings
- * @param {Object} [tableOptions={}] Options that will override the default ones
- */
- jsPDF.API.autoTable = function (headers, data, tableOptions) {
- if (tableOptions === void 0) { tableOptions = {}; }
- this.autoTableState = this.autoTableState || {};
- jsPDF.autoTableState = jsPDF.autoTableState || {};
- var allOptions = [jsPDF.autoTableState.defaults || {}, this.autoTableState.defaults || {}, tableOptions || {}];
- creator_1.validateInput(headers, data, allOptions);
- var table = config_1.Config.createTable(this);
- config_1.Config.initSettings(table, allOptions);
- var settings = table.settings;
- // Create the table model with its columns, rows and cells
- creator_1.createModels(headers, data);
- settings.margin = config_1.Config.marginOrPadding(settings.margin, config_1.getDefaults().margin);
- calculator_1.calculateWidths(this, config_1.Config.pageSize().width);
- table.cursor = {
- x: table.margin('left'),
- y: settings.startY === false ? table.margin('top') : settings.startY
- };
- var minTableBottomPos = settings.startY + table.margin('bottom') + table.headerRow.height;
- if (settings.pageBreak === 'avoid') {
- minTableBottomPos += table.height;
- }
- var pageHeight = config_1.Config.pageSize().height;
- if ((settings.pageBreak === 'always' && settings.startY !== false) ||
- (settings.startY !== false && minTableBottomPos > pageHeight)) {
- common_1.nextPage(table.doc);
- table.cursor.y = table.margin('top');
- }
- table.pageStartX = table.cursor.x;
- table.pageStartY = table.cursor.y;
- config_1.Config.applyUserStyles();
- if (settings.showHeader === true || settings.showHeader === 'firstPage' || settings.showHeader === 'everyPage') {
- painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
- }
- config_1.Config.applyUserStyles();
- table.rows.forEach(function (row) {
- painter_1.printFullRow(row, table.hooks.drawRow, table.hooks.drawCell);
- });
- common_1.addTableBorder();
- // Don't call global and document addPageContent more than once for each page
- var pageNumber = this.internal.getCurrentPageInfo().pageNumber;
- if (this.autoTableState.addPageHookPages && this.autoTableState.addPageHookPages[pageNumber]) {
- if (typeof tableOptions['addPageContent'] === 'function') {
- tableOptions['addPageContent'](config_1.Config.hooksData());
- }
- }
- else {
- if (!this.autoTableState.addPageHookPages)
- this.autoTableState.addPageHookPages = {};
- this.autoTableState.addPageHookPages[pageNumber] = true;
- common_1.addContentHooks();
- }
- table.finalY = table.cursor.y;
- this.autoTable.previous = table;
- config_1.Config.applyUserStyles();
- return this;
- };
- // Enables doc.autoTable.previous.finalY || 40;
- jsPDF.API.autoTable.previous = false;
- jsPDF.API.autoTableSetDefaults = function (defaults) {
- if (!this.autoTableState)
- this.autoTableState = {};
- if (defaults && typeof defaults === 'object') {
- this.autoTableState.defaults = defaults;
- }
- else {
- delete this.autoTableState.defaults;
- }
- return this;
- };
- jsPDF.autoTableSetDefaults = function (defaults) {
- if (!jsPDF.autoTableState)
- jsPDF.autoTableState = {};
- if (defaults && typeof defaults === 'object') {
- this.autoTableState.defaults = defaults;
- }
- else {
- delete this.autoTableState.defaults;
- }
- jsPDF.autoTableState.defaults = defaults;
- };
- /**
- * Parses an html table
- *
- * @param tableElem Html table element
- * @param includeHiddenElements If to include hidden rows and columns (defaults to false)
- * @returns Object Object with two properties, columns and rows
- */
- jsPDF.API.autoTableHtmlToJson = function (tableElem, includeHiddenElements) {
- includeHiddenElements = includeHiddenElements || false;
- if (!tableElem || !(tableElem instanceof HTMLTableElement)) {
- console.error("A HTMLTableElement has to be sent to autoTableHtmlToJson");
- return null;
- }
- var columns = {}, rows = [];
- var header = tableElem.rows[0];
- for (var i = 0; i < header.cells.length; i++) {
- var cell = header.cells[i];
- var style = window.getComputedStyle(cell);
- if (includeHiddenElements || style.display !== 'none') {
- columns[i] = cell;
- }
- }
- var _loop_1 = function (i) {
- var tableRow = tableElem.rows[i];
- var style = window.getComputedStyle(tableRow);
- if (includeHiddenElements || style.display !== 'none') {
- var rowData_1 = [];
- Object.keys(columns).forEach(function (key) {
- var cell = tableRow.cells[key];
- rowData_1.push(cell);
- });
- rows.push(rowData_1);
- }
- };
- for (var i = 1; i < tableElem.rows.length; i++) {
- _loop_1(i);
- }
- var values = Object.keys(columns).map(function (key) { return columns[key]; });
- return { columns: values, rows: rows, data: rows };
- };
- /**
- * Improved text function with halign and valign support
- * Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113
- */
- jsPDF.API.autoTableText = function (text, x, y, styles) {
- if (typeof x !== 'number' || typeof y !== 'number') {
- console.error('The x and y parameters are required. Missing for the text: ', text);
- }
- var k = this.internal.scaleFactor;
- var fontSize = this.internal.getFontSize() / k;
- var splitRegex = /\r\n|\r|\n/g;
- var splitText = null;
- var lineCount = 1;
- if (styles.valign === 'middle' || styles.valign === 'bottom' || styles.halign === 'center' || styles.halign === 'right') {
- splitText = typeof text === 'string' ? text.split(splitRegex) : text;
- lineCount = splitText.length || 1;
- }
- // Align the top
- y += fontSize * (2 - config_1.FONT_ROW_RATIO);
- if (styles.valign === 'middle')
- y -= (lineCount / 2) * fontSize * config_1.FONT_ROW_RATIO;
- else if (styles.valign === 'bottom')
- y -= lineCount * fontSize * config_1.FONT_ROW_RATIO;
- if (styles.halign === 'center' || styles.halign === 'right') {
- var alignSize = fontSize;
- if (styles.halign === 'center')
- alignSize *= 0.5;
- if (lineCount >= 1) {
- for (var iLine = 0; iLine < splitText.length; iLine++) {
- this.text(splitText[iLine], x - this.getStringUnitWidth(splitText[iLine]) * alignSize, y);
- y += fontSize;
- }
- return this;
- }
- x -= this.getStringUnitWidth(text) * alignSize;
- }
- this.text(text, x, y);
- return this;
- };
- /**
- * @deprecated Use doc.autoTable.previous.finalY instead
- */
- jsPDF.API.autoTableEndPosY = function () {
- var prev = this.autoTable.previous;
- if (prev.cursor && typeof prev.cursor.y === 'number') {
- return prev.cursor.y;
- }
- else {
- return 0;
- }
- };
- /**
- * @deprecated Use jsPDF.autoTableSetDefaults({addPageContent: function() {}}) instead
- */
- jsPDF.API.autoTableAddPageContent = function (hook) {
- if (!jsPDF.API.autoTable.globalDefaults) {
- jsPDF.API.autoTable.globalDefaults = {};
- }
- jsPDF.API.autoTable.globalDefaults.addPageContent = hook;
- return this;
- };
- /**
- * @deprecated Use data.addPage in hooks instead
- */
- jsPDF.API.autoTableAddPage = function () {
- common_1.addPage();
- return this;
- };
- /***/ }),
- /* 19 */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE__19__;
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var define = __webpack_require__(7);
- var implementation = __webpack_require__(8);
- var getPolyfill = __webpack_require__(16);
- var shim = __webpack_require__(35);
- var polyfill = getPolyfill();
- define(polyfill, {
- getPolyfill: getPolyfill,
- implementation: implementation,
- shim: shim
- });
- module.exports = polyfill;
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // modified from https://github.com/es-shims/es5-shim
- var has = Object.prototype.hasOwnProperty;
- var toStr = Object.prototype.toString;
- var slice = Array.prototype.slice;
- var isArgs = __webpack_require__(22);
- var isEnumerable = Object.prototype.propertyIsEnumerable;
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
- var dontEnums = [
- 'toString',
- 'toLocaleString',
- 'valueOf',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'constructor'
- ];
- var equalsConstructorPrototype = function (o) {
- var ctor = o.constructor;
- return ctor && ctor.prototype === o;
- };
- var excludedKeys = {
- $applicationCache: true,
- $console: true,
- $external: true,
- $frame: true,
- $frameElement: true,
- $frames: true,
- $innerHeight: true,
- $innerWidth: true,
- $outerHeight: true,
- $outerWidth: true,
- $pageXOffset: true,
- $pageYOffset: true,
- $parent: true,
- $scrollLeft: true,
- $scrollTop: true,
- $scrollX: true,
- $scrollY: true,
- $self: true,
- $webkitIndexedDB: true,
- $webkitStorageInfo: true,
- $window: true
- };
- var hasAutomationEqualityBug = (function () {
- /* global window */
- if (typeof window === 'undefined') { return false; }
- for (var k in window) {
- try {
- if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
- try {
- equalsConstructorPrototype(window[k]);
- } catch (e) {
- return true;
- }
- }
- } catch (e) {
- return true;
- }
- }
- return false;
- }());
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
- /* global window */
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
- return equalsConstructorPrototype(o);
- }
- try {
- return equalsConstructorPrototype(o);
- } catch (e) {
- return false;
- }
- };
- var keysShim = function keys(object) {
- var isObject = object !== null && typeof object === 'object';
- var isFunction = toStr.call(object) === '[object Function]';
- var isArguments = isArgs(object);
- var isString = isObject && toStr.call(object) === '[object String]';
- var theKeys = [];
- if (!isObject && !isFunction && !isArguments) {
- throw new TypeError('Object.keys called on a non-object');
- }
- var skipProto = hasProtoEnumBug && isFunction;
- if (isString && object.length > 0 && !has.call(object, 0)) {
- for (var i = 0; i < object.length; ++i) {
- theKeys.push(String(i));
- }
- }
- if (isArguments && object.length > 0) {
- for (var j = 0; j < object.length; ++j) {
- theKeys.push(String(j));
- }
- } else {
- for (var name in object) {
- if (!(skipProto && name === 'prototype') && has.call(object, name)) {
- theKeys.push(String(name));
- }
- }
- }
- if (hasDontEnumBug) {
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
- for (var k = 0; k < dontEnums.length; ++k) {
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
- theKeys.push(dontEnums[k]);
- }
- }
- }
- return theKeys;
- };
- keysShim.shim = function shimObjectKeys() {
- if (Object.keys) {
- var keysWorksWithArguments = (function () {
- // Safari 5.0 bug
- return (Object.keys(arguments) || '').length === 2;
- }(1, 2));
- if (!keysWorksWithArguments) {
- var originalKeys = Object.keys;
- Object.keys = function keys(object) { // eslint-disable-line func-name-matching
- if (isArgs(object)) {
- return originalKeys(slice.call(object));
- } else {
- return originalKeys(object);
- }
- };
- }
- } else {
- Object.keys = keysShim;
- }
- return Object.keys || keysShim;
- };
- module.exports = keysShim;
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var toStr = Object.prototype.toString;
- module.exports = function isArguments(value) {
- var str = toStr.call(value);
- var isArgs = str === '[object Arguments]';
- if (!isArgs) {
- isArgs = str !== '[object Array]' &&
- value !== null &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- value.length >= 0 &&
- toStr.call(value.callee) === '[object Function]';
- }
- return isArgs;
- };
- /***/ }),
- /* 23 */
- /***/ (function(module, exports) {
- var hasOwn = Object.prototype.hasOwnProperty;
- var toString = Object.prototype.toString;
- module.exports = function forEach (obj, fn, ctx) {
- if (toString.call(fn) !== '[object Function]') {
- throw new TypeError('iterator must be a function');
- }
- var l = obj.length;
- if (l === +l) {
- for (var i = 0; i < l; i++) {
- fn.call(ctx, obj[i], i, obj);
- }
- } else {
- for (var k in obj) {
- if (hasOwn.call(obj, k)) {
- fn.call(ctx, obj[k], k, obj);
- }
- }
- }
- };
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = __webpack_require__(25);
- /***/ }),
- /* 25 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var ES2015 = __webpack_require__(26);
- var assign = __webpack_require__(13);
- var ES2016 = assign(assign({}, ES2015), {
- // https://github.com/tc39/ecma262/pull/60
- SameValueNonNumber: function SameValueNonNumber(x, y) {
- if (typeof x === 'number' || typeof x !== typeof y) {
- throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
- }
- return this.SameValue(x, y);
- }
- });
- module.exports = ES2016;
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var has = __webpack_require__(1);
- var toPrimitive = __webpack_require__(28);
- var GetIntrinsic = __webpack_require__(10);
- var $TypeError = GetIntrinsic('%TypeError%');
- var $SyntaxError = GetIntrinsic('%SyntaxError%');
- var $Array = GetIntrinsic('%Array%');
- var $String = GetIntrinsic('%String%');
- var $Object = GetIntrinsic('%Object%');
- var $Number = GetIntrinsic('%Number%');
- var $Symbol = GetIntrinsic('%Symbol%', true);
- var $RegExp = GetIntrinsic('%RegExp%');
- var hasSymbols = !!$Symbol;
- var $isNaN = __webpack_require__(11);
- var $isFinite = __webpack_require__(12);
- var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
- var assign = __webpack_require__(13);
- var sign = __webpack_require__(14);
- var mod = __webpack_require__(15);
- var isPrimitive = __webpack_require__(31);
- var parseInteger = parseInt;
- var bind = __webpack_require__(2);
- var arraySlice = bind.call(Function.call, $Array.prototype.slice);
- var strSlice = bind.call(Function.call, $String.prototype.slice);
- var isBinary = bind.call(Function.call, $RegExp.prototype.test, /^0b[01]+$/i);
- var isOctal = bind.call(Function.call, $RegExp.prototype.test, /^0o[0-7]+$/i);
- var regexExec = bind.call(Function.call, $RegExp.prototype.exec);
- var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
- var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
- var hasNonWS = bind.call(Function.call, $RegExp.prototype.test, nonWSregex);
- var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i;
- var isInvalidHexLiteral = bind.call(Function.call, $RegExp.prototype.test, invalidHexLiteral);
- var $charCodeAt = bind.call(Function.call, $String.prototype.charCodeAt);
- var toStr = bind.call(Function.call, Object.prototype.toString);
- var $floor = Math.floor;
- var $abs = Math.abs;
- var $ObjectCreate = Object.create;
- var $gOPD = $Object.getOwnPropertyDescriptor;
- var $isExtensible = $Object.isExtensible;
- // whitespace from: http://es5.github.io/#x15.5.4.20
- // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
- var ws = [
- '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
- '\u2029\uFEFF'
- ].join('');
- var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
- var replace = bind.call(Function.call, $String.prototype.replace);
- var trim = function (value) {
- return replace(value, trimRegex, '');
- };
- var ES5 = __webpack_require__(32);
- var hasRegExpMatcher = __webpack_require__(34);
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
- var ES6 = assign(assign({}, ES5), {
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
- Call: function Call(F, V) {
- var args = arguments.length > 2 ? arguments[2] : [];
- if (!this.IsCallable(F)) {
- throw new $TypeError(F + ' is not a function');
- }
- return F.apply(V, args);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
- ToPrimitive: toPrimitive,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
- // ToBoolean: ES5.ToBoolean,
- // https://ecma-international.org/ecma-262/6.0/#sec-tonumber
- ToNumber: function ToNumber(argument) {
- var value = isPrimitive(argument) ? argument : toPrimitive(argument, $Number);
- if (typeof value === 'symbol') {
- throw new $TypeError('Cannot convert a Symbol value to a number');
- }
- if (typeof value === 'string') {
- if (isBinary(value)) {
- return this.ToNumber(parseInteger(strSlice(value, 2), 2));
- } else if (isOctal(value)) {
- return this.ToNumber(parseInteger(strSlice(value, 2), 8));
- } else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
- return NaN;
- } else {
- var trimmed = trim(value);
- if (trimmed !== value) {
- return this.ToNumber(trimmed);
- }
- }
- }
- return $Number(value);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
- // ToInteger: ES5.ToNumber,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
- // ToInt32: ES5.ToInt32,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
- // ToUint32: ES5.ToUint32,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
- ToInt16: function ToInt16(argument) {
- var int16bit = this.ToUint16(argument);
- return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
- // ToUint16: ES5.ToUint16,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
- ToInt8: function ToInt8(argument) {
- var int8bit = this.ToUint8(argument);
- return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
- ToUint8: function ToUint8(argument) {
- var number = this.ToNumber(argument);
- if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
- var posInt = sign(number) * $floor($abs(number));
- return mod(posInt, 0x100);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
- ToUint8Clamp: function ToUint8Clamp(argument) {
- var number = this.ToNumber(argument);
- if ($isNaN(number) || number <= 0) { return 0; }
- if (number >= 0xFF) { return 0xFF; }
- var f = $floor(argument);
- if (f + 0.5 < number) { return f + 1; }
- if (number < f + 0.5) { return f; }
- if (f % 2 !== 0) { return f + 1; }
- return f;
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
- ToString: function ToString(argument) {
- if (typeof argument === 'symbol') {
- throw new $TypeError('Cannot convert a Symbol value to a string');
- }
- return $String(argument);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
- ToObject: function ToObject(value) {
- this.RequireObjectCoercible(value);
- return $Object(value);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
- ToPropertyKey: function ToPropertyKey(argument) {
- var key = this.ToPrimitive(argument, $String);
- return typeof key === 'symbol' ? key : this.ToString(key);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
- ToLength: function ToLength(argument) {
- var len = this.ToInteger(argument);
- if (len <= 0) { return 0; } // includes converting -0 to +0
- if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
- return len;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
- CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
- if (toStr(argument) !== '[object String]') {
- throw new $TypeError('must be a string');
- }
- if (argument === '-0') { return -0; }
- var n = this.ToNumber(argument);
- if (this.SameValue(this.ToString(n), argument)) { return n; }
- return void 0;
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
- RequireObjectCoercible: ES5.CheckObjectCoercible,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
- IsArray: $Array.isArray || function IsArray(argument) {
- return toStr(argument) === '[object Array]';
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
- // IsCallable: ES5.IsCallable,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
- IsConstructor: function IsConstructor(argument) {
- return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
- IsExtensible: Object.preventExtensions
- ? function IsExtensible(obj) {
- if (isPrimitive(obj)) {
- return false;
- }
- return $isExtensible(obj);
- }
- : function isExtensible(obj) { return true; }, // eslint-disable-line no-unused-vars
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
- IsInteger: function IsInteger(argument) {
- if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
- return false;
- }
- var abs = $abs(argument);
- return $floor(abs) === abs;
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
- IsPropertyKey: function IsPropertyKey(argument) {
- return typeof argument === 'string' || typeof argument === 'symbol';
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
- IsRegExp: function IsRegExp(argument) {
- if (!argument || typeof argument !== 'object') {
- return false;
- }
- if (hasSymbols) {
- var isRegExp = argument[$Symbol.match];
- if (typeof isRegExp !== 'undefined') {
- return ES5.ToBoolean(isRegExp);
- }
- }
- return hasRegExpMatcher(argument);
- },
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
- // SameValue: ES5.SameValue,
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
- SameValueZero: function SameValueZero(x, y) {
- return (x === y) || ($isNaN(x) && $isNaN(y));
- },
- /**
- * 7.3.2 GetV (V, P)
- * 1. Assert: IsPropertyKey(P) is true.
- * 2. Let O be ToObject(V).
- * 3. ReturnIfAbrupt(O).
- * 4. Return O.[[Get]](P, V).
- */
- GetV: function GetV(V, P) {
- // 7.3.2.1
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
- }
- // 7.3.2.2-3
- var O = this.ToObject(V);
- // 7.3.2.4
- return O[P];
- },
- /**
- * 7.3.9 - https://ecma-international.org/ecma-262/6.0/#sec-getmethod
- * 1. Assert: IsPropertyKey(P) is true.
- * 2. Let func be GetV(O, P).
- * 3. ReturnIfAbrupt(func).
- * 4. If func is either undefined or null, return undefined.
- * 5. If IsCallable(func) is false, throw a TypeError exception.
- * 6. Return func.
- */
- GetMethod: function GetMethod(O, P) {
- // 7.3.9.1
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
- }
- // 7.3.9.2
- var func = this.GetV(O, P);
- // 7.3.9.4
- if (func == null) {
- return void 0;
- }
- // 7.3.9.5
- if (!this.IsCallable(func)) {
- throw new $TypeError(P + 'is not a function');
- }
- // 7.3.9.6
- return func;
- },
- /**
- * 7.3.1 Get (O, P) - https://ecma-international.org/ecma-262/6.0/#sec-get-o-p
- * 1. Assert: Type(O) is Object.
- * 2. Assert: IsPropertyKey(P) is true.
- * 3. Return O.[[Get]](P, O).
- */
- Get: function Get(O, P) {
- // 7.3.1.1
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(O) is not Object');
- }
- // 7.3.1.2
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
- }
- // 7.3.1.3
- return O[P];
- },
- Type: function Type(x) {
- if (typeof x === 'symbol') {
- return 'Symbol';
- }
- return ES5.Type(x);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
- SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(O) is not Object');
- }
- var C = O.constructor;
- if (typeof C === 'undefined') {
- return defaultConstructor;
- }
- if (this.Type(C) !== 'Object') {
- throw new $TypeError('O.constructor is not an Object');
- }
- var S = hasSymbols && $Symbol.species ? C[$Symbol.species] : void 0;
- if (S == null) {
- return defaultConstructor;
- }
- if (this.IsConstructor(S)) {
- return S;
- }
- throw new $TypeError('no constructor found');
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor
- CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) {
- if (!this.IsPropertyDescriptor(Desc)) {
- throw new $TypeError('Desc must be a Property Descriptor');
- }
- if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
- if (!has(Desc, '[[Value]]')) {
- Desc['[[Value]]'] = void 0;
- }
- if (!has(Desc, '[[Writable]]')) {
- Desc['[[Writable]]'] = false;
- }
- } else {
- if (!has(Desc, '[[Get]]')) {
- Desc['[[Get]]'] = void 0;
- }
- if (!has(Desc, '[[Set]]')) {
- Desc['[[Set]]'] = void 0;
- }
- }
- if (!has(Desc, '[[Enumerable]]')) {
- Desc['[[Enumerable]]'] = false;
- }
- if (!has(Desc, '[[Configurable]]')) {
- Desc['[[Configurable]]'] = false;
- }
- return Desc;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw
- Set: function Set(O, P, V, Throw) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('O must be an Object');
- }
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('P must be a Property Key');
- }
- if (this.Type(Throw) !== 'Boolean') {
- throw new $TypeError('Throw must be a Boolean');
- }
- if (Throw) {
- O[P] = V;
- return true;
- } else {
- try {
- O[P] = V;
- } catch (e) {
- return false;
- }
- }
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty
- HasOwnProperty: function HasOwnProperty(O, P) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('O must be an Object');
- }
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('P must be a Property Key');
- }
- return has(O, P);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-hasproperty
- HasProperty: function HasProperty(O, P) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('O must be an Object');
- }
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('P must be a Property Key');
- }
- return P in O;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
- IsConcatSpreadable: function IsConcatSpreadable(O) {
- if (this.Type(O) !== 'Object') {
- return false;
- }
- if (hasSymbols && typeof $Symbol.isConcatSpreadable === 'symbol') {
- var spreadable = this.Get(O, Symbol.isConcatSpreadable);
- if (typeof spreadable !== 'undefined') {
- return this.ToBoolean(spreadable);
- }
- }
- return this.IsArray(O);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-invoke
- Invoke: function Invoke(O, P) {
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('P must be a Property Key');
- }
- var argumentsList = arraySlice(arguments, 2);
- var func = this.GetV(O, P);
- return this.Call(func, O, argumentsList);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-getiterator
- GetIterator: function GetIterator(obj, method) {
- if (!hasSymbols) {
- throw new SyntaxError('ES.GetIterator depends on native iterator support.');
- }
- var actualMethod = method;
- if (arguments.length < 2) {
- actualMethod = this.GetMethod(obj, $Symbol.iterator);
- }
- var iterator = this.Call(actualMethod, obj);
- if (this.Type(iterator) !== 'Object') {
- throw new $TypeError('iterator must return an object');
- }
- return iterator;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-iteratornext
- IteratorNext: function IteratorNext(iterator, value) {
- var result = this.Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]);
- if (this.Type(result) !== 'Object') {
- throw new $TypeError('iterator next must return an object');
- }
- return result;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete
- IteratorComplete: function IteratorComplete(iterResult) {
- if (this.Type(iterResult) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
- }
- return this.ToBoolean(this.Get(iterResult, 'done'));
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue
- IteratorValue: function IteratorValue(iterResult) {
- if (this.Type(iterResult) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
- }
- return this.Get(iterResult, 'value');
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep
- IteratorStep: function IteratorStep(iterator) {
- var result = this.IteratorNext(iterator);
- var done = this.IteratorComplete(result);
- return done === true ? false : result;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose
- IteratorClose: function IteratorClose(iterator, completion) {
- if (this.Type(iterator) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(iterator) is not Object');
- }
- if (!this.IsCallable(completion)) {
- throw new $TypeError('Assertion failed: completion is not a thunk for a Completion Record');
- }
- var completionThunk = completion;
- var iteratorReturn = this.GetMethod(iterator, 'return');
- if (typeof iteratorReturn === 'undefined') {
- return completionThunk();
- }
- var completionRecord;
- try {
- var innerResult = this.Call(iteratorReturn, iterator, []);
- } catch (e) {
- // if we hit here, then "e" is the innerResult completion that needs re-throwing
- // if the completion is of type "throw", this will throw.
- completionRecord = completionThunk();
- completionThunk = null; // ensure it's not called twice.
- // if not, then return the innerResult completion
- throw e;
- }
- completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does
- completionThunk = null; // ensure it's not called twice.
- if (this.Type(innerResult) !== 'Object') {
- throw new $TypeError('iterator .return must return an object');
- }
- return completionRecord;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject
- CreateIterResultObject: function CreateIterResultObject(value, done) {
- if (this.Type(done) !== 'Boolean') {
- throw new $TypeError('Assertion failed: Type(done) is not Boolean');
- }
- return {
- value: value,
- done: done
- };
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-regexpexec
- RegExpExec: function RegExpExec(R, S) {
- if (this.Type(R) !== 'Object') {
- throw new $TypeError('R must be an Object');
- }
- if (this.Type(S) !== 'String') {
- throw new $TypeError('S must be a String');
- }
- var exec = this.Get(R, 'exec');
- if (this.IsCallable(exec)) {
- var result = this.Call(exec, R, [S]);
- if (result === null || this.Type(result) === 'Object') {
- return result;
- }
- throw new $TypeError('"exec" method must return `null` or an Object');
- }
- return regexExec(R, S);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate
- ArraySpeciesCreate: function ArraySpeciesCreate(originalArray, length) {
- if (!this.IsInteger(length) || length < 0) {
- throw new $TypeError('Assertion failed: length must be an integer >= 0');
- }
- var len = length === 0 ? 0 : length;
- var C;
- var isArray = this.IsArray(originalArray);
- if (isArray) {
- C = this.Get(originalArray, 'constructor');
- // TODO: figure out how to make a cross-realm normal Array, a same-realm Array
- // if (this.IsConstructor(C)) {
- // if C is another realm's Array, C = undefined
- // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ?
- // }
- if (this.Type(C) === 'Object' && hasSymbols && $Symbol.species) {
- C = this.Get(C, $Symbol.species);
- if (C === null) {
- C = void 0;
- }
- }
- }
- if (typeof C === 'undefined') {
- return $Array(len);
- }
- if (!this.IsConstructor(C)) {
- throw new $TypeError('C must be a constructor');
- }
- return new C(len); // this.Construct(C, len);
- },
- CreateDataProperty: function CreateDataProperty(O, P, V) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(O) is not Object');
- }
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
- }
- var oldDesc = $gOPD(O, P);
- var extensible = oldDesc || (typeof $isExtensible !== 'function' || $isExtensible(O));
- var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
- if (immutable || !extensible) {
- return false;
- }
- var newDesc = {
- configurable: true,
- enumerable: true,
- value: V,
- writable: true
- };
- Object.defineProperty(O, P, newDesc);
- return true;
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow
- CreateDataPropertyOrThrow: function CreateDataPropertyOrThrow(O, P, V) {
- if (this.Type(O) !== 'Object') {
- throw new $TypeError('Assertion failed: Type(O) is not Object');
- }
- if (!this.IsPropertyKey(P)) {
- throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
- }
- var success = this.CreateDataProperty(O, P, V);
- if (!success) {
- throw new $TypeError('unable to create data property');
- }
- return success;
- },
- // https://www.ecma-international.org/ecma-262/6.0/#sec-objectcreate
- ObjectCreate: function ObjectCreate(proto, internalSlotsList) {
- if (proto !== null && this.Type(proto) !== 'Object') {
- throw new $TypeError('Assertion failed: proto must be null or an object');
- }
- var slots = arguments.length < 2 ? [] : internalSlotsList;
- if (slots.length > 0) {
- throw new $SyntaxError('es-abstract does not yet support internal slots');
- }
- if (proto === null && !$ObjectCreate) {
- throw new $SyntaxError('native Object.create support is required to create null objects');
- }
- return $ObjectCreate(proto);
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex
- AdvanceStringIndex: function AdvanceStringIndex(S, index, unicode) {
- if (this.Type(S) !== 'String') {
- throw new $TypeError('S must be a String');
- }
- if (!this.IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
- throw new $TypeError('Assertion failed: length must be an integer >= 0 and <= 2**53');
- }
- if (this.Type(unicode) !== 'Boolean') {
- throw new $TypeError('Assertion failed: unicode must be a Boolean');
- }
- if (!unicode) {
- return index + 1;
- }
- var length = S.length;
- if ((index + 1) >= length) {
- return index + 1;
- }
- var first = $charCodeAt(S, index);
- if (first < 0xD800 || first > 0xDBFF) {
- return index + 1;
- }
- var second = $charCodeAt(S, index + 1);
- if (second < 0xDC00 || second > 0xDFFF) {
- return index + 1;
- }
- return index + 2;
- }
- });
- delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
- module.exports = ES6;
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /* eslint no-invalid-this: 1 */
- var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
- var slice = Array.prototype.slice;
- var toStr = Object.prototype.toString;
- var funcType = '[object Function]';
- module.exports = function bind(that) {
- var target = this;
- if (typeof target !== 'function' || toStr.call(target) !== funcType) {
- throw new TypeError(ERROR_MESSAGE + target);
- }
- var args = slice.call(arguments, 1);
- var bound;
- var binder = function () {
- if (this instanceof bound) {
- var result = target.apply(
- this,
- args.concat(slice.call(arguments))
- );
- if (Object(result) === result) {
- return result;
- }
- return this;
- } else {
- return target.apply(
- that,
- args.concat(slice.call(arguments))
- );
- }
- };
- var boundLength = Math.max(0, target.length - args.length);
- var boundArgs = [];
- for (var i = 0; i < boundLength; i++) {
- boundArgs.push('$' + i);
- }
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
- if (target.prototype) {
- var Empty = function Empty() {};
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
- Empty.prototype = null;
- }
- return bound;
- };
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
- var isPrimitive = __webpack_require__(9);
- var isCallable = __webpack_require__(3);
- var isDate = __webpack_require__(29);
- var isSymbol = __webpack_require__(30);
- var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
- if (typeof O === 'undefined' || O === null) {
- throw new TypeError('Cannot call method on ' + O);
- }
- if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
- throw new TypeError('hint must be "string" or "number"');
- }
- var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
- var method, result, i;
- for (i = 0; i < methodNames.length; ++i) {
- method = O[methodNames[i]];
- if (isCallable(method)) {
- result = method.call(O);
- if (isPrimitive(result)) {
- return result;
- }
- }
- }
- throw new TypeError('No default value');
- };
- var GetMethod = function GetMethod(O, P) {
- var func = O[P];
- if (func !== null && typeof func !== 'undefined') {
- if (!isCallable(func)) {
- throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
- }
- return func;
- }
- };
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
- module.exports = function ToPrimitive(input, PreferredType) {
- if (isPrimitive(input)) {
- return input;
- }
- var hint = 'default';
- if (arguments.length > 1) {
- if (PreferredType === String) {
- hint = 'string';
- } else if (PreferredType === Number) {
- hint = 'number';
- }
- }
- var exoticToPrim;
- if (hasSymbols) {
- if (Symbol.toPrimitive) {
- exoticToPrim = GetMethod(input, Symbol.toPrimitive);
- } else if (isSymbol(input)) {
- exoticToPrim = Symbol.prototype.valueOf;
- }
- }
- if (typeof exoticToPrim !== 'undefined') {
- var result = exoticToPrim.call(input, hint);
- if (isPrimitive(result)) {
- return result;
- }
- throw new TypeError('unable to convert exotic object to primitive');
- }
- if (hint === 'default' && (isDate(input) || isSymbol(input))) {
- hint = 'string';
- }
- return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
- };
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var getDay = Date.prototype.getDay;
- var tryDateObject = function tryDateObject(value) {
- try {
- getDay.call(value);
- return true;
- } catch (e) {
- return false;
- }
- };
- var toStr = Object.prototype.toString;
- var dateClass = '[object Date]';
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
- module.exports = function isDateObject(value) {
- if (typeof value !== 'object' || value === null) { return false; }
- return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
- };
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var toStr = Object.prototype.toString;
- var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
- if (hasSymbols) {
- var symToStr = Symbol.prototype.toString;
- var symStringRegex = /^Symbol\(.*\)$/;
- var isSymbolObject = function isSymbolObject(value) {
- if (typeof value.valueOf() !== 'symbol') { return false; }
- return symStringRegex.test(symToStr.call(value));
- };
- module.exports = function isSymbol(value) {
- if (typeof value === 'symbol') { return true; }
- if (toStr.call(value) !== '[object Symbol]') { return false; }
- try {
- return isSymbolObject(value);
- } catch (e) {
- return false;
- }
- };
- } else {
- module.exports = function isSymbol(value) {
- // this environment does not support Symbols.
- return false;
- };
- }
- /***/ }),
- /* 31 */
- /***/ (function(module, exports) {
- module.exports = function isPrimitive(value) {
- return value === null || (typeof value !== 'function' && typeof value !== 'object');
- };
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var GetIntrinsic = __webpack_require__(10);
- var $Object = GetIntrinsic('%Object%');
- var $TypeError = GetIntrinsic('%TypeError%');
- var $String = GetIntrinsic('%String%');
- var $isNaN = __webpack_require__(11);
- var $isFinite = __webpack_require__(12);
- var sign = __webpack_require__(14);
- var mod = __webpack_require__(15);
- var IsCallable = __webpack_require__(3);
- var toPrimitive = __webpack_require__(33);
- var has = __webpack_require__(1);
- // https://es5.github.io/#x9
- var ES5 = {
- ToPrimitive: toPrimitive,
- ToBoolean: function ToBoolean(value) {
- return !!value;
- },
- ToNumber: function ToNumber(value) {
- return +value; // eslint-disable-line no-implicit-coercion
- },
- ToInteger: function ToInteger(value) {
- var number = this.ToNumber(value);
- if ($isNaN(number)) { return 0; }
- if (number === 0 || !$isFinite(number)) { return number; }
- return sign(number) * Math.floor(Math.abs(number));
- },
- ToInt32: function ToInt32(x) {
- return this.ToNumber(x) >> 0;
- },
- ToUint32: function ToUint32(x) {
- return this.ToNumber(x) >>> 0;
- },
- ToUint16: function ToUint16(value) {
- var number = this.ToNumber(value);
- if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
- var posInt = sign(number) * Math.floor(Math.abs(number));
- return mod(posInt, 0x10000);
- },
- ToString: function ToString(value) {
- return $String(value);
- },
- ToObject: function ToObject(value) {
- this.CheckObjectCoercible(value);
- return $Object(value);
- },
- CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
- /* jshint eqnull:true */
- if (value == null) {
- throw new $TypeError(optMessage || 'Cannot call method on ' + value);
- }
- return value;
- },
- IsCallable: IsCallable,
- SameValue: function SameValue(x, y) {
- if (x === y) { // 0 === -0, but they are not identical.
- if (x === 0) { return 1 / x === 1 / y; }
- return true;
- }
- return $isNaN(x) && $isNaN(y);
- },
- // https://www.ecma-international.org/ecma-262/5.1/#sec-8
- Type: function Type(x) {
- if (x === null) {
- return 'Null';
- }
- if (typeof x === 'undefined') {
- return 'Undefined';
- }
- if (typeof x === 'function' || typeof x === 'object') {
- return 'Object';
- }
- if (typeof x === 'number') {
- return 'Number';
- }
- if (typeof x === 'boolean') {
- return 'Boolean';
- }
- if (typeof x === 'string') {
- return 'String';
- }
- },
- // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
- IsPropertyDescriptor: function IsPropertyDescriptor(Desc) {
- if (this.Type(Desc) !== 'Object') {
- return false;
- }
- var allowed = {
- '[[Configurable]]': true,
- '[[Enumerable]]': true,
- '[[Get]]': true,
- '[[Set]]': true,
- '[[Value]]': true,
- '[[Writable]]': true
- };
- // jscs:disable
- for (var key in Desc) { // eslint-disable-line
- if (has(Desc, key) && !allowed[key]) {
- return false;
- }
- }
- // jscs:enable
- var isData = has(Desc, '[[Value]]');
- var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]');
- if (isData && IsAccessor) {
- throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
- }
- return true;
- },
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.1
- IsAccessorDescriptor: function IsAccessorDescriptor(Desc) {
- if (typeof Desc === 'undefined') {
- return false;
- }
- if (!this.IsPropertyDescriptor(Desc)) {
- throw new $TypeError('Desc must be a Property Descriptor');
- }
- if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) {
- return false;
- }
- return true;
- },
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.2
- IsDataDescriptor: function IsDataDescriptor(Desc) {
- if (typeof Desc === 'undefined') {
- return false;
- }
- if (!this.IsPropertyDescriptor(Desc)) {
- throw new $TypeError('Desc must be a Property Descriptor');
- }
- if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
- return false;
- }
- return true;
- },
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.3
- IsGenericDescriptor: function IsGenericDescriptor(Desc) {
- if (typeof Desc === 'undefined') {
- return false;
- }
- if (!this.IsPropertyDescriptor(Desc)) {
- throw new $TypeError('Desc must be a Property Descriptor');
- }
- if (!this.IsAccessorDescriptor(Desc) && !this.IsDataDescriptor(Desc)) {
- return true;
- }
- return false;
- },
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.4
- FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
- if (typeof Desc === 'undefined') {
- return Desc;
- }
- if (!this.IsPropertyDescriptor(Desc)) {
- throw new $TypeError('Desc must be a Property Descriptor');
- }
- if (this.IsDataDescriptor(Desc)) {
- return {
- value: Desc['[[Value]]'],
- writable: !!Desc['[[Writable]]'],
- enumerable: !!Desc['[[Enumerable]]'],
- configurable: !!Desc['[[Configurable]]']
- };
- } else if (this.IsAccessorDescriptor(Desc)) {
- return {
- get: Desc['[[Get]]'],
- set: Desc['[[Set]]'],
- enumerable: !!Desc['[[Enumerable]]'],
- configurable: !!Desc['[[Configurable]]']
- };
- } else {
- throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor');
- }
- },
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.5
- ToPropertyDescriptor: function ToPropertyDescriptor(Obj) {
- if (this.Type(Obj) !== 'Object') {
- throw new $TypeError('ToPropertyDescriptor requires an object');
- }
- var desc = {};
- if (has(Obj, 'enumerable')) {
- desc['[[Enumerable]]'] = this.ToBoolean(Obj.enumerable);
- }
- if (has(Obj, 'configurable')) {
- desc['[[Configurable]]'] = this.ToBoolean(Obj.configurable);
- }
- if (has(Obj, 'value')) {
- desc['[[Value]]'] = Obj.value;
- }
- if (has(Obj, 'writable')) {
- desc['[[Writable]]'] = this.ToBoolean(Obj.writable);
- }
- if (has(Obj, 'get')) {
- var getter = Obj.get;
- if (typeof getter !== 'undefined' && !this.IsCallable(getter)) {
- throw new TypeError('getter must be a function');
- }
- desc['[[Get]]'] = getter;
- }
- if (has(Obj, 'set')) {
- var setter = Obj.set;
- if (typeof setter !== 'undefined' && !this.IsCallable(setter)) {
- throw new $TypeError('setter must be a function');
- }
- desc['[[Set]]'] = setter;
- }
- if ((has(desc, '[[Get]]') || has(desc, '[[Set]]')) && (has(desc, '[[Value]]') || has(desc, '[[Writable]]'))) {
- throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
- }
- return desc;
- }
- };
- module.exports = ES5;
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var toStr = Object.prototype.toString;
- var isPrimitive = __webpack_require__(9);
- var isCallable = __webpack_require__(3);
- // https://es5.github.io/#x8.12
- var ES5internalSlots = {
- '[[DefaultValue]]': function (O, hint) {
- var actualHint = hint || (toStr.call(O) === '[object Date]' ? String : Number);
- if (actualHint === String || actualHint === Number) {
- var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
- var value, i;
- for (i = 0; i < methods.length; ++i) {
- if (isCallable(O[methods[i]])) {
- value = O[methods[i]]();
- if (isPrimitive(value)) {
- return value;
- }
- }
- }
- throw new TypeError('No default value');
- }
- throw new TypeError('invalid [[DefaultValue]] hint supplied');
- }
- };
- // https://es5.github.io/#x9
- module.exports = function ToPrimitive(input, PreferredType) {
- if (isPrimitive(input)) {
- return input;
- }
- return ES5internalSlots['[[DefaultValue]]'](input, PreferredType);
- };
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var has = __webpack_require__(1);
- var regexExec = RegExp.prototype.exec;
- var gOPD = Object.getOwnPropertyDescriptor;
- var tryRegexExecCall = function tryRegexExec(value) {
- try {
- var lastIndex = value.lastIndex;
- value.lastIndex = 0;
- regexExec.call(value);
- return true;
- } catch (e) {
- return false;
- } finally {
- value.lastIndex = lastIndex;
- }
- };
- var toStr = Object.prototype.toString;
- var regexClass = '[object RegExp]';
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
- module.exports = function isRegex(value) {
- if (!value || typeof value !== 'object') {
- return false;
- }
- if (!hasToStringTag) {
- return toStr.call(value) === regexClass;
- }
- var descriptor = gOPD(value, 'lastIndex');
- var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
- if (!hasLastIndexDataProperty) {
- return false;
- }
- return tryRegexExecCall(value);
- };
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var getPolyfill = __webpack_require__(16);
- var define = __webpack_require__(7);
- module.exports = function shimEntries() {
- var polyfill = getPolyfill();
- define(Object, { entries: polyfill }, {
- entries: function testEntries() {
- return Object.entries !== polyfill;
- }
- });
- return polyfill;
- };
- /***/ }),
- /* 36 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var config_1 = __webpack_require__(0);
- var common_1 = __webpack_require__(4);
- /**
- * Calculate the column widths
- */
- function calculateWidths(doc, pageWidth) {
- var table = config_1.Config.tableInstance();
- // Column and table content width
- var fixedWidth = 0;
- var autoWidth = 0;
- var dynamicColumns = [];
- table.columns.forEach(function (column) {
- column.contentWidth = 0;
- table.rows.concat(table.headerRow).forEach(function (row) {
- var cell = row.cells[column.dataKey];
- cell.contentWidth = cell.padding('horizontal') + common_1.getStringWidth(cell.text, cell.styles);
- if (cell.contentWidth > column.contentWidth) {
- column.contentWidth = cell.contentWidth;
- }
- });
- table.contentWidth += column.contentWidth;
- if (typeof column.widthStyle === 'number') {
- column.preferredWidth = column.widthStyle;
- fixedWidth += column.preferredWidth;
- column.width = column.preferredWidth;
- }
- else if (column.widthStyle === 'wrap') {
- column.preferredWidth = column.contentWidth;
- fixedWidth += column.preferredWidth;
- column.width = column.preferredWidth;
- }
- else {
- column.preferredWidth = column.contentWidth;
- autoWidth += column.contentWidth;
- dynamicColumns.push(column);
- }
- table.preferredWidth += column.preferredWidth;
- });
- if (typeof table.settings.tableWidth === 'number') {
- table.width = table.settings.tableWidth;
- }
- else if (table.settings.tableWidth === 'wrap') {
- table.width = table.preferredWidth;
- }
- else {
- table.width = pageWidth - table.margin('left') - table.margin('right');
- }
- distributeWidth(dynamicColumns, fixedWidth, autoWidth, 0);
- // Row height, table height and text overflow
- var all = table.rows.concat(table.headerRow);
- all.forEach(function (row) {
- table.columns.forEach(function (col) {
- var cell = row.cells[col.dataKey];
- config_1.Config.applyStyles(cell.styles);
- var textSpace = col.width - cell.padding('horizontal');
- var k = config_1.Config.scaleFactor();
- if (cell.styles.overflow === 'linebreak') {
- // Add one pt to textSpace to fix rounding error
- try {
- cell.text = doc.splitTextToSize(cell.text, textSpace + 1 / k, { fontSize: cell.styles.fontSize });
- }
- catch (e) {
- if (e instanceof TypeError && Array.isArray(cell.text)) {
- cell.text = doc.splitTextToSize(cell.text.join(' '), textSpace + 1 / k, { fontSize: cell.styles.fontSize });
- }
- else {
- throw e;
- }
- }
- }
- else if (cell.styles.overflow === 'ellipsize') {
- cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles);
- }
- else if (cell.styles.overflow === 'visible') {
- // Do nothing
- }
- else if (cell.styles.overflow === 'hidden') {
- cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles, '');
- }
- else if (typeof cell.styles.overflow === 'function') {
- cell.text = cell.styles.overflow(cell.text, textSpace);
- }
- else {
- console.error("Unrecognized overflow type: " + cell.styles.overflow);
- }
- var lineCount = Array.isArray(cell.text) ? cell.text.length : 1;
- var fontHeight = cell.styles.fontSize / k * config_1.FONT_ROW_RATIO;
- cell.contentHeight = lineCount * fontHeight + cell.padding('vertical');
- if (cell.contentHeight > row.height) {
- row.height = cell.contentHeight;
- row.maxLineCount = lineCount;
- }
- });
- table.height += row.height;
- });
- }
- exports.calculateWidths = calculateWidths;
- function distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth) {
- var table = config_1.Config.tableInstance();
- var extraWidth = table.width - staticWidth - dynamicColumnsContentWidth;
- for (var i = 0; i < dynamicColumns.length; i++) {
- var col = dynamicColumns[i];
- var ratio = col.contentWidth / dynamicColumnsContentWidth;
- // A column turned out to be none dynamic, start over recursively
- var isNoneDynamic = col.contentWidth + extraWidth * ratio < fairWidth;
- if (extraWidth < 0 && isNoneDynamic) {
- dynamicColumns.splice(i, 1);
- dynamicColumnsContentWidth -= col.contentWidth;
- col.width = fairWidth;
- staticWidth += col.width;
- distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth);
- break;
- }
- else {
- col.width = col.contentWidth + extraWidth * ratio;
- }
- }
- }
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- var models_1 = __webpack_require__(5);
- var config_1 = __webpack_require__(0);
- var assign = __webpack_require__(6);
- function validateInput(headers, data, allOptions) {
- if (!headers || typeof headers !== 'object') {
- console.error("The headers should be an object or array, is: " + typeof headers);
- }
- if (!data || typeof data !== 'object') {
- console.error("The data should be an object or array, is: " + typeof data);
- }
- var _loop_1 = function (settings) {
- if (settings && typeof settings !== 'object') {
- console.error("The options parameter should be of type object, is: " + typeof settings);
- }
- if (typeof settings.extendWidth !== 'undefined') {
- settings.tableWidth = settings.extendWidth ? 'auto' : 'wrap';
- console.error("Use of deprecated option: extendWidth, use tableWidth instead.");
- }
- if (typeof settings.margins !== 'undefined') {
- if (typeof settings.margin === 'undefined')
- settings.margin = settings.margins;
- console.error("Use of deprecated option: margins, use margin instead.");
- }
- if (typeof settings.afterPageContent !== 'undefined' || typeof settings.beforePageContent !== 'undefined' || typeof settings.afterPageAdd !== 'undefined') {
- console.error("The afterPageContent, beforePageContent and afterPageAdd hooks are deprecated. Use addPageContent instead");
- if (typeof settings.addPageContent === 'undefined') {
- settings.addPageContent = function (data) {
- config_1.Config.applyUserStyles();
- if (settings.beforePageContent)
- settings.beforePageContent(data);
- config_1.Config.applyUserStyles();
- if (settings.afterPageContent)
- settings.afterPageContent(data);
- config_1.Config.applyUserStyles();
- if (settings.afterPageAdd && data.pageCount > 1) {
- data.afterPageAdd(data);
- }
- config_1.Config.applyUserStyles();
- };
- }
- }
- [['padding', 'cellPadding'], ['lineHeight', 'rowHeight'], 'fontSize', 'overflow'].forEach(function (o) {
- var deprecatedOption = typeof o === 'string' ? o : o[0];
- var style = typeof o === 'string' ? o : o[1];
- if (typeof settings[deprecatedOption] !== 'undefined') {
- if (typeof settings.styles[style] === 'undefined') {
- settings.styles[style] = settings[deprecatedOption];
- }
- console.error("Use of deprecated option: " + deprecatedOption + ", use the style " + style + " instead.");
- }
- });
- for (var _i = 0, _a = ['styles', 'bodyStyles', 'headerStyles', 'columnStyles']; _i < _a.length; _i++) {
- var styleProp = _a[_i];
- if (settings[styleProp] && typeof settings[styleProp] !== 'object') {
- console.error("The " + styleProp + " style should be of type object, is: " + typeof settings[styleProp]);
- }
- else if (settings[styleProp] && settings[styleProp].rowHeight) {
- console.error("Use of deprecated style: rowHeight, use vertical cell padding instead");
- }
- }
- };
- for (var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++) {
- var settings = allOptions_1[_i];
- _loop_1(settings);
- }
- }
- exports.validateInput = validateInput;
- /**
- * Create models from the user input
- *
- * @param inputHeaders
- * @param inputData
- */
- function createModels(inputHeaders, inputData) {
- var splitRegex = /\r\n|\r|\n/g;
- var table = config_1.Config.tableInstance();
- var settings = table.settings;
- var theme = config_1.getTheme(settings.theme);
- // Header row and columns
- var headerRow = new models_1.Row(inputHeaders, -1);
- headerRow.index = -1;
- // Columns and header row
- inputHeaders.forEach(function (rawColumn, index) {
- var dataKey = index;
- if (typeof rawColumn.dataKey !== 'undefined') {
- dataKey = rawColumn.dataKey;
- }
- else if (typeof rawColumn.key !== 'undefined') {
- console.error("Deprecation warning: Use dataKey instead of key");
- dataKey = rawColumn.key; // deprecated since 2.x
- }
- var col = new models_1.Column(dataKey, index);
- col.raw = rawColumn;
- col.widthStyle = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.columnStyles[col.dataKey] || {}]).columnWidth;
- table.columns.push(col);
- var cell = new models_1.Cell(rawColumn);
- cell.styles = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.headerStyles]);
- if (cell.raw instanceof HTMLElement) {
- cell.text = (cell.raw.innerText || '').trim();
- }
- else {
- var text = typeof cell.raw === 'object' ? cell.raw.title : cell.raw;
- // Stringify 0 and false, but not undefined
- cell.text = typeof cell.raw !== 'undefined' ? '' + text : '';
- }
- cell.text = cell.text.split(splitRegex);
- headerRow.cells[dataKey] = cell;
- for (var _i = 0, _a = table.hooks.createdHeaderCell; _i < _a.length; _i++) {
- var hook = _a[_i];
- hook(cell, { cell: cell, column: col, row: headerRow, settings: settings });
- }
- });
- table.headerRow = headerRow;
- // Rows och cells
- inputData.forEach(function (rawRow, i) {
- var row = new models_1.Row(rawRow, i);
- var rowStyles = i % 2 === 0 ? assign({}, theme.alternateRow, table.styles.alternateRowStyles) : {};
- table.columns.forEach(function (column) {
- var cell = new models_1.Cell(rawRow[column.dataKey]);
- var colStyles = table.styles.columnStyles[column.dataKey] || {};
- cell.styles = config_1.Config.styles([theme.table, theme.body, table.styles.styles, table.styles.bodyStyles, rowStyles, colStyles]);
- if (cell.raw && cell.raw instanceof HTMLElement) {
- cell.text = (cell.raw.innerText || '').trim();
- }
- else {
- // Stringify 0 and false, but not undefined
- cell.text = typeof cell.raw !== 'undefined' ? '' + cell.raw : '';
- }
- cell.text = cell.text.split(splitRegex);
- row.cells[column.dataKey] = cell;
- for (var _i = 0, _a = table.hooks.createdCell; _i < _a.length; _i++) {
- var hook = _a[_i];
- hook(cell, config_1.Config.hooksData({ cell: cell, column: column, row: row }));
- }
- });
- table.rows.push(row);
- });
- }
- exports.createModels = createModels;
- /***/ })
- /******/ ]);
- });
|