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 CHANGED
@@ -1,19 +1,90 @@
1
1
  # html-standard
2
2
 
3
- `html-standard` is a **work-in-progress** JavaScript/TypeScript library that provides structured data from the [HTML Living Standard](https://html.spec.whatwg.org/).
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
- ```console
65
+ ```bash
8
66
  npm install html-standard
9
67
  ```
10
68
 
11
- ## Usage
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
- ```js
14
- import { getElementSpec } from "html-standard";
78
+ # Run tests with UI
79
+ npm run test:ui
15
80
 
16
- const divSpec = getElementSpec("div");
81
+ # Type check
82
+ npm run ts
17
83
 
18
- divSpec.attributes.has("id"); // true
84
+ # Build
85
+ npm run build
19
86
  ```
87
+
88
+ ## License
89
+
90
+ MIT