aria-ease 2.2.2 → 2.2.3

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
@@ -478,10 +478,15 @@ function runAudit(url) {
478
478
  console.error("\n\u274C Server Not Running!\n");
479
479
  console.log(" Make sure your server is running before auditing URL");
480
480
  console.log(" Run: npm run dev # or your start command");
481
+ } else if (error.message.includes("page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL")) {
482
+ console.error("\n\u274C Cannot audit invalid URL\n");
483
+ } else {
484
+ console.error("\u274C Audit error:", error.message);
485
+ console.log(" Make sure you provide a valid URL");
481
486
  }
482
- process.exit(1);
487
+ } else {
488
+ console.error("\u274C Audit error (non-Error):", String(error));
483
489
  }
484
- console.error("Error during audit:", error);
485
490
  throw error;
486
491
  case 7:
487
492
  if (!browser) return [
@@ -617,7 +622,7 @@ var program = new import_commander.Command();
617
622
  program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
618
623
  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) {
619
624
  return _async_to_generator(function() {
620
- var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, error, err, hasResults;
625
+ var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, error, err, hasResults, auditedCount;
621
626
  function createReport(format2) {
622
627
  return _async_to_generator(function() {
623
628
  var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
@@ -805,24 +810,54 @@ program.command("audit").description("Run axe-core powered accessibility audit o
805
810
  return r.result && r.result.violations && r.result.violations.length > 0;
806
811
  });
807
812
  if (!hasResults) {
808
- console.log(import_chalk.default.red("\u274C No audit report generated"));
809
- process.exit(1);
813
+ auditedCount = allResults.filter(function(r) {
814
+ return r.result;
815
+ }).length;
816
+ if (auditedCount === 0) {
817
+ console.log(import_chalk.default.red("\u274C No pages were successfully audited."));
818
+ process.exit(1);
819
+ }
820
+ console.log(import_chalk.default.green("\n\uD83C\uDF89 Great news! No accessibility violations found!"));
821
+ console.log(import_chalk.default.gray(" Audited ".concat(auditedCount, " page").concat(auditedCount > 1 ? "s" : "", " successfully.\n")));
822
+ process.exit(0);
810
823
  }
811
- if ([
824
+ if (![
812
825
  "json",
813
826
  "csv",
814
827
  "html"
815
- ].includes(format)) {
816
- createReport(format);
817
- } else if (format === "all") {
818
- [
828
+ ].includes(format)) return [
829
+ 3,
830
+ 18
831
+ ];
832
+ return [
833
+ 4,
834
+ createReport(format)
835
+ ];
836
+ case 17:
837
+ _state.sent();
838
+ return [
839
+ 3,
840
+ 20
841
+ ];
842
+ case 18:
843
+ if (!(format === "all")) return [
844
+ 3,
845
+ 20
846
+ ];
847
+ return [
848
+ 4,
849
+ Promise.all([
819
850
  "json",
820
851
  "csv",
821
852
  "html"
822
853
  ].map(function(format2) {
823
- createReport(format2);
824
- });
825
- }
854
+ return createReport(format2);
855
+ }))
856
+ ];
857
+ case 19:
858
+ _state.sent();
859
+ _state.label = 20;
860
+ case 20:
826
861
  console.log(import_chalk.default.green("\n\uD83C\uDF89 All audits completed."));
827
862
  return [
828
863
  2
package/bin/audit-cli.js CHANGED
@@ -385,10 +385,15 @@ function runAudit(url) {
385
385
  console.error("\n\u274C Server Not Running!\n");
386
386
  console.log(" Make sure your server is running before auditing URL");
387
387
  console.log(" Run: npm run dev # or your start command");
388
+ } else if (error.message.includes("page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL")) {
389
+ console.error("\n\u274C Cannot audit invalid URL\n");
390
+ } else {
391
+ console.error("\u274C Audit error:", error.message);
392
+ console.log(" Make sure you provide a valid URL");
388
393
  }
389
- process.exit(1);
394
+ } else {
395
+ console.error("\u274C Audit error (non-Error):", String(error));
390
396
  }
391
- console.error("Error during audit:", error);
392
397
  throw error;
393
398
  case 7:
394
399
  if (!browser) return [
@@ -524,7 +529,7 @@ var program = new Command();
524
529
  program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
525
530
  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) {
526
531
  return _async_to_generator(function() {
527
- var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, error, err, hasResults;
532
+ var _urls, _opts_audit, _config_audit, _config_audit1, _opts_audit1, configPath, config, _tmp, urls, format, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, error, err, hasResults, auditedCount;
528
533
  function createReport(format2) {
529
534
  return _async_to_generator(function() {
530
535
  var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
@@ -708,24 +713,54 @@ program.command("audit").description("Run axe-core powered accessibility audit o
708
713
  return r.result && r.result.violations && r.result.violations.length > 0;
709
714
  });
710
715
  if (!hasResults) {
711
- console.log(chalk.red("\u274C No audit report generated"));
712
- process.exit(1);
716
+ auditedCount = allResults.filter(function(r) {
717
+ return r.result;
718
+ }).length;
719
+ if (auditedCount === 0) {
720
+ console.log(chalk.red("\u274C No pages were successfully audited."));
721
+ process.exit(1);
722
+ }
723
+ console.log(chalk.green("\n\uD83C\uDF89 Great news! No accessibility violations found!"));
724
+ console.log(chalk.gray(" Audited ".concat(auditedCount, " page").concat(auditedCount > 1 ? "s" : "", " successfully.\n")));
725
+ process.exit(0);
713
726
  }
714
- if ([
727
+ if (![
715
728
  "json",
716
729
  "csv",
717
730
  "html"
718
- ].includes(format)) {
719
- createReport(format);
720
- } else if (format === "all") {
721
- [
731
+ ].includes(format)) return [
732
+ 3,
733
+ 18
734
+ ];
735
+ return [
736
+ 4,
737
+ createReport(format)
738
+ ];
739
+ case 17:
740
+ _state.sent();
741
+ return [
742
+ 3,
743
+ 20
744
+ ];
745
+ case 18:
746
+ if (!(format === "all")) return [
747
+ 3,
748
+ 20
749
+ ];
750
+ return [
751
+ 4,
752
+ Promise.all([
722
753
  "json",
723
754
  "csv",
724
755
  "html"
725
756
  ].map(function(format2) {
726
- createReport(format2);
727
- });
728
- }
757
+ return createReport(format2);
758
+ }))
759
+ ];
760
+ case 19:
761
+ _state.sent();
762
+ _state.label = 20;
763
+ case 20:
729
764
  console.log(chalk.green("\n\uD83C\uDF89 All audits completed."));
730
765
  return [
731
766
  2
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/bin/audit-cli.js","../dist/src/utils/audit/audit.js"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n\n// dist/src/utils/audit/audit.js\nimport AxeBuilder from \"@axe-core/playwright\";\nimport { chromium } from \"playwright\";\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args2 = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args2);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(void 0);\n });\n };\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nfunction runAudit() {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, snapshot, error;\n return _ts_generator(this, function(_state) {\n switch (_state.label) {\n case 0:\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(\"http://localhost:5173/\")\n ];\n case 4:\n _state.sent();\n _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 8,\n ,\n 9\n ]);\n axe = new AxeBuilder({\n page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n return [\n 4,\n page.accessibility.snapshot()\n ];\n case 7:\n snapshot = _state.sent();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n return [\n 3,\n 9\n ];\n case 8:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 9\n ];\n case 9:\n return [\n 4,\n browser.close()\n ];\n case 10:\n _state.sent();\n return [\n 2\n ];\n }\n });\n })();\n}\n\n// bin/audit-cli.ts\nvar args = process.argv.slice(2);\nif (args[0] === \"audit\") {\n (async () => {\n await runAudit();\n })();\n} else {\n console.log(\"Usage: npx aria-ease audit\");\n}\n","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(undefined);\n });\n };\n}\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while(g && (g = 0, op[0] && (_ = 0)), _)try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch(op[0]){\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally{\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nimport AxeBuilder from '@axe-core/playwright';\nimport { chromium } from 'playwright';\n// src/utils/audit/audit.ts\nfunction runAudit(url) {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, error;\n return _ts_generator(this, function(_state) {\n switch(_state.label){\n case 0:\n _state.trys.push([\n 0,\n 6,\n 7,\n 10\n ]);\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(url, {\n waitUntil: \"networkidle\"\n })\n ];\n case 4:\n _state.sent();\n axe = new AxeBuilder({\n page: page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 5:\n axeResults = _state.sent();\n return [\n 2,\n axeResults\n ];\n case 6:\n error = _state.sent();\n if (_instanceof(error, Error)) {\n if (error.message.includes(\"Executable doesn't exist\")) {\n console.error(\"\\n\\u274C Playwright browsers not found!\\n\");\n console.log(\"\\uD83D\\uDCE6 First-time setup required:\");\n console.log(\" Run: npx playwright install chromium\\n\");\n console.log(\"\\uD83D\\uDCA1 This downloads the browser needed for auditing (~200MB)\");\n console.log(\" You only need to do this once.\\n\");\n } else if (error.message.includes(\"page.goto: net::ERR_CONNECTION_REFUSED\")) {\n console.error(\"\\n\\u274C Server Not Running!\\n\");\n console.log(\" Make sure your server is running before auditing URL\");\n console.log(\" Run: npm run dev # or your start command\");\n }\n process.exit(1);\n }\n console.error(\"Error during audit:\", error);\n throw error;\n case 7:\n if (!browser) return [\n 3,\n 9\n ];\n return [\n 4,\n browser.close()\n ];\n case 8:\n _state.sent();\n _state.label = 9;\n case 9:\n return [\n 7\n ];\n case 10:\n return [\n 2\n ];\n }\n });\n })();\n}\nexport { runAudit }; //# sourceMappingURL=audit.js.map\n//# sourceMappingURL=audit.js.map"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/bin/audit-cli.js","../dist/src/utils/audit/audit.js"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n\n// dist/src/utils/audit/audit.js\nimport AxeBuilder from \"@axe-core/playwright\";\nimport { chromium } from \"playwright\";\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args2 = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args2);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(void 0);\n });\n };\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nfunction runAudit() {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, snapshot, error;\n return _ts_generator(this, function(_state) {\n switch (_state.label) {\n case 0:\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(\"http://localhost:5173/\")\n ];\n case 4:\n _state.sent();\n _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 8,\n ,\n 9\n ]);\n axe = new AxeBuilder({\n page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n return [\n 4,\n page.accessibility.snapshot()\n ];\n case 7:\n snapshot = _state.sent();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n return [\n 3,\n 9\n ];\n case 8:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 9\n ];\n case 9:\n return [\n 4,\n browser.close()\n ];\n case 10:\n _state.sent();\n return [\n 2\n ];\n }\n });\n })();\n}\n\n// bin/audit-cli.ts\nvar args = process.argv.slice(2);\nif (args[0] === \"audit\") {\n (async () => {\n await runAudit();\n })();\n} else {\n console.log(\"Usage: npx aria-ease audit\");\n}\n","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(undefined);\n });\n };\n}\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while(g && (g = 0, op[0] && (_ = 0)), _)try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch(op[0]){\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally{\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nimport AxeBuilder from '@axe-core/playwright';\nimport { chromium } from 'playwright';\n// src/utils/audit/audit.ts\nfunction runAudit(url) {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, error;\n return _ts_generator(this, function(_state) {\n switch(_state.label){\n case 0:\n _state.trys.push([\n 0,\n 6,\n 7,\n 10\n ]);\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(url, {\n waitUntil: \"networkidle\"\n })\n ];\n case 4:\n _state.sent();\n axe = new AxeBuilder({\n page: page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 5:\n axeResults = _state.sent();\n return [\n 2,\n axeResults\n ];\n case 6:\n error = _state.sent();\n if (_instanceof(error, Error)) {\n if (error.message.includes(\"Executable doesn't exist\")) {\n console.error(\"\\n\\u274C Playwright browsers not found!\\n\");\n console.log(\"\\uD83D\\uDCE6 First-time setup required:\");\n console.log(\" Run: npx playwright install chromium\\n\");\n console.log(\"\\uD83D\\uDCA1 This downloads the browser needed for auditing (~200MB)\");\n console.log(\" You only need to do this once.\\n\");\n } else if (error.message.includes(\"page.goto: net::ERR_CONNECTION_REFUSED\")) {\n console.error(\"\\n\\u274C Server Not Running!\\n\");\n console.log(\" Make sure your server is running before auditing URL\");\n console.log(\" Run: npm run dev # or your start command\");\n } else if (error.message.includes(\"page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL\")) {\n console.error(\"\\n\\u274C Cannot audit invalid URL\\n\");\n } else {\n console.error(\"\\u274C Audit error:\", error.message);\n console.log(\" Make sure you provide a valid URL\");\n }\n } else {\n console.error(\"\\u274C Audit error (non-Error):\", String(error));\n }\n throw error;\n case 7:\n if (!browser) return [\n 3,\n 9\n ];\n return [\n 4,\n browser.close()\n ];\n case 8:\n _state.sent();\n _state.label = 9;\n case 9:\n return [\n 7\n ];\n case 10:\n return [\n 2\n ];\n }\n });\n })();\n}\nexport { runAudit }; //# sourceMappingURL=audit.js.map\n//# sourceMappingURL=audit.js.map"]}
package/bin/audit-cli.ts CHANGED
@@ -60,8 +60,14 @@ program.command('audit')
60
60
 
61
61
  const hasResults = allResults.some(r => r.result && r.result.violations && r.result.violations.length > 0);
62
62
  if (!hasResults) {
63
- console.log(chalk.red('āŒ No audit report generated'));
64
- process.exit(1);
63
+ const auditedCount = allResults.filter(r => r.result).length;
64
+ if (auditedCount === 0) {
65
+ console.log(chalk.red('āŒ No pages were successfully audited.'));
66
+ process.exit(1);
67
+ }
68
+ console.log(chalk.green('\nšŸŽ‰ Great news! No accessibility violations found!'));
69
+ console.log(chalk.gray(` Audited ${auditedCount} page${auditedCount > 1 ? 's' : ''} successfully.\n`));
70
+ process.exit(0);
65
71
  }
66
72
 
67
73
  async function createReport(format: string) {
@@ -81,11 +87,9 @@ program.command('audit')
81
87
  }
82
88
 
83
89
  if(['json', 'csv', 'html'].includes(format)) {
84
- createReport(format);
90
+ await createReport(format);
85
91
  } else if(format === 'all') {
86
- ['json', 'csv', 'html'].map((format) => {
87
- createReport(format);
88
- })
92
+ await Promise.all(['json', 'csv', 'html'].map((format) => createReport(format)));
89
93
  }
90
94
 
91
95
  console.log(chalk.green('\nšŸŽ‰ All audits completed.'));
@@ -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,CAAPN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA;sHACvE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAU;4OACX,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;sHACpB;QAEMC,aAA4BC,MAAMC,IAAA,CAAKN,SAASO,gBAAA,CAAiB,IAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAXV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;sHAC3E,CAAA,CAAA,CAAA,CAAGO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,EAAG;4OAC1B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;sHAClB;sfAEAC,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAWK,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAA,CAAQ,SAACC,CAAAA,UAAwBC;4HACxC,CAAA,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQd,CAAAA,CAAA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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,IAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAPN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO;gIACvE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAU;gQACX,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gIACpB;QAEMC,aAA4BC,MAAMC,IAAA,CAAKN,SAASO,gBAAA,CAAiB,IAAe,CAAA,CAAA,CAAA,CAAXV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAA,CAAA;gIACtF,CAAA,CAAA,CAAA,CAAGO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,EAAG;gQAC1B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;gIAClB;wiBAEAC,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAWK,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,S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A,IAAAA,CAAUM,CAAAA,IAAAA,CAAAA,CAAAA,IAAAA,CAAA,CAAa,IAAA,MAAA,MAAgBD;gQAC3C;gIACJ;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,CAAA,CAARN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQ;sHACzE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAW;4OACd,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;sHAClB;QAEMC,cAA6BC,MAAMC,IAAA,CAAKN,UAAUO,gBAAA,CAAiB,IAAgB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAZV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAY;sHACzF,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;4OAC5B,EAAA,EAAA,EAAM,EAAA,EAAIL,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/CA,CAAAA,EAAAA,GAAvD,CAAA,GAA6D,GAAA,CAAyC,KAAA,EAAA,CAAzC,CAAA,EAAA,GAA7D,CAAA,GAAmFV,GAAAA,CAAmB,KAAA,EAAA,CAAnBA,CAAAA,EAAAA,GAAxCM,CAAAA,MAAAA,CAA2D,KAAA,EAAA,CAA3DA,CAAAA,EAAAA,IAAYI,MAAAA,CAA+C,KAAA,EAAA,CAA/CA,CAAM,EAAA,UAAA,CAAyC,KAAA,EAAA,CAAzC,aAAA,CAAyC,KAAA,EAAA,CAAnBV,aAAaU,MAAM,EAAA;sHACxH;8eAEAJ,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAYK,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAAA,CAAAA,OAAAA,EAAA,CAAQ,OAAA,EAACC,QAAQC;4OAC3B,CAAA,CAAA,EAAIA,CAAAA,CAAAA,GAAAA,CAAAA,GAAAA,CAAUZ,GAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAA2B;kWACvCW,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;4OAC7E;sHACF;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;gIACjE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAW;gQACd,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gIAClB;QAEMC,cAA6BC,MAAMC,IAAA,CAAKN,UAAUO,gBAAA,CAAiB,IAAgB,CAAZV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA;gIACzF,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;gQAC5B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;gIAClB;gIAEA,CAAA,CAAA,CAAA,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAYI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAWV,CAAAA,EAAAA,EA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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,IAAIC,OAAM;sHACjD,CAAA,CAAA,CAAA,CAAI,CAACH,CAAAA,EAAAA,EAAAA,EAAAA,EAAS,EAAA,EAAA,EAAM,EAAA,EAAII,EAAAA,EAAAA,EAAM;QAExBC,gBAAgBJ,SAASC,aAAA,CAAc,IAAII,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAATA,CAAAA;sHACjD,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;sHAEvB,CAAA,EAAA,EAAA,EAAA,EAASC,EAAAA,EAAAA,EAAAA,EAAQC,EAAAA,EAAAA,EAAA;4OACfL,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;sHAChE;sHAEA,CAAA,EAAA,EAAA,EAAA,EAASE;qDACmBC,CAARb,CAAyB,CAAzBA,CAA6BD,CAArBc,CAApBC,CAAoBD,CAApBC,CAAoBD,CAARb,CAAyB,CAAjBa,CAAsC,CAAtCA,CAApBC,CAAoBD,CAApBC,CAAqC,CAAzBd,CAA6BD,CAArBc,CAApBC,CAAoBD,CAApBC;opBACNA,CAAAA,CAAAA,OAAAA,EAAAA,EAAAA,CAAAA,OAAAA,EAAAA,EAAAA,CAAUC,OAAAA,EAAAA,EAAAA,CAAAA,OAAAA,EAAAA,EAAA,CAAQ,OAAA,EAACC,UAAuBC;kWACxC,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
+ {"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;gIAC3C,CAAA,CAAA,CAAA,CAAI,CAACH,CA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ACxC,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,IAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAXN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;sHACpE,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAc;4OACf,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;sHACpB;QAEMC,iBAAgCC,MAAMC,IAAA,CAAKN,aAAaO,gBAAA,CAAiB,IAAIV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAtBA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;sHACnF,CAAA,CAAA,CAAA,CAAIO,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAeI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,EAAG;4OAC7B,E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KAAA,CAAa,KAAA,MAAA,MAAiBF;4OAChD;sHACJ;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","expanded","getAttribute","shouldBeExpanded","display","setAttribute"],"mappings":"AAAA,iGAAiG;ACU1F,SAASA,qCAAqCC,WAAA,EAAqBC,sBAAA,EAAgCC,eAAA,EAAoCC,mBAAA;QACpIC,eAAmCC,SAASC,aAAA,CAAc,IAAe,CAAA,CAAA,CAAA,CAAXN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAA,CAAA;gIAC/E,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAc;gQACf,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gIACpB;QAEMC,iBAAgCC,MAAMC,IAAA,CAAKN,aAAaO,gBAAA,CAAiB,IAAIV,CAAAA,CAAAA,C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AAA,CAAAA,CAAmBJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAUZ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,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;gQAC9F,CAAA,EAAA,CAAIH,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAYA,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAaE,EAAAA,IAAAA,IAAAA,IAAAA,IAAkB;gYAC3CL,EAAAA,CAAAA,KAAAA,CAAAA,KAAcO,CAAAA,KAAAA,CAAAA,KAAA,CAAa,KAAA,MAAA,MAAiBF;gQAChD;gIACJ;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,SAASC,aAAA,CAAc,IAAIN,CAAAA,CAAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;sHACnE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAa;4OAChB,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;sHAClB;QAEMC,gBAA+BC,MAAMC,IAAA,CAAKL,SAASM,gBAAA,CAAiB,IAAIV,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAfA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;sHAC9E,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;4OAC9B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM;sHAClB;seAEAC,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAcK,SAAAA,CAAAA,SAAAA,CAAAA,SAAAA,CAAAA,SAAA,CAAQ,SAACC,UAAuBC;4OAC5C,EAAA,CAAA,CAAIA,EAAAA,CAAAA,GAAAA,CAAAA,GAAUZ,CAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAAAA,IAA6B;kWACzCW,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;4OACjF;sHACF;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,IAAIN,CAAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;gIACnE,CAAA,CAAA,CAAA,CAAI,CAACI,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAa;gQAChB,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gIAClB;QAEMC,gBAA+BC,MAAMC,IAAA,CAAKL,SAASM,gBAAA,CAAiB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Attributes(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;sHACjB,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;gIACjB,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}"]}
@@ -201,10 +201,15 @@ function runAudit(url) {
201
201
  console.error("\n\u274C Server Not Running!\n");
202
202
  console.log(" Make sure your server is running before auditing URL");
203
203
  console.log(" Run: npm run dev # or your start command");
204
+ } else if (error.message.includes("page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL")) {
205
+ console.error("\n\u274C Cannot audit invalid URL\n");
206
+ } else {
207
+ console.error("\u274C Audit error:", error.message);
208
+ console.log(" Make sure you provide a valid URL");
204
209
  }
205
- process.exit(1);
210
+ } else {
211
+ console.error("\u274C Audit error (non-Error):", String(error));
206
212
  }
207
- console.error("Error during audit:", error);
208
213
  throw error;
209
214
  case 7:
210
215
  if (!browser) return [
@@ -194,10 +194,15 @@ function runAudit(url) {
194
194
  console.error("\n\u274C Server Not Running!\n");
195
195
  console.log(" Make sure your server is running before auditing URL");
196
196
  console.log(" Run: npm run dev # or your start command");
197
+ } else if (error.message.includes("page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL")) {
198
+ console.error("\n\u274C Cannot audit invalid URL\n");
199
+ } else {
200
+ console.error("\u274C Audit error:", error.message);
201
+ console.log(" Make sure you provide a valid URL");
197
202
  }
198
- process.exit(1);
203
+ } else {
204
+ console.error("\u274C Audit error (non-Error):", String(error));
199
205
  }
200
- console.error("Error during audit:", error);
201
206
  throw error;
202
207
  case 7:
203
208
  if (!browser) return [
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/macx/aria-ease/package/dist/src/utils/audit/audit.js","../../../../src/utils/audit/audit.ts"],"names":[],"mappings":"","sourcesContent":["import AxeBuilder from '@axe-core/playwright';\nimport { chromium } from 'playwright';\n\n// src/utils/audit/audit.ts\nasync function runAudit() {\n const browser = await chromium.launch({ headless: true });\n const context = await browser.newContext();\n const page = await context.newPage();\n await page.goto(\"http://localhost:5173/\");\n try {\n const axe = new AxeBuilder({ page });\n const axeResults = await axe.analyze();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n const snapshot = await page.accessibility.snapshot();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n } catch (error) {\n console.log(error);\n }\n await browser.close();\n}\n\nexport { runAudit };\n//# sourceMappingURL=audit.js.map\n","import AxeBuilder from \"@axe-core/playwright\";\nimport { chromium } from \"playwright\";\nimport { AxeResults } from \"Types\";\n\nexport async function runAudit(url: string) {\n let browser;\n\n try{ \n browser = await chromium.launch({ headless: true });\n const context = await browser.newContext();\n const page = await context.newPage();\n await page.goto(url, { waitUntil: 'networkidle' });\n const axe = new AxeBuilder({ page });\n const axeResults: AxeResults = await axe.analyze();\n return axeResults;\n } catch(error: unknown) {\n if (error instanceof Error) {\n if (error.message.includes(\"Executable doesn't exist\")) {\n console.error('\\nāŒ Playwright browsers not found!\\n');\n console.log('šŸ“¦ First-time setup required:');\n console.log(' Run: npx playwright install chromium\\n');\n console.log('šŸ’” This downloads the browser needed for auditing (~200MB)');\n console.log(' You only need to do this once.\\n');\n } else if(error.message.includes(\"page.goto: net::ERR_CONNECTION_REFUSED\")) {\n console.error('\\nāŒ Server Not Running!\\n');\n console.log(' Make sure your server is running before auditing URL')\n console.log(' Run: npm run dev # or your start command');\n }\n process.exit(1);\n }\n console.error('Error during audit:', error);\n throw error;\n } finally {\n if(browser) await browser.close(); \n }\n}"]}
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/dist/src/utils/audit/audit.js","../../../../src/utils/audit/audit.ts"],"names":[],"mappings":"","sourcesContent":["import AxeBuilder from '@axe-core/playwright';\nimport { chromium } from 'playwright';\n\n// src/utils/audit/audit.ts\nasync function runAudit() {\n const browser = await chromium.launch({ headless: true });\n const context = await browser.newContext();\n const page = await context.newPage();\n await page.goto(\"http://localhost:5173/\");\n try {\n const axe = new AxeBuilder({ page });\n const axeResults = await axe.analyze();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n const snapshot = await page.accessibility.snapshot();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n } catch (error) {\n console.log(error);\n }\n await browser.close();\n}\n\nexport { runAudit };\n//# sourceMappingURL=audit.js.map\n","import AxeBuilder from \"@axe-core/playwright\";\nimport { chromium } from \"playwright\";\nimport { AxeResults } from \"Types\";\n\nexport async function runAudit(url: string) {\n let browser;\n\n try{ \n browser = await chromium.launch({ headless: true });\n const context = await browser.newContext();\n const page = await context.newPage();\n await page.goto(url, { waitUntil: 'networkidle' });\n const axe = new AxeBuilder({ page });\n const axeResults: AxeResults = await axe.analyze();\n return axeResults;\n } catch(error: unknown) {\n if (error instanceof Error) {\n if (error.message.includes(\"Executable doesn't exist\")) {\n console.error('\\nāŒ Playwright browsers not found!\\n');\n console.log('šŸ“¦ First-time setup required:');\n console.log(' Run: npx playwright install chromium\\n');\n console.log('šŸ’” This downloads the browser needed for auditing (~200MB)');\n console.log(' You only need to do this once.\\n');\n } else if(error.message.includes(\"page.goto: net::ERR_CONNECTION_REFUSED\")) {\n console.error('\\nāŒ Server Not Running!\\n');\n console.log(' Make sure your server is running before auditing URL');\n console.log(' Run: npm run dev # or your start command');\n } else if(error.message.includes(\"page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL\")) {\n console.error('\\nāŒ Cannot audit invalid URL\\n')\n } else {\n console.error('āŒ Audit error:', error.message);\n console.log(' Make sure you provide a valid URL');\n }\n } else {\n console.error('āŒ Audit error (non-Error):', String(error));\n }\n throw error;\n } finally {\n if(browser) await browser.close(); \n }\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-ease",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
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",