jspdf.autotable.js 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343
  1. /*!
  2. * jsPDF AutoTable plugin v2.3.0
  3. * Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
  4. *
  5. * Licensed under the MIT License.
  6. * http://opensource.org/licenses/mit-license
  7. *
  8. * */if (typeof window === 'object') window.jspdfAutoTableVersion = '2.3.0';/*
  9. */
  10. (function webpackUniversalModuleDefinition(root, factory) {
  11. if(typeof exports === 'object' && typeof module === 'object')
  12. module.exports = factory(require("jspdf"));
  13. else if(typeof define === 'function' && define.amd)
  14. define(["jspdf"], factory);
  15. else {
  16. var a = typeof exports === 'object' ? factory(require("jspdf")) : factory(root["jsPDF"]);
  17. for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
  18. }
  19. })(this, function(__WEBPACK_EXTERNAL_MODULE_18__) {
  20. return /******/ (function(modules) { // webpackBootstrap
  21. /******/ // The module cache
  22. /******/ var installedModules = {};
  23. /******/ // The require function
  24. /******/ function __webpack_require__(moduleId) {
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId])
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ // Create a new module (and put it into the cache)
  29. /******/ var module = installedModules[moduleId] = {
  30. /******/ i: moduleId,
  31. /******/ l: false,
  32. /******/ exports: {}
  33. /******/ };
  34. /******/ // Execute the module function
  35. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36. /******/ // Flag the module as loaded
  37. /******/ module.l = true;
  38. /******/ // Return the exports of the module
  39. /******/ return module.exports;
  40. /******/ }
  41. /******/ // expose the modules object (__webpack_modules__)
  42. /******/ __webpack_require__.m = modules;
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/ // identity function for calling harmony imports with the correct context
  46. /******/ __webpack_require__.i = function(value) { return value; };
  47. /******/ // define getter function for harmony exports
  48. /******/ __webpack_require__.d = function(exports, name, getter) {
  49. /******/ if(!__webpack_require__.o(exports, name)) {
  50. /******/ Object.defineProperty(exports, name, {
  51. /******/ configurable: false,
  52. /******/ enumerable: true,
  53. /******/ get: getter
  54. /******/ });
  55. /******/ }
  56. /******/ };
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/ // Object.prototype.hasOwnProperty.call
  66. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  67. /******/ // __webpack_public_path__
  68. /******/ __webpack_require__.p = "";
  69. /******/ // Load entry module and return exports
  70. /******/ return __webpack_require__(__webpack_require__.s = 35);
  71. /******/ })
  72. /************************************************************************/
  73. /******/ ([
  74. /* 0 */
  75. /***/ function(module, exports, __webpack_require__) {
  76. "use strict";
  77. /**
  78. * Ratio between font size and font height. The number comes from jspdf's source code
  79. */
  80. exports.FONT_ROW_RATIO = 1.15;
  81. var models_1 = __webpack_require__(15);
  82. var table = null;
  83. var assign = __webpack_require__(12);
  84. var entries = __webpack_require__(33);
  85. /**
  86. * Styles for the themes (overriding the default styles)
  87. */
  88. exports.getTheme = function (name) {
  89. var themes = {
  90. 'striped': {
  91. table: { fillColor: 255, textColor: 80, fontStyle: 'normal' },
  92. header: { textColor: 255, fillColor: [41, 128, 185], fontStyle: 'bold' },
  93. body: {},
  94. alternateRow: { fillColor: 245 }
  95. },
  96. 'grid': {
  97. table: { fillColor: 255, textColor: 80, fontStyle: 'normal', lineWidth: 0.1 },
  98. header: { textColor: 255, fillColor: [26, 188, 156], fontStyle: 'bold', lineWidth: 0 },
  99. body: {},
  100. alternateRow: {}
  101. },
  102. 'plain': {
  103. header: { fontStyle: 'bold' }
  104. }
  105. };
  106. return themes[name];
  107. };
  108. function getDefaults() {
  109. var scaleFactor = Config.scaleFactor();
  110. return {
  111. // Styling
  112. theme: 'striped',
  113. styles: {},
  114. headerStyles: {},
  115. bodyStyles: {},
  116. alternateRowStyles: {},
  117. columnStyles: {},
  118. // Properties
  119. startY: false,
  120. margin: 40 / scaleFactor,
  121. pageBreak: 'auto',
  122. tableWidth: 'auto',
  123. showHeader: 'everyPage',
  124. tableLineWidth: 0,
  125. tableLineColor: 200,
  126. // Hooks
  127. createdHeaderCell: function (cell, data) { },
  128. createdCell: function (cell, data) { },
  129. drawHeaderRow: function (row, data) { },
  130. drawRow: function (row, data) { },
  131. drawHeaderCell: function (cell, data) { },
  132. drawCell: function (cell, data) { },
  133. addPageContent: function (data) { }
  134. };
  135. }
  136. exports.getDefaults = getDefaults;
  137. // Base style for all themes
  138. function defaultStyles() {
  139. var scaleFactor = Config.scaleFactor();
  140. return {
  141. font: "helvetica",
  142. fontStyle: 'normal',
  143. overflow: 'ellipsize',
  144. fillColor: false,
  145. textColor: 20,
  146. halign: 'left',
  147. valign: 'top',
  148. fontSize: 10,
  149. cellPadding: 5 / scaleFactor,
  150. lineColor: 200,
  151. lineWidth: 0 / scaleFactor,
  152. columnWidth: 'auto'
  153. };
  154. }
  155. var Config = (function () {
  156. function Config() {
  157. }
  158. Config.pageSize = function () {
  159. return table.doc.internal.pageSize;
  160. };
  161. Config.applyUserStyles = function () {
  162. Config.applyStyles(table.userStyles);
  163. };
  164. Config.createTable = function (doc) {
  165. table = new models_1.Table(doc);
  166. return table;
  167. };
  168. Config.tableInstance = function () {
  169. return table;
  170. };
  171. Config.scaleFactor = function () {
  172. return table.doc.internal.scaleFactor;
  173. };
  174. Config.hooksData = function (additionalData) {
  175. if (additionalData === void 0) { additionalData = {}; }
  176. return assign({
  177. pageCount: table.pageCount,
  178. settings: table.settings,
  179. table: table,
  180. doc: table.doc,
  181. cursor: table.cursor
  182. }, additionalData || {});
  183. };
  184. Config.initSettings = function (table, allOptions) {
  185. var _loop_1 = function (styleProp) {
  186. var styles = allOptions.map(function (opts) { return opts[styleProp] || {}; });
  187. table.styles[styleProp] = assign.apply(void 0, [{}].concat(styles));
  188. };
  189. // Merge styles one level deeper
  190. for (var _i = 0, _a = Object.keys(table.styles); _i < _a.length; _i++) {
  191. var styleProp = _a[_i];
  192. _loop_1(styleProp);
  193. }
  194. // Append event handlers instead of replacing them
  195. for (var _b = 0, _c = entries(table.hooks); _b < _c.length; _b++) {
  196. var _d = _c[_b], hookName = _d[0], list = _d[1];
  197. for (var _e = 0, allOptions_1 = allOptions; _e < allOptions_1.length; _e++) {
  198. var opts = allOptions_1[_e];
  199. if (opts && opts[hookName]) {
  200. list.push(opts[hookName]);
  201. }
  202. }
  203. }
  204. // Merge all other options one level
  205. table.settings = assign.apply(void 0, [getDefaults()].concat(allOptions));
  206. };
  207. // This is messy, only keep array and number format the next major version
  208. Config.marginOrPadding = function (value, defaultValue) {
  209. var newValue = {};
  210. if (Array.isArray(value)) {
  211. if (value.length >= 4) {
  212. newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[3] };
  213. }
  214. else if (value.length === 3) {
  215. newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[1] };
  216. }
  217. else if (value.length === 2) {
  218. newValue = { 'top': value[0], 'right': value[1], 'bottom': value[0], 'left': value[1] };
  219. }
  220. else if (value.length === 1) {
  221. value = value[0];
  222. }
  223. else {
  224. value = defaultValue;
  225. }
  226. }
  227. else if (typeof value === 'object') {
  228. if (value['vertical']) {
  229. value['top'] = value['vertical'];
  230. value['bottom'] = value['vertical'];
  231. }
  232. else if (value['horizontal']) {
  233. value['right'] = value['horizontal'];
  234. value['left'] = value['horizontal'];
  235. }
  236. for (var _i = 0, _a = ['top', 'right', 'bottom', 'left']; _i < _a.length; _i++) {
  237. var side = _a[_i];
  238. newValue[side] = value[side] || value[side] === 0 ? value[side] : defaultValue;
  239. }
  240. }
  241. if (typeof value === 'number') {
  242. newValue = { 'top': value, 'right': value, 'bottom': value, 'left': value };
  243. }
  244. return newValue;
  245. };
  246. Config.styles = function (styles) {
  247. styles = Array.isArray(styles) ? styles : [styles];
  248. return assign.apply(void 0, [defaultStyles()].concat(styles));
  249. };
  250. Config.applyStyles = function (styles) {
  251. var doc = table.doc;
  252. var styleModifiers = {
  253. fillColor: doc.setFillColor,
  254. textColor: doc.setTextColor,
  255. fontStyle: doc.setFontStyle,
  256. lineColor: doc.setDrawColor,
  257. lineWidth: doc.setLineWidth,
  258. font: doc.setFont,
  259. fontSize: doc.setFontSize
  260. };
  261. Object.keys(styleModifiers).forEach(function (name) {
  262. var style = styles[name];
  263. var modifier = styleModifiers[name];
  264. if (typeof style !== 'undefined') {
  265. if (Array.isArray(style)) {
  266. modifier.apply(this, style);
  267. }
  268. else {
  269. modifier(style);
  270. }
  271. }
  272. });
  273. };
  274. return Config;
  275. }());
  276. exports.Config = Config;
  277. /***/ },
  278. /* 1 */
  279. /***/ function(module, exports, __webpack_require__) {
  280. "use strict";
  281. var config_1 = __webpack_require__(0);
  282. var painter_1 = __webpack_require__(4);
  283. function getStringWidth(text, styles) {
  284. var k = config_1.Config.scaleFactor();
  285. var fontSize = styles.fontSize / k;
  286. config_1.Config.applyStyles(styles);
  287. text = Array.isArray(text) ? text : [text];
  288. var maxWidth = 0;
  289. text.forEach(function (line) {
  290. var width = config_1.Config.tableInstance().doc.getStringUnitWidth(line);
  291. if (width > maxWidth) {
  292. maxWidth = width;
  293. }
  294. });
  295. var precision = 10000 * k;
  296. maxWidth = Math.floor(maxWidth * precision) / precision;
  297. return maxWidth * fontSize;
  298. }
  299. exports.getStringWidth = getStringWidth;
  300. /**
  301. * Ellipsize the text to fit in the width
  302. */
  303. function ellipsize(text, width, styles, ellipsizeStr) {
  304. if (ellipsizeStr === void 0) { ellipsizeStr = '...'; }
  305. if (Array.isArray(text)) {
  306. var value_1 = [];
  307. text.forEach(function (str, i) {
  308. value_1[i] = ellipsize(str, width, styles, ellipsizeStr);
  309. });
  310. return value_1;
  311. }
  312. var precision = 10000 * config_1.Config.scaleFactor();
  313. width = Math.ceil(width * precision) / precision;
  314. if (width >= getStringWidth(text, styles)) {
  315. return text;
  316. }
  317. while (width < getStringWidth(text + ellipsizeStr, styles)) {
  318. if (text.length <= 1) {
  319. break;
  320. }
  321. text = text.substring(0, text.length - 1);
  322. }
  323. return text.trim() + ellipsizeStr;
  324. }
  325. exports.ellipsize = ellipsize;
  326. function addTableBorder() {
  327. var table = config_1.Config.tableInstance();
  328. var styles = { lineWidth: table.settings.tableLineWidth, lineColor: table.settings.tableLineColor };
  329. config_1.Config.applyStyles(styles);
  330. var fs = getFillStyle(styles);
  331. if (fs) {
  332. table.doc.rect(table.pageStartX, table.pageStartY, table.width, table.cursor.y - table.pageStartY, fs);
  333. }
  334. }
  335. exports.addTableBorder = addTableBorder;
  336. function addPage() {
  337. var table = config_1.Config.tableInstance();
  338. table.finalY = table.cursor.y;
  339. // Add user content just before adding new page ensure it will
  340. // be drawn above other things on the page
  341. addContentHooks();
  342. addTableBorder();
  343. table.doc.addPage();
  344. table.pageCount++;
  345. table.cursor = { x: table.margin('left'), y: table.margin('top') };
  346. table.pageStartX = table.cursor.x;
  347. table.pageStartY = table.cursor.y;
  348. if (table.settings.showHeader === true || table.settings.showHeader === 'everyPage') {
  349. painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
  350. }
  351. }
  352. exports.addPage = addPage;
  353. function addContentHooks() {
  354. for (var _i = 0, _a = config_1.Config.tableInstance().hooks.addPageContent; _i < _a.length; _i++) {
  355. var hook = _a[_i];
  356. config_1.Config.applyUserStyles();
  357. hook(config_1.Config.hooksData());
  358. }
  359. config_1.Config.applyUserStyles();
  360. }
  361. exports.addContentHooks = addContentHooks;
  362. function getFillStyle(styles) {
  363. var drawLine = styles.lineWidth > 0;
  364. var drawBackground = styles.fillColor || styles.fillColor === 0;
  365. if (drawLine && drawBackground) {
  366. return 'DF'; // Fill then stroke
  367. }
  368. else if (drawLine) {
  369. return 'S'; // Only stroke (transparent background)
  370. }
  371. else if (drawBackground) {
  372. return 'F'; // Only fill, no stroke
  373. }
  374. else {
  375. return false;
  376. }
  377. }
  378. exports.getFillStyle = getFillStyle;
  379. /***/ },
  380. /* 2 */
  381. /***/ function(module, exports, __webpack_require__) {
  382. var implementation = __webpack_require__(26);
  383. module.exports = Function.prototype.bind || implementation;
  384. /***/ },
  385. /* 3 */
  386. /***/ function(module, exports, __webpack_require__) {
  387. "use strict";
  388. var fnToStr = Function.prototype.toString;
  389. var constructorRegex = /^\s*class /;
  390. var isES6ClassFn = function isES6ClassFn(value) {
  391. try {
  392. var fnStr = fnToStr.call(value);
  393. var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
  394. var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
  395. var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
  396. return constructorRegex.test(spaceStripped);
  397. } catch (e) {
  398. return false; // not a function
  399. }
  400. };
  401. var tryFunctionObject = function tryFunctionObject(value) {
  402. try {
  403. if (isES6ClassFn(value)) { return false; }
  404. fnToStr.call(value);
  405. return true;
  406. } catch (e) {
  407. return false;
  408. }
  409. };
  410. var toStr = Object.prototype.toString;
  411. var fnClass = '[object Function]';
  412. var genClass = '[object GeneratorFunction]';
  413. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  414. module.exports = function isCallable(value) {
  415. if (!value) { return false; }
  416. if (typeof value !== 'function' && typeof value !== 'object') { return false; }
  417. if (hasToStringTag) { return tryFunctionObject(value); }
  418. if (isES6ClassFn(value)) { return false; }
  419. var strClass = toStr.call(value);
  420. return strClass === fnClass || strClass === genClass;
  421. };
  422. /***/ },
  423. /* 4 */
  424. /***/ function(module, exports, __webpack_require__) {
  425. "use strict";
  426. var config_1 = __webpack_require__(0);
  427. var common_1 = __webpack_require__(1);
  428. function printFullRow(row, drawRowHooks, drawCellHooks) {
  429. var remainingRowHeight = 0;
  430. var remainingTexts = {};
  431. var table = config_1.Config.tableInstance();
  432. if (!canFitOnPage(row.height)) {
  433. if (row.maxLineCount <= 1) {
  434. common_1.addPage();
  435. }
  436. else {
  437. // Modify the row to fit the current page and calculate text and height of partial row
  438. row.spansMultiplePages = true;
  439. var pageHeight = table.doc.internal.pageSize.height;
  440. var maxCellHeight = 0;
  441. for (var j = 0; j < table.columns.length; j++) {
  442. var col = table.columns[j];
  443. var cell = row.cells[col.dataKey];
  444. var fontHeight = cell.styles.fontSize / config_1.Config.scaleFactor() * config_1.FONT_ROW_RATIO;
  445. var vPadding = cell.padding('vertical');
  446. var remainingPageSpace = pageHeight - table.cursor.y - table.margin('bottom');
  447. var remainingLineCount = Math.floor((remainingPageSpace - vPadding) / fontHeight);
  448. if (Array.isArray(cell.text) && cell.text.length > remainingLineCount) {
  449. var remainingLines = cell.text.splice(remainingLineCount, cell.text.length);
  450. remainingTexts[col.dataKey] = remainingLines;
  451. var cellHeight = cell.text.length * fontHeight + vPadding;
  452. if (cellHeight > maxCellHeight) {
  453. maxCellHeight = cellHeight;
  454. }
  455. var rCellHeight = remainingLines.length * fontHeight + vPadding;
  456. if (rCellHeight > remainingRowHeight) {
  457. remainingRowHeight = rCellHeight;
  458. }
  459. }
  460. }
  461. // Reset row height since text are now removed
  462. row.height = maxCellHeight;
  463. }
  464. }
  465. printRow(row, drawRowHooks, drawCellHooks);
  466. // Parts of the row is now printed. Time for adding a new page, prune
  467. // the text and start over
  468. if (Object.keys(remainingTexts).length > 0) {
  469. for (var j = 0; j < table.columns.length; j++) {
  470. var col = table.columns[j];
  471. var cell = row.cells[col.dataKey];
  472. cell.text = remainingTexts[col.dataKey] || '';
  473. }
  474. common_1.addPage();
  475. row.pageCount++;
  476. row.height = remainingRowHeight;
  477. printFullRow(row, drawRowHooks, drawCellHooks);
  478. }
  479. }
  480. exports.printFullRow = printFullRow;
  481. function printRow(row, drawRowHooks, drawCellHooks) {
  482. var table = config_1.Config.tableInstance();
  483. row.y = table.cursor.y;
  484. for (var _i = 0, drawRowHooks_1 = drawRowHooks; _i < drawRowHooks_1.length; _i++) {
  485. var hook = drawRowHooks_1[_i];
  486. if (hook(row, config_1.Config.hooksData({ row: row, addPage: common_1.addPage })) === false) {
  487. return;
  488. }
  489. }
  490. table.cursor.x = table.margin('left');
  491. for (var i = 0; i < table.columns.length; i++) {
  492. var column = table.columns[i];
  493. var cell = row.cells[column.dataKey];
  494. if (!cell) {
  495. continue;
  496. }
  497. config_1.Config.applyStyles(cell.styles);
  498. cell.x = table.cursor.x;
  499. cell.y = table.cursor.y;
  500. cell.height = row.height;
  501. cell.width = column.width;
  502. if (cell.styles.valign === 'top') {
  503. cell.textPos.y = table.cursor.y + cell.padding('top');
  504. }
  505. else if (cell.styles.valign === 'bottom') {
  506. cell.textPos.y = table.cursor.y + row.height - cell.padding('bottom');
  507. }
  508. else {
  509. cell.textPos.y = table.cursor.y + row.height / 2;
  510. }
  511. if (cell.styles.halign === 'right') {
  512. cell.textPos.x = cell.x + cell.width - cell.padding('right');
  513. }
  514. else if (cell.styles.halign === 'center') {
  515. cell.textPos.x = cell.x + cell.width / 2;
  516. }
  517. else {
  518. cell.textPos.x = cell.x + cell.padding('left');
  519. }
  520. var shouldDrawCell = true;
  521. var data = config_1.Config.hooksData({ column: column, row: row, addPage: common_1.addPage });
  522. for (var _a = 0, drawCellHooks_1 = drawCellHooks; _a < drawCellHooks_1.length; _a++) {
  523. var hook = drawCellHooks_1[_a];
  524. if (hook(cell, data) === false) {
  525. shouldDrawCell = false;
  526. }
  527. }
  528. if (shouldDrawCell) {
  529. var fillStyle = common_1.getFillStyle(cell.styles);
  530. if (fillStyle) {
  531. table.doc.rect(cell.x, cell.y, cell.width, cell.height, fillStyle);
  532. }
  533. table.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, {
  534. halign: cell.styles.halign,
  535. valign: cell.styles.valign
  536. });
  537. }
  538. table.cursor.x += cell.width;
  539. }
  540. table.cursor.y += row.height;
  541. }
  542. exports.printRow = printRow;
  543. function canFitOnPage(rowHeight) {
  544. var table = config_1.Config.tableInstance();
  545. var pos = rowHeight + table.cursor.y + table.margin('bottom');
  546. return pos < config_1.Config.pageSize().height;
  547. }
  548. /***/ },
  549. /* 5 */
  550. /***/ function(module, exports, __webpack_require__) {
  551. "use strict";
  552. var keys = __webpack_require__(31);
  553. var foreach = __webpack_require__(25);
  554. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
  555. var toStr = Object.prototype.toString;
  556. var isFunction = function (fn) {
  557. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  558. };
  559. var arePropertyDescriptorsSupported = function () {
  560. var obj = {};
  561. try {
  562. Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
  563. /* eslint-disable no-unused-vars, no-restricted-syntax */
  564. for (var _ in obj) { return false; }
  565. /* eslint-enable no-unused-vars, no-restricted-syntax */
  566. return obj.x === obj;
  567. } catch (e) { /* this is IE 8. */
  568. return false;
  569. }
  570. };
  571. var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
  572. var defineProperty = function (object, name, value, predicate) {
  573. if (name in object && (!isFunction(predicate) || !predicate())) {
  574. return;
  575. }
  576. if (supportsDescriptors) {
  577. Object.defineProperty(object, name, {
  578. configurable: true,
  579. enumerable: false,
  580. value: value,
  581. writable: true
  582. });
  583. } else {
  584. object[name] = value;
  585. }
  586. };
  587. var defineProperties = function (object, map) {
  588. var predicates = arguments.length > 2 ? arguments[2] : {};
  589. var props = keys(map);
  590. if (hasSymbols) {
  591. props = props.concat(Object.getOwnPropertySymbols(map));
  592. }
  593. foreach(props, function (name) {
  594. defineProperty(object, name, map[name], predicates[name]);
  595. });
  596. };
  597. defineProperties.supportsDescriptors = !!supportsDescriptors;
  598. module.exports = defineProperties;
  599. /***/ },
  600. /* 6 */
  601. /***/ function(module, exports) {
  602. var has = Object.prototype.hasOwnProperty;
  603. module.exports = Object.assign || function assign(target, source) {
  604. for (var key in source) {
  605. if (has.call(source, key)) {
  606. target[key] = source[key];
  607. }
  608. }
  609. return target;
  610. };
  611. /***/ },
  612. /* 7 */
  613. /***/ function(module, exports) {
  614. var $isNaN = Number.isNaN || function (a) { return a !== a; };
  615. module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
  616. /***/ },
  617. /* 8 */
  618. /***/ function(module, exports) {
  619. module.exports = Number.isNaN || function isNaN(a) {
  620. return a !== a;
  621. };
  622. /***/ },
  623. /* 9 */
  624. /***/ function(module, exports) {
  625. module.exports = function mod(number, modulo) {
  626. var remain = number % modulo;
  627. return Math.floor(remain >= 0 ? remain : remain + modulo);
  628. };
  629. /***/ },
  630. /* 10 */
  631. /***/ function(module, exports) {
  632. module.exports = function sign(number) {
  633. return number >= 0 ? 1 : -1;
  634. };
  635. /***/ },
  636. /* 11 */
  637. /***/ function(module, exports) {
  638. module.exports = function isPrimitive(value) {
  639. return value === null || (typeof value !== 'function' && typeof value !== 'object');
  640. };
  641. /***/ },
  642. /* 12 */
  643. /***/ function(module, exports, __webpack_require__) {
  644. "use strict";
  645. /* eslint-disable no-unused-vars */
  646. var hasOwnProperty = Object.prototype.hasOwnProperty;
  647. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  648. function toObject(val) {
  649. if (val === null || val === undefined) {
  650. throw new TypeError('Object.assign cannot be called with null or undefined');
  651. }
  652. return Object(val);
  653. }
  654. function shouldUseNative() {
  655. try {
  656. if (!Object.assign) {
  657. return false;
  658. }
  659. // Detect buggy property enumeration order in older V8 versions.
  660. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  661. var test1 = new String('abc'); // eslint-disable-line
  662. test1[5] = 'de';
  663. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  664. return false;
  665. }
  666. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  667. var test2 = {};
  668. for (var i = 0; i < 10; i++) {
  669. test2['_' + String.fromCharCode(i)] = i;
  670. }
  671. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  672. return test2[n];
  673. });
  674. if (order2.join('') !== '0123456789') {
  675. return false;
  676. }
  677. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  678. var test3 = {};
  679. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  680. test3[letter] = letter;
  681. });
  682. if (Object.keys(Object.assign({}, test3)).join('') !==
  683. 'abcdefghijklmnopqrst') {
  684. return false;
  685. }
  686. return true;
  687. } catch (e) {
  688. // We don't expect any of the above to throw, but better to be safe.
  689. return false;
  690. }
  691. }
  692. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  693. var from;
  694. var to = toObject(target);
  695. var symbols;
  696. for (var s = 1; s < arguments.length; s++) {
  697. from = Object(arguments[s]);
  698. for (var key in from) {
  699. if (hasOwnProperty.call(from, key)) {
  700. to[key] = from[key];
  701. }
  702. }
  703. if (Object.getOwnPropertySymbols) {
  704. symbols = Object.getOwnPropertySymbols(from);
  705. for (var i = 0; i < symbols.length; i++) {
  706. if (propIsEnumerable.call(from, symbols[i])) {
  707. to[symbols[i]] = from[symbols[i]];
  708. }
  709. }
  710. }
  711. }
  712. return to;
  713. };
  714. /***/ },
  715. /* 13 */
  716. /***/ function(module, exports, __webpack_require__) {
  717. "use strict";
  718. var ES = __webpack_require__(21);
  719. var has = __webpack_require__(27);
  720. var bind = __webpack_require__(2);
  721. var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
  722. module.exports = function entries(O) {
  723. var obj = ES.RequireObjectCoercible(O);
  724. var entrys = [];
  725. for (var key in obj) {
  726. if (has(obj, key) && isEnumerable(obj, key)) {
  727. entrys.push([key, obj[key]]);
  728. }
  729. }
  730. return entrys;
  731. };
  732. /***/ },
  733. /* 14 */
  734. /***/ function(module, exports, __webpack_require__) {
  735. "use strict";
  736. var implementation = __webpack_require__(13);
  737. module.exports = function getPolyfill() {
  738. return typeof Object.entries === 'function' ? Object.entries : implementation;
  739. };
  740. /***/ },
  741. /* 15 */
  742. /***/ function(module, exports, __webpack_require__) {
  743. "use strict";
  744. var config_1 = __webpack_require__(0);
  745. exports.table = {};
  746. var Table = (function () {
  747. function Table(doc) {
  748. this.height = 0;
  749. this.width = 0;
  750. this.contentWidth = 0;
  751. this.preferredWidth = 0;
  752. this.rows = [];
  753. this.columns = [];
  754. this.headerRow = null;
  755. this.pageCount = 1;
  756. this.hooks = {
  757. createdHeaderCell: [],
  758. createdCell: [],
  759. drawHeaderRow: [],
  760. drawRow: [],
  761. drawHeaderCell: [],
  762. drawCell: [],
  763. addPageContent: []
  764. };
  765. this.styles = {
  766. styles: {},
  767. headerStyles: {},
  768. bodyStyles: {},
  769. alternateRowStyles: {},
  770. columnStyles: {}
  771. };
  772. this.doc = doc;
  773. this.userStyles = {
  774. textColor: 30,
  775. fontSize: doc.internal.getFontSize(),
  776. fontStyle: doc.internal.getFont().fontStyle
  777. };
  778. }
  779. Table.prototype.margin = function (side) {
  780. return config_1.Config.marginOrPadding(this.settings.margin, config_1.getDefaults().margin)[side];
  781. };
  782. return Table;
  783. }());
  784. exports.Table = Table;
  785. var Row = (function () {
  786. function Row(raw, index) {
  787. this.cells = {};
  788. this.spansMultiplePages = false;
  789. this.pageCount = 1;
  790. this.height = 0;
  791. this.y = 0;
  792. this.maxLineCount = 1;
  793. this.raw = raw;
  794. this.index = index;
  795. }
  796. return Row;
  797. }());
  798. exports.Row = Row;
  799. var Cell = (function () {
  800. function Cell(raw) {
  801. this.styles = {};
  802. this.text = '';
  803. this.contentWidth = 0;
  804. this.textPos = {};
  805. this.height = 0;
  806. this.width = 0;
  807. this.x = 0;
  808. this.y = 0;
  809. this.raw = raw;
  810. }
  811. Cell.prototype.padding = function (name) {
  812. var padding = config_1.Config.marginOrPadding(this.styles.cellPadding, config_1.Config.styles([]).cellPadding);
  813. if (name === 'vertical') {
  814. return padding.top + padding.bottom;
  815. }
  816. else if (name === 'horizontal') {
  817. return padding.left + padding.right;
  818. }
  819. else {
  820. return padding[name];
  821. }
  822. };
  823. return Cell;
  824. }());
  825. exports.Cell = Cell;
  826. var Column = (function () {
  827. function Column(dataKey, index) {
  828. this.options = {};
  829. this.contentWidth = 0;
  830. this.preferredWidth = 0;
  831. this.widthStyle = 'auto';
  832. this.width = 0;
  833. this.x = 0;
  834. this.dataKey = dataKey;
  835. this.index = index;
  836. }
  837. return Column;
  838. }());
  839. exports.Column = Column;
  840. /***/ },
  841. /* 16 */
  842. /***/ function(module, exports, __webpack_require__) {
  843. "use strict";
  844. var config_1 = __webpack_require__(0);
  845. var common_1 = __webpack_require__(1);
  846. /**
  847. * Calculate the column widths
  848. */
  849. function calculateWidths(doc, pageWidth) {
  850. var table = config_1.Config.tableInstance();
  851. // Column and table content width
  852. var fixedWidth = 0;
  853. var autoWidth = 0;
  854. var dynamicColumns = [];
  855. table.columns.forEach(function (column) {
  856. column.contentWidth = 0;
  857. table.rows.concat(table.headerRow).forEach(function (row) {
  858. var cell = row.cells[column.dataKey];
  859. cell.contentWidth = cell.padding('horizontal') + common_1.getStringWidth(cell.text, cell.styles);
  860. if (cell.contentWidth > column.contentWidth) {
  861. column.contentWidth = cell.contentWidth;
  862. }
  863. });
  864. table.contentWidth += column.contentWidth;
  865. if (typeof column.widthStyle === 'number') {
  866. column.preferredWidth = column.widthStyle;
  867. fixedWidth += column.preferredWidth;
  868. column.width = column.preferredWidth;
  869. }
  870. else if (column.widthStyle === 'wrap') {
  871. column.preferredWidth = column.contentWidth;
  872. fixedWidth += column.preferredWidth;
  873. column.width = column.preferredWidth;
  874. }
  875. else {
  876. column.preferredWidth = column.contentWidth;
  877. autoWidth += column.contentWidth;
  878. dynamicColumns.push(column);
  879. }
  880. table.preferredWidth += column.preferredWidth;
  881. });
  882. if (typeof table.settings.tableWidth === 'number') {
  883. table.width = table.settings.tableWidth;
  884. }
  885. else if (table.settings.tableWidth === 'wrap') {
  886. table.width = table.preferredWidth;
  887. }
  888. else {
  889. table.width = pageWidth - table.margin('left') - table.margin('right');
  890. }
  891. distributeWidth(dynamicColumns, fixedWidth, autoWidth, 0);
  892. // Row height, table height and text overflow
  893. var all = table.rows.concat(table.headerRow);
  894. all.forEach(function (row) {
  895. table.columns.forEach(function (col) {
  896. var cell = row.cells[col.dataKey];
  897. config_1.Config.applyStyles(cell.styles);
  898. var textSpace = col.width - cell.padding('horizontal');
  899. if (cell.styles.overflow === 'linebreak') {
  900. // Add one pt to textSpace to fix rounding error
  901. try {
  902. cell.text = doc.splitTextToSize(cell.text, textSpace + 1, { fontSize: cell.styles.fontSize });
  903. }
  904. catch (e) {
  905. if (e instanceof TypeError && Array.isArray(cell.text)) {
  906. cell.text = doc.splitTextToSize(cell.text.join(' '), textSpace + 1, { fontSize: cell.styles.fontSize });
  907. }
  908. else {
  909. throw e;
  910. }
  911. }
  912. }
  913. else if (cell.styles.overflow === 'ellipsize') {
  914. cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles);
  915. }
  916. else if (cell.styles.overflow === 'visible') {
  917. }
  918. else if (cell.styles.overflow === 'hidden') {
  919. cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles, '');
  920. }
  921. else if (typeof cell.styles.overflow === 'function') {
  922. cell.text = cell.styles.overflow(cell.text, textSpace);
  923. }
  924. else {
  925. console.error("Unrecognized overflow type: " + cell.styles.overflow);
  926. }
  927. var k = config_1.Config.scaleFactor();
  928. var lineCount = Array.isArray(cell.text) ? cell.text.length : 1;
  929. var fontHeight = cell.styles.fontSize / k * config_1.FONT_ROW_RATIO;
  930. cell.contentHeight = lineCount * fontHeight + cell.padding('vertical');
  931. if (cell.contentHeight > row.height) {
  932. row.height = cell.contentHeight;
  933. row.maxLineCount = lineCount;
  934. }
  935. });
  936. table.height += row.height;
  937. });
  938. }
  939. exports.calculateWidths = calculateWidths;
  940. function distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth) {
  941. var table = config_1.Config.tableInstance();
  942. var extraWidth = table.width - staticWidth - dynamicColumnsContentWidth;
  943. for (var i = 0; i < dynamicColumns.length; i++) {
  944. var col = dynamicColumns[i];
  945. var ratio = col.contentWidth / dynamicColumnsContentWidth;
  946. // A column turned out to be none dynamic, start over recursively
  947. var isNoneDynamic = col.contentWidth + extraWidth * ratio < fairWidth;
  948. if (extraWidth < 0 && isNoneDynamic) {
  949. dynamicColumns.splice(i, 1);
  950. dynamicColumnsContentWidth -= col.contentWidth;
  951. col.width = fairWidth;
  952. staticWidth += col.width;
  953. distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth);
  954. break;
  955. }
  956. else {
  957. col.width = col.contentWidth + extraWidth * ratio;
  958. }
  959. }
  960. }
  961. /***/ },
  962. /* 17 */
  963. /***/ function(module, exports, __webpack_require__) {
  964. "use strict";
  965. var models_1 = __webpack_require__(15);
  966. var config_1 = __webpack_require__(0);
  967. var assign = __webpack_require__(12);
  968. function validateInput(headers, data, allOptions) {
  969. if (!headers || typeof headers !== 'object') {
  970. console.error("The headers should be an object or array, is: " + typeof headers);
  971. }
  972. if (!data || typeof data !== 'object') {
  973. console.error("The data should be an object or array, is: " + typeof data);
  974. }
  975. var _loop_1 = function (settings) {
  976. if (settings && typeof settings !== 'object') {
  977. console.error("The options parameter should be of type object, is: " + typeof settings);
  978. }
  979. if (typeof settings.extendWidth !== 'undefined') {
  980. settings.tableWidth = settings.extendWidth ? 'auto' : 'wrap';
  981. console.error("Use of deprecated option: extendWidth, use tableWidth instead.");
  982. }
  983. if (typeof settings.margins !== 'undefined') {
  984. if (typeof settings.margin === 'undefined')
  985. settings.margin = settings.margins;
  986. console.error("Use of deprecated option: margins, use margin instead.");
  987. }
  988. if (typeof settings.afterPageContent !== 'undefined' || typeof settings.beforePageContent !== 'undefined' || typeof settings.afterPageAdd !== 'undefined') {
  989. console.error("The afterPageContent, beforePageContent and afterPageAdd hooks are deprecated. Use addPageContent instead");
  990. if (typeof settings.addPageContent === 'undefined') {
  991. settings.addPageContent = function (data) {
  992. config_1.Config.applyUserStyles();
  993. if (settings.beforePageContent)
  994. settings.beforePageContent(data);
  995. config_1.Config.applyUserStyles();
  996. if (settings.afterPageContent)
  997. settings.afterPageContent(data);
  998. config_1.Config.applyUserStyles();
  999. if (settings.afterPageAdd && data.pageCount > 1) {
  1000. data.afterPageAdd(data);
  1001. }
  1002. config_1.Config.applyUserStyles();
  1003. };
  1004. }
  1005. }
  1006. [['padding', 'cellPadding'], ['lineHeight', 'rowHeight'], 'fontSize', 'overflow'].forEach(function (o) {
  1007. var deprecatedOption = typeof o === 'string' ? o : o[0];
  1008. var style = typeof o === 'string' ? o : o[1];
  1009. if (typeof settings[deprecatedOption] !== 'undefined') {
  1010. if (typeof settings.styles[style] === 'undefined') {
  1011. settings.styles[style] = settings[deprecatedOption];
  1012. }
  1013. console.error("Use of deprecated option: " + deprecatedOption + ", use the style " + style + " instead.");
  1014. }
  1015. });
  1016. for (var _i = 0, _a = ['styles', 'bodyStyles', 'headerStyles', 'columnStyles']; _i < _a.length; _i++) {
  1017. var styleProp = _a[_i];
  1018. if (settings[styleProp] && typeof settings[styleProp] !== 'object') {
  1019. console.error("The " + styleProp + " style should be of type object, is: " + typeof settings[styleProp]);
  1020. }
  1021. else if (settings[styleProp] && settings[styleProp].rowHeight) {
  1022. console.error("Use of deprecated style: rowHeight, use vertical cell padding instead");
  1023. }
  1024. }
  1025. };
  1026. for (var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++) {
  1027. var settings = allOptions_1[_i];
  1028. _loop_1(settings);
  1029. }
  1030. }
  1031. exports.validateInput = validateInput;
  1032. /**
  1033. * Create models from the user input
  1034. *
  1035. * @param inputHeaders
  1036. * @param inputData
  1037. */
  1038. function createModels(inputHeaders, inputData) {
  1039. var splitRegex = /\r\n|\r|\n/g;
  1040. var table = config_1.Config.tableInstance();
  1041. var settings = table.settings;
  1042. var theme = config_1.getTheme(settings.theme);
  1043. // Header row and columns
  1044. var headerRow = new models_1.Row(inputHeaders, -1);
  1045. headerRow.index = -1;
  1046. // Columns and header row
  1047. inputHeaders.forEach(function (rawColumn, index) {
  1048. var dataKey = index;
  1049. if (typeof rawColumn.dataKey !== 'undefined') {
  1050. dataKey = rawColumn.dataKey;
  1051. }
  1052. else if (typeof rawColumn.key !== 'undefined') {
  1053. console.error("Deprecation warning: Use dataKey instead of key");
  1054. dataKey = rawColumn.key; // deprecated since 2.x
  1055. }
  1056. var col = new models_1.Column(dataKey, index);
  1057. col.widthStyle = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.columnStyles[col.dataKey] || {}]).columnWidth;
  1058. table.columns.push(col);
  1059. var cell = new models_1.Cell(rawColumn);
  1060. cell.styles = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.headerStyles]);
  1061. if (cell.raw instanceof HTMLElement) {
  1062. cell.text = (cell.raw.innerText || '').trim();
  1063. }
  1064. else {
  1065. var text = typeof cell.raw === 'object' ? cell.raw.title : cell.raw;
  1066. // Stringify 0 and false, but not undefined
  1067. cell.text = typeof cell.raw !== 'undefined' ? '' + text : '';
  1068. }
  1069. cell.text = cell.text.split(splitRegex);
  1070. headerRow.cells[dataKey] = cell;
  1071. for (var _i = 0, _a = table.hooks.createdHeaderCell; _i < _a.length; _i++) {
  1072. var hook = _a[_i];
  1073. hook(cell, { cell: cell, column: col, row: headerRow, settings: settings });
  1074. }
  1075. });
  1076. table.headerRow = headerRow;
  1077. // Rows och cells
  1078. inputData.forEach(function (rawRow, i) {
  1079. var row = new models_1.Row(rawRow, i);
  1080. var rowStyles = i % 2 === 0 ? assign({}, theme.alternateRow, table.styles.alternateRowStyles) : {};
  1081. table.columns.forEach(function (column) {
  1082. var cell = new models_1.Cell(rawRow[column.dataKey]);
  1083. var colStyles = table.styles.columnStyles[column.dataKey] || {};
  1084. cell.styles = config_1.Config.styles([theme.table, theme.body, table.styles.styles, table.styles.bodyStyles, rowStyles, colStyles]);
  1085. if (cell.raw && cell.raw instanceof HTMLElement) {
  1086. cell.text = (cell.raw.innerText || '').trim();
  1087. }
  1088. else {
  1089. // Stringify 0 and false, but not undefined
  1090. cell.text = typeof cell.raw !== 'undefined' ? '' + cell.raw : '';
  1091. }
  1092. cell.text = cell.text.split(splitRegex);
  1093. row.cells[column.dataKey] = cell;
  1094. for (var _i = 0, _a = table.hooks.createdCell; _i < _a.length; _i++) {
  1095. var hook = _a[_i];
  1096. hook(cell, config_1.Config.hooksData({ cell: cell, column: column, row: row }));
  1097. }
  1098. });
  1099. table.rows.push(row);
  1100. });
  1101. }
  1102. exports.createModels = createModels;
  1103. /***/ },
  1104. /* 18 */
  1105. /***/ function(module, exports) {
  1106. module.exports = __WEBPACK_EXTERNAL_MODULE_18__;
  1107. /***/ },
  1108. /* 19 */
  1109. /***/ function(module, exports, __webpack_require__) {
  1110. "use strict";
  1111. var $isNaN = __webpack_require__(8);
  1112. var $isFinite = __webpack_require__(7);
  1113. var sign = __webpack_require__(10);
  1114. var mod = __webpack_require__(9);
  1115. var IsCallable = __webpack_require__(3);
  1116. var toPrimitive = __webpack_require__(23);
  1117. // https://es5.github.io/#x9
  1118. var ES5 = {
  1119. ToPrimitive: toPrimitive,
  1120. ToBoolean: function ToBoolean(value) {
  1121. return Boolean(value);
  1122. },
  1123. ToNumber: function ToNumber(value) {
  1124. return Number(value);
  1125. },
  1126. ToInteger: function ToInteger(value) {
  1127. var number = this.ToNumber(value);
  1128. if ($isNaN(number)) { return 0; }
  1129. if (number === 0 || !$isFinite(number)) { return number; }
  1130. return sign(number) * Math.floor(Math.abs(number));
  1131. },
  1132. ToInt32: function ToInt32(x) {
  1133. return this.ToNumber(x) >> 0;
  1134. },
  1135. ToUint32: function ToUint32(x) {
  1136. return this.ToNumber(x) >>> 0;
  1137. },
  1138. ToUint16: function ToUint16(value) {
  1139. var number = this.ToNumber(value);
  1140. if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
  1141. var posInt = sign(number) * Math.floor(Math.abs(number));
  1142. return mod(posInt, 0x10000);
  1143. },
  1144. ToString: function ToString(value) {
  1145. return String(value);
  1146. },
  1147. ToObject: function ToObject(value) {
  1148. this.CheckObjectCoercible(value);
  1149. return Object(value);
  1150. },
  1151. CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
  1152. /* jshint eqnull:true */
  1153. if (value == null) {
  1154. throw new TypeError(optMessage || 'Cannot call method on ' + value);
  1155. }
  1156. return value;
  1157. },
  1158. IsCallable: IsCallable,
  1159. SameValue: function SameValue(x, y) {
  1160. if (x === y) { // 0 === -0, but they are not identical.
  1161. if (x === 0) { return 1 / x === 1 / y; }
  1162. return true;
  1163. }
  1164. return $isNaN(x) && $isNaN(y);
  1165. },
  1166. // http://www.ecma-international.org/ecma-262/5.1/#sec-8
  1167. Type: function Type(x) {
  1168. if (x === null) {
  1169. return 'Null';
  1170. }
  1171. if (typeof x === 'undefined') {
  1172. return 'Undefined';
  1173. }
  1174. if (typeof x === 'function' || typeof x === 'object') {
  1175. return 'Object';
  1176. }
  1177. if (typeof x === 'number') {
  1178. return 'Number';
  1179. }
  1180. if (typeof x === 'boolean') {
  1181. return 'Boolean';
  1182. }
  1183. if (typeof x === 'string') {
  1184. return 'String';
  1185. }
  1186. }
  1187. };
  1188. module.exports = ES5;
  1189. /***/ },
  1190. /* 20 */
  1191. /***/ function(module, exports, __webpack_require__) {
  1192. "use strict";
  1193. var toStr = Object.prototype.toString;
  1194. var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
  1195. var symbolToStr = hasSymbols ? Symbol.prototype.toString : toStr;
  1196. var $isNaN = __webpack_require__(8);
  1197. var $isFinite = __webpack_require__(7);
  1198. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
  1199. var assign = __webpack_require__(6);
  1200. var sign = __webpack_require__(10);
  1201. var mod = __webpack_require__(9);
  1202. var isPrimitive = __webpack_require__(22);
  1203. var toPrimitive = __webpack_require__(24);
  1204. var parseInteger = parseInt;
  1205. var bind = __webpack_require__(2);
  1206. var strSlice = bind.call(Function.call, String.prototype.slice);
  1207. var isBinary = bind.call(Function.call, RegExp.prototype.test, /^0b[01]+$/i);
  1208. var isOctal = bind.call(Function.call, RegExp.prototype.test, /^0o[0-7]+$/i);
  1209. var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
  1210. var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
  1211. var hasNonWS = bind.call(Function.call, RegExp.prototype.test, nonWSregex);
  1212. var invalidHexLiteral = /^[\-\+]0x[0-9a-f]+$/i;
  1213. var isInvalidHexLiteral = bind.call(Function.call, RegExp.prototype.test, invalidHexLiteral);
  1214. // whitespace from: http://es5.github.io/#x15.5.4.20
  1215. // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
  1216. var ws = [
  1217. '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
  1218. '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
  1219. '\u2029\uFEFF'
  1220. ].join('');
  1221. var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
  1222. var replace = bind.call(Function.call, String.prototype.replace);
  1223. var trim = function (value) {
  1224. return replace(value, trimRegex, '');
  1225. };
  1226. var ES5 = __webpack_require__(19);
  1227. var hasRegExpMatcher = __webpack_require__(29);
  1228. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
  1229. var ES6 = assign(assign({}, ES5), {
  1230. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
  1231. Call: function Call(F, V) {
  1232. var args = arguments.length > 2 ? arguments[2] : [];
  1233. if (!this.IsCallable(F)) {
  1234. throw new TypeError(F + ' is not a function');
  1235. }
  1236. return F.apply(V, args);
  1237. },
  1238. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
  1239. ToPrimitive: toPrimitive,
  1240. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
  1241. // ToBoolean: ES5.ToBoolean,
  1242. // http://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
  1243. ToNumber: function ToNumber(argument) {
  1244. var value = isPrimitive(argument) ? argument : toPrimitive(argument, 'number');
  1245. if (typeof value === 'symbol') {
  1246. throw new TypeError('Cannot convert a Symbol value to a number');
  1247. }
  1248. if (typeof value === 'string') {
  1249. if (isBinary(value)) {
  1250. return this.ToNumber(parseInteger(strSlice(value, 2), 2));
  1251. } else if (isOctal(value)) {
  1252. return this.ToNumber(parseInteger(strSlice(value, 2), 8));
  1253. } else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
  1254. return NaN;
  1255. } else {
  1256. var trimmed = trim(value);
  1257. if (trimmed !== value) {
  1258. return this.ToNumber(trimmed);
  1259. }
  1260. }
  1261. }
  1262. return Number(value);
  1263. },
  1264. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
  1265. // ToInteger: ES5.ToNumber,
  1266. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
  1267. // ToInt32: ES5.ToInt32,
  1268. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
  1269. // ToUint32: ES5.ToUint32,
  1270. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
  1271. ToInt16: function ToInt16(argument) {
  1272. var int16bit = this.ToUint16(argument);
  1273. return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
  1274. },
  1275. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
  1276. // ToUint16: ES5.ToUint16,
  1277. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
  1278. ToInt8: function ToInt8(argument) {
  1279. var int8bit = this.ToUint8(argument);
  1280. return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
  1281. },
  1282. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
  1283. ToUint8: function ToUint8(argument) {
  1284. var number = this.ToNumber(argument);
  1285. if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
  1286. var posInt = sign(number) * Math.floor(Math.abs(number));
  1287. return mod(posInt, 0x100);
  1288. },
  1289. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
  1290. ToUint8Clamp: function ToUint8Clamp(argument) {
  1291. var number = this.ToNumber(argument);
  1292. if ($isNaN(number) || number <= 0) { return 0; }
  1293. if (number >= 0xFF) { return 0xFF; }
  1294. var f = Math.floor(argument);
  1295. if (f + 0.5 < number) { return f + 1; }
  1296. if (number < f + 0.5) { return f; }
  1297. if (f % 2 !== 0) { return f + 1; }
  1298. return f;
  1299. },
  1300. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
  1301. ToString: function ToString(argument) {
  1302. if (typeof argument === 'symbol') {
  1303. throw new TypeError('Cannot convert a Symbol value to a string');
  1304. }
  1305. return String(argument);
  1306. },
  1307. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
  1308. ToObject: function ToObject(value) {
  1309. this.RequireObjectCoercible(value);
  1310. return Object(value);
  1311. },
  1312. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
  1313. ToPropertyKey: function ToPropertyKey(argument) {
  1314. var key = this.ToPrimitive(argument, String);
  1315. return typeof key === 'symbol' ? symbolToStr.call(key) : this.ToString(key);
  1316. },
  1317. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
  1318. ToLength: function ToLength(argument) {
  1319. var len = this.ToInteger(argument);
  1320. if (len <= 0) { return 0; } // includes converting -0 to +0
  1321. if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
  1322. return len;
  1323. },
  1324. // http://www.ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
  1325. CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
  1326. if (toStr.call(argument) !== '[object String]') {
  1327. throw new TypeError('must be a string');
  1328. }
  1329. if (argument === '-0') { return -0; }
  1330. var n = this.ToNumber(argument);
  1331. if (this.SameValue(this.ToString(n), argument)) { return n; }
  1332. return void 0;
  1333. },
  1334. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
  1335. RequireObjectCoercible: ES5.CheckObjectCoercible,
  1336. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
  1337. IsArray: Array.isArray || function IsArray(argument) {
  1338. return toStr.call(argument) === '[object Array]';
  1339. },
  1340. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
  1341. // IsCallable: ES5.IsCallable,
  1342. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
  1343. IsConstructor: function IsConstructor(argument) {
  1344. return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
  1345. },
  1346. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
  1347. IsExtensible: function IsExtensible(obj) {
  1348. if (!Object.preventExtensions) { return true; }
  1349. if (isPrimitive(obj)) {
  1350. return false;
  1351. }
  1352. return Object.isExtensible(obj);
  1353. },
  1354. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
  1355. IsInteger: function IsInteger(argument) {
  1356. if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
  1357. return false;
  1358. }
  1359. var abs = Math.abs(argument);
  1360. return Math.floor(abs) === abs;
  1361. },
  1362. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
  1363. IsPropertyKey: function IsPropertyKey(argument) {
  1364. return typeof argument === 'string' || typeof argument === 'symbol';
  1365. },
  1366. // http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp
  1367. IsRegExp: function IsRegExp(argument) {
  1368. if (!argument || typeof argument !== 'object') {
  1369. return false;
  1370. }
  1371. if (hasSymbols) {
  1372. var isRegExp = argument[Symbol.match];
  1373. if (typeof isRegExp !== 'undefined') {
  1374. return ES5.ToBoolean(isRegExp);
  1375. }
  1376. }
  1377. return hasRegExpMatcher(argument);
  1378. },
  1379. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
  1380. // SameValue: ES5.SameValue,
  1381. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
  1382. SameValueZero: function SameValueZero(x, y) {
  1383. return (x === y) || ($isNaN(x) && $isNaN(y));
  1384. },
  1385. Type: function Type(x) {
  1386. if (typeof x === 'symbol') {
  1387. return 'Symbol';
  1388. }
  1389. return ES5.Type(x);
  1390. },
  1391. // http://www.ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
  1392. SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
  1393. if (this.Type(O) !== 'Object') {
  1394. throw new TypeError('Assertion failed: Type(O) is not Object');
  1395. }
  1396. var C = O.constructor;
  1397. if (typeof C === 'undefined') {
  1398. return defaultConstructor;
  1399. }
  1400. if (this.Type(C) !== 'Object') {
  1401. throw new TypeError('O.constructor is not an Object');
  1402. }
  1403. var S = hasSymbols && Symbol.species ? C[Symbol.species] : undefined;
  1404. if (S == null) {
  1405. return defaultConstructor;
  1406. }
  1407. if (this.IsConstructor(S)) {
  1408. return S;
  1409. }
  1410. throw new TypeError('no constructor found');
  1411. }
  1412. });
  1413. delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
  1414. module.exports = ES6;
  1415. /***/ },
  1416. /* 21 */
  1417. /***/ function(module, exports, __webpack_require__) {
  1418. "use strict";
  1419. var ES6 = __webpack_require__(20);
  1420. var assign = __webpack_require__(6);
  1421. var ES7 = assign(ES6, {
  1422. // https://github.com/tc39/ecma262/pull/60
  1423. SameValueNonNumber: function SameValueNonNumber(x, y) {
  1424. if (typeof x === 'number' || typeof x !== typeof y) {
  1425. throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
  1426. }
  1427. return this.SameValue(x, y);
  1428. }
  1429. });
  1430. module.exports = ES7;
  1431. /***/ },
  1432. /* 22 */
  1433. /***/ function(module, exports) {
  1434. module.exports = function isPrimitive(value) {
  1435. return value === null || (typeof value !== 'function' && typeof value !== 'object');
  1436. };
  1437. /***/ },
  1438. /* 23 */
  1439. /***/ function(module, exports, __webpack_require__) {
  1440. "use strict";
  1441. var toStr = Object.prototype.toString;
  1442. var isPrimitive = __webpack_require__(11);
  1443. var isCallable = __webpack_require__(3);
  1444. // https://es5.github.io/#x8.12
  1445. var ES5internalSlots = {
  1446. '[[DefaultValue]]': function (O, hint) {
  1447. var actualHint = hint || (toStr.call(O) === '[object Date]' ? String : Number);
  1448. if (actualHint === String || actualHint === Number) {
  1449. var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
  1450. var value, i;
  1451. for (i = 0; i < methods.length; ++i) {
  1452. if (isCallable(O[methods[i]])) {
  1453. value = O[methods[i]]();
  1454. if (isPrimitive(value)) {
  1455. return value;
  1456. }
  1457. }
  1458. }
  1459. throw new TypeError('No default value');
  1460. }
  1461. throw new TypeError('invalid [[DefaultValue]] hint supplied');
  1462. }
  1463. };
  1464. // https://es5.github.io/#x9
  1465. module.exports = function ToPrimitive(input, PreferredType) {
  1466. if (isPrimitive(input)) {
  1467. return input;
  1468. }
  1469. return ES5internalSlots['[[DefaultValue]]'](input, PreferredType);
  1470. };
  1471. /***/ },
  1472. /* 24 */
  1473. /***/ function(module, exports, __webpack_require__) {
  1474. "use strict";
  1475. var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
  1476. var isPrimitive = __webpack_require__(11);
  1477. var isCallable = __webpack_require__(3);
  1478. var isDate = __webpack_require__(28);
  1479. var isSymbol = __webpack_require__(30);
  1480. var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
  1481. if (typeof O === 'undefined' || O === null) {
  1482. throw new TypeError('Cannot call method on ' + O);
  1483. }
  1484. if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
  1485. throw new TypeError('hint must be "string" or "number"');
  1486. }
  1487. var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
  1488. var method, result, i;
  1489. for (i = 0; i < methodNames.length; ++i) {
  1490. method = O[methodNames[i]];
  1491. if (isCallable(method)) {
  1492. result = method.call(O);
  1493. if (isPrimitive(result)) {
  1494. return result;
  1495. }
  1496. }
  1497. }
  1498. throw new TypeError('No default value');
  1499. };
  1500. var GetMethod = function GetMethod(O, P) {
  1501. var func = O[P];
  1502. if (func !== null && typeof func !== 'undefined') {
  1503. if (!isCallable(func)) {
  1504. throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
  1505. }
  1506. return func;
  1507. }
  1508. };
  1509. // http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
  1510. module.exports = function ToPrimitive(input, PreferredType) {
  1511. if (isPrimitive(input)) {
  1512. return input;
  1513. }
  1514. var hint = 'default';
  1515. if (arguments.length > 1) {
  1516. if (PreferredType === String) {
  1517. hint = 'string';
  1518. } else if (PreferredType === Number) {
  1519. hint = 'number';
  1520. }
  1521. }
  1522. var exoticToPrim;
  1523. if (hasSymbols) {
  1524. if (Symbol.toPrimitive) {
  1525. exoticToPrim = GetMethod(input, Symbol.toPrimitive);
  1526. } else if (isSymbol(input)) {
  1527. exoticToPrim = Symbol.prototype.valueOf;
  1528. }
  1529. }
  1530. if (typeof exoticToPrim !== 'undefined') {
  1531. var result = exoticToPrim.call(input, hint);
  1532. if (isPrimitive(result)) {
  1533. return result;
  1534. }
  1535. throw new TypeError('unable to convert exotic object to primitive');
  1536. }
  1537. if (hint === 'default' && (isDate(input) || isSymbol(input))) {
  1538. hint = 'string';
  1539. }
  1540. return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
  1541. };
  1542. /***/ },
  1543. /* 25 */
  1544. /***/ function(module, exports) {
  1545. var hasOwn = Object.prototype.hasOwnProperty;
  1546. var toString = Object.prototype.toString;
  1547. module.exports = function forEach (obj, fn, ctx) {
  1548. if (toString.call(fn) !== '[object Function]') {
  1549. throw new TypeError('iterator must be a function');
  1550. }
  1551. var l = obj.length;
  1552. if (l === +l) {
  1553. for (var i = 0; i < l; i++) {
  1554. fn.call(ctx, obj[i], i, obj);
  1555. }
  1556. } else {
  1557. for (var k in obj) {
  1558. if (hasOwn.call(obj, k)) {
  1559. fn.call(ctx, obj[k], k, obj);
  1560. }
  1561. }
  1562. }
  1563. };
  1564. /***/ },
  1565. /* 26 */
  1566. /***/ function(module, exports) {
  1567. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  1568. var slice = Array.prototype.slice;
  1569. var toStr = Object.prototype.toString;
  1570. var funcType = '[object Function]';
  1571. module.exports = function bind(that) {
  1572. var target = this;
  1573. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  1574. throw new TypeError(ERROR_MESSAGE + target);
  1575. }
  1576. var args = slice.call(arguments, 1);
  1577. var bound;
  1578. var binder = function () {
  1579. if (this instanceof bound) {
  1580. var result = target.apply(
  1581. this,
  1582. args.concat(slice.call(arguments))
  1583. );
  1584. if (Object(result) === result) {
  1585. return result;
  1586. }
  1587. return this;
  1588. } else {
  1589. return target.apply(
  1590. that,
  1591. args.concat(slice.call(arguments))
  1592. );
  1593. }
  1594. };
  1595. var boundLength = Math.max(0, target.length - args.length);
  1596. var boundArgs = [];
  1597. for (var i = 0; i < boundLength; i++) {
  1598. boundArgs.push('$' + i);
  1599. }
  1600. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  1601. if (target.prototype) {
  1602. var Empty = function Empty() {};
  1603. Empty.prototype = target.prototype;
  1604. bound.prototype = new Empty();
  1605. Empty.prototype = null;
  1606. }
  1607. return bound;
  1608. };
  1609. /***/ },
  1610. /* 27 */
  1611. /***/ function(module, exports, __webpack_require__) {
  1612. var bind = __webpack_require__(2);
  1613. module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
  1614. /***/ },
  1615. /* 28 */
  1616. /***/ function(module, exports, __webpack_require__) {
  1617. "use strict";
  1618. var getDay = Date.prototype.getDay;
  1619. var tryDateObject = function tryDateObject(value) {
  1620. try {
  1621. getDay.call(value);
  1622. return true;
  1623. } catch (e) {
  1624. return false;
  1625. }
  1626. };
  1627. var toStr = Object.prototype.toString;
  1628. var dateClass = '[object Date]';
  1629. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  1630. module.exports = function isDateObject(value) {
  1631. if (typeof value !== 'object' || value === null) { return false; }
  1632. return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
  1633. };
  1634. /***/ },
  1635. /* 29 */
  1636. /***/ function(module, exports, __webpack_require__) {
  1637. "use strict";
  1638. var regexExec = RegExp.prototype.exec;
  1639. var tryRegexExec = function tryRegexExec(value) {
  1640. try {
  1641. regexExec.call(value);
  1642. return true;
  1643. } catch (e) {
  1644. return false;
  1645. }
  1646. };
  1647. var toStr = Object.prototype.toString;
  1648. var regexClass = '[object RegExp]';
  1649. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  1650. module.exports = function isRegex(value) {
  1651. if (typeof value !== 'object') { return false; }
  1652. return hasToStringTag ? tryRegexExec(value) : toStr.call(value) === regexClass;
  1653. };
  1654. /***/ },
  1655. /* 30 */
  1656. /***/ function(module, exports, __webpack_require__) {
  1657. "use strict";
  1658. var toStr = Object.prototype.toString;
  1659. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
  1660. if (hasSymbols) {
  1661. var symToStr = Symbol.prototype.toString;
  1662. var symStringRegex = /^Symbol\(.*\)$/;
  1663. var isSymbolObject = function isSymbolObject(value) {
  1664. if (typeof value.valueOf() !== 'symbol') { return false; }
  1665. return symStringRegex.test(symToStr.call(value));
  1666. };
  1667. module.exports = function isSymbol(value) {
  1668. if (typeof value === 'symbol') { return true; }
  1669. if (toStr.call(value) !== '[object Symbol]') { return false; }
  1670. try {
  1671. return isSymbolObject(value);
  1672. } catch (e) {
  1673. return false;
  1674. }
  1675. };
  1676. } else {
  1677. module.exports = function isSymbol(value) {
  1678. // this environment does not support Symbols.
  1679. return false;
  1680. };
  1681. }
  1682. /***/ },
  1683. /* 31 */
  1684. /***/ function(module, exports, __webpack_require__) {
  1685. "use strict";
  1686. // modified from https://github.com/es-shims/es5-shim
  1687. var has = Object.prototype.hasOwnProperty;
  1688. var toStr = Object.prototype.toString;
  1689. var slice = Array.prototype.slice;
  1690. var isArgs = __webpack_require__(32);
  1691. var isEnumerable = Object.prototype.propertyIsEnumerable;
  1692. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  1693. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  1694. var dontEnums = [
  1695. 'toString',
  1696. 'toLocaleString',
  1697. 'valueOf',
  1698. 'hasOwnProperty',
  1699. 'isPrototypeOf',
  1700. 'propertyIsEnumerable',
  1701. 'constructor'
  1702. ];
  1703. var equalsConstructorPrototype = function (o) {
  1704. var ctor = o.constructor;
  1705. return ctor && ctor.prototype === o;
  1706. };
  1707. var excludedKeys = {
  1708. $console: true,
  1709. $external: true,
  1710. $frame: true,
  1711. $frameElement: true,
  1712. $frames: true,
  1713. $innerHeight: true,
  1714. $innerWidth: true,
  1715. $outerHeight: true,
  1716. $outerWidth: true,
  1717. $pageXOffset: true,
  1718. $pageYOffset: true,
  1719. $parent: true,
  1720. $scrollLeft: true,
  1721. $scrollTop: true,
  1722. $scrollX: true,
  1723. $scrollY: true,
  1724. $self: true,
  1725. $webkitIndexedDB: true,
  1726. $webkitStorageInfo: true,
  1727. $window: true
  1728. };
  1729. var hasAutomationEqualityBug = (function () {
  1730. /* global window */
  1731. if (typeof window === 'undefined') { return false; }
  1732. for (var k in window) {
  1733. try {
  1734. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  1735. try {
  1736. equalsConstructorPrototype(window[k]);
  1737. } catch (e) {
  1738. return true;
  1739. }
  1740. }
  1741. } catch (e) {
  1742. return true;
  1743. }
  1744. }
  1745. return false;
  1746. }());
  1747. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  1748. /* global window */
  1749. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  1750. return equalsConstructorPrototype(o);
  1751. }
  1752. try {
  1753. return equalsConstructorPrototype(o);
  1754. } catch (e) {
  1755. return false;
  1756. }
  1757. };
  1758. var keysShim = function keys(object) {
  1759. var isObject = object !== null && typeof object === 'object';
  1760. var isFunction = toStr.call(object) === '[object Function]';
  1761. var isArguments = isArgs(object);
  1762. var isString = isObject && toStr.call(object) === '[object String]';
  1763. var theKeys = [];
  1764. if (!isObject && !isFunction && !isArguments) {
  1765. throw new TypeError('Object.keys called on a non-object');
  1766. }
  1767. var skipProto = hasProtoEnumBug && isFunction;
  1768. if (isString && object.length > 0 && !has.call(object, 0)) {
  1769. for (var i = 0; i < object.length; ++i) {
  1770. theKeys.push(String(i));
  1771. }
  1772. }
  1773. if (isArguments && object.length > 0) {
  1774. for (var j = 0; j < object.length; ++j) {
  1775. theKeys.push(String(j));
  1776. }
  1777. } else {
  1778. for (var name in object) {
  1779. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  1780. theKeys.push(String(name));
  1781. }
  1782. }
  1783. }
  1784. if (hasDontEnumBug) {
  1785. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  1786. for (var k = 0; k < dontEnums.length; ++k) {
  1787. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  1788. theKeys.push(dontEnums[k]);
  1789. }
  1790. }
  1791. }
  1792. return theKeys;
  1793. };
  1794. keysShim.shim = function shimObjectKeys() {
  1795. if (Object.keys) {
  1796. var keysWorksWithArguments = (function () {
  1797. // Safari 5.0 bug
  1798. return (Object.keys(arguments) || '').length === 2;
  1799. }(1, 2));
  1800. if (!keysWorksWithArguments) {
  1801. var originalKeys = Object.keys;
  1802. Object.keys = function keys(object) {
  1803. if (isArgs(object)) {
  1804. return originalKeys(slice.call(object));
  1805. } else {
  1806. return originalKeys(object);
  1807. }
  1808. };
  1809. }
  1810. } else {
  1811. Object.keys = keysShim;
  1812. }
  1813. return Object.keys || keysShim;
  1814. };
  1815. module.exports = keysShim;
  1816. /***/ },
  1817. /* 32 */
  1818. /***/ function(module, exports, __webpack_require__) {
  1819. "use strict";
  1820. var toStr = Object.prototype.toString;
  1821. module.exports = function isArguments(value) {
  1822. var str = toStr.call(value);
  1823. var isArgs = str === '[object Arguments]';
  1824. if (!isArgs) {
  1825. isArgs = str !== '[object Array]' &&
  1826. value !== null &&
  1827. typeof value === 'object' &&
  1828. typeof value.length === 'number' &&
  1829. value.length >= 0 &&
  1830. toStr.call(value.callee) === '[object Function]';
  1831. }
  1832. return isArgs;
  1833. };
  1834. /***/ },
  1835. /* 33 */
  1836. /***/ function(module, exports, __webpack_require__) {
  1837. "use strict";
  1838. var define = __webpack_require__(5);
  1839. var implementation = __webpack_require__(13);
  1840. var getPolyfill = __webpack_require__(14);
  1841. var shim = __webpack_require__(34);
  1842. var polyfill = getPolyfill();
  1843. define(polyfill, {
  1844. getPolyfill: getPolyfill,
  1845. implementation: implementation,
  1846. shim: shim
  1847. });
  1848. module.exports = polyfill;
  1849. /***/ },
  1850. /* 34 */
  1851. /***/ function(module, exports, __webpack_require__) {
  1852. "use strict";
  1853. var getPolyfill = __webpack_require__(14);
  1854. var define = __webpack_require__(5);
  1855. module.exports = function shimEntries() {
  1856. var polyfill = getPolyfill();
  1857. define(Object, { entries: polyfill }, {
  1858. entries: function testEntries() {
  1859. return Object.entries !== polyfill;
  1860. }
  1861. });
  1862. return polyfill;
  1863. };
  1864. /***/ },
  1865. /* 35 */
  1866. /***/ function(module, exports, __webpack_require__) {
  1867. "use strict";
  1868. var jsPDF = __webpack_require__(18);
  1869. var config_1 = __webpack_require__(0);
  1870. var common_1 = __webpack_require__(1);
  1871. var painter_1 = __webpack_require__(4);
  1872. var calculator_1 = __webpack_require__(16);
  1873. var creator_1 = __webpack_require__(17);
  1874. /**
  1875. * Create a table from a set of rows and columns.
  1876. *
  1877. * @param {Object[]|String[]} headers Either as an array of objects or array of strings
  1878. * @param {Object[][]|String[][]} data Either as an array of objects or array of strings
  1879. * @param {Object} [userOptions={}] Options that will override the default ones
  1880. */
  1881. jsPDF.API.autoTable = function (headers, data, tableOptions) {
  1882. if (tableOptions === void 0) { tableOptions = {}; }
  1883. this.autoTableState = this.autoTableState || {};
  1884. jsPDF.autoTableState = jsPDF.autoTableState || {};
  1885. var allOptions = [jsPDF.autoTableState.defaults || {}, this.autoTableState.defaults || {}, tableOptions || {}];
  1886. creator_1.validateInput(headers, data, allOptions);
  1887. var table = config_1.Config.createTable(this);
  1888. config_1.Config.initSettings(table, allOptions);
  1889. var settings = table.settings;
  1890. // Create the table model with its columns, rows and cells
  1891. creator_1.createModels(headers, data);
  1892. settings.margin = config_1.Config.marginOrPadding(settings.margin, config_1.getDefaults().margin);
  1893. calculator_1.calculateWidths(this, config_1.Config.pageSize().width);
  1894. table.cursor = {
  1895. x: table.margin('left'),
  1896. y: settings.startY === false ? table.margin('top') : settings.startY
  1897. };
  1898. var minTableBottomPos = settings.startY + table.margin('bottom') + table.headerRow.height;
  1899. if (settings.pageBreak === 'avoid') {
  1900. minTableBottomPos += table.height;
  1901. }
  1902. var pageHeight = config_1.Config.pageSize().height;
  1903. if ((settings.pageBreak === 'always' && settings.startY !== false) ||
  1904. (settings.startY !== false && minTableBottomPos > pageHeight)) {
  1905. table.doc.addPage();
  1906. table.cursor.y = table.margin('top');
  1907. }
  1908. table.pageStartX = table.cursor.x;
  1909. table.pageStartY = table.cursor.y;
  1910. config_1.Config.applyUserStyles();
  1911. if (settings.showHeader === true || settings.showHeader === 'firstPage' || settings.showHeader === 'everyPage') {
  1912. painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
  1913. }
  1914. config_1.Config.applyUserStyles();
  1915. table.rows.forEach(function (row) {
  1916. painter_1.printFullRow(row, table.hooks.drawRow, table.hooks.drawCell);
  1917. });
  1918. common_1.addTableBorder();
  1919. // Don't call global and document addPageContent more than once for each page
  1920. var pageNumber = this.internal.getCurrentPageInfo().pageNumber;
  1921. if (this.autoTableState.addPageHookPages && this.autoTableState.addPageHookPages[pageNumber]) {
  1922. if (typeof tableOptions['addPageContent'] === 'function') {
  1923. tableOptions['addPageContent'](config_1.Config.hooksData());
  1924. }
  1925. }
  1926. else {
  1927. if (!this.autoTableState.addPageHookPages)
  1928. this.autoTableState.addPageHookPages = {};
  1929. this.autoTableState.addPageHookPages[pageNumber] = true;
  1930. common_1.addContentHooks();
  1931. }
  1932. table.finalY = table.cursor.y;
  1933. this.autoTable.previous = table;
  1934. config_1.Config.applyUserStyles();
  1935. return this;
  1936. };
  1937. // Enables doc.autoTable.previous.finalY || 40;
  1938. jsPDF.API.autoTable.previous = false;
  1939. jsPDF.API.autoTableSetDefaults = function (defaults) {
  1940. if (!this.autoTableState)
  1941. this.autoTableState = {};
  1942. if (defaults && typeof defaults === 'object') {
  1943. this.autoTableState.defaults = defaults;
  1944. }
  1945. else {
  1946. delete this.autoTableState.defaults;
  1947. }
  1948. return this;
  1949. };
  1950. jsPDF.autoTableSetDefaults = function (defaults) {
  1951. if (!jsPDF.autoTableState)
  1952. jsPDF.autoTableState = {};
  1953. if (defaults && typeof defaults === 'object') {
  1954. this.autoTableState.defaults = defaults;
  1955. }
  1956. else {
  1957. delete this.autoTableState.defaults;
  1958. }
  1959. jsPDF.autoTableState.defaults = defaults;
  1960. };
  1961. /**
  1962. * Parses an html table
  1963. *
  1964. * @param tableElem Html table element
  1965. * @param includeHiddenElements If to include hidden rows and columns (defaults to false)
  1966. * @returns Object Object with two properties, columns and rows
  1967. */
  1968. jsPDF.API.autoTableHtmlToJson = function (tableElem, includeHiddenElements) {
  1969. includeHiddenElements = includeHiddenElements || false;
  1970. if (!tableElem || !(tableElem instanceof HTMLTableElement)) {
  1971. console.error("A HTMLTableElement has to be sent to autoTableHtmlToJson");
  1972. return null;
  1973. }
  1974. var columns = {}, rows = [];
  1975. var header = tableElem.rows[0];
  1976. for (var i = 0; i < header.cells.length; i++) {
  1977. var cell = header.cells[i];
  1978. var style = window.getComputedStyle(cell);
  1979. if (includeHiddenElements || style.display !== 'none') {
  1980. columns[i] = cell;
  1981. }
  1982. }
  1983. var _loop_1 = function (i) {
  1984. var tableRow = tableElem.rows[i];
  1985. var style = window.getComputedStyle(tableRow);
  1986. if (includeHiddenElements || style.display !== 'none') {
  1987. var rowData_1 = [];
  1988. Object.keys(columns).forEach(function (key) {
  1989. var cell = tableRow.cells[key];
  1990. rowData_1.push(cell);
  1991. });
  1992. rows.push(rowData_1);
  1993. }
  1994. };
  1995. for (var i = 1; i < tableElem.rows.length; i++) {
  1996. _loop_1(i);
  1997. }
  1998. var values = Object.keys(columns).map(function (key) { return columns[key]; });
  1999. return { columns: values, rows: rows, data: rows };
  2000. };
  2001. /**
  2002. * Improved text function with halign and valign support
  2003. * Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113
  2004. */
  2005. jsPDF.API.autoTableText = function (text, x, y, styles) {
  2006. if (typeof x !== 'number' || typeof y !== 'number') {
  2007. console.error('The x and y parameters are required. Missing for the text: ', text);
  2008. }
  2009. var k = this.internal.scaleFactor;
  2010. var fontSize = this.internal.getFontSize() / k;
  2011. var splitRegex = /\r\n|\r|\n/g;
  2012. var splitText = null;
  2013. var lineCount = 1;
  2014. if (styles.valign === 'middle' || styles.valign === 'bottom' || styles.halign === 'center' || styles.halign === 'right') {
  2015. splitText = typeof text === 'string' ? text.split(splitRegex) : text;
  2016. lineCount = splitText.length || 1;
  2017. }
  2018. // Align the top
  2019. y += fontSize * (2 - config_1.FONT_ROW_RATIO);
  2020. if (styles.valign === 'middle')
  2021. y -= (lineCount / 2) * fontSize * config_1.FONT_ROW_RATIO;
  2022. else if (styles.valign === 'bottom')
  2023. y -= lineCount * fontSize * config_1.FONT_ROW_RATIO;
  2024. if (styles.halign === 'center' || styles.halign === 'right') {
  2025. var alignSize = fontSize;
  2026. if (styles.halign === 'center')
  2027. alignSize *= 0.5;
  2028. if (lineCount >= 1) {
  2029. for (var iLine = 0; iLine < splitText.length; iLine++) {
  2030. this.text(splitText[iLine], x - this.getStringUnitWidth(splitText[iLine]) * alignSize, y);
  2031. y += fontSize;
  2032. }
  2033. return this;
  2034. }
  2035. x -= this.getStringUnitWidth(text) * alignSize;
  2036. }
  2037. this.text(text, x, y);
  2038. return this;
  2039. };
  2040. /**
  2041. * @deprecated Use doc.autoTable.previous.finalY instead
  2042. */
  2043. jsPDF.API.autoTableEndPosY = function () {
  2044. var prev = this.autoTable.previous;
  2045. if (prev.cursor && typeof prev.cursor.y === 'number') {
  2046. return prev.cursor.y;
  2047. }
  2048. else {
  2049. return 0;
  2050. }
  2051. };
  2052. /**
  2053. * @deprecated Use jsPDF.autoTableSetDefaults({addPageContent: function() {}}) instead
  2054. */
  2055. jsPDF.API.autoTableAddPageContent = function (hook) {
  2056. if (!jsPDF.API.autoTable.globalDefaults) {
  2057. jsPDF.API.autoTable.globalDefaults = {};
  2058. }
  2059. jsPDF.API.autoTable.globalDefaults.addPageContent = hook;
  2060. return this;
  2061. };
  2062. /**
  2063. * @deprecated Use data.addPage in hooks instead
  2064. */
  2065. jsPDF.API.autoTableAddPage = function () {
  2066. common_1.addPage();
  2067. return this;
  2068. };
  2069. /***/ }
  2070. /******/ ]);
  2071. });