@a11y-oracle/focus-analyzer 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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;
|
|
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
|
-
|
|
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
|
-
//
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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.
|
|
3
|
+
"version": "1.1.3",
|
|
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.
|
|
46
|
-
"@a11y-oracle/keyboard-engine": "1.1.
|
|
45
|
+
"@a11y-oracle/cdp-types": "1.1.3",
|
|
46
|
+
"@a11y-oracle/keyboard-engine": "1.1.3",
|
|
47
47
|
"tslib": "^2.3.0"
|
|
48
48
|
}
|
|
49
49
|
}
|