@k8ordo/ui 3.0.0 → 4.0.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.
Files changed (264) hide show
  1. package/README.md +73 -182
  2. package/dist/{integrations/_shared → catalog}/icon-map.d.mts +4 -2
  3. package/dist/catalog/icon-map.mjs +212 -0
  4. package/dist/catalog/icon-names.d.mts +1 -0
  5. package/dist/{integrations/_shared → catalog}/icon-names.mjs +3 -1
  6. package/dist/catalog/index.d.mts +1289 -0
  7. package/dist/catalog/index.mjs +419 -0
  8. package/dist/catalog/render.css +34 -0
  9. package/dist/catalog/render.d.mts +72 -0
  10. package/dist/catalog/render.mjs +631 -0
  11. package/dist/catalog/render.module.mjs +11 -0
  12. package/dist/{integrations/_shared → catalog}/schemas.d.mts +120 -132
  13. package/dist/{integrations/_shared → catalog}/schemas.mjs +189 -131
  14. package/dist/catalog/to-tree.d.mts +4 -0
  15. package/dist/catalog/to-tree.mjs +17 -0
  16. package/dist/components/_internal/checked-values.d.mts +1 -0
  17. package/dist/components/_internal/checked-values.mjs +5 -0
  18. package/dist/components/_internal/field-message.css +25 -0
  19. package/dist/components/_internal/field-message.d.mts +10 -0
  20. package/dist/components/_internal/field-message.mjs +22 -0
  21. package/dist/components/_internal/field-message.module.mjs +9 -0
  22. package/dist/components/_internal/focus-ring.css +1 -1
  23. package/dist/components/_internal/high-contrast.css +1 -0
  24. package/dist/components/{observers/in-view → _internal}/in-view.mjs +1 -1
  25. package/dist/components/{observers/resize → _internal}/resize.mjs +1 -1
  26. package/dist/components/ai/_internal/attachment-preview.mjs +1 -1
  27. package/dist/components/ai/_internal/collapsible.mjs +1 -1
  28. package/dist/components/ai/attachment/attachment.d.mts +1 -1
  29. package/dist/components/ai/attachment/index.d.mts +1 -1
  30. package/dist/components/ai/conversation/conversation.mjs +4 -4
  31. package/dist/components/ai/index.d.mts +2 -2
  32. package/dist/components/ai/message/index.d.mts +2 -2
  33. package/dist/components/ai/message/message.d.mts +2 -2
  34. package/dist/components/ai/message/message.mjs +9 -9
  35. package/dist/components/ai/prompt-input/prompt-input.mjs +4 -4
  36. package/dist/components/ai/source/index.d.mts +2 -2
  37. package/dist/components/ai/source/source.d.mts +2 -2
  38. package/dist/components/ai/source/source.mjs +1 -1
  39. package/dist/components/ai/tool-invocation/approval-bar.mjs +11 -22
  40. package/dist/components/ai/tool-invocation/tool-invocation.d.mts +2 -2
  41. package/dist/components/buttons/button/button.css +1 -1
  42. package/dist/components/buttons/button/button.d.mts +34 -37
  43. package/dist/components/buttons/button/button.mjs +37 -24
  44. package/dist/components/buttons/button/button.module.mjs +0 -1
  45. package/dist/components/buttons/button/index.d.mts +2 -2
  46. package/dist/components/buttons/copy-button/copy-button.mjs +4 -4
  47. package/dist/components/buttons/icon-button/icon-button.css +3 -3
  48. package/dist/components/buttons/icon-button/icon-button.d.mts +37 -43
  49. package/dist/components/buttons/icon-button/icon-button.mjs +73 -63
  50. package/dist/components/buttons/icon-button/icon-button.module.mjs +2 -2
  51. package/dist/components/buttons/icon-button/index.d.mts +2 -2
  52. package/dist/components/buttons/toolbar/toolbar.css +5 -1
  53. package/dist/components/buttons/toolbar/toolbar.mjs +1 -1
  54. package/dist/components/data-display/accordion/accordion-button.d.mts +4 -1
  55. package/dist/components/data-display/accordion/accordion-button.mjs +4 -4
  56. package/dist/components/data-display/accordion/index.d.mts +3 -3
  57. package/dist/components/data-display/card/card-action.d.mts +6 -0
  58. package/dist/components/data-display/card/card-action.mjs +21 -0
  59. package/dist/components/data-display/card/card.css +24 -0
  60. package/dist/components/data-display/card/card.d.mts +26 -3
  61. package/dist/components/data-display/card/card.mjs +46 -6
  62. package/dist/components/data-display/card/card.module.mjs +4 -1
  63. package/dist/components/data-display/card/index.d.mts +2 -2
  64. package/dist/components/data-display/carousel/carousel.mjs +2 -2
  65. package/dist/components/data-display/code/code.css +4 -0
  66. package/dist/components/data-display/code-block/code-block.mjs +1 -1
  67. package/dist/components/data-display/data-table/data-table.css +0 -3
  68. package/dist/components/data-display/data-table/data-table.mjs +25 -26
  69. package/dist/components/data-display/tree/tree.d.mts +1 -1
  70. package/dist/components/data-display/tree/tree.mjs +6 -5
  71. package/dist/components/feedback/alert/alert.d.mts +2 -7
  72. package/dist/components/feedback/alert/alert.mjs +11 -11
  73. package/dist/components/feedback/alert/index.d.mts +2 -2
  74. package/dist/components/feedback/callout/callout.mjs +2 -2
  75. package/dist/components/feedback/progress/progress.mjs +1 -1
  76. package/dist/components/feedback/toast/context.d.mts +4 -5
  77. package/dist/components/feedback/toast/index.d.mts +2 -2
  78. package/dist/components/feedback/toast/provider.d.mts +7 -2
  79. package/dist/components/feedback/toast/provider.mjs +7 -2
  80. package/dist/components/feedback/toast/toast.d.mts +2 -3
  81. package/dist/components/form/autocomplete/autocomplete.d.mts +2 -2
  82. package/dist/components/form/autocomplete/autocomplete.mjs +12 -9
  83. package/dist/components/form/calendar/calendar.mjs +3 -5
  84. package/dist/components/form/checkbox/checkbox.d.mts +3 -1
  85. package/dist/components/form/checkbox/checkbox.mjs +44 -45
  86. package/dist/components/form/checkbox-card/checkbox-card.d.mts +3 -2
  87. package/dist/components/form/checkbox-card/checkbox-card.mjs +13 -6
  88. package/dist/components/form/checkbox-group/checkbox-group.d.mts +15 -20
  89. package/dist/components/form/checkbox-group/checkbox-group.mjs +18 -26
  90. package/dist/components/form/checkbox-group/index.d.mts +2 -34
  91. package/dist/components/form/checkbox-group/index.mjs +1 -8
  92. package/dist/components/form/color-picker/color-picker.css +3 -5
  93. package/dist/components/form/color-picker/color-picker.d.mts +0 -1
  94. package/dist/components/form/color-picker/color-picker.mjs +4 -4
  95. package/dist/components/form/combobox/combobox.d.mts +0 -1
  96. package/dist/components/form/combobox/combobox.mjs +9 -8
  97. package/dist/components/form/date-picker/date-picker.css +0 -5
  98. package/dist/components/form/date-picker/date-picker.mjs +21 -22
  99. package/dist/components/form/file-field/file-field.d.mts +6 -3
  100. package/dist/components/form/file-field/file-field.mjs +41 -18
  101. package/dist/components/form/file-field/index.d.mts +4 -1
  102. package/dist/components/form/form/form.mjs +0 -1
  103. package/dist/components/form/form-control/form-control.css +0 -15
  104. package/dist/components/form/form-control/form-control.d.mts +3 -4
  105. package/dist/components/form/form-control/form-control.mjs +44 -46
  106. package/dist/components/form/form-control/form-control.module.mjs +0 -3
  107. package/dist/components/form/number-field/number-field.d.mts +2 -2
  108. package/dist/components/form/number-field/number-field.mjs +13 -52
  109. package/dist/components/form/password-input/password-input.mjs +1 -1
  110. package/dist/components/form/radio/radio.mjs +4 -2
  111. package/dist/components/form/radio-card/radio-card.mjs +9 -2
  112. package/dist/components/form/range-slider/range-slider.d.mts +4 -2
  113. package/dist/components/form/range-slider/range-slider.mjs +2 -4
  114. package/dist/components/form/select/select.css +6 -4
  115. package/dist/components/form/select/select.d.mts +5 -0
  116. package/dist/components/form/select/select.mjs +10 -7
  117. package/dist/components/form/slider/slider.d.mts +2 -2
  118. package/dist/components/form/slider/slider.mjs +3 -6
  119. package/dist/components/form/switch/switch.d.mts +3 -0
  120. package/dist/components/form/switch/switch.mjs +43 -31
  121. package/dist/components/form/text-field/index.d.mts +2 -2
  122. package/dist/components/form/text-field/text-field.css +4 -0
  123. package/dist/components/form/text-field/text-field.d.mts +1 -1
  124. package/dist/components/form/textarea/textarea.d.mts +0 -1
  125. package/dist/components/form/textarea/textarea.mjs +1 -1
  126. package/dist/components/icons/base.d.mts +0 -1
  127. package/dist/components/icons/base.mjs +1 -2
  128. package/dist/components/icons/clipboard-check.d.mts +3 -0
  129. package/dist/components/icons/clipboard-check.mjs +18 -0
  130. package/dist/components/icons/git-pull-request.d.mts +3 -0
  131. package/dist/components/icons/git-pull-request.mjs +20 -0
  132. package/dist/components/icons/index.d.mts +9 -7
  133. package/dist/components/icons/index.mjs +30 -28
  134. package/dist/components/index.d.mts +58 -66
  135. package/dist/components/index.mjs +13 -19
  136. package/dist/components/layout/resizable-panels/resizable-panels.mjs +3 -3
  137. package/dist/components/navigation/anchor/anchor.css +3 -3
  138. package/dist/components/navigation/anchor/anchor.mjs +20 -7
  139. package/dist/components/navigation/anchor/anchor.module.mjs +1 -1
  140. package/dist/components/navigation/breadcrumb/breadcrumb.d.mts +6 -4
  141. package/dist/components/navigation/breadcrumb/breadcrumb.mjs +3 -2
  142. package/dist/components/navigation/pagination/pagination.d.mts +2 -2
  143. package/dist/components/navigation/pagination/pagination.mjs +2 -2
  144. package/dist/components/navigation/side-nav/side-nav.mjs +1 -1
  145. package/dist/components/navigation/stepper/stepper.mjs +3 -3
  146. package/dist/components/navigation/tabs/index.d.mts +10 -5
  147. package/dist/components/navigation/tabs/tabs.d.mts +11 -6
  148. package/dist/components/navigation/tabs/tabs.mjs +24 -27
  149. package/dist/components/overlays/_internal/modal-header.css +38 -0
  150. package/dist/components/overlays/_internal/modal-header.d.mts +7 -0
  151. package/dist/components/overlays/_internal/modal-header.mjs +32 -0
  152. package/dist/components/overlays/_internal/modal-header.module.mjs +10 -0
  153. package/dist/components/overlays/command-palette/command-palette.d.mts +2 -2
  154. package/dist/components/overlays/command-palette/command-palette.mjs +9 -8
  155. package/dist/components/overlays/context-menu/context-menu.mjs +3 -3
  156. package/dist/components/overlays/context-menu/index.d.mts +27 -2
  157. package/dist/components/overlays/dialog/dialog.css +3 -21
  158. package/dist/components/overlays/dialog/dialog.d.mts +20 -9
  159. package/dist/components/overlays/dialog/dialog.mjs +35 -73
  160. package/dist/components/overlays/dialog/dialog.module.mjs +1 -3
  161. package/dist/components/overlays/dialog/index.d.mts +2 -15
  162. package/dist/components/overlays/dialog/index.mjs +1 -8
  163. package/dist/components/overlays/drawer/drawer.css +4 -26
  164. package/dist/components/overlays/drawer/drawer.d.mts +7 -2
  165. package/dist/components/overlays/drawer/drawer.mjs +24 -37
  166. package/dist/components/overlays/drawer/drawer.module.mjs +2 -6
  167. package/dist/components/overlays/dropdown-menu/dropdown-menu.d.mts +35 -5
  168. package/dist/components/overlays/dropdown-menu/dropdown-menu.mjs +29 -11
  169. package/dist/components/overlays/dropdown-menu/hooks.d.mts +1 -1
  170. package/dist/components/overlays/dropdown-menu/hooks.mjs +1 -1
  171. package/dist/components/overlays/dropdown-menu/index.d.mts +34 -4
  172. package/dist/components/overlays/dropdown-menu/shared.css +1 -0
  173. package/dist/components/overlays/dropdown-menu/sub-menu.mjs +4 -4
  174. package/dist/components/overlays/list-box/hooks.mjs +2 -2
  175. package/dist/components/overlays/list-box/index.d.mts +2 -25
  176. package/dist/components/overlays/list-box/index.mjs +1 -9
  177. package/dist/components/overlays/list-box/list-box.d.mts +11 -16
  178. package/dist/components/overlays/list-box/list-box.mjs +23 -16
  179. package/dist/components/overlays/modal/modal.d.mts +8 -7
  180. package/dist/components/overlays/modal/modal.mjs +23 -32
  181. package/dist/components/overlays/popover/anchor-positioning.d.mts +3 -16
  182. package/dist/components/overlays/popover/anchor-positioning.mjs +14 -6
  183. package/dist/components/overlays/popover/hooks.d.mts +0 -2
  184. package/dist/components/overlays/popover/hooks.mjs +0 -2
  185. package/dist/components/overlays/popover/index.d.mts +19 -2
  186. package/dist/components/overlays/popover/index.mjs +7 -2
  187. package/dist/components/overlays/popover/popover.css +6 -0
  188. package/dist/components/overlays/popover/popover.d.mts +15 -2
  189. package/dist/components/overlays/popover/popover.mjs +28 -13
  190. package/dist/components/overlays/popover/popover.module.mjs +2 -1
  191. package/dist/components/overlays/tooltip/bridge.css +1 -1
  192. package/dist/components/overlays/tooltip/tooltip.mjs +5 -5
  193. package/dist/helpers/index.mjs +1 -1
  194. package/dist/i18n/en.mjs +1 -2
  195. package/dist/i18n/index.d.mts +3 -4
  196. package/dist/i18n/index.mjs +1 -2
  197. package/dist/i18n/ja.mjs +1 -2
  198. package/dist/i18n/messages.d.mts +2 -4
  199. package/dist/i18n/usage.d.mts +2 -1
  200. package/dist/i18n/usage.mjs +3 -3
  201. package/dist/index.d.mts +30 -36
  202. package/dist/index.mjs +4 -10
  203. package/dist/internal/iso-date.mjs +1 -1
  204. package/dist/styles/index.css +79 -225
  205. package/dist/styles/tailwind.css +1 -1
  206. package/dist/styles/tokens.css +281 -0
  207. package/dist/styles/tokens.d.mts +1 -1
  208. package/dist/styles/tokens.mjs +1 -1
  209. package/dist/types/index.d.mts +2 -2
  210. package/dist/types/variables.d.mts +4 -2
  211. package/docs/GUIDE.md +141 -66
  212. package/docs/llms.txt +38 -11
  213. package/docs/props.generated.json +752 -481
  214. package/docs/references/ai-chat.md +87 -39
  215. package/docs/references/color.md +15 -15
  216. package/docs/references/components.md +568 -499
  217. package/docs/references/generative-ui.md +373 -185
  218. package/docs/references/interaction-design.md +6 -5
  219. package/docs/references/spatial-design.md +8 -8
  220. package/docs/references/types.md +22 -25
  221. package/package.json +37 -70
  222. package/dist/components/form/date-field/date-field.css +0 -31
  223. package/dist/components/form/date-field/date-field.d.mts +0 -7
  224. package/dist/components/form/date-field/date-field.mjs +0 -19
  225. package/dist/components/form/date-field/date-field.module.mjs +0 -4
  226. package/dist/components/form/date-field/index.d.mts +0 -2
  227. package/dist/components/form/date-field/index.mjs +0 -1
  228. package/dist/components/observers/in-view/index.d.mts +0 -2
  229. package/dist/components/observers/in-view/index.mjs +0 -1
  230. package/dist/components/observers/resize/index.d.mts +0 -2
  231. package/dist/components/observers/resize/index.mjs +0 -1
  232. package/dist/components/overlays/_internal/modal-dialog-context.d.mts +0 -11
  233. package/dist/components/overlays/_internal/modal-dialog-context.mjs +0 -12
  234. package/dist/components/providers/index.d.mts +0 -3
  235. package/dist/components/providers/index.mjs +0 -3
  236. package/dist/components/providers/portal-root.d.mts +0 -8
  237. package/dist/components/providers/portal-root.mjs +0 -11
  238. package/dist/components/providers/ui-provider.d.mts +0 -2
  239. package/dist/components/providers/ui-provider.mjs +0 -6
  240. package/dist/integrations/_shared/icon-map.mjs +0 -208
  241. package/dist/integrations/_shared/icon-names.d.mts +0 -1
  242. package/dist/integrations/_shared/openui-defs.d.mts +0 -15
  243. package/dist/integrations/_shared/openui-defs.mjs +0 -230
  244. package/dist/integrations/_shared/renderers.css +0 -50
  245. package/dist/integrations/_shared/renderers.d.mts +0 -88
  246. package/dist/integrations/_shared/renderers.mjs +0 -880
  247. package/dist/integrations/_shared/renderers.module.mjs +0 -13
  248. package/dist/integrations/ai-sdk/index.d.mts +0 -3
  249. package/dist/integrations/ai-sdk/index.mjs +0 -1
  250. package/dist/integrations/ai-sdk/map-parts.d.mts +0 -44
  251. package/dist/integrations/ai-sdk/map-parts.mjs +0 -56
  252. package/dist/integrations/json-render/catalog.d.mts +0 -1359
  253. package/dist/integrations/json-render/catalog.mjs +0 -373
  254. package/dist/integrations/json-render/registry.d.mts +0 -26
  255. package/dist/integrations/json-render/registry.mjs +0 -192
  256. package/dist/integrations/openui/form-views.d.mts +0 -24
  257. package/dist/integrations/openui/form-views.mjs +0 -89
  258. package/dist/integrations/openui/library.d.mts +0 -202
  259. package/dist/integrations/openui/library.mjs +0 -83
  260. package/dist/integrations/openui/prompt.d.mts +0 -2
  261. package/dist/integrations/openui/prompt.mjs +0 -18
  262. /package/dist/components/{observers → _internal}/fragment-instance.d.mts +0 -0
  263. /package/dist/components/{observers/in-view → _internal}/in-view.d.mts +0 -0
  264. /package/dist/components/{observers/resize → _internal}/resize.d.mts +0 -0
