@vaadin/date-picker 25.3.0-alpha13 → 25.3.0-alpha14

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.3.0-alpha13",
3
+ "version": "25.3.0-alpha14",
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.3.0-alpha13",
39
- "@vaadin/button": "25.3.0-alpha13",
40
- "@vaadin/component-base": "25.3.0-alpha13",
41
- "@vaadin/field-base": "25.3.0-alpha13",
42
- "@vaadin/input-container": "25.3.0-alpha13",
43
- "@vaadin/overlay": "25.3.0-alpha13",
44
- "@vaadin/vaadin-themable-mixin": "25.3.0-alpha13",
38
+ "@vaadin/a11y-base": "25.3.0-alpha14",
39
+ "@vaadin/button": "25.3.0-alpha14",
40
+ "@vaadin/component-base": "25.3.0-alpha14",
41
+ "@vaadin/field-base": "25.3.0-alpha14",
42
+ "@vaadin/input-container": "25.3.0-alpha14",
43
+ "@vaadin/overlay": "25.3.0-alpha14",
44
+ "@vaadin/vaadin-themable-mixin": "25.3.0-alpha14",
45
45
  "lit": "^3.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@vaadin/aura": "25.3.0-alpha13",
49
- "@vaadin/chai-plugins": "25.3.0-alpha13",
50
- "@vaadin/test-runner-commands": "25.3.0-alpha13",
48
+ "@vaadin/aura": "25.3.0-alpha14",
49
+ "@vaadin/chai-plugins": "25.3.0-alpha14",
50
+ "@vaadin/test-runner-commands": "25.3.0-alpha14",
51
51
  "@vaadin/testing-helpers": "^2.0.0",
52
- "@vaadin/vaadin-lumo-styles": "25.3.0-alpha13",
52
+ "@vaadin/vaadin-lumo-styles": "25.3.0-alpha14",
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": "e23e44d29e6bc1e47245d5e2cc0e4b022ec61818"
60
+ "gitHead": "10a01ae7a1e278af50eda7255dbb68dafc0e4caf"
61
61
  }
@@ -6,19 +6,85 @@
6
6
  import type { DateMetadataController } from './vaadin-date-metadata-controller.js';
7
7
  import type { DatePickerDate } from './vaadin-date-picker-mixin.js';
8
8
 
9
+ /**
10
+ * Create a date at midnight in local time. Unlike `new Date(year, month, day)`,
11
+ * this supports years below 100, which the constructor maps into the 20th
12
+ * century. The month is assigned before the day so that the initial day of month
13
+ * (1) always exists in the target month.
14
+ *
15
+ * @param month Zero-based month, may be out of range to shift the year
16
+ * @param day May be `0` to select the last day of the previous month
17
+ */
18
+ declare function createDate(year: number, month: number, day: number): Date;
19
+
20
+ /**
21
+ * Get the first day of the month the given date is in.
22
+ */
23
+ declare function firstOfMonth(date: Date): Date;
24
+
25
+ /**
26
+ * Get the last day of the month the given date is in.
27
+ */
28
+ declare function lastOfMonth(date: Date): Date;
29
+
30
+ /**
31
+ * Get the index of a month, counted from January of year 0. Reduces a month to a single
32
+ * integer, so a lookup builds no key and two months are adjacent when their indexes are.
33
+ *
34
+ * @param month Zero-based month
35
+ */
36
+ declare function monthIndexOf(year: number, month: number): number;
37
+
38
+ /**
39
+ * Get the index of the month the given date is in.
40
+ */
41
+ declare function monthIndex(date: Date): number;
42
+
43
+ /**
44
+ * Get the first day of the month with the given index, inverting `monthIndexOf`. Counting from
45
+ * January of year 0 also inverts negative indexes, since `createDate` normalizes a month outside
46
+ * 0-11 into the year.
47
+ */
48
+ declare function monthDate(index: number): Date;
49
+
9
50
  /**
10
51
  * Get ISO 8601 week number for the given date.
11
52
  *
12
53
  * @returns Week number
13
54
  */
14
- declare function getISOWeekNumber(Date: Date): number;
55
+ declare function getISOWeekNumber(date: Date): number;
56
+
57
+ /**
58
+ * Creates a new object with the same date, but sets the hours, minutes, seconds and milliseconds to 0.
59
+ *
60
+ * @param date in system timezone
61
+ * @returns The same date with time elements set to 0, in system timezone.
62
+ */
63
+ declare function normalizeDate(date: Date): Date;
64
+
65
+ /**
66
+ * Creates a new object with the same date, but sets the hours, minutes, seconds and milliseconds to 0.
67
+ *
68
+ * Uses UTC date components to allow handling date instances independently of
69
+ * the system time-zone.
70
+ *
71
+ * @param date in UTC timezone
72
+ * @returns The same date with time elements set to 0, in UTC timezone.
73
+ */
74
+ declare function normalizeUTCDate(date: Date): Date;
15
75
 
