daterangepicker-4.x 4.3.2 → 4.4.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.
- package/README.md +7 -4
- package/daterangepicker.css +12 -0
- package/daterangepicker.js +52 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
18
18
|
```html
|
|
19
19
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
20
20
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
21
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.
|
|
22
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.
|
|
21
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.4.0/daterangepicker.min.js"></script>
|
|
22
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.4.0/daterangepicker.min.css" rel="stylesheet" />
|
|
23
23
|
|
|
24
24
|
<input type="text" id="daterange" />
|
|
25
25
|
|
|
@@ -91,7 +91,7 @@ isInvalidDate: function(date) {
|
|
|
91
91
|
Compared to [inital repository](https://github.com/dangrossman/daterangepicker), this fork added following features and changes:
|
|
92
92
|
|
|
93
93
|
- Replaced [moment](https://momentjs.com/) by [luxon](https://moment.github.io/luxon/index.html) (see differences below)
|
|
94
|
-
- Added
|
|
94
|
+
- Added option `weekendClasses`, `weekendDayClasses`, `todayClasses` to highlight weekend days or today, respectively
|
|
95
95
|
- Added option `timePickerStepSize` to succeed options `timePickerIncrement` and `timePickerSeconds`
|
|
96
96
|
- Added events `dateChange.daterangepicker` and `timeChange.daterangepicker` emitted when user clicks on a date/time
|
|
97
97
|
- Added event `beforeHide.daterangepicker` enables you to keep the picker visible after click on `Apply` or `Cancel` button.
|
|
@@ -545,7 +545,10 @@ Options for DateRangePicker
|
|
|
545
545
|
| isCustomDate | <code>function</code> | <code>false</code> | A function that is passed each date in the two calendars before they are displayed, and may return a string or array of CSS class names to apply to that date's calendar cell.<br/> Signature: `isCustomDate(date)` |
|
|
546
546
|
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
547
547
|
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
548
|
-
| buttonClasses | <code>string</code> | <code>"btn"</code> | btn-sm - CSS class names that will be added to both the apply and cancel buttons. |
|
|
548
|
+
| buttonClasses | <code>string</code> | <code>"\"btn"</code> | btn-sm" - CSS class names that will be added to both the apply and cancel buttons. |
|
|
549
|
+
| weekendClasses | <code>string</code> | <code>"weekend"</code> | CSS class names that will be used to highlight weekend (Saturday+Sunday) days.<br/> Use `null` or empty string if you don't like to highlight weekend days. |
|
|
550
|
+
| weekendDayClasses | <code>string</code> | <code>"weekend-day"</code> | CSS class names that will be used to highlight weekend (Saturday+Sunday) day names.<br/> Use `null` or empty string if you don't like to highlight weekend day names. |
|
|
551
|
+
| todayClasses | <code>string</code> | <code>"today"</code> | CSS class names that will be used to highlight the current day.<br/> Use `null` or empty string if you don't like to highlight the current day. |
|
|
549
552
|
| opens | <code>string</code> | <code>"right"</code> | Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to.<br/> `'left' \| 'right' \| 'center'` |
|
|
550
553
|
| drops | <code>string</code> | <code>"down"</code> | Whether the picker appears below or above the HTML element it's attached to.<br/> `'down' \| 'up' \| 'auto'` |
|
|
551
554
|
| ranges | <code>object</code> | <code>{}</code> | Set predefined date [Ranges](#Ranges) the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range. |
|
package/daterangepicker.css
CHANGED
|
@@ -357,6 +357,18 @@
|
|
|
357
357
|
color: #fff;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
.daterangepicker td.weekend {
|
|
361
|
+
color: red
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.daterangepicker th.weekend-day {
|
|
365
|
+
color: red
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.daterangepicker td.today {
|
|
369
|
+
color: blue
|
|
370
|
+
}
|
|
371
|
+
|
|
360
372
|
/* Larger Screen Styling */
|
|
361
373
|
@media (min-width: 564px) {
|
|
362
374
|
.daterangepicker {
|
package/daterangepicker.js
CHANGED
|
@@ -113,7 +113,14 @@
|
|
|
113
113
|
|
|
114
114
|
* @property {string} applyButtonClasses=btn-primary - CSS class names that will be added only to the apply button
|
|
115
115
|
* @property {string} cancelButtonClasses=btn-default - CSS class names that will be added only to the cancel button
|
|
116
|
-
* @property {string} buttonClasses=btn btn-sm - CSS class names that will be added to both the apply and cancel buttons.
|
|
116
|
+
* @property {string} buttonClasses="btn btn-sm" - CSS class names that will be added to both the apply and cancel buttons.
|
|
117
|
+
* @property {string} weekendClasses=weekend - CSS class names that will be used to highlight weekend (Saturday+Sunday) days.<br/>
|
|
118
|
+
* Use `null` or empty string if you don't like to highlight weekend days.
|
|
119
|
+
* @property {string} weekendDayClasses=weekend-day - CSS class names that will be used to highlight weekend (Saturday+Sunday) day names.<br/>
|
|
120
|
+
* Use `null` or empty string if you don't like to highlight weekend day names.
|
|
121
|
+
* @property {string} todayClasses=today - CSS class names that will be used to highlight the current day.<br/>
|
|
122
|
+
* Use `null` or empty string if you don't like to highlight the current day.
|
|
123
|
+
|
|
117
124
|
* @property {string} opens=right - Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to.<br/>
|
|
118
125
|
* `'left' \| 'right' \| 'center'`
|
|
119
126
|
* @property {string} drops=down - Whether the picker appears below or above the HTML element it's attached to.<br/>
|
|
@@ -207,6 +214,9 @@
|
|
|
207
214
|
this.buttonClasses = 'btn btn-sm';
|
|
208
215
|
this.applyButtonClasses = 'btn-primary';
|
|
209
216
|
this.cancelButtonClasses = 'btn-default';
|
|
217
|
+
this.weekendClasses = 'weekend';
|
|
218
|
+
this.weekendDayClasses = 'weekend-day';
|
|
219
|
+
this.todayClasses = 'today';
|
|
210
220
|
this.warnings = true;
|
|
211
221
|
this.ranges = {};
|
|
212
222
|
|
|
@@ -319,9 +329,12 @@
|
|
|
319
329
|
this[key] = options[key];
|
|
320
330
|
}
|
|
321
331
|
|
|
322
|
-
for (let key of ['applyButtonClasses', 'cancelButtonClasses']) {
|
|
323
|
-
if (typeof options[key] === 'string')
|
|
332
|
+
for (let key of ['applyButtonClasses', 'cancelButtonClasses', 'weekendClasses', 'weekendDayClasses', 'todayClasses']) {
|
|
333
|
+
if (typeof options[key] === 'string') {
|
|
334
|
+
this[key] = options[key];
|
|
335
|
+
} else if (['weekendClasses', 'weekendDayClasses', 'todayClasses'].includes(key) && options[key] === null) {
|
|
324
336
|
this[key] = options[key];
|
|
337
|
+
}
|
|
325
338
|
}
|
|
326
339
|
|
|
327
340
|
for (let key of ['minYear', 'maxYear']) {
|
|
@@ -693,6 +706,18 @@
|
|
|
693
706
|
if (isValid === undefined || !isValid)
|
|
694
707
|
this.constrainDate();
|
|
695
708
|
|
|
709
|
+
if (!this.singleDatePicker) {
|
|
710
|
+
if (this.locale.durationFormat)
|
|
711
|
+
this.container.find('.drp-duration-label').html('');
|
|
712
|
+
if (typeof this.locale.format === 'object') {
|
|
713
|
+
const empty = `<span style="color: rgb(0,0,0,0);">${this.startDate.toLocaleString(this.locale.format)}</span>`;
|
|
714
|
+
this.container.find('.drp-selected').html(this.startDate.toLocaleString(this.locale.format) + this.locale.separator + empty);
|
|
715
|
+
} else {
|
|
716
|
+
const empty = `<span style="color: rgb(0,0,0,0);">${this.startDate.toFormat(this.locale.format)}</span>`;
|
|
717
|
+
this.container.find('.drp-selected').html(this.startDate.toFormat(this.locale.format) + this.locale.separator + empty);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
696
721
|
if (!this.isShowing)
|
|
697
722
|
this.updateElement();
|
|
698
723
|
|
|
@@ -746,19 +771,21 @@
|
|
|
746
771
|
|
|
747
772
|
this.previousRightTime = this.endDate;
|
|
748
773
|
|
|
749
|
-
if (
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
774
|
+
if (!this.singleDatePicker) {
|
|
775
|
+
if (this.locale.durationFormat) {
|
|
776
|
+
const duration = this.endDate.diff(this.startDate).rescale();
|
|
777
|
+
if (typeof this.locale.durationFormat === 'object') {
|
|
778
|
+
this.container.find('.drp-duration-label').html(duration.toHuman(this.locale.durationFormat));
|
|
779
|
+
} else {
|
|
780
|
+
this.container.find('.drp-duration-label').html(duration.toFormat(this.locale.durationFormat));
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (typeof this.locale.format === 'object') {
|
|
784
|
+
this.container.find('.drp-selected').html(this.startDate.toLocaleString(this.locale.format) + this.locale.separator + this.endDate.toLocaleString(this.locale.format));
|
|
753
785
|
} else {
|
|
754
|
-
this.container.find('.drp-
|
|
786
|
+
this.container.find('.drp-selected').html(this.startDate.toFormat(this.locale.format) + this.locale.separator + this.endDate.toFormat(this.locale.format));
|
|
755
787
|
}
|
|
756
788
|
}
|
|
757
|
-
if (typeof this.locale.format === 'object') {
|
|
758
|
-
this.container.find('.drp-selected').html(this.startDate.toLocaleString(this.locale.format) + this.locale.separator + this.endDate.toLocaleString(this.locale.format));
|
|
759
|
-
} else {
|
|
760
|
-
this.container.find('.drp-selected').html(this.startDate.toFormat(this.locale.format) + this.locale.separator + this.endDate.toFormat(this.locale.format));
|
|
761
|
-
}
|
|
762
789
|
|
|
763
790
|
if (!this.isShowing)
|
|
764
791
|
this.updateElement();
|
|
@@ -1265,16 +1292,15 @@
|
|
|
1265
1292
|
|
|
1266
1293
|
// add week number label
|
|
1267
1294
|
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
|
1268
|
-
html +=
|
|
1295
|
+
html += `<th class="week">${this.locale.weekLabel}</th>`;
|
|
1269
1296
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1297
|
+
for (let [index, dayOfWeek] of this.locale.daysOfWeek.entries()) {
|
|
1298
|
+
html += '<th';
|
|
1299
|
+
if (this.weekendDayClasses && this.weekendDayClasses.length && Info.getWeekendWeekdays().includes(index + 1))
|
|
1272
1300
|
//highlight weekend day
|
|
1273
|
-
html +=
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1301
|
+
html += ` class="${this.weekendDayClasses}"`;
|
|
1302
|
+
html += `>${dayOfWeek}</th>`;
|
|
1303
|
+
};
|
|
1278
1304
|
|
|
1279
1305
|
html += '</tr>';
|
|
1280
1306
|
html += '</thead>';
|
|
@@ -1304,16 +1330,15 @@
|
|
|
1304
1330
|
html += '<td class="week">' + calendar[row][0].localWeekNumber + '</td>';
|
|
1305
1331
|
|
|
1306
1332
|
for (let col = 0; col < 7; col++) {
|
|
1307
|
-
|
|
1308
1333
|
var classes = [];
|
|
1309
1334
|
|
|
1310
1335
|
//highlight today's date
|
|
1311
|
-
if (calendar[row][col].hasSame(DateTime.now(), 'day'))
|
|
1312
|
-
classes.push(
|
|
1336
|
+
if (this.todayClasses && this.todayClasses.length && calendar[row][col].hasSame(DateTime.now(), 'day'))
|
|
1337
|
+
classes.push(this.todayClasses);
|
|
1313
1338
|
|
|
1314
1339
|
//highlight weekends
|
|
1315
|
-
if (Info.getWeekendWeekdays().includes(calendar[row][col].weekday))
|
|
1316
|
-
classes.push(
|
|
1340
|
+
if (this.weekendClasses && this.weekendClasses.length && Info.getWeekendWeekdays().includes(calendar[row][col].weekday))
|
|
1341
|
+
classes.push(this.weekendClasses);
|
|
1317
1342
|
|
|
1318
1343
|
//grey out the dates in other months displayed at beginning and end of this calendar
|
|
1319
1344
|
if (calendar[row][col].month != calendar[1][1].month)
|
|
@@ -2372,6 +2397,7 @@
|
|
|
2372
2397
|
updateElement: function () {
|
|
2373
2398
|
if (this.startDate == null && this.initalMonth)
|
|
2374
2399
|
return;
|
|
2400
|
+
|
|
2375
2401
|
if (this.element.is('input')) {
|
|
2376
2402
|
let newValue = typeof this.locale.format === 'object' ? this.startDate.toLocaleString(this.locale.format) : this.startDate.toFormat(this.locale.format);
|
|
2377
2403
|
if (!this.singleDatePicker) {
|