@vaadin/date-picker 23.0.0-alpha2 → 23.0.0-beta1

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.0.0-alpha2",
3
+ "version": "23.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-date-picker.js",
20
20
  "module": "vaadin-date-picker.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -32,24 +33,23 @@
32
33
  ],
33
34
  "dependencies": {
34
35
  "@open-wc/dedupe-mixin": "^1.3.0",
35
- "@polymer/iron-a11y-announcer": "^3.0.0",
36
36
  "@polymer/iron-media-query": "^3.0.0",
37
37
  "@polymer/polymer": "^3.2.0",
38
- "@vaadin/button": "23.0.0-alpha2",
39
- "@vaadin/component-base": "23.0.0-alpha2",
40
- "@vaadin/field-base": "23.0.0-alpha2",
41
- "@vaadin/input-container": "23.0.0-alpha2",
42
- "@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
43
- "@vaadin/vaadin-material-styles": "23.0.0-alpha2",
44
- "@vaadin/vaadin-overlay": "23.0.0-alpha2",
45
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
38
+ "@vaadin/button": "23.0.0-beta1",
39
+ "@vaadin/component-base": "23.0.0-beta1",
40
+ "@vaadin/field-base": "23.0.0-beta1",
41
+ "@vaadin/input-container": "23.0.0-beta1",
42
+ "@vaadin/vaadin-lumo-styles": "23.0.0-beta1",
43
+ "@vaadin/vaadin-material-styles": "23.0.0-beta1",
44
+ "@vaadin/vaadin-overlay": "23.0.0-beta1",
45
+ "@vaadin/vaadin-themable-mixin": "23.0.0-beta1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/dialog": "23.0.0-alpha2",
50
- "@vaadin/polymer-legacy-adapter": "23.0.0-alpha2",
49
+ "@vaadin/dialog": "23.0.0-beta1",
50
+ "@vaadin/polymer-legacy-adapter": "23.0.0-beta1",
51
51
  "@vaadin/testing-helpers": "^0.3.2",
52
52
  "sinon": "^9.2.0"
53
53
  },
54
- "gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
54
+ "gitHead": "467244b76021176c109df675799b07029b293e58"
55
55
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 '@polymer/iron-media-query/iron-media-query.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,19 +1,22 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
7
8
  import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
8
9
  import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
9
10
  import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
11
+ import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
10
12
  import { dateAllowed, dateEquals, extractDateParts, getClosestDate } from './vaadin-date-picker-helper.js';
11
13
 
12
14
  /**
13
15
  * @polymerMixin
16
+ * @param {function(new:HTMLElement)} subclass
14
17
  */
15
18
  export const DatePickerMixin = (subclass) =>
