<!DOCTYPE html>
<html>
<head>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script data-require="jquery@*" data-semver="3.1.1" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script data-require="angularjs@1.6.2" data-semver="1.6.2" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.js"></script>
<script data-require="chartjs@2.2.1" data-semver="2.2.1" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/angular.chartjs/1.1.1/angular-chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js"></script>
<script src="jspdf.plugin.autotable.js"></script>
<script src="smart-table.debug.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="myApp" id="top">
<div class="container" ng-controller="mainCtrl">
<header>
<h3>Dynamic Data Visualisation and Analytics: (Angularjs Smart Table + Chart JS + JSON)</h3>
</header>
<button onclick="generate()">Table pdf</button>
<button id="download1">Table Chart Pdf</button>
<button id="download2">Save Table Chart Pdf</button>
<div id="div1" style="width: 60%; float:left">-
<canvas id="canvas" class="chart chart-base" chart-type="type" chart-data="data"
chart-labels="labels" chart-colors="colors"></canvas>
<ul>
<li>
<button ng-click="toggle()" class="btn btn-primary pull-left">
Toggle
</button>
<button ng-click="line()" class="btn btn-success">
Line
</button>
<button ng-click="bar()" class="btn btn-success">
Bar
</button>
<button ng-click="radar()" class="btn btn-success">
Radar
</button>
<button ng-click="polarArea()" class="btn btn-success">
Polar
</button>
<button ng-click="pie()" class="btn btn-success">
Pie
</button>
<button ng-click="doughnut()" class="btn btn-success">
Doughnut
</button>
</li>
</ul>
</div>
<div class="container">
<div id="div2" style="width: 30%; float:left">-
<table id="demo" st-table="displayed" st-safe-src="collection" class="table table-striped">
<thead>
<tr>
<th st-sort="time">time</th>
<th st-sort="intvalue">intvalue</th>
</tr>
<tr>
<th colspan="5">
<input st-search placeholder="global search" class="input-sm form-control" type="search"/>
</th>
</tr>
<tr>
<th>
<input st-search="'time'" placeholder="search for time" class="input-sm form-control" type="search" />
</th>
<th>
<input st-search="'intvalue'" placeholder="search for intvalue" class="input-sm form-control" type="search" />
</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in displayed">
<td>{{row.time}}</td>
<td>{{row.intvalue}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" class="text-left" float:left>
<div st-template="pagination.html" st-pagination="" st-items-by-page="ctrl.itemsByPage"></div>
<!-- could be within a ng-repeat-->
<button type="button" ng-class="{'active':ctrl.itemsByPage==5}" ng-click="ctrl.itemsByPage=5"
class="btn btn-default">5</button>
<button type="button" ng-class="{'active':ctrl.itemsByPage==25}" ng-click="ctrl.itemsByPage=10"
class="btn btn-default">10</button>
<button type="button" ng-class="{'active':ctrl.itemsByPage==50}" ng-click="ctrl.itemsByPage=25"
class="btn btn-default">25</button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div ng-show="isLoading" class="loading-indicator"></div>
</body>
</html>
// Code goes here
var app = angular.module('myApp', ['smart-table', 'chart.js'])
app.config(function (ChartJsProvider) {
// Configure all charts
ChartJsProvider.setOptions({
colors: ['#97BBCD', '#DCDCDC', '#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360']
});
// Configure all doughnut charts
ChartJsProvider.setOptions('radar', {
cutoutPercentage: 60
});
ChartJsProvider.setOptions('bubble', {
tooltips: {enabled: false}
});
});
app.controller('mainCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.loading = false;
$scope.getData = function () {
$scope.loading = true;
// $http.get("http://localhost/smarttablechart/ignition.php")
$http.get("Ignition.json")
.then(function (response) {
$scope.zdata = response.data;
$scope.collection = response.data;
$scope.labels = [];
$scope.data = [];
$scope.datalength = $scope.zdata.length;
$scope.itemsByPage = 5;
$scope.loading = false;
});
}
$scope.getData();
$scope.$watch(function () {
$scope.zdata = $scope.displayed;
$scope.labels = [];
$scope.data = [];
$scope.zdata.forEach(function (zdata) {
$scope.labels.push(zdata.time);
$scope.data.push(zdata.intvalue);
});
});
$scope.type = 'doughnut';
$scope.toggle = function () {
$scope.type = $scope.type === 'polarArea' ? 'pie' : 'polarArea';
};
$scope.line = function () {
$scope.type = 'line';
$scope.colors = ['#97BBCD', '#DCDCDC', '#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360']
};
$scope.bar = function () {
$scope.type = 'bar';
};
$scope.radar = function () {
$scope.type = 'radar';
$scope.colors = ['#97BBCD', '#DCDCDC', '#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360']
};
$scope.polarArea = function () {
$scope.type = 'polarArea';
};
$scope.pie = function () {
$scope.type = 'pie';
};
$scope.doughnut = function () {
$scope.type = 'doughnut';
};
}]);
$(document).ready(function () {
var d_canvas = document.getElementById('canvas');
var context = d_canvas.getContext('2d');
$('#download1').click(function () {
html2canvas($("#canvas"), {
onrendered: function (canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'pt', 'a4');
doc.text("Dynamic -- Angularjs Smart Table + Chart JS + JSON:", 70, 40);
doc.addImage(imgData, 'PNG', 0, 60);
var tbl = $('#demo').clone();
tbl.find('tfoot').remove();
var res = doc.autoTableHtmlToJson(tbl.get(0));
doc.autoTable(res.columns, res.data, {
startY: 400,
styles: {
overflow: 'linebreak'
}
// showHeader: 'firstPage'
})
doc.output('dataurlnewwindow');
// doc.save('sample-file.pdf');
}
});
});
});
$(document).ready(function () {
var d_canvas = document.getElementById('canvas');
var context = d_canvas.getContext('2d');
$('#download2').click(function () {
html2canvas($("#canvas"), {
onrendered: function (canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'pt', 'a4');
doc.text("Dynamic -- Angularjs Smart Table + Chart JS + JSON:", 70, 40);
doc.addImage(imgData, 'PNG', 0, 60);
var tbl = $('#demo').clone();
tbl.find('tfoot').remove();
var res = doc.autoTableHtmlToJson(tbl.get(0));
doc.autoTable(res.columns, res.data, {
startY: 400,
styles: {
overflow: 'linebreak'
}
// showHeader: 'firstPage'
})
// doc.output('dataurlnewwindow');
doc.save('sample-file.pdf');
}
});
});
});
/* Styles go here */
/**
* @version 1.4.9
* @license MIT
*/
(function (ng, undefined){
'use strict';
ng.module('smart-table', []).run(['$templateCache', function ($templateCache) {
$templateCache.put('template/smart-table/pagination.html',
'<div class="pagination" ng-if="pages.length >= 2"><ul class="pagination">' +
'<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li>' +
'</ul></div>');
}]);
ng.module('smart-table')
.controller('stTableController', ['$scope', '$parse', '$filter', '$attrs', function StTableController($scope, $parse, $filter, $attrs) {
var propertyName = $attrs.stTable;
var displayGetter = $parse(propertyName);
var displaySetter = displayGetter.assign;
var safeGetter;
var orderBy = $filter('orderBy');
var filter = $filter('filter');
var safeCopy = copyRefs(displayGetter($scope));
var tableState = {
sort: {},
search: {},
pagination: {
start: 0
}
};
var pipeAfterSafeCopy = true;
var ctrl = this;
var lastSelected;
function copyRefs(src) {
return src ? [].concat(src) : [];
}
function updateSafeCopy() {
safeCopy = copyRefs(safeGetter($scope));
if (pipeAfterSafeCopy === true) {
ctrl.pipe();
}
}
if ($attrs.stSafeSrc) {
safeGetter = $parse($attrs.stSafeSrc);
$scope.$watch(function () {
var safeSrc = safeGetter($scope);
return safeSrc ? safeSrc.length : 0;
}, function (newValue, oldValue) {
if (newValue !== safeCopy.length) {
updateSafeCopy();
}
});
$scope.$watch(function () {
return safeGetter($scope);
}, function (newValue, oldValue) {
if (newValue !== oldValue) {
updateSafeCopy();
}
});
}
/**
* sort the rows
* @param {Function | String} predicate - function or string which will be used as predicate for the sorting
* @param [reverse] - if you want to reverse the order
*/
this.sortBy = function sortBy(predicate, reverse) {
tableState.sort.predicate = predicate;
tableState.sort.reverse = reverse === true;
if (ng.isFunction(predicate)) {
tableState.sort.functionName = predicate.name;
} else {
delete tableState.sort.functionName;
}
tableState.pagination.start = 0;
return this.pipe();
};
/**
* search matching rows
* @param {String} input - the input string
* @param {String} [predicate] - the property name against you want to check the match, otherwise it will search on all properties
*/
this.search = function search(input, predicate) {
var predicateObject = tableState.search.predicateObject || {};
var prop = predicate ? predicate : '$';
predicateObject[prop] = input;
// to avoid to filter out null value
if (!input) {
delete predicateObject[prop];
}
tableState.search.predicateObject = predicateObject;
tableState.pagination.start = 0;
return this.pipe();
};
/**
* this will chain the operations of sorting and filtering based on the current table state (sort options, filtering, ect)
*/
this.pipe = function pipe() {
var pagination = tableState.pagination;
var filtered = tableState.search.predicateObject ? filter(safeCopy, tableState.search.predicateObject) : safeCopy;
if (tableState.sort.predicate) {
filtered = orderBy(filtered, tableState.sort.predicate, tableState.sort.reverse);
}
if (pagination.number !== undefined) {
pagination.numberOfPages = filtered.length > 0 ? Math.ceil(filtered.length / pagination.number) : 1;
pagination.start = pagination.start >= filtered.length ? (pagination.numberOfPages - 1) * pagination.number : pagination.start;
filtered = filtered.slice(pagination.start, pagination.start + parseInt(pagination.number));
}
displaySetter($scope, filtered);
};
/**
* select a dataRow (it will add the attribute isSelected to the row object)
* @param {Object} row - the row to select
* @param {String} [mode] - "single" or "multiple" (multiple by default)
*/
this.select = function select(row, mode) {
var rows = safeCopy;
var index = rows.indexOf(row);
if (index !== -1) {
if (mode === 'single') {
row.isSelected = row.isSelected !== true;
if (lastSelected) {
lastSelected.isSelected = false;
}
lastSelected = row.isSelected === true ? row : undefined;
} else {
rows[index].isSelected = !rows[index].isSelected;
}
}
};
/**
* take a slice of the current sorted/filtered collection (pagination)
*
* @param {Number} start - start index of the slice
* @param {Number} number - the number of item in the slice
*/
this.slice = function splice(start, number) {
tableState.pagination.start = start;
tableState.pagination.number = number;
return this.pipe();
};
/**
* return the current state of the table
* @returns {{sort: {}, search: {}, pagination: {start: number}}}
*/
this.tableState = function getTableState() {
return tableState;
};
/**
* Use a different filter function than the angular FilterFilter
* @param filterName the name under which the custom filter is registered
*/
this.setFilterFunction = function setFilterFunction(filterName) {
filter = $filter(filterName);
};
/**
*User a different function than the angular orderBy
* @param sortFunctionName the name under which the custom order function is registered
*/
this.setSortFunction = function setSortFunction(sortFunctionName) {
orderBy = $filter(sortFunctionName);
};
/**
* Usually when the safe copy is updated the pipe function is called.
* Calling this method will prevent it, which is something required when using a custom pipe function
*/
this.preventPipeOnWatch = function preventPipe() {
pipeAfterSafeCopy = false;
};
}])
.directive('stTable', function () {
return {
restrict: 'A',
controller: 'stTableController',
link: function (scope, element, attr, ctrl) {
if (attr.stSetFilter) {
ctrl.setFilterFunction(attr.stSetFilter);
}
if (attr.stSetSort) {
ctrl.setSortFunction(attr.stSetSort);
}
}
};
});
ng.module('smart-table')
.directive('stSearch', ['$timeout', function ($timeout) {
return {
require: '^stTable',
scope: {
predicate: '=?stSearch'
},
link: function (scope, element, attr, ctrl) {
var tableCtrl = ctrl;
var promise = null;
var throttle = attr.stDelay || 400;
scope.$watch('predicate', function (newValue, oldValue) {
if (newValue !== oldValue) {
ctrl.tableState().search = {};
tableCtrl.search(element[0].value || '', newValue);
}
});
//table state -> view
scope.$watch(function () {
return ctrl.tableState().search;
}, function (newValue, oldValue) {
var predicateExpression = scope.predicate || '$';
if (newValue.predicateObject && newValue.predicateObject[predicateExpression] !== element[0].value) {
element[0].value = newValue.predicateObject[predicateExpression] || '';
}
}, true);
// view -> table state
element.bind('input', function (evt) {
evt = evt.originalEvent || evt;
if (promise !== null) {
$timeout.cancel(promise);
}
promise = $timeout(function () {
tableCtrl.search(evt.target.value, scope.predicate || '');
promise = null;
}, throttle);
});
}
};
}]);
ng.module('smart-table')
.directive('stSelectRow', function () {
return {
restrict: 'A',
require: '^stTable',
scope: {
row: '=stSelectRow'
},
link: function (scope, element, attr, ctrl) {
var mode = attr.stSelectMode || 'single';
element.bind('click', function () {
scope.$apply(function () {
ctrl.select(scope.row, mode);
});
});
scope.$watch('row.isSelected', function (newValue) {
if (newValue === true) {
element.addClass('st-selected');
} else {
element.removeClass('st-selected');
}
});
}
};
});
ng.module('smart-table')
.directive('stSort', ['$parse', function ($parse) {
return {
restrict: 'A',
require: '^stTable',
link: function (scope, element, attr, ctrl) {
var predicate = attr.stSort;
var getter = $parse(predicate);
var index = 0;
var classAscent = attr.stClassAscent || 'st-sort-ascent';
var classDescent = attr.stClassDescent || 'st-sort-descent';
var stateClasses = [classAscent, classDescent];
var sortDefault;
if (attr.stSortDefault) {
sortDefault = scope.$eval(attr.stSortDefault) !== undefined ? scope.$eval(attr.stSortDefault) : attr.stSortDefault;
}
//view --> table state
function sort() {
index++;
predicate = ng.isFunction(getter(scope)) ? getter(scope) : attr.stSort;
if (index % 3 === 0 && attr.stSkipNatural === undefined) {
//manual reset
index = 0;
ctrl.tableState().sort = {};
ctrl.tableState().pagination.start = 0;
ctrl.pipe();
} else {
ctrl.sortBy(predicate, index % 2 === 0);
}
}
element.bind('click', function sortClick() {
if (predicate) {
scope.$apply(sort);
}
});
if (sortDefault) {
index = attr.stSortDefault === 'reverse' ? 1 : 0;
sort();
}
//table state --> view
scope.$watch(function () {
return ctrl.tableState().sort;
}, function (newValue) {
if (newValue.predicate !== predicate) {
index = 0;
element
.removeClass(classAscent)
.removeClass(classDescent);
} else {
index = newValue.reverse === true ? 2 : 1;
element
.removeClass(stateClasses[index % 2])
.addClass(stateClasses[index - 1]);
}
}, true);
}
};
}]);
ng.module('smart-table')
.directive('stPagination', function () {
return {
restrict: 'EA',
require: '^stTable',
scope: {
stItemsByPage: '=?',
stDisplayedPages: '=?'
},
templateUrl: function (element, attrs) {
if (attrs.stTemplate) {
return attrs.stTemplate;
}
return 'template/smart-table/pagination.html';
},
link: function (scope, element, attrs, ctrl) {
scope.stItemsByPage = scope.stItemsByPage ? +(scope.stItemsByPage) : 5;
scope.stDisplayedPages = scope.stDisplayedPages ? +(scope.stDisplayedPages) : 5;
scope.currentPage = 1;
scope.pages = [];
function redraw() {
var paginationState = ctrl.tableState().pagination;
var start = 1;
var end;
var i;
scope.currentPage = Math.floor(paginationState.start / paginationState.number) + 1;
start = Math.max(start, scope.currentPage - Math.abs(Math.floor(scope.stDisplayedPages / 2)));
end = start + scope.stDisplayedPages;
if (end > paginationState.numberOfPages) {
end = paginationState.numberOfPages + 1;
start = Math.max(1, end - scope.stDisplayedPages);
}
scope.pages = [];
scope.numPages = paginationState.numberOfPages;
for (i = start; i < end; i++) {
scope.pages.push(i);
}
}
//table state --> view
scope.$watch(function () {
return ctrl.tableState().pagination;
}, redraw, true);
//scope --> table state (--> view)
scope.$watch('stItemsByPage', function () {
scope.selectPage(1);
});
scope.$watch('stDisplayedPages', redraw);
//view -> table state
scope.selectPage = function (page) {
if (page > 0 && page <= scope.numPages) {
ctrl.slice((page - 1) * scope.stItemsByPage, scope.stItemsByPage);
}
};
//select the first page
ctrl.slice(0, scope.stItemsByPage);
}
};
});
ng.module('smart-table')
.directive('stPipe', function () {
return {
require: 'stTable',
scope: {
stPipe: '='
},
link: {
pre: function (scope, element, attrs, ctrl) {
if (ng.isFunction(scope.stPipe)) {
ctrl.preventPipeOnWatch();
ctrl.pipe = function () {
return scope.stPipe(ctrl.tableState(), ctrl);
}
}
}
}
};
});
})(angular);
/*!
* jsPDF AutoTable plugin v2.3.0
* Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*
* */if (typeof window === 'object') window.jspdfAutoTableVersion = '2.3.0';/*
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("jspdf"));
else if(typeof define === 'function' && define.amd)
define(["jspdf"], factory);
else {
var a = typeof exports === 'object' ? factory(require("jspdf")) : factory(root["jsPDF"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, function(__WEBPACK_EXTERNAL_MODULE_18__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 35);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
/**
* Ratio between font size and font height. The number comes from jspdf's source code
*/
exports.FONT_ROW_RATIO = 1.15;
var models_1 = __webpack_require__(15);
var table = null;
var assign = __webpack_require__(12);
var entries = __webpack_require__(33);
/**
* Styles for the themes (overriding the default styles)
*/
exports.getTheme = function (name) {
var themes = {
'striped': {
table: { fillColor: 255, textColor: 80, fontStyle: 'normal' },
header: { textColor: 255, fillColor: [41, 128, 185], fontStyle: 'bold' },
body: {},
alternateRow: { fillColor: 245 }
},
'grid': {
table: { fillColor: 255, textColor: 80, fontStyle: 'normal', lineWidth: 0.1 },
header: { textColor: 255, fillColor: [26, 188, 156], fontStyle: 'bold', lineWidth: 0 },
body: {},
alternateRow: {}
},
'plain': {
header: { fontStyle: 'bold' }
}
};
return themes[name];
};
function getDefaults() {
var scaleFactor = Config.scaleFactor();
return {
// Styling
theme: 'striped',
styles: {},
headerStyles: {},
bodyStyles: {},
alternateRowStyles: {},
columnStyles: {},
// Properties
startY: false,
margin: 40 / scaleFactor,
pageBreak: 'auto',
tableWidth: 'auto',
showHeader: 'everyPage',
tableLineWidth: 0,
tableLineColor: 200,
// Hooks
createdHeaderCell: function (cell, data) { },
createdCell: function (cell, data) { },
drawHeaderRow: function (row, data) { },
drawRow: function (row, data) { },
drawHeaderCell: function (cell, data) { },
drawCell: function (cell, data) { },
addPageContent: function (data) { }
};
}
exports.getDefaults = getDefaults;
// Base style for all themes
function defaultStyles() {
var scaleFactor = Config.scaleFactor();
return {
font: "helvetica",
fontStyle: 'normal',
overflow: 'ellipsize',
fillColor: false,
textColor: 20,
halign: 'left',
valign: 'top',
fontSize: 10,
cellPadding: 5 / scaleFactor,
lineColor: 200,
lineWidth: 0 / scaleFactor,
columnWidth: 'auto'
};
}
var Config = (function () {
function Config() {
}
Config.pageSize = function () {
return table.doc.internal.pageSize;
};
Config.applyUserStyles = function () {
Config.applyStyles(table.userStyles);
};
Config.createTable = function (doc) {
table = new models_1.Table(doc);
return table;
};
Config.tableInstance = function () {
return table;
};
Config.scaleFactor = function () {
return table.doc.internal.scaleFactor;
};
Config.hooksData = function (additionalData) {
if (additionalData === void 0) { additionalData = {}; }
return assign({
pageCount: table.pageCount,
settings: table.settings,
table: table,
doc: table.doc,
cursor: table.cursor
}, additionalData || {});
};
Config.initSettings = function (table, allOptions) {
var _loop_1 = function (styleProp) {
var styles = allOptions.map(function (opts) { return opts[styleProp] || {}; });
table.styles[styleProp] = assign.apply(void 0, [{}].concat(styles));
};
// Merge styles one level deeper
for (var _i = 0, _a = Object.keys(table.styles); _i < _a.length; _i++) {
var styleProp = _a[_i];
_loop_1(styleProp);
}
// Append event handlers instead of replacing them
for (var _b = 0, _c = entries(table.hooks); _b < _c.length; _b++) {
var _d = _c[_b], hookName = _d[0], list = _d[1];
for (var _e = 0, allOptions_1 = allOptions; _e < allOptions_1.length; _e++) {
var opts = allOptions_1[_e];
if (opts && opts[hookName]) {
list.push(opts[hookName]);
}
}
}
// Merge all other options one level
table.settings = assign.apply(void 0, [getDefaults()].concat(allOptions));
};
// This is messy, only keep array and number format the next major version
Config.marginOrPadding = function (value, defaultValue) {
var newValue = {};
if (Array.isArray(value)) {
if (value.length >= 4) {
newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[3] };
}
else if (value.length === 3) {
newValue = { 'top': value[0], 'right': value[1], 'bottom': value[2], 'left': value[1] };
}
else if (value.length === 2) {
newValue = { 'top': value[0], 'right': value[1], 'bottom': value[0], 'left': value[1] };
}
else if (value.length === 1) {
value = value[0];
}
else {
value = defaultValue;
}
}
else if (typeof value === 'object') {
if (value['vertical']) {
value['top'] = value['vertical'];
value['bottom'] = value['vertical'];
}
else if (value['horizontal']) {
value['right'] = value['horizontal'];
value['left'] = value['horizontal'];
}
for (var _i = 0, _a = ['top', 'right', 'bottom', 'left']; _i < _a.length; _i++) {
var side = _a[_i];
newValue[side] = value[side] || value[side] === 0 ? value[side] : defaultValue;
}
}
if (typeof value === 'number') {
newValue = { 'top': value, 'right': value, 'bottom': value, 'left': value };
}
return newValue;
};
Config.styles = function (styles) {
styles = Array.isArray(styles) ? styles : [styles];
return assign.apply(void 0, [defaultStyles()].concat(styles));
};
Config.applyStyles = function (styles) {
var doc = table.doc;
var styleModifiers = {
fillColor: doc.setFillColor,
textColor: doc.setTextColor,
fontStyle: doc.setFontStyle,
lineColor: doc.setDrawColor,
lineWidth: doc.setLineWidth,
font: doc.setFont,
fontSize: doc.setFontSize
};
Object.keys(styleModifiers).forEach(function (name) {
var style = styles[name];
var modifier = styleModifiers[name];
if (typeof style !== 'undefined') {
if (Array.isArray(style)) {
modifier.apply(this, style);
}
else {
modifier(style);
}
}
});
};
return Config;
}());
exports.Config = Config;
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var config_1 = __webpack_require__(0);
var painter_1 = __webpack_require__(4);
function getStringWidth(text, styles) {
var k = config_1.Config.scaleFactor();
var fontSize = styles.fontSize / k;
config_1.Config.applyStyles(styles);
text = Array.isArray(text) ? text : [text];
var maxWidth = 0;
text.forEach(function (line) {
var width = config_1.Config.tableInstance().doc.getStringUnitWidth(line);
if (width > maxWidth) {
maxWidth = width;
}
});
var precision = 10000 * k;
maxWidth = Math.floor(maxWidth * precision) / precision;
return maxWidth * fontSize;
}
exports.getStringWidth = getStringWidth;
/**
* Ellipsize the text to fit in the width
*/
function ellipsize(text, width, styles, ellipsizeStr) {
if (ellipsizeStr === void 0) { ellipsizeStr = '...'; }
if (Array.isArray(text)) {
var value_1 = [];
text.forEach(function (str, i) {
value_1[i] = ellipsize(str, width, styles, ellipsizeStr);
});
return value_1;
}
var precision = 10000 * config_1.Config.scaleFactor();
width = Math.ceil(width * precision) / precision;
if (width >= getStringWidth(text, styles)) {
return text;
}
while (width < getStringWidth(text + ellipsizeStr, styles)) {
if (text.length <= 1) {
break;
}
text = text.substring(0, text.length - 1);
}
return text.trim() + ellipsizeStr;
}
exports.ellipsize = ellipsize;
function addTableBorder() {
var table = config_1.Config.tableInstance();
var styles = { lineWidth: table.settings.tableLineWidth, lineColor: table.settings.tableLineColor };
config_1.Config.applyStyles(styles);
var fs = getFillStyle(styles);
if (fs) {
table.doc.rect(table.pageStartX, table.pageStartY, table.width, table.cursor.y - table.pageStartY, fs);
}
}
exports.addTableBorder = addTableBorder;
function addPage() {
var table = config_1.Config.tableInstance();
table.finalY = table.cursor.y;
// Add user content just before adding new page ensure it will
// be drawn above other things on the page
addContentHooks();
addTableBorder();
table.doc.addPage();
table.pageCount++;
table.cursor = { x: table.margin('left'), y: table.margin('top') };
table.pageStartX = table.cursor.x;
table.pageStartY = table.cursor.y;
if (table.settings.showHeader === true || table.settings.showHeader === 'everyPage') {
painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
}
}
exports.addPage = addPage;
function addContentHooks() {
for (var _i = 0, _a = config_1.Config.tableInstance().hooks.addPageContent; _i < _a.length; _i++) {
var hook = _a[_i];
config_1.Config.applyUserStyles();
hook(config_1.Config.hooksData());
}
config_1.Config.applyUserStyles();
}
exports.addContentHooks = addContentHooks;
function getFillStyle(styles) {
var drawLine = styles.lineWidth > 0;
var drawBackground = styles.fillColor || styles.fillColor === 0;
if (drawLine && drawBackground) {
return 'DF'; // Fill then stroke
}
else if (drawLine) {
return 'S'; // Only stroke (transparent background)
}
else if (drawBackground) {
return 'F'; // Only fill, no stroke
}
else {
return false;
}
}
exports.getFillStyle = getFillStyle;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
var implementation = __webpack_require__(26);
module.exports = Function.prototype.bind || implementation;
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var fnToStr = Function.prototype.toString;
var constructorRegex = /^\s*class /;
var isES6ClassFn = function isES6ClassFn(value) {
try {
var fnStr = fnToStr.call(value);
var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
return constructorRegex.test(spaceStripped);
} catch (e) {
return false; // not a function
}
};
var tryFunctionObject = function tryFunctionObject(value) {
try {
if (isES6ClassFn(value)) { return false; }
fnToStr.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var fnClass = '[object Function]';
var genClass = '[object GeneratorFunction]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isCallable(value) {
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass;
};
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var config_1 = __webpack_require__(0);
var common_1 = __webpack_require__(1);
function printFullRow(row, drawRowHooks, drawCellHooks) {
var remainingRowHeight = 0;
var remainingTexts = {};
var table = config_1.Config.tableInstance();
if (!canFitOnPage(row.height)) {
if (row.maxLineCount <= 1) {
common_1.addPage();
}
else {
// Modify the row to fit the current page and calculate text and height of partial row
row.spansMultiplePages = true;
var pageHeight = table.doc.internal.pageSize.height;
var maxCellHeight = 0;
for (var j = 0; j < table.columns.length; j++) {
var col = table.columns[j];
var cell = row.cells[col.dataKey];
var fontHeight = cell.styles.fontSize / config_1.Config.scaleFactor() * config_1.FONT_ROW_RATIO;
var vPadding = cell.padding('vertical');
var remainingPageSpace = pageHeight - table.cursor.y - table.margin('bottom');
var remainingLineCount = Math.floor((remainingPageSpace - vPadding) / fontHeight);
if (Array.isArray(cell.text) && cell.text.length > remainingLineCount) {
var remainingLines = cell.text.splice(remainingLineCount, cell.text.length);
remainingTexts[col.dataKey] = remainingLines;
var cellHeight = cell.text.length * fontHeight + vPadding;
if (cellHeight > maxCellHeight) {
maxCellHeight = cellHeight;
}
var rCellHeight = remainingLines.length * fontHeight + vPadding;
if (rCellHeight > remainingRowHeight) {
remainingRowHeight = rCellHeight;
}
}
}
// Reset row height since text are now removed
row.height = maxCellHeight;
}
}
printRow(row, drawRowHooks, drawCellHooks);
// Parts of the row is now printed. Time for adding a new page, prune
// the text and start over
if (Object.keys(remainingTexts).length > 0) {
for (var j = 0; j < table.columns.length; j++) {
var col = table.columns[j];
var cell = row.cells[col.dataKey];
cell.text = remainingTexts[col.dataKey] || '';
}
common_1.addPage();
row.pageCount++;
row.height = remainingRowHeight;
printFullRow(row, drawRowHooks, drawCellHooks);
}
}
exports.printFullRow = printFullRow;
function printRow(row, drawRowHooks, drawCellHooks) {
var table = config_1.Config.tableInstance();
row.y = table.cursor.y;
for (var _i = 0, drawRowHooks_1 = drawRowHooks; _i < drawRowHooks_1.length; _i++) {
var hook = drawRowHooks_1[_i];
if (hook(row, config_1.Config.hooksData({ row: row, addPage: common_1.addPage })) === false) {
return;
}
}
table.cursor.x = table.margin('left');
for (var i = 0; i < table.columns.length; i++) {
var column = table.columns[i];
var cell = row.cells[column.dataKey];
if (!cell) {
continue;
}
config_1.Config.applyStyles(cell.styles);
cell.x = table.cursor.x;
cell.y = table.cursor.y;
cell.height = row.height;
cell.width = column.width;
if (cell.styles.valign === 'top') {
cell.textPos.y = table.cursor.y + cell.padding('top');
}
else if (cell.styles.valign === 'bottom') {
cell.textPos.y = table.cursor.y + row.height - cell.padding('bottom');
}
else {
cell.textPos.y = table.cursor.y + row.height / 2;
}
if (cell.styles.halign === 'right') {
cell.textPos.x = cell.x + cell.width - cell.padding('right');
}
else if (cell.styles.halign === 'center') {
cell.textPos.x = cell.x + cell.width / 2;
}
else {
cell.textPos.x = cell.x + cell.padding('left');
}
var shouldDrawCell = true;
var data = config_1.Config.hooksData({ column: column, row: row, addPage: common_1.addPage });
for (var _a = 0, drawCellHooks_1 = drawCellHooks; _a < drawCellHooks_1.length; _a++) {
var hook = drawCellHooks_1[_a];
if (hook(cell, data) === false) {
shouldDrawCell = false;
}
}
if (shouldDrawCell) {
var fillStyle = common_1.getFillStyle(cell.styles);
if (fillStyle) {
table.doc.rect(cell.x, cell.y, cell.width, cell.height, fillStyle);
}
table.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, {
halign: cell.styles.halign,
valign: cell.styles.valign
});
}
table.cursor.x += cell.width;
}
table.cursor.y += row.height;
}
exports.printRow = printRow;
function canFitOnPage(rowHeight) {
var table = config_1.Config.tableInstance();
var pos = rowHeight + table.cursor.y + table.margin('bottom');
return pos < config_1.Config.pageSize().height;
}
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var keys = __webpack_require__(31);
var foreach = __webpack_require__(25);
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var toStr = Object.prototype.toString;
var isFunction = function (fn) {
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
};
var arePropertyDescriptorsSupported = function () {
var obj = {};
try {
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
/* eslint-disable no-unused-vars, no-restricted-syntax */
for (var _ in obj) { return false; }
/* eslint-enable no-unused-vars, no-restricted-syntax */
return obj.x === obj;
} catch (e) { /* this is IE 8. */
return false;
}
};
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
var defineProperty = function (object, name, value, predicate) {
if (name in object && (!isFunction(predicate) || !predicate())) {
return;
}
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
value: value,
writable: true
});
} else {
object[name] = value;
}
};
var defineProperties = function (object, map) {
var predicates = arguments.length > 2 ? arguments[2] : {};
var props = keys(map);
if (hasSymbols) {
props = props.concat(Object.getOwnPropertySymbols(map));
}
foreach(props, function (name) {
defineProperty(object, name, map[name], predicates[name]);
});
};
defineProperties.supportsDescriptors = !!supportsDescriptors;
module.exports = defineProperties;
/***/ },
/* 6 */
/***/ function(module, exports) {
var has = Object.prototype.hasOwnProperty;
module.exports = Object.assign || function assign(target, source) {
for (var key in source) {
if (has.call(source, key)) {
target[key] = source[key];
}
}
return target;
};
/***/ },
/* 7 */
/***/ function(module, exports) {
var $isNaN = Number.isNaN || function (a) { return a !== a; };
module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
/***/ },
/* 8 */
/***/ function(module, exports) {
module.exports = Number.isNaN || function isNaN(a) {
return a !== a;
};
/***/ },
/* 9 */
/***/ function(module, exports) {
module.exports = function mod(number, modulo) {
var remain = number % modulo;
return Math.floor(remain >= 0 ? remain : remain + modulo);
};
/***/ },
/* 10 */
/***/ function(module, exports) {
module.exports = function sign(number) {
return number >= 0 ? 1 : -1;
};
/***/ },
/* 11 */
/***/ function(module, exports) {
module.exports = function isPrimitive(value) {
return value === null || (typeof value !== 'function' && typeof value !== 'object');
};
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* eslint-disable no-unused-vars */
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (e) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (Object.getOwnPropertySymbols) {
symbols = Object.getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var ES = __webpack_require__(21);
var has = __webpack_require__(27);
var bind = __webpack_require__(2);
var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
module.exports = function entries(O) {
var obj = ES.RequireObjectCoercible(O);
var entrys = [];
for (var key in obj) {
if (has(obj, key) && isEnumerable(obj, key)) {
entrys.push([key, obj[key]]);
}
}
return entrys;
};
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var implementation = __webpack_require__(13);
module.exports = function getPolyfill() {
return typeof Object.entries === 'function' ? Object.entries : implementation;
};
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var config_1 = __webpack_require__(0);
exports.table = {};
var Table = (function () {
function Table(doc) {
this.height = 0;
this.width = 0;
this.contentWidth = 0;
this.preferredWidth = 0;
this.rows = [];
this.columns = [];
this.headerRow = null;
this.pageCount = 1;
this.hooks = {
createdHeaderCell: [],
createdCell: [],
drawHeaderRow: [],
drawRow: [],
drawHeaderCell: [],
drawCell: [],
addPageContent: []
};
this.styles = {
styles: {},
headerStyles: {},
bodyStyles: {},
alternateRowStyles: {},
columnStyles: {}
};
this.doc = doc;
this.userStyles = {
textColor: 30,
fontSize: doc.internal.getFontSize(),
fontStyle: doc.internal.getFont().fontStyle
};
}
Table.prototype.margin = function (side) {
return config_1.Config.marginOrPadding(this.settings.margin, config_1.getDefaults().margin)[side];
};
return Table;
}());
exports.Table = Table;
var Row = (function () {
function Row(raw, index) {
this.cells = {};
this.spansMultiplePages = false;
this.pageCount = 1;
this.height = 0;
this.y = 0;
this.maxLineCount = 1;
this.raw = raw;
this.index = index;
}
return Row;
}());
exports.Row = Row;
var Cell = (function () {
function Cell(raw) {
this.styles = {};
this.text = '';
this.contentWidth = 0;
this.textPos = {};
this.height = 0;
this.width = 0;
this.x = 0;
this.y = 0;
this.raw = raw;
}
Cell.prototype.padding = function (name) {
var padding = config_1.Config.marginOrPadding(this.styles.cellPadding, config_1.Config.styles([]).cellPadding);
if (name === 'vertical') {
return padding.top + padding.bottom;
}
else if (name === 'horizontal') {
return padding.left + padding.right;
}
else {
return padding[name];
}
};
return Cell;
}());
exports.Cell = Cell;
var Column = (function () {
function Column(dataKey, index) {
this.options = {};
this.contentWidth = 0;
this.preferredWidth = 0;
this.widthStyle = 'auto';
this.width = 0;
this.x = 0;
this.dataKey = dataKey;
this.index = index;
}
return Column;
}());
exports.Column = Column;
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var config_1 = __webpack_require__(0);
var common_1 = __webpack_require__(1);
/**
* Calculate the column widths
*/
function calculateWidths(doc, pageWidth) {
var table = config_1.Config.tableInstance();
// Column and table content width
var fixedWidth = 0;
var autoWidth = 0;
var dynamicColumns = [];
table.columns.forEach(function (column) {
column.contentWidth = 0;
table.rows.concat(table.headerRow).forEach(function (row) {
var cell = row.cells[column.dataKey];
cell.contentWidth = cell.padding('horizontal') + common_1.getStringWidth(cell.text, cell.styles);
if (cell.contentWidth > column.contentWidth) {
column.contentWidth = cell.contentWidth;
}
});
table.contentWidth += column.contentWidth;
if (typeof column.widthStyle === 'number') {
column.preferredWidth = column.widthStyle;
fixedWidth += column.preferredWidth;
column.width = column.preferredWidth;
}
else if (column.widthStyle === 'wrap') {
column.preferredWidth = column.contentWidth;
fixedWidth += column.preferredWidth;
column.width = column.preferredWidth;
}
else {
column.preferredWidth = column.contentWidth;
autoWidth += column.contentWidth;
dynamicColumns.push(column);
}
table.preferredWidth += column.preferredWidth;
});
if (typeof table.settings.tableWidth === 'number') {
table.width = table.settings.tableWidth;
}
else if (table.settings.tableWidth === 'wrap') {
table.width = table.preferredWidth;
}
else {
table.width = pageWidth - table.margin('left') - table.margin('right');
}
distributeWidth(dynamicColumns, fixedWidth, autoWidth, 0);
// Row height, table height and text overflow
var all = table.rows.concat(table.headerRow);
all.forEach(function (row) {
table.columns.forEach(function (col) {
var cell = row.cells[col.dataKey];
config_1.Config.applyStyles(cell.styles);
var textSpace = col.width - cell.padding('horizontal');
if (cell.styles.overflow === 'linebreak') {
// Add one pt to textSpace to fix rounding error
try {
cell.text = doc.splitTextToSize(cell.text, textSpace + 1, { fontSize: cell.styles.fontSize });
}
catch (e) {
if (e instanceof TypeError && Array.isArray(cell.text)) {
cell.text = doc.splitTextToSize(cell.text.join(' '), textSpace + 1, { fontSize: cell.styles.fontSize });
}
else {
throw e;
}
}
}
else if (cell.styles.overflow === 'ellipsize') {
cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles);
}
else if (cell.styles.overflow === 'visible') {
}
else if (cell.styles.overflow === 'hidden') {
cell.text = common_1.ellipsize(cell.text, textSpace, cell.styles, '');
}
else if (typeof cell.styles.overflow === 'function') {
cell.text = cell.styles.overflow(cell.text, textSpace);
}
else {
console.error("Unrecognized overflow type: " + cell.styles.overflow);
}
var k = config_1.Config.scaleFactor();
var lineCount = Array.isArray(cell.text) ? cell.text.length : 1;
var fontHeight = cell.styles.fontSize / k * config_1.FONT_ROW_RATIO;
cell.contentHeight = lineCount * fontHeight + cell.padding('vertical');
if (cell.contentHeight > row.height) {
row.height = cell.contentHeight;
row.maxLineCount = lineCount;
}
});
table.height += row.height;
});
}
exports.calculateWidths = calculateWidths;
function distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth) {
var table = config_1.Config.tableInstance();
var extraWidth = table.width - staticWidth - dynamicColumnsContentWidth;
for (var i = 0; i < dynamicColumns.length; i++) {
var col = dynamicColumns[i];
var ratio = col.contentWidth / dynamicColumnsContentWidth;
// A column turned out to be none dynamic, start over recursively
var isNoneDynamic = col.contentWidth + extraWidth * ratio < fairWidth;
if (extraWidth < 0 && isNoneDynamic) {
dynamicColumns.splice(i, 1);
dynamicColumnsContentWidth -= col.contentWidth;
col.width = fairWidth;
staticWidth += col.width;
distributeWidth(dynamicColumns, staticWidth, dynamicColumnsContentWidth, fairWidth);
break;
}
else {
col.width = col.contentWidth + extraWidth * ratio;
}
}
}
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var models_1 = __webpack_require__(15);
var config_1 = __webpack_require__(0);
var assign = __webpack_require__(12);
function validateInput(headers, data, allOptions) {
if (!headers || typeof headers !== 'object') {
console.error("The headers should be an object or array, is: " + typeof headers);
}
if (!data || typeof data !== 'object') {
console.error("The data should be an object or array, is: " + typeof data);
}
var _loop_1 = function (settings) {
if (settings && typeof settings !== 'object') {
console.error("The options parameter should be of type object, is: " + typeof settings);
}
if (typeof settings.extendWidth !== 'undefined') {
settings.tableWidth = settings.extendWidth ? 'auto' : 'wrap';
console.error("Use of deprecated option: extendWidth, use tableWidth instead.");
}
if (typeof settings.margins !== 'undefined') {
if (typeof settings.margin === 'undefined')
settings.margin = settings.margins;
console.error("Use of deprecated option: margins, use margin instead.");
}
if (typeof settings.afterPageContent !== 'undefined' || typeof settings.beforePageContent !== 'undefined' || typeof settings.afterPageAdd !== 'undefined') {
console.error("The afterPageContent, beforePageContent and afterPageAdd hooks are deprecated. Use addPageContent instead");
if (typeof settings.addPageContent === 'undefined') {
settings.addPageContent = function (data) {
config_1.Config.applyUserStyles();
if (settings.beforePageContent)
settings.beforePageContent(data);
config_1.Config.applyUserStyles();
if (settings.afterPageContent)
settings.afterPageContent(data);
config_1.Config.applyUserStyles();
if (settings.afterPageAdd && data.pageCount > 1) {
data.afterPageAdd(data);
}
config_1.Config.applyUserStyles();
};
}
}
[['padding', 'cellPadding'], ['lineHeight', 'rowHeight'], 'fontSize', 'overflow'].forEach(function (o) {
var deprecatedOption = typeof o === 'string' ? o : o[0];
var style = typeof o === 'string' ? o : o[1];
if (typeof settings[deprecatedOption] !== 'undefined') {
if (typeof settings.styles[style] === 'undefined') {
settings.styles[style] = settings[deprecatedOption];
}
console.error("Use of deprecated option: " + deprecatedOption + ", use the style " + style + " instead.");
}
});
for (var _i = 0, _a = ['styles', 'bodyStyles', 'headerStyles', 'columnStyles']; _i < _a.length; _i++) {
var styleProp = _a[_i];
if (settings[styleProp] && typeof settings[styleProp] !== 'object') {
console.error("The " + styleProp + " style should be of type object, is: " + typeof settings[styleProp]);
}
else if (settings[styleProp] && settings[styleProp].rowHeight) {
console.error("Use of deprecated style: rowHeight, use vertical cell padding instead");
}
}
};
for (var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++) {
var settings = allOptions_1[_i];
_loop_1(settings);
}
}
exports.validateInput = validateInput;
/**
* Create models from the user input
*
* @param inputHeaders
* @param inputData
*/
function createModels(inputHeaders, inputData) {
var splitRegex = /\r\n|\r|\n/g;
var table = config_1.Config.tableInstance();
var settings = table.settings;
var theme = config_1.getTheme(settings.theme);
// Header row and columns
var headerRow = new models_1.Row(inputHeaders, -1);
headerRow.index = -1;
// Columns and header row
inputHeaders.forEach(function (rawColumn, index) {
var dataKey = index;
if (typeof rawColumn.dataKey !== 'undefined') {
dataKey = rawColumn.dataKey;
}
else if (typeof rawColumn.key !== 'undefined') {
console.error("Deprecation warning: Use dataKey instead of key");
dataKey = rawColumn.key; // deprecated since 2.x
}
var col = new models_1.Column(dataKey, index);
col.widthStyle = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.columnStyles[col.dataKey] || {}]).columnWidth;
table.columns.push(col);
var cell = new models_1.Cell(rawColumn);
cell.styles = config_1.Config.styles([theme.table, theme.header, table.styles.styles, table.styles.headerStyles]);
if (cell.raw instanceof HTMLElement) {
cell.text = (cell.raw.innerText || '').trim();
}
else {
var text = typeof cell.raw === 'object' ? cell.raw.title : cell.raw;
// Stringify 0 and false, but not undefined
cell.text = typeof cell.raw !== 'undefined' ? '' + text : '';
}
cell.text = cell.text.split(splitRegex);
headerRow.cells[dataKey] = cell;
for (var _i = 0, _a = table.hooks.createdHeaderCell; _i < _a.length; _i++) {
var hook = _a[_i];
hook(cell, { cell: cell, column: col, row: headerRow, settings: settings });
}
});
table.headerRow = headerRow;
// Rows och cells
inputData.forEach(function (rawRow, i) {
var row = new models_1.Row(rawRow, i);
var rowStyles = i % 2 === 0 ? assign({}, theme.alternateRow, table.styles.alternateRowStyles) : {};
table.columns.forEach(function (column) {
var cell = new models_1.Cell(rawRow[column.dataKey]);
var colStyles = table.styles.columnStyles[column.dataKey] || {};
cell.styles = config_1.Config.styles([theme.table, theme.body, table.styles.styles, table.styles.bodyStyles, rowStyles, colStyles]);
if (cell.raw && cell.raw instanceof HTMLElement) {
cell.text = (cell.raw.innerText || '').trim();
}
else {
// Stringify 0 and false, but not undefined
cell.text = typeof cell.raw !== 'undefined' ? '' + cell.raw : '';
}
cell.text = cell.text.split(splitRegex);
row.cells[column.dataKey] = cell;
for (var _i = 0, _a = table.hooks.createdCell; _i < _a.length; _i++) {
var hook = _a[_i];
hook(cell, config_1.Config.hooksData({ cell: cell, column: column, row: row }));
}
});
table.rows.push(row);
});
}
exports.createModels = createModels;
/***/ },
/* 18 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_18__;
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var $isNaN = __webpack_require__(8);
var $isFinite = __webpack_require__(7);
var sign = __webpack_require__(10);
var mod = __webpack_require__(9);
var IsCallable = __webpack_require__(3);
var toPrimitive = __webpack_require__(23);
// https://es5.github.io/#x9
var ES5 = {
ToPrimitive: toPrimitive,
ToBoolean: function ToBoolean(value) {
return Boolean(value);
},
ToNumber: function ToNumber(value) {
return Number(value);
},
ToInteger: function ToInteger(value) {
var number = this.ToNumber(value);
if ($isNaN(number)) { return 0; }
if (number === 0 || !$isFinite(number)) { return number; }
return sign(number) * Math.floor(Math.abs(number));
},
ToInt32: function ToInt32(x) {
return this.ToNumber(x) >> 0;
},
ToUint32: function ToUint32(x) {
return this.ToNumber(x) >>> 0;
},
ToUint16: function ToUint16(value) {
var number = this.ToNumber(value);
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
var posInt = sign(number) * Math.floor(Math.abs(number));
return mod(posInt, 0x10000);
},
ToString: function ToString(value) {
return String(value);
},
ToObject: function ToObject(value) {
this.CheckObjectCoercible(value);
return Object(value);
},
CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
/* jshint eqnull:true */
if (value == null) {
throw new TypeError(optMessage || 'Cannot call method on ' + value);
}
return value;
},
IsCallable: IsCallable,
SameValue: function SameValue(x, y) {
if (x === y) { // 0 === -0, but they are not identical.
if (x === 0) { return 1 / x === 1 / y; }
return true;
}
return $isNaN(x) && $isNaN(y);
},
// http://www.ecma-international.org/ecma-262/5.1/#sec-8
Type: function Type(x) {
if (x === null) {
return 'Null';
}
if (typeof x === 'undefined') {
return 'Undefined';
}
if (typeof x === 'function' || typeof x === 'object') {
return 'Object';
}
if (typeof x === 'number') {
return 'Number';
}
if (typeof x === 'boolean') {
return 'Boolean';
}
if (typeof x === 'string') {
return 'String';
}
}
};
module.exports = ES5;
/***/ },
/* 20 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var toStr = Object.prototype.toString;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var symbolToStr = hasSymbols ? Symbol.prototype.toString : toStr;
var $isNaN = __webpack_require__(8);
var $isFinite = __webpack_require__(7);
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
var assign = __webpack_require__(6);
var sign = __webpack_require__(10);
var mod = __webpack_require__(9);
var isPrimitive = __webpack_require__(22);
var toPrimitive = __webpack_require__(24);
var parseInteger = parseInt;
var bind = __webpack_require__(2);
var strSlice = bind.call(Function.call, String.prototype.slice);
var isBinary = bind.call(Function.call, RegExp.prototype.test, /^0b[01]+$/i);
var isOctal = bind.call(Function.call, RegExp.prototype.test, /^0o[0-7]+$/i);
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
var hasNonWS = bind.call(Function.call, RegExp.prototype.test, nonWSregex);
var invalidHexLiteral = /^[\-\+]0x[0-9a-f]+$/i;
var isInvalidHexLiteral = bind.call(Function.call, RegExp.prototype.test, invalidHexLiteral);
// whitespace from: http://es5.github.io/#x15.5.4.20
// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
var ws = [
'\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
'\u2029\uFEFF'
].join('');
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
var replace = bind.call(Function.call, String.prototype.replace);
var trim = function (value) {
return replace(value, trimRegex, '');
};
var ES5 = __webpack_require__(19);
var hasRegExpMatcher = __webpack_require__(29);
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
var ES6 = assign(assign({}, ES5), {
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
Call: function Call(F, V) {
var args = arguments.length > 2 ? arguments[2] : [];
if (!this.IsCallable(F)) {
throw new TypeError(F + ' is not a function');
}
return F.apply(V, args);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
ToPrimitive: toPrimitive,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
// ToBoolean: ES5.ToBoolean,
// http://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
ToNumber: function ToNumber(argument) {
var value = isPrimitive(argument) ? argument : toPrimitive(argument, 'number');
if (typeof value === 'symbol') {
throw new TypeError('Cannot convert a Symbol value to a number');
}
if (typeof value === 'string') {
if (isBinary(value)) {
return this.ToNumber(parseInteger(strSlice(value, 2), 2));
} else if (isOctal(value)) {
return this.ToNumber(parseInteger(strSlice(value, 2), 8));
} else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
return NaN;
} else {
var trimmed = trim(value);
if (trimmed !== value) {
return this.ToNumber(trimmed);
}
}
}
return Number(value);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
// ToInteger: ES5.ToNumber,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
// ToInt32: ES5.ToInt32,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
// ToUint32: ES5.ToUint32,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
ToInt16: function ToInt16(argument) {
var int16bit = this.ToUint16(argument);
return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
// ToUint16: ES5.ToUint16,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
ToInt8: function ToInt8(argument) {
var int8bit = this.ToUint8(argument);
return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
ToUint8: function ToUint8(argument) {
var number = this.ToNumber(argument);
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
var posInt = sign(number) * Math.floor(Math.abs(number));
return mod(posInt, 0x100);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
ToUint8Clamp: function ToUint8Clamp(argument) {
var number = this.ToNumber(argument);
if ($isNaN(number) || number <= 0) { return 0; }
if (number >= 0xFF) { return 0xFF; }
var f = Math.floor(argument);
if (f + 0.5 < number) { return f + 1; }
if (number < f + 0.5) { return f; }
if (f % 2 !== 0) { return f + 1; }
return f;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
ToString: function ToString(argument) {
if (typeof argument === 'symbol') {
throw new TypeError('Cannot convert a Symbol value to a string');
}
return String(argument);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
ToObject: function ToObject(value) {
this.RequireObjectCoercible(value);
return Object(value);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
ToPropertyKey: function ToPropertyKey(argument) {
var key = this.ToPrimitive(argument, String);
return typeof key === 'symbol' ? symbolToStr.call(key) : this.ToString(key);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
ToLength: function ToLength(argument) {
var len = this.ToInteger(argument);
if (len <= 0) { return 0; } // includes converting -0 to +0
if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
return len;
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
if (toStr.call(argument) !== '[object String]') {
throw new TypeError('must be a string');
}
if (argument === '-0') { return -0; }
var n = this.ToNumber(argument);
if (this.SameValue(this.ToString(n), argument)) { return n; }
return void 0;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
RequireObjectCoercible: ES5.CheckObjectCoercible,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
IsArray: Array.isArray || function IsArray(argument) {
return toStr.call(argument) === '[object Array]';
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
// IsCallable: ES5.IsCallable,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
IsConstructor: function IsConstructor(argument) {
return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
IsExtensible: function IsExtensible(obj) {
if (!Object.preventExtensions) { return true; }
if (isPrimitive(obj)) {
return false;
}
return Object.isExtensible(obj);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
IsInteger: function IsInteger(argument) {
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
return false;
}
var abs = Math.abs(argument);
return Math.floor(abs) === abs;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
IsPropertyKey: function IsPropertyKey(argument) {
return typeof argument === 'string' || typeof argument === 'symbol';
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp
IsRegExp: function IsRegExp(argument) {
if (!argument || typeof argument !== 'object') {
return false;
}
if (hasSymbols) {
var isRegExp = argument[Symbol.match];
if (typeof isRegExp !== 'undefined') {
return ES5.ToBoolean(isRegExp);
}
}
return hasRegExpMatcher(argument);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
// SameValue: ES5.SameValue,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
SameValueZero: function SameValueZero(x, y) {
return (x === y) || ($isNaN(x) && $isNaN(y));
},
Type: function Type(x) {
if (typeof x === 'symbol') {
return 'Symbol';
}
return ES5.Type(x);
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
if (this.Type(O) !== 'Object') {
throw new TypeError('Assertion failed: Type(O) is not Object');
}
var C = O.constructor;
if (typeof C === 'undefined') {
return defaultConstructor;
}
if (this.Type(C) !== 'Object') {
throw new TypeError('O.constructor is not an Object');
}
var S = hasSymbols && Symbol.species ? C[Symbol.species] : undefined;
if (S == null) {
return defaultConstructor;
}
if (this.IsConstructor(S)) {
return S;
}
throw new TypeError('no constructor found');
}
});
delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
module.exports = ES6;
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var ES6 = __webpack_require__(20);
var assign = __webpack_require__(6);
var ES7 = assign(ES6, {
// https://github.com/tc39/ecma262/pull/60
SameValueNonNumber: function SameValueNonNumber(x, y) {
if (typeof x === 'number' || typeof x !== typeof y) {
throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
}
return this.SameValue(x, y);
}
});
module.exports = ES7;
/***/ },
/* 22 */
/***/ function(module, exports) {
module.exports = function isPrimitive(value) {
return value === null || (typeof value !== 'function' && typeof value !== 'object');
};
/***/ },
/* 23 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var toStr = Object.prototype.toString;
var isPrimitive = __webpack_require__(11);
var isCallable = __webpack_require__(3);
// https://es5.github.io/#x8.12
var ES5internalSlots = {
'[[DefaultValue]]': function (O, hint) {
var actualHint = hint || (toStr.call(O) === '[object Date]' ? String : Number);
if (actualHint === String || actualHint === Number) {
var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var value, i;
for (i = 0; i < methods.length; ++i) {
if (isCallable(O[methods[i]])) {
value = O[methods[i]]();
if (isPrimitive(value)) {
return value;
}
}
}
throw new TypeError('No default value');
}
throw new TypeError('invalid [[DefaultValue]] hint supplied');
}
};
// https://es5.github.io/#x9
module.exports = function ToPrimitive(input, PreferredType) {
if (isPrimitive(input)) {
return input;
}
return ES5internalSlots['[[DefaultValue]]'](input, PreferredType);
};
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var isPrimitive = __webpack_require__(11);
var isCallable = __webpack_require__(3);
var isDate = __webpack_require__(28);
var isSymbol = __webpack_require__(30);
var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
if (typeof O === 'undefined' || O === null) {
throw new TypeError('Cannot call method on ' + O);
}
if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
throw new TypeError('hint must be "string" or "number"');
}
var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var method, result, i;
for (i = 0; i < methodNames.length; ++i) {
method = O[methodNames[i]];
if (isCallable(method)) {
result = method.call(O);
if (isPrimitive(result)) {
return result;
}
}
}
throw new TypeError('No default value');
};
var GetMethod = function GetMethod(O, P) {
var func = O[P];
if (func !== null && typeof func !== 'undefined') {
if (!isCallable(func)) {
throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
}
return func;
}
};
// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
module.exports = function ToPrimitive(input, PreferredType) {
if (isPrimitive(input)) {
return input;
}
var hint = 'default';
if (arguments.length > 1) {
if (PreferredType === String) {
hint = 'string';
} else if (PreferredType === Number) {
hint = 'number';
}
}
var exoticToPrim;
if (hasSymbols) {
if (Symbol.toPrimitive) {
exoticToPrim = GetMethod(input, Symbol.toPrimitive);
} else if (isSymbol(input)) {
exoticToPrim = Symbol.prototype.valueOf;
}
}
if (typeof exoticToPrim !== 'undefined') {
var result = exoticToPrim.call(input, hint);
if (isPrimitive(result)) {
return result;
}
throw new TypeError('unable to convert exotic object to primitive');
}
if (hint === 'default' && (isDate(input) || isSymbol(input))) {
hint = 'string';
}
return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
};
/***/ },
/* 25 */
/***/ function(module, exports) {
var hasOwn = Object.prototype.hasOwnProperty;
var toString = Object.prototype.toString;
module.exports = function forEach (obj, fn, ctx) {
if (toString.call(fn) !== '[object Function]') {
throw new TypeError('iterator must be a function');
}
var l = obj.length;
if (l === +l) {
for (var i = 0; i < l; i++) {
fn.call(ctx, obj[i], i, obj);
}
} else {
for (var k in obj) {
if (hasOwn.call(obj, k)) {
fn.call(ctx, obj[k], k, obj);
}
}
}
};
/***/ },
/* 26 */
/***/ function(module, exports) {
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
var slice = Array.prototype.slice;
var toStr = Object.prototype.toString;
var funcType = '[object Function]';
module.exports = function bind(that) {
var target = this;
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slice.call(arguments, 1);
var bound;
var binder = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
var boundLength = Math.max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push('$' + i);
}
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
if (target.prototype) {
var Empty = function Empty() {};
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
/***/ },
/* 27 */
/***/ function(module, exports, __webpack_require__) {
var bind = __webpack_require__(2);
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
/***/ },
/* 28 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var getDay = Date.prototype.getDay;
var tryDateObject = function tryDateObject(value) {
try {
getDay.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var dateClass = '[object Date]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isDateObject(value) {
if (typeof value !== 'object' || value === null) { return false; }
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
};
/***/ },
/* 29 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var regexExec = RegExp.prototype.exec;
var tryRegexExec = function tryRegexExec(value) {
try {
regexExec.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var regexClass = '[object RegExp]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isRegex(value) {
if (typeof value !== 'object') { return false; }
return hasToStringTag ? tryRegexExec(value) : toStr.call(value) === regexClass;
};
/***/ },
/* 30 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var toStr = Object.prototype.toString;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
if (hasSymbols) {
var symToStr = Symbol.prototype.toString;
var symStringRegex = /^Symbol\(.*\)$/;
var isSymbolObject = function isSymbolObject(value) {
if (typeof value.valueOf() !== 'symbol') { return false; }
return symStringRegex.test(symToStr.call(value));
};
module.exports = function isSymbol(value) {
if (typeof value === 'symbol') { return true; }
if (toStr.call(value) !== '[object Symbol]') { return false; }
try {
return isSymbolObject(value);
} catch (e) {
return false;
}
};
} else {
module.exports = function isSymbol(value) {
// this environment does not support Symbols.
return false;
};
}
/***/ },
/* 31 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
// modified from https://github.com/es-shims/es5-shim
var has = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var slice = Array.prototype.slice;
var isArgs = __webpack_require__(32);
var isEnumerable = Object.prototype.propertyIsEnumerable;
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var equalsConstructorPrototype = function (o) {
var ctor = o.constructor;
return ctor && ctor.prototype === o;
};
var excludedKeys = {
$console: true,
$external: true,
$frame: true,
$frameElement: true,
$frames: true,
$innerHeight: true,
$innerWidth: true,
$outerHeight: true,
$outerWidth: true,
$pageXOffset: true,
$pageYOffset: true,
$parent: true,
$scrollLeft: true,
$scrollTop: true,
$scrollX: true,
$scrollY: true,
$self: true,
$webkitIndexedDB: true,
$webkitStorageInfo: true,
$window: true
};
var hasAutomationEqualityBug = (function () {
/* global window */
if (typeof window === 'undefined') { return false; }
for (var k in window) {
try {
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
equalsConstructorPrototype(window[k]);
} catch (e) {
return true;
}
}
} catch (e) {
return true;
}
}
return false;
}());
var equalsConstructorPrototypeIfNotBuggy = function (o) {
/* global window */
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
return equalsConstructorPrototype(o);
}
try {
return equalsConstructorPrototype(o);
} catch (e) {
return false;
}
};
var keysShim = function keys(object) {
var isObject = object !== null && typeof object === 'object';
var isFunction = toStr.call(object) === '[object Function]';
var isArguments = isArgs(object);
var isString = isObject && toStr.call(object) === '[object String]';
var theKeys = [];
if (!isObject && !isFunction && !isArguments) {
throw new TypeError('Object.keys called on a non-object');
}
var skipProto = hasProtoEnumBug && isFunction;
if (isString && object.length > 0 && !has.call(object, 0)) {
for (var i = 0; i < object.length; ++i) {
theKeys.push(String(i));
}
}
if (isArguments && object.length > 0) {
for (var j = 0; j < object.length; ++j) {
theKeys.push(String(j));
}
} else {
for (var name in object) {
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
theKeys.push(String(name));
}
}
}
if (hasDontEnumBug) {
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
for (var k = 0; k < dontEnums.length; ++k) {
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
theKeys.push(dontEnums[k]);
}
}
}
return theKeys;
};
keysShim.shim = function shimObjectKeys() {
if (Object.keys) {
var keysWorksWithArguments = (function () {
// Safari 5.0 bug
return (Object.keys(arguments) || '').length === 2;
}(1, 2));
if (!keysWorksWithArguments) {
var originalKeys = Object.keys;
Object.keys = function keys(object) {
if (isArgs(object)) {
return originalKeys(slice.call(object));
} else {
return originalKeys(object);
}
};
}
} else {
Object.keys = keysShim;
}
return Object.keys || keysShim;
};
module.exports = keysShim;
/***/ },
/* 32 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var toStr = Object.prototype.toString;
module.exports = function isArguments(value) {
var str = toStr.call(value);
var isArgs = str === '[object Arguments]';
if (!isArgs) {
isArgs = str !== '[object Array]' &&
value !== null &&
typeof value === 'object' &&
typeof value.length === 'number' &&
value.length >= 0 &&
toStr.call(value.callee) === '[object Function]';
}
return isArgs;
};
/***/ },
/* 33 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var define = __webpack_require__(5);
var implementation = __webpack_require__(13);
var getPolyfill = __webpack_require__(14);
var shim = __webpack_require__(34);
var polyfill = getPolyfill();
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;
/***/ },
/* 34 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var getPolyfill = __webpack_require__(14);
var define = __webpack_require__(5);
module.exports = function shimEntries() {
var polyfill = getPolyfill();
define(Object, { entries: polyfill }, {
entries: function testEntries() {
return Object.entries !== polyfill;
}
});
return polyfill;
};
/***/ },
/* 35 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var jsPDF = __webpack_require__(18);
var config_1 = __webpack_require__(0);
var common_1 = __webpack_require__(1);
var painter_1 = __webpack_require__(4);
var calculator_1 = __webpack_require__(16);
var creator_1 = __webpack_require__(17);
/**
* Create a table from a set of rows and columns.
*
* @param {Object[]|String[]} headers Either as an array of objects or array of strings
* @param {Object[][]|String[][]} data Either as an array of objects or array of strings
* @param {Object} [userOptions={}] Options that will override the default ones
*/
jsPDF.API.autoTable = function (headers, data, tableOptions) {
if (tableOptions === void 0) { tableOptions = {}; }
this.autoTableState = this.autoTableState || {};
jsPDF.autoTableState = jsPDF.autoTableState || {};
var allOptions = [jsPDF.autoTableState.defaults || {}, this.autoTableState.defaults || {}, tableOptions || {}];
creator_1.validateInput(headers, data, allOptions);
var table = config_1.Config.createTable(this);
config_1.Config.initSettings(table, allOptions);
var settings = table.settings;
// Create the table model with its columns, rows and cells
creator_1.createModels(headers, data);
settings.margin = config_1.Config.marginOrPadding(settings.margin, config_1.getDefaults().margin);
calculator_1.calculateWidths(this, config_1.Config.pageSize().width);
table.cursor = {
x: table.margin('left'),
y: settings.startY === false ? table.margin('top') : settings.startY
};
var minTableBottomPos = settings.startY + table.margin('bottom') + table.headerRow.height;
if (settings.pageBreak === 'avoid') {
minTableBottomPos += table.height;
}
var pageHeight = config_1.Config.pageSize().height;
if ((settings.pageBreak === 'always' && settings.startY !== false) ||
(settings.startY !== false && minTableBottomPos > pageHeight)) {
table.doc.addPage();
table.cursor.y = table.margin('top');
}
table.pageStartX = table.cursor.x;
table.pageStartY = table.cursor.y;
config_1.Config.applyUserStyles();
if (settings.showHeader === true || settings.showHeader === 'firstPage' || settings.showHeader === 'everyPage') {
painter_1.printRow(table.headerRow, table.hooks.drawHeaderRow, table.hooks.drawHeaderCell);
}
config_1.Config.applyUserStyles();
table.rows.forEach(function (row) {
painter_1.printFullRow(row, table.hooks.drawRow, table.hooks.drawCell);
});
common_1.addTableBorder();
// Don't call global and document addPageContent more than once for each page
var pageNumber = this.internal.getCurrentPageInfo().pageNumber;
if (this.autoTableState.addPageHookPages && this.autoTableState.addPageHookPages[pageNumber]) {
if (typeof tableOptions['addPageContent'] === 'function') {
tableOptions['addPageContent'](config_1.Config.hooksData());
}
}
else {
if (!this.autoTableState.addPageHookPages)
this.autoTableState.addPageHookPages = {};
this.autoTableState.addPageHookPages[pageNumber] = true;
common_1.addContentHooks();
}
table.finalY = table.cursor.y;
this.autoTable.previous = table;
config_1.Config.applyUserStyles();
return this;
};
// Enables doc.autoTable.previous.finalY || 40;
jsPDF.API.autoTable.previous = false;
jsPDF.API.autoTableSetDefaults = function (defaults) {
if (!this.autoTableState)
this.autoTableState = {};
if (defaults && typeof defaults === 'object') {
this.autoTableState.defaults = defaults;
}
else {
delete this.autoTableState.defaults;
}
return this;
};
jsPDF.autoTableSetDefaults = function (defaults) {
if (!jsPDF.autoTableState)
jsPDF.autoTableState = {};
if (defaults && typeof defaults === 'object') {
this.autoTableState.defaults = defaults;
}
else {
delete this.autoTableState.defaults;
}
jsPDF.autoTableState.defaults = defaults;
};
/**
* Parses an html table
*
* @param tableElem Html table element
* @param includeHiddenElements If to include hidden rows and columns (defaults to false)
* @returns Object Object with two properties, columns and rows
*/
jsPDF.API.autoTableHtmlToJson = function (tableElem, includeHiddenElements) {
includeHiddenElements = includeHiddenElements || false;
if (!tableElem || !(tableElem instanceof HTMLTableElement)) {
console.error("A HTMLTableElement has to be sent to autoTableHtmlToJson");
return null;
}
var columns = {}, rows = [];
var header = tableElem.rows[0];
for (var i = 0; i < header.cells.length; i++) {
var cell = header.cells[i];
var style = window.getComputedStyle(cell);
if (includeHiddenElements || style.display !== 'none') {
columns[i] = cell;
}
}
var _loop_1 = function (i) {
var tableRow = tableElem.rows[i];
var style = window.getComputedStyle(tableRow);
if (includeHiddenElements || style.display !== 'none') {
var rowData_1 = [];
Object.keys(columns).forEach(function (key) {
var cell = tableRow.cells[key];
rowData_1.push(cell);
});
rows.push(rowData_1);
}
};
for (var i = 1; i < tableElem.rows.length; i++) {
_loop_1(i);
}
var values = Object.keys(columns).map(function (key) { return columns[key]; });
return { columns: values, rows: rows, data: rows };
};
/**
* Improved text function with halign and valign support
* Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113
*/
jsPDF.API.autoTableText = function (text, x, y, styles) {
if (typeof x !== 'number' || typeof y !== 'number') {
console.error('The x and y parameters are required. Missing for the text: ', text);
}
var k = this.internal.scaleFactor;
var fontSize = this.internal.getFontSize() / k;
var splitRegex = /\r\n|\r|\n/g;
var splitText = null;
var lineCount = 1;
if (styles.valign === 'middle' || styles.valign === 'bottom' || styles.halign === 'center' || styles.halign === 'right') {
splitText = typeof text === 'string' ? text.split(splitRegex) : text;
lineCount = splitText.length || 1;
}
// Align the top
y += fontSize * (2 - config_1.FONT_ROW_RATIO);
if (styles.valign === 'middle')
y -= (lineCount / 2) * fontSize * config_1.FONT_ROW_RATIO;
else if (styles.valign === 'bottom')
y -= lineCount * fontSize * config_1.FONT_ROW_RATIO;
if (styles.halign === 'center' || styles.halign === 'right') {
var alignSize = fontSize;
if (styles.halign === 'center')
alignSize *= 0.5;
if (lineCount >= 1) {
for (var iLine = 0; iLine < splitText.length; iLine++) {
this.text(splitText[iLine], x - this.getStringUnitWidth(splitText[iLine]) * alignSize, y);
y += fontSize;
}
return this;
}
x -= this.getStringUnitWidth(text) * alignSize;
}
this.text(text, x, y);
return this;
};
/**
* @deprecated Use doc.autoTable.previous.finalY instead
*/
jsPDF.API.autoTableEndPosY = function () {
var prev = this.autoTable.previous;
if (prev.cursor && typeof prev.cursor.y === 'number') {
return prev.cursor.y;
}
else {
return 0;
}
};
/**
* @deprecated Use jsPDF.autoTableSetDefaults({addPageContent: function() {}}) instead
*/
jsPDF.API.autoTableAddPageContent = function (hook) {
if (!jsPDF.API.autoTable.globalDefaults) {
jsPDF.API.autoTable.globalDefaults = {};
}
jsPDF.API.autoTable.globalDefaults.addPageContent = hook;
return this;
};
/**
* @deprecated Use data.addPage in hooks instead
*/
jsPDF.API.autoTableAddPage = function () {
common_1.addPage();
return this;
};
/***/ }
/******/ ]);
});
[{"time":"2017-05-31 21:51:47","intvalue":3},{"time":"2017-05-31 21:51:45","intvalue":2},
{"time":"2017-05-31 21:51:44","intvalue":2},{"time":"2017-05-31 21:51:43","intvalue":0},
{"time":"2017-05-31 21:51:42","intvalue":7},{"time":"2017-05-31 21:51:41","intvalue":13},
{"time":"2017-05-31 21:51:40","intvalue":11},{"time":"2017-05-31 21:51:39","intvalue":18},
{"time":"2017-05-31 21:51:38","intvalue":19},{"time":"2017-05-31 21:51:37","intvalue":11},
{"time":"2017-05-31 21:51:36","intvalue":10},{"time":"2017-05-31 21:51:35","intvalue":10},
{"time":"2017-05-31 21:51:34","intvalue":0},{"time":"2017-05-31 21:51:31","intvalue":0},
{"time":"2017-05-31 21:51:30","intvalue":5},{"time":"2017-05-31 21:51:29","intvalue":8},
{"time":"2017-05-31 21:51:28","intvalue":0},{"time":"2017-05-31 21:51:27","intvalue":8},
{"time":"2017-05-31 21:51:26","intvalue":9},{"time":"2017-05-31 21:51:25","intvalue":12},
{"time":"2017-05-31 21:51:24","intvalue":12},{"time":"2017-05-31 21:51:23","intvalue":11},
{"time":"2017-05-31 21:51:22","intvalue":13},{"time":"2017-05-31 21:51:21","intvalue":9},
{"time":"2017-05-31 21:51:20","intvalue":0}]
<div class="pagination" ng-if="pages.length >= 2">
<ul class="pagination">
<li ng-if="currentPage > 1">
<a ng-click="selectPage(1)"><<</a>
</li>
<li ng-if="currentPage > 1">
<a ng-click="selectPage(currentPage-1)"><</a>
</li>
<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a>
</li>
<li ng-if="currentPage < numPages"><a ng-click="selectPage(currentPage+1)">></a>
</li>
<li ng-if="currentPage < numPages">
<a ng-click="selectPage(numPages)">>></a>
</li>
</ul>
</div>