aria-ease 2.1.1 → 2.2.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.
package/bin/audit-cli.cjs CHANGED
@@ -5,6 +5,9 @@ function _array_like_to_array(arr, len) {
5
5
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6
6
  return arr2;
7
7
  }
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr)) return arr;
10
+ }
8
11
  function _array_without_holes(arr) {
9
12
  if (Array.isArray(arr)) return _array_like_to_array(arr);
10
13
  }
@@ -81,9 +84,39 @@ function _interop_require_wildcard(obj, nodeInterop) {
81
84
  function _iterable_to_array(iter) {
82
85
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
83
86
  }
87
+ function _iterable_to_array_limit(arr, i) {
88
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
89
+ if (_i == null) return;
90
+ var _arr = [];
91
+ var _n = true;
92
+ var _d = false;
93
+ var _s, _e;
94
+ try {
95
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
96
+ _arr.push(_s.value);
97
+ if (i && _arr.length === i) break;
98
+ }
99
+ } catch (err) {
100
+ _d = true;
101
+ _e = err;
102
+ } finally{
103
+ try {
104
+ if (!_n && _i["return"] != null) _i["return"]();
105
+ } finally{
106
+ if (_d) throw _e;
107
+ }
108
+ }
109
+ return _arr;
110
+ }
111
+ function _non_iterable_rest() {
112
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
+ }
84
114
  function _non_iterable_spread() {
85
115
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
86
116
  }
117
+ function _sliced_to_array(arr, i) {
118
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
119
+ }
87
120
  function _to_consumable_array(arr) {
88
121
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
89
122
  }
@@ -462,6 +495,8 @@ function formatResults(allResults, format) {
462
495
  }), null, 2);
463
496
  case "csv":
464
497
  return toCSV(allResults);
498
+ case "html":
499
+ return toHTML(allResults);
465
500
  default:
466
501
  return "";
467
502
  }
@@ -475,19 +510,116 @@ function toCSV(allResults) {
475
510
  if (result) {
476
511
  result.violations.forEach(function(v) {
477
512
  v.nodes.forEach(function(n) {
478
- rows.push('"'.concat(url, '","').concat(v.id, '","').concat(v.impact, '","').concat(v.description, '","').concat(n.target, '","').concat(n.failureSummary, '"'));
513
+ var _n_failureSummary;
514
+ rows.push(escapeCSV(url) + "," + escapeCSV(v.id) + "," + escapeCSV(v.impact) + "," + escapeCSV(v.description) + "," + escapeCSV(Array.isArray(n.target) ? n.target.join("; ") : String(n.target)) + "," + escapeCSV((_n_failureSummary = n.failureSummary) !== null && _n_failureSummary !== void 0 ? _n_failureSummary : ""));
479
515
  });
480
516
  });
481
517
  }
482
518
  });
483
519
  return rows.join("\n");
484
520
  }
