aria-ease 2.2.0 → 2.2.2

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/README.md CHANGED
@@ -39,7 +39,7 @@ const toggleMenuDisplay = () => {
39
39
  };
40
40
  ```
41
41
 
42
- [Check out more features/functionality in the docs](https://ariaease.web.app/docs)
42
+ [Check out more features/functionality in the docs](https://ariaease.site/docs)
43
43
 
44
44
  [Start contributing on GitHub](https://github.com/aria-ease/aria-ease)
45
45
 
package/bin/audit-cli.cjs CHANGED
@@ -40,6 +40,13 @@ function _async_to_generator(fn) {
40
40
  });
41
41
  };
42
42
  }
43
+ function _instanceof(left, right) {
44
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
45
+ return !!right[Symbol.hasInstance](left);
46
+ } else {
47
+ return left instanceof right;
48
+ }
49
+ }
43
50
  function _getRequireWildcardCache(nodeInterop) {
44
51
  if (typeof WeakMap !== "function") return null;
45
52
  var cacheBabelInterop = new WeakMap();
@@ -307,6 +314,13 @@ function _async_to_generator1(fn) {
307
314
  });
308
315
  };
309
316
  }
317
+ function _instanceof1(left, right) {
318
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
319
+ return !!right[Symbol.hasInstance](left);
320
+ } else {
321
+ return _instanceof(left, right);
322
+ }
323
+ }
310
324
  function _ts_generator1(thisArg, body) {
311
325
  var f, y, t, _ = {
312
326
  label: 0,
@@ -404,6 +418,12 @@ function runAudit(url) {
404
418
  return _ts_generator1(this, function(_state) {
405
419
  switch(_state.label){
406
420
  case 0:
421
+ _state.trys.push([
422
+ 0,
423
+ 6,
424
+ 7,
425
+ 10
426
+ ]);
407
427
  return [
408
428
  4,
409
429
  import_playwright2.chromium.launch({
@@ -432,14 +452,6 @@ function runAudit(url) {
432
452
  ];
433
453
  case 4:
434
454
  _state.sent();
435
- _state.label = 5;
436
- case 5:
437
- _state.trys.push([
438
- 5,
439
- 7,
440
- ,
441
- 8
442
- ]);
443
455
  axe = new import_playwright.default({
444
456
  page: page
445
457
  });
@@ -447,26 +459,47 @@ function runAudit(url) {
447
459
  4,
448
460
  axe.analyze()
449
461
  ];
450
- case 6:
462
+ case 5:
451
463
  axeResults = _state.sent();
452
464
  return [
453
465
  2,
454
466
  axeResults
455
467
  ];
456
- case 7:
468
+ case 6:
457
469
  error = _state.sent();
458
- console.log(error);
459
- return [
470
+ if (_instanceof1(error, Error)) {
471
+ if (error.message.includes("Executable doesn't exist")) {
472
+ console.error("\n\u274C Playwright browsers not found!\n");
473
+ console.log("\uD83D\uDCE6 First-time setup required:");
474
+ console.log(" Run: npx playwright install chromium\n");
475
+ console.log("\uD83D\uDCA1 This downloads the browser needed for auditing (~200MB)");
476
+ console.log(" You only need to do this once.\n");
477
+ } else if (error.message.includes("page.goto: net::ERR_CONNECTION_REFUSED")) {
478
+ console.error("\n\u274C Server Not Running!\n");
479
+ console.log(" Make sure your server is running before auditing URL");
480
+ console.log(" Run: npm run dev # or your start command");
481
+ }
482
+ process.exit(1);
483
+ }
484
+ console.error("Error during audit:", error);
485
+ throw error;
486
+ case 7:
487
+ if (!browser) return [
460
488
  3,
461
- 8
489
+ 9
462
490
  ];
463
- case 8:
464
491
  return [
465
492
  4,
466
493
  browser.close()
467
494
  ];
468
- case 9:
495
+ case 8:
469
496
  _state.sent();
497
+ _state.label = 9;
498
+ case 9:
499
+ return [
500
+ 7
501
+ ];
502
+ case 10:
470
503
  return [
471
504
  2
472
505
  ];
@@ -584,7 +617,7 @@ var program = new import_commander.Command();
584
617
  program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
585
618
  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) {
586
619
  return _async_to_generator(function() {
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;
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;
588
621
  function createReport(format2) {
589
622
  return _async_to_generator(function() {
590
623
  var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
@@ -664,7 +697,7 @@ program.command("audit").description("Run axe-core powered accessibility audit o
664
697
  6
665
698
  ];
666
699
  case 5:
667
- console.log(import_chalk.default.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using default configurations."));
700
+ console.log(import_chalk.default.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using CLI configurations."));
668
701
  _state.label = 6;
669
702
  case 6:
670
703
  urls = [];
@@ -727,8 +760,10 @@ program.command("audit").description("Run axe-core powered accessibility audit o
727
760
  12
728
761
  ];
729
762
  case 11:
730
- err1 = _state.sent();
731
- console.log(import_chalk.default.red("āŒ Failed auditing ".concat(url, ": ").concat(err1.message)));
763
+ error = _state.sent();
764
+ if (_instanceof(error, Error) && error.message) {
765
+ console.log(import_chalk.default.red("āŒ Failed auditing ".concat(url, ": ").concat(error.message)));
766
+ }
732
767
  return [
733
768
  3,
734
769
  12
package/bin/audit-cli.js CHANGED
@@ -39,6 +39,13 @@ function _async_to_generator(fn) {
39
39
  });
40
40
  };
41
41
  }
42
+ function _instanceof(left, right) {
43
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
44
+ return !!right[Symbol.hasInstance](left);
45
+ } else {
46
+ return left instanceof right;
47
+ }
48
+ }
42
49
  function _iterable_to_array(iter) {
43
50
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
44
51
  }
@@ -214,6 +221,13 @@ function _async_to_generator1(fn) {
214
221
  });
215
222
  };
216
223
  }
224
+ function _instanceof1(left, right) {
225
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
226
+ return !!right[Symbol.hasInstance](left);
227
+ } else {
228
+ return _instanceof(left, right);
229
+ }
230
+ }
217
231
  function _ts_generator1(thisArg, body) {
218
232
  var f, y, t, _ = {
219
233
  label: 0,
@@ -311,6 +325,12 @@ function runAudit(url) {
311
325
  return _ts_generator1(this, function(_state) {
312
326
  switch(_state.label){
313
327
  case 0:
328
+ _state.trys.push([
329
+ 0,
330
+ 6,
331
+ 7,
332
+ 10
333
+ ]);
314
334
  return [
315
335
  4,
316
336
  chromium.launch({
@@ -339,14 +359,6 @@ function runAudit(url) {
339
359
  ];
340
360
  case 4:
341
361
  _state.sent();
342
- _state.label = 5;
343
- case 5:
344
- _state.trys.push([
345
- 5,
346
- 7,
347
- ,
348
- 8
349
- ]);
350
362
  axe = new AxeBuilder({
351
363
  page: page
352
364
  });
@@ -354,26 +366,47 @@ function runAudit(url) {
354
366
  4,
355
367
  axe.analyze()
356
368
  ];
357
- case 6:
369
+ case 5:
358
370
  axeResults = _state.sent();
359
371
  return [
360
372
  2,
361
373
  axeResults
362
374
  ];
363
- case 7:
375
+ case 6:
364
376
  error = _state.sent();
365
- console.log(error);
366
- return [
377
+ if (_instanceof1(error, Error)) {
378
+ if (error.message.includes("Executable doesn't exist")) {
379
+ console.error("\n\u274C Playwright browsers not found!\n");
380
+ console.log("\uD83D\uDCE6 First-time setup required:");
381
+ console.log(" Run: npx playwright install chromium\n");
382
+ console.log("\uD83D\uDCA1 This downloads the browser needed for auditing (~200MB)");
383
+ console.log(" You only need to do this once.\n");
384
+ } else if (error.message.includes("page.goto: net::ERR_CONNECTION_REFUSED")) {
385
+ console.error("\n\u274C Server Not Running!\n");
386
+ console.log(" Make sure your server is running before auditing URL");
387
+ console.log(" Run: npm run dev # or your start command");
388
+ }
389
+ process.exit(1);
390
+ }
391
+ console.error("Error during audit:", error);
392
+ throw error;
393
+ case 7:
394
+ if (!browser) return [
367
395
  3,
368
- 8
396
+ 9
369
397
  ];
370
- case 8:
371
398
  return [
372
399
  4,
373
400
  browser.close()
374
401
  ];
375
- case 9:
402
+ case 8:
376
403
  _state.sent();
404
+ _state.label = 9;
405
+ case 9:
406
+ return [
407
+ 7
408
+ ];
409
+ case 10:
377
410
  return [
378
411
  2
379
412
  ];
@@ -491,7 +524,7 @@ var program = new Command();
491
524
  program.name("aria-ease").description("Run accessibility tests and audits").version("2.1.1");
492
525
  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) {
493
526
  return _async_to_generator(function() {
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;
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;
495
528
  function createReport(format2) {
496
529
  return _async_to_generator(function() {
497
530
  var _config_audit, formatted, out, d, pad, timestamp, fileName, filePath;
@@ -567,7 +600,7 @@ program.command("audit").description("Run axe-core powered accessibility audit o
567
600
  6
568
601
  ];
569
602
  case 5:
570
- console.log(chalk.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using default configurations."));
603
+ console.log(chalk.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using CLI configurations."));
571
604
  _state.label = 6;
572
605
  case 6:
573
606
  urls = [];
@@ -630,8 +663,10 @@ program.command("audit").description("Run axe-core powered accessibility audit o
630
663
  12
631
664
  ];
632
665
  case 11:
633
- err = _state.sent();
634
- console.log(chalk.red("āŒ Failed auditing ".concat(url, ": ").concat(err.message)));
666
+ error = _state.sent();
667
+ if (_instanceof(error, Error) && error.message) {
668
+ console.log(chalk.red("āŒ Failed auditing ".concat(url, ": ").concat(error.message)));
669
+ }
635
670
  return [
636
671
  3,
637
672
  12
@@ -648,9 +683,9 @@ program.command("audit").description("Run axe-core powered accessibility audit o
648
683
  16
649
684
  ];
650
685
  case 14:
651
- err1 = _state.sent();
686
+ err = _state.sent();
652
687
  _didIteratorError = true;
653
- _iteratorError = err1;
688
+ _iteratorError = err;
654
689
  return [
655
690
  3,
656
691
  16
@@ -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 _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 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 _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 7,\n ,\n 8\n ]);\n axe = new AxeBuilder({\n page: page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n return [\n 2,\n axeResults\n ];\n case 7:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 8\n ];\n case 8:\n return [\n 4,\n browser.close()\n ];\n case 9:\n _state.sent();\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 }\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"]}
package/bin/audit-cli.ts CHANGED
@@ -26,7 +26,7 @@ program.command('audit')
26
26
  config = (await import(configPath)).default || (await import(configPath));
27
27
  console.log(chalk.green('āœ… Loaded config from ariaease.config.js\n'));
28
28
  } else {
29
- console.log(chalk.yellow('ā„¹ļø No ariaease.config.js found at project root, using default configurations.'));
29
+ console.log(chalk.yellow('ā„¹ļø No ariaease.config.js found at project root, using CLI configurations.'));
30
30
  }
31
31
 
32
32
  const urls: string[] = [];
@@ -48,13 +48,13 @@ program.command('audit')
48
48
  for (const url of urls) {
49
49
  console.log(chalk.yellow(`šŸ”Ž Auditing: ${url}`));
50
50
  try {
51
- const result = await runAudit(url);
51
+ const result: AxeResults = await runAudit(url);
52
52
  allResults.push({ url: url, result });
53
53
  console.log(chalk.green(`āœ… Completed audit for ${url}\n`));
54
-
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- } catch (err: any) {
57
- console.log(chalk.red(`āŒ Failed auditing ${url}: ${err.message}`));
54
+ } catch (error: unknown) {
55
+ if(error instanceof Error && error.message) {
56
+ console.log(chalk.red(`āŒ Failed auditing ${url}: ${error.message}`));
57
+ }
58
58
  }
59
59
  }
60
60
 
@@ -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,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,CAAAA,CAAAA,CAAAA,CAAAA,CAAW;gGACtF,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;gMAC1B,EAAA,EAAA,EAAM,EAAA,EAAIL,EAAAA,IAAM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AAA,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
+ {"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,CAAA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A,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;4OAClG,GAAA,CAAIA,GAAAA,CAAAA,GAAAA,CAAAA,GAAWA,CAAAA,GAAAA,CAAAA,GAAAA,CAAAA,GAAYE,CAAAA,IAAAA,IAAAA,IAAAA,IAAiB;kWACxCL,GAAAA,CAAAA,CAAAA,IAAAA,CAAUM,CAAAA,IAAAA,CAAAA,CAAAA,IAAAA,CAAA,CAAa,IAAA,MAAA,MAAgBD;4OAC3C;sHACJ;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,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,C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AA,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;gMAC3B,CAAA,CAAA,EAAIA,CAAAA,CAAAA,GAAAA,CAAAA,GAAAA,CAAUZ,GAAAA,IAAAA,IAAAA,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
+ {"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,CAA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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 +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","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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":["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,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 +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,CAAXN,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW;gGAC/E,CAAA,CAAA,CAAA,CAAI,CAACI,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAc;gMACf,EAAA,EAAA,EAAM,EAAA,EAAIG,EAAAA,IAAM;gGACpB;QAEMC,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esContent":["// 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,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,CA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AAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAU,CAAA,EAAA,EAAA,EAAA,EAAS,EAAA,EAAA,EAAA,EAAA,EAAW;4OAC9F,CAAA,EAAA,CAAIH,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,CAAYA,CAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAaE,EAAAA,IAAAA,IAAAA,IAAAA,IAAkB;kWAC3CL,EAAAA,CAAAA,KAAAA,CAAAA,KAAcO,CAAAA,KAAAA,CAAAA,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 +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,IAAc,CA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A,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
+ {"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 +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;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}"]}
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}"]}
@@ -28,6 +28,13 @@ function _async_to_generator(fn) {
28
28
  });
29
29
  };
30
30
  }
31
+ function _instanceof(left, right) {
32
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
33
+ return !!right[Symbol.hasInstance](left);
34
+ } else {
35
+ return left instanceof right;
36
+ }
37
+ }
31
38
  function _ts_generator(thisArg, body) {
32
39
  var f, y, t, _ = {
33
40
  label: 0,
@@ -134,6 +141,12 @@ function runAudit(url) {
134
141
  return _ts_generator(this, function(_state) {
135
142
  switch(_state.label){
136
143
  case 0:
144
+ _state.trys.push([
145
+ 0,
146
+ 6,
147
+ 7,
148
+ 10
149
+ ]);
137
150
  return [
138
151
  4,
139
152
  playwright.chromium.launch({
@@ -162,14 +175,6 @@ function runAudit(url) {
162
175
  ];
163
176
  case 4:
164
177
  _state.sent();
165
- _state.label = 5;
166
- case 5:
167
- _state.trys.push([
168
- 5,
169
- 7,
170
- ,
171
- 8
172
- ]);
173
178
  axe = new AxeBuilder__default.default({
174
179
  page: page
175
180
  });
@@ -177,26 +182,47 @@ function runAudit(url) {
177
182
  4,
178
183
  axe.analyze()
179
184
  ];
180
- case 6:
185
+ case 5:
181
186
  axeResults = _state.sent();
182
187
  return [
183
188
  2,
184
189
  axeResults
185
190
  ];
186
- case 7:
191
+ case 6:
187
192
  error = _state.sent();
188
- console.log(error);
189
- return [
193
+ if (_instanceof(error, Error)) {
194
+ if (error.message.includes("Executable doesn't exist")) {
195
+ console.error("\n\u274C Playwright browsers not found!\n");
196
+ console.log("\uD83D\uDCE6 First-time setup required:");
197
+ console.log(" Run: npx playwright install chromium\n");
198
+ console.log("\uD83D\uDCA1 This downloads the browser needed for auditing (~200MB)");
199
+ console.log(" You only need to do this once.\n");
200
+ } else if (error.message.includes("page.goto: net::ERR_CONNECTION_REFUSED")) {
201
+ console.error("\n\u274C Server Not Running!\n");
202
+ console.log(" Make sure your server is running before auditing URL");
203
+ console.log(" Run: npm run dev # or your start command");
204
+ }
205
+ process.exit(1);
206
+ }
207
+ console.error("Error during audit:", error);
208
+ throw error;
209
+ case 7:
210
+ if (!browser) return [
190
211
  3,
191
- 8
212
+ 9
192
213
  ];
193
- case 8:
194
214
  return [
195
215
  4,
196
216
  browser.close()
197
217
  ];
198
- case 9:
218
+ case 8:
199
219
  _state.sent();
220
+ _state.label = 9;
221
+ case 9:
222
+ return [
223
+ 7
224
+ ];
225
+ case 10:
200
226
  return [
201
227
  2
202
228
  ];
@@ -1,5 +1,5 @@
1
1
  import * as axe_core from 'axe-core';
2
2
 
3
- declare function runAudit(url: string): Promise<axe_core.AxeResults | undefined>;
3
+ declare function runAudit(url: string): Promise<axe_core.AxeResults>;
4
4
 
5
5
  export { runAudit };
@@ -1,5 +1,5 @@
1
1
  import * as axe_core from 'axe-core';
2
2
 
3
- declare function runAudit(url: string): Promise<axe_core.AxeResults | undefined>;
3
+ declare function runAudit(url: string): Promise<axe_core.AxeResults>;
4
4
 
5
5
  export { runAudit };
@@ -27,6 +27,13 @@ function _async_to_generator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
+ function _instanceof(left, right) {
31
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
32
+ return !!right[Symbol.hasInstance](left);
33
+ } else {
34
+ return left instanceof right;
35
+ }
36
+ }
30
37
  function _ts_generator(thisArg, body) {
31
38
  var f, y, t, _ = {
32
39
  label: 0,
@@ -127,6 +134,12 @@ function runAudit(url) {
127
134
  return _ts_generator(this, function(_state) {
128
135
  switch(_state.label){
129
136
  case 0:
137
+ _state.trys.push([
138
+ 0,
139
+ 6,
140
+ 7,
141
+ 10
142
+ ]);
130
143
  return [
131
144
  4,
132
145
  chromium.launch({
@@ -155,14 +168,6 @@ function runAudit(url) {
155
168
  ];
156
169
  case 4:
157
170
  _state.sent();
158
- _state.label = 5;
159
- case 5:
160
- _state.trys.push([
161
- 5,
162
- 7,
163
- ,
164
- 8
165
- ]);
166
171
  axe = new AxeBuilder({
167
172
  page: page
168
173
  });
@@ -170,26 +175,47 @@ function runAudit(url) {
170
175
  4,
171
176
  axe.analyze()
172
177
  ];
173
- case 6:
178
+ case 5:
174
179
  axeResults = _state.sent();
175
180
  return [
176
181
  2,
177
182
  axeResults
178
183
  ];
179
- case 7:
184
+ case 6:
180
185
  error = _state.sent();
181
- console.log(error);
182
- return [
186
+ if (_instanceof(error, Error)) {
187
+ if (error.message.includes("Executable doesn't exist")) {
188
+ console.error("\n\u274C Playwright browsers not found!\n");
189
+ console.log("\uD83D\uDCE6 First-time setup required:");
190
+ console.log(" Run: npx playwright install chromium\n");
191
+ console.log("\uD83D\uDCA1 This downloads the browser needed for auditing (~200MB)");
192
+ console.log(" You only need to do this once.\n");
193
+ } else if (error.message.includes("page.goto: net::ERR_CONNECTION_REFUSED")) {
194
+ console.error("\n\u274C Server Not Running!\n");
195
+ console.log(" Make sure your server is running before auditing URL");
196
+ console.log(" Run: npm run dev # or your start command");
197
+ }
198
+ process.exit(1);
199
+ }
200
+ console.error("Error during audit:", error);
201
+ throw error;
202
+ case 7:
203
+ if (!browser) return [
183
204
  3,
184
- 8
205
+ 9
185
206
  ];
186
- case 8:
187
207
  return [
188
208
  4,
189
209
  browser.close()
190
210
  ];
191
- case 9:
211
+ case 8:
192
212
  _state.sent();
213
+ _state.label = 9;
214
+ case 9:
215
+ return [
216
+ 7
217
+ ];
218
+ case 10:
193
219
  return [
194
220
  2
195
221
  ];
@@ -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 const 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\n try{\n const axe = new AxeBuilder({ page });\n const axeResults: AxeResults = await axe.analyze();\n return axeResults;\n } catch(error) {\n console.log(error);\n }\n \n await browser.close(); \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 }\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}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-ease",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
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",
@@ -35,7 +35,7 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/aria-ease/aria-ease/issues"
37
37
  },
38
- "homepage": "https://ariaease.web.app/docs",
38
+ "homepage": "https://ariaease.site/docs",
39
39
  "devDependencies": {
40
40
  "@swc/core": "^1.13.5",
41
41
  "@testing-library/dom": "^10.4.1",
@@ -98,6 +98,14 @@
98
98
  "playwright": "^1.55.1",
99
99
  "typescript-eslint": "^8.41.0"
100
100
  },
101
+ "peerDependencies": {
102
+ "playwright": "^1.55.1"
103
+ },
104
+ "peerDependenciesMeta": {
105
+ "playwright": {
106
+ "optional": true
107
+ }
108
+ },
101
109
  "bin": {
102
110
  "aria-ease": "./bin/audit-cli.js"
103
111
  }