@wernfried/daterangepicker 5.7.1 → 5.8.1

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/API_Doc.md CHANGED
@@ -119,8 +119,8 @@ Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <co
119
119
  * [.updateAltInput()](#DateRangePicker+updateAltInput)
120
120
  * [.remove()](#DateRangePicker+remove)
121
121
  * [.triggerEvent(ev, ...args)](#DateRangePicker+triggerEvent)
122
- * [.addEventListener(type, listener, [options])](#DateRangePicker+addEventListener)
123
- * [.removeEventListener(type, listener, [options])](#DateRangePicker+removeEventListener)
122
+ * [.addEventListener(type, listener, [options])](#DateRangePicker+addEventListener) ⇒ [<code>DateRangePicker</code>](#DateRangePicker)
123
+ * [.removeEventListener(type, listener, [options])](#DateRangePicker+removeEventListener) ⇒ [<code>DateRangePicker</code>](#DateRangePicker)
124
124
 
125
125
  <a name="new_DateRangePicker_new"></a>
126
126
 
@@ -376,11 +376,12 @@ Helper function to dispatch events
376
376
 
377
377
  <a name="DateRangePicker+addEventListener"></a>
378
378
 
379
- ### dateRangePicker.addEventListener(type, listener, [options])
379
+ ### dateRangePicker.addEventListener(type, listener, [options]) ⇒ [<code>DateRangePicker</code>](#DateRangePicker)
380
380
  Adding event listener to input element where dateragnepicker is attached to.
381
381
  Wrapper to give easy access for `addEventListener()` on DateRangePicker instance.
382
382
 
383
383
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
384
+ **Returns**: [<code>DateRangePicker</code>](#DateRangePicker) - - The DateRangePicker instance, usefull for chaining
384
385
 
385
386
  | Param | Type | Description |
386
387
  | --- | --- | --- |
@@ -396,11 +397,12 @@ picker.addEventListener('hide', (e) => {
396
397
  ```
397
398
  <a name="DateRangePicker+removeEventListener"></a>
398
399
 
399
- ### dateRangePicker.removeEventListener(type, listener, [options])
400
+ ### dateRangePicker.removeEventListener(type, listener, [options]) ⇒ [<code>DateRangePicker</code>](#DateRangePicker)
400
401
  Counterpart to `addEventListener()`
401
402
  Note, `listener` most be a named function to enable remove.
402
403
 
403
404
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
405
+ **Returns**: [<code>DateRangePicker</code>](#DateRangePicker) - - The DateRangePicker instance, usefull for chaining
404
406
 
405
407
  | Param | Type | Description |
406
408
  | --- | --- | --- |
@@ -712,8 +714,8 @@ Options for DateRangePicker
712
714
  | isInvalidDate | <code>function</code> | <code>false</code> | A function that is passed each date in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidDate(date)`<br> |
713
715
  | isInvalidTime | <code>function</code> | <code>false</code> | A function that is passed each hour/minute/second/am-pm in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidTime(time, side, unit)`<br> `side` is `'start'` or `'end'` or `null` for `singleDatePicker: true`<br> `unit` is `'hour'`, `'minute'`, `'second'` or `'ampm'`<br> Hours are always given as 24-hour clock<br> Ensure that your function returns `false` for at least one item. Otherwise the calender is not rendered.<br> |
714
716
  | 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)` |
715
- | altInput | <code>string</code> \| <code>Array</code> \| [<code>HTMLInputElement</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | <code>null</code> | A [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors)<br> string or `HTMLElement` for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string/HTMLElement for `singleDatePicker: true` or an array of two strings or HTMLElement for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
716
- | altFormat | <code>function</code> \| <code>string</code> | | The output format used for `altInput`.<br> Default: ISO-8601 basic format without time zone, precisison is derived from `timePicker` and `timePickerStepSize`<br> Example `yyyyMMdd'T'HHmm` for `timePicker=true` and display of Minutes<br> If defined, either a string used with [Format tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or a function.<br> Examples: `"yyyy:MM:dd'T'HH:mm"`,<br>`(date) => date.toUnixInteger()` |
717
+ | altInput | <code>string</code> \| <code>Array</code> \| [<code>HTMLInputElement</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) \| [<code>HTMLCollection</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) | <code>null</code> | A [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors)<br> string matching a single `<input>` element or an `HTMLInputElement` for the alternative output. Uses `altFormat` to format the value.<br> For `singleDatePicker: false` you may provide:<br> - A CSS querySelector string matching exactly two `<input>` elements (e.g., `'.start-date, .end-date'`)<br> - An array of two strings or `HTMLInputElement` elements<br> - An `HTMLCollection` of two `HTMLInputElement` elements<br> Uses `altFormat` to format the values.<br> Examples: `'#start, #end'`, `['#start', '#end']`, or `[startInput, endInput]` |
718
+ | altFormat | <code>function</code> \| <code>string</code> \| <code>object</code> | | The output format used for `altInput`.<br> Either a string of [Format tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or [DateTime.toISO()](https://moment.github.io/luxon/api-docs/index.html#datetimetoiso) opts object or a function.<br> Default: `{format: 'extended', precision: <derived from timePickerStepSize>, includeOffset: false}`<br> Examples: `"yyyy:MM:dd'T'HH:mm"`<br> `(date) => date.toUnixInteger()` for singleDatePicker: true or altInput[]<br> `(interval) => interval.toISO('yyyy:MM:dd', {separator: '..'})` for singleDatePicker: false and single altInput |
717
719
  | applyButtonClasses | <code>string</code> | <code>&quot;btn-primary&quot;</code> | CSS class names that will be added only to the apply button |
718
720
  | cancelButtonClasses | <code>string</code> | <code>&quot;btn-default&quot;</code> | CSS class names that will be added only to the cancel button |
719
721
  | buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
package/README.md CHANGED
@@ -19,8 +19,8 @@ Above samples are based on the [original repository](https://github.com/dangross
19
19
  #### Global import with `<script>` tags
20
20
  ```html
21
21
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
22
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/dist/global/daterangepicker.min.js"></script>
23
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/css/daterangepicker.min.css" rel="stylesheet" />
22
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/dist/global/daterangepicker.min.js"></script>
23
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/css/daterangepicker.min.css" rel="stylesheet" />
24
24
 
25
25
  <input type="text" id="picker" />
26
26
 
@@ -40,11 +40,11 @@ Above samples are based on the [original repository](https://github.com/dangross
40
40
  {
41
41
  "imports": {
42
42
  "luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
43
- "daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/+esm"
43
+ "daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/+esm"
44
44
  }
45
45
  }
46
46
  </script>
47
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/css/daterangepicker.min.css" rel="stylesheet" />
47
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/css/daterangepicker.min.css" rel="stylesheet" />
48
48
 
49
49
  <input type="text" id="picker" />
50
50
 
@@ -63,9 +63,9 @@ Above samples are based on the [original repository](https://github.com/dangross
63
63
  #### Style with Bulma
64
64
  ```html
65
65
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
66
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/dist/global/daterangepicker.min.js"></script>
66
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/dist/global/daterangepicker.min.js"></script>
67
67
  <link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
68
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/css/daterangepicker.bulma.min.css" rel="stylesheet" />
68
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/css/daterangepicker.bulma.min.css" rel="stylesheet" />
69
69
 
70
70
  <input type="text" id="picker" />
71
71
 
@@ -122,8 +122,8 @@ Initialisation with jQuery is supported in version 5.x
122
122
  ```html
123
123
  <script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
124
124
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
125
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/dist/global/daterangepicker.min.js"></script>
126
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.7.1/css/daterangepicker.min.css" rel="stylesheet" />
125
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/dist/global/daterangepicker.min.js"></script>
126
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.8.1/css/daterangepicker.min.css" rel="stylesheet" />
127
127
 
128
128
  <input type="text" id="picker" />
129
129
 
@@ -377,8 +377,8 @@ Options for DateRangePicker
377
377
  | isInvalidDate | <code>function</code> | <code>false</code> | A function that is passed each date in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidDate(date)`<br> |
378
378
  | isInvalidTime | <code>function</code> | <code>false</code> | A function that is passed each hour/minute/second/am-pm in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidTime(time, side, unit)`<br> `side` is `'start'` or `'end'` or `null` for `singleDatePicker: true`<br> `unit` is `'hour'`, `'minute'`, `'second'` or `'ampm'`<br> Hours are always given as 24-hour clock<br> Ensure that your function returns `false` for at least one item. Otherwise the calender is not rendered.<br> |
379
379
  | 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)` |
380
- | altInput | <code>string</code> \| <code>Array</code> \| [<code>HTMLInputElement</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | <code>null</code> | A [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors)<br> string or `HTMLElement` for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string/HTMLElement for `singleDatePicker: true` or an array of two strings or HTMLElement for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
381
- | altFormat | <code>function</code> \| <code>string</code> | | The output format used for `altInput`.<br> Default: ISO-8601 basic format without time zone, precisison is derived from `timePicker` and `timePickerStepSize`<br> Example `yyyyMMdd'T'HHmm` for `timePicker=true` and display of Minutes<br> If defined, either a string used with [Format tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or a function.<br> Examples: `"yyyy:MM:dd'T'HH:mm"`,<br>`(date) => date.toUnixInteger()` |
380
+ | altInput | <code>string</code> \| <code>Array</code> \| [<code>HTMLInputElement</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) \| [<code>HTMLCollection</code>](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) | <code>null</code> | A [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors)<br> string matching a single `<input>` element or an `HTMLInputElement` for the alternative output. Uses `altFormat` to format the value.<br> For `singleDatePicker: false` you may provide:<br> - A CSS querySelector string matching exactly two `<input>` elements (e.g., `'.start-date, .end-date'`)<br> - An array of two strings or `HTMLInputElement` elements<br> - An `HTMLCollection` of two `HTMLInputElement` elements<br> Uses `altFormat` to format the values.<br> Examples: `'#start, #end'`, `['#start', '#end']`, or `[startInput, endInput]` |
381
+ | altFormat | <code>function</code> \| <code>string</code> \| <code>object</code> | | The output format used for `altInput`.<br> Either a string of [Format tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or [DateTime.toISO()](https://moment.github.io/luxon/api-docs/index.html#datetimetoiso) opts object or a function.<br> Default: `{format: 'extended', precision: <derived from timePickerStepSize>, includeOffset: false}`<br> Examples: `"yyyy:MM:dd'T'HH:mm"`<br> `(date) => date.toUnixInteger()` for singleDatePicker: true or altInput[]<br> `(interval) => interval.toISO('yyyy:MM:dd', {separator: '..'})` for singleDatePicker: false and single altInput |
382
382
  | applyButtonClasses | <code>string</code> | <code>&quot;btn-primary&quot;</code> | CSS class names that will be added only to the apply button |
383
383
  | cancelButtonClasses | <code>string</code> | <code>&quot;btn-default&quot;</code> | CSS class names that will be added only to the cancel button |
384
384
  | buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
@@ -413,27 +413,33 @@ class DateRangePicker {
413
413
  }
414
414
  }
415
415
  }
416
- if (this.singleDatePicker) {
417
- if (typeof options.altInput === "string") {
416
+ if (["function", "string", "object"].includes(typeof options.altFormat))
417
+ this.altFormat = options.altFormat;
418
+ if (typeof options.altInput === "string") {
419
+ if (this.singleDatePicker) {
418
420
  const el = document.querySelector(options.altInput);
419
- this.altInput = el instanceof HTMLInputElement && ["text", "hidden"].includes(el.type) ? el : null;
420
- } else if (options.altInput instanceof HTMLElement) {
421
- this.altInput = options.altInput instanceof HTMLInputElement && ["text", "hidden"].includes(options.altInput.type) ? options.altInput : null;
422
- }
423
- } else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length === 2) {
424
- this.altInput = [];
425
- for (let item of options.altInput) {
426
- const el = typeof item === "string" ? document.querySelector(item) : item;
427
421
  if (el instanceof HTMLInputElement && ["text", "hidden"].includes(el.type))
428
- this.altInput.push(el);
429
- }
430
- if (this.altInput.length !== 2)
431
- this.altInput = null;
432
- } else if (options.altInput != null) {
433
- console.warn(`Option 'altInput' ${JSON.stringify(options.altInput)} is not valid`);
434
- }
435
- if (options.altInput && ["function", "string"].includes(typeof options.altFormat))
436
- this.altFormat = options.altFormat;
422
+ this.altInput = el;
423
+ } else {
424
+ const el = Array.from(document.querySelectorAll(options.altInput));
425
+ if ([1, 2].includes(el.length) && el.every((x) => x instanceof HTMLInputElement && ["text", "hidden"].includes(x.type)))
426
+ this.altInput = el.length === 1 ? el[0] : el;
427
+ }
428
+ } else if (options.altInput instanceof HTMLElement && ["text", "hidden"].includes(options.altInput.type)) {
429
+ this.altInput = options.altInput;
430
+ } else if (Array.isArray(options.altInput) || options.altInput instanceof HTMLCollection || options.altInput instanceof NodeList) {
431
+ let el = Array.isArray(options.altInput) ? options.altInput : Array.from(options.altInput);
432
+ if (!this.singleDatePicker && el.length === 2) {
433
+ if (el.every((x) => typeof x === "string"))
434
+ el = el.map((x) => {
435
+ return document.querySelector(x);
436
+ });
437
+ if (el.every((x) => x instanceof HTMLInputElement && ["text", "hidden"].includes(x.type)))
438
+ this.altInput = el;
439
+ }
440
+ }
441
+ if (options.altInput != null && this.altInput == null)
442
+ console.error(`Option 'altInput' ${JSON.stringify(options.altInput)} is not valid`);
437
443
  if (typeof options.opens === "string") {
438
444
  if (["left", "right", "center"].includes(options.opens))
439
445
  this.opens = options.opens;
@@ -876,24 +882,41 @@ class DateRangePicker {
876
882
  * @param {sting|external:DateTime|Date} month - The month to be shown, if null then current month is selected.
877
883
  */
878
884
  clearDate(month) {
879
- const initialMonth = this.parseDate(month ?? this.#startDate.startOf("month"));
885
+ if (this.#startDate == null && this.#endDate == null)
886
+ return;
887
+ const monthChange = month !== void 0 && !this.parseDate(month).hasSame(this.#startDate, "month");
888
+ if (monthChange)
889
+ this.#startDate = this.parseDate(month);
890
+ this.updateMonthsInView();
880
891
  this.oldStartDate = this.#startDate;
881
892
  this.oldEndDate = this.#endDate;
882
893
  this.#startDate = null;
883
894
  this.#endDate = null;
895
+ this.updateCalendars(monthChange);
896
+ this.setApplyBtnState();
897
+ if (this.timePicker) {
898
+ this.triggerEvent(this.#events.onBeforeRenderTimePicker);
899
+ this.renderTimePicker("start");
900
+ this.renderTimePicker("end");
901
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
902
+ el.disabled = !this.#endDate;
903
+ });
904
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
905
+ el.classList.toggle("disabled", !this.#endDate);
906
+ });
907
+ }
884
908
  if (this.isInputText)
885
909
  this.element.value = "";
886
910
  if (!this.singleDatePicker)
887
911
  this.chosenLabel = null;
888
912
  if (this.altInput) {
889
- if (this.singleDatePicker) {
913
+ if (this.singleDatePicker || !Array.isArray(this.altInput)) {
890
914
  this.altInput.value = "";
891
915
  } else {
892
916
  this.altInput[0].value = "";
893
917
  this.altInput[1].value = "";
894
918
  }
895
919
  }
896
- this.updateView(!initialMonth.hasSame(this.oldStartDate, "month"));
897
920
  }
898
921
  /**
899
922
  * Parse date value
@@ -2300,7 +2323,7 @@ class DateRangePicker {
2300
2323
  updateAltInput() {
2301
2324
  if (this.altInput == null)
2302
2325
  return;
2303
- if (this.altFormat == null) {
2326
+ if (this.altFormat == null || typeof this.altFormat === "object") {
2304
2327
  let precision = "day";
2305
2328
  if (this.timePicker) {
2306
2329
  if (this.timePickerOpts.showSeconds) {
@@ -2311,18 +2334,37 @@ class DateRangePicker {
2311
2334
  precision = "hour";
2312
2335
  }
2313
2336
  }
2314
- const startDate = this.#startDate.toISO({ format: "basic", precision, includeOffset: false });
2315
- (this.singleDatePicker ? this.altInput : this.altInput[0]).value = startDate;
2316
- if (!this.singleDatePicker && this.#endDate) {
2317
- const endDate = this.#endDate.toISO({ format: "basic", precision, includeOffset: false });
2318
- this.altInput[1].value = endDate;
2337
+ const isoOptions = this.altFormat ?? { format: "basic", precision, includeOffset: false };
2338
+ const startDate = this.#startDate.toISO(isoOptions);
2339
+ if (this.singleDatePicker) {
2340
+ this.altInput.value = startDate;
2341
+ } else if (this.#endDate) {
2342
+ const endDate = this.#endDate.toISO(isoOptions);
2343
+ if (Array.isArray(this.altInput)) {
2344
+ this.altInput[0].value = startDate;
2345
+ this.altInput[1].value = endDate;
2346
+ } else {
2347
+ const interval = luxon.Interval.fromDateTimes(this.#startDate, this.#endDate);
2348
+ this.altInput.value = interval.toISO(isoOptions);
2349
+ }
2319
2350
  }
2320
2351
  } else {
2321
- const startDate = typeof this.altFormat === "function" ? this.altFormat(this.#startDate) : this.formatDate(this.#startDate, this.altFormat);
2322
- (this.singleDatePicker ? this.altInput : this.altInput[0]).value = startDate;
2323
- if (!this.singleDatePicker && this.#endDate) {
2324
- const endDate = typeof this.altFormat === "function" ? this.altFormat(this.#endDate) : this.formatDate(this.#endDate, this.altFormat);
2325
- this.altInput[1].value = endDate;
2352
+ const startDate = typeof this.altFormat === "function" ? this.altFormat(this.#startDate) : this.toFormat(this.#startDate, this.altFormat);
2353
+ if (this.singleDatePicker) {
2354
+ this.altInput.value = startDate;
2355
+ } else if (this.#endDate) {
2356
+ const endDate = typeof this.altFormat === "function" ? this.altFormat(this.#endDate) : this.toFormat(this.#endDate, this.altFormat);
2357
+ if (Array.isArray(this.altInput)) {
2358
+ this.altInput[0].value = startDate;
2359
+ this.altInput[1].value = endDate;
2360
+ } else {
2361
+ const interval = luxon.Interval.fromDateTimes(this.#startDate, this.#endDate);
2362
+ if (typeof this.altFormat === "function") {
2363
+ this.altInput.value = this.altFormat(interval);
2364
+ } else {
2365
+ this.altInput.value = this.toFormat(interval, this.altFormat, { separator: "/" });
2366
+ }
2367
+ }
2326
2368
  }
2327
2369
  }
2328
2370
  }
@@ -2384,6 +2426,7 @@ class DateRangePicker {
2384
2426
  * @param {boolean|object} [options] - Optional event options:
2385
2427
  * - `boolean capture`: Whether to listen in the capture phase (default: `false`)
2386
2428
  * - `object signal`: An `AbortSignal` for later removal of the listener (default: `undefined`)
2429
+ * @returns {DateRangePicker} - The DateRangePicker instance, usefull for chaining
2387
2430
  *
2388
2431
  * @example
2389
2432
  * picker.addEventListener('hide', (e) => {
@@ -2393,6 +2436,7 @@ class DateRangePicker {
2393
2436
  */
2394
2437
  addEventListener(type, listener, options) {
2395
2438
  this.element.addEventListener(type, listener, options);
2439
+ return this;
2396
2440
  }
2397
2441
  /**
2398
2442
  * Counterpart to `addEventListener()`
@@ -2403,9 +2447,11 @@ class DateRangePicker {
2403
2447
  * @param {boolean|object} [options] - Optional event options:
2404
2448
  * - `boolean capture`: Whether to listen in the capture phase (default: `false`)
2405
2449
  * - `object signal`: An `AbortSignal` for later removal of the listener (default: `undefined`)
2406
- */
2450
+ * @returns {DateRangePicker} - The DateRangePicker instance, usefull for chaining
2451
+ */
2407
2452
  removeEventListener(type, listener, options) {
2408
2453
  this.element.removeEventListener(type, listener, options);
2454
+ return this;
2409
2455
  }
2410
2456
  }
2411
2457
  function createElementFromHTML(html) {