@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
|
@@ -182,109 +182,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
/**
|
|
186
|
+
* @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.
|
|
187
|
+
* @param {string} dateStr - Date string to parse.
|
|
188
|
+
* @param {string} format - Date format to parse.
|
|
189
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
190
|
+
*/
|
|
191
|
+
function getDateParts$1(dateStr, format) {
|
|
192
|
+
if (!dateStr) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
186
195
|
|
|
187
|
-
|
|
196
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
197
|
+
let valueParts;
|
|
198
|
+
let formatParts;
|
|
188
199
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
if (formatSeparatorMatch) {
|
|
201
|
+
const separator = formatSeparatorMatch[0];
|
|
202
|
+
valueParts = dateStr.split(separator);
|
|
203
|
+
formatParts = format.split(separator);
|
|
204
|
+
} else {
|
|
205
|
+
if (dateStr.match(/[/.-]/)) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
208
|
+
);
|
|
209
|
+
}
|
|
196
210
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
if (dateStr.length !== format.length) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
214
|
+
);
|
|
215
|
+
}
|
|
201
216
|
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
valueParts = [dateStr];
|
|
218
|
+
formatParts = [format];
|
|
219
|
+
}
|
|
204
220
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
221
|
+
if (valueParts.length !== formatParts.length) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
208
226
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
212
|
-
}
|
|
227
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
228
|
+
const value = valueParts[index];
|
|
213
229
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
230
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
231
|
+
acc.month = value;
|
|
232
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
233
|
+
acc.day = value;
|
|
234
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
235
|
+
acc.year = value;
|
|
236
|
+
}
|
|
217
237
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else if ((/d/iu).test(part)) {
|
|
221
|
-
acc.day = value;
|
|
222
|
-
} else if ((/y/iu).test(part)) {
|
|
223
|
-
acc.year = value;
|
|
224
|
-
}
|
|
238
|
+
return acc;
|
|
239
|
+
}, {});
|
|
225
240
|
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
if (!result.month && !result.day && !result.year) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
244
|
+
);
|
|
245
|
+
}
|
|
228
246
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return result;
|
|
232
|
-
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
233
249
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
function isCalendarDate$1(year, month, day) {
|
|
251
|
+
let yearNumber = Number(year);
|
|
252
|
+
const monthNumber = Number(month);
|
|
253
|
+
const dayNumber = Number(day);
|
|
237
254
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
year: "numeric",
|
|
246
|
-
month: "2-digit",
|
|
247
|
-
day: "2-digit",
|
|
248
|
-
});
|
|
255
|
+
if (
|
|
256
|
+
!Number.isInteger(yearNumber) ||
|
|
257
|
+
!Number.isInteger(monthNumber) ||
|
|
258
|
+
!Number.isInteger(dayNumber)
|
|
259
|
+
) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
249
262
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
263
|
+
// 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.
|
|
264
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
265
|
+
yearNumber += 1900;
|
|
266
|
+
} else if (yearNumber < 50) {
|
|
267
|
+
yearNumber += 2000;
|
|
268
|
+
}
|
|
257
269
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
270
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
271
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
275
|
+
);
|
|
276
|
+
}
|
|
261
277
|
|
|
262
|
-
|
|
278
|
+
/**
|
|
279
|
+
* @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).
|
|
280
|
+
*
|
|
281
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
282
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
283
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
284
|
+
* @param {string} dateStr - Date string to parse.
|
|
285
|
+
* @param {string} format - Date format to parse.
|
|
286
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
287
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
288
|
+
*/
|
|
289
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
290
|
+
if (!dateStr || !format) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
263
294
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
295
|
+
if (!result) {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
267
298
|
|
|
268
|
-
|
|
299
|
+
const lowerFormat = format.toLowerCase();
|
|
300
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
301
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
302
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
269
303
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
304
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
274
307
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
308
|
+
throw new Error(
|
|
309
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
278
312
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Convert a date object to string format.
|
|
315
|
+
* @param {Object} date - Date to convert to string.
|
|
316
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
317
|
+
* @returns {String} Returns the date as a string.
|
|
318
|
+
*/
|
|
319
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
320
|
+
return date.toLocaleDateString(locale, {
|
|
321
|
+
year: "numeric",
|
|
322
|
+
month: "2-digit",
|
|
323
|
+
day: "2-digit",
|
|
324
|
+
});
|
|
325
|
+
}
|
|
282
326
|
|
|
283
|
-
|
|
284
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Converts a date string to a North American date format.
|
|
329
|
+
* @param {String} dateStr - Date to validate.
|
|
330
|
+
* @param {String} format - Date format to validate against.
|
|
331
|
+
* @returns {String}
|
|
332
|
+
*/
|
|
333
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
334
|
+
if (format === "mm/dd/yyyy") {
|
|
335
|
+
return dateStr;
|
|
285
336
|
}
|
|
337
|
+
|
|
338
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
339
|
+
|
|
340
|
+
if (!parsedDate) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const { month, day, year } = parsedDate;
|
|
347
|
+
|
|
348
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
353
|
+
*
|
|
354
|
+
* @param {string} dateStr - Date string to validate.
|
|
355
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
356
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
357
|
+
*/
|
|
358
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
359
|
+
try {
|
|
360
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (parseDate$1(dateStr, format)) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
} catch (error) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 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.
|
|
375
|
+
*
|
|
376
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
377
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
378
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
379
|
+
*/
|
|
380
|
+
function toISOFormatString$1(date) {
|
|
381
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
382
|
+
throw new Error(
|
|
383
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 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.
|
|
391
|
+
*
|
|
392
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
393
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
394
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
395
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
396
|
+
*/
|
|
397
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
398
|
+
if (typeof dateStr !== "string") {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
403
|
+
return new Date(`${year}/${month}/${day}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const dateFormatter$1 = {
|
|
407
|
+
parseDate: parseDate$1,
|
|
408
|
+
getDateParts: getDateParts$1,
|
|
409
|
+
getDateAsString: getDateAsString$1,
|
|
410
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
411
|
+
isValidDate: isValidDate$1,
|
|
412
|
+
toISOFormatString: toISOFormatString$1,
|
|
413
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
286
414
|
};
|
|
287
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
288
415
|
|
|
289
416
|
// filepath: dateConstraints.mjs
|
|
290
417
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -356,12 +483,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
356
483
|
/* eslint-disable no-magic-numbers */
|
|
357
484
|
|
|
358
485
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
359
|
-
|
|
360
486
|
/**
|
|
361
487
|
* Returns the current century.
|
|
362
488
|
* @returns {String} The current century.
|
|
363
489
|
*/
|
|
364
|
-
getCentury
|
|
490
|
+
getCentury() {
|
|
365
491
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
366
492
|
}
|
|
367
493
|
|
|
@@ -370,14 +496,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
370
496
|
* @param {String} year - The year to convert to four digits.
|
|
371
497
|
* @returns {String} The four digit year.
|
|
372
498
|
*/
|
|
373
|
-
getFourDigitYear
|
|
374
|
-
|
|
499
|
+
getFourDigitYear(year) {
|
|
375
500
|
const strYear = String(year).trim();
|
|
376
501
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
377
502
|
}
|
|
378
503
|
|
|
379
504
|
constructor() {
|
|
380
|
-
|
|
381
505
|
super();
|
|
382
506
|
|
|
383
507
|
/**
|
|
@@ -386,7 +510,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
386
510
|
* @param {Object} date2 - Second date to compare.
|
|
387
511
|
* @returns {Boolean} Returns true if the dates match.
|
|
388
512
|
*/
|
|
389
|
-
this.datesMatch = (date1, date2) =>
|
|
513
|
+
this.datesMatch = (date1, date2) =>
|
|
514
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
390
515
|
|
|
391
516
|
/**
|
|
392
517
|
* Returns true if value passed in is a valid date.
|
|
@@ -395,53 +520,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
395
520
|
* @returns {Boolean}
|
|
396
521
|
*/
|
|
397
522
|
this.validDateStr = (date, format) => {
|
|
398
|
-
|
|
399
523
|
// The length we expect the date string to be
|
|
400
|
-
const dateStrLength = format
|
|
524
|
+
const dateStrLength = format?.length || 0;
|
|
401
525
|
|
|
402
526
|
// Guard Clause: Date and format are defined
|
|
403
527
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
404
|
-
throw new Error(
|
|
528
|
+
throw new Error(
|
|
529
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
530
|
+
);
|
|
405
531
|
}
|
|
406
532
|
|
|
407
533
|
// Guard Clause: Date should be of type string
|
|
408
534
|
if (typeof date !== "string") {
|
|
409
|
-
throw new Error(
|
|
535
|
+
throw new Error(
|
|
536
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
537
|
+
);
|
|
410
538
|
}
|
|
411
539
|
|
|
412
540
|
// Guard Clause: Format should be of type string
|
|
413
541
|
if (typeof format !== "string") {
|
|
414
|
-
throw new Error(
|
|
542
|
+
throw new Error(
|
|
543
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
544
|
+
);
|
|
415
545
|
}
|
|
416
546
|
|
|
417
547
|
// Guard Clause: Length is what we expect it to be
|
|
418
548
|
if (date.length !== dateStrLength) {
|
|
419
549
|
return false;
|
|
420
550
|
}
|
|
421
|
-
// Get a formatted date string and parse it
|
|
422
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
423
|
-
|
|
424
|
-
// Guard Clause: Date parse succeeded
|
|
425
|
-
if (!dateParts) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Create the expected date string based on the date parts
|
|
430
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
431
|
-
|
|
432
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
433
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
434
551
|
|
|
435
|
-
// Get
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (expectedDateStr !== actualDateStr) {
|
|
552
|
+
// Get a formatted date string and parse and validate it
|
|
553
|
+
try {
|
|
554
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
555
|
+
} catch (error) {
|
|
440
556
|
return false;
|
|
441
557
|
}
|
|
442
|
-
|
|
443
|
-
// If we passed all other checks, we can assume the date is valid
|
|
444
|
-
return true;
|
|
445
558
|
};
|
|
446
559
|
|
|
447
560
|
/**
|
|
@@ -451,10 +564,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
451
564
|
* @returns {boolean}
|
|
452
565
|
*/
|
|
453
566
|
this.dateAndFormatMatch = (value, format) => {
|
|
454
|
-
|
|
455
567
|
// Ensure we have both values we need to do the comparison
|
|
456
568
|
if (!value || !format) {
|
|
457
|
-
throw new Error(
|
|
569
|
+
throw new Error(
|
|
570
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
571
|
+
);
|
|
458
572
|
}
|
|
459
573
|
|
|
460
574
|
// If the lengths are different, they cannot match
|
|
@@ -463,11 +577,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
463
577
|
}
|
|
464
578
|
|
|
465
579
|
// Get the parts of the date
|
|
466
|
-
const dateParts = dateFormatter$1.
|
|
580
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
467
581
|
|
|
468
582
|
// Validator for day
|
|
469
583
|
const dayValueIsValid = (day) => {
|
|
470
|
-
|
|
471
584
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
472
585
|
if (!dateParts.day) {
|
|
473
586
|
return true;
|
|
@@ -483,7 +596,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
483
596
|
|
|
484
597
|
// Guard clause: ensure day is a valid integer
|
|
485
598
|
if (Number.isNaN(numDay)) {
|
|
486
|
-
throw new Error(
|
|
599
|
+
throw new Error(
|
|
600
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
601
|
+
);
|
|
487
602
|
}
|
|
488
603
|
|
|
489
604
|
// Guard clause: ensure day is within the valid range
|
|
@@ -497,6 +612,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
497
612
|
|
|
498
613
|
// Validator for month
|
|
499
614
|
const monthValueIsValid = (month) => {
|
|
615
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
616
|
+
if (!dateParts.month) {
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
500
619
|
|
|
501
620
|
// Guard clause: ensure month exists.
|
|
502
621
|
if (!month) {
|
|
@@ -508,7 +627,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
508
627
|
|
|
509
628
|
// Guard clause: ensure month is a valid integer
|
|
510
629
|
if (Number.isNaN(numMonth)) {
|
|
511
|
-
throw new Error(
|
|
630
|
+
throw new Error(
|
|
631
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
632
|
+
);
|
|
512
633
|
}
|
|
513
634
|
|
|
514
635
|
// Guard clause: ensure month is within the valid range
|
|
@@ -522,6 +643,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
522
643
|
|
|
523
644
|
// Validator for year
|
|
524
645
|
const yearIsValid = (_year) => {
|
|
646
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
647
|
+
if (!dateParts.year) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
525
650
|
|
|
526
651
|
// Guard clause: ensure year exists.
|
|
527
652
|
if (!_year) {
|
|
@@ -536,7 +661,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
536
661
|
|
|
537
662
|
// Guard clause: ensure year is a valid integer
|
|
538
663
|
if (Number.isNaN(numYear)) {
|
|
539
|
-
throw new Error(
|
|
664
|
+
throw new Error(
|
|
665
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
666
|
+
);
|
|
540
667
|
}
|
|
541
668
|
|
|
542
669
|
// Guard clause: ensure year is within the valid range
|
|
@@ -552,7 +679,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
552
679
|
const checks = [
|
|
553
680
|
monthValueIsValid(dateParts.month),
|
|
554
681
|
dayValueIsValid(dateParts.day),
|
|
555
|
-
yearIsValid(dateParts.year)
|
|
682
|
+
yearIsValid(dateParts.year),
|
|
556
683
|
];
|
|
557
684
|
|
|
558
685
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -586,10 +713,7 @@ const {
|
|
|
586
713
|
} = dateUtilities$1;
|
|
587
714
|
|
|
588
715
|
const {
|
|
589
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
590
|
-
parseDate: parseDate$1,
|
|
591
|
-
getDateAsString: getDateAsString$1
|
|
592
|
-
} = dateFormatter$1;
|
|
716
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
593
717
|
|
|
594
718
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
595
719
|
// See LICENSE in the project root for license information.
|
|
@@ -826,13 +950,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
826
950
|
}
|
|
827
951
|
|
|
828
952
|
// Perform the rest of the validation
|
|
829
|
-
const formattedValue = toNorthAmericanFormat$
|
|
953
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
830
954
|
const valueDate = new Date(formattedValue);
|
|
831
955
|
|
|
832
956
|
// // Validate max date
|
|
833
957
|
if (elem.max?.length === elem.lengthForType) {
|
|
834
958
|
|
|
835
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
959
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
836
960
|
|
|
837
961
|
if (valueDate > maxDate) {
|
|
838
962
|
elem.validity = 'rangeOverflow';
|
|
@@ -843,7 +967,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
843
967
|
|
|
844
968
|
// Validate min date
|
|
845
969
|
if (elem.min?.length === elem.lengthForType) {
|
|
846
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
970
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
847
971
|
|
|
848
972
|
if (valueDate < minDate) {
|
|
849
973
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5293,7 +5417,7 @@ let AuroHelpText$2 = class AuroHelpText extends i$4 {
|
|
|
5293
5417
|
}
|
|
5294
5418
|
};
|
|
5295
5419
|
|
|
5296
|
-
var formkitVersion$2 = '
|
|
5420
|
+
var formkitVersion$2 = '202606022350';
|
|
5297
5421
|
|
|
5298
5422
|
let AuroElement$2 = class AuroElement extends i$4 {
|
|
5299
5423
|
static get properties() {
|
|
@@ -6286,16 +6410,20 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6286
6410
|
|
|
6287
6411
|
// Walk up the ancestor chain, inerting siblings at each level
|
|
6288
6412
|
// to ensure the entire page outside the host subtree is inert.
|
|
6413
|
+
// Uses a reference counter (data-auro-inert-count) so multiple
|
|
6414
|
+
// simultaneous modal dropdowns share inert state safely.
|
|
6289
6415
|
let current = host;
|
|
6290
6416
|
while (current.parentElement) {
|
|
6291
6417
|
const parent = current.parentElement;
|
|
6292
6418
|
for (const sibling of parent.children) {
|
|
6293
6419
|
if (sibling !== current) {
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
}
|
|
6420
|
+
const count = parseInt(sibling.dataset.auroInertCount || '0', 10);
|
|
6421
|
+
if (count === 0) {
|
|
6422
|
+
sibling.dataset.auroInertWas = sibling.inert ? 'true' : 'false';
|
|
6423
|
+
}
|
|
6424
|
+
sibling.dataset.auroInertCount = String(count + 1);
|
|
6298
6425
|
sibling.inert = true;
|
|
6426
|
+
this._inertSiblings.push(sibling);
|
|
6299
6427
|
}
|
|
6300
6428
|
}
|
|
6301
6429
|
current = parent;
|
|
@@ -6304,14 +6432,23 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6304
6432
|
|
|
6305
6433
|
/**
|
|
6306
6434
|
* Restores `inert` state on siblings that were tracked by `_setPageInert`.
|
|
6307
|
-
*
|
|
6308
|
-
*
|
|
6435
|
+
* Uses reference counting so inert is only cleared when the last modal
|
|
6436
|
+
* dropdown releases a given element. Preserves the original inert state
|
|
6437
|
+
* so externally-inerted elements are not inadvertently re-enabled.
|
|
6309
6438
|
* @private
|
|
6310
6439
|
*/
|
|
6311
6440
|
_clearPageInert() {
|
|
6312
6441
|
if (this._inertSiblings) {
|
|
6313
|
-
for (const
|
|
6314
|
-
|
|
6442
|
+
for (const sibling of this._inertSiblings) {
|
|
6443
|
+
const count = parseInt(sibling.dataset.auroInertCount || '1', 10) - 1;
|
|
6444
|
+
if (count <= 0) {
|
|
6445
|
+
const wasInert = sibling.dataset.auroInertWas === 'true';
|
|
6446
|
+
delete sibling.dataset.auroInertCount;
|
|
6447
|
+
delete sibling.dataset.auroInertWas;
|
|
6448
|
+
sibling.inert = wasInert;
|
|
6449
|
+
} else {
|
|
6450
|
+
sibling.dataset.auroInertCount = String(count);
|
|
6451
|
+
}
|
|
6315
6452
|
}
|
|
6316
6453
|
this._inertSiblings = undefined;
|
|
6317
6454
|
}
|
|
@@ -10636,109 +10773,236 @@ class AuroInputUtilities {
|
|
|
10636
10773
|
}
|
|
10637
10774
|
}
|
|
10638
10775
|
|
|
10639
|
-
|
|
10776
|
+
/**
|
|
10777
|
+
* @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.
|
|
10778
|
+
* @param {string} dateStr - Date string to parse.
|
|
10779
|
+
* @param {string} format - Date format to parse.
|
|
10780
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10781
|
+
*/
|
|
10782
|
+
function getDateParts(dateStr, format) {
|
|
10783
|
+
if (!dateStr) {
|
|
10784
|
+
return undefined;
|
|
10785
|
+
}
|
|
10640
10786
|
|
|
10641
|
-
|
|
10787
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10788
|
+
let valueParts;
|
|
10789
|
+
let formatParts;
|
|
10642
10790
|
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10791
|
+
if (formatSeparatorMatch) {
|
|
10792
|
+
const separator = formatSeparatorMatch[0];
|
|
10793
|
+
valueParts = dateStr.split(separator);
|
|
10794
|
+
formatParts = format.split(separator);
|
|
10795
|
+
} else {
|
|
10796
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10797
|
+
throw new Error(
|
|
10798
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10799
|
+
);
|
|
10800
|
+
}
|
|
10650
10801
|
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10802
|
+
if (dateStr.length !== format.length) {
|
|
10803
|
+
throw new Error(
|
|
10804
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10805
|
+
);
|
|
10806
|
+
}
|
|
10655
10807
|
|
|
10656
|
-
|
|
10657
|
-
|
|
10808
|
+
valueParts = [dateStr];
|
|
10809
|
+
formatParts = [format];
|
|
10810
|
+
}
|
|
10658
10811
|
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10812
|
+
if (valueParts.length !== formatParts.length) {
|
|
10813
|
+
throw new Error(
|
|
10814
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10815
|
+
);
|
|
10816
|
+
}
|
|
10662
10817
|
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10666
|
-
}
|
|
10818
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10819
|
+
const value = valueParts[index];
|
|
10667
10820
|
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10821
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10822
|
+
acc.month = value;
|
|
10823
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10824
|
+
acc.day = value;
|
|
10825
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10826
|
+
acc.year = value;
|
|
10827
|
+
}
|
|
10671
10828
|
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
} else if ((/d/iu).test(part)) {
|
|
10675
|
-
acc.day = value;
|
|
10676
|
-
} else if ((/y/iu).test(part)) {
|
|
10677
|
-
acc.year = value;
|
|
10678
|
-
}
|
|
10829
|
+
return acc;
|
|
10830
|
+
}, {});
|
|
10679
10831
|
|
|
10680
|
-
|
|
10681
|
-
|
|
10832
|
+
if (!result.month && !result.day && !result.year) {
|
|
10833
|
+
throw new Error(
|
|
10834
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10835
|
+
);
|
|
10836
|
+
}
|
|
10682
10837
|
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
return result;
|
|
10686
|
-
}
|
|
10838
|
+
return result;
|
|
10839
|
+
}
|
|
10687
10840
|
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10841
|
+
function isCalendarDate(year, month, day) {
|
|
10842
|
+
let yearNumber = Number(year);
|
|
10843
|
+
const monthNumber = Number(month);
|
|
10844
|
+
const dayNumber = Number(day);
|
|
10691
10845
|
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
year: "numeric",
|
|
10700
|
-
month: "2-digit",
|
|
10701
|
-
day: "2-digit",
|
|
10702
|
-
});
|
|
10846
|
+
if (
|
|
10847
|
+
!Number.isInteger(yearNumber) ||
|
|
10848
|
+
!Number.isInteger(monthNumber) ||
|
|
10849
|
+
!Number.isInteger(dayNumber)
|
|
10850
|
+
) {
|
|
10851
|
+
return false;
|
|
10852
|
+
}
|
|
10703
10853
|
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10854
|
+
// 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.
|
|
10855
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10856
|
+
yearNumber += 1900;
|
|
10857
|
+
} else if (yearNumber < 50) {
|
|
10858
|
+
yearNumber += 2000;
|
|
10859
|
+
}
|
|
10711
10860
|
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
}
|
|
10861
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10862
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10715
10863
|
|
|
10716
|
-
|
|
10864
|
+
return (
|
|
10865
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10866
|
+
);
|
|
10867
|
+
}
|
|
10717
10868
|
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10869
|
+
/**
|
|
10870
|
+
* @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).
|
|
10871
|
+
*
|
|
10872
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10873
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10874
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10875
|
+
* @param {string} dateStr - Date string to parse.
|
|
10876
|
+
* @param {string} format - Date format to parse.
|
|
10877
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10878
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10879
|
+
*/
|
|
10880
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10881
|
+
if (!dateStr || !format) {
|
|
10882
|
+
return undefined;
|
|
10883
|
+
}
|
|
10884
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10721
10885
|
|
|
10722
|
-
|
|
10886
|
+
if (!result) {
|
|
10887
|
+
return undefined;
|
|
10888
|
+
}
|
|
10723
10889
|
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10890
|
+
const lowerFormat = format.toLowerCase();
|
|
10891
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10892
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10893
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10728
10894
|
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10895
|
+
if (isCalendarDate(year, month, day)) {
|
|
10896
|
+
return result;
|
|
10897
|
+
}
|
|
10732
10898
|
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10899
|
+
throw new Error(
|
|
10900
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10901
|
+
);
|
|
10902
|
+
}
|
|
10736
10903
|
|
|
10737
|
-
|
|
10738
|
-
|
|
10904
|
+
/**
|
|
10905
|
+
* Convert a date object to string format.
|
|
10906
|
+
* @param {Object} date - Date to convert to string.
|
|
10907
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10908
|
+
* @returns {String} Returns the date as a string.
|
|
10909
|
+
*/
|
|
10910
|
+
function getDateAsString(date, locale = undefined) {
|
|
10911
|
+
return date.toLocaleDateString(locale, {
|
|
10912
|
+
year: "numeric",
|
|
10913
|
+
month: "2-digit",
|
|
10914
|
+
day: "2-digit",
|
|
10915
|
+
});
|
|
10916
|
+
}
|
|
10917
|
+
|
|
10918
|
+
/**
|
|
10919
|
+
* Converts a date string to a North American date format.
|
|
10920
|
+
* @param {String} dateStr - Date to validate.
|
|
10921
|
+
* @param {String} format - Date format to validate against.
|
|
10922
|
+
* @returns {String}
|
|
10923
|
+
*/
|
|
10924
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10925
|
+
if (format === "mm/dd/yyyy") {
|
|
10926
|
+
return dateStr;
|
|
10739
10927
|
}
|
|
10928
|
+
|
|
10929
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10930
|
+
|
|
10931
|
+
if (!parsedDate) {
|
|
10932
|
+
throw new Error(
|
|
10933
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10934
|
+
);
|
|
10935
|
+
}
|
|
10936
|
+
|
|
10937
|
+
const { month, day, year } = parsedDate;
|
|
10938
|
+
|
|
10939
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10940
|
+
}
|
|
10941
|
+
|
|
10942
|
+
/**
|
|
10943
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10944
|
+
*
|
|
10945
|
+
* @param {string} dateStr - Date string to validate.
|
|
10946
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10947
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10948
|
+
*/
|
|
10949
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10950
|
+
try {
|
|
10951
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10952
|
+
return false;
|
|
10953
|
+
}
|
|
10954
|
+
|
|
10955
|
+
if (parseDate(dateStr, format)) {
|
|
10956
|
+
return true;
|
|
10957
|
+
}
|
|
10958
|
+
} catch (error) {
|
|
10959
|
+
return false;
|
|
10960
|
+
}
|
|
10961
|
+
return false;
|
|
10962
|
+
}
|
|
10963
|
+
|
|
10964
|
+
/**
|
|
10965
|
+
* 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.
|
|
10966
|
+
*
|
|
10967
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10968
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10969
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10970
|
+
*/
|
|
10971
|
+
function toISOFormatString(date) {
|
|
10972
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10973
|
+
throw new Error(
|
|
10974
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10975
|
+
);
|
|
10976
|
+
}
|
|
10977
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10978
|
+
}
|
|
10979
|
+
|
|
10980
|
+
/**
|
|
10981
|
+
* 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.
|
|
10982
|
+
*
|
|
10983
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10984
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10985
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10986
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10987
|
+
*/
|
|
10988
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10989
|
+
if (typeof dateStr !== "string") {
|
|
10990
|
+
return null;
|
|
10991
|
+
}
|
|
10992
|
+
|
|
10993
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10994
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10740
10995
|
}
|
|
10741
|
-
|
|
10996
|
+
|
|
10997
|
+
const dateFormatter = {
|
|
10998
|
+
parseDate,
|
|
10999
|
+
getDateParts,
|
|
11000
|
+
getDateAsString,
|
|
11001
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
11002
|
+
isValidDate,
|
|
11003
|
+
toISOFormatString,
|
|
11004
|
+
stringToDateInstance,
|
|
11005
|
+
};
|
|
10742
11006
|
|
|
10743
11007
|
// filepath: dateConstraints.mjs
|
|
10744
11008
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10810,12 +11074,11 @@ class AuroDateUtilitiesBase {
|
|
|
10810
11074
|
/* eslint-disable no-magic-numbers */
|
|
10811
11075
|
|
|
10812
11076
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10813
|
-
|
|
10814
11077
|
/**
|
|
10815
11078
|
* Returns the current century.
|
|
10816
11079
|
* @returns {String} The current century.
|
|
10817
11080
|
*/
|
|
10818
|
-
getCentury
|
|
11081
|
+
getCentury() {
|
|
10819
11082
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10820
11083
|
}
|
|
10821
11084
|
|
|
@@ -10824,14 +11087,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10824
11087
|
* @param {String} year - The year to convert to four digits.
|
|
10825
11088
|
* @returns {String} The four digit year.
|
|
10826
11089
|
*/
|
|
10827
|
-
getFourDigitYear
|
|
10828
|
-
|
|
11090
|
+
getFourDigitYear(year) {
|
|
10829
11091
|
const strYear = String(year).trim();
|
|
10830
11092
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10831
11093
|
}
|
|
10832
11094
|
|
|
10833
11095
|
constructor() {
|
|
10834
|
-
|
|
10835
11096
|
super();
|
|
10836
11097
|
|
|
10837
11098
|
/**
|
|
@@ -10840,7 +11101,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10840
11101
|
* @param {Object} date2 - Second date to compare.
|
|
10841
11102
|
* @returns {Boolean} Returns true if the dates match.
|
|
10842
11103
|
*/
|
|
10843
|
-
this.datesMatch = (date1, date2) =>
|
|
11104
|
+
this.datesMatch = (date1, date2) =>
|
|
11105
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10844
11106
|
|
|
10845
11107
|
/**
|
|
10846
11108
|
* Returns true if value passed in is a valid date.
|
|
@@ -10849,53 +11111,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10849
11111
|
* @returns {Boolean}
|
|
10850
11112
|
*/
|
|
10851
11113
|
this.validDateStr = (date, format) => {
|
|
10852
|
-
|
|
10853
11114
|
// The length we expect the date string to be
|
|
10854
|
-
const dateStrLength = format
|
|
11115
|
+
const dateStrLength = format?.length || 0;
|
|
10855
11116
|
|
|
10856
11117
|
// Guard Clause: Date and format are defined
|
|
10857
11118
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10858
|
-
throw new Error(
|
|
11119
|
+
throw new Error(
|
|
11120
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11121
|
+
);
|
|
10859
11122
|
}
|
|
10860
11123
|
|
|
10861
11124
|
// Guard Clause: Date should be of type string
|
|
10862
11125
|
if (typeof date !== "string") {
|
|
10863
|
-
throw new Error(
|
|
11126
|
+
throw new Error(
|
|
11127
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11128
|
+
);
|
|
10864
11129
|
}
|
|
10865
11130
|
|
|
10866
11131
|
// Guard Clause: Format should be of type string
|
|
10867
11132
|
if (typeof format !== "string") {
|
|
10868
|
-
throw new Error(
|
|
11133
|
+
throw new Error(
|
|
11134
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11135
|
+
);
|
|
10869
11136
|
}
|
|
10870
11137
|
|
|
10871
11138
|
// Guard Clause: Length is what we expect it to be
|
|
10872
11139
|
if (date.length !== dateStrLength) {
|
|
10873
11140
|
return false;
|
|
10874
11141
|
}
|
|
10875
|
-
// Get a formatted date string and parse it
|
|
10876
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10877
|
-
|
|
10878
|
-
// Guard Clause: Date parse succeeded
|
|
10879
|
-
if (!dateParts) {
|
|
10880
|
-
return false;
|
|
10881
|
-
}
|
|
10882
|
-
|
|
10883
|
-
// Create the expected date string based on the date parts
|
|
10884
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
10885
|
-
|
|
10886
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
10887
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10888
|
-
|
|
10889
|
-
// Get the date string of the date object we created from the string date
|
|
10890
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10891
11142
|
|
|
10892
|
-
//
|
|
10893
|
-
|
|
11143
|
+
// Get a formatted date string and parse and validate it
|
|
11144
|
+
try {
|
|
11145
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11146
|
+
} catch (error) {
|
|
10894
11147
|
return false;
|
|
10895
11148
|
}
|
|
10896
|
-
|
|
10897
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10898
|
-
return true;
|
|
10899
11149
|
};
|
|
10900
11150
|
|
|
10901
11151
|
/**
|
|
@@ -10905,10 +11155,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10905
11155
|
* @returns {boolean}
|
|
10906
11156
|
*/
|
|
10907
11157
|
this.dateAndFormatMatch = (value, format) => {
|
|
10908
|
-
|
|
10909
11158
|
// Ensure we have both values we need to do the comparison
|
|
10910
11159
|
if (!value || !format) {
|
|
10911
|
-
throw new Error(
|
|
11160
|
+
throw new Error(
|
|
11161
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11162
|
+
);
|
|
10912
11163
|
}
|
|
10913
11164
|
|
|
10914
11165
|
// If the lengths are different, they cannot match
|
|
@@ -10917,11 +11168,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10917
11168
|
}
|
|
10918
11169
|
|
|
10919
11170
|
// Get the parts of the date
|
|
10920
|
-
const dateParts = dateFormatter.
|
|
11171
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10921
11172
|
|
|
10922
11173
|
// Validator for day
|
|
10923
11174
|
const dayValueIsValid = (day) => {
|
|
10924
|
-
|
|
10925
11175
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10926
11176
|
if (!dateParts.day) {
|
|
10927
11177
|
return true;
|
|
@@ -10937,7 +11187,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10937
11187
|
|
|
10938
11188
|
// Guard clause: ensure day is a valid integer
|
|
10939
11189
|
if (Number.isNaN(numDay)) {
|
|
10940
|
-
throw new Error(
|
|
11190
|
+
throw new Error(
|
|
11191
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11192
|
+
);
|
|
10941
11193
|
}
|
|
10942
11194
|
|
|
10943
11195
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10951,6 +11203,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10951
11203
|
|
|
10952
11204
|
// Validator for month
|
|
10953
11205
|
const monthValueIsValid = (month) => {
|
|
11206
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11207
|
+
if (!dateParts.month) {
|
|
11208
|
+
return true;
|
|
11209
|
+
}
|
|
10954
11210
|
|
|
10955
11211
|
// Guard clause: ensure month exists.
|
|
10956
11212
|
if (!month) {
|
|
@@ -10962,7 +11218,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10962
11218
|
|
|
10963
11219
|
// Guard clause: ensure month is a valid integer
|
|
10964
11220
|
if (Number.isNaN(numMonth)) {
|
|
10965
|
-
throw new Error(
|
|
11221
|
+
throw new Error(
|
|
11222
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11223
|
+
);
|
|
10966
11224
|
}
|
|
10967
11225
|
|
|
10968
11226
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10976,6 +11234,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10976
11234
|
|
|
10977
11235
|
// Validator for year
|
|
10978
11236
|
const yearIsValid = (_year) => {
|
|
11237
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11238
|
+
if (!dateParts.year) {
|
|
11239
|
+
return true;
|
|
11240
|
+
}
|
|
10979
11241
|
|
|
10980
11242
|
// Guard clause: ensure year exists.
|
|
10981
11243
|
if (!_year) {
|
|
@@ -10990,7 +11252,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10990
11252
|
|
|
10991
11253
|
// Guard clause: ensure year is a valid integer
|
|
10992
11254
|
if (Number.isNaN(numYear)) {
|
|
10993
|
-
throw new Error(
|
|
11255
|
+
throw new Error(
|
|
11256
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11257
|
+
);
|
|
10994
11258
|
}
|
|
10995
11259
|
|
|
10996
11260
|
// Guard clause: ensure year is within the valid range
|
|
@@ -11006,7 +11270,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
11006
11270
|
const checks = [
|
|
11007
11271
|
monthValueIsValid(dateParts.month),
|
|
11008
11272
|
dayValueIsValid(dateParts.day),
|
|
11009
|
-
yearIsValid(dateParts.year)
|
|
11273
|
+
yearIsValid(dateParts.year),
|
|
11010
11274
|
];
|
|
11011
11275
|
|
|
11012
11276
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -11040,10 +11304,7 @@ const {
|
|
|
11040
11304
|
} = dateUtilities;
|
|
11041
11305
|
|
|
11042
11306
|
const {
|
|
11043
|
-
toNorthAmericanFormat
|
|
11044
|
-
parseDate,
|
|
11045
|
-
getDateAsString
|
|
11046
|
-
} = dateFormatter;
|
|
11307
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
11047
11308
|
|
|
11048
11309
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
11049
11310
|
// See LICENSE in the project root for license information.
|
|
@@ -13258,7 +13519,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$4 {
|
|
|
13258
13519
|
}
|
|
13259
13520
|
};
|
|
13260
13521
|
|
|
13261
|
-
var formkitVersion$1 = '
|
|
13522
|
+
var formkitVersion$1 = '202606022350';
|
|
13262
13523
|
|
|
13263
13524
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13264
13525
|
// See LICENSE in the project root for license information.
|
|
@@ -14331,7 +14592,7 @@ class AuroBibtemplate extends i$4 {
|
|
|
14331
14592
|
}
|
|
14332
14593
|
}
|
|
14333
14594
|
|
|
14334
|
-
var formkitVersion = '
|
|
14595
|
+
var formkitVersion = '202606022350';
|
|
14335
14596
|
|
|
14336
14597
|
var styleCss$3 = i$7`.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}`;
|
|
14337
14598
|
|