@vaadin/date-picker 25.4.0-alpha3 → 25.4.0-alpha5

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": "25.4.0-alpha3",
3
+ "version": "25.4.0-alpha5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,21 +35,21 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/a11y-base": "25.4.0-alpha3",
39
- "@vaadin/button": "25.4.0-alpha3",
40
- "@vaadin/component-base": "25.4.0-alpha3",
41
- "@vaadin/field-base": "25.4.0-alpha3",
42
- "@vaadin/input-container": "25.4.0-alpha3",
43
- "@vaadin/overlay": "25.4.0-alpha3",
44
- "@vaadin/vaadin-themable-mixin": "25.4.0-alpha3",
38
+ "@vaadin/a11y-base": "25.4.0-alpha5",
39
+ "@vaadin/button": "25.4.0-alpha5",
40
+ "@vaadin/component-base": "25.4.0-alpha5",
41
+ "@vaadin/field-base": "25.4.0-alpha5",
42
+ "@vaadin/input-container": "25.4.0-alpha5",
43
+ "@vaadin/overlay": "25.4.0-alpha5",
44
+ "@vaadin/vaadin-themable-mixin": "25.4.0-alpha5",
45
45
  "lit": "^3.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@vaadin/aura": "25.4.0-alpha3",
49
- "@vaadin/chai-plugins": "25.4.0-alpha3",
50
- "@vaadin/test-runner-commands": "25.4.0-alpha3",
48
+ "@vaadin/aura": "25.4.0-alpha5",
49
+ "@vaadin/chai-plugins": "25.4.0-alpha5",
50
+ "@vaadin/test-runner-commands": "25.4.0-alpha5",
51
51
  "@vaadin/testing-helpers": "^2.0.0",
52
- "@vaadin/vaadin-lumo-styles": "25.4.0-alpha3",
52
+ "@vaadin/vaadin-lumo-styles": "25.4.0-alpha5",
53
53
  "sinon": "^22.0.0"
54
54
  },
55
55
  "customElements": "custom-elements.json",
@@ -57,5 +57,5 @@
57
57
  "web-types.json",
58
58
  "web-types.lit.json"
59
59
  ],
60
- "gitHead": "db7e679c1a8af00840cc05ddcbefff68dfed1e45"
60
+ "gitHead": "65e9c9e49c0a723b08ee91b9aae8b901e91a3597"
61
61
  }
@@ -69,7 +69,8 @@ export const monthCalendarStyles = css`
69
69
 
70
70
  [part~='weekday'],
71
71
  [part~='week-number'],
72
- [part~='date'] {
72
+ [part~='date'],
73
+ .date-button {
73
74
  align-items: center;
74
75
  display: flex;
75
76
  justify-content: center;
@@ -81,7 +82,6 @@ export const monthCalendarStyles = css`
81
82
  position: relative;
82
83
  height: var(--vaadin-date-picker-date-height, 2rem);
83
84
  cursor: var(--vaadin-clickable-cursor);
84
- outline: none;
85
85
  }
86
86
 
