@lessonkit/accessibility 0.1.0 → 0.2.1
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 +6 -1
- package/dist/index.cjs +15 -2
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +13 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# `@lessonkit/accessibility`
|
|
2
2
|
|
|
3
|
+
[](https://github.com/eddiethedean/lessonkit/actions/workflows/checks.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@lessonkit/accessibility)
|
|
5
|
+
[](../../LICENSE)
|
|
6
|
+
|
|
3
7
|
Small accessibility utilities used by LessonKit packages and apps.
|
|
4
8
|
|
|
5
9
|
## Install
|
|
@@ -8,8 +12,9 @@ Small accessibility utilities used by LessonKit packages and apps.
|
|
|
8
12
|
npm install @lessonkit/accessibility
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
## Included (0.1
|
|
15
|
+
## Included (0.2.1)
|
|
12
16
|
|
|
13
17
|
- `prefersReducedMotion()`
|
|
14
18
|
- `focusFirst(container)`
|
|
19
|
+
- `visuallyHiddenStyle` — inline styles for screen-reader-only content (used by `@lessonkit/react` `Quiz`)
|
|
15
20
|
|
package/dist/index.cjs
CHANGED
|
@@ -21,9 +21,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
focusFirst: () => focusFirst,
|
|
24
|
-
prefersReducedMotion: () => prefersReducedMotion
|
|
24
|
+
prefersReducedMotion: () => prefersReducedMotion,
|
|
25
|
+
visuallyHiddenStyle: () => visuallyHiddenStyle
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var visuallyHiddenStyle = {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
width: "1px",
|
|
31
|
+
height: "1px",
|
|
32
|
+
padding: 0,
|
|
33
|
+
margin: "-1px",
|
|
34
|
+
overflow: "hidden",
|
|
35
|
+
clip: "rect(0, 0, 0, 0)",
|
|
36
|
+
whiteSpace: "nowrap",
|
|
37
|
+
border: 0
|
|
38
|
+
};
|
|
27
39
|
function prefersReducedMotion() {
|
|
28
40
|
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
29
41
|
}
|
|
@@ -45,5 +57,6 @@ function focusFirst(container) {
|
|
|
45
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
58
|
0 && (module.exports = {
|
|
47
59
|
focusFirst,
|
|
48
|
-
prefersReducedMotion
|
|
60
|
+
prefersReducedMotion,
|
|
61
|
+
visuallyHiddenStyle
|
|
49
62
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
type Focusable =
|
|
1
|
+
type Focusable = {
|
|
2
2
|
focus: () => void;
|
|
3
3
|
};
|
|
4
|
+
/** Screen-reader-only styles (no external CSS required). */
|
|
5
|
+
declare const visuallyHiddenStyle: Record<string, string | number>;
|
|
6
|
+
type FocusContainer = {
|
|
7
|
+
querySelector<T>(selectors: string): T | null;
|
|
8
|
+
};
|
|
4
9
|
declare function prefersReducedMotion(): boolean;
|
|
5
|
-
declare function focusFirst(container:
|
|
10
|
+
declare function focusFirst(container: FocusContainer | null): boolean;
|
|
6
11
|
|
|
7
|
-
export { type Focusable, focusFirst, prefersReducedMotion };
|
|
12
|
+
export { type FocusContainer, type Focusable, focusFirst, prefersReducedMotion, visuallyHiddenStyle };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
type Focusable =
|
|
1
|
+
type Focusable = {
|
|
2
2
|
focus: () => void;
|
|
3
3
|
};
|
|
4
|
+
/** Screen-reader-only styles (no external CSS required). */
|
|
5
|
+
declare const visuallyHiddenStyle: Record<string, string | number>;
|
|
6
|
+
type FocusContainer = {
|
|
7
|
+
querySelector<T>(selectors: string): T | null;
|
|
8
|
+
};
|
|
4
9
|
declare function prefersReducedMotion(): boolean;
|
|
5
|
-
declare function focusFirst(container:
|
|
10
|
+
declare function focusFirst(container: FocusContainer | null): boolean;
|
|
6
11
|
|
|
7
|
-
export { type Focusable, focusFirst, prefersReducedMotion };
|
|
12
|
+
export { type FocusContainer, type Focusable, focusFirst, prefersReducedMotion, visuallyHiddenStyle };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
var visuallyHiddenStyle = {
|
|
3
|
+
position: "absolute",
|
|
4
|
+
width: "1px",
|
|
5
|
+
height: "1px",
|
|
6
|
+
padding: 0,
|
|
7
|
+
margin: "-1px",
|
|
8
|
+
overflow: "hidden",
|
|
9
|
+
clip: "rect(0, 0, 0, 0)",
|
|
10
|
+
whiteSpace: "nowrap",
|
|
11
|
+
border: 0
|
|
12
|
+
};
|
|
2
13
|
function prefersReducedMotion() {
|
|
3
14
|
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4
15
|
}
|
|
@@ -19,5 +30,6 @@ function focusFirst(container) {
|
|
|
19
30
|
}
|
|
20
31
|
export {
|
|
21
32
|
focusFirst,
|
|
22
|
-
prefersReducedMotion
|
|
33
|
+
prefersReducedMotion,
|
|
34
|
+
visuallyHiddenStyle
|
|
23
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lessonkit/accessibility",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Accessibility utilities for LessonKit packages and apps.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"prepublishOnly": "npm run build",
|
|
40
40
|
"typecheck": "tsc -p tsconfig.json",
|
|
41
41
|
"test": "vitest run --passWithNoTests",
|
|
42
|
+
"test:coverage": "vitest run --coverage --passWithNoTests=false",
|
|
42
43
|
"lint": "echo \"(no lint configured yet)\""
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|