16
- class VaadinDatePickerMixin extends DelegateFocusMixin(InputMixin(KeyboardMixin(subclass))) {
19
+ class VaadinDatePickerMixin extends ControllerMixin(DelegateFocusMixin(InputMixin(KeyboardMixin(subclass)))) {
17
20
  static get properties() {
18
21
  return {
19
22
  /**
@@ -419,6 +422,8 @@ export const DatePickerMixin = (subclass) =>
419
422
  this.open();
420
423
  }
421
424
  });
425
+
426
+ this.addController(new VirtualKeyboardController(this));
422
427
  }
423
428
 
424
429
  /** @protected */
@@ -577,6 +582,7 @@ export const DatePickerMixin = (subclass) =>
577
582
  _inputElementChanged(input) {
578
583
  super._inputElementChanged(input);
579
584
  if (input) {
585
+ input.autocomplete = 'off';
580
586
  input.setAttribute('role', 'combobox');
581
587
  input.setAttribute('aria-expanded', !!this.opened);
582
588
  this._applyInputValue(this._selectedDate);
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 '@polymer/iron-media-query/iron-media-query.js';
7
7
  import '@vaadin/button/src/vaadin-button.js';
8
8
  import './vaadin-month-calendar.js';
9
9
  import './vaadin-infinite-scroller.js';
10
- import { IronA11yAnnouncer } from '@polymer/iron-a11y-announcer/iron-a11y-announcer.js';
11
10
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
11
+ import { announce } from '@vaadin/component-base/src/a11y-announcer.js';
12
12
  import { timeOut } from '@vaadin/component-base/src/async.js';
13
13
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
14
14
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
@@ -204,6 +204,7 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
204
204
  buffer-size="12"
205
205
  active="[[initialPosition]]"
206
206
  part="years"
207
+ aria-hidden="true"
207
208
  >
208
209
  <template>
209
210
  <div
@@ -350,34 +351,25 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
350
351
  this._closeYearScroller();
351
352
  this._toggleAnimateClass(true);
352
353
  setTouchAction(this.$.scrollers, 'pan-y');
353
- IronA11yAnnouncer.requestAvailability();
354
354
  }
355
355
 
356
356
  announceFocusedDate() {
357
- var focusedDate = this._currentlyFocusedDate();
358
- var announce = [];
357
+ const focusedDate = this._currentlyFocusedDate();
358
+ let messages = [];
359
359
  if (dateEquals(focusedDate, new Date())) {
360
- announce.push(this.i18n.today);
360
+ messages.push(this.i18n.today);
361
361
  }
362
- announce = announce.concat([
362
+ messages = messages.concat([
363
363
  this.i18n.weekdays[focusedDate.getDay()],
364
364
  focusedDate.getDate(),
365
365
  this.i18n.monthNames[focusedDate.getMonth()],
366
366
  focusedDate.getFullYear()
367
367
  ]);
368
368
  if (this.showWeekNumbers && this.i18n.firstDayOfWeek === 1) {
369
- announce.push(this.i18n.week);
370
- announce.push(getISOWeekNumber(focusedDate));
369
+ messages.push(this.i18n.week);
370
+ messages.push(getISOWeekNumber(focusedDate));
371
371
  }
372
- this.dispatchEvent(
373
- new CustomEvent('iron-announce', {
374
- bubbles: true,
375
- composed: true,
376
- detail: {
377
- text: announce.join(' ')
378
- }
379
- })
380
- );
372
+ announce(messages.join(' '));
381
373
  }
382
374
 
383
375
  /**
@@ -411,18 +403,22 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
411
403
  /**
412
404
  * Scrolls the month and year scrollers enough to reveal the given date.
413
405
  */
414
- revealDate(date) {
406
+ revealDate(date, animate = true) {
415
407
  if (date) {
416
- var diff = this._differenceInMonths(date, this._originDate);
417
- var scrolledAboveViewport = this.$.monthScroller.position > diff;
408
+ const diff = this._differenceInMonths(date, this._originDate);
409
+ const scrolledAboveViewport = this.$.monthScroller.position > diff;
418
410
 
419
- var visibleItems = this.$.monthScroller.clientHeight / this.$.monthScroller.itemHeight;
420
- var scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
411
+ const visibleArea = Math.max(
412
+ this.$.monthScroller.itemHeight,
413
+ this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2
414
+ );
415
+ const visibleItems = visibleArea / this.$.monthScroller.itemHeight;
416
+ const scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
421
417
 
422
418
  if (scrolledAboveViewport) {
423
- this._scrollToPosition(diff, true);
419
+ this._scrollToPosition(diff, animate);
424
420
  } else if (scrolledBelowViewport) {
425
- this._scrollToPosition(diff - visibleItems + 1, true);
421
+ this._scrollToPosition(diff - visibleItems + 1, animate);
426
422
  }
427
423
  }
428
424
  }
@@ -537,7 +533,7 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
537
533
  if (t < 1) {
538
534
  return (c / 2) * t * t + b;
539
535
  }
540
- t--;
536
+ t -= 1;
541
537
  return (-c / 2) * (t * (t - 2) - 1) + b;
542
538
  };
543
539
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { DisableUpgradeMixin } from '@polymer/polymer/lib/mixins/disable-upgrade-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 '@polymer/iron-media-query/iron-media-query.js';
@@ -212,7 +212,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
212
212
  this.ariaTarget = input;
213
213
  })
214
214
  );
215
- this.addController(new LabelledInputController(this.inputElement, this._labelNode));
215
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
216
216
  addListener(this.shadowRoot.querySelector('[part="toggle-button"]'), 'tap', this._toggle.bind(this));
217
217
  }
218
218
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
@@ -186,9 +186,9 @@ class InfiniteScroller extends PolymerElement {
186
186
  }
187
187
 
188
188
  // Check if we scrolled enough to translate the buffer positions.
189
- const bufferOffset = this.root.querySelector('.buffer').offsetTop;
190
- const upperThresholdReached = scrollTop > this._buffers[1].translateY + this.itemHeight + bufferOffset;
191
- const lowerThresholdReached = scrollTop < this._buffers[0].translateY + this.itemHeight + bufferOffset;
189
+ const offset = this.itemHeight + this.bufferOffset;
190
+ const upperThresholdReached = scrollTop > this._buffers[1].translateY + offset;
191
+ const lowerThresholdReached = scrollTop < this._buffers[0].translateY + offset;
192
192
 
193
193
  if (upperThresholdReached || lowerThresholdReached) {
194
194
  this._translateBuffer(lowerThresholdReached);
@@ -210,7 +210,14 @@ class InfiniteScroller extends PolymerElement {
210
210
  }
211
211
 
212
212
  /**
213
- * @private
213
+ * @return {number}
214
+ */
215
+ get bufferOffset() {
216
+ return this._buffers[0].offsetTop;
217
+ }
218
+
219
+ /**
220
+ * @return {number}
214
221
  */
215
222
  get position() {
216
223
  return (this.$.scroller.scrollTop - this._buffers[0].translateY) / this.itemHeight + this._firstIndex;
@@ -219,7 +226,7 @@ class InfiniteScroller extends PolymerElement {
219
226
  /**
220
227
  * Current scroller position as index. Can be a fractional number.
221
228
  *
222
- * @type {Number}
229
+ * @type {number}
223
230
  */
224
231
  set position(index) {
225
232
  this._preventScrollEvent = true;
@@ -245,6 +252,9 @@ class InfiniteScroller extends PolymerElement {
245
252
  }
246
253
  }
247
254
 
255
+ /**
256
+ * @return {number}
257
+ */
248
258
  get itemHeight() {
249
259
  if (!this._itemHeightVal) {
250
260
  const itemHeight = getComputedStyle(this).getPropertyValue('--vaadin-infinite-scroller-item-height');
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 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 '@polymer/polymer/lib/elements/dom-repeat.js';
@@ -110,7 +110,7 @@ registerStyles(
110
110
  /* Month scroller */
111
111
 
112
112
  [part='months'] {
113
- --vaadin-infinite-scroller-item-height: 320px;
113
+ --vaadin-infinite-scroller-item-height: 328px;
114
114
  text-align: center;
115
115
  }
116
116