datatables.net 1.13.3 → 1.13.4

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.
@@ -1,16 +1,22 @@
1
- /*! DataTables 1.13.3
1
+ /*! DataTables 1.13.4
2
2
  * ©2008-2023 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  import jQuery from 'jquery';
6
6
 
7
7
  // DataTables code uses $ internally, but we want to be able to
8
- // reassign $ with the `use` method below, so it is a regular var.
8
+ // reassign $ with the `use` method, so it is a regular var.
9
9
  let $ = jQuery;
10
10
 
11
11
 
12
12
  var DataTable = function ( selector, options )
13
13
  {
14
+ // Check if called with a window or jQuery object for DOM less applications
15
+ // This is for backwards compatibility
16
+ if (DataTable.factory(selector, options)) {
17
+ return DataTable;
18
+ }
19
+
14
20
  // When creating with `new`, create a new DataTable, returning the API instance
15
21
  if (this instanceof DataTable) {
16
22
  return $(selector).DataTable(options);
@@ -1115,6 +1121,7 @@ var DataTable = function ( selector, options )
1115
1121
  type: sort !== null ? i+'.@data-'+sort : undefined,
1116
1122
  filter: filter !== null ? i+'.@data-'+filter : undefined
1117
1123
  };
1124
+ col._isArrayHost = true;
1118
1125
 
1119
1126
  _fnColumnOptions( oSettings, i );
1120
1127
  }
@@ -2303,7 +2310,7 @@ function _fnColumnOptions( oSettings, iCol, oOptions )
2303
2310
 
2304
2311
  // Indicate if DataTables should read DOM data as an object or array
2305
2312
  // Used in _fnGetRowElements
2306
- if ( typeof mDataSrc !== 'number' ) {
2313
+ if ( typeof mDataSrc !== 'number' && ! oCol._isArrayHost ) {
2307
2314
  oSettings._rowReadObject = true;
2308
2315
  }
2309
2316
 
@@ -9306,6 +9313,48 @@ _api_register( 'state.save()', function () {
9306
9313
 
9307
9314
 
9308
9315
 
9316
+ /**
9317
+ * Set the jQuery or window object to be used by DataTables
9318
+ *
9319
+ * @param {*} module Library / container object
9320
+ * @param {string} type Library or container type `lib` or `win`.
9321
+ */
9322
+ DataTable.use = function (module, type) {
9323
+ if (type === 'lib' || module.fn) {
9324
+ $ = module;
9325
+ }
9326
+ else if (type == 'win' || module.document) {
9327
+ window = module;
9328
+ document = module.document;
9329
+ }
9330
+ }
9331
+
9332
+ /**
9333
+ * CommonJS factory function pass through. This will check if the arguments
9334
+ * given are a window object or a jQuery object. If so they are set
9335
+ * accordingly.
9336
+ * @param {*} root Window
9337
+ * @param {*} jq jQUery
9338
+ * @returns {boolean} Indicator
9339
+ */
9340
+ DataTable.factory = function (root, jq) {
9341
+ var is = false;
9342
+
9343
+ // Test if the first parameter is a window object
9344
+ if (root && root.document) {
9345
+ window = root;
9346
+ document = root.document;
9347
+ }
9348
+
9349
+ // Test if the second parameter is a jQuery object
9350
+ if (jq && jq.fn && jq.fn.jquery) {
9351
+ $ = jq;
9352
+ is = true;
9353
+ }
9354
+
9355
+ return is;
9356
+ }
9357
+
9309
9358
  /**
9310
9359
  * Provide a common method for plug-ins to check the version of DataTables being
9311
9360
  * used, in order to ensure compatibility.
@@ -9647,7 +9696,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9647
9696
  * @type string
9648
9697
  * @default Version number
9649
9698
  */
9650
- DataTable.version = "1.13.3";
9699
+ DataTable.version = "1.13.4";
9651
9700
 
9652
9701
  /**
9653
9702
  * Private data store, containing all of the settings objects that are
@@ -15576,13 +15625,4 @@ $.each( DataTable, function ( prop, val ) {
15576
15625
  $.fn.DataTable[ prop ] = val;
15577
15626
  } );
15578
15627
 
15579
- DataTable.use = function (module, type) {
15580
- if (type === 'lib' || module.fn) {
15581
- $ = module;
15582
- }
15583
- else if (type == 'win' || module.document) {
15584
- window = module;
15585
- }
15586
- }
15587
-
15588
15628
  export default DataTable;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/jquery.dataTables.js",
5
5
  "module": "js/jquery.dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "1.13.3",
7
+ "version": "1.13.4",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
package/types/types.d.ts CHANGED
@@ -79,6 +79,12 @@ declare interface DataTables<T> extends DataTablesStatic {
79
79
  selector: InstSelector,
80
80
  opts?: Config
81
81
  ): Api<T>
82
+
83
+ /**
84
+ * CommonJS factory. This only applies to CommonJS environments,
85
+ * in all others it would throw an error.
86
+ */
87
+ (win?: Window, jQuery?: JQuery): DataTables<T>;
82
88
  }
83
89
 
84
90
  declare const DataTables: DataTables<any>;
@@ -97,12 +103,20 @@ interface JQueryDataTables extends JQuery {
97
103
 
98
104
  // Extend the jQuery object with DataTables' construction methods
99
105
  declare global {
106
+ interface JQueryDataTableApi extends DataTablesStatic {
107
+ <T = any>(opts?: Config): Api<T>;
108
+ }
109
+
110
+ interface JQueryDataTableJq extends DataTablesStatic {
111
+ (opts?: Config): JQueryDataTables;
112
+ }
113
+
100
114
  interface JQuery {
101
115
  /**
102
116
  * Create a new DataTable, returning a DataTables API instance.
103
117
  * @param opts Configuration settings
104
118
  */
105
- DataTable<T = any>(opts?: Config): Api<T>;
119
+ DataTable: JQueryDataTableApi;
106
120
 
107
121
  /**
108
122
  * Create a new DataTable, returning a jQuery object, extended
@@ -110,7 +124,7 @@ declare global {
110
124
  * DataTables API.
111
125
  * @param opts Configuration settings
112
126
  */
113
- dataTable(opts?: Config): JQueryDataTables;
127
+ dataTable: JQueryDataTableJq;
114
128
  }
115
129
  }
116
130
 
@@ -575,8 +589,6 @@ export interface ConfigSearch {
575
589
  */
576
590
 
577
591
  export interface Api<T> {
578
- new(context: any, data: any[]);
579
-
580
592
  /**
581
593
  * API should be array-like
582
594
  */
@@ -2113,7 +2125,7 @@ export interface ApiStatic {
2113
2125
  * Create a new API instance to an existing DataTable. Note that this
2114
2126
  * does not create a new DataTable.
2115
2127
  */
2116
- new (selector: string | Node | Node[] | JQuery): Api<any>;
2128
+ new (selector: string | Node | Node[] | JQuery | InternalSettings): Api<any>;
2117
2129
 
2118
2130
  register<T=any>(name: string, fn: Function): T;
2119
2131
  registerPlural<T=any>(name: string, fn: Function): T;