@@ -1,55 +1,380 @@
1
- # Generative UI (json-render / OpenUI)
1
+ # Generative UI (the catalog)
2
2
 
3
- `@k8ordo/ui` ships official adapters that let an LLM generate UI out of
4
- `@k8ordo/ui` components only. The generated UI is pinned to the design tokens,
5
- so it cannot drift off-brand. Two frameworks are supported:
6
- [json-render](https://json-render.dev) and [OpenUI](https://www.openui.com).
3
+ `@k8ordo/ui` describes its own components for an LLM, for no generative-UI
4
+ format in particular: what each component is, the props a model may write,
5
+ whether it holds children, and which prop holds a field's value. The props are
6
+ pinned to the design tokens, so a UI a model composes from them cannot drift
7
+ off-brand.
7
8
 
8
- Both are optional peer dependencies — install only the one you use.
9
+ The library ties itself to no format. json-render, OpenUI, A2UI, or your own
10
+ format each needs a small piece of glue that maps over the catalog — see
11
+ [Connecting a format](#connecting-a-format). `zod` is the only peer the catalog
12
+ needs:
9
13
 
10
14
  ```bash
11
- # json-render
12
- pnpm add @json-render/core @json-render/react zod
13
- # OpenUI — both entries import lang-core directly, so install both packages
14
- pnpm add @openuidev/react-lang @openuidev/lang-core zod
15
+ pnpm add zod
15
16
  ```
16
17
 
17
- `@openuidev/lang-core` is not optional for OpenUI: `@k8ordo/ui/openui` builds its
18
- component library with it and `@k8ordo/ui/openui/prompt` is the React-free entry
19
- on top of it. `@openuidev/react-lang` depends on it as well, but pnpm will not
20
- let your app resolve a dependency of a dependency — declare it yourself.
21
-
22
- json-render is 0.x, where a minor bump is a breaking release, so `@k8ordo/ui`
23
- declares a range that stops at the next minor; OpenUI is 1.x, and the range
24
- stops at the next major. The peer table in the package's README
25
- (`node_modules/@k8ordo/ui/README.md` when installed via npm) lists the current
26
- range for each package. Pick a version inside it.
27
-
28
- Within that range, resolve exactly **one copy** of each framework. The adapters
29
- read the framework's own React context — `useStateField` for OpenUI,
30
- `useBoundProp` for json-render — so if your app and `@k8ordo/ui` end up on two
31
- different copies, the context objects are different objects: every schema check,
32
- the types, and the build all pass, and the form views throw
33
- `useOpenUI must be used within a <Renderer /> component.` at render time. With
34
- pnpm this happens as soon as your version differs from the one `@k8ordo/ui`
35
- resolves, even when both satisfy the range.
18
+ ## The two entries
19
+
20
+ - `@k8ordo/ui/catalog` is **server-safe**: it imports no React, so a Server
21
+ Component or an API route can build the system prompt from it.
22
+ - `@k8ordo/ui/catalog/render` is `'use client'`: how each component is drawn.
23
+
24
+ ```ts
25
+ import { catalog, catalogRules, catalogPropIssues } from '@k8ordo/ui/catalog';
26
+ ```
27
+
28
+ ```tsx
29
+ 'use client';
30
+ import { renderers } from '@k8ordo/ui/catalog/render';
31
+ ```
32
+
33
+ ## What an entry says
34
+
35
+ `catalog` maps each component's name to an entry:
36
+
37
+ - `description`: what the component is, for the model.
38
+ - `props`: a zod object of the props the model writes.
39
+ - `children: true`: the component lays out children of its own (`Stack`,
40
+ `Card`, `Dialog`, …). Absent for every other component.
41
+ - `value`: present on a field. `value.prop` is the prop that carries the value
42
+ the field starts from (`defaultValue`, `defaultChecked`, or `defaultPage`), and
43
+ `value.initial(props)` is what it starts from when nothing is bound to it.
44
+ - `events`: present on a component the user acts on in a way the application
45
+ should hear about. It maps each event's name to a description for the model.
46
+ `Button`, `IconButton`, `Card`, and `DropdownMenuItem` have one, `press`.
47
+
48
+ ```ts
49
+ catalog.TextField;
50
+ // {
51
+ // description: 'Single-line text input. type picks the kind of value: …',
52
+ // props: z.object({ name, label, placeholder, … }),
53
+ // value: { prop: 'defaultValue', initial: (props) => props.defaultValue ?? '' },
54
+ // }
55
+ ```
56
+
57
+ The types follow the table: `CatalogName` is the union of the names,
58
+ `CatalogProps<'Button'>` the props of one component, `CatalogValueOf<'Slider'>`
59
+ the value of one field (`never` for a component that is not a field), and
60
+ `CatalogEventOf<'Card'>` the events of one component (`never` for none).
61
+
62
+ The key order of every `props` schema is part of the contract. A format with
63
+ positional arguments (OpenUI Lang) maps the arguments back to props by that
64
+ order, so an optional key is only ever appended. A new required key breaks every
65
+ saved string of its entry anyway, so it goes where it reads best: a field's
66
+ `label` comes right after its `name`.
67
+
68
+ Some entries' `props` also check props against each other (see
69
+ [Checking what a model wrote](#checking-what-a-model-wrote)). zod keeps such a
70
+ check only on the schema it was written on: `.omit()`, `.pick()`, and
71
+ `.partial()` throw on these entries, and `.extend()` throws when it replaces a
72
+ key, so a glue that derives a schema from one uses `.safeExtend()`. The checks
73
+ do not reach JSON Schema either (`z.toJSONSchema` leaves them out): only a zod
74
+ parse, or `catalogPropIssues`, applies them.
75
+
76
+ ## Drawing
77
+
78
+ `renderers` has the same names as `catalog`. Call one with props that fit the
79
+ entry's schema (see below) and the children the format drew — one node per
80
+ child, keyed; `Children.toArray` keys them. A component without children takes
81
+ none. A field also takes its value and a setter, so the format decides
82
+ where the value lives: in its own state, or in the component's. A component
83
+ with events takes `on`, the handler of each event the model bound. Leave an
84
+ event out of `on` when the model bound nothing to it: an unbound `Card` is not
85
+ pressable, and an unbound button presses to no effect. A handler may return a
86
+ promise; the button or card is busy until it settles.
87
+
88
+ ```tsx
89
+ 'use client';
90
+ import { renderers } from '@k8ordo/ui/catalog/render';
91
+
92
+ renderers.Button({
93
+ props: { label: 'Save' },
94
+ on: { press: () => sendToAgent('save') },
95
+ });
96
+ renderers.TextField({
97
+ props: { name: 'title', label: 'Title' },
98
+ value,
99
+ setValue,
100
+ });
101
+ ```
102
+
103
+ The props a renderer takes are values that fit the entry's `props` schema, with
104
+ no `null`: a prop the model left out is absent or `undefined`. A renderer does
105
+ not tidy up what a format wrote; the glue does, before it calls one. It drops
106
+ every `null` key, nested ones included (OpenUI Lang, for one, writes an omitted
107
+ positional argument as `null`), parses the rest with the entry's `props`
108
+ schema, and hands the renderer what the parse returns. A format's own
109
+ validation is not enough: JSON Schema leaves zod's own checks out, and OpenUI
110
+ does not check `pattern`. An element whose props do not parse is drawn as
111
+ nothing; while a spec streams in, it appears once they do. That includes an
112
+ element with an unknown key inside an object nested in its props (a `Table`
113
+ column, an `Accordion` item, an option): the schema refuses the key. An
114
+ unknown prop at the top of the props is dropped instead, and the element is
115
+ drawn without it. A field's value bound to the format's state is left out of
116
+ the parse, since the user, not the model, wrote it.
117
+
118
+ `Form` submits nothing, not even on Enter in a field: a submission is the press
119
+ of a `Button` inside it. A `Button` or `Card` with `href` is a link and reports
120
+ no press.
121
+
122
+ Draw the generated UI inside your application's `ToastProvider`, the one its own
123
+ `useToast` reads. A `Toast` opens its toast there, in the same region, under the
124
+ same limit, as the application's own. Outside one, drawing a `Toast` fails with
125
+ `useToast`'s error.
126
+
127
+ ## Connecting a format
128
+
129
+ The glue for a format does three things, each by mapping over `catalog`:
130
+
131
+ 1. **Register** every component with the format, by name, with its
132
+ `description` and its `props` schema. A component with `children: true`
133
+ gets the format's way of holding children — json-render's `slots`, a
134
+ `children` prop in OpenUI.
135
+ 2. **Bind** each field: read the format's state at `value.prop` (json-render's
136
+ `$bindState`, OpenUI's form state by `name`, A2UI's `{"@path": ...}` into
137
+ the data model), starting from `value.initial(props)` when nothing is bound.
138
+ Bind each of `events` to the format's own action — A2UI's `action` prop,
139
+ json-render's `on`, an OpenUI action prop — and hand the bound ones to the
140
+ renderer as `on`. What an action does then (report to the agent, or change
141
+ the format's own state) is the format's.
142
+ 3. **Draw** each component through `renderers`: drop the `null` keys, parse
143
+ the rest with the entry's `props` schema, and hand the renderer what the
144
+ parse returns. Draw nothing for an element that fails (see
145
+ [Drawing](#drawing)).
146
+
147
+ Since no step names a component, a component added to `@k8ordo/ui` reaches
148
+ every format without a change to the glue, and a new format is one new piece of
149
+ glue.
150
+
151
+ The glue knows a component's name only at run time, where each entry's own
152
+ types are of no use. `@k8ordo/ui/catalog` and `@k8ordo/ui/catalog/render`
153
+ each export a view with those types erased, so the glue needs no cast: every
154
+ entry of `catalog` is assignable to `AnyCatalogEntry`, whose `value.initial`
155
+ takes any props, and `rendererOf(name)` returns the renderer as an
156
+ `AnyRenderer`, which takes `AnyRenderArgs` — the parsed props as
157
+ `Record<string, unknown>`, and a field's value and setter as `unknown`. A name
158
+ the format hands over as a string becomes a `CatalogName` through
159
+ `isCatalogName(name)`, and `catalogNames` lists every entry's name, so building
160
+ a format's registry needs no cast either.
161
+
162
+ ```tsx
163
+ 'use client';
164
+ import { catalog } from '@k8ordo/ui/catalog';
165
+ import type { AnyCatalogEntry, CatalogName } from '@k8ordo/ui/catalog';
166
+ import { rendererOf } from '@k8ordo/ui/catalog/render';
167
+ import type { AnyRenderArgs } from '@k8ordo/ui/catalog/render';
168
+
169
+ // args.props: what the format resolved, its null keys dropped
170
+ const draw = (name: CatalogName, args: AnyRenderArgs) => {
171
+ const entry: AnyCatalogEntry = catalog[name];
172
+ const parsed = entry.props.safeParse(args.props);
173
+ if (!parsed.success) return null;
174
+ return rendererOf(name)({
175
+ ...args,
176
+ props: parsed.data,
177
+ value: args.value ?? entry.value?.initial(parsed.data),
178
+ });
179
+ };
180
+ ```
181
+
182
+ The repository keeps working glue for A2UI 1.0, json-render, OpenUI, and the AI SDK in
183
+ [`examples/ui-integrations`](https://github.com/k35o/k8ordo/tree/main/examples/ui-integrations),
184
+ run in a real browser on every change. Copy the one you use into your
185
+ application and own it: the glue depends on the format's own release cycle, not
186
+ on `@k8ordo/ui`'s.
187
+
188
+ json-render, for example, is registered like this (the full glue adds the
189
+ system prompt, validation, and a ready-wired `<JsonRenderUI spec={spec} />`):
190
+
191
+ ```ts
192
+ import { defineCatalog } from '@json-render/core';
193
+ import { schema } from '@json-render/react/schema';
194
+ import { catalog as k8ordo } from '@k8ordo/ui/catalog';
195
+
196
+ export const catalog = defineCatalog(schema, {
197
+ components: Object.fromEntries(
198
+ Object.entries(k8ordo).map(([name, entry]) => [
199
+ name,
200
+ {
201
+ props: entry.props,
202
+ description:
203
+ entry.value === undefined
204
+ ? entry.description
205
+ : `${entry.description} ${entry.value.prop} can be bound to state with $bindState.`,
206
+ ...(entry.children === true ? { slots: ['default'] } : {}),
207
+ },
208
+ ]),
209
+ ),
210
+ actions: {},
211
+ });
212
+ ```
213
+
214
+ ## Checking what a model wrote
215
+
216
+ `catalogPropIssues(type, props)` checks one component the model wrote and
217
+ returns what is wrong with it, in English, ready to send back to the model. An
218
+ empty array means the component exists and its props are valid.
219
+
220
+ ```ts
221
+ catalogPropIssues('Anchor', {
222
+ label: 'Docs',
223
+ href: 'ftp://example.com',
224
+ rel: 'x',
225
+ });
226
+ // [
227
+ // 'Anchor.href: …',
228
+ // 'Anchor: Unknown prop "rel". Allowed props: label, href, …',
229
+ // ]
230
+ ```
231
+
232
+ Unknown props are reported too. zod drops a key the schema does not know rather
233
+ than failing, so a prop the model invented would otherwise pass and render as if
234
+ it were not there. An object nested in the props — a `Table` column, an
235
+ `Accordion` item, an option — refuses a key it does not know, and the issue
236
+ names the path of that object:
237
+
238
+ ```ts
239
+ catalogPropIssues('Table', {
240
+ columns: [{ label: 'Name' }, { label: 'Qty', width: 80 }],
241
+ rows: [['Apple', '3']],
242
+ });
243
+ // ['Table.columns.1: Unknown prop "width". Allowed props: label, align.']
244
+ ```
245
+
246
+ Run it on every element of a spec, after the format's own structural check,
247
+ and send the issues back as a repair prompt.
248
+
249
+ Props are also checked against each other, each issue under the path it is at
250
+ and in the same round as the other issues of the component, as long as the
251
+ props the check reads are valid themselves. Every row of a `Table` or
252
+ `DataTable` must have as many cells as there are columns. A `TextField` whose
253
+ `type` is a date or time kind takes a `defaultValue` in the input format of
254
+ that kind, as `DatePicker` does: a real calendar day as `YYYY-MM-DD` for
255
+ `date`, `HH:MM` or `HH:MM:SS` for `time`, `YYYY-MM-DDTHH:MM` with optional
256
+ seconds for `datetime-local`, `YYYY-MM` for `month`, and `YYYY-Www` for
257
+ `week`. The `defaultValue` of `Select`, `Radio`,
258
+ `RadioCard`, `ListBox`, `CheckboxGroup`, and `CheckboxCard` must be the `value`
259
+ of one of its `options` (each entry of it, for the two that take an array):
260
+
261
+ ```ts
262
+ catalogPropIssues('Table', {
263
+ caption: 3,
264
+ columns: [{ label: 'Name' }, { label: 'Qty' }],
265
+ rows: [['Apple', '3'], ['Orange']],
266
+ });
267
+ // [
268
+ // 'Table.caption: Invalid input: expected string, received number',
269
+ // 'Table.rows.1: Expected 2 cells (one per column), received 1',
270
+ // ]
271
+
272
+ catalogPropIssues('CheckboxGroup', {
273
+ name: 'tags',
274
+ label: 'Tags',
275
+ options: [
276
+ { value: 'news', label: 'News' },
277
+ { value: 'blog', label: 'Blog' },
278
+ ],
279
+ defaultValue: ['news', 'Blog'],
280
+ });
281
+ // ['CheckboxGroup.defaultValue.1: Expected the value of an option ("news" | "blog"), received "Blog"']
282
+ ```
283
+
284
+ A prop the format resolves later, such as one a json-render spec binds with
285
+ `{ "$bindState": "/form/name" }`, cannot be checked as a value yet. Name it in
286
+ `unresolved`: its name is still checked, its value is not, and a required one
287
+ is not reported missing. A check across props that needs it is not made.
288
+
289
+ ```ts
290
+ catalogPropIssues(
291
+ 'TextField',
292
+ {
293
+ name: 'nickname',
294
+ label: 'Nickname',
295
+ defaultValue: { $bindState: '/form/nickname' },
296
+ },
297
+ { unresolved: ['defaultValue'] },
298
+ );
299
+ // []
300
+ ```
301
+
302
+ ## Prompt language
303
+
304
+ Everything the catalog hands the model — the descriptions, the schemas'
305
+ descriptions, `catalogRules`, and the issues `catalogPropIssues` returns — is
306
+ English, whatever your application's locale. The model reads it; your users
307
+ never see it.
308
+
309
+ `catalogRules` holds the cross-cutting constraints a model most often breaks
310
+ (a `Table` row with as many cells as there are columns, the `href` format, plain
311
+ text inside `Tabs` and `Accordion`). Pass it to the format's system prompt, and
312
+ add a rule of your own to pin the language of the text the model writes into the
313
+ UI:
314
+
315
+ ```ts
316
+ // json-render
317
+ catalog.prompt({
318
+ customRules: [...catalogRules, 'Write all UI text in Japanese.'],
319
+ });
320
+ // OpenUI
321
+ prompt({
322
+ additionalRules: [...catalogRules, 'Write all UI text in Japanese.'],
323
+ });
324
+ ```
36
325
 
37
326
  ## What the catalog covers
38
327
 
39
- Both adapters register the same components, and the prompts they generate list
40
- them. Most are the exported component of the same name. A few are shaped for a
328
+ The entries, under the category of the component each one draws. An entry that
329
+ is no exported component of its own is under Catalog only.
330
+
331
+ <!-- generated:catalog-entries -->
332
+
333
+ - **Buttons**: `Button`, `IconButton`, `CopyButton`, `Toolbar`
334
+ - **Navigation**: `Anchor`, `Breadcrumb`, `Pagination`, `Stepper`, `SideNav`,
335
+ `Tabs`
336
+ - **Forms**: `Form`, `TextField`, `Textarea`, `PasswordInput`, `NumberField`,
337
+ `Slider`, `RangeSlider`, `DatePicker`, `Calendar`, `ColorPicker`, `Combobox`,
338
+ `Checkbox`, `Switch`, `Select`, `Radio`, `RadioCard`, `CheckboxCard`,
339
+ `CheckboxGroup`, `Autocomplete`, `FileField`
340
+ - **Data display**: `Card`, `Carousel`, `Badge`, `Heading`, `Avatar`, `Code`,
341
+ `Kbd`, `Accordion`, `Table`, `DataTable`, `Tree`
342
+ - **Feedback**: `EmptyState`, `Alert`, `Callout`, `Spinner`, `Progress`,
343
+ `Skeleton`
344
+ - **Overlays**: `Dialog`, `Drawer`, `Popover`, `Tooltip`, `DropdownMenu`,
345
+ `ListBox`
346
+ - **Layout**: `Stack`, `Grid`, `Separator`
347
+ - **Catalog only**: `Icon`, `DropdownMenuItem`, `Toast`
348
+
349
+ <!-- /generated:catalog-entries -->
350
+
351
+ Most entries are the exported component of the same name. A few are shaped for a
41
352
  model instead:
42
353
 
43
354
  - **Icons** are one `Icon` entry whose `name` picks the glyph. Every icon in
44
355
  `@k8ordo/ui/icons` that needs nothing but a size is there, under its name in
45
356
  kebab-case without the suffix: `eye-closed` is `EyeClosedIcon`. `ChevronIcon`
46
- has an entry of its own, and `AlertIcon` is the `StatusIcon` entry.
47
- - **Toasts** are a `Toast` entry, standing in for `ToastProvider` and
48
- `useToast`: a self-contained widget whose `triggerLabel` button shows the
49
- toast.
50
- - **Overlays** (`Modal`, `Dialog`, `Drawer`, `Popover`, `Tooltip`,
51
- `DropdownMenu`) are self-contained widgets too. Each declares its own trigger
52
- with `triggerLabel` and handles opening and closing itself.
357
+ and `AlertIcon` are not there by name: each draws one of the icons above,
358
+ picked by `direction` or `status`, so a spec names that icon instead
359
+ (`chevron-down`, `circle-check`).
360
+ - **Fields** each take a required `label` and an optional `helpText`, and are
361
+ drawn through `FormControl`'s `renderInput`. The label is a `<label for>`
362
+ tied to the input, or, for a group (`Radio`, `RadioCard`, `CheckboxGroup`,
363
+ `CheckboxCard`, `RangeSlider`, `FileField`), the heading the group is named
364
+ by (`labelAs="group"`). The help text sits under the field and describes it.
365
+ `Checkbox` and `Switch` are not wrapped in `FormControl`: their `label` is
366
+ their own, and they draw `helpText` themselves. `ListBox` is a button that
367
+ opens a list, and its required `label` names the button.
368
+ - **Toasts** are a `Toast` entry, standing in for `useToast`: a widget whose
369
+ `triggerLabel` button opens the toast through your application's
370
+ `ToastProvider` (see [Drawing](#drawing)).
371
+ - **Overlays** (`Dialog`, `Drawer`, `Popover`, `Tooltip`, `DropdownMenu`) are
372
+ self-contained widgets. Each declares its own trigger with `triggerLabel` and
373
+ handles opening and closing itself. `Dialog` opens in the center or along the
374
+ bottom edge and `Drawer` along the left or right one, each by its `side`, as
375
+ the components do. The items of a `DropdownMenu` are its children, each a
376
+ `DropdownMenuItem` with its own `press`, so the menu needs no event of its
377
+ own to say which item was chosen.
53
378
  - **Compound components** (`Tabs`, `Accordion`, `Table`, `Breadcrumb`, …) are
54
379
  one entry each, with their parts flattened into data such as
55
380
  `tabs: [{ label, content }]`. `Carousel` is one container entry whose
@@ -67,12 +392,6 @@ These exports are left out on purpose, so a model cannot place them:
67
392
  - `ContextMenu` — it opens on a right-click, which nothing on screen invites,
68
393
  so actions put in it would be hidden in a generated UI. It belongs on your
69
394
  application's own content (a file, a row).
70
- - `InView`, `Resize` — they report to a callback and draw nothing of their own,
71
- and a spec has no code to receive the report.
72
- - `UIProvider` — your application mounts it once, around the generated UI as
73
- well.
74
- - `PortalRootProvider`, `usePortalRoot` — wiring for your own `createPortal`
75
- calls. The generated overlays open their own surfaces.
76
395
  - `Conversation`, `Message`, `PromptInput`, `Reasoning`, `Suggestion`,
77
396
  `ToolInvocation`, `Attachment`, and `Source` from `@k8ordo/ui/ai`, and
78
397
  `Response` from
@@ -95,151 +414,20 @@ These exports are left out on purpose, so a model cannot place them:
95
414
  lay a flow out with `Stack`.
96
415
  - `BaseIcon` — the base your own icons are drawn on. It has no glyph of its
97
416
  own, and a spec picks a glyph by `name`.
417
+ - `FormControl` — every field in the catalog takes its own `label` and
418
+ `helpText` and is drawn through `FormControl` already (see
419
+ [What the catalog covers](#what-the-catalog-covers)). An entry for the frame
420
+ alone would be a second way to write the same field.
98
421
  - `TableOfContents` — it points at the ids of the document's headings and
99
422
  follows the scroll. The headings a spec places carry no id, so there would be
100
423
  nothing to point at.
101
424
 
102
- ## Prompt language
103
-
104
- Everything the adapters hand the model — component descriptions, `uiRules`,
105
- schema descriptions, and the repair prompt — is English, whatever your
106
- application's locale. The model reads it; your users never see it. To pin the
107
- language of the text the model writes into the UI, add a rule of your own:
108
-
109
- ```tsx
110
- // json-render
111
- catalog.prompt({ customRules: [...uiRules, 'Write all UI text in Japanese.'] });
112
- // OpenUI
113
- prompt({ additionalRules: ['Write all UI text in Japanese.'] });
114
- ```
115
-
116
- ## json-render
117
-
118
- The catalog (schemas and prompt) is separate from the registry (rendering), and
119
- the catalog is **server-safe**.
120
-
121
- ### 1. Generate the prompt on the server
122
-
123
- ```tsx
124
- import { catalog, uiRules } from '@k8ordo/ui/json-render';
125
-
126
- // customRules injects the cross-cutting constraints an LLM most often breaks
127
- // (cell count matching columns in Table, href format, text-only content in
128
- // Tabs and Accordion).
129
- const systemPrompt = catalog.prompt({ customRules: [...uiRules] });
130
- ```
131
-
132
- ### 2. Render on the client
133
-
134
- `JsonRenderUI` already wires up `JSONUIProvider` + `Renderer` + registry
135
- internally, so passing the spec is enough. Pass `onStateChange` when you need to
136
- collect form values.
137
-
138
- ```tsx
139
- 'use client';
140
- import type { UISpec } from '@k8ordo/ui/json-render';
141
- import { JsonRenderUI } from '@k8ordo/ui/json-render/registry';
142
-
143
- export function GenUi({ spec }: { spec: UISpec }) {
144
- return <JsonRenderUI spec={spec} />;
145
- }
146
- ```
147
-
148
- Props:
149
-
150
- - `spec`: `Spec | null` (required; a `UISpec` is assignable to json-render's `Spec` without a cast, and `null` renders nothing)
151
- - `loading`: boolean (passed to `Renderer`: set it while the spec is still streaming in, so children that have not arrived yet are skipped without a warning)
152
- - `onStateChange`: `(changes: Array<{ path: string; value: unknown }>) => void` (called once per state update with every changed path and its new value)
153
-
154
- For an advanced setup (your own `navigate`, `handlers`, or
155
- `validationFunctions`), pass the low-level `registry` straight to
156
- `@json-render/react`'s `JSONUIProvider` / `Renderer`.
157
-
158
- ### 3. Validate LLM output, then render or repair it
159
-
160
- `validateGeneratedSpec` applies mechanical fixes, validates the structure, then
161
- validates props per component. On failure it returns the `issues` it found (each
162
- a `message`, plus the `elementKey` of the offending element when there is one)
163
- and a repair prompt built from them that you can send straight back to the LLM.
164
- Use it instead of `catalog.validate()`, which rejects valid specs in the current
165
- upstream version. The result and issue types are exported as
166
- `ValidateGeneratedSpecResult` and `GeneratedSpecIssue`.
167
-
168
- ```tsx
169
- import { validateGeneratedSpec } from '@k8ordo/ui/json-render';
170
-
171
- const result = validateGeneratedSpec(JSON.parse(llmOutput));
172
- if (result.ok) {
173
- // result.fixes lists what was auto-corrected
174
- return <JsonRenderUI spec={result.spec} />;
175
- }
176
- // If it is broken, regenerate with the repair prompt
177
- const retried = await llm(result.repairPrompt);
178
- ```
179
-
180
- ### 4. Typed specs (optional)
181
-
182
- Writing `satisfies UISpec` turns a typo in a component name or prop into a
183
- compile error, and removes the need for `as unknown as Spec`.
184
-
185
- ```tsx
186
- import type { UISpec } from '@k8ordo/ui/json-render';
187
-
188
- const spec = {
189
- root: 'root',
190
- elements: {
191
- root: { type: 'Stack', props: { direction: 'column' }, children: ['ok'] },
192
- ok: { type: 'Button', props: { label: 'OK' } },
193
- },
194
- } satisfies UISpec;
195
- ```
196
-
197
- `UISpecElement` (one element of a `UISpec`), `ComponentName`, and
198
- `ComponentProps<K>` are exported as well, so you can pull out the props type of a
199
- specific component.
200
-
201
- ## OpenUI
202
-
203
- A model where children are expressed as typed subcomponents
204
- (`z.array(Child.ref)`). Rendering is `'use client'`.
205
-
206
- ```tsx
207
- 'use client';
208
- import { library } from '@k8ordo/ui/openui';
209
- import { Renderer } from '@openuidev/react-lang';
210
-
211
- export function GenUi({ response }: { response: string }) {
212
- return <Renderer library={library} response={response} />;
213
- }
214
- ```
215
-
216
- The system prompt comes from a dedicated server-safe entry, mirroring
217
- json-render's `catalog.prompt()`.
218
-
219
- ```tsx
220
- import { prompt } from '@k8ordo/ui/openui/prompt';
221
-
222
- const systemPrompt = prompt(); // No React dependency — callable from RSC or an API route
223
- ```
224
-
225
- `prompt` takes an optional `PromptOptions` from `@openuidev/lang-core`
226
- (`preamble`, `additionalRules`, `examples`, …) and passes it straight through to
227
- the library's prompt generation.
228
-
229
- Containers nest freely in OpenUI, as they do in json-render: `Stack`, `Grid`,
230
- `Card`, `Form`, `Modal`, `Dialog`, `Drawer`, and `Popover` each list every
231
- container among their children, so a `Card` can sit inside a `Stack` and a
232
- `Stack` inside another `Stack`.
233
-
234
425
  ## Exports at a glance
235
426
 
236
- | Export | Kind | Contents |
237
- | --------------------------------- | -------------- | ------------------------------------------------------------------ |
238
- | `@k8ordo/ui/json-render` | server-safe | `catalog`, `validateGeneratedSpec`, `uiRules`, types (`UISpec`, …) |
239
- | `@k8ordo/ui/json-render/registry` | `'use client'` | `JsonRenderUI` (pre-wired), `registry` (low level) |
240
- | `@k8ordo/ui/openui` | `'use client'` | `library` (rendering) |
241
- | `@k8ordo/ui/openui/prompt` | server-safe | `prompt(options?)` (prompt generation) |
427
+ | Export | Kind | Contents |
428
+ | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
429
+ | `@k8ordo/ui/catalog` | server-safe | `catalog`, `catalogNames`, `isCatalogName`, `catalogRules`, `catalogPropIssues`, types (`CatalogName`, `CatalogProps`, `CatalogEntry`, `AnyCatalogEntry`, …) |
430
+ | `@k8ordo/ui/catalog/render` | `'use client'` | `renderers`, `rendererOf`, types (`RenderArgs`, `Renderer`, `AnyRenderArgs`, `AnyRenderer`) |
242
431
 
243
- > All of them assume you have loaded `@k8ordo/ui/styles.css` (or
244
- > `@k8ordo/ui/tailwind.css` after Tailwind, in a Tailwind CSS 4 project) and
245
- > wrapped the tree in `UIProvider`.
432
+ > The drawn components assume you have loaded `@k8ordo/ui/styles.css` (or
433
+ > `@k8ordo/ui/tailwind.css` after Tailwind, in a Tailwind CSS 4 project).
@@ -70,10 +70,11 @@ duration-150 ease-out`.
70
70
  ## Focus management
71
71
 
72
72
  - Use `:focus-visible`, not `:focus` — no ring appears on a mouse click
73
+ - A date or time `<input>` is the exception and takes the ring on `:focus` as well. Its inner parts (year, month, day) hold the focus, and WebKit then matches `:focus` on the input but never `:focus-visible`. Chromium and Firefox match `:focus-visible` on such a field whenever it has focus, a mouse click included, so `:focus` adds nothing there. `TextField` does this
73
74
  - Keep the focus ring consistent with `--shadow-ring-info`
74
75
  - Clear the default outline before applying the ring, and give it back under forced colors, where the ring (a shadow) disappears
75
- - Keep focus on a button that is waiting on its own action: show the wait with `aria-busy` and `aria-disabled` and ignore presses, rather than setting `disabled`. Chromium moves focus to `body` when the focused element becomes disabled, so the keyboard user who pressed it loses their place. `Button` and `IconButton` do this for `onAction`
76
- - For the same reason, a text field whose form's action is pending turns `readOnly`, not `disabled`, and ignores the keys that would change its value, so the user who pressed Enter in it keeps their place. `TextField`, `Textarea`, `PasswordInput`, `NumberField`, `DateField`, `DatePicker`, `ColorPicker`, `Combobox`, and `Autocomplete` do this. `readOnly` does not apply to a checkbox, radio, range, or select, yet Enter in one still submits the form through its submit button, so `Checkbox`, `Radio`, `Switch`, `Slider`, `RangeSlider`, and `Select` take `aria-disabled` instead and ignore what would change their value. A checkbox or radio cancels the click in the capture phase and stops it there: cancelled any later, React's change tracking has already recorded the toggle the browser then undoes, calls `onChange` for it, and misses the next real one. A range ignores the arrow, Home, End, and Page keys and the pointer; a select ignores those keys, Space, F4, typed characters, and the pointer
76
+ - Keep focus on a button that is waiting on its own action: show the wait with `aria-busy` and `aria-disabled` and ignore presses, rather than setting `disabled`. Chromium moves focus to `body` when the focused element becomes disabled, so the keyboard user who pressed it loses their place. `Button` and `IconButton` do this for `action`
77
+ - For the same reason, a text field whose form's action is pending turns `readOnly`, not `disabled`, and ignores the keys that would change its value, so the user who pressed Enter in it keeps their place. `TextField`, `Textarea`, `PasswordInput`, `NumberField`, `DatePicker`, `ColorPicker`, `Combobox`, and `Autocomplete` do this. `readOnly` does not apply to a checkbox, radio, range, or select, yet Enter in one still submits the form through its submit button, so `Checkbox`, `Radio`, `Switch`, `CheckboxCard`, `RadioCard`, `Slider`, `RangeSlider`, and `Select` take `aria-disabled` instead and ignore what would change their value. A checkbox or radio cancels the click in the capture phase and stops it there: cancelled any later, React's change tracking has already recorded the toggle the browser then undoes, calls `onChange` for it, and misses the next real one. A range ignores the arrow, Home, End, and Page keys and the pointer; a select ignores those keys, Space, F4, typed characters, and the pointer
77
78
 
78
79
  ```css
79
80
  .control:focus-visible {
@@ -91,9 +92,9 @@ duration-150 ease-out`.
91
92
 
92
93
  - Put the label above the input (a left-aligned label reads badly in Japanese)
93
94
  - Put the error message directly under the input, in `--color-fg-error` at `--font-size-sm`
94
- - Mark required fields with `*` after the label
95
+ - Mark a required field after its label: `FormControl`'s `required` draws the built-in `required` wording there. A single field's mark is hidden from screen readers, since the input's own `required` already says it; with `labelAs="group"` — a group, or `FileField`, whose trigger is a button — the mark is part of the name, since neither a group nor a button can be required itself
95
96
  - Validate on submit; keep real-time validation to a minimum
96
- - Use the `FormControl` component so labels and errors stay consistent
97
+ - Use the `FormControl` component so labels and errors stay consistent. `Checkbox` and `Switch` carry their own label instead, and take `errorText` / `helpText` themselves
97
98
 
98
99
  ```tsx
99
100
  import { FormControl, TextField } from '@k8ordo/ui';
@@ -112,7 +113,7 @@ import { FormControl, TextField } from '@k8ordo/ui';
112
113
 
113
114
  - Set `aria-label` / `aria-describedby` where they belong
114
115
  - Guarantee keyboard navigation (Tab, Enter, Escape, arrow keys)
115
- - Respect `prefers-reduced-motion`. Under it the stylesheet turns off the open animation of Popover and what is built on it (DropdownMenu, ListBox, Tooltip), the Toast, Modal, and Drawer animations, the Tabs indicator slide, and every view transition; `Card`'s hover scale runs only under `prefers-reduced-motion: no-preference`. Skeleton's pulse, Spinner's spin, and the Accordion chevron, Switch thumb, and Progress bar transitions keep running. Put your own motion under `@media (prefers-reduced-motion: no-preference)`
116
+ - Respect `prefers-reduced-motion`. Under it the stylesheet turns off the open animation of Popover and what is built on it (DropdownMenu, ListBox, Tooltip), the Toast, Dialog, and Drawer animations, the Tabs indicator slide, and every view transition; `Card`'s hover scale runs only under `prefers-reduced-motion: no-preference`. Skeleton's pulse, Spinner's spin, and the Accordion chevron, Switch thumb, and Progress bar transitions keep running. Put your own motion under `@media (prefers-reduced-motion: no-preference)`
116
117
  - Never signal state with color alone; pair it with an icon or text
117
118
  - The components follow `prefers-contrast: more` and stay legible under `forced-colors: active` (see [High contrast and forced colors](./color.md#high-contrast-and-forced-colors)); do the same in your own UI
118
119