87
87
  [part~='date']:empty {
@@ -97,7 +97,13 @@ export const monthCalendarStyles = css`
97
97
  aspect-ratio: 1;
98
98
  }
99
99
 
100
- :where([part~='date']:focus-visible)::after {
100
+ .date-button {
101
+ flex: 1;
102
+ align-self: stretch;
103
+ outline: none;
104
+ }
105
+
106
+ :where([part~='date']:has(:focus-visible))::after {
101
107
  outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
102
108
  outline-offset: calc(var(--vaadin-focus-ring-width) * -1);
103
109
  }
@@ -8,9 +8,16 @@ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-foc
8
8
  import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
9
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
10
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
11
+ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
11
12
  import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
13
+ import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
14
+ import type { ClearButtonMixinClass } from '@vaadin/field-base/src/clear-button-mixin.js';
15
+ import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
12
16
  import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
17
+ import type { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
13
18
  import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
19
+ import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
20
+ import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
14
21
 
15
22
  export interface DatePickerDate {
16
23
  day: number;
@@ -135,14 +142,21 @@ export interface DatePickerI18n {
135
142
 
136
143
  export declare function DatePickerMixin<T extends Constructor<HTMLElement>>(
137
144
  base: T,
138
- ): Constructor<DatePickerMixinClass> &
145
+ ): Constructor<ClearButtonMixinClass> &
146
+ Constructor<DatePickerMixinClass> &
139
147
  Constructor<DelegateFocusMixinClass> &
148
+ Constructor<DelegateStateMixinClass> &
140
149
  Constructor<DisabledMixinClass> &
150
+ Constructor<FieldMixinClass> &
141
151
  Constructor<FocusMixinClass> &
142
152
  Constructor<I18nMixinClass<DatePickerI18n>> &
143
153
  Constructor<InputConstraintsMixinClass> &
154
+ Constructor<InputControlMixinClass> &
144
155
  Constructor<InputMixinClass> &
145
156
  Constructor<KeyboardMixinClass> &
157
+ Constructor<LabelMixinClass> &
158
+ Constructor<SlotStylesMixinClass> &
159
+ Constructor<ValidateMixinClass> &
146
160
  T;
147
161
 
148
162
  export declare class DatePickerMixinClass {
@@ -4,14 +4,12 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { hideOthers } from '@vaadin/a11y-base/src/aria-hidden.js';
7
- import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
8
7
  import { isElementFocused, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
9
- import { KeyboardMixin } from '@vaadin/a11y-base/src/keyboard-mixin.js';
10
8
  import { isIOS } from '@vaadin/component-base/src/browser-utils.js';
11
9
  import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
12
10
  import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
13
11
  import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
14
- import { InputConstraintsMixin } from '@vaadin/field-base/src/input-constraints-mixin.js';
12
+ import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
15
13
  import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
16
14
  import { DateMetadataController } from './vaadin-date-metadata-controller.js';
17
15
  import {
@@ -83,7 +81,7 @@ export const datePickerI18nDefaults = Object.freeze({
83
81
  });
84
82
 
85
83
  export const DatePickerMixin = (subclass) =>
86
- class DatePickerMixinClass extends I18nMixin(DelegateFocusMixin(InputConstraintsMixin(KeyboardMixin(subclass)))) {
84
+ class DatePickerMixinClass extends I18nMixin(InputControlMixin(subclass)) {
87
85
  static get properties() {
88
86
  return {
89
87
  /**
@@ -230,6 +230,10 @@ export const DatePickerOverlayContentMixin = (superClass) =>
230
230
  return this.calendars.map((calendar) => calendar.focusableDateElement).find(Boolean);
231
231
  }
232
232
 
233
+ get focusableDateButton() {
234
+ return this.calendars.map((calendar) => calendar.focusableDateButton).find(Boolean);
235
+ }
236
+
233
237
  /** @protected */
234
238
  _initControllers() {
235
239
  this.addController(
@@ -897,12 +901,12 @@ export const DatePickerOverlayContentMixin = (superClass) =>
897
901
  __tryFocusDate() {
898
902
  const dateToFocus = this.__pendingDateFocus;
899
903
  if (dateToFocus) {
900
- // Check the date element with tabindex="0"
904
+ // Check the cell of the date that has the focusable button
901
905
  const dateElement = this.focusableDateElement;
902
906
 
903
907
  if (dateElement && dateEquals(dateElement.date, this.__pendingDateFocus)) {
904
908
  delete this.__pendingDateFocus;
905
- dateElement.focus();
909
+ this.focusableDateButton.focus();
906
910
  }
907
911
  }
908
912
  }
@@ -4,7 +4,6 @@
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';
7
- import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
8
7
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
8
  import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
10
9
  export {
@@ -256,7 +255,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
256
255
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
257
256
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
258
257
  */
259
- declare class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
258
+ declare class DatePicker extends DatePickerMixin(ThemableMixin(ElementMixin(HTMLElement))) {
260
259
  addEventListener<K extends keyof DatePickerEventMap>(
261
260
  type: K,
262
261
  listener: (this: DatePicker, ev: DatePickerEventMap[K]) => void,
@@ -12,7 +12,6 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
12
12
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
13
13
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
14
14
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
15
- import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
16
15
  import { InputController } from '@vaadin/field-base/src/input-controller.js';
17
16
  import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
18
17
  import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
@@ -218,9 +217,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
218
217
  * @customElement vaadin-date-picker
219
218
  * @extends HTMLElement
220
219
  */
221
- class DatePicker extends DatePickerMixin(
222
- InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
223
- ) {
220
+ class DatePicker extends DatePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
224
221
  static get is() {
225
222
  return 'vaadin-date-picker';
226
223
  }
@@ -146,15 +146,32 @@ export const MonthCalendarMixin = (superClass) =>
146
146
  return ['__focusedDateChanged(focusedDate, _days)', '_showWeekNumbersChanged(showWeekNumbers, i18n)'];
147
147
  }
148
148
 
149
+ /**
150
+ * The date cell of the focused date. It carries the `date` property and the date part names,
151
+ * while the button inside it is the element that takes DOM focus.
152
+ */
149
153
  get focusableDateElement() {
150
154
  return [...this.shadowRoot.querySelectorAll('[part~=date]')].find((datePart) => {
151
155
  return dateEquals(datePart.date, this.focusedDate);
152
156
  });
153
157
  }
154
158
 
159
+ /**
160
+ * The button inside the cell of the focused date. Screen readers get the date's name and state
161
+ * from this element, so it is also the element that takes DOM focus.
162
+ */
163
+ get focusableDateButton() {
164
+ const cell = this.focusableDateElement;
165
+ return cell ? cell.querySelector('.date-button') : undefined;
166
+ }
167
+
155
168
  /** @protected */
156
169
  ready() {
157
170
  super.ready();
171
+
172
+ // Use application to enforce focus mode for date cells in NVDA
173
+ this.setAttribute('role', 'application');
174
+
158
175
  addListener(this.$.monthGrid, 'tap', this._handleTap.bind(this));
159
176
  }
160
177
 
@@ -289,18 +306,18 @@ export const MonthCalendarMixin = (superClass) =>
289
306
  if (i % 7 === 0) {
290
307
  acc.push([]);
291
308
  }
292
- acc[acc.length - 1].push(day);
309
+ acc.at(-1).push(day);
293
310
  return acc;
294
311
  }, []);
295
312
  }
296
313
 
297
314
  /** @protected */
298
315
  _handleTap(e) {
299
- if (!this.ignoreTaps && !this._notTapping && e.target.date && !e.target.hasAttribute('disabled')) {
300
- this.selectedDate = e.target.date;
301
- this.dispatchEvent(
302
- new CustomEvent('date-tap', { detail: { date: e.target.date }, bubbles: true, composed: true }),
303
- );
316
+ // A tap can land on the button or on the cell padding around it.
317
+ const cell = e.target.closest('[part~=date]');
318
+ if (!this.ignoreTaps && !this._notTapping && cell?.date && !cell.hasAttribute('disabled')) {
319
+ this.selectedDate = cell.date;
320
+ this.dispatchEvent(new CustomEvent('date-tap', { detail: { date: cell.date }, bubbles: true, composed: true }));
304
321
  }
305
322
  }
306
323
 
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html, LitElement } from 'lit';
6
+ import { html, LitElement, nothing } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
9
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
@@ -80,16 +80,24 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LumoIn
80
80
  )}"
81
81
  .date="${date}"
82
82
  ?disabled="${this.__isDayDisabled(date, this.minDate, this.maxDate, this.isDateDisabled)}"
83
- tabindex="${this.__computeDayTabIndex(date, this.focusedDate)}"
84
83
  aria-selected="${this.__computeDayAriaSelected(date, this.selectedDate)}"
85
- aria-disabled="${this.__computeDayAriaDisabled(
86
- date,
87
- this.minDate,
88
- this.maxDate,
89
- this.isDateDisabled,
90
- )}"
91
- aria-label="${this.__computeDayAriaLabel(date)}"
92
- >${this._getDate(date)}</td
84
+ >${
85
+ date
86
+ ? html`<div
87
+ class="date-button"
88
+ role="button"
89
+ tabindex="${this.__computeDayTabIndex(date, this.focusedDate)}"
90
+ aria-label="${this.__computeDayAriaLabel(date)}"
91
+ aria-disabled="${this.__computeDayAriaDisabled(
92
+ date,
93
+ this.minDate,
94
+ this.maxDate,
95
+ this.isDateDisabled,
96
+ )}"
97
+ >${this._getDate(date)}</div
98
+ >`
99
+ : nothing
100
+ }</td
93
101
  >
94
102
  `;
