datatables.net 1.13.3 → 1.13.5

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.5
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.
9
- let $ = jQuery;
8
+ // reassign $ with the `use` method, so it is a regular var.
9
+ var $ = 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
  }
@@ -1320,7 +1327,7 @@ var _numToDecimal = function ( num, decimalPoint ) {
1320
1327
 
1321
1328
 
1322
1329
  var _isNumber = function ( d, decimalPoint, formatted ) {
1323
- let type = typeof d;
1330
+ var type = typeof d;
1324
1331
  var strType = type === 'string';
1325
1332
 
1326
1333
  if ( type === 'number' || type === 'bigint') {
@@ -1454,7 +1461,9 @@ var _removeEmpty = function ( a )
1454
1461
 
1455
1462
 
1456
1463
  var _stripHtml = function ( d ) {
1457
- return d.replace( _re_html, '' );
1464
+ return d
1465
+ .replace( _re_html, '' ) // Complete tags
1466
+ .replace(/<script/i, ''); // Safety for incomplete script tag
1458
1467
  };
1459
1468
 
1460
1469
 
@@ -1828,7 +1837,10 @@ DataTable.util = {
1828
1837
  continue;
1829
1838
  }
1830
1839
 
1831
- if ( data === null || data[ a[i] ] === undefined ) {
1840
+ if (data === null || data[ a[i] ] === null) {
1841
+ return null;
1842
+ }
1843
+ else if ( data === undefined || data[ a[i] ] === undefined ) {
1832
1844
  return undefined;
1833
1845
  }
1834
1846
 
@@ -2303,7 +2315,7 @@ function _fnColumnOptions( oSettings, iCol, oOptions )
2303
2315
 
2304
2316
  // Indicate if DataTables should read DOM data as an object or array
2305
2317
  // Used in _fnGetRowElements
2306
- if ( typeof mDataSrc !== 'number' ) {
2318
+ if ( typeof mDataSrc !== 'number' && ! oCol._isArrayHost ) {
2307
2319
  oSettings._rowReadObject = true;
2308
2320
  }
2309
2321
 
@@ -3999,11 +4011,16 @@ function _fnAjaxUpdate( settings )
3999
4011
  settings.iDraw++;
4000
4012
  _fnProcessingDisplay( settings, true );
4001
4013
 
4014
+ // Keep track of drawHold state to handle scrolling after the Ajax call
4015
+ var drawHold = settings._drawHold;
4016
+
4002
4017
  _fnBuildAjax(
4003
4018
  settings,
4004
4019
  _fnAjaxParameters( settings ),
4005
4020
  function(json) {
4021
+ settings._drawHold = drawHold;
4006
4022
  _fnAjaxUpdateDraw( settings, json );
4023
+ settings._drawHold = false;
4007
4024
  }
4008
4025
  );
4009
4026
  }
@@ -4267,7 +4284,7 @@ function _fnFeatureHtmlFilter ( settings )
4267
4284
  _fnThrottle( searchFn, searchDelay ) :
4268
4285
  searchFn
4269
4286
  )
4270
- .on( 'mouseup', function(e) {
4287
+ .on( 'mouseup.DT', function(e) {
4271
4288
  // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
4272
4289
  // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
4273
4290
  // checks the value to see if it has changed. In other browsers it won't have.
@@ -4333,7 +4350,7 @@ function _fnFilterComplete ( oSettings, oInput, iForce )
4333
4350
  if ( _fnDataSource( oSettings ) != 'ssp' )
4334
4351
  {
4335
4352
  /* Global filter */
4336
- _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive, oInput.return );
4353
+ _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
4337
4354
  fnSaveFilter( oInput );
4338
4355
 
4339
4356
  /* Now do the individual column filter */
@@ -4502,11 +4519,15 @@ function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
4502
4519
  *
4503
4520
  * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
4504
4521
  */
4505
- var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
4522
+ var a = $.map( search.match( /["\u201C][^"\u201D]+["\u201D]|[^ ]+/g ) || [''], function ( word ) {
4506
4523
  if ( word.charAt(0) === '"' ) {
4507
4524
  var m = word.match( /^"(.*)"$/ );
4508
4525
  word = m ? m[1] : word;
4509
4526
  }
4527
+ else if ( word.charAt(0) === '\u201C' ) {
4528
+ var m = word.match( /^\u201C(.*)\u201D$/ );
4529
+ word = m ? m[1] : word;
4530
+ }
4510
4531
 
4511
4532
  return word.replace('"', '');
4512
4533
  } );
@@ -9306,6 +9327,52 @@ _api_register( 'state.save()', function () {
9306
9327
 
9307
9328
 
9308
9329
 
9330
+ /**
9331
+ * Set the jQuery or window object to be used by DataTables
9332
+ *
9333
+ * @param {*} module Library / container object
9334
+ * @param {string} [type] Library or container type `lib`, `win` or `datetime`.
9335
+ * If not provided, automatic detection is attempted.
9336
+ */
9337
+ DataTable.use = function (module, type) {
9338
+ if (type === 'lib' || module.fn) {
9339
+ $ = module;
9340
+ }
9341
+ else if (type == 'win' || module.document) {
9342
+ window = module;
9343
+ document = module.document;
9344
+ }
9345
+ else if (type === 'datetime' || module.type === 'DateTime') {
9346
+ DataTable.DateTime = module;
9347
+ }
9348
+ }
9349
+
9350
+ /**
9351
+ * CommonJS factory function pass through. This will check if the arguments
9352
+ * given are a window object or a jQuery object. If so they are set
9353
+ * accordingly.
9354
+ * @param {*} root Window
9355
+ * @param {*} jq jQUery
9356
+ * @returns {boolean} Indicator
9357
+ */
9358
+ DataTable.factory = function (root, jq) {
9359
+ var is = false;
9360
+
9361
+ // Test if the first parameter is a window object
9362
+ if (root && root.document) {
9363
+ window = root;
9364
+ document = root.document;
9365
+ }
9366
+
9367
+ // Test if the second parameter is a jQuery object
9368
+ if (jq && jq.fn && jq.fn.jquery) {
9369
+ $ = jq;
9370
+ is = true;
9371
+ }
9372
+
9373
+ return is;
9374
+ }
9375
+
9309
9376
  /**
9310
9377
  * Provide a common method for plug-ins to check the version of DataTables being
9311
9378
  * used, in order to ensure compatibility.
@@ -9637,7 +9704,9 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9637
9704
  resolved._;
9638
9705
  }
9639
9706
 
9640
- return resolved.replace( '%d', plural ); // nb: plural might be undefined,
9707
+ return typeof resolved === 'string'
9708
+ ? resolved.replace( '%d', plural ) // nb: plural might be undefined,
9709
+ : resolved;
9641
9710
  } );
9642
9711
  /**
9643
9712
  * Version string for plug-ins to check compatibility. Allowed format is
@@ -9647,7 +9716,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9647
9716
  * @type string
9648
9717
  * @default Version number
9649
9718
  */
9650
- DataTable.version = "1.13.3";
9719
+ DataTable.version = "1.13.5";
9651
9720
 
9652
9721
  /**
9653
9722
  * Private data store, containing all of the settings objects that are
@@ -14789,7 +14858,7 @@ $.extend( true, DataTable.ext.renderer, {
14789
14858
  'aria-controls': settings.sTableId,
14790
14859
  'aria-disabled': disabled ? 'true' : null,
14791
14860
  'aria-label': aria[ button ],
14792
- 'aria-role': 'link',
14861
+ 'role': 'link',
14793
14862
  'aria-current': btnClass === classes.sPageButtonActive ? 'page' : null,
14794
14863
  'data-dt-idx': button,
14795
14864
  'tabindex': tabIndex,
@@ -14923,7 +14992,7 @@ var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
14923
14992
  return -Infinity;
14924
14993
  }
14925
14994
 
14926
- let type = typeof d;
14995
+ var type = typeof d;
14927
14996
 
14928
14997
  if (type === 'number' || type === 'bigint') {
14929
14998
  return d;
@@ -15297,7 +15366,7 @@ function __mlHelper (localeString) {
15297
15366
  var __thousands = ',';
15298
15367
  var __decimal = '.';
15299
15368
 
15300
- if (Intl) {
15369
+ if (window.Intl !== undefined) {
15301
15370
  try {
15302
15371
  var num = new Intl.NumberFormat().formatToParts(100000.1);
15303
15372
 
@@ -15576,13 +15645,4 @@ $.each( DataTable, function ( prop, val ) {
15576
15645
  $.fn.DataTable[ prop ] = val;
15577
15646
  } );
15578
15647
 
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
15648
  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.5",
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
  */
@@ -1707,7 +1719,7 @@ export interface ApiRowChildMethods<T> {
1707
1719
  * @param showRemove This parameter can be given as true or false
1708
1720
  * @returns DataTables Api instance.
1709
1721
  */
1710
- (showRemove: boolean): RowChildMethods<T> | Api<T>;
1722
+ (showRemove: boolean): RowChildMethods<T>;
1711
1723
 
1712
1724
  /**
1713
1725
  * Set the data to show in the child row(s). Note that calling this method will replace any child rows which are already attached to the parent row.
@@ -1716,7 +1728,7 @@ export interface ApiRowChildMethods<T> {
1716
1728
  * @param className Class name that is added to the td cell node(s) of the child row(s). As of 1.10.1 it is also added to the tr row node of the child row(s).
1717
1729
  * @returns DataTables Api instance
1718
1730
  */
1719
- (data: (string | Node | JQuery) | Array<(string | number | JQuery)>, className?: string): RowChildMethods<T> | Api<T>;
1731
+ (data: (string | Node | JQuery) | Array<(string | number | JQuery)>, className?: string): RowChildMethods<T>;
1720
1732
 
1721
1733
  /**
1722
1734
  * Hide the child row(s) of a parent row
@@ -2113,10 +2125,10 @@ 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
- registerPlural<T=any>(name: string, fn: Function): T;
2131
+ registerPlural<T=any>(pluralName: string, singleName: string, fn: Function): T;
2120
2132
  }
2121
2133
 
2122
2134
  export interface OrderFixed {