@aurodesignsystem-dev/auro-formkit 0.0.0-pr1483.2 → 0.0.0-pr1488.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/components/checkbox/demo/customize.min.js +436 -14
  2. package/components/checkbox/demo/getting-started.min.js +436 -14
  3. package/components/checkbox/demo/index.min.js +436 -14
  4. package/components/checkbox/dist/index.js +436 -14
  5. package/components/checkbox/dist/registered.js +436 -14
  6. package/components/combobox/demo/customize.min.js +1482 -6618
  7. package/components/combobox/demo/getting-started.min.js +1482 -6618
  8. package/components/combobox/demo/index.min.js +1482 -6618
  9. package/components/combobox/demo/keyboard-behavior.md +68 -8
  10. package/components/combobox/dist/index.js +1489 -6625
  11. package/components/combobox/dist/registered.js +1489 -6625
  12. package/components/counter/demo/customize.min.js +437 -15
  13. package/components/counter/demo/index.min.js +437 -15
  14. package/components/counter/dist/index.js +436 -14
  15. package/components/counter/dist/registered.js +436 -14
  16. package/components/datepicker/demo/api.md +3 -10
  17. package/components/datepicker/demo/customize.md +6 -6
  18. package/components/datepicker/demo/index.md +4 -4
  19. package/components/datepicker/demo/index.min.js +2319 -7650
  20. package/components/datepicker/dist/index.js +2319 -7650
  21. package/components/datepicker/dist/registered.js +2319 -7650
  22. package/components/datepicker/dist/src/auro-calendar.d.ts +0 -6
  23. package/components/datepicker/dist/src/auro-datepicker.d.ts +11 -24
  24. package/components/datepicker/dist/src/utilities.d.ts +40 -14
  25. package/components/datepicker/dist/src/utilitiesCalendar.d.ts +1 -1
  26. package/components/dropdown/demo/customize.min.js +1 -1
  27. package/components/dropdown/demo/getting-started.min.js +1 -1
  28. package/components/dropdown/demo/index.min.js +1 -1
  29. package/components/dropdown/dist/index.js +1 -1
  30. package/components/dropdown/dist/registered.js +1 -1
  31. package/components/form/demo/customize.min.js +44181 -58516
  32. package/components/form/demo/getting-started.min.js +44181 -58516
  33. package/components/form/demo/index.min.js +44181 -58516
  34. package/components/form/demo/registerDemoDeps.min.js +44181 -58516
  35. package/components/input/demo/api.md +51 -57
  36. package/components/input/demo/customize.md +0 -160
  37. package/components/input/demo/customize.min.js +1011 -6565
  38. package/components/input/demo/getting-started.md +0 -11
  39. package/components/input/demo/getting-started.min.js +1010 -6564
  40. package/components/input/demo/index.md +3 -28
  41. package/components/input/demo/index.min.js +1010 -6564
  42. package/components/input/dist/auro-input.d.ts +6 -25
  43. package/components/input/dist/base-input.d.ts +69 -82
  44. package/components/input/dist/index.d.ts +1 -2
  45. package/components/input/dist/index.js +1003 -6599
  46. package/components/input/dist/registered.js +1010 -6564
  47. package/components/input/dist/utilities.d.ts +9 -68
  48. package/components/radio/demo/index.min.js +436 -14
  49. package/components/radio/dist/index.js +436 -14
  50. package/components/radio/dist/registered.js +436 -14
  51. package/components/select/demo/customize.min.js +455 -31
  52. package/components/select/demo/getting-started.min.js +455 -31
  53. package/components/select/demo/index.min.js +455 -31
  54. package/components/select/demo/keyboard-behavior.md +54 -8
  55. package/components/select/dist/index.js +455 -31
  56. package/components/select/dist/registered.js +455 -31
  57. package/custom-elements.json +2117 -2625
  58. package/package.json +4 -4
  59. package/components/input/dist/auro-input-util.d.ts +0 -17
@@ -258,6 +258,415 @@ let p$2 = class p{registerComponent(t,a){customElements.get(t)||customElements.d
258
258
 
259
259
  var iconVersion$1 = '9.1.2';
260
260
 
261
+ class DateFormatter {
262
+
263
+ constructor() {
264
+
265
+ /**
266
+ * @description Parses a date string into its components.
267
+ * @param {string} dateStr - Date string to parse.
268
+ * @param {string} format - Date format to parse.
269
+ * @returns {Object<key["month" | "day" | "year"]: number>|undefined}
270
+ */
271
+ this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
272
+
273
+ // Guard Clause: Date string is defined
274
+ if (!dateStr) {
275
+ return undefined;
276
+ }
277
+
278
+ // Assume the separator is a "/" a defined in our code base
279
+ const separator = '/';
280
+
281
+ // Get the parts of the date and format
282
+ const valueParts = dateStr.split(separator);
283
+ const formatParts = format.split(separator);
284
+
285
+ // Check if the value and format have the correct number of parts
286
+ if (valueParts.length !== formatParts.length) {
287
+ throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
288
+ }
289
+
290
+ // Holds the result to be returned
291
+ const result = formatParts.reduce((acc, part, index) => {
292
+ const value = valueParts[index];
293
+
294
+ if ((/m/iu).test(part)) {
295
+ acc.month = value;
296
+ } else if ((/d/iu).test(part)) {
297
+ acc.day = value;
298
+ } else if ((/y/iu).test(part)) {
299
+ acc.year = value;
300
+ }
301
+
302
+ return acc;
303
+ }, {});
304
+
305
+ // If we found all the parts, return the result
306
+ if (result.month && result.year) {
307
+ return result;
308
+ }
309
+
310
+ // Throw an error to let the dev know we were unable to parse the date string
311
+ throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
312
+ };
313
+
314
+ /**
315
+ * Convert a date object to string format.
316
+ * @param {Object} date - Date to convert to string.
317
+ * @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
318
+ * @returns {String} Returns the date as a string.
319
+ */
320
+ this.getDateAsString = (date, locale = undefined) => date.toLocaleDateString(locale, {
321
+ year: "numeric",
322
+ month: "2-digit",
323
+ day: "2-digit",
324
+ });
325
+
326
+ /**
327
+ * Converts a date string to a North American date format.
328
+ * @param {String} dateStr - Date to validate.
329
+ * @param {String} format - Date format to validate against.
330
+ * @returns {Boolean}
331
+ */
332
+ this.toNorthAmericanFormat = (dateStr, format) => {
333
+
334
+ if (format === 'mm/dd/yyyy') {
335
+ return dateStr;
336
+ }
337
+
338
+ const parsedDate = this.parseDate(dateStr, format);
339
+
340
+ if (!parsedDate) {
341
+ throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
342
+ }
343
+
344
+ const { month, day, year } = parsedDate;
345
+
346
+ const dateParts = [];
347
+ if (month) {
348
+ dateParts.push(month);
349
+ }
350
+
351
+ if (day) {
352
+ dateParts.push(day);
353
+ }
354
+
355
+ if (year) {
356
+ dateParts.push(year);
357
+ }
358
+
359
+ return dateParts.join('/');
360
+ };
361
+ }
362
+ }
363
+ const dateFormatter = new DateFormatter();
364
+
365
+ // filepath: dateConstraints.mjs
366
+ const DATE_UTIL_CONSTRAINTS = {
367
+ maxDay: 31,
368
+ maxMonth: 12,
369
+ maxYear: 2400,
370
+ minDay: 1,
371
+ minMonth: 1,
372
+ minYear: 1900,
373
+ };
374
+
375
+ class AuroDateUtilitiesBase {
376
+
377
+ /**
378
+ * @description The maximum day value allowed by the various utilities in this class.
379
+ * @readonly
380
+ * @type {Number}
381
+ */
382
+ get maxDay() {
383
+ return DATE_UTIL_CONSTRAINTS.maxDay;
384
+ }
385
+
386
+ /**
387
+ * @description The maximum month value allowed by the various utilities in this class.
388
+ * @readonly
389
+ * @type {Number}
390
+ */
391
+ get maxMonth() {
392
+ return DATE_UTIL_CONSTRAINTS.maxMonth;
393
+ }
394
+
395
+ /**
396
+ * @description The maximum year value allowed by the various utilities in this class.
397
+ * @readonly
398
+ * @type {Number}
399
+ */
400
+ get maxYear() {
401
+ return DATE_UTIL_CONSTRAINTS.maxYear;
402
+ }
403
+
404
+ /**
405
+ * @description The minimum day value allowed by the various utilities in this class.
406
+ * @readonly
407
+ * @type {Number}
408
+ */
409
+ get minDay() {
410
+ return DATE_UTIL_CONSTRAINTS.minDay;
411
+ }
412
+
413
+ /**
414
+ * @description The minimum month value allowed by the various utilities in this class.
415
+ * @readonly
416
+ * @type {Number}
417
+ */
418
+ get minMonth() {
419
+ return DATE_UTIL_CONSTRAINTS.minMonth;
420
+ }
421
+
422
+ /**
423
+ * @description The minimum year value allowed by the various utilities in this class.
424
+ * @readonly
425
+ * @type {Number}
426
+ */
427
+ get minYear() {
428
+ return DATE_UTIL_CONSTRAINTS.minYear;
429
+ }
430
+ }
431
+
432
+ /* eslint-disable no-magic-numbers */
433
+
434
+ class AuroDateUtilities extends AuroDateUtilitiesBase {
435
+
436
+ /**
437
+ * Returns the current century.
438
+ * @returns {String} The current century.
439
+ */
440
+ getCentury () {
441
+ return String(new Date().getFullYear()).slice(0, 2);
442
+ }
443
+
444
+ /**
445
+ * Returns a four digit year.
446
+ * @param {String} year - The year to convert to four digits.
447
+ * @returns {String} The four digit year.
448
+ */
449
+ getFourDigitYear (year) {
450
+
451
+ const strYear = String(year).trim();
452
+ return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
453
+ }
454
+
455
+ constructor() {
456
+
457
+ super();
458
+
459
+ /**
460
+ * Compares two dates to see if they match.
461
+ * @param {Object} date1 - First date to compare.
462
+ * @param {Object} date2 - Second date to compare.
463
+ * @returns {Boolean} Returns true if the dates match.
464
+ */
465
+ this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
466
+
467
+ /**
468
+ * Returns true if value passed in is a valid date.
469
+ * @param {String} date - Date to validate.
470
+ * @param {String} format - Date format to validate against.
471
+ * @returns {Boolean}
472
+ */
473
+ this.validDateStr = (date, format) => {
474
+
475
+ // The length we expect the date string to be
476
+ const dateStrLength = format.length;
477
+
478
+ // Guard Clause: Date and format are defined
479
+ if (typeof date === "undefined" || typeof format === "undefined") {
480
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
481
+ }
482
+
483
+ // Guard Clause: Date should be of type string
484
+ if (typeof date !== "string") {
485
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
486
+ }
487
+
488
+ // Guard Clause: Format should be of type string
489
+ if (typeof format !== "string") {
490
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
491
+ }
492
+
493
+ // Guard Clause: Length is what we expect it to be
494
+ if (date.length !== dateStrLength) {
495
+ return false;
496
+ }
497
+ // Get a formatted date string and parse it
498
+ const dateParts = dateFormatter.parseDate(date, format);
499
+
500
+ // Guard Clause: Date parse succeeded
501
+ if (!dateParts) {
502
+ return false;
503
+ }
504
+
505
+ // Create the expected date string based on the date parts
506
+ const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
507
+
508
+ // Generate a date object that we will extract a string date from to compare to the passed in date string
509
+ const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
510
+
511
+ // Get the date string of the date object we created from the string date
512
+ const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
513
+
514
+ // Guard Clause: Generated date matches date string input
515
+ if (expectedDateStr !== actualDateStr) {
516
+ return false;
517
+ }
518
+
519
+ // If we passed all other checks, we can assume the date is valid
520
+ return true;
521
+ };
522
+
523
+ /**
524
+ * Determines if a string date value matches the format provided.
525
+ * @param {string} value = The date string value.
526
+ * @param { string} format = The date format to match against.
527
+ * @returns {boolean}
528
+ */
529
+ this.dateAndFormatMatch = (value, format) => {
530
+
531
+ // Ensure we have both values we need to do the comparison
532
+ if (!value || !format) {
533
+ throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
534
+ }
535
+
536
+ // If the lengths are different, they cannot match
537
+ if (value.length !== format.length) {
538
+ return false;
539
+ }
540
+
541
+ // Get the parts of the date
542
+ const dateParts = dateFormatter.parseDate(value, format);
543
+
544
+ // Validator for day
545
+ const dayValueIsValid = (day) => {
546
+
547
+ // Guard clause: if there is no day in the dateParts, we can ignore this check.
548
+ if (!dateParts.day) {
549
+ return true;
550
+ }
551
+
552
+ // Guard clause: ensure day exists.
553
+ if (!day) {
554
+ return false;
555
+ }
556
+
557
+ // Convert day to number
558
+ const numDay = Number.parseInt(day, 10);
559
+
560
+ // Guard clause: ensure day is a valid integer
561
+ if (Number.isNaN(numDay)) {
562
+ throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
563
+ }
564
+
565
+ // Guard clause: ensure day is within the valid range
566
+ if (numDay < this.minDay || numDay > this.maxDay) {
567
+ return false;
568
+ }
569
+
570
+ // Default return
571
+ return true;
572
+ };
573
+
574
+ // Validator for month
575
+ const monthValueIsValid = (month) => {
576
+
577
+ // Guard clause: ensure month exists.
578
+ if (!month) {
579
+ return false;
580
+ }
581
+
582
+ // Convert month to number
583
+ const numMonth = Number.parseInt(month, 10);
584
+
585
+ // Guard clause: ensure month is a valid integer
586
+ if (Number.isNaN(numMonth)) {
587
+ throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
588
+ }
589
+
590
+ // Guard clause: ensure month is within the valid range
591
+ if (numMonth < this.minMonth || numMonth > this.maxMonth) {
592
+ return false;
593
+ }
594
+
595
+ // Default return
596
+ return true;
597
+ };
598
+
599
+ // Validator for year
600
+ const yearIsValid = (_year) => {
601
+
602
+ // Guard clause: ensure year exists.
603
+ if (!_year) {
604
+ return false;
605
+ }
606
+
607
+ // Get the full year
608
+ const year = this.getFourDigitYear(_year);
609
+
610
+ // Convert year to number
611
+ const numYear = Number.parseInt(year, 10);
612
+
613
+ // Guard clause: ensure year is a valid integer
614
+ if (Number.isNaN(numYear)) {
615
+ throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
616
+ }
617
+
618
+ // Guard clause: ensure year is within the valid range
619
+ if (numYear < this.minYear || numYear > this.maxYear) {
620
+ return false;
621
+ }
622
+
623
+ // Default return
624
+ return true;
625
+ };
626
+
627
+ // Self-contained checks for month, day, and year
628
+ const checks = [
629
+ monthValueIsValid(dateParts.month),
630
+ dayValueIsValid(dateParts.day),
631
+ yearIsValid(dateParts.year)
632
+ ];
633
+
634
+ // If any of the checks failed, the date format does not match and the result is invalid
635
+ const isValid = checks.every((check) => check === true);
636
+
637
+ // If the check is invalid, return false
638
+ if (!isValid) {
639
+ return false;
640
+ }
641
+
642
+ // Default case
643
+ return true;
644
+ };
645
+ }
646
+ }
647
+
648
+ // Export a class instance
649
+ const dateUtilities = new AuroDateUtilities();
650
+
651
+ // Export the class instance methods individually
652
+ const {
653
+ datesMatch,
654
+ validDateStr,
655
+ dateAndFormatMatch,
656
+ minDay,
657
+ minMonth,
658
+ minYear,
659
+ maxDay,
660
+ maxMonth,
661
+ maxYear
662
+ } = dateUtilities;
663
+
664
+ const {
665
+ toNorthAmericanFormat,
666
+ parseDate,
667
+ getDateAsString
668
+ } = dateFormatter;
669
+
261
670
  // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
262
671
  // See LICENSE in the project root for license information.
263
672
 
@@ -399,7 +808,7 @@ class AuroFormValidation {
399
808
  validity: 'valueMissing',
400
809
  message: e => e.getAttribute('setCustomValidityValueMissingFilter') || e.setCustomValidity || ''
401
810
  }
402
- ]
811
+ ]
403
812
  }
