@vaadin/date-picker 23.3.3 → 24.0.0-alpha10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/date-picker",
3
- "version": "23.3.3",
3
+ "version": "24.0.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,14 +36,14 @@
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
38
  "@polymer/polymer": "^3.2.0",
39
- "@vaadin/button": "~23.3.3",
40
- "@vaadin/component-base": "~23.3.3",
41
- "@vaadin/field-base": "~23.3.3",
42
- "@vaadin/input-container": "~23.3.3",
43
- "@vaadin/overlay": "~23.3.3",
44
- "@vaadin/vaadin-lumo-styles": "~23.3.3",
45
- "@vaadin/vaadin-material-styles": "~23.3.3",
46
- "@vaadin/vaadin-themable-mixin": "~23.3.3"
39
+ "@vaadin/button": "24.0.0-alpha10",
40
+ "@vaadin/component-base": "24.0.0-alpha10",
41
+ "@vaadin/field-base": "24.0.0-alpha10",
42
+ "@vaadin/input-container": "24.0.0-alpha10",
43
+ "@vaadin/overlay": "24.0.0-alpha10",
44
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
45
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha10",
46
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@esm-bundle/chai": "^4.3.4",
@@ -54,5 +54,5 @@
54
54
  "web-types.json",
55
55
  "web-types.lit.json"
56
56
  ],
57
- "gitHead": "1529ed623e053d28a3c1c66af55ebe402743ddd0"
57
+ "gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
58
58
  }
@@ -42,6 +42,13 @@ export { extractDateParts };
42
42
  */
43
43
  declare function extractDateParts(date: Date): { day: number; month: number; year: number };
44
44
 
45
+ /**
46
+ * Get difference in months between today and given months value.
47
+ */
48
+ declare function dateAfterXMonths(months: number): number;
49
+
50
+ export { dateAfterXMonths };
51
+
45
52
  /**
46
53
  * Calculate the year of the date based on the provided reference date
47
54
  * Gets a two-digit year and returns a full year.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -104,6 +104,20 @@ export function extractDateParts(date) {
104
104
  };
105
105
  }
106
106
 
107
+ /**
108
+ * Get difference in months between today and given months value.
109
+ *
110
+ * @param {number} months
111
+ * @return {number}
112
+ */
113
+ export function dateAfterXMonths(months) {
114
+ const today = new Date();
115
+ const result = new Date(today);
116
+ result.setDate(1);
117
+ result.setMonth(parseInt(months) + today.getMonth());
118
+ return result;
119
+ }
120
+
107
121
  /**
108
122
  * Calculate the year of the date based on the provided reference date.
109
123
  * Gets a two-digit year and returns a full year.
@@ -139,7 +153,7 @@ export function getAdjustedYear(referenceDate, year, month = 0, day = 1) {
139
153
  */
