UNPKG

44.3 kBJavaScriptView Raw
1/******/ (() => { // webpackBootstrap
2/******/ var __webpack_modules__ = ({
3
4/***/ "./src/index.js":
5/*!**********************!*\
6 !*** ./src/index.js ***!
7 \**********************/
8/*! namespace exports */
9/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
10/*! other exports [not provided] [no usage info] */
11/*! runtime requirements: __webpack_require__, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
12/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13
14"use strict";
15__webpack_require__.r(__webpack_exports__);
16/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
18/* harmony export */ });
19/* harmony import */ var _js_init__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./js/init */ "./src/js/init.js");
20
21var objectExporter = _js_init__WEBPACK_IMPORTED_MODULE_0__.default.init;
22
23if (typeof window !== 'undefined') {
24 window.objectExporter = objectExporter;
25}
26
27/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (objectExporter);
28
29/***/ }),
30
31/***/ "./src/js/csv.js":
32/*!***********************!*\
33 !*** ./src/js/csv.js ***!
34 \***********************/
35/*! namespace exports */
36/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
37/*! other exports [not provided] [no usage info] */
38/*! runtime requirements: __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
39/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
40
41"use strict";
42__webpack_require__.r(__webpack_exports__);
43/* harmony export */ __webpack_require__.d(__webpack_exports__, {
44/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
45/* harmony export */ });
46function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
47
48/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
49 "export": function _export(params) {
50 exportObject2CSV(params.headers, params.exportable, params.fileName, params.columnSeparator);
51 }
52});
53/**
54 * Function to export the object as csv.
55 * @param {array} headers the columns of the csv file.
56 * @param {object} exportable the records of csv file.
57 * @param {string} fileName the title of the file which needs to be exported.
58 * @param {char} columnSeparator the character that separates one colum from another.
59 */
60
61function exportObject2CSV(headers, exportable, fileName, columnSeparator) {
62 // Check if there is headers provided
63 if (headers) {
64 // Check if the provided header is an arry (backward-compatibility for version below 3.3.0 - more info at: https://github.com/gharibi/JsObjExporter/issues/4)
65 if (_typeof(headers[0]) !== 'object') {
66 exportable.unshift(headers);
67 } else {
68 var headerDataset = {};
69
70 for (var i = 0; i < headers.length; i++) {
71 headerDataset[headers[i].name] = headers[i].alias;
72 }
73
74 exportable.unshift(headerDataset);
75 }
76 } // Convert Object to JSON
77
78
79 var jsonObject = JSON.stringify(exportable);
80 var csv = convert2csv(jsonObject, columnSeparator);
81 var exportFileName = fileName + '.csv';
82 var blob = new Blob([csv], {
83 type: 'text/csv;charset=utf-8;'
84 });
85
86 if (navigator.msSaveBlob) {
87 // IE 10+
88 navigator.msSaveBlob(blob, exportFileName);
89 } else {
90 var link = document.createElement('a');
91
92 if (link.download !== undefined) {
93 // Browsers that support HTML5 download attribute
94 var url = URL.createObjectURL(blob);
95 link.setAttribute('href', url);
96 link.setAttribute('download', exportFileName);
97 link.style.visibility = 'hidden';
98 document.body.appendChild(link);
99 link.click();
100 document.body.removeChild(link);
101 }
102 }
103}
104/**
105 * Function to create an object of arrays to csv.
106 * @param {object} objArray the json data which needs to be converted to an array.
107 * @param {char} columnSeparator the character that separates one column from another.
108 */
109
110
111function convert2csv(objArray, columnSeparator) {
112 var array = _typeof(objArray) !== 'object' ? JSON.parse(objArray) : objArray;
113 var str = '';
114
115 for (var i = 0; i < array.length; i++) {
116 var line = '';
117
118 for (var index in array[i]) {
119 line += array[i][index] + columnSeparator;
120 }
121
122 line = line.substring(0, line.length - 1);
123 str += line + '\r\n';
124 }
125
126 return str;
127}
128
129/***/ }),
130
131/***/ "./src/js/doc.js":
132/*!***********************!*\
133 !*** ./src/js/doc.js ***!
134 \***********************/
135/*! namespace exports */
136/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
137/*! other exports [not provided] [no usage info] */
138/*! runtime requirements: __webpack_require__, __webpack_require__.n, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
139/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
140
141"use strict";
142__webpack_require__.r(__webpack_exports__);
143/* harmony export */ __webpack_require__.d(__webpack_exports__, {
144/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
145/* harmony export */ });
146/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/dist/FileSaver.min.js");
147/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_0__);
148/* harmony import */ var _el__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./el */ "./src/js/el.js");
149
150
151/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
152 "export": function _export(params) {
153 exportObject2Doc(params.headers, params.exportable, params.fileName, params.headerStyle, params.cellStyle, params.repeatHeader);
154 }
155});
156/**
157 * Function to export the dataset as doc.
158 * @param {array} headers the columns of the csv file.
159 * @param {object} exportable the records of csv file.
160 * @param {string} fileName the title of the file which needs to be exported.
161 * @param {string} headerStyle the style which can be applied to the headers.
162 * @param {string} cellStyle the style which can be applied to the cells.
163 * @param {boolean} repeatHeader determines whether there should be a repeated header on each page.
164 */
165
166function exportObject2Doc(headers, exportable, fileName, headerStyle, cellStyle, repeatHeader) {
167 // Create the html structured dataset
168 var dataset = (0,_el__WEBPACK_IMPORTED_MODULE_1__.htmlTblCreater)('doc', headers, exportable, headerStyle, cellStyle, repeatHeader);
169 var htmlString = '<html><body>' + dataset + '</body></html>'; // Create the bytes
170
171 var bytes = new Uint8Array(htmlString.length);
172
173 for (var i = 0; i < htmlString.length; i++) {
174 bytes[i] = htmlString.charCodeAt(i);
175 } // Convert the contents to blob
176
177
178 var blob = new Blob([bytes], {
179 type: 'text/html'
180 }); // Save the file as doc
181
182 (0,file_saver__WEBPACK_IMPORTED_MODULE_0__.saveAs)(blob, fileName + '.doc');
183}
184
185/***/ }),
186
187/***/ "./src/js/el.js":
188/*!**********************!*\
189 !*** ./src/js/el.js ***!
190 \**********************/
191/*! namespace exports */
192/*! export htmlTblCreater [provided] [no usage info] [missing usage info prevents renaming] */
193/*! other exports [not provided] [no usage info] */
194/*! runtime requirements: __webpack_require__.r, __webpack_exports__, __webpack_require__.d, __webpack_require__.* */
195/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
196
197"use strict";
198__webpack_require__.r(__webpack_exports__);
199/* harmony export */ __webpack_require__.d(__webpack_exports__, {
200/* harmony export */ "htmlTblCreater": () => /* binding */ htmlTblCreater
201/* harmony export */ });
202function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
203
204function htmlTblCreater(type, headers, exportable, headerStyle, cellStyle, repeatHeader) {
205 // Construct the html structure for the provided exportable
206 var dataset = '<table style="border-collapse: collapse;" width="100%;">'; // Check if the headers should be repeated
207
208 if (repeatHeader === true) {
209 dataset += '<thead>';
210 } // Check if the provided header is an arry (backward-compatibility for version below 3.3.0 - more info at: https://github.com/gharibi/JsObjExporter/issues/4)
211
212
213 var columnFlex = 0;
214
215 if (_typeof(headers[0]) !== 'object') {
216 // Construct the table headers
217 dataset += '<tr>';
218
219 for (var j = 0; j < headers.length; j++) {
220 dataset += '<th style="' + headerStyle + '" >' + headers[j] + '</th>';
221 }
222
223 dataset += '</tr>'; // Check if the headers should be repeated
224
225 if (repeatHeader === true) {
226 dataset += '</thead>';
227 } // Construct the body elements
228
229
230 for (var _j = 0; _j < exportable.length; _j++) {
231 dataset += '<tr style="' + cellStyle + '">';
232
233 var _loop = function _loop(k) {
234 // Check if the input string is HTML, if so, do not add the cell tags
235 var cellContents = exportable[_j][Object.keys(exportable[_j])[k]];
236
237 if (/<[a-z][\s\S]*>/i.test(cellContents) === true) {
238 dataset += cellContents;
239 } else {
240 dataset += '<td style="' + cellStyle + '" ' + function () {
241 return type.toLowerCase() === 'csv' ? 'width="' + headers[k].flex / columnFlex * 100 + '%;"' : '';
242 }() + ' >' + cellContents + '</td>';
243 }
244 };
245
246 for (var k = 0; k < Object.keys(exportable[_j]).length - 1; k++) {
247 _loop(k);
248 }
249
250 dataset += '</tr>';
251 }
252
253 dataset += '</table>';
254 } else {
255 var _loop2 = function _loop2(i) {
256 // Check if the header contains a flex, otherwise consider flex=1 to have equal sized columns
257 columnFlex += function () {
258 return 'flex' in headers[i] ? headers[i].flex : 1;
259 }();
260 };
261
262 for (var i = 0; i < headers.length; i++) {
263 _loop2(i);
264 } // Construct the table headers
265
266
267 dataset += '<tr>';
268
269 for (var _j2 = 0; _j2 < headers.length; _j2++) {
270 dataset += '<th style="' + headerStyle + '" width="' + headers[_j2].flex / columnFlex * 100 + '%;" >' + headers[_j2].alias + '</th>';
271 }
272
273 dataset += '</tr>'; // Check if the headers should be repeated
274
275 if (repeatHeader === true) {
276 dataset += '</thead>';
277 } // Construct the body elements
278
279
280 for (var _j3 = 0; _j3 < exportable.length; _j3++) {
281 dataset += '<tr style="' + cellStyle + '">'; // Loop through the header items to show only the items associated with a header
282
283 var _loop3 = function _loop3(_k) {
284 // Check if the input string is HTML, if so, do not add the cell tags
285 var cellContents = exportable[_j3][headers[_k].name];
286
287 if (/<[a-z][\s\S]*>/i.test(cellContents) === true) {
288 dataset += cellContents;
289 } else {
290 dataset += '<td style="' + cellStyle + '" ' + function () {
291 return type.toLowerCase() === 'csv' ? 'width="' + headers[_k].flex / columnFlex * 100 + '%;"' : '';
292 }() + ' >' + cellContents + '</td>';
293 }
294 };
295
296 for (var _k = 0; _k < headers.length; _k++) {
297 _loop3(_k);
298 }
299
300 dataset += '</tr>';
301 }
302 } // Return the dataset
303
304
305 return dataset;
306}
307
308/***/ }),
309
310/***/ "./src/js/html.js":
311/*!************************!*\
312 !*** ./src/js/html.js ***!
313 \************************/
314/*! namespace exports */
315/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
316/*! other exports [not provided] [no usage info] */
317/*! runtime requirements: __webpack_require__, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
318/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
319
320"use strict";
321__webpack_require__.r(__webpack_exports__);
322/* harmony export */ __webpack_require__.d(__webpack_exports__, {
323/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
324/* harmony export */ });
325/* harmony import */ var _placeholder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./placeholder */ "./src/js/placeholder.js");
326
327
328var _require = __webpack_require__(/*! detect-browser */ "./node_modules/detect-browser/es/index.js"),
329 detect = _require.detect;
330
331/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
332 "export": function _export(params) {
333 // Detect the browser information
334 var browser = detect(); // Retrieve the DOM for the requested exportable
335
336 var elementDom = document.getElementById(params.exportable); // Check if the DOM is available
337
338 if (typeof elementDom === 'undefined') {
339 throw new Error('There is no DOM object available for the requested id.');
340 } // Construct the exportable for the print
341
342
343 var exportableFrame = _placeholder__WEBPACK_IMPORTED_MODULE_0__.default.generateFrame(params, elementDom.innerHTML); // Cleanup the DOM from the exportable frame
344
345 if (document.getElementById('jsObjExporterFrameId')) document.getElementById('jsObjExporterFrameId').remove(); // Attach the exportable frame to the document body
346
347 document.getElementsByTagName('body')[0].appendChild(exportableFrame); // Get the iframe element
348
349 var iframeElement = document.getElementById('jsObjExporterFrameId'); // Set the onload method
350
351 exportableFrame.onload = function () {
352 // Focus on the frame for priting
353 iframeElement.focus(); // Check the if the browser is Edge or Internet Explorer
354
355 if (browser.name === 'edge' || browser.name === 'ie') {
356 iframeElement.contentWindow.document.execCommand('print', false, null);
357 } else {
358 // All other browsers
359 iframeElement.contentWindow.print();
360 }
361 };
362 }
363});
364
365/***/ }),
366
367/***/ "./src/js/init.js":
368/*!************************!*\
369 !*** ./src/js/init.js ***!
370 \************************/
371/*! namespace exports */
372/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
373/*! other exports [not provided] [no usage info] */
374/*! runtime requirements: __webpack_require__, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
375/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
376
377"use strict";
378__webpack_require__.r(__webpack_exports__);
379/* harmony export */ __webpack_require__.d(__webpack_exports__, {
380/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
381/* harmony export */ });
382/* harmony import */ var _csv__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./csv */ "./src/js/csv.js");
383/* harmony import */ var _xls__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./xls */ "./src/js/xls.js");
384/* harmony import */ var _pdf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pdf */ "./src/js/pdf.js");
385/* harmony import */ var _doc__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./doc */ "./src/js/doc.js");
386/* harmony import */ var _html__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./html */ "./src/js/html.js");
387
388
389function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
390
391
392
393
394
395
396/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
397 init: function init() {
398 var params = {
399 type: 'object',
400 headers: null,
401 exportable: null,
402 fileName: 'export',
403 headerStyle: 'font-size:16px; font-weight:bold;',
404 cellStyle: 'font-size:14px;',
405 sheetName: 'worksheet',
406 documentTitle: 'test document title',
407 documentTitleStyle: 'color:red;',
408 repeatHeader: true,
409 columnSeparator: ','
410 }; // Check if an exportable document or object was supplied
411
412 var args = arguments[0];
413 if (args === undefined) throw new Error('obj2csv expects at least 1 exportable!'); // Process parameters
414
415 switch (_typeof(args)) {
416 case 'object':
417 params.exportable = args.exportable;
418 params.type = typeof args.type !== 'undefined' ? args.type : params.type;
419 params.headers = typeof args.headers !== 'undefined' ? args.headers : params.headers;
420 params.fileName = typeof args.fileName !== 'undefined' ? args.fileName : params.fileName;
421 params.headerStyle = typeof args.headerStyle !== 'undefined' ? args.headerStyle : params.headerStyle;
422 params.cellStyle = typeof args.cellStyle !== 'undefined' ? args.cellStyle : params.cellStyle;
423 params.sheetName = typeof args.sheetName !== 'undefined' ? args.sheetName : params.sheetName;
424 params.documentTitle = typeof args.documentTitle !== 'undefined' ? args.documentTitle : params.documentTitle;
425 params.documentTitleStyle = typeof args.documentTitleStyle !== 'undefined' ? args.documentTitleStyle : params.documentTitleStyle;
426 params.repeatHeader = typeof args.repeatHeader !== 'undefined' ? args.repeatHeader : params.repeatHeader;
427 params.columnSeparator = typeof args.columnSeparator !== 'undefined' ? args.columnSeparator : params.columnSeparator;
428 break;
429
430 default:
431 throw new Error('Unexpected argument type! Expected "object", got ' + _typeof(args));
432 } // Validate type
433
434
435 if (!params.exportable) {
436 throw new Error('Invalid exportable!');
437 }
438
439 if (!params.type || typeof params.type !== 'string') {
440 throw new Error('Invalid exportable type! only string type is acceptable!');
441 }
442
443 if (['csv', 'xls', 'pdf', 'doc', 'html'].indexOf(params.type.toLowerCase()) === -1) {
444 throw new Error('Invalid exportable type. Available types are "CSV", "XLS", "pdf" and "DOC".');
445 }
446
447 if (typeof params.repeatHeader !== 'boolean' && typeof params.repeatHeader !== 'undefined') {
448 throw new Error('Invalid value for the repeat header parameter. Available types are "true" and "false".');
449 } // Check exportable type
450
451
452 switch (params.type) {
453 case 'csv':
454 _csv__WEBPACK_IMPORTED_MODULE_0__.default.export(params);
455 break;
456
457 case 'xls':
458 _xls__WEBPACK_IMPORTED_MODULE_1__.default.export(params);
459 break;
460
461 case 'pdf':
462 _pdf__WEBPACK_IMPORTED_MODULE_2__.default.export(params);
463 break;
464
465 case 'doc':
466 _doc__WEBPACK_IMPORTED_MODULE_3__.default.export(params);
467 break;
468
469 case 'html':
470 _html__WEBPACK_IMPORTED_MODULE_4__.default.export(params);
471 break;
472 }
473 }
474});
475
476/***/ }),
477
478/***/ "./src/js/pdf.js":
479/*!***********************!*\
480 !*** ./src/js/pdf.js ***!
481 \***********************/
482/*! namespace exports */
483/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
484/*! other exports [not provided] [no usage info] */
485/*! runtime requirements: __webpack_require__, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
486/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
487
488"use strict";
489__webpack_require__.r(__webpack_exports__);
490/* harmony export */ __webpack_require__.d(__webpack_exports__, {
491/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
492/* harmony export */ });
493/* harmony import */ var _el__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./el */ "./src/js/el.js");
494
495
496var _require = __webpack_require__(/*! detect-browser */ "./node_modules/detect-browser/es/index.js"),
497 detect = _require.detect;
498
499/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
500 "export": function _export(params) {
501 exportObject2PDF(params.documentTitle, params.documentTitleStyle, params.headers, params.exportable, params.headerStyle, params.cellStyle, params.repeatHeader);
502 }
503});
504
505function exportObject2PDF(documentTitle, documentTitleStyle, headers, exportable, headerStyle, cellStyle, repeatHeader) {
506 // Define a printable body element
507 var printableBody = document.createElement('iframe'); // Set the prontableBody to hidden
508
509 printableBody.setAttribute('style', 'visibility: hidden; height: 0; width: 0; position: absolute;');
510 printableBody.setAttribute('id', 'objectExporterPrintableBodyId'); // Construct the document title
511
512 printableBody.srcdoc = '<html></html>'; // Append the printableBody to the current document
513
514 document.getElementsByTagName('body')[0].appendChild(printableBody); // Get the printable elements
515
516 var printableElements = document.getElementById('objectExporterPrintableBodyId'); // Check when the printableBody is loaded successfully
517
518 printableBody.onload = function () {
519 // Detect the browser information
520 var browser = detect(); // Define a printable document
521
522 var printableDocument = printableElements.contentWindow || printableElements.contentDocument; // Check if there is document element
523
524 if (printableDocument.document) printableDocument = printableDocument.document;
525 var printableDocumentContents = '<span style="' + documentTitleStyle + '">' + documentTitle + '</span><br>';
526 printableDocumentContents += (0,_el__WEBPACK_IMPORTED_MODULE_0__.htmlTblCreater)('pdf', headers, exportable, headerStyle, cellStyle, repeatHeader);
527 printableDocument.body.innerHTML = printableDocumentContents; // Assign style to the printable
528
529 var style = document.createElement('style');
530 style.innerHTML = '';
531 printableDocument.head.appendChild(style); // Prepare the printable for the print
532
533 printableElements.focus(); // Check the if the browser is Edge or Internet Explorer
534
535 if (browser.name === 'edge' || browser.name === 'ie') {
536 printableElements.contentWindow.document.execCommand('print', false, null);
537 } else {
538 // All other browsers
539 printableElements.contentWindow.print();
540 }
541 };
542}
543
544/***/ }),
545
546/***/ "./src/js/placeholder.js":
547/*!*******************************!*\
548 !*** ./src/js/placeholder.js ***!
549 \*******************************/
550/*! namespace exports */
551/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
552/*! other exports [not provided] [no usage info] */
553/*! runtime requirements: __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
554/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
555
556"use strict";
557__webpack_require__.r(__webpack_exports__);
558/* harmony export */ __webpack_require__.d(__webpack_exports__, {
559/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
560/* harmony export */ });
561var placeholder = {
562 /**
563 * Method to generate the frame for opening the print/export dialog.
564 * @param {object} params parameters which will are provided at the API level.
565 * @param {string} body the body of the element which needs to be exported.
566 */
567 generateFrame: function generateFrame(params, body) {
568 var printFrame = document.createElement('iframe');
569 printFrame.setAttribute('style', 'visibility: hidden; height: 0; width: 0; position: absolute;');
570 printFrame.setAttribute('id', 'jsObjExporterFrameId');
571 printFrame.srcdoc = '</head><body>' + body + '</body></html>';
572 return printFrame;
573 }
574}; // Export the module
575
576/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (placeholder);
577
578/***/ }),
579
580/***/ "./src/js/xls.js":
581/*!***********************!*\
582 !*** ./src/js/xls.js ***!
583 \***********************/
584/*! namespace exports */
585/*! export default [provided] [no usage info] [missing usage info prevents renaming] */
586/*! other exports [not provided] [no usage info] */
587/*! runtime requirements: __webpack_require__, __webpack_exports__, __webpack_require__.r, __webpack_require__.d, __webpack_require__.* */
588/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
589
590"use strict";
591__webpack_require__.r(__webpack_exports__);
592/* harmony export */ __webpack_require__.d(__webpack_exports__, {
593/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
594/* harmony export */ });
595/* harmony import */ var _el__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./el */ "./src/js/el.js");
596
597
598var _require = __webpack_require__(/*! detect-browser */ "./node_modules/detect-browser/es/index.js"),
599 detect = _require.detect;
600
601/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
602 "export": function _export(params) {
603 exportObject2XLS(params.headers, params.exportable, params.fileName, params.headerStyle, params.cellStyle, params.sheetName, params.documentTitle, params.documentTitleStyle);
604 }
605}); // Defining the required functions
606
607var base64 = function base64(s) {
608 return window.btoa(unescape(encodeURIComponent(s)));
609};
610
611var format = function format(s, c) {
612 return s.replace(/{(\w+)}/g, function (m, p) {
613 return c[p];
614 });
615};
616
617var uri = 'data:application/vnd.ms-excel;base64,';
618var template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>';
619/**
620 * Function to export the dataset as xls.
621 * @param {array} headers the columns of the csv file.
622 * @param {object} exportable the records of csv file.
623 * @param {string} fileName the title of the file which needs to be exported.
624 * @param {string} headerStyle the style which can be applied to the headers.
625 * @param {string} cellStyle the style which can be applied to the cells.
626 * @param {string} sheetName the excel sheet name which needs to be applied to the exported xls file.
627 * @param {string} documentTitle the document title which needs to be written as a header on the excel sheet.
628 * @param {string} documentTitleStyle the style of the document title.
629 */
630
631function exportObject2XLS(headers, exportable, fileName, headerStyle, cellStyle, sheetName, documentTitle, documentTitleStyle) {
632 // Construct the html structure for the provided exportable
633 var dataset = '<span style="' + documentTitleStyle + '">' + documentTitle + '</span><br>';
634 dataset += (0,_el__WEBPACK_IMPORTED_MODULE_0__.htmlTblCreater)('xls', headers, exportable, headerStyle, cellStyle, false); // Push the file for being downloaded
635
636 var ctx = {
637 worksheet: sheetName,
638 table: dataset
639 };
640 var link = document.createElement('a');
641 var exportFileName = fileName + '.xls';
642 link.setAttribute('href', uri + base64(format(template, ctx)));
643 link.setAttribute('download', exportFileName);
644 link.style.visibility = 'hidden'; // Detect the browser information
645
646 var browser = detect(); // Check the if the browser is Edge or Internet Explorer
647
648 if (browser.name === 'edge' || browser.name === 'ie') {
649 if (window.navigator.msSaveBlob) {
650 var blob = new Blob([dataset], {
651 type: 'data:application/vnd.ms-excel;'
652 });
653 navigator.msSaveBlob(blob, exportFileName);
654 }
655 } else {
656 // All other browsers
657 document.body.appendChild(link);
658 link.click();
659 document.body.removeChild(link);
660 }
661}
662
663/***/ }),
664
665/***/ "./node_modules/detect-browser/es/index.js":
666/*!*************************************************!*\
667 !*** ./node_modules/detect-browser/es/index.js ***!
668 \*************************************************/
669/*! namespace exports */
670/*! export BotInfo [provided] [no usage info] [missing usage info prevents renaming] */
671/*! export BrowserInfo [provided] [no usage info] [missing usage info prevents renaming] */
672/*! export NodeInfo [provided] [no usage info] [missing usage info prevents renaming] */
673/*! export ReactNativeInfo [provided] [no usage info] [missing usage info prevents renaming] */
674/*! export SearchBotDeviceInfo [provided] [no usage info] [missing usage info prevents renaming] */
675/*! export browserName [provided] [no usage info] [missing usage info prevents renaming] */
676/*! export detect [provided] [no usage info] [missing usage info prevents renaming] */
677/*! export detectOS [provided] [no usage info] [missing usage info prevents renaming] */
678/*! export getNodeVersion [provided] [no usage info] [missing usage info prevents renaming] */
679/*! export parseUserAgent [provided] [no usage info] [missing usage info prevents renaming] */
680/*! other exports [not provided] [no usage info] */
681/*! runtime requirements: __webpack_require__.r, __webpack_exports__, __webpack_require__.d, __webpack_require__.* */
682/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
683
684"use strict";
685__webpack_require__.r(__webpack_exports__);
686/* harmony export */ __webpack_require__.d(__webpack_exports__, {
687/* harmony export */ "BrowserInfo": () => /* binding */ BrowserInfo,
688/* harmony export */ "NodeInfo": () => /* binding */ NodeInfo,
689/* harmony export */ "SearchBotDeviceInfo": () => /* binding */ SearchBotDeviceInfo,
690/* harmony export */ "BotInfo": () => /* binding */ BotInfo,
691/* harmony export */ "ReactNativeInfo": () => /* binding */ ReactNativeInfo,
692/* harmony export */ "detect": () => /* binding */ detect,
693/* harmony export */ "browserName": () => /* binding */ browserName,
694/* harmony export */ "parseUserAgent": () => /* binding */ parseUserAgent,
695/* harmony export */ "detectOS": () => /* binding */ detectOS,
696/* harmony export */ "getNodeVersion": () => /* binding */ getNodeVersion
697/* harmony export */ });
698var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
699 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
700 for (var r = Array(s), k = 0, i = 0; i < il; i++)
701 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
702 r[k] = a[j];
703 return r;
704};
705var BrowserInfo = /** @class */ (function () {
706 function BrowserInfo(name, version, os) {
707 this.name = name;
708 this.version = version;
709 this.os = os;
710 this.type = 'browser';
711 }
712 return BrowserInfo;
713}());
714
715var NodeInfo = /** @class */ (function () {
716 function NodeInfo(version) {
717 this.version = version;
718 this.type = 'node';
719 this.name = 'node';
720 this.os = process.platform;
721 }
722 return NodeInfo;
723}());
724
725var SearchBotDeviceInfo = /** @class */ (function () {
726 function SearchBotDeviceInfo(name, version, os, bot) {
727 this.name = name;
728 this.version = version;
729 this.os = os;
730 this.bot = bot;
731 this.type = 'bot-device';
732 }
733 return SearchBotDeviceInfo;
734}());
735
736var BotInfo = /** @class */ (function () {
737 function BotInfo() {
738 this.type = 'bot';
739 this.bot = true; // NOTE: deprecated test name instead
740 this.name = 'bot';
741 this.version = null;
742 this.os = null;
743 }
744 return BotInfo;
745}());
746
747var ReactNativeInfo = /** @class */ (function () {
748 function ReactNativeInfo() {
749 this.type = 'react-native';
750 this.name = 'react-native';
751 this.version = null;
752 this.os = null;
753 }
754 return ReactNativeInfo;
755}());
756
757// tslint:disable-next-line:max-line-length
758var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;
759var SEARCHBOT_OS_REGEX = /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/;
760var REQUIRED_VERSION_PARTS = 3;
761var userAgentRules = [
762 ['aol', /AOLShield\/([0-9\._]+)/],
763 ['edge', /Edge\/([0-9\._]+)/],
764 ['edge-ios', /EdgiOS\/([0-9\._]+)/],
765 ['yandexbrowser', /YaBrowser\/([0-9\._]+)/],
766 ['kakaotalk', /KAKAOTALK\s([0-9\.]+)/],
767 ['samsung', /SamsungBrowser\/([0-9\.]+)/],
768 ['silk', /\bSilk\/([0-9._-]+)\b/],
769 ['miui', /MiuiBrowser\/([0-9\.]+)$/],
770 ['beaker', /BeakerBrowser\/([0-9\.]+)/],
771 ['edge-chromium', /EdgA?\/([0-9\.]+)/],
772 [
773 'chromium-webview',
774 /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/,
775 ],
776 ['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
777 ['phantomjs', /PhantomJS\/([0-9\.]+)(:?\s|$)/],
778 ['crios', /CriOS\/([0-9\.]+)(:?\s|$)/],
779 ['firefox', /Firefox\/([0-9\.]+)(?:\s|$)/],
780 ['fxios', /FxiOS\/([0-9\.]+)/],
781 ['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
782 ['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
783 ['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
784 ['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
785 ['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
786 ['ie', /MSIE\s(7\.0)/],
787 ['bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/],
788 ['android', /Android\s([0-9\.]+)/],
789 ['ios', /Version\/([0-9\._]+).*Mobile.*Safari.*/],
790 ['safari', /Version\/([0-9\._]+).*Safari/],
791 ['facebook', /FBAV\/([0-9\.]+)/],
792 ['instagram', /Instagram\s([0-9\.]+)/],
793 ['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/],
794 ['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
795 ['searchbot', SEARCHBOX_UA_REGEX],
796];
797var operatingSystemRules = [
798 ['iOS', /iP(hone|od|ad)/],
799 ['Android OS', /Android/],
800 ['BlackBerry OS', /BlackBerry|BB10/],
801 ['Windows Mobile', /IEMobile/],
802 ['Amazon OS', /Kindle/],
803 ['Windows 3.11', /Win16/],
804 ['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],
805 ['Windows 98', /(Windows 98)|(Win98)/],
806 ['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],
807 ['Windows XP', /(Windows NT 5.1)|(Windows XP)/],
808 ['Windows Server 2003', /(Windows NT 5.2)/],
809 ['Windows Vista', /(Windows NT 6.0)/],
810 ['Windows 7', /(Windows NT 6.1)/],
811 ['Windows 8', /(Windows NT 6.2)/],
812 ['Windows 8.1', /(Windows NT 6.3)/],
813 ['Windows 10', /(Windows NT 10.0)/],
814 ['Windows ME', /Windows ME/],
815 ['Open BSD', /OpenBSD/],
816 ['Sun OS', /SunOS/],
817 ['Chrome OS', /CrOS/],
818 ['Linux', /(Linux)|(X11)/],
819 ['Mac OS', /(Mac_PowerPC)|(Macintosh)/],
820 ['QNX', /QNX/],
821 ['BeOS', /BeOS/],
822 ['OS/2', /OS\/2/],
823];
824function detect(userAgent) {
825 if (!!userAgent) {
826 return parseUserAgent(userAgent);
827 }
828 if (typeof document === 'undefined' &&
829 typeof navigator !== 'undefined' &&
830 navigator.product === 'ReactNative') {
831 return new ReactNativeInfo();
832 }
833 if (typeof navigator !== 'undefined') {
834 return parseUserAgent(navigator.userAgent);
835 }
836 return getNodeVersion();
837}
838function matchUserAgent(ua) {
839 // opted for using reduce here rather than Array#first with a regex.test call
840 // this is primarily because using the reduce we only perform the regex
841 // execution once rather than once for the test and for the exec again below
842 // probably something that needs to be benchmarked though
843 return (ua !== '' &&
844 userAgentRules.reduce(function (matched, _a) {
845 var browser = _a[0], regex = _a[1];
846 if (matched) {
847 return matched;
848 }
849 var uaMatch = regex.exec(ua);
850 return !!uaMatch && [browser, uaMatch];
851 }, false));
852}
853function browserName(ua) {
854 var data = matchUserAgent(ua);
855 return data ? data[0] : null;
856}
857function parseUserAgent(ua) {
858 var matchedRule = matchUserAgent(ua);
859 if (!matchedRule) {
860 return null;
861 }
862 var name = matchedRule[0], match = matchedRule[1];
863 if (name === 'searchbot') {
864 return new BotInfo();
865 }
866 var versionParts = match[1] && match[1].split(/[._]/).slice(0, 3);
867 if (versionParts) {
868 if (versionParts.length < REQUIRED_VERSION_PARTS) {
869 versionParts = __spreadArrays(versionParts, createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length));
870 }
871 }
872 else {
873 versionParts = [];
874 }
875 var version = versionParts.join('.');
876 var os = detectOS(ua);
877 var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua);
878 if (searchBotMatch && searchBotMatch[1]) {
879 return new SearchBotDeviceInfo(name, version, os, searchBotMatch[1]);
880 }
881 return new BrowserInfo(name, version, os);
882}
883function detectOS(ua) {
884 for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {
885 var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];
886 var match = regex.exec(ua);
887 if (match) {
888 return os;
889 }
890 }
891 return null;
892}
893function getNodeVersion() {
894 var isNode = typeof process !== 'undefined' && process.version;
895 return isNode ? new NodeInfo(process.version.slice(1)) : null;
896}
897function createVersionParts(count) {
898 var output = [];
899 for (var ii = 0; ii < count; ii++) {
900 output.push('0');
901 }
902 return output;
903}
904
905
906/***/ }),
907
908/***/ "./node_modules/file-saver/dist/FileSaver.min.js":
909/*!*******************************************************!*\
910 !*** ./node_modules/file-saver/dist/FileSaver.min.js ***!
911 \*******************************************************/
912/*! unknown exports (runtime-defined) */
913/*! runtime requirements: top-level-this-exports, module, __webpack_require__.g, __webpack_exports__, __webpack_require__.* */
914/*! CommonJS bailout: this is used directly at 1:154-158 */
915/*! CommonJS bailout: module.exports is used directly at 1:2545-2559 */
916/***/ (function(module, exports, __webpack_require__) {
917
918var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b),
919 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
920 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
921 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof __webpack_require__.g&&__webpack_require__.g.global===__webpack_require__.g?__webpack_require__.g:void 0,a=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(a,b,d,e){if(e=e||open("","_blank"),e&&(e.document.title=e.document.body.innerText="downloading..."),"string"==typeof a)return c(a,b,d);var g="application/octet-stream"===a.type,h=/constructor/i.test(f.HTMLElement)||f.safari,i=/CriOS\/[\d]+/.test(navigator.userAgent);if((i||g&&h)&&"object"==typeof FileReader){var j=new FileReader;j.onloadend=function(){var a=j.result;a=i?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),e?e.location.href=a:location=a,e=null},j.readAsDataURL(a)}else{var k=f.URL||f.webkitURL,l=k.createObjectURL(a);e?e.location=l:location.href=l,e=null,setTimeout(function(){k.revokeObjectURL(l)},4E4)}});f.saveAs=a.saveAs=a, true&&(module.exports=a)});
922
923//# sourceMappingURL=FileSaver.min.js.map
924
925/***/ })
926
927/******/ });
928/************************************************************************/
929/******/ // The module cache
930/******/ var __webpack_module_cache__ = {};
931/******/
932/******/ // The require function
933/******/ function __webpack_require__(moduleId) {
934/******/ // Check if module is in cache
935/******/ if(__webpack_module_cache__[moduleId]) {
936/******/ return __webpack_module_cache__[moduleId].exports;
937/******/ }
938/******/ // Create a new module (and put it into the cache)
939/******/ var module = __webpack_module_cache__[moduleId] = {
940/******/ // no module.id needed
941/******/ // no module.loaded needed
942/******/ exports: {}
943/******/ };
944/******/
945/******/ // Execute the module function
946/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
947/******/
948/******/ // Return the exports of the module
949/******/ return module.exports;
950/******/ }
951/******/
952/************************************************************************/
953/******/ /* webpack/runtime/compat get default export */
954/******/ (() => {
955/******/ // getDefaultExport function for compatibility with non-harmony modules
956/******/ __webpack_require__.n = (module) => {
957/******/ var getter = module && module.__esModule ?
958/******/ () => module['default'] :
959/******/ () => module;
960/******/ __webpack_require__.d(getter, { a: getter });
961/******/ return getter;
962/******/ };
963/******/ })();
964/******/
965/******/ /* webpack/runtime/define property getters */
966/******/ (() => {
967/******/ // define getter functions for harmony exports
968/******/ __webpack_require__.d = (exports, definition) => {
969/******/ for(var key in definition) {
970/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
971/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
972/******/ }
973/******/ }
974/******/ };
975/******/ })();
976/******/
977/******/ /* webpack/runtime/global */
978/******/ (() => {
979/******/ __webpack_require__.g = (function() {
980/******/ if (typeof globalThis === 'object') return globalThis;
981/******/ try {
982/******/ return this || new Function('return this')();
983/******/ } catch (e) {
984/******/ if (typeof window === 'object') return window;
985/******/ }
986/******/ })();
987/******/ })();
988/******/
989/******/ /* webpack/runtime/hasOwnProperty shorthand */
990/******/ (() => {
991/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
992/******/ })();
993/******/
994/******/ /* webpack/runtime/make namespace object */
995/******/ (() => {
996/******/ // define __esModule on exports
997/******/ __webpack_require__.r = (exports) => {
998/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
999/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1000/******/ }
1001/******/ Object.defineProperty(exports, '__esModule', { value: true });
1002/******/ };
1003/******/ })();
1004/******/
1005/************************************************************************/
1006/******/ // startup
1007/******/ // Load entry module
1008/******/ __webpack_require__("./src/index.js");
1009/******/ // This entry module used 'exports' so it can't be inlined
1010/******/ })()
1011;
1012//# sourceMappingURL=objectexporter.min.js.map
\No newline at end of file