dattatable 2.11.52 → 2.11.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ require("datatables.net-bs5");
12
12
  var DataTable = /** @class */ (function () {
13
13
  // Constructor
14
14
  function DataTable(props) {
15
+ var _this = this;
15
16
  this._datatable = null;
16
17
  this._props = null;
17
18
  this._table = null;
@@ -19,6 +20,17 @@ var DataTable = /** @class */ (function () {
19
20
  this._props = props;
20
21
  // Set the default properties
21
22
  this._props.dtProps = this._props.dtProps || {
23
+ createdRow: function (row, data, dataIndex) {
24
+ // Parse the columns
25
+ for (var i = 0; i < _this._props.columns.length; i++) {
26
+ var column = _this._props.columns[i];
27
+ // See if an event exists
28
+ if (column.onRenderCell) {
29
+ // Call it
30
+ column.onRenderCell(row, column, data, dataIndex);
31
+ }
32
+ }
33
+ },
22
34
  drawCallback: function (settings) {
23
35
  var api = new $.fn.dataTable.Api(settings);
24
36
  // Styling option for striped rows
@@ -70,7 +82,7 @@ var DataTable = /** @class */ (function () {
70
82
  // Set the event reference
71
83
  events[i] = column.onRenderCell;
72
84
  // Set the flag
73
- hasEvents = column.onRenderCell ? true : hasEvents;
85
+ //hasEvents = column.onRenderCell ? true : hasEvents;
74
86
  }
75
87
  // Parse the rows
76
88
  (row && typeof (row.length) === "number" ? row : [row]).forEach(function (row) {
@@ -87,7 +99,7 @@ var DataTable = /** @class */ (function () {
87
99
  // See if events exist
88
100
  if (hasEvents) {
89
101
  // Wait for the row to be rendered
90
- var loopId_1 = setInterval(function () {
102
+ setTimeout(function () {
91
103
  // Get the node
92
104
  var elNode = dtRow.node();
93
105
  if (elNode) {
@@ -96,8 +108,9 @@ var DataTable = /** @class */ (function () {
96
108
  // Call the event
97
109
  events[i] ? events[i](elNode.children[i], _this._props.columns[i], row, elNode.rowIndex) : null;
98
110
  }
99
- // Cancel the loop
100
- clearInterval(loopId_1);
111
+ }
112
+ else {
113
+ console.error("Datatables node returned null when adding a row...");
101
114
  }
102
115
  }, 10);
103
116
  }
@@ -247,7 +247,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
247
247
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
248
248
 
249
249
  "use strict";
250
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DataTable = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.15.21_@popperjs+core@2.11.8/node_modules/gd-sprest-bs/build/index.js\");\r\n// DataTables.net\r\nvar $ = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.7.1/node_modules/jquery/dist/jquery.min.js\");\r\n__webpack_require__(/*! datatables.net */ \"./node_modules/.pnpm/datatables.net@2.3.4/node_modules/datatables.net/js/dataTables.min.js\");\r\n__webpack_require__(/*! datatables.net-bs5 */ \"./node_modules/.pnpm/datatables.net-bs5@2.3.4/node_modules/datatables.net-bs5/js/dataTables.bootstrap5.min.js\");\r\n/**\r\n * Data Table\r\n */\r\nvar DataTable = /** @class */ (function () {\r\n // Constructor\r\n function DataTable(props) {\r\n this._datatable = null;\r\n this._props = null;\r\n this._table = null;\r\n // Save the properties\r\n this._props = props;\r\n // Set the default properties\r\n this._props.dtProps = this._props.dtProps || {\r\n drawCallback: function (settings) {\r\n var api = new $.fn.dataTable.Api(settings);\r\n // Styling option for striped rows\r\n $(api.context[0].nTable).addClass('table-striped');\r\n // Align the text to be centered\r\n $(api.context[0].nTableWrapper).find('.dt-info').parent().removeClass('col-md d-md-flex justify-content-between align-items-center');\r\n $(api.context[0].nTableWrapper).find('.dt-info').addClass('text-center');\r\n // Remove the label spacing to align with paging\r\n $(api.context[0].nTableWrapper).find('.dt-length label').addClass('d-none');\r\n // Push paging to the end\r\n $(api.context[0].nTableWrapper).find('.dt-paging').addClass('d-flex justify-content-end mx-0 px-0');\r\n // Add spacing for the footer\r\n $(api.context[0].nTableWrapper).find('.row:last-child').addClass('mb-1');\r\n },\r\n language: {\r\n lengthMenu: \"_MENU_\",\r\n paginate: {\r\n first: \"First\",\r\n last: \"Last\",\r\n next: \"Next\",\r\n previous: \"Previous\"\r\n }\r\n },\r\n layout: {\r\n top: null,\r\n topStart: null,\r\n topEnd: null,\r\n bottom: \"info\",\r\n bottomStart: \"pageLength\",\r\n bottomEnd: {\r\n paging: {\r\n type: \"full_numbers\"\r\n }\r\n }\r\n }\r\n };\r\n // Render the table\r\n this.refresh(props.rows);\r\n }\r\n // Adds row(s) to the table\r\n DataTable.prototype.addRow = function (row) {\r\n var _this = this;\r\n // Set the column events\r\n var events = [];\r\n var hasEvents = false;\r\n for (var i = 0; i < this._props.columns.length; i++) {\r\n // Set the event\r\n var column = this._props.columns[i];\r\n // Set the event reference\r\n events[i] = column.onRenderCell;\r\n // Set the flag\r\n hasEvents = column.onRenderCell ? true : hasEvents;\r\n }\r\n // Parse the rows\r\n (row && typeof (row.length) === \"number\" ? row : [row]).forEach(function (row) {\r\n var newRow = [];\r\n // Parse the columns\r\n for (var i = 0; i < _this._props.columns.length; i++) {\r\n var column = _this._props.columns[i];\r\n var value = typeof (row[column.name]) != \"undefined\" ? row[column.name] : \"\";\r\n // Append the value\r\n newRow.push(value);\r\n }\r\n // Add the row\r\n var dtRow = _this._datatable.row.add(newRow).draw(false);\r\n // See if events exist\r\n if (hasEvents) {\r\n // Wait for the row to be rendered\r\n var loopId_1 = setInterval(function () {\r\n // Get the node\r\n var elNode = dtRow.node();\r\n if (elNode) {\r\n // Parse the events\r\n for (var i = 0; i < events.length; i++) {\r\n // Call the event\r\n events[i] ? events[i](elNode.children[i], _this._props.columns[i], row, elNode.rowIndex) : null;\r\n }\r\n // Cancel the loop\r\n clearInterval(loopId_1);\r\n }\r\n }, 10);\r\n }\r\n });\r\n };\r\n // Applies the datatables.net plugin\r\n DataTable.prototype.applyPlugin = function (table) {\r\n var _this = this;\r\n // Call the rendering event\r\n this._props.dtProps = this._props.onRendering ? this._props.onRendering(this._props.dtProps) : this._props.dtProps;\r\n // Render the datatable\r\n this._datatable = $(table.el).DataTable(this._props.dtProps);\r\n // Call the rendered event in a separate thread to ensure the dashboard object is created\r\n setTimeout(function () {\r\n _this._props.onRendered ? _this._props.onRendered(_this._props.el, _this._datatable) : null;\r\n }, 50);\r\n };\r\n Object.defineProperty(DataTable.prototype, \"datatable\", {\r\n /** Public Interface */\r\n // Datatables.net object\r\n get: function () { return this._datatable; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(DataTable.prototype, \"el\", {\r\n // The data table element\r\n get: function () { return this._props.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Filters the status\r\n DataTable.prototype.filter = function (idx, value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Set the filter\r\n this._datatable.column(idx).search(value.replace(/[-[/\\]{}()*+?.,\\\\^$#\\s]/g, '\\\\$&'), true, false).draw();\r\n };\r\n // Filters the status\r\n DataTable.prototype.filterExact = function (idx, value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Set the filter\r\n this._datatable.column(idx).search(\"^\" + value.replace(/[-[/\\]{}()*+?.,\\\\^$#\\s]/g, '\\\\$&') + \"$\", true, false).draw();\r\n };\r\n // Filters multiple values against the status\r\n DataTable.prototype.filterMulti = function (idx, values) {\r\n if (values === void 0) { values = []; }\r\n // Parse the values\r\n for (var i = 0; i < values.length; i++) {\r\n // Update the value\r\n values[i] = values[i].replace(/\\|/g, '\\\\$&');\r\n }\r\n // Filter the values\r\n this.filter(idx, values.join('|'));\r\n };\r\n // Filters multiple values against the status\r\n DataTable.prototype.filterMultiExact = function (idx, values) {\r\n if (values === void 0) { values = []; }\r\n // Parse the values\r\n for (var i = 0; i < values.length; i++) {\r\n // Update the value\r\n values[i] = values[i].replace(/\\|/g, '\\\\$&');\r\n }\r\n // Filter the values\r\n this._datatable.column(idx).search(\"^(\" + values.join('|') + \")$\", true, false).draw();\r\n };\r\n // Method to reload the data\r\n DataTable.prototype.refresh = function (rows) {\r\n if (rows === void 0) { rows = []; }\r\n // See if the datatable exists\r\n if (this._datatable != null) {\r\n // Clear the datatable\r\n this._datatable.clear();\r\n this._datatable.destroy();\r\n this._datatable = null;\r\n }\r\n // Clear the datatable element\r\n while (this._props.el.firstChild) {\r\n this._props.el.removeChild(this._props.el.firstChild);\r\n }\r\n // Render the data table\r\n this._table = gd_sprest_bs_1.Components.Table({\r\n className: this._props.className,\r\n el: this._props.el,\r\n rows: rows,\r\n columns: this._props.columns\r\n });\r\n // Apply the plugin\r\n this.applyPlugin(this._table);\r\n };\r\n // Searches the datatable\r\n DataTable.prototype.search = function (value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Search the table\r\n this._datatable.search(value).draw();\r\n };\r\n // Updates a cell in the datatable\r\n DataTable.prototype.updateCell = function (row, column, value) {\r\n // Update the cell\r\n this._datatable.cell({ row: row, column: column }).data(value).draw(false);\r\n };\r\n return DataTable;\r\n}());\r\nexports.DataTable = DataTable;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/table.js?");
250
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DataTable = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.15.21_@popperjs+core@2.11.8/node_modules/gd-sprest-bs/build/index.js\");\r\n// DataTables.net\r\nvar $ = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.7.1/node_modules/jquery/dist/jquery.min.js\");\r\n__webpack_require__(/*! datatables.net */ \"./node_modules/.pnpm/datatables.net@2.3.4/node_modules/datatables.net/js/dataTables.min.js\");\r\n__webpack_require__(/*! datatables.net-bs5 */ \"./node_modules/.pnpm/datatables.net-bs5@2.3.4/node_modules/datatables.net-bs5/js/dataTables.bootstrap5.min.js\");\r\n/**\r\n * Data Table\r\n */\r\nvar DataTable = /** @class */ (function () {\r\n // Constructor\r\n function DataTable(props) {\r\n var _this = this;\r\n this._datatable = null;\r\n this._props = null;\r\n this._table = null;\r\n // Save the properties\r\n this._props = props;\r\n // Set the default properties\r\n this._props.dtProps = this._props.dtProps || {\r\n createdRow: function (row, data, dataIndex) {\r\n // Parse the columns\r\n for (var i = 0; i < _this._props.columns.length; i++) {\r\n var column = _this._props.columns[i];\r\n // See if an event exists\r\n if (column.onRenderCell) {\r\n // Call it\r\n column.onRenderCell(row, column, data, dataIndex);\r\n }\r\n }\r\n },\r\n drawCallback: function (settings) {\r\n var api = new $.fn.dataTable.Api(settings);\r\n // Styling option for striped rows\r\n $(api.context[0].nTable).addClass('table-striped');\r\n // Align the text to be centered\r\n $(api.context[0].nTableWrapper).find('.dt-info').parent().removeClass('col-md d-md-flex justify-content-between align-items-center');\r\n $(api.context[0].nTableWrapper).find('.dt-info').addClass('text-center');\r\n // Remove the label spacing to align with paging\r\n $(api.context[0].nTableWrapper).find('.dt-length label').addClass('d-none');\r\n // Push paging to the end\r\n $(api.context[0].nTableWrapper).find('.dt-paging').addClass('d-flex justify-content-end mx-0 px-0');\r\n // Add spacing for the footer\r\n $(api.context[0].nTableWrapper).find('.row:last-child').addClass('mb-1');\r\n },\r\n language: {\r\n lengthMenu: \"_MENU_\",\r\n paginate: {\r\n first: \"First\",\r\n last: \"Last\",\r\n next: \"Next\",\r\n previous: \"Previous\"\r\n }\r\n },\r\n layout: {\r\n top: null,\r\n topStart: null,\r\n topEnd: null,\r\n bottom: \"info\",\r\n bottomStart: \"pageLength\",\r\n bottomEnd: {\r\n paging: {\r\n type: \"full_numbers\"\r\n }\r\n }\r\n }\r\n };\r\n // Render the table\r\n this.refresh(props.rows);\r\n }\r\n // Adds row(s) to the table\r\n DataTable.prototype.addRow = function (row) {\r\n var _this = this;\r\n // Set the column events\r\n var events = [];\r\n var hasEvents = false;\r\n for (var i = 0; i < this._props.columns.length; i++) {\r\n // Set the event\r\n var column = this._props.columns[i];\r\n // Set the event reference\r\n events[i] = column.onRenderCell;\r\n // Set the flag\r\n //hasEvents = column.onRenderCell ? true : hasEvents;\r\n }\r\n // Parse the rows\r\n (row && typeof (row.length) === \"number\" ? row : [row]).forEach(function (row) {\r\n var newRow = [];\r\n // Parse the columns\r\n for (var i = 0; i < _this._props.columns.length; i++) {\r\n var column = _this._props.columns[i];\r\n var value = typeof (row[column.name]) != \"undefined\" ? row[column.name] : \"\";\r\n // Append the value\r\n newRow.push(value);\r\n }\r\n // Add the row\r\n var dtRow = _this._datatable.row.add(newRow).draw(false);\r\n // See if events exist\r\n if (hasEvents) {\r\n // Wait for the row to be rendered\r\n setTimeout(function () {\r\n // Get the node\r\n var elNode = dtRow.node();\r\n if (elNode) {\r\n // Parse the events\r\n for (var i = 0; i < events.length; i++) {\r\n // Call the event\r\n events[i] ? events[i](elNode.children[i], _this._props.columns[i], row, elNode.rowIndex) : null;\r\n }\r\n }\r\n else {\r\n console.error(\"Datatables node returned null when adding a row...\");\r\n }\r\n }, 10);\r\n }\r\n });\r\n };\r\n // Applies the datatables.net plugin\r\n DataTable.prototype.applyPlugin = function (table) {\r\n var _this = this;\r\n // Call the rendering event\r\n this._props.dtProps = this._props.onRendering ? this._props.onRendering(this._props.dtProps) : this._props.dtProps;\r\n // Render the datatable\r\n this._datatable = $(table.el).DataTable(this._props.dtProps);\r\n // Call the rendered event in a separate thread to ensure the dashboard object is created\r\n setTimeout(function () {\r\n _this._props.onRendered ? _this._props.onRendered(_this._props.el, _this._datatable) : null;\r\n }, 50);\r\n };\r\n Object.defineProperty(DataTable.prototype, \"datatable\", {\r\n /** Public Interface */\r\n // Datatables.net object\r\n get: function () { return this._datatable; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(DataTable.prototype, \"el\", {\r\n // The data table element\r\n get: function () { return this._props.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Filters the status\r\n DataTable.prototype.filter = function (idx, value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Set the filter\r\n this._datatable.column(idx).search(value.replace(/[-[/\\]{}()*+?.,\\\\^$#\\s]/g, '\\\\$&'), true, false).draw();\r\n };\r\n // Filters the status\r\n DataTable.prototype.filterExact = function (idx, value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Set the filter\r\n this._datatable.column(idx).search(\"^\" + value.replace(/[-[/\\]{}()*+?.,\\\\^$#\\s]/g, '\\\\$&') + \"$\", true, false).draw();\r\n };\r\n // Filters multiple values against the status\r\n DataTable.prototype.filterMulti = function (idx, values) {\r\n if (values === void 0) { values = []; }\r\n // Parse the values\r\n for (var i = 0; i < values.length; i++) {\r\n // Update the value\r\n values[i] = values[i].replace(/\\|/g, '\\\\$&');\r\n }\r\n // Filter the values\r\n this.filter(idx, values.join('|'));\r\n };\r\n // Filters multiple values against the status\r\n DataTable.prototype.filterMultiExact = function (idx, values) {\r\n if (values === void 0) { values = []; }\r\n // Parse the values\r\n for (var i = 0; i < values.length; i++) {\r\n // Update the value\r\n values[i] = values[i].replace(/\\|/g, '\\\\$&');\r\n }\r\n // Filter the values\r\n this._datatable.column(idx).search(\"^(\" + values.join('|') + \")$\", true, false).draw();\r\n };\r\n // Method to reload the data\r\n DataTable.prototype.refresh = function (rows) {\r\n if (rows === void 0) { rows = []; }\r\n // See if the datatable exists\r\n if (this._datatable != null) {\r\n // Clear the datatable\r\n this._datatable.clear();\r\n this._datatable.destroy();\r\n this._datatable = null;\r\n }\r\n // Clear the datatable element\r\n while (this._props.el.firstChild) {\r\n this._props.el.removeChild(this._props.el.firstChild);\r\n }\r\n // Render the data table\r\n this._table = gd_sprest_bs_1.Components.Table({\r\n className: this._props.className,\r\n el: this._props.el,\r\n rows: rows,\r\n columns: this._props.columns\r\n });\r\n // Apply the plugin\r\n this.applyPlugin(this._table);\r\n };\r\n // Searches the datatable\r\n DataTable.prototype.search = function (value) {\r\n if (value === void 0) { value = \"\"; }\r\n // Search the table\r\n this._datatable.search(value).draw();\r\n };\r\n // Updates a cell in the datatable\r\n DataTable.prototype.updateCell = function (row, column, value) {\r\n // Update the cell\r\n this._datatable.cell({ row: row, column: column }).data(value).draw(false);\r\n };\r\n return DataTable;\r\n}());\r\nexports.DataTable = DataTable;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/table.js?");
251
251
 
252
252
  /***/ }),
253
253