@capagents/forgeqe 3.1.1 → 3.1.3

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 (258) hide show
  1. package/HOW_TO_USE.md +5152 -1869
  2. package/README.md +155 -434
  3. package/THIRD_PARTY_NOTICES.md +210 -1
  4. package/dist/docs-site/CREDITS.md +6 -0
  5. package/dist/docs-site/architecture-map/index.html +1 -1
  6. package/dist/docs-site/docs/app-theme.css +126 -13
  7. package/dist/docs-site/docs/architecture/index.html +56 -530
  8. package/dist/docs-site/docs/architecture-reference/index.html +1781 -0
  9. package/dist/docs-site/docs/area-api/index.html +491 -0
  10. package/dist/docs-site/docs/area-automated-tests/index.html +1777 -0
  11. package/dist/docs-site/docs/area-browser/index.html +472 -0
  12. package/dist/docs-site/docs/area-data/index.html +595 -0
  13. package/dist/docs-site/docs/area-desktop/index.html +802 -0
  14. package/dist/docs-site/docs/area-mobile/index.html +683 -0
  15. package/dist/docs-site/docs/area-operations/index.html +1243 -0
  16. package/dist/docs-site/docs/area-pull-requests/index.html +290 -0
  17. package/dist/docs-site/docs/area-quality/index.html +427 -0
  18. package/dist/docs-site/docs/area-release/index.html +435 -0
  19. package/dist/docs-site/docs/area-setup/index.html +1595 -0
  20. package/dist/docs-site/docs/area-systems/index.html +191 -0
  21. package/dist/docs-site/docs/area-test-cases/index.html +927 -0
  22. package/dist/docs-site/docs/containers/index.html +168 -189
  23. package/dist/docs-site/docs/cost-architecture/index.html +110 -113
  24. package/dist/docs-site/docs/custom-agents-first-run/index.html +121 -67
  25. package/dist/docs-site/docs/desktop/index.html +363 -373
  26. package/dist/docs-site/docs/desktop-ci/index.html +39 -36
  27. package/dist/docs-site/docs/docs-tabs.js +56 -0
  28. package/dist/docs-site/docs/evidence/index.html +297 -300
  29. package/dist/docs-site/docs/feature-test-prompts/index.html +79 -73
  30. package/dist/docs-site/docs/get-started/index.html +791 -0
  31. package/dist/docs-site/docs/graphify/index.html +45 -48
  32. package/dist/docs-site/docs/guardrails/index.html +35 -23
  33. package/dist/docs-site/docs/index.html +18 -6729
  34. package/dist/docs-site/docs/mobile/index.html +223 -210
  35. package/dist/docs-site/docs/model-routing/index.html +84 -65
  36. package/dist/docs-site/docs/overview/index.html +192 -0
  37. package/dist/docs-site/docs/product-graph/index.html +60 -62
  38. package/dist/docs-site/docs/product-knowledge/index.html +24 -17
  39. package/dist/docs-site/docs/product-views/index.html +57 -60
  40. package/dist/docs-site/docs/reference/index.html +409 -0
  41. package/dist/docs-site/docs/search.js +1 -1
  42. package/dist/docs-site/docs/using/index.html +798 -0
  43. package/dist/docs-site/docs/web-app/index.html +168 -111
  44. package/dist/docs-site/security/index.html +930 -0
  45. package/dist/docs-site/security/security-theme.css +161 -0
  46. package/dist/docs-site/security/security.js +1465 -0
  47. package/dist/docs-site/vendor/react-18.3.1.production.min.js +31 -0
  48. package/dist/docs-site/vendor/react-dom-18.3.1.production.min.js +267 -0
  49. package/dist/docs-site/vendor/reactflow-11.11.4.umd.js +10 -0
  50. package/dist/forgeqe.js +1903 -1896
  51. package/dist/web/THIRD_PARTY_NOTICES.md +0 -136
  52. package/dist/web/assets/Agent-3pV8Rwap.js +8 -0
  53. package/dist/web/assets/AgentWork-DAnmH0My.js +2 -0
  54. package/dist/web/assets/ApiTests-DW4MRFzG.js +10 -0
  55. package/dist/web/assets/Browse-Bd0ZZfc2.js +1 -0
  56. package/dist/web/assets/Chat-DnBUm_97.js +3 -0
  57. package/dist/web/assets/CommandPalette-B1O9aDTk.js +1 -0
  58. package/dist/web/assets/Compare-1v7_ca7z.js +1 -0
  59. package/dist/web/assets/Cost-CWrc4McH.js +1 -0
  60. package/dist/web/assets/Data-rWSiG4Cq.js +6 -0
  61. package/dist/web/assets/Desktop-3x6EQqos.js +1 -0
  62. package/dist/web/assets/DesktopReview-cSA10Rm3.js +1 -0
  63. package/dist/web/assets/Evidence-CKy3o7cw.js +1 -0
  64. package/dist/web/assets/Explore-CMAxWE_8.js +2 -0
  65. package/dist/web/assets/Features-haQchkhA.js +1 -0
  66. package/dist/web/assets/Flags-BaQjYi_t.js +2 -0
  67. package/dist/web/assets/Flaky-DUuC0qTn.js +1 -0
  68. package/dist/web/assets/Impact-CP0H8ygo.js +3 -0
  69. package/dist/web/assets/Jobs-cYxoYd3i.js +5 -0
  70. package/dist/web/assets/KindPage-DWW8gN5_.js +6 -0
  71. package/dist/web/assets/Migration-Bsm7WU1d.js +2 -0
  72. package/dist/web/assets/PageAgent-c95zT2PJ.js +1 -0
  73. package/dist/web/assets/Product-BQSiR28a.js +7 -0
  74. package/dist/web/assets/Production-CAv0Vtoy.js +1 -0
  75. package/dist/web/assets/Quality-aQPaPYQc.js +1 -0
  76. package/dist/web/assets/Readiness-CkknP87n.js +1 -0
  77. package/dist/web/assets/Record-09IsC9U-.js +1 -0
  78. package/dist/web/assets/Regression-BL4MfN47.js +5 -0
  79. package/dist/web/assets/RelationGraph-Dg4fqt7l.js +1 -0
  80. package/dist/web/assets/Reports-CMV1l-iS.js +2 -0
  81. package/dist/web/assets/Response-DTBFBeKB.js +9 -0
  82. package/dist/web/assets/Responsive-DBRQ9FUO.js +3 -0
  83. package/dist/web/assets/RunDiff-CMDrnsA3.js +1 -0
  84. package/dist/web/assets/Runs-Dkeu6_vZ.js +2 -0
  85. package/dist/web/assets/Settings-KjKm8h-_.js +21 -0
  86. package/dist/web/assets/Steps-HYHK9psI.js +2 -0
  87. package/dist/web/assets/TestCases-Cv6-OSv0.js +1 -0
  88. package/dist/web/assets/TestData-DbEfNlUE.js +2 -0
  89. package/dist/web/assets/TestDebt-DzHQIU4X.js +1 -0
  90. package/dist/web/assets/TestManagement-BgRTGHMT.js +1 -0
  91. package/dist/web/assets/Tosca-DZpHAtnH.js +3 -0
  92. package/dist/web/assets/WhatsNew-jp0c4WSV.js +1 -0
  93. package/dist/web/assets/agents-C0Jg2pN8.js +1 -0
  94. package/dist/web/assets/coverage-BB9BLjGz.js +5 -0
  95. package/dist/web/assets/dataParts-DEPK4eQE.js +3 -0
  96. package/dist/web/assets/diff-CcNwLCX6.js +2 -0
  97. package/dist/web/assets/families-gkpkloLT.js +1 -0
  98. package/dist/web/assets/filters-C7phIFfd.js +1 -0
  99. package/dist/web/assets/fold-i73P-EDV.js +1 -0
  100. package/dist/web/assets/head-BtTqyLlj.js +1 -0
  101. package/dist/web/assets/highlight-DZI39CzZ.js +4 -0
  102. package/dist/web/assets/index-ClFOh63x.css +2 -0
  103. package/dist/web/assets/index-YGWJEkAT.js +64 -0
  104. package/dist/web/assets/input-C2vQ9O3a.js +1 -0
  105. package/dist/web/assets/jsx-runtime-LKYXHABd.js +1 -0
  106. package/dist/web/assets/logos-BmbNTDu2.js +1 -0
  107. package/dist/web/assets/palette-XFlqvgZl.js +1 -0
  108. package/dist/web/assets/paletteCommands-DsbD2ASU.js +1 -0
  109. package/dist/web/assets/parts-DEVx2Sea.js +1 -0
  110. package/dist/web/assets/productParts-Bi-XjszL.js +1 -0
  111. package/dist/web/assets/qualityParts-Dbu01g7G.js +1 -0
  112. package/dist/web/assets/recordTest--Wr40QdN.js +1 -0
  113. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  114. package/dist/web/assets/route-Dg53WdFu.js +1 -0
  115. package/dist/web/index.html +11 -6
  116. package/docs/ARCHITECTURE.md +50 -563
  117. package/docs/ARCHITECTURE_REFERENCE.md +1484 -0
  118. package/docs/BASAL.md +1 -1
  119. package/docs/CONTAINERS.md +87 -87
  120. package/docs/CUSTOM_AGENTS_FIRST_RUN.md +125 -43
  121. package/docs/DESKTOP-CI.md +18 -3
  122. package/docs/DESKTOP.md +306 -286
  123. package/docs/EVIDENCE.md +1 -1
  124. package/docs/MOBILE.md +107 -75
  125. package/docs/MODEL_ROUTING.md +48 -15
  126. package/docs/PRODUCT_KNOWLEDGE.md +2 -0
  127. package/docs/WEB_APP.md +143 -75
  128. package/docs/feature-test-prompts.md +29 -16
  129. package/docs/user-guide.html +5402 -2269
  130. package/forgeqe.example.yaml +3 -3
  131. package/guardrails/README.md +22 -2
  132. package/knowledge/README.md +15 -2
  133. package/package.json +1 -1
  134. package/prompts/brain.md +1 -0
  135. package/prompts/page-differs.md +1 -1
  136. package/prompts/requests-rule.md +1 -1
  137. package/prompts/test-reviewer.md +1 -1
  138. package/prompts/test-rules.md +3 -4
  139. package/py/forgeqe_engine/recordsession.py +100 -24
  140. package/skills/web-guidance/LICENSE +202 -0
  141. package/skills/web-guidance/SKILL.md +76 -0
  142. package/skills/web-guidance/UPSTREAM +67 -0
  143. package/skills/web-guidance/references/accessibility/accessibility.md +585 -0
  144. package/skills/web-guidance/references/accessibility/accessible-error-announcement.md +302 -0
  145. package/skills/web-guidance/references/accessibility/accessible-generated-content.md +41 -0
  146. package/skills/web-guidance/references/accessibility/respect-os-text-scale.md +127 -0
  147. package/skills/web-guidance/references/css/responsive-design.md +16 -0
  148. package/skills/web-guidance/references/forms/autofill-address-form.md +86 -0
  149. package/skills/web-guidance/references/forms/autofill-payment-form.md +142 -0
  150. package/skills/web-guidance/references/forms/autofill-sign-in-form.md +145 -0
  151. package/skills/web-guidance/references/forms/autofill-sign-up-form.md +155 -0
  152. package/skills/web-guidance/references/forms/forms.md +415 -0
  153. package/skills/web-guidance/references/forms/ime-safe-enter-submit.md +115 -0
  154. package/skills/web-guidance/references/forms/required-field-feedback.md +317 -0
  155. package/skills/web-guidance/references/forms/select-menu-interaction.md +310 -0
  156. package/skills/web-guidance/references/forms/slider.md +184 -0
  157. package/skills/web-guidance/references/forms/sms-otp-form.md +208 -0
  158. package/skills/web-guidance/references/forms/switch.md +60 -0
  159. package/skills/web-guidance/references/forms/validate-input-after-interaction.md +406 -0
  160. package/skills/web-guidance/references/performance/break-up-long-tasks.md +64 -0
  161. package/skills/web-guidance/references/performance/identify-heavy-scripts.md +69 -0
  162. package/skills/web-guidance/references/performance/identify-inp-causes.md +105 -0
  163. package/skills/web-guidance/references/performance/interaction-paint-timing.md +200 -0
  164. package/skills/web-guidance/references/performance/optimize-image-priority.md +73 -0
  165. package/skills/web-guidance/references/performance/performance.md +384 -0
  166. package/skills/web-guidance/references/privacy/privacy.md +247 -0
  167. package/skills/web-guidance/references/security/passkey-authentication.md +218 -0
  168. package/skills/web-guidance/references/security/passkey-management.md +310 -0
  169. package/skills/web-guidance/references/security/passkey-reauthentication.md +142 -0
  170. package/skills/web-guidance/references/security/passkey-registration.md +186 -0
  171. package/skills/web-guidance/references/security/passkeys.md +39 -0
  172. package/skills/web-guidance/references/security/sanitize-untrusted-html.md +105 -0
  173. package/skills/web-guidance/references/security/secure-external-subresources.md +202 -0
  174. package/skills/web-guidance/references/security/security.md +390 -0
  175. package/skills/web-guidance/references/security/trusted-types.md +141 -0
  176. package/skills/web-guidance/references/security/validate-origins.md +197 -0
  177. package/skills/web-guidance/references/security/verify-email-ownership.md +235 -0
  178. package/skills/web-guidance/references/ui-atoms/position-aware-tooltips.md +173 -0
  179. package/skills/web-guidance/references/ui-atoms/responsive-table.md +122 -0
  180. package/skills/web-guidance/references/ui-atoms/viewport-aware-dropdowns.md +178 -0
  181. package/skills/web-guidance/references/ui-behaviors/drag-and-drop.md +108 -0
  182. package/skills/web-guidance/references/ui-behaviors/light-dismiss-a-dialog.md +89 -0
  183. package/skills/web-guidance/references/ui-behaviors/motion.md +97 -0
  184. package/skills/web-guidance/references/ui-behaviors/platform-controls-dismiss-dialog.md +40 -0
  185. package/skills/web-guidance/references/ui-behaviors/prevent-page-scroll-under-modal-dialog.md +59 -0
  186. package/skills/web-guidance/references/ui-behaviors/search-hidden-content.md +141 -0
  187. package/skills/web-guidance/references/ui-behaviors/sortable-table.md +140 -0
  188. package/skills/web-guidance/references/ui-components/accordion.md +343 -0
  189. package/skills/web-guidance/references/ui-components/breadcrumbs.md +168 -0
  190. package/skills/web-guidance/references/ui-components/carousel.md +206 -0
  191. package/skills/web-guidance/references/ui-components/checkbox.md +144 -0
  192. package/skills/web-guidance/references/ui-components/dialog.md +218 -0
  193. package/skills/web-guidance/references/ui-components/hovercard.md +391 -0
  194. package/skills/web-guidance/references/ui-components/menu.md +415 -0
  195. package/skills/web-guidance/references/ui-components/navbar.md +281 -0
  196. package/skills/web-guidance/references/ui-components/navigation-drawer.md +429 -0
  197. package/skills/web-guidance/references/ui-components/persistent-toast-notifications.md +185 -0
  198. package/skills/web-guidance/references/ui-components/progress.md +181 -0
  199. package/skills/web-guidance/references/ui-components/spinner.md +179 -0
  200. package/skills/web-guidance/references/ui-components/tabs.md +371 -0
  201. package/skills/web-guidance/references/ui-components/toolbar.md +277 -0
  202. package/skills/web-guidance/references/user-experience/form-factor-adaptation.md +120 -0
  203. package/skills/web-guidance/references/user-experience/natural-interactions.md +155 -0
  204. package/skills/web-guidance/references/visual-design/color.md +43 -0
  205. package/skills/web-guidance/references/visual-design/dark-mode.md +350 -0
  206. package/dist/web/assets/AgentWork-DwAI0_Of.js +0 -2
  207. package/dist/web/assets/ApiTests-C0vFSHmM.js +0 -10
  208. package/dist/web/assets/Browse-5jfdtRc5.js +0 -2
  209. package/dist/web/assets/Chat-B3uhI94O.js +0 -3
  210. package/dist/web/assets/CommandPalette-D2J4nf5y.js +0 -1
  211. package/dist/web/assets/Compare-CN75w1p9.js +0 -1
  212. package/dist/web/assets/Cost-QoxyjR95.js +0 -1
  213. package/dist/web/assets/Data-BAvkcBVt.js +0 -6
  214. package/dist/web/assets/Desktop-BXdOIalN.js +0 -1
  215. package/dist/web/assets/DesktopReview-Bl2SrPP0.js +0 -1
  216. package/dist/web/assets/Evidence-BJ_I52CD.js +0 -1
  217. package/dist/web/assets/Explore-D9AuyTip.js +0 -2
  218. package/dist/web/assets/Features-CusGMDR9.js +0 -1
  219. package/dist/web/assets/Flags-CycGFuUP.js +0 -2
  220. package/dist/web/assets/Flaky-BcSzJogN.js +0 -1
  221. package/dist/web/assets/Impact-CJHnyZ21.js +0 -3
  222. package/dist/web/assets/Jobs-4xcFzEFo.js +0 -5
  223. package/dist/web/assets/KindPage-BielEIej.js +0 -6
  224. package/dist/web/assets/Migration-NwanKpJg.js +0 -2
  225. package/dist/web/assets/PageAgent-CNw4NXva.js +0 -1
  226. package/dist/web/assets/Product-DS3LJZ4P.js +0 -7
  227. package/dist/web/assets/Production-D3zsyNIS.js +0 -1
  228. package/dist/web/assets/Quality-Ctj2YpC4.js +0 -1
  229. package/dist/web/assets/Readiness-DGcRr_co.js +0 -1
  230. package/dist/web/assets/Record-Cc-wGe_Y.js +0 -1
  231. package/dist/web/assets/Regression-DcsbrRa1.js +0 -5
  232. package/dist/web/assets/Reports-BkCn0-Sf.js +0 -2
  233. package/dist/web/assets/Response-BP0UwQcW.js +0 -9
  234. package/dist/web/assets/Responsive-C8U7dumd.js +0 -3
  235. package/dist/web/assets/RunDiff-BhABuhF_.js +0 -1
  236. package/dist/web/assets/Runs-OwdWEYBv.js +0 -2
  237. package/dist/web/assets/Steps-BvzbQyoD.js +0 -2
  238. package/dist/web/assets/TestCases-CLq_6JA5.js +0 -1
  239. package/dist/web/assets/TestData-B0oKAhp6.js +0 -2
  240. package/dist/web/assets/TestDebt-8NLQ5YV_.js +0 -1
  241. package/dist/web/assets/TestManagement-2LYQ7vsN.js +0 -1
  242. package/dist/web/assets/Tosca-DfvMpPTG.js +0 -3
  243. package/dist/web/assets/WhatsNew-BGFNGwqN.js +0 -1
  244. package/dist/web/assets/families-DYlN5v0i.js +0 -1
  245. package/dist/web/assets/filters-faaSnoIq.js +0 -1
  246. package/dist/web/assets/fold-CUjwWAK3.js +0 -1
  247. package/dist/web/assets/frame-BLPdAXUq.js +0 -13
  248. package/dist/web/assets/head-CsTxBsO0.js +0 -1
  249. package/dist/web/assets/index-CxiCvGZq.js +0 -78
  250. package/dist/web/assets/index-dOIsrzhD.css +0 -2
  251. package/dist/web/assets/line-icons-CwZWt93L.js +0 -1
  252. package/dist/web/assets/logos-dGuc1jIM.js +0 -1
  253. package/dist/web/assets/markdown-BI3F-SJ1.js +0 -10
  254. package/dist/web/assets/paletteCommands-QJiCuUEr.js +0 -1
  255. package/dist/web/assets/parts-CdF1f7yS.js +0 -1
  256. package/dist/web/assets/productParts-hNLD9fN0.js +0 -1
  257. package/dist/web/assets/qualityParts-CT25lBWU.js +0 -1
  258. package/dist/web/assets/recordTest-P792aBUt.js +0 -1
