html-standard 0.0.6 → 0.0.8
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 +78 -7
- package/dist/index.cjs +271 -2376
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -64
- package/dist/index.d.ts +53 -64
- package/dist/index.js +269 -2381
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,19 +1,90 @@
|
|
|
1
1
|
# html-standard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript library that provides utilities for working with the HTML Living Standard specification.
|
|
4
|
+
|
|
5
|
+
> ⚠️ **Experimental**: This project is currently in an experimental stage and may introduce breaking changes frequently.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### Element API
|
|
10
|
+
|
|
11
|
+
Create an element instance to access various HTML standard utilities:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { element } from "html-standard";
|
|
15
|
+
|
|
16
|
+
// Basic usage without attributes
|
|
17
|
+
const button = element("button");
|
|
18
|
+
button.accessibility.implicitRole(); // 'button'
|
|
19
|
+
|
|
20
|
+
const nav = element("nav");
|
|
21
|
+
nav.accessibility.implicitRole(); // 'navigation'
|
|
22
|
+
|
|
23
|
+
// Elements with attributes
|
|
24
|
+
const anchor = element("a", {
|
|
25
|
+
attributes: {
|
|
26
|
+
get: (key) => (key === "href" ? "https://example.com" : null),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
anchor.accessibility.implicitRole(); // 'link'
|
|
30
|
+
|
|
31
|
+
const anchorWithoutHref = element("a");
|
|
32
|
+
anchorWithoutHref.accessibility.implicitRole(); // 'generic'
|
|
33
|
+
|
|
34
|
+
const checkbox = element("input", {
|
|
35
|
+
attributes: {
|
|
36
|
+
get: (key) => (key === "type" ? "checkbox" : null),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
checkbox.accessibility.implicitRole(); // 'checkbox'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Accessibility API
|
|
43
|
+
|
|
44
|
+
Access accessibility utilities directly:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { accessibility } from "html-standard";
|
|
48
|
+
|
|
49
|
+
const buttonA11y = accessibility("button", {
|
|
50
|
+
attributes: {
|
|
51
|
+
get: () => null,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
buttonA11y.implicitRole(); // 'button'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Key Features:**
|
|
58
|
+
|
|
59
|
+
- **Implicit ARIA Roles**: Get the default ARIA role for HTML elements according to the [HTML-ARIA specification](https://www.w3.org/TR/html-aria/)
|
|
60
|
+
- **Attribute-Dependent Roles**: Supports roles that vary based on element attributes (e.g., `<a>`, `<input>`, `<img>`, `<select>`)
|
|
61
|
+
- **Case-Insensitive**: Element names are handled case-insensitively
|
|
4
62
|
|
|
5
63
|
## Installation
|
|
6
64
|
|
|
7
|
-
```
|
|
65
|
+
```bash
|
|
8
66
|
npm install html-standard
|
|
9
67
|
```
|
|
10
68
|
|
|
11
|
-
##
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Run tests
|
|
73
|
+
npm test
|
|
74
|
+
|
|
75
|
+
# Run tests in watch mode
|
|
76
|
+
npm run test:watch
|
|
12
77
|
|
|
13
|
-
|
|
14
|
-
|
|
78
|
+
# Run tests with UI
|
|
79
|
+
npm run test:ui
|
|
15
80
|
|
|
16
|
-
|
|
81
|
+
# Type check
|
|
82
|
+
npm run ts
|
|
17
83
|
|
|
18
|
-
|
|
84
|
+
# Build
|
|
85
|
+
npm run build
|
|
19
86
|
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|