@lessonkit/accessibility 0.1.0
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 +15 -0
- package/dist/index.cjs +49 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@lessonkit/accessibility`
|
|
2
|
+
|
|
3
|
+
Small accessibility utilities used by LessonKit packages and apps.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lessonkit/accessibility
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Included (0.1.x)
|
|
12
|
+
|
|
13
|
+
- `prefersReducedMotion()`
|
|
14
|
+
- `focusFirst(container)`
|
|
15
|
+
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
focusFirst: () => focusFirst,
|
|
24
|
+
prefersReducedMotion: () => prefersReducedMotion
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
function prefersReducedMotion() {
|
|
28
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
29
|
+
}
|
|
30
|
+
function focusFirst(container) {
|
|
31
|
+
if (!container) return false;
|
|
32
|
+
const el = container.querySelector(
|
|
33
|
+
[
|
|
34
|
+
"a[href]",
|
|
35
|
+
"button:not([disabled])",
|
|
36
|
+
"input:not([disabled])",
|
|
37
|
+
"select:not([disabled])",
|
|
38
|
+
"textarea:not([disabled])",
|
|
39
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
40
|
+
].join(",")
|
|
41
|
+
);
|
|
42
|
+
el?.focus();
|
|
43
|
+
return Boolean(el);
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
focusFirst,
|
|
48
|
+
prefersReducedMotion
|
|
49
|
+
});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function prefersReducedMotion() {
|
|
3
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4
|
+
}
|
|
5
|
+
function focusFirst(container) {
|
|
6
|
+
if (!container) return false;
|
|
7
|
+
const el = container.querySelector(
|
|
8
|
+
[
|
|
9
|
+
"a[href]",
|
|
10
|
+
"button:not([disabled])",
|
|
11
|
+
"input:not([disabled])",
|
|
12
|
+
"select:not([disabled])",
|
|
13
|
+
"textarea:not([disabled])",
|
|
14
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
15
|
+
].join(",")
|
|
16
|
+
);
|
|
17
|
+
el?.focus();
|
|
18
|
+
return Boolean(el);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
focusFirst,
|
|
22
|
+
prefersReducedMotion
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lessonkit/accessibility",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Accessibility utilities for LessonKit packages and apps.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/eddiethedean/lessonkit.git",
|
|
10
|
+
"directory": "packages/accessibility"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/eddiethedean/lessonkit",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/eddiethedean/lessonkit/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"lessonkit",
|
|
18
|
+
"accessibility",
|
|
19
|
+
"a11y",
|
|
20
|
+
"wcag"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
38
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
39
|
+
"prepublishOnly": "npm run build",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
41
|
+
"test": "vitest run --passWithNoTests",
|
|
42
|
+
"lint": "echo \"(no lint configured yet)\""
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"tsup": "^8.5.0",
|
|
46
|
+
"typescript": "^5.8.3",
|
|
47
|
+
"vitest": "^3.2.4"
|
|
48
|
+
}
|
|
49
|
+
}
|