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

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-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,24 +32,23 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@open-wc/dedupe-mixin": "^1.3.0",
35
- "@polymer/iron-a11y-announcer": "^3.0.0",
36
35
  "@polymer/iron-media-query": "^3.0.0",
37
36
  "@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"
37
+ "@vaadin/button": "23.0.0-alpha3",
38
+ "@vaadin/component-base": "23.0.0-alpha3",
39
+ "@vaadin/field-base": "23.0.0-alpha3",
40
+ "@vaadin/input-container": "23.0.0-alpha3",
41
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha3",
42
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha3",
43
+ "@vaadin/vaadin-overlay": "23.0.0-alpha3",
44
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha3"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/dialog": "23.0.0-alpha2",
50
- "@vaadin/polymer-legacy-adapter": "23.0.0-alpha2",
48
+ "@vaadin/dialog": "23.0.0-alpha3",
49
+ "@vaadin/polymer-legacy-adapter": "23.0.0-alpha3",
51
50
  "@vaadin/testing-helpers": "^0.3.2",
52
51
  "sinon": "^9.2.0"
53
52
  },
54
- "gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
53
+ "gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44"
55
54
  }
@@ -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 */
@@ -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';
@@ -350,34 +350,25 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
350
350
  this._closeYearScroller();
351
351
  this._toggleAnimateClass(true);
352
352
  setTouchAction(this.$.scrollers, 'pan-y');
353
- IronA11yAnnouncer.requestAvailability();
354
353
  }
355
354
 
356
355
  announceFocusedDate() {
357
- var focusedDate = this._currentlyFocusedDate();
358
- var announce = [];
356
+ const focusedDate = this._currentlyFocusedDate();
357
+ let messages = [];
359
358
  if (dateEquals(focusedDate, new Date())) {
360
- announce.push(this.i18n.today);
359
+ messages.push(this.i18n.today);
361
360
  }
362
- announce = announce.concat([
361
+ messages = messages.concat([
363
362
  this.i18n.weekdays[focusedDate.getDay()],
364
363
  focusedDate.getDate(),
365
364
  this.i18n.monthNames[focusedDate.getMonth()],
366
365
  focusedDate.getFullYear()
367
366
  ]);
368
367
  if (this.showWeekNumbers && this.i18n.firstDayOfWeek === 1) {
369
- announce.push(this.i18n.week);
370
- announce.push(getISOWeekNumber(focusedDate));
368
+ messages.push(this.i18n.week);
369
+ messages.push(getISOWeekNumber(focusedDate));
371
370
  }
372
- this.dispatchEvent(
373
- new CustomEvent('iron-announce', {
374
- bubbles: true,
375
- composed: true,
376
- detail: {
377
- text: announce.join(' ')
378
- }
379
- })
380
- );
371
+ announce(messages.join(' '));
381
372
  }
382
373
 
383
374
  /**
@@ -411,18 +402,22 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
411
402
  /**
412
403
  * Scrolls the month and year scrollers enough to reveal the given date.
413
404
  */
414
- revealDate(date) {
405
+ revealDate(date, animate = true) {
415
406
  if (date) {
416
- var diff = this._differenceInMonths(date, this._originDate);
417
- var scrolledAboveViewport = this.$.monthScroller.position > diff;
407
+ const diff = this._differenceInMonths(date, this._originDate);
408
+ const scrolledAboveViewport = this.$.monthScroller.position > diff;
418
409
 
419
- var visibleItems = this.$.monthScroller.clientHeight / this.$.monthScroller.itemHeight;
420
- var scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
410
+ const visibleArea = Math.max(
411
+ this.$.monthScroller.itemHeight,
412
+ this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2
413
+ );
414
+ const visibleItems = visibleArea / this.$.monthScroller.itemHeight;
415
+ const scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
421
416
 
422
417
  if (scrolledAboveViewport) {
423
- this._scrollToPosition(diff, true);
418
+ this._scrollToPosition(diff, animate);
424
419
  } else if (scrolledBelowViewport) {
425
- this._scrollToPosition(diff - visibleItems + 1, true);
420
+ this._scrollToPosition(diff - visibleItems + 1, animate);
426
421
  }
427
422
  }
428
423
  }
@@ -537,7 +532,7 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(PolymerElement)) {
537
532
  if (t < 1) {
538
533
  return (c / 2) * t * t + b;
539
534
  }
540
- t--;
535
+ t -= 1;
541
536
  return (-c / 2) * (t * (t - 2) - 1) + b;
542
537
  };
543
538
 
@@ -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