@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
|
@@ -167,109 +167,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @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.
|
|
172
|
+
* @param {string} dateStr - Date string to parse.
|
|
173
|
+
* @param {string} format - Date format to parse.
|
|
174
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
175
|
+
*/
|
|
176
|
+
function getDateParts$1(dateStr, format) {
|
|
177
|
+
if (!dateStr) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
171
180
|
|
|
172
|
-
|
|
181
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
182
|
+
let valueParts;
|
|
183
|
+
let formatParts;
|
|
173
184
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
if (formatSeparatorMatch) {
|
|
186
|
+
const separator = formatSeparatorMatch[0];
|
|
187
|
+
valueParts = dateStr.split(separator);
|
|
188
|
+
formatParts = format.split(separator);
|
|
189
|
+
} else {
|
|
190
|
+
if (dateStr.match(/[/.-]/)) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
193
|
+
);
|
|
194
|
+
}
|
|
181
195
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
if (dateStr.length !== format.length) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
199
|
+
);
|
|
200
|
+
}
|
|
186
201
|
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
valueParts = [dateStr];
|
|
203
|
+
formatParts = [format];
|
|
204
|
+
}
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
if (valueParts.length !== formatParts.length) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
193
211
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
197
|
-
}
|
|
212
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
213
|
+
const value = valueParts[index];
|
|
198
214
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
216
|
+
acc.month = value;
|
|
217
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
218
|
+
acc.day = value;
|
|
219
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
220
|
+
acc.year = value;
|
|
221
|
+
}
|
|
202
222
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
} else if ((/d/iu).test(part)) {
|
|
206
|
-
acc.day = value;
|
|
207
|
-
} else if ((/y/iu).test(part)) {
|
|
208
|
-
acc.year = value;
|
|
209
|
-
}
|
|
223
|
+
return acc;
|
|
224
|
+
}, {});
|
|
210
225
|
|
|
211
|
-
|
|
212
|
-
|
|
226
|
+
if (!result.month && !result.day && !result.year) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
229
|
+
);
|
|
230
|
+
}
|
|
213
231
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
218
234
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
235
|
+
function isCalendarDate$1(year, month, day) {
|
|
236
|
+
let yearNumber = Number(year);
|
|
237
|
+
const monthNumber = Number(month);
|
|
238
|
+
const dayNumber = Number(day);
|
|
222
239
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
year: "numeric",
|
|
231
|
-
month: "2-digit",
|
|
232
|
-
day: "2-digit",
|
|
233
|
-
});
|
|
240
|
+
if (
|
|
241
|
+
!Number.isInteger(yearNumber) ||
|
|
242
|
+
!Number.isInteger(monthNumber) ||
|
|
243
|
+
!Number.isInteger(dayNumber)
|
|
244
|
+
) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
234
247
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
248
|
+
// 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.
|
|
249
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
250
|
+
yearNumber += 1900;
|
|
251
|
+
} else if (yearNumber < 50) {
|
|
252
|
+
yearNumber += 2000;
|
|
253
|
+
}
|
|
242
254
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
255
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
256
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
260
|
+
);
|
|
261
|
+
}
|
|
246
262
|
|
|
247
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @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).
|
|
265
|
+
*
|
|
266
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
267
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
268
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
269
|
+
* @param {string} dateStr - Date string to parse.
|
|
270
|
+
* @param {string} format - Date format to parse.
|
|
271
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
272
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
273
|
+
*/
|
|
274
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
275
|
+
if (!dateStr || !format) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
248
279
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
280
|
+
if (!result) {
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
252
283
|
|
|
253
|
-
|
|
284
|
+
const lowerFormat = format.toLowerCase();
|
|
285
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
286
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
287
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
254
288
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
289
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
259
292
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
293
|
+
throw new Error(
|
|
294
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
295
|
+
);
|
|
296
|
+
}
|
|
263
297
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Convert a date object to string format.
|
|
300
|
+
* @param {Object} date - Date to convert to string.
|
|
301
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
302
|
+
* @returns {String} Returns the date as a string.
|
|
303
|
+
*/
|
|
304
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
305
|
+
return date.toLocaleDateString(locale, {
|
|
306
|
+
year: "numeric",
|
|
307
|
+
month: "2-digit",
|
|
308
|
+
day: "2-digit",
|
|
309
|
+
});
|
|
310
|
+
}
|
|
267
311
|
|
|
268
|
-
|
|
269
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Converts a date string to a North American date format.
|
|
314
|
+
* @param {String} dateStr - Date to validate.
|
|
315
|
+
* @param {String} format - Date format to validate against.
|
|
316
|
+
* @returns {String}
|
|
317
|
+
*/
|
|
318
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
319
|
+
if (format === "mm/dd/yyyy") {
|
|
320
|
+
return dateStr;
|
|
270
321
|
}
|
|
322
|
+
|
|
323
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
324
|
+
|
|
325
|
+
if (!parsedDate) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const { month, day, year } = parsedDate;
|
|
332
|
+
|
|
333
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
338
|
+
*
|
|
339
|
+
* @param {string} dateStr - Date string to validate.
|
|
340
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
341
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
342
|
+
*/
|
|
343
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
344
|
+
try {
|
|
345
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (parseDate$1(dateStr, format)) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
} catch (error) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* 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.
|
|
360
|
+
*
|
|
361
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
362
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
363
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
364
|
+
*/
|
|
365
|
+
function toISOFormatString$1(date) {
|
|
366
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
367
|
+
throw new Error(
|
|
368
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 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.
|
|
376
|
+
*
|
|
377
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
378
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
379
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
380
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
381
|
+
*/
|
|
382
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
383
|
+
if (typeof dateStr !== "string") {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
388
|
+
return new Date(`${year}/${month}/${day}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const dateFormatter$1 = {
|
|
392
|
+
parseDate: parseDate$1,
|
|
393
|
+
getDateParts: getDateParts$1,
|
|
394
|
+
getDateAsString: getDateAsString$1,
|
|
395
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
396
|
+
isValidDate: isValidDate$1,
|
|
397
|
+
toISOFormatString: toISOFormatString$1,
|
|
398
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
271
399
|
};
|
|
272
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
273
400
|
|
|
274
401
|
// filepath: dateConstraints.mjs
|
|
275
402
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -341,12 +468,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
341
468
|
/* eslint-disable no-magic-numbers */
|
|
342
469
|
|
|
343
470
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
344
|
-
|
|
345
471
|
/**
|
|
346
472
|
* Returns the current century.
|
|
347
473
|
* @returns {String} The current century.
|
|
348
474
|
*/
|
|
349
|
-
getCentury
|
|
475
|
+
getCentury() {
|
|
350
476
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
351
477
|
}
|
|
352
478
|
|
|
@@ -355,14 +481,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
355
481
|
* @param {String} year - The year to convert to four digits.
|
|
356
482
|
* @returns {String} The four digit year.
|
|
357
483
|
*/
|
|
358
|
-
getFourDigitYear
|
|
359
|
-
|
|
484
|
+
getFourDigitYear(year) {
|
|
360
485
|
const strYear = String(year).trim();
|
|
361
486
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
362
487
|
}
|
|
363
488
|
|
|
364
489
|
constructor() {
|
|
365
|
-
|
|
366
490
|
super();
|
|
367
491
|
|
|
368
492
|
/**
|
|
@@ -371,7 +495,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
371
495
|
* @param {Object} date2 - Second date to compare.
|
|
372
496
|
* @returns {Boolean} Returns true if the dates match.
|
|
373
497
|
*/
|
|
374
|
-
this.datesMatch = (date1, date2) =>
|
|
498
|
+
this.datesMatch = (date1, date2) =>
|
|
499
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
375
500
|
|
|
376
501
|
/**
|
|
377
502
|
* Returns true if value passed in is a valid date.
|
|
@@ -380,53 +505,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
380
505
|
* @returns {Boolean}
|
|
381
506
|
*/
|
|
382
507
|
this.validDateStr = (date, format) => {
|
|
383
|
-
|
|
384
508
|
// The length we expect the date string to be
|
|
385
|
-
const dateStrLength = format
|
|
509
|
+
const dateStrLength = format?.length || 0;
|
|
386
510
|
|
|
387
511
|
// Guard Clause: Date and format are defined
|
|
388
512
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
389
|
-
throw new Error(
|
|
513
|
+
throw new Error(
|
|
514
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
515
|
+
);
|
|
390
516
|
}
|
|
391
517
|
|
|
392
518
|
// Guard Clause: Date should be of type string
|
|
393
519
|
if (typeof date !== "string") {
|
|
394
|
-
throw new Error(
|
|
520
|
+
throw new Error(
|
|
521
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
522
|
+
);
|
|
395
523
|
}
|
|
396
524
|
|
|
397
525
|
// Guard Clause: Format should be of type string
|
|
398
526
|
if (typeof format !== "string") {
|
|
399
|
-
throw new Error(
|
|
527
|
+
throw new Error(
|
|
528
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
529
|
+
);
|
|
400
530
|
}
|
|
401
531
|
|
|
402
532
|
// Guard Clause: Length is what we expect it to be
|
|
403
533
|
if (date.length !== dateStrLength) {
|
|
404
534
|
return false;
|
|
405
535
|
}
|
|
406
|
-
// Get a formatted date string and parse it
|
|
407
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
408
|
-
|
|
409
|
-
// Guard Clause: Date parse succeeded
|
|
410
|
-
if (!dateParts) {
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Create the expected date string based on the date parts
|
|
415
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
416
|
-
|
|
417
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
418
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
419
536
|
|
|
420
|
-
// Get
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (expectedDateStr !== actualDateStr) {
|
|
537
|
+
// Get a formatted date string and parse and validate it
|
|
538
|
+
try {
|
|
539
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
540
|
+
} catch (error) {
|
|
425
541
|
return false;
|
|
426
542
|
}
|
|
427
|
-
|
|
428
|
-
// If we passed all other checks, we can assume the date is valid
|
|
429
|
-
return true;
|
|
430
543
|
};
|
|
431
544
|
|
|
432
545
|
/**
|
|
@@ -436,10 +549,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
436
549
|
* @returns {boolean}
|
|
437
550
|
*/
|
|
438
551
|
this.dateAndFormatMatch = (value, format) => {
|
|
439
|
-
|
|
440
552
|
// Ensure we have both values we need to do the comparison
|
|
441
553
|
if (!value || !format) {
|
|
442
|
-
throw new Error(
|
|
554
|
+
throw new Error(
|
|
555
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
556
|
+
);
|
|
443
557
|
}
|
|
444
558
|
|
|
445
559
|
// If the lengths are different, they cannot match
|
|
@@ -448,11 +562,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
448
562
|
}
|
|
449
563
|
|
|
450
564
|
// Get the parts of the date
|
|
451
|
-
const dateParts = dateFormatter$1.
|
|
565
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
452
566
|
|
|
453
567
|
// Validator for day
|
|
454
568
|
const dayValueIsValid = (day) => {
|
|
455
|
-
|
|
456
569
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
457
570
|
if (!dateParts.day) {
|
|
458
571
|
return true;
|
|
@@ -468,7 +581,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
468
581
|
|
|
469
582
|
// Guard clause: ensure day is a valid integer
|
|
470
583
|
if (Number.isNaN(numDay)) {
|
|
471
|
-
throw new Error(
|
|
584
|
+
throw new Error(
|
|
585
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
586
|
+
);
|
|
472
587
|
}
|
|
473
588
|
|
|
474
589
|
// Guard clause: ensure day is within the valid range
|
|
@@ -482,6 +597,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
482
597
|
|
|
483
598
|
// Validator for month
|
|
484
599
|
const monthValueIsValid = (month) => {
|
|
600
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
601
|
+
if (!dateParts.month) {
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
485
604
|
|
|
486
605
|
// Guard clause: ensure month exists.
|
|
487
606
|
if (!month) {
|
|
@@ -493,7 +612,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
493
612
|
|
|
494
613
|
// Guard clause: ensure month is a valid integer
|
|
495
614
|
if (Number.isNaN(numMonth)) {
|
|
496
|
-
throw new Error(
|
|
615
|
+
throw new Error(
|
|
616
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
617
|
+
);
|
|
497
618
|
}
|
|
498
619
|
|
|
499
620
|
// Guard clause: ensure month is within the valid range
|
|
@@ -507,6 +628,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
507
628
|
|
|
508
629
|
// Validator for year
|
|
509
630
|
const yearIsValid = (_year) => {
|
|
631
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
632
|
+
if (!dateParts.year) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
510
635
|
|
|
511
636
|
// Guard clause: ensure year exists.
|
|
512
637
|
if (!_year) {
|
|
@@ -521,7 +646,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
521
646
|
|
|
522
647
|
// Guard clause: ensure year is a valid integer
|
|
523
648
|
if (Number.isNaN(numYear)) {
|
|
524
|
-
throw new Error(
|
|
649
|
+
throw new Error(
|
|
650
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
651
|
+
);
|
|
525
652
|
}
|
|
526
653
|
|
|
527
654
|
// Guard clause: ensure year is within the valid range
|
|
@@ -537,7 +664,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
537
664
|
const checks = [
|
|
538
665
|
monthValueIsValid(dateParts.month),
|
|
539
666
|
dayValueIsValid(dateParts.day),
|
|
540
|
-
yearIsValid(dateParts.year)
|
|
667
|
+
yearIsValid(dateParts.year),
|
|
541
668
|
];
|
|
542
669
|
|
|
543
670
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -571,10 +698,7 @@ const {
|
|
|
571
698
|
} = dateUtilities$1;
|
|
572
699
|
|
|
573
700
|
const {
|
|
574
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
575
|
-
parseDate: parseDate$1,
|
|
576
|
-
getDateAsString: getDateAsString$1
|
|
577
|
-
} = dateFormatter$1;
|
|
701
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
578
702
|
|
|
579
703
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
580
704
|
// See LICENSE in the project root for license information.
|
|
@@ -811,13 +935,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
811
935
|
}
|
|
812
936
|
|
|
813
937
|
// Perform the rest of the validation
|
|
814
|
-
const formattedValue = toNorthAmericanFormat$
|
|
938
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
815
939
|
const valueDate = new Date(formattedValue);
|
|
816
940
|
|
|
817
941
|
// // Validate max date
|
|
818
942
|
if (elem.max?.length === elem.lengthForType) {
|
|
819
943
|
|
|
820
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
944
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
821
945
|
|
|
822
946
|
if (valueDate > maxDate) {
|
|
823
947
|
elem.validity = 'rangeOverflow';
|
|
@@ -828,7 +952,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
828
952
|
|
|
829
953
|
// Validate min date
|
|
830
954
|
if (elem.min?.length === elem.lengthForType) {
|
|
831
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
955
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
832
956
|
|
|
833
957
|
if (valueDate < minDate) {
|
|
834
958
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5278,7 +5402,7 @@ let AuroHelpText$2 = class AuroHelpText extends i$4 {
|
|
|
5278
5402
|
}
|
|
5279
5403
|
};
|
|
5280
5404
|
|
|
5281
|
-
var formkitVersion$2 = '
|
|
5405
|
+
var formkitVersion$2 = '202606022350';
|
|
5282
5406
|
|
|
5283
5407
|
let AuroElement$2 = class AuroElement extends i$4 {
|
|
5284
5408
|
static get properties() {
|
|
@@ -6271,16 +6395,20 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6271
6395
|
|
|
6272
6396
|
// Walk up the ancestor chain, inerting siblings at each level
|
|
6273
6397
|
// to ensure the entire page outside the host subtree is inert.
|
|
6398
|
+
// Uses a reference counter (data-auro-inert-count) so multiple
|
|
6399
|
+
// simultaneous modal dropdowns share inert state safely.
|
|
6274
6400
|
let current = host;
|
|
6275
6401
|
while (current.parentElement) {
|
|
6276
6402
|
const parent = current.parentElement;
|
|
6277
6403
|
for (const sibling of parent.children) {
|
|
6278
6404
|
if (sibling !== current) {
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
}
|
|
6405
|
+
const count = parseInt(sibling.dataset.auroInertCount || '0', 10);
|
|
6406
|
+
if (count === 0) {
|
|
6407
|
+
sibling.dataset.auroInertWas = sibling.inert ? 'true' : 'false';
|
|
6408
|
+
}
|
|
6409
|
+
sibling.dataset.auroInertCount = String(count + 1);
|
|
6283
6410
|
sibling.inert = true;
|
|
6411
|
+
this._inertSiblings.push(sibling);
|
|
6284
6412
|
}
|
|
6285
6413
|
}
|
|
6286
6414
|
current = parent;
|
|
@@ -6289,14 +6417,23 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6289
6417
|
|
|
6290
6418
|
/**
|
|
6291
6419
|
* Restores `inert` state on siblings that were tracked by `_setPageInert`.
|
|
6292
|
-
*
|
|
6293
|
-
*
|
|
6420
|
+
* Uses reference counting so inert is only cleared when the last modal
|
|
6421
|
+
* dropdown releases a given element. Preserves the original inert state
|
|
6422
|
+
* so externally-inerted elements are not inadvertently re-enabled.
|
|
6294
6423
|
* @private
|
|
6295
6424
|
*/
|
|
6296
6425
|
_clearPageInert() {
|
|
6297
6426
|
if (this._inertSiblings) {
|
|
6298
|
-
for (const
|
|
6299
|
-
|
|
6427
|
+
for (const sibling of this._inertSiblings) {
|
|
6428
|
+
const count = parseInt(sibling.dataset.auroInertCount || '1', 10) - 1;
|
|
6429
|
+
if (count <= 0) {
|
|
6430
|
+
const wasInert = sibling.dataset.auroInertWas === 'true';
|
|
6431
|
+
delete sibling.dataset.auroInertCount;
|
|
6432
|
+
delete sibling.dataset.auroInertWas;
|
|
6433
|
+
sibling.inert = wasInert;
|
|
6434
|
+
} else {
|
|
6435
|
+
sibling.dataset.auroInertCount = String(count);
|
|
6436
|
+
}
|
|
6300
6437
|
}
|
|
6301
6438
|
this._inertSiblings = undefined;
|
|
6302
6439
|
}
|
|
@@ -10621,109 +10758,236 @@ class AuroInputUtilities {
|
|
|
10621
10758
|
}
|
|
10622
10759
|
}
|
|
10623
10760
|
|
|
10624
|
-
|
|
10761
|
+
/**
|
|
10762
|
+
* @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.
|
|
10763
|
+
* @param {string} dateStr - Date string to parse.
|
|
10764
|
+
* @param {string} format - Date format to parse.
|
|
10765
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10766
|
+
*/
|
|
10767
|
+
function getDateParts(dateStr, format) {
|
|
10768
|
+
if (!dateStr) {
|
|
10769
|
+
return undefined;
|
|
10770
|
+
}
|
|
10625
10771
|
|
|
10626
|
-
|
|
10772
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10773
|
+
let valueParts;
|
|
10774
|
+
let formatParts;
|
|
10627
10775
|
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10776
|
+
if (formatSeparatorMatch) {
|
|
10777
|
+
const separator = formatSeparatorMatch[0];
|
|
10778
|
+
valueParts = dateStr.split(separator);
|
|
10779
|
+
formatParts = format.split(separator);
|
|
10780
|
+
} else {
|
|
10781
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10782
|
+
throw new Error(
|
|
10783
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10784
|
+
);
|
|
10785
|
+
}
|
|
10635
10786
|
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10787
|
+
if (dateStr.length !== format.length) {
|
|
10788
|
+
throw new Error(
|
|
10789
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
10640
10792
|
|
|
10641
|
-
|
|
10642
|
-
|
|
10793
|
+
valueParts = [dateStr];
|
|
10794
|
+
formatParts = [format];
|
|
10795
|
+
}
|
|
10643
10796
|
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10797
|
+
if (valueParts.length !== formatParts.length) {
|
|
10798
|
+
throw new Error(
|
|
10799
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10800
|
+
);
|
|
10801
|
+
}
|
|
10647
10802
|
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10651
|
-
}
|
|
10803
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10804
|
+
const value = valueParts[index];
|
|
10652
10805
|
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10806
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10807
|
+
acc.month = value;
|
|
10808
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10809
|
+
acc.day = value;
|
|
10810
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10811
|
+
acc.year = value;
|
|
10812
|
+
}
|
|
10656
10813
|
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
} else if ((/d/iu).test(part)) {
|
|
10660
|
-
acc.day = value;
|
|
10661
|
-
} else if ((/y/iu).test(part)) {
|
|
10662
|
-
acc.year = value;
|
|
10663
|
-
}
|
|
10814
|
+
return acc;
|
|
10815
|
+
}, {});
|
|
10664
10816
|
|
|
10665
|
-
|
|
10666
|
-
|
|
10817
|
+
if (!result.month && !result.day && !result.year) {
|
|
10818
|
+
throw new Error(
|
|
10819
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10820
|
+
);
|
|
10821
|
+
}
|
|
10667
10822
|
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
return result;
|
|
10671
|
-
}
|
|
10823
|
+
return result;
|
|
10824
|
+
}
|
|
10672
10825
|
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10826
|
+
function isCalendarDate(year, month, day) {
|
|
10827
|
+
let yearNumber = Number(year);
|
|
10828
|
+
const monthNumber = Number(month);
|
|
10829
|
+
const dayNumber = Number(day);
|
|
10676
10830
|
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
year: "numeric",
|
|
10685
|
-
month: "2-digit",
|
|
10686
|
-
day: "2-digit",
|
|
10687
|
-
});
|
|
10831
|
+
if (
|
|
10832
|
+
!Number.isInteger(yearNumber) ||
|
|
10833
|
+
!Number.isInteger(monthNumber) ||
|
|
10834
|
+
!Number.isInteger(dayNumber)
|
|
10835
|
+
) {
|
|
10836
|
+
return false;
|
|
10837
|
+
}
|
|
10688
10838
|
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10839
|
+
// 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.
|
|
10840
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10841
|
+
yearNumber += 1900;
|
|
10842
|
+
} else if (yearNumber < 50) {
|
|
10843
|
+
yearNumber += 2000;
|
|
10844
|
+
}
|
|
10696
10845
|
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
}
|
|
10846
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10847
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10700
10848
|
|
|
10701
|
-
|
|
10849
|
+
return (
|
|
10850
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10851
|
+
);
|
|
10852
|
+
}
|
|
10702
10853
|
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10854
|
+
/**
|
|
10855
|
+
* @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).
|
|
10856
|
+
*
|
|
10857
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10858
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10859
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10860
|
+
* @param {string} dateStr - Date string to parse.
|
|
10861
|
+
* @param {string} format - Date format to parse.
|
|
10862
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10863
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10864
|
+
*/
|
|
10865
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10866
|
+
if (!dateStr || !format) {
|
|
10867
|
+
return undefined;
|
|
10868
|
+
}
|
|
10869
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10706
10870
|
|
|
10707
|
-
|
|
10871
|
+
if (!result) {
|
|
10872
|
+
return undefined;
|
|
10873
|
+
}
|
|
10708
10874
|
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10875
|
+
const lowerFormat = format.toLowerCase();
|
|
10876
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10877
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10878
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10713
10879
|
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10880
|
+
if (isCalendarDate(year, month, day)) {
|
|
10881
|
+
return result;
|
|
10882
|
+
}
|
|
10717
10883
|
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10884
|
+
throw new Error(
|
|
10885
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10886
|
+
);
|
|
10887
|
+
}
|
|
10721
10888
|
|
|
10722
|
-
|
|
10723
|
-
|
|
10889
|
+
/**
|
|
10890
|
+
* Convert a date object to string format.
|
|
10891
|
+
* @param {Object} date - Date to convert to string.
|
|
10892
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10893
|
+
* @returns {String} Returns the date as a string.
|
|
10894
|
+
*/
|
|
10895
|
+
function getDateAsString(date, locale = undefined) {
|
|
10896
|
+
return date.toLocaleDateString(locale, {
|
|
10897
|
+
year: "numeric",
|
|
10898
|
+
month: "2-digit",
|
|
10899
|
+
day: "2-digit",
|
|
10900
|
+
});
|
|
10901
|
+
}
|
|
10902
|
+
|
|
10903
|
+
/**
|
|
10904
|
+
* Converts a date string to a North American date format.
|
|
10905
|
+
* @param {String} dateStr - Date to validate.
|
|
10906
|
+
* @param {String} format - Date format to validate against.
|
|
10907
|
+
* @returns {String}
|
|
10908
|
+
*/
|
|
10909
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10910
|
+
if (format === "mm/dd/yyyy") {
|
|
10911
|
+
return dateStr;
|
|
10724
10912
|
}
|
|
10913
|
+
|
|
10914
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10915
|
+
|
|
10916
|
+
if (!parsedDate) {
|
|
10917
|
+
throw new Error(
|
|
10918
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10919
|
+
);
|
|
10920
|
+
}
|
|
10921
|
+
|
|
10922
|
+
const { month, day, year } = parsedDate;
|
|
10923
|
+
|
|
10924
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
/**
|
|
10928
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10929
|
+
*
|
|
10930
|
+
* @param {string} dateStr - Date string to validate.
|
|
10931
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10932
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10933
|
+
*/
|
|
10934
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10935
|
+
try {
|
|
10936
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10937
|
+
return false;
|
|
10938
|
+
}
|
|
10939
|
+
|
|
10940
|
+
if (parseDate(dateStr, format)) {
|
|
10941
|
+
return true;
|
|
10942
|
+
}
|
|
10943
|
+
} catch (error) {
|
|
10944
|
+
return false;
|
|
10945
|
+
}
|
|
10946
|
+
return false;
|
|
10947
|
+
}
|
|
10948
|
+
|
|
10949
|
+
/**
|
|
10950
|
+
* 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.
|
|
10951
|
+
*
|
|
10952
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10953
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10954
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10955
|
+
*/
|
|
10956
|
+
function toISOFormatString(date) {
|
|
10957
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10958
|
+
throw new Error(
|
|
10959
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10960
|
+
);
|
|
10961
|
+
}
|
|
10962
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
/**
|
|
10966
|
+
* 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.
|
|
10967
|
+
*
|
|
10968
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10969
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10970
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10971
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10972
|
+
*/
|
|
10973
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10974
|
+
if (typeof dateStr !== "string") {
|
|
10975
|
+
return null;
|
|
10976
|
+
}
|
|
10977
|
+
|
|
10978
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10979
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10725
10980
|
}
|
|
10726
|
-
|
|
10981
|
+
|
|
10982
|
+
const dateFormatter = {
|
|
10983
|
+
parseDate,
|
|
10984
|
+
getDateParts,
|
|
10985
|
+
getDateAsString,
|
|
10986
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10987
|
+
isValidDate,
|
|
10988
|
+
toISOFormatString,
|
|
10989
|
+
stringToDateInstance,
|
|
10990
|
+
};
|
|
10727
10991
|
|
|
10728
10992
|
// filepath: dateConstraints.mjs
|
|
10729
10993
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10795,12 +11059,11 @@ class AuroDateUtilitiesBase {
|
|
|
10795
11059
|
/* eslint-disable no-magic-numbers */
|
|
10796
11060
|
|
|
10797
11061
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10798
|
-
|
|
10799
11062
|
/**
|
|
10800
11063
|
* Returns the current century.
|
|
10801
11064
|
* @returns {String} The current century.
|
|
10802
11065
|
*/
|
|
10803
|
-
getCentury
|
|
11066
|
+
getCentury() {
|
|
10804
11067
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10805
11068
|
}
|
|
10806
11069
|
|
|
@@ -10809,14 +11072,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10809
11072
|
* @param {String} year - The year to convert to four digits.
|
|
10810
11073
|
* @returns {String} The four digit year.
|
|
10811
11074
|
*/
|
|
10812
|
-
getFourDigitYear
|
|
10813
|
-
|
|
11075
|
+
getFourDigitYear(year) {
|
|
10814
11076
|
const strYear = String(year).trim();
|
|
10815
11077
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10816
11078
|
}
|
|
10817
11079
|
|
|
10818
11080
|
constructor() {
|
|
10819
|
-
|
|
10820
11081
|
super();
|
|
10821
11082
|
|
|
10822
11083
|
/**
|
|
@@ -10825,7 +11086,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10825
11086
|
* @param {Object} date2 - Second date to compare.
|
|
10826
11087
|
* @returns {Boolean} Returns true if the dates match.
|
|
10827
11088
|
*/
|
|
10828
|
-
this.datesMatch = (date1, date2) =>
|
|
11089
|
+
this.datesMatch = (date1, date2) =>
|
|
11090
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10829
11091
|
|
|
10830
11092
|
/**
|
|
10831
11093
|
* Returns true if value passed in is a valid date.
|
|
@@ -10834,53 +11096,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10834
11096
|
* @returns {Boolean}
|
|
10835
11097
|
*/
|
|
10836
11098
|
this.validDateStr = (date, format) => {
|
|
10837
|
-
|
|
10838
11099
|
// The length we expect the date string to be
|
|
10839
|
-
const dateStrLength = format
|
|
11100
|
+
const dateStrLength = format?.length || 0;
|
|
10840
11101
|
|
|
10841
11102
|
// Guard Clause: Date and format are defined
|
|
10842
11103
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10843
|
-
throw new Error(
|
|
11104
|
+
throw new Error(
|
|
11105
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11106
|
+
);
|
|
10844
11107
|
}
|
|
10845
11108
|
|
|
10846
11109
|
// Guard Clause: Date should be of type string
|
|
10847
11110
|
if (typeof date !== "string") {
|
|
10848
|
-
throw new Error(
|
|
11111
|
+
throw new Error(
|
|
11112
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11113
|
+
);
|
|
10849
11114
|
}
|
|
10850
11115
|
|
|
10851
11116
|
// Guard Clause: Format should be of type string
|
|
10852
11117
|
if (typeof format !== "string") {
|
|
10853
|
-
throw new Error(
|
|
11118
|
+
throw new Error(
|
|
11119
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11120
|
+
);
|
|
10854
11121
|
}
|
|
10855
11122
|
|
|
10856
11123
|
// Guard Clause: Length is what we expect it to be
|
|
10857
11124
|
if (date.length !== dateStrLength) {
|
|
10858
11125
|
return false;
|
|
10859
11126
|
}
|
|
10860
|
-
// Get a formatted date string and parse it
|
|
10861
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10862
|
-
|
|
10863
|
-
// Guard Clause: Date parse succeeded
|
|
10864
|
-
if (!dateParts) {
|
|
10865
|
-
return false;
|
|
10866
|
-
}
|
|
10867
|
-
|
|
10868
|
-
// Create the expected date string based on the date parts
|
|
10869
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
10870
|
-
|
|
10871
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
10872
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10873
|
-
|
|
10874
|
-
// Get the date string of the date object we created from the string date
|
|
10875
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10876
11127
|
|
|
10877
|
-
//
|
|
10878
|
-
|
|
11128
|
+
// Get a formatted date string and parse and validate it
|
|
11129
|
+
try {
|
|
11130
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11131
|
+
} catch (error) {
|
|
10879
11132
|
return false;
|
|
10880
11133
|
}
|
|
10881
|
-
|
|
10882
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10883
|
-
return true;
|
|
10884
11134
|
};
|
|
10885
11135
|
|
|
10886
11136
|
/**
|
|
@@ -10890,10 +11140,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10890
11140
|
* @returns {boolean}
|
|
10891
11141
|
*/
|
|
10892
11142
|
this.dateAndFormatMatch = (value, format) => {
|
|
10893
|
-
|
|
10894
11143
|
// Ensure we have both values we need to do the comparison
|
|
10895
11144
|
if (!value || !format) {
|
|
10896
|
-
throw new Error(
|
|
11145
|
+
throw new Error(
|
|
11146
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11147
|
+
);
|
|
10897
11148
|
}
|
|
10898
11149
|
|
|
10899
11150
|
// If the lengths are different, they cannot match
|
|
@@ -10902,11 +11153,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10902
11153
|
}
|
|
10903
11154
|
|
|
10904
11155
|
// Get the parts of the date
|
|
10905
|
-
const dateParts = dateFormatter.
|
|
11156
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10906
11157
|
|
|
10907
11158
|
// Validator for day
|
|
10908
11159
|
const dayValueIsValid = (day) => {
|
|
10909
|
-
|
|
10910
11160
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10911
11161
|
if (!dateParts.day) {
|
|
10912
11162
|
return true;
|
|
@@ -10922,7 +11172,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10922
11172
|
|
|
10923
11173
|
// Guard clause: ensure day is a valid integer
|
|
10924
11174
|
if (Number.isNaN(numDay)) {
|
|
10925
|
-
throw new Error(
|
|
11175
|
+
throw new Error(
|
|
11176
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11177
|
+
);
|
|
10926
11178
|
}
|
|
10927
11179
|
|
|
10928
11180
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10936,6 +11188,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10936
11188
|
|
|
10937
11189
|
// Validator for month
|
|
10938
11190
|
const monthValueIsValid = (month) => {
|
|
11191
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11192
|
+
if (!dateParts.month) {
|
|
11193
|
+
return true;
|
|
11194
|
+
}
|
|
10939
11195
|
|
|
10940
11196
|
// Guard clause: ensure month exists.
|
|
10941
11197
|
if (!month) {
|
|
@@ -10947,7 +11203,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10947
11203
|
|
|
10948
11204
|
// Guard clause: ensure month is a valid integer
|
|
10949
11205
|
if (Number.isNaN(numMonth)) {
|
|
10950
|
-
throw new Error(
|
|
11206
|
+
throw new Error(
|
|
11207
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11208
|
+
);
|
|
10951
11209
|
}
|
|
10952
11210
|
|
|
10953
11211
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10961,6 +11219,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10961
11219
|
|
|
10962
11220
|
// Validator for year
|
|
10963
11221
|
const yearIsValid = (_year) => {
|
|
11222
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11223
|
+
if (!dateParts.year) {
|
|
11224
|
+
return true;
|
|
11225
|
+
}
|
|
10964
11226
|
|
|
10965
11227
|
// Guard clause: ensure year exists.
|
|
10966
11228
|
if (!_year) {
|
|
@@ -10975,7 +11237,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10975
11237
|
|
|
10976
11238
|
// Guard clause: ensure year is a valid integer
|
|
10977
11239
|
if (Number.isNaN(numYear)) {
|
|
10978
|
-
throw new Error(
|
|
11240
|
+
throw new Error(
|
|
11241
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11242
|
+
);
|
|
10979
11243
|
}
|
|
10980
11244
|
|
|
10981
11245
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10991,7 +11255,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10991
11255
|
const checks = [
|
|
10992
11256
|
monthValueIsValid(dateParts.month),
|
|
10993
11257
|
dayValueIsValid(dateParts.day),
|
|
10994
|
-
yearIsValid(dateParts.year)
|
|
11258
|
+
yearIsValid(dateParts.year),
|
|
10995
11259
|
];
|
|
10996
11260
|
|
|
10997
11261
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -11025,10 +11289,7 @@ const {
|
|
|
11025
11289
|
} = dateUtilities;
|
|
11026
11290
|
|
|
11027
11291
|
const {
|
|
11028
|
-
toNorthAmericanFormat
|
|
11029
|
-
parseDate,
|
|
11030
|
-
getDateAsString
|
|
11031
|
-
} = dateFormatter;
|
|
11292
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
11032
11293
|
|
|
11033
11294
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
11034
11295
|
// See LICENSE in the project root for license information.
|
|
@@ -13243,7 +13504,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$4 {
|
|
|
13243
13504
|
}
|
|
13244
13505
|
};
|
|
13245
13506
|
|
|
13246
|
-
var formkitVersion$1 = '
|
|
13507
|
+
var formkitVersion$1 = '202606022350';
|
|
13247
13508
|
|
|
13248
13509
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13249
13510
|
// See LICENSE in the project root for license information.
|
|
@@ -14316,7 +14577,7 @@ class AuroBibtemplate extends i$4 {
|
|
|
14316
14577
|
}
|
|
14317
14578
|
}
|
|
14318
14579
|
|
|
14319
|
-
var formkitVersion = '
|
|
14580
|
+
var formkitVersion = '202606022350';
|
|
14320
14581
|
|
|
14321
14582
|
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}`;
|
|
14322
14583
|
|