521
+ function escapeCSV(value) {
522
+ var s = String(value !== null && value !== void 0 ? value : "");
523
+ return '"'.concat(s.replace(/"/g, '""'), '"');
524
+ }
525
+ function toHTML(allResults) {
526
+ var summary = {
527
+ pagesAudited: 0,
528
+ pagesWithViolations: 0,
529
+ totalViolations: 0,
530
+ distinctRules: /* @__PURE__ */ new Set(),
531
+ impactCounts: /* @__PURE__ */ new Map()
532
+ };
533
+ allResults.forEach(function(param) {
534
+ var result = param.result;
535
+ if (!result) return;
536
+ summary.pagesAudited++;
537
+ var pageViolations = result.violations.reduce(function(acc, v) {
538
+ var nodesCount = (v.nodes || []).length;
539
+ if (nodesCount > 0) {
540
+ summary.distinctRules.add(v.id);
541
+ summary.totalViolations += nodesCount;
542
+ acc += nodesCount;
543
+ var _v_impact;
544
+ var impact = String((_v_impact = v.impact) !== null && _v_impact !== void 0 ? _v_impact : "unknown");
545
+ summary.impactCounts.set(impact, (summary.impactCounts.get(impact) || 0) + nodesCount);
546
+ }
547
+ return acc;
548
+ }, 0);
549
+ if (pageViolations > 0) summary.pagesWithViolations++;
550
+ });
551
+ var rows = [];
552
+ allResults.forEach(function(param) {
553
+ var url = param.url, result = param.result;
554
+ if (!result) return;
555
+ result.violations.forEach(function(v) {
556
+ v.nodes.forEach(function(n) {
557
+ var target = Array.isArray(n.target) ? n.target.join("; ") : String(n.target);
558
+ var _v_impact, _v_impact1, _v_description, _n_failureSummary;
559
+ rows.push('\n <tr>\n <td class="nowrap">'.concat(escapeHTML(url), '</td>\n <td class="nowrap">').concat(escapeHTML(v.id), '</td>\n <td class="impact ').concat(escapeClass(String((_v_impact = v.impact) !== null && _v_impact !== void 0 ? _v_impact : "unknown")), '">').concat(escapeHTML(String((_v_impact1 = v.impact) !== null && _v_impact1 !== void 0 ? _v_impact1 : "")), '</td>\n <td class="desc">').concat(escapeHTML((_v_description = v.description) !== null && _v_description !== void 0 ? _v_description : ""), '</td>\n <td class="target"><code>').concat(escapeHTML(target), '</code></td>\n <td class="fail">').concat(escapeHTML((_n_failureSummary = n.failureSummary) !== null && _n_failureSummary !== void 0 ? _n_failureSummary : "").split(/\r?\n/).join("<br/>"), "</td>\n </tr>\n "));
560
+ });
561
+ });
562
+ });
563
+ var impactSummary = Array.from(summary.impactCounts.entries()).map(function(param) {
564
+ var _param = _sliced_to_array(param, 2), impact = _param[0], count = _param[1];
565
+ return '<li><strong class="impact '.concat(escapeClass(impact), '">').concat(escapeHTML(impact), "</strong>: ").concat(count, "</li>");
566
+ }).join("\n");
567
+ var d = /* @__PURE__ */ new Date();
568
+ var pad = function(n) {
569
+ return String(n).padStart(2, "0");
570
+ };
571
+ var reportDateTime = "".concat(pad(d.getDate()), "-").concat(pad(d.getMonth() + 1), "-").concat(d.getFullYear(), " ").concat(pad(d.getHours()), ":").concat(pad(d.getMinutes()), ":").concat(pad(d.getSeconds()));
572
+ var headerSummary = '\n <section class="summary">\n <h2>Report summary</h2>\n <ul>\n <li><strong>Date:</strong> '.concat(reportDateTime, "</li>\n <li><strong>Pages audited:</strong> ").concat(summary.pagesAudited, "</li>\n <li><strong>Pages with violations:</strong> ").concat(summary.pagesWithViolations, "</li>\n <li><strong>Total violations:</strong> ").concat(summary.totalViolations, "</li>\n <li><strong>Distinct rules:</strong> ").concat(summary.distinctRules.size, '</li>\n </ul>\n <div class="impact-summary">\n <h3>By impact</h3>\n <ul class="summary-list">\n ').concat(impactSummary || "<li>None</li>", "\n </ul>\n </div>\n </section>\n ").trim();
573
+ var html = '\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8"/>\n <title>Aria-Ease Accessibility Audit Report</title>\n <meta name="viewport" content="width=device-width, initial-scale=1"/>\n <style>\n :root{\n --bg:#ffffff; --muted:#6b7280; --border:#e6e9ee;\n --impact-critical: red; --impact-moderate:#fff4dd; --impact-serious:rgb(255, 123, 0);\n }\n body{font-family:Inter,ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial; background:var(--bg); color:#111827; padding:24px; line-height:1.4}\n h1{margin:0 0 8px}\n .summary{background:#f8fafc;border:1px solid var(--border);padding:12px 16px;border-radius:8px;margin-bottom:18px}\n .summary ul{margin:6px 0 0 0;padding:0 18px}\n .impact-summary h3{margin:12px 0 6px}\n table{width:100%; border-collapse:collapse; margin-top:12px}\n th,td{border:1px solid var(--border); padding:10px; text-align:left; vertical-align:top}\n th{background:#f3f4f6; font-weight:600; position:sticky; top:0; z-index:1}\n .nowrap{white-space:nowrap}\n .target code{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace; white-space:pre-wrap}\n .desc{max-width:380px}\n tr:nth-child(even){background:#fbfbfb}\n td.fail{color:#7b1e1e}\n .impact.critical{background:var(--impact-critical); font-weight:600}\n .impact.moderate{background:var(--impact-moderate); font-weight:600}\n .impact.serious{background:var(--impact-serious); font-weight:600}\n @media (max-width:900px){\n .desc{max-width:200px}\n table, thead, tbody, th, td, tr{display:block}\n thead{display:none}\n tr{margin-bottom:10px; border: 1px solid var(--border);}\n td{border:1px solid var(--border); padding:6px}\n td::before{font-weight:600; display:inline-block; width:120px}\n }\n .summary-list strong,\n .summary-list li {\n padding: 2px 4px;\n }\n </style>\n </head>\n <body>\n <h1>Aria-Ease Accessibility Audit Report</h1>\n '.concat(headerSummary, "\n <table>\n <thead>\n <tr>\n <th>URL</th><th>Rule</th><th>Impact</th><th>Description</th><th>Target</th><th>FailureSummary</th>\n </tr>\n </thead>\n <tbody>\n ").concat(rows.join("\n") || '<tr><td colspan="6"><em>No violations found.</em></td></tr>', "\n </tbody>\n </table>\n </body>\n </html>\n ").trim();
574
+ return html;
575
+ }
576
+ function escapeHTML(str) {
577
+ return String(str !== null && str !== void 0 ? str : "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
578
+ }
579
+ function escapeClass(s) {
580
+ return String(s !== null && s !== void 0 ? s : "").toLowerCase().replace(/[^a-z0-9]+/g, "-");
581
+ }
485
582
  // bin/audit-cli.ts
486
583
  var program = new import_commander.Command();
487
- program.name("aria-ease").description("Run accessibility audits").version("2.0.4");
488
- program.command("audit").description("Run accessibility audit").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv", "csv").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports").action(function(opts) {
584
+ program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
585
+ program.command("audit").description("Run axe-core powered accessibility audit on webpages").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv | html", "all").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports/audit").action(function(opts) {
489
586
  return _async_to_generator(function() {
490
- var _urls, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err1, err, hasResults, formatted, out, timestamp, fileName, filePath;
587
+ var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err1, err, hasResults;
588
+ function createReport(format2) {
589
+ return _async_to_generator(function() {
590
+ var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
591
+ return _ts_generator(this, function(_state) {
592
+ switch(_state.label){
593
+ case 0:
594
+ formatted = formatResults(allResults, format2);
595
+ out = ((_config_audit = config.audit) === null || _config_audit === void 0 ? void 0 : _config_audit.output) && config.audit.output.out || opts.audit.out;
596
+ return [
597
+ 4,
598
+ import_fs_extra.default.ensureDir(out)
599
+ ];
600
+ case 1:
601
+ _state.sent();
602
+ d = /* @__PURE__ */ new Date();
603
+ pad = function(n) {
604
+ return String(n).padStart(2, "0");
605
+ };
606
+ timestamp = "".concat(pad(d.getDate()), "-").concat(pad(d.getMonth() + 1), "-").concat(d.getFullYear(), " ").concat(pad(d.getHours()), ":").concat(pad(d.getMinutes()), ":").concat(pad(d.getSeconds()));
607
+ fileName = "ariaease-report-".concat(timestamp, ".").concat(format2);
608
+ filePath = import_path.default.join(out, fileName);
609
+ return [
610
+ 4,
611
+ import_fs_extra.default.writeFile(filePath, formatted, "utf-8")
612
+ ];
613
+ case 2:
614
+ _state.sent();
615
+ console.log(import_chalk.default.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
616
+ return [
617
+ 2
618
+ ];
619
+ }
620
+ });
621
+ })();
622
+ }
491
623
  return _ts_generator(this, function(_state) {
492
624
  switch(_state.label){
493
625
  case 0:
@@ -536,14 +668,16 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
536
668
  _state.label = 6;
537
669
  case 6:
538
670
  urls = [];
539
- if (opts.url) urls.push(opts.url);
540
- if (config.urls && Array.isArray(config.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.urls));
541
- format = config.output && config.output.format || opts.format;
671
+ if ((_opts_audit = opts.audit) === null || _opts_audit === void 0 ? void 0 : _opts_audit.url) urls.push(opts.audit.url);
672
+ if (((_config_audit = config.audit) === null || _config_audit === void 0 ? void 0 : _config_audit.urls) && Array.isArray(config.audit.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.audit.urls));
673
+ format = ((_config_audit1 = config.audit) === null || _config_audit1 === void 0 ? void 0 : _config_audit1.output) && config.audit.output.format || ((_opts_audit1 = opts.audit) === null || _opts_audit1 === void 0 ? void 0 : _opts_audit1.format);
542
674
  if (![
543
675
  "json",
544
- "csv"
676
+ "csv",
677
+ "html",
678
+ "all"
545
679
  ].includes(format)) {
546
- console.log(import_chalk.default.red('\u274C Invalid format. Use "json" or "csv".'));
680
+ console.log(import_chalk.default.red('\u274C Invalid format. Use "json", "csv", "html" or "all".'));
547
681
  process.exit(1);
548
682
  }
549
683
  if (urls.length === 0) {
@@ -639,24 +773,21 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
639
773
  console.log(import_chalk.default.red("\u274C No audit report generated"));
640
774
  process.exit(1);
641
775
  }
642
- formatted = formatResults(allResults, format);
643
- out = config.output && config.output.out || opts.out;
644
- return [
645
- 4,
646
- import_fs_extra.default.ensureDir(out)
647
- ];
648
- case 17:
649
- _state.sent();
650
- timestamp = /* @__PURE__ */ new Date().toISOString().replace(/[:.]/g, "-");
651
- fileName = "ariaease-report-".concat(timestamp, ".").concat(format);
652
- filePath = import_path.default.join(out, fileName);
653
- return [
654
- 4,
655
- import_fs_extra.default.writeFile(filePath, formatted, "utf-8")
656
- ];
657
- case 18:
658
- _state.sent();
659
- console.log(import_chalk.default.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
776
+ if ([
777
+ "json",
778
+ "csv",
779
+ "html"
780
+ ].includes(format)) {
781
+ createReport(format);
782
+ } else if (format === "all") {
783
+ [
784
+ "json",
785
+ "csv",
786
+ "html"
787
+ ].map(function(format2) {
788
+ createReport(format2);
789
+ });
790
+ }
660
791
  console.log(import_chalk.default.green("\n\uD83C\uDF89 All audits completed."));
661
792
  return [
662
793
  2
@@ -665,6 +796,9 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
665
796
  });
666
797
  })();
667
798
  });
799
+ program.command("test").description("Run core a11y accessibility standard tests on UI components").option("-f, --format <format>", "Output format for the test report: json | csv | html", "html").option("-o, --out <path>", "Directory to save the test report", "./accessibility-reports/test").action(function() {
800
+ console.log("Coming soon");
801
+ });
668
802
  program.command("help").description("Display help information").action(function() {
669
803
  program.outputHelp();
670
804
  });
package/bin/audit-cli.js CHANGED
@@ -4,6 +4,9 @@ function _array_like_to_array(arr, len) {
4
4
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
5
  return arr2;
6
6
  }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
7
10
  function _array_without_holes(arr) {
8
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
9
12
  }
@@ -39,9 +42,39 @@ function _async_to_generator(fn) {
39
42
  function _iterable_to_array(iter) {
40
43
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
41
44
  }
45
+ function _iterable_to_array_limit(arr, i) {
46
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
47
+ if (_i == null) return;
48
+ var _arr = [];
49
+ var _n = true;
50
+ var _d = false;
51
+ var _s, _e;
52
+ try {
53
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
54
+ _arr.push(_s.value);
55
+ if (i && _arr.length === i) break;
56
+ }
57
+ } catch (err) {
58
+ _d = true;
59
+ _e = err;
60
+ } finally{
61
+ try {
62
+ if (!_n && _i["return"] != null) _i["return"]();
63
+ } finally{
64
+ if (_d) throw _e;
65
+ }
66
+ }
67
+ return _arr;
68
+ }
69
+ function _non_iterable_rest() {
70
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
+ }
42
72
  function _non_iterable_spread() {
43
73
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
74
  }
75
+ function _sliced_to_array(arr, i) {
76
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
77
+ }
45
78
  function _to_consumable_array(arr) {
46
79
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
47
80
  }
@@ -369,6 +402,8 @@ function formatResults(allResults, format) {
369
402
  }), null, 2);
370
403
  case "csv":
371
404
  return toCSV(allResults);
405
+ case "html":
406
+ return toHTML(allResults);
372
407
  default:
373
408
  return "";
374
409
  }
@@ -382,19 +417,116 @@ function toCSV(allResults) {
382
417
  if (result) {
383
418
  result.violations.forEach(function(v) {
384
419
  v.nodes.forEach(function(n) {
385
- rows.push('"'.concat(url, '","').concat(v.id, '","').concat(v.impact, '","').concat(v.description, '","').concat(n.target, '","').concat(n.failureSummary, '"'));
420
+ var _n_failureSummary;
421
+ rows.push(escapeCSV(url) + "," + escapeCSV(v.id) + "," + escapeCSV(v.impact) + "," + escapeCSV(v.description) + "," + escapeCSV(Array.isArray(n.target) ? n.target.join("; ") : String(n.target)) + "," + escapeCSV((_n_failureSummary = n.failureSummary) !== null && _n_failureSummary !== void 0 ? _n_failureSummary : ""));
386
422
  });
387
423
  });
388
424
  }
389
425
  });
390
426
  return rows.join("\n");
391
427
  }
428
+ function escapeCSV(value) {
429
+ var s = String(value !== null && value !== void 0 ? value : "");
430
+ return '"'.concat(s.replace(/"/g, '""'), '"');
431
+ }
432
+ function toHTML(allResults) {
433
+ var summary = {
434
+ pagesAudited: 0,
435
+ pagesWithViolations: 0,
436
+ totalViolations: 0,
437
+ distinctRules: /* @__PURE__ */ new Set(),
438
+ impactCounts: /* @__PURE__ */ new Map()
439
+ };
440
+ allResults.forEach(function(param) {
441
+ var result = param.result;
442
+ if (!result) return;
443
+ summary.pagesAudited++;
444
+ var pageViolations = result.violations.reduce(function(acc, v) {
445
+ var nodesCount = (v.nodes || []).length;
446
+ if (nodesCount > 0) {
447
+ summary.distinctRules.add(v.id);
448
+ summary.totalViolations += nodesCount;
449
+ acc += nodesCount;
450
+ var _v_impact;
451
+ var impact = String((_v_impact = v.impact) !== null && _v_impact !== void 0 ? _v_impact : "unknown");
452
+ summary.impactCounts.set(impact, (summary.impactCounts.get(impact) || 0) + nodesCount);
453
+ }
454
+ return acc;
455
+ }, 0);
456
+ if (pageViolations > 0) summary.pagesWithViolations++;
457
+ });
458
+ var rows = [];
459
+ allResults.forEach(function(param) {
460
+ var url = param.url, result = param.result;
461
+ if (!result) return;
462
+ result.violations.forEach(function(v) {
463
+ v.nodes.forEach(function(n) {
464
+ var target = Array.isArray(n.target) ? n.target.join("; ") : String(n.target);
465
+ var _v_impact, _v_impact1, _v_description, _n_failureSummary;
466
+ rows.push('\n <tr>\n <td class="nowrap">'.concat(escapeHTML(url), '</td>\n <td class="nowrap">').concat(escapeHTML(v.id), '</td>\n <td class="impact ').concat(escapeClass(String((_v_impact = v.impact) !== null && _v_impact !== void 0 ? _v_impact : "unknown")), '">').concat(escapeHTML(String((_v_impact1 = v.impact) !== null && _v_impact1 !== void 0 ? _v_impact1 : "")), '</td>\n <td class="desc">').concat(escapeHTML((_v_description = v.description) !== null && _v_description !== void 0 ? _v_description : ""), '</td>\n <td class="target"><code>').concat(escapeHTML(target), '</code></td>\n <td class="fail">').concat(escapeHTML((_n_failureSummary = n.failureSummary) !== null && _n_failureSummary !== void 0 ? _n_failureSummary : "").split(/\r?\n/).join("<br/>"), "</td>\n </tr>\n "));
467
+ });
468
+ });
469
+ });
470
+ var impactSummary = Array.from(summary.impactCounts.entries()).map(function(param) {
471
+ var _param = _sliced_to_array(param, 2), impact = _param[0], count = _param[1];
472
+ return '<li><strong class="impact '.concat(escapeClass(impact), '">').concat(escapeHTML(impact), "</strong>: ").concat(count, "</li>");
473
+ }).join("\n");
474
+ var d = /* @__PURE__ */ new Date();
475
+ var pad = function(n) {
476
+ return String(n).padStart(2, "0");
477
+ };
478
+ var reportDateTime = "".concat(pad(d.getDate()), "-").concat(pad(d.getMonth() + 1), "-").concat(d.getFullYear(), " ").concat(pad(d.getHours()), ":").concat(pad(d.getMinutes()), ":").concat(pad(d.getSeconds()));
479
+ var headerSummary = '\n <section class="summary">\n <h2>Report summary</h2>\n <ul>\n <li><strong>Date:</strong> '.concat(reportDateTime, "</li>\n <li><strong>Pages audited:</strong> ").concat(summary.pagesAudited, "</li>\n <li><strong>Pages with violations:</strong> ").concat(summary.pagesWithViolations, "</li>\n <li><strong>Total violations:</strong> ").concat(summary.totalViolations, "</li>\n <li><strong>Distinct rules:</strong> ").concat(summary.distinctRules.size, '</li>\n </ul>\n <div class="impact-summary">\n <h3>By impact</h3>\n <ul class="summary-list">\n ').concat(impactSummary || "<li>None</li>", "\n </ul>\n </div>\n </section>\n ").trim();
480
+ var html = '\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8"/>\n <title>Aria-Ease Accessibility Audit Report</title>\n <meta name="viewport" content="width=device-width, initial-scale=1"/>\n <style>\n :root{\n --bg:#ffffff; --muted:#6b7280; --border:#e6e9ee;\n --impact-critical: red; --impact-moderate:#fff4dd; --impact-serious:rgb(255, 123, 0);\n }\n body{font-family:Inter,ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial; background:var(--bg); color:#111827; padding:24px; line-height:1.4}\n h1{margin:0 0 8px}\n .summary{background:#f8fafc;border:1px solid var(--border);padding:12px 16px;border-radius:8px;margin-bottom:18px}\n .summary ul{margin:6px 0 0 0;padding:0 18px}\n .impact-summary h3{margin:12px 0 6px}\n table{width:100%; border-collapse:collapse; margin-top:12px}\n th,td{border:1px solid var(--border); padding:10px; text-align:left; vertical-align:top}\n th{background:#f3f4f6; font-weight:600; position:sticky; top:0; z-index:1}\n .nowrap{white-space:nowrap}\n .target code{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace; white-space:pre-wrap}\n .desc{max-width:380px}\n tr:nth-child(even){background:#fbfbfb}\n td.fail{color:#7b1e1e}\n .impact.critical{background:var(--impact-critical); font-weight:600}\n .impact.moderate{background:var(--impact-moderate); font-weight:600}\n .impact.serious{background:var(--impact-serious); font-weight:600}\n @media (max-width:900px){\n .desc{max-width:200px}\n table, thead, tbody, th, td, tr{display:block}\n thead{display:none}\n tr{margin-bottom:10px; border: 1px solid var(--border);}\n td{border:1px solid var(--border); padding:6px}\n td::before{font-weight:600; display:inline-block; width:120px}\n }\n .summary-list strong,\n .summary-list li {\n padding: 2px 4px;\n }\n </style>\n </head>\n <body>\n <h1>Aria-Ease Accessibility Audit Report</h1>\n '.concat(headerSummary, "\n <table>\n <thead>\n <tr>\n <th>URL</th><th>Rule</th><th>Impact</th><th>Description</th><th>Target</th><th>FailureSummary</th>\n </tr>\n </thead>\n <tbody>\n ").concat(rows.join("\n") || '<tr><td colspan="6"><em>No violations found.</em></td></tr>', "\n </tbody>\n </table>\n </body>\n </html>\n ").trim();
481
+ return html;
482
+ }
483
+ function escapeHTML(str) {
484
+ return String(str !== null && str !== void 0 ? str : "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
485
+ }
486
+ function escapeClass(s) {
487
+ return String(s !== null && s !== void 0 ? s : "").toLowerCase().replace(/[^a-z0-9]+/g, "-");
488
+ }
392
489
  // bin/audit-cli.ts
393
490
  var program = new Command();
394
- program.name("aria-ease").description("Run accessibility audits").version("2.0.4");
395
- program.command("audit").description("Run accessibility audit").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv", "csv").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports").action(function(opts) {
491
+ program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
492
+ program.command("audit").description("Run axe-core powered accessibility audit on webpages").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv | html", "all").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports/audit").action(function(opts) {
396
493
  return _async_to_generator(function() {
397
- var _urls, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err, err1, hasResults, formatted, out, timestamp, fileName, filePath;
494
+ var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err, err1, hasResults;
495
+ function createReport(format2) {
496
+ return _async_to_generator(function() {
497
+ var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
498
+ return _ts_generator(this, function(_state) {
499
+ switch(_state.label){
500
+ case 0:
501
+ formatted = formatResults(allResults, format2);
502
+ out = ((_config_audit = config.audit) === null || _config_audit === void 0 ? void 0 : _config_audit.output) && config.audit.output.out || opts.audit.out;
503
+ return [
504
+ 4,
505
+ fs.ensureDir(out)
506
+ ];
507
+ case 1:
508
+ _state.sent();
509
+ d = /* @__PURE__ */ new Date();
510
+ pad = function(n) {
511
+ return String(n).padStart(2, "0");
512
+ };
513
+ timestamp = "".concat(pad(d.getDate()), "-").concat(pad(d.getMonth() + 1), "-").concat(d.getFullYear(), " ").concat(pad(d.getHours()), ":").concat(pad(d.getMinutes()), ":").concat(pad(d.getSeconds()));
514
+ fileName = "ariaease-report-".concat(timestamp, ".").concat(format2);
515
+ filePath = path.join(out, fileName);
516
+ return [
517
+ 4,
518
+ fs.writeFile(filePath, formatted, "utf-8")
519
+ ];
520
+ case 2:
521
+ _state.sent();
522
+ console.log(chalk.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
523
+ return [
524
+ 2
525
+ ];
526
+ }
527
+ });
528
+ })();
529
+ }
398
530
  return _ts_generator(this, function(_state) {
399
531
  switch(_state.label){
400
532
  case 0:
@@ -439,14 +571,16 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
439
571
  _state.label = 6;
440
572
  case 6:
441
573
  urls = [];
442
- if (opts.url) urls.push(opts.url);
443
- if (config.urls && Array.isArray(config.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.urls));
444
- format = config.output && config.output.format || opts.format;
574
+ if ((_opts_audit = opts.audit) === null || _opts_audit === void 0 ? void 0 : _opts_audit.url) urls.push(opts.audit.url);
575
+ if (((_config_audit = config.audit) === null || _config_audit === void 0 ? void 0 : _config_audit.urls) && Array.isArray(config.audit.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.audit.urls));
576
+ format = ((_config_audit1 = config.audit) === null || _config_audit1 === void 0 ? void 0 : _config_audit1.output) && config.audit.output.format || ((_opts_audit1 = opts.audit) === null || _opts_audit1 === void 0 ? void 0 : _opts_audit1.format);
445
577
  if (![
446
578
  "json",
447
- "csv"
579
+ "csv",
580
+ "html",
581
+ "all"
448
582
  ].includes(format)) {
449
- console.log(chalk.red('\u274C Invalid format. Use "json" or "csv".'));
583
+ console.log(chalk.red('\u274C Invalid format. Use "json", "csv", "html" or "all".'));
450
584
  process.exit(1);
451
585
  }
452
586
  if (urls.length === 0) {
@@ -542,24 +676,21 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
542
676
  console.log(chalk.red("\u274C No audit report generated"));
543
677
  process.exit(1);
544
678
  }
545
- formatted = formatResults(allResults, format);
546
- out = config.output && config.output.out || opts.out;
547
- return [
548
- 4,
549
- fs.ensureDir(out)
550
- ];
551
- case 17:
552
- _state.sent();
553
- timestamp = /* @__PURE__ */ new Date().toISOString().replace(/[:.]/g, "-");
554
- fileName = "ariaease-report-".concat(timestamp, ".").concat(format);
555
- filePath = path.join(out, fileName);
556
- return [
557
- 4,
558
- fs.writeFile(filePath, formatted, "utf-8")
559
- ];
560
- case 18:
561
- _state.sent();
562
- console.log(chalk.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
679
+ if ([
680
+ "json",
681
+ "csv",
682
+ "html"
683
+ ].includes(format)) {
684
+ createReport(format);
685
+ } else if (format === "all") {
686
+ [
687
+ "json",
688
+ "csv",
689
+ "html"
690
+ ].map(function(format2) {
691
+ createReport(format2);
692
+ });
693
+ }
563
694
  console.log(chalk.green("\n\uD83C\uDF89 All audits completed."));
564
695
  return [
565
696
  2
@@ -568,6 +699,9 @@ program.command("audit").description("Run accessibility audit").option("-u, --ur
568
699
  });
569
700
  })();
570
701
  });
702
+ program.command("test").description("Run core a11y accessibility standard tests on UI components").option("-f, --format <format>", "Output format for the test report: json | csv | html", "html").option("-o, --out <path>", "Directory to save the test report", "./accessibility-reports/test").action(function() {
703
+ console.log("Coming soon");
704
+ });
571
705
  program.command("help").description("Display help information").action(function() {
572
706
  program.outputHelp();
573
707
  });
package/bin/audit-cli.ts CHANGED
@@ -10,13 +10,13 @@ import { formatResults } from "src/utils/audit/formatters";
10
10
 
11
11
  const program = new Command();
12
12
 
13
- program.name('aria-ease').description('Run accessibility audits').version('2.0.4');
13
+ program.name('aria-ease').description('Run accessibility tests and audits').version('2.1.1');
14
14
 
15
15
  program.command('audit')
16
- .description('Run accessibility audit')
16
+ .description('Run axe-core powered accessibility audit on webpages')
17
17
  .option('-u, --url <url>', 'Single URL to audit')
18
- .option('-f, --format <format>', 'Output format for the audit report: json | csv', 'csv')
19
- .option('-o, --out <path>', 'Directory to save the audit report', './accessibility-reports')
18
+ .option('-f, --format <format>', 'Output format for the audit report: json | csv | html', 'all')
19
+ .option('-o, --out <path>', 'Directory to save the audit report', './accessibility-reports/audit')
20
20
  .action(async (opts) => {
21
21
  console.log(chalk.cyanBright('🚀 Starting accessibility audit...\n'));
22
22
 
@@ -30,12 +30,12 @@ program.command('audit')
30
30
  }
31
31
 
32
32
  const urls: string[] = [];
33
- if(opts.url) urls.push(opts.url);
34
- if(config.urls && Array.isArray(config.urls)) urls.push(...config.urls);
33
+ if(opts.audit?.url) urls.push(opts.audit.url);
34
+ if(config.audit?.urls && Array.isArray(config.audit.urls)) urls.push(...config.audit.urls);
35
35
 
36
- const format: string = (config.output && (config.output as { format?: string }).format) || opts.format;
37
- if(!['json', 'csv'].includes(format)) {
38
- console.log(chalk.red('❌ Invalid format. Use "json" or "csv".'));
36
+ const format: string = (config.audit?.output && (config.audit.output as { format?: string }).format) || opts.audit?.format;
37
+ if(!['json', 'csv', 'html', 'all'].includes(format)) {
38
+ console.log(chalk.red('❌ Invalid format. Use "json", "csv", "html" or "all".'));
39
39
  process.exit(1);
40
40
  }
41
41
 
@@ -64,21 +64,41 @@ program.command('audit')
64
64
  process.exit(1);
65
65
  }
66
66
 
67
- const formatted = formatResults(allResults, format);
67
+ async function createReport(format: string) {
68
+ const formatted = formatResults(allResults, format);
68
69
 
69
- const out = (config.output && (config.output as { out?: string }).out) || opts.out;
70
+ const out = (config.audit?.output && (config.audit.output as { out?: string }).out) || opts.audit.out;
70
71
 
71
- await fs.ensureDir(out);
72
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
73
- const fileName = `ariaease-report-${timestamp}.${format}`;
74
- const filePath = path.join(out, fileName);
72
+ await fs.ensureDir(out);
73
+ const d = new Date();
74
+ const pad = (n: number) => String(n).padStart(2, '0');
75
+ const timestamp = `${pad(d.getDate())}-${pad(d.getMonth() + 1)}-${d.getFullYear()} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
76
+ const fileName = `ariaease-report-${timestamp}.${format}`;
77
+ const filePath = path.join(out, fileName);
75
78
 
76
- await fs.writeFile(filePath, formatted, 'utf-8');
77
- console.log(chalk.magentaBright(`📁 Report saved to ${filePath}`));
79
+ await fs.writeFile(filePath, formatted, 'utf-8');
80
+ console.log(chalk.magentaBright(`📁 Report saved to ${filePath}`));
81
+ }
82
+
83
+ if(['json', 'csv', 'html'].includes(format)) {
84
+ createReport(format);
85
+ } else if(format === 'all') {
86
+ ['json', 'csv', 'html'].map((format) => {
87
+ createReport(format);
88
+ })
89
+ }
78
90
 
79
91
  console.log(chalk.green('\n🎉 All audits completed.'));
80
92
  })
81
93
 
94
+ program.command('test')
95
+ .description('Run core a11y accessibility standard tests on UI components')
96
+ .option('-f, --format <format>', 'Output format for the test report: json | csv | html', 'html')
97
+ .option('-o, --out <path>', 'Directory to save the test report', './accessibility-reports/test')
98
+ .action(() => {
99
+ console.log('Coming soon')
100
+ })
101
+
82
102
  program.command('help')
83
103
  .description('Display help information')
84
104
  .action(() => {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-5HQ6LLC5.js","../src/radio/src/updateRadioAriaAttributes/updateRadioAriaAttributes.ts"],"names":["updateRadioAriaAttributes","radioId","radiosClass","radioStates","currentPressedRadioIndex","radioDiv","document","querySelector","Error","radioItems","Array","from","querySelectorAll","length","forEach","radioItem","index","state","checked","getAttribute","shouldBeChecked","setAttribute"],"mappings":"AAAA,uEAAuE;ACUhE,SAASA,0BAA0BC,OAAA,EAAiBC,WAAA,EAAqBC,WAAA,EAA4BC,wBAAA;QAClGC,WAA+BC,SAASC,aAAA,CAAc,IAAW,CAAA,CAAA,CAAA,CAAA,CAAPN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,CAAA;wEACvE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAU;gJACX,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;wEACpB;QAEMC,aAA4BC,MAAMC,IAAA,CAAKN,SAASO,gBAAA,CAAiB,IAAIV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAXA,CAAAA;wEAC3E,CAAA,CAAA,CAAA,CAAGO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,C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AAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;gJAClG,GAAA,CAAIA,GAAAA,CAAAA,GAAAA,CAAAA,GAAWA,CAAAA,GAAAA,CAAAA,GAAAA,CAAAA,GAAYE,CAAAA,IAAAA,IAAAA,IAAAA,IAAiB;wNACxCL,GAAAA,CAAAA,CAAAA,IAAAA,CAAUM,CAAAA,IAAAA,CAAAA,CAAAA,IAAAA,CAAA,CAAa,IAAA,MAAA,MAAgBD;gJAC3C;wEACJ;AACJ","sourcesContent":["// src/radio/src/updateRadioAriaAttributes/updateRadioAriaAttributes.ts\nfunction updateRadioAriaAttributes(radioId, radiosClass, radioStates, currentPressedRadioIndex) {\n const radioDiv = document.querySelector(`#${radioId}`);\n if (!radioDiv) {\n throw new Error(\"Invalid radio main div id provided.\");\n }\n const radioItems = Array.from(radioDiv.querySelectorAll(`.${radiosClass}`));\n if (radioItems.length === 0) {\n throw new Error(\"Invalid radios shared class provided.\");\n }\n radioItems.forEach((radioItem, index) => {\n const state = radioStates[index];\n const checked = radioItem.getAttribute(\"aria-checked\");\n const shouldBeChecked = index === currentPressedRadioIndex ? state.checked ? \"true\" : \"false\" : \"false\";\n if (checked && checked !== shouldBeChecked) {\n radioItem.setAttribute(\"aria-checked\", shouldBeChecked);\n }\n });\n}\n\nexport { updateRadioAriaAttributes };\n//# sourceMappingURL=chunk-5HQ6LLC5.js.map\n","/**\n * Adds screen reader accessibility to multiple radio buttons. Updates the aria attributes of the radio buttons. Radio elements must possess the following aria attributes; aria-checked and aria-label.\n * @param {string} radioId The id of the radio parent container.\n * @param {string} radiosClass The shared class of all the radios.\n * @param {RadioStates[]} radioStates Array of objects containing radio buttons state information.\n * @param {number} currentPressedRadioIndex Index of the currently checked or unchecked radio button.\n */\n\nimport { HTMLElement, RadioStates } from \"../../../../Types\";\n\nexport function updateRadioAriaAttributes(radioId: string, radiosClass: string, radioStates: RadioStates[], currentPressedRadioIndex: number): void {\n const radioDiv: HTMLElement | null = document.querySelector(`#${radioId}`);\n if (!radioDiv) {\n throw new Error(\"Invalid radio main div id provided.\");\n }\n \n const radioItems: HTMLElement[] = Array.from(radioDiv.querySelectorAll(`.${radiosClass}`));\n if(radioItems.length === 0) {\n throw new Error('Invalid radios shared class provided.');\n }\n\n radioItems.forEach((radioItem: HTMLElement, index: number) => {\n const state = radioStates[index];\n const checked = radioItem.getAttribute(\"aria-checked\");\n const shouldBeChecked = index === currentPressedRadioIndex ? (state.checked ? \"true\" : \"false\") : \"false\";\n if (checked && checked !== shouldBeChecked) {\n radioItem.setAttribute(\"aria-checked\", shouldBeChecked);\n }\n });\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-5HQ6LLC5.js","../src/radio/src/updateRadioAriaAttributes/updateRadioAriaAttributes.ts"],"names":["updateRadioAriaAttributes","radioId","radiosClass","radioStates","currentPressedRadioIndex","radioDiv","document","querySelector","Error","radioItems","Array","from","querySelectorAll","length","forEach","radioItem","index","state","checked","getAttribute","shouldBeChecked","setAttribute"],"mappings":"AAAA,uEAAuE;ACUhE,SAASA,0BAA0BC,OAAA,EAAiBC,WAAA,EAAqBC,WAAA,EAA4BC,wBAAA;QAClGC,WAA+BC,SAASC,aAAA,CAAc,IAAIN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAPA;gGAChE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAU;gMACX,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gGACpB;QAEMC,aAA4BC,MAAMC,IAAA,CAAKN,SAASO,gBAAA,CAAiB,IAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAXV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA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AA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA4Ba,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;gMAClG,GAAA,CAAIA,GAAAA,CAAAA,GAAAA,CAAAA,GAAWA,CAAAA,GAAAA,CAAAA,GAAAA,CAAAA,GAAYE,CAAAA,IAAAA,IAAAA,IAAAA,IAAiB;gSACxCL,GAAAA,CAAAA,CAAAA,IAAAA,CAAUM,CAAAA,IAAAA,CAAAA,CAAAA,IAAAA,CAAA,CAAa,IAAA,MAAA,MAAgBD;gMAC3C;gGACJ;AACJ","sourcesContent":["// src/radio/src/updateRadioAriaAttributes/updateRadioAriaAttributes.ts\nfunction updateRadioAriaAttributes(radioId, radiosClass, radioStates, currentPressedRadioIndex) {\n const radioDiv = document.querySelector(`#${radioId}`);\n if (!radioDiv) {\n throw new Error(\"Invalid radio main div id provided.\");\n }\n const radioItems = Array.from(radioDiv.querySelectorAll(`.${radiosClass}`));\n if (radioItems.length === 0) {\n throw new Error(\"Invalid radios shared class provided.\");\n }\n radioItems.forEach((radioItem, index) => {\n const state = radioStates[index];\n const checked = radioItem.getAttribute(\"aria-checked\");\n const shouldBeChecked = index === currentPressedRadioIndex ? state.checked ? \"true\" : \"false\" : \"false\";\n if (checked && checked !== shouldBeChecked) {\n radioItem.setAttribute(\"aria-checked\", shouldBeChecked);\n }\n });\n}\n\nexport { updateRadioAriaAttributes };\n//# sourceMappingURL=chunk-5HQ6LLC5.js.map\n","/**\n * Adds screen reader accessibility to multiple radio buttons. Updates the aria attributes of the radio buttons. Radio elements must possess the following aria attributes; aria-checked and aria-label.\n * @param {string} radioId The id of the radio parent container.\n * @param {string} radiosClass The shared class of all the radios.\n * @param {RadioStates[]} radioStates Array of objects containing radio buttons state information.\n * @param {number} currentPressedRadioIndex Index of the currently checked or unchecked radio button.\n */\n\nimport { HTMLElement, RadioStates } from \"../../../../Types\";\n\nexport function updateRadioAriaAttributes(radioId: string, radiosClass: string, radioStates: RadioStates[], currentPressedRadioIndex: number): void {\n const radioDiv: HTMLElement | null = document.querySelector(`#${radioId}`);\n if (!radioDiv) {\n throw new Error(\"Invalid radio main div id provided.\");\n }\n \n const radioItems: HTMLElement[] = Array.from(radioDiv.querySelectorAll(`.${radiosClass}`));\n if(radioItems.length === 0) {\n throw new Error('Invalid radios shared class provided.');\n }\n\n radioItems.forEach((radioItem: HTMLElement, index: number) => {\n const state = radioStates[index];\n const checked = radioItem.getAttribute(\"aria-checked\");\n const shouldBeChecked = index === currentPressedRadioIndex ? (state.checked ? \"true\" : \"false\") : \"false\";\n if (checked && checked !== shouldBeChecked) {\n radioItem.setAttribute(\"aria-checked\", shouldBeChecked);\n }\n });\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-FBQ5LF2T.js","../src/toggle/src/updateToggleAriaAttribute/updateToggleAriaAttribute.ts"],"names":["updateToggleAriaAttribute","toggleId","togglesClass","toggleStates","currentPressedToggleIndex","toggleDiv","document","querySelector","Error","toggleItems","Array","from","querySelectorAll","length","forEach","toggle","index","setAttribute","pressed"],"mappings":"AAAA,wEAAwE;ACUjE,SAASA,0BAA0BC,QAAA,EAAkBC,YAAA,EAAsBC,YAAA,EAA8BC,yBAAA;QACxGC,YAAgCC,SAASC,aAAA,CAAc,IAAY,CAAA,CAAA,CAAA,CAAA,CAARN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQ,CAAA;wEACzE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAW;gJACd,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;wEAClB;QAEMC,cAA6BC,MA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AA,GAAU,GAAA,MAAS;gJAC7E;wEACF;AACF","sourcesContent":["// src/toggle/src/updateToggleAriaAttribute/updateToggleAriaAttribute.ts\nfunction updateToggleAriaAttribute(toggleId, togglesClass, toggleStates, currentPressedToggleIndex) {\n const toggleDiv = document.querySelector(`#${toggleId}`);\n if (!toggleDiv) {\n throw new Error(\"Invalid toggle main div id provided.\");\n }\n const toggleItems = Array.from(toggleDiv.querySelectorAll(`.${togglesClass}`));\n if (toggleItems.length === 0) {\n throw new Error(\"Invalid toggles shared class provided.\");\n }\n if (toggleItems.length !== toggleStates.length) {\n throw new Error(`Toggle state/DOM length mismatch: found ${toggleItems.length} triggers, but got ${toggleStates.length} state objects.`);\n }\n toggleItems.forEach((toggle, index) => {\n if (index === currentPressedToggleIndex) {\n toggle.setAttribute(\"aria-pressed\", toggleStates[index].pressed ? \"true\" : \"false\");\n }\n });\n}\n\nexport { updateToggleAriaAttribute };\n//# sourceMappingURL=chunk-FBQ5LF2T.js.map\n","/**\n * Adds screen reader accessibility to toggle buttons. Updates the aria attributes of the toggle buttons. Button must be a semantic button element or a non-semantic element with a role of button, and possess the aria-pressed attribute.\n * @param {string} toggleId The id of the toggle buttons parent container.\n * @param {string} togglesClass The shared class of all the toggle buttons.\n * @param {ToggleStates[]} toggleStates Array of objects containing toggle buttons state information.\n * @param {number} currentPressedToggleIndex Index of the currently pressed or unpressed toggle button.\n*/\n\nimport { HTMLElement, ToggleStates } from \"../../../../Types\";\n\nexport function updateToggleAriaAttribute(toggleId: string, togglesClass: string, toggleStates: ToggleStates[], currentPressedToggleIndex: number): void {\n const toggleDiv: HTMLElement | null = document.querySelector(`#${toggleId}`);\n if (!toggleDiv) {\n throw new Error(\"Invalid toggle main div id provided.\");\n }\n\n const toggleItems: HTMLElement[] = Array.from(toggleDiv.querySelectorAll(`.${togglesClass}`));\n if (toggleItems.length === 0) {\n throw new Error('Invalid toggles shared class provided.');\n }\n\n if(toggleItems.length !== toggleStates.length) {\n throw new Error(`Toggle state/DOM length mismatch: found ${toggleItems.length} triggers, but got ${toggleStates.length} state objects.`);\n }\n\n toggleItems.forEach((toggle, index) => {\n if (index === currentPressedToggleIndex) {\n toggle.setAttribute(\"aria-pressed\", toggleStates[index].pressed ? 'true' : 'false');\n }\n });\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-FBQ5LF2T.js","../src/toggle/src/updateToggleAriaAttribute/updateToggleAriaAttribute.ts"],"names":["updateToggleAriaAttribute","toggleId","togglesClass","toggleStates","currentPressedToggleIndex","toggleDiv","document","querySelector","Error","toggleItems","Array","from","querySelectorAll","length","forEach","toggle","index","setAttribute","pressed"],"mappings":"AAAA,wEAAwE;ACUjE,SAASA,0BAA0BC,QAAA,EAAkBC,YAAA,EAAsBC,YAAA,EAA8BC,yBAAA;QACxGC,YAAgCC,SAASC,aAAA,CAAc,IAAIN,CAAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAARA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;gGACjE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAW;gMACd,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gGAClB;QAEMC,cAA6BC,MAAMC,IAAA,CAAKN,UAAUO,gBAAA,CAAiB,IAAIV,CAAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAZA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;gGAC7E,CAAA,CAAA,CAAA,CAAIO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAYI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,EAAG;gMAC5B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;gGA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IAAAA,IAAAA,IAAAA,IAA2B;gSACvCW,CAAAA,CAAAA,CAAAA,GAAAA,CAAOE,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAA,CAAa,CAAA,GAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,GAAgBd,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,GAAA,CAAaa,CAAAA,CAAAA,GAAAA,CAAK,CAAEE,CAAAA,GAAAA,GAAA,GAAU,GAAA,MAAS;gMAC7E;gGACF;AACF","sourcesContent":["// src/toggle/src/updateToggleAriaAttribute/updateToggleAriaAttribute.ts\nfunction updateToggleAriaAttribute(toggleId, togglesClass, toggleStates, currentPressedToggleIndex) {\n const toggleDiv = document.querySelector(`#${toggleId}`);\n if (!toggleDiv) {\n throw new Error(\"Invalid toggle main div id provided.\");\n }\n const toggleItems = Array.from(toggleDiv.querySelectorAll(`.${togglesClass}`));\n if (toggleItems.length === 0) {\n throw new Error(\"Invalid toggles shared class provided.\");\n }\n if (toggleItems.length !== toggleStates.length) {\n throw new Error(`Toggle state/DOM length mismatch: found ${toggleItems.length} triggers, but got ${toggleStates.length} state objects.`);\n }\n toggleItems.forEach((toggle, index) => {\n if (index === currentPressedToggleIndex) {\n toggle.setAttribute(\"aria-pressed\", toggleStates[index].pressed ? \"true\" : \"false\");\n }\n });\n}\n\nexport { updateToggleAriaAttribute };\n//# sourceMappingURL=chunk-FBQ5LF2T.js.map\n","/**\n * Adds screen reader accessibility to toggle buttons. Updates the aria attributes of the toggle buttons. Button must be a semantic button element or a non-semantic element with a role of button, and possess the aria-pressed attribute.\n * @param {string} toggleId The id of the toggle buttons parent container.\n * @param {string} togglesClass The shared class of all the toggle buttons.\n * @param {ToggleStates[]} toggleStates Array of objects containing toggle buttons state information.\n * @param {number} currentPressedToggleIndex Index of the currently pressed or unpressed toggle button.\n*/\n\nimport { HTMLElement, ToggleStates } from \"../../../../Types\";\n\nexport function updateToggleAriaAttribute(toggleId: string, togglesClass: string, toggleStates: ToggleStates[], currentPressedToggleIndex: number): void {\n const toggleDiv: HTMLElement | null = document.querySelector(`#${toggleId}`);\n if (!toggleDiv) {\n throw new Error(\"Invalid toggle main div id provided.\");\n }\n\n const toggleItems: HTMLElement[] = Array.from(toggleDiv.querySelectorAll(`.${togglesClass}`));\n if (toggleItems.length === 0) {\n throw new Error('Invalid toggles shared class provided.');\n }\n\n if(toggleItems.length !== toggleStates.length) {\n throw new Error(`Toggle state/DOM length mismatch: found ${toggleItems.length} triggers, but got ${toggleStates.length} state objects.`);\n }\n\n toggleItems.forEach((toggle, index) => {\n if (index === currentPressedToggleIndex) {\n toggle.setAttribute(\"aria-pressed\", toggleStates[index].pressed ? 'true' : 'false');\n }\n });\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-KVTLMA4J.js","../src/menu/src/makeMenuAccessible/makeMenuAccessible.ts"],"names":["handleKeyPress","menuElementsClass","menuDiv","document","querySelector","menuId","Error","triggerButton","triggerId","handlerMap","Map","setAria","isOpen","setAttribute","addListeners","querySelectorAll","menuItems","forEach","menuItem","index","has"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAsB;QCURC,CAAAA,QAAAA,MAAAA,CAAAA,IAAAA,KAAAA,EAAAA,MAAAA,YAAAA,GAAAA;QAAAA,CAAAA,QAAAA,MAAAA,CAAAA,IAAAA,KAAAA,EAAAA,MAAAA,YAAAA;QAAAA,SAAAA,MAAAA,CAAAA,OAAAA,oBAAAA,MAAAA,aAAAA,MAAAA,YAAAA;QACrCC,UAAUC,SAASC,aAAA,CAAc,IAAU,OAANC;wEAC3C,CAAA,CAAA,CAAA,CAAI,CAACH,CAAAA,EAAAA,EAAAA,EAAAA,EAAS,EAAA,EAAA,EAAM,EAAA,EAAII,EAAAA,EAAAA,EAAM;QAExBC,gBAAgBJ,SAASC,aAAA,CAAc,IAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CA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essible/makeMenuAccessible.ts\nfunction makeMenuAccessible({ menuId, menuElementsClass, triggerId }) {\n const menuDiv = document.querySelector(`#${menuId}`);\n if (!menuDiv) throw new Error(\"Invalid menu div id provided\");\n const triggerButton = document.querySelector(`#${triggerId}`);\n if (!triggerButton) throw new Error(\"Invalid trigger button id provided\");\n const handlerMap = /* @__PURE__ */ new Map();\n function setAria(isOpen) {\n triggerButton.setAttribute(\"aria-expanded\", isOpen ? \"true\" : \"false\");\n }\n function addListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n menuItems.forEach((menuItem, index) => {\n if (!handlerMap.has(menuItem)) {\n const handler = (event) => handleKeyPress(event, menuItems, index, menuDiv, triggerButton);\n menuItem.addEventListener(\"keydown\", handler);\n handlerMap.set(menuItem, handler);\n }\n });\n }\n function removeListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n menuItems.forEach((menuItem) => {\n const handler = handlerMap.get(menuItem);\n if (handler) {\n menuItem.removeEventListener(\"keydown\", handler);\n handlerMap.delete(menuItem);\n }\n });\n }\n function openMenu() {\n menuDiv.style.display = \"block\";\n setAria(true);\n addListeners();\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n if (menuItems.length > 0) menuItems[0].focus();\n }\n function closeMenu() {\n removeListeners();\n menuDiv.style.display = \"none\";\n setAria(false);\n triggerButton.focus();\n }\n function cleanup() {\n removeListeners();\n }\n return { openMenu, closeMenu, cleanup };\n}\n\nexport { makeMenuAccessible };\n//# sourceMappingURL=chunk-KVTLMA4J.js.map\n","/**\n * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.\n * @param {string} menuId - The id of the menu.\n * @param {string} menuElementsClass - The class of the items that are children of the menu.\n * @param {string} triggerId - The id of the button that triggers the menu.\n*/\n\nimport { handleKeyPress } from \"../../../utils/handleKeyPress/handleKeyPress\";\nimport { NodeListOfHTMLElement } from \"../../../../Types\";\n\nexport function makeMenuAccessible({ menuId, menuElementsClass, triggerId }: {menuId: string; menuElementsClass: string; triggerId: string;}) {\n const menuDiv = document.querySelector(`#${menuId}`) as HTMLElement;\n if (!menuDiv) throw new Error(\"Invalid menu div id provided\");\n\n const triggerButton = document.querySelector(`#${triggerId}`) as HTMLElement;\n if (!triggerButton) throw new Error(\"Invalid trigger button id provided\");\n\n\n const handlerMap = new Map<HTMLElement, (event: KeyboardEvent) => void>();\n\n function setAria(isOpen: boolean) {\n triggerButton.setAttribute(\"aria-expanded\", isOpen ? \"true\" : \"false\");\n }\n\n function addListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n menuItems.forEach((menuItem: HTMLElement, index: number) => {\n if (!handlerMap.has(menuItem)) {\n const handler = (event: KeyboardEvent) => handleKeyPress(event, menuItems, index, menuDiv, triggerButton);\n menuItem.addEventListener(\"keydown\", handler);\n handlerMap.set(menuItem, handler);\n }\n });\n }\n\n function removeListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n menuItems.forEach((menuItem: HTMLElement) => {\n const handler = handlerMap.get(menuItem);\n if (handler) {\n menuItem.removeEventListener(\"keydown\", handler);\n handlerMap.delete(menuItem);\n }\n });\n }\n\n function openMenu() {\n menuDiv.style.display = \"block\";\n setAria(true);\n addListeners();\n \n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n if (menuItems.length > 0) menuItems[0].focus();\n }\n\n function closeMenu() {\n removeListeners();\n menuDiv.style.display = \"none\";\n setAria(false);\n triggerButton.focus();\n }\n\n function cleanup() {\n removeListeners();\n }\n\n return { openMenu, closeMenu, cleanup };\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-KVTLMA4J.js","../src/menu/src/makeMenuAccessible/makeMenuAccessible.ts"],"names":["handleKeyPress","menuElementsClass","menuDiv","document","querySelector","menuId","Error","triggerButton","triggerId","handlerMap","Map","setAria","isOpen","setAttribute","addListeners","menuItems","querySelectorAll","forEach","menuItem","index","has"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAsB;QCURC,CAAAA,QAAAA,MAAAA,CAAAA,IAAAA,KAAAA,EAAAA,MAAAA,YAAAA,GAAAA;QAAAA,CAAAA,QAAAA,MAAAA,CAAAA,IAAAA,KAAAA,EAAAA,MAAAA,YAAAA;QAAAA,SAAAA,MAAAA,CAAAA,OAAAA,oBAAAA,MAAAA,aAAAA,MAAAA,YAAAA;QACrCC,UAAUC,SAASC,aAAA,CAAc,IAAU,OAANC;gGAC3C,CAAA,CAAA,CAAA,CAAI,CAACH,CAAAA,EAAAA,EAAAA,EAAAA,EAAS,EAAA,EAAA,EAAM,EAAA,EAAII,EAAAA,EAAAA,EAAM;QAExBC,gBAAgBJ,SAASC,aAAA,CAAc,IAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAATI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS;gGAC1D,CAAA,CAAA,CAAA,CAAI,CAACD,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAe,EAAA,EAAA,EAAM,EAAA,EAAID,EAAAA,EAAAA,EAAM;QAG9BG,aAAA,aAAA,GAAA,IAAiBC;gGAEvB,CAAA,EAAA,EAAA,EAAA,EAASC,EAAAA,EAAAA,EAAAA,EAAQC,EAAAA,EAAAA,EAAA;gMACfL,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAa,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAiBD,CAAAA,CAAAA,GAAAA,CAAAA,GAAS,CAAA,IAAA,IAAS;gGAChE;gGAEA,CAAA,EAAA,EAAA,EAAA,EAASE;qDACDC,CAAoBC,CAARd,CAAyB,CAAzBA,CAA6BD,CAArBe,CAApBD,CAAoBC,CAApBD,CAAoBC,CAARd,CAAyB,CAAjBc,CAAsC,CAAtCA,CAApBD,CAAoBC,CAApBD,CAAqC,CAAzBb,CAA6BD,CAArBe,CAApBD,CAAoBC;ghBAC1BD,CAAAA,CAAAA,OAAAA,EAAAA,EAAAA,CAAAA,OAAAA,EAAAA,EAAAA,CAAUE,OAAAA,EAAAA,EAAAA,CAAAA,OAAAA,EAAAA,EAAA,CAAQ,OAAA,EAACC,UAAuBC;gSACxC,CAAA,CAAA,EAAI,CAACV,EAAAA,CAAAA,EAAAA,GAAAA,CAAAA,EAAWW,GAAA,CAAIF,KAAAA,MAAW","sourcesContent":["import { handleKeyPress } from './chunk-RT5IROW4.js';\n\n// src/menu/src/makeMenuAccessible/makeMenuAccessible.ts\nfunction makeMenuAccessible({ menuId, menuElementsClass, triggerId }) {\n const menuDiv = document.querySelector(`#${menuId}`);\n if (!menuDiv) throw new Error(\"Invalid menu div id provided\");\n const triggerButton = document.querySelector(`#${triggerId}`);\n if (!triggerButton) throw new Error(\"Invalid trigger button id provided\");\n const handlerMap = /* @__PURE__ */ new Map();\n function setAria(isOpen) {\n triggerButton.setAttribute(\"aria-expanded\", isOpen ? \"true\" : \"false\");\n }\n function addListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n menuItems.forEach((menuItem, index) => {\n if (!handlerMap.has(menuItem)) {\n const handler = (event) => handleKeyPress(event, menuItems, index, menuDiv, triggerButton);\n menuItem.addEventListener(\"keydown\", handler);\n handlerMap.set(menuItem, handler);\n }\n });\n }\n function removeListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n menuItems.forEach((menuItem) => {\n const handler = handlerMap.get(menuItem);\n if (handler) {\n menuItem.removeEventListener(\"keydown\", handler);\n handlerMap.delete(menuItem);\n }\n });\n }\n function openMenu() {\n menuDiv.style.display = \"block\";\n setAria(true);\n addListeners();\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`);\n if (menuItems.length > 0) menuItems[0].focus();\n }\n function closeMenu() {\n removeListeners();\n menuDiv.style.display = \"none\";\n setAria(false);\n triggerButton.focus();\n }\n function cleanup() {\n removeListeners();\n }\n return { openMenu, closeMenu, cleanup };\n}\n\nexport { makeMenuAccessible };\n//# sourceMappingURL=chunk-KVTLMA4J.js.map\n","/**\n * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.\n * @param {string} menuId - The id of the menu.\n * @param {string} menuElementsClass - The class of the items that are children of the menu.\n * @param {string} triggerId - The id of the button that triggers the menu.\n*/\n\nimport { handleKeyPress } from \"../../../utils/handleKeyPress/handleKeyPress\";\nimport { NodeListOfHTMLElement } from \"../../../../Types\";\n\nexport function makeMenuAccessible({ menuId, menuElementsClass, triggerId }: {menuId: string; menuElementsClass: string; triggerId: string;}) {\n const menuDiv = document.querySelector(`#${menuId}`) as HTMLElement;\n if (!menuDiv) throw new Error(\"Invalid menu div id provided\");\n\n const triggerButton = document.querySelector(`#${triggerId}`) as HTMLElement;\n if (!triggerButton) throw new Error(\"Invalid trigger button id provided\");\n\n\n const handlerMap = new Map<HTMLElement, (event: KeyboardEvent) => void>();\n\n function setAria(isOpen: boolean) {\n triggerButton.setAttribute(\"aria-expanded\", isOpen ? \"true\" : \"false\");\n }\n\n function addListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n menuItems.forEach((menuItem: HTMLElement, index: number) => {\n if (!handlerMap.has(menuItem)) {\n const handler = (event: KeyboardEvent) => handleKeyPress(event, menuItems, index, menuDiv, triggerButton);\n menuItem.addEventListener(\"keydown\", handler);\n handlerMap.set(menuItem, handler);\n }\n });\n }\n\n function removeListeners() {\n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n menuItems.forEach((menuItem: HTMLElement) => {\n const handler = handlerMap.get(menuItem);\n if (handler) {\n menuItem.removeEventListener(\"keydown\", handler);\n handlerMap.delete(menuItem);\n }\n });\n }\n\n function openMenu() {\n menuDiv.style.display = \"block\";\n setAria(true);\n addListeners();\n \n const menuItems = menuDiv.querySelectorAll(`.${menuElementsClass}`) as NodeListOfHTMLElement<HTMLElement>;\n if (menuItems.length > 0) menuItems[0].focus();\n }\n\n function closeMenu() {\n removeListeners();\n menuDiv.style.display = \"none\";\n setAria(false);\n triggerButton.focus();\n }\n\n function cleanup() {\n removeListeners();\n }\n\n return { openMenu, closeMenu, cleanup };\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-MEA5U2G4.js","../src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts"],"names":["updateAccordionTriggerAriaAttributes","accordionId","accordionTriggersClass","accordionStates","clickedTriggerIndex","accordionDiv","document","querySelector","Error","accordionItems","Array","from","querySelectorAll","length","forEach","accordionItem","index","state","expanded","getAttribute","shouldBeExpanded","display","setAttribute"],"mappings":"AAAA,iGAAiG;ACU1F,SAASA,qCAAqCC,WAAA,EAAqBC,sBAAA,EAAgCC,eAAA,EAAoCC,mBAAA;QACpIC,eAAmCC,SAASC,aAAA,CAAc,IAAIN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAXA,CAAAA;wEACpE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAc;gJACf,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;wEACpB;QAEMC,iBAAgCC,MAAMC,IAAA,CAAKN,aAAaO,gBAAA,CAAiB,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A,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAuBa,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAMI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;gJAC9F,CAAA,EAAA,CAAIH,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAYA,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAaE,EAAAA,IAAAA,IAAAA,IAAAA,IAAkB;wNAC3CL,EAAAA,CAAAA,KAAAA,CAAAA,KAAcO,CAAAA,KAAAA,CAAAA,KAAA,CAAa,KAAA,MAAA,MAAiBF;gJAChD;wEACJ;AACJ","sourcesContent":["// src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts\nfunction updateAccordionTriggerAriaAttributes(accordionId, accordionTriggersClass, accordionStates, clickedTriggerIndex) {\n const accordionDiv = document.querySelector(`#${accordionId}`);\n if (!accordionDiv) {\n throw new Error(\"Invalid accordion main div id provided.\");\n }\n const accordionItems = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));\n if (accordionItems.length === 0) {\n throw new Error(\"Invalid accordion items shared class provided.\");\n }\n if (accordionItems.length !== accordionStates.length) {\n throw new Error(`Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.`);\n }\n accordionItems.forEach((accordionItem, index) => {\n const state = accordionStates[index];\n const expanded = accordionItem.getAttribute(\"aria-expanded\");\n const shouldBeExpanded = index === clickedTriggerIndex ? state.display ? \"true\" : \"false\" : \"false\";\n if (expanded && expanded !== shouldBeExpanded) {\n accordionItem.setAttribute(\"aria-expanded\", shouldBeExpanded);\n }\n });\n}\n\nexport { updateAccordionTriggerAriaAttributes };\n//# sourceMappingURL=chunk-MEA5U2G4.js.map\n","/**\n * Adds screen reader accessibility to accordions. Updates the aria attributes of the accordion trigger button. Trigger button element must possess the following aria attributes; aria-expanded, aria-controls, aria-label (for only non-text triggers).\n * @param {string} accordionId The id of the accordion triggers parent container.\n * @param {string} accordionTriggersClass The shared class of all the accordion triggers.\n * @param {AccordionStates[]} accordionStates Array of objects containing accordions state information.\n * @param {number} clickedTriggerIndex Index of the currently clicked accordion trigger within the accordion div container.\n*/\n\nimport { HTMLElement, AccordionStates } from \"../../../../Types\";\n\nexport function updateAccordionTriggerAriaAttributes(accordionId: string, accordionTriggersClass: string, accordionStates: AccordionStates[], clickedTriggerIndex: number): void {\n const accordionDiv: HTMLElement | null = document.querySelector(`#${accordionId}`);\n if (!accordionDiv) {\n throw new Error(\"Invalid accordion main div id provided.\");\n }\n\n const accordionItems: HTMLElement[] = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));\n if (accordionItems.length === 0) {\n throw new Error(\"Invalid accordion items shared class provided.\");\n }\n\n if (accordionItems.length !== accordionStates.length) {\n throw new Error(`Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.`);\n }\n\n accordionItems.forEach((accordionItem: HTMLElement, index: number) => {\n const state = accordionStates[index];\n const expanded = accordionItem.getAttribute(\"aria-expanded\");\n const shouldBeExpanded = index === clickedTriggerIndex ? (state.display ? \"true\" : \"false\") : \"false\";\n if (expanded && expanded !== shouldBeExpanded) {\n accordionItem.setAttribute(\"aria-expanded\", shouldBeExpanded);\n }\n });\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-MEA5U2G4.js","../src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts"],"names":["updateAccordionTriggerAriaAttributes","accordionId","accordionTriggersClass","accordionStates","clickedTriggerIndex","accordionDiv","document","querySelector","Error","accordionItems","Array","from","querySelectorAll","length","forEach","accordionItem","index","state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A,CAAAA,CAAMI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;gMAC9F,CAAA,EAAA,CAAIH,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAYA,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAaE,EAAAA,IAAAA,IAAAA,IAAAA,IAAkB;gSAC3CL,EAAAA,CAAAA,KAAAA,CAAAA,KAAcO,CAAAA,KAAAA,CAAAA,KAAA,CAAa,KAAA,MAAA,MAAiBF;gMAChD;gGACJ;AACJ","sourcesContent":["// src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts\nfunction updateAccordionTriggerAriaAttributes(accordionId, accordionTriggersClass, accordionStates, clickedTriggerIndex) {\n const accordionDiv = document.querySelector(`#${accordionId}`);\n if (!accordionDiv) {\n throw new Error(\"Invalid accordion main div id provided.\");\n }\n const accordionItems = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));\n if (accordionItems.length === 0) {\n throw new Error(\"Invalid accordion items shared class provided.\");\n }\n if (accordionItems.length !== accordionStates.length) {\n throw new Error(`Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.`);\n }\n accordionItems.forEach((accordionItem, index) => {\n const state = accordionStates[index];\n const expanded = accordionItem.getAttribute(\"aria-expanded\");\n const shouldBeExpanded = index === clickedTriggerIndex ? state.display ? \"true\" : \"false\" : \"false\";\n if (expanded && expanded !== shouldBeExpanded) {\n accordionItem.setAttribute(\"aria-expanded\", shouldBeExpanded);\n }\n });\n}\n\nexport { updateAccordionTriggerAriaAttributes };\n//# sourceMappingURL=chunk-MEA5U2G4.js.map\n","/**\n * Adds screen reader accessibility to accordions. Updates the aria attributes of the accordion trigger button. Trigger button element must possess the following aria attributes; aria-expanded, aria-controls, aria-label (for only non-text triggers).\n * @param {string} accordionId The id of the accordion triggers parent container.\n * @param {string} accordionTriggersClass The shared class of all the accordion triggers.\n * @param {AccordionStates[]} accordionStates Array of objects containing accordions state information.\n * @param {number} clickedTriggerIndex Index of the currently clicked accordion trigger within the accordion div container.\n*/\n\nimport { HTMLElement, AccordionStates } from \"../../../../Types\";\n\nexport function updateAccordionTriggerAriaAttributes(accordionId: string, accordionTriggersClass: string, accordionStates: AccordionStates[], clickedTriggerIndex: number): void {\n const accordionDiv: HTMLElement | null = document.querySelector(`#${accordionId}`);\n if (!accordionDiv) {\n throw new Error(\"Invalid accordion main div id provided.\");\n }\n\n const accordionItems: HTMLElement[] = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));\n if (accordionItems.length === 0) {\n throw new Error(\"Invalid accordion items shared class provided.\");\n }\n\n if (accordionItems.length !== accordionStates.length) {\n throw new Error(`Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.`);\n }\n\n accordionItems.forEach((accordionItem: HTMLElement, index: number) => {\n const state = accordionStates[index];\n const expanded = accordionItem.getAttribute(\"aria-expanded\");\n const shouldBeExpanded = index === clickedTriggerIndex ? (state.display ? \"true\" : \"false\") : \"false\";\n if (expanded && expanded !== shouldBeExpanded) {\n accordionItem.setAttribute(\"aria-expanded\", shouldBeExpanded);\n }\n });\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-RK3JUAFZ.js","../src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts"],"names":["updateCheckboxAriaAttributes","checkboxId","checkboxesClass","checkboxStates","currentPressedCheckboxIndex","checkboxDiv","document","querySelector","Error","checkboxItems","Array","from","querySelectorAll","length","forEach","checkbox","index","setAttribute","checked"],"mappings":"AAAA,gFAAgF;ACUzE,SAASA,6BAA6BC,UAAA,EAAoBC,eAAA,EAAyBC,cAAA,EAAkCC,2BAAA;QACpHC,cAAkCC,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A,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAgBd,EAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,GAAA,CAAea,CAAAA,CAAAA,GAAAA,CAAK,CAAEE,CAAAA,GAAAA,GAAA,GAAU,GAAA,MAAS;gJACjF;wEACF;AACF","sourcesContent":["// src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts\nfunction updateCheckboxAriaAttributes(checkboxId, checkboxesClass, checkboxStates, currentPressedCheckboxIndex) {\n const checkboxDiv = document.querySelector(`#${checkboxId}`);\n if (!checkboxDiv) {\n throw new Error(\"Invalid checkbox main div id provided.\");\n }\n const checkboxItems = Array.from(document.querySelectorAll(`.${checkboxesClass}`));\n if (checkboxItems.length === 0) {\n throw new Error(\"Invalid checkboxes shared class provided.\");\n }\n checkboxItems.forEach((checkbox, index) => {\n if (index === currentPressedCheckboxIndex) {\n checkbox.setAttribute(\"aria-checked\", checkboxStates[index].checked ? \"true\" : \"false\");\n }\n });\n}\n\nexport { updateCheckboxAriaAttributes };\n//# sourceMappingURL=chunk-RK3JUAFZ.js.map\n","/**\n * Adds screen reader accessibility to multiple checkboxes. Updates the aria attributes of the checkboxes. Checkbox elements must possess the following aria attributes; aria-checked and aria-label.\n * @param {string} checkboxId The id of the checkbox parent container.\n * @param {string} checkboxesClass The shared class of all the checkboxes.\n * @param {CheckboxStates[]} checkboxStates Array of objects containing checkboxes state information.\n * @param {number} currentPressedCheckboxIndex Index of the currently checked or unchecked checkbox.\n*/\n\nimport { HTMLElement, CheckboxStates } from \"../../../../Types\";\n\nexport function updateCheckboxAriaAttributes(checkboxId: string, checkboxesClass: string, checkboxStates: CheckboxStates[], currentPressedCheckboxIndex: number): void {\n const checkboxDiv: HTMLElement | null = document.querySelector(`#${checkboxId}`);\n if (!checkboxDiv) {\n throw new Error(\"Invalid checkbox main div id provided.\");\n }\n \n const checkboxItems: HTMLElement[] = Array.from(document.querySelectorAll(`.${checkboxesClass}`));\n if (checkboxItems.length === 0) {\n throw new Error('Invalid checkboxes shared class provided.');\n };\n\n checkboxItems.forEach((checkbox: HTMLElement, index: number) => {\n if (index === currentPressedCheckboxIndex) {\n checkbox.setAttribute(\"aria-checked\", checkboxStates[index].checked ? 'true' : 'false');\n }\n });\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-RK3JUAFZ.js","../src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts"],"names":["updateCheckboxAriaAttributes","checkboxId","checkboxesClass","checkboxStates","currentPressedCheckboxIndex","checkboxDiv","document","querySelector","Error","checkboxItems","Array","from","querySelectorAll","length","forEach","checkbox","index","setAttribute","checked"],"mappings":"AAAA,gFAAgF;ACUzE,SAASA,6BAA6BC,UAAA,EAAoBC,eAAA,EAAyBC,cAAA,EAAkCC,2BAAA;QACpHC,cAAkCC,SAASC,aAAA,CAAc,IAAc,CAAA,CAAA,CAAA,CAAA,CAAVN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAU,CAAA;gGAC7E,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAa;gMAChB,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gGAClB;QAEMC,gBAA+BC,MAAMC,IAAA,CAAKL,SAASM,gBAAA,CAAiB,IAAmB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAfV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;gGAC9E,CAAA,CAAA,CAAA,CAAIO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,EAAG;gMAC9B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;gGAClB;wXAEAC,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAcK,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAA,CAAQ,SAACC,UAAuBC;gMAC5C,EAAA,CAAA,CAAIA,EAAAA,CAAAA,GAAAA,CAAAA,GAAUZ,CAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAA6B;gSACzCW,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAASE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAgBd,EAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,GAAA,CAAea,CAAAA,CAAAA,GAAAA,CAAK,CAAEE,CAAAA,GAAAA,GAAA,GAAU,GAAA,MAAS;gMACjF;gGACF;AACF","sourcesContent":["// src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts\nfunction updateCheckboxAriaAttributes(checkboxId, checkboxesClass, checkboxStates, currentPressedCheckboxIndex) {\n const checkboxDiv = document.querySelector(`#${checkboxId}`);\n if (!checkboxDiv) {\n throw new Error(\"Invalid checkbox main div id provided.\");\n }\n const checkboxItems = Array.from(document.querySelectorAll(`.${checkboxesClass}`));\n if (checkboxItems.length === 0) {\n throw new Error(\"Invalid checkboxes shared class provided.\");\n }\n checkboxItems.forEach((checkbox, index) => {\n if (index === currentPressedCheckboxIndex) {\n checkbox.setAttribute(\"aria-checked\", checkboxStates[index].checked ? \"true\" : \"false\");\n }\n });\n}\n\nexport { updateCheckboxAriaAttributes };\n//# sourceMappingURL=chunk-RK3JUAFZ.js.map\n","/**\n * Adds screen reader accessibility to multiple checkboxes. Updates the aria attributes of the checkboxes. Checkbox elements must possess the following aria attributes; aria-checked and aria-label.\n * @param {string} checkboxId The id of the checkbox parent container.\n * @param {string} checkboxesClass The shared class of all the checkboxes.\n * @param {CheckboxStates[]} checkboxStates Array of objects containing checkboxes state information.\n * @param {number} currentPressedCheckboxIndex Index of the currently checked or unchecked checkbox.\n*/\n\nimport { HTMLElement, CheckboxStates } from \"../../../../Types\";\n\nexport function updateCheckboxAriaAttributes(checkboxId: string, checkboxesClass: string, checkboxStates: CheckboxStates[], currentPressedCheckboxIndex: number): void {\n const checkboxDiv: HTMLElement | null = document.querySelector(`#${checkboxId}`);\n if (!checkboxDiv) {\n throw new Error(\"Invalid checkbox main div id provided.\");\n }\n \n const checkboxItems: HTMLElement[] = Array.from(document.querySelectorAll(`.${checkboxesClass}`));\n if (checkboxItems.length === 0) {\n throw new Error('Invalid checkboxes shared class provided.');\n };\n\n checkboxItems.forEach((checkbox: HTMLElement, index: number) => {\n if (index === currentPressedCheckboxIndex) {\n checkbox.setAttribute(\"aria-checked\", checkboxStates[index].checked ? 'true' : 'false');\n }\n });\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-RT5IROW4.js","../src/utils/handleKeyPress/handleKeyPress.ts"],"names":["isTextInput","el","tagName","type"],"mappings":"AAAA,6CAA6C;ACG7C,SAASA,YAAYC,EAAA;wEACjB,CAAA,CAAA,CAAA,CAAIA,CAAAA,CAAAA,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,EAAA,EAAA,EAAO;QAC7BC,OAAQF,GAAwBE,IAAA","sourcesContent":["// src/utils/handleKeyPress/handleKeyPress.ts\nfunction isTextInput(el) {\n if (el.tagName !== \"INPUT\") return false;\n const type = el.type;\n return [\"text\", \"email\", \"password\", \"tel\", \"number\"].includes(type);\n}\nfunction isTextArea(el) {\n return el.tagName === \"TEXTAREA\";\n}\nfunction isNativeButton(el) {\n return el.tagName === \"BUTTON\" || el.tagName === \"INPUT\" && [\"button\", \"submit\", \"reset\"].includes(el.type);\n}\nfunction isLink(el) {\n return el.tagName === \"A\";\n}\nfunction moveFocus(elementItems, currentIndex, direction) {\n const len = elementItems.length;\n const nextIndex = (currentIndex + direction + len) % len;\n elementItems.item(nextIndex).focus();\n}\nfunction isClickableButNotSemantic(el) {\n return el.getAttribute(\"data-custom-click\") !== null || el.getAttribute(\"data-custom-click\") !== void 0;\n}\nfunction handleMenuEscapeKeyPress(menuElement, menuTriggerButton) {\n menuElement.style.display = \"none\";\n const menuTriggerButtonId = menuTriggerButton.getAttribute(\"id\");\n if (!menuTriggerButtonId) {\n throw new Error(\"Menu trigger button does not have id attribute\");\n }\n menuTriggerButton.setAttribute(\"aria-expanded\", \"false\");\n}\nfunction handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, triggerButton) {\n const currentEl = elementItems.item(elementItemIndex);\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowLeft\": {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const cursorStart = currentEl.selectionStart;\n if (cursorStart === 0) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n }\n }\n break;\n }\n case \"ArrowDown\":\n case \"ArrowRight\": {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const value = currentEl.value;\n const cursorEnd = currentEl.selectionStart;\n if (cursorEnd === value.length) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n }\n }\n break;\n }\n case \"Escape\": {\n event.preventDefault();\n if (menuElementDiv && triggerButton) {\n if (getComputedStyle(menuElementDiv).display === \"block\") {\n handleMenuEscapeKeyPress(menuElementDiv, triggerButton);\n }\n triggerButton.focus();\n }\n break;\n }\n case \"Enter\":\n case \" \": {\n if (!isNativeButton(currentEl) && !isLink(currentEl) && isClickableButNotSemantic(currentEl)) {\n event.preventDefault();\n currentEl.click();\n }\n break;\n }\n }\n}\n\nexport { handleKeyPress };\n//# sourceMappingURL=chunk-RT5IROW4.js.map\n","import { NodeListOfHTMLElement, HTMLElement } from \"../../../Types\";\n\n\nfunction isTextInput(el: HTMLElement): boolean {\n if (el.tagName !== 'INPUT') return false;\n const type = (el as HTMLInputElement).type;\n return ['text', 'email', 'password', 'tel', 'number'].includes(type);\n}\n\nfunction isTextArea(el: HTMLElement): boolean {\n return el.tagName === 'TEXTAREA';\n}\n\nexport function isNativeButton(el: HTMLElement): boolean {\n return el.tagName === 'BUTTON' || (el.tagName === 'INPUT' && ['button', 'submit', 'reset'].includes((el as HTMLInputElement).type));\n}\n\nexport function isLink(el: HTMLElement): boolean {\n return el.tagName === 'A';\n}\n\nfunction moveFocus(elementItems: NodeListOfHTMLElement, currentIndex: number, direction: -1 | 1) {\n const len = elementItems.length;\n const nextIndex = (currentIndex + direction + len) % len;\n elementItems.item(nextIndex).focus();\n}\n\nfunction isClickableButNotSemantic(el: HTMLElement): boolean {\n return el.getAttribute(\"data-custom-click\") !== null || el.getAttribute(\"data-custom-click\") !== undefined;\n}\n\nfunction handleMenuEscapeKeyPress(menuElement: HTMLElement, menuTriggerButton: HTMLElement) {\n menuElement.style.display = 'none';\n const menuTriggerButtonId = menuTriggerButton.getAttribute('id');\n if (!menuTriggerButtonId) {\n throw new Error(\"Menu trigger button does not have id attribute\");\n }\n menuTriggerButton.setAttribute(\"aria-expanded\", \"false\");\n}\n\nexport function handleKeyPress(\n event: KeyboardEvent,\n elementItems: NodeListOfHTMLElement,\n elementItemIndex: number,\n menuElementDiv?: HTMLElement,\n triggerButton?: HTMLElement\n): void {\n const currentEl = elementItems.item(elementItemIndex);\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowLeft': {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const cursorStart = (currentEl as HTMLInputElement | HTMLTextAreaElement).selectionStart;\n if (cursorStart === 0) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n }\n }\n break;\n }\n case 'ArrowDown':\n case 'ArrowRight': {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const value = (currentEl as HTMLInputElement | HTMLTextAreaElement).value;\n const cursorEnd = (currentEl as HTMLInputElement | HTMLTextAreaElement).selectionStart;\n if (cursorEnd === value.length) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n }\n }\n break;\n }\n case 'Escape': {\n event.preventDefault();\n if (menuElementDiv && triggerButton) {\n if (getComputedStyle(menuElementDiv).display === 'block') {\n handleMenuEscapeKeyPress(menuElementDiv, triggerButton);\n }\n triggerButton.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n if (!isNativeButton(currentEl) && !isLink(currentEl) && isClickableButNotSemantic(currentEl)) {\n event.preventDefault();\n currentEl.click();\n }\n break;\n }\n default:\n break;\n }\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/chunk-RT5IROW4.js","../src/utils/handleKeyPress/handleKeyPress.ts"],"names":["isTextInput","el","tagName","type"],"mappings":"AAAA,6CAA6C;ACG7C,SAASA,YAAYC,EAAA;gGACjB,CAAA,CAAA,CAAA,CAAIA,CAAAA,CAAAA,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,EAAA,EAAA,EAAO;QAC7BC,OAAQF,GAAwBE,IAAA","sourcesContent":["// src/utils/handleKeyPress/handleKeyPress.ts\nfunction isTextInput(el) {\n if (el.tagName !== \"INPUT\") return false;\n const type = el.type;\n return [\"text\", \"email\", \"password\", \"tel\", \"number\"].includes(type);\n}\nfunction isTextArea(el) {\n return el.tagName === \"TEXTAREA\";\n}\nfunction isNativeButton(el) {\n return el.tagName === \"BUTTON\" || el.tagName === \"INPUT\" && [\"button\", \"submit\", \"reset\"].includes(el.type);\n}\nfunction isLink(el) {\n return el.tagName === \"A\";\n}\nfunction moveFocus(elementItems, currentIndex, direction) {\n const len = elementItems.length;\n const nextIndex = (currentIndex + direction + len) % len;\n elementItems.item(nextIndex).focus();\n}\nfunction isClickableButNotSemantic(el) {\n return el.getAttribute(\"data-custom-click\") !== null || el.getAttribute(\"data-custom-click\") !== void 0;\n}\nfunction handleMenuEscapeKeyPress(menuElement, menuTriggerButton) {\n menuElement.style.display = \"none\";\n const menuTriggerButtonId = menuTriggerButton.getAttribute(\"id\");\n if (!menuTriggerButtonId) {\n throw new Error(\"Menu trigger button does not have id attribute\");\n }\n menuTriggerButton.setAttribute(\"aria-expanded\", \"false\");\n}\nfunction handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, triggerButton) {\n const currentEl = elementItems.item(elementItemIndex);\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowLeft\": {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const cursorStart = currentEl.selectionStart;\n if (cursorStart === 0) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n }\n }\n break;\n }\n case \"ArrowDown\":\n case \"ArrowRight\": {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const value = currentEl.value;\n const cursorEnd = currentEl.selectionStart;\n if (cursorEnd === value.length) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n }\n }\n break;\n }\n case \"Escape\": {\n event.preventDefault();\n if (menuElementDiv && triggerButton) {\n if (getComputedStyle(menuElementDiv).display === \"block\") {\n handleMenuEscapeKeyPress(menuElementDiv, triggerButton);\n }\n triggerButton.focus();\n }\n break;\n }\n case \"Enter\":\n case \" \": {\n if (!isNativeButton(currentEl) && !isLink(currentEl) && isClickableButNotSemantic(currentEl)) {\n event.preventDefault();\n currentEl.click();\n }\n break;\n }\n }\n}\n\nexport { handleKeyPress };\n//# sourceMappingURL=chunk-RT5IROW4.js.map\n","import { NodeListOfHTMLElement, HTMLElement } from \"../../../Types\";\n\n\nfunction isTextInput(el: HTMLElement): boolean {\n if (el.tagName !== 'INPUT') return false;\n const type = (el as HTMLInputElement).type;\n return ['text', 'email', 'password', 'tel', 'number'].includes(type);\n}\n\nfunction isTextArea(el: HTMLElement): boolean {\n return el.tagName === 'TEXTAREA';\n}\n\nexport function isNativeButton(el: HTMLElement): boolean {\n return el.tagName === 'BUTTON' || (el.tagName === 'INPUT' && ['button', 'submit', 'reset'].includes((el as HTMLInputElement).type));\n}\n\nexport function isLink(el: HTMLElement): boolean {\n return el.tagName === 'A';\n}\n\nfunction moveFocus(elementItems: NodeListOfHTMLElement, currentIndex: number, direction: -1 | 1) {\n const len = elementItems.length;\n const nextIndex = (currentIndex + direction + len) % len;\n elementItems.item(nextIndex).focus();\n}\n\nfunction isClickableButNotSemantic(el: HTMLElement): boolean {\n return el.getAttribute(\"data-custom-click\") !== null || el.getAttribute(\"data-custom-click\") !== undefined;\n}\n\nfunction handleMenuEscapeKeyPress(menuElement: HTMLElement, menuTriggerButton: HTMLElement) {\n menuElement.style.display = 'none';\n const menuTriggerButtonId = menuTriggerButton.getAttribute('id');\n if (!menuTriggerButtonId) {\n throw new Error(\"Menu trigger button does not have id attribute\");\n }\n menuTriggerButton.setAttribute(\"aria-expanded\", \"false\");\n}\n\nexport function handleKeyPress(\n event: KeyboardEvent,\n elementItems: NodeListOfHTMLElement,\n elementItemIndex: number,\n menuElementDiv?: HTMLElement,\n triggerButton?: HTMLElement\n): void {\n const currentEl = elementItems.item(elementItemIndex);\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowLeft': {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const cursorStart = (currentEl as HTMLInputElement | HTMLTextAreaElement).selectionStart;\n if (cursorStart === 0) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, -1);\n }\n }\n break;\n }\n case 'ArrowDown':\n case 'ArrowRight': {\n if (!isTextInput(currentEl) && !isTextArea(currentEl)) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n } else if (isTextInput(currentEl) || isTextArea(currentEl)) {\n const value = (currentEl as HTMLInputElement | HTMLTextAreaElement).value;\n const cursorEnd = (currentEl as HTMLInputElement | HTMLTextAreaElement).selectionStart;\n if (cursorEnd === value.length) {\n event.preventDefault();\n moveFocus(elementItems, elementItemIndex, 1);\n }\n }\n break;\n }\n case 'Escape': {\n event.preventDefault();\n if (menuElementDiv && triggerButton) {\n if (getComputedStyle(menuElementDiv).display === 'block') {\n handleMenuEscapeKeyPress(menuElementDiv, triggerButton);\n }\n triggerButton.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n if (!isNativeButton(currentEl) && !isLink(currentEl) && isClickableButNotSemantic(currentEl)) {\n event.preventDefault();\n currentEl.click();\n }\n break;\n }\n default:\n break;\n }\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-ease",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Out-of-the-box accessibility utility package to develop production ready applications.",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",