@angular/material 21.0.0-next.8 → 21.0.0-rc.0
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/core/tokens/_classes.scss +1 -1
- package/core/tokens/m2/_md-sys-color.scss +17 -17
- package/fesm2022/_animation-chunk.mjs +10 -16
- package/fesm2022/_animation-chunk.mjs.map +1 -1
- package/fesm2022/_date-formats-chunk.mjs +68 -164
- package/fesm2022/_date-formats-chunk.mjs.map +1 -1
- package/fesm2022/_date-range-input-harness-chunk.mjs +284 -463
- package/fesm2022/_date-range-input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_error-options-chunk.mjs +56 -19
- package/fesm2022/_error-options-chunk.mjs.map +1 -1
- package/fesm2022/_error-state-chunk.mjs +24 -31
- package/fesm2022/_error-state-chunk.mjs.map +1 -1
- package/fesm2022/_form-field-chunk.mjs +1224 -1017
- package/fesm2022/_form-field-chunk.mjs.map +1 -1
- package/fesm2022/_icon-button-chunk.mjs +243 -187
- package/fesm2022/_icon-button-chunk.mjs.map +1 -1
- package/fesm2022/_icon-registry-chunk.mjs +350 -575
- package/fesm2022/_icon-registry-chunk.mjs.map +1 -1
- package/fesm2022/_input-harness-chunk.mjs +56 -107
- package/fesm2022/_input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_input-value-accessor-chunk.mjs +0 -6
- package/fesm2022/_input-value-accessor-chunk.mjs.map +1 -1
- package/fesm2022/_internal-form-field-chunk.mjs +59 -19
- package/fesm2022/_internal-form-field-chunk.mjs.map +1 -1
- package/fesm2022/_line-chunk.mjs +83 -43
- package/fesm2022/_line-chunk.mjs.map +1 -1
- package/fesm2022/_option-chunk.mjs +348 -311
- package/fesm2022/_option-chunk.mjs.map +1 -1
- package/fesm2022/_option-harness-chunk.mjs +23 -39
- package/fesm2022/_option-harness-chunk.mjs.map +1 -1
- package/fesm2022/_option-module-chunk.mjs +36 -10
- package/fesm2022/_option-module-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-chunk.mjs +79 -44
- package/fesm2022/_pseudo-checkbox-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs +36 -10
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs.map +1 -1
- package/fesm2022/_public-api-chunk.mjs +71 -134
- package/fesm2022/_public-api-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-chunk.mjs +504 -600
- package/fesm2022/_ripple-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-loader-chunk.mjs +120 -138
- package/fesm2022/_ripple-loader-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-module-chunk.mjs +36 -10
- package/fesm2022/_ripple-module-chunk.mjs.map +1 -1
- package/fesm2022/_structural-styles-chunk.mjs +37 -10
- package/fesm2022/_structural-styles-chunk.mjs.map +1 -1
- package/fesm2022/_tooltip-chunk.mjs +810 -888
- package/fesm2022/_tooltip-chunk.mjs.map +1 -1
- package/fesm2022/autocomplete-testing.mjs +62 -86
- package/fesm2022/autocomplete-testing.mjs.map +1 -1
- package/fesm2022/autocomplete.mjs +965 -1126
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge-testing.mjs +38 -54
- package/fesm2022/badge-testing.mjs.map +1 -1
- package/fesm2022/badge.mjs +321 -272
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet-testing.mjs +10 -24
- package/fesm2022/bottom-sheet-testing.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs +349 -344
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button-testing.mjs +60 -94
- package/fesm2022/button-testing.mjs.map +1 -1
- package/fesm2022/button-toggle-testing.mjs +76 -125
- package/fesm2022/button-toggle-testing.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs +752 -662
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs +263 -158
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card-testing.mjs +19 -33
- package/fesm2022/card-testing.mjs.map +1 -1
- package/fesm2022/card.mjs +576 -272
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox-testing.mjs +71 -123
- package/fesm2022/checkbox-testing.mjs.map +1 -1
- package/fesm2022/checkbox.mjs +515 -477
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips-testing.mjs +201 -350
- package/fesm2022/chips-testing.mjs.map +1 -1
- package/fesm2022/chips.mjs +2552 -2289
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/core-testing.mjs +14 -28
- package/fesm2022/core-testing.mjs.map +1 -1
- package/fesm2022/core.mjs +357 -328
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/datepicker-testing.mjs +15 -25
- package/fesm2022/datepicker-testing.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +4826 -4563
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog-testing.mjs +93 -129
- package/fesm2022/dialog-testing.mjs.map +1 -1
- package/fesm2022/dialog.mjs +810 -829
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider-testing.mjs +10 -11
- package/fesm2022/divider-testing.mjs.map +1 -1
- package/fesm2022/divider.mjs +119 -43
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/expansion-testing.mjs +74 -130
- package/fesm2022/expansion-testing.mjs.map +1 -1
- package/fesm2022/expansion.mjs +703 -515
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field-testing-control.mjs +16 -33
- package/fesm2022/form-field-testing-control.mjs.map +1 -1
- package/fesm2022/form-field-testing.mjs +118 -179
- package/fesm2022/form-field-testing.mjs.map +1 -1
- package/fesm2022/form-field.mjs +36 -10
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list-testing.mjs +65 -113
- package/fesm2022/grid-list-testing.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +559 -494
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon-testing.mjs +148 -127
- package/fesm2022/icon-testing.mjs.map +1 -1
- package/fesm2022/icon.mjs +325 -351
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/input-testing.mjs +59 -99
- package/fesm2022/input-testing.mjs.map +1 -1
- package/fesm2022/input.mjs +457 -520
- package/fesm2022/input.mjs.map +1 -1
- package/fesm2022/list-testing.mjs +251 -434
- package/fesm2022/list-testing.mjs.map +1 -1
- package/fesm2022/list.mjs +1522 -1204
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/material.mjs +0 -5
- package/fesm2022/material.mjs.map +1 -1
- package/fesm2022/menu-testing.mjs +159 -228
- package/fesm2022/menu-testing.mjs.map +1 -1
- package/fesm2022/menu.mjs +1338 -1343
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/paginator-testing.mjs +55 -79
- package/fesm2022/paginator-testing.mjs.map +1 -1
- package/fesm2022/paginator.mjs +381 -309
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar-testing.mjs +12 -21
- package/fesm2022/progress-bar-testing.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs +224 -169
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner-testing.mjs +13 -23
- package/fesm2022/progress-spinner-testing.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +235 -160
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/radio-testing.mjs +133 -208
- package/fesm2022/radio-testing.mjs.map +1 -1
- package/fesm2022/radio.mjs +712 -679
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/select-testing.mjs +83 -117
- package/fesm2022/select-testing.mjs.map +1 -1
- package/fesm2022/select.mjs +1116 -1246
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav-testing.mjs +54 -120
- package/fesm2022/sidenav-testing.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +1078 -995
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle-testing.mjs +57 -92
- package/fesm2022/slide-toggle-testing.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +369 -279
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider-testing.mjs +90 -138
- package/fesm2022/slider-testing.mjs.map +1 -1
- package/fesm2022/slider.mjs +1651 -1716
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar-testing.mjs +40 -87
- package/fesm2022/snack-bar-testing.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs +763 -714
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort-testing.mjs +45 -66
- package/fesm2022/sort-testing.mjs.map +1 -1
- package/fesm2022/sort.mjs +419 -344
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper-testing.mjs +78 -154
- package/fesm2022/stepper-testing.mjs.map +1 -1
- package/fesm2022/stepper.mjs +790 -498
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/table-testing.mjs +125 -186
- package/fesm2022/table-testing.mjs.map +1 -1
- package/fesm2022/table.mjs +1026 -684
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs-testing.mjs +125 -197
- package/fesm2022/tabs-testing.mjs.map +1 -1
- package/fesm2022/tabs.mjs +2351 -2028
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/timepicker-testing.mjs +113 -172
- package/fesm2022/timepicker-testing.mjs.map +1 -1
- package/fesm2022/timepicker.mjs +1019 -826
- package/fesm2022/timepicker.mjs.map +1 -1
- package/fesm2022/toolbar-testing.mjs +16 -27
- package/fesm2022/toolbar-testing.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +163 -78
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip-testing.mjs +41 -52
- package/fesm2022/tooltip-testing.mjs.map +1 -1
- package/fesm2022/tooltip.mjs +36 -10
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree-testing.mjs +86 -162
- package/fesm2022/tree-testing.mjs.map +1 -1
- package/fesm2022/tree.mjs +638 -466
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/schematics/ng-add/index.js +1 -1
- package/types/expansion.d.ts +4 -2
- package/types/menu-testing.d.ts +2 -0
- package/types/select.d.ts +1 -1
- package/types/sort.d.ts +1 -1
- package/types/table-testing.d.ts +27 -1
- package/types/timepicker.d.ts +148 -128
package/fesm2022/core.mjs
CHANGED
|
@@ -24,355 +24,384 @@ import '@angular/cdk/private';
|
|
|
24
24
|
import '@angular/cdk/platform';
|
|
25
25
|
import '@angular/cdk/coercion';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
const VERSION = new Version('21.0.0-next.8');
|
|
27
|
+
const VERSION = new Version('21.0.0-rc.0');
|
|
29
28
|
|
|
30
|
-
/**
|
|
31
|
-
* Matches strings that have the form of a valid RFC 3339 string
|
|
32
|
-
* (https://tools.ietf.org/html/rfc3339). Note that the string may not actually be a valid date
|
|
33
|
-
* because the regex will match strings with an out of bounds month, date, etc.
|
|
34
|
-
*/
|
|
35
29
|
const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
|
|
36
|
-
/**
|
|
37
|
-
* Matches a time string. Supported formats:
|
|
38
|
-
* - {{hours}}:{{minutes}}
|
|
39
|
-
* - {{hours}}:{{minutes}}:{{seconds}}
|
|
40
|
-
* - {{hours}}:{{minutes}} AM/PM
|
|
41
|
-
* - {{hours}}:{{minutes}}:{{seconds}} AM/PM
|
|
42
|
-
* - {{hours}}.{{minutes}}
|
|
43
|
-
* - {{hours}}.{{minutes}}.{{seconds}}
|
|
44
|
-
* - {{hours}}.{{minutes}} AM/PM
|
|
45
|
-
* - {{hours}}.{{minutes}}.{{seconds}} AM/PM
|
|
46
|
-
*/
|
|
47
30
|
const TIME_REGEX = /^(\d?\d)[:.](\d?\d)(?:[:.](\d?\d))?\s*(AM|PM)?$/i;
|
|
48
|
-
/** Creates an array and fills it with values. */
|
|
49
31
|
function range(length, valueFunction) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
const valuesArray = Array(length);
|
|
33
|
+
for (let i = 0; i < length; i++) {
|
|
34
|
+
valuesArray[i] = valueFunction(i);
|
|
35
|
+
}
|
|
36
|
+
return valuesArray;
|
|
55
37
|
}
|
|
56
|
-
/** Adapts the native JS Date for use with cdk-based components that work with dates. */
|
|
57
38
|
class NativeDateAdapter extends DateAdapter {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
* Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
|
|
179
|
-
* (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
|
|
180
|
-
* invalid date for all other values.
|
|
181
|
-
*/
|
|
182
|
-
deserialize(value) {
|
|
183
|
-
if (typeof value === 'string') {
|
|
184
|
-
if (!value) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
// The `Date` constructor accepts formats other than ISO 8601, so we need to make sure the
|
|
188
|
-
// string is the right format first.
|
|
189
|
-
if (ISO_8601_REGEX.test(value)) {
|
|
190
|
-
let date = new Date(value);
|
|
191
|
-
if (this.isValid(date)) {
|
|
192
|
-
return date;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return super.deserialize(value);
|
|
197
|
-
}
|
|
198
|
-
isDateInstance(obj) {
|
|
199
|
-
return obj instanceof Date;
|
|
200
|
-
}
|
|
201
|
-
isValid(date) {
|
|
202
|
-
return !isNaN(date.getTime());
|
|
203
|
-
}
|
|
204
|
-
invalid() {
|
|
205
|
-
return new Date(NaN);
|
|
206
|
-
}
|
|
207
|
-
setTime(target, hours, minutes, seconds) {
|
|
208
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
209
|
-
if (!inRange(hours, 0, 23)) {
|
|
210
|
-
throw Error(`Invalid hours "${hours}". Hours value must be between 0 and 23.`);
|
|
211
|
-
}
|
|
212
|
-
if (!inRange(minutes, 0, 59)) {
|
|
213
|
-
throw Error(`Invalid minutes "${minutes}". Minutes value must be between 0 and 59.`);
|
|
214
|
-
}
|
|
215
|
-
if (!inRange(seconds, 0, 59)) {
|
|
216
|
-
throw Error(`Invalid seconds "${seconds}". Seconds value must be between 0 and 59.`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const clone = this.clone(target);
|
|
220
|
-
clone.setHours(hours, minutes, seconds, 0);
|
|
221
|
-
return clone;
|
|
222
|
-
}
|
|
223
|
-
getHours(date) {
|
|
224
|
-
return date.getHours();
|
|
225
|
-
}
|
|
226
|
-
getMinutes(date) {
|
|
227
|
-
return date.getMinutes();
|
|
228
|
-
}
|
|
229
|
-
getSeconds(date) {
|
|
230
|
-
return date.getSeconds();
|
|
231
|
-
}
|
|
232
|
-
parseTime(userValue, parseFormat) {
|
|
233
|
-
if (typeof userValue !== 'string') {
|
|
234
|
-
return userValue instanceof Date ? new Date(userValue.getTime()) : null;
|
|
235
|
-
}
|
|
236
|
-
const value = userValue.trim();
|
|
237
|
-
if (value.length === 0) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
// Attempt to parse the value directly.
|
|
241
|
-
let result = this._parseTimeString(value);
|
|
242
|
-
// Some locales add extra characters around the time, but are otherwise parseable
|
|
243
|
-
// (e.g. `00:05 ч.` in bg-BG). Try replacing all non-number and non-colon characters.
|
|
244
|
-
if (result === null) {
|
|
245
|
-
const withoutExtras = value.replace(/[^0-9:(AM|PM)]/gi, '').trim();
|
|
246
|
-
if (withoutExtras.length > 0) {
|
|
247
|
-
result = this._parseTimeString(withoutExtras);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return result || this.invalid();
|
|
251
|
-
}
|
|
252
|
-
addSeconds(date, amount) {
|
|
253
|
-
return new Date(date.getTime() + amount * 1000);
|
|
254
|
-
}
|
|
255
|
-
/** Creates a date but allows the month and date to overflow. */
|
|
256
|
-
_createDateWithOverflow(year, month, date) {
|
|
257
|
-
// Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
|
|
258
|
-
// To work around this we use `setFullYear` and `setHours` instead.
|
|
259
|
-
const d = new Date();
|
|
260
|
-
d.setFullYear(year, month, date);
|
|
261
|
-
d.setHours(0, 0, 0, 0);
|
|
262
|
-
return d;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Pads a number to make it two digits.
|
|
266
|
-
* @param n The number to pad.
|
|
267
|
-
* @returns The padded number.
|
|
268
|
-
*/
|
|
269
|
-
_2digit(n) {
|
|
270
|
-
return ('00' + n).slice(-2);
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* When converting Date object to string, javascript built-in functions may return wrong
|
|
274
|
-
* results because it applies its internal DST rules. The DST rules around the world change
|
|
275
|
-
* very frequently, and the current valid rule is not always valid in previous years though.
|
|
276
|
-
* We work around this problem building a new Date object which has its internal UTC
|
|
277
|
-
* representation with the local date and time.
|
|
278
|
-
* @param dtf Intl.DateTimeFormat object, containing the desired string format. It must have
|
|
279
|
-
* timeZone set to 'utc' to work fine.
|
|
280
|
-
* @param date Date from which we want to get the string representation according to dtf
|
|
281
|
-
* @returns A Date object with its UTC representation based on the passed in date info
|
|
282
|
-
*/
|
|
283
|
-
_format(dtf, date) {
|
|
284
|
-
// Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
|
|
285
|
-
// To work around this we use `setUTCFullYear` and `setUTCHours` instead.
|
|
286
|
-
const d = new Date();
|
|
287
|
-
d.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
|
|
288
|
-
d.setUTCHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
289
|
-
return dtf.format(d);
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Attempts to parse a time string into a date object. Returns null if it cannot be parsed.
|
|
293
|
-
* @param value Time string to parse.
|
|
294
|
-
*/
|
|
295
|
-
_parseTimeString(value) {
|
|
296
|
-
// Note: we can technically rely on the browser for the time parsing by generating
|
|
297
|
-
// an ISO string and appending the string to the end of it. We don't do it, because
|
|
298
|
-
// browsers aren't consistent in what they support. Some examples:
|
|
299
|
-
// - Safari doesn't support AM/PM.
|
|
300
|
-
// - Firefox produces a valid date object if the time string has overflows (e.g. 12:75) while
|
|
301
|
-
// other browsers produce an invalid date.
|
|
302
|
-
// - Safari doesn't allow padded numbers.
|
|
303
|
-
const parsed = value.toUpperCase().match(TIME_REGEX);
|
|
304
|
-
if (parsed) {
|
|
305
|
-
let hours = parseInt(parsed[1]);
|
|
306
|
-
const minutes = parseInt(parsed[2]);
|
|
307
|
-
let seconds = parsed[3] == null ? undefined : parseInt(parsed[3]);
|
|
308
|
-
const amPm = parsed[4];
|
|
309
|
-
if (hours === 12) {
|
|
310
|
-
hours = amPm === 'AM' ? 0 : hours;
|
|
311
|
-
}
|
|
312
|
-
else if (amPm === 'PM') {
|
|
313
|
-
hours += 12;
|
|
314
|
-
}
|
|
315
|
-
if (inRange(hours, 0, 23) &&
|
|
316
|
-
inRange(minutes, 0, 59) &&
|
|
317
|
-
(seconds == null || inRange(seconds, 0, 59))) {
|
|
318
|
-
return this.setTime(this.today(), hours, minutes, seconds || 0);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
39
|
+
_matDateLocale = inject(MAT_DATE_LOCALE, {
|
|
40
|
+
optional: true
|
|
41
|
+
});
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
const matDateLocale = inject(MAT_DATE_LOCALE, {
|
|
45
|
+
optional: true
|
|
46
|
+
});
|
|
47
|
+
if (matDateLocale !== undefined) {
|
|
48
|
+
this._matDateLocale = matDateLocale;
|
|
49
|
+
}
|
|
50
|
+
super.setLocale(this._matDateLocale);
|
|
51
|
+
}
|
|
52
|
+
getYear(date) {
|
|
53
|
+
return date.getFullYear();
|
|
54
|
+
}
|
|
55
|
+
getMonth(date) {
|
|
56
|
+
return date.getMonth();
|
|
57
|
+
}
|
|
58
|
+
getDate(date) {
|
|
59
|
+
return date.getDate();
|
|
60
|
+
}
|
|
61
|
+
getDayOfWeek(date) {
|
|
62
|
+
return date.getDay();
|
|
63
|
+
}
|
|
64
|
+
getMonthNames(style) {
|
|
65
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
66
|
+
month: style,
|
|
67
|
+
timeZone: 'utc'
|
|
68
|
+
});
|
|
69
|
+
return range(12, i => this._format(dtf, new Date(2017, i, 1)));
|
|
70
|
+
}
|
|
71
|
+
getDateNames() {
|
|
72
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
73
|
+
day: 'numeric',
|
|
74
|
+
timeZone: 'utc'
|
|
75
|
+
});
|
|
76
|
+
return range(31, i => this._format(dtf, new Date(2017, 0, i + 1)));
|
|
77
|
+
}
|
|
78
|
+
getDayOfWeekNames(style) {
|
|
79
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
80
|
+
weekday: style,
|
|
81
|
+
timeZone: 'utc'
|
|
82
|
+
});
|
|
83
|
+
return range(7, i => this._format(dtf, new Date(2017, 0, i + 1)));
|
|
84
|
+
}
|
|
85
|
+
getYearName(date) {
|
|
86
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
87
|
+
year: 'numeric',
|
|
88
|
+
timeZone: 'utc'
|
|
89
|
+
});
|
|
90
|
+
return this._format(dtf, date);
|
|
91
|
+
}
|
|
92
|
+
getFirstDayOfWeek() {
|
|
93
|
+
if (typeof Intl !== 'undefined' && Intl.Locale) {
|
|
94
|
+
const locale = new Intl.Locale(this.locale);
|
|
95
|
+
const firstDay = (locale.getWeekInfo?.() || locale.weekInfo)?.firstDay ?? 0;
|
|
96
|
+
return firstDay === 7 ? 0 : firstDay;
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
getNumDaysInMonth(date) {
|
|
101
|
+
return this.getDate(this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0));
|
|
102
|
+
}
|
|
103
|
+
clone(date) {
|
|
104
|
+
return new Date(date.getTime());
|
|
105
|
+
}
|
|
106
|
+
createDate(year, month, date) {
|
|
107
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
108
|
+
if (month < 0 || month > 11) {
|
|
109
|
+
throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
|
|
110
|
+
}
|
|
111
|
+
if (date < 1) {
|
|
112
|
+
throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let result = this._createDateWithOverflow(year, month, date);
|
|
116
|
+
if (result.getMonth() != month && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
117
|
+
throw Error(`Invalid date "${date}" for month with index "${month}".`);
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
today() {
|
|
122
|
+
return new Date();
|
|
123
|
+
}
|
|
124
|
+
parse(value, parseFormat) {
|
|
125
|
+
if (typeof value == 'number') {
|
|
126
|
+
return new Date(value);
|
|
127
|
+
}
|
|
128
|
+
return value ? new Date(Date.parse(value)) : null;
|
|
129
|
+
}
|
|
130
|
+
format(date, displayFormat) {
|
|
131
|
+
if (!this.isValid(date)) {
|
|
132
|
+
throw Error('NativeDateAdapter: Cannot format invalid date.');
|
|
133
|
+
}
|
|
134
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
135
|
+
...displayFormat,
|
|
136
|
+
timeZone: 'utc'
|
|
137
|
+
});
|
|
138
|
+
return this._format(dtf, date);
|
|
139
|
+
}
|
|
140
|
+
addCalendarYears(date, years) {
|
|
141
|
+
return this.addCalendarMonths(date, years * 12);
|
|
142
|
+
}
|
|
143
|
+
addCalendarMonths(date, months) {
|
|
144
|
+
let newDate = this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
|
|
145
|
+
if (this.getMonth(newDate) != ((this.getMonth(date) + months) % 12 + 12) % 12) {
|
|
146
|
+
newDate = this._createDateWithOverflow(this.getYear(newDate), this.getMonth(newDate), 0);
|
|
147
|
+
}
|
|
148
|
+
return newDate;
|
|
149
|
+
}
|
|
150
|
+
addCalendarDays(date, days) {
|
|
151
|
+
return this._createDateWithOverflow(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
|
|
152
|
+
}
|
|
153
|
+
toIso8601(date) {
|
|
154
|
+
return [date.getUTCFullYear(), this._2digit(date.getUTCMonth() + 1), this._2digit(date.getUTCDate())].join('-');
|
|
155
|
+
}
|
|
156
|
+
deserialize(value) {
|
|
157
|
+
if (typeof value === 'string') {
|
|
158
|
+
if (!value) {
|
|
321
159
|
return null;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
160
|
+
}
|
|
161
|
+
if (ISO_8601_REGEX.test(value)) {
|
|
162
|
+
let date = new Date(value);
|
|
163
|
+
if (this.isValid(date)) {
|
|
164
|
+
return date;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return super.deserialize(value);
|
|
169
|
+
}
|
|
170
|
+
isDateInstance(obj) {
|
|
171
|
+
return obj instanceof Date;
|
|
172
|
+
}
|
|
173
|
+
isValid(date) {
|
|
174
|
+
return !isNaN(date.getTime());
|
|
175
|
+
}
|
|
176
|
+
invalid() {
|
|
177
|
+
return new Date(NaN);
|
|
178
|
+
}
|
|
179
|
+
setTime(target, hours, minutes, seconds) {
|
|
180
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
181
|
+
if (!inRange(hours, 0, 23)) {
|
|
182
|
+
throw Error(`Invalid hours "${hours}". Hours value must be between 0 and 23.`);
|
|
183
|
+
}
|
|
184
|
+
if (!inRange(minutes, 0, 59)) {
|
|
185
|
+
throw Error(`Invalid minutes "${minutes}". Minutes value must be between 0 and 59.`);
|
|
186
|
+
}
|
|
187
|
+
if (!inRange(seconds, 0, 59)) {
|
|
188
|
+
throw Error(`Invalid seconds "${seconds}". Seconds value must be between 0 and 59.`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const clone = this.clone(target);
|
|
192
|
+
clone.setHours(hours, minutes, seconds, 0);
|
|
193
|
+
return clone;
|
|
194
|
+
}
|
|
195
|
+
getHours(date) {
|
|
196
|
+
return date.getHours();
|
|
197
|
+
}
|
|
198
|
+
getMinutes(date) {
|
|
199
|
+
return date.getMinutes();
|
|
200
|
+
}
|
|
201
|
+
getSeconds(date) {
|
|
202
|
+
return date.getSeconds();
|
|
203
|
+
}
|
|
204
|
+
parseTime(userValue, parseFormat) {
|
|
205
|
+
if (typeof userValue !== 'string') {
|
|
206
|
+
return userValue instanceof Date ? new Date(userValue.getTime()) : null;
|
|
207
|
+
}
|
|
208
|
+
const value = userValue.trim();
|
|
209
|
+
if (value.length === 0) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
let result = this._parseTimeString(value);
|
|
213
|
+
if (result === null) {
|
|
214
|
+
const withoutExtras = value.replace(/[^0-9:(AM|PM)]/gi, '').trim();
|
|
215
|
+
if (withoutExtras.length > 0) {
|
|
216
|
+
result = this._parseTimeString(withoutExtras);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result || this.invalid();
|
|
220
|
+
}
|
|
221
|
+
addSeconds(date, amount) {
|
|
222
|
+
return new Date(date.getTime() + amount * 1000);
|
|
223
|
+
}
|
|
224
|
+
_createDateWithOverflow(year, month, date) {
|
|
225
|
+
const d = new Date();
|
|
226
|
+
d.setFullYear(year, month, date);
|
|
227
|
+
d.setHours(0, 0, 0, 0);
|
|
228
|
+
return d;
|
|
229
|
+
}
|
|
230
|
+
_2digit(n) {
|
|
231
|
+
return ('00' + n).slice(-2);
|
|
232
|
+
}
|
|
233
|
+
_format(dtf, date) {
|
|
234
|
+
const d = new Date();
|
|
235
|
+
d.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
|
|
236
|
+
d.setUTCHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
237
|
+
return dtf.format(d);
|
|
238
|
+
}
|
|
239
|
+
_parseTimeString(value) {
|
|
240
|
+
const parsed = value.toUpperCase().match(TIME_REGEX);
|
|
241
|
+
if (parsed) {
|
|
242
|
+
let hours = parseInt(parsed[1]);
|
|
243
|
+
const minutes = parseInt(parsed[2]);
|
|
244
|
+
let seconds = parsed[3] == null ? undefined : parseInt(parsed[3]);
|
|
245
|
+
const amPm = parsed[4];
|
|
246
|
+
if (hours === 12) {
|
|
247
|
+
hours = amPm === 'AM' ? 0 : hours;
|
|
248
|
+
} else if (amPm === 'PM') {
|
|
249
|
+
hours += 12;
|
|
250
|
+
}
|
|
251
|
+
if (inRange(hours, 0, 23) && inRange(minutes, 0, 59) && (seconds == null || inRange(seconds, 0, 59))) {
|
|
252
|
+
return this.setTime(this.today(), hours, minutes, seconds || 0);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
258
|
+
minVersion: "12.0.0",
|
|
259
|
+
version: "20.2.0-next.2",
|
|
260
|
+
ngImport: i0,
|
|
261
|
+
type: NativeDateAdapter,
|
|
262
|
+
deps: [],
|
|
263
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
264
|
+
});
|
|
265
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
266
|
+
minVersion: "12.0.0",
|
|
267
|
+
version: "20.2.0-next.2",
|
|
268
|
+
ngImport: i0,
|
|
269
|
+
type: NativeDateAdapter
|
|
270
|
+
});
|
|
325
271
|
}
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
273
|
+
minVersion: "12.0.0",
|
|
274
|
+
version: "20.2.0-next.2",
|
|
275
|
+
ngImport: i0,
|
|
276
|
+
type: NativeDateAdapter,
|
|
277
|
+
decorators: [{
|
|
278
|
+
type: Injectable
|
|
279
|
+
}],
|
|
280
|
+
ctorParameters: () => []
|
|
281
|
+
});
|
|
330
282
|
function inRange(value, min, max) {
|
|
331
|
-
|
|
283
|
+
return !isNaN(value) && value >= min && value <= max;
|
|
332
284
|
}
|
|
333
285
|
|
|
334
286
|
const MAT_NATIVE_DATE_FORMATS = {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
287
|
+
parse: {
|
|
288
|
+
dateInput: null,
|
|
289
|
+
timeInput: null
|
|
290
|
+
},
|
|
291
|
+
display: {
|
|
292
|
+
dateInput: {
|
|
293
|
+
year: 'numeric',
|
|
294
|
+
month: 'numeric',
|
|
295
|
+
day: 'numeric'
|
|
296
|
+
},
|
|
297
|
+
timeInput: {
|
|
298
|
+
hour: 'numeric',
|
|
299
|
+
minute: 'numeric'
|
|
338
300
|
},
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
monthYearLabel: { year: 'numeric', month: 'short' },
|
|
343
|
-
dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
|
|
344
|
-
monthYearA11yLabel: { year: 'numeric', month: 'long' },
|
|
345
|
-
timeOptionLabel: { hour: 'numeric', minute: 'numeric' },
|
|
301
|
+
monthYearLabel: {
|
|
302
|
+
year: 'numeric',
|
|
303
|
+
month: 'short'
|
|
346
304
|
},
|
|
305
|
+
dateA11yLabel: {
|
|
306
|
+
year: 'numeric',
|
|
307
|
+
month: 'long',
|
|
308
|
+
day: 'numeric'
|
|
309
|
+
},
|
|
310
|
+
monthYearA11yLabel: {
|
|
311
|
+
year: 'numeric',
|
|
312
|
+
month: 'long'
|
|
313
|
+
},
|
|
314
|
+
timeOptionLabel: {
|
|
315
|
+
hour: 'numeric',
|
|
316
|
+
minute: 'numeric'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
347
319
|
};
|
|
348
320
|
|
|
349
321
|
class NativeDateModule {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
322
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
323
|
+
minVersion: "12.0.0",
|
|
324
|
+
version: "20.2.0-next.2",
|
|
325
|
+
ngImport: i0,
|
|
326
|
+
type: NativeDateModule,
|
|
327
|
+
deps: [],
|
|
328
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
329
|
+
});
|
|
330
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
331
|
+
minVersion: "14.0.0",
|
|
332
|
+
version: "20.2.0-next.2",
|
|
333
|
+
ngImport: i0,
|
|
334
|
+
type: NativeDateModule
|
|
335
|
+
});
|
|
336
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
337
|
+
minVersion: "12.0.0",
|
|
338
|
+
version: "20.2.0-next.2",
|
|
339
|
+
ngImport: i0,
|
|
340
|
+
type: NativeDateModule,
|
|
341
|
+
providers: [{
|
|
342
|
+
provide: DateAdapter,
|
|
343
|
+
useClass: NativeDateAdapter
|
|
344
|
+
}]
|
|
345
|
+
});
|
|
353
346
|
}
|
|
354
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
347
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
348
|
+
minVersion: "12.0.0",
|
|
349
|
+
version: "20.2.0-next.2",
|
|
350
|
+
ngImport: i0,
|
|
351
|
+
type: NativeDateModule,
|
|
352
|
+
decorators: [{
|
|
353
|
+
type: NgModule,
|
|
354
|
+
args: [{
|
|
355
|
+
providers: [{
|
|
356
|
+
provide: DateAdapter,
|
|
357
|
+
useClass: NativeDateAdapter
|
|
358
|
+
}]
|
|
359
|
+
}]
|
|
360
|
+
}]
|
|
361
|
+
});
|
|
360
362
|
class MatNativeDateModule {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
364
|
+
minVersion: "12.0.0",
|
|
365
|
+
version: "20.2.0-next.2",
|
|
366
|
+
ngImport: i0,
|
|
367
|
+
type: MatNativeDateModule,
|
|
368
|
+
deps: [],
|
|
369
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
370
|
+
});
|
|
371
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
372
|
+
minVersion: "14.0.0",
|
|
373
|
+
version: "20.2.0-next.2",
|
|
374
|
+
ngImport: i0,
|
|
375
|
+
type: MatNativeDateModule
|
|
376
|
+
});
|
|
377
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
378
|
+
minVersion: "12.0.0",
|
|
379
|
+
version: "20.2.0-next.2",
|
|
380
|
+
ngImport: i0,
|
|
381
|
+
type: MatNativeDateModule,
|
|
382
|
+
providers: [provideNativeDateAdapter()]
|
|
383
|
+
});
|
|
364
384
|
}
|
|
365
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
385
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
386
|
+
minVersion: "12.0.0",
|
|
387
|
+
version: "20.2.0-next.2",
|
|
388
|
+
ngImport: i0,
|
|
389
|
+
type: MatNativeDateModule,
|
|
390
|
+
decorators: [{
|
|
391
|
+
type: NgModule,
|
|
392
|
+
args: [{
|
|
393
|
+
providers: [provideNativeDateAdapter()]
|
|
394
|
+
}]
|
|
395
|
+
}]
|
|
396
|
+
});
|
|
371
397
|
function provideNativeDateAdapter(formats = MAT_NATIVE_DATE_FORMATS) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
398
|
+
return [{
|
|
399
|
+
provide: DateAdapter,
|
|
400
|
+
useClass: NativeDateAdapter
|
|
401
|
+
}, {
|
|
402
|
+
provide: MAT_DATE_FORMATS,
|
|
403
|
+
useValue: formats
|
|
404
|
+
}];
|
|
376
405
|
}
|
|
377
406
|
|
|
378
407
|
export { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MAT_NATIVE_DATE_FORMATS, MatNativeDateModule, NativeDateAdapter, NativeDateModule, VERSION, provideNativeDateAdapter };
|