16
76
  /**
17
77
  * Check if two dates are equal.
18
78
  *
19
79
  * @returns True if the given date objects refer to the same date
20
80
  */
21
- declare function dateEquals(date1: Date | null, date2: Date | null): boolean;
81
+ declare function dateEquals(date1: Date | null, date2: Date | null, normalizer?: (date: Date) => Date): boolean;
82
+
83
+ /**
84
+ * Extracts the basic component parts of a date (day, month and year)
85
+ * to the expected format.
86
+ */
87
+ declare function extractDateParts(date: Date): { day: number; month: number; year: number };
22
88
 
23
89
  /**
24
90
  * Check if the given date is in the range of allowed dates.
@@ -55,37 +121,85 @@ declare function dateSelectable(
55
121
  declare function getClosestDate(date: Date, dates: Date[]): Date;
56
122
 
57
123
  /**
58
- * Extracts the basic component parts of a date (day, month and year)
59
- * to the expected format.
124
+ * Get difference in months between today and given months value.
60
125
  */
61
- declare function extractDateParts(date: Date): { day: number; month: number; year: number };
126
+ declare function dateAfterXMonths(months: number): Date;
62
127
 
63
128
  /**
64
- * Get difference in months between today and given months value.
129
+ * Calculate the year of the date based on the provided reference date.
130
+ * Gets a two-digit year and returns a full year.
131
+ *
132
+ * @param year Should be in the range of [0, 99]
133
+ * @returns Adjusted year value
65
134
  */
66
- declare function dateAfterXMonths(months: number): number;
135
+ declare function getAdjustedYear(referenceDate: Date, year: number, month?: number, day?: number): number;
67
136
 
68
137
  /**
69
- * Calculate the year of the date based on the provided reference date
70
- * Gets a two-digit year and returns a full year.
138
+ * Parse date string of one of the following date formats:
139
+ * - ISO 8601 `"YYYY-MM-DD"`
140
+ * - Extended ISO 8601 with a signed year, e.g. `"+012026-MM-DD"` or `"-0001-MM-DD"`
141
+ *
142
+ * A date that does not exist, such as `"2026-02-30"`, is not parsed. Building it would carry the
143
+ * surplus into the next month or year and answer with a date that was never asked for.
144
+ *
145
+ * @param str Date string to parse
146
+ * @returns Parsed date in system timezone, or `undefined` when the string is not a date
71
147
  */
72
- declare function getAdjustedYear(referenceDate: Date, year: number, month?: number, day?: number): Date;
148
+ declare function parseDate(str: string): Date | undefined;
73
149
 
74
150
  /**
75
151
  * Parse date string of one of the following date formats:
76
152
  * - ISO 8601 `"YYYY-MM-DD"`
77
- * - 6-digit extended ISO 8601 `"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`
153
+ * - Extended ISO 8601 with a signed year, e.g. `"+012026-MM-DD"` or `"-0001-MM-DD"`
154
+ *
155
+ * Uses UTC date components to allow handling date instances independently of
156
+ * the system time-zone.
157
+ *
158
+ * A date that does not exist, such as `"2026-02-30"`, is not parsed, as in `parseDate`.
159
+ *
160
+ * @param str Date string to parse
161
+ * @returns Parsed date in UTC timezone, or `undefined` when the string is not a date
162
+ */
163
+ declare function parseUTCDate(str: string): Date | undefined;
164
+
165
+ /**
166
+ * Format a date instance in ISO 8601 (`"YYYY-MM-DD"`) or 6-digit extended ISO
167
+ * 8601 (`"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`) format.
168
+ *
169
+ * @param date in system timezone
78
170
  */
79
- declare function parseDate(str: string): Date;
171
+ declare function formatISODate(date: Date): string;
172
+
173
+ /**
174
+ * Format a date instance in ISO 8601 (`"YYYY-MM-DD"`) or 6-digit extended ISO
175
+ * 8601 (`"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`) format.
176
+ *
177
+ * Uses UTC date components to allow handling date instances independently of
178
+ * the system time-zone.
179
+ *
180
+ * @param date in UTC timezone
181
+ */
182
+ declare function formatUTCISODate(date: Date): string;
80
183
 
81
184
  export {
185
+ createDate,
186
+ firstOfMonth,
187
+ lastOfMonth,
188
+ monthIndexOf,
189
+ monthIndex,
190
+ monthDate,
82
191
  getISOWeekNumber,
192
+ normalizeDate,
193
+ normalizeUTCDate,
83
194
  dateEquals,
195
+ extractDateParts,
84
196
  dateAllowed,
85
197
  dateSelectable,
86
198
  getClosestDate,
87
- extractDateParts,
88
199
  dateAfterXMonths,
89
200
  getAdjustedYear,
90
201
  parseDate,
202
+ parseUTCDate,
203
+ formatISODate,
204
+ formatUTCISODate,
91
205
  };
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.3.0-alpha13",
4
+ "version": "25.3.0-alpha14",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/date-picker",
4
- "version": "25.3.0-alpha13",
4
+ "version": "25.3.0-alpha14",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {