@vaadin/date-picker 23.1.0-beta1 → 23.1.0-beta4

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.1.0-beta1",
3
+ "version": "23.1.0-beta4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,21 +34,21 @@
34
34
  "dependencies": {
35
35
  "@open-wc/dedupe-mixin": "^1.3.0",
36
36
  "@polymer/polymer": "^3.2.0",
37
- "@vaadin/button": "23.1.0-beta1",
38
- "@vaadin/component-base": "23.1.0-beta1",
39
- "@vaadin/field-base": "23.1.0-beta1",
40
- "@vaadin/input-container": "23.1.0-beta1",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-beta1",
42
- "@vaadin/vaadin-material-styles": "23.1.0-beta1",
43
- "@vaadin/vaadin-overlay": "23.1.0-beta1",
44
- "@vaadin/vaadin-themable-mixin": "23.1.0-beta1"
37
+ "@vaadin/button": "23.1.0-beta4",
38
+ "@vaadin/component-base": "23.1.0-beta4",
39
+ "@vaadin/field-base": "23.1.0-beta4",
40
+ "@vaadin/input-container": "23.1.0-beta4",
41
+ "@vaadin/vaadin-lumo-styles": "23.1.0-beta4",
42
+ "@vaadin/vaadin-material-styles": "23.1.0-beta4",
43
+ "@vaadin/vaadin-overlay": "23.1.0-beta4",
44
+ "@vaadin/vaadin-themable-mixin": "23.1.0-beta4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/dialog": "23.1.0-beta1",
49
- "@vaadin/polymer-legacy-adapter": "23.1.0-beta1",
48
+ "@vaadin/dialog": "23.1.0-beta4",
49
+ "@vaadin/polymer-legacy-adapter": "23.1.0-beta4",
50
50
  "@vaadin/testing-helpers": "^0.3.2",
51
51
  "sinon": "^13.0.2"
52
52
  },
53
- "gitHead": "8be43cf83102a6b9ccf309687446e590ce0164e8"
53
+ "gitHead": "06e283473964ecb3085aacf3eddb5333d052a045"
54
54
  }
@@ -84,8 +84,8 @@ export function getClosestDate(date, dates) {
84
84
  return candidate;
85
85
  }
86
86
 
87
- var candidateDiff = Math.abs(date.getTime() - candidate.getTime());
88
- var closestDateDiff = Math.abs(closestDate.getTime() - date.getTime());
87
+ const candidateDiff = Math.abs(date.getTime() - candidate.getTime());
88
+ const closestDateDiff = Math.abs(closestDate.getTime() - date.getTime());
89
89
  return candidateDiff < closestDateDiff ? candidate : closestDate;
90
90
  });
91
91
  }
@@ -26,9 +26,9 @@ export interface DatePickerI18n {
26
26
  clear: string;
27
27
  today: string;
28
28
  cancel: string;
29
- parseDate: (date: string) => DatePickerDate | undefined;
30
- formatDate: (date: DatePickerDate) => string;
31
- formatTitle: (monthName: string, fullYear: number) => string;
29
+ parseDate(date: string): DatePickerDate | undefined;
30
+ formatDate(date: DatePickerDate): string;
31
+ formatTitle(monthName: string, fullYear: number): string;
32
32
  }
33
33
 