95
103
  })}
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/date-picker",
4
- "version": "25.4.0-alpha3",
4
+ "version": "25.4.0-alpha5",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -284,8 +284,8 @@
284
284
  }
285
285
  },
286
286
  {
287
- "name": "autofocus",
288
- "description": "Specify that this control should have input focus when the page loads.",
287
+ "name": "autoOpenDisabled",
288
+ "description": "Set true to prevent the overlay from opening automatically.",
289
289
  "value": {
290
290
  "type": [
291
291
  "boolean"
@@ -293,8 +293,8 @@
293
293
  }
294
294
  },
295
295
  {
296
- "name": "autoOpenDisabled",
297
- "description": "Set true to prevent the overlay from opening automatically.",
296
+ "name": "autofocus",
297
+ "description": "Specify that this control should have input focus when the page loads.",
298
298
  "value": {
299
299
  "type": [
300
300
  "boolean"
@@ -362,7 +362,7 @@
362
362
  "description": "The object used to localize this component. To change the default\nlocalization, set this to an object that provides all properties, or\njust the individual properties you want to change.\n\nWhen not set, defaults to `undefined`.\n\nThe object has the following JSON structure and default values:\n\n```js\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Accessible name of the overlay content, announced by screen readers\n // when the overlay opens.\n dialogAccessibleName: 'Calendar',\n\n // Used for adjusting the year value when parsing dates with short years.\n // The year values between 0 and 99 are evaluated and adjusted.\n // Example: for a referenceDate of 1970-10-30;\n // dateToBeParsed: 40-10-30, result: 1940-10-30\n // dateToBeParsed: 80-10-30, result: 1980-10-30\n // dateToBeParsed: 10-10-30, result: 2010-10-30\n // Supported date format: ISO 8601 `\"YYYY-MM-DD\"` (default)\n // The default value is the current date.\n referenceDate: '',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
363
363
  "value": {
364
364
  "type": [
365
- "Object",
365
+ "DatePickerI18n",
366
366
  "undefined"
367
367
  ]
368
368
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/date-picker",
4
- "version": "25.4.0-alpha3",
4
+ "version": "25.4.0-alpha5",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -48,15 +48,15 @@
48
48
  }
49
49
  },
50
50
  {
51
- "name": "?autofocus",
52
- "description": "Specify that this control should have input focus when the page loads.",
51
+ "name": "?autoOpenDisabled",
52
+ "description": "Set true to prevent the overlay from opening automatically.",
53
53
  "value": {
54
54
  "kind": "expression"
55
55
  }
56
56
  },
57
57
  {
58
- "name": "?autoOpenDisabled",
59
- "description": "Set true to prevent the overlay from opening automatically.",
58
+ "name": "?autofocus",
59
+ "description": "Specify that this control should have input focus when the page loads.",
60
60
  "value": {
61
61
  "kind": "expression"
62
62
  }