@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.5 → 0.0.0-pr1489.7
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/components/checkbox/demo/customize.min.js +249 -125
- package/components/checkbox/demo/getting-started.min.js +249 -125
- package/components/checkbox/demo/index.min.js +249 -125
- package/components/checkbox/demo/styles.min.css +1 -1
- package/components/checkbox/dist/index.js +249 -125
- package/components/checkbox/dist/registered.js +249 -125
- package/components/combobox/demo/customize.min.js +523 -262
- package/components/combobox/demo/getting-started.min.js +523 -262
- package/components/combobox/demo/index.min.js +523 -262
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +523 -262
- package/components/combobox/dist/registered.js +523 -262
- package/components/counter/demo/customize.min.js +271 -134
- package/components/counter/demo/index.min.js +271 -134
- package/components/counter/demo/styles.min.css +1 -1
- package/components/counter/dist/index.js +249 -125
- package/components/counter/dist/registered.js +249 -125
- package/components/datepicker/demo/accessibility.md +9 -6
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.min.js +1636 -656
- package/components/datepicker/demo/index.md +31 -3
- package/components/datepicker/demo/index.min.js +1652 -661
- package/components/datepicker/demo/keyboard-behavior.md +16 -16
- package/components/datepicker/demo/styles.min.css +1 -1
- package/components/datepicker/demo/voiceover.md +5 -3
- package/components/datepicker/demo/why-datepicker.md +2 -2
- package/components/datepicker/dist/index.js +1640 -660
- package/components/datepicker/dist/registered.js +1640 -660
- package/components/datepicker/dist/src/auro-calendar-cell.d.ts +52 -17
- package/components/datepicker/dist/src/auro-calendar-month.d.ts +12 -4
- package/components/datepicker/dist/src/auro-calendar.d.ts +161 -8
- package/components/datepicker/dist/src/auro-datepicker.d.ts +77 -79
- package/components/dropdown/demo/customize.min.js +22 -9
- package/components/dropdown/demo/getting-started.min.js +22 -9
- package/components/dropdown/demo/index.min.js +22 -9
- package/components/dropdown/demo/styles.min.css +1 -1
- package/components/dropdown/dist/auro-dropdown.d.ts +3 -2
- package/components/dropdown/dist/index.js +22 -9
- package/components/dropdown/dist/registered.js +22 -9
- package/components/form/demo/customize.min.js +3459 -1572
- package/components/form/demo/getting-started.min.js +3459 -1572
- package/components/form/demo/index.min.js +3459 -1572
- package/components/form/demo/registerDemoDeps.min.js +3459 -1572
- package/components/form/demo/styles.min.css +1 -1
- package/components/input/demo/customize.min.js +249 -125
- package/components/input/demo/getting-started.min.js +249 -125
- package/components/input/demo/index.min.js +249 -125
- package/components/input/demo/styles.min.css +1 -1
- package/components/input/dist/index.js +249 -125
- package/components/input/dist/registered.js +249 -125
- package/components/menu/demo/styles.min.css +1 -1
- package/components/radio/demo/customize.min.js +249 -125
- package/components/radio/demo/getting-started.min.js +249 -125
- package/components/radio/demo/index.min.js +249 -125
- package/components/radio/demo/styles.min.css +1 -1
- package/components/radio/dist/index.js +249 -125
- package/components/radio/dist/registered.js +249 -125
- package/components/select/demo/customize.min.js +271 -134
- package/components/select/demo/getting-started.min.js +271 -134
- package/components/select/demo/index.min.js +271 -134
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +271 -134
- package/components/select/dist/registered.js +271 -134
- package/custom-elements.json +500 -178
- package/package.json +8 -8
|
@@ -130,109 +130,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @description Splits a date string into its parts according to the provided format. Does NOT validate that the result is a real calendar date — use `parseDate` when validation is required.
|
|
135
|
+
* @param {string} dateStr - Date string to parse.
|
|
136
|
+
* @param {string} format - Date format to parse.
|
|
137
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
138
|
+
*/
|
|
139
|
+
function getDateParts$1(dateStr, format) {
|
|
140
|
+
if (!dateStr) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
134
143
|
|
|
135
|
-
|
|
144
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
145
|
+
let valueParts;
|
|
146
|
+
let formatParts;
|
|
136
147
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
if (formatSeparatorMatch) {
|
|
149
|
+
const separator = formatSeparatorMatch[0];
|
|
150
|
+
valueParts = dateStr.split(separator);
|
|
151
|
+
formatParts = format.split(separator);
|
|
152
|
+
} else {
|
|
153
|
+
if (dateStr.match(/[/.-]/)) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
156
|
+
);
|
|
157
|
+
}
|
|
144
158
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
if (dateStr.length !== format.length) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
162
|
+
);
|
|
163
|
+
}
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
valueParts = [dateStr];
|
|
166
|
+
formatParts = [format];
|
|
167
|
+
}
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
if (valueParts.length !== formatParts.length) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
156
174
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
160
|
-
}
|
|
175
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
176
|
+
const value = valueParts[index];
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
179
|
+
acc.month = value;
|
|
180
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
181
|
+
acc.day = value;
|
|
182
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
183
|
+
acc.year = value;
|
|
184
|
+
}
|
|
165
185
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} else if ((/d/iu).test(part)) {
|
|
169
|
-
acc.day = value;
|
|
170
|
-
} else if ((/y/iu).test(part)) {
|
|
171
|
-
acc.year = value;
|
|
172
|
-
}
|
|
186
|
+
return acc;
|
|
187
|
+
}, {});
|
|
173
188
|
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
if (!result.month && !result.day && !result.year) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
192
|
+
);
|
|
193
|
+
}
|
|
176
194
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
181
197
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
function isCalendarDate$1(year, month, day) {
|
|
199
|
+
let yearNumber = Number(year);
|
|
200
|
+
const monthNumber = Number(month);
|
|
201
|
+
const dayNumber = Number(day);
|
|
185
202
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
year: "numeric",
|
|
194
|
-
month: "2-digit",
|
|
195
|
-
day: "2-digit",
|
|
196
|
-
});
|
|
203
|
+
if (
|
|
204
|
+
!Number.isInteger(yearNumber) ||
|
|
205
|
+
!Number.isInteger(monthNumber) ||
|
|
206
|
+
!Number.isInteger(dayNumber)
|
|
207
|
+
) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
211
|
+
// Handle 2-digit years by converting them to 4-digit years based on a cutoff. This allows for parsing of 2-digit year formats while still validating the resulting date.
|
|
212
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
213
|
+
yearNumber += 1900;
|
|
214
|
+
} else if (yearNumber < 50) {
|
|
215
|
+
yearNumber += 2000;
|
|
216
|
+
}
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
219
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
223
|
+
);
|
|
224
|
+
}
|
|
209
225
|
|
|
210
|
-
|
|
226
|
+
/**
|
|
227
|
+
* @description Parses a date string into its components and validates that the result is a real calendar date. Use `getDateParts` instead when raw splitting without validation is needed (e.g. for in-progress input).
|
|
228
|
+
*
|
|
229
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
230
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
231
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
232
|
+
* @param {string} dateStr - Date string to parse.
|
|
233
|
+
* @param {string} format - Date format to parse.
|
|
234
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
235
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
236
|
+
*/
|
|
237
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
238
|
+
if (!dateStr || !format) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
211
242
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
243
|
+
if (!result) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
215
246
|
|
|
216
|
-
|
|
247
|
+
const lowerFormat = format.toLowerCase();
|
|
248
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
249
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
250
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
217
251
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
252
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
222
255
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
256
|
+
throw new Error(
|
|
257
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
226
260
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Convert a date object to string format.
|
|
263
|
+
* @param {Object} date - Date to convert to string.
|
|
264
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
265
|
+
* @returns {String} Returns the date as a string.
|
|
266
|
+
*/
|
|
267
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
268
|
+
return date.toLocaleDateString(locale, {
|
|
269
|
+
year: "numeric",
|
|
270
|
+
month: "2-digit",
|
|
271
|
+
day: "2-digit",
|
|
272
|
+
});
|
|
273
|
+
}
|
|
230
274
|
|
|
231
|
-
|
|
232
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Converts a date string to a North American date format.
|
|
277
|
+
* @param {String} dateStr - Date to validate.
|
|
278
|
+
* @param {String} format - Date format to validate against.
|
|
279
|
+
* @returns {String}
|
|
280
|
+
*/
|
|
281
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
282
|
+
if (format === "mm/dd/yyyy") {
|
|
283
|
+
return dateStr;
|
|
233
284
|
}
|
|
285
|
+
|
|
286
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
287
|
+
|
|
288
|
+
if (!parsedDate) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const { month, day, year } = parsedDate;
|
|
295
|
+
|
|
296
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} dateStr - Date string to validate.
|
|
303
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
304
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
305
|
+
*/
|
|
306
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
307
|
+
try {
|
|
308
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (parseDate$1(dateStr, format)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Converts a JavaScript Date instance to a simple ISO-like date string. This returns only the calendar date portion without any time or timezone information.
|
|
323
|
+
*
|
|
324
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
325
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
326
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
327
|
+
*/
|
|
328
|
+
function toISOFormatString$1(date) {
|
|
329
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Converts a date string into a JavaScript Date instance. This method supports ISO formatted strings and other formats that can be parsed by the formatter.
|
|
339
|
+
*
|
|
340
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
341
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
342
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
343
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
344
|
+
*/
|
|
345
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
346
|
+
if (typeof dateStr !== "string") {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
351
|
+
return new Date(`${year}/${month}/${day}`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const dateFormatter$1 = {
|
|
355
|
+
parseDate: parseDate$1,
|
|
356
|
+
getDateParts: getDateParts$1,
|
|
357
|
+
getDateAsString: getDateAsString$1,
|
|
358
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
359
|
+
isValidDate: isValidDate$1,
|
|
360
|
+
toISOFormatString: toISOFormatString$1,
|
|
361
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
234
362
|
};
|
|
235
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
236
363
|
|
|
237
364
|
// filepath: dateConstraints.mjs
|
|
238
365
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -304,12 +431,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
304
431
|
/* eslint-disable no-magic-numbers */
|
|
305
432
|
|
|
306
433
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
307
|
-
|
|
308
434
|
/**
|
|
309
435
|
* Returns the current century.
|
|
310
436
|
* @returns {String} The current century.
|
|
311
437
|
*/
|
|
312
|
-
getCentury
|
|
438
|
+
getCentury() {
|
|
313
439
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
314
440
|
}
|
|
315
441
|
|
|
@@ -318,14 +444,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
318
444
|
* @param {String} year - The year to convert to four digits.
|
|
319
445
|
* @returns {String} The four digit year.
|
|
320
446
|
*/
|
|
321
|
-
getFourDigitYear
|
|
322
|
-
|
|
447
|
+
getFourDigitYear(year) {
|
|
323
448
|
const strYear = String(year).trim();
|
|
324
449
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
325
450
|
}
|
|
326
451
|
|
|
327
452
|
constructor() {
|
|
328
|
-
|
|
329
453
|
super();
|
|
330
454
|
|
|
331
455
|
/**
|
|
@@ -334,7 +458,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
334
458
|
* @param {Object} date2 - Second date to compare.
|
|
335
459
|
* @returns {Boolean} Returns true if the dates match.
|
|
336
460
|
*/
|
|
337
|
-
this.datesMatch = (date1, date2) =>
|
|
461
|
+
this.datesMatch = (date1, date2) =>
|
|
462
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
338
463
|
|
|
339
464
|
/**
|
|
340
465
|
* Returns true if value passed in is a valid date.
|
|
@@ -343,53 +468,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
343
468
|
* @returns {Boolean}
|
|
344
469
|
*/
|
|
345
470
|
this.validDateStr = (date, format) => {
|
|
346
|
-
|
|
347
471
|
// The length we expect the date string to be
|
|
348
|
-
const dateStrLength = format
|
|
472
|
+
const dateStrLength = format?.length || 0;
|
|
349
473
|
|
|
350
474
|
// Guard Clause: Date and format are defined
|
|
351
475
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
352
|
-
throw new Error(
|
|
476
|
+
throw new Error(
|
|
477
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
478
|
+
);
|
|
353
479
|
}
|
|
354
480
|
|
|
355
481
|
// Guard Clause: Date should be of type string
|
|
356
482
|
if (typeof date !== "string") {
|
|
357
|
-
throw new Error(
|
|
483
|
+
throw new Error(
|
|
484
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
485
|
+
);
|
|
358
486
|
}
|
|
359
487
|
|
|
360
488
|
// Guard Clause: Format should be of type string
|
|
361
489
|
if (typeof format !== "string") {
|
|
362
|
-
throw new Error(
|
|
490
|
+
throw new Error(
|
|
491
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
492
|
+
);
|
|
363
493
|
}
|
|
364
494
|
|
|
365
495
|
// Guard Clause: Length is what we expect it to be
|
|
366
496
|
if (date.length !== dateStrLength) {
|
|
367
497
|
return false;
|
|
368
498
|
}
|
|
369
|
-
// Get a formatted date string and parse it
|
|
370
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
371
|
-
|
|
372
|
-
// Guard Clause: Date parse succeeded
|
|
373
|
-
if (!dateParts) {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Create the expected date string based on the date parts
|
|
378
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
379
|
-
|
|
380
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
381
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
382
499
|
|
|
383
|
-
// Get
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (expectedDateStr !== actualDateStr) {
|
|
500
|
+
// Get a formatted date string and parse and validate it
|
|
501
|
+
try {
|
|
502
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
503
|
+
} catch (error) {
|
|
388
504
|
return false;
|
|
389
505
|
}
|
|
390
|
-
|
|
391
|
-
// If we passed all other checks, we can assume the date is valid
|
|
392
|
-
return true;
|
|
393
506
|
};
|
|
394
507
|
|
|
395
508
|
/**
|
|
@@ -399,10 +512,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
399
512
|
* @returns {boolean}
|
|
400
513
|
*/
|
|
401
514
|
this.dateAndFormatMatch = (value, format) => {
|
|
402
|
-
|
|
403
515
|
// Ensure we have both values we need to do the comparison
|
|
404
516
|
if (!value || !format) {
|
|
405
|
-
throw new Error(
|
|
517
|
+
throw new Error(
|
|
518
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
519
|
+
);
|
|
406
520
|
}
|
|
407
521
|
|
|
408
522
|
// If the lengths are different, they cannot match
|
|
@@ -411,11 +525,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
411
525
|
}
|
|
412
526
|
|
|
413
527
|
// Get the parts of the date
|
|
414
|
-
const dateParts = dateFormatter$1.
|
|
528
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
415
529
|
|
|
416
530
|
// Validator for day
|
|
417
531
|
const dayValueIsValid = (day) => {
|
|
418
|
-
|
|
419
532
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
420
533
|
if (!dateParts.day) {
|
|
421
534
|
return true;
|
|
@@ -431,7 +544,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
431
544
|
|
|
432
545
|
// Guard clause: ensure day is a valid integer
|
|
433
546
|
if (Number.isNaN(numDay)) {
|
|
434
|
-
throw new Error(
|
|
547
|
+
throw new Error(
|
|
548
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
549
|
+
);
|
|
435
550
|
}
|
|
436
551
|
|
|
437
552
|
// Guard clause: ensure day is within the valid range
|
|
@@ -445,6 +560,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
445
560
|
|
|
446
561
|
// Validator for month
|
|
447
562
|
const monthValueIsValid = (month) => {
|
|
563
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
564
|
+
if (!dateParts.month) {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
448
567
|
|
|
449
568
|
// Guard clause: ensure month exists.
|
|
450
569
|
if (!month) {
|
|
@@ -456,7 +575,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
456
575
|
|
|
457
576
|
// Guard clause: ensure month is a valid integer
|
|
458
577
|
if (Number.isNaN(numMonth)) {
|
|
459
|
-
throw new Error(
|
|
578
|
+
throw new Error(
|
|
579
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
580
|
+
);
|
|
460
581
|
}
|
|
461
582
|
|
|
462
583
|
// Guard clause: ensure month is within the valid range
|
|
@@ -470,6 +591,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
470
591
|
|
|
471
592
|
// Validator for year
|
|
472
593
|
const yearIsValid = (_year) => {
|
|
594
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
595
|
+
if (!dateParts.year) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
473
598
|
|
|
474
599
|
// Guard clause: ensure year exists.
|
|
475
600
|
if (!_year) {
|
|
@@ -484,7 +609,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
484
609
|
|
|
485
610
|
// Guard clause: ensure year is a valid integer
|
|
486
611
|
if (Number.isNaN(numYear)) {
|
|
487
|
-
throw new Error(
|
|
612
|
+
throw new Error(
|
|
613
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
614
|
+
);
|
|
488
615
|
}
|
|
489
616
|
|
|
490
617
|
// Guard clause: ensure year is within the valid range
|
|
@@ -500,7 +627,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
500
627
|
const checks = [
|
|
501
628
|
monthValueIsValid(dateParts.month),
|
|
502
629
|
dayValueIsValid(dateParts.day),
|
|
503
|
-
yearIsValid(dateParts.year)
|
|
630
|
+
yearIsValid(dateParts.year),
|
|
504
631
|
];
|
|
505
632
|
|
|
506
633
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -534,10 +661,7 @@ const {
|
|
|
534
661
|
} = dateUtilities$1;
|
|
535
662
|
|
|
536
663
|
const {
|
|
537
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
538
|
-
parseDate: parseDate$1,
|
|
539
|
-
getDateAsString: getDateAsString$1
|
|
540
|
-
} = dateFormatter$1;
|
|
664
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
541
665
|
|
|
542
666
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
543
667
|
// See LICENSE in the project root for license information.
|
|
@@ -774,13 +898,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
774
898
|
}
|
|
775
899
|
|
|
776
900
|
// Perform the rest of the validation
|
|
777
|
-
const formattedValue = toNorthAmericanFormat$
|
|
901
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
778
902
|
const valueDate = new Date(formattedValue);
|
|
779
903
|
|
|
780
904
|
// // Validate max date
|
|
781
905
|
if (elem.max?.length === elem.lengthForType) {
|
|
782
906
|
|
|
783
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
907
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
784
908
|
|
|
785
909
|
if (valueDate > maxDate) {
|
|
786
910
|
elem.validity = 'rangeOverflow';
|
|
@@ -791,7 +915,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
791
915
|
|
|
792
916
|
// Validate min date
|
|
793
917
|
if (elem.min?.length === elem.lengthForType) {
|
|
794
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
918
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
795
919
|
|
|
796
920
|
if (valueDate < minDate) {
|
|
797
921
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5211,7 +5335,7 @@ let AuroHelpText$2 = class AuroHelpText extends LitElement {
|
|
|
5211
5335
|
}
|
|
5212
5336
|
};
|
|
5213
5337
|
|
|
5214
|
-
var formkitVersion$2 = '
|
|
5338
|
+
var formkitVersion$2 = '202606022350';
|
|
5215
5339
|
|
|
5216
5340
|
let AuroElement$2 = class AuroElement extends LitElement {
|
|
5217
5341
|
static get properties() {
|
|
@@ -6204,16 +6328,20 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6204
6328
|
|
|
6205
6329
|
// Walk up the ancestor chain, inerting siblings at each level
|
|
6206
6330
|
// to ensure the entire page outside the host subtree is inert.
|
|
6331
|
+
// Uses a reference counter (data-auro-inert-count) so multiple
|
|
6332
|
+
// simultaneous modal dropdowns share inert state safely.
|
|
6207
6333
|
let current = host;
|
|
6208
6334
|
while (current.parentElement) {
|
|
6209
6335
|
const parent = current.parentElement;
|
|
6210
6336
|
for (const sibling of parent.children) {
|
|
6211
6337
|
if (sibling !== current) {
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
}
|
|
6338
|
+
const count = parseInt(sibling.dataset.auroInertCount || '0', 10);
|
|
6339
|
+
if (count === 0) {
|
|
6340
|
+
sibling.dataset.auroInertWas = sibling.inert ? 'true' : 'false';
|
|
6341
|
+
}
|
|
6342
|
+
sibling.dataset.auroInertCount = String(count + 1);
|
|
6216
6343
|
sibling.inert = true;
|
|
6344
|
+
this._inertSiblings.push(sibling);
|
|
6217
6345
|
}
|
|
6218
6346
|
}
|
|
6219
6347
|
current = parent;
|
|
@@ -6222,14 +6350,23 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6222
6350
|
|
|
6223
6351
|
/**
|
|
6224
6352
|
* Restores `inert` state on siblings that were tracked by `_setPageInert`.
|
|
6225
|
-
*
|
|
6226
|
-
*
|
|
6353
|
+
* Uses reference counting so inert is only cleared when the last modal
|
|
6354
|
+
* dropdown releases a given element. Preserves the original inert state
|
|
6355
|
+
* so externally-inerted elements are not inadvertently re-enabled.
|
|
6227
6356
|
* @private
|
|
6228
6357
|
*/
|
|
6229
6358
|
_clearPageInert() {
|
|
6230
6359
|
if (this._inertSiblings) {
|
|
6231
|
-
for (const
|
|
6232
|
-
|
|
6360
|
+
for (const sibling of this._inertSiblings) {
|
|
6361
|
+
const count = parseInt(sibling.dataset.auroInertCount || '1', 10) - 1;
|
|
6362
|
+
if (count <= 0) {
|
|
6363
|
+
const wasInert = sibling.dataset.auroInertWas === 'true';
|
|
6364
|
+
delete sibling.dataset.auroInertCount;
|
|
6365
|
+
delete sibling.dataset.auroInertWas;
|
|
6366
|
+
sibling.inert = wasInert;
|
|
6367
|
+
} else {
|
|
6368
|
+
sibling.dataset.auroInertCount = String(count);
|
|
6369
|
+
}
|
|
6233
6370
|
}
|
|
6234
6371
|
this._inertSiblings = undefined;
|
|
6235
6372
|
}
|
|
@@ -10547,109 +10684,236 @@ class AuroInputUtilities {
|
|
|
10547
10684
|
}
|
|
10548
10685
|
}
|
|
10549
10686
|
|
|
10550
|
-
|
|
10687
|
+
/**
|
|
10688
|
+
* @description Splits a date string into its parts according to the provided format. Does NOT validate that the result is a real calendar date — use `parseDate` when validation is required.
|
|
10689
|
+
* @param {string} dateStr - Date string to parse.
|
|
10690
|
+
* @param {string} format - Date format to parse.
|
|
10691
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10692
|
+
*/
|
|
10693
|
+
function getDateParts(dateStr, format) {
|
|
10694
|
+
if (!dateStr) {
|
|
10695
|
+
return undefined;
|
|
10696
|
+
}
|
|
10551
10697
|
|
|
10552
|
-
|
|
10698
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10699
|
+
let valueParts;
|
|
10700
|
+
let formatParts;
|
|
10553
10701
|
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10702
|
+
if (formatSeparatorMatch) {
|
|
10703
|
+
const separator = formatSeparatorMatch[0];
|
|
10704
|
+
valueParts = dateStr.split(separator);
|
|
10705
|
+
formatParts = format.split(separator);
|
|
10706
|
+
} else {
|
|
10707
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10708
|
+
throw new Error(
|
|
10709
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10710
|
+
);
|
|
10711
|
+
}
|
|
10561
10712
|
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10713
|
+
if (dateStr.length !== format.length) {
|
|
10714
|
+
throw new Error(
|
|
10715
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10716
|
+
);
|
|
10717
|
+
}
|
|
10566
10718
|
|
|
10567
|
-
|
|
10568
|
-
|
|
10719
|
+
valueParts = [dateStr];
|
|
10720
|
+
formatParts = [format];
|
|
10721
|
+
}
|
|
10569
10722
|
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10723
|
+
if (valueParts.length !== formatParts.length) {
|
|
10724
|
+
throw new Error(
|
|
10725
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10726
|
+
);
|
|
10727
|
+
}
|
|
10573
10728
|
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10577
|
-
}
|
|
10729
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10730
|
+
const value = valueParts[index];
|
|
10578
10731
|
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10732
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10733
|
+
acc.month = value;
|
|
10734
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10735
|
+
acc.day = value;
|
|
10736
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10737
|
+
acc.year = value;
|
|
10738
|
+
}
|
|
10582
10739
|
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
} else if ((/d/iu).test(part)) {
|
|
10586
|
-
acc.day = value;
|
|
10587
|
-
} else if ((/y/iu).test(part)) {
|
|
10588
|
-
acc.year = value;
|
|
10589
|
-
}
|
|
10740
|
+
return acc;
|
|
10741
|
+
}, {});
|
|
10590
10742
|
|
|
10591
|
-
|
|
10592
|
-
|
|
10743
|
+
if (!result.month && !result.day && !result.year) {
|
|
10744
|
+
throw new Error(
|
|
10745
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10746
|
+
);
|
|
10747
|
+
}
|
|
10593
10748
|
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
return result;
|
|
10597
|
-
}
|
|
10749
|
+
return result;
|
|
10750
|
+
}
|
|
10598
10751
|
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10752
|
+
function isCalendarDate(year, month, day) {
|
|
10753
|
+
let yearNumber = Number(year);
|
|
10754
|
+
const monthNumber = Number(month);
|
|
10755
|
+
const dayNumber = Number(day);
|
|
10602
10756
|
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
year: "numeric",
|
|
10611
|
-
month: "2-digit",
|
|
10612
|
-
day: "2-digit",
|
|
10613
|
-
});
|
|
10757
|
+
if (
|
|
10758
|
+
!Number.isInteger(yearNumber) ||
|
|
10759
|
+
!Number.isInteger(monthNumber) ||
|
|
10760
|
+
!Number.isInteger(dayNumber)
|
|
10761
|
+
) {
|
|
10762
|
+
return false;
|
|
10763
|
+
}
|
|
10614
10764
|
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10765
|
+
// Handle 2-digit years by converting them to 4-digit years based on a cutoff. This allows for parsing of 2-digit year formats while still validating the resulting date.
|
|
10766
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10767
|
+
yearNumber += 1900;
|
|
10768
|
+
} else if (yearNumber < 50) {
|
|
10769
|
+
yearNumber += 2000;
|
|
10770
|
+
}
|
|
10622
10771
|
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
}
|
|
10772
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10773
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10626
10774
|
|
|
10627
|
-
|
|
10775
|
+
return (
|
|
10776
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10777
|
+
);
|
|
10778
|
+
}
|
|
10628
10779
|
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10780
|
+
/**
|
|
10781
|
+
* @description Parses a date string into its components and validates that the result is a real calendar date. Use `getDateParts` instead when raw splitting without validation is needed (e.g. for in-progress input).
|
|
10782
|
+
*
|
|
10783
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10784
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10785
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10786
|
+
* @param {string} dateStr - Date string to parse.
|
|
10787
|
+
* @param {string} format - Date format to parse.
|
|
10788
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10789
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10790
|
+
*/
|
|
10791
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10792
|
+
if (!dateStr || !format) {
|
|
10793
|
+
return undefined;
|
|
10794
|
+
}
|
|
10795
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10632
10796
|
|
|
10633
|
-
|
|
10797
|
+
if (!result) {
|
|
10798
|
+
return undefined;
|
|
10799
|
+
}
|
|
10634
10800
|
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10801
|
+
const lowerFormat = format.toLowerCase();
|
|
10802
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10803
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10804
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10639
10805
|
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10806
|
+
if (isCalendarDate(year, month, day)) {
|
|
10807
|
+
return result;
|
|
10808
|
+
}
|
|
10643
10809
|
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10810
|
+
throw new Error(
|
|
10811
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10812
|
+
);
|
|
10813
|
+
}
|
|
10647
10814
|
|
|
10648
|
-
|
|
10649
|
-
|
|
10815
|
+
/**
|
|
10816
|
+
* Convert a date object to string format.
|
|
10817
|
+
* @param {Object} date - Date to convert to string.
|
|
10818
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10819
|
+
* @returns {String} Returns the date as a string.
|
|
10820
|
+
*/
|
|
10821
|
+
function getDateAsString(date, locale = undefined) {
|
|
10822
|
+
return date.toLocaleDateString(locale, {
|
|
10823
|
+
year: "numeric",
|
|
10824
|
+
month: "2-digit",
|
|
10825
|
+
day: "2-digit",
|
|
10826
|
+
});
|
|
10827
|
+
}
|
|
10828
|
+
|
|
10829
|
+
/**
|
|
10830
|
+
* Converts a date string to a North American date format.
|
|
10831
|
+
* @param {String} dateStr - Date to validate.
|
|
10832
|
+
* @param {String} format - Date format to validate against.
|
|
10833
|
+
* @returns {String}
|
|
10834
|
+
*/
|
|
10835
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10836
|
+
if (format === "mm/dd/yyyy") {
|
|
10837
|
+
return dateStr;
|
|
10650
10838
|
}
|
|
10839
|
+
|
|
10840
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10841
|
+
|
|
10842
|
+
if (!parsedDate) {
|
|
10843
|
+
throw new Error(
|
|
10844
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10845
|
+
);
|
|
10846
|
+
}
|
|
10847
|
+
|
|
10848
|
+
const { month, day, year } = parsedDate;
|
|
10849
|
+
|
|
10850
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10851
|
+
}
|
|
10852
|
+
|
|
10853
|
+
/**
|
|
10854
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10855
|
+
*
|
|
10856
|
+
* @param {string} dateStr - Date string to validate.
|
|
10857
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10858
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10859
|
+
*/
|
|
10860
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10861
|
+
try {
|
|
10862
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10863
|
+
return false;
|
|
10864
|
+
}
|
|
10865
|
+
|
|
10866
|
+
if (parseDate(dateStr, format)) {
|
|
10867
|
+
return true;
|
|
10868
|
+
}
|
|
10869
|
+
} catch (error) {
|
|
10870
|
+
return false;
|
|
10871
|
+
}
|
|
10872
|
+
return false;
|
|
10873
|
+
}
|
|
10874
|
+
|
|
10875
|
+
/**
|
|
10876
|
+
* Converts a JavaScript Date instance to a simple ISO-like date string. This returns only the calendar date portion without any time or timezone information.
|
|
10877
|
+
*
|
|
10878
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10879
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10880
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10881
|
+
*/
|
|
10882
|
+
function toISOFormatString(date) {
|
|
10883
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10884
|
+
throw new Error(
|
|
10885
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10886
|
+
);
|
|
10887
|
+
}
|
|
10888
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10889
|
+
}
|
|
10890
|
+
|
|
10891
|
+
/**
|
|
10892
|
+
* Converts a date string into a JavaScript Date instance. This method supports ISO formatted strings and other formats that can be parsed by the formatter.
|
|
10893
|
+
*
|
|
10894
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10895
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10896
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10897
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10898
|
+
*/
|
|
10899
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10900
|
+
if (typeof dateStr !== "string") {
|
|
10901
|
+
return null;
|
|
10902
|
+
}
|
|
10903
|
+
|
|
10904
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10905
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10651
10906
|
}
|
|
10652
|
-
|
|
10907
|
+
|
|
10908
|
+
const dateFormatter = {
|
|
10909
|
+
parseDate,
|
|
10910
|
+
getDateParts,
|
|
10911
|
+
getDateAsString,
|
|
10912
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10913
|
+
isValidDate,
|
|
10914
|
+
toISOFormatString,
|
|
10915
|
+
stringToDateInstance,
|
|
10916
|
+
};
|
|
10653
10917
|
|
|
10654
10918
|
// filepath: dateConstraints.mjs
|
|
10655
10919
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10721,12 +10985,11 @@ class AuroDateUtilitiesBase {
|
|
|
10721
10985
|
/* eslint-disable no-magic-numbers */
|
|
10722
10986
|
|
|
10723
10987
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10724
|
-
|
|
10725
10988
|
/**
|
|
10726
10989
|
* Returns the current century.
|
|
10727
10990
|
* @returns {String} The current century.
|
|
10728
10991
|
*/
|
|
10729
|
-
getCentury
|
|
10992
|
+
getCentury() {
|
|
10730
10993
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10731
10994
|
}
|
|
10732
10995
|
|
|
@@ -10735,14 +10998,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10735
10998
|
* @param {String} year - The year to convert to four digits.
|
|
10736
10999
|
* @returns {String} The four digit year.
|
|
10737
11000
|
*/
|
|
10738
|
-
getFourDigitYear
|
|
10739
|
-
|
|
11001
|
+
getFourDigitYear(year) {
|
|
10740
11002
|
const strYear = String(year).trim();
|
|
10741
11003
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10742
11004
|
}
|
|
10743
11005
|
|
|
10744
11006
|
constructor() {
|
|
10745
|
-
|
|
10746
11007
|
super();
|
|
10747
11008
|
|
|
10748
11009
|
/**
|
|
@@ -10751,7 +11012,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10751
11012
|
* @param {Object} date2 - Second date to compare.
|
|
10752
11013
|
* @returns {Boolean} Returns true if the dates match.
|
|
10753
11014
|
*/
|
|
10754
|
-
this.datesMatch = (date1, date2) =>
|
|
11015
|
+
this.datesMatch = (date1, date2) =>
|
|
11016
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10755
11017
|
|
|
10756
11018
|
/**
|
|
10757
11019
|
* Returns true if value passed in is a valid date.
|
|
@@ -10760,53 +11022,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10760
11022
|
* @returns {Boolean}
|
|
10761
11023
|
*/
|
|
10762
11024
|
this.validDateStr = (date, format) => {
|
|
10763
|
-
|
|
10764
11025
|
// The length we expect the date string to be
|
|
10765
|
-
const dateStrLength = format
|
|
11026
|
+
const dateStrLength = format?.length || 0;
|
|
10766
11027
|
|
|
10767
11028
|
// Guard Clause: Date and format are defined
|
|
10768
11029
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10769
|
-
throw new Error(
|
|
11030
|
+
throw new Error(
|
|
11031
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11032
|
+
);
|
|
10770
11033
|
}
|
|
10771
11034
|
|
|
10772
11035
|
// Guard Clause: Date should be of type string
|
|
10773
11036
|
if (typeof date !== "string") {
|
|
10774
|
-
throw new Error(
|
|
11037
|
+
throw new Error(
|
|
11038
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11039
|
+
);
|
|
10775
11040
|
}
|
|
10776
11041
|
|
|
10777
11042
|
// Guard Clause: Format should be of type string
|
|
10778
11043
|
if (typeof format !== "string") {
|
|
10779
|
-
throw new Error(
|
|
11044
|
+
throw new Error(
|
|
11045
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11046
|
+
);
|
|
10780
11047
|
}
|
|
10781
11048
|
|
|
10782
11049
|
// Guard Clause: Length is what we expect it to be
|
|
10783
11050
|
if (date.length !== dateStrLength) {
|
|
10784
11051
|
return false;
|
|
10785
11052
|
}
|
|
10786
|
-
// Get a formatted date string and parse it
|
|
10787
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10788
|
-
|
|
10789
|
-
// Guard Clause: Date parse succeeded
|
|
10790
|
-
if (!dateParts) {
|
|
10791
|
-
return false;
|
|
10792
|
-
}
|
|
10793
|
-
|
|
10794
|
-
// Create the expected date string based on the date parts
|
|
10795
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
10796
|
-
|
|
10797
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
10798
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10799
|
-
|
|
10800
|
-
// Get the date string of the date object we created from the string date
|
|
10801
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10802
11053
|
|
|
10803
|
-
//
|
|
10804
|
-
|
|
11054
|
+
// Get a formatted date string and parse and validate it
|
|
11055
|
+
try {
|
|
11056
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11057
|
+
} catch (error) {
|
|
10805
11058
|
return false;
|
|
10806
11059
|
}
|
|
10807
|
-
|
|
10808
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10809
|
-
return true;
|
|
10810
11060
|
};
|
|
10811
11061
|
|
|
10812
11062
|
/**
|
|
@@ -10816,10 +11066,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10816
11066
|
* @returns {boolean}
|
|
10817
11067
|
*/
|
|
10818
11068
|
this.dateAndFormatMatch = (value, format) => {
|
|
10819
|
-
|
|
10820
11069
|
// Ensure we have both values we need to do the comparison
|
|
10821
11070
|
if (!value || !format) {
|
|
10822
|
-
throw new Error(
|
|
11071
|
+
throw new Error(
|
|
11072
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11073
|
+
);
|
|
10823
11074
|
}
|
|
10824
11075
|
|
|
10825
11076
|
// If the lengths are different, they cannot match
|
|
@@ -10828,11 +11079,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10828
11079
|
}
|
|
10829
11080
|
|
|
10830
11081
|
// Get the parts of the date
|
|
10831
|
-
const dateParts = dateFormatter.
|
|
11082
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10832
11083
|
|
|
10833
11084
|
// Validator for day
|
|
10834
11085
|
const dayValueIsValid = (day) => {
|
|
10835
|
-
|
|
10836
11086
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10837
11087
|
if (!dateParts.day) {
|
|
10838
11088
|
return true;
|
|
@@ -10848,7 +11098,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10848
11098
|
|
|
10849
11099
|
// Guard clause: ensure day is a valid integer
|
|
10850
11100
|
if (Number.isNaN(numDay)) {
|
|
10851
|
-
throw new Error(
|
|
11101
|
+
throw new Error(
|
|
11102
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11103
|
+
);
|
|
10852
11104
|
}
|
|
10853
11105
|
|
|
10854
11106
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10862,6 +11114,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10862
11114
|
|
|
10863
11115
|
// Validator for month
|
|
10864
11116
|
const monthValueIsValid = (month) => {
|
|
11117
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11118
|
+
if (!dateParts.month) {
|
|
11119
|
+
return true;
|
|
11120
|
+
}
|
|
10865
11121
|
|
|
10866
11122
|
// Guard clause: ensure month exists.
|
|
10867
11123
|
if (!month) {
|
|
@@ -10873,7 +11129,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10873
11129
|
|
|
10874
11130
|
// Guard clause: ensure month is a valid integer
|
|
10875
11131
|
if (Number.isNaN(numMonth)) {
|
|
10876
|
-
throw new Error(
|
|
11132
|
+
throw new Error(
|
|
11133
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11134
|
+
);
|
|
10877
11135
|
}
|
|
10878
11136
|
|
|
10879
11137
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10887,6 +11145,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10887
11145
|
|
|
10888
11146
|
// Validator for year
|
|
10889
11147
|
const yearIsValid = (_year) => {
|
|
11148
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11149
|
+
if (!dateParts.year) {
|
|
11150
|
+
return true;
|
|
11151
|
+
}
|
|
10890
11152
|
|
|
10891
11153
|
// Guard clause: ensure year exists.
|
|
10892
11154
|
if (!_year) {
|
|
@@ -10901,7 +11163,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10901
11163
|
|
|
10902
11164
|
// Guard clause: ensure year is a valid integer
|
|
10903
11165
|
if (Number.isNaN(numYear)) {
|
|
10904
|
-
throw new Error(
|
|
11166
|
+
throw new Error(
|
|
11167
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11168
|
+
);
|
|
10905
11169
|
}
|
|
10906
11170
|
|
|
10907
11171
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10917,7 +11181,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10917
11181
|
const checks = [
|
|
10918
11182
|
monthValueIsValid(dateParts.month),
|
|
10919
11183
|
dayValueIsValid(dateParts.day),
|
|
10920
|
-
yearIsValid(dateParts.year)
|
|
11184
|
+
yearIsValid(dateParts.year),
|
|
10921
11185
|
];
|
|
10922
11186
|
|
|
10923
11187
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -10951,10 +11215,7 @@ const {
|
|
|
10951
11215
|
} = dateUtilities;
|
|
10952
11216
|
|
|
10953
11217
|
const {
|
|
10954
|
-
toNorthAmericanFormat
|
|
10955
|
-
parseDate,
|
|
10956
|
-
getDateAsString
|
|
10957
|
-
} = dateFormatter;
|
|
11218
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
10958
11219
|
|
|
10959
11220
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
10960
11221
|
// See LICENSE in the project root for license information.
|
|
@@ -13169,7 +13430,7 @@ let AuroHelpText$1 = class AuroHelpText extends LitElement {
|
|
|
13169
13430
|
}
|
|
13170
13431
|
};
|
|
13171
13432
|
|
|
13172
|
-
var formkitVersion$1 = '
|
|
13433
|
+
var formkitVersion$1 = '202606022350';
|
|
13173
13434
|
|
|
13174
13435
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13175
13436
|
// See LICENSE in the project root for license information.
|
|
@@ -14242,7 +14503,7 @@ class AuroBibtemplate extends LitElement {
|
|
|
14242
14503
|
}
|
|
14243
14504
|
}
|
|
14244
14505
|
|
|
14245
|
-
var formkitVersion = '
|
|
14506
|
+
var formkitVersion = '202606022350';
|
|
14246
14507
|
|
|
14247
14508
|
var styleCss$1 = css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;text-align:left}:host [auro-dropdown]{--ds-auro-dropdown-trigger-background-color: transparent}:host #inputInBib::part(wrapper){box-shadow:none}:host #inputInBib::part(accent-left){display:none}:host([layout*=classic]) [auro-input]{width:100%}:host([layout*=classic]) [auro-input]::part(helpText){display:none}:host([layout*=classic]) #slotHolder{display:none}`;
|
|
14248
14509
|
|