1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | (function webpackUniversalModuleDefinition(root, factory) {
|
13 | if(typeof exports === 'object' && typeof module === 'object')
|
14 | module.exports = factory(require("jspdf"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define(["jspdf"], factory);
|
17 | else {
|
18 | var a = typeof exports === 'object' ? factory(require("jspdf")) : factory(root["jsPDF"]);
|
19 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
20 | }
|
21 | })(window, function(__WEBPACK_EXTERNAL_MODULE__4__) {
|
22 | return (function(modules) {
|
23 |
|
24 | var installedModules = {};
|
25 |
|
26 |
|
27 | function __webpack_require__(moduleId) {
|
28 |
|
29 |
|
30 | if(installedModules[moduleId]) {
|
31 | return installedModules[moduleId].exports;
|
32 | }
|
33 |
|
34 | var module = installedModules[moduleId] = {
|
35 | i: moduleId,
|
36 | l: false,
|
37 | exports: {}
|
38 | };
|
39 |
|
40 |
|
41 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
42 |
|
43 |
|
44 | module.l = true;
|
45 |
|
46 |
|
47 | return module.exports;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 | __webpack_require__.m = modules;
|
53 |
|
54 |
|
55 | __webpack_require__.c = installedModules;
|
56 |
|
57 |
|
58 | __webpack_require__.d = function(exports, name, getter) {
|
59 | if(!__webpack_require__.o(exports, name)) {
|
60 | Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
61 | }
|
62 | };
|
63 |
|
64 |
|
65 | __webpack_require__.r = function(exports) {
|
66 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
67 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
68 | }
|
69 | Object.defineProperty(exports, '__esModule', { value: true });
|
70 | };
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | __webpack_require__.t = function(value, mode) {
|
78 | if(mode & 1) value = __webpack_require__(value);
|
79 | if(mode & 8) return value;
|
80 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
81 | var ns = Object.create(null);
|
82 | __webpack_require__.r(ns);
|
83 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
84 | if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
85 | return ns;
|
86 | };
|
87 |
|
88 |
|
89 | __webpack_require__.n = function(module) {
|
90 | var getter = module && module.__esModule ?
|
91 | function getDefault() { return module['default']; } :
|
92 | function getModuleExports() { return module; };
|
93 | __webpack_require__.d(getter, 'a', getter);
|
94 | return getter;
|
95 | };
|
96 |
|
97 |
|
98 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
99 |
|
100 |
|
101 | __webpack_require__.p = "";
|
102 |
|
103 |
|
104 |
|
105 | return __webpack_require__(__webpack_require__.s = 5);
|
106 | })
|
107 |
|
108 | ([
|
109 |
|
110 | (function(module, exports, __webpack_require__) {
|
111 |
|
112 | "use strict";
|
113 |
|
114 | Object.defineProperty(exports, "__esModule", { value: true });
|
115 | var defaultsDocument = null;
|
116 | var previousTableState;
|
117 | var tableState = null;
|
118 | exports.globalDefaults = {};
|
119 | exports.documentDefaults = {};
|
120 | function default_1() {
|
121 | return tableState;
|
122 | }
|
123 | exports.default = default_1;
|
124 | function getGlobalOptions() {
|
125 | return exports.globalDefaults;
|
126 | }
|
127 | exports.getGlobalOptions = getGlobalOptions;
|
128 | function getDocumentOptions() {
|
129 | return exports.documentDefaults;
|
130 | }
|
131 | exports.getDocumentOptions = getDocumentOptions;
|
132 | var TableState = (function () {
|
133 | function TableState(doc) {
|
134 | this.doc = doc;
|
135 | }
|
136 | TableState.prototype.pageHeight = function () {
|
137 | return this.pageSize().height;
|
138 | };
|
139 | ;
|
140 | TableState.prototype.pageWidth = function () {
|
141 | return this.pageSize().width;
|
142 | };
|
143 | ;
|
144 | TableState.prototype.pageSize = function () {
|
145 | var pageSize = this.doc.internal.pageSize;
|
146 |
|
147 | if (pageSize.width == null) {
|
148 | pageSize = {
|
149 | width: pageSize.getWidth(),
|
150 | height: pageSize.getHeight()
|
151 | };
|
152 | }
|
153 | return pageSize;
|
154 | };
|
155 | ;
|
156 | TableState.prototype.scaleFactor = function () {
|
157 | return this.doc.internal.scaleFactor;
|
158 | };
|
159 | ;
|
160 | TableState.prototype.pageNumber = function () {
|
161 | return this.doc.internal.getCurrentPageInfo().pageNumber;
|
162 | };
|
163 | return TableState;
|
164 | }());
|
165 | function setupState(doc) {
|
166 | previousTableState = tableState;
|
167 | tableState = new TableState(doc);
|
168 | if (doc !== defaultsDocument) {
|
169 | defaultsDocument = doc;
|
170 | exports.documentDefaults = {};
|
171 | }
|
172 | }
|
173 | exports.setupState = setupState;
|
174 | function resetState() {
|
175 | tableState = previousTableState;
|
176 | }
|
177 | exports.resetState = resetState;
|
178 | function setDefaults(defaults, doc) {
|
179 | if (doc === void 0) { doc = null; }
|
180 | if (doc) {
|
181 | exports.documentDefaults = defaults || {};
|
182 | defaultsDocument = doc;
|
183 | }
|
184 | else {
|
185 | exports.globalDefaults = defaults || {};
|
186 | }
|
187 | }
|
188 | exports.setDefaults = setDefaults;
|
189 |
|
190 |
|
191 | }),
|
192 |
|
193 | (function(module, exports, __webpack_require__) {
|
194 |
|
195 | "use strict";
|
196 |
|
197 | Object.defineProperty(exports, "__esModule", { value: true });
|
198 | var config_1 = __webpack_require__(2);
|
199 | var state_1 = __webpack_require__(0);
|
200 | var polyfills_1 = __webpack_require__(3);
|
201 | function getStringWidth(text, styles) {
|
202 | var fontSize = styles.fontSize / state_1.default().scaleFactor();
|
203 | applyStyles(styles);
|
204 | text = Array.isArray(text) ? text : [text];
|
205 | var maxWidth = 0;
|
206 | text.forEach(function (line) {
|
207 | var width = state_1.default().doc.getStringUnitWidth(line);
|
208 | if (width > maxWidth) {
|
209 | maxWidth = width;
|
210 | }
|
211 | });
|
212 | var precision = 10000 * state_1.default().scaleFactor();
|
213 | maxWidth = Math.floor(maxWidth * precision) / precision;
|
214 | return maxWidth * fontSize;
|
215 | }
|
216 | exports.getStringWidth = getStringWidth;
|
217 |
|
218 |
|
219 |
|
220 | function ellipsize(text, width, styles, ellipsizeStr) {
|
221 | if (ellipsizeStr === void 0) { ellipsizeStr = '...'; }
|
222 | if (Array.isArray(text)) {
|
223 | var value_1 = [];
|
224 | text.forEach(function (str, i) {
|
225 | value_1[i] = ellipsize(str, width, styles, ellipsizeStr);
|
226 | });
|
227 | return value_1;
|
228 | }
|
229 | var precision = 10000 * state_1.default().scaleFactor();
|
230 | width = Math.ceil(width * precision) / precision;
|
231 | if (width >= getStringWidth(text, styles)) {
|
232 | return text;
|
233 | }
|
234 | while (width < getStringWidth(text + ellipsizeStr, styles)) {
|
235 | if (text.length <= 1) {
|
236 | break;
|
237 | }
|
238 | text = text.substring(0, text.length - 1);
|
239 | }
|
240 | return text.trim() + ellipsizeStr;
|
241 | }
|
242 | exports.ellipsize = ellipsize;
|
243 | function addTableBorder() {
|
244 | var table = state_1.default().table;
|
245 | var styles = { lineWidth: table.settings.tableLineWidth, lineColor: table.settings.tableLineColor };
|
246 | applyStyles(styles);
|
247 | var fs = getFillStyle(styles);
|
248 | if (fs) {
|
249 | state_1.default().doc.rect(table.pageStartX, table.pageStartY, table.width, table.cursor.y - table.pageStartY, fs);
|
250 | }
|
251 | }
|
252 | exports.addTableBorder = addTableBorder;
|
253 | function getFillStyle(styles) {
|
254 | var drawLine = styles.lineWidth > 0;
|
255 | var drawBackground = styles.fillColor || styles.fillColor === 0;
|
256 | if (drawLine && drawBackground) {
|
257 | return 'DF';
|
258 | }
|
259 | else if (drawLine) {
|
260 | return 'S';
|
261 | }
|
262 | else if (drawBackground) {
|
263 | return 'F';
|
264 | }
|
265 | else {
|
266 | return false;
|
267 | }
|
268 | }
|
269 | exports.getFillStyle = getFillStyle;
|
270 | function applyUserStyles() {
|
271 | applyStyles(state_1.default().table.userStyles);
|
272 | }
|
273 | exports.applyUserStyles = applyUserStyles;
|
274 | function applyStyles(styles) {
|
275 | var doc = state_1.default().doc;
|
276 | var styleModifiers = {
|
277 | fillColor: doc.setFillColor,
|
278 | textColor: doc.setTextColor,
|
279 | fontStyle: doc.setFontStyle,
|
280 | lineColor: doc.setDrawColor,
|
281 | lineWidth: doc.setLineWidth,
|
282 | font: doc.setFont,
|
283 | fontSize: doc.setFontSize
|
284 | };
|
285 | Object.keys(styleModifiers).forEach(function (name) {
|
286 | var style = styles[name];
|
287 | var modifier = styleModifiers[name];
|
288 | if (typeof style !== 'undefined') {
|
289 | if (Array.isArray(style)) {
|
290 | modifier.apply(this, style);
|
291 | }
|
292 | else {
|
293 | modifier(style);
|
294 | }
|
295 | }
|
296 | });
|
297 | }
|
298 | exports.applyStyles = applyStyles;
|
299 |
|
300 | function marginOrPadding(value, defaultValue) {
|
301 | var newValue = {};
|
302 | if (Array.isArray(value)) {
|
303 | if (value.length >= 4) {
|
304 | newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[3] };
|
305 | }
|
306 | else if (value.length === 3) {
|
307 | newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[1] };
|
308 | }
|
309 | else if (value.length === 2) {
|
310 | newValue = { 'top': value[0], 'right': value[1], 'bottom': value[0], 'left': value[1] };
|
311 | }
|
312 | else if (value.length === 1) {
|
313 | value = value[0];
|
314 | }
|
315 | else {
|
316 | value = defaultValue;
|
317 | }
|
318 | }
|
319 | else if (typeof value === 'object') {
|
320 | if (value['vertical']) {
|
321 | value['top'] = value['vertical'];
|
322 | value['bottom'] = value['vertical'];
|
323 | }
|
324 | if (value['horizontal']) {
|
325 | value['right'] = value['horizontal'];
|
326 | value['left'] = value['horizontal'];
|
327 | }
|
328 | for (var _i = 0, _a = ['top', 'right', 'bottom', 'left']; _i < _a.length; _i++) {
|
329 | var side = _a[_i];
|
330 | newValue[side] = (value[side] || value[side] === 0) ? value[side] : defaultValue;
|
331 | }
|
332 | }
|
333 | if (typeof value === 'number') {
|
334 | newValue = { 'top': value, 'right': value, 'bottom': value, 'left': value };
|
335 | }
|
336 | return newValue;
|
337 | }
|
338 | exports.marginOrPadding = marginOrPadding;
|
339 | function styles(styles) {
|
340 | styles = Array.isArray(styles) ? styles : [styles];
|
341 | return polyfills_1.assign.apply(void 0, [config_1.defaultStyles()].concat(styles));
|
342 | }
|
343 | exports.styles = styles;
|
344 |
|
345 |
|
346 | }),
|
347 |
|
348 | (function(module, exports, __webpack_require__) {
|
349 |
|
350 | "use strict";
|
351 |
|
352 | Object.defineProperty(exports, "__esModule", { value: true });
|
353 |
|
354 |
|
355 |
|
356 | exports.FONT_ROW_RATIO = 1.15;
|
357 | var state_1 = __webpack_require__(0);
|
358 | function defaultConfig() {
|
359 | return {
|
360 |
|
361 | html: null,
|
362 |
|
363 | head: null,
|
364 | body: null,
|
365 | foot: null,
|
366 |
|
367 | includeHiddenHtml: false,
|
368 | startY: null,
|
369 | margin: 40 / state_1.default().scaleFactor(),
|
370 | pageBreak: 'auto',
|
371 | rowPageBreak: 'auto',
|
372 | tableWidth: 'auto',
|
373 | showHead: 'everyPage',
|
374 | showFoot: 'everyPage',
|
375 | tableLineWidth: 0,
|
376 | tableLineColor: 200,
|
377 | tableId: null,
|
378 |
|
379 | theme: 'striped',
|
380 | useCss: false,
|
381 | styles: {},
|
382 | headStyles: {},
|
383 | bodyStyles: {},
|
384 | footStyles: {},
|
385 | alternateRowStyles: {},
|
386 | columnStyles: {},
|
387 |
|
388 |
|
389 | didParseCell: function (data) {
|
390 | },
|
391 | willDrawCell: function (data) {
|
392 | },
|
393 |
|
394 | didDrawCell: function (data) {
|
395 | },
|
396 |
|
397 | didDrawPage: function (data) {
|
398 | },
|
399 | };
|
400 | }
|
401 | exports.defaultConfig = defaultConfig;
|
402 |
|
403 | function defaultStyles() {
|
404 | return {
|
405 | font: "helvetica",
|
406 | fontStyle: 'normal',
|
407 | overflow: 'linebreak',
|
408 | fillColor: false,
|
409 | textColor: 20,
|
410 | halign: 'left',
|
411 | valign: 'top',
|
412 | fontSize: 10,
|
413 | cellPadding: 5 / state_1.default().scaleFactor(),
|
414 | lineColor: 200,
|
415 | lineWidth: 0 / state_1.default().scaleFactor(),
|
416 | cellWidth: 'auto',
|
417 | minCellHeight: 0
|
418 | };
|
419 | }
|
420 | exports.defaultStyles = defaultStyles;
|
421 |
|
422 |
|
423 |
|
424 | function getTheme(name) {
|
425 | var themes = {
|
426 | 'striped': {
|
427 | table: { fillColor: 255, textColor: 80, fontStyle: 'normal' },
|
428 | head: { textColor: 255, fillColor: [41, 128, 185], fontStyle: 'bold' },
|
429 | body: {},
|
430 | foot: { textColor: 255, fillColor: [41, 128, 185], fontStyle: 'bold' },
|
431 | alternateRow: { fillColor: 245 }
|
432 | },
|
433 | 'grid': {
|
434 | table: { fillColor: 255, textColor: 80, fontStyle: 'normal', lineWidth: 0.1 },
|
435 | head: { textColor: 255, fillColor: [26, 188, 156], fontStyle: 'bold', lineWidth: 0 },
|
436 | body: {},
|
437 | foot: { textColor: 255, fillColor: [26, 188, 156], fontStyle: 'bold', lineWidth: 0 },
|
438 | alternateRow: {}
|
439 | },
|
440 | 'plain': {
|
441 | head: { fontStyle: 'bold' },
|
442 | foot: { fontStyle: 'bold' }
|
443 | }
|
444 | };
|
445 | return themes[name];
|
446 | }
|
447 | exports.getTheme = getTheme;
|
448 |
|
449 |
|
450 | }),
|
451 |
|
452 | (function(module, exports, __webpack_require__) {
|
453 |
|
454 | "use strict";
|
455 |
|
456 |
|
457 |
|
458 |
|
459 | Object.defineProperty(exports, "__esModule", { value: true });
|
460 |
|
461 | function assign(target) {
|
462 | 'use strict';
|
463 | var varArgs = [];
|
464 | for (var _i = 1; _i < arguments.length; _i++) {
|
465 | varArgs[_i - 1] = arguments[_i];
|
466 | }
|
467 | if (target == null) {
|
468 | throw new TypeError('Cannot convert undefined or null to object');
|
469 | }
|
470 | var to = Object(target);
|
471 | for (var index = 1; index < arguments.length; index++) {
|
472 | var nextSource = arguments[index];
|
473 | if (nextSource != null) {
|
474 | for (var nextKey in nextSource) {
|
475 |
|
476 | if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
477 | to[nextKey] = nextSource[nextKey];
|
478 | }
|
479 | }
|
480 | }
|
481 | }
|
482 | return to;
|
483 | }
|
484 | exports.assign = assign;
|
485 |
|
486 |
|
487 | }),
|
488 |
|
489 | (function(module, exports) {
|
490 |
|
491 | module.exports = __WEBPACK_EXTERNAL_MODULE__4__;
|
492 |
|
493 | }),
|
494 |
|
495 | (function(module, exports, __webpack_require__) {
|
496 |
|
497 | "use strict";
|
498 |
|
499 | Object.defineProperty(exports, "__esModule", { value: true });
|
500 | var tableDrawer_1 = __webpack_require__(6);
|
501 | var widthCalculator_1 = __webpack_require__(7);
|
502 | var inputParser_1 = __webpack_require__(8);
|
503 | var state_1 = __webpack_require__(0);
|
504 | __webpack_require__(15);
|
505 | var common_1 = __webpack_require__(1);
|
506 | var jsPDF = __webpack_require__(4);
|
507 | jsPDF.API.autoTable = function () {
|
508 | state_1.setupState(this);
|
509 |
|
510 | var table = inputParser_1.parseInput(arguments);
|
511 |
|
512 | widthCalculator_1.calculateWidths(table);
|
513 |
|
514 | tableDrawer_1.drawTable(table);
|
515 | table.finalY = table.cursor.y;
|
516 | this.previousAutoTable = table;
|
517 | this.lastAutoTable = table;
|
518 | this.autoTable.previous = table;
|
519 | common_1.applyUserStyles();
|
520 | state_1.resetState();
|
521 | return this;
|
522 | };
|
523 |
|
524 | jsPDF.API.lastAutoTable = false;
|
525 | jsPDF.API.previousAutoTable = false;
|
526 | jsPDF.API.autoTable.previous = false;
|
527 | jsPDF.API.autoTableSetDefaults = function (defaults) {
|
528 | state_1.setDefaults(defaults, this);
|
529 | return this;
|
530 | };
|
531 | jsPDF.autoTableSetDefaults = function (defaults, doc) {
|
532 | state_1.setDefaults(defaults, doc);
|
533 | return this;
|
534 | };
|
535 |
|
536 |
|
537 |
|
538 | jsPDF.API.autoTableHtmlToJson = function (tableElem, includeHiddenElements) {
|
539 | console.error("Use of deprecated function: autoTableHtmlToJson. Use html option instead.");
|
540 | includeHiddenElements = includeHiddenElements || false;
|
541 | if (!tableElem || !(tableElem instanceof HTMLTableElement)) {
|
542 | console.error("A HTMLTableElement has to be sent to autoTableHtmlToJson");
|
543 | return null;
|
544 | }
|
545 | var columns = {}, rows = [];
|
546 | var header = tableElem.rows[0];
|
547 | for (var i = 0; i < header.cells.length; i++) {
|
548 | var cell = header.cells[i];
|
549 | var style = window.getComputedStyle(cell);
|
550 | if (includeHiddenElements || style.display !== 'none') {
|
551 | columns[i] = cell;
|
552 | }
|
553 | }
|
554 | var _loop_1 = function (i) {
|
555 | var tableRow = tableElem.rows[i];
|
556 | var style = window.getComputedStyle(tableRow);
|
557 | if (includeHiddenElements || style.display !== 'none') {
|
558 | var rowData_1 = [];
|
559 | Object.keys(columns).forEach(function (key) {
|
560 | var cell = tableRow.cells[key];
|
561 | rowData_1.push(cell);
|
562 | });
|
563 | rows.push(rowData_1);
|
564 | }
|
565 | };
|
566 | for (var i = 1; i < tableElem.rows.length; i++) {
|
567 | _loop_1(i);
|
568 | }
|
569 | var values = Object.keys(columns).map(function (key) {
|
570 | return columns[key];
|
571 | });
|
572 | return { columns: values, rows: rows, data: rows };
|
573 | };
|
574 |
|
575 |
|
576 |
|
577 | jsPDF.API.autoTableEndPosY = function () {
|
578 | console.error("Use of deprecated function: autoTableEndPosY. Use doc.previousAutoTable.finalY instead.");
|
579 | var prev = this.previousAutoTable;
|
580 | if (prev.cursor && typeof prev.cursor.y === 'number') {
|
581 | return prev.cursor.y;
|
582 | }
|
583 | else {
|
584 | return 0;
|
585 | }
|
586 | };
|
587 |
|
588 |
|
589 |
|
590 | jsPDF.API.autoTableAddPageContent = function (hook) {
|
591 | console.error("Use of deprecated function: autoTableAddPageContent. Use jsPDF.autoTableSetDefaults({didDrawPage: () => {}}) instead.");
|
592 | if (!jsPDF.API.autoTable.globalDefaults) {
|
593 | jsPDF.API.autoTable.globalDefaults = {};
|
594 | }
|
595 | jsPDF.API.autoTable.globalDefaults.addPageContent = hook;
|
596 | return this;
|
597 | };
|
598 |
|
599 |
|
600 |
|
601 | jsPDF.API.autoTableAddPage = function () {
|
602 | console.error("Use of deprecated function: autoTableAddPage. Use doc.addPage()");
|
603 | this.addPage();
|
604 | return this;
|
605 | };
|
606 |
|
607 |
|
608 | }),
|
609 |
|
610 | (function(module, exports, __webpack_require__) {
|
611 |
|
612 | "use strict";
|
613 |
|
614 | Object.defineProperty(exports, "__esModule", { value: true });
|
615 | var config_1 = __webpack_require__(2);
|
616 | var common_1 = __webpack_require__(1);
|
617 | var state_1 = __webpack_require__(0);
|
618 | function drawTable(table) {
|
619 | var settings = table.settings;
|
620 | table.cursor = {
|
621 | x: table.margin('left'),
|
622 | y: settings.startY == null ? table.margin('top') : settings.startY
|
623 | };
|
624 | var minTableBottomPos = settings.startY + table.margin('bottom') + table.headHeight + table.footHeight;
|
625 | if (settings.pageBreak === 'avoid') {
|
626 | minTableBottomPos += table.height;
|
627 | }
|
628 | if (settings.pageBreak === 'always' || settings.startY != null && settings.startY !== false && minTableBottomPos > state_1.default().pageHeight()) {
|
629 | nextPage(state_1.default().doc);
|
630 | table.cursor.y = table.margin('top');
|
631 | }
|
632 | table.pageStartX = table.cursor.x;
|
633 | table.pageStartY = table.cursor.y;
|
634 | table.startPageNumber = state_1.default().pageNumber();
|
635 | common_1.applyUserStyles();
|
636 | if (settings.showHead === true || settings.showHead === 'firstPage' || settings.showHead === 'everyPage') {
|
637 | table.head.forEach(function (row) { return printRow(row); });
|
638 | }
|
639 | common_1.applyUserStyles();
|
640 | table.body.forEach(function (row) {
|
641 | printFullRow(row);
|
642 | });
|
643 | common_1.applyUserStyles();
|
644 | if (settings.showFoot === true || settings.showFoot === 'lastPage' || settings.showFoot === 'everyPage') {
|
645 | table.foot.forEach(function (row) { return printRow(row); });
|
646 | }
|
647 | common_1.addTableBorder();
|
648 | table.callEndPageHooks();
|
649 | }
|
650 | exports.drawTable = drawTable;
|
651 | function printFullRow(row) {
|
652 | var remainingRowHeight = 0;
|
653 | var remainingTexts = {};
|
654 | var table = state_1.default().table;
|
655 | if (!canFitOnPage(row.maxCellHeight)) {
|
656 | if (row.maxCellLineCount <= 1 || (table.settings.rowPageBreak === 'avoid' && !rowHeightGreaterThanMaxTableHeight(row))) {
|
657 | addPage();
|
658 | }
|
659 | else {
|
660 |
|
661 | row.spansMultiplePages = true;
|
662 | var maxCellHeight = 0;
|
663 | var maxRowSpanCellHeight = 0;
|
664 | for (var j = 0; j < table.columns.length; j++) {
|
665 | var column = table.columns[j];
|
666 | var cell = row.cells[column.dataKey];
|
667 | if (!cell) {
|
668 | continue;
|
669 | }
|
670 | var fontHeight = cell.styles.fontSize / state_1.default().scaleFactor() * config_1.FONT_ROW_RATIO;
|
671 | var vPadding = cell.padding('vertical');
|
672 | var pageHeight = state_1.default().pageHeight();
|
673 | var remainingPageSpace = pageHeight - table.cursor.y - table.margin('bottom');
|
674 | var remainingLineCount = Math.floor((remainingPageSpace - vPadding) / fontHeight);
|
675 | if (Array.isArray(cell.text) && cell.text.length > remainingLineCount) {
|
676 | var remainingLines = cell.text.splice(remainingLineCount, cell.text.length);
|
677 | remainingTexts[column.dataKey] = remainingLines;
|
678 | var cellHeight = cell.text.length * fontHeight + vPadding;
|
679 | if (cellHeight > maxCellHeight) {
|
680 | maxCellHeight = cellHeight;
|
681 | }
|
682 | var rCellHeight = remainingLines.length * fontHeight + vPadding;
|
683 | if (rCellHeight > remainingRowHeight) {
|
684 | remainingRowHeight = rCellHeight;
|
685 | }
|
686 | }
|
687 | }
|
688 | for (var j = 0; j < table.columns.length; j++) {
|
689 | var column = table.columns[j];
|
690 | var cell = row.cells[column.dataKey];
|
691 | cell.height = maxCellHeight;
|
692 | }
|
693 |
|
694 | row.height = maxCellHeight;
|
695 | row.maxCellHeight = maxRowSpanCellHeight;
|
696 | }
|
697 | }
|
698 | printRow(row);
|
699 |
|
700 |
|
701 | if (Object.keys(remainingTexts).length > 0) {
|
702 | for (var j = 0; j < table.columns.length; j++) {
|
703 | var col = table.columns[j];
|
704 | var cell = row.cells[col.dataKey];
|
705 | cell.height = remainingRowHeight;
|
706 | if (cell) {
|
707 | cell.text = remainingTexts[col.dataKey] || '';
|
708 | }
|
709 | }
|
710 | addPage();
|
711 | row.pageNumber++;
|
712 | row.height = remainingRowHeight;
|
713 | printFullRow(row);
|
714 | }
|
715 | }
|
716 | function rowHeightGreaterThanMaxTableHeight(row) {
|
717 | var table = state_1.default().table;
|
718 | var pageHeight = state_1.default().pageHeight();
|
719 | var maxTableHeight = pageHeight - table.margin('top') - table.margin('bottom');
|
720 | return row.maxCellHeight > maxTableHeight;
|
721 | }
|
722 | function printRow(row) {
|
723 | var table = state_1.default().table;
|
724 | table.cursor.x = table.margin('left');
|
725 | row.y = table.cursor.y;
|
726 | row.x = table.cursor.x;
|
727 |
|
728 | table.cursor.x = table.margin('left');
|
729 | row.y = table.cursor.y;
|
730 | row.x = table.cursor.x;
|
731 | for (var _i = 0, _a = table.columns; _i < _a.length; _i++) {
|
732 | var column = _a[_i];
|
733 | var cell = row.cells[column.dataKey];
|
734 | if (!cell) {
|
735 | table.cursor.x += column.width;
|
736 | continue;
|
737 | }
|
738 | common_1.applyStyles(cell.styles);
|
739 | cell.x = table.cursor.x;
|
740 | cell.y = row.y;
|
741 | if (cell.styles.valign === 'top') {
|
742 | cell.textPos.y = table.cursor.y + cell.padding('top');
|
743 | }
|
744 | else if (cell.styles.valign === 'bottom') {
|
745 | cell.textPos.y = table.cursor.y + cell.height - cell.padding('bottom');
|
746 | }
|
747 | else {
|
748 | cell.textPos.y = table.cursor.y + cell.height / 2;
|
749 | }
|
750 | if (cell.styles.halign === 'right') {
|
751 | cell.textPos.x = cell.x + cell.width - cell.padding('right');
|
752 | }
|
753 | else if (cell.styles.halign === 'center') {
|
754 | cell.textPos.x = cell.x + cell.width / 2;
|
755 | }
|
756 | else {
|
757 | cell.textPos.x = cell.x + cell.padding('left');
|
758 | }
|
759 | if (table.callCellHooks(table.cellHooks.willDrawCell, cell, row, column) === false) {
|
760 | table.cursor.x += column.width;
|
761 | continue;
|
762 | }
|
763 | var fillStyle = common_1.getFillStyle(cell.styles);
|
764 | if (fillStyle) {
|
765 | state_1.default().doc.rect(cell.x, table.cursor.y, cell.width, cell.height, fillStyle);
|
766 | }
|
767 | state_1.default().doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, {
|
768 | halign: cell.styles.halign,
|
769 | valign: cell.styles.valign,
|
770 | maxWidth: cell.width - cell.padding('left') - cell.padding('right')
|
771 | });
|
772 | table.callCellHooks(table.cellHooks.didDrawCell, cell, row, column);
|
773 | table.cursor.x += column.width;
|
774 | }
|
775 | table.cursor.y += row.height;
|
776 | }
|
777 | function canFitOnPage(rowHeight) {
|
778 | var table = state_1.default().table;
|
779 | var bottomContentHeight = table.margin('bottom');
|
780 | var showFoot = table.settings.showFoot;
|
781 | if (showFoot === true || showFoot === 'everyPage' || showFoot === 'lastPage') {
|
782 | bottomContentHeight += table.footHeight;
|
783 | }
|
784 | var pos = rowHeight + table.cursor.y + bottomContentHeight;
|
785 | return pos < state_1.default().pageHeight();
|
786 | }
|
787 | function addPage() {
|
788 | var table = state_1.default().table;
|
789 | common_1.applyUserStyles();
|
790 | if (table.settings.showFoot === true || table.settings.showFoot === 'everyPage') {
|
791 | table.foot.forEach(function (row) { return printRow(row); });
|
792 | }
|
793 | table.finalY = table.cursor.y;
|
794 |
|
795 |
|
796 | table.callEndPageHooks();
|
797 | common_1.addTableBorder();
|
798 | nextPage(state_1.default().doc);
|
799 | table.pageNumber++;
|
800 | table.cursor = { x: table.margin('left'), y: table.margin('top') };
|
801 | table.pageStartX = table.cursor.x;
|
802 | table.pageStartY = table.cursor.y;
|
803 | if (table.settings.showHead === true || table.settings.showHead === 'everyPage') {
|
804 | table.head.forEach(function (row) { return printRow(row); });
|
805 | }
|
806 | }
|
807 | exports.addPage = addPage;
|
808 | function nextPage(doc) {
|
809 | var current = state_1.default().pageNumber();
|
810 | doc.setPage(current + 1);
|
811 | var newCurrent = state_1.default().pageNumber();
|
812 | if (newCurrent === current) {
|
813 | doc.addPage();
|
814 | }
|
815 | }
|
816 |
|
817 |
|
818 | }),
|
819 |
|
820 | (function(module, exports, __webpack_require__) {
|
821 |
|
822 | "use strict";
|
823 |
|
824 | Object.defineProperty(exports, "__esModule", { value: true });
|
825 | var config_1 = __webpack_require__(2);
|
826 | var common_1 = __webpack_require__(1);
|
827 | var state_1 = __webpack_require__(0);
|
828 |
|
829 |
|
830 |
|
831 | function calculateWidths(table) {
|
832 |
|
833 | var columnMinWidth = 10 / state_1.default().scaleFactor();
|
834 | if (columnMinWidth * table.columns.length > table.width) {
|
835 | console.error('Columns could not fit on page');
|
836 | }
|
837 | else if (table.minWidth > table.width) {
|
838 | console.error("Column widths to wide and can't fit page");
|
839 | }
|
840 | var copy = table.columns.slice(0);
|
841 | var diffWidth = table.width - table.wrappedWidth;
|
842 | distributeWidth(copy, diffWidth, table.wrappedWidth);
|
843 | applyColSpans(table);
|
844 | fitContent(table);
|
845 | applyRowSpans(table);
|
846 | }
|
847 | exports.calculateWidths = calculateWidths;
|
848 | function applyRowSpans(table) {
|
849 | var rowSpanCells = {};
|
850 | var colRowSpansLeft = 1;
|
851 | var all = table.allRows();
|
852 | for (var rowIndex = 0; rowIndex < all.length; rowIndex++) {
|
853 | var row = all[rowIndex];
|
854 | for (var _i = 0, _a = table.columns; _i < _a.length; _i++) {
|
855 | var column = _a[_i];
|
856 | var data = rowSpanCells[column.dataKey];
|
857 | if (colRowSpansLeft > 1) {
|
858 | colRowSpansLeft--;
|
859 | delete row.cells[column.dataKey];
|
860 | }
|
861 | else if (data) {
|
862 | data.cell.height += row.height;
|
863 | if (data.cell.height > row.maxCellHeight) {
|
864 | data.row.maxCellHeight = data.cell.height;
|
865 | data.row.maxCellLineCount = Array.isArray(data.cell.text) ? data.cell.text.length : 1;
|
866 | }
|
867 | colRowSpansLeft = data.cell.colSpan;
|
868 | delete row.cells[column.dataKey];
|
869 | data.left--;
|
870 | if (data.left <= 1) {
|
871 | delete rowSpanCells[column.dataKey];
|
872 | }
|
873 | }
|
874 | else {
|
875 | var cell = row.cells[column.dataKey];
|
876 | if (!cell) {
|
877 | continue;
|
878 | }
|
879 | cell.height = row.height;
|
880 | if (cell.rowSpan > 1) {
|
881 | var remaining = all.length - rowIndex;
|
882 | var left = cell.rowSpan > remaining ? remaining : cell.rowSpan;
|
883 | rowSpanCells[column.dataKey] = { cell: cell, left: left, row: row };
|
884 | }
|
885 | }
|
886 | }
|
887 | if (row.section === 'head') {
|
888 | table.headHeight += row.maxCellHeight;
|
889 | }
|
890 | if (row.section === 'foot') {
|
891 | table.footHeight += row.maxCellHeight;
|
892 | }
|
893 | table.height += row.height;
|
894 | }
|
895 | }
|
896 | function applyColSpans(table) {
|
897 | var all = table.allRows();
|
898 | for (var rowIndex = 0; rowIndex < all.length; rowIndex++) {
|
899 | var row = all[rowIndex];
|
900 | var colSpanCell = null;
|
901 | var combinedColSpanWidth = 0;
|
902 | var colSpansLeft = 0;
|
903 | for (var columnIndex = 0; columnIndex < table.columns.length; columnIndex++) {
|
904 | var column = table.columns[columnIndex];
|
905 | var cell = null;
|
906 |
|
907 | colSpansLeft -= 1;
|
908 | if (colSpansLeft > 1 && table.columns[columnIndex + 1]) {
|
909 | combinedColSpanWidth += column.width;
|
910 | delete row.cells[column.dataKey];
|
911 | continue;
|
912 | }
|
913 | else if (colSpanCell) {
|
914 | cell = colSpanCell;
|
915 | delete row.cells[column.dataKey];
|
916 | colSpanCell = null;
|
917 | }
|
918 | else {
|
919 | cell = row.cells[column.dataKey];
|
920 | if (!cell)
|
921 | continue;
|
922 | colSpansLeft = cell.colSpan;
|
923 | combinedColSpanWidth = 0;
|
924 | if (cell.colSpan > 1) {
|
925 | colSpanCell = cell;
|
926 | combinedColSpanWidth += column.width;
|
927 | continue;
|
928 | }
|
929 | }
|
930 | cell.width = column.width + combinedColSpanWidth;
|
931 | }
|
932 | }
|
933 | }
|
934 | function fitContent(table) {
|
935 | for (var _i = 0, _a = table.allRows(); _i < _a.length; _i++) {
|
936 | var row = _a[_i];
|
937 | for (var _b = 0, _c = table.columns; _b < _c.length; _b++) {
|
938 | var column = _c[_b];
|
939 | var cell = row.cells[column.dataKey];
|
940 | if (!cell)
|
941 | continue;
|
942 | common_1.applyStyles(cell.styles);
|
943 | var textSpace = cell.width - cell.padding('horizontal');
|
944 | if (cell.styles.overflow === 'linebreak') {
|
945 | cell.text = Array.isArray(cell.text) ? cell.text.join(' ') : cell.text;
|
946 |
|
947 | cell.text = state_1.default().doc.splitTextToSize(cell.text, textSpace + 1 / (state_1.default().scaleFactor() || 1), { fontSize: cell.styles.fontSize });
|
948 | }
|
949 | else if (cell.styles.overflow === 'ellipsize') {
|
950 | cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles);
|
951 | }
|
952 | else if (cell.styles.overflow === 'hidden') {
|
953 | cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles, '');
|
954 | }
|
955 | else if (typeof cell.styles.overflow === 'function') {
|
956 | cell.text = cell.styles.overflow(cell.text, textSpace);
|
957 | }
|
958 | var lineCount = Array.isArray(cell.text) ? cell.text.length : 1;
|
959 | lineCount = cell.rowSpan <= 1 ? lineCount : 1;
|
960 | var fontHeight = cell.styles.fontSize / state_1.default().scaleFactor() * config_1.FONT_ROW_RATIO;
|
961 | cell.contentHeight = lineCount * fontHeight + cell.padding('vertical');
|
962 | if (cell.styles.minCellHeight > cell.contentHeight) {
|
963 | cell.contentHeight = cell.styles.minCellHeight;
|
964 | }
|
965 | if (cell.contentHeight > row.height) {
|
966 | row.height = cell.contentHeight;
|
967 | row.maxCellHeight = cell.contentHeight;
|
968 | row.maxCellLineCount = lineCount;
|
969 | }
|
970 | }
|
971 | }
|
972 | }
|
973 | function distributeWidth(autoColumns, diffWidth, wrappedAutoColumnsWidth) {
|
974 | for (var i = 0; i < autoColumns.length; i++) {
|
975 | var column = autoColumns[i];
|
976 | var ratio = column.wrappedWidth / wrappedAutoColumnsWidth;
|
977 | var suggestedChange = diffWidth * ratio;
|
978 | var suggestedWidth = column.wrappedWidth + suggestedChange;
|
979 | if (suggestedWidth >= column.minWidth) {
|
980 | column.width = suggestedWidth;
|
981 | }
|
982 | else {
|
983 |
|
984 |
|
985 | column.width = column.minWidth + 1 / state_1.default().scaleFactor();
|
986 | wrappedAutoColumnsWidth -= column.wrappedWidth;
|
987 | autoColumns.splice(i, 1);
|
988 | distributeWidth(autoColumns, diffWidth, wrappedAutoColumnsWidth);
|
989 | break;
|
990 | }
|
991 | }
|
992 | }
|
993 |
|
994 |
|
995 | }),
|
996 |
|
997 | (function(module, exports, __webpack_require__) {
|
998 |
|
999 | "use strict";
|
1000 |
|
1001 | var __assign = (this && this.__assign) || function () {
|
1002 | __assign = Object.assign || function(t) {
|
1003 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1004 | s = arguments[i];
|
1005 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
1006 | t[p] = s[p];
|
1007 | }
|
1008 | return t;
|
1009 | };
|
1010 | return __assign.apply(this, arguments);
|
1011 | };
|
1012 | Object.defineProperty(exports, "__esModule", { value: true });
|
1013 | var models_1 = __webpack_require__(9);
|
1014 | var config_1 = __webpack_require__(2);
|
1015 | var htmlParser_1 = __webpack_require__(12);
|
1016 | var polyfills_1 = __webpack_require__(3);
|
1017 | var common_1 = __webpack_require__(1);
|
1018 | var state_1 = __webpack_require__(0);
|
1019 | var inputValidator_1 = __webpack_require__(14);
|
1020 |
|
1021 |
|
1022 |
|
1023 | function parseInput(args) {
|
1024 | var tableOptions = parseUserArguments(args);
|
1025 | var globalOptions = state_1.getGlobalOptions();
|
1026 | var documentOptions = state_1.getDocumentOptions();
|
1027 | var allOptions = [globalOptions, documentOptions, tableOptions];
|
1028 | inputValidator_1.default(allOptions);
|
1029 | var table = new models_1.Table();
|
1030 | state_1.default().table = table;
|
1031 | table.id = tableOptions.tableId;
|
1032 | var doc = state_1.default().doc;
|
1033 | table.userStyles = {
|
1034 |
|
1035 | textColor: doc.getTextColor ? doc.getTextColor() : 0,
|
1036 | fontSize: doc.internal.getFontSize(),
|
1037 | fontStyle: doc.internal.getFont().fontStyle,
|
1038 | font: doc.internal.getFont().fontName
|
1039 | };
|
1040 | var _loop_1 = function (styleProp) {
|
1041 | var styles = allOptions.map(function (opts) { return opts[styleProp] || {}; });
|
1042 | table.styles[styleProp] = polyfills_1.assign.apply(void 0, [{}].concat(styles));
|
1043 | };
|
1044 |
|
1045 | for (var _i = 0, _a = Object.keys(table.styles); _i < _a.length; _i++) {
|
1046 | var styleProp = _a[_i];
|
1047 | _loop_1(styleProp);
|
1048 | }
|
1049 |
|
1050 | for (var _b = 0, allOptions_1 = allOptions; _b < allOptions_1.length; _b++) {
|
1051 | var opts = allOptions_1[_b];
|
1052 | for (var _c = 0, _d = Object.keys(table.cellHooks); _c < _d.length; _c++) {
|
1053 | var hookName = _d[_c];
|
1054 | if (opts && typeof opts[hookName] === 'function') {
|
1055 | table.cellHooks[hookName].push(opts[hookName]);
|
1056 | delete opts[hookName];
|
1057 | }
|
1058 | }
|
1059 | }
|
1060 | table.settings = polyfills_1.assign.apply(void 0, [{}, config_1.defaultConfig()].concat(allOptions));
|
1061 | table.settings.margin = common_1.marginOrPadding(table.settings.margin, config_1.defaultConfig().margin);
|
1062 | if (table.settings.theme === 'auto') {
|
1063 | table.settings.theme = table.settings.useCss ? 'plain' : 'striped';
|
1064 | }
|
1065 | if (table.settings.startY === false) {
|
1066 | delete table.settings.startY;
|
1067 | }
|
1068 | var previous = state_1.default().doc.previousAutoTable;
|
1069 | var isSamePageAsPrevious = previous && previous.startPageNumber + previous.pageNumber - 1 === state_1.default().pageNumber();
|
1070 | if (table.settings.startY == null && isSamePageAsPrevious) {
|
1071 | table.settings.startY = previous.finalY + 20 / state_1.default().scaleFactor();
|
1072 | }
|
1073 | var htmlContent = {};
|
1074 | if (table.settings.html) {
|
1075 | htmlContent = htmlParser_1.parseHtml(table.settings.html, table.settings.includeHiddenHtml, table.settings.useCss) || {};
|
1076 | }
|
1077 | table.settings.head = htmlContent.head || table.settings.head || [];
|
1078 | table.settings.body = htmlContent.body || table.settings.body || [];
|
1079 | table.settings.foot = htmlContent.foot || table.settings.foot || [];
|
1080 | parseContent(table);
|
1081 | table.minWidth = table.columns.reduce(function (total, col) { return (total + col.minWidth); }, 0);
|
1082 | table.wrappedWidth = table.columns.reduce(function (total, col) { return (total + col.wrappedWidth); }, 0);
|
1083 | if (typeof table.settings.tableWidth === 'number') {
|
1084 | table.width = table.settings.tableWidth;
|
1085 | }
|
1086 | else if (table.settings.tableWidth === 'wrap') {
|
1087 | table.width = table.wrappedWidth;
|
1088 | }
|
1089 | else {
|
1090 | table.width = state_1.default().pageWidth() - table.margin('left') - table.margin('right');
|
1091 | }
|
1092 | return table;
|
1093 | }
|
1094 | exports.parseInput = parseInput;
|
1095 | function parseUserArguments(args) {
|
1096 |
|
1097 | if (args.length === 1) {
|
1098 | return args[0];
|
1099 | }
|
1100 | else {
|
1101 |
|
1102 | var opts = args[2] || {};
|
1103 | opts.body = args[1];
|
1104 | opts.columns = args[0];
|
1105 |
|
1106 | opts.columns.forEach(function (col) {
|
1107 | if (col.header == null) {
|
1108 | col.header = col.title;
|
1109 | }
|
1110 | });
|
1111 | return opts;
|
1112 | }
|
1113 | }
|
1114 | function parseContent(table) {
|
1115 | var settings = table.settings;
|
1116 | table.columns = getTableColumns(settings);
|
1117 | var _loop_2 = function (sectionName) {
|
1118 | var rowSpansLeftForColumn = {};
|
1119 | var sectionRows = settings[sectionName];
|
1120 | if (sectionRows.length === 0 && settings.columns) {
|
1121 | var sectionRow_1 = {};
|
1122 | table.columns
|
1123 | .forEach(function (col) {
|
1124 | var columnData = col.raw;
|
1125 | if (sectionName === 'head') {
|
1126 | var val = typeof columnData === 'object' ? columnData.header : columnData;
|
1127 | if (val) {
|
1128 | sectionRow_1[col.dataKey] = val;
|
1129 | }
|
1130 | }
|
1131 | else if (sectionName === 'foot' && columnData.footer) {
|
1132 | sectionRow_1[col.dataKey] = columnData.footer;
|
1133 | }
|
1134 | });
|
1135 | if (Object.keys(sectionRow_1).length) {
|
1136 | sectionRows.push(sectionRow_1);
|
1137 | }
|
1138 | }
|
1139 | sectionRows.forEach(function (rawRow, rowIndex) {
|
1140 | var row = new models_1.Row(rawRow, rowIndex, sectionName);
|
1141 | table[sectionName].push(row);
|
1142 | var colSpansAdded = 0;
|
1143 | var columnSpansLeft = 0;
|
1144 | for (var _i = 0, _a = table.columns; _i < _a.length; _i++) {
|
1145 | var column = _a[_i];
|
1146 | if (rowSpansLeftForColumn[column.dataKey] == null || rowSpansLeftForColumn[column.dataKey].left === 0) {
|
1147 | if (columnSpansLeft === 0) {
|
1148 | var rawCell = void 0;
|
1149 | if (Array.isArray(rawRow)) {
|
1150 | rawCell = rawRow[column.dataKey - colSpansAdded];
|
1151 | }
|
1152 | else {
|
1153 | rawCell = rawRow[column.dataKey];
|
1154 | }
|
1155 | var styles = cellStyles(sectionName, column.dataKey, rowIndex);
|
1156 | var cell = new models_1.Cell(rawCell, styles, sectionName);
|
1157 | row.cells[column.dataKey] = cell;
|
1158 | table.callCellHooks(table.cellHooks.didParseCell, cell, row, column);
|
1159 | columnSpansLeft = cell.colSpan - 1;
|
1160 | rowSpansLeftForColumn[column.dataKey] = { left: cell.rowSpan - 1, times: columnSpansLeft };
|
1161 | }
|
1162 | else {
|
1163 | columnSpansLeft--;
|
1164 | colSpansAdded++;
|
1165 | }
|
1166 | }
|
1167 | else {
|
1168 | rowSpansLeftForColumn[column.dataKey].left--;
|
1169 | columnSpansLeft = rowSpansLeftForColumn[column.dataKey].times;
|
1170 | }
|
1171 | }
|
1172 | });
|
1173 | };
|
1174 | for (var _i = 0, _a = ['head', 'body', 'foot']; _i < _a.length; _i++) {
|
1175 | var sectionName = _a[_i];
|
1176 | _loop_2(sectionName);
|
1177 | }
|
1178 | table.allRows().forEach(function (row) {
|
1179 | for (var _i = 0, _a = table.columns; _i < _a.length; _i++) {
|
1180 | var column = _a[_i];
|
1181 | var cell = row.cells[column.dataKey];
|
1182 |
|
1183 |
|
1184 | if (cell && cell.colSpan === 1) {
|
1185 | if (cell.wrappedWidth > column.wrappedWidth) {
|
1186 | column.wrappedWidth = cell.wrappedWidth;
|
1187 | }
|
1188 | if (cell.minWidth > column.minWidth) {
|
1189 | column.minWidth = cell.minWidth;
|
1190 | }
|
1191 | }
|
1192 | }
|
1193 | });
|
1194 | }
|
1195 | function getTableColumns(settings) {
|
1196 | if (settings.columns) {
|
1197 | return settings.columns.map(function (input, index) {
|
1198 | var key = input.dataKey || input.key || index;
|
1199 | var raw = input != null ? input : index;
|
1200 | return new models_1.Column(key, raw, index);
|
1201 | });
|
1202 | }
|
1203 | else {
|
1204 | var merged = __assign({}, settings.head[0], settings.body[0], settings.foot[0]);
|
1205 | delete merged._element;
|
1206 | var dataKeys = Object.keys(merged);
|
1207 | return dataKeys.map(function (key) { return new models_1.Column(key, key, key); });
|
1208 | }
|
1209 | }
|
1210 | function cellStyles(sectionName, dataKey, rowIndex) {
|
1211 | var table = state_1.default().table;
|
1212 | var theme = config_1.getTheme(table.settings.theme);
|
1213 | var otherStyles = [theme.table, theme[sectionName], table.styles.styles, table.styles[sectionName + "Styles"]];
|
1214 | var colStyles = sectionName === 'body' ? table.styles.columnStyles[dataKey] || {} : {};
|
1215 | var rowStyles = sectionName === 'body' && rowIndex % 2 === 0 ? polyfills_1.assign({}, theme.alternateRow, table.styles.alternateRowStyles) : {};
|
1216 | return polyfills_1.assign.apply(void 0, [config_1.defaultStyles()].concat(otherStyles.concat([rowStyles, colStyles])));
|
1217 | }
|
1218 |
|
1219 |
|
1220 | }),
|
1221 |
|
1222 | (function(module, exports, __webpack_require__) {
|
1223 |
|
1224 | "use strict";
|
1225 |
|
1226 | Object.defineProperty(exports, "__esModule", { value: true });
|
1227 | var config_1 = __webpack_require__(2);
|
1228 | var state_1 = __webpack_require__(0);
|
1229 | var HookData_1 = __webpack_require__(10);
|
1230 | var common_1 = __webpack_require__(1);
|
1231 | var assign = __webpack_require__(11);
|
1232 | var CellHooks = (function () {
|
1233 | function CellHooks() {
|
1234 | this.willParseCell = [];
|
1235 | this.didParseCell = [];
|
1236 | this.willDrawCell = [];
|
1237 | this.didDrawCell = [];
|
1238 | this.didDrawPage = [];
|
1239 | }
|
1240 | return CellHooks;
|
1241 | }());
|
1242 | var Table = (function () {
|
1243 | function Table() {
|
1244 | this.columns = [];
|
1245 | this.head = [];
|
1246 | this.body = [];
|
1247 | this.foot = [];
|
1248 | this.height = 0;
|
1249 | this.width = 0;
|
1250 | this.preferredWidth = 0;
|
1251 | this.wrappedWidth = 0;
|
1252 | this.minWidth = 0;
|
1253 | this.headHeight = 0;
|
1254 | this.footHeight = 0;
|
1255 | this.startPageNumber = 1;
|
1256 | this.pageNumber = 1;
|
1257 | this.styles = {
|
1258 | styles: {},
|
1259 | headStyles: {},
|
1260 | bodyStyles: {},
|
1261 | footStyles: {},
|
1262 | alternateRowStyles: {},
|
1263 | columnStyles: {},
|
1264 | };
|
1265 | this.cellHooks = new CellHooks();
|
1266 | }
|
1267 | Object.defineProperty(Table.prototype, "pageCount", {
|
1268 | get: function () {
|
1269 | return this.pageNumber;
|
1270 | },
|
1271 | enumerable: true,
|
1272 | configurable: true
|
1273 | });
|
1274 | Table.prototype.allRows = function () {
|
1275 | return this.head.concat(this.body).concat(this.foot);
|
1276 | };
|
1277 | Table.prototype.callCellHooks = function (handlers, cell, row, column) {
|
1278 | for (var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++) {
|
1279 | var handler = handlers_1[_i];
|
1280 | if (handler(new HookData_1.CellHookData(cell, row, column)) === false) {
|
1281 | return false;
|
1282 | }
|
1283 | }
|
1284 | return true;
|
1285 | };
|
1286 | Table.prototype.callEndPageHooks = function () {
|
1287 | common_1.applyUserStyles();
|
1288 | for (var _i = 0, _a = this.cellHooks.didDrawPage; _i < _a.length; _i++) {
|
1289 | var handler = _a[_i];
|
1290 | handler(new HookData_1.HookData());
|
1291 | }
|
1292 | };
|
1293 | Table.prototype.margin = function (side) {
|
1294 | return common_1.marginOrPadding(this.settings.margin, config_1.defaultConfig().margin)[side];
|
1295 | };
|
1296 | return Table;
|
1297 | }());
|
1298 | exports.Table = Table;
|
1299 | var Row = (function () {
|
1300 | function Row(raw, index, section) {
|
1301 | this.cells = {};
|
1302 | this.height = 0;
|
1303 | this.maxCellLineCount = 1;
|
1304 | this.maxCellHeight = 0;
|
1305 | this.pageNumber = 1;
|
1306 | this.spansMultiplePages = false;
|
1307 | this.raw = raw;
|
1308 | if (raw._element) {
|
1309 | this.raw = raw._element;
|
1310 | }
|
1311 | this.index = index;
|
1312 | this.section = section;
|
1313 | }
|
1314 | Object.defineProperty(Row.prototype, "pageCount", {
|
1315 | get: function () {
|
1316 | return this.pageNumber;
|
1317 | },
|
1318 | enumerable: true,
|
1319 | configurable: true
|
1320 | });
|
1321 | return Row;
|
1322 | }());
|
1323 | exports.Row = Row;
|
1324 | var Cell = (function () {
|
1325 | function Cell(raw, themeStyles, section) {
|
1326 | this.contentWidth = 0;
|
1327 | this.wrappedWidth = 0;
|
1328 | this.minWidth = 0;
|
1329 | this.textPos = {};
|
1330 | this.height = 0;
|
1331 | this.width = 0;
|
1332 | this.rowSpan = raw && raw.rowSpan || 1;
|
1333 | this.colSpan = raw && raw.colSpan || 1;
|
1334 | this.styles = assign(themeStyles, raw && raw.styles || {});
|
1335 | this.section = section;
|
1336 | var text = '';
|
1337 | var content = raw && typeof raw.content !== 'undefined' ? raw.content : raw;
|
1338 | content = content != undefined && content.dataKey != undefined ? content.title : content;
|
1339 | var fromHtml = typeof window === 'object' && window.HTMLElement && content instanceof window.HTMLElement;
|
1340 | this.raw = fromHtml ? content : raw;
|
1341 | if (content && fromHtml) {
|
1342 | text = (content.innerText || '').replace(/\s+/g, ' ').trim();
|
1343 | }
|
1344 | else {
|
1345 |
|
1346 | text = content != undefined ? '' + content : '';
|
1347 | }
|
1348 | var splitRegex = /\r\n|\r|\n/g;
|
1349 | this.text = text.split(splitRegex);
|
1350 | this.contentWidth = this.padding('horizontal') + common_1.getStringWidth(this.text, this.styles);
|
1351 | if (typeof this.styles.cellWidth === 'number') {
|
1352 | this.minWidth = this.styles.cellWidth;
|
1353 | this.wrappedWidth = this.styles.cellWidth;
|
1354 | }
|
1355 | else if (this.styles.cellWidth === 'wrap') {
|
1356 | this.minWidth = this.contentWidth;
|
1357 | this.wrappedWidth = this.contentWidth;
|
1358 | }
|
1359 | else {
|
1360 | var defaultMinWidth = 10 / state_1.default().scaleFactor();
|
1361 | this.minWidth = this.styles.minCellWidth || defaultMinWidth;
|
1362 | this.wrappedWidth = this.contentWidth;
|
1363 | if (this.minWidth > this.wrappedWidth) {
|
1364 | this.wrappedWidth = this.minWidth;
|
1365 | }
|
1366 | }
|
1367 | }
|
1368 | Cell.prototype.padding = function (name) {
|
1369 | var padding = common_1.marginOrPadding(this.styles.cellPadding, common_1.styles([]).cellPadding);
|
1370 | if (name === 'vertical') {
|
1371 | return padding.top + padding.bottom;
|
1372 | }
|
1373 | else if (name === 'horizontal') {
|
1374 | return padding.left + padding.right;
|
1375 | }
|
1376 | else {
|
1377 | return padding[name];
|
1378 | }
|
1379 | };
|
1380 | return Cell;
|
1381 | }());
|
1382 | exports.Cell = Cell;
|
1383 | var Column = (function () {
|
1384 | function Column(dataKey, raw, index) {
|
1385 | this.preferredWidth = 0;
|
1386 | this.minWidth = 0;
|
1387 | this.wrappedWidth = 0;
|
1388 | this.width = 0;
|
1389 | this.dataKey = dataKey;
|
1390 | this.raw = raw;
|
1391 | this.index = index;
|
1392 | }
|
1393 | return Column;
|
1394 | }());
|
1395 | exports.Column = Column;
|
1396 |
|
1397 |
|
1398 | }),
|
1399 |
|
1400 | (function(module, exports, __webpack_require__) {
|
1401 |
|
1402 | "use strict";
|
1403 |
|
1404 | var __extends = (this && this.__extends) || (function () {
|
1405 | var extendStatics = function (d, b) {
|
1406 | extendStatics = Object.setPrototypeOf ||
|
1407 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
1408 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
1409 | return extendStatics(d, b);
|
1410 | };
|
1411 | return function (d, b) {
|
1412 | extendStatics(d, b);
|
1413 | function __() { this.constructor = d; }
|
1414 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1415 | };
|
1416 | })();
|
1417 | Object.defineProperty(exports, "__esModule", { value: true });
|
1418 | var state_1 = __webpack_require__(0);
|
1419 | var HookData = (function () {
|
1420 | function HookData() {
|
1421 | var table = state_1.default().table;
|
1422 | this.table = table;
|
1423 | this.pageNumber = table.pageNumber;
|
1424 | this.settings = table.settings;
|
1425 | this.cursor = table.cursor;
|
1426 | this.doc = state_1.default().doc;
|
1427 | }
|
1428 | Object.defineProperty(HookData.prototype, "pageCount", {
|
1429 | get: function () {
|
1430 | return this.pageNumber;
|
1431 | },
|
1432 | enumerable: true,
|
1433 | configurable: true
|
1434 | });
|
1435 | return HookData;
|
1436 | }());
|
1437 | exports.HookData = HookData;
|
1438 | var CellHookData = (function (_super) {
|
1439 | __extends(CellHookData, _super);
|
1440 | function CellHookData(cell, row, column) {
|
1441 | var _this = _super.call(this) || this;
|
1442 | _this.cell = cell;
|
1443 | _this.row = row;
|
1444 | _this.column = column;
|
1445 | _this.section = row.section;
|
1446 | return _this;
|
1447 | }
|
1448 | return CellHookData;
|
1449 | }(HookData));
|
1450 | exports.CellHookData = CellHookData;
|
1451 |
|
1452 |
|
1453 | }),
|
1454 |
|
1455 | (function(module, exports, __webpack_require__) {
|
1456 |
|
1457 | "use strict";
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
1467 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
1468 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
1469 |
|
1470 | function toObject(val) {
|
1471 | if (val === null || val === undefined) {
|
1472 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
1473 | }
|
1474 |
|
1475 | return Object(val);
|
1476 | }
|
1477 |
|
1478 | function shouldUseNative() {
|
1479 | try {
|
1480 | if (!Object.assign) {
|
1481 | return false;
|
1482 | }
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 | var test1 = new String('abc');
|
1488 | test1[5] = 'de';
|
1489 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
1490 | return false;
|
1491 | }
|
1492 |
|
1493 |
|
1494 | var test2 = {};
|
1495 | for (var i = 0; i < 10; i++) {
|
1496 | test2['_' + String.fromCharCode(i)] = i;
|
1497 | }
|
1498 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
1499 | return test2[n];
|
1500 | });
|
1501 | if (order2.join('') !== '0123456789') {
|
1502 | return false;
|
1503 | }
|
1504 |
|
1505 |
|
1506 | var test3 = {};
|
1507 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
1508 | test3[letter] = letter;
|
1509 | });
|
1510 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
1511 | 'abcdefghijklmnopqrst') {
|
1512 | return false;
|
1513 | }
|
1514 |
|
1515 | return true;
|
1516 | } catch (err) {
|
1517 |
|
1518 | return false;
|
1519 | }
|
1520 | }
|
1521 |
|
1522 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
1523 | var from;
|
1524 | var to = toObject(target);
|
1525 | var symbols;
|
1526 |
|
1527 | for (var s = 1; s < arguments.length; s++) {
|
1528 | from = Object(arguments[s]);
|
1529 |
|
1530 | for (var key in from) {
|
1531 | if (hasOwnProperty.call(from, key)) {
|
1532 | to[key] = from[key];
|
1533 | }
|
1534 | }
|
1535 |
|
1536 | if (getOwnPropertySymbols) {
|
1537 | symbols = getOwnPropertySymbols(from);
|
1538 | for (var i = 0; i < symbols.length; i++) {
|
1539 | if (propIsEnumerable.call(from, symbols[i])) {
|
1540 | to[symbols[i]] = from[symbols[i]];
|
1541 | }
|
1542 | }
|
1543 | }
|
1544 | }
|
1545 |
|
1546 | return to;
|
1547 | };
|
1548 |
|
1549 |
|
1550 | }),
|
1551 |
|
1552 | (function(module, exports, __webpack_require__) {
|
1553 |
|
1554 | "use strict";
|
1555 |
|
1556 | Object.defineProperty(exports, "__esModule", { value: true });
|
1557 | var cssParser_1 = __webpack_require__(13);
|
1558 | var state_1 = __webpack_require__(0);
|
1559 | var polyfills_1 = __webpack_require__(3);
|
1560 | function parseHtml(input, includeHiddenHtml, useCss) {
|
1561 | if (includeHiddenHtml === void 0) { includeHiddenHtml = false; }
|
1562 | if (useCss === void 0) { useCss = false; }
|
1563 | var tableElement;
|
1564 | if (typeof input === 'string') {
|
1565 | tableElement = window.document.querySelector(input);
|
1566 | }
|
1567 | else {
|
1568 | tableElement = input;
|
1569 | }
|
1570 | if (!tableElement) {
|
1571 | console.error("Html table could not be found with input: ", input);
|
1572 | return;
|
1573 | }
|
1574 | var head = parseTableSection(window, tableElement.tHead, includeHiddenHtml, useCss);
|
1575 | var body = [];
|
1576 | for (var i = 0; i < tableElement.tBodies.length; i++) {
|
1577 | body = body.concat(parseTableSection(window, tableElement.tBodies[i], includeHiddenHtml, useCss));
|
1578 | }
|
1579 | var foot = parseTableSection(window, tableElement.tFoot, includeHiddenHtml, useCss);
|
1580 | return { head: head, body: body, foot: foot };
|
1581 | }
|
1582 | exports.parseHtml = parseHtml;
|
1583 | function parseTableSection(window, sectionElement, includeHidden, useCss) {
|
1584 | var results = [];
|
1585 | if (!sectionElement) {
|
1586 | return results;
|
1587 | }
|
1588 | for (var i = 0; i < sectionElement.rows.length; i++) {
|
1589 | var row = sectionElement.rows[i];
|
1590 | var resultRow = [];
|
1591 | var rowStyles = useCss ? cssParser_1.parseCss(row, state_1.default().scaleFactor(), ['cellPadding', 'lineWidth', 'lineColor']) : {};
|
1592 | for (var i_1 = 0; i_1 < row.cells.length; i_1++) {
|
1593 | var cell = row.cells[i_1];
|
1594 | var style = window.getComputedStyle(cell);
|
1595 | if (includeHidden || style.display !== 'none') {
|
1596 | var cellStyles = useCss ? cssParser_1.parseCss(cell, state_1.default().scaleFactor()) : {};
|
1597 | resultRow.push({
|
1598 | rowSpan: cell.rowSpan,
|
1599 | colSpan: cell.colSpan,
|
1600 | styles: useCss ? polyfills_1.assign(rowStyles, cellStyles) : null,
|
1601 | content: cell
|
1602 | });
|
1603 | }
|
1604 | }
|
1605 | if (resultRow.length > 0 && (includeHidden || rowStyles.display !== 'none')) {
|
1606 | resultRow._element = row;
|
1607 | results.push(resultRow);
|
1608 | }
|
1609 | }
|
1610 | return results;
|
1611 | }
|
1612 |
|
1613 |
|
1614 | }),
|
1615 |
|
1616 | (function(module, exports, __webpack_require__) {
|
1617 |
|
1618 | "use strict";
|
1619 |
|
1620 | Object.defineProperty(exports, "__esModule", { value: true });
|
1621 |
|
1622 |
|
1623 |
|
1624 | var common_1 = __webpack_require__(1);
|
1625 | function parseCss(element, scaleFactor, ignored) {
|
1626 | if (ignored === void 0) { ignored = []; }
|
1627 | var result = {};
|
1628 | var style = window.getComputedStyle(element);
|
1629 | function assign(name, value, accepted) {
|
1630 | if (accepted === void 0) { accepted = []; }
|
1631 | if ((accepted.length === 0 || accepted.indexOf(value) !== -1) && ignored.indexOf(name) === -1) {
|
1632 | if (value === 0 || value) {
|
1633 | result[name] = value;
|
1634 | }
|
1635 | }
|
1636 | }
|
1637 | var pxScaleFactor = 96 / 72;
|
1638 | assign('fillColor', parseColor(element, 'backgroundColor') || 255);
|
1639 | assign('lineColor', parseColor(element, 'borderColor'));
|
1640 | assign('fontStyle', parseFontStyle(style));
|
1641 | assign('textColor', parseColor(element, 'color'));
|
1642 | assign('halign', style.textAlign, ['left', 'right', 'center', 'justify']);
|
1643 | assign('valign', style.verticalAlign, ['middle', 'bottom', 'top']);
|
1644 | assign('fontSize', parseInt(style.fontSize || '') / pxScaleFactor);
|
1645 | assign('cellPadding', parsePadding(style.padding, style.fontSize, style.lineHeight, scaleFactor));
|
1646 | assign('lineWidth', parseInt(style.borderWidth || '') / pxScaleFactor / scaleFactor);
|
1647 | assign('font', (style.fontFamily || '').toLowerCase());
|
1648 | return result;
|
1649 | }
|
1650 | exports.parseCss = parseCss;
|
1651 | function parseFontStyle(style) {
|
1652 | var res = '';
|
1653 | if (style.fontWeight === 'bold' || style.fontWeight === 'bolder' || parseInt(style.fontWeight) >= 700) {
|
1654 | res += 'bold';
|
1655 | }
|
1656 | if (style.fontStyle === 'italic' || style.fontStyle === 'oblique') {
|
1657 | res += 'italic';
|
1658 | }
|
1659 | return res;
|
1660 | }
|
1661 | function parseColor(element, colorProp) {
|
1662 | var cssColor = realColor(element, colorProp);
|
1663 | if (!cssColor)
|
1664 | return null;
|
1665 | var rgba = cssColor.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);
|
1666 | if (!rgba || !Array.isArray(rgba)) {
|
1667 | return null;
|
1668 | }
|
1669 | var color = [parseInt(rgba[1]), parseInt(rgba[2]), parseInt(rgba[3])];
|
1670 | var alpha = parseInt(rgba[4]);
|
1671 | if (alpha === 0 || isNaN(color[0]) || isNaN(color[1]) || isNaN(color[2])) {
|
1672 | return null;
|
1673 | }
|
1674 | return color;
|
1675 | }
|
1676 | function realColor(elem, colorProp) {
|
1677 | if (!elem)
|
1678 | return null;
|
1679 | var bg = window.getComputedStyle(elem)[colorProp];
|
1680 | if (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent' || bg === 'initial' || bg === 'inherit') {
|
1681 | return realColor(elem.parentElement, colorProp);
|
1682 | }
|
1683 | else {
|
1684 | return bg;
|
1685 | }
|
1686 | }
|
1687 | function parsePadding(val, fontSize, lineHeight, scaleFactor) {
|
1688 | if (!val)
|
1689 | return null;
|
1690 | var pxScaleFactor = (96 / (72 / scaleFactor));
|
1691 | var linePadding = (parseInt(lineHeight) - parseInt(fontSize)) / scaleFactor / 2;
|
1692 | var padding = val.split(' ').map(function (n) {
|
1693 | return parseInt(n) / pxScaleFactor;
|
1694 | });
|
1695 | padding = common_1.marginOrPadding(padding, 0);
|
1696 | if (linePadding > padding.top) {
|
1697 | padding.top = linePadding;
|
1698 | }
|
1699 | if (linePadding > padding.bottom) {
|
1700 | padding.bottom = linePadding;
|
1701 | }
|
1702 | return padding;
|
1703 | }
|
1704 |
|
1705 |
|
1706 | }),
|
1707 |
|
1708 | (function(module, exports, __webpack_require__) {
|
1709 |
|
1710 | "use strict";
|
1711 |
|
1712 | Object.defineProperty(exports, "__esModule", { value: true });
|
1713 | var common_1 = __webpack_require__(1);
|
1714 | function default_1(allOptions) {
|
1715 | var _loop_1 = function (settings) {
|
1716 | if (settings && typeof settings !== 'object') {
|
1717 | console.error("The options parameter should be of type object, is: " + typeof settings);
|
1718 | }
|
1719 | if (typeof settings.extendWidth !== 'undefined') {
|
1720 | settings.tableWidth = settings.extendWidth ? 'auto' : 'wrap';
|
1721 | console.error("Use of deprecated option: extendWidth, use tableWidth instead.");
|
1722 | }
|
1723 | if (typeof settings.margins !== 'undefined') {
|
1724 | if (typeof settings.margin === 'undefined')
|
1725 | settings.margin = settings.margins;
|
1726 | console.error("Use of deprecated option: margins, use margin instead.");
|
1727 | }
|
1728 | if (!settings.didDrawPage && (settings.afterPageContent || settings.beforePageContent || settings.afterPageAdd)) {
|
1729 | console.error("The afterPageContent, beforePageContent and afterPageAdd hooks are deprecated. Use didDrawPage instead");
|
1730 | settings.didDrawPage = function (data) {
|
1731 | common_1.applyUserStyles();
|
1732 | if (settings.beforePageContent)
|
1733 | settings.beforePageContent(data);
|
1734 | common_1.applyUserStyles();
|
1735 | if (settings.afterPageContent)
|
1736 | settings.afterPageContent(data);
|
1737 | common_1.applyUserStyles();
|
1738 | if (settings.afterPageAdd && data.pageNumber > 1) {
|
1739 | data.afterPageAdd(data);
|
1740 | }
|
1741 | common_1.applyUserStyles();
|
1742 | };
|
1743 | }
|
1744 | ["createdHeaderCell", "drawHeaderRow", "drawRow", "drawHeaderCell"].forEach(function (name) {
|
1745 | if (settings[name]) {
|
1746 | console.error("The \"" + name + "\" hook has changed in version 3.0, check the changelog for how to migrate.");
|
1747 | }
|
1748 | });
|
1749 | [['showFoot', 'showFooter'], ['showHead', 'showHeader'], ['didDrawPage', 'addPageContent'], ['didParseCell', 'createdCell'], ['headStyles', 'headerStyles']].forEach(function (_a) {
|
1750 | var current = _a[0], deprecated = _a[1];
|
1751 | if (settings[deprecated]) {
|
1752 | console.error("Use of deprecated option " + deprecated + ". Use " + current + " instead");
|
1753 | settings[current] = settings[deprecated];
|
1754 | }
|
1755 | });
|
1756 | [['padding', 'cellPadding'], ['lineHeight', 'rowHeight'], 'fontSize', 'overflow'].forEach(function (o) {
|
1757 | var deprecatedOption = typeof o === 'string' ? o : o[0];
|
1758 | var style = typeof o === 'string' ? o : o[1];
|
1759 | if (typeof settings[deprecatedOption] !== 'undefined') {
|
1760 | if (typeof settings.styles[style] === 'undefined') {
|
1761 | settings.styles[style] = settings[deprecatedOption];
|
1762 | }
|
1763 | console.error("Use of deprecated option: " + deprecatedOption + ", use the style " + style + " instead.");
|
1764 | }
|
1765 | });
|
1766 | for (var _i = 0, _a = ['styles', 'bodyStyles', 'headStyles', 'footStyles']; _i < _a.length; _i++) {
|
1767 | var styleProp = _a[_i];
|
1768 | checkStyles(settings[styleProp] || {});
|
1769 | }
|
1770 | var columnStyles = settings['columnStyles'] || {};
|
1771 | for (var _b = 0, _c = Object.keys(columnStyles); _b < _c.length; _b++) {
|
1772 | var dataKey = _c[_b];
|
1773 | checkStyles(columnStyles[dataKey] || {});
|
1774 | }
|
1775 | };
|
1776 | for (var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++) {
|
1777 | var settings = allOptions_1[_i];
|
1778 | _loop_1(settings);
|
1779 | }
|
1780 | }
|
1781 | exports.default = default_1;
|
1782 | function checkStyles(styles) {
|
1783 | if (styles.rowHeight) {
|
1784 | console.error("Use of deprecated style rowHeight. It is renamed to minCellHeight.");
|
1785 | if (!styles.minCellHeight) {
|
1786 | styles.minCellHeight = styles.rowHeight;
|
1787 | }
|
1788 | }
|
1789 | else if (styles.columnWidth) {
|
1790 | console.error("Use of deprecated style columnWidth. It is renamed to cellWidth.");
|
1791 | if (!styles.cellWidth) {
|
1792 | styles.cellWidth = styles.columnWidth;
|
1793 | }
|
1794 | }
|
1795 | }
|
1796 |
|
1797 |
|
1798 | }),
|
1799 |
|
1800 | (function(module, exports, __webpack_require__) {
|
1801 |
|
1802 | var jsPDF = __webpack_require__(4);
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 | jsPDF.API.autoTableText = function (text, x, y, styles) {
|
1808 | styles = styles || {};
|
1809 | var FONT_ROW_RATIO = 1.15;
|
1810 | if (typeof x !== 'number' || typeof y !== 'number') {
|
1811 | console.error('The x and y parameters are required. Missing for text: ', text);
|
1812 | }
|
1813 | var k = this.internal.scaleFactor;
|
1814 | var fontSize = this.internal.getFontSize() / k;
|
1815 | var splitRegex = /\r\n|\r|\n/g;
|
1816 | var splitText = null;
|
1817 | var lineCount = 1;
|
1818 | if (styles.valign === 'middle' || styles.valign === 'bottom' || styles.halign === 'center' || styles.halign === 'right') {
|
1819 | splitText = typeof text === 'string' ? text.split(splitRegex) : text;
|
1820 | lineCount = splitText.length || 1;
|
1821 | }
|
1822 |
|
1823 | y += fontSize * (2 - FONT_ROW_RATIO);
|
1824 | if (styles.valign === 'middle')
|
1825 | y -= (lineCount / 2) * fontSize * FONT_ROW_RATIO;
|
1826 | else if (styles.valign === 'bottom')
|
1827 | y -= lineCount * fontSize * FONT_ROW_RATIO;
|
1828 | if (styles.halign === 'center' || styles.halign === 'right') {
|
1829 | var alignSize = fontSize;
|
1830 | if (styles.halign === 'center')
|
1831 | alignSize *= 0.5;
|
1832 | if (lineCount >= 1) {
|
1833 | for (var iLine = 0; iLine < splitText.length; iLine++) {
|
1834 | this.text(splitText[iLine], x - this.getStringUnitWidth(splitText[iLine]) * alignSize, y);
|
1835 | y += fontSize;
|
1836 | }
|
1837 | return this;
|
1838 | }
|
1839 | x -= this.getStringUnitWidth(text) * alignSize;
|
1840 | }
|
1841 | if (styles.halign === 'justify') {
|
1842 | this.text(text, x, y, { maxWidth: styles.maxWidth || 100, align: 'justify' });
|
1843 | }
|
1844 | else {
|
1845 | this.text(text, x, y);
|
1846 | }
|
1847 | return this;
|
1848 | };
|
1849 |
|
1850 |
|
1851 | })
|
1852 | ]);
|
1853 | }); |
\ | No newline at end of file |