@@ -0,0 +1,415 @@
1
+ # Forms
2
+
3
+ ## 1. Semantic Structure and Form Element
4
+
5
+ ### Guidelines
6
+
7
+ - **DO** use the `<form>` element to wrap interactive controls for data collection.
8
+ - **DO** wrap search forms and filtering controls in a `<search>` element.
9
+ - **DO** give `<form>` elements an accessible name via `aria-labelledby` (pointing to the form's heading) when a page has multiple forms.
10
+ - **DO** use `method="POST"` for sensitive data and mutations; use `method="GET"` for idempotent requests (e.g., search).
11
+ - **DO** specify the `action` attribute for the destination URL.
12
+ - **DO** specify a `name` attribute for every form control to identify data on submission.
13
+ - **DO** use semantic tags like `<button type="submit">`, `<textarea>`, `<select>`, and specific `<input>` types.
14
+ - **DO** explicitly set `type="button"` on secondary or helper buttons so they don't default to type="submit".
15
+ - **DO** use `<fieldset>` and `<legend>` (with `<legend>` as the first child) to group related controls. **DON'T** use `<fieldset>` for visual styling without a `<legend>`
16
+ - **DO** use actionable language on submit buttons (e.g., "Save changes").
17
+
18
+ - **DON'T** nest `<form>` elements inside other `<form>` elements.
19
+ - **DON'T** use `GET` for sensitive data (it exposes data in history/logs).
20
+ - **DON'T** use generic `<div>`, `<span>`, or `<a>` elements for form controls.
21
+ - **DON'T** use `type="button"` for primary submission buttons.
22
+ - **DON'T** disable textarea resizing without alternate layout provisions.
23
+ - **DON'T** use CSS to visually reorder form controls away from their DOM/keyboard `Tab` order.
24
+ - **DON'T** auto-submit a form when a user changes `<select>`, radio buttons, or checkbox without an explicit submit action.
25
+
26
+ ### Code Example
27
+
28
+ ```html
29
+ <search>
30
+ <form action="/search" method="GET">
31
+ <label for="q">Search query</label>
32
+ <input type="search" id="q" name="q">
33
+
34
+ <fieldset>
35
+ <legend>Search filters</legend>
36
+ <input type="checkbox" id="exact" name="exact" value="true">
37
+ <label for="exact">Exact match only</label>
38
+ <input type="checkbox" id="archived" name="archived" value="true">
39
+ <label for="archived">Include archived results</label>
40
+ </fieldset>
41
+
42
+ <button type="submit">Search</button>
43
+ </form>
44
+ </search>
45
+ ```
46
+
47
+ ### Selection Control Decision Matrix
48
+
49
+ | Options Count | Choice Type | Recommended Element | Usability & Accessibility Logic |
50
+ | :--- | :--- | :--- | :--- |
51
+ | **1** | Binary toggle (Yes/No) | `<input type="checkbox">` | **Reversible State**: Can be checked and unchecked with space unlike a radio button, which gets stuck once checked. |
52
+ | **2–5** | Single (Exclusive) | `<input type="radio">` | **Zero-click scanning**: All choices are immediately visible. Faster scan time. |
53
+ | **6+** | Single (Exclusive) | `<select>` | **Space conservation**: Use only when vertical space is premium or the list is long. |
54
+ | **10+ / Dynamic** | Single (Exclusive) | `<input list="id">` (`<datalist>`) | **Fuzzy Search**: Prevents scrolling fatigue in massive sets (e.g., countries). |
55
+ | **2+** | Multi-select | `<input type="checkbox">` | **Standard semantics**: Native non-exclusive toggles. |
56
+
57
+ **Single-Sentence Mental Model**: "Expose 2 to 5 mutually exclusive options as visible radio buttons when choices are fewer than six; use `<select>` only when space is constrained or the list is long."
58
+
59
+ ## 2. Accessible Labeling and State
60
+
61
+ ### Guidelines
62
+
63
+ - **DO** always associate `<label>` with its input using `for` and `id`.
64
+ - **DO** place `<label>` elements before text inputs, `<textarea>`, and `<select>` controls in the DOM and stack them visually above the control for faster scanning.
65
+ - **DO** place `<label>` elements inline immediately after `<input type="checkbox">` and `<input type="radio">` controls for consistent alignment.
66
+ - **DO** use visible labels and keep critical format instructions (e.g., `3-12 characters`) in the label or persistent helper text; do not rely on `placeholder` alone.
67
+ - **DO** ensure the vertical margin between a label and its input is less than the margin between form groups (**Gestalt Proximity Rule**).
68
+ - **DO** set `aria-invalid="true"` on form controls that fail custom validation, and clear it once resolved.
69
+ - **DO** use `aria-describedby` to link inputs with help text or error messages.
70
+ - **DO** define the `lang` attribute on `<html>` for proper device translation.
71
+ - **DO** use non-color visual cues (icons, text) to communicate state (don't rely on color alone).
72
+ - **DO** indicate clearly which fields are required both visually in the label and programmatically with the `required` attribute.
73
+ - **DO** use `aria-live` for dynamic error announcements.
74
+
75
+ - **DON'T** use `aria-label` when a visible `<label>` can be used or override visible text with a mismatched `aria-label`.
76
+
77
+ ### Code Example
78
+
79
+ ```html
80
+ <div class="field">
81
+ <label for="username">Username: <span aria-hidden="true">*</span></label>
82
+ <input type="text" id="username" name="username" aria-describedby="user-help" required>
83
+ <span id="user-help" class="hint">3-12 characters.</span>
84
+ </div>
85
+
86
+ <style>
87
+ .field {
88
+ display: flex;
89
+ flex-direction: column;
90
+ align-items: flex-start;
91
+ gap: 0.25rem;
92
+ margin-block-end: 1.5rem;
93
+ }
94
+
95
+ input:focus-visible {
96
+ outline: 3px solid #0b57d0;
97
+ outline-offset: 2px;
98
+ }
99
+ </style>
100
+ ```
101
+
102
+ ## 3. Autofill and Input Hints
103
+
104
+ ### Guidelines
105
+
106
+ - **DO** use the `autocomplete` attribute to specify expected data (e.g., `email`, `tel`, `current-password`, `new-password`).
107
+ - **DO** use `inputmode` to optimize on-screen keyboards (e.g., `inputmode="numeric"` for PINs).
108
+ - **DO** use `enterkeyhint` to set the Enter key label (e.g., `next`, `done`).
109
+ - **DO** turn off text correction on fields that hold identifiers rather than prose: `autocorrect="off"` (plus `autocapitalize="none"` and `spellcheck="false"`) on usernames, emails, URLs, codes, and search inputs. Leave the defaults on for free-text fields like messages and comments.
110
+ - **DO** use single-field inputs for complex numbers (credit cards, phones) to help autofill.
111
+ - **DO** use a single `<input type="text" inputmode="numeric" autocomplete="one-time-code">` and the WebOTP API for SMS one-time passcode verification. See guide `sms-otp-form` (references/forms/sms-otp-form.md).
112
+
113
+ - **DON'T** use `type="number"` for credit cards, ZIP codes, or one-time passcodes (causes UI scroll issues and removes leading zeros).
114
+ - **DON'T** split a single value (such as a 6-digit OTP, phone number, or credit card) across multiple `<input>` boxes that auto-advance focus on keypress. Instead, use `type="text"` with `inputmode="numeric"` (`type=number` adds spinner buttons). If needed, styling can convey a similar UI. JS can set a `--value-length` CSS variable for higher fidelity styling that resembles these inputs, without their usability and accessibility issues.
115
+ - **DON'T** block copy-and-paste (`paste` events) or disable `autocomplete` on passwords, verification codes, or other authentication fields.
116
+
117
+ ### Code Example
118
+
119
+ ```html
120
+ <label for="zip">ZIP Code:</label>
121
+ <input type="text" id="zip" name="zip" autocomplete="postal-code" inputmode="numeric" pattern="\d{5}" enterkeyhint="next">
122
+
123
+ <label for="username">Username:</label>
124
+ <input type="text" id="username" name="username" autocomplete="username" autocorrect="off" autocapitalize="none" spellcheck="false" enterkeyhint="done">
125
+ ```
126
+
127
+ ## 4. Constraints and Validation
128
+
129
+ ### Guidelines
130
+
131
+ - **DO** use native constraints: `required`, `minlength`, `maxlength`, `pattern`.
132
+ - **DO** use CSS pseudo-classes `:user-invalid` for non-intrusive styling.
133
+ - **DO** use the ValidityState API (`setCustomValidity`) for custom messaging and write clear error messages that explain how to fix the issue.
134
+ - **DO** move focus to the first invalid field (or an error summary) when a form submission fails validation.
135
+
136
+ - **DON'T** use the raw `:invalid` CSS pseudo-class alone for error styling to ensure empty required fields are not marked as invalid before the user interacts with the form.
137
+ - **DON'T** disable submit buttons to block validation; let users submit and highlight errors. However, **DO** disable the button *after* a valid submission is clicked to prevent double-posts.
138
+ - **DON'T** trigger validation errors or `aria-live` error announcements on every keystroke while the user is typing (validate on submit or `blur`, and clear errors on `input` once resolved).
139
+
140
+ ### Code Example
141
+
142
+ ```html
143
+ <label for="code">Activation Code (4 digits):</label>
144
+ <input type="text" id="code" name="code" required pattern="\d{4}">
145
+
146
+ <script>
147
+ const input = document.getElementById('code');
148
+ input.addEventListener('invalid', () => {
149
+ input.setCustomValidity('Please enter exactly 4 digits.');
150
+ });
151
+ input.addEventListener('input', () => {
152
+ input.setCustomValidity('');
153
+ });
154
+ </script>
155
+ ```
156
+
157
+ ### Validation Event Timing Matrix
158
+
159
+ | Event Trigger | Phase | Action Allowed | UX / Accessibility Logic |
160
+ | :--- | :--- | :--- | :--- |
161
+ | **`input`** | Active Typing | **Clear** existing errors only. | **Non-intrusive**: Do not yell at the user before they finish typing. |
162
+ | **`blur` / `focusout`** | Exiting Field | **Run** check (if edited) and show error. | **Contextual validation**: Validate once the user indicates they are "done" with a field. |
163
+ | **`submit`** | Final Attempt | **Block** and route focus. | **Final gatekeeper**: Intercepts bad payloads and moves keyboard and screen reader focus to the first invalid field or an error summary. |
164
+
165
+ **Single-Sentence Mental Model**: "Validate on `blur` (if edited) to avoid premature warnings while typing, and reset error states on `input` as soon as the user fixes the value, and route the focus to the first error or summary on `submit`."
166
+
167
+ **Security vs UX Scale**: Client-side validation is for User Experience; Server-side validation is for Security. Never treat browser constraints as a data integrity defense.
168
+
169
+ ## 5. Responsive Design and Typography
170
+
171
+ ### Guidelines
172
+
173
+ - **DO** use single-column layouts for scanning.
174
+ - **DO** set `font: inherit` and `font-size: max(1rem, 1em)` on form controls to scale with larger containers while staying at least `1rem`(16px) to prevent iOS zoom.
175
+ - **DO** expand clickable areas for mobile tap targets using padding tricks.
176
+ - **DO** ensure tap targets are at least `48px`.
177
+ - **DO** use units relative to root (`rem`) and unitless `line-height`.
178
+ - **DO** use CSS logical properties (e.g., `margin-inline-start`) for RTL support.
179
+
180
+ ### Code Example
181
+
182
+ ```css
183
+ .form-group {
184
+ margin-block-end: 1.5rem;
185
+ }
186
+
187
+ /* Expand clickable tap area without layout shift */
188
+ label {
189
+ display: inline-block;
190
+ padding: 10px 0;
191
+ margin: -10px 0;
192
+ }
193
+
194
+ input {
195
+ font: inherit;
196
+ font-size: max(1rem, 1em);
197
+ padding: 0.75rem;
198
+ min-height: 48px;
199
+ box-sizing: border-box;
200
+ }
201
+
202
+ @media (pointer: coarse) {
203
+ input {
204
+ min-height: 52px;
205
+ }
206
+ }
207
+ ```
208
+
209
+ ## 6. Styling Form Controls
210
+
211
+ ### Guidelines
212
+
213
+ - **DO** use `accent-color` for quick branding of native radios/checkboxes.
214
+ - **DO** use `appearance: none` for custom dropdown arrows without breaking semantics.
215
+ - **DO** ensure inputs are clearly visible with adequate border contrast (e.g., `#767676` or darker on white backgrounds).
216
+ - **DO** maintain a visible `:focus-visible` indicator on all controls. Never disable focus outlines (`outline:none`) without providing a high-contrast alternative.
217
+ - **DO** hide inputs visually using the canonical `.visually-hidden` recipe (`clip-path: inset(50%)` with 1px dimensions) — NOT `display: none`, which removes them from the accessibility tree.
218
+
219
+ ### Code Example
220
+
221
+ ```html
222
+ <div class="checkbox-container">
223
+ <input type="checkbox" id="sub" name="sub" class="visually-hidden">
224
+ <label for="sub" class="checkbox-label">Subscribe</label>
225
+ </div>
226
+
227
+ <style>
228
+ .visually-hidden {
229
+ position: absolute;
230
+ clip-path: inset(50%);
231
+ overflow: hidden;
232
+ width: 1px;
233
+ height: 1px;
234
+ margin: -1px;
235
+ padding: 0;
236
+ border: 0;
237
+ white-space: nowrap;
238
+ }
239
+ .checkbox-label::before {
240
+ content: "";
241
+ display: inline-block;
242
+ width: 1.25rem;
243
+ height: 1.25rem;
244
+ border: 2px solid #767676;
245
+ }
246
+ input:focus-visible + .checkbox-label::before {
247
+ outline: 2px solid #0b57d0;
248
+ }
249
+ </style>
250
+ ```
251
+
252
+ ## 7. JavaScript and AJAX
253
+
254
+ ### Guidelines
255
+
256
+ - **DO** check `KeyboardEvent.isComposing` before treating the `Enter` key as a submit action in chat or text inputs to ensure IME text composition is not interrupted. See guide `ime-safe-enter-submit` (references/forms/ime-safe-enter-submit.md).
257
+ - **DO** prevent default navigation on form submit for AJAX (`e.preventDefault()`).
258
+ - **DO** use `ValidityState` interfaces for real-time validation checks.
259
+ - **DO** announce AJAX submission results via `role="status"` or `aria-live`.
260
+ - **DO** use `aria-expanded` and `aria-controls` for dynamic UI reveals.
261
+
262
+ - **DON'T** block page submission if JS fails; ensure server-side fallback.
263
+
264
+ ### Code Example
265
+
266
+ ```js
267
+ form.addEventListener('submit', (e) => {
268
+ e.preventDefault();
269
+ const data = new FormData(form);
270
+ // fetch('/submit', { method: 'POST', body: data });
271
+ });
272
+ ```
273
+
274
+ ## 8. Identity, Payments, and Advanced Security
275
+
276
+ ### Guidelines
277
+
278
+ - **DO** use `autocomplete="new-password"` for sign-up and `autocomplete="current-password"` for sign-in.
279
+ - **DO** allow pasting into password fields.
280
+ - **DO** provide an accessible toggle `<button type="button">` with `aria-pressed` allowing users to unmask password input.
281
+ - **DO** indicate exact amounts on pay buttons (e.g., "Pay $100").
282
+ - **DO** use `autocomplete="cc-number"`, `cc-exp`, `cc-csc`.
283
+ - **DO** use HTTPS for all pages.
284
+ - **DO** implement cryptographically secure anti-CSRF tokens for mutating actions (POST/PUT/DELETE).
285
+ - **DO** sanitize user input (e.g., via DOMPurify) before injecting it into the DOM to prevent XSS.
286
+ - **DO** implement spam protection for open forms using accessible CAPTCHAs (e.g., invisible reCAPTCHA) or honeypot fields hidden from assistive tech (`tabindex="-1"` and `aria-hidden="true"`)
287
+
288
+ - **DON'T** utilize HTTP `GET` for endpoints executing state changes.
289
+ - **DON'T** use inline JavaScript (e.g., `onclick="..."`) directly within form markup to satisfy strict Content Security Policies (CSP).
290
+
291
+ ### Code Example
292
+
293
+ ```html
294
+ <form method="post">
295
+ <input type="hidden" name="csrf_token" value="secure_token_abc123">
296
+
297
+ <h1>Sign up</h1>
298
+
299
+ <div class="form-group">
300
+ <label for="name">Full name</label>
301
+ <input id="name" name="name" autocomplete="name" required pattern="[\p{L}\.\- ]+">
302
+ </div>
303
+
304
+ <div class="form-group">
305
+ <label for="email">Email</label>
306
+ <input id="email" name="email" type="email" autocomplete="username" required>
307
+ </div>
308
+
309
+ <div class="form-group">
310
+ <label for="password">Password</label>
311
+ <button id="toggle-password" type="button" aria-pressed="false" aria-label="Show password" aria-describedby="toggle-warning">
312
+ <img class="icon-eye" src="/icons/eye.svg" alt="" width="20" height="20">
313
+ <img class="icon-eye-off" src="/icons/eye-off.svg" alt="" width="20" height="20">
314
+ </button>
315
+ <span id="toggle-warning" class="visually-hidden">Warning: this will display your password on the screen.</span>
316
+ <input id="password" name="password" type="password" autocomplete="new-password" minlength="8" aria-describedby="password-constraints" required>
317
+ <div id="password-constraints">Eight or more characters.</div>
318
+ </div>
319
+
320
+ <button id="sign-up" type="submit">Sign up</button>
321
+ </form>
322
+ ```
323
+
324
+
325
+ ## 9. Address Collection
326
+
327
+ ### Guidelines
328
+
329
+ - **DO** use a single field for names.
330
+ - **DO** use `autocomplete="street-address"`.
331
+ - If the site has users in different countries, **DO** use the `<textarea>` element for addresses, to accommodate different address formats in different geographical regions. If the form uses separate inputs for address parts (e.g. Street, City), **DO** use `autocomplete` values `address-line1`, `address-line2`, etc.
332
+ - **DO** make postal codes optional.
333
+ - **DO** provide a "Same as shipping address" checkbox when collecting both shipping and billing addresses (and scope `autocomplete` with `shipping` or `billing` inside a `<fieldset>`).
334
+
335
+ - **DON'T** split name inputs into rigid variables ("First", "Last") for global audiences.
336
+ - **DON'T** enforce Latin-only characters for names and usernames.
337
+
338
+ ### Code Example
339
+
340
+ ```html
341
+ <!-- Accessible Address Form with Autofill -->
342
+ <form action="/save-address" method="POST">
343
+ <div class="form-group">
344
+ <label for="full-name">Full name</label>
345
+ <input type="text" id="full-name" name="full_name" maxlength="100" required autocomplete="name">
346
+ </div>
347
+
348
+ <div class="form-group">
349
+ <label for="address">Address</label>
350
+ <textarea id="address" name="address" required autocomplete="street-address" maxlength="300"></textarea>
351
+ </div>
352
+
353
+ <button type="submit">Save Address</button>
354
+ </form>
355
+ ```
356
+
357
+
358
+ ## 10. Usability Testing and Analytics
359
+
360
+ ### Guidelines
361
+
362
+ - **DO** test forms across multiple devices, browsers, and screen sizes.
363
+ - **DO** test keyboard-only navigation (using `Tab`, `Shift+Tab`, `Space`, `Enter`, and Arrow keys) and verify visual focus.
364
+ - **DO** emulate various impairments (visual, motor) using browser tools.
365
+ - **DO** use analytics to monitor form completion rates and bounce points.
366
+ - **DO** track discrete events (e.g., field focus, click) to find micro-friction points.
367
+
368
+ - **DON'T** rely solely on automated tools (Lighthouse) for usability; test with real users.
369
+ - **DON'T** track sensitive personal data in standard event labels.
370
+
371
+ ### Code Example
372
+
373
+ ```html
374
+ <form action="/submit" method="POST" id="track-form">
375
+ <label for="postal-code">ZIP or postal code</label>
376
+ <input type="text" id="postal-code" name="postal-code" autocomplete="postal-code" maxlength="20" required>
377
+ <button type="submit" id="submit-btn">Submit</button>
378
+ </form>
379
+
380
+ <script>
381
+ const trackForm = document.getElementById('track-form');
382
+ const trackBtn = document.getElementById('submit-btn');
383
+
384
+ trackBtn.addEventListener('click', () => {
385
+ console.log('Analytics Event: Submit clicked');
386
+ });
387
+ </script>
388
+ ```
389
+
390
+ ## 11. Multi-Page Forms
391
+
392
+ ### Guidelines
393
+
394
+ - **DO** clearly display progress through a multi-page form with clear labels and accessible progress indicators (e.g., `aria-current="step"` or `<progress>`).
395
+ - **DO** allow users to navigate backwards and forwards between pages without losing previously entered data.
396
+ - **DO** move focus to the new step's heading (`tabindex="-1"`) or first input when transitioning between steps dynamically without a full page reload.
397
+ - **DO** use context-specific `enterkeyhint` values (e.g., `"previous"`, `"next"`) to guide navigation via on-screen keyboards.
398
+ - **DO** design layouts so that the mobile keyboard does not obscure inputs or buttons (e.g., by placing them in the upper half of the viewport when focused or using CSS scroll-padding).
399
+
400
+ - **DON'T** leave inactive wizard steps in the keyboard `Tab` order or accessibility tree (use `hidden`, `display: none`, or `inert` on non-active steps).
401
+
402
+ ### Code Example
403
+
404
+ ```html
405
+ <nav aria-label="Progress">
406
+ <ol class="progress-tracker">
407
+ <li class="step-done">Step 1: Account (completed)</li>
408
+ <li class="step-active" aria-current="step">Step 2: Shipping</li>
409
+ <li class="step-todo">Step 3: Payment</li>
410
+ </ol>
411
+ </nav>
412
+
413
+ <button type="button" onclick="history.back()" enterkeyhint="previous">Previous</button>
414
+ <button type="submit" enterkeyhint="next">Next</button>
415
+ ```
@@ -0,0 +1,115 @@
1
+ # IME-safe enter-to-submit
2
+
3
+ Many chat interfaces submit their message when the user presses `Enter` in a `<textarea>`.
4
+
5
+ This works for users typing with direct Latin keyboard input (e.g. English), but breaks for users typing with an Input Method Editor (IME) to compose text in languages like Japanese, Chinese, or Korean.
6
+
7
+ In these contexts, the `Enter`/`Return` key is used to confirm the current character conversion candidate. If custom JavaScript listens to `keydown` on `Enter` and submits immediately, the user's message is sent while they are still converting characters, resulting in incomplete, fragmented, or incorrect messages.
8
+
9
+ The composition-active check applies to any custom `keydown` handler that acts on `Enter`, not only to multiline `<textarea>` fields. Single-line `<input>` fields with their own `Enter` handling, such as search and find bars, inline rename fields, modal dialog fields, and command palettes, receive the same IME-confirming `Enter` keydown as a `<textarea>` does, with `isComposing` set to `true`. Native implicit submission of a `<form>` from an `<input>` with no custom `Enter` handler needs no explicit handling, because browsers suppress implicit submission when the `Enter` keystroke is consumed by an IME.
10
+
11
+ ## Implementation strategy
12
+
13
+ For a `<textarea>` or `<input>` with custom enter-to-submit, check the native `isComposing` property of the `KeyboardEvent` before submitting the content. Also call `event.preventDefault()`: the default action of `Enter` inserts a newline in a `<textarea>`, and in an `<input>` inside a `<form>` it triggers the browser's implicit submission, which would submit a second time.
14
+
15
+ ```html
16
+ <form id="chat-form">
17
+ <label for="chat-input" class="visually-hidden">Message</label>
18
+ <textarea id="chat-input" placeholder="Type a message..."></textarea>
19
+ <button type="submit" id="send-button">Send</button>
20
+ </form>
21
+ ```
22
+
23
+ ```js
24
+ const textarea = document.getElementById('chat-input');
25
+ const form = document.getElementById('chat-form');
26
+
27
+ textarea.addEventListener('keydown', (event) => {
28
+ if (event.key === 'Enter' && !event.shiftKey) {
29
+ // Prevent the default action (newline in a textarea, implicit form submission in an input)
30
+ event.preventDefault();
31
+
32
+ // If the user is composing text, return early.
33
+ if (event.isComposing) {
34
+ return;
35
+ }
36
+
37
+ form.requestSubmit();
38
+ }
39
+ });
40
+ ```
41
+
42
+ For a single-line `<input>`, use the same handler without the `!event.shiftKey` condition, which exists only because `Shift+Enter` inserts a newline in a `<textarea>`.
43
+
44
+ Note: Other custom submission shortcuts (such as `Cmd+Enter` or `Ctrl+Enter`) do not conflict with IME confirmation keys and do not require IME safety checks.
45
+
46
+ ## Accessibility and testing
47
+
48
+ 1. **Explicit submit button**: Always include a `<button type="submit">` element. Keyboard shortcuts are helpers; they must not replace native form submit paths.
49
+ 2. **Accessible inputs**: Ensure all `<input>` and `<textarea>` elements are programmatically associated with a `<label>` using matching `id` and `for` attributes.
50
+
51
+ ## Fallback strategies
52
+
53
+ Browser support for the api.KeyboardEvent.isComposing capability: Limited availability.
54
+ Supported by: Chrome 56 (Jan 2017), Edge 79 (Jan 2020), and Firefox 31 (Jul 2014).
55
+ Unsupported in: Safari.
56
+
57
+ In recent versions of Safari, an event-ordering issue (WebKit bug 165004) delivered `compositionend` to script handlers before the confirming `Enter` `keydown`, even though the underlying events were dispatched in the opposite order. By the time the keydown handler ran, `event.isComposing` had already been reset to `false`, meaning the standard check alone would have failed to prevent premature submission.
58
+
59
+ If you need to support cross-browser compatibility across older versions of Safari and other platforms, adopt one of the following fallback strategies:
60
+
61
+ ### Strategy 1: Add a `keyCode === 229` check (recommended)
62
+
63
+ During IME composition, browsers report `keyCode: 229` (`VK_PROCESSKEY`) instead of `13` on `keydown`, even while setting `event.key === 'Enter'` on the confirming keystroke. Pairing `event.isComposing` with `event.keyCode === 229` reliably catches Safari's out-of-order confirming `Enter` keydown. (This also means legacy `event.keyCode === 13` handlers are already immune to IME confirmation, whereas migrating them to `event.key === 'Enter'` without `event.isComposing` and `event.keyCode === 229` will introduce premature submission.) Because this check is nested under the `event.key === 'Enter'` gate, it is safe from mobile virtual keyboards that might use `229` for normal character layout entry.
64
+
65
+ ```js
66
+ textarea.addEventListener('keydown', (event) => {
67
+ if (event.key === 'Enter' && !event.shiftKey) {
68
+ event.preventDefault();
69
+
70
+ // Block submission if composing natively or if keyCode is 229
71
+ if (event.isComposing || event.keyCode === 229) {
72
+ return;
73
+ }
74
+
75
+ form.requestSubmit();
76
+ }
77
+ });
78
+ ```
79
+
80
+ ### Strategy 2: The `event.timeStamp` window workaround (alternative)
81
+
82
+ For codebases that strictly forbid the use of deprecated APIs like `keyCode`, or if there are known issues with the `229` check in specific targeted environments, you can track the browser-reported event dispatch timestamp instead.
83
+
84
+ Because Safari dispatches the confirming `Enter` keydown event extremely close to the `compositionend` event (often within 5ms, and sometimes with the keydown timestamp being slightly *earlier* due to handler delivery order inversion), checking the time difference is highly reliable and is unlikely to trigger false-positives on mobile virtual keyboards under standard conditions.
85
+
86
+ ```js
87
+ let lastCompositionEndAt = null;
88
+
89
+ textarea.addEventListener('compositionend', (event) => {
90
+ // IMPORTANT: Always use event.timeStamp, not Date.now() or performance.now().
91
+ // Handler-time measurements are vulnerable to drift when the main thread is blocked.
92
+ lastCompositionEndAt = event.timeStamp;
93
+ });
94
+
95
+ textarea.addEventListener('keydown', (event) => {
96
+ if (event.key === 'Enter' && !event.shiftKey) {
97
+ event.preventDefault();
98
+
99
+ if (event.isComposing) {
100
+ return;
101
+ }
102
+
103
+ // Block submission if the event occurs within a 50ms window of composition ending.
104
+ // Math.abs handles Safari's inverted event delivery timing bug.
105
+ if (
106
+ lastCompositionEndAt !== null &&
107
+ Math.abs(event.timeStamp - lastCompositionEndAt) < 50
108
+ ) {
109
+ return;
110
+ }
111
+
112
+ form.requestSubmit();
113
+ }
114
+ });
115
+ ```