@vaadin/vaadin-date-picker 4.4.0 → 4.4.3

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 CHANGED
@@ -1,20 +1,18 @@
1
- [![npm version](https://badgen.net/npm/v/@vaadin/vaadin-date-picker)](https://www.npmjs.com/package/@vaadin/vaadin-date-picker)
2
- [![Bower version](https://badgen.net/github/release/vaadin/vaadin-date-picker)](https://github.com/vaadin/vaadin-date-picker/releases)
3
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/vaadin/vaadin-date-picker)
4
- [![Build Status](https://travis-ci.org/vaadin/vaadin-date-picker.svg?branch=master)](https://travis-ci.org/vaadin/vaadin-date-picker)
5
- [![Coverage Status](https://coveralls.io/repos/github/vaadin/vaadin-date-picker/badge.svg?branch=master)](https://coveralls.io/github/vaadin/vaadin-date-picker?branch=master)
6
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1
+ # <vaadin-date-picker>
7
2
 
8
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-date-picker)
9
- [![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/vaadinvaadin-date-picker.svg)](https://vaadin.com/directory/component/vaadinvaadin-date-picker)
3
+ > ⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the [`vaadin/web-components`](https://github.com/vaadin/web-components/tree/master/packages/vaadin-date-picker) monorepository.
4
+ > This repository contains the source code and releases of `<vaadin-date-picker>` for the Vaadin versions 10 to 19.
10
5
 
11
- # &lt;vaadin-date-picker&gt;
6
+ [&lt;vaadin-date-picker&gt;](https://vaadin.com/components/vaadin-date-picker) is a Web Component providing a date selection field which includes a scrollable month calendar view, part of the [Vaadin components](https://vaadin.com/components).
12
7
 
13
8
  [Live Demo ↗](https://vaadin.com/components/vaadin-date-picker/html-examples)
14
9
  |
15
10
  [API documentation ↗](https://vaadin.com/components/vaadin-date-picker/html-api)
16
11
 
17
- [&lt;vaadin-date-picker&gt;](https://vaadin.com/components/vaadin-date-picker) is a Web Component providing a date selection field which includes a scrollable month calendar view, part of the [Vaadin components](https://vaadin.com/components).
12
+ [![npm version](https://badgen.net/npm/v/@vaadin/vaadin-date-picker)](https://www.npmjs.com/package/@vaadin/vaadin-date-picker)
13
+ [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/vaadin/va
14
+ [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-date-picker)
15
+ [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
18
16
 
19
17
  <!--
20
18
  ```
@@ -80,18 +78,18 @@ To use the Material theme, import the correspondent file from the `theme/materia
80
78
 
81
79
  - The components with the Lumo theme:
82
80
 
83
- `theme/lumo/vaadin-date-picker.html`
81
+ `theme/lumo/vaadin-date-picker.html`
84
82
  `theme/lumo/vaadin-date-picker-light.html`
85
83
 
86
84
  - The components with the Material theme:
87
85
 
88
- `theme/material/vaadin-date-picker.html`
86
+ `theme/material/vaadin-date-picker.html`
89
87
  `theme/material/vaadin-date-picker-light.html`
90
88
 
91
- - Alias for `theme/lumo/vaadin-date-picker.html`
89
+ - Alias for `theme/lumo/vaadin-date-picker.html`
92
90
  `theme/lumo/vaadin-date-picker-light.html`:
93
91
 
94
- `vaadin-date-picker.html`
92
+ `vaadin-date-picker.html`
95
93
  `vaadin-date-picker-light.html`
96
94
 
97
95
 
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "repository": "vaadin/vaadin-date-picker",
11
11
  "homepage": "https://vaadin.com/components",
12
12
  "name": "@vaadin/vaadin-date-picker",
13
- "version": "4.4.0",
13
+ "version": "4.4.3",
14
14
  "main": "vaadin-date-picker.js",
15
15
  "author": "Vaadin Ltd",
16
16
  "license": "Apache-2.0",
@@ -45,10 +45,9 @@
45
45
  "@vaadin/vaadin-material-styles": "^1.3.2",
46
46
  "@vaadin/vaadin-element-mixin": "^2.4.1"
47
47
  },
48
- "scripts": {
49
- "generate-typings": "gen-typescript-declarations --outDir . --verify"
50
- },
51
48
  "devDependencies": {
49
+ "@web-padawan/gen-typescript-declarations": "^1.6.2",
50
+ "web-component-tester": "6.9.2",
52
51
  "@polymer/iron-component-page": "^4.0.0",
53
52
  "@polymer/iron-form": "^3.0.0",
54
53
  "@polymer/iron-icon": "^3.0.0",
@@ -60,5 +59,9 @@
60
59
  "@vaadin/vaadin-demo-helpers": "^3.1.0",
61
60
  "@vaadin/vaadin-custom-field": "^1.0.0",
62
61
  "@vaadin/vaadin-dialog": "^2.2.1"
62
+ },
63
+ "scripts": {
64
+ "generate-typings": "gen-typescript-declarations --outDir . --verify",
65
+ "test": "wct --npm"
63
66
  }
64
67
  }
@@ -307,7 +307,7 @@ export const DatePickerMixin = subclass => class VaadinDatePickerMixin extends m
307
307
  /** @private */
308
308
  _noInput: {
309
309
  type: Boolean,
310
- computed: '_isNoInput(_fullscreen, _ios, i18n, i18n.*)'
310
+ computed: '_isNoInput(_fullscreen, _ios, i18n, i18n.*, opened, autoOpenDisabled)'
311
311
  },
312
312
 
313
313
  /** @private */
@@ -370,7 +370,7 @@ export const DatePickerMixin = subclass => class VaadinDatePickerMixin extends m
370
370
  });
371
371
 
372
372
  this.addEventListener('touchend', e => {
373
- if (!isClearButton(e)) {
373
+ if (this._noInput && !isClearButton(e)) {
374
374
  e.preventDefault();
375
375
  }
376
376
  });
@@ -498,8 +498,16 @@ export const DatePickerMixin = subclass => class VaadinDatePickerMixin extends m
498
498
  }
499
499
 
500
500
  /** @private */
501
- _isNoInput(fullscreen, ios, i18n) {
502
- return !this._inputElement || fullscreen || ios || !i18n.parseDate;
501
+ _isNoInput(fullscreen, ios, i18n, i18nChanges, opened, autoOpenDisabled) {
502
+ // On fullscreen mode, text input is disabled if auto-open isn't disabled or
503
+ // whenever the dropdown is opened
504
+ const noInputOnFullscreenMode = fullscreen && (!autoOpenDisabled || opened);
505
+ // On iOS, text input is disabled whenever the dropdown is opened, because
506
+ // the virtual keyboard doesn't affect the viewport metrics and thus the
507
+ // dropdown could get covered by the keyboard.
508
+ const noInputOnIos = ios && opened;
509
+
510
+ return !this._inputElement || noInputOnFullscreenMode || noInputOnIos || !i18n.parseDate;
503
511
  }
504
512
 
505
513
  /** @private */
@@ -199,10 +199,10 @@ class DatePickerOverlayContentElement extends
199
199
  </div>
200
200
 
201
201
  <div on-touchend="_preventDefault" role="toolbar" part="toolbar">
202
- <vaadin-button id="todayButton" part="today-button" disabled="[[!_isTodayAllowed(minDate, maxDate)]]" on-tap="_onTodayTap">
202
+ <vaadin-button id="todayButton" theme="tertiary" part="today-button" disabled="[[!_isTodayAllowed(minDate, maxDate)]]" on-tap="_onTodayTap">
203
203
  [[i18n.today]]
204
204
  </vaadin-button>
205
- <vaadin-button id="cancelButton" part="cancel-button" on-tap="_cancel">
205
+ <vaadin-button id="cancelButton" theme="tertiary" part="cancel-button" on-tap="_cancel">
206
206
  [[i18n.cancel]]
207
207
  </vaadin-button>
208
208
  </div>
@@ -376,18 +376,22 @@ class DatePickerOverlayContentElement extends
376
376
  /**
377
377
  * Scrolls the month and year scrollers enough to reveal the given date.
378
378
  */
379
- revealDate(date) {
379
+ revealDate(date, animate = true) {
380
380
  if (date) {
381
- var diff = this._differenceInMonths(date, this._originDate);
382
- var scrolledAboveViewport = this.$.monthScroller.position > diff;
381
+ const diff = this._differenceInMonths(date, this._originDate);
382
+ const scrolledAboveViewport = this.$.monthScroller.position > diff;
383
383
 
384
- var visibleItems = this.$.monthScroller.clientHeight / this.$.monthScroller.itemHeight;
385
- var scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
384
+ const visibleArea = Math.max(
385
+ this.$.monthScroller.itemHeight,
386
+ this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2
387
+ );
388
+ const visibleItems = visibleArea / this.$.monthScroller.itemHeight;
389
+ const scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
386
390
 
387
391
  if (scrolledAboveViewport) {
388
- this._scrollToPosition(diff, true);
392
+ this._scrollToPosition(diff, animate);
389
393
  } else if (scrolledBelowViewport) {
390
- this._scrollToPosition(diff - visibleItems + 1, true);
394
+ this._scrollToPosition(diff - visibleItems + 1, animate);
391
395
  }
392
396
  }
393
397
  }
@@ -147,7 +147,7 @@ class DatePickerElement extends
147
147
  }
148
148
 
149
149
  static get version() {
150
- return '4.4.0';
150
+ return '4.4.3';
151
151
  }
152
152
 
153
153
  static get properties() {
@@ -187,9 +187,9 @@ class InfiniteScrollerElement extends PolymerElement {
187
187
  }
188
188
 
189
189
  // Check if we scrolled enough to translate the buffer positions.
190
- var bufferOffset = this.root.querySelector('.buffer').offsetTop;
191
- var upperThresholdReached = scrollTop > this._buffers[1].translateY + this.itemHeight + bufferOffset;
192
- var lowerThresholdReached = scrollTop < this._buffers[0].translateY + this.itemHeight + bufferOffset;
190
+ const offset = this.itemHeight + this.bufferOffset;
191
+ const upperThresholdReached = scrollTop > this._buffers[1].translateY + offset;
192
+ const lowerThresholdReached = scrollTop < this._buffers[0].translateY + offset;
193
193
 
194
194
  if (upperThresholdReached || lowerThresholdReached) {
195
195
  this._translateBuffer(lowerThresholdReached);
@@ -241,6 +241,13 @@ class InfiniteScrollerElement extends PolymerElement {
241
241
 
242
242
  }
243
243
 
244
+ /**
245
+ * @return {number}
246
+ */
247
+ get bufferOffset() {
248
+ return this._buffers[0].offsetTop;
249
+ }
250
+
244
251
  /**
245
252
  * @private
246
253
  */
@@ -129,14 +129,8 @@ const $_documentContainer = html`<dom-module id="lumo-date-picker-overlay-conten
129
129
  }
130
130
  }
131
131
 
132
- /* Today and Cancel buttons */
133
-
134
- /* TODO: Would be great if I could apply the "tertiary" theme from here instead of copying those styles */
135
132
  [part="toolbar"] [part\$="button"] {
136
- background-color: transparent;
137
133
  margin: 0;
138
- min-width: 0;
139
- padding: 0 0.75em;
140
134
  }
141
135
 
142
136
  /* Narrow viewport mode (fullscreen) */