404
813
  };
405
814
 
@@ -464,12 +873,12 @@ class AuroFormValidation {
464
873
 
465
874
  // Guard Clause: if the value is too short
466
875
  if (elem.value?.length < elem.lengthForType) {
467
-
876
+
468
877
  elem.validity = 'tooShort';
469
878
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
470
879
  return;
471
- }
472
-
880
+ }
881
+
473
882
  // Guard Clause: If the value is too long for the type
474
883
  if (elem.value?.length > elem.lengthForType) {
475
884
 
@@ -477,20 +886,31 @@ class AuroFormValidation {
477
886
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
478
887
  return;
479
888
  }
480
-
481
- // Validate that the date passed was the correct format and is a valid date
482
- if (elem.value && !elem.valueObject) {
889
+
890
+ // Validate that the date passed was the correct format
891
+ if (!dateAndFormatMatch(elem.value, elem.format)) {
483
892
  elem.validity = 'patternMismatch';
484
- elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
893
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
894
+ return;
895
+ }
896
+
897
+ // Validate that the date passed was a valid date
898
+ if (!validDateStr(elem.value, elem.format)) {
899
+ elem.validity = 'invalidDate';
900
+ elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
485
901
  return;
486
902
  }
487
903
 
488
904
  // Perform the rest of the validation
905
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
906
+ const valueDate = new Date(formattedValue);
489
907
 
490
908
  // // Validate max date
491
909
  if (elem.max?.length === elem.lengthForType) {
492
910
 
493
- if (elem.valueObject > elem.maxObject) {
911
+ const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
912
+
913
+ if (valueDate > maxDate) {
494
914
  elem.validity = 'rangeOverflow';
495
915
  elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
496
916
  return;
@@ -499,7 +919,9 @@ class AuroFormValidation {
499
919
 
500
920
  // Validate min date
501
921
  if (elem.min?.length === elem.lengthForType) {
502
- if (elem.valueObject < elem.minObject) {
922
+ const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
923
+
924
+ if (valueDate < minDate) {
503
925
  elem.validity = 'rangeUnderflow';
504
926
  elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
505
927
  return;
@@ -559,7 +981,7 @@ class AuroFormValidation {
559
981
  if (typeof elem.value === "string") {
560
982
  hasValue = elem.value && elem.value.length > 0;
561
983
  }
562
-
984
+
563
985
  if (typeof elem.value === "boolean") {
564
986
  hasValue = elem.value || elem.value === false;
565
987
  }
@@ -584,7 +1006,7 @@ class AuroFormValidation {
584
1006
  }
585
1007
 
586
1008
  const isCombobox = this.runtimeUtils.elementMatch(elem, 'auro-combobox');
587
-
1009
+
588
1010
  if (isCombobox) {
589
1011
 
590
1012
  if (!elem.persistInput || elem.behavior === "filter") {
@@ -624,7 +1046,7 @@ class AuroFormValidation {
624
1046
  }
625
1047
 
626
1048
  // multiple input in one components (datepicker)
627
- // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
1049
+ // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
628
1050
  if (elem.validity === 'valid' && this.auroInputElements.length > 1 && !isCombobox) {
629
1051
  elem.validity = this.auroInputElements[1].validity;
630
1052
  elem.errorMessage = this.auroInputElements[1].errorMessage;
@@ -1049,7 +1471,7 @@ class AuroHelpText extends LitElement {
1049
1471
  }
1050
1472
  }
1051
1473
 
1052
- var formkitVersion = '202605271836';
1474
+ var formkitVersion = '202605292307';
1053
1475
 
1054
1476
  // Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
1055
1477
  // See LICENSE in the project root for license information.