datatables.net-datetime 1.1.2 → 1.2.0

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.
@@ -9,7 +9,7 @@
9
9
  </default>
10
10
 
11
11
  <description>
12
- When enabled, this option will cause DateTime to show a button (text set by `dt-init i18n.today`) which the end user can activate to shift the calendar view to show today's date.
12
+ When enabled, this option will cause DateTime to show a button (text set by `de-init i18n.today`) which the end user can activate to shift the calendar view to show today's date.
13
13
 
14
14
  Note that the value of the field does not change when activating this button.
15
15
  </description>
@@ -7,7 +7,7 @@
7
7
  <![CDATA[
8
8
 
9
9
  $(document).ready(function() {
10
- new DateTime(document.getElementById('test'), {
10
+ window.d = new DateTime(document.getElementById('test'), {
11
11
  format: 'D MMM YYYY HH:mm'
12
12
  });
13
13
  });
@@ -2,15 +2,17 @@
2
2
  <dt-example table-type="html" table-class="display nowrap" order="9">
3
3
 
4
4
  <css lib="datetime"/>
5
- <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.8.17/dayjs.min.js"/>
6
- <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.8.17/plugin/utc.js"/>
5
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/dayjs.min.js"/>
6
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/plugin/utc.js"/>
7
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/plugin/customParseFormat.min.js"/>
7
8
  <js lib="jquery datetime">
8
9
  <![CDATA[
9
10
 
10
11
  dayjs.extend(dayjs_plugin_utc);
12
+ dayjs.extend(dayjs_plugin_customParseFormat);
11
13
 
12
14
  $(document).ready(function() {
13
- new DateTime(document.getElementById('test'), {
15
+ window.allan = new DateTime(document.getElementById('test'), {
14
16
  format: 'D/M/YYYY'
15
17
  });
16
18
  });
@@ -23,12 +25,12 @@ $(document).ready(function() {
23
25
 
24
26
  This example shows the date / time input with [DayJS](https://github.com/iamkun/dayjs) used to provide the date / time formatting.
25
27
 
26
- Please note that you also need the DayJS `UTC` plugin.
28
+ Please note that you also need the DayJS `UTC` and `customParseFormat` plug-ins.
27
29
 
28
30
  ]]></info>
29
31
 
30
32
  <custom-table>
31
- <input id="test" type="text" value="17/1/2020" />
33
+ <input id="test" type="text" value="17/1/2022" />
32
34
  </custom-table>
33
35
 
34
36
  </dt-example>
@@ -1,53 +1,65 @@
1
+ // Type definitions for DataTables DateTime
2
+ //
3
+ // Project: https://datatables.net/extensions/datetime
4
+ // Definitions by:
5
+ // SpryMedia
1
6
 
2
- declare module 'datatables.net-datetime' {
3
- interface IDateTimeOptions {
4
- classPrefix?: string;
5
- disableDays?: number[] | null;
6
- firstDay?: number;
7
- format?: string;
8
- hoursAvailable?: number[] | null;
9
- i18n?: {
10
- previous?: string;
11
- next?: string;
12
- months?: string[];
13
- weekdays?: string[];
14
- amPm?: string[];
15
- hours?: string;
16
- minutes?: string;
17
- seconds?: string;
18
- unknown?: string;
19
- };
20
- maxDate?: Date | null;
21
- minDate?: Date | null;
22
- minutesAvailable?: number[] | null;
23
- strict?: boolean;
24
- locale?: string;
25
- onChange?: (value: string, date: Date, el: HTMLElement) => void;
26
- secondsAvailable?: number[] | null;
27
- showWeekNumber?: boolean;
28
- yearRange?: number;
29
- }
7
+ /// <reference types="jquery" />
30
8
 
31
- class DateTime {
32
- static use(moment: any); // Moment library
9
+ interface IDateTimeOptions {
10
+ classPrefix?: string;
11
+ disableDays?: number[] | null;
12
+ firstDay?: number;
13
+ format?: string;
14
+ hoursAvailable?: number[] | null;
15
+ i18n?: {
16
+ previous?: string;
17
+ next?: string;
18
+ months?: string[];
19
+ weekdays?: string[];
20
+ amPm?: string[];
21
+ hours?: string;
22
+ minutes?: string;
23
+ seconds?: string;
24
+ unknown?: string;
25
+ };
26
+ maxDate?: Date | null;
27
+ minDate?: Date | null;
28
+ minutesAvailable?: number[] | null;
29
+ strict?: boolean;
30
+ locale?: string;
31
+ onChange?: (value: string, date: Date, el: HTMLElement) => void;
32
+ secondsAvailable?: number[] | null;
33
+ showWeekNumber?: boolean;
34
+ yearRange?: number;
35
+ }
33
36
 
34
- constructor(el: HTMLElement, opts?: IDateTimeOptions);
35
-
36
- destroy(): void;
37
- errorMsg(): this;
38
- errorMsg(message: string): this;
39
- hide(): this;
40
- max(max: Date): this;
41
- main(min: Date): this;
42
- owns(el: HTMLElement): boolean;
43
- val(): Date;
44
- val(set: string | Date): this;
45
- }
37
+ export class DateTime {
38
+ static use(moment: any); // Moment library
46
39
 
47
- export = DateTime;
40
+ constructor(el: HTMLElement, opts?: IDateTimeOptions);
41
+
42
+ destroy(): void;
43
+ errorMsg(): this;
44
+ errorMsg(message: string): this;
45
+ hide(): this;
46
+ max(max: Date): this;
47
+ main(min: Date): this;
48
+ owns(el: HTMLElement): boolean;
49
+ val(): Date;
50
+ val(set: string | Date): this;
51
+ }
48
52
 
49
- // jQuery interface additions
50
- interface JQuery {
51
- dtDateTime(opts?: IDateTimeOptions): JQuery;
53
+ export default DateTime;
54
+
55
+ // jQuery interface additions
56
+ interface JQuery {
57
+ dtDateTime(opts?: IDateTimeOptions): JQuery;
58
+ }
59
+
60
+ // Also attached to DataTables object
61
+ declare module 'datatables.net-datetime' {
62
+ interface ApiStatic {
63
+ DataTime: DateTime;
52
64
  }
53
65
  }
@@ -1,4 +1,4 @@
1
- /*! DateTime picker for DataTables.net v1.1.2
1
+ /*! DateTime picker for DataTables.net v1.2.0
2
2
  *
3
3
  * © SpryMedia Ltd, all rights reserved.
4
4
  * License: MIT datatables.net/license/mit
@@ -6,34 +6,11 @@
6
6
 
7
7
  /**
8
8
  * @summary DateTime picker for DataTables.net
9
- * @version 1.1.2
9
+ * @version 1.2.0
10
10
  * @file dataTables.dateTime.js
11
11
  * @author SpryMedia Ltd
12
12
  * @contact www.datatables.net/contact
13
13
  */
14
- (function( factory ){
15
- if ( typeof define === 'function' && define.amd ) {
16
- // AMD
17
- define( ['jquery'], function ( $ ) {
18
- return factory( $, window, document );
19
- } );
20
- }
21
- else if ( typeof exports === 'object' ) {
22
- // CommonJS
23
- module.exports = function (root, $) {
24
- if ( ! root ) {
25
- root = window;
26
- }
27
-
28
- return factory( $, root, root.document );
29
- };
30
- }
31
- else {
32
- // Browser
33
- factory( jQuery, window, document );
34
- }
35
- }(function( $, window, document, undefined ) {
36
- 'use strict';
37
14
 
38
15
  // Supported formatting and parsing libraries:
39
16
  // * Moment
@@ -268,7 +245,7 @@ $.extend( DateTime.prototype, {
268
245
  this.s.d = null;
269
246
  }
270
247
  else if ( set === '--now' ) {
271
- this.s.d = new Date();
248
+ this.s.d = this._dateToUtc(new Date());
272
249
  }
273
250
  else if ( typeof set === 'string' ) {
274
251
  // luxon uses different method names so need to be able to call them
@@ -586,6 +563,7 @@ $.extend( DateTime.prototype, {
586
563
  'setSeconds';
587
564
 
588
565
  d[set]( val );
566
+ that._setCalander();
589
567
  that._setTime();
590
568
  that._writeOutput( true );
591
569
  onChange();
@@ -619,6 +597,7 @@ $.extend( DateTime.prototype, {
619
597
  }
620
598
  else {
621
599
  that._setCalander();
600
+ that._setTime();
622
601
  }
623
602
 
624
603
  onChange();
@@ -983,6 +962,13 @@ $.extend( DateTime.prototype, {
983
962
  _needValue: function () {
984
963
  if ( ! this.s.d ) {
985
964
  this.s.d = this._dateToUtc( new Date() );
965
+
966
+ if (! this.s.parts.time) {
967
+ this.s.d.setUTCHours(0);
968
+ this.s.d.setUTCMinutes(0);
969
+ this.s.d.setSeconds(0);
970
+ this.s.d.setMilliseconds(0);
971
+ }
986
972
  }
987
973
 
988
974
  return this.s.d;
@@ -1077,7 +1063,7 @@ $.extend( DateTime.prototype, {
1077
1063
  'selected' :
1078
1064
  '';
1079
1065
 
1080
- if (allowed && $.inArray(value, allowed) === -1) {
1066
+ if (typeof value === 'number' && allowed && $.inArray(value, allowed) === -1) {
1081
1067
  selected += ' disabled';
1082
1068
  }
1083
1069
 
@@ -1137,9 +1123,11 @@ $.extend( DateTime.prototype, {
1137
1123
  // Slight hack to allow for the different number of columns
1138
1124
  a += '</tbody></thead><table class="'+className+' '+className+'-nospace"><tbody>';
1139
1125
 
1140
- var start = range !== null ?
1141
- range :
1142
- Math.floor( val / 10 )*10;
1126
+ var start = range !== null
1127
+ ? range
1128
+ : val === -1
1129
+ ? 0
1130
+ : Math.floor( val / 10 )*10;
1143
1131
 
1144
1132
  a += '<tr>';
1145
1133
  for (j=start+1 ; j<start+10 ; j++ ) {
@@ -1327,7 +1315,7 @@ $.extend( DateTime.prototype, {
1327
1315
  ? luxDT.hour
1328
1316
  : d
1329
1317
  ? d.getUTCHours()
1330
- : 0;
1318
+ : -1;
1331
1319
 
1332
1320
  var allowed = function ( prop ) { // Backwards compt with `Increment` option
1333
1321
  return that.c[prop+'Available'] ?
@@ -1343,7 +1331,8 @@ $.extend( DateTime.prototype, {
1343
1331
  ? luxDT.minute
1344
1332
  : d
1345
1333
  ? d.getUTCMinutes()
1346
- : 0, allowed('minutes'),
1334
+ : -1,
1335
+ allowed('minutes'),
1347
1336
  this.s.minutesRange
1348
1337
  );
1349
1338
  this._optionsTime(
@@ -1353,7 +1342,7 @@ $.extend( DateTime.prototype, {
1353
1342
  ? luxDT.second
1354
1343
  : d
1355
1344
  ? d.getSeconds()
1356
- : 0,
1345
+ : -1,
1357
1346
  allowed('seconds'),
1358
1347
  this.s.secondsRange
1359
1348
  );
@@ -1535,7 +1524,7 @@ DateTime.defaults = {
1535
1524
  yearRange: 25
1536
1525
  };
1537
1526
 
1538
- DateTime.version = '1.1.2';
1527
+ DateTime.version = '1.2.0';
1539
1528
 
1540
1529
  // Global export - if no conflicts
1541
1530
  if (! window.DateTime) {
@@ -1558,7 +1547,3 @@ if ($.fn.dataTable) {
1558
1547
  $.fn.dataTable.Editor.DateTime = DateTime;
1559
1548
  }
1560
1549
  }
1561
-
1562
- return DateTime;
1563
-
1564
- }));
package/make.sh CHANGED
@@ -29,7 +29,7 @@ fi
29
29
 
30
30
  ./node_modules/gulp/bin/gulp.js
31
31
 
32
- js_compress dist/dataTables.dateTime.js
32
+ js_wrap dist/dataTables.dateTime.js "jquery"
33
33
  css_compress dist/dataTables.dateTime.css
34
34
 
35
35
  if [ ! -d $OUT_DIR ]; then
@@ -39,6 +39,7 @@ if [ ! -d $OUT_DIR ]; then
39
39
  fi
40
40
 
41
41
  rsync -r dist/*.js $OUT_DIR/js
42
+ rsync -r dist/*.mjs $OUT_DIR/js
42
43
  rsync -r dist/*.css $OUT_DIR/css
43
44
 
44
45
  # Copy and build examples
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "datatables.net-datetime",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "DateTime picker for DataTables.net",
5
5
  "main": "dist/dataTables.dateTime.js",
6
+ "module": "dist/dataTables.dateTime.mjs",
6
7
  "style": "dist/dataTables.dateTime.css",
7
8
  "types": "js/dataTables.dateTime.d.ts",
8
9
  "scripts": {