140
154
  export function parseDate(str) {
141
155
  // Parsing with RegExp to ensure correct format
142
- const parts = /^([-+]\d{1}|\d{2,4}|[-+]\d{6})-(\d{1,2})-(\d{1,2})$/.exec(str);
156
+ const parts = /^([-+]\d{1}|\d{2,4}|[-+]\d{6})-(\d{1,2})-(\d{1,2})$/u.exec(str);
143
157
  if (!parts) {
144
158
  return undefined;
145
159
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ValidateMixin } from '@vaadin/field-base/src/validate-mixin.js';
@@ -66,12 +66,6 @@ export interface DatePickerLightEventMap extends HTMLElementEventMap, DatePicker
66
66
  *
67
67
  * ### Styling
68
68
  *
69
- * The following shadow DOM parts are available for styling:
70
- *
71
- * Part name | Description | Theme for Element
72
- * ----------------|----------------|----------------
73
- * `overlay-content` | The overlay element | vaadin-date-picker-light
74
- *
75
69
  * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
76
70
  *
77
71
  * In addition to `<vaadin-date-picker-light>` itself, the following
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import './vaadin-date-picker-overlay.js';
@@ -28,12 +28,6 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
28
28
  *
29
29
  * ### Styling
30
30
  *
31
- * The following shadow DOM parts are available for styling:
32
- *
33
- * Part name | Description | Theme for Element
34
- * ----------------|----------------|----------------
35
- * `overlay-content` | The overlay element | vaadin-date-picker-light
36
- *
37
31
  * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
38
32
  *
39
33
  * In addition to `<vaadin-date-picker-light>` itself, the following
@@ -73,29 +67,13 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
73
67
  id="overlay"
74
68
  fullscreen$="[[_fullscreen]]"
75
69
  opened="{{opened}}"
70
+ on-vaadin-overlay-escape-press="_onOverlayEscapePress"
76
71
  on-vaadin-overlay-open="_onOverlayOpened"
77
72
  on-vaadin-overlay-closing="_onOverlayClosed"
78
73
  restore-focus-on-close
79
74
  restore-focus-node="[[inputElement]]"
80
- theme$="[[__getOverlayTheme(_theme, _overlayInitialized)]]"
81
- >
82
- <template>
83
- <vaadin-date-picker-overlay-content
84
- id="overlay-content"
85
- i18n="[[i18n]]"
86
- fullscreen$="[[_fullscreen]]"
87
- label="[[label]]"
88
- selected-date="[[_selectedDate]]"
89
- focused-date="{{_focusedDate}}"
90
- show-week-numbers="[[showWeekNumbers]]"
91
- min-date="[[_minDate]]"
92
- max-date="[[_maxDate]]"
93
- part="overlay-content"
94
- theme$="[[__getOverlayTheme(_theme, _overlayInitialized)]]"
95
- >
96
- </vaadin-date-picker-overlay-content>
97
- </template>
98
- </vaadin-date-picker-overlay>
75
+ theme$="[[_theme]]"
76
+ ></vaadin-date-picker-overlay>
99
77
  `;
100
78
  }
101
79
 
@@ -115,33 +93,9 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
115
93
  type: String,
116
94
  value: 'value',
117
95
  },
118
-
119
- /**
120
- * @type {boolean}
121
- * @protected
122
- */
123
- _overlayInitialized: {
124
- type: Boolean,
125
- value: true,
126
- },
127
96
  };
128
97
  }
129
98
 
130
- /** @protected */
131
- ready() {
132
- super.ready();
133
-
134
- this._initOverlay();
135
- }
136
-
137
- /** @protected */
138
- connectedCallback() {
139
- super.connectedCallback();
140
- const cssSelector = 'vaadin-text-field,iron-input,paper-input,.paper-input-input,.input';
141
- this._setInputElement(this.querySelector(cssSelector));
142
- this._setFocusElement(this.inputElement);
143
- }
144
-
145
99
  /** @return {string | undefined} */
146
100
  get _inputValue() {
147
101
  return this.inputElement && this.inputElement[dashToCamelCase(this.attrForValue)];
@@ -153,6 +107,14 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
153
107
  }
154
108
  }
155
109
 
110
+ /** @protected */
111
+ connectedCallback() {
112
+ super.connectedCallback();
113
+ const cssSelector = 'vaadin-text-field,.input';
114
+ this._setInputElement(this.querySelector(cssSelector));
115
+ this._setFocusElement(this.inputElement);
116
+ }
117
+
156
118
  // Workaround https://github.com/vaadin/web-components/issues/2855
157
119
  /** @protected */
158
120
  _openedChanged(opened) {
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { DelegateFocusMixinClass } from '@vaadin/component-base/src/delegate-focus-mixin.js';
7
8
  import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
8
9
  import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
9
10
  import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
10
- import type { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
11
+ import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
12
  import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
12
13
  import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
13
14
 
@@ -38,15 +39,6 @@ export interface DatePickerI18n {
38
39
  * (0 = Sunday, 1 = Monday, etc.).
39
40
  */
40
41
  firstDayOfWeek: number;
41
- /**
42
- * Used in screen reader announcements along with week
43
- * numbers, if they are displayed.
44
- */
45
- week: string;
46
- /**
47
- * Translation of the Calendar icon button title.
48
- */
49
- calendar: string;
50
42
  /**
51
43
  * Translation of the Today shortcut button text.
52
44
  */
@@ -102,6 +94,7 @@ export declare function DatePickerMixin<T extends Constructor<HTMLElement>>(
102
94
  Constructor<InputConstraintsMixinClass> &
103
95
  Constructor<InputMixinClass> &
104
96
  Constructor<KeyboardMixinClass> &
97
+ Constructor<OverlayClassMixinClass> &
105
98
  T;
106
99
 
107
100
  export declare class DatePickerMixinClass {
@@ -183,13 +176,6 @@ export declare class DatePickerMixinClass {
183
176
  * // (0 = Sunday, 1 = Monday, etc.).
184
177
  * firstDayOfWeek: 0,
185
178
  *
186
- * // Used in screen reader announcements along with week
187
- * // numbers, if they are displayed.
188
- * week: 'Week',
189
- *
190
- * // Translation of the Calendar icon button title.
191
- * calendar: 'Calendar',
192
- *
193
179
  * // Translation of the Today shortcut button text.
194
180
  * today: 'Today',
195
181
  *
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { isIOS } from '@vaadin/component-base/src/browser-utils.js';
7
7
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
+ import { DelegateFocusMixin } from '@vaadin/component-base/src/delegate-focus-mixin.js';
8
9
  import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
9
10
  import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
10
- import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
11
+ import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
12
  import { InputConstraintsMixin } from '@vaadin/field-base/src/input-constraints-mixin.js';
12
13
  import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
13
14
  import {
@@ -21,11 +22,16 @@ import {
21
22
 
22
23
  /**
23
24
  * @polymerMixin
25
+ * @mixes ControllerMixin
26
+ * @mixes DelegateFocusMixin
27
+ * @mixes InputConstraintsMixin
28
+ * @mixes KeyboardMixin
29
+ * @mixes OverlayClassMixin
24
30
  * @param {function(new:HTMLElement)} subclass
25
31
  */
26
32
  export const DatePickerMixin = (subclass) =>
27
- class VaadinDatePickerMixin extends ControllerMixin(
28
- DelegateFocusMixin(InputConstraintsMixin(KeyboardMixin(subclass))),
33
+ class DatePickerMixinClass extends OverlayClassMixin(
34
+ ControllerMixin(DelegateFocusMixin(InputConstraintsMixin(KeyboardMixin(subclass)))),
29
35
  ) {
30
36
  static get properties() {
31
37
  return {
@@ -91,6 +97,7 @@ export const DatePickerMixin = (subclass) =>
91
97
  */
92
98
  showWeekNumbers: {
93
99
  type: Boolean,
100
+ value: false,
94
101
  },
95
102
 
96
103
  /**
@@ -152,13 +159,6 @@ export const DatePickerMixin = (subclass) =>
152
159
  * // (0 = Sunday, 1 = Monday, etc.).
153
160
  * firstDayOfWeek: 0,
154
161
  *
155
- * // Used in screen reader announcements along with week
156
- * // numbers, if they are displayed.
157
- * week: 'Week',
158
- *
159
- * // Translation of the Calendar icon button title.
160
- * calendar: 'Calendar',
161
- *
162
162
  * // Translation of the Today shortcut button text.
163
163
  * today: 'Today',
164
164
  *
@@ -224,13 +224,11 @@ export const DatePickerMixin = (subclass) =>
224
224
  weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
225
225
  weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
226
226
  firstDayOfWeek: 0,
227
- week: 'Week',
228
- calendar: 'Calendar',
229
227
  today: 'Today',
230
228
  cancel: 'Cancel',
231
229
  referenceDate: '',
232
230
  formatDate(d) {
233
- const yearStr = String(d.year).replace(/\d+/, (y) => '0000'.substr(y.length) + y);
231
+ const yearStr = String(d.year).replace(/\d+/u, (y) => '0000'.substr(y.length) + y);
234
232
  return [d.month + 1, d.day, yearStr].join('/');
235
233
  },
236
234
  parseDate(text) {
@@ -327,8 +325,8 @@ export const DatePickerMixin = (subclass) =>
327
325
  /** @private */
328
326
  _focusOverlayOnOpen: Boolean,
329
327
 
330
- /** @protected */
331
- _overlayInitialized: Boolean,
328
+ /** @private */
329
+ _overlayContent: Object,
332
330
  };
333
331
  }
334
332
 
@@ -336,6 +334,9 @@ export const DatePickerMixin = (subclass) =>
336
334
  return [
337
335
  '_selectedDateChanged(_selectedDate, i18n.formatDate)',
338
336
  '_focusedDateChanged(_focusedDate, i18n.formatDate)',
337
+ '__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers)',
338
+ '__updateOverlayContentTheme(_overlayContent, _theme)',
339
+ '__updateOverlayContentFullScreen(_overlayContent, _fullscreen)',
339
340
  ];
340
341
  }
341
342
 
@@ -343,6 +344,14 @@ export const DatePickerMixin = (subclass) =>
343
344
  return [...super.constraints, 'min', 'max'];
344
345
  }
345
346
 
347
+ constructor() {
348
+ super();
349
+
350
+ this._boundOnClick = this._onClick.bind(this);
351
+ this._boundOnScroll = this._onScroll.bind(this);
352
+ this._boundOverlayRenderer = this._overlayRenderer.bind(this);
353
+ }
354
+
346
355
  /**
347
356
  * Override a getter from `InputControlMixin` to make it optional
348
357
  * and to prevent warning when a clear button is missing,
@@ -354,18 +363,6 @@ export const DatePickerMixin = (subclass) =>
354
363
  return null;
355
364
  }
356
365
 
357
- /** @protected */
358
- get _inputValue() {
359
- return this.inputElement ? this.inputElement.value : undefined;
360
- }
361
-
362
- /** @protected */
363
- set _inputValue(value) {
364
- if (this.inputElement) {
365
- this.inputElement.value = value;
366
- }
367
- }
368
-
369
366
  /** @private */
370
367
  get _nativeInput() {
371
368
  if (this.inputElement) {
@@ -375,11 +372,16 @@ export const DatePickerMixin = (subclass) =>
375
372
  return null;
376
373
  }
377
374
 
378
- constructor() {
379
- super();
375
+ /** @protected */
376
+ get _inputValue() {
377
+ return this.inputElement ? this.inputElement.value : undefined;
378
+ }
380
379
 
381
- this._boundOnClick = this._onClick.bind(this);
382
- this._boundOnScroll = this._onScroll.bind(this);
380
+ /** @protected */
381
+ set _inputValue(value) {
382
+ if (this.inputElement) {
383
+ this.inputElement.value = value;
384
+ }
383
385
  }
384
386
 
385
387
  /**
@@ -427,6 +429,14 @@ export const DatePickerMixin = (subclass) =>
427
429
  );
428
430
 
429
431
  this.addController(new VirtualKeyboardController(this));
432
+
433
+ const overlay = this.$.overlay;
434
+ this._overlayElement = overlay;
435
+
436
+ overlay.renderer = this._boundOverlayRenderer;
437
+
438
+ this.addEventListener('mousedown', () => this.__bringToFront());
439
+ this.addEventListener('touchstart', () => this.__bringToFront());
430
440
  }
431
441
 
432
442
  /** @protected */
@@ -468,33 +478,29 @@ export const DatePickerMixin = (subclass) =>
468
478
  * Closes the dropdown.
469
479
  */
470
480
  close() {
471
- if (this._overlayInitialized || this.autoOpenDisabled) {
472
- this.$.overlay.close();
473
- }
481
+ this.$.overlay.close();
474
482
  }
475
483
 
476
- /** @protected */
477
- _initOverlay() {
478
- this.$.overlay.removeAttribute('disable-upgrade');
479
- this._overlayInitialized = true;
484
+ /** @private */
485
+ _overlayRenderer(root) {
486
+ if (root.firstChild) {
487
+ return;
488
+ }
480
489
 
481
- this.$.overlay.addEventListener('opened-changed', (e) => {
482
- this.opened = e.detail.value;
483
- });
490
+ // Create and store document content element
491
+ const content = document.createElement('vaadin-date-picker-overlay-content');
492
+ root.appendChild(content);
484
493
 
485
- this.$.overlay.addEventListener('vaadin-overlay-escape-press', () => {
486
- this._focusedDate = this._selectedDate;
487
- this._close();
488
- });
494
+ this._overlayContent = content;
489
495
 
490
- this._overlayContent.addEventListener('close', () => {
496
+ content.addEventListener('close', () => {
491
497
  this._close();
492
498
  });
493
499
 
494
- this._overlayContent.addEventListener('focus-input', this._focusAndSelect.bind(this));
500
+ content.addEventListener('focus-input', this._focusAndSelect.bind(this));
495
501
 
496
502
  // User confirmed selected date by clicking the calendar.
497
- this._overlayContent.addEventListener('date-tap', (e) => {
503
+ content.addEventListener('date-tap', (e) => {
498
504
  this.__userConfirmedDate = true;
499
505
 
500
506
  this._selectDate(e.detail.date);
@@ -503,7 +509,7 @@ export const DatePickerMixin = (subclass) =>
503
509
  });
504
510
 
505
511
  // User confirmed selected date by pressing Enter or Today.
506
- this._overlayContent.addEventListener('date-selected', (e) => {
512
+ content.addEventListener('date-selected', (e) => {
507
513
  this.__userConfirmedDate = true;
508
514
 
509
515
  this._selectDate(e.detail.date);
@@ -511,14 +517,16 @@ export const DatePickerMixin = (subclass) =>
511
517
 
512
518
  // Set focus-ring attribute when moving focus to the overlay
513
519
  // by pressing Tab or arrow key, after opening it on click.
514
- this._overlayContent.addEventListener('focusin', () => {
520
+ content.addEventListener('focusin', () => {
515
521
  if (this._keyboardActive) {
516
522
  this._setFocused(true);
517
523
  }
518
524
  });
519
525
 
520
- this.addEventListener('mousedown', () => this.__bringToFront());
521
- this.addEventListener('touchstart', () => this.__bringToFront());
526
+ // Two-way data binding for `focusedDate` property
527
+ content.addEventListener('focused-date-changed', (e) => {
528
+ this._focusedDate = e.detail.value;
529
+ });
522
530
  }
523
531
 
524
532
  /**
@@ -677,12 +685,6 @@ export const DatePickerMixin = (subclass) =>
677
685
 
678
686
  /** @protected */
679
687
  _openedChanged(opened) {
680
- if (opened && !this._overlayInitialized) {
681
- this._initOverlay();
682
- }
683
- if (this._overlayInitialized) {
684
- this.$.overlay.opened = opened;
685
- }
686
688
  if (this.inputElement) {
687
689
  this.inputElement.setAttribute('aria-expanded', opened);
688
690
  }
@@ -718,13 +720,6 @@ export const DatePickerMixin = (subclass) =>
718
720
  }
719
721
  }
720
722
 
721
- /** @private */
722
- __getOverlayTheme(theme, overlayInitialized) {
723
- if (overlayInitialized) {
724
- return theme;
725
- }
726
- }
727
-
728
723
  /**
729
724
  * Override the value observer from `InputMixin` to implement custom
730
725
  * handling of the `value` property. The date-picker doesn't forward
@@ -763,23 +758,59 @@ export const DatePickerMixin = (subclass) =>
763
758
  this._toggleHasValue(this._hasValue);
764
759
  }
765
760
 
766
- /** @protected */
767
- _onOverlayOpened() {
768
- const parsedInitialPosition = parseDate(this.initialPosition);
761
+ /** @private */
762
+ // eslint-disable-next-line max-params
763
+ __updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
764
+ if (overlayContent) {
765
+ overlayContent.setProperties({
766
+ i18n,
767
+ label,
768
+ minDate,
769
+ maxDate,
770
+ focusedDate,
771
+ selectedDate,
772
+ showWeekNumbers,
773
+ });
774
+ }
775
+ }
769
776
 
770
- const initialPosition =
771
- this._selectedDate || this._overlayContent.initialPosition || parsedInitialPosition || new Date();
777
+ /** @private */
778
+ __updateOverlayContentTheme(overlayContent, theme) {
779
+ if (overlayContent) {
780
+ if (theme) {
781
+ overlayContent.setAttribute('theme', theme);
782
+ } else {
783
+ overlayContent.removeAttribute('theme');
784
+ }
785
+ }
786
+ }
772
787
 
773
- if (parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate)) {
774
- this._overlayContent.initialPosition = initialPosition;
775
- } else {
776
- this._overlayContent.initialPosition = getClosestDate(initialPosition, [this._minDate, this._maxDate]);
788
+ /** @private */
789
+ __updateOverlayContentFullScreen(overlayContent, fullscreen) {
790
+ if (overlayContent) {
791
+ overlayContent.toggleAttribute('fullscreen', fullscreen);
777
792
  }
793
+ }
794
+
795
+ /** @protected */
796
+ _onOverlayEscapePress() {
797
+ this._focusedDate = this._selectedDate;
798
+ this._close();
799
+ }
800
+
801
+ /** @protected */
802
+ _onOverlayOpened() {
803
+ // Detect which date to show
804
+ const initialPosition = this._getInitialPosition();
805
+ this._overlayContent.initialPosition = initialPosition;
806
+
807
+ // Scroll the date into view
808
+ const scrollFocusDate = this._overlayContent.focusedDate || initialPosition;
809
+ this._overlayContent.scrollToDate(scrollFocusDate);
778
810
 
779
- this._overlayContent.scrollToDate(this._overlayContent.focusedDate || this._overlayContent.initialPosition);
780
- // Have a default focused date
811
+ // Ensure the date is focused
781
812
  this._ignoreFocusedDateChange = true;
782
- this._overlayContent.focusedDate = this._overlayContent.focusedDate || this._overlayContent.initialPosition;
813
+ this._overlayContent.focusedDate = scrollFocusDate;
783
814
  this._ignoreFocusedDateChange = false;
784
815
 
785
816
  window.addEventListener('scroll', this._boundOnScroll, true);
@@ -797,6 +828,18 @@ export const DatePickerMixin = (subclass) =>
797
828
  }
798
829
  }
799
830
 
831
+ /** @private */
832
+ _getInitialPosition() {
833
+ const parsedInitialPosition = parseDate(this.initialPosition);
834
+
835
+ const initialPosition =
836
+ this._selectedDate || this._overlayContent.initialPosition || parsedInitialPosition || new Date();
837
+
838
+ return parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate)
839
+ ? initialPosition
840
+ : getClosestDate(initialPosition, [this._minDate, this._maxDate]);
841
+ }
842
+
800
843
  /** @private */
801
844
  _selectParsedOrFocusedDate() {
802
845
  // Select the parsed input or focused date
@@ -1079,11 +1122,6 @@ export const DatePickerMixin = (subclass) =>
1079
1122
  }
1080
1123
  }
1081
1124
 
1082
- /** @private */
1083
- get _overlayContent() {
1084
- return this.$.overlay.content.querySelector('#overlay-content');
1085
- }
1086
-
1087
1125
  /** @private */
1088
1126
  __computeMinOrMaxDate(dateString) {
1089
1127
  return parseDate(dateString);