34
34
  export declare function DatePickerMixin<T extends Constructor<HTMLElement>>(
@@ -55,6 +55,7 @@ export declare class DatePickerMixinClass {
55
55
  * Date which should be visible when there is no value selected.
56
56
  *
57
57
  * The same date formats as for the `value` property are supported.
58
+ * @attr {string} initial-position
58
59
  */
59
60
  initialPosition: string | null | undefined;
60
61
 
@@ -65,6 +66,7 @@ export declare class DatePickerMixinClass {
65
66
 
66
67
  /**
67
68
  * Set true to prevent the overlay from opening automatically.
69
+ * @attr {boolean} auto-open-disabled
68
70
  */
69
71
  autoOpenDisabled: boolean | null | undefined;
70
72
 
@@ -72,6 +74,7 @@ export declare class DatePickerMixinClass {
72
74
  * Set true to display ISO-8601 week numbers in the calendar. Notice that
73
75
  * displaying week numbers is only supported when `i18n.firstDayOfWeek`
74
76
  * is 1 (Monday).
77
+ * @attr {boolean} show-week-numbers
75
78
  */
76
79
  showWeekNumbers: boolean | null | undefined;
77
80
 
@@ -288,7 +288,7 @@ export const DatePickerMixin = (subclass) =>
288
288
  */
289
289
  _minDate: {
290
290
  type: Date,
291
- // null does not work here because minimizer passes undefined to overlay (#351)
291
+ // Null does not work here because minimizer passes undefined to overlay (#351)
292
292
  value: '',
293
293
  },
294
294
 
@@ -535,7 +535,7 @@ export const DatePickerMixin = (subclass) =>
535
535
  if (this.inputElement.checkValidity) {
536
536
  inputValidity = this.inputElement.checkValidity();
537
537
  } else if (this.inputElement.validate) {
538
- // iron-form-elements have the validate API
538
+ // Iron-form-elements have the validate API
539
539
  inputValidity = this.inputElement.validate();
540
540
  }
541
541
  }
@@ -780,8 +780,8 @@ export const DatePickerMixin = (subclass) =>
780
780
  const oldInlineValue = element.style.webkitOverflowScrolling;
781
781
  element.style.webkitOverflowScrolling = 'auto';
782
782
  result.push({
783
- element: element,
784
- oldInlineValue: oldInlineValue,
783
+ element,
784
+ oldInlineValue,
785
785
  });
786
786
  }
787
787
  element = element.parentElement;
@@ -931,8 +931,8 @@ export const DatePickerMixin = (subclass) =>
931
931
  // The input element cannot be readonly as it would conflict with
932
932
  // the required attribute. Both are not allowed on an input element.
933
933
  // Therefore we prevent default on most keydown events.
934
- var allowedKeys = [
935
- 9, // tab
934
+ const allowedKeys = [
935
+ 9, // Tab
936
936
  ];
937
937
  if (allowedKeys.indexOf(e.keyCode) === -1) {
938
938
  e.preventDefault();
@@ -942,7 +942,7 @@ export const DatePickerMixin = (subclass) =>
942
942
  switch (e.key) {
943
943
  case 'ArrowDown':
944
944
  case 'ArrowUp':
945
- // prevent scrolling the page with arrows
945
+ // Prevent scrolling the page with arrows
946
946
  e.preventDefault();
947
947
  if (this.opened) {
948
948
  // The overlay can be opened with ctrl + option + shift in VoiceOver
@@ -233,6 +233,11 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
233
233
 
234
234
  static get properties() {
235
235
  return {
236
+ scrollDuration: {
237
+ type: Number,
238
+ default: 300,
239
+ },
240
+
236
241
  /**
237
242
  * The value for this element.
238
243
  */
@@ -465,7 +470,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
465
470
  }
466
471
 
467
472
  _onTodayTap() {
468
- var today = new Date();
473
+ const today = new Date();
469
474
 
470
475
  if (Math.abs(this.$.monthScroller.position - this._differenceInMonths(today, this._originDate)) < 0.001) {
471
476
  // Select today only if the month scroller is positioned approximately
@@ -491,9 +496,9 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
491
496
 
492
497
  _onYearTap(e) {
493
498
  if (!this._ignoreTaps && !this._notTapping) {
494
- var scrollDelta =
499
+ const scrollDelta =
495
500
  e.detail.y - (this.$.yearScroller.getBoundingClientRect().top + this.$.yearScroller.clientHeight / 2);
496
- var yearDelta = scrollDelta / this.$.yearScroller.itemHeight;
501
+ const yearDelta = scrollDelta / this.$.yearScroller.itemHeight;
497
502
  this._scrollToPosition(this.$.monthScroller.position + yearDelta * 12, true);
498
503
  }
499
504
  }
@@ -515,7 +520,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
515
520
  this._targetPosition = targetPosition;
516
521
 
517
522
  // http://gizma.com/easing/
518
- var easingFunction = (t, b, c, d) => {
523
+ const easingFunction = (t, b, c, d) => {
519
524
  t /= d / 2;
520
525
  if (t < 1) {
521
526
  return (c / 2) * t * t + b;
@@ -524,16 +529,20 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
524
529
  return (-c / 2) * (t * (t - 2) - 1) + b;
525
530
  };
526
531
 
527
- var duration = animate ? 300 : 0;
528
- var start = 0;
529
- var initialPosition = this.$.monthScroller.position;
532
+ let start = 0;
533
+ const initialPosition = this.$.monthScroller.position;
530
534
 
531
- var smoothScroll = (timestamp) => {
535
+ const smoothScroll = (timestamp) => {
532
536
  start = start || timestamp;
533
- var currentTime = timestamp - start;
534
-
535
- if (currentTime < duration) {
536
- var currentPos = easingFunction(currentTime, initialPosition, this._targetPosition - initialPosition, duration);
537
+ const currentTime = timestamp - start;
538
+
539
+ if (currentTime < this.scrollDuration) {
540
+ const currentPos = easingFunction(
541
+ currentTime,
542
+ initialPosition,
543
+ this._targetPosition - initialPosition,
544
+ this.scrollDuration,
545
+ );
537
546
  this.$.monthScroller.position = currentPos;
538
547
  window.requestAnimationFrame(smoothScroll);
539
548
  } else {
@@ -576,7 +585,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
576
585
  this._toggleAnimateClass(true);
577
586
  }
578
587
 
579
- var newTranslateX = this._translateX + e.detail.ddx;
588
+ const newTranslateX = this._translateX + e.detail.ddx;
580
589
  this._translateX = this._limit(newTranslateX, {
581
590
  min: 0,
582
591
  max: this._yearScrollerWidth,
@@ -647,7 +656,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
647
656
  }
648
657
 
649
658
  _yearAfterXYears(index) {
650
- var result = new Date(this._originDate);
659
+ const result = new Date(this._originDate);
651
660
  result.setFullYear(parseInt(index) + this._originDate.getFullYear());
652
661
  return result.getFullYear();
653
662
  }
@@ -657,14 +666,14 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
657
666
  }
658
667
 
659
668
  _dateAfterXMonths(months) {
660
- var result = new Date(this._originDate);
669
+ const result = new Date(this._originDate);
661
670
  result.setDate(1);
662
671
  result.setMonth(parseInt(months) + this._originDate.getMonth());
663
672
  return result;
664
673
  }
665
674
 
666
675
  _differenceInMonths(date1, date2) {
667
- var months = (date1.getFullYear() - date2.getFullYear()) * 12;
676
+ const months = (date1.getFullYear() - date2.getFullYear()) * 12;
668
677
  return months - date2.getMonth() + date1.getMonth();
669
678
  }
670
679
 
@@ -841,8 +850,8 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
841
850
  }
842
851
 
843
852
  _moveFocusByDays(days) {
844
- var focus = this.focusedDate;
845
- var dateToFocus = new Date(0, 0);
853
+ const focus = this.focusedDate;
854
+ const dateToFocus = new Date(0, 0);
846
855
  dateToFocus.setFullYear(focus.getFullYear());
847
856
  dateToFocus.setMonth(focus.getMonth());
848
857
  dateToFocus.setDate(focus.getDate() + days);
@@ -852,10 +861,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
852
861
  } else if (this._dateAllowed(focus, this.minDate, this.maxDate)) {
853
862
  // Move to min or max date
854
863
  if (days > 0) {
855
- // down or right
864
+ // Down or right
856
865
  this.focusDate(this.maxDate);
857
866
  } else {
858
- // up or left
867
+ // Up or left
859
868
  this.focusDate(this.minDate);
860
869
  }
861
870
  } else {
@@ -865,12 +874,12 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
865
874
  }
866
875
 
867
876
  _moveFocusByMonths(months) {
868
- var focus = this.focusedDate;
869
- var dateToFocus = new Date(0, 0);
877
+ const focus = this.focusedDate;
878
+ const dateToFocus = new Date(0, 0);
870
879
  dateToFocus.setFullYear(focus.getFullYear());
871
880
  dateToFocus.setMonth(focus.getMonth() + months);
872
881
 
873
- var targetMonth = dateToFocus.getMonth();
882
+ const targetMonth = dateToFocus.getMonth();
874
883
 
875
884
  dateToFocus.setDate(this._focusedMonthDate || (this._focusedMonthDate = focus.getDate()));
876
885
  if (dateToFocus.getMonth() !== targetMonth) {
@@ -882,10 +891,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
882
891
  } else if (this._dateAllowed(focus, this.minDate, this.maxDate)) {
883
892
  // Move to min or max date
884
893
  if (months > 0) {
885
- // pagedown
894
+ // Pagedown
886
895
  this.focusDate(this.maxDate);
887
896
  } else {
888
- // pageup
897
+ // Pageup
889
898
  this.focusDate(this.minDate);
890
899
  }
891
900
  } else {
@@ -895,7 +904,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
895
904
  }
896
905
 
897
906
  _moveFocusInsideMonth(focusedDate, property) {
898
- var dateToFocus = new Date(0, 0);
907
+ const dateToFocus = new Date(0, 0);
899
908
  dateToFocus.setFullYear(focusedDate.getFullYear());
900
909
 
901
910
  if (property === 'minDate') {
@@ -922,8 +931,8 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
922
931
  }
923
932
 
924
933
  _isTodayAllowed(min, max) {
925
- var today = new Date();
926
- var todayMidnight = new Date(0, 0);
934
+ const today = new Date();
935
+ const todayMidnight = new Date(0, 0);
927
936
  todayMidnight.setFullYear(today.getFullYear());
928
937
  todayMidnight.setMonth(today.getMonth());
929
938
  todayMidnight.setDate(today.getDate());
@@ -125,7 +125,7 @@ class InfiniteScroller extends PolymerElement {
125
125
 
126
126
  const tpl = this.querySelector('template');
127
127
  this._TemplateClass = templatize(tpl, this, {
128
- forwardHostProp: function (prop, value) {
128
+ forwardHostProp(prop, value) {
129
129
  if (prop !== 'index') {
130
130
  this._buffers.forEach((buffer) => {
131
131
  [].forEach.call(buffer.children, (insertionPoint) => {
@@ -330,7 +330,7 @@ class InfiniteScroller extends PolymerElement {
330
330
  return;
331
331
  }
332
332
 
333
- var tmpInstance = itemWrapper.instance;
333
+ const tmpInstance = itemWrapper.instance;
334
334
 
335
335
  itemWrapper.instance = new this._TemplateClass({});
336
336
  itemWrapper.appendChild(itemWrapper.instance.root);
@@ -343,10 +343,10 @@ class InfiniteScroller extends PolymerElement {
343
343
  _updateClones(viewPortOnly) {
344
344
  this._firstIndex = ~~((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex;
345
345
 
346
- var scrollerRect = viewPortOnly ? this.$.scroller.getBoundingClientRect() : undefined;
346
+ const scrollerRect = viewPortOnly ? this.$.scroller.getBoundingClientRect() : undefined;
347
347
  this._buffers.forEach((buffer, bufferIndex) => {
348
348
  if (!buffer.updated) {
349
- var firstIndex = this._firstIndex + this.bufferSize * bufferIndex;
349
+ const firstIndex = this._firstIndex + this.bufferSize * bufferIndex;
350
350
 
351
351
  [].forEach.call(buffer.children, (insertionPoint, index) => {
352
352
  const itemWrapper = insertionPoint._itemWrapper;
@@ -360,7 +360,7 @@ class InfiniteScroller extends PolymerElement {
360
360
  }
361
361
 
362
362
  _isVisible(element, container) {
363
- var rect = element.getBoundingClientRect();
363
+ const rect = element.getBoundingClientRect();
364
364
  return rect.bottom > container.top && rect.top < container.bottom;
365
365
  }
366
366
  }
@@ -217,13 +217,13 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
217
217
  /* Returns true if all the dates in the month are out of the allowed range */
218
218
  _isDisabled(month, minDate, maxDate) {
219
219
  // First day of the month
220
- var firstDate = new Date(0, 0);
220
+ const firstDate = new Date(0, 0);
221
221
  firstDate.setFullYear(month.getFullYear());
222
222
  firstDate.setMonth(month.getMonth());
223
223
  firstDate.setDate(1);
224
224
 
225
225
  // Last day of the month
226
- var lastDate = new Date(0, 0);
226
+ const lastDate = new Date(0, 0);
227
227
  lastDate.setFullYear(month.getFullYear());
228
228
  lastDate.setMonth(month.getMonth() + 1);
229
229
  lastDate.setDate(0);
@@ -320,7 +320,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
320
320
  return;
321
321
  }
322
322
  // First day of the month (at midnight).
323
- var date = new Date(0, 0);
323
+ const date = new Date(0, 0);
324
324
  date.setFullYear(month.getFullYear());
325
325
  date.setMonth(month.getMonth());
326
326
  date.setDate(1);
@@ -330,9 +330,9 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
330
330
  this._dateAdd(date, -1);
331
331
  }
332
332
 
333
- var days = [];
334
- var startMonth = date.getMonth();
335
- var targetMonth = month.getMonth();
333
+ const days = [];
334
+ const startMonth = date.getMonth();
335
+ const targetMonth = month.getMonth();
336
336
  while (date.getMonth() === targetMonth || date.getMonth() === startMonth) {
337
337
  days.push(date.getMonth() === targetMonth ? new Date(date.getTime()) : null);
338
338
 
@@ -406,7 +406,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
406
406
  return '';
407
407
  }
408
408
 
409
- var ariaLabel = `${this._getDate(date)} ${this.i18n.monthNames[date.getMonth()]} ${date.getFullYear()}, ${
409
+ let ariaLabel = `${this._getDate(date)} ${this.i18n.monthNames[date.getMonth()]} ${date.getFullYear()}, ${
410
410
  this.i18n.weekdays[date.getDay()]
411
411
  }`;
412
412