@a11y-oracle/focus-analyzer 1.1.0 → 1.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"focus-analyzer.d.ts","sourceRoot":"","sources":["../../src/lib/focus-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AA4EpB;;;;;;GAMG;AACH,qBAAa,aAAa;IAMZ,OAAO,CAAC,GAAG;IALvB,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;OAEG;gBACiB,GAAG,EAAE,cAAc;IAIvC;;;;;;;;;OASG;IACG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAiDlD;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAS7C;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAW,GACnB,OAAO,CAAC,eAAe,CAAC;IAgG3B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAc7B"}
1
+ {"version":3,"file":"focus-analyzer.d.ts","sourceRoot":"","sources":["../../src/lib/focus-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AA4EpB;;;;;;GAMG;AACH,qBAAa,aAAa;IAMZ,OAAO,CAAC,GAAG;IALvB,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;OAEG;gBACiB,GAAG,EAAE,cAAc;IAIvC;;;;;;;;;OASG;IACG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAmDlD;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAS7C;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAW,GACnB,OAAO,CAAC,eAAe,CAAC;IAgG3B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAyB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAc7B"}
@@ -123,9 +123,11 @@ export class FocusAnalyzer {
123
123
  return this.createEmptyIndicator();
124
124
  }
125
125
  const outlineWidth = styles.outlineWidth || '0px';
126
+ const outlineParsed = parseColor(styles.outlineColor);
126
127
  const hasOutline = outlineWidth !== '0px' &&
127
128
  outlineWidth !== '0' &&
128
- styles.outlineColor !== 'transparent';
129
+ !!outlineParsed &&
130
+ outlineParsed.a > 0;
129
131
  const hasBoxShadow = styles.boxShadow !== 'none' && styles.boxShadow !== '';
130
132
  const isVisible = hasOutline || hasBoxShadow;
131
133
  // Calculate contrast ratio between focus indicator and background
@@ -267,15 +269,24 @@ export class FocusAnalyzer {
267
269
  * Example: `"0px 0px 0px 3px rgb(52, 152, 219)"` → rgb(52, 152, 219)
268
270
  */
269
271
  extractBoxShadowColor(boxShadow) {
270
- // Try to find an rgb/rgba color in the box-shadow
271
- const rgbMatch = boxShadow.match(/rgba?\([^)]+\)/);
272
- if (rgbMatch) {
273
- return parseColor(rgbMatch[0]);
272
+ // Extract ALL color values from the box-shadow.
273
+ // For multi-ring patterns (e.g. Tailwind's ring-offset + ring + default),
274
+ // the outermost visible ring is the last non-transparent color.
275
+ const rgbMatches = boxShadow.match(/rgba?\([^)]+\)/g) ?? [];
276
+ const hexMatches = boxShadow.match(/#[0-9a-fA-F]{3,8}/g) ?? [];
277
+ // Collect all parsed colors in order of appearance
278
+ const colors = [];
279
+ for (const m of rgbMatches) {
280
+ colors.push(parseColor(m));
274
281
  }
275
- // Try to find a hex color
276
- const hexMatch = boxShadow.match(/#[0-9a-fA-F]{3,8}/);
277
- if (hexMatch) {
278
- return parseColor(hexMatch[0]);
282
+ for (const m of hexMatches) {
283
+ colors.push(parseColor(m));
284
+ }
285
+ // Return the last non-transparent color (outermost visible ring)
286
+ for (let i = colors.length - 1; i >= 0; i--) {
287
+ const c = colors[i];
288
+ if (c && c.a > 0)
289
+ return c;
279
290
  }
280
291
  return null;
281
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a11y-oracle/focus-analyzer",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Focus indicator CSS analysis (WCAG 2.4.12), tab order extraction, and keyboard trap detection",
5
5
  "license": "MIT",
6
6
  "author": "a11y-oracle",
@@ -42,8 +42,8 @@
42
42
  "!**/*.tsbuildinfo"
43
43
  ],
44
44
  "dependencies": {
45
- "@a11y-oracle/cdp-types": "1.1.0",
46
- "@a11y-oracle/keyboard-engine": "1.1.0",
45
+ "@a11y-oracle/cdp-types": "1.1.2",
46
+ "@a11y-oracle/keyboard-engine": "1.1.2",
47
47
  "tslib": "^2.3.0"
48
48
  }
49
49
  }