@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.1 → 0.0.0-pr1489.10
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 -259
- package/components/combobox/demo/getting-started.min.js +523 -259
- package/components/combobox/demo/index.min.js +523 -259
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +523 -259
- package/components/combobox/dist/registered.js +523 -259
- package/components/counter/demo/customize.min.js +271 -131
- package/components/counter/demo/index.min.js +271 -131
- package/components/counter/demo/styles.min.css +1 -1
- package/components/counter/dist/index.js +488 -137
- package/components/counter/dist/registered.js +249 -125
- package/components/datepicker/demo/accessibility.md +12 -9
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.md +4 -0
- package/components/datepicker/demo/customize.min.js +1638 -654
- package/components/datepicker/demo/index.md +35 -5
- package/components/datepicker/demo/index.min.js +1654 -659
- 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 +1642 -658
- package/components/datepicker/dist/registered.js +1642 -658
- 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 -6
- package/components/dropdown/demo/getting-started.min.js +22 -6
- package/components/dropdown/demo/index.min.js +22 -6
- 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 -6
- package/components/dropdown/dist/registered.js +22 -6
- package/components/form/demo/customize.min.js +3731 -1831
- package/components/form/demo/getting-started.min.js +3731 -1831
- package/components/form/demo/index.min.js +3731 -1831
- package/components/form/demo/registerDemoDeps.min.js +3727 -1827
- 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 -131
- package/components/select/demo/getting-started.min.js +271 -131
- package/components/select/demo/index.min.js +271 -131
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +271 -131
- package/components/select/dist/registered.js +271 -131
- 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 = '202606030033';
|
|
5282
5406
|
|
|
5283
5407
|
let AuroElement$2 = class AuroElement extends i$4 {
|
|
5284
5408
|
static get properties() {
|
|
@@ -6271,13 +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
|
-
|
|
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);
|
|
6280
6410
|
sibling.inert = true;
|
|
6411
|
+
this._inertSiblings.push(sibling);
|
|
6281
6412
|
}
|
|
6282
6413
|
}
|
|
6283
6414
|
current = parent;
|
|
@@ -6286,14 +6417,23 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6286
6417
|
|
|
6287
6418
|
/**
|
|
6288
6419
|
* Restores `inert` state on siblings that were tracked by `_setPageInert`.
|
|
6289
|
-
*
|
|
6290
|
-
*
|
|
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.
|
|
6291
6423
|
* @private
|
|
6292
6424
|
*/
|
|
6293
6425
|
_clearPageInert() {
|
|
6294
6426
|
if (this._inertSiblings) {
|
|
6295
|
-
for (const
|
|
6296
|
-
|
|
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
|
+
}
|
|
6297
6437
|
}
|
|
6298
6438
|
this._inertSiblings = undefined;
|
|
6299
6439
|
}
|
|
@@ -10618,109 +10758,236 @@ class AuroInputUtilities {
|
|
|
10618
10758
|
}
|
|
10619
10759
|
}
|
|
10620
10760
|
|
|
10621
|
-
|
|
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
|
+
}
|
|
10622
10771
|
|
|
10623
|
-
|
|
10772
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10773
|
+
let valueParts;
|
|
10774
|
+
let formatParts;
|
|
10624
10775
|
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
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
|
+
}
|
|
10632
10786
|
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10787
|
+
if (dateStr.length !== format.length) {
|
|
10788
|
+
throw new Error(
|
|
10789
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
10637
10792
|
|
|
10638
|
-
|
|
10639
|
-
|
|
10793
|
+
valueParts = [dateStr];
|
|
10794
|
+
formatParts = [format];
|
|
10795
|
+
}
|
|
10640
10796
|
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
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
|
+
}
|
|
10644
10802
|
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10648
|
-
}
|
|
10803
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10804
|
+
const value = valueParts[index];
|
|
10649
10805
|
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
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
|
+
}
|
|
10653
10813
|
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
} else if ((/d/iu).test(part)) {
|
|
10657
|
-
acc.day = value;
|
|
10658
|
-
} else if ((/y/iu).test(part)) {
|
|
10659
|
-
acc.year = value;
|
|
10660
|
-
}
|
|
10814
|
+
return acc;
|
|
10815
|
+
}, {});
|
|
10661
10816
|
|
|
10662
|
-
|
|
10663
|
-
|
|
10817
|
+
if (!result.month && !result.day && !result.year) {
|
|
10818
|
+
throw new Error(
|
|
10819
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10820
|
+
);
|
|
10821
|
+
}
|
|
10664
10822
|
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
return result;
|
|
10668
|
-
}
|
|
10823
|
+
return result;
|
|
10824
|
+
}
|
|
10669
10825
|
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10826
|
+
function isCalendarDate(year, month, day) {
|
|
10827
|
+
let yearNumber = Number(year);
|
|
10828
|
+
const monthNumber = Number(month);
|
|
10829
|
+
const dayNumber = Number(day);
|
|
10673
10830
|
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
year: "numeric",
|
|
10682
|
-
month: "2-digit",
|
|
10683
|
-
day: "2-digit",
|
|
10684
|
-
});
|
|
10831
|
+
if (
|
|
10832
|
+
!Number.isInteger(yearNumber) ||
|
|
10833
|
+
!Number.isInteger(monthNumber) ||
|
|
10834
|
+
!Number.isInteger(dayNumber)
|
|
10835
|
+
) {
|
|
10836
|
+
return false;
|
|
10837
|
+
}
|
|
10685
10838
|
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
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
|
+
}
|
|
10693
10845
|
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
}
|
|
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, "/"));
|
|
10697
10848
|
|
|
10698
|
-
|
|
10849
|
+
return (
|
|
10850
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10851
|
+
);
|
|
10852
|
+
}
|
|
10699
10853
|
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
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);
|
|
10703
10870
|
|
|
10704
|
-
|
|
10871
|
+
if (!result) {
|
|
10872
|
+
return undefined;
|
|
10873
|
+
}
|
|
10705
10874
|
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
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";
|
|
10710
10879
|
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10880
|
+
if (isCalendarDate(year, month, day)) {
|
|
10881
|
+
return result;
|
|
10882
|
+
}
|
|
10714
10883
|
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10884
|
+
throw new Error(
|
|
10885
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10886
|
+
);
|
|
10887
|
+
}
|
|
10718
10888
|
|
|
10719
|
-
|
|
10720
|
-
|
|
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;
|
|
10721
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}`);
|
|
10722
10980
|
}
|
|
10723
|
-
|
|
10981
|
+
|
|
10982
|
+
const dateFormatter = {
|
|
10983
|
+
parseDate,
|
|
10984
|
+
getDateParts,
|
|
10985
|
+
getDateAsString,
|
|
10986
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10987
|
+
isValidDate,
|
|
10988
|
+
toISOFormatString,
|
|
10989
|
+
stringToDateInstance,
|
|
10990
|
+
};
|
|
10724
10991
|
|
|
10725
10992
|
// filepath: dateConstraints.mjs
|
|
10726
10993
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10792,12 +11059,11 @@ class AuroDateUtilitiesBase {
|
|
|
10792
11059
|
/* eslint-disable no-magic-numbers */
|
|
10793
11060
|
|
|
10794
11061
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10795
|
-
|
|
10796
11062
|
/**
|
|
10797
11063
|
* Returns the current century.
|
|
10798
11064
|
* @returns {String} The current century.
|
|
10799
11065
|
*/
|
|
10800
|
-
getCentury
|
|
11066
|
+
getCentury() {
|
|
10801
11067
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10802
11068
|
}
|
|
10803
11069
|
|
|
@@ -10806,14 +11072,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10806
11072
|
* @param {String} year - The year to convert to four digits.
|
|
10807
11073
|
* @returns {String} The four digit year.
|
|
10808
11074
|
*/
|
|
10809
|
-
getFourDigitYear
|
|
10810
|
-
|
|
11075
|
+
getFourDigitYear(year) {
|
|
10811
11076
|
const strYear = String(year).trim();
|
|
10812
11077
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10813
11078
|
}
|
|
10814
11079
|
|
|
10815
11080
|
constructor() {
|
|
10816
|
-
|
|
10817
11081
|
super();
|
|
10818
11082
|
|
|
10819
11083
|
/**
|
|
@@ -10822,7 +11086,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10822
11086
|
* @param {Object} date2 - Second date to compare.
|
|
10823
11087
|
* @returns {Boolean} Returns true if the dates match.
|
|
10824
11088
|
*/
|
|
10825
|
-
this.datesMatch = (date1, date2) =>
|
|
11089
|
+
this.datesMatch = (date1, date2) =>
|
|
11090
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10826
11091
|
|
|
10827
11092
|
/**
|
|
10828
11093
|
* Returns true if value passed in is a valid date.
|
|
@@ -10831,53 +11096,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10831
11096
|
* @returns {Boolean}
|
|
10832
11097
|
*/
|
|
10833
11098
|
this.validDateStr = (date, format) => {
|
|
10834
|
-
|
|
10835
11099
|
// The length we expect the date string to be
|
|
10836
|
-
const dateStrLength = format
|
|
11100
|
+
const dateStrLength = format?.length || 0;
|
|
10837
11101
|
|
|
10838
11102
|
// Guard Clause: Date and format are defined
|
|
10839
11103
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10840
|
-
throw new Error(
|
|
11104
|
+
throw new Error(
|
|
11105
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11106
|
+
);
|
|
10841
11107
|
}
|
|
10842
11108
|
|
|
10843
11109
|
// Guard Clause: Date should be of type string
|
|
10844
11110
|
if (typeof date !== "string") {
|
|
10845
|
-
throw new Error(
|
|
11111
|
+
throw new Error(
|
|
11112
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11113
|
+
);
|
|
10846
11114
|
}
|
|
10847
11115
|
|
|
10848
11116
|
// Guard Clause: Format should be of type string
|
|
10849
11117
|
if (typeof format !== "string") {
|
|
10850
|
-
throw new Error(
|
|
11118
|
+
throw new Error(
|
|
11119
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11120
|
+
);
|
|
10851
11121
|
}
|
|
10852
11122
|
|
|
10853
11123
|
// Guard Clause: Length is what we expect it to be
|
|
10854
11124
|
if (date.length !== dateStrLength) {
|
|
10855
11125
|
return false;
|
|
10856
11126
|
}
|
|
10857
|
-
// Get a formatted date string and parse it
|
|
10858
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10859
|
-
|
|
10860
|
-
// Guard Clause: Date parse succeeded
|
|
10861
|
-
if (!dateParts) {
|
|
10862
|
-
return false;
|
|
10863
|
-
}
|
|
10864
|
-
|
|
10865
|
-
// Create the expected date string based on the date parts
|
|
10866
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
10867
|
-
|
|
10868
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
10869
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10870
|
-
|
|
10871
|
-
// Get the date string of the date object we created from the string date
|
|
10872
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10873
11127
|
|
|
10874
|
-
//
|
|
10875
|
-
|
|
11128
|
+
// Get a formatted date string and parse and validate it
|
|
11129
|
+
try {
|
|
11130
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11131
|
+
} catch (error) {
|
|
10876
11132
|
return false;
|
|
10877
11133
|
}
|
|
10878
|
-
|
|
10879
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10880
|
-
return true;
|
|
10881
11134
|
};
|
|
10882
11135
|
|
|
10883
11136
|
/**
|
|
@@ -10887,10 +11140,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10887
11140
|
* @returns {boolean}
|
|
10888
11141
|
*/
|
|
10889
11142
|
this.dateAndFormatMatch = (value, format) => {
|
|
10890
|
-
|
|
10891
11143
|
// Ensure we have both values we need to do the comparison
|
|
10892
11144
|
if (!value || !format) {
|
|
10893
|
-
throw new Error(
|
|
11145
|
+
throw new Error(
|
|
11146
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11147
|
+
);
|
|
10894
11148
|
}
|
|
10895
11149
|
|
|
10896
11150
|
// If the lengths are different, they cannot match
|
|
@@ -10899,11 +11153,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10899
11153
|
}
|
|
10900
11154
|
|
|
10901
11155
|
// Get the parts of the date
|
|
10902
|
-
const dateParts = dateFormatter.
|
|
11156
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10903
11157
|
|
|
10904
11158
|
// Validator for day
|
|
10905
11159
|
const dayValueIsValid = (day) => {
|
|
10906
|
-
|
|
10907
11160
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10908
11161
|
if (!dateParts.day) {
|
|
10909
11162
|
return true;
|
|
@@ -10919,7 +11172,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10919
11172
|
|
|
10920
11173
|
// Guard clause: ensure day is a valid integer
|
|
10921
11174
|
if (Number.isNaN(numDay)) {
|
|
10922
|
-
throw new Error(
|
|
11175
|
+
throw new Error(
|
|
11176
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11177
|
+
);
|
|
10923
11178
|
}
|
|
10924
11179
|
|
|
10925
11180
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10933,6 +11188,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10933
11188
|
|
|
10934
11189
|
// Validator for month
|
|
10935
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
|
+
}
|
|
10936
11195
|
|
|
10937
11196
|
// Guard clause: ensure month exists.
|
|
10938
11197
|
if (!month) {
|
|
@@ -10944,7 +11203,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10944
11203
|
|
|
10945
11204
|
// Guard clause: ensure month is a valid integer
|
|
10946
11205
|
if (Number.isNaN(numMonth)) {
|
|
10947
|
-
throw new Error(
|
|
11206
|
+
throw new Error(
|
|
11207
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11208
|
+
);
|
|
10948
11209
|
}
|
|
10949
11210
|
|
|
10950
11211
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10958,6 +11219,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10958
11219
|
|
|
10959
11220
|
// Validator for year
|
|
10960
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
|
+
}
|
|
10961
11226
|
|
|
10962
11227
|
// Guard clause: ensure year exists.
|
|
10963
11228
|
if (!_year) {
|
|
@@ -10972,7 +11237,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10972
11237
|
|
|
10973
11238
|
// Guard clause: ensure year is a valid integer
|
|
10974
11239
|
if (Number.isNaN(numYear)) {
|
|
10975
|
-
throw new Error(
|
|
11240
|
+
throw new Error(
|
|
11241
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11242
|
+
);
|
|
10976
11243
|
}
|
|
10977
11244
|
|
|
10978
11245
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10988,7 +11255,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10988
11255
|
const checks = [
|
|
10989
11256
|
monthValueIsValid(dateParts.month),
|
|
10990
11257
|
dayValueIsValid(dateParts.day),
|
|
10991
|
-
yearIsValid(dateParts.year)
|
|
11258
|
+
yearIsValid(dateParts.year),
|
|
10992
11259
|
];
|
|
10993
11260
|
|
|
10994
11261
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -11022,10 +11289,7 @@ const {
|
|
|
11022
11289
|
} = dateUtilities;
|
|
11023
11290
|
|
|
11024
11291
|
const {
|
|
11025
|
-
toNorthAmericanFormat
|
|
11026
|
-
parseDate,
|
|
11027
|
-
getDateAsString
|
|
11028
|
-
} = dateFormatter;
|
|
11292
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
11029
11293
|
|
|
11030
11294
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
11031
11295
|
// See LICENSE in the project root for license information.
|
|
@@ -13240,7 +13504,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$4 {
|
|
|
13240
13504
|
}
|
|
13241
13505
|
};
|
|
13242
13506
|
|
|
13243
|
-
var formkitVersion$1 = '
|
|
13507
|
+
var formkitVersion$1 = '202606030033';
|
|
13244
13508
|
|
|
13245
13509
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13246
13510
|
// See LICENSE in the project root for license information.
|
|
@@ -14313,7 +14577,7 @@ class AuroBibtemplate extends i$4 {
|
|
|
14313
14577
|
}
|
|
14314
14578
|
}
|
|
14315
14579
|
|
|
14316
|
-
var formkitVersion = '
|
|
14580
|
+
var formkitVersion = '202606030033';
|
|
14317
14581
|
|
|
14318
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}`;
|
|
14319
14583
|
|