@intent-framework/dom 0.1.0-alpha.7 → 0.1.0-alpha.9

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.
Files changed (2) hide show
  1. package/README.md +60 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -22,6 +22,66 @@ npm install @intent-framework/core @intent-framework/dom
22
22
  - Opt-in screen-name heading via `showScreenName`
23
23
  - Opt-in semantic data attributes via `showSemanticIds`
24
24
 
25
+ ## renderDom behavior
26
+
27
+ ### Input types
28
+
29
+ | Ask kind | Renders as |
30
+ |----------|------------|
31
+ | `$.state.text()` / default | `<input type="text">` |
32
+ | `asContact("email")` | `<input type="email">` with `autocomplete="email"` |
33
+ | `asSecret()` | `<input type="password">` |
34
+ | `$.state.boolean()` | `<input type="checkbox">` |
35
+ | `$.state.choice()` with `asChoice()` | `<select>` with `<option>` elements |
36
+
37
+ ### Boolean and choice asks
38
+
39
+ Boolean asks render as checkboxes. The checked state is synced with the underlying `BooleanState`.
40
+
41
+ Choice asks render as `<select>` elements. Options are populated from the `ChoiceState` options array. The selected value is synced with the underlying state.
42
+
43
+ ### Blocked reasons
44
+
45
+ When an action is disabled due to blocked reasons, the renderer adds:
46
+
47
+ - `disabled` attribute on the button
48
+ - `<p class="intent-blocked-reason" role="alert">` with the first blocked reason text
49
+ - `aria-describedby` on the button pointing to the reason element
50
+
51
+ When the action becomes enabled, the reason element is removed from the DOM and `aria-describedby` is cleared.
52
+
53
+ ### Single-surface output
54
+
55
+ When a screen has exactly one surface, the output is backward compatible: a single `<main>` element containing one `<form>` with all asks and actions. No surface name suffix is added to DOM ids.
56
+
57
+ ### Multi-surface output
58
+
59
+ When a screen has multiple surfaces, each surface renders as a separate `<section>` with `aria-label` set to the surface name. Each section contains its own `<form>` with only the items belonging to that surface.
60
+
61
+ **DOM id suffixes:** All ask inputs, buttons, hint paragraphs, reason paragraphs, and feedback outputs get a `--<surfaceName>` suffix to avoid id collisions.
62
+
63
+ **Duplicate controls share state:** The same ask appearing in multiple surfaces shares the underlying state. Typing in one surface updates the input in all surfaces.
64
+
65
+ **Duplicate action buttons:** The same action appearing in multiple surfaces renders separate buttons, all executing the same `executeAct()` call.
66
+
67
+ **Per-surface feedback:** Each surface gets its own `<output aria-live="polite">` element. Action feedback is updated independently per surface.
68
+
69
+ **`data-intent-*` semantic ids:** The `data-intent-ask` and `data-intent-action` attributes remain the same across all copies — they identify the semantic node, not the DOM position.
70
+
71
+ ### Enter key default action
72
+
73
+ When exactly one primary action exists (or exactly one action total), pressing Enter in any text input triggers that action. The Enter hint ("Press Enter to ...") appears reactively when the default action becomes enabled, and is hidden when disabled. Shift/ Meta/ Ctrl/ Alt + Enter are ignored. Enter is ignored on `<textarea>`, `<select>`, and checkbox inputs.
74
+
75
+ ### Options
76
+
77
+ ```ts
78
+ renderDom(Screen, {
79
+ target: document.getElementById("root")!,
80
+ showScreenName: true, // render screen name as <h1>
81
+ showSemanticIds: true, // add data-intent-screen, data-intent-ask, data-intent-action attributes
82
+ })
83
+ ```
84
+
25
85
  ## Minimal example
26
86
 
27
87
  ```ts
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.0-alpha.7",
6
+ "version": "0.1.0-alpha.9",
7
7
  "description": "DOM materializer for Intent screens and router",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -26,8 +26,8 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@intent-framework/core": "^0.1.0-alpha.7",
30
- "@intent-framework/router": "^0.1.0-alpha.7"
29
+ "@intent-framework/core": "^0.1.0-alpha.9",
30
+ "@intent-framework/router": "^0.1.0-alpha.9"
31
31
  },
32
32
  "devDependencies": {
33
33
  "jsdom